summaryrefslogtreecommitdiff
path: root/internal/federation/federatingdb
diff options
context:
space:
mode:
authorLibravatar Daenney <git@noreply.sourcery.dny.nu>2025-05-22 12:26:11 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-05-22 12:26:11 +0200
commitd5c9c4adc167cdb05e73f5105702cf340293e61c (patch)
tree1d21fe376099864900837eba675a965517f98e5d /internal/federation/federatingdb
parent[feature] Allow exposing allows, implement `/api/v1/domain_blocks` and `/api/... (diff)
downloadgotosocial-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/federation/federatingdb')
-rw-r--r--internal/federation/federatingdb/announce_test.go6
-rw-r--r--internal/federation/federatingdb/create_test.go11
-rw-r--r--internal/federation/federatingdb/federatingdb_test.go8
-rw-r--r--internal/federation/federatingdb/followers_test.go3
-rw-r--r--internal/federation/federatingdb/following_test.go3
-rw-r--r--internal/federation/federatingdb/inbox_test.go7
-rw-r--r--internal/federation/federatingdb/move_test.go2
-rw-r--r--internal/federation/federatingdb/reject_test.go2
-rw-r--r--internal/federation/federatingdb/update_test.go3
9 files changed, 20 insertions, 25 deletions
diff --git a/internal/federation/federatingdb/announce_test.go b/internal/federation/federatingdb/announce_test.go
index efb8c2381..309b2beee 100644
--- a/internal/federation/federatingdb/announce_test.go
+++ b/internal/federation/federatingdb/announce_test.go
@@ -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))
diff --git a/internal/federation/federatingdb/create_test.go b/internal/federation/federatingdb/create_test.go
index 2061c6be1..5a2b51a76 100644
--- a/internal/federation/federatingdb/create_test.go
+++ b/internal/federation/federatingdb/create_test.go
@@ -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())
}
}
diff --git a/internal/federation/federatingdb/federatingdb_test.go b/internal/federation/federatingdb/federatingdb_test.go
index 1203cf6b8..ee898e293 100644
--- a/internal/federation/federatingdb/federatingdb_test.go
+++ b/internal/federation/federatingdb/federatingdb_test.go
@@ -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
}
diff --git a/internal/federation/federatingdb/followers_test.go b/internal/federation/federatingdb/followers_test.go
index 2c40c0a8c..e37e59d04 100644
--- a/internal/federation/federatingdb/followers_test.go
+++ b/internal/federation/federatingdb/followers_test.go
@@ -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)
diff --git a/internal/federation/federatingdb/following_test.go b/internal/federation/federatingdb/following_test.go
index ff8c11160..d139201d8 100644
--- a/internal/federation/federatingdb/following_test.go
+++ b/internal/federation/federatingdb/following_test.go
@@ -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)
diff --git a/internal/federation/federatingdb/inbox_test.go b/internal/federation/federatingdb/inbox_test.go
index d8c308a10..b26950962 100644
--- a/internal/federation/federatingdb/inbox_test.go
+++ b/internal/federation/federatingdb/inbox_test.go
@@ -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
diff --git a/internal/federation/federatingdb/move_test.go b/internal/federation/federatingdb/move_test.go
index 38a869f15..d5026b778 100644
--- a/internal/federation/federatingdb/move_test.go
+++ b/internal/federation/federatingdb/move_test.go
@@ -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 {
diff --git a/internal/federation/federatingdb/reject_test.go b/internal/federation/federatingdb/reject_test.go
index 28a46eaad..142db7842 100644
--- a/internal/federation/federatingdb/reject_test.go
+++ b/internal/federation/federatingdb/reject_test.go
@@ -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{
diff --git a/internal/federation/federatingdb/update_test.go b/internal/federation/federatingdb/update_test.go
index 3c2d54fc7..5df9974b6 100644
--- a/internal/federation/federatingdb/update_test.go
+++ b/internal/federation/federatingdb/update_test.go
@@ -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"]