mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 17:02:25 -05:00
[bugfix] Don't copy ptr fields in caches (#2386)
This commit is contained in:
parent
0bb9b72334
commit
33ee61575f
12 changed files with 469 additions and 109 deletions
|
|
@ -224,6 +224,51 @@ func (suite *StatusTestSuite) TestUpdateStatus() {
|
|||
suite.True(updated.PinnedAt.IsZero())
|
||||
}
|
||||
|
||||
func (suite *StatusTestSuite) TestPutPopulatedStatus() {
|
||||
ctx := context.Background()
|
||||
|
||||
targetStatus := >smodel.Status{}
|
||||
*targetStatus = *suite.testStatuses["admin_account_status_1"]
|
||||
|
||||
// Populate fields on the target status.
|
||||
if err := suite.db.PopulateStatus(ctx, targetStatus); err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
// Delete it from the database.
|
||||
if err := suite.db.DeleteStatusByID(ctx, targetStatus.ID); err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
// Reinsert the populated version
|
||||
// so that it becomes cached.
|
||||
if err := suite.db.PutStatus(ctx, targetStatus); err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
// Update the status owner's
|
||||
// account with a new bio.
|
||||
account := >smodel.Account{}
|
||||
*account = *targetStatus.Account
|
||||
account.Note = "new note for this test"
|
||||
if err := suite.db.UpdateAccount(ctx, account, "note"); err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
dbStatus, err := suite.db.GetStatusByID(ctx, targetStatus.ID)
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
// Account note should be updated,
|
||||
// even though we stored this
|
||||
// status with the old note.
|
||||
suite.Equal(
|
||||
"new note for this test",
|
||||
dbStatus.Account.Note,
|
||||
)
|
||||
}
|
||||
|
||||
func TestStatusTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(StatusTestSuite))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue