[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
parent ec4d4d0115
commit d5c9c4adc1
175 changed files with 857 additions and 1004 deletions

View File

@@ -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)
}

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)
}

View File

@@ -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)
}

View File

@@ -1,7 +1,6 @@
package auth_test
import (
"context"
"fmt"
"net/http"
"testing"
@@ -93,9 +92,9 @@ func (suite *AuthAuthorizeTestSuite) TestAccountAuthorizeHandler() {
testCase.description = fmt.Sprintf("%s, %t, %s", user.Email, *user.Disabled, account.SuspendedAt)
err := suite.db.UpdateUser(context.Background(), user, columns...)
err := suite.db.UpdateUser(suite.T().Context(), user, columns...)
suite.NoError(err)
err = suite.db.UpdateAccount(context.Background(), account)
err = suite.db.UpdateAccount(suite.T().Context(), account)
suite.NoError(err)
// call the handler

View File

@@ -19,7 +19,6 @@ package auth_test
import (
"bytes"
"context"
"encoding/json"
"io"
"net/http"
@@ -71,7 +70,7 @@ func (suite *RevokeTestSuite) TestRevokeOK() {
// Ensure token now gone.
_, err = suite.state.DB.GetTokenByAccess(
context.Background(),
suite.T().Context(),
token.Access,
)
suite.ErrorIs(err, db.ErrNoEntries)
@@ -130,7 +129,7 @@ func (suite *RevokeTestSuite) TestRevokeWrongSecret() {
// Ensure token still there.
_, err = suite.state.DB.GetTokenByAccess(
context.Background(),
suite.T().Context(),
token.Access,
)
suite.NoError(err)
@@ -188,7 +187,7 @@ func (suite *RevokeTestSuite) TestRevokeNoClientID() {
// Ensure token still there.
_, err = suite.state.DB.GetTokenByAccess(
context.Background(),
suite.T().Context(),
token.Access,
)
suite.NoError(err)

View File

@@ -18,7 +18,6 @@
package auth_test
import (
"context"
"encoding/json"
"io"
"net/http"
@@ -93,7 +92,7 @@ func (suite *TokenTestSuite) TestRetrieveClientCredentialsOK() {
// there should be a token in the database now too
dbToken := &gtsmodel.Token{}
err = suite.db.GetWhere(context.Background(), []db.Where{{Key: "access", Value: t.AccessToken}}, dbToken)
err = suite.db.GetWhere(suite.T().Context(), []db.Where{{Key: "access", Value: t.AccessToken}}, dbToken)
suite.NoError(err)
suite.NotNil(dbToken)
}
@@ -204,7 +203,7 @@ func (suite *TokenTestSuite) TestRetrieveAuthorizationCodeOK() {
suite.WithinDuration(time.Now(), time.Unix(t.CreatedAt, 0), 1*time.Minute)
dbToken := &gtsmodel.Token{}
err = suite.db.GetWhere(context.Background(), []db.Where{{Key: "access", Value: t.AccessToken}}, dbToken)
err = suite.db.GetWhere(suite.T().Context(), []db.Where{{Key: "access", Value: t.AccessToken}}, dbToken)
suite.NoError(err)
suite.NotNil(dbToken)
}

View File

@@ -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())
}

View File

@@ -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,
)
}

View File

@@ -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",

View File

@@ -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

View File

@@ -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)
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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()

View File

@@ -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()

View File

@@ -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())
}

View File

@@ -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()

View File

@@ -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,
)
}

View File

@@ -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()

View File

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

View File

@@ -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())
}

View File

@@ -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"),

View File

@@ -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 {

View File

@@ -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())
}

View File

@@ -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())
}
}

View File

@@ -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",

View File

@@ -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())

View File

@@ -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())

View File

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

View File

@@ -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(),

View File

@@ -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())
}

View File

@@ -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())
}

View File

@@ -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())
}

View File

@@ -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)
}

View File

@@ -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())
}

View File

