diff options
| author | 2025-05-22 12:26:11 +0200 | |
|---|---|---|
| committer | 2025-05-22 12:26:11 +0200 | |
| commit | d5c9c4adc167cdb05e73f5105702cf340293e61c (patch) | |
| tree | 1d21fe376099864900837eba675a965517f98e5d /internal/api/activitypub | |
| parent | [feature] Allow exposing allows, implement `/api/v1/domain_blocks` and `/api/... (diff) | |
| download | gotosocial-d5c9c4adc167cdb05e73f5105702cf340293e61c.tar.xz | |
[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>
Diffstat (limited to 'internal/api/activitypub')
| -rw-r--r-- | internal/api/activitypub/users/inboxpost_test.go | 15 | ||||
| -rw-r--r-- | internal/api/activitypub/users/outboxget_test.go | 7 | ||||
| -rw-r--r-- | internal/api/activitypub/users/repliesget_test.go | 7 | ||||
| -rw-r--r-- | internal/api/activitypub/users/statusget_test.go | 9 | ||||
| -rw-r--r-- | internal/api/activitypub/users/userget_test.go | 13 |
5 files changed, 23 insertions, 28 deletions
diff --git a/internal/api/activitypub/users/inboxpost_test.go b/internal/api/activitypub/users/inboxpost_test.go index e00a705a0..81b21eafc 100644 --- a/internal/api/activitypub/users/inboxpost_test.go +++ b/internal/api/activitypub/users/inboxpost_test.go @@ -19,7 +19,6 @@ package users_test import ( "bytes" - "context" "encoding/json" "errors" "io" @@ -232,7 +231,7 @@ func (suite *InboxPostTestSuite) TestPostBlock() { ) if !testrig.WaitFor(func() bool { - dbBlock, err = suite.db.GetBlock(context.Background(), requestingAccount.ID, targetAccount.ID) + dbBlock, err = suite.db.GetBlock(suite.T().Context(), requestingAccount.ID, targetAccount.ID) return err == nil && dbBlock != nil }) { suite.FailNow("timed out waiting for block to be created") @@ -243,7 +242,7 @@ func (suite *InboxPostTestSuite) TestPostBlock() { // one of our instance users should be able to undo that block. func (suite *InboxPostTestSuite) TestPostUnblock() { var ( - ctx = context.Background() + ctx = suite.T().Context() requestingAccount = suite.testAccounts["remote_account_1"] targetAccount = suite.testAccounts["local_account_1"] blockID = "http://fossbros-anonymous.io/blocks/01H1462TPRTVG2RTQCTSQ7N6Q0" @@ -315,7 +314,7 @@ func (suite *InboxPostTestSuite) TestPostUpdate() { requestingAccount.Emojis = []*gtsmodel.Emoji{testEmoji} // Create an update from the account. - accountable, err := suite.tc.AccountToAS(context.Background(), requestingAccount) + accountable, err := suite.tc.AccountToAS(suite.T().Context(), requestingAccount) if err != nil { suite.FailNow(err.Error()) } @@ -344,7 +343,7 @@ func (suite *InboxPostTestSuite) TestPostUpdate() { if !testrig.WaitFor(func() bool { // displayName should be updated - dbUpdatedAccount, _ = suite.db.GetAccountByID(context.Background(), requestingAccount.ID) + dbUpdatedAccount, _ = suite.db.GetAccountByID(suite.T().Context(), requestingAccount.ID) return dbUpdatedAccount.DisplayName == updatedDisplayName }) { suite.FailNow("timed out waiting for account update") @@ -399,7 +398,7 @@ func (suite *InboxPostTestSuite) TestPostUpdate() { func (suite *InboxPostTestSuite) TestPostDelete() { var ( - ctx = context.Background() + ctx = suite.T().Context() requestingAccount = suite.testAccounts["remote_account_1"] targetAccount = suite.testAccounts["local_account_1"] activityID = requestingAccount.URI + "/some-new-activity/01FG9C441MCTW3R2W117V2PQK3" @@ -517,7 +516,7 @@ func (suite *InboxPostTestSuite) TestPostFromBlockedAccount() { ) // Create an update from the account. - accountable, err := suite.tc.AccountToAS(context.Background(), requestingAccount) + accountable, err := suite.tc.AccountToAS(suite.T().Context(), requestingAccount) if err != nil { suite.FailNow(err.Error()) } @@ -559,7 +558,7 @@ func (suite *InboxPostTestSuite) TestPostFromBlockedAccountToOtherAccount() { suite.signatureCheck, ) - _, err := suite.state.DB.GetStatusByURI(context.Background(), statusURI) + _, err := suite.state.DB.GetStatusByURI(suite.T().Context(), statusURI) suite.ErrorIs(err, db.ErrNoEntries) } diff --git a/internal/api/activitypub/users/outboxget_test.go b/internal/api/activitypub/users/outboxget_test.go index dc9c621a6..1290830b2 100644 --- a/internal/api/activitypub/users/outboxget_test.go +++ b/internal/api/activitypub/users/outboxget_test.go @@ -19,7 +19,6 @@ package users_test import ( "bytes" - "context" "encoding/json" "io/ioutil" "net/http" @@ -90,7 +89,7 @@ func (suite *OutboxGetTestSuite) TestGetOutbox() { err = json.Unmarshal(b, &m) suite.NoError(err) - t, err := streams.ToType(context.Background(), m) + t, err := streams.ToType(suite.T().Context(), m) suite.NoError(err) _, ok := t.(vocab.ActivityStreamsOrderedCollection) @@ -177,7 +176,7 @@ func (suite *OutboxGetTestSuite) TestGetOutboxFirstPage() { err = json.Unmarshal(b, &m) suite.NoError(err) - t, err := streams.ToType(context.Background(), m) + t, err := streams.ToType(suite.T().Context(), m) suite.NoError(err) _, ok := t.(vocab.ActivityStreamsOrderedCollectionPage) @@ -240,7 +239,7 @@ func (suite *OutboxGetTestSuite) TestGetOutboxNextPage() { err = json.Unmarshal(b, &m) suite.NoError(err) - t, err := streams.ToType(context.Background(), m) + t, err := streams.ToType(suite.T().Context(), m) suite.NoError(err) _, ok := t.(vocab.ActivityStreamsOrderedCollectionPage) diff --git a/internal/api/activitypub/users/repliesget_test.go b/internal/api/activitypub/users/repliesget_test.go index 9d2141811..5d3754a8c 100644 --- a/internal/api/activitypub/users/repliesget_test.go +++ b/internal/api/activitypub/users/repliesget_test.go @@ -19,7 +19,6 @@ package users_test import ( "bytes" - "context" "encoding/json" "io" "net/http" @@ -101,7 +100,7 @@ func (suite *RepliesGetTestSuite) TestGetReplies() { err = json.Unmarshal(b, &m) assert.NoError(suite.T(), err) - t, err := streams.ToType(context.Background(), m) + t, err := streams.ToType(suite.T().Context(), m) assert.NoError(suite.T(), err) _, ok := t.(vocab.ActivityStreamsOrderedCollection) @@ -172,7 +171,7 @@ func (suite *RepliesGetTestSuite) TestGetRepliesNext() { err = json.Unmarshal(b, &m) assert.NoError(suite.T(), err) - t, err := streams.ToType(context.Background(), m) + t, err := streams.ToType(suite.T().Context(), m) assert.NoError(suite.T(), err) page, ok := t.(vocab.ActivityStreamsOrderedCollectionPage) @@ -243,7 +242,7 @@ func (suite *RepliesGetTestSuite) TestGetRepliesLast() { err = json.Unmarshal(b, &m) assert.NoError(suite.T(), err) - t, err := streams.ToType(context.Background(), m) + t, err := streams.ToType(suite.T().Context(), m) assert.NoError(suite.T(), err) page, ok := t.(vocab.ActivityStreamsOrderedCollectionPage) diff --git a/internal/api/activitypub/users/statusget_test.go b/internal/api/activitypub/users/statusget_test.go index dc3aef5a7..275acdc02 100644 --- a/internal/api/activitypub/users/statusget_test.go +++ b/internal/api/activitypub/users/statusget_test.go @@ -18,7 +18,6 @@ package users_test import ( - "context" "encoding/json" "io/ioutil" "net/http" @@ -85,14 +84,14 @@ func (suite *StatusGetTestSuite) TestGetStatus() { err = json.Unmarshal(b, &m) suite.NoError(err) - t, err := streams.ToType(context.Background(), m) + t, err := streams.ToType(suite.T().Context(), m) suite.NoError(err) note, ok := t.(vocab.ActivityStreamsNote) suite.True(ok) // convert note to status - a, err := suite.tc.ASStatusToStatus(context.Background(), note) + a, err := suite.tc.ASStatusToStatus(suite.T().Context(), note) suite.NoError(err) suite.EqualValues(targetStatus.Content, a.Content) } @@ -144,14 +143,14 @@ func (suite *StatusGetTestSuite) TestGetStatusLowercase() { err = json.Unmarshal(b, &m) suite.NoError(err) - t, err := streams.ToType(context.Background(), m) + t, err := streams.ToType(suite.T().Context(), m) suite.NoError(err) note, ok := t.(vocab.ActivityStreamsNote) suite.True(ok) // convert note to status - a, err := suite.tc.ASStatusToStatus(context.Background(), note) + a, err := suite.tc.ASStatusToStatus(suite.T().Context(), note) suite.NoError(err) suite.EqualValues(targetStatus.Content, a.Content) } diff --git a/internal/api/activitypub/users/userget_test.go b/internal/api/activitypub/users/userget_test.go index 06bc46452..a9cba468f 100644 --- a/internal/api/activitypub/users/userget_test.go +++ b/internal/api/activitypub/users/userget_test.go @@ -18,7 +18,6 @@ package users_test import ( - "context" "encoding/json" "io/ioutil" "net/http" @@ -79,14 +78,14 @@ func (suite *UserGetTestSuite) TestGetUser() { err = json.Unmarshal(b, &m) suite.NoError(err) - t, err := streams.ToType(context.Background(), m) + t, err := streams.ToType(suite.T().Context(), m) suite.NoError(err) person, ok := t.(vocab.ActivityStreamsPerson) suite.True(ok) // convert person to account - a, err := suite.tc.ASRepresentationToAccount(context.Background(), person, "", "") + a, err := suite.tc.ASRepresentationToAccount(suite.T().Context(), person, "", "") suite.NoError(err) suite.EqualValues(targetAccount.Username, a.Username) } @@ -97,11 +96,11 @@ func (suite *UserGetTestSuite) TestGetUserPublicKeyDeleted() { userModule := users.New(suite.processor) targetAccount := suite.testAccounts["local_account_1"] - suite.processor.User().DeleteSelf(context.Background(), suite.testAccounts["local_account_1"]) + suite.processor.User().DeleteSelf(suite.T().Context(), suite.testAccounts["local_account_1"]) // wait for the account delete to be processed if !testrig.WaitFor(func() bool { - a, _ := suite.db.GetAccountByID(context.Background(), targetAccount.ID) + a, _ := suite.db.GetAccountByID(suite.T().Context(), targetAccount.ID) return !a.SuspendedAt.IsZero() }) { suite.FailNow("delete of account timed out") @@ -147,14 +146,14 @@ func (suite *UserGetTestSuite) TestGetUserPublicKeyDeleted() { err = json.Unmarshal(b, &m) suite.NoError(err) - t, err := streams.ToType(context.Background(), m) + t, err := streams.ToType(suite.T().Context(), m) suite.NoError(err) person, ok := t.(vocab.ActivityStreamsPerson) suite.True(ok) // convert person to account - a, err := suite.tc.ASRepresentationToAccount(context.Background(), person, "", "") + a, err := suite.tc.ASRepresentationToAccount(suite.T().Context(), person, "", "") suite.NoError(err) suite.EqualValues(targetAccount.Username, a.Username) } |
