[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 <git@noreply.sourcery.dny.nu>
Co-committed-by: Daenney <git@noreply.sourcery.dny.nu>
This commit is contained in:
Daenney 2025-05-22 12:26:11 +02:00 committed by kim
commit d5c9c4adc1
175 changed files with 857 additions and 1004 deletions

View file

@ -36,7 +36,7 @@ func (suite *AnnounceTestSuite) TestNewAnnounce() {
receivingAccount1 := suite.testAccounts["local_account_1"]
announcingAccount := suite.testAccounts["remote_account_1"]
ctx := createTestContext(receivingAccount1, announcingAccount)
ctx := createTestContext(suite.T(), receivingAccount1, announcingAccount)
announce1 := suite.testActivities["announce_forwarded_1_zork"]
err := suite.federatingDB.Announce(ctx, announce1.Activity.(vocab.ActivityStreamsAnnounce))
@ -63,7 +63,7 @@ func (suite *AnnounceTestSuite) TestAnnounceTwice() {
announcingAccount := suite.testAccounts["remote_account_1"]
ctx1 := createTestContext(receivingAccount1, announcingAccount)
ctx1 := createTestContext(suite.T(), receivingAccount1, announcingAccount)
announce1 := suite.testActivities["announce_forwarded_1_zork"]
err := suite.federatingDB.Announce(ctx1, announce1.Activity.(vocab.ActivityStreamsAnnounce))
@ -87,7 +87,7 @@ func (suite *AnnounceTestSuite) TestAnnounceTwice() {
suite.Nil(boost.BoostOf)
suite.Equal("http://example.org/users/Some_User/statuses/afaba698-5740-4e32-a702-af61aa543bc1", boost.BoostOfURI)
ctx2 := createTestContext(receivingAccount2, announcingAccount)
ctx2 := createTestContext(suite.T(), receivingAccount2, announcingAccount)
announce2 := suite.testActivities["announce_forwarded_1_turtle"]
err = suite.federatingDB.Announce(ctx2, announce2.Activity.(vocab.ActivityStreamsAnnounce))

View file

@ -18,7 +18,6 @@
package federatingdb_test
import (
"context"
"encoding/json"
"testing"
"time"
@ -40,7 +39,7 @@ func (suite *CreateTestSuite) TestCreateNote() {
receivingAccount := suite.testAccounts["local_account_1"]
requestingAccount := suite.testAccounts["remote_account_1"]
ctx := createTestContext(receivingAccount, requestingAccount)
ctx := createTestContext(suite.T(), receivingAccount, requestingAccount)
create := suite.testActivities["dm_for_zork"].Activity
objProp := create.GetActivityStreamsObject()
@ -60,7 +59,7 @@ func (suite *CreateTestSuite) TestCreateNoteForward() {
receivingAccount := suite.testAccounts["local_account_1"]
requestingAccount := suite.testAccounts["remote_account_1"]
ctx := createTestContext(receivingAccount, requestingAccount)
ctx := createTestContext(suite.T(), receivingAccount, requestingAccount)
create := suite.testActivities["forwarded_message"].Activity
@ -111,14 +110,14 @@ func (suite *CreateTestSuite) TestCreateFlag1() {
suite.FailNow(err.Error())
}
t, err := streams.ToType(context.Background(), m)
t, err := streams.ToType(suite.T().Context(), m)
if err != nil {
suite.FailNow(err.Error())
}
flag := t.(vocab.ActivityStreamsFlag)
ctx := createTestContext(reportedAccount, reportingAccount)
ctx := createTestContext(suite.T(), reportedAccount, reportingAccount)
if err := suite.federatingDB.Flag(ctx, flag); err != nil {
suite.FailNow(err.Error())
}
@ -133,7 +132,7 @@ func (suite *CreateTestSuite) TestCreateFlag1() {
report := msg.GTSModel.(*gtsmodel.Report)
// report should be in the database
if _, err := suite.db.GetReportByID(context.Background(), report.ID); err != nil {
if _, err := suite.db.GetReportByID(suite.T().Context(), report.ID); err != nil {
suite.FailNow(err.Error())
}
}

View file

@ -19,6 +19,7 @@ package federatingdb_test
import (
"context"
"testing"
"time"
"code.superseriousbusiness.org/gotosocial/internal/admin"
@ -51,7 +52,7 @@ type FederatingDBTestSuite struct {
}
func (suite *FederatingDBTestSuite) getFederatorMsg(timeout time.Duration) (*messages.FromFediAPI, bool) {
ctx := context.Background()
ctx := suite.T().Context()
ctx, cncl := context.WithTimeout(ctx, timeout)
defer cncl()
return suite.state.Workers.Federator.Queue.PopCtx(ctx)
@ -91,9 +92,8 @@ func (suite *FederatingDBTestSuite) TearDownTest() {
testrig.StopWorkers(&suite.state)
}
func createTestContext(receivingAccount *gtsmodel.Account, requestingAccount *gtsmodel.Account) context.Context {
ctx := context.Background()
ctx = gtscontext.SetReceivingAccount(ctx, receivingAccount)
func createTestContext(t *testing.T, receivingAccount *gtsmodel.Account, requestingAccount *gtsmodel.Account) context.Context {
ctx := gtscontext.SetReceivingAccount(t.Context(), receivingAccount)
ctx = gtscontext.SetRequestingAccount(ctx, requestingAccount)
return ctx
}

View file

@ -18,7 +18,6 @@
package federatingdb_test
import (
"context"
"encoding/json"
"testing"
@ -34,7 +33,7 @@ type FollowersTestSuite struct {
func (suite *FollowersTestSuite) TestGetFollowers() {
testAccount := suite.testAccounts["local_account_2"]
f, err := suite.federatingDB.Followers(context.Background(), testrig.URLMustParse(testAccount.URI))
f, err := suite.federatingDB.Followers(suite.T().Context(), testrig.URLMustParse(testAccount.URI))
suite.NoError(err)
fi, err := ap.Serialize(f)

View file

@ -18,7 +18,6 @@
package federatingdb_test
import (
"context"
"encoding/json"
"testing"
@ -34,7 +33,7 @@ type FollowingTestSuite struct {
func (suite *FollowingTestSuite) TestGetFollowing() {
testAccount := suite.testAccounts["local_account_1"]
f, err := suite.federatingDB.Following(context.Background(), testrig.URLMustParse(testAccount.URI))
f, err := suite.federatingDB.Following(suite.T().Context(), testrig.URLMustParse(testAccount.URI))
suite.NoError(err)
fi, err := ap.Serialize(f)

View file

@ -18,7 +18,6 @@
package federatingdb_test
import (
"context"
"testing"
"code.superseriousbusiness.org/gotosocial/testrig"
@ -30,7 +29,7 @@ type InboxTestSuite struct {
}
func (suite *InboxTestSuite) TestInboxesForFollowersIRI() {
ctx := context.Background()
ctx := suite.T().Context()
testAccount := suite.testAccounts["local_account_1"]
inboxIRIs, err := suite.federatingDB.InboxesForIRI(ctx, testrig.URLMustParse(testAccount.FollowersURI))
@ -47,7 +46,7 @@ func (suite *InboxTestSuite) TestInboxesForFollowersIRI() {
}
func (suite *InboxTestSuite) TestInboxesForAccountIRI() {
ctx := context.Background()
ctx := suite.T().Context()
testAccount := suite.testAccounts["local_account_1"]
inboxIRIs, err := suite.federatingDB.InboxesForIRI(ctx, testrig.URLMustParse(testAccount.URI))
@ -63,7 +62,7 @@ func (suite *InboxTestSuite) TestInboxesForAccountIRI() {
}
func (suite *InboxTestSuite) TestInboxesForAccountIRIWithSharedInbox() {
ctx := context.Background()
ctx := suite.T().Context()
testAccount := suite.testAccounts["local_account_1"]
sharedInbox := "http://some-inbox-iri/weeeeeeeeeeeee"
testAccount.SharedInboxURI = &sharedInbox

View file

@ -38,7 +38,7 @@ func (suite *MoveTestSuite) move(
requestingAcct *gtsmodel.Account,
moveStr string,
) error {
ctx := createTestContext(receivingAcct, requestingAcct)
ctx := createTestContext(suite.T(), receivingAcct, requestingAcct)
rawMove := make(map[string]interface{})
if err := json.Unmarshal([]byte(moveStr), &rawMove); err != nil {

View file

@ -39,7 +39,7 @@ func (suite *RejectTestSuite) TestRejectFollowRequest() {
// remote_account_2 rejects the follow request
followingAccount := suite.testAccounts["local_account_1"]
followedAccount := suite.testAccounts["remote_account_2"]
ctx := createTestContext(followingAccount, followedAccount)
ctx := createTestContext(suite.T(), followingAccount, followedAccount)
// put the follow request in the database
fr := &gtsmodel.FollowRequest{

View file

@ -18,7 +18,6 @@
package federatingdb_test
import (
"context"
"encoding/json"
"testing"
"time"
@ -34,7 +33,7 @@ type UpdateTestSuite struct {
func (suite *UpdateTestSuite) TestUpdateNewMention() {
var (
ctx = context.Background()
ctx = suite.T().Context()
update = suite.testActivities["remote_account_2_status_1_update"]
receivingAcct = suite.testAccounts["local_account_1"]
requestingAcct = suite.testAccounts["remote_account_2"]