diff options
author | 2023-05-09 17:05:35 +0200 | |
---|---|---|
committer | 2023-05-09 16:05:35 +0100 | |
commit | 878ed48de34365474498365ab11e3a0feb646be3 (patch) | |
tree | beafb33aec0292badf3600aa8cdc9bac71df07d7 /internal/typeutils/internaltofrontend_test.go | |
parent | [bugfix] fix possible domain blockcache nil ptr + add debug String() func (#1... (diff) | |
download | gotosocial-878ed48de34365474498365ab11e3a0feb646be3.tar.xz |
[bugfix] Don't try to get user when serializing local instance account (#1757)
Diffstat (limited to 'internal/typeutils/internaltofrontend_test.go')
-rw-r--r-- | internal/typeutils/internaltofrontend_test.go | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/internal/typeutils/internaltofrontend_test.go b/internal/typeutils/internaltofrontend_test.go index 558d3acea..5a98303e8 100644 --- a/internal/typeutils/internaltofrontend_test.go +++ b/internal/typeutils/internaltofrontend_test.go @@ -248,6 +248,82 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendPublicPunycode() }`, string(b)) } +func (suite *InternalToFrontendTestSuite) TestLocalInstanceAccountToFrontendPublic() { + ctx := context.Background() + testAccount, err := suite.db.GetInstanceAccount(ctx, "") + if err != nil { + suite.FailNow(err.Error()) + } + + apiAccount, err := suite.typeconverter.AccountToAPIAccountPublic(ctx, testAccount) + suite.NoError(err) + suite.NotNil(apiAccount) + + b, err := json.MarshalIndent(apiAccount, "", " ") + suite.NoError(err) + + suite.Equal(`{ + "id": "01AY6P665V14JJR0AFVRT7311Y", + "username": "localhost:8080", + "acct": "localhost:8080", + "display_name": "", + "locked": false, + "discoverable": true, + "bot": false, + "created_at": "2020-05-17T13:10:59.000Z", + "note": "", + "url": "http://localhost:8080/@localhost:8080", + "avatar": "", + "avatar_static": "", + "header": "http://localhost:8080/assets/default_header.png", + "header_static": "http://localhost:8080/assets/default_header.png", + "followers_count": 0, + "following_count": 0, + "statuses_count": 0, + "last_status_at": null, + "emojis": [], + "fields": [] +}`, string(b)) +} + +func (suite *InternalToFrontendTestSuite) TestLocalInstanceAccountToFrontendBlocked() { + ctx := context.Background() + testAccount, err := suite.db.GetInstanceAccount(ctx, "") + if err != nil { + suite.FailNow(err.Error()) + } + + apiAccount, err := suite.typeconverter.AccountToAPIAccountBlocked(ctx, testAccount) + suite.NoError(err) + suite.NotNil(apiAccount) + + b, err := json.MarshalIndent(apiAccount, "", " ") + suite.NoError(err) + + suite.Equal(`{ + "id": "01AY6P665V14JJR0AFVRT7311Y", + "username": "localhost:8080", + "acct": "localhost:8080", + "display_name": "", + "locked": false, + "discoverable": false, + "bot": false, + "created_at": "2020-05-17T13:10:59.000Z", + "note": "", + "url": "http://localhost:8080/@localhost:8080", + "avatar": "", + "avatar_static": "", + "header": "", + "header_static": "", + "followers_count": 0, + "following_count": 0, + "statuses_count": 0, + "last_status_at": null, + "emojis": null, + "fields": null +}`, string(b)) +} + func (suite *InternalToFrontendTestSuite) TestStatusToFrontend() { testStatus := suite.testStatuses["admin_account_status_1"] requestingAccount := suite.testAccounts["local_account_1"] |