mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-01 22:12:25 -05:00
[bugfix] Fix setting bot on/off
This commit is contained in:
parent
e032c959e1
commit
e89ce8d43b
5 changed files with 88 additions and 22 deletions
|
|
@ -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,56 @@ 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)
|
||||
|
||||
// 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)
|
||||
|
||||
// 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))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue