diff options
author | 2023-11-27 16:39:44 +0100 | |
---|---|---|
committer | 2023-11-27 15:39:44 +0000 | |
commit | 33ee61575f2fc15c5a85c3fdbb3823a0cd22d25d (patch) | |
tree | 5e887d5ea5b828c84a1a9eb386bbaa07ad63a420 /internal/db/bundb/status_test.go | |
parent | [docs] Add docs about memory requirements and swap (#2385) (diff) | |
download | gotosocial-33ee61575f2fc15c5a85c3fdbb3823a0cd22d25d.tar.xz |
[bugfix] Don't copy ptr fields in caches (#2386)
Diffstat (limited to 'internal/db/bundb/status_test.go')
-rw-r--r-- | internal/db/bundb/status_test.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/internal/db/bundb/status_test.go b/internal/db/bundb/status_test.go index c0ff6c0da..2129aa0e8 100644 --- a/internal/db/bundb/status_test.go +++ b/internal/db/bundb/status_test.go @@ -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)) } |