diff options
author | 2023-02-16 14:20:23 +0100 | |
---|---|---|
committer | 2023-02-16 13:20:23 +0000 | |
commit | b5993095fad2d18ce29e92b0ae1e5e1450bd7f4a (patch) | |
tree | 27714bd915eabf8f8f0ca52a5a2ec35864ba93c1 /internal/api/client/accounts/accountupdate_test.go | |
parent | [bugfix] Set cache-control max-age dynamically for s3 (#1510) (diff) | |
download | gotosocial-b5993095fad2d18ce29e92b0ae1e5e1450bd7f4a.tar.xz |
[bugfix] Set 'discoverable' properly on API accounts (#1511)v0.7.0
Diffstat (limited to 'internal/api/client/accounts/accountupdate_test.go')
-rw-r--r-- | internal/api/client/accounts/accountupdate_test.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/internal/api/client/accounts/accountupdate_test.go b/internal/api/client/accounts/accountupdate_test.go index 9ccb29302..95387f3d7 100644 --- a/internal/api/client/accounts/accountupdate_test.go +++ b/internal/api/client/accounts/accountupdate_test.go @@ -250,6 +250,48 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateCredentialsPATCHHandlerTwo suite.NotEmpty(dbZork.EmojiIDs) } +func (suite *AccountUpdateTestSuite) TestAccountUpdateCredentialsPATCHHandlerDiscoverable() { + requestBody, w, err := testrig.CreateMultipartFormData( + "", "", + map[string]string{ + "discoverable": "false", + }) + if err != nil { + panic(err) + } + bodyBytes := requestBody.Bytes() + recorder := httptest.NewRecorder() + ctx := suite.newContext(recorder, http.MethodPatch, bodyBytes, accounts.UpdateCredentialsPath, w.FormDataContentType()) + + // call the handler + suite.accountsModule.AccountUpdateCredentialsPATCHHandler(ctx) + + // 1. we should have OK because our request was valid + suite.Equal(http.StatusOK, recorder.Code) + + // 2. we should have no error message in the result body + result := recorder.Result() + defer result.Body.Close() + + // check the response + b, err := ioutil.ReadAll(result.Body) + suite.NoError(err) + + // unmarshal the returned account + apimodelAccount := &apimodel.Account{} + err = json.Unmarshal(b, apimodelAccount) + suite.NoError(err) + + // check the returned api model account + // fields should be updated + suite.False(apimodelAccount.Discoverable) + + // check the account in the database + dbZork, err := suite.db.GetAccountByID(context.Background(), apimodelAccount.ID) + suite.NoError(err) + suite.False(*dbZork.Discoverable) +} + func (suite *AccountUpdateTestSuite) TestAccountUpdateCredentialsPATCHHandlerWithMedia() { // set up the request // we're updating the header image, the display name, and the locked status of zork |