From d5c9c4adc167cdb05e73f5105702cf340293e61c Mon Sep 17 00:00:00 2001 From: Daenney Date: Thu, 22 May 2025 12:26:11 +0200 Subject: [chore] Upgrade to Go 1.24 (#4187) * Set `go.mod` to 1.24 now that it's been out for 3 months. * Update all the test to use `testing.T.Context()`. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4187 Co-authored-by: Daenney Co-committed-by: Daenney --- internal/cleaner/emoji_test.go | 16 ++++++++-------- internal/cleaner/media_test.go | 38 +++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 27 deletions(-) (limited to 'internal/cleaner') diff --git a/internal/cleaner/emoji_test.go b/internal/cleaner/emoji_test.go index b789d2d5a..1b33224ef 100644 --- a/internal/cleaner/emoji_test.go +++ b/internal/cleaner/emoji_test.go @@ -26,42 +26,42 @@ func copyMap(in map[string]*gtsmodel.Emoji) map[string]*gtsmodel.Emoji { func (suite *CleanerTestSuite) TestEmojiUncacheRemote() { suite.testEmojiUncacheRemote( - context.Background(), + suite.T().Context(), mapvals(suite.emojis), ) } func (suite *CleanerTestSuite) TestEmojiUncacheRemoteDryRun() { suite.testEmojiUncacheRemote( - gtscontext.SetDryRun(context.Background()), + gtscontext.SetDryRun(suite.T().Context()), mapvals(suite.emojis), ) } func (suite *CleanerTestSuite) TestEmojiFixBroken() { suite.testEmojiFixBroken( - context.Background(), + suite.T().Context(), mapvals(suite.emojis), ) } func (suite *CleanerTestSuite) TestEmojiFixBrokenDryRun() { suite.testEmojiFixBroken( - gtscontext.SetDryRun(context.Background()), + gtscontext.SetDryRun(suite.T().Context()), mapvals(suite.emojis), ) } func (suite *CleanerTestSuite) TestEmojiPruneUnused() { suite.testEmojiPruneUnused( - context.Background(), + suite.T().Context(), mapvals(suite.emojis), ) } func (suite *CleanerTestSuite) TestEmojiPruneUnusedDryRun() { suite.testEmojiPruneUnused( - gtscontext.SetDryRun(context.Background()), + gtscontext.SetDryRun(suite.T().Context()), mapvals(suite.emojis), ) } @@ -74,7 +74,7 @@ func (suite *CleanerTestSuite) TestEmojiFixCacheStates() { emojis["rainbow"].Cached = util.Ptr(false) suite.testEmojiFixCacheStates( - context.Background(), + suite.T().Context(), mapvals(emojis), ) } @@ -87,7 +87,7 @@ func (suite *CleanerTestSuite) TestEmojiFixCacheStatesDryRun() { emojis["rainbow"].Cached = util.Ptr(false) suite.testEmojiFixCacheStates( - gtscontext.SetDryRun(context.Background()), + gtscontext.SetDryRun(suite.T().Context()), mapvals(emojis), ) } diff --git a/internal/cleaner/media_test.go b/internal/cleaner/media_test.go index 02470f72d..797e6ea46 100644 --- a/internal/cleaner/media_test.go +++ b/internal/cleaner/media_test.go @@ -94,11 +94,11 @@ func (suite *MediaTestSuite) TearDownTest() { // } // pandaPath := "01GJQJ1YD9QCHCE12GG0EYHVNW/attachment/original/01GJQJ2AYM1VKSRW96YVAJ3NK3.gif" -// if _, err := suite.storage.Put(context.Background(), pandaPath, b); err != nil { +// if _, err := suite.storage.Put(suite.T().Context(), pandaPath, b); err != nil { // suite.FailNow(err.Error()) // } -// ctx := context.Background() +// ctx := suite.T().Context() // // dry run should show up 1 orphaned panda // totalPruned, err := suite.cleaner.Media().PruneOrphaned(gtscontext.SetDryRun(ctx)) @@ -121,11 +121,11 @@ func (suite *MediaTestSuite) TearDownTest() { // } // pandaPath := "01GJQJ1YD9QCHCE12GG0EYHVNW/attachment/original/01GJQJ2AYM1VKSRW96YVAJ3NK3.gif" -// if _, err := suite.storage.Put(context.Background(), pandaPath, b); err != nil { +// if _, err := suite.storage.Put(suite.T().Context(), pandaPath, b); err != nil { // suite.FailNow(err.Error()) // } -// ctx := context.Background() +// ctx := suite.T().Context() // // should show up 1 orphaned panda // totalPruned, err := suite.cleaner.Media().PruneOrphaned(ctx) @@ -142,11 +142,11 @@ func (suite *MediaTestSuite) TearDownTest() { // testAttachment := suite.testAttachments["local_account_1_unattached_1"] // suite.True(*testAttachment.Cached) -// totalPruned, err := suite.manager.PruneUnusedLocal(context.Background(), false) +// totalPruned, err := suite.manager.PruneUnusedLocal(suite.T().Context(), false) // suite.NoError(err) // suite.Equal(1, totalPruned) -// _, err = suite.db.GetAttachmentByID(context.Background(), testAttachment.ID) +// _, err = suite.db.GetAttachmentByID(suite.T().Context(), testAttachment.ID) // suite.ErrorIs(err, db.ErrNoEntries) // } @@ -154,27 +154,27 @@ func (suite *MediaTestSuite) TearDownTest() { // testAttachment := suite.testAttachments["local_account_1_unattached_1"] // suite.True(*testAttachment.Cached) -// totalPruned, err := suite.manager.PruneUnusedLocal(context.Background(), true) +// totalPruned, err := suite.manager.PruneUnusedLocal(suite.T().Context(), true) // suite.NoError(err) // suite.Equal(1, totalPruned) -// _, err = suite.db.GetAttachmentByID(context.Background(), testAttachment.ID) +// _, err = suite.db.GetAttachmentByID(suite.T().Context(), testAttachment.ID) // suite.NoError(err) // } // func (suite *MediaTestSuite) TestPruneRemoteTwice() { -// totalPruned, err := suite.manager.PruneUnusedLocal(context.Background(), false) +// totalPruned, err := suite.manager.PruneUnusedLocal(suite.T().Context(), false) // suite.NoError(err) // suite.Equal(1, totalPruned) // // final prune should prune nothing, since the first prune already happened -// totalPrunedAgain, err := suite.manager.PruneUnusedLocal(context.Background(), false) +// totalPrunedAgain, err := suite.manager.PruneUnusedLocal(suite.T().Context(), false) // suite.NoError(err) // suite.Equal(0, totalPrunedAgain) // } // func (suite *MediaTestSuite) TestPruneOneNonExistent() { -// ctx := context.Background() +// ctx := suite.T().Context() // testAttachment := suite.testAttachments["local_account_1_unattached_1"] // // Delete this attachment cached on disk @@ -191,7 +191,7 @@ func (suite *MediaTestSuite) TearDownTest() { // } // func (suite *MediaTestSuite) TestPruneUnusedRemote() { -// ctx := context.Background() +// ctx := suite.T().Context() // // start by clearing zork's avatar + header // zorkOldAvatar := suite.testAttachments["local_account_1_avatar"] @@ -225,7 +225,7 @@ func (suite *MediaTestSuite) TearDownTest() { // } // func (suite *MediaTestSuite) TestPruneUnusedRemoteTwice() { -// ctx := context.Background() +// ctx := suite.T().Context() // // start by clearing zork's avatar + header // zork := suite.testAccounts["local_account_1"] @@ -246,7 +246,7 @@ func (suite *MediaTestSuite) TearDownTest() { // } // func (suite *MediaTestSuite) TestPruneUnusedRemoteMultipleAccounts() { -// ctx := context.Background() +// ctx := suite.T().Context() // // start by clearing zork's avatar + header // zorkOldAvatar := suite.testAttachments["local_account_1_avatar"] @@ -287,7 +287,7 @@ func (suite *MediaTestSuite) TearDownTest() { // } func (suite *MediaTestSuite) TestUncacheRemote() { - ctx := context.Background() + ctx := suite.T().Context() testStatusAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"] suite.True(*testStatusAttachment.Cached) @@ -310,7 +310,7 @@ func (suite *MediaTestSuite) TestUncacheRemote() { } func (suite *MediaTestSuite) TestUncacheRemoteDry() { - ctx := context.Background() + ctx := suite.T().Context() testStatusAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"] suite.True(*testStatusAttachment.Cached) @@ -333,7 +333,7 @@ func (suite *MediaTestSuite) TestUncacheRemoteDry() { } func (suite *MediaTestSuite) TestUncacheRemoteTwice() { - ctx := context.Background() + ctx := suite.T().Context() after := time.Now().Add(-24 * time.Hour) totalUncached, err := suite.cleaner.Media().UncacheRemote(ctx, after) @@ -347,7 +347,7 @@ func (suite *MediaTestSuite) TestUncacheRemoteTwice() { } func (suite *MediaTestSuite) TestUncacheAndRecache() { - ctx := context.Background() + ctx := suite.T().Context() testStatusAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"] testHeader := suite.testAttachments["remote_account_3_header"] @@ -403,7 +403,7 @@ func (suite *MediaTestSuite) TestUncacheAndRecache() { } func (suite *MediaTestSuite) TestUncacheOneNonExistent() { - ctx := context.Background() + ctx := suite.T().Context() testStatusAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"] // Delete this attachment cached on disk -- cgit v1.2.3