diff options
| author | 2025-04-11 16:36:40 +0200 | |
|---|---|---|
| committer | 2025-04-11 15:36:40 +0100 | |
| commit | c8a780e12a8112a4d4cbe8ed72d241a382f73903 (patch) | |
| tree | b385a1d5e11a0de4a84bba01d44e2b2b75abff16 /internal/processing/account/update_test.go | |
| parent | [chore] Fix header insets (#3987) (diff) | |
| download | gotosocial-c8a780e12a8112a4d4cbe8ed72d241a382f73903.tar.xz | |
[bugfix] Fix setting bot on/off (#3986)
* [bugfix] Fix setting bot on/off
* read client messages in tests
* test fix
Diffstat (limited to 'internal/processing/account/update_test.go')
| -rw-r--r-- | internal/processing/account/update_test.go | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/internal/processing/account/update_test.go b/internal/processing/account/update_test.go index a07562544..674502b75 100644 --- a/internal/processing/account/update_test.go +++ b/internal/processing/account/update_test.go @@ -26,6 +26,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/ap" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" + "github.com/superseriousbusiness/gotosocial/internal/util" ) type AccountUpdateTestSuite struct { @@ -331,6 +332,64 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateNoteNotFields() { suite.Equal(fieldsBefore, len(dbAccount.Fields)) } +func (suite *AccountUpdateTestSuite) TestAccountUpdateBotNotBot() { + testAccount := >smodel.Account{} + *testAccount = *suite.testAccounts["local_account_1"] + ctx := context.Background() + + // Call update function to set bot = true. + apiAccount, errWithCode := suite.accountProcessor.Update( + ctx, + testAccount, + &apimodel.UpdateCredentialsRequest{ + Bot: util.Ptr(true), + }, + ) + if errWithCode != nil { + suite.FailNow(errWithCode.Error()) + } + + // Returned profile should be updated. + suite.True(apiAccount.Bot) + + // We should have an update in the client api channel. + msg, _ := suite.getClientMsg(5 * time.Second) + suite.NotNil(msg) + + // Check database model of account as well. + dbAccount, err := suite.db.GetAccountByID(ctx, testAccount.ID) + if err != nil { + suite.FailNow(err.Error()) + } + suite.True(dbAccount.ActorType.IsBot()) + + // Call update function to set bot = false. + apiAccount, errWithCode = suite.accountProcessor.Update( + ctx, + testAccount, + &apimodel.UpdateCredentialsRequest{ + Bot: util.Ptr(false), + }, + ) + if errWithCode != nil { + suite.FailNow(errWithCode.Error()) + } + + // Returned profile should be updated. + suite.False(apiAccount.Bot) + + // We should have an update in the client api channel. + msg, _ = suite.getClientMsg(5 * time.Second) + suite.NotNil(msg) + + // Check database model of account as well. + dbAccount, err = suite.db.GetAccountByID(ctx, testAccount.ID) + if err != nil { + suite.FailNow(err.Error()) + } + suite.False(dbAccount.ActorType.IsBot()) +} + func TestAccountUpdateTestSuite(t *testing.T) { suite.Run(t, new(AccountUpdateTestSuite)) } |
