summaryrefslogtreecommitdiff
path: root/internal/api/client
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/client')
-rw-r--r--internal/api/client/accounts/accountupdate_test.go11
-rw-r--r--internal/api/client/accounts/follow_test.go11
-rw-r--r--internal/api/client/admin/domainpermissionsubscriptiontest_test.go5
-rw-r--r--internal/api/client/admin/emojicreate_test.go7
-rw-r--r--internal/api/client/admin/emojidelete_test.go5
-rw-r--r--internal/api/client/admin/emojiupdate_test.go9
-rw-r--r--internal/api/client/admin/mediacleanup_test.go7
-rw-r--r--internal/api/client/bookmarks/bookmarks_test.go9
-rw-r--r--internal/api/client/filters/v1/filter_test.go4
-rw-r--r--internal/api/client/filters/v2/filter_test.go4
-rw-r--r--internal/api/client/followedtags/get_test.go3
-rw-r--r--internal/api/client/followrequests/authorize_test.go3
-rw-r--r--internal/api/client/followrequests/get_test.go11
-rw-r--r--internal/api/client/followrequests/reject_test.go3
-rw-r--r--internal/api/client/import/import_test.go5
-rw-r--r--internal/api/client/instance/instancepatch_test.go5
-rw-r--r--internal/api/client/instance/instancepeersget_test.go5
-rw-r--r--internal/api/client/lists/listaccountsadd_test.go3
-rw-r--r--internal/api/client/mutes/mutesget_test.go7
-rw-r--r--internal/api/client/notifications/notificationsget_test.go3
-rw-r--r--internal/api/client/search/searchget_test.go11
-rw-r--r--internal/api/client/statuses/statusboost_test.go7
-rw-r--r--internal/api/client/statuses/statuscreate_test.go3
-rw-r--r--internal/api/client/statuses/statusfave_test.go3
-rw-r--r--internal/api/client/statuses/statuspin_test.go5
-rw-r--r--internal/api/client/tags/follow_test.go3
-rw-r--r--internal/api/client/tags/get_test.go3
-rw-r--r--internal/api/client/tags/unfollow_test.go3
-rw-r--r--internal/api/client/tokens/tokeninvalidate_test.go3
-rw-r--r--internal/api/client/user/passwordchange_test.go3
30 files changed, 68 insertions, 96 deletions
diff --git a/internal/api/client/accounts/accountupdate_test.go b/internal/api/client/accounts/accountupdate_test.go
index 1ab9f1fce..b234617a7 100644
--- a/internal/api/client/accounts/accountupdate_test.go
+++ b/internal/api/client/accounts/accountupdate_test.go
@@ -18,7 +18,6 @@
package accounts_test
import (
- "context"
"encoding/json"
"fmt"
"io"
@@ -289,7 +288,7 @@ func (suite *AccountUpdateTestSuite) TestUpdateAccountCache() {
// Get the account first to make sure it's in the database
// cache. When the account is updated via the PATCH handler,
// it should invalidate the cache and return the new version.
- if _, err := suite.db.GetAccountByID(context.Background(), suite.testAccounts["local_account_1"].ID); err != nil {
+ if _, err := suite.db.GetAccountByID(suite.T().Context(), suite.testAccounts["local_account_1"].ID); err != nil {
suite.FailNow(err.Error())
}
@@ -318,7 +317,7 @@ func (suite *AccountUpdateTestSuite) TestUpdateAccountDiscoverableForm() {
suite.False(apimodelAccount.Discoverable)
// Check the account in the database too.
- dbZork, err := suite.db.GetAccountByID(context.Background(), apimodelAccount.ID)
+ dbZork, err := suite.db.GetAccountByID(suite.T().Context(), apimodelAccount.ID)
suite.NoError(err)
suite.False(*dbZork.Discoverable)
}
@@ -336,7 +335,7 @@ func (suite *AccountUpdateTestSuite) TestUpdateAccountDiscoverableFormData() {
suite.False(apimodelAccount.Discoverable)
// Check the account in the database too.
- dbZork, err := suite.db.GetAccountByID(context.Background(), apimodelAccount.ID)
+ dbZork, err := suite.db.GetAccountByID(suite.T().Context(), apimodelAccount.ID)
suite.NoError(err)
suite.False(*dbZork.Discoverable)
}
@@ -355,7 +354,7 @@ func (suite *AccountUpdateTestSuite) TestUpdateAccountDiscoverableJSON() {
suite.False(apimodelAccount.Discoverable)
// Check the account in the database too.
- dbZork, err := suite.db.GetAccountByID(context.Background(), apimodelAccount.ID)
+ dbZork, err := suite.db.GetAccountByID(suite.T().Context(), apimodelAccount.ID)
suite.NoError(err)
suite.False(*dbZork.Discoverable)
}
@@ -477,7 +476,7 @@ func (suite *AccountUpdateTestSuite) TestUpdateAccountSourceBadContentTypeFormDa
suite.Equal(data["source[status_content_type]"][0], apimodelAccount.Source.StatusContentType)
// Check the account in the database too.
- dbAccount, err := suite.db.GetAccountByID(context.Background(), suite.testAccounts["local_account_1"].ID)
+ dbAccount, err := suite.db.GetAccountByID(suite.T().Context(), suite.testAccounts["local_account_1"].ID)
if err != nil {
suite.FailNow(err.Error())
}
diff --git a/internal/api/client/accounts/follow_test.go b/internal/api/client/accounts/follow_test.go
index d87b8c9b9..1d470f126 100644
--- a/internal/api/client/accounts/follow_test.go
+++ b/internal/api/client/accounts/follow_test.go
@@ -18,7 +18,6 @@
package accounts_test
import (
- "context"
"encoding/json"
"fmt"
"io"
@@ -102,7 +101,7 @@ func (suite *FollowTestSuite) TestGetFollowersPageOldestToNewestLimit6() {
}
func (suite *FollowTestSuite) testGetFollowersPage(limit int, direction string) {
- ctx := context.Background()
+ ctx := suite.T().Context()
// The authed local account we are going to use for HTTP requests
requestingAccount := suite.testAccounts["local_account_1"]
@@ -304,7 +303,7 @@ func (suite *FollowTestSuite) TestGetFollowingPageOldestToNewestLimit6() {
}
func (suite *FollowTestSuite) testGetFollowingPage(limit int, direction string) {
- ctx := context.Background()
+ ctx := suite.T().Context()
// The authed local account we are going to use for HTTP requests
requestingAccount := suite.testAccounts["local_account_1"]
@@ -483,19 +482,19 @@ func (suite *FollowTestSuite) testGetFollowingPage(limit int, direction string)
func (suite *FollowTestSuite) clearAccountRelations(id string) {
// Esnure no account blocks exist between accounts.
_ = suite.db.DeleteAccountBlocks(
- context.Background(),
+ suite.T().Context(),
id,
)
// Ensure no account follows exist between accounts.
_ = suite.db.DeleteAccountFollows(
- context.Background(),
+ suite.T().Context(),
id,
)
// Ensure no account follow_requests exist between accounts.
_ = suite.db.DeleteAccountFollowRequests(
- context.Background(),
+ suite.T().Context(),
id,
)
}
diff --git a/internal/api/client/admin/domainpermissionsubscriptiontest_test.go b/internal/api/client/admin/domainpermissionsubscriptiontest_test.go
index 6d3356f0e..49ab3c330 100644
--- a/internal/api/client/admin/domainpermissionsubscriptiontest_test.go
+++ b/internal/api/client/admin/domainpermissionsubscriptiontest_test.go
@@ -19,7 +19,6 @@ package admin_test
import (
"bytes"
- "context"
"encoding/json"
"io"
"net/http"
@@ -41,7 +40,7 @@ type DomainPermissionSubscriptionTestTestSuite struct {
func (suite *DomainPermissionSubscriptionTestTestSuite) TestDomainPermissionSubscriptionTestCSV() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testAccount = suite.testAccounts["admin_account"]
permSub = &gtsmodel.DomainPermissionSubscription{
ID: "01JGE681TQSBPAV59GZXPKE62H",
@@ -129,7 +128,7 @@ func (suite *DomainPermissionSubscriptionTestTestSuite) TestDomainPermissionSubs
func (suite *DomainPermissionSubscriptionTestTestSuite) TestDomainPermissionSubscriptionTestText() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testAccount = suite.testAccounts["admin_account"]
permSub = &gtsmodel.DomainPermissionSubscription{
ID: "01JGE681TQSBPAV59GZXPKE62H",
diff --git a/internal/api/client/admin/emojicreate_test.go b/internal/api/client/admin/emojicreate_test.go
index 1a6983c21..3970ced09 100644
--- a/internal/api/client/admin/emojicreate_test.go
+++ b/internal/api/client/admin/emojicreate_test.go
@@ -18,7 +18,6 @@
package admin_test
import (
- "context"
"encoding/json"
"io/ioutil"
"net/http"
@@ -77,7 +76,7 @@ func (suite *EmojiCreateTestSuite) TestEmojiCreateNewCategory() {
suite.True(apiEmoji.VisibleInPicker)
// emoji should be in the db
- dbEmoji, err := suite.db.GetEmojiByShortcodeDomain(context.Background(), apiEmoji.Shortcode, "")
+ dbEmoji, err := suite.db.GetEmojiByShortcodeDomain(suite.T().Context(), apiEmoji.Shortcode, "")
suite.NoError(err)
// check fields on the emoji
@@ -150,7 +149,7 @@ func (suite *EmojiCreateTestSuite) TestEmojiCreateExistingCategory() {
suite.True(apiEmoji.VisibleInPicker)
// emoji should be in the db
- dbEmoji, err := suite.db.GetEmojiByShortcodeDomain(context.Background(), apiEmoji.Shortcode, "")
+ dbEmoji, err := suite.db.GetEmojiByShortcodeDomain(suite.T().Context(), apiEmoji.Shortcode, "")
suite.NoError(err)
// check fields on the emoji
@@ -223,7 +222,7 @@ func (suite *EmojiCreateTestSuite) TestEmojiCreateNoCategory() {
suite.True(apiEmoji.VisibleInPicker)
// emoji should be in the db
- dbEmoji, err := suite.db.GetEmojiByShortcodeDomain(context.Background(), apiEmoji.Shortcode, "")
+ dbEmoji, err := suite.db.GetEmojiByShortcodeDomain(suite.T().Context(), apiEmoji.Shortcode, "")
suite.NoError(err)
// check fields on the emoji
diff --git a/internal/api/client/admin/emojidelete_test.go b/internal/api/client/admin/emojidelete_test.go
index c327bed94..1672a4e71 100644
--- a/internal/api/client/admin/emojidelete_test.go
+++ b/internal/api/client/admin/emojidelete_test.go
@@ -19,7 +19,6 @@ package admin_test
import (
"bytes"
- "context"
"encoding/json"
"io"
"net/http"
@@ -68,7 +67,7 @@ func (suite *EmojiDeleteTestSuite) TestEmojiDelete1() {
}`, dst.String())
// emoji should no longer be in the db
- dbEmoji, err := suite.db.GetEmojiByID(context.Background(), testEmoji.ID)
+ dbEmoji, err := suite.db.GetEmojiByID(suite.T().Context(), testEmoji.ID)
suite.Nil(dbEmoji)
suite.ErrorIs(err, db.ErrNoEntries)
}
@@ -91,7 +90,7 @@ func (suite *EmojiDeleteTestSuite) TestEmojiDelete2() {
suite.Equal(`{"error":"Bad Request: emoji with id 01GD5KP5CQEE1R3X43Y1EHS2CW was not a local emoji, will not delete"}`, string(b))
// emoji should still be in the db
- dbEmoji, err := suite.db.GetEmojiByID(context.Background(), testEmoji.ID)
+ dbEmoji, err := suite.db.GetEmojiByID(suite.T().Context(), testEmoji.ID)
suite.NoError(err)
suite.NotNil(dbEmoji)
}
diff --git a/internal/api/client/admin/emojiupdate_test.go b/internal/api/client/admin/emojiupdate_test.go
index 91a9ec8f4..6fc8d826e 100644
--- a/internal/api/client/admin/emojiupdate_test.go
+++ b/internal/api/client/admin/emojiupdate_test.go
@@ -18,7 +18,6 @@
package admin_test
import (
- "context"
"encoding/json"
"io"
"net/http"
@@ -84,7 +83,7 @@ func (suite *EmojiUpdateTestSuite) TestEmojiUpdateNewCategory() {
suite.True(adminEmoji.VisibleInPicker)
// emoji should be in the db
- dbEmoji, err := suite.db.GetEmojiByShortcodeDomain(context.Background(), adminEmoji.Shortcode, "")
+ dbEmoji, err := suite.db.GetEmojiByShortcodeDomain(suite.T().Context(), adminEmoji.Shortcode, "")
suite.NoError(err)
// check fields on the emoji
@@ -161,7 +160,7 @@ func (suite *EmojiUpdateTestSuite) TestEmojiUpdateSwitchCategory() {
suite.True(adminEmoji.VisibleInPicker)
// emoji should be in the db
- dbEmoji, err := suite.db.GetEmojiByShortcodeDomain(context.Background(), adminEmoji.Shortcode, "")
+ dbEmoji, err := suite.db.GetEmojiByShortcodeDomain(suite.T().Context(), adminEmoji.Shortcode, "")
suite.NoError(err)
// check fields on the emoji
@@ -239,7 +238,7 @@ func (suite *EmojiUpdateTestSuite) TestEmojiUpdateCopyRemoteToLocal() {
suite.True(adminEmoji.VisibleInPicker)
// emoji should be in the db
- dbEmoji, err := suite.db.GetEmojiByShortcodeDomain(context.Background(), adminEmoji.Shortcode, "")
+ dbEmoji, err := suite.db.GetEmojiByShortcodeDomain(suite.T().Context(), adminEmoji.Shortcode, "")
suite.NoError(err)
// check fields on the emoji
@@ -387,7 +386,7 @@ func (suite *EmojiUpdateTestSuite) TestEmojiUpdateModify() {
suite.True(adminEmoji.VisibleInPicker)
// emoji should be in the db
- dbEmoji, err := suite.db.GetEmojiByShortcodeDomain(context.Background(), adminEmoji.Shortcode, "")
+ dbEmoji, err := suite.db.GetEmojiByShortcodeDomain(suite.T().Context(), adminEmoji.Shortcode, "")
suite.NoError(err)
// check fields on the emoji
diff --git a/internal/api/client/admin/mediacleanup_test.go b/internal/api/client/admin/mediacleanup_test.go
index 8224b875f..8efef54c4 100644
--- a/internal/api/client/admin/mediacleanup_test.go
+++ b/internal/api/client/admin/mediacleanup_test.go
@@ -18,7 +18,6 @@
package admin_test
import (
- "context"
"net/http"
"net/http/httptest"
"testing"
@@ -49,7 +48,7 @@ func (suite *MediaCleanupTestSuite) TestMediaCleanup() {
// the attachment should be updated in the database
if !testrig.WaitFor(func() bool {
- if prunedAttachment, _ := suite.db.GetAttachmentByID(context.Background(), testAttachment.ID); prunedAttachment != nil {
+ if prunedAttachment, _ := suite.db.GetAttachmentByID(suite.T().Context(), testAttachment.ID); prunedAttachment != nil {
return !*prunedAttachment.Cached
}
return false
@@ -74,7 +73,7 @@ func (suite *MediaCleanupTestSuite) TestMediaCleanupNoArg() {
suite.Equal(http.StatusOK, recorder.Code)
if !testrig.WaitFor(func() bool {
- if prunedAttachment, _ := suite.db.GetAttachmentByID(context.Background(), testAttachment.ID); prunedAttachment != nil {
+ if prunedAttachment, _ := suite.db.GetAttachmentByID(suite.T().Context(), testAttachment.ID); prunedAttachment != nil {
return !*prunedAttachment.Cached
}
return false
@@ -101,7 +100,7 @@ func (suite *MediaCleanupTestSuite) TestMediaCleanupNotOldEnough() {
time.Sleep(1 * time.Second)
// Get media we pruned
- prunedAttachment, err := suite.db.GetAttachmentByID(context.Background(), testAttachment.ID)
+ prunedAttachment, err := suite.db.GetAttachmentByID(suite.T().Context(), testAttachment.ID)
suite.NoError(err)
// the media should still be cached
diff --git a/internal/api/client/bookmarks/bookmarks_test.go b/internal/api/client/bookmarks/bookmarks_test.go
index 9210d6f1c..f056a05b5 100644
--- a/internal/api/client/bookmarks/bookmarks_test.go
+++ b/internal/api/client/bookmarks/bookmarks_test.go
@@ -18,7 +18,6 @@
package bookmarks_test
import (
- "context"
"encoding/json"
"fmt"
"io/ioutil"
@@ -198,7 +197,7 @@ func (suite *BookmarkTestSuite) TestGetBookmarksMultiple() {
testUser := suite.testUsers["local_account_1"]
// Add a few extra bookmarks for this account.
- ctx := context.Background()
+ ctx := suite.T().Context()
for _, b := range []*gtsmodel.StatusBookmark{
{
ID: "01GSZPDQYE9WZ26T501KMM876V", // oldest
@@ -239,7 +238,7 @@ func (suite *BookmarkTestSuite) TestGetBookmarksMultiplePaging() {
testUser := suite.testUsers["local_account_1"]
// Add a few extra bookmarks for this account.
- ctx := context.Background()
+ ctx := suite.T().Context()
for _, b := range []*gtsmodel.StatusBookmark{
{
ID: "01GSZPDQYE9WZ26T501KMM876V", // oldest
@@ -280,7 +279,7 @@ func (suite *BookmarkTestSuite) TestGetBookmarksNone() {
testUser := suite.testUsers["local_account_1"]
// Remove all bookmarks for this account.
- if err := suite.db.DeleteStatusBookmarks(context.Background(), "", testAccount.ID); err != nil {
+ if err := suite.db.DeleteStatusBookmarks(suite.T().Context(), "", testAccount.ID); err != nil {
suite.FailNow(err.Error())
}
@@ -299,7 +298,7 @@ func (suite *BookmarkTestSuite) TestGetBookmarksNonexistentStatus() {
testUser := suite.testUsers["local_account_1"]
// Add a few extra bookmarks for this account.
- ctx := context.Background()
+ ctx := suite.T().Context()
for _, b := range []*gtsmodel.StatusBookmark{
{
ID: "01GSZPDQYE9WZ26T501KMM876V", // oldest
diff --git a/internal/api/client/filters/v1/filter_test.go b/internal/api/client/filters/v1/filter_test.go
index df182493e..7beb9313a 100644
--- a/internal/api/client/filters/v1/filter_test.go
+++ b/internal/api/client/filters/v1/filter_test.go
@@ -115,7 +115,7 @@ func (suite *FiltersTestSuite) TearDownTest() {
}
func (suite *FiltersTestSuite) openHomeStream(account *gtsmodel.Account) *stream.Stream {
- stream, err := suite.processor.Stream().Open(context.Background(), account, stream.TimelineHome)
+ stream, err := suite.processor.Stream().Open(suite.T().Context(), account, stream.TimelineHome)
if err != nil {
suite.FailNow(err.Error())
}
@@ -129,7 +129,7 @@ func (suite *FiltersTestSuite) checkStreamed(
expectEventType string,
) {
// Set a 5s timeout on context.
- ctx := context.Background()
+ ctx := suite.T().Context()
ctx, cncl := context.WithTimeout(ctx, time.Second*5)
defer cncl()
diff --git a/internal/api/client/filters/v2/filter_test.go b/internal/api/client/filters/v2/filter_test.go
index 038205460..6e9e4ef07 100644
--- a/internal/api/client/filters/v2/filter_test.go
+++ b/internal/api/client/filters/v2/filter_test.go
@@ -114,7 +114,7 @@ func (suite *FiltersTestSuite) TearDownTest() {
}
func (suite *FiltersTestSuite) openHomeStream(account *gtsmodel.Account) *stream.Stream {
- stream, err := suite.processor.Stream().Open(context.Background(), account, stream.TimelineHome)
+ stream, err := suite.processor.Stream().Open(suite.T().Context(), account, stream.TimelineHome)
if err != nil {
suite.FailNow(err.Error())
}
@@ -128,7 +128,7 @@ func (suite *FiltersTestSuite) checkStreamed(
expectEventType string,
) {
// Set a 5s timeout on context.
- ctx := context.Background()
+ ctx := suite.T().Context()
ctx, cncl := context.WithTimeout(ctx, time.Second*5)
defer cncl()
diff --git a/internal/api/client/followedtags/get_test.go b/internal/api/client/followedtags/get_test.go
index 41a8b43d8..1f4f21cff 100644
--- a/internal/api/client/followedtags/get_test.go
+++ b/internal/api/client/followedtags/get_test.go
@@ -18,7 +18,6 @@
package followedtags_test
import (
- "context"
"encoding/json"
"io"
"net/http"
@@ -94,7 +93,7 @@ func (suite *FollowedTagsTestSuite) TestGet() {
testTag := suite.testTags["welcome"]
// Follow an existing tag.
- if err := suite.db.PutFollowedTag(context.Background(), testAccount.ID, testTag.ID); err != nil {
+ if err := suite.db.PutFollowedTag(suite.T().Context(), testAccount.ID, testTag.ID); err != nil {
suite.FailNow(err.Error())
}
diff --git a/internal/api/client/followrequests/authorize_test.go b/internal/api/client/followrequests/authorize_test.go
index 712263e86..0f938434e 100644
--- a/internal/api/client/followrequests/authorize_test.go
+++ b/internal/api/client/followrequests/authorize_test.go
@@ -19,7 +19,6 @@ package followrequests_test
import (
"bytes"
- "context"
"encoding/json"
"fmt"
"io/ioutil"
@@ -52,7 +51,7 @@ func (suite *AuthorizeTestSuite) TestAuthorize() {
TargetAccountID: targetAccount.ID,
}
- err := suite.db.Put(context.Background(), fr)
+ err := suite.db.Put(suite.T().Context(), fr)
suite.NoError(err)
recorder := httptest.NewRecorder()
diff --git a/internal/api/client/followrequests/get_test.go b/internal/api/client/followrequests/get_test.go
index ad0fc839d..2589aba36 100644
--- a/internal/api/client/followrequests/get_test.go
+++ b/internal/api/client/followrequests/get_test.go
@@ -19,7 +19,6 @@ package followrequests_test
import (
"bytes"
- "context"
"encoding/json"
"fmt"
"io"
@@ -59,7 +58,7 @@ func (suite *GetTestSuite) TestGet() {
TargetAccountID: targetAccount.ID,
}
- err := suite.db.Put(context.Background(), fr)
+ err := suite.db.Put(suite.T().Context(), fr)
suite.NoError(err)
recorder := httptest.NewRecorder()
@@ -134,7 +133,7 @@ func (suite *GetTestSuite) TestGetPageOldestToNewestLimit6() {
}
func (suite *GetTestSuite) testGetPage(limit int, direction string) {
- ctx := context.Background()
+ ctx := suite.T().Context()
// The authed local account we are going to use for HTTP requests
requestingAccount := suite.testAccounts["local_account_1"]
@@ -312,19 +311,19 @@ func (suite *GetTestSuite) testGetPage(limit int, direction string) {
func (suite *GetTestSuite) clearAccountRelations(id string) {
// Esnure no account blocks exist between accounts.
_ = suite.db.DeleteAccountBlocks(
- context.Background(),
+ suite.T().Context(),
id,
)
// Ensure no account follows exist between accounts.
_ = suite.db.DeleteAccountFollows(
- context.Background(),
+ suite.T().Context(),
id,
)
// Ensure no account follow_requests exist between accounts.
_ = suite.db.DeleteAccountFollowRequests(
- context.Background(),
+ suite.T().Context(),
id,
)
}
diff --git a/internal/api/client/followrequests/reject_test.go b/internal/api/client/followrequests/reject_test.go
index 3d5f93286..9ef6dd34a 100644
--- a/internal/api/client/followrequests/reject_test.go
+++ b/internal/api/client/followrequests/reject_test.go
@@ -19,7 +19,6 @@ package followrequests_test
import (
"bytes"
- "context"
"encoding/json"
"fmt"
"io/ioutil"
@@ -52,7 +51,7 @@ func (suite *RejectTestSuite) TestReject() {
TargetAccountID: targetAccount.ID,
}
- err := suite.db.Put(context.Background(), fr)
+ err := suite.db.Put(suite.T().Context(), fr)
suite.NoError(err)
recorder := httptest.NewRecorder()
diff --git a/internal/api/client/import/import_test.go b/internal/api/client/import/import_test.go
index d6abcf242..ed4b07e39 100644
--- a/internal/api/client/import/import_test.go
+++ b/internal/api/client/import/import_test.go
@@ -19,7 +19,6 @@ package importdata_test
import (
"bytes"
- "context"
"io"
"net/http"
"net/http/httptest"
@@ -144,7 +143,7 @@ func (suite *ImportTestSuite) TearDownTest() {
func (suite *ImportTestSuite) TestImportFollows() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testAccount = suite.testAccounts["local_account_1"]
)
@@ -199,7 +198,7 @@ admin@localhost:8080,true
func (suite *ImportTestSuite) TestImportMutes() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testAccount = suite.testAccounts["local_account_1"]
)
diff --git a/internal/api/client/instance/instancepatch_test.go b/internal/api/client/instance/instancepatch_test.go
index 1139ac6d2..dc3eb84b1 100644
--- a/internal/api/client/instance/instancepatch_test.go
+++ b/internal/api/client/instance/instancepatch_test.go
@@ -19,7 +19,6 @@ package instance_test
import (
"bytes"
- "context"
"encoding/json"
"io"
"net/http"
@@ -721,7 +720,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch8() {
suite.FailNow(err.Error())
}
- instanceAccount, err := suite.db.GetInstanceAccount(context.Background(), "")
+ instanceAccount, err := suite.db.GetInstanceAccount(suite.T().Context(), "")
if err != nil {
suite.FailNow(err.Error())
}
@@ -859,7 +858,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch8() {
}`, dst.String())
// extra bonus: check the v2 model thumbnail after the patch
- instanceV2, err := suite.processor.InstanceGetV2(context.Background())
+ instanceV2, err := suite.processor.InstanceGetV2(suite.T().Context())
if err != nil {
suite.FailNow(err.Error())
}
diff --git a/internal/api/client/instance/instancepeersget_test.go b/internal/api/client/instance/instancepeersget_test.go
index 3c7f1f665..18d4761ac 100644
--- a/internal/api/client/instance/instancepeersget_test.go
+++ b/internal/api/client/instance/instancepeersget_test.go
@@ -19,7 +19,6 @@ package instance_test
import (
"bytes"
- "context"
"encoding/json"
"fmt"
"io"
@@ -249,7 +248,7 @@ func (suite *InstancePeersGetTestSuite) TestInstancePeersGetAllowed() {
}
func (suite *InstancePeersGetTestSuite) TestInstancePeersGetAllWithObfuscated() {
- err := suite.db.Put(context.Background(), &gtsmodel.DomainBlock{
+ err := suite.db.Put(suite.T().Context(), &gtsmodel.DomainBlock{
ID: "01G633XTNK51GBADQZFZQDP6WR",
CreatedAt: testrig.TimeMustParse("2021-06-09T12:34:55+02:00"),
UpdatedAt: testrig.TimeMustParse("2021-06-09T12:34:55+02:00"),
@@ -300,7 +299,7 @@ func (suite *InstancePeersGetTestSuite) TestInstancePeersGetAllWithObfuscated()
}
func (suite *InstancePeersGetTestSuite) TestInstancePeersGetAllWithObfuscatedFlat() {
- err := suite.db.Put(context.Background(), &gtsmodel.DomainBlock{
+ err := suite.db.Put(suite.T().Context(), &gtsmodel.DomainBlock{
ID: "01G633XTNK51GBADQZFZQDP6WR",
CreatedAt: testrig.TimeMustParse("2021-06-09T12:34:55+02:00"),
UpdatedAt: testrig.TimeMustParse("2021-06-09T12:34:55+02:00"),
diff --git a/internal/api/client/lists/listaccountsadd_test.go b/internal/api/client/lists/listaccountsadd_test.go
index 354019f46..036a81d4c 100644
--- a/internal/api/client/lists/listaccountsadd_test.go
+++ b/internal/api/client/lists/listaccountsadd_test.go
@@ -19,7 +19,6 @@ package lists_test
import (
"bytes"
- "context"
"fmt"
"io"
"net/http"
@@ -106,7 +105,7 @@ func (suite *ListAccountsAddTestSuite) TestPostListAccountOK() {
// Remove turtle from the list.
if err := suite.db.DeleteListEntry(
- context.Background(),
+ suite.T().Context(),
entry.ListID,
entry.FollowID,
); err != nil {
diff --git a/internal/api/client/mutes/mutesget_test.go b/internal/api/client/mutes/mutesget_test.go
index 978c1a845..e53ab364a 100644
--- a/internal/api/client/mutes/mutesget_test.go
+++ b/internal/api/client/mutes/mutesget_test.go
@@ -18,7 +18,6 @@
package mutes_test
import (
- "context"
"encoding/json"
"io"
"net/http"
@@ -96,7 +95,7 @@ func (suite *MutesTestSuite) TestGetMutedAccounts() {
AccountID: suite.testAccounts["local_account_1"].ID,
TargetAccountID: suite.testAccounts["local_account_2"].ID,
}
- err := suite.db.PutMute(context.Background(), mute1)
+ err := suite.db.PutMute(suite.T().Context(), mute1)
if err != nil {
suite.FailNow(err.Error())
}
@@ -107,7 +106,7 @@ func (suite *MutesTestSuite) TestGetMutedAccounts() {
AccountID: suite.testAccounts["local_account_1"].ID,
TargetAccountID: suite.testAccounts["remote_account_1"].ID,
}
- err = suite.db.PutMute(context.Background(), mute2)
+ err = suite.db.PutMute(suite.T().Context(), mute2)
if err != nil {
suite.FailNow(err.Error())
}
@@ -141,7 +140,7 @@ func (suite *MutesTestSuite) TestIndefinitelyMutedAccountSerializesMuteExpiratio
AccountID: suite.testAccounts["local_account_1"].ID,
TargetAccountID: suite.testAccounts["remote_account_1"].ID,
}
- err := suite.db.PutMute(context.Background(), mute)
+ err := suite.db.PutMute(suite.T().Context(), mute)
if err != nil {
suite.FailNow(err.Error())
}
diff --git a/internal/api/client/notifications/notificationsget_test.go b/internal/api/client/notifications/notificationsget_test.go
index 78e746f79..9032d6322 100644
--- a/internal/api/client/notifications/notificationsget_test.go
+++ b/internal/api/client/notifications/notificationsget_test.go
@@ -18,7 +18,6 @@
package notifications_test
import (
- "context"
"encoding/json"
"io"
"net/http"
@@ -164,7 +163,7 @@ func (suite *NotificationsTestSuite) addMoreNotifications(testAccount *gtsmodel.
OriginAccountID: suite.testAccounts["remote_account_2"].ID,
},
} {
- if err := suite.db.Put(context.Background(), b); err != nil {
+ if err := suite.db.Put(suite.T().Context(), b); err != nil {
suite.FailNow(err.Error())
}
}
diff --git a/internal/api/client/search/searchget_test.go b/internal/api/client/search/searchget_test.go
index b978c0d3f..651d5301d 100644
--- a/internal/api/client/search/searchget_test.go
+++ b/internal/api/client/search/searchget_test.go
@@ -18,7 +18,6 @@
package search_test
import (
- "context"
"crypto/rand"
"crypto/rsa"
"encoding/json"
@@ -160,7 +159,7 @@ func (suite *SearchGetTestSuite) bodgeLocalInstance(domain string) {
// Set username of instance account to given domain.
instanceAccount.Username = domain
- if err := suite.db.UpdateAccount(context.Background(), instanceAccount, "username"); err != nil {
+ if err := suite.db.UpdateAccount(suite.T().Context(), instanceAccount, "username"); err != nil {
suite.FailNow(err.Error())
}
}
@@ -1389,7 +1388,7 @@ func (suite *SearchGetTestSuite) TestSearchRemoteInstanceAccountPartial() {
suite.FailNow(err.Error())
}
- if err := suite.db.PutAccount(context.Background(), &gtsmodel.Account{
+ if err := suite.db.PutAccount(suite.T().Context(), &gtsmodel.Account{
ID: "01H6RWPG8T6DNW6VNXPBCJBH5S",
Username: theirDomain,
Domain: theirDomain,
@@ -1724,7 +1723,7 @@ func (suite *SearchGetTestSuite) TestSearchBlockedAccountFullNamestring() {
// Block the account
// we're about to search.
if err := suite.db.PutBlock(
- context.Background(),
+ suite.T().Context(),
&gtsmodel.Block{
ID: id.NewULID(),
URI: "https://example.org/nooooooo",
@@ -1788,7 +1787,7 @@ func (suite *SearchGetTestSuite) TestSearchBlockedAccountPartialNamestring() {
// Block the account
// we're about to search.
if err := suite.db.PutBlock(
- context.Background(),
+ suite.T().Context(),
&gtsmodel.Block{
ID: id.NewULID(),
URI: "https://example.org/nooooooo",
@@ -1849,7 +1848,7 @@ func (suite *SearchGetTestSuite) TestSearchBlockedAccountURI() {
// Block the account
// we're about to search.
if err := suite.db.PutBlock(
- context.Background(),
+ suite.T().Context(),
&gtsmodel.Block{
ID: id.NewULID(),
URI: "https://example.org/nooooooo",
diff --git a/internal/api/client/statuses/statusboost_test.go b/internal/api/client/statuses/statusboost_test.go
index abbe4857b..a108c436c 100644
--- a/internal/api/client/statuses/statusboost_test.go
+++ b/internal/api/client/statuses/statusboost_test.go
@@ -16,7 +16,6 @@
package statuses_test
import (
- "context"
"net/http"
"net/http/httptest"
"strings"
@@ -499,7 +498,7 @@ func (suite *StatusBoostTestSuite) TestPostUnboostable() {
func (suite *StatusBoostTestSuite) TestPostNotVisible() {
// Stop local_account_2 following zork.
err := suite.db.DeleteFollowByID(
- context.Background(),
+ suite.T().Context(),
suite.testFollows["local_account_2_local_account_1"].ID,
)
if err != nil {
@@ -714,7 +713,7 @@ func (suite *StatusBoostTestSuite) TestPostBoostImplicitAccept() {
// Target status should no
// longer be pending approval.
dbStatus, err := suite.state.DB.GetStatusByID(
- context.Background(),
+ suite.T().Context(),
targetStatus.ID,
)
if err != nil {
@@ -725,7 +724,7 @@ func (suite *StatusBoostTestSuite) TestPostBoostImplicitAccept() {
// There should be an Accept
// stored for the target status.
intReq, err := suite.state.DB.GetInteractionRequestByInteractionURI(
- context.Background(), targetStatus.URI,
+ suite.T().Context(), targetStatus.URI,
)
if err != nil {
suite.FailNow(err.Error())
diff --git a/internal/api/client/statuses/statuscreate_test.go b/internal/api/client/statuses/statuscreate_test.go
index 60069d362..548eced29 100644
--- a/internal/api/client/statuses/statuscreate_test.go
+++ b/internal/api/client/statuses/statuscreate_test.go
@@ -19,7 +19,6 @@ package statuses_test
import (
"bytes"
- "context"
"encoding/json"
"fmt"
"io"
@@ -671,7 +670,7 @@ func (suite *StatusCreateTestSuite) TestMentionUnknownAccount() {
// so it gets looked up again when we mention it.
remoteAccount := suite.testAccounts["remote_account_1"]
if err := suite.db.DeleteAccount(
- context.Background(),
+ suite.T().Context(),
remoteAccount.ID,
); err != nil {
suite.FailNow(err.Error())
diff --git a/internal/api/client/statuses/statusfave_test.go b/internal/api/client/statuses/statusfave_test.go
index 11c03cc5b..515b66a3c 100644
--- a/internal/api/client/statuses/statusfave_test.go
+++ b/internal/api/client/statuses/statusfave_test.go
@@ -18,7 +18,6 @@
package statuses_test
import (
- "context"
"net/http"
"net/http/httptest"
"strings"
@@ -203,7 +202,7 @@ func (suite *StatusFaveTestSuite) TestPostUnfaveable() {
// Fave a status that's pending approval by us.
func (suite *StatusFaveTestSuite) TestPostFaveImplicitAccept() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
targetStatus = suite.testStatuses["admin_account_status_5"]
app = suite.testApplications["application_1"]
token = suite.testTokens["local_account_2"]
diff --git a/internal/api/client/statuses/statuspin_test.go b/internal/api/client/statuses/statuspin_test.go
index 87650dd43..cbefb3977 100644
--- a/internal/api/client/statuses/statuspin_test.go
+++ b/internal/api/client/statuses/statuspin_test.go
@@ -18,7 +18,6 @@
package statuses_test
import (
- "context"
"encoding/json"
"io/ioutil"
"net/http"
@@ -135,7 +134,7 @@ func (suite *StatusPinTestSuite) TestPinStatusTwiceError() {
testAccount := new(gtsmodel.Account)
*testAccount = *suite.testAccounts["local_account_1"]
- if err := suite.db.UpdateStatus(context.Background(), targetStatus, "pinned_at"); err != nil {
+ if err := suite.db.UpdateStatus(suite.T().Context(), targetStatus, "pinned_at"); err != nil {
suite.FailNow(err.Error())
}
@@ -171,7 +170,7 @@ func (suite *StatusPinTestSuite) TestPinStatusTooManyPins() {
*testAccount = *suite.testAccounts["local_account_1"]
// Spam 10 pinned statuses into the database.
- ctx := context.Background()
+ ctx := suite.T().Context()
for i := range make([]interface{}, 10) {
status := &gtsmodel.Status{
ID: id.NewULID(),
diff --git a/internal/api/client/tags/follow_test.go b/internal/api/client/tags/follow_test.go
index 87f903452..ad58c4daa 100644
--- a/internal/api/client/tags/follow_test.go
+++ b/internal/api/client/tags/follow_test.go
@@ -18,7 +18,6 @@
package tags_test
import (
- "context"
"net/http"
"code.superseriousbusiness.org/gotosocial/internal/api/client/tags"
@@ -65,7 +64,7 @@ func (suite *TagsTestSuite) TestFollowIdempotent() {
testTag := suite.testTags["welcome"]
// Setup: follow an existing tag.
- if err := suite.db.PutFollowedTag(context.Background(), testAccount.ID, testTag.ID); err != nil {
+ if err := suite.db.PutFollowedTag(suite.T().Context(), testAccount.ID, testTag.ID); err != nil {
suite.FailNow(err.Error())
}
diff --git a/internal/api/client/tags/get_test.go b/internal/api/client/tags/get_test.go
index d8052822e..3b068c5de 100644
--- a/internal/api/client/tags/get_test.go
+++ b/internal/api/client/tags/get_test.go
@@ -18,7 +18,6 @@
package tags_test
import (
- "context"
"net/http"
"code.superseriousbusiness.org/gotosocial/internal/api/client/tags"
@@ -50,7 +49,7 @@ func (suite *TagsTestSuite) TestGetFollowed() {
testTag := suite.testTags["welcome"]
// Setup: follow an existing tag.
- if err := suite.db.PutFollowedTag(context.Background(), testAccount.ID, testTag.ID); err != nil {
+ if err := suite.db.PutFollowedTag(suite.T().Context(), testAccount.ID, testTag.ID); err != nil {
suite.FailNow(err.Error())
}
diff --git a/internal/api/client/tags/unfollow_test.go b/internal/api/client/tags/unfollow_test.go
index 5b748a8aa..188840773 100644
--- a/internal/api/client/tags/unfollow_test.go
+++ b/internal/api/client/tags/unfollow_test.go
@@ -18,7 +18,6 @@
package tags_test
import (
- "context"
"net/http"
"code.superseriousbusiness.org/gotosocial/internal/api/client/tags"
@@ -49,7 +48,7 @@ func (suite *TagsTestSuite) TestUnfollow() {
testTag := suite.testTags["welcome"]
// Setup: follow an existing tag.
- if err := suite.db.PutFollowedTag(context.Background(), testAccount.ID, testTag.ID); err != nil {
+ if err := suite.db.PutFollowedTag(suite.T().Context(), testAccount.ID, testTag.ID); err != nil {
suite.FailNow(err.Error())
}
diff --git a/internal/api/client/tokens/tokeninvalidate_test.go b/internal/api/client/tokens/tokeninvalidate_test.go
index 2e726bd50..6a8867cf5 100644
--- a/internal/api/client/tokens/tokeninvalidate_test.go
+++ b/internal/api/client/tokens/tokeninvalidate_test.go
@@ -18,7 +18,6 @@
package tokens_test
import (
- "context"
"net/http"
"testing"
@@ -58,7 +57,7 @@ func (suite *TokenInvalidateTestSuite) TestTokenInvalidate() {
// Check database for token we
// just invalidated, should be gone.
_, err := suite.testStructs.State.DB.GetTokenByID(
- context.Background(), testToken.ID,
+ suite.T().Context(), testToken.ID,
)
suite.ErrorIs(err, db.ErrNoEntries)
}
diff --git a/internal/api/client/user/passwordchange_test.go b/internal/api/client/user/passwordchange_test.go
index 8fee821c0..4cf746400 100644
--- a/internal/api/client/user/passwordchange_test.go
+++ b/internal/api/client/user/passwordchange_test.go
@@ -18,7 +18,6 @@
package user_test
import (
- "context"
"io"
"net/http"
"testing"
@@ -45,7 +44,7 @@ func (suite *PasswordChangeTestSuite) TestPasswordChangePOST() {
suite.EqualValues(http.StatusOK, code)
dbUser := &gtsmodel.User{}
- err := suite.db.GetByID(context.Background(), suite.testUsers["local_account_1"].ID, dbUser)
+ err := suite.db.GetByID(suite.T().Context(), suite.testUsers["local_account_1"].ID, dbUser)
if err != nil {
suite.FailNow(err.Error())
}