@@ -18,7 +18,6 @@
package fileserver_test
import (
"context"
"io"
"net/http"
"net/http/httptest"
@@ -74,7 +73,7 @@ func (suite *ServeFileTestSuite) GetFile(
// UncacheAttachment is a convenience function that uncaches the targetAttachment by
// removing its associated files from storage, and updating the database.
func (suite *ServeFileTestSuite) UncacheAttachment(targetAttachment *gtsmodel.MediaAttachment) {
ctx := context.Background()
ctx := suite.T().Context()
cached := false
targetAttachment.Cached = &cached
@@ -93,7 +92,7 @@ func (suite *ServeFileTestSuite) UncacheAttachment(targetAttachment *gtsmodel.Me
func (suite *ServeFileTestSuite) TestServeOriginalLocalFileOK() {
targetAttachment := &gtsmodel.MediaAttachment{}
*targetAttachment = *suite.testAttachments["admin_account_status_1_attachment_1"]
fileInStorage, err := suite.storage.Get(context.Background(), targetAttachment.File.Path)
fileInStorage, err := suite.storage.Get(suite.T().Context(), targetAttachment.File.Path)
if err != nil {
suite.FailNow(err.Error())
}
@@ -113,7 +112,7 @@ func (suite *ServeFileTestSuite) TestServeOriginalLocalFileOK() {
func (suite *ServeFileTestSuite) TestServeSmallLocalFileOK() {
targetAttachment := &gtsmodel.MediaAttachment{}
*targetAttachment = *suite.testAttachments["admin_account_status_1_attachment_1"]
fileInStorage, err := suite.storage.Get(context.Background(), targetAttachment.Thumbnail.Path)
fileInStorage, err := suite.storage.Get(suite.T().Context(), targetAttachment.Thumbnail.Path)
if err != nil {
suite.FailNow(err.Error())
}
@@ -133,7 +132,7 @@ func (suite *ServeFileTestSuite) TestServeSmallLocalFileOK() {
func (suite *ServeFileTestSuite) TestServeOriginalRemoteFileOK() {
targetAttachment := &gtsmodel.MediaAttachment{}
*targetAttachment = *suite.testAttachments["remote_account_1_status_1_attachment_1"]
fileInStorage, err := suite.storage.Get(context.Background(), targetAttachment.File.Path)
fileInStorage, err := suite.storage.Get(suite.T().Context(), targetAttachment.File.Path)
if err != nil {
suite.FailNow(err.Error())
}
@@ -153,7 +152,7 @@ func (suite *ServeFileTestSuite) TestServeOriginalRemoteFileOK() {
func (suite *ServeFileTestSuite) TestServeSmallRemoteFileOK() {
targetAttachment := &gtsmodel.MediaAttachment{}
*targetAttachment = *suite.testAttachments["remote_account_1_status_1_attachment_1"]
fileInStorage, err := suite.storage.Get(context.Background(), targetAttachment.Thumbnail.Path)
fileInStorage, err := suite.storage.Get(suite.T().Context(), targetAttachment.Thumbnail.Path)
if err != nil {
suite.FailNow(err.Error())
}
@@ -173,7 +172,7 @@ func (suite *ServeFileTestSuite) TestServeSmallRemoteFileOK() {
func (suite *ServeFileTestSuite) TestServeOriginalRemoteFileRecache() {
targetAttachment := &gtsmodel.MediaAttachment{}
*targetAttachment = *suite.testAttachments["remote_account_1_status_1_attachment_1"]
fileInStorage, err := suite.storage.Get(context.Background(), targetAttachment.File.Path)
fileInStorage, err := suite.storage.Get(suite.T().Context(), targetAttachment.File.Path)
if err != nil {
suite.FailNow(err.Error())
}
@@ -196,7 +195,7 @@ func (suite *ServeFileTestSuite) TestServeOriginalRemoteFileRecache() {
func (suite *ServeFileTestSuite) TestServeSmallRemoteFileRecache() {
targetAttachment := &gtsmodel.MediaAttachment{}
*targetAttachment = *suite.testAttachments["remote_account_1_status_1_attachment_1"]
fileInStorage, err := suite.storage.Get(context.Background(), targetAttachment.Thumbnail.Path)
fileInStorage, err := suite.storage.Get(suite.T().Context(), targetAttachment.Thumbnail.Path)
if err != nil {
suite.FailNow(err.Error())
}
@@ -223,7 +222,7 @@ func (suite *ServeFileTestSuite) TestServeOriginalRemoteFileRecacheNotFound() {
// uncache the attachment *and* set the remote URL to something that will return a 404
suite.UncacheAttachment(targetAttachment)
targetAttachment.RemoteURL = "http://nothing.at.this.url/weeeeeeeee"
if err := suite.db.UpdateByID(context.Background(), targetAttachment, targetAttachment.ID, "remote_url"); err != nil {
if err := suite.db.UpdateByID(suite.T().Context(), targetAttachment, targetAttachment.ID, "remote_url"); err != nil {
suite.FailNow(err.Error())
}
@@ -244,7 +243,7 @@ func (suite *ServeFileTestSuite) TestServeSmallRemoteFileRecacheNotFound() {
// uncache the attachment *and* set the remote URL to something that will return a 404
suite.UncacheAttachment(targetAttachment)
targetAttachment.RemoteURL = "http://nothing.at.this.url/weeeeeeeee"
if err := suite.db.UpdateByID(context.Background(), targetAttachment, targetAttachment.ID, "remote_url"); err != nil {
if err := suite.db.UpdateByID(suite.T().Context(), targetAttachment, targetAttachment.ID, "remote_url"); err != nil {
suite.FailNow(err.Error())
}

View File

@@ -19,7 +19,6 @@ package webfinger_test
import (
"bytes"
"context"
"crypto/rand"
"crypto/rsa"
"encoding/json"
@@ -129,11 +128,11 @@ func (suite *WebfingerGetTestSuite) funkifyAccountDomain(host string, accountDom
PublicKeyURI: "http://" + host + "/users/new_account_domain_user/main-key",
}
if err := suite.db.PutAccount(context.Background(), targetAccount); err != nil {
if err := suite.db.PutAccount(suite.T().Context(), targetAccount); err != nil {
suite.FailNow(err.Error())
}
if err := suite.db.PutAccountSettings(context.Background(), &gtsmodel.AccountSettings{AccountID: targetAccount.ID}); err != nil {
if err := suite.db.PutAccountSettings(suite.T().Context(), &gtsmodel.AccountSettings{AccountID: targetAccount.ID}); err != nil {
suite.FailNow(err.Error())
}