diff options
Diffstat (limited to 'internal/processing/account/update_test.go')
-rw-r--r-- | internal/processing/account/update_test.go | 75 |
1 files changed, 56 insertions, 19 deletions
diff --git a/internal/processing/account/update_test.go b/internal/processing/account/update_test.go index 76ad3abe8..ad09ff25c 100644 --- a/internal/processing/account/update_test.go +++ b/internal/processing/account/update_test.go @@ -20,6 +20,7 @@ package account_test import ( "context" "testing" + "time" "github.com/stretchr/testify/suite" "github.com/superseriousbusiness/gotosocial/internal/ap" @@ -31,20 +32,6 @@ type AccountUpdateTestSuite struct { AccountStandardTestSuite } -func (suite *AccountStandardTestSuite) checkClientAPIChan(accountID string) { - msg := <-suite.fromClientAPIChan - - // Profile update. - suite.Equal(ap.ActivityUpdate, msg.APActivityType) - suite.Equal(ap.ObjectProfile, msg.APObjectType) - - // Correct account updated. - if msg.OriginAccount == nil { - suite.FailNow("expected msg.OriginAccount not to be nil") - } - suite.Equal(accountID, msg.OriginAccount.ID) -} - func (suite *AccountUpdateTestSuite) TestAccountUpdateSimple() { testAccount := >smodel.Account{} *testAccount = *suite.testAccounts["local_account_1"] @@ -73,7 +60,17 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateSimple() { suite.Equal(noteExpected, apiAccount.Note) // We should have an update in the client api channel. - suite.checkClientAPIChan(testAccount.ID) + msg, _ := suite.getClientMsg(5 * time.Second) + + // Profile update. + suite.Equal(ap.ActivityUpdate, msg.APActivityType) + suite.Equal(ap.ObjectProfile, msg.APObjectType) + + // Correct account updated. + if msg.Origin == nil { + suite.FailNow("expected msg.OriginAccount not to be nil") + } + suite.Equal(testAccount.ID, msg.Origin.ID) // Check database model of account as well. dbAccount, err := suite.db.GetAccountByID(ctx, testAccount.ID) @@ -113,7 +110,17 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateWithMention() { suite.Equal(noteExpected, apiAccount.Note) // We should have an update in the client api channel. - suite.checkClientAPIChan(testAccount.ID) + msg, _ := suite.getClientMsg(5 * time.Second) + + // Profile update. + suite.Equal(ap.ActivityUpdate, msg.APActivityType) + suite.Equal(ap.ObjectProfile, msg.APObjectType) + + // Correct account updated. + if msg.Origin == nil { + suite.FailNow("expected msg.OriginAccount not to be nil") + } + suite.Equal(testAccount.ID, msg.Origin.ID) // Check database model of account as well. dbAccount, err := suite.db.GetAccountByID(ctx, testAccount.ID) @@ -159,7 +166,17 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateWithMarkdownNote() { suite.Equal(noteExpected, apiAccount.Note) // We should have an update in the client api channel. - suite.checkClientAPIChan(testAccount.ID) + msg, _ := suite.getClientMsg(5 * time.Second) + + // Profile update. + suite.Equal(ap.ActivityUpdate, msg.APActivityType) + suite.Equal(ap.ObjectProfile, msg.APObjectType) + + // Correct account updated. + if msg.Origin == nil { + suite.FailNow("expected msg.OriginAccount not to be nil") + } + suite.Equal(testAccount.ID, msg.Origin.ID) // Check database model of account as well. dbAccount, err := suite.db.GetAccountByID(ctx, testAccount.ID) @@ -234,7 +251,17 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateWithFields() { suite.EqualValues(emojisExpected, apiAccount.Emojis) // We should have an update in the client api channel. - suite.checkClientAPIChan(testAccount.ID) + msg, _ := suite.getClientMsg(5 * time.Second) + + // Profile update. + suite.Equal(ap.ActivityUpdate, msg.APActivityType) + suite.Equal(ap.ObjectProfile, msg.APObjectType) + + // Correct account updated. + if msg.Origin == nil { + suite.FailNow("expected msg.OriginAccount not to be nil") + } + suite.Equal(testAccount.ID, msg.Origin.ID) // Check database model of account as well. dbAccount, err := suite.db.GetAccountByID(ctx, testAccount.ID) @@ -281,7 +308,17 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateNoteNotFields() { suite.Equal(fieldsBefore, len(apiAccount.Fields)) // We should have an update in the client api channel. - suite.checkClientAPIChan(testAccount.ID) + msg, _ := suite.getClientMsg(5 * time.Second) + + // Profile update. + suite.Equal(ap.ActivityUpdate, msg.APActivityType) + suite.Equal(ap.ObjectProfile, msg.APObjectType) + + // Correct account updated. + if msg.Origin == nil { + suite.FailNow("expected msg.OriginAccount not to be nil") + } + suite.Equal(testAccount.ID, msg.Origin.ID) // Check database model of account as well. dbAccount, err := suite.db.GetAccountByID(ctx, testAccount.ID) |