[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

@ -51,7 +51,7 @@ func (suite *AccountTestSuite) TestDereferenceGroup() {
groupURL := testrig.URLMustParse("https://unknown-instance.com/groups/some_group")
group, _, err := suite.dereferencer.GetAccountByURI(
context.Background(),
suite.T().Context(),
fetchingAccount.Username,
groupURL,
false,
@ -65,7 +65,7 @@ func (suite *AccountTestSuite) TestDereferenceGroup() {
suite.WithinDuration(time.Now(), group.FetchedAt, 5*time.Second)
// group should be in the database
dbGroup, err := suite.db.GetAccountByURI(context.Background(), group.URI)
dbGroup, err := suite.db.GetAccountByURI(suite.T().Context(), group.URI)
suite.NoError(err)
suite.Equal(group.ID, dbGroup.ID)
suite.Equal(ap.ActorGroup, dbGroup.ActorType.String())
@ -76,7 +76,7 @@ func (suite *AccountTestSuite) TestDereferenceService() {
serviceURL := testrig.URLMustParse("https://owncast.example.org/federation/user/rgh")
service, _, err := suite.dereferencer.GetAccountByURI(
context.Background(),
suite.T().Context(),
fetchingAccount.Username,
serviceURL,
false,
@ -90,7 +90,7 @@ func (suite *AccountTestSuite) TestDereferenceService() {
suite.WithinDuration(time.Now(), service.FetchedAt, 5*time.Second)
// service should be in the database
dbService, err := suite.db.GetAccountByURI(context.Background(), service.URI)
dbService, err := suite.db.GetAccountByURI(suite.T().Context(), service.URI)
suite.NoError(err)
suite.Equal(service.ID, dbService.ID)
suite.Equal(ap.ActorService, dbService.ActorType.String())
@ -109,7 +109,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountAsRemoteURL() {
targetAccount := suite.testAccounts["local_account_2"]
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
context.Background(),
suite.T().Context(),
fetchingAccount.Username,
testrig.URLMustParse(targetAccount.URI),
false,
@ -124,12 +124,12 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountAsRemoteURLNoSharedInb
targetAccount := suite.testAccounts["local_account_2"]
targetAccount.SharedInboxURI = nil
if err := suite.db.UpdateAccount(context.Background(), targetAccount); err != nil {
if err := suite.db.UpdateAccount(suite.T().Context(), targetAccount); err != nil {
suite.FailNow(err.Error())
}
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
context.Background(),
suite.T().Context(),
fetchingAccount.Username,
testrig.URLMustParse(targetAccount.URI),
false,
@ -144,7 +144,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountAsUsername() {
targetAccount := suite.testAccounts["local_account_2"]
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
context.Background(),
suite.T().Context(),
fetchingAccount.Username,
testrig.URLMustParse(targetAccount.URI),
false,
@ -159,7 +159,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountAsUsernameDomain() {
targetAccount := suite.testAccounts["local_account_2"]
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
context.Background(),
suite.T().Context(),
fetchingAccount.Username,
testrig.URLMustParse(targetAccount.URI),
false,
@ -174,7 +174,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountAsUsernameDomainAndURL
targetAccount := suite.testAccounts["local_account_2"]
fetchedAccount, _, err := suite.dereferencer.GetAccountByUsernameDomain(
context.Background(),
suite.T().Context(),
fetchingAccount.Username,
targetAccount.Username,
config.GetHost(),
@ -188,7 +188,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountWithUnknownUsername()
fetchingAccount := suite.testAccounts["local_account_1"]
fetchedAccount, _, err := suite.dereferencer.GetAccountByUsernameDomain(
context.Background(),
suite.T().Context(),
fetchingAccount.Username,
"thisaccountdoesnotexist",
config.GetHost(),
@ -202,7 +202,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountWithUnknownUsernameDom
fetchingAccount := suite.testAccounts["local_account_1"]
fetchedAccount, _, err := suite.dereferencer.GetAccountByUsernameDomain(
context.Background(),
suite.T().Context(),
fetchingAccount.Username,
"thisaccountdoesnotexist",
"localhost:8080",
@ -216,7 +216,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountWithUnknownUserURI() {
fetchingAccount := suite.testAccounts["local_account_1"]
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
context.Background(),
suite.T().Context(),
fetchingAccount.Username,
testrig.URLMustParse("http://localhost:8080/users/thisaccountdoesnotexist"),
false,
@ -227,7 +227,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountWithUnknownUserURI() {
}
func (suite *AccountTestSuite) TestDereferenceLocalAccountByRedirect() {
ctx, cncl := context.WithCancel(context.Background())
ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
fetchingAccount := suite.testAccounts["local_account_1"]
@ -280,7 +280,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountByRedirect() {
}
func (suite *AccountTestSuite) TestDereferenceMasqueradingLocalAccount() {
ctx, cncl := context.WithCancel(context.Background())
ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
fetchingAccount := suite.testAccounts["local_account_1"]
@ -345,7 +345,7 @@ func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithNonMatchingURI()
// Attempt to fetch account at alternative URI, it should fail!
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
context.Background(),
suite.T().Context(),
fetchingAccount.Username,
testrig.URLMustParse(remoteAltURI),
false,
@ -355,7 +355,7 @@ func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithNonMatchingURI()
}
func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithUnexpectedKeyChange() {
ctx, cncl := context.WithCancel(context.Background())
ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
fetchingAcc := suite.testAccounts["local_account_1"]
@ -394,7 +394,7 @@ func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithUnexpectedKeyChan
}
func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithExpectedKeyChange() {
ctx, cncl := context.WithCancel(context.Background())
ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
fetchingAcc := suite.testAccounts["local_account_1"]
@ -436,7 +436,7 @@ func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithExpectedKeyChange
}
func (suite *AccountTestSuite) TestRefreshFederatedRemoteAccountWithKeyChange() {
ctx, cncl := context.WithCancel(context.Background())
ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
fetchingAcc := suite.testAccounts["local_account_1"]

View file

@ -18,7 +18,6 @@
package dereferencing_test
import (
"context"
"fmt"
"testing"
"time"
@ -32,7 +31,7 @@ type EmojiTestSuite struct {
}
func (suite *EmojiTestSuite) TestDereferenceEmojiBlocking() {
ctx := context.Background()
ctx := suite.T().Context()
emojiImageRemoteURL := "http://example.org/media/emojis/1781772.gif"
emojiImageStaticRemoteURL := "http://example.org/media/emojis/1781772.gif"
emojiURI := "http://example.org/emojis/1781772"

View file

@ -18,7 +18,6 @@
package dereferencing_test
import (
"context"
"net/url"
"testing"
@ -77,7 +76,7 @@ func (suite *InstanceTestSuite) TestDerefInstance() {
},
} {
instance, err := suite.dereferencer.GetRemoteInstance(
gtscontext.SetFastFail(context.Background()),
gtscontext.SetFastFail(suite.T().Context()),
suite.testAccounts["admin_account"].Username,
tc.instanceIRI,
)

View file

@ -44,7 +44,7 @@ func (suite *StatusTestSuite) TestDereferenceSimpleStatus() {
fetchingAccount := suite.testAccounts["local_account_1"]
statusURL := testrig.URLMustParse("https://unknown-instance.com/users/brand_new_person/statuses/01FE4NTHKWW7THT67EF10EB839")
status, _, err := suite.dereferencer.GetStatusByURI(context.Background(), fetchingAccount.Username, statusURL)
status, _, err := suite.dereferencer.GetStatusByURI(suite.T().Context(), fetchingAccount.Username, statusURL)
suite.NoError(err)
suite.NotNil(status)
@ -59,13 +59,13 @@ func (suite *StatusTestSuite) TestDereferenceSimpleStatus() {
suite.Equal(ap.ObjectNote, status.ActivityStreamsType)
// status should be in the database
dbStatus, err := suite.db.GetStatusByURI(context.Background(), status.URI)
dbStatus, err := suite.db.GetStatusByURI(suite.T().Context(), status.URI)
suite.NoError(err)
suite.Equal(status.ID, dbStatus.ID)
suite.True(*dbStatus.Federated)
// account should be in the database now too
account, err := suite.db.GetAccountByURI(context.Background(), status.AccountURI)
account, err := suite.db.GetAccountByURI(suite.T().Context(), status.AccountURI)
suite.NoError(err)
suite.NotNil(account)
suite.True(*account.Discoverable)
@ -81,7 +81,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithMention() {
fetchingAccount := suite.testAccounts["local_account_1"]
statusURL := testrig.URLMustParse("https://unknown-instance.com/users/brand_new_person/statuses/01FE5Y30E3W4P7TRE0R98KAYQV")
status, _, err := suite.dereferencer.GetStatusByURI(context.Background(), fetchingAccount.Username, statusURL)
status, _, err := suite.dereferencer.GetStatusByURI(suite.T().Context(), fetchingAccount.Username, statusURL)
suite.NoError(err)
suite.NotNil(status)
@ -96,13 +96,13 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithMention() {
suite.Equal(ap.ObjectNote, status.ActivityStreamsType)
// status should be in the database
dbStatus, err := suite.db.GetStatusByURI(context.Background(), status.URI)
dbStatus, err := suite.db.GetStatusByURI(suite.T().Context(), status.URI)
suite.NoError(err)
suite.Equal(status.ID, dbStatus.ID)
suite.True(*dbStatus.Federated)
// account should be in the database now too
account, err := suite.db.GetAccountByURI(context.Background(), status.AccountURI)
account, err := suite.db.GetAccountByURI(suite.T().Context(), status.AccountURI)
suite.NoError(err)
suite.NotNil(account)
suite.True(*account.Discoverable)
@ -115,7 +115,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithMention() {
// we should have a mention in the database
m := &gtsmodel.Mention{}
err = suite.db.GetWhere(context.Background(), []db.Where{{Key: "status_id", Value: status.ID}}, m)
err = suite.db.GetWhere(suite.T().Context(), []db.Where{{Key: "status_id", Value: status.ID}}, m)
suite.NoError(err)
suite.NotNil(m)
suite.Equal(status.ID, m.StatusID)
@ -129,7 +129,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithTag() {
fetchingAccount := suite.testAccounts["local_account_1"]
statusURL := testrig.URLMustParse("https://unknown-instance.com/users/brand_new_person/statuses/01H641QSRS3TCXSVC10X4GPKW7")
status, _, err := suite.dereferencer.GetStatusByURI(context.Background(), fetchingAccount.Username, statusURL)
status, _, err := suite.dereferencer.GetStatusByURI(suite.T().Context(), fetchingAccount.Username, statusURL)
suite.NoError(err)
suite.NotNil(status)
@ -148,13 +148,13 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithTag() {
suite.Len(status.TagIDs, 1)
// status should be in the database
dbStatus, err := suite.db.GetStatusByURI(context.Background(), status.URI)
dbStatus, err := suite.db.GetStatusByURI(suite.T().Context(), status.URI)
suite.NoError(err)
suite.Equal(status.ID, dbStatus.ID)
suite.True(*dbStatus.Federated)
// account should be in the database now too
account, err := suite.db.GetAccountByURI(context.Background(), status.AccountURI)
account, err := suite.db.GetAccountByURI(suite.T().Context(), status.AccountURI)
suite.NoError(err)
suite.NotNil(account)
suite.True(*account.Discoverable)
@ -167,7 +167,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithTag() {
// we should have a tag in the database
t := &gtsmodel.Tag{}
err = suite.db.GetWhere(context.Background(), []db.Where{{Key: "name", Value: "piss"}}, t)
err = suite.db.GetWhere(suite.T().Context(), []db.Where{{Key: "name", Value: "piss"}}, t)
suite.NoError(err)
suite.NotNil(t)
}
@ -176,7 +176,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithImageAndNoContent() {
fetchingAccount := suite.testAccounts["local_account_1"]
statusURL := testrig.URLMustParse("https://turnip.farm/users/turniplover6969/statuses/70c53e54-3146-42d5-a630-83c8b6c7c042")
status, _, err := suite.dereferencer.GetStatusByURI(context.Background(), fetchingAccount.Username, statusURL)
status, _, err := suite.dereferencer.GetStatusByURI(suite.T().Context(), fetchingAccount.Username, statusURL)
suite.NoError(err)
suite.NotNil(status)
@ -191,13 +191,13 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithImageAndNoContent() {
suite.Equal(ap.ObjectNote, status.ActivityStreamsType)
// status should be in the database
dbStatus, err := suite.db.GetStatusByURI(context.Background(), status.URI)
dbStatus, err := suite.db.GetStatusByURI(suite.T().Context(), status.URI)
suite.NoError(err)
suite.Equal(status.ID, dbStatus.ID)
suite.True(*dbStatus.Federated)
// account should be in the database now too
account, err := suite.db.GetAccountByURI(context.Background(), status.AccountURI)
account, err := suite.db.GetAccountByURI(suite.T().Context(), status.AccountURI)
suite.NoError(err)
suite.NotNil(account)
suite.True(*account.Discoverable)
@ -210,7 +210,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithImageAndNoContent() {
// we should have an attachment in the database
a := &gtsmodel.MediaAttachment{}
err = suite.db.GetWhere(context.Background(), []db.Where{{Key: "status_id", Value: status.ID}}, a)
err = suite.db.GetWhere(suite.T().Context(), []db.Where{{Key: "status_id", Value: status.ID}}, a)
suite.NoError(err)
}
@ -228,7 +228,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithNonMatchingURI() {
// Attempt to fetch account at alternative URI, it should fail!
fetchedStatus, _, err := suite.dereferencer.GetStatusByURI(
context.Background(),
suite.T().Context(),
fetchingAccount.Username,
testrig.URLMustParse(remoteAltURI),
)
@ -238,7 +238,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithNonMatchingURI() {
func (suite *StatusTestSuite) TestDereferencerRefreshStatusUpdated() {
// Create a new context for this test.
ctx, cncl := context.WithCancel(context.Background())
ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// The local account we will be fetching statuses as.

View file

@ -19,7 +19,6 @@ package federation_test
import (
"bytes"
"context"
"encoding/json"
"io"
"net/url"
@ -40,7 +39,7 @@ type FederatingActorTestSuite struct {
}
func (suite *FederatingActorTestSuite) TestSendNoRemoteFollowers() {
ctx := context.Background()
ctx := suite.T().Context()
testAccount := suite.testAccounts["local_account_1"]
testNote := testrig.NewAPNote(
testrig.URLMustParse("http://localhost:8080/users/the_mighty_zork/statuses/01G1TR6BADACCZWQMNF9X21TV5"),
@ -82,7 +81,7 @@ func (suite *FederatingActorTestSuite) TestSendNoRemoteFollowers() {
}
func (suite *FederatingActorTestSuite) TestSendRemoteFollower() {
ctx := context.Background()
ctx := suite.T().Context()
testAccount := suite.testAccounts["local_account_1"]
testRemoteAccount := suite.testAccounts["remote_account_1"]

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"]

View file

@ -130,7 +130,7 @@ func (suite *FederatingProtocolTestSuite) TestPostInboxRequestBodyHookDM() {
)
ctx := suite.postInboxRequestBodyHook(
context.Background(),
suite.T().Context(),
receivingAccount,
activity,
)
@ -155,7 +155,7 @@ func (suite *FederatingProtocolTestSuite) TestPostInboxRequestBodyHookReply() {
)
ctx := suite.postInboxRequestBodyHook(
context.Background(),
suite.T().Context(),
receivingAccount,
activity,
)
@ -180,7 +180,7 @@ func (suite *FederatingProtocolTestSuite) TestPostInboxRequestBodyHookReplyToRep
)
ctx := suite.postInboxRequestBodyHook(
context.Background(),
suite.T().Context(),
receivingAccount,
activity,
)
@ -205,7 +205,7 @@ func (suite *FederatingProtocolTestSuite) TestPostInboxRequestBodyHookAnnounceFo
)
ctx := suite.postInboxRequestBodyHook(
context.Background(),
suite.T().Context(),
receivingAccount,
activity,
)
@ -230,7 +230,7 @@ func (suite *FederatingProtocolTestSuite) TestPostInboxRequestBodyHookAnnounceFo
)
ctx := suite.postInboxRequestBodyHook(
context.Background(),
suite.T().Context(),
receivingAccount,
activity,
)
@ -255,7 +255,7 @@ func (suite *FederatingProtocolTestSuite) TestAuthenticatePostInbox() {
)
ctx, authed, resp, code := suite.authenticatePostInbox(
context.Background(),
suite.T().Context(),
receivingAccount,
activity,
)
@ -268,7 +268,7 @@ func (suite *FederatingProtocolTestSuite) TestAuthenticatePostInbox() {
func (suite *FederatingProtocolTestSuite) TestAuthenticatePostInboxKeyExpired() {
var (
ctx = context.Background()
ctx = suite.T().Context()
activity = suite.testActivities["dm_for_zork"]
receivingAccount = suite.testAccounts["local_account_1"]
)
@ -300,7 +300,7 @@ func (suite *FederatingProtocolTestSuite) TestAuthenticatePostGoneWithTombstone(
)
ctx, authed, resp, code := suite.authenticatePostInbox(
context.Background(),
suite.T().Context(),
receivingAccount,
activity,
)
@ -320,12 +320,12 @@ func (suite *FederatingProtocolTestSuite) TestAuthenticatePostGoneNoTombstone()
)
// Delete the tombstone; it'll have to be created again.
if err := suite.state.DB.DeleteTombstone(context.Background(), testTombstone.ID); err != nil {
if err := suite.state.DB.DeleteTombstone(suite.T().Context(), testTombstone.ID); err != nil {
suite.FailNow(err.Error())
}
ctx, authed, resp, code := suite.authenticatePostInbox(
context.Background(),
suite.T().Context(),
receivingAccount,
activity,
)
@ -337,7 +337,7 @@ func (suite *FederatingProtocolTestSuite) TestAuthenticatePostGoneNoTombstone()
// Tombstone should be back, baby!
exists, err := suite.state.DB.TombstoneExistsWithURI(
context.Background(),
suite.T().Context(),
"https://somewhere.mysterious/users/rest_in_piss#main-key",
)
suite.NoError(err)
@ -368,7 +368,7 @@ func (suite *FederatingProtocolTestSuite) TestBlockedNoProblem() {
)
blocked, err := suite.blocked(
context.Background(),
suite.T().Context(),
receivingAccount,
requestingAccount,
otherIRIs,
@ -390,7 +390,7 @@ func (suite *FederatingProtocolTestSuite) TestBlockedReceiverBlocksRequester() {
)
// Insert a block from receivingAccount targeting requestingAccount.
if err := suite.state.DB.PutBlock(context.Background(), &gtsmodel.Block{
if err := suite.state.DB.PutBlock(suite.T().Context(), &gtsmodel.Block{
ID: "01G3KBEMJD4VQ2D615MPV7KTRD",
URI: "whatever",
AccountID: receivingAccount.ID,
@ -400,7 +400,7 @@ func (suite *FederatingProtocolTestSuite) TestBlockedReceiverBlocksRequester() {
}
blocked, err := suite.blocked(
context.Background(),
suite.T().Context(),
receivingAccount,
requestingAccount,
otherIRIs,
@ -425,7 +425,7 @@ func (suite *FederatingProtocolTestSuite) TestBlockedCCd() {
)
// Insert a block from receivingAccount targeting ccedAccount.
if err := suite.state.DB.PutBlock(context.Background(), &gtsmodel.Block{
if err := suite.state.DB.PutBlock(suite.T().Context(), &gtsmodel.Block{
ID: "01G3KBEMJD4VQ2D615MPV7KTRD",
URI: "whatever",
AccountID: receivingAccount.ID,
@ -435,7 +435,7 @@ func (suite *FederatingProtocolTestSuite) TestBlockedCCd() {
}
blocked, err := suite.blocked(
context.Background(),
suite.T().Context(),
receivingAccount,
requestingAccount,
otherIRIs,
@ -462,7 +462,7 @@ func (suite *FederatingProtocolTestSuite) TestBlockedRepliedStatus() {
)
blocked, err := suite.blocked(
context.Background(),
suite.T().Context(),
receivingAccount,
requestingAccount,
otherIRIs,

View file

@ -18,8 +18,6 @@
package federation_test
import (
"context"
"github.com/stretchr/testify/suite"
"code.superseriousbusiness.org/gotosocial/internal/federation"
@ -68,7 +66,7 @@ func (suite *FederatorStandardTestSuite) SetupTest() {
// Ensure it's possible to deref
// main key of foss satan.
fossSatanAS, err := suite.typeconverter.AccountToAS(context.Background(), suite.testAccounts["remote_account_1"])
fossSatanAS, err := suite.typeconverter.AccountToAS(suite.T().Context(), suite.testAccounts["remote_account_1"])
if err != nil {
suite.FailNow(err.Error())
}