From 9dc2255a8fab8ef0bc4b9f417c6131e4c468cb9c Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sat, 11 Sep 2021 13:19:06 +0200 Subject: kim is a reply guy (#208) * bun debug * bun trace logging hooks * more tests * fix up some stuffffff * drop the frontend cache until a proper fix is made * go fmt --- internal/processing/account/update_test.go | 49 ++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) (limited to 'internal/processing/account/update_test.go') diff --git a/internal/processing/account/update_test.go b/internal/processing/account/update_test.go index b18a5e42e..63370cd39 100644 --- a/internal/processing/account/update_test.go +++ b/internal/processing/account/update_test.go @@ -36,7 +36,7 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateSimple() { locked := true displayName := "new display name" - note := "" + note := "#hello here i am!" form := &apimodel.UpdateCredentialsRequest{ DisplayName: &displayName, @@ -52,7 +52,7 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateSimple() { // fields on the profile should be updated suite.True(apiAccount.Locked) suite.Equal(displayName, apiAccount.DisplayName) - suite.Empty(apiAccount.Note) + suite.Equal(`

#hello here i am!

`, apiAccount.Note) // we should have an update in the client api channel msg := <-suite.fromClientAPIChan @@ -67,7 +67,50 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateSimple() { suite.NoError(err) suite.True(dbAccount.Locked) suite.Equal(displayName, dbAccount.DisplayName) - suite.Empty(dbAccount.Note) + suite.Equal(`

#hello here i am!

`, dbAccount.Note) +} + +func (suite *AccountUpdateTestSuite) TestAccountUpdateWithMention() { + testAccount := suite.testAccounts["local_account_1"] + + locked := true + displayName := "new display name" + note := `#hello here i am! + +go check out @1happyturtle, they have a cool account! +` + noteExpected := `

#hello here i am!

go check out @1happyturtle, they have a cool account!

` + + form := &apimodel.UpdateCredentialsRequest{ + DisplayName: &displayName, + Locked: &locked, + Note: ¬e, + } + + // should get no error from the update function, and an api model account returned + apiAccount, err := suite.accountProcessor.Update(context.Background(), testAccount, form) + suite.NoError(err) + suite.NotNil(apiAccount) + + // fields on the profile should be updated + suite.True(apiAccount.Locked) + suite.Equal(displayName, apiAccount.DisplayName) + suite.Equal(noteExpected, apiAccount.Note) + + // we should have an update in the client api channel + msg := <-suite.fromClientAPIChan + suite.Equal(ap.ActivityUpdate, msg.APActivityType) + suite.Equal(ap.ObjectProfile, msg.APObjectType) + suite.NotNil(msg.OriginAccount) + suite.Equal(testAccount.ID, msg.OriginAccount.ID) + suite.Nil(msg.TargetAccount) + + // fields should be updated in the database as well + dbAccount, err := suite.db.GetAccountByID(context.Background(), testAccount.ID) + suite.NoError(err) + suite.True(dbAccount.Locked) + suite.Equal(displayName, dbAccount.DisplayName) + suite.Equal(noteExpected, dbAccount.Note) } func TestAccountUpdateTestSuite(t *testing.T) { -- cgit v1.2.3