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/filter/spam/statusable_test.go | 3 +-- internal/filter/visibility/home_timeline_test.go | 21 ++++++++++----------- internal/filter/visibility/status_test.go | 21 ++++++++++----------- 3 files changed, 21 insertions(+), 24 deletions(-) (limited to 'internal/filter') diff --git a/internal/filter/spam/statusable_test.go b/internal/filter/spam/statusable_test.go index 7d710416f..0f31e627a 100644 --- a/internal/filter/spam/statusable_test.go +++ b/internal/filter/spam/statusable_test.go @@ -19,7 +19,6 @@ package spam_test import ( "bytes" - "context" "io" "testing" @@ -621,7 +620,7 @@ const ( func (suite *StatusableTestSuite) TestStatusableOK() { var ( - ctx = context.Background() + ctx = suite.T().Context() receiver = suite.testAccounts["local_account_1"] requester = suite.testAccounts["remote_account_1"] ) diff --git a/internal/filter/visibility/home_timeline_test.go b/internal/filter/visibility/home_timeline_test.go index a152a64bc..d2be788e2 100644 --- a/internal/filter/visibility/home_timeline_test.go +++ b/internal/filter/visibility/home_timeline_test.go @@ -18,7 +18,6 @@ package visibility_test import ( - "context" "testing" "time" @@ -36,7 +35,7 @@ type StatusStatusHomeTimelineableTestSuite struct { func (suite *StatusStatusHomeTimelineableTestSuite) TestOwnStatusHomeTimelineable() { testStatus := suite.testStatuses["local_account_1_status_1"] testAccount := suite.testAccounts["local_account_1"] - ctx := context.Background() + ctx := suite.T().Context() timelineable, err := suite.filter.StatusHomeTimelineable(ctx, testAccount, testStatus) suite.NoError(err) @@ -47,7 +46,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestOwnStatusHomeTimelineabl func (suite *StatusStatusHomeTimelineableTestSuite) TestFollowingStatusHomeTimelineable() { testStatus := suite.testStatuses["local_account_2_status_1"] testAccount := suite.testAccounts["local_account_1"] - ctx := context.Background() + ctx := suite.T().Context() timelineable, err := suite.filter.StatusHomeTimelineable(ctx, testAccount, testStatus) suite.NoError(err) @@ -56,7 +55,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestFollowingStatusHomeTimel } func (suite *StatusStatusHomeTimelineableTestSuite) TestFollowingBoostedStatusHomeTimelineable() { - ctx := context.Background() + ctx := suite.T().Context() testStatus := suite.testStatuses["admin_account_status_4"] testAccount := suite.testAccounts["local_account_1"] @@ -67,7 +66,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestFollowingBoostedStatusHo } func (suite *StatusStatusHomeTimelineableTestSuite) TestFollowingBoostedStatusHomeTimelineableNoReblogs() { - ctx := context.Background() + ctx := suite.T().Context() // Update follow to indicate that local_account_1 // doesn't want to see reblogs by admin_account. @@ -90,7 +89,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestFollowingBoostedStatusHo func (suite *StatusStatusHomeTimelineableTestSuite) TestNotFollowingStatusHomeTimelineable() { testStatus := suite.testStatuses["remote_account_1_status_1"] testAccount := suite.testAccounts["local_account_1"] - ctx := context.Background() + ctx := suite.T().Context() timelineable, err := suite.filter.StatusHomeTimelineable(ctx, testAccount, testStatus) suite.NoError(err) @@ -105,7 +104,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestStatusTooNewNotTimelinea testStatus.CreatedAt = time.Now().Add(25 * time.Hour) testAccount := suite.testAccounts["local_account_1"] - ctx := context.Background() + ctx := suite.T().Context() timelineable, err := suite.filter.StatusHomeTimelineable(ctx, testAccount, testStatus) suite.NoError(err) @@ -120,7 +119,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestStatusNotTooNewTimelinea testStatus.CreatedAt = time.Now().Add(23 * time.Hour) testAccount := suite.testAccounts["local_account_1"] - ctx := context.Background() + ctx := suite.T().Context() timelineable, err := suite.filter.StatusHomeTimelineable(ctx, testAccount, testStatus) suite.NoError(err) @@ -129,7 +128,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestStatusNotTooNewTimelinea } func (suite *StatusStatusHomeTimelineableTestSuite) TestThread() { - ctx := context.Background() + ctx := suite.T().Context() threadParentAccount := suite.testAccounts["local_account_1"] timelineOwnerAccount := suite.testAccounts["local_account_2"] @@ -173,7 +172,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestThread() { } func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyFollowersOnly() { - ctx := context.Background() + ctx := suite.T().Context() // This scenario makes sure that we don't timeline a status which is a followers-only // reply to a followers-only status TO A FOLLOWERS-ONLY STATUS owned by someone the @@ -282,7 +281,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyFollowersOnly( } func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyPublicAndUnlocked() { - ctx := context.Background() + ctx := suite.T().Context() // This scenario is exactly the same as the above test, but for a mix of unlocked + public posts diff --git a/internal/filter/visibility/status_test.go b/internal/filter/visibility/status_test.go index d7442089c..5abd13065 100644 --- a/internal/filter/visibility/status_test.go +++ b/internal/filter/visibility/status_test.go @@ -18,7 +18,6 @@ package visibility_test import ( - "context" "testing" "code.superseriousbusiness.org/gotosocial/internal/gtsmodel" @@ -33,7 +32,7 @@ type StatusVisibleTestSuite struct { func (suite *StatusVisibleTestSuite) TestOwnStatusVisible() { testStatus := suite.testStatuses["local_account_1_status_1"] testAccount := suite.testAccounts["local_account_1"] - ctx := context.Background() + ctx := suite.T().Context() visible, err := suite.filter.StatusVisible(ctx, testAccount, testStatus) suite.NoError(err) @@ -42,7 +41,7 @@ func (suite *StatusVisibleTestSuite) TestOwnStatusVisible() { } func (suite *StatusVisibleTestSuite) TestOwnDMVisible() { - ctx := context.Background() + ctx := suite.T().Context() testStatusID := suite.testStatuses["local_account_2_status_6"].ID testStatus, err := suite.db.GetStatusByID(ctx, testStatusID) @@ -56,7 +55,7 @@ func (suite *StatusVisibleTestSuite) TestOwnDMVisible() { } func (suite *StatusVisibleTestSuite) TestDMVisibleToTarget() { - ctx := context.Background() + ctx := suite.T().Context() testStatusID := suite.testStatuses["local_account_2_status_6"].ID testStatus, err := suite.db.GetStatusByID(ctx, testStatusID) @@ -70,7 +69,7 @@ func (suite *StatusVisibleTestSuite) TestDMVisibleToTarget() { } func (suite *StatusVisibleTestSuite) TestDMNotVisibleIfNotMentioned() { - ctx := context.Background() + ctx := suite.T().Context() testStatusID := suite.testStatuses["local_account_2_status_6"].ID testStatus, err := suite.db.GetStatusByID(ctx, testStatusID) @@ -84,7 +83,7 @@ func (suite *StatusVisibleTestSuite) TestDMNotVisibleIfNotMentioned() { } func (suite *StatusVisibleTestSuite) TestStatusNotVisibleIfNotMutuals() { - ctx := context.Background() + ctx := suite.T().Context() suite.db.DeleteByID(ctx, suite.testFollows["local_account_2_local_account_1"].ID, >smodel.Follow{}) @@ -100,7 +99,7 @@ func (suite *StatusVisibleTestSuite) TestStatusNotVisibleIfNotMutuals() { } func (suite *StatusVisibleTestSuite) TestStatusNotVisibleIfNotFollowing() { - ctx := context.Background() + ctx := suite.T().Context() suite.db.DeleteByID(ctx, suite.testFollows["admin_account_local_account_1"].ID, >smodel.Follow{}) @@ -116,7 +115,7 @@ func (suite *StatusVisibleTestSuite) TestStatusNotVisibleIfNotFollowing() { } func (suite *StatusVisibleTestSuite) TestStatusNotVisibleIfNotMutualsCached() { - ctx := context.Background() + ctx := suite.T().Context() testStatusID := suite.testStatuses["local_account_1_status_4"].ID testStatus, err := suite.db.GetStatusByID(ctx, testStatusID) suite.NoError(err) @@ -137,7 +136,7 @@ func (suite *StatusVisibleTestSuite) TestStatusNotVisibleIfNotMutualsCached() { } func (suite *StatusVisibleTestSuite) TestStatusNotVisibleIfNotFollowingCached() { - ctx := context.Background() + ctx := suite.T().Context() testStatusID := suite.testStatuses["local_account_1_status_5"].ID testStatus, err := suite.db.GetStatusByID(ctx, testStatusID) suite.NoError(err) @@ -158,7 +157,7 @@ func (suite *StatusVisibleTestSuite) TestStatusNotVisibleIfNotFollowingCached() } func (suite *StatusVisibleTestSuite) TestVisiblePending() { - ctx := context.Background() + ctx := suite.T().Context() // Copy the test status and mark // the copy as pending approval. @@ -241,7 +240,7 @@ func (suite *StatusVisibleTestSuite) TestVisiblePending() { } func (suite *StatusVisibleTestSuite) TestVisibleLocalOnly() { - ctx := context.Background() + ctx := suite.T().Context() // Local-only, Public status. testStatus := suite.testStatuses["local_account_2_status_4"] -- cgit v1.2.3