diff options
Diffstat (limited to 'internal/db/bundb/status_test.go')
-rw-r--r-- | internal/db/bundb/status_test.go | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/internal/db/bundb/status_test.go b/internal/db/bundb/status_test.go index d86e0bcf9..2335c75a9 100644 --- a/internal/db/bundb/status_test.go +++ b/internal/db/bundb/status_test.go @@ -26,6 +26,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/superseriousbusiness/gotosocial/internal/db" + "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" ) type StatusTestSuite struct { @@ -176,7 +177,10 @@ func (suite *StatusTestSuite) TestGetStatusChildren() { } func (suite *StatusTestSuite) TestDeleteStatus() { - targetStatus := suite.testStatuses["admin_account_status_1"] + // Take a copy of the status. + targetStatus := >smodel.Status{} + *targetStatus = *suite.testStatuses["admin_account_status_1"] + err := suite.db.DeleteStatusByID(context.Background(), targetStatus.ID) suite.NoError(err) @@ -184,6 +188,31 @@ func (suite *StatusTestSuite) TestDeleteStatus() { suite.ErrorIs(err, db.ErrNoEntries) } +// This test was added specifically to ensure that Postgres wasn't getting upset +// about trying to use a transaction in which an error has already occurred, which +// was previously leading to errors like 'current transaction is aborted, commands +// ignored until end of transaction block' when updating a status that already had +// emojis or tags set on it. +// +// To run this test for postgres specifically, start a postgres container on localhost +// and then run: +// +// GTS_DB_TYPE=postgres GTS_DB_ADDRESS=localhost go test ./internal/db/bundb -run '^TestStatusTestSuite$' -testify.m '^(TestUpdateStatus)$' github.com/superseriousbusiness/gotosocial/internal/db/bundb +func (suite *StatusTestSuite) TestUpdateStatus() { + // Take a copy of the status. + targetStatus := >smodel.Status{} + *targetStatus = *suite.testStatuses["admin_account_status_1"] + + targetStatus.PinnedAt = time.Time{} + + err := suite.db.UpdateStatus(context.Background(), targetStatus, "pinned_at") + suite.NoError(err) + + updated, err := suite.db.GetStatusByID(context.Background(), targetStatus.ID) + suite.NoError(err) + suite.True(updated.PinnedAt.IsZero()) +} + func TestStatusTestSuite(t *testing.T) { suite.Run(t, new(StatusTestSuite)) } |