diff --git a/.woodpecker/pr.yaml b/.woodpecker/pr.yaml
index 7a392ad50..6cc08932a 100644
--- a/.woodpecker/pr.yaml
+++ b/.woodpecker/pr.yaml
@@ -22,7 +22,7 @@ steps:
# We use golangci-lint for linting.
# See: https://golangci-lint.run/
- image: golangci/golangci-lint:v1.62.0
+ image: golangci/golangci-lint:v1.64.8
pull: true
# https://woodpecker-ci.org/docs/administration/configuration/backends/docker#run-user
@@ -61,7 +61,7 @@ steps:
any(fromJSON(CI_PIPELINE_FILES), { # startsWith "internal/" || # startsWith "cmd/" || # startsWith "testrig/" || # startsWith "vendor/" }) ||
len(fromJSON(CI_PIPELINE_FILES)) == 0
- image: golang:1.23-alpine
+ image: golang:1.24-alpine
pull: true
# https://woodpecker-ci.org/docs/administration/configuration/backends/docker#run-user
diff --git a/.woodpecker/release.yaml b/.woodpecker/release.yaml
index 23f42cb8f..62673311c 100644
--- a/.woodpecker/release.yaml
+++ b/.woodpecker/release.yaml
@@ -13,7 +13,7 @@ clone:
steps:
release:
# https://codeberg.org/superseriousbusiness/gotosocial-woodpecker-build
- image: superseriousbusiness/gotosocial-woodpecker-build:0.11.0
+ image: superseriousbusiness/gotosocial-woodpecker-build:0.12.0
pull: true
# https://woodpecker-ci.org/docs/usage/volumes
diff --git a/.woodpecker/snapshot.yaml b/.woodpecker/snapshot.yaml
index 17afd96b5..db611e2a2 100644
--- a/.woodpecker/snapshot.yaml
+++ b/.woodpecker/snapshot.yaml
@@ -29,7 +29,7 @@ steps:
len(fromJSON(CI_PIPELINE_FILES)) == 0
# https://codeberg.org/superseriousbusiness/gotosocial-woodpecker-build
- image: superseriousbusiness/gotosocial-woodpecker-build:0.11.0
+ image: superseriousbusiness/gotosocial-woodpecker-build:0.12.0
pull: true
# https://woodpecker-ci.org/docs/usage/volumes
diff --git a/go.mod b/go.mod
index c1042e76c..a51aab638 100644
--- a/go.mod
+++ b/go.mod
@@ -1,8 +1,8 @@
module code.superseriousbusiness.org/gotosocial
-go 1.23.0
+go 1.24
-toolchain go1.23.3
+toolchain go1.24.3
// Replace go-swagger with our version that fixes (ours particularly) use of Go1.23
replace github.com/go-swagger/go-swagger => codeberg.org/superseriousbusiness/go-swagger v0.31.0-gts-go1.23-fix
diff --git a/internal/admin/actions_test.go b/internal/admin/actions_test.go
index 653051612..6d5ddcf9c 100644
--- a/internal/admin/actions_test.go
+++ b/internal/admin/actions_test.go
@@ -49,7 +49,7 @@ func (suite *ActionsTestSuite) SetupSuite() {
func (suite *ActionsTestSuite) TestActionOverlap() {
var (
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
- ctx = context.Background()
+ ctx = suite.T().Context()
)
defer testrig.TearDownTestStructs(testStructs)
@@ -130,7 +130,7 @@ func (suite *ActionsTestSuite) TestActionOverlap() {
func (suite *ActionsTestSuite) TestActionWithErrors() {
var (
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
- ctx = context.Background()
+ ctx = suite.T().Context()
)
defer testrig.TearDownTestStructs(testStructs)
diff --git a/internal/ap/ap_test.go b/internal/ap/ap_test.go
index 06856812c..0956fee66 100644
--- a/internal/ap/ap_test.go
+++ b/internal/ap/ap_test.go
@@ -19,9 +19,9 @@ package ap_test
import (
"bytes"
- "context"
"encoding/json"
"io"
+ "testing"
"code.superseriousbusiness.org/activity/streams"
"code.superseriousbusiness.org/activity/streams/vocab"
@@ -250,7 +250,7 @@ func (suite *APTestSuite) noteWithHashtags1() ap.Statusable {
}`)
statusable, err := ap.ResolveStatusable(
- context.Background(),
+ suite.T().Context(),
io.NopCloser(bytes.NewReader(noteJson)),
)
if err != nil {
@@ -306,7 +306,7 @@ func addressable3() ap.Addressable {
return note
}
-func addressable4() vocab.ActivityStreamsAnnounce {
+func addressable4(t *testing.T) vocab.ActivityStreamsAnnounce {
// https://codeberg.org/superseriousbusiness/gotosocial/issues/267
announceJson := []byte(`
{
@@ -326,12 +326,12 @@ func addressable4() vocab.ActivityStreamsAnnounce {
panic(err)
}
- t, err := streams.ToType(context.Background(), jsonAsMap)
+ typ, err := streams.ToType(t.Context(), jsonAsMap)
if err != nil {
panic(err)
}
- return t.(vocab.ActivityStreamsAnnounce)
+ return typ.(vocab.ActivityStreamsAnnounce)
}
func addressable5() ap.Addressable {
@@ -366,7 +366,7 @@ func (suite *APTestSuite) jsonToType(rawJson string) (vocab.Type, map[string]int
panic(err)
}
- t, err := streams.ToType(context.Background(), raw)
+ t, err := streams.ToType(suite.T().Context(), raw)
if err != nil {
panic(err)
}
@@ -395,7 +395,7 @@ func (suite *APTestSuite) SetupTest() {
suite.addressable1 = addressable1()
suite.addressable2 = addressable2()
suite.addressable3 = addressable3()
- suite.addressable4 = addressable4()
+ suite.addressable4 = addressable4(suite.T())
suite.addressable5 = addressable5()
suite.testAccounts = testrig.NewTestAccounts()
}
diff --git a/internal/ap/extractattachments_test.go b/internal/ap/extractattachments_test.go
index f3af66708..362fa1a05 100644
--- a/internal/ap/extractattachments_test.go
+++ b/internal/ap/extractattachments_test.go
@@ -18,7 +18,6 @@
package ap_test
import (
- "context"
"encoding/json"
"testing"
@@ -59,7 +58,7 @@ func (suite *ExtractAttachmentsTestSuite) TestExtractDescription() {
suite.FailNow(err.Error())
}
- t, err := streams.ToType(context.Background(), raw)
+ t, err := streams.ToType(suite.T().Context(), raw)
if err != nil {
suite.FailNow(err.Error())
}
diff --git a/internal/ap/extractemojis_test.go b/internal/ap/extractemojis_test.go
index eba30b8b8..21bba4219 100644
--- a/internal/ap/extractemojis_test.go
+++ b/internal/ap/extractemojis_test.go
@@ -19,7 +19,6 @@ package ap_test
import (
"bytes"
- "context"
"io"
"testing"
@@ -61,7 +60,7 @@ func (suite *ExtractEmojisTestSuite) TestExtractEmojis() {
}`
statusable, err := ap.ResolveStatusable(
- context.Background(),
+ suite.T().Context(),
io.NopCloser(bytes.NewBufferString(noteWithEmojis)),
)
if err != nil {
@@ -115,7 +114,7 @@ func (suite *ExtractEmojisTestSuite) TestExtractEmojisNoID() {
}`
statusable, err := ap.ResolveStatusable(
- context.Background(),
+ suite.T().Context(),
io.NopCloser(bytes.NewBufferString(noteWithEmojis)),
)
if err != nil {
@@ -170,7 +169,7 @@ func (suite *ExtractEmojisTestSuite) TestExtractEmojisNullID() {
}`
statusable, err := ap.ResolveStatusable(
- context.Background(),
+ suite.T().Context(),
io.NopCloser(bytes.NewBufferString(noteWithEmojis)),
)
if err != nil {
@@ -225,7 +224,7 @@ func (suite *ExtractEmojisTestSuite) TestExtractEmojisEmptyID() {
}`
statusable, err := ap.ResolveStatusable(
- context.Background(),
+ suite.T().Context(),
io.NopCloser(bytes.NewBufferString(noteWithEmojis)),
)
if err != nil {
diff --git a/internal/ap/extractfocus_test.go b/internal/ap/extractfocus_test.go
index e7f922930..3af2daa81 100644
--- a/internal/ap/extractfocus_test.go
+++ b/internal/ap/extractfocus_test.go
@@ -18,7 +18,6 @@
package ap_test
import (
- "context"
"encoding/json"
"fmt"
"testing"
@@ -33,7 +32,7 @@ type ExtractFocusTestSuite struct {
}
func (suite *ExtractFocusTestSuite) TestExtractFocus() {
- ctx := context.Background()
+ ctx := suite.T().Context()
type test struct {
data string
diff --git a/internal/ap/extractpolicy_test.go b/internal/ap/extractpolicy_test.go
index d735b9618..24b198b29 100644
--- a/internal/ap/extractpolicy_test.go
+++ b/internal/ap/extractpolicy_test.go
@@ -19,7 +19,6 @@ package ap_test
import (
"bytes"
- "context"
"io"
"testing"
@@ -86,7 +85,7 @@ func (suite *ExtractPolicyTestSuite) TestExtractPolicy() {
}`
statusable, err := ap.ResolveStatusable(
- context.Background(),
+ suite.T().Context(),
io.NopCloser(
bytes.NewBufferString(rawNote),
),
@@ -186,7 +185,7 @@ func (suite *ExtractPolicyTestSuite) TestExtractPolicyDeprecated() {
}`
statusable, err := ap.ResolveStatusable(
- context.Background(),
+ suite.T().Context(),
io.NopCloser(
bytes.NewBufferString(rawNote),
),
diff --git a/internal/ap/extractpubkey_test.go b/internal/ap/extractpubkey_test.go
index ab4f38a22..c5807cd9d 100644
--- a/internal/ap/extractpubkey_test.go
+++ b/internal/ap/extractpubkey_test.go
@@ -18,7 +18,6 @@
package ap_test
import (
- "context"
"encoding/json"
"testing"
@@ -62,7 +61,7 @@ func (suite *ExtractPubKeyTestSuite) TestExtractPubKeyFromStub() {
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())
}
diff --git a/internal/ap/resolve_test.go b/internal/ap/resolve_test.go
index a5e279fa2..4909a7505 100644
--- a/internal/ap/resolve_test.go
+++ b/internal/ap/resolve_test.go
@@ -19,7 +19,6 @@ package ap_test
import (
"bytes"
- "context"
"io"
"testing"
@@ -36,7 +35,7 @@ func (suite *ResolveTestSuite) TestResolveDocumentAsStatusable() {
b := []byte(suite.typeToJson(suite.document1))
statusable, err := ap.ResolveStatusable(
- context.Background(), io.NopCloser(bytes.NewReader(b)),
+ suite.T().Context(), io.NopCloser(bytes.NewReader(b)),
)
suite.NoError(err)
suite.NotNil(statusable)
@@ -46,7 +45,7 @@ func (suite *ResolveTestSuite) TestResolveDocumentAsAccountable() {
b := []byte(suite.typeToJson(suite.document1))
accountable, err := ap.ResolveAccountable(
- context.Background(), io.NopCloser(bytes.NewReader(b)),
+ suite.T().Context(), io.NopCloser(bytes.NewReader(b)),
)
suite.True(gtserror.IsWrongType(err))
suite.EqualError(err, "ResolveAccountable: cannot resolve vocab type *typedocument.ActivityStreamsDocument as accountable")
@@ -58,7 +57,7 @@ func (suite *ResolveTestSuite) TestResolveHTMLAsAccountable() {
.`)
accountable, err := ap.ResolveAccountable(
- context.Background(), io.NopCloser(bytes.NewReader(b)),
+ suite.T().Context(), io.NopCloser(bytes.NewReader(b)),
)
suite.True(gtserror.IsWrongType(err))
suite.EqualError(err, "ResolveAccountable: error decoding into json: invalid character '<' looking for beginning of value")
@@ -73,7 +72,7 @@ func (suite *ResolveTestSuite) TestResolveNonAPJSONAsAccountable() {
}`)
accountable, err := ap.ResolveAccountable(
- context.Background(), io.NopCloser(bytes.NewReader(b)),
+ suite.T().Context(), io.NopCloser(bytes.NewReader(b)),
)
suite.True(gtserror.IsWrongType(err))
suite.EqualError(err, "ResolveAccountable: error resolving json into ap vocab type: activity stream did not match any known types")
@@ -124,7 +123,7 @@ func (suite *ResolveTestSuite) TestResolveBandwagonAlbumAsStatusable() {
}`)
statusable, err := ap.ResolveStatusable(
- context.Background(), io.NopCloser(bytes.NewReader(b)),
+ suite.T().Context(), io.NopCloser(bytes.NewReader(b)),
)
suite.NoError(err)
suite.NotNil(statusable)
diff --git a/internal/api/activitypub/users/inboxpost_test.go b/internal/api/activitypub/users/inboxpost_test.go
index e00a705a0..81b21eafc 100644
--- a/internal/api/activitypub/users/inboxpost_test.go
+++ b/internal/api/activitypub/users/inboxpost_test.go
@@ -19,7 +19,6 @@ package users_test
import (
"bytes"
- "context"
"encoding/json"
"errors"
"io"
@@ -232,7 +231,7 @@ func (suite *InboxPostTestSuite) TestPostBlock() {
)
if !testrig.WaitFor(func() bool {
- dbBlock, err = suite.db.GetBlock(context.Background(), requestingAccount.ID, targetAccount.ID)
+ dbBlock, err = suite.db.GetBlock(suite.T().Context(), requestingAccount.ID, targetAccount.ID)
return err == nil && dbBlock != nil
}) {
suite.FailNow("timed out waiting for block to be created")
@@ -243,7 +242,7 @@ func (suite *InboxPostTestSuite) TestPostBlock() {
// one of our instance users should be able to undo that block.
func (suite *InboxPostTestSuite) TestPostUnblock() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
requestingAccount = suite.testAccounts["remote_account_1"]
targetAccount = suite.testAccounts["local_account_1"]
blockID = "http://fossbros-anonymous.io/blocks/01H1462TPRTVG2RTQCTSQ7N6Q0"
@@ -315,7 +314,7 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
requestingAccount.Emojis = []*gtsmodel.Emoji{testEmoji}
// Create an update from the account.
- accountable, err := suite.tc.AccountToAS(context.Background(), requestingAccount)
+ accountable, err := suite.tc.AccountToAS(suite.T().Context(), requestingAccount)
if err != nil {
suite.FailNow(err.Error())
}
@@ -344,7 +343,7 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
if !testrig.WaitFor(func() bool {
// displayName should be updated
- dbUpdatedAccount, _ = suite.db.GetAccountByID(context.Background(), requestingAccount.ID)
+ dbUpdatedAccount, _ = suite.db.GetAccountByID(suite.T().Context(), requestingAccount.ID)
return dbUpdatedAccount.DisplayName == updatedDisplayName
}) {
suite.FailNow("timed out waiting for account update")
@@ -399,7 +398,7 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
func (suite *InboxPostTestSuite) TestPostDelete() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
requestingAccount = suite.testAccounts["remote_account_1"]
targetAccount = suite.testAccounts["local_account_1"]
activityID = requestingAccount.URI + "/some-new-activity/01FG9C441MCTW3R2W117V2PQK3"
@@ -517,7 +516,7 @@ func (suite *InboxPostTestSuite) TestPostFromBlockedAccount() {
)
// Create an update from the account.
- accountable, err := suite.tc.AccountToAS(context.Background(), requestingAccount)
+ accountable, err := suite.tc.AccountToAS(suite.T().Context(), requestingAccount)
if err != nil {
suite.FailNow(err.Error())
}
@@ -559,7 +558,7 @@ func (suite *InboxPostTestSuite) TestPostFromBlockedAccountToOtherAccount() {
suite.signatureCheck,
)
- _, err := suite.state.DB.GetStatusByURI(context.Background(), statusURI)
+ _, err := suite.state.DB.GetStatusByURI(suite.T().Context(), statusURI)
suite.ErrorIs(err, db.ErrNoEntries)
}
diff --git a/internal/api/activitypub/users/outboxget_test.go b/internal/api/activitypub/users/outboxget_test.go
index dc9c621a6..1290830b2 100644
--- a/internal/api/activitypub/users/outboxget_test.go
+++ b/internal/api/activitypub/users/outboxget_test.go
@@ -19,7 +19,6 @@ package users_test
import (
"bytes"
- "context"
"encoding/json"
"io/ioutil"
"net/http"
@@ -90,7 +89,7 @@ func (suite *OutboxGetTestSuite) TestGetOutbox() {
err = json.Unmarshal(b, &m)
suite.NoError(err)
- t, err := streams.ToType(context.Background(), m)
+ t, err := streams.ToType(suite.T().Context(), m)
suite.NoError(err)
_, ok := t.(vocab.ActivityStreamsOrderedCollection)
@@ -177,7 +176,7 @@ func (suite *OutboxGetTestSuite) TestGetOutboxFirstPage() {
err = json.Unmarshal(b, &m)
suite.NoError(err)
- t, err := streams.ToType(context.Background(), m)
+ t, err := streams.ToType(suite.T().Context(), m)
suite.NoError(err)
_, ok := t.(vocab.ActivityStreamsOrderedCollectionPage)
@@ -240,7 +239,7 @@ func (suite *OutboxGetTestSuite) TestGetOutboxNextPage() {
err = json.Unmarshal(b, &m)
suite.NoError(err)
- t, err := streams.ToType(context.Background(), m)
+ t, err := streams.ToType(suite.T().Context(), m)
suite.NoError(err)
_, ok := t.(vocab.ActivityStreamsOrderedCollectionPage)
diff --git a/internal/api/activitypub/users/repliesget_test.go b/internal/api/activitypub/users/repliesget_test.go
index 9d2141811..5d3754a8c 100644
--- a/internal/api/activitypub/users/repliesget_test.go
+++ b/internal/api/activitypub/users/repliesget_test.go
@@ -19,7 +19,6 @@ package users_test
import (
"bytes"
- "context"
"encoding/json"
"io"
"net/http"
@@ -101,7 +100,7 @@ func (suite *RepliesGetTestSuite) TestGetReplies() {
err = json.Unmarshal(b, &m)
assert.NoError(suite.T(), err)
- t, err := streams.ToType(context.Background(), m)
+ t, err := streams.ToType(suite.T().Context(), m)
assert.NoError(suite.T(), err)
_, ok := t.(vocab.ActivityStreamsOrderedCollection)
@@ -172,7 +171,7 @@ func (suite *RepliesGetTestSuite) TestGetRepliesNext() {
err = json.Unmarshal(b, &m)
assert.NoError(suite.T(), err)
- t, err := streams.ToType(context.Background(), m)
+ t, err := streams.ToType(suite.T().Context(), m)
assert.NoError(suite.T(), err)
page, ok := t.(vocab.ActivityStreamsOrderedCollectionPage)
@@ -243,7 +242,7 @@ func (suite *RepliesGetTestSuite) TestGetRepliesLast() {
err = json.Unmarshal(b, &m)
assert.NoError(suite.T(), err)
- t, err := streams.ToType(context.Background(), m)
+ t, err := streams.ToType(suite.T().Context(), m)
assert.NoError(suite.T(), err)
page, ok := t.(vocab.ActivityStreamsOrderedCollectionPage)
diff --git a/internal/api/activitypub/users/statusget_test.go b/internal/api/activitypub/users/statusget_test.go
index dc3aef5a7..275acdc02 100644
--- a/internal/api/activitypub/users/statusget_test.go
+++ b/internal/api/activitypub/users/statusget_test.go
@@ -18,7 +18,6 @@
package users_test
import (
- "context"
"encoding/json"
"io/ioutil"
"net/http"
@@ -85,14 +84,14 @@ func (suite *StatusGetTestSuite) TestGetStatus() {
err = json.Unmarshal(b, &m)
suite.NoError(err)
- t, err := streams.ToType(context.Background(), m)
+ t, err := streams.ToType(suite.T().Context(), m)
suite.NoError(err)
note, ok := t.(vocab.ActivityStreamsNote)
suite.True(ok)
// convert note to status
- a, err := suite.tc.ASStatusToStatus(context.Background(), note)
+ a, err := suite.tc.ASStatusToStatus(suite.T().Context(), note)
suite.NoError(err)
suite.EqualValues(targetStatus.Content, a.Content)
}
@@ -144,14 +143,14 @@ func (suite *StatusGetTestSuite) TestGetStatusLowercase() {
err = json.Unmarshal(b, &m)
suite.NoError(err)
- t, err := streams.ToType(context.Background(), m)
+ t, err := streams.ToType(suite.T().Context(), m)
suite.NoError(err)
note, ok := t.(vocab.ActivityStreamsNote)
suite.True(ok)
// convert note to status
- a, err := suite.tc.ASStatusToStatus(context.Background(), note)
+ a, err := suite.tc.ASStatusToStatus(suite.T().Context(), note)
suite.NoError(err)
suite.EqualValues(targetStatus.Content, a.Content)
}
diff --git a/internal/api/activitypub/users/userget_test.go b/internal/api/activitypub/users/userget_test.go
index 06bc46452..a9cba468f 100644
--- a/internal/api/activitypub/users/userget_test.go
+++ b/internal/api/activitypub/users/userget_test.go
@@ -18,7 +18,6 @@
package users_test
import (
- "context"
"encoding/json"
"io/ioutil"
"net/http"
@@ -79,14 +78,14 @@ func (suite *UserGetTestSuite) TestGetUser() {
err = json.Unmarshal(b, &m)
suite.NoError(err)
- t, err := streams.ToType(context.Background(), m)
+ t, err := streams.ToType(suite.T().Context(), m)
suite.NoError(err)
person, ok := t.(vocab.ActivityStreamsPerson)
suite.True(ok)
// convert person to account
- a, err := suite.tc.ASRepresentationToAccount(context.Background(), person, "", "")
+ a, err := suite.tc.ASRepresentationToAccount(suite.T().Context(), person, "", "")
suite.NoError(err)
suite.EqualValues(targetAccount.Username, a.Username)
}
@@ -97,11 +96,11 @@ func (suite *UserGetTestSuite) TestGetUserPublicKeyDeleted() {
userModule := users.New(suite.processor)
targetAccount := suite.testAccounts["local_account_1"]
- suite.processor.User().DeleteSelf(context.Background(), suite.testAccounts["local_account_1"])
+ suite.processor.User().DeleteSelf(suite.T().Context(), suite.testAccounts["local_account_1"])
// wait for the account delete to be processed
if !testrig.WaitFor(func() bool {
- a, _ := suite.db.GetAccountByID(context.Background(), targetAccount.ID)
+ a, _ := suite.db.GetAccountByID(suite.T().Context(), targetAccount.ID)
return !a.SuspendedAt.IsZero()
}) {
suite.FailNow("delete of account timed out")
@@ -147,14 +146,14 @@ func (suite *UserGetTestSuite) TestGetUserPublicKeyDeleted() {
err = json.Unmarshal(b, &m)
suite.NoError(err)
- t, err := streams.ToType(context.Background(), m)
+ t, err := streams.ToType(suite.T().Context(), m)
suite.NoError(err)
person, ok := t.(vocab.ActivityStreamsPerson)
suite.True(ok)
// convert person to account
- a, err := suite.tc.ASRepresentationToAccount(context.Background(), person, "", "")
+ a, err := suite.tc.ASRepresentationToAccount(suite.T().Context(), person, "", "")
suite.NoError(err)
suite.EqualValues(targetAccount.Username, a.Username)
}
diff --git a/internal/api/auth/authorize_test.go b/internal/api/auth/authorize_test.go
index b73f5e0e1..56a05416b 100644
--- a/internal/api/auth/authorize_test.go
+++ b/internal/api/auth/authorize_test.go
@@ -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
diff --git a/internal/api/auth/revoke_test.go b/internal/api/auth/revoke_test.go
index e482c8aac..3af573411 100644
--- a/internal/api/auth/revoke_test.go
+++ b/internal/api/auth/revoke_test.go
@@ -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)
diff --git a/internal/api/auth/token_test.go b/internal/api/auth/token_test.go
index e333a8867..5d1aa4df5 100644
--- a/internal/api/auth/token_test.go
+++ b/internal/api/auth/token_test.go
@@ -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 := >smodel.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 := >smodel.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)
}
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 = >smodel.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 = >smodel.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(), >smodel.DomainBlock{
+ err := suite.db.Put(suite.T().Context(), >smodel.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(), >smodel.DomainBlock{
+ err := suite.db.Put(suite.T().Context(), >smodel.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(), >smodel.Account{
+ if err := suite.db.PutAccount(suite.T().Context(), >smodel.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(),
>smodel.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(),
>smodel.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(),
>smodel.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 := >smodel.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 := >smodel.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())
}
diff --git a/internal/api/fileserver/servefile_test.go b/internal/api/fileserver/servefile_test.go
index cfaa73515..e07c204eb 100644
--- a/internal/api/fileserver/servefile_test.go
+++ b/internal/api/fileserver/servefile_test.go
@@ -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 := >smodel.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 := >smodel.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 := >smodel.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 := >smodel.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 := >smodel.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 := >smodel.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())
}
diff --git a/internal/api/wellknown/webfinger/webfingerget_test.go b/internal/api/wellknown/webfinger/webfingerget_test.go
index a0a8aa22f..0ad35d4d9 100644
--- a/internal/api/wellknown/webfinger/webfingerget_test.go
+++ b/internal/api/wellknown/webfinger/webfingerget_test.go
@@ -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(), >smodel.AccountSettings{AccountID: targetAccount.ID}); err != nil {
+ if err := suite.db.PutAccountSettings(suite.T().Context(), >smodel.AccountSettings{AccountID: targetAccount.ID}); err != nil {
suite.FailNow(err.Error())
}
diff --git a/internal/cache/timeline/status_test.go b/internal/cache/timeline/status_test.go
index 6d513032a..93623f3ab 100644
--- a/internal/cache/timeline/status_test.go
+++ b/internal/cache/timeline/status_test.go
@@ -69,7 +69,7 @@ var testStatusMeta = []*StatusMeta{
}
func TestStatusTimelinePreloader(t *testing.T) {
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(t.Context())
defer cncl()
var tt StatusTimeline
@@ -154,7 +154,7 @@ func TestStatusTimelineLoadLimit(t *testing.T) {
tt.Init(1000)
// Prepare new context for the duration of this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(t.Context())
defer cncl()
// Clone the input test status data.
diff --git a/internal/cleaner/emoji_test.go b/internal/cleaner/emoji_test.go
index b789d2d5a..1b33224ef 100644
--- a/internal/cleaner/emoji_test.go
+++ b/internal/cleaner/emoji_test.go
@@ -26,42 +26,42 @@ func copyMap(in map[string]*gtsmodel.Emoji) map[string]*gtsmodel.Emoji {
func (suite *CleanerTestSuite) TestEmojiUncacheRemote() {
suite.testEmojiUncacheRemote(
- context.Background(),
+ suite.T().Context(),
mapvals(suite.emojis),
)
}
func (suite *CleanerTestSuite) TestEmojiUncacheRemoteDryRun() {
suite.testEmojiUncacheRemote(
- gtscontext.SetDryRun(context.Background()),
+ gtscontext.SetDryRun(suite.T().Context()),
mapvals(suite.emojis),
)
}
func (suite *CleanerTestSuite) TestEmojiFixBroken() {
suite.testEmojiFixBroken(
- context.Background(),
+ suite.T().Context(),
mapvals(suite.emojis),
)
}
func (suite *CleanerTestSuite) TestEmojiFixBrokenDryRun() {
suite.testEmojiFixBroken(
- gtscontext.SetDryRun(context.Background()),
+ gtscontext.SetDryRun(suite.T().Context()),
mapvals(suite.emojis),
)
}
func (suite *CleanerTestSuite) TestEmojiPruneUnused() {
suite.testEmojiPruneUnused(
- context.Background(),
+ suite.T().Context(),
mapvals(suite.emojis),
)
}
func (suite *CleanerTestSuite) TestEmojiPruneUnusedDryRun() {
suite.testEmojiPruneUnused(
- gtscontext.SetDryRun(context.Background()),
+ gtscontext.SetDryRun(suite.T().Context()),
mapvals(suite.emojis),
)
}
@@ -74,7 +74,7 @@ func (suite *CleanerTestSuite) TestEmojiFixCacheStates() {
emojis["rainbow"].Cached = util.Ptr(false)
suite.testEmojiFixCacheStates(
- context.Background(),
+ suite.T().Context(),
mapvals(emojis),
)
}
@@ -87,7 +87,7 @@ func (suite *CleanerTestSuite) TestEmojiFixCacheStatesDryRun() {
emojis["rainbow"].Cached = util.Ptr(false)
suite.testEmojiFixCacheStates(
- gtscontext.SetDryRun(context.Background()),
+ gtscontext.SetDryRun(suite.T().Context()),
mapvals(emojis),
)
}
diff --git a/internal/cleaner/media_test.go b/internal/cleaner/media_test.go
index 02470f72d..797e6ea46 100644
--- a/internal/cleaner/media_test.go
+++ b/internal/cleaner/media_test.go
@@ -94,11 +94,11 @@ func (suite *MediaTestSuite) TearDownTest() {
// }
// pandaPath := "01GJQJ1YD9QCHCE12GG0EYHVNW/attachment/original/01GJQJ2AYM1VKSRW96YVAJ3NK3.gif"
-// if _, err := suite.storage.Put(context.Background(), pandaPath, b); err != nil {
+// if _, err := suite.storage.Put(suite.T().Context(), pandaPath, b); err != nil {
// suite.FailNow(err.Error())
// }
-// ctx := context.Background()
+// ctx := suite.T().Context()
// // dry run should show up 1 orphaned panda
// totalPruned, err := suite.cleaner.Media().PruneOrphaned(gtscontext.SetDryRun(ctx))
@@ -121,11 +121,11 @@ func (suite *MediaTestSuite) TearDownTest() {
// }
// pandaPath := "01GJQJ1YD9QCHCE12GG0EYHVNW/attachment/original/01GJQJ2AYM1VKSRW96YVAJ3NK3.gif"
-// if _, err := suite.storage.Put(context.Background(), pandaPath, b); err != nil {
+// if _, err := suite.storage.Put(suite.T().Context(), pandaPath, b); err != nil {
// suite.FailNow(err.Error())
// }
-// ctx := context.Background()
+// ctx := suite.T().Context()
// // should show up 1 orphaned panda
// totalPruned, err := suite.cleaner.Media().PruneOrphaned(ctx)
@@ -142,11 +142,11 @@ func (suite *MediaTestSuite) TearDownTest() {
// testAttachment := suite.testAttachments["local_account_1_unattached_1"]
// suite.True(*testAttachment.Cached)
-// totalPruned, err := suite.manager.PruneUnusedLocal(context.Background(), false)
+// totalPruned, err := suite.manager.PruneUnusedLocal(suite.T().Context(), false)
// suite.NoError(err)
// suite.Equal(1, totalPruned)
-// _, err = suite.db.GetAttachmentByID(context.Background(), testAttachment.ID)
+// _, err = suite.db.GetAttachmentByID(suite.T().Context(), testAttachment.ID)
// suite.ErrorIs(err, db.ErrNoEntries)
// }
@@ -154,27 +154,27 @@ func (suite *MediaTestSuite) TearDownTest() {
// testAttachment := suite.testAttachments["local_account_1_unattached_1"]
// suite.True(*testAttachment.Cached)
-// totalPruned, err := suite.manager.PruneUnusedLocal(context.Background(), true)
+// totalPruned, err := suite.manager.PruneUnusedLocal(suite.T().Context(), true)
// suite.NoError(err)
// suite.Equal(1, totalPruned)
-// _, err = suite.db.GetAttachmentByID(context.Background(), testAttachment.ID)
+// _, err = suite.db.GetAttachmentByID(suite.T().Context(), testAttachment.ID)
// suite.NoError(err)
// }
// func (suite *MediaTestSuite) TestPruneRemoteTwice() {
-// totalPruned, err := suite.manager.PruneUnusedLocal(context.Background(), false)
+// totalPruned, err := suite.manager.PruneUnusedLocal(suite.T().Context(), false)
// suite.NoError(err)
// suite.Equal(1, totalPruned)
// // final prune should prune nothing, since the first prune already happened
-// totalPrunedAgain, err := suite.manager.PruneUnusedLocal(context.Background(), false)
+// totalPrunedAgain, err := suite.manager.PruneUnusedLocal(suite.T().Context(), false)
// suite.NoError(err)
// suite.Equal(0, totalPrunedAgain)
// }
// func (suite *MediaTestSuite) TestPruneOneNonExistent() {
-// ctx := context.Background()
+// ctx := suite.T().Context()
// testAttachment := suite.testAttachments["local_account_1_unattached_1"]
// // Delete this attachment cached on disk
@@ -191,7 +191,7 @@ func (suite *MediaTestSuite) TearDownTest() {
// }
// func (suite *MediaTestSuite) TestPruneUnusedRemote() {
-// ctx := context.Background()
+// ctx := suite.T().Context()
// // start by clearing zork's avatar + header
// zorkOldAvatar := suite.testAttachments["local_account_1_avatar"]
@@ -225,7 +225,7 @@ func (suite *MediaTestSuite) TearDownTest() {
// }
// func (suite *MediaTestSuite) TestPruneUnusedRemoteTwice() {
-// ctx := context.Background()
+// ctx := suite.T().Context()
// // start by clearing zork's avatar + header
// zork := suite.testAccounts["local_account_1"]
@@ -246,7 +246,7 @@ func (suite *MediaTestSuite) TearDownTest() {
// }
// func (suite *MediaTestSuite) TestPruneUnusedRemoteMultipleAccounts() {
-// ctx := context.Background()
+// ctx := suite.T().Context()
// // start by clearing zork's avatar + header
// zorkOldAvatar := suite.testAttachments["local_account_1_avatar"]
@@ -287,7 +287,7 @@ func (suite *MediaTestSuite) TearDownTest() {
// }
func (suite *MediaTestSuite) TestUncacheRemote() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testStatusAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
suite.True(*testStatusAttachment.Cached)
@@ -310,7 +310,7 @@ func (suite *MediaTestSuite) TestUncacheRemote() {
}
func (suite *MediaTestSuite) TestUncacheRemoteDry() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testStatusAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
suite.True(*testStatusAttachment.Cached)
@@ -333,7 +333,7 @@ func (suite *MediaTestSuite) TestUncacheRemoteDry() {
}
func (suite *MediaTestSuite) TestUncacheRemoteTwice() {
- ctx := context.Background()
+ ctx := suite.T().Context()
after := time.Now().Add(-24 * time.Hour)
totalUncached, err := suite.cleaner.Media().UncacheRemote(ctx, after)
@@ -347,7 +347,7 @@ func (suite *MediaTestSuite) TestUncacheRemoteTwice() {
}
func (suite *MediaTestSuite) TestUncacheAndRecache() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testStatusAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
testHeader := suite.testAttachments["remote_account_3_header"]
@@ -403,7 +403,7 @@ func (suite *MediaTestSuite) TestUncacheAndRecache() {
}
func (suite *MediaTestSuite) TestUncacheOneNonExistent() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testStatusAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
// Delete this attachment cached on disk
diff --git a/internal/db/bundb/account_test.go b/internal/db/bundb/account_test.go
index bb842415c..4c4cad3dd 100644
--- a/internal/db/bundb/account_test.go
+++ b/internal/db/bundb/account_test.go
@@ -43,53 +43,53 @@ type AccountTestSuite struct {
}
func (suite *AccountTestSuite) TestGetAccountStatuses() {
- statuses, err := suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 20, false, false, "", "", false, false)
+ statuses, err := suite.db.GetAccountStatuses(suite.T().Context(), suite.testAccounts["local_account_1"].ID, 20, false, false, "", "", false, false)
suite.NoError(err)
suite.Len(statuses, 9)
}
func (suite *AccountTestSuite) TestGetAccountWebStatusesMediaOnly() {
- statuses, err := suite.db.GetAccountWebStatuses(context.Background(), suite.testAccounts["local_account_3"], true, 20, "")
+ statuses, err := suite.db.GetAccountWebStatuses(suite.T().Context(), suite.testAccounts["local_account_3"], true, 20, "")
suite.NoError(err)
suite.Len(statuses, 2)
}
func (suite *AccountTestSuite) TestGetAccountStatusesPageDown() {
// get the first page
- statuses, err := suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 3, false, false, "", "", false, false)
+ statuses, err := suite.db.GetAccountStatuses(suite.T().Context(), suite.testAccounts["local_account_1"].ID, 3, false, false, "", "", false, false)
if err != nil {
suite.FailNow(err.Error())
}
suite.Len(statuses, 3)
// get the second page
- statuses, err = suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 3, false, false, statuses[len(statuses)-1].ID, "", false, false)
+ statuses, err = suite.db.GetAccountStatuses(suite.T().Context(), suite.testAccounts["local_account_1"].ID, 3, false, false, statuses[len(statuses)-1].ID, "", false, false)
if err != nil {
suite.FailNow(err.Error())
}
suite.Len(statuses, 3)
// get the third page
- statuses, err = suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 3, false, false, statuses[len(statuses)-1].ID, "", false, false)
+ statuses, err = suite.db.GetAccountStatuses(suite.T().Context(), suite.testAccounts["local_account_1"].ID, 3, false, false, statuses[len(statuses)-1].ID, "", false, false)
if err != nil {
suite.FailNow(err.Error())
}
suite.Len(statuses, 3)
// try to get the last page (should be empty)
- statuses, err = suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 3, false, false, statuses[len(statuses)-1].ID, "", false, false)
+ statuses, err = suite.db.GetAccountStatuses(suite.T().Context(), suite.testAccounts["local_account_1"].ID, 3, false, false, statuses[len(statuses)-1].ID, "", false, false)
suite.ErrorIs(err, db.ErrNoEntries)
suite.Empty(statuses)
}
func (suite *AccountTestSuite) TestGetAccountStatusesExcludeRepliesAndReblogs() {
- statuses, err := suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 20, true, true, "", "", false, false)
+ statuses, err := suite.db.GetAccountStatuses(suite.T().Context(), suite.testAccounts["local_account_1"].ID, 20, true, true, "", "", false, false)
suite.NoError(err)
suite.Len(statuses, 8)
}
func (suite *AccountTestSuite) TestGetAccountStatusesExcludeRepliesAndReblogsPublicOnly() {
- statuses, err := suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 20, true, true, "", "", false, true)
+ statuses, err := suite.db.GetAccountStatuses(suite.T().Context(), suite.testAccounts["local_account_1"].ID, 20, true, true, "", "", false, true)
suite.NoError(err)
suite.Len(statuses, 4)
}
@@ -169,14 +169,14 @@ func (suite *AccountTestSuite) TestGetAccountStatusesExcludeRepliesExcludesSelfR
)
for _, status := range []*gtsmodel.Status{post, reply, riposte, followup} {
- if err := suite.db.PutStatus(context.Background(), status); err != nil {
+ if err := suite.db.PutStatus(suite.T().Context(), status); err != nil {
suite.FailNowf("", "Error while adding test status with ID %s: %v", status.ID, err)
return
}
}
testAccount := suite.testAccounts["local_account_1"]
- statuses, err := suite.db.GetAccountStatuses(context.Background(), testAccount.ID, 20, true, true, "", "", false, false)
+ statuses, err := suite.db.GetAccountStatuses(suite.T().Context(), testAccount.ID, 20, true, true, "", "", false, false)
suite.NoError(err)
suite.Len(statuses, 9)
for _, status := range statuses {
@@ -190,7 +190,7 @@ func (suite *AccountTestSuite) TestGetAccountStatusesExcludeRepliesExcludesSelfR
}
func (suite *AccountTestSuite) TestGetAccountStatusesMediaOnly() {
- statuses, err := suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 20, false, false, "", "", true, false)
+ statuses, err := suite.db.GetAccountStatuses(suite.T().Context(), suite.testAccounts["local_account_1"].ID, 20, false, false, "", "", true, false)
suite.NoError(err)
suite.Len(statuses, 2)
}
@@ -199,7 +199,7 @@ func (suite *AccountTestSuite) TestGetAccountBy() {
t := suite.T()
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Sentinel error to mark avoiding a test case.
@@ -344,7 +344,7 @@ func (suite *AccountTestSuite) TestGetAccountBy() {
}
func (suite *AccountTestSuite) TestGetAccountsByURLMulti() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Update admin account to have the same url as zork.
testAccount1 := suite.testAccounts["local_account_1"]
@@ -391,7 +391,7 @@ func (suite *AccountTestSuite) TestInsertAccountWithDefaults() {
PublicKeyURI: "https://example.org/users/test_service#main-key",
}
- err = suite.db.Put(context.Background(), newAccount)
+ err = suite.db.Put(suite.T().Context(), newAccount)
suite.NoError(err)
suite.WithinDuration(time.Now(), newAccount.CreatedAt, 30*time.Second)
@@ -403,7 +403,7 @@ func (suite *AccountTestSuite) TestInsertAccountWithDefaults() {
func (suite *AccountTestSuite) TestGetAccountPinnedStatusesSomeResults() {
testAccount := suite.testAccounts["admin_account"]
- statuses, err := suite.db.GetAccountPinnedStatuses(context.Background(), testAccount.ID)
+ statuses, err := suite.db.GetAccountPinnedStatuses(suite.T().Context(), testAccount.ID)
suite.NoError(err)
suite.Len(statuses, 2) // This account has 2 statuses pinned.
}
@@ -411,7 +411,7 @@ func (suite *AccountTestSuite) TestGetAccountPinnedStatusesSomeResults() {
func (suite *AccountTestSuite) TestGetAccountPinnedStatusesNothingPinned() {
testAccount := suite.testAccounts["local_account_1"]
- statuses, err := suite.db.GetAccountPinnedStatuses(context.Background(), testAccount.ID)
+ statuses, err := suite.db.GetAccountPinnedStatuses(suite.T().Context(), testAccount.ID)
suite.ErrorIs(err, db.ErrNoEntries)
suite.Empty(statuses) // This account has nothing pinned.
}
@@ -423,13 +423,13 @@ func (suite *AccountTestSuite) TestPopulateAccountWithUnknownMovedToURI() {
// Set test account MovedToURI to something we don't have in the database.
// We should not get an error when populating.
testAccount.MovedToURI = "https://unknown-instance.example.org/users/someone_we_dont_know"
- err := suite.db.PopulateAccount(context.Background(), testAccount)
+ err := suite.db.PopulateAccount(suite.T().Context(), testAccount)
suite.NoError(err)
}
func (suite *AccountTestSuite) TestGetAccountsAll() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
origin = ""
status = ""
mods = false
@@ -464,7 +464,7 @@ func (suite *AccountTestSuite) TestGetAccountsAll() {
func (suite *AccountTestSuite) TestGetAccountsMaxID() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
origin = ""
status = ""
mods = false
@@ -501,7 +501,7 @@ func (suite *AccountTestSuite) TestGetAccountsMaxID() {
func (suite *AccountTestSuite) TestGetAccountsMinID() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
origin = ""
status = ""
mods = false
@@ -538,7 +538,7 @@ func (suite *AccountTestSuite) TestGetAccountsMinID() {
func (suite *AccountTestSuite) TestGetAccountsModsOnly() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
origin = ""
status = ""
mods = true
@@ -575,7 +575,7 @@ func (suite *AccountTestSuite) TestGetAccountsModsOnly() {
func (suite *AccountTestSuite) TestGetAccountsLocalWithEmail() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
origin = "local"
status = ""
mods = false
@@ -612,7 +612,7 @@ func (suite *AccountTestSuite) TestGetAccountsLocalWithEmail() {
func (suite *AccountTestSuite) TestGetAccountsWithIP() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
origin = ""
status = ""
mods = false
@@ -649,7 +649,7 @@ func (suite *AccountTestSuite) TestGetAccountsWithIP() {
func (suite *AccountTestSuite) TestGetPendingAccounts() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
origin = ""
status = "pending"
mods = false
@@ -685,7 +685,7 @@ func (suite *AccountTestSuite) TestGetPendingAccounts() {
}
func (suite *AccountTestSuite) TestAccountStatsAll() {
- ctx := context.Background()
+ ctx := suite.T().Context()
for _, account := range suite.testAccounts {
// Get stats for the first time. They
// should all be generated now since
diff --git a/internal/db/bundb/admin_test.go b/internal/db/bundb/admin_test.go
index 247431e87..60ff0359e 100644
--- a/internal/db/bundb/admin_test.go
+++ b/internal/db/bundb/admin_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
@@ -31,31 +30,31 @@ type AdminTestSuite struct {
}
func (suite *AdminTestSuite) TestIsUsernameAvailableNo() {
- available, err := suite.db.IsUsernameAvailable(context.Background(), "the_mighty_zork")
+ available, err := suite.db.IsUsernameAvailable(suite.T().Context(), "the_mighty_zork")
suite.NoError(err)
suite.False(available)
}
func (suite *AdminTestSuite) TestIsUsernameAvailableYes() {
- available, err := suite.db.IsUsernameAvailable(context.Background(), "someone_completely_different")
+ available, err := suite.db.IsUsernameAvailable(suite.T().Context(), "someone_completely_different")
suite.NoError(err)
suite.True(available)
}
func (suite *AdminTestSuite) TestIsEmailAvailableNo() {
- available, err := suite.db.IsEmailAvailable(context.Background(), "zork@example.org")
+ available, err := suite.db.IsEmailAvailable(suite.T().Context(), "zork@example.org")
suite.NoError(err)
suite.False(available)
}
func (suite *AdminTestSuite) TestIsEmailAvailableYes() {
- available, err := suite.db.IsEmailAvailable(context.Background(), "someone@somewhere.com")
+ available, err := suite.db.IsEmailAvailable(suite.T().Context(), "someone@somewhere.com")
suite.NoError(err)
suite.True(available)
}
func (suite *AdminTestSuite) TestIsEmailAvailableDomainBlocked() {
- if err := suite.db.Put(context.Background(), >smodel.EmailDomainBlock{
+ if err := suite.db.Put(suite.T().Context(), >smodel.EmailDomainBlock{
ID: "01GEEV2R2YC5GRSN96761YJE47",
Domain: "somewhere.com",
CreatedByAccountID: suite.testAccounts["admin_account"].ID,
@@ -63,7 +62,7 @@ func (suite *AdminTestSuite) TestIsEmailAvailableDomainBlocked() {
suite.FailNow(err.Error())
}
- available, err := suite.db.IsEmailAvailable(context.Background(), "someone@somewhere.com")
+ available, err := suite.db.IsEmailAvailable(suite.T().Context(), "someone@somewhere.com")
suite.EqualError(err, "email domain somewhere.com is blocked")
suite.False(available)
}
@@ -78,22 +77,22 @@ func (suite *AdminTestSuite) TestCreateInstanceAccount() {
testrig.CreateTestTables(suite.db)
// make sure there's no instance account in the db yet
- acct, err := suite.db.GetInstanceAccount(context.Background(), "")
+ acct, err := suite.db.GetInstanceAccount(suite.T().Context(), "")
suite.Error(err)
suite.Nil(acct)
// create it
- err = suite.db.CreateInstanceAccount(context.Background())
+ err = suite.db.CreateInstanceAccount(suite.T().Context())
suite.NoError(err)
// and now check it exists
- acct, err = suite.db.GetInstanceAccount(context.Background(), "")
+ acct, err = suite.db.GetInstanceAccount(suite.T().Context(), "")
suite.NoError(err)
suite.NotNil(acct)
}
func (suite *AdminTestSuite) TestNewSignupWithNoInstanceApp() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Delete the instance app.
if err := suite.state.DB.DeleteApplicationByID(
diff --git a/internal/db/bundb/application_test.go b/internal/db/bundb/application_test.go
index 858cb15b6..a9ef80ce4 100644
--- a/internal/db/bundb/application_test.go
+++ b/internal/db/bundb/application_test.go
@@ -36,7 +36,7 @@ func (suite *ApplicationTestSuite) TestGetApplicationBy() {
t := suite.T()
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Sentinel error to mark avoiding a test case.
@@ -86,7 +86,7 @@ func (suite *ApplicationTestSuite) TestDeleteApplicationBy() {
t := suite.T()
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
for _, app := range suite.testApplications {
@@ -117,7 +117,7 @@ func (suite *ApplicationTestSuite) TestDeleteApplicationBy() {
}
func (suite *ApplicationTestSuite) TestGetAllTokens() {
- tokens, err := suite.db.GetAllTokens(context.Background())
+ tokens, err := suite.db.GetAllTokens(suite.T().Context())
if err != nil {
suite.FailNow(err.Error())
}
@@ -125,7 +125,7 @@ func (suite *ApplicationTestSuite) TestGetAllTokens() {
}
func (suite *ApplicationTestSuite) TestDeleteTokensByClientID() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Delete tokens by each app.
for _, app := range suite.testApplications {
@@ -147,7 +147,7 @@ func (suite *ApplicationTestSuite) TestDeleteTokensByUnknownClientID() {
// Should not return ErrNoRows even though
// the client with given ID doesn't exist.
if err := suite.state.DB.DeleteTokensByClientID(
- context.Background(),
+ suite.T().Context(),
"01JPJ4NCGH6GHY7ZVYBHNP55XS",
); err != nil {
suite.FailNow(err.Error())
diff --git a/internal/db/bundb/basic_test.go b/internal/db/bundb/basic_test.go
index bdda1cad3..cc4303666 100644
--- a/internal/db/bundb/basic_test.go
+++ b/internal/db/bundb/basic_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"crypto/rand"
"crypto/rsa"
"testing"
@@ -37,7 +36,7 @@ func (suite *BasicTestSuite) TestGetAccountByID() {
testAccount := suite.testAccounts["local_account_1"]
a := >smodel.Account{}
- err := suite.db.GetByID(context.Background(), testAccount.ID, a)
+ err := suite.db.GetByID(suite.T().Context(), testAccount.ID, a)
suite.NoError(err)
}
@@ -60,12 +59,12 @@ func (suite *BasicTestSuite) TestPutAccountWithBunDefaultFields() {
PublicKey: &key.PublicKey,
}
- if err := suite.db.Put(context.Background(), testAccount); err != nil {
+ if err := suite.db.Put(suite.T().Context(), testAccount); err != nil {
suite.FailNow(err.Error())
}
a := >smodel.Account{}
- if err := suite.db.GetByID(context.Background(), testAccount.ID, a); err != nil {
+ if err := suite.db.GetByID(suite.T().Context(), testAccount.ID, a); err != nil {
suite.FailNow(err.Error())
}
@@ -111,7 +110,7 @@ func (suite *BasicTestSuite) TestPutAccountWithBunDefaultFields() {
func (suite *BasicTestSuite) TestGetAllStatuses() {
s := []*gtsmodel.Status{}
- err := suite.db.GetAll(context.Background(), &s)
+ err := suite.db.GetAll(suite.T().Context(), &s)
suite.NoError(err)
suite.Len(s, 30)
}
@@ -125,7 +124,7 @@ func (suite *BasicTestSuite) TestGetAllNotNull() {
a := []*gtsmodel.Account{}
- err := suite.db.GetWhere(context.Background(), where, &a)
+ err := suite.db.GetWhere(suite.T().Context(), where, &a)
suite.NoError(err)
suite.NotEmpty(a)
diff --git a/internal/db/bundb/bundbnew_test.go b/internal/db/bundb/bundbnew_test.go
index 6dbe2120b..870086cd9 100644
--- a/internal/db/bundb/bundbnew_test.go
+++ b/internal/db/bundb/bundbnew_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/config"
@@ -32,7 +31,7 @@ type BundbNewTestSuite struct {
func (suite *BundbNewTestSuite) TestCreateNewDB() {
// create a new db with standard test settings
- db, err := bundb.NewBunDBService(context.Background(), nil)
+ db, err := bundb.NewBunDBService(suite.T().Context(), nil)
suite.NoError(err)
suite.NotNil(db)
}
@@ -41,7 +40,7 @@ func (suite *BundbNewTestSuite) TestCreateNewSqliteDBNoAddress() {
// create a new db with no address specified
config.SetDbAddress("")
config.SetDbType("sqlite")
- db, err := bundb.NewBunDBService(context.Background(), nil)
+ db, err := bundb.NewBunDBService(suite.T().Context(), nil)
suite.EqualError(err, "'db-address' was not set when attempting to start sqlite")
suite.Nil(db)
}
diff --git a/internal/db/bundb/conversation_test.go b/internal/db/bundb/conversation_test.go
index 15cdf8b3c..61ef12c89 100644
--- a/internal/db/bundb/conversation_test.go
+++ b/internal/db/bundb/conversation_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"time"
@@ -57,7 +56,7 @@ func (suite *ConversationTestSuite) SetupTest() {
// deleteStatus deletes a status from conversations and ends the test if that fails.
func (suite *ConversationTestSuite) deleteStatus(statusID string) {
- err := suite.db.DeleteStatusFromConversations(context.Background(), statusID)
+ err := suite.db.DeleteStatusFromConversations(suite.T().Context(), statusID)
if err != nil {
suite.FailNow(err.Error())
}
@@ -65,7 +64,7 @@ func (suite *ConversationTestSuite) deleteStatus(statusID string) {
// getConversation fetches a conversation by ID and ends the test if that fails.
func (suite *ConversationTestSuite) getConversation(conversationID string) *gtsmodel.Conversation {
- conversation, err := suite.db.GetConversationByID(context.Background(), conversationID)
+ conversation, err := suite.db.GetConversationByID(suite.T().Context(), conversationID)
if err != nil {
suite.FailNow(err.Error())
}
@@ -106,7 +105,7 @@ func (suite *ConversationTestSuite) TestDeleteOnlyStatus() {
initial := conversation.LastStatus
suite.deleteStatus(initial.ID)
- _, err := suite.db.GetConversationByID(context.Background(), conversation.ID)
+ _, err := suite.db.GetConversationByID(suite.T().Context(), conversation.ID)
suite.ErrorIs(err, db.ErrNoEntries)
}
diff --git a/internal/db/bundb/domain_test.go b/internal/db/bundb/domain_test.go
index 553cdeb80..8ebe0a2ba 100644
--- a/internal/db/bundb/domain_test.go
+++ b/internal/db/bundb/domain_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"slices"
"testing"
"time"
@@ -32,7 +31,7 @@ type DomainTestSuite struct {
}
func (suite *DomainTestSuite) TestIsDomainBlocked() {
- ctx := context.Background()
+ ctx := suite.T().Context()
domainBlock := >smodel.DomainBlock{
ID: "01G204214Y9TNJEBX39C7G88SW",
@@ -57,7 +56,7 @@ func (suite *DomainTestSuite) TestIsDomainBlocked() {
}
func (suite *DomainTestSuite) TestIsDomainBlockedWithAllow() {
- ctx := context.Background()
+ ctx := suite.T().Context()
domainBlock := >smodel.DomainBlock{
ID: "01G204214Y9TNJEBX39C7G88SW",
@@ -110,7 +109,7 @@ func (suite *DomainTestSuite) TestIsDomainBlockedWithAllow() {
}
func (suite *DomainTestSuite) TestIsDomainBlockedWildcard() {
- ctx := context.Background()
+ ctx := suite.T().Context()
domainBlock := >smodel.DomainBlock{
ID: "01G204214Y9TNJEBX39C7G88SW",
@@ -142,7 +141,7 @@ func (suite *DomainTestSuite) TestIsDomainBlockedWildcard() {
}
func (suite *DomainTestSuite) TestIsDomainBlockedNonASCII() {
- ctx := context.Background()
+ ctx := suite.T().Context()
now := time.Now()
@@ -178,7 +177,7 @@ func (suite *DomainTestSuite) TestIsDomainBlockedNonASCII() {
}
func (suite *DomainTestSuite) TestIsDomainBlockedNonASCII2() {
- ctx := context.Background()
+ ctx := suite.T().Context()
now := time.Now()
@@ -214,7 +213,7 @@ func (suite *DomainTestSuite) TestIsDomainBlockedNonASCII2() {
}
func (suite *DomainTestSuite) TestIsOtherDomainBlockedWildcardAndExplicit() {
- ctx := context.Background()
+ ctx := suite.T().Context()
blocks := []*gtsmodel.DomainBlock{
{
diff --git a/internal/db/bundb/domainpermissiondraft_test.go b/internal/db/bundb/domainpermissiondraft_test.go
index b3bb20d00..abbfaf202 100644
--- a/internal/db/bundb/domainpermissiondraft_test.go
+++ b/internal/db/bundb/domainpermissiondraft_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"errors"
"testing"
@@ -34,7 +33,7 @@ type DomainPermissionDraftTestSuite struct {
func (suite *DomainPermissionDraftTestSuite) TestPermDraftCreateGetDelete() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
draft = >smodel.DomainPermissionDraft{
ID: "01JCZN614XG85GCGAMSV9ZZAEJ",
PermissionType: gtsmodel.DomainPermissionBlock,
diff --git a/internal/db/bundb/domainpermissionexclude_test.go b/internal/db/bundb/domainpermissionexclude_test.go
index dd55d7add..a73fa300a 100644
--- a/internal/db/bundb/domainpermissionexclude_test.go
+++ b/internal/db/bundb/domainpermissionexclude_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"errors"
"testing"
@@ -34,7 +33,7 @@ type DomainPermissionExcludeTestSuite struct {
func (suite *DomainPermissionExcludeTestSuite) TestPermExcludeCreateGetDelete() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
exclude = >smodel.DomainPermissionExclude{
ID: "01JCZN614XG85GCGAMSV9ZZAEJ",
Domain: "exämple.org",
@@ -103,7 +102,7 @@ func (suite *DomainPermissionExcludeTestSuite) TestPermExcludeCreateGetDelete()
func (suite *DomainPermissionExcludeTestSuite) TestExcluded() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
createdByAccountID = suite.testAccounts["admin_account"].ID
)
diff --git a/internal/db/bundb/domainpermissionsubscription_test.go b/internal/db/bundb/domainpermissionsubscription_test.go
index b05330138..bbba85711 100644
--- a/internal/db/bundb/domainpermissionsubscription_test.go
+++ b/internal/db/bundb/domainpermissionsubscription_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
@@ -31,7 +30,7 @@ type DomainPermissionSubscriptionTestSuite struct {
func (suite *DomainPermissionSubscriptionTestSuite) TestCount() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testAccount = suite.testAccounts["admin_account"]
permSub = >smodel.DomainPermissionSubscription{
ID: "01JGV3VZ72K58BYW8H5GEVBZGN",
diff --git a/internal/db/bundb/emoji_test.go b/internal/db/bundb/emoji_test.go
index a71678eac..3c10b1a98 100644
--- a/internal/db/bundb/emoji_test.go
+++ b/internal/db/bundb/emoji_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/db"
@@ -32,7 +31,7 @@ type EmojiTestSuite struct {
}
func (suite *EmojiTestSuite) TestGetUseableEmojis() {
- emojis, err := suite.db.GetUseableEmojis(context.Background())
+ emojis, err := suite.db.GetUseableEmojis(suite.T().Context())
suite.NoError(err)
suite.Equal(1, len(emojis))
@@ -42,16 +41,16 @@ func (suite *EmojiTestSuite) TestGetUseableEmojis() {
func (suite *EmojiTestSuite) TestDeleteEmojiByID() {
testEmoji := suite.testEmojis["rainbow"]
- err := suite.db.DeleteEmojiByID(context.Background(), testEmoji.ID)
+ err := suite.db.DeleteEmojiByID(suite.T().Context(), testEmoji.ID)
suite.NoError(err)
- 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)
}
func (suite *EmojiTestSuite) TestGetEmojiByStaticURL() {
- emoji, err := suite.db.GetEmojiByStaticURL(context.Background(), "http://localhost:8080/fileserver/01AY6P665V14JJR0AFVRT7311Y/emoji/static/01F8MH9H8E4VG3KDYJR9EGPXCQ.png")
+ emoji, err := suite.db.GetEmojiByStaticURL(suite.T().Context(), "http://localhost:8080/fileserver/01AY6P665V14JJR0AFVRT7311Y/emoji/static/01F8MH9H8E4VG3KDYJR9EGPXCQ.png")
suite.NoError(err)
suite.NotNil(emoji)
suite.Equal("rainbow", emoji.Shortcode)
@@ -60,7 +59,7 @@ func (suite *EmojiTestSuite) TestGetEmojiByStaticURL() {
}
func (suite *EmojiTestSuite) TestGetAllEmojis() {
- emojis, err := suite.db.GetEmojisBy(context.Background(), db.EmojiAllDomains, true, true, "", "", "", 0)
+ emojis, err := suite.db.GetEmojisBy(suite.T().Context(), db.EmojiAllDomains, true, true, "", "", "", 0)
suite.NoError(err)
suite.Equal(2, len(emojis))
@@ -69,7 +68,7 @@ func (suite *EmojiTestSuite) TestGetAllEmojis() {
}
func (suite *EmojiTestSuite) TestGetAllEmojisLimit1() {
- emojis, err := suite.db.GetEmojisBy(context.Background(), db.EmojiAllDomains, true, true, "", "", "", 1)
+ emojis, err := suite.db.GetEmojisBy(suite.T().Context(), db.EmojiAllDomains, true, true, "", "", "", 1)
suite.NoError(err)
suite.Equal(1, len(emojis))
@@ -77,7 +76,7 @@ func (suite *EmojiTestSuite) TestGetAllEmojisLimit1() {
}
func (suite *EmojiTestSuite) TestGetAllEmojisMaxID() {
- emojis, err := suite.db.GetEmojisBy(context.Background(), db.EmojiAllDomains, true, true, "", "rainbow@", "", 0)
+ emojis, err := suite.db.GetEmojisBy(suite.T().Context(), db.EmojiAllDomains, true, true, "", "rainbow@", "", 0)
suite.NoError(err)
suite.Equal(1, len(emojis))
@@ -85,7 +84,7 @@ func (suite *EmojiTestSuite) TestGetAllEmojisMaxID() {
}
func (suite *EmojiTestSuite) TestGetAllEmojisMinID() {
- emojis, err := suite.db.GetEmojisBy(context.Background(), db.EmojiAllDomains, true, true, "", "", "yell@fossbros-anonymous.io", 0)
+ emojis, err := suite.db.GetEmojisBy(suite.T().Context(), db.EmojiAllDomains, true, true, "", "", "yell@fossbros-anonymous.io", 0)
suite.NoError(err)
suite.Equal(1, len(emojis))
@@ -93,14 +92,14 @@ func (suite *EmojiTestSuite) TestGetAllEmojisMinID() {
}
func (suite *EmojiTestSuite) TestGetAllDisabledEmojis() {
- emojis, err := suite.db.GetEmojisBy(context.Background(), db.EmojiAllDomains, true, false, "", "", "", 0)
+ emojis, err := suite.db.GetEmojisBy(suite.T().Context(), db.EmojiAllDomains, true, false, "", "", "", 0)
suite.ErrorIs(err, db.ErrNoEntries)
suite.Equal(0, len(emojis))
}
func (suite *EmojiTestSuite) TestGetAllEnabledEmojis() {
- emojis, err := suite.db.GetEmojisBy(context.Background(), db.EmojiAllDomains, false, true, "", "", "", 0)
+ emojis, err := suite.db.GetEmojisBy(suite.T().Context(), db.EmojiAllDomains, false, true, "", "", "", 0)
suite.NoError(err)
suite.Equal(2, len(emojis))
@@ -109,7 +108,7 @@ func (suite *EmojiTestSuite) TestGetAllEnabledEmojis() {
}
func (suite *EmojiTestSuite) TestGetLocalEnabledEmojis() {
- emojis, err := suite.db.GetEmojisBy(context.Background(), "", false, true, "", "", "", 0)
+ emojis, err := suite.db.GetEmojisBy(suite.T().Context(), "", false, true, "", "", "", 0)
suite.NoError(err)
suite.Equal(1, len(emojis))
@@ -117,21 +116,21 @@ func (suite *EmojiTestSuite) TestGetLocalEnabledEmojis() {
}
func (suite *EmojiTestSuite) TestGetLocalDisabledEmojis() {
- emojis, err := suite.db.GetEmojisBy(context.Background(), "", true, false, "", "", "", 0)
+ emojis, err := suite.db.GetEmojisBy(suite.T().Context(), "", true, false, "", "", "", 0)
suite.ErrorIs(err, db.ErrNoEntries)
suite.Equal(0, len(emojis))
}
func (suite *EmojiTestSuite) TestGetAllEmojisFromDomain() {
- emojis, err := suite.db.GetEmojisBy(context.Background(), "peepee.poopoo", true, true, "", "", "", 0)
+ emojis, err := suite.db.GetEmojisBy(suite.T().Context(), "peepee.poopoo", true, true, "", "", "", 0)
suite.ErrorIs(err, db.ErrNoEntries)
suite.Equal(0, len(emojis))
}
func (suite *EmojiTestSuite) TestGetAllEmojisFromDomain2() {
- emojis, err := suite.db.GetEmojisBy(context.Background(), "fossbros-anonymous.io", true, true, "", "", "", 0)
+ emojis, err := suite.db.GetEmojisBy(suite.T().Context(), "fossbros-anonymous.io", true, true, "", "", "", 0)
suite.NoError(err)
suite.Equal(1, len(emojis))
@@ -139,7 +138,7 @@ func (suite *EmojiTestSuite) TestGetAllEmojisFromDomain2() {
}
func (suite *EmojiTestSuite) TestGetSpecificEmojisFromDomain2() {
- emojis, err := suite.db.GetEmojisBy(context.Background(), "fossbros-anonymous.io", true, true, "yell", "", "", 0)
+ emojis, err := suite.db.GetEmojisBy(suite.T().Context(), "fossbros-anonymous.io", true, true, "yell", "", "", 0)
suite.NoError(err)
suite.Equal(1, len(emojis))
@@ -147,7 +146,7 @@ func (suite *EmojiTestSuite) TestGetSpecificEmojisFromDomain2() {
}
func (suite *EmojiTestSuite) TestGetEmojiCategories() {
- categories, err := suite.db.GetEmojiCategories(context.Background())
+ categories, err := suite.db.GetEmojiCategories(suite.T().Context())
suite.NoError(err)
suite.Len(categories, 2)
// check alphabetical order
@@ -156,7 +155,7 @@ func (suite *EmojiTestSuite) TestGetEmojiCategories() {
}
func (suite *EmojiTestSuite) TestGetEmojiCategory() {
- category, err := suite.db.GetEmojiCategory(context.Background(), testrig.NewTestEmojiCategories()["reactions"].ID)
+ category, err := suite.db.GetEmojiCategory(suite.T().Context(), testrig.NewTestEmojiCategories()["reactions"].ID)
suite.NoError(err)
suite.NotNil(category)
}
@@ -167,7 +166,7 @@ func (suite *EmojiTestSuite) TestUpdateEmojiCategory() {
testEmoji.CategoryID = ""
- err := suite.db.UpdateEmoji(context.Background(), testEmoji, "category_id")
+ err := suite.db.UpdateEmoji(suite.T().Context(), testEmoji, "category_id")
suite.NoError(err)
}
diff --git a/internal/db/bundb/errors_test.go b/internal/db/bundb/errors_test.go
index a235e185b..b90e3b5e6 100644
--- a/internal/db/bundb/errors_test.go
+++ b/internal/db/bundb/errors_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"errors"
"testing"
@@ -38,7 +37,7 @@ func (suite *ErrorsTestSuite) TestErrorAlreadyExists() {
}
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
initialFollow = >smodel.Follow{
ID: "01HD11D8JH5V64GJRFDA7VFNDX",
URI: "https://example.org/unique_uri",
diff --git a/internal/db/bundb/filter_test.go b/internal/db/bundb/filter_test.go
index faa2957d6..12f3476ed 100644
--- a/internal/db/bundb/filter_test.go
+++ b/internal/db/bundb/filter_test.go
@@ -54,7 +54,7 @@ func (suite *FilterTestSuite) TestFilterCRUD() {
filter.Keywords = []*gtsmodel.FilterKeyword{filterKeyword}
// Create new cancellable test context.
- ctx := context.Background()
+ ctx := suite.T().Context()
ctx, cncl := context.WithCancel(ctx)
defer cncl()
@@ -249,7 +249,7 @@ func (suite *FilterTestSuite) TestFilterCRUD() {
func (suite *FilterTestSuite) TestFilterTitleOverlap() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
account1 = "01HNEJXCPRTJVJY9MV0VVHGD47"
account2 = "01JAG5BRJPJYA0FSA5HR2MMFJH"
)
diff --git a/internal/db/bundb/filterkeyword_test.go b/internal/db/bundb/filterkeyword_test.go
index e1482a225..ab814d413 100644
--- a/internal/db/bundb/filterkeyword_test.go
+++ b/internal/db/bundb/filterkeyword_test.go
@@ -41,7 +41,7 @@ func (suite *FilterTestSuite) TestFilterKeywordCRUD() {
}
// Create new cancellable test context.
- ctx := context.Background()
+ ctx := suite.T().Context()
ctx, cncl := context.WithCancel(ctx)
defer cncl()
diff --git a/internal/db/bundb/filterstatus_test.go b/internal/db/bundb/filterstatus_test.go
index e5dceb7f1..9485ee3f7 100644
--- a/internal/db/bundb/filterstatus_test.go
+++ b/internal/db/bundb/filterstatus_test.go
@@ -41,7 +41,7 @@ func (suite *FilterTestSuite) TestFilterStatusCRD() {
}
// Create new cancellable test context.
- ctx := context.Background()
+ ctx := suite.T().Context()
ctx, cncl := context.WithCancel(ctx)
defer cncl()
diff --git a/internal/db/bundb/headerfilter_test.go b/internal/db/bundb/headerfilter_test.go
index 85a2dd03e..d9a9e38b2 100644
--- a/internal/db/bundb/headerfilter_test.go
+++ b/internal/db/bundb/headerfilter_test.go
@@ -68,7 +68,7 @@ func (suite *HeaderFilterTestSuite) testHeaderFilterGetPutUpdateDelete(
}
// Create new cancellable test context.
- ctx := context.Background()
+ ctx := suite.T().Context()
ctx, cncl := context.WithCancel(ctx)
defer cncl()
diff --git a/internal/db/bundb/instance_test.go b/internal/db/bundb/instance_test.go
index c6f177821..3fba2af50 100644
--- a/internal/db/bundb/instance_test.go
+++ b/internal/db/bundb/instance_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/config"
@@ -33,68 +32,68 @@ type InstanceTestSuite struct {
}
func (suite *InstanceTestSuite) TestCountInstanceUsers() {
- count, err := suite.db.CountInstanceUsers(context.Background(), config.GetHost())
+ count, err := suite.db.CountInstanceUsers(suite.T().Context(), config.GetHost())
suite.NoError(err)
suite.Equal(5, count)
}
func (suite *InstanceTestSuite) TestCountInstanceUsersRemote() {
- count, err := suite.db.CountInstanceUsers(context.Background(), "fossbros-anonymous.io")
+ count, err := suite.db.CountInstanceUsers(suite.T().Context(), "fossbros-anonymous.io")
suite.NoError(err)
suite.Equal(1, count)
}
func (suite *InstanceTestSuite) TestCountInstanceStatuses() {
- count, err := suite.db.CountInstanceStatuses(context.Background(), config.GetHost())
+ count, err := suite.db.CountInstanceStatuses(suite.T().Context(), config.GetHost())
suite.NoError(err)
suite.Equal(23, count)
}
func (suite *InstanceTestSuite) TestCountInstanceStatusesRemote() {
- count, err := suite.db.CountInstanceStatuses(context.Background(), "fossbros-anonymous.io")
+ count, err := suite.db.CountInstanceStatuses(suite.T().Context(), "fossbros-anonymous.io")
suite.NoError(err)
suite.Equal(4, count)
}
func (suite *InstanceTestSuite) TestCountInstanceDomains() {
- count, err := suite.db.CountInstanceDomains(context.Background(), config.GetHost())
+ count, err := suite.db.CountInstanceDomains(suite.T().Context(), config.GetHost())
suite.NoError(err)
suite.Equal(2, count)
}
func (suite *InstanceTestSuite) TestGetInstanceOK() {
- instance, err := suite.db.GetInstance(context.Background(), "localhost:8080")
+ instance, err := suite.db.GetInstance(suite.T().Context(), "localhost:8080")
suite.NoError(err)
suite.NotNil(instance)
}
func (suite *InstanceTestSuite) TestGetInstanceNonexistent() {
- instance, err := suite.db.GetInstance(context.Background(), "doesnt.exist.com")
+ instance, err := suite.db.GetInstance(suite.T().Context(), "doesnt.exist.com")
suite.ErrorIs(err, db.ErrNoEntries)
suite.Nil(instance)
}
func (suite *InstanceTestSuite) TestGetInstancePeers() {
- peers, err := suite.db.GetInstancePeers(context.Background(), false)
+ peers, err := suite.db.GetInstancePeers(suite.T().Context(), false)
suite.NoError(err)
suite.Len(peers, 2)
}
func (suite *InstanceTestSuite) TestGetInstancePeersIncludeSuspended() {
- peers, err := suite.db.GetInstancePeers(context.Background(), true)
+ peers, err := suite.db.GetInstancePeers(suite.T().Context(), true)
suite.NoError(err)
suite.Len(peers, 2)
}
func (suite *InstanceTestSuite) TestGetInstanceAccounts() {
- accounts, err := suite.db.GetInstanceAccounts(context.Background(), "fossbros-anonymous.io", "", 10)
+ accounts, err := suite.db.GetInstanceAccounts(suite.T().Context(), "fossbros-anonymous.io", "", 10)
suite.NoError(err)
suite.Len(accounts, 1)
}
func (suite *InstanceTestSuite) TestGetInstanceModeratorAddressesOK() {
// We have one admin user by default.
- addresses, err := suite.db.GetInstanceModeratorAddresses(context.Background())
+ addresses, err := suite.db.GetInstanceModeratorAddresses(suite.T().Context())
suite.NoError(err)
suite.EqualValues([]string{"admin@example.org"}, addresses)
}
@@ -104,11 +103,11 @@ func (suite *InstanceTestSuite) TestGetInstanceModeratorAddressesZorkAsModerator
testUser := >smodel.User{}
*testUser = *suite.testUsers["local_account_1"]
testUser.Moderator = util.Ptr(true)
- if err := suite.db.UpdateUser(context.Background(), testUser, "moderator"); err != nil {
+ if err := suite.db.UpdateUser(suite.T().Context(), testUser, "moderator"); err != nil {
suite.FailNow(err.Error())
}
- addresses, err := suite.db.GetInstanceModeratorAddresses(context.Background())
+ addresses, err := suite.db.GetInstanceModeratorAddresses(suite.T().Context())
suite.NoError(err)
suite.EqualValues([]string{"admin@example.org", "zork@example.org"}, addresses)
}
@@ -119,11 +118,11 @@ func (suite *InstanceTestSuite) TestGetInstanceModeratorAddressesNoAdmin() {
*testUser = *suite.testUsers["admin_account"]
testUser.Admin = util.Ptr(false)
testUser.Moderator = util.Ptr(false)
- if err := suite.db.UpdateUser(context.Background(), testUser, "admin", "moderator"); err != nil {
+ if err := suite.db.UpdateUser(suite.T().Context(), testUser, "admin", "moderator"); err != nil {
suite.FailNow(err.Error())
}
- addresses, err := suite.db.GetInstanceModeratorAddresses(context.Background())
+ addresses, err := suite.db.GetInstanceModeratorAddresses(suite.T().Context())
suite.ErrorIs(err, db.ErrNoEntries)
suite.Empty(addresses)
}
diff --git a/internal/db/bundb/interaction_test.go b/internal/db/bundb/interaction_test.go
index 4518f7ac9..564b3a3f2 100644
--- a/internal/db/bundb/interaction_test.go
+++ b/internal/db/bundb/interaction_test.go
@@ -127,7 +127,7 @@ func (suite *InteractionTestSuite) markInteractionsPending(
func (suite *InteractionTestSuite) TestGetPending() {
var (
testStatus = suite.testStatuses["local_account_1_status_1"]
- ctx = context.Background()
+ ctx = suite.T().Context()
acctID = suite.testAccounts["local_account_1"].ID
statusID = ""
likes = true
@@ -175,7 +175,7 @@ func (suite *InteractionTestSuite) TestGetPending() {
func (suite *InteractionTestSuite) TestGetPendingRepliesOnly() {
var (
testStatus = suite.testStatuses["local_account_1_status_1"]
- ctx = context.Background()
+ ctx = suite.T().Context()
acctID = suite.testAccounts["local_account_1"].ID
statusID = ""
likes = false
@@ -211,7 +211,7 @@ func (suite *InteractionTestSuite) TestGetPendingRepliesOnly() {
func (suite *InteractionTestSuite) TestInteractionRejected() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
req = new(gtsmodel.InteractionRequest)
)
diff --git a/internal/db/bundb/list_test.go b/internal/db/bundb/list_test.go
index dde336c46..f71b5e7b0 100644
--- a/internal/db/bundb/list_test.go
+++ b/internal/db/bundb/list_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"slices"
"testing"
@@ -102,7 +101,7 @@ func (suite *ListTestSuite) checkListEntries(expected []*gtsmodel.ListEntry, act
func (suite *ListTestSuite) TestGetListByID() {
testList, _, _ := suite.testStructs()
- dbList, err := suite.db.GetListByID(context.Background(), testList.ID)
+ dbList, err := suite.db.GetListByID(suite.T().Context(), testList.ID)
if err != nil {
suite.FailNow(err.Error())
}
@@ -113,7 +112,7 @@ func (suite *ListTestSuite) TestGetListByID() {
func (suite *ListTestSuite) TestGetListsForAccountID() {
testList, _, testAccount := suite.testStructs()
- dbLists, err := suite.db.GetListsByAccountID(context.Background(), testAccount.ID)
+ dbLists, err := suite.db.GetListsByAccountID(suite.T().Context(), testAccount.ID)
if err != nil {
suite.FailNow(err.Error())
}
@@ -126,7 +125,7 @@ func (suite *ListTestSuite) TestGetListsForAccountID() {
}
func (suite *ListTestSuite) TestPutList() {
- ctx := context.Background()
+ ctx := suite.T().Context()
_, _, testAccount := suite.testStructs()
testList := >smodel.List{
@@ -150,7 +149,7 @@ func (suite *ListTestSuite) TestPutList() {
}
func (suite *ListTestSuite) TestUpdateList() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testList, _, _ := suite.testStructs()
// Get List in the cache first.
@@ -176,7 +175,7 @@ func (suite *ListTestSuite) TestUpdateList() {
}
func (suite *ListTestSuite) TestDeleteList() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testList, _, _ := suite.testStructs()
// Get List in the cache first.
@@ -205,7 +204,7 @@ func (suite *ListTestSuite) TestDeleteList() {
}
func (suite *ListTestSuite) TestPutListEntries() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testList, testEntries, _ := suite.testStructs()
listEntries := []*gtsmodel.ListEntry{
@@ -241,7 +240,7 @@ func (suite *ListTestSuite) TestPutListEntries() {
}
func (suite *ListTestSuite) TestDeleteListEntry() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testList, testEntries, _ := suite.testStructs()
// Delete the first entry.
@@ -261,7 +260,7 @@ func (suite *ListTestSuite) TestDeleteListEntry() {
}
func (suite *ListTestSuite) TestDeleteAllListEntriesByFollows() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testList, testEntries, _ := suite.testStructs()
// Delete the first entry.
@@ -280,7 +279,7 @@ func (suite *ListTestSuite) TestDeleteAllListEntriesByFollows() {
}
func (suite *ListTestSuite) TestListIncludesAccount() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testList, _, _ := suite.testStructs()
for accountID, expected := range map[string]bool{
diff --git a/internal/db/bundb/markers_test.go b/internal/db/bundb/markers_test.go
index 618fb3383..6541c3deb 100644
--- a/internal/db/bundb/markers_test.go
+++ b/internal/db/bundb/markers_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"time"
@@ -35,7 +34,7 @@ type MarkersTestSuite struct {
}
func (suite *MarkersTestSuite) TestGetExisting() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// This account has home and notifications markers set.
localAccount1 := suite.testAccounts["local_account_1"]
@@ -49,7 +48,7 @@ func (suite *MarkersTestSuite) TestGetExisting() {
}
func (suite *MarkersTestSuite) TestGetUnset() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// This account has no markers set.
localAccount2 := suite.testAccounts["local_account_2"]
@@ -60,7 +59,7 @@ func (suite *MarkersTestSuite) TestGetUnset() {
}
func (suite *MarkersTestSuite) TestUpdateExisting() {
- ctx := context.Background()
+ ctx := suite.T().Context()
now := time.Now()
// This account has home and notifications markers set.
@@ -92,7 +91,7 @@ func (suite *MarkersTestSuite) TestUpdateExisting() {
}
func (suite *MarkersTestSuite) TestUpdateUnset() {
- ctx := context.Background()
+ ctx := suite.T().Context()
now := time.Now()
// This account has no markers set.
diff --git a/internal/db/bundb/media_test.go b/internal/db/bundb/media_test.go
index 6237d96b1..86da44148 100644
--- a/internal/db/bundb/media_test.go
+++ b/internal/db/bundb/media_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"time"
@@ -31,19 +30,19 @@ type MediaTestSuite struct {
func (suite *MediaTestSuite) TestGetAttachmentByID() {
testAttachment := suite.testAttachments["admin_account_status_1_attachment_1"]
- attachment, err := suite.db.GetAttachmentByID(context.Background(), testAttachment.ID)
+ attachment, err := suite.db.GetAttachmentByID(suite.T().Context(), testAttachment.ID)
suite.NoError(err)
suite.NotNil(attachment)
}
func (suite *MediaTestSuite) TestGetOlder() {
- attachments, err := suite.db.GetCachedAttachmentsOlderThan(context.Background(), time.Now(), 20)
+ attachments, err := suite.db.GetCachedAttachmentsOlderThan(suite.T().Context(), time.Now(), 20)
suite.NoError(err)
suite.Len(attachments, 3)
}
func (suite *MediaTestSuite) TestGetCachedAttachmentsOlderThan() {
- ctx := context.Background()
+ ctx := suite.T().Context()
attachments, err := suite.db.GetCachedAttachmentsOlderThan(ctx, time.Now(), 20)
suite.NoError(err)
diff --git a/internal/db/bundb/mention_test.go b/internal/db/bundb/mention_test.go
index 9ec087607..f4fb03d2f 100644
--- a/internal/db/bundb/mention_test.go
+++ b/internal/db/bundb/mention_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"github.com/stretchr/testify/suite"
@@ -31,7 +30,7 @@ type MentionTestSuite struct {
func (suite *MentionTestSuite) TestGetMention() {
m := suite.testMentions["local_user_2_mention_zork"]
- dbMention, err := suite.db.GetMention(context.Background(), m.ID)
+ dbMention, err := suite.db.GetMention(suite.T().Context(), m.ID)
suite.NoError(err)
suite.NotNil(dbMention)
suite.Equal(m.ID, dbMention.ID)
@@ -46,7 +45,7 @@ func (suite *MentionTestSuite) TestGetMention() {
func (suite *MentionTestSuite) TestGetMentions() {
m := suite.testMentions["local_user_2_mention_zork"]
- dbMentions, err := suite.db.GetMentions(context.Background(), []string{m.ID})
+ dbMentions, err := suite.db.GetMentions(suite.T().Context(), []string{m.ID})
suite.NoError(err)
suite.Len(dbMentions, 1)
dbMention := dbMentions[0]
diff --git a/internal/db/bundb/move_test.go b/internal/db/bundb/move_test.go
index c3e0dce3d..79fbf504f 100644
--- a/internal/db/bundb/move_test.go
+++ b/internal/db/bundb/move_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"time"
@@ -32,7 +31,7 @@ type MoveTestSuite struct {
}
func (suite *MoveTestSuite) TestMoveIntegration() {
- ctx := context.Background()
+ ctx := suite.T().Context()
firstMove := >smodel.Move{
ID: "01HPPN38MZYEC6WBTR21J6241N",
OriginURI: "https://example.org/users/my_old_account",
diff --git a/internal/db/bundb/notification_test.go b/internal/db/bundb/notification_test.go
index b3104f905..10b82b7ce 100644
--- a/internal/db/bundb/notification_test.go
+++ b/internal/db/bundb/notification_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"errors"
"testing"
"time"
@@ -74,7 +73,7 @@ func (suite *NotificationTestSuite) spamNotifs() {
Read: util.Ptr(false),
}
- if err := suite.db.PutNotification(context.Background(), notif); err != nil {
+ if err := suite.db.PutNotification(suite.T().Context(), notif); err != nil {
panic(err)
}
}
@@ -91,7 +90,7 @@ func (suite *NotificationTestSuite) TestGetAccountNotificationsWithSpam() {
testAccount := suite.testAccounts["local_account_1"]
before := time.Now()
notifications, err := suite.db.GetAccountNotifications(
- gtscontext.SetBarebones(context.Background()),
+ gtscontext.SetBarebones(suite.T().Context()),
testAccount.ID,
&paging.Page{
Min: paging.EitherMinID("", id.Lowest),
@@ -115,7 +114,7 @@ func (suite *NotificationTestSuite) TestGetAccountNotificationsWithoutSpam() {
testAccount := suite.testAccounts["local_account_1"]
before := time.Now()
notifications, err := suite.db.GetAccountNotifications(
- gtscontext.SetBarebones(context.Background()),
+ gtscontext.SetBarebones(suite.T().Context()),
testAccount.ID,
&paging.Page{
Min: paging.EitherMinID("", id.Lowest),
@@ -141,7 +140,7 @@ func (suite *NotificationTestSuite) TestDeleteNotificationsWithSpam() {
// Test getting notifs first.
notifications, err := suite.db.GetAccountNotifications(
- gtscontext.SetBarebones(context.Background()),
+ gtscontext.SetBarebones(suite.T().Context()),
testAccount.ID,
&paging.Page{
Min: paging.EitherMinID("", id.Lowest),
@@ -157,13 +156,13 @@ func (suite *NotificationTestSuite) TestDeleteNotificationsWithSpam() {
suite.Len(notifications, 20)
// Now delete.
- if err := suite.db.DeleteNotifications(context.Background(), nil, testAccount.ID, ""); err != nil {
+ if err := suite.db.DeleteNotifications(suite.T().Context(), nil, testAccount.ID, ""); err != nil {
suite.FailNow(err.Error())
}
// Now try getting again.
notifications, err = suite.db.GetAccountNotifications(
- gtscontext.SetBarebones(context.Background()),
+ gtscontext.SetBarebones(suite.T().Context()),
testAccount.ID,
&paging.Page{
Min: paging.EitherMinID("", id.Lowest),
@@ -182,11 +181,11 @@ func (suite *NotificationTestSuite) TestDeleteNotificationsWithSpam() {
func (suite *NotificationTestSuite) TestDeleteNotificationsWithTwoAccounts() {
suite.spamNotifs()
testAccount := suite.testAccounts["local_account_1"]
- err := suite.db.DeleteNotifications(context.Background(), nil, testAccount.ID, "")
+ err := suite.db.DeleteNotifications(suite.T().Context(), nil, testAccount.ID, "")
suite.NoError(err)
notifications, err := suite.db.GetAccountNotifications(
- gtscontext.SetBarebones(context.Background()),
+ gtscontext.SetBarebones(suite.T().Context()),
testAccount.ID,
&paging.Page{
Min: paging.EitherMinID("", id.Lowest),
@@ -201,7 +200,7 @@ func (suite *NotificationTestSuite) TestDeleteNotificationsWithTwoAccounts() {
suite.Empty(notifications)
notif := []*gtsmodel.Notification{}
- err = suite.db.GetAll(context.Background(), ¬if)
+ err = suite.db.GetAll(suite.T().Context(), ¬if)
suite.NoError(err)
suite.NotEmpty(notif)
}
@@ -209,12 +208,12 @@ func (suite *NotificationTestSuite) TestDeleteNotificationsWithTwoAccounts() {
func (suite *NotificationTestSuite) TestDeleteNotificationsOriginatingFromAccount() {
testAccount := suite.testAccounts["local_account_2"]
- if err := suite.db.DeleteNotifications(context.Background(), nil, "", testAccount.ID); err != nil {
+ if err := suite.db.DeleteNotifications(suite.T().Context(), nil, "", testAccount.ID); err != nil {
suite.FailNow(err.Error())
}
notif := []*gtsmodel.Notification{}
- if err := suite.db.GetAll(context.Background(), ¬if); err != nil && !errors.Is(err, db.ErrNoEntries) {
+ if err := suite.db.GetAll(suite.T().Context(), ¬if); err != nil && !errors.Is(err, db.ErrNoEntries) {
suite.FailNow(err.Error())
}
@@ -229,12 +228,12 @@ func (suite *NotificationTestSuite) TestDeleteNotificationsOriginatingFromAndTar
originAccount := suite.testAccounts["local_account_2"]
targetAccount := suite.testAccounts["admin_account"]
- if err := suite.db.DeleteNotifications(context.Background(), nil, targetAccount.ID, originAccount.ID); err != nil {
+ if err := suite.db.DeleteNotifications(suite.T().Context(), nil, targetAccount.ID, originAccount.ID); err != nil {
suite.FailNow(err.Error())
}
notif := []*gtsmodel.Notification{}
- if err := suite.db.GetAll(context.Background(), ¬if); err != nil && !errors.Is(err, db.ErrNoEntries) {
+ if err := suite.db.GetAll(suite.T().Context(), ¬if); err != nil && !errors.Is(err, db.ErrNoEntries) {
suite.FailNow(err.Error())
}
@@ -253,12 +252,12 @@ func (suite *NotificationTestSuite) TestDeleteNotificationsOriginatingFromAndTar
func (suite *NotificationTestSuite) TestDeleteNotificationsPertainingToStatusID() {
testStatus := suite.testStatuses["local_account_1_status_1"]
- if err := suite.db.DeleteNotificationsForStatus(context.Background(), testStatus.ID); err != nil {
+ if err := suite.db.DeleteNotificationsForStatus(suite.T().Context(), testStatus.ID); err != nil {
suite.FailNow(err.Error())
}
notif := []*gtsmodel.Notification{}
- if err := suite.db.GetAll(context.Background(), ¬if); err != nil && !errors.Is(err, db.ErrNoEntries) {
+ if err := suite.db.GetAll(suite.T().Context(), ¬if); err != nil && !errors.Is(err, db.ErrNoEntries) {
suite.FailNow(err.Error())
}
diff --git a/internal/db/bundb/poll_test.go b/internal/db/bundb/poll_test.go
index 04c8609e8..09a152c1d 100644
--- a/internal/db/bundb/poll_test.go
+++ b/internal/db/bundb/poll_test.go
@@ -39,7 +39,7 @@ func (suite *PollTestSuite) TestGetPollBy() {
t := suite.T()
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Sentinel error to mark avoiding a test case.
@@ -103,7 +103,7 @@ func (suite *PollTestSuite) TestGetPollVoteBy() {
t := suite.T()
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Sentinel error to mark avoiding a test case.
@@ -175,7 +175,7 @@ func (suite *PollTestSuite) TestGetPollVoteBy() {
func (suite *PollTestSuite) TestUpdatePoll() {
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
for _, poll := range suite.testPolls {
@@ -200,7 +200,7 @@ func (suite *PollTestSuite) TestUpdatePoll() {
func (suite *PollTestSuite) TestPutPoll() {
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
for _, poll := range suite.testPolls {
@@ -220,7 +220,7 @@ func (suite *PollTestSuite) TestPutPoll() {
func (suite *PollTestSuite) TestPutPollVote() {
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// randomChoices generates random vote choices in poll.
@@ -271,7 +271,7 @@ func (suite *PollTestSuite) TestPutPollVote() {
func (suite *PollTestSuite) TestDeletePoll() {
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
for _, poll := range suite.testPolls {
@@ -286,7 +286,7 @@ func (suite *PollTestSuite) TestDeletePoll() {
}
func (suite *PollTestSuite) TestDeletePollVotesBy() {
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
for _, vote := range suite.testPollVotes {
@@ -308,7 +308,7 @@ func (suite *PollTestSuite) TestDeletePollVotesBy() {
}
func (suite *PollTestSuite) TestDeletePollVotesByNoAccount() {
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Try to delete a poll by nonexisting account.
diff --git a/internal/db/bundb/relationship_test.go b/internal/db/bundb/relationship_test.go
index 50f790a42..1d47db6a7 100644
--- a/internal/db/bundb/relationship_test.go
+++ b/internal/db/bundb/relationship_test.go
@@ -39,7 +39,7 @@ func (suite *RelationshipTestSuite) TestGetBlockBy() {
t := suite.T()
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Sentinel error to mark avoiding a test case.
@@ -152,7 +152,7 @@ func (suite *RelationshipTestSuite) TestGetFollowBy() {
t := suite.T()
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Sentinel error to mark avoiding a test case.
@@ -264,7 +264,7 @@ func (suite *RelationshipTestSuite) TestGetFollowRequestBy() {
t := suite.T()
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Sentinel error to mark avoiding a test case.
@@ -374,7 +374,7 @@ func (suite *RelationshipTestSuite) TestGetFollowRequestBy() {
}
func (suite *RelationshipTestSuite) TestIsBlocked() {
- ctx := context.Background()
+ ctx := suite.T().Context()
account1 := suite.testAccounts["local_account_1"].ID
account2 := suite.testAccounts["local_account_2"].ID
@@ -418,7 +418,7 @@ func (suite *RelationshipTestSuite) TestIsBlocked() {
}
func (suite *RelationshipTestSuite) TestDeleteBlockByID() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// put a block in first
account1 := suite.testAccounts["local_account_1"].ID
@@ -449,7 +449,7 @@ func (suite *RelationshipTestSuite) TestDeleteBlockByID() {
}
func (suite *RelationshipTestSuite) TestDeleteBlockByURI() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// put a block in first
account1 := suite.testAccounts["local_account_1"].ID
@@ -480,7 +480,7 @@ func (suite *RelationshipTestSuite) TestDeleteBlockByURI() {
}
func (suite *RelationshipTestSuite) TestDeleteAccountBlocks() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// put a block in first
account1 := suite.testAccounts["local_account_1"].ID
@@ -511,7 +511,7 @@ func (suite *RelationshipTestSuite) TestDeleteAccountBlocks() {
}
func (suite *RelationshipTestSuite) TestDeleteAccountMutes() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Add a mute.
accountID1 := suite.testAccounts["local_account_1"].ID
@@ -551,7 +551,7 @@ func (suite *RelationshipTestSuite) TestGetRelationship() {
requestingAccount := suite.testAccounts["local_account_1"]
targetAccount := suite.testAccounts["admin_account"]
- relationship, err := suite.db.GetRelationship(context.Background(), requestingAccount.ID, targetAccount.ID)
+ relationship, err := suite.db.GetRelationship(suite.T().Context(), requestingAccount.ID, targetAccount.ID)
suite.NoError(err)
suite.NotNil(relationship)
@@ -572,7 +572,7 @@ func (suite *RelationshipTestSuite) TestGetRelationship() {
func (suite *RelationshipTestSuite) TestIsFollowingYes() {
requestingAccount := suite.testAccounts["local_account_1"]
targetAccount := suite.testAccounts["admin_account"]
- isFollowing, err := suite.db.IsFollowing(context.Background(), requestingAccount.ID, targetAccount.ID)
+ isFollowing, err := suite.db.IsFollowing(suite.T().Context(), requestingAccount.ID, targetAccount.ID)
suite.NoError(err)
suite.True(isFollowing)
}
@@ -580,7 +580,7 @@ func (suite *RelationshipTestSuite) TestIsFollowingYes() {
func (suite *RelationshipTestSuite) TestIsFollowingNo() {
requestingAccount := suite.testAccounts["admin_account"]
targetAccount := suite.testAccounts["local_account_2"]
- isFollowing, err := suite.db.IsFollowing(context.Background(), requestingAccount.ID, targetAccount.ID)
+ isFollowing, err := suite.db.IsFollowing(suite.T().Context(), requestingAccount.ID, targetAccount.ID)
suite.NoError(err)
suite.False(isFollowing)
}
@@ -588,7 +588,7 @@ func (suite *RelationshipTestSuite) TestIsFollowingNo() {
func (suite *RelationshipTestSuite) TestIsMutualFollowing() {
requestingAccount := suite.testAccounts["local_account_1"]
targetAccount := suite.testAccounts["admin_account"]
- isMutualFollowing, err := suite.db.IsMutualFollowing(context.Background(), requestingAccount.ID, targetAccount.ID)
+ isMutualFollowing, err := suite.db.IsMutualFollowing(suite.T().Context(), requestingAccount.ID, targetAccount.ID)
suite.NoError(err)
suite.True(isMutualFollowing)
}
@@ -596,13 +596,13 @@ func (suite *RelationshipTestSuite) TestIsMutualFollowing() {
func (suite *RelationshipTestSuite) TestIsMutualFollowingNo() {
requestingAccount := suite.testAccounts["local_account_1"]
targetAccount := suite.testAccounts["local_account_2"]
- isMutualFollowing, err := suite.db.IsMutualFollowing(context.Background(), requestingAccount.ID, targetAccount.ID)
+ isMutualFollowing, err := suite.db.IsMutualFollowing(suite.T().Context(), requestingAccount.ID, targetAccount.ID)
suite.NoError(err)
suite.True(isMutualFollowing)
}
func (suite *RelationshipTestSuite) TestAcceptFollowRequestOK() {
- ctx := context.Background()
+ ctx := suite.T().Context()
account := suite.testAccounts["admin_account"]
targetAccount := suite.testAccounts["local_account_2"]
@@ -672,7 +672,7 @@ func (suite *RelationshipTestSuite) TestAcceptFollowRequestOK() {
}
func (suite *RelationshipTestSuite) TestAcceptFollowRequestNoNotification() {
- ctx := context.Background()
+ ctx := suite.T().Context()
account := suite.testAccounts["admin_account"]
targetAccount := suite.testAccounts["local_account_2"]
@@ -697,7 +697,7 @@ func (suite *RelationshipTestSuite) TestAcceptFollowRequestNoNotification() {
}
func (suite *RelationshipTestSuite) TestAcceptFollowRequestNotExisting() {
- ctx := context.Background()
+ ctx := suite.T().Context()
account := suite.testAccounts["admin_account"]
targetAccount := suite.testAccounts["local_account_2"]
@@ -707,7 +707,7 @@ func (suite *RelationshipTestSuite) TestAcceptFollowRequestNotExisting() {
}
func (suite *RelationshipTestSuite) TestAcceptFollowRequestFollowAlreadyExists() {
- ctx := context.Background()
+ ctx := suite.T().Context()
account := suite.testAccounts["local_account_1"]
targetAccount := suite.testAccounts["admin_account"]
@@ -738,7 +738,7 @@ func (suite *RelationshipTestSuite) TestAcceptFollowRequestFollowAlreadyExists()
}
func (suite *RelationshipTestSuite) TestRejectFollowRequestOK() {
- ctx := context.Background()
+ ctx := suite.T().Context()
account := suite.testAccounts["admin_account"]
targetAccount := suite.testAccounts["local_account_2"]
@@ -774,7 +774,7 @@ func (suite *RelationshipTestSuite) TestRejectFollowRequestOK() {
}
func (suite *RelationshipTestSuite) TestRejectFollowRequestNotExisting() {
- ctx := context.Background()
+ ctx := suite.T().Context()
account := suite.testAccounts["admin_account"]
targetAccount := suite.testAccounts["local_account_2"]
@@ -783,7 +783,7 @@ func (suite *RelationshipTestSuite) TestRejectFollowRequestNotExisting() {
}
func (suite *RelationshipTestSuite) TestGetAccountFollowRequests() {
- ctx := context.Background()
+ ctx := suite.T().Context()
account := suite.testAccounts["admin_account"]
targetAccount := suite.testAccounts["local_account_2"]
@@ -805,14 +805,14 @@ func (suite *RelationshipTestSuite) TestGetAccountFollowRequests() {
func (suite *RelationshipTestSuite) TestGetAccountFollows() {
account := suite.testAccounts["local_account_1"]
- follows, err := suite.db.GetAccountFollows(context.Background(), account.ID, nil)
+ follows, err := suite.db.GetAccountFollows(suite.T().Context(), account.ID, nil)
suite.NoError(err)
suite.Len(follows, 2)
}
func (suite *RelationshipTestSuite) TestGetAccountFollowers() {
account := suite.testAccounts["local_account_1"]
- follows, err := suite.db.GetAccountFollowers(context.Background(), account.ID, nil)
+ follows, err := suite.db.GetAccountFollowers(suite.T().Context(), account.ID, nil)
suite.NoError(err)
suite.Len(follows, 2)
}
@@ -821,25 +821,25 @@ func (suite *RelationshipTestSuite) TestUnfollowExisting() {
originAccount := suite.testAccounts["local_account_1"]
targetAccount := suite.testAccounts["admin_account"]
- follow, err := suite.db.GetFollow(context.Background(), originAccount.ID, targetAccount.ID)
+ follow, err := suite.db.GetFollow(suite.T().Context(), originAccount.ID, targetAccount.ID)
suite.NoError(err)
suite.NotNil(follow)
followID := follow.ID
// We should have lists that this follow is a part of.
- lists, err := suite.db.GetListsContainingFollowID(context.Background(), followID)
+ lists, err := suite.db.GetListsContainingFollowID(suite.T().Context(), followID)
suite.NoError(err)
suite.NotEmpty(lists)
- err = suite.db.DeleteFollowByID(context.Background(), followID)
+ err = suite.db.DeleteFollowByID(suite.T().Context(), followID)
suite.NoError(err)
- follow, err = suite.db.GetFollow(context.Background(), originAccount.ID, targetAccount.ID)
+ follow, err = suite.db.GetFollow(suite.T().Context(), originAccount.ID, targetAccount.ID)
suite.EqualError(err, db.ErrNoEntries.Error())
suite.Nil(follow)
// Lists containing this follow should return empty too.
- lists, err = suite.db.GetListsContainingFollowID(context.Background(), followID)
+ lists, err = suite.db.GetListsContainingFollowID(suite.T().Context(), followID)
suite.NoError(err)
suite.Empty(lists)
}
@@ -848,13 +848,13 @@ func (suite *RelationshipTestSuite) TestGetFollowNotExisting() {
originAccount := suite.testAccounts["local_account_1"]
targetAccountID := "01GTVD9N484CZ6AM90PGGNY7GQ"
- follow, err := suite.db.GetFollow(context.Background(), originAccount.ID, targetAccountID)
+ follow, err := suite.db.GetFollow(suite.T().Context(), originAccount.ID, targetAccountID)
suite.EqualError(err, db.ErrNoEntries.Error())
suite.Nil(follow)
}
func (suite *RelationshipTestSuite) TestDeleteFollow() {
- ctx := context.Background()
+ ctx := suite.T().Context()
originAccount := suite.testAccounts["local_account_1"]
targetAccount := suite.testAccounts["admin_account"]
@@ -867,7 +867,7 @@ func (suite *RelationshipTestSuite) TestDeleteFollow() {
}
func (suite *RelationshipTestSuite) TestUnfollowRequestExisting() {
- ctx := context.Background()
+ ctx := suite.T().Context()
originAccount := suite.testAccounts["admin_account"]
targetAccount := suite.testAccounts["local_account_2"]
@@ -882,14 +882,14 @@ func (suite *RelationshipTestSuite) TestUnfollowRequestExisting() {
suite.FailNow(err.Error())
}
- followRequest, err := suite.db.GetFollowRequest(context.Background(), originAccount.ID, targetAccount.ID)
+ followRequest, err := suite.db.GetFollowRequest(suite.T().Context(), originAccount.ID, targetAccount.ID)
suite.NoError(err)
suite.NotNil(followRequest)
- err = suite.db.DeleteFollowRequestByID(context.Background(), followRequest.ID)
+ err = suite.db.DeleteFollowRequestByID(suite.T().Context(), followRequest.ID)
suite.NoError(err)
- followRequest, err = suite.db.GetFollowRequest(context.Background(), originAccount.ID, targetAccount.ID)
+ followRequest, err = suite.db.GetFollowRequest(suite.T().Context(), originAccount.ID, targetAccount.ID)
suite.EqualError(err, db.ErrNoEntries.Error())
suite.Nil(followRequest)
}
@@ -898,13 +898,13 @@ func (suite *RelationshipTestSuite) TestUnfollowRequestNotExisting() {
originAccount := suite.testAccounts["local_account_1"]
targetAccountID := "01GTVD9N484CZ6AM90PGGNY7GQ"
- followRequest, err := suite.db.GetFollowRequest(context.Background(), originAccount.ID, targetAccountID)
+ followRequest, err := suite.db.GetFollowRequest(suite.T().Context(), originAccount.ID, targetAccountID)
suite.EqualError(err, db.ErrNoEntries.Error())
suite.Nil(followRequest)
}
func (suite *RelationshipTestSuite) TestUpdateFollow() {
- ctx := context.Background()
+ ctx := suite.T().Context()
follow := >smodel.Follow{}
*follow = *suite.testFollows["local_account_1_admin_account"]
@@ -930,7 +930,7 @@ func (suite *RelationshipTestSuite) TestUpdateFollow() {
}
func (suite *RelationshipTestSuite) TestGetNote() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Retrieve a fixture note
account1 := suite.testAccounts["local_account_1"].ID
@@ -944,7 +944,7 @@ func (suite *RelationshipTestSuite) TestGetNote() {
}
func (suite *RelationshipTestSuite) TestPutNote() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// put a note in
account1 := suite.testAccounts["local_account_1"].ID
diff --git a/internal/db/bundb/report_test.go b/internal/db/bundb/report_test.go
index 910a5c370..ec90f783f 100644
--- a/internal/db/bundb/report_test.go
+++ b/internal/db/bundb/report_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/db"
@@ -35,7 +34,7 @@ type ReportTestSuite struct {
}
func (suite *ReportTestSuite) TestGetReportByID() {
- report, err := suite.db.GetReportByID(context.Background(), suite.testReports["local_account_2_report_remote_account_1"].ID)
+ report, err := suite.db.GetReportByID(suite.T().Context(), suite.testReports["local_account_2_report_remote_account_1"].ID)
if err != nil {
suite.FailNow(err.Error())
}
@@ -49,7 +48,7 @@ func (suite *ReportTestSuite) TestGetReportByID() {
}
func (suite *ReportTestSuite) TestGetReportByURI() {
- report, err := suite.db.GetReportByID(context.Background(), suite.testReports["remote_account_1_report_local_account_2"].ID)
+ report, err := suite.db.GetReportByID(suite.T().Context(), suite.testReports["remote_account_1_report_local_account_2"].ID)
if err != nil {
suite.FailNow(err.Error())
}
@@ -64,7 +63,7 @@ func (suite *ReportTestSuite) TestGetReportByURI() {
func (suite *ReportTestSuite) TestGetAllReports() {
reports, err := suite.db.GetReports(
- context.Background(),
+ suite.T().Context(),
nil,
"",
"",
@@ -77,7 +76,7 @@ func (suite *ReportTestSuite) TestGetAllReports() {
func (suite *ReportTestSuite) TestReportPagingDown() {
// Get one from the top.
reports1, err := suite.db.GetReports(
- context.Background(),
+ suite.T().Context(),
nil,
"",
"",
@@ -95,7 +94,7 @@ func (suite *ReportTestSuite) TestReportPagingDown() {
// Use this one to page down.
reports2, err := suite.db.GetReports(
- context.Background(),
+ suite.T().Context(),
nil,
"",
"",
@@ -118,7 +117,7 @@ func (suite *ReportTestSuite) TestReportPagingDown() {
func (suite *ReportTestSuite) TestReportPagingUp() {
// Get one from the bottom.
reports1, err := suite.db.GetReports(
- context.Background(),
+ suite.T().Context(),
nil,
"",
"",
@@ -137,7 +136,7 @@ func (suite *ReportTestSuite) TestReportPagingUp() {
// Use this one to page up.
reports2, err := suite.db.GetReports(
- context.Background(),
+ suite.T().Context(),
nil,
"",
"",
@@ -160,7 +159,7 @@ func (suite *ReportTestSuite) TestReportPagingUp() {
func (suite *ReportTestSuite) TestGetAllReportsByAccountID() {
accountID := suite.testAccounts["local_account_2"].ID
reports, err := suite.db.GetReports(
- context.Background(),
+ suite.T().Context(),
nil,
accountID,
"",
@@ -174,7 +173,7 @@ func (suite *ReportTestSuite) TestGetAllReportsByAccountID() {
}
func (suite *ReportTestSuite) TestPutReport() {
- ctx := context.Background()
+ ctx := suite.T().Context()
reportID := "01GP3ECY8QJD8DBJSS8B1CR0AX"
report := >smodel.Report{
@@ -194,7 +193,7 @@ func (suite *ReportTestSuite) TestPutReport() {
}
func (suite *ReportTestSuite) TestUpdateReport() {
- ctx := context.Background()
+ ctx := suite.T().Context()
report := >smodel.Report{}
*report = *suite.testReports["local_account_2_report_remote_account_1"]
@@ -220,7 +219,7 @@ func (suite *ReportTestSuite) TestUpdateReport() {
}
func (suite *ReportTestSuite) TestUpdateReportAllColumns() {
- ctx := context.Background()
+ ctx := suite.T().Context()
report := >smodel.Report{}
*report = *suite.testReports["local_account_2_report_remote_account_1"]
@@ -246,11 +245,11 @@ func (suite *ReportTestSuite) TestUpdateReportAllColumns() {
}
func (suite *ReportTestSuite) TestDeleteReport() {
- if err := suite.db.DeleteReportByID(context.Background(), suite.testReports["remote_account_1_report_local_account_2"].ID); err != nil {
+ if err := suite.db.DeleteReportByID(suite.T().Context(), suite.testReports["remote_account_1_report_local_account_2"].ID); err != nil {
suite.FailNow(err.Error())
}
- report, err := suite.db.GetReportByID(context.Background(), suite.testReports["remote_account_1_report_local_account_2"].ID)
+ report, err := suite.db.GetReportByID(suite.T().Context(), suite.testReports["remote_account_1_report_local_account_2"].ID)
suite.ErrorIs(err, db.ErrNoEntries)
suite.Nil(report)
}
diff --git a/internal/db/bundb/rule_test.go b/internal/db/bundb/rule_test.go
index deaf7c14c..a7bff0546 100644
--- a/internal/db/bundb/rule_test.go
+++ b/internal/db/bundb/rule_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/db"
@@ -37,7 +36,7 @@ func (suite *RuleTestSuite) TestPutRuleWithExisting() {
Text: "Pee pee poo poo",
}
- if err := suite.state.DB.PutRule(context.Background(), r); err != nil {
+ if err := suite.state.DB.PutRule(suite.T().Context(), r); err != nil {
suite.FailNow(err.Error())
}
@@ -46,7 +45,7 @@ func (suite *RuleTestSuite) TestPutRuleWithExisting() {
func (suite *RuleTestSuite) TestPutRuleNoExisting() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
whereAny = []db.Where{{Key: "id", Value: "", Not: true}}
)
@@ -74,7 +73,7 @@ func (suite *RuleTestSuite) TestPutRuleNoExisting() {
func (suite *RuleTestSuite) TestGetRuleByID() {
rule, err := suite.state.DB.GetRuleByID(
- context.Background(),
+ suite.T().Context(),
suite.testRules["rule1"].ID,
)
if err != nil {
@@ -91,7 +90,7 @@ func (suite *RuleTestSuite) TestGetRulesByID() {
}
rules, err := suite.state.DB.GetRulesByIDs(
- context.Background(),
+ suite.T().Context(),
ruleIDs,
)
if err != nil {
@@ -109,7 +108,7 @@ func (suite *RuleTestSuite) TestGetActiveRules() {
}
}
- rules, err := suite.state.DB.GetActiveRules(context.Background())
+ rules, err := suite.state.DB.GetActiveRules(suite.T().Context())
if err != nil {
suite.FailNow(err.Error())
}
diff --git a/internal/db/bundb/search_test.go b/internal/db/bundb/search_test.go
index 5ce1a6064..c864f6da2 100644
--- a/internal/db/bundb/search_test.go
+++ b/internal/db/bundb/search_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/db"
@@ -32,7 +31,7 @@ type SearchTestSuite struct {
func (suite *SearchTestSuite) TestSearchAccountsTurtleAny() {
testAccount := suite.testAccounts["local_account_1"]
- accounts, err := suite.db.SearchForAccounts(context.Background(), testAccount.ID, "turtle", "", "", 10, false, 0)
+ accounts, err := suite.db.SearchForAccounts(suite.T().Context(), testAccount.ID, "turtle", "", "", 10, false, 0)
suite.NoError(err)
suite.Len(accounts, 1)
}
@@ -41,7 +40,7 @@ func (suite *SearchTestSuite) TestSearchAccounts1HappyWithPrefix() {
testAccount := suite.testAccounts["local_account_1"]
// Query will just look for usernames that start with "1happy".
- accounts, err := suite.db.SearchForAccounts(context.Background(), testAccount.ID, "@1happy", "", "", 10, false, 0)
+ accounts, err := suite.db.SearchForAccounts(suite.T().Context(), testAccount.ID, "@1happy", "", "", 10, false, 0)
suite.NoError(err)
suite.Len(accounts, 1)
}
@@ -50,7 +49,7 @@ func (suite *SearchTestSuite) TestSearchAccounts1HappyWithPrefixUpper() {
testAccount := suite.testAccounts["local_account_1"]
// Query will just look for usernames that start with "1HAPPY".
- accounts, err := suite.db.SearchForAccounts(context.Background(), testAccount.ID, "@1HAPPY", "", "", 10, false, 0)
+ accounts, err := suite.db.SearchForAccounts(suite.T().Context(), testAccount.ID, "@1HAPPY", "", "", 10, false, 0)
suite.NoError(err)
suite.Len(accounts, 1)
}
@@ -59,7 +58,7 @@ func (suite *SearchTestSuite) TestSearchAccounts1HappyNoPrefix() {
testAccount := suite.testAccounts["local_account_1"]
// Query will do the full coalesce.
- accounts, err := suite.db.SearchForAccounts(context.Background(), testAccount.ID, "1happy", "", "", 10, false, 0)
+ accounts, err := suite.db.SearchForAccounts(suite.T().Context(), testAccount.ID, "1happy", "", "", 10, false, 0)
suite.NoError(err)
suite.Len(accounts, 1)
}
@@ -67,7 +66,7 @@ func (suite *SearchTestSuite) TestSearchAccounts1HappyNoPrefix() {
func (suite *SearchTestSuite) TestSearchAccountsTurtleFollowing() {
testAccount := suite.testAccounts["local_account_1"]
- accounts, err := suite.db.SearchForAccounts(context.Background(), testAccount.ID, "turtle", "", "", 10, true, 0)
+ accounts, err := suite.db.SearchForAccounts(suite.T().Context(), testAccount.ID, "turtle", "", "", 10, true, 0)
suite.NoError(err)
suite.Len(accounts, 1)
}
@@ -75,7 +74,7 @@ func (suite *SearchTestSuite) TestSearchAccountsTurtleFollowing() {
func (suite *SearchTestSuite) TestSearchAccountsTurtleFollowingUpper() {
testAccount := suite.testAccounts["local_account_1"]
- accounts, err := suite.db.SearchForAccounts(context.Background(), testAccount.ID, "TURTLE", "", "", 10, true, 0)
+ accounts, err := suite.db.SearchForAccounts(suite.T().Context(), testAccount.ID, "TURTLE", "", "", 10, true, 0)
suite.NoError(err)
suite.Len(accounts, 1)
}
@@ -83,7 +82,7 @@ func (suite *SearchTestSuite) TestSearchAccountsTurtleFollowingUpper() {
func (suite *SearchTestSuite) TestSearchAccountsPostFollowing() {
testAccount := suite.testAccounts["local_account_1"]
- accounts, err := suite.db.SearchForAccounts(context.Background(), testAccount.ID, "post", "", "", 10, true, 0)
+ accounts, err := suite.db.SearchForAccounts(suite.T().Context(), testAccount.ID, "post", "", "", 10, true, 0)
suite.NoError(err)
suite.Len(accounts, 1)
}
@@ -91,7 +90,7 @@ func (suite *SearchTestSuite) TestSearchAccountsPostFollowing() {
func (suite *SearchTestSuite) TestSearchAccountsPostAny() {
testAccount := suite.testAccounts["local_account_1"]
- accounts, err := suite.db.SearchForAccounts(context.Background(), testAccount.ID, "post", "", "", 10, false, 0)
+ accounts, err := suite.db.SearchForAccounts(suite.T().Context(), testAccount.ID, "post", "", "", 10, false, 0)
suite.NoError(err, db.ErrNoEntries)
suite.Empty(accounts)
}
@@ -99,7 +98,7 @@ func (suite *SearchTestSuite) TestSearchAccountsPostAny() {
func (suite *SearchTestSuite) TestSearchAccountsFossAny() {
testAccount := suite.testAccounts["local_account_1"]
- accounts, err := suite.db.SearchForAccounts(context.Background(), testAccount.ID, "foss", "", "", 10, false, 0)
+ accounts, err := suite.db.SearchForAccounts(suite.T().Context(), testAccount.ID, "foss", "", "", 10, false, 0)
suite.NoError(err)
suite.Len(accounts, 1)
}
@@ -107,7 +106,7 @@ func (suite *SearchTestSuite) TestSearchAccountsFossAny() {
func (suite *SearchTestSuite) TestSearchStatuses() {
testAccount := suite.testAccounts["local_account_1"]
- statuses, err := suite.db.SearchForStatuses(context.Background(), testAccount.ID, "hello", "", "", "", 10, 0)
+ statuses, err := suite.db.SearchForStatuses(suite.T().Context(), testAccount.ID, "hello", "", "", "", 10, 0)
suite.NoError(err)
suite.Len(statuses, 1)
}
@@ -116,7 +115,7 @@ func (suite *SearchTestSuite) TestSearchStatusesFromAccount() {
testAccount := suite.testAccounts["local_account_1"]
fromAccount := suite.testAccounts["local_account_2"]
- statuses, err := suite.db.SearchForStatuses(context.Background(), testAccount.ID, "hi", fromAccount.ID, "", "", 10, 0)
+ statuses, err := suite.db.SearchForStatuses(suite.T().Context(), testAccount.ID, "hi", fromAccount.ID, "", "", 10, 0)
suite.NoError(err)
if suite.Len(statuses, 1) {
suite.Equal(fromAccount.ID, statuses[0].AccountID)
@@ -125,17 +124,17 @@ func (suite *SearchTestSuite) TestSearchStatusesFromAccount() {
func (suite *SearchTestSuite) TestSearchTags() {
// Search with full tag string.
- tags, err := suite.db.SearchForTags(context.Background(), "welcome", "", "", 10, 0)
+ tags, err := suite.db.SearchForTags(suite.T().Context(), "welcome", "", "", 10, 0)
suite.NoError(err)
suite.Len(tags, 1)
// Search with partial tag string.
- tags, err = suite.db.SearchForTags(context.Background(), "wel", "", "", 10, 0)
+ tags, err = suite.db.SearchForTags(suite.T().Context(), "wel", "", "", 10, 0)
suite.NoError(err)
suite.Len(tags, 1)
// Search with end of tag string.
- tags, err = suite.db.SearchForTags(context.Background(), "come", "", "", 10, 0)
+ tags, err = suite.db.SearchForTags(suite.T().Context(), "come", "", "", 10, 0)
suite.NoError(err)
suite.Len(tags, 0)
}
diff --git a/internal/db/bundb/session_test.go b/internal/db/bundb/session_test.go
index 43921cacc..0c1199e84 100644
--- a/internal/db/bundb/session_test.go
+++ b/internal/db/bundb/session_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"github.com/stretchr/testify/suite"
@@ -29,7 +28,7 @@ type SessionTestSuite struct {
}
func (suite *SessionTestSuite) TestGetSession() {
- session, err := suite.db.GetSession(context.Background())
+ session, err := suite.db.GetSession(suite.T().Context())
suite.NoError(err)
suite.NotNil(session)
suite.NotEmpty(session.Auth)
@@ -37,7 +36,7 @@ func (suite *SessionTestSuite) TestGetSession() {
suite.NotEmpty(session.ID)
// the same session should be returned with consecutive selects
- session2, err := suite.db.GetSession(context.Background())
+ session2, err := suite.db.GetSession(suite.T().Context())
suite.NoError(err)
suite.NotNil(session2)
suite.Equal(session.Auth, session2.Auth)
diff --git a/internal/db/bundb/status_test.go b/internal/db/bundb/status_test.go
index 3ee494213..9c1eb73bd 100644
--- a/internal/db/bundb/status_test.go
+++ b/internal/db/bundb/status_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"time"
@@ -32,7 +31,7 @@ type StatusTestSuite struct {
}
func (suite *StatusTestSuite) TestGetStatusByID() {
- status, err := suite.db.GetStatusByID(context.Background(), suite.testStatuses["local_account_1_status_1"].ID)
+ status, err := suite.db.GetStatusByID(suite.T().Context(), suite.testStatuses["local_account_1_status_1"].ID)
if err != nil {
suite.FailNow(err.Error())
}
@@ -52,7 +51,7 @@ func (suite *StatusTestSuite) TestGetStatusesByIDs() {
suite.testStatuses["local_account_2_status_3"].ID,
}
- statuses, err := suite.db.GetStatusesByIDs(context.Background(), ids)
+ statuses, err := suite.db.GetStatusesByIDs(suite.T().Context(), ids)
if err != nil {
suite.FailNow(err.Error())
}
@@ -83,7 +82,7 @@ func (suite *StatusTestSuite) TestGetStatusesByIDs() {
}
func (suite *StatusTestSuite) TestGetStatusByURI() {
- status, err := suite.db.GetStatusByURI(context.Background(), suite.testStatuses["local_account_2_status_3"].URI)
+ status, err := suite.db.GetStatusByURI(suite.T().Context(), suite.testStatuses["local_account_2_status_3"].URI)
if err != nil {
suite.FailNow(err.Error())
}
@@ -98,7 +97,7 @@ func (suite *StatusTestSuite) TestGetStatusByURI() {
}
func (suite *StatusTestSuite) TestGetStatusWithExtras() {
- status, err := suite.db.GetStatusByID(context.Background(), suite.testStatuses["admin_account_status_1"].ID)
+ status, err := suite.db.GetStatusByID(suite.T().Context(), suite.testStatuses["admin_account_status_1"].ID)
if err != nil {
suite.FailNow(err.Error())
}
@@ -112,7 +111,7 @@ func (suite *StatusTestSuite) TestGetStatusWithExtras() {
}
func (suite *StatusTestSuite) TestGetStatusWithMention() {
- status, err := suite.db.GetStatusByID(context.Background(), suite.testStatuses["local_account_2_status_5"].ID)
+ status, err := suite.db.GetStatusByID(suite.T().Context(), suite.testStatuses["local_account_2_status_5"].ID)
if err != nil {
suite.FailNow(err.Error())
}
@@ -135,14 +134,14 @@ func (suite *StatusTestSuite) TestGetStatusWithMention() {
/*
func (suite *StatusTestSuite) TestGetStatusTwice() {
before1 := time.Now()
- _, err := suite.db.GetStatusByURI(context.Background(), suite.testStatuses["local_account_1_status_1"].URI)
+ _, err := suite.db.GetStatusByURI(suite.T().Context(), suite.testStatuses["local_account_1_status_1"].URI)
suite.NoError(err)
after1 := time.Now()
duration1 := after1.Sub(before1)
fmt.Println(duration1.Microseconds())
before2 := time.Now()
- _, err = suite.db.GetStatusByURI(context.Background(), suite.testStatuses["local_account_1_status_1"].URI)
+ _, err = suite.db.GetStatusByURI(suite.T().Context(), suite.testStatuses["local_account_1_status_1"].URI)
suite.NoError(err)
after2 := time.Now()
duration2 := after2.Sub(before2)
@@ -155,7 +154,7 @@ func (suite *StatusTestSuite) TestGetStatusTwice() {
func (suite *StatusTestSuite) TestGetStatusReplies() {
targetStatus := suite.testStatuses["local_account_1_status_1"]
- children, err := suite.db.GetStatusReplies(context.Background(), targetStatus.ID)
+ children, err := suite.db.GetStatusReplies(suite.T().Context(), targetStatus.ID)
suite.NoError(err)
suite.Len(children, 2)
for _, c := range children {
@@ -167,7 +166,7 @@ func (suite *StatusTestSuite) TestGetStatusReplies() {
func (suite *StatusTestSuite) TestGetStatusChildren() {
targetStatus := suite.testStatuses["local_account_1_status_1"]
- children, err := suite.db.GetStatusChildren(context.Background(), targetStatus.ID)
+ children, err := suite.db.GetStatusChildren(suite.T().Context(), targetStatus.ID)
suite.NoError(err)
suite.Len(children, 3)
}
@@ -177,10 +176,10 @@ func (suite *StatusTestSuite) TestDeleteStatus() {
targetStatus := >smodel.Status{}
*targetStatus = *suite.testStatuses["admin_account_status_1"]
- err := suite.db.DeleteStatusByID(context.Background(), targetStatus.ID)
+ err := suite.db.DeleteStatusByID(suite.T().Context(), targetStatus.ID)
suite.NoError(err)
- _, err = suite.db.GetStatusByID(context.Background(), targetStatus.ID)
+ _, err = suite.db.GetStatusByID(suite.T().Context(), targetStatus.ID)
suite.ErrorIs(err, db.ErrNoEntries)
}
@@ -201,16 +200,16 @@ func (suite *StatusTestSuite) TestUpdateStatus() {
targetStatus.PinnedAt = time.Time{}
- err := suite.db.UpdateStatus(context.Background(), targetStatus, "pinned_at")
+ err := suite.db.UpdateStatus(suite.T().Context(), targetStatus, "pinned_at")
suite.NoError(err)
- updated, err := suite.db.GetStatusByID(context.Background(), targetStatus.ID)
+ updated, err := suite.db.GetStatusByID(suite.T().Context(), targetStatus.ID)
suite.NoError(err)
suite.True(updated.PinnedAt.IsZero())
}
func (suite *StatusTestSuite) TestPutPopulatedStatus() {
- ctx := context.Background()
+ ctx := suite.T().Context()
targetStatus := >smodel.Status{}
*targetStatus = *suite.testStatuses["admin_account_status_1"]
diff --git a/internal/db/bundb/statusbookmark_test.go b/internal/db/bundb/statusbookmark_test.go
index c2977fdfb..51d4d4d20 100644
--- a/internal/db/bundb/statusbookmark_test.go
+++ b/internal/db/bundb/statusbookmark_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"errors"
"testing"
@@ -33,7 +32,7 @@ type StatusBookmarkTestSuite struct {
func (suite *StatusBookmarkTestSuite) TestGetStatusBookmarkOK() {
testBookmark := suite.testBookmarks["local_account_1_admin_account_status_1"]
- bookmark, err := suite.db.GetStatusBookmark(context.Background(), testBookmark.AccountID, testBookmark.StatusID)
+ bookmark, err := suite.db.GetStatusBookmark(suite.T().Context(), testBookmark.AccountID, testBookmark.StatusID)
suite.NoError(err)
suite.Equal(testBookmark.ID, bookmark.ID)
suite.Equal(testBookmark.AccountID, bookmark.AccountID)
@@ -41,7 +40,7 @@ func (suite *StatusBookmarkTestSuite) TestGetStatusBookmarkOK() {
}
func (suite *StatusBookmarkTestSuite) TestGetStatusBookmarkNonexisting() {
- bookmark, err := suite.db.GetStatusBookmark(context.Background(), "01GVAVGD06YJ2FSB5GJSMF8M2K", "01GVAVGKGR1MK9ZN7JCJFYSFZV")
+ bookmark, err := suite.db.GetStatusBookmark(suite.T().Context(), "01GVAVGD06YJ2FSB5GJSMF8M2K", "01GVAVGKGR1MK9ZN7JCJFYSFZV")
suite.Nil(bookmark)
suite.ErrorIs(err, db.ErrNoEntries)
}
@@ -49,7 +48,7 @@ func (suite *StatusBookmarkTestSuite) TestGetStatusBookmarkNonexisting() {
func (suite *StatusBookmarkTestSuite) IsStatusBookmarked() {
for _, bookmark := range suite.testBookmarks {
ok, err := suite.db.IsStatusBookmarked(
- context.Background(),
+ suite.T().Context(),
bookmark.StatusID,
)
suite.NoError(err)
@@ -60,12 +59,12 @@ func (suite *StatusBookmarkTestSuite) IsStatusBookmarked() {
func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarksOriginatingFromAccount() {
testAccount := suite.testAccounts["local_account_1"]
- 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())
}
bookmarks := []*gtsmodel.StatusBookmark{}
- if err := suite.db.GetAll(context.Background(), &bookmarks); err != nil && !errors.Is(err, db.ErrNoEntries) {
+ if err := suite.db.GetAll(suite.T().Context(), &bookmarks); err != nil && !errors.Is(err, db.ErrNoEntries) {
suite.FailNow(err.Error())
}
@@ -79,12 +78,12 @@ func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarksOriginatingFromAc
func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarksTargetingAccount() {
testAccount := suite.testAccounts["local_account_1"]
- 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())
}
bookmarks := []*gtsmodel.StatusBookmark{}
- if err := suite.db.GetAll(context.Background(), &bookmarks); err != nil && !errors.Is(err, db.ErrNoEntries) {
+ if err := suite.db.GetAll(suite.T().Context(), &bookmarks); err != nil && !errors.Is(err, db.ErrNoEntries) {
suite.FailNow(err.Error())
}
@@ -98,12 +97,12 @@ func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarksTargetingAccount(
func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarksTargetingStatus() {
testStatus := suite.testStatuses["local_account_1_status_1"]
- if err := suite.db.DeleteStatusBookmarksForStatus(context.Background(), testStatus.ID); err != nil {
+ if err := suite.db.DeleteStatusBookmarksForStatus(suite.T().Context(), testStatus.ID); err != nil {
suite.FailNow(err.Error())
}
bookmarks := []*gtsmodel.StatusBookmark{}
- if err := suite.db.GetAll(context.Background(), &bookmarks); err != nil && !errors.Is(err, db.ErrNoEntries) {
+ if err := suite.db.GetAll(suite.T().Context(), &bookmarks); err != nil && !errors.Is(err, db.ErrNoEntries) {
suite.FailNow(err.Error())
}
@@ -116,7 +115,7 @@ func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarksTargetingStatus()
func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarkByID() {
testBookmark := suite.testBookmarks["local_account_1_admin_account_status_1"]
- ctx := context.Background()
+ ctx := suite.T().Context()
if err := suite.db.DeleteStatusBookmarkByID(ctx, testBookmark.ID); err != nil {
suite.FailNow(err.Error())
@@ -128,7 +127,7 @@ func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarkByID() {
}
func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarkByIDNonExisting() {
- err := suite.db.DeleteStatusBookmarkByID(context.Background(), "01GVAV715K6Y2SG9ZKS9ZA8G7G")
+ err := suite.db.DeleteStatusBookmarkByID(suite.T().Context(), "01GVAV715K6Y2SG9ZKS9ZA8G7G")
suite.NoError(err)
}
diff --git a/internal/db/bundb/statusedit_test.go b/internal/db/bundb/statusedit_test.go
index 639e5ba9b..bb23ecc83 100644
--- a/internal/db/bundb/statusedit_test.go
+++ b/internal/db/bundb/statusedit_test.go
@@ -37,7 +37,7 @@ func (suite *StatusEditTestSuite) TestGetStatusEditBy() {
t := suite.T()
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Sentinel error to mark avoiding a test case.
@@ -78,7 +78,7 @@ func (suite *StatusEditTestSuite) TestGetStatusEditsByIDs() {
t := suite.T()
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// editsByStatus returns all test edits by the given status with ID.
@@ -115,7 +115,7 @@ func (suite *StatusEditTestSuite) TestGetStatusEditsByIDs() {
func (suite *StatusEditTestSuite) TestDeleteStatusEdits() {
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
for _, status := range suite.testStatuses {
diff --git a/internal/db/bundb/statusfave_test.go b/internal/db/bundb/statusfave_test.go
index 88f10e146..b31cc4640 100644
--- a/internal/db/bundb/statusfave_test.go
+++ b/internal/db/bundb/statusfave_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"errors"
"testing"
@@ -34,7 +33,7 @@ type StatusFaveTestSuite struct {
func (suite *StatusFaveTestSuite) TestGetStatusFaves() {
testStatus := suite.testStatuses["admin_account_status_1"]
- faves, err := suite.db.GetStatusFaves(context.Background(), testStatus.ID)
+ faves, err := suite.db.GetStatusFaves(suite.T().Context(), testStatus.ID)
if err != nil {
suite.FailNow(err.Error())
}
@@ -50,7 +49,7 @@ func (suite *StatusFaveTestSuite) TestGetStatusFaves() {
func (suite *StatusFaveTestSuite) TestGetStatusFavesNone() {
testStatus := suite.testStatuses["admin_account_status_4"]
- faves, err := suite.db.GetStatusFaves(context.Background(), testStatus.ID)
+ faves, err := suite.db.GetStatusFaves(suite.T().Context(), testStatus.ID)
if err != nil {
suite.FailNow(err.Error())
}
@@ -62,7 +61,7 @@ func (suite *StatusFaveTestSuite) TestGetStatusFaveByAccountID() {
testAccount := suite.testAccounts["local_account_1"]
testStatus := suite.testStatuses["admin_account_status_1"]
- fave, err := suite.db.GetStatusFave(context.Background(), testAccount.ID, testStatus.ID)
+ fave, err := suite.db.GetStatusFave(suite.T().Context(), testAccount.ID, testStatus.ID)
suite.NoError(err)
suite.NotNil(fave)
}
@@ -70,12 +69,12 @@ func (suite *StatusFaveTestSuite) TestGetStatusFaveByAccountID() {
func (suite *StatusFaveTestSuite) TestDeleteStatusFavesOriginatingFromAccount() {
testAccount := suite.testAccounts["local_account_1"]
- if err := suite.db.DeleteStatusFaves(context.Background(), "", testAccount.ID); err != nil {
+ if err := suite.db.DeleteStatusFaves(suite.T().Context(), "", testAccount.ID); err != nil {
suite.FailNow(err.Error())
}
faves := []*gtsmodel.StatusFave{}
- if err := suite.db.GetAll(context.Background(), &faves); err != nil && !errors.Is(err, db.ErrNoEntries) {
+ if err := suite.db.GetAll(suite.T().Context(), &faves); err != nil && !errors.Is(err, db.ErrNoEntries) {
suite.FailNow(err.Error())
}
@@ -89,12 +88,12 @@ func (suite *StatusFaveTestSuite) TestDeleteStatusFavesOriginatingFromAccount()
func (suite *StatusFaveTestSuite) TestDeleteStatusFavesTargetingAccount() {
testAccount := suite.testAccounts["local_account_1"]
- if err := suite.db.DeleteStatusFaves(context.Background(), testAccount.ID, ""); err != nil {
+ if err := suite.db.DeleteStatusFaves(suite.T().Context(), testAccount.ID, ""); err != nil {
suite.FailNow(err.Error())
}
faves := []*gtsmodel.StatusFave{}
- if err := suite.db.GetAll(context.Background(), &faves); err != nil && !errors.Is(err, db.ErrNoEntries) {
+ if err := suite.db.GetAll(suite.T().Context(), &faves); err != nil && !errors.Is(err, db.ErrNoEntries) {
suite.FailNow(err.Error())
}
@@ -108,12 +107,12 @@ func (suite *StatusFaveTestSuite) TestDeleteStatusFavesTargetingAccount() {
func (suite *StatusFaveTestSuite) TestDeleteStatusFavesTargetingStatus() {
testStatus := suite.testStatuses["local_account_1_status_1"]
- if err := suite.db.DeleteStatusFavesForStatus(context.Background(), testStatus.ID); err != nil {
+ if err := suite.db.DeleteStatusFavesForStatus(suite.T().Context(), testStatus.ID); err != nil {
suite.FailNow(err.Error())
}
faves := []*gtsmodel.StatusFave{}
- if err := suite.db.GetAll(context.Background(), &faves); err != nil && !errors.Is(err, db.ErrNoEntries) {
+ if err := suite.db.GetAll(suite.T().Context(), &faves); err != nil && !errors.Is(err, db.ErrNoEntries) {
suite.FailNow(err.Error())
}
@@ -126,7 +125,7 @@ func (suite *StatusFaveTestSuite) TestDeleteStatusFavesTargetingStatus() {
func (suite *StatusFaveTestSuite) TestDeleteStatusFave() {
testFave := suite.testFaves["local_account_1_admin_account_status_1"]
- ctx := context.Background()
+ ctx := suite.T().Context()
if err := suite.db.DeleteStatusFaveByID(ctx, testFave.ID); err != nil {
suite.FailNow(err.Error())
@@ -138,7 +137,7 @@ func (suite *StatusFaveTestSuite) TestDeleteStatusFave() {
}
func (suite *StatusFaveTestSuite) TestDeleteStatusFaveNonExisting() {
- err := suite.db.DeleteStatusFaveByID(context.Background(), "01GVAV715K6Y2SG9ZKS9ZA8G7G")
+ err := suite.db.DeleteStatusFaveByID(suite.T().Context(), "01GVAV715K6Y2SG9ZKS9ZA8G7G")
suite.NoError(err)
}
diff --git a/internal/db/bundb/tag_test.go b/internal/db/bundb/tag_test.go
index 62d6e8543..f6da8bb6b 100644
--- a/internal/db/bundb/tag_test.go
+++ b/internal/db/bundb/tag_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"errors"
"testing"
@@ -35,7 +34,7 @@ type TagTestSuite struct {
func (suite *TagTestSuite) TestGetTag() {
testTag := suite.testTags["welcome"]
- dbTag, err := suite.db.GetTag(context.Background(), testTag.ID)
+ dbTag, err := suite.db.GetTag(suite.T().Context(), testTag.ID)
suite.NoError(err)
suite.NotNil(dbTag)
suite.Equal(testTag.ID, dbTag.ID)
@@ -53,7 +52,7 @@ func (suite *TagTestSuite) TestGetTagByName() {
"Welcome",
"WELCoME ",
} {
- dbTag, err := suite.db.GetTagByName(context.Background(), name)
+ dbTag, err := suite.db.GetTagByName(suite.T().Context(), name)
suite.NoError(err)
suite.NotNil(dbTag)
suite.Equal(testTag.ID, dbTag.ID)
@@ -70,7 +69,7 @@ func (suite *TagTestSuite) TestPutTag() {
"NEWtag",
"NEWTAG ",
} {
- err := suite.db.PutTag(context.Background(), >smodel.Tag{
+ err := suite.db.PutTag(suite.T().Context(), >smodel.Tag{
ID: id.NewULID(),
Name: name,
})
diff --git a/internal/db/bundb/thread_test.go b/internal/db/bundb/thread_test.go
index d8b8d0b3b..0d34b6450 100644
--- a/internal/db/bundb/thread_test.go
+++ b/internal/db/bundb/thread_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
@@ -32,7 +31,7 @@ type ThreadTestSuite struct {
func (suite *ThreadTestSuite) TestPutThread() {
suite.NoError(
suite.db.PutThread(
- context.Background(),
+ suite.T().Context(),
>smodel.Thread{
ID: "01HCWK4HVQ4VGSS1G4VQP3AXZF",
},
@@ -44,7 +43,7 @@ func (suite *ThreadTestSuite) TestMuteUnmuteThread() {
var (
threadID = suite.testThreads["local_account_1_status_1"].ID
accountID = suite.testAccounts["local_account_1"].ID
- ctx = context.Background()
+ ctx = suite.T().Context()
threadMute = >smodel.ThreadMute{
ID: "01HD3K14B62YJHH4RR0DSZ1EQ2",
ThreadID: threadID,
diff --git a/internal/db/bundb/timeline_test.go b/internal/db/bundb/timeline_test.go
index 8f3bbe23e..3d3f06252 100644
--- a/internal/db/bundb/timeline_test.go
+++ b/internal/db/bundb/timeline_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/gtscontext"
@@ -110,7 +109,7 @@ func (suite *TimelineTestSuite) checkStatuses(statuses []*gtsmodel.Status, maxID
}
func (suite *TimelineTestSuite) TestGetPublicTimeline() {
- ctx := context.Background()
+ ctx := suite.T().Context()
page := toPage("", "", "", 20)
@@ -123,7 +122,7 @@ func (suite *TimelineTestSuite) TestGetPublicTimeline() {
}
func (suite *TimelineTestSuite) TestGetPublicTimelineLocal() {
- ctx := context.Background()
+ ctx := suite.T().Context()
page := toPage("", "", "", 20)
@@ -137,7 +136,7 @@ func (suite *TimelineTestSuite) TestGetPublicTimelineLocal() {
func (suite *TimelineTestSuite) TestGetHomeTimeline() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
viewingAccount = suite.testAccounts["local_account_1"]
)
@@ -153,7 +152,7 @@ func (suite *TimelineTestSuite) TestGetHomeTimeline() {
func (suite *TimelineTestSuite) TestGetHomeTimelineIgnoreExclusive() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
viewingAccount = suite.testAccounts["local_account_1"]
)
@@ -195,7 +194,7 @@ func (suite *TimelineTestSuite) TestGetHomeTimelineIgnoreExclusive() {
func (suite *TimelineTestSuite) TestGetHomeTimelineNoFollowing() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
viewingAccount = suite.testAccounts["local_account_1"]
)
@@ -229,7 +228,7 @@ func (suite *TimelineTestSuite) TestGetHomeTimelineNoFollowing() {
func (suite *TimelineTestSuite) TestGetHomeTimelineBackToFront() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
viewingAccount = suite.testAccounts["local_account_1"]
)
@@ -247,7 +246,7 @@ func (suite *TimelineTestSuite) TestGetHomeTimelineBackToFront() {
func (suite *TimelineTestSuite) TestGetHomeTimelineFromHighest() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
viewingAccount = suite.testAccounts["local_account_1"]
)
@@ -265,7 +264,7 @@ func (suite *TimelineTestSuite) TestGetHomeTimelineFromHighest() {
func (suite *TimelineTestSuite) TestGetListTimelineNoParams() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
list = suite.testLists["local_account_1_list_1"]
)
@@ -281,7 +280,7 @@ func (suite *TimelineTestSuite) TestGetListTimelineNoParams() {
func (suite *TimelineTestSuite) TestGetListTimelineMaxID() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
list = suite.testLists["local_account_1_list_1"]
)
@@ -299,7 +298,7 @@ func (suite *TimelineTestSuite) TestGetListTimelineMaxID() {
func (suite *TimelineTestSuite) TestGetListTimelineMinID() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
list = suite.testLists["local_account_1_list_1"]
)
@@ -317,7 +316,7 @@ func (suite *TimelineTestSuite) TestGetListTimelineMinID() {
func (suite *TimelineTestSuite) TestGetListTimelineMinIDPagingUp() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
list = suite.testLists["local_account_1_list_1"]
)
@@ -335,7 +334,7 @@ func (suite *TimelineTestSuite) TestGetListTimelineMinIDPagingUp() {
func (suite *TimelineTestSuite) TestGetTagTimelineNoParams() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
tag = suite.testTags["welcome"]
)
diff --git a/internal/db/bundb/user_test.go b/internal/db/bundb/user_test.go
index f5ece561d..a247bce42 100644
--- a/internal/db/bundb/user_test.go
+++ b/internal/db/bundb/user_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
@@ -30,25 +29,25 @@ type UserTestSuite struct {
}
func (suite *UserTestSuite) TestGetAllUsers() {
- users, err := suite.db.GetAllUsers(context.Background())
+ users, err := suite.db.GetAllUsers(suite.T().Context())
suite.NoError(err)
suite.Len(users, len(suite.testUsers))
}
func (suite *UserTestSuite) TestGetUser() {
- user, err := suite.db.GetUserByID(context.Background(), suite.testUsers["local_account_1"].ID)
+ user, err := suite.db.GetUserByID(suite.T().Context(), suite.testUsers["local_account_1"].ID)
suite.NoError(err)
suite.NotNil(user)
}
func (suite *UserTestSuite) TestGetUserByEmailAddress() {
- user, err := suite.db.GetUserByEmailAddress(context.Background(), suite.testUsers["local_account_1"].Email)
+ user, err := suite.db.GetUserByEmailAddress(suite.T().Context(), suite.testUsers["local_account_1"].Email)
suite.NoError(err)
suite.NotNil(user)
}
func (suite *UserTestSuite) TestGetUserByAccountID() {
- user, err := suite.db.GetUserByAccountID(context.Background(), suite.testAccounts["local_account_1"].ID)
+ user, err := suite.db.GetUserByAccountID(suite.T().Context(), suite.testAccounts["local_account_1"].ID)
suite.NoError(err)
suite.NotNil(user)
}
@@ -61,10 +60,10 @@ func (suite *UserTestSuite) TestUpdateUserSelectedColumns() {
updateUser.Email = "whatever"
updateUser.Locale = "es"
- err := suite.db.UpdateUser(context.Background(), updateUser)
+ err := suite.db.UpdateUser(suite.T().Context(), updateUser)
suite.NoError(err)
- dbUser, err := suite.db.GetUserByID(context.Background(), testUser.ID)
+ dbUser, err := suite.db.GetUserByID(suite.T().Context(), testUser.ID)
suite.NoError(err)
suite.NotNil(dbUser)
suite.Equal(updateUser.Email, dbUser.Email)
diff --git a/internal/db/bundb/webpush_test.go b/internal/db/bundb/webpush_test.go
index 8ca83955a..f750ca359 100644
--- a/internal/db/bundb/webpush_test.go
+++ b/internal/db/bundb/webpush_test.go
@@ -18,7 +18,6 @@
package bundb_test
import (
- "context"
"testing"
"github.com/stretchr/testify/suite"
@@ -30,7 +29,7 @@ type WebPushTestSuite struct {
// Get the text fixture VAPID key pair.
func (suite *WebPushTestSuite) TestGetVAPIDKeyPair() {
- ctx := context.Background()
+ ctx := suite.T().Context()
vapidKeyPair, err := suite.db.GetVAPIDKeyPair(ctx)
suite.NoError(err)
@@ -51,7 +50,7 @@ func (suite *WebPushTestSuite) TestGetVAPIDKeyPair() {
// Generate a VAPID key pair when there isn't one.
func (suite *WebPushTestSuite) TestGenerateVAPIDKeyPair() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Delete the text fixture VAPID key pair.
if err := suite.db.DeleteVAPIDKeyPair(ctx); !suite.NoError(err) {
diff --git a/internal/federation/dereferencing/account_test.go b/internal/federation/dereferencing/account_test.go
index 24ee16f82..518f3e89f 100644
--- a/internal/federation/dereferencing/account_test.go
+++ b/internal/federation/dereferencing/account_test.go
@@ -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"]
diff --git a/internal/federation/dereferencing/emoji_test.go b/internal/federation/dereferencing/emoji_test.go
index 3c77d5108..c8c905781 100644
--- a/internal/federation/dereferencing/emoji_test.go
+++ b/internal/federation/dereferencing/emoji_test.go
@@ -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"
diff --git a/internal/federation/dereferencing/instance_test.go b/internal/federation/dereferencing/instance_test.go
index 614e49035..53d5d9fdf 100644
--- a/internal/federation/dereferencing/instance_test.go
+++ b/internal/federation/dereferencing/instance_test.go
@@ -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,
)
diff --git a/internal/federation/dereferencing/status_test.go b/internal/federation/dereferencing/status_test.go
index 6f9ee9359..e44babbfc 100644
--- a/internal/federation/dereferencing/status_test.go
+++ b/internal/federation/dereferencing/status_test.go
@@ -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 := >smodel.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 := >smodel.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 := >smodel.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.
diff --git a/internal/federation/federatingactor_test.go b/internal/federation/federatingactor_test.go
index c08ddcbcf..51ead5f31 100644
--- a/internal/federation/federatingactor_test.go
+++ b/internal/federation/federatingactor_test.go
@@ -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"]
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 := >smodel.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"]
diff --git a/internal/federation/federatingprotocol_test.go b/internal/federation/federatingprotocol_test.go
index fa4950d82..ed0895ca8 100644
--- a/internal/federation/federatingprotocol_test.go
+++ b/internal/federation/federatingprotocol_test.go
@@ -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(), >smodel.Block{
+ if err := suite.state.DB.PutBlock(suite.T().Context(), >smodel.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(), >smodel.Block{
+ if err := suite.state.DB.PutBlock(suite.T().Context(), >smodel.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,
diff --git a/internal/federation/federator_test.go b/internal/federation/federator_test.go
index 5c07cfa85..755c9233b 100644
--- a/internal/federation/federator_test.go
+++ b/internal/federation/federator_test.go
@@ -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())
}
diff --git a/internal/filter/spam/statusable_test.go b/internal/filter/spam/statusable_test.go
index 7d710416f..0f31e627a 100644
--- a/internal/filter/spam/statusable_test.go
+++ b/internal/filter/spam/statusable_test.go
@@ -19,7 +19,6 @@ package spam_test
import (
"bytes"
- "context"
"io"
"testing"
@@ -621,7 +620,7 @@ const (
func (suite *StatusableTestSuite) TestStatusableOK() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
receiver = suite.testAccounts["local_account_1"]
requester = suite.testAccounts["remote_account_1"]
)
diff --git a/internal/filter/visibility/home_timeline_test.go b/internal/filter/visibility/home_timeline_test.go
index a152a64bc..d2be788e2 100644
--- a/internal/filter/visibility/home_timeline_test.go
+++ b/internal/filter/visibility/home_timeline_test.go
@@ -18,7 +18,6 @@
package visibility_test
import (
- "context"
"testing"
"time"
@@ -36,7 +35,7 @@ type StatusStatusHomeTimelineableTestSuite struct {
func (suite *StatusStatusHomeTimelineableTestSuite) TestOwnStatusHomeTimelineable() {
testStatus := suite.testStatuses["local_account_1_status_1"]
testAccount := suite.testAccounts["local_account_1"]
- ctx := context.Background()
+ ctx := suite.T().Context()
timelineable, err := suite.filter.StatusHomeTimelineable(ctx, testAccount, testStatus)
suite.NoError(err)
@@ -47,7 +46,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestOwnStatusHomeTimelineabl
func (suite *StatusStatusHomeTimelineableTestSuite) TestFollowingStatusHomeTimelineable() {
testStatus := suite.testStatuses["local_account_2_status_1"]
testAccount := suite.testAccounts["local_account_1"]
- ctx := context.Background()
+ ctx := suite.T().Context()
timelineable, err := suite.filter.StatusHomeTimelineable(ctx, testAccount, testStatus)
suite.NoError(err)
@@ -56,7 +55,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestFollowingStatusHomeTimel
}
func (suite *StatusStatusHomeTimelineableTestSuite) TestFollowingBoostedStatusHomeTimelineable() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testStatus := suite.testStatuses["admin_account_status_4"]
testAccount := suite.testAccounts["local_account_1"]
@@ -67,7 +66,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestFollowingBoostedStatusHo
}
func (suite *StatusStatusHomeTimelineableTestSuite) TestFollowingBoostedStatusHomeTimelineableNoReblogs() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Update follow to indicate that local_account_1
// doesn't want to see reblogs by admin_account.
@@ -90,7 +89,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestFollowingBoostedStatusHo
func (suite *StatusStatusHomeTimelineableTestSuite) TestNotFollowingStatusHomeTimelineable() {
testStatus := suite.testStatuses["remote_account_1_status_1"]
testAccount := suite.testAccounts["local_account_1"]
- ctx := context.Background()
+ ctx := suite.T().Context()
timelineable, err := suite.filter.StatusHomeTimelineable(ctx, testAccount, testStatus)
suite.NoError(err)
@@ -105,7 +104,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestStatusTooNewNotTimelinea
testStatus.CreatedAt = time.Now().Add(25 * time.Hour)
testAccount := suite.testAccounts["local_account_1"]
- ctx := context.Background()
+ ctx := suite.T().Context()
timelineable, err := suite.filter.StatusHomeTimelineable(ctx, testAccount, testStatus)
suite.NoError(err)
@@ -120,7 +119,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestStatusNotTooNewTimelinea
testStatus.CreatedAt = time.Now().Add(23 * time.Hour)
testAccount := suite.testAccounts["local_account_1"]
- ctx := context.Background()
+ ctx := suite.T().Context()
timelineable, err := suite.filter.StatusHomeTimelineable(ctx, testAccount, testStatus)
suite.NoError(err)
@@ -129,7 +128,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestStatusNotTooNewTimelinea
}
func (suite *StatusStatusHomeTimelineableTestSuite) TestThread() {
- ctx := context.Background()
+ ctx := suite.T().Context()
threadParentAccount := suite.testAccounts["local_account_1"]
timelineOwnerAccount := suite.testAccounts["local_account_2"]
@@ -173,7 +172,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestThread() {
}
func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyFollowersOnly() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// This scenario makes sure that we don't timeline a status which is a followers-only
// reply to a followers-only status TO A FOLLOWERS-ONLY STATUS owned by someone the
@@ -282,7 +281,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyFollowersOnly(
}
func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyPublicAndUnlocked() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// This scenario is exactly the same as the above test, but for a mix of unlocked + public posts
diff --git a/internal/filter/visibility/status_test.go b/internal/filter/visibility/status_test.go
index d7442089c..5abd13065 100644
--- a/internal/filter/visibility/status_test.go
+++ b/internal/filter/visibility/status_test.go
@@ -18,7 +18,6 @@
package visibility_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
@@ -33,7 +32,7 @@ type StatusVisibleTestSuite struct {
func (suite *StatusVisibleTestSuite) TestOwnStatusVisible() {
testStatus := suite.testStatuses["local_account_1_status_1"]
testAccount := suite.testAccounts["local_account_1"]
- ctx := context.Background()
+ ctx := suite.T().Context()
visible, err := suite.filter.StatusVisible(ctx, testAccount, testStatus)
suite.NoError(err)
@@ -42,7 +41,7 @@ func (suite *StatusVisibleTestSuite) TestOwnStatusVisible() {
}
func (suite *StatusVisibleTestSuite) TestOwnDMVisible() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testStatusID := suite.testStatuses["local_account_2_status_6"].ID
testStatus, err := suite.db.GetStatusByID(ctx, testStatusID)
@@ -56,7 +55,7 @@ func (suite *StatusVisibleTestSuite) TestOwnDMVisible() {
}
func (suite *StatusVisibleTestSuite) TestDMVisibleToTarget() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testStatusID := suite.testStatuses["local_account_2_status_6"].ID
testStatus, err := suite.db.GetStatusByID(ctx, testStatusID)
@@ -70,7 +69,7 @@ func (suite *StatusVisibleTestSuite) TestDMVisibleToTarget() {
}
func (suite *StatusVisibleTestSuite) TestDMNotVisibleIfNotMentioned() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testStatusID := suite.testStatuses["local_account_2_status_6"].ID
testStatus, err := suite.db.GetStatusByID(ctx, testStatusID)
@@ -84,7 +83,7 @@ func (suite *StatusVisibleTestSuite) TestDMNotVisibleIfNotMentioned() {
}
func (suite *StatusVisibleTestSuite) TestStatusNotVisibleIfNotMutuals() {
- ctx := context.Background()
+ ctx := suite.T().Context()
suite.db.DeleteByID(ctx, suite.testFollows["local_account_2_local_account_1"].ID, >smodel.Follow{})
@@ -100,7 +99,7 @@ func (suite *StatusVisibleTestSuite) TestStatusNotVisibleIfNotMutuals() {
}
func (suite *StatusVisibleTestSuite) TestStatusNotVisibleIfNotFollowing() {
- ctx := context.Background()
+ ctx := suite.T().Context()
suite.db.DeleteByID(ctx, suite.testFollows["admin_account_local_account_1"].ID, >smodel.Follow{})
@@ -116,7 +115,7 @@ func (suite *StatusVisibleTestSuite) TestStatusNotVisibleIfNotFollowing() {
}
func (suite *StatusVisibleTestSuite) TestStatusNotVisibleIfNotMutualsCached() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testStatusID := suite.testStatuses["local_account_1_status_4"].ID
testStatus, err := suite.db.GetStatusByID(ctx, testStatusID)
suite.NoError(err)
@@ -137,7 +136,7 @@ func (suite *StatusVisibleTestSuite) TestStatusNotVisibleIfNotMutualsCached() {
}
func (suite *StatusVisibleTestSuite) TestStatusNotVisibleIfNotFollowingCached() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testStatusID := suite.testStatuses["local_account_1_status_5"].ID
testStatus, err := suite.db.GetStatusByID(ctx, testStatusID)
suite.NoError(err)
@@ -158,7 +157,7 @@ func (suite *StatusVisibleTestSuite) TestStatusNotVisibleIfNotFollowingCached()
}
func (suite *StatusVisibleTestSuite) TestVisiblePending() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Copy the test status and mark
// the copy as pending approval.
@@ -241,7 +240,7 @@ func (suite *StatusVisibleTestSuite) TestVisiblePending() {
}
func (suite *StatusVisibleTestSuite) TestVisibleLocalOnly() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Local-only, Public status.
testStatus := suite.testStatuses["local_account_2_status_4"]
diff --git a/internal/media/ffmpeg.go b/internal/media/ffmpeg.go
index 41cc2666f..676eba9be 100644
--- a/internal/media/ffmpeg.go
+++ b/internal/media/ffmpeg.go
@@ -348,11 +348,10 @@ func (res *result) GetFileType() (gtsmodel.FileType, string, string) {
// video file aka gifv.
return gtsmodel.FileTypeGifv,
"video/mp4", "mp4"
- } else {
- // Video file (with or without audio).
- return gtsmodel.FileTypeVideo,
- "video/mp4", "mp4"
}
+ // Video file (with or without audio).
+ return gtsmodel.FileTypeVideo,
+ "video/mp4", "mp4"
case len(res.audio) > 0 &&
res.audio[0].codec == "aac":
// m4a only supports [aac] audio.
diff --git a/internal/media/manager_test.go b/internal/media/manager_test.go
index 4988c2485..6182babbb 100644
--- a/internal/media/manager_test.go
+++ b/internal/media/manager_test.go
@@ -44,7 +44,7 @@ type ManagerTestSuite struct {
}
func (suite *ManagerTestSuite) TestEmojiProcess() {
- ctx := context.Background()
+ ctx := suite.T().Context()
data := func(_ context.Context) (io.ReadCloser, error) {
// load bytes from a test image
@@ -84,7 +84,7 @@ func (suite *ManagerTestSuite) TestEmojiProcess() {
}
func (suite *ManagerTestSuite) TestEmojiProcessRefresh() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// we're going to 'refresh' the remote 'yell' emoji by changing the image url to the pixellated gts logo
originalEmoji := suite.testEmojis["yell"]
@@ -157,7 +157,7 @@ func (suite *ManagerTestSuite) TestEmojiProcessRefresh() {
}
func (suite *ManagerTestSuite) TestEmojiProcessTooLarge() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Open test image as file for reading.
file, err := os.Open("./test/big-panda.gif")
@@ -191,7 +191,7 @@ func (suite *ManagerTestSuite) TestEmojiProcessTooLarge() {
}
func (suite *ManagerTestSuite) TestEmojiWebpProcess() {
- ctx := context.Background()
+ ctx := suite.T().Context()
data := func(_ context.Context) (io.ReadCloser, error) {
// load bytes from a test image
@@ -232,7 +232,7 @@ func (suite *ManagerTestSuite) TestEmojiWebpProcess() {
}
func (suite *ManagerTestSuite) TestSimpleJpegProcess() {
- ctx := context.Background()
+ ctx := suite.T().Context()
data := func(_ context.Context) (io.ReadCloser, error) {
// load bytes from a test image
@@ -288,7 +288,7 @@ func (suite *ManagerTestSuite) TestSimpleJpegProcess() {
}
func (suite *ManagerTestSuite) TestSimpleJpegProcessTooLarge() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Open test image as file for reading.
file, err := os.Open("./test/test-jpeg.jpg")
@@ -325,7 +325,7 @@ func (suite *ManagerTestSuite) TestSimpleJpegProcessTooLarge() {
}
func (suite *ManagerTestSuite) TestPDFProcess() {
- ctx := context.Background()
+ ctx := suite.T().Context()
data := func(_ context.Context) (io.ReadCloser, error) {
// load bytes from Frantz
@@ -381,7 +381,7 @@ func (suite *ManagerTestSuite) TestPDFProcess() {
}
func (suite *ManagerTestSuite) TestSlothVineProcess() {
- ctx := context.Background()
+ ctx := suite.T().Context()
data := func(_ context.Context) (io.ReadCloser, error) {
// load bytes from a test video
@@ -441,7 +441,7 @@ func (suite *ManagerTestSuite) TestSlothVineProcess() {
}
func (suite *ManagerTestSuite) TestAnimatedGifProcess() {
- ctx := context.Background()
+ ctx := suite.T().Context()
data := func(_ context.Context) (io.ReadCloser, error) {
// load bytes from a test image
@@ -506,7 +506,7 @@ func (suite *ManagerTestSuite) TestAnimatedGifProcess() {
}
func (suite *ManagerTestSuite) TestLongerMp4Process() {
- ctx := context.Background()
+ ctx := suite.T().Context()
data := func(_ context.Context) (io.ReadCloser, error) {
// load bytes from a test video
@@ -566,7 +566,7 @@ func (suite *ManagerTestSuite) TestLongerMp4Process() {
}
func (suite *ManagerTestSuite) TestBirdnestMp4Process() {
- ctx := context.Background()
+ ctx := suite.T().Context()
data := func(_ context.Context) (io.ReadCloser, error) {
// load bytes from a test video
@@ -626,7 +626,7 @@ func (suite *ManagerTestSuite) TestBirdnestMp4Process() {
}
func (suite *ManagerTestSuite) TestOpusProcess() {
- ctx := context.Background()
+ ctx := suite.T().Context()
data := func(_ context.Context) (io.ReadCloser, error) {
// load bytes from a test image
@@ -678,7 +678,7 @@ func (suite *ManagerTestSuite) TestOpusProcess() {
}
func (suite *ManagerTestSuite) TestPngNoAlphaChannelProcess() {
- ctx := context.Background()
+ ctx := suite.T().Context()
data := func(_ context.Context) (io.ReadCloser, error) {
// load bytes from a test image
@@ -734,7 +734,7 @@ func (suite *ManagerTestSuite) TestPngNoAlphaChannelProcess() {
}
func (suite *ManagerTestSuite) TestPngAlphaChannelProcess() {
- ctx := context.Background()
+ ctx := suite.T().Context()
data := func(_ context.Context) (io.ReadCloser, error) {
// load bytes from a test image
@@ -790,7 +790,7 @@ func (suite *ManagerTestSuite) TestPngAlphaChannelProcess() {
}
func (suite *ManagerTestSuite) TestSimpleJpegProcessWithCallback() {
- ctx := context.Background()
+ ctx := suite.T().Context()
data := func(_ context.Context) (io.ReadCloser, error) {
// load bytes from a test image
@@ -846,7 +846,7 @@ func (suite *ManagerTestSuite) TestSimpleJpegProcessWithCallback() {
}
func (suite *ManagerTestSuite) TestSimpleJpegProcessWithDiskStorage() {
- ctx := context.Background()
+ ctx := suite.T().Context()
data := func(_ context.Context) (io.ReadCloser, error) {
// load bytes from a test image
@@ -951,7 +951,7 @@ func (suite *ManagerTestSuite) TestSmallSizedMediaTypeDetection_issue2263() {
},
} {
suite.Run(test.name, func() {
- ctx, cncl := context.WithTimeout(context.Background(), time.Second*60)
+ ctx, cncl := context.WithTimeout(suite.T().Context(), time.Second*60)
defer cncl()
data := func(_ context.Context) (io.ReadCloser, error) {
@@ -1002,7 +1002,7 @@ func TestManagerTestSuite(t *testing.T) {
// equalFiles checks whether
func equalFiles(t *testing.T, st *storage.Driver, storagePath, testPath string) {
- b1, err := st.Get(context.Background(), storagePath)
+ b1, err := st.Get(t.Context(), storagePath)
if err != nil {
t.Fatalf("error reading file %s: %v", storagePath, err)
}
diff --git a/internal/media/refetch_test.go b/internal/media/refetch_test.go
index c59b37d8d..cd9fb9468 100644
--- a/internal/media/refetch_test.go
+++ b/internal/media/refetch_test.go
@@ -18,7 +18,6 @@
package media_test
import (
- "context"
"testing"
"github.com/stretchr/testify/suite"
@@ -29,7 +28,7 @@ type RefetchTestSuite struct {
}
func (suite *RefetchTestSuite) TestRefetchEmojisNothingToDo() {
- ctx := context.Background()
+ ctx := suite.T().Context()
adminAccount := suite.testAccounts["admin_account"]
transport, err := suite.transportController.NewTransportForUsername(ctx, adminAccount.Username)
@@ -43,7 +42,7 @@ func (suite *RefetchTestSuite) TestRefetchEmojisNothingToDo() {
}
func (suite *RefetchTestSuite) TestRefetchEmojis() {
- ctx := context.Background()
+ ctx := suite.T().Context()
if err := suite.storage.Delete(ctx, suite.testEmojis["yell"].ImagePath); err != nil {
suite.FailNow(err.Error())
@@ -61,7 +60,7 @@ func (suite *RefetchTestSuite) TestRefetchEmojis() {
}
func (suite *RefetchTestSuite) TestRefetchEmojisLocal() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// delete the image for a LOCAL emoji
if err := suite.storage.Delete(ctx, suite.testEmojis["rainbow"].ImagePath); err != nil {
diff --git a/internal/middleware/headerfilter_test.go b/internal/middleware/headerfilter_test.go
index 4ad40b86f..28c5254b3 100644
--- a/internal/middleware/headerfilter_test.go
+++ b/internal/middleware/headerfilter_test.go
@@ -18,7 +18,6 @@
package middleware_test
import (
- "context"
"fmt"
"net/http"
"net/http/httptest"
@@ -210,10 +209,7 @@ func TestHeaderFilter(t *testing.T) {
func testHeaderFilter(t *testing.T, allow, block []filter, input http.Header, expect bool) {
var err error
- // Create test context with cancel.
- ctx := context.Background()
- ctx, cncl := context.WithCancel(ctx)
- defer cncl()
+ ctx := t.Context()
// Initialize caches.
var state state.State
diff --git a/internal/oauth/clientstore_test.go b/internal/oauth/clientstore_test.go
index 73e070002..e7c67782d 100644
--- a/internal/oauth/clientstore_test.go
+++ b/internal/oauth/clientstore_test.go
@@ -18,7 +18,6 @@
package oauth_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/admin"
@@ -60,7 +59,7 @@ func (suite *ClientStoreTestSuite) TestClientStoreGet() {
cs := oauth.NewClientStore(&suite.state)
// Fetch clientInfo from the store.
- clientInfo, err := cs.GetByID(context.Background(), testApp.ClientID)
+ clientInfo, err := cs.GetByID(suite.T().Context(), testApp.ClientID)
if err != nil {
suite.FailNow(err.Error())
}
diff --git a/internal/processing/account/account_test.go b/internal/processing/account/account_test.go
index 5c80922e6..4af63d1b3 100644
--- a/internal/processing/account/account_test.go
+++ b/internal/processing/account/account_test.go
@@ -67,7 +67,7 @@ type AccountStandardTestSuite struct {
}
func (suite *AccountStandardTestSuite) getClientMsg(timeout time.Duration) (*messages.FromClientAPI, bool) {
- ctx := context.Background()
+ ctx := suite.T().Context()
ctx, cncl := context.WithTimeout(ctx, timeout)
defer cncl()
return suite.state.Workers.Client.Queue.PopCtx(ctx)
diff --git a/internal/processing/account/alias_test.go b/internal/processing/account/alias_test.go
index f3231cd74..fef2335ec 100644
--- a/internal/processing/account/alias_test.go
+++ b/internal/processing/account/alias_test.go
@@ -18,7 +18,6 @@
package account_test
import (
- "context"
"slices"
"testing"
@@ -145,7 +144,7 @@ func (suite *AliasTestSuite) TestAliasAccount() {
},
} {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testAcct = new(gtsmodel.Account)
)
diff --git a/internal/processing/account/delete_test.go b/internal/processing/account/delete_test.go
index fd19099c3..93bc1f9c4 100644
--- a/internal/processing/account/delete_test.go
+++ b/internal/processing/account/delete_test.go
@@ -18,7 +18,6 @@
package account_test
import (
- "context"
"net"
"testing"
"time"
@@ -32,7 +31,7 @@ type AccountDeleteTestSuite struct {
}
func (suite *AccountDeleteTestSuite) TestAccountDeleteLocal() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Keep a reference around to the original account
// and user, before the delete was processed.
diff --git a/internal/processing/account/follow_test.go b/internal/processing/account/follow_test.go
index 68653f329..d68d8d065 100644
--- a/internal/processing/account/follow_test.go
+++ b/internal/processing/account/follow_test.go
@@ -18,7 +18,6 @@
package account_test
import (
- "context"
"testing"
"time"
@@ -33,7 +32,7 @@ type FollowTestSuite struct {
}
func (suite *FollowTestSuite) TestUpdateExistingFollowChangeBoth() {
- ctx := context.Background()
+ ctx := suite.T().Context()
requestingAccount := suite.testAccounts["local_account_1"]
targetAccount := suite.testAccounts["admin_account"]
@@ -54,7 +53,7 @@ func (suite *FollowTestSuite) TestUpdateExistingFollowChangeBoth() {
}
func (suite *FollowTestSuite) TestUpdateExistingFollowChangeNotifyIgnoreReblogs() {
- ctx := context.Background()
+ ctx := suite.T().Context()
requestingAccount := suite.testAccounts["local_account_1"]
targetAccount := suite.testAccounts["admin_account"]
@@ -74,7 +73,7 @@ func (suite *FollowTestSuite) TestUpdateExistingFollowChangeNotifyIgnoreReblogs(
}
func (suite *FollowTestSuite) TestUpdateExistingFollowChangeNotifySetReblogs() {
- ctx := context.Background()
+ ctx := suite.T().Context()
requestingAccount := suite.testAccounts["local_account_1"]
targetAccount := suite.testAccounts["admin_account"]
@@ -95,7 +94,7 @@ func (suite *FollowTestSuite) TestUpdateExistingFollowChangeNotifySetReblogs() {
}
func (suite *FollowTestSuite) TestUpdateExistingFollowChangeNothing() {
- ctx := context.Background()
+ ctx := suite.T().Context()
requestingAccount := suite.testAccounts["local_account_1"]
targetAccount := suite.testAccounts["admin_account"]
@@ -115,7 +114,7 @@ func (suite *FollowTestSuite) TestUpdateExistingFollowChangeNothing() {
}
func (suite *FollowTestSuite) TestUpdateExistingFollowSetNothing() {
- ctx := context.Background()
+ ctx := suite.T().Context()
requestingAccount := suite.testAccounts["local_account_1"]
targetAccount := suite.testAccounts["admin_account"]
@@ -133,7 +132,7 @@ func (suite *FollowTestSuite) TestUpdateExistingFollowSetNothing() {
}
func (suite *FollowTestSuite) TestFollowRequestLocal() {
- ctx := context.Background()
+ ctx := suite.T().Context()
requestingAccount := suite.testAccounts["admin_account"]
targetAccount := suite.testAccounts["local_account_2"]
diff --git a/internal/processing/account/move_test.go b/internal/processing/account/move_test.go
index 54b016528..55d6548db 100644
--- a/internal/processing/account/move_test.go
+++ b/internal/processing/account/move_test.go
@@ -18,7 +18,6 @@
package account_test
import (
- "context"
"testing"
"time"
@@ -34,7 +33,7 @@ type MoveTestSuite struct {
}
func (suite *MoveTestSuite) TestMoveAccountOK() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Copy zork.
requestingAcct := new(gtsmodel.Account)
@@ -106,7 +105,7 @@ func (suite *MoveTestSuite) TestMoveAccountOK() {
}
func (suite *MoveTestSuite) TestMoveAccountNotAliased() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Copy zork.
requestingAcct := new(gtsmodel.Account)
@@ -136,7 +135,7 @@ func (suite *MoveTestSuite) TestMoveAccountNotAliased() {
}
func (suite *MoveTestSuite) TestMoveAccountBadPassword() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Copy zork.
requestingAcct := new(gtsmodel.Account)
diff --git a/internal/processing/account/rss_test.go b/internal/processing/account/rss_test.go
index 9b6b1ee75..0b64e8464 100644
--- a/internal/processing/account/rss_test.go
+++ b/internal/processing/account/rss_test.go
@@ -18,7 +18,6 @@
package account_test
import (
- "context"
"testing"
"github.com/stretchr/testify/suite"
@@ -29,7 +28,7 @@ type GetRSSTestSuite struct {
}
func (suite *GetRSSTestSuite) TestGetAccountRSSAdmin() {
- getFeed, lastModified, err := suite.accountProcessor.GetRSSFeedForUsername(context.Background(), "admin")
+ getFeed, lastModified, err := suite.accountProcessor.GetRSSFeedForUsername(suite.T().Context(), "admin")
suite.NoError(err)
suite.EqualValues(1634726497, lastModified.Unix())
@@ -68,7 +67,7 @@ func (suite *GetRSSTestSuite) TestGetAccountRSSAdmin() {
}
func (suite *GetRSSTestSuite) TestGetAccountRSSZork() {
- getFeed, lastModified, err := suite.accountProcessor.GetRSSFeedForUsername(context.Background(), "the_mighty_zork")
+ getFeed, lastModified, err := suite.accountProcessor.GetRSSFeedForUsername(suite.T().Context(), "the_mighty_zork")
suite.NoError(err)
suite.EqualValues(1730451600, lastModified.Unix())
@@ -156,7 +155,7 @@ func (suite *GetRSSTestSuite) TestGetAccountRSSZork() {
}
func (suite *GetRSSTestSuite) TestGetAccountRSSZorkNoPosts() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Get all of zork's posts.
statuses, err := suite.db.GetAccountStatuses(ctx, suite.testAccounts["local_account_1"].ID, 0, false, false, "", "", false, false)
diff --git a/internal/processing/account/update_test.go b/internal/processing/account/update_test.go
index 52895a463..b6e315d41 100644
--- a/internal/processing/account/update_test.go
+++ b/internal/processing/account/update_test.go
@@ -18,7 +18,6 @@
package account_test
import (
- "context"
"testing"
"time"
@@ -38,7 +37,7 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateSimple() {
*testAccount = *suite.testAccounts["local_account_1"]
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
locked = true
displayName = "new display name"
note = "#hello here i am!"
@@ -88,7 +87,7 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateWithMention() {
*testAccount = *suite.testAccounts["local_account_1"]
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
locked = true
displayName = "new display name"
note = "#hello here i am!\n\ngo check out @1happyturtle, they have a cool account!"
@@ -144,7 +143,7 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateWithMarkdownNote() {
testAccount.Settings = settings
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
note = "*hello* ~~here~~ i am!"
noteExpected = `hello here i am!
`
)
@@ -193,7 +192,7 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateWithFields() {
*testAccount = *suite.testAccounts["local_account_1"]
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
updateFields = []apimodel.UpdateField{
{
Name: func() *string { s := "favourite emoji"; return &s }(),
@@ -287,7 +286,7 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateNoteNotFields() {
*testAccount = *suite.testAccounts["local_account_2"]
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
fieldsRawBefore = len(testAccount.FieldsRaw)
fieldsBefore = len(testAccount.Fields)
note = "#hello here i am!"
@@ -335,7 +334,7 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateNoteNotFields() {
func (suite *AccountUpdateTestSuite) TestAccountUpdateBotNotBot() {
testAccount := >smodel.Account{}
*testAccount = *suite.testAccounts["local_account_1"]
- ctx := context.Background()
+ ctx := suite.T().Context()
// Call update function to set bot = true.
apiAccount, errWithCode := suite.accountProcessor.Update(
diff --git a/internal/processing/admin/account_test.go b/internal/processing/admin/account_test.go
index 76c4c82f5..34eb1d2fd 100644
--- a/internal/processing/admin/account_test.go
+++ b/internal/processing/admin/account_test.go
@@ -18,7 +18,6 @@
package admin_test
import (
- "context"
"testing"
apimodel "code.superseriousbusiness.org/gotosocial/internal/api/model"
@@ -33,7 +32,7 @@ type AccountTestSuite struct {
func (suite *AccountTestSuite) TestAccountActionSuspend() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
adminAcct = suite.testAccounts["admin_account"]
request = &apimodel.AdminActionRequest{
Category: gtsmodel.AdminActionCategoryAccount.String(),
@@ -79,7 +78,7 @@ func (suite *AccountTestSuite) TestAccountActionSuspend() {
func (suite *AccountTestSuite) TestAccountActionUnsupported() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
adminAcct = suite.testAccounts["admin_account"]
request = &apimodel.AdminActionRequest{
Category: gtsmodel.AdminActionCategoryAccount.String(),
diff --git a/internal/processing/admin/domainpermission_test.go b/internal/processing/admin/domainpermission_test.go
index f53c241b6..fccb9e10f 100644
--- a/internal/processing/admin/domainpermission_test.go
+++ b/internal/processing/admin/domainpermission_test.go
@@ -82,7 +82,7 @@ func (suite *DomainBlockTestSuite) runDomainPermTest(t domainPermTest) {
config.SetInstanceFederationMode(t.instanceFederationMode)
for _, action := range t.actions {
- ctx, cancel := context.WithCancel(context.Background())
+ ctx, cancel := context.WithCancel(suite.T().Context())
defer cancel()
// Run the desired action.
@@ -102,7 +102,7 @@ func (suite *DomainBlockTestSuite) runDomainPermTest(t domainPermTest) {
// Check expected results
// against each account.
accounts, err := suite.db.GetInstanceAccounts(
- context.Background(),
+ suite.T().Context(),
action.domain,
"", 0,
)
@@ -123,7 +123,7 @@ func (suite *DomainBlockTestSuite) createDomainPerm(
permissionType gtsmodel.DomainPermissionType,
domain string,
) (*apimodel.DomainPermission, string) {
- ctx := context.Background()
+ ctx := suite.T().Context()
apiPerm, actionID, errWithCode := suite.adminProcessor.DomainPermissionCreate(
ctx,
@@ -148,7 +148,7 @@ func (suite *DomainBlockTestSuite) deleteDomainPerm(
domain string,
) (*apimodel.DomainPermission, string) {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
domainPermission gtsmodel.DomainPermission
)
@@ -183,7 +183,7 @@ func (suite *DomainBlockTestSuite) deleteDomainPerm(
// waits for given actionID to be completed.
func (suite *DomainBlockTestSuite) awaitAction(actionID string) {
- ctx := context.Background()
+ ctx := suite.T().Context()
if !testrig.WaitFor(func() bool {
return suite.state.AdminActions.TotalRunning() == 0
diff --git a/internal/processing/admin/emoji_test.go b/internal/processing/admin/emoji_test.go
index 4968ad1af..b050cefe8 100644
--- a/internal/processing/admin/emoji_test.go
+++ b/internal/processing/admin/emoji_test.go
@@ -18,7 +18,6 @@
package admin_test
import (
- "context"
"testing"
apimodel "code.superseriousbusiness.org/gotosocial/internal/api/model"
@@ -32,7 +31,7 @@ type EmojiTestSuite struct {
}
func (suite *EmojiTestSuite) TestUpdateEmojiCategory() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testEmoji := new(gtsmodel.Emoji)
*testEmoji = *suite.testEmojis["rainbow"]
diff --git a/internal/processing/admin/signupapprove_test.go b/internal/processing/admin/signupapprove_test.go
index 7203c3223..5739325c2 100644
--- a/internal/processing/admin/signupapprove_test.go
+++ b/internal/processing/admin/signupapprove_test.go
@@ -18,7 +18,6 @@
package admin_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
@@ -32,7 +31,7 @@ type AdminApproveTestSuite struct {
func (suite *AdminApproveTestSuite) TestApprove() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
adminAcct = suite.testAccounts["admin_account"]
targetAcct = suite.testAccounts["unconfirmed_account"]
targetUser = new(gtsmodel.User)
diff --git a/internal/processing/admin/signupreject_test.go b/internal/processing/admin/signupreject_test.go
index 2017c6364..ea517f579 100644
--- a/internal/processing/admin/signupreject_test.go
+++ b/internal/processing/admin/signupreject_test.go
@@ -18,7 +18,6 @@
package admin_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/db"
@@ -33,7 +32,7 @@ type AdminRejectTestSuite struct {
func (suite *AdminRejectTestSuite) TestReject() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
adminAcct = suite.testAccounts["admin_account"]
targetAcct = suite.testAccounts["unconfirmed_account"]
targetUser = suite.testUsers["unconfirmed_account"]
@@ -95,7 +94,7 @@ func (suite *AdminRejectTestSuite) TestReject() {
func (suite *AdminRejectTestSuite) TestRejectRemote() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
adminAcct = suite.testAccounts["admin_account"]
targetAcct = suite.testAccounts["remote_account_1"]
privateComment = "It's a no from me chief."
@@ -117,7 +116,7 @@ func (suite *AdminRejectTestSuite) TestRejectRemote() {
func (suite *AdminRejectTestSuite) TestRejectApproved() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
adminAcct = suite.testAccounts["admin_account"]
targetAcct = suite.testAccounts["local_account_1"]
privateComment = "It's a no from me chief."
diff --git a/internal/processing/admin/workertask_test.go b/internal/processing/admin/workertask_test.go
index 37b7059d7..8ce0a3436 100644
--- a/internal/processing/admin/workertask_test.go
+++ b/internal/processing/admin/workertask_test.go
@@ -94,7 +94,7 @@ type WorkerTaskTestSuite struct {
}
func (suite *WorkerTaskTestSuite) TestFillWorkerQueues() {
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
var tasks []*gtsmodel.WorkerTask
@@ -255,7 +255,7 @@ func (suite *WorkerTaskTestSuite) TestFillWorkerQueues() {
}
func (suite *WorkerTaskTestSuite) TestPersistWorkerQueues() {
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Push all test worker tasks to their respective queues.
diff --git a/internal/processing/conversations/conversations_test.go b/internal/processing/conversations/conversations_test.go
index 0f96ecbac..40145c2fb 100644
--- a/internal/processing/conversations/conversations_test.go
+++ b/internal/processing/conversations/conversations_test.go
@@ -75,7 +75,7 @@ type ConversationsTestSuite struct {
}
func (suite *ConversationsTestSuite) getClientMsg(timeout time.Duration) (*messages.FromClientAPI, bool) {
- ctx := context.Background()
+ ctx := suite.T().Context()
ctx, cncl := context.WithTimeout(ctx, timeout)
defer cncl()
return suite.state.Workers.Client.Queue.PopCtx(ctx)
@@ -130,8 +130,8 @@ func (suite *ConversationsTestSuite) TearDownTest() {
(*gtsmodel.ConversationToStatus)(nil),
}
for _, model := range conversationModels {
- if err := suite.db.DropTable(context.Background(), model); err != nil {
- log.Error(context.Background(), err)
+ if err := suite.db.DropTable(suite.T().Context(), model); err != nil {
+ log.Error(suite.T().Context(), err)
}
}
diff --git a/internal/processing/conversations/delete_test.go b/internal/processing/conversations/delete_test.go
index 23b4f1c1a..d3d8d47a6 100644
--- a/internal/processing/conversations/delete_test.go
+++ b/internal/processing/conversations/delete_test.go
@@ -17,11 +17,9 @@
package conversations_test
-import "context"
-
func (suite *ConversationsTestSuite) TestDelete() {
conversation := suite.NewTestConversation(suite.testAccount, 0)
- err := suite.conversationsProcessor.Delete(context.Background(), suite.testAccount, conversation.ID)
+ err := suite.conversationsProcessor.Delete(suite.T().Context(), suite.testAccount, conversation.ID)
suite.NoError(err)
}
diff --git a/internal/processing/conversations/get_test.go b/internal/processing/conversations/get_test.go
index ea8794601..9106c930c 100644
--- a/internal/processing/conversations/get_test.go
+++ b/internal/processing/conversations/get_test.go
@@ -18,7 +18,6 @@
package conversations_test
import (
- "context"
"time"
apimodel "code.superseriousbusiness.org/gotosocial/internal/api/model"
@@ -27,7 +26,7 @@ import (
func (suite *ConversationsTestSuite) TestGetAll() {
conversation := suite.NewTestConversation(suite.testAccount, 0)
- resp, err := suite.conversationsProcessor.GetAll(context.Background(), suite.testAccount, nil)
+ resp, err := suite.conversationsProcessor.GetAll(suite.T().Context(), suite.testAccount, nil)
if suite.NoError(err) && suite.Len(resp.Items, 1) && suite.IsType((*apimodel.Conversation)(nil), resp.Items[0]) {
apiConversation := resp.Items[0].(*apimodel.Conversation)
suite.Equal(conversation.ID, apiConversation.ID)
@@ -46,11 +45,11 @@ func (suite *ConversationsTestSuite) TestGetAllOrder() {
// Add an even newer status than that to conversation1.
conversation1Status2 := suite.NewTestStatus(suite.testAccount, conversation1.LastStatus.ThreadID, 2*time.Second, conversation1.LastStatus)
conversation1.LastStatusID = conversation1Status2.ID
- if err := suite.db.UpsertConversation(context.Background(), conversation1, "last_status_id"); err != nil {
+ if err := suite.db.UpsertConversation(suite.T().Context(), conversation1, "last_status_id"); err != nil {
suite.FailNow(err.Error())
}
- resp, err := suite.conversationsProcessor.GetAll(context.Background(), suite.testAccount, nil)
+ resp, err := suite.conversationsProcessor.GetAll(suite.T().Context(), suite.testAccount, nil)
if suite.NoError(err) && suite.Len(resp.Items, 2) {
// conversation1 should be the first conversation returned.
apiConversation1 := resp.Items[0].(*apimodel.Conversation)
diff --git a/internal/processing/conversations/migrate_test.go b/internal/processing/conversations/migrate_test.go
index 7253b30a6..a6e506e49 100644
--- a/internal/processing/conversations/migrate_test.go
+++ b/internal/processing/conversations/migrate_test.go
@@ -18,8 +18,6 @@
package conversations_test
import (
- "context"
-
"code.superseriousbusiness.org/gotosocial/internal/db"
"code.superseriousbusiness.org/gotosocial/internal/db/bundb"
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
@@ -29,7 +27,7 @@ import (
// This test assumes that we're using the standard test fixtures, which contain some conversation-eligible DMs.
func (suite *ConversationsTestSuite) TestMigrateDMsToConversations() {
advancedMigrationID := "20240611190733_add_conversations"
- ctx := context.Background()
+ ctx := suite.T().Context()
rawDB := (suite.db).(*bundb.DBService).DB()
// Precondition: we shouldn't have any conversations yet.
diff --git a/internal/processing/conversations/read_test.go b/internal/processing/conversations/read_test.go
index 3b86326fd..a15ddcca3 100644
--- a/internal/processing/conversations/read_test.go
+++ b/internal/processing/conversations/read_test.go
@@ -18,8 +18,6 @@
package conversations_test
import (
- "context"
-
"code.superseriousbusiness.org/gotosocial/internal/util"
)
@@ -27,7 +25,7 @@ func (suite *ConversationsTestSuite) TestRead() {
conversation := suite.NewTestConversation(suite.testAccount, 0)
suite.False(util.PtrOrValue(conversation.Read, false))
- apiConversation, err := suite.conversationsProcessor.Read(context.Background(), suite.testAccount, conversation.ID)
+ apiConversation, err := suite.conversationsProcessor.Read(suite.T().Context(), suite.testAccount, conversation.ID)
if suite.NoError(err) {
suite.False(apiConversation.Unread)
}
diff --git a/internal/processing/conversations/update_test.go b/internal/processing/conversations/update_test.go
index 8ba2800fe..b547fae7c 100644
--- a/internal/processing/conversations/update_test.go
+++ b/internal/processing/conversations/update_test.go
@@ -17,13 +17,9 @@
package conversations_test
-import (
- "context"
-)
-
// Test that we can create conversations when a new status comes in.
func (suite *ConversationsTestSuite) TestUpdateConversationsForStatus() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// Precondition: the test user shouldn't have any conversations yet.
conversations, err := suite.db.GetConversationsByOwnerAccountID(ctx, suite.testAccount.ID, nil)
diff --git a/internal/processing/followrequest_test.go b/internal/processing/followrequest_test.go
index ca77d1e34..d5b7fdad2 100644
--- a/internal/processing/followrequest_test.go
+++ b/internal/processing/followrequest_test.go
@@ -18,7 +18,6 @@
package processing_test
import (
- "context"
"encoding/json"
"fmt"
"io"
@@ -53,11 +52,11 @@ func (suite *FollowRequestTestSuite) TestFollowRequestAccept() {
TargetAccountID: requestingAccount.ID,
}
- err := suite.db.Put(context.Background(), fr)
+ err := suite.db.Put(suite.T().Context(), fr)
suite.NoError(err)
relationship, errWithCode := suite.processor.Account().FollowRequestAccept(
- context.Background(),
+ suite.T().Context(),
requestingAccount,
targetAccount.ID,
)
@@ -139,11 +138,11 @@ func (suite *FollowRequestTestSuite) TestFollowRequestReject() {
TargetAccountID: requestingAccount.ID,
}
- err := suite.db.Put(context.Background(), fr)
+ err := suite.db.Put(suite.T().Context(), fr)
suite.NoError(err)
relationship, errWithCode := suite.processor.Account().FollowRequestReject(
- context.Background(),
+ suite.T().Context(),
requestingAccount,
targetAccount.ID,
)
diff --git a/internal/processing/interactionrequests/accept_test.go b/internal/processing/interactionrequests/accept_test.go
index eae17b6d6..b48978f2c 100644
--- a/internal/processing/interactionrequests/accept_test.go
+++ b/internal/processing/interactionrequests/accept_test.go
@@ -18,7 +18,6 @@
package interactionrequests_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
@@ -36,7 +35,7 @@ func (suite *AcceptTestSuite) TestAccept() {
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
state = testStructs.State
acct = suite.testAccounts["local_account_2"]
intReq = suite.testInteractionRequests["admin_account_reply_turtle"]
diff --git a/internal/processing/interactionrequests/reject_test.go b/internal/processing/interactionrequests/reject_test.go
index 353684938..76e31b491 100644
--- a/internal/processing/interactionrequests/reject_test.go
+++ b/internal/processing/interactionrequests/reject_test.go
@@ -18,7 +18,6 @@
package interactionrequests_test
import (
- "context"
"errors"
"testing"
@@ -38,7 +37,7 @@ func (suite *RejectTestSuite) TestReject() {
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
state = testStructs.State
acct = suite.testAccounts["local_account_2"]
intReq = suite.testInteractionRequests["admin_account_reply_turtle"]
diff --git a/internal/processing/media/getemoji_test.go b/internal/processing/media/getemoji_test.go
index eeb1e5020..0e2c2d0cc 100644
--- a/internal/processing/media/getemoji_test.go
+++ b/internal/processing/media/getemoji_test.go
@@ -18,7 +18,6 @@
package media_test
import (
- "context"
"testing"
"github.com/stretchr/testify/suite"
@@ -29,7 +28,7 @@ type GetEmojiTestSuite struct {
}
func (suite *GetEmojiTestSuite) TestGetCustomEmojis() {
- emojis, err := suite.mediaProcessor.GetCustomEmojis(context.Background())
+ emojis, err := suite.mediaProcessor.GetCustomEmojis(suite.T().Context())
suite.NoError(err)
suite.Equal(1, len(emojis))
diff --git a/internal/processing/media/getfile_test.go b/internal/processing/media/getfile_test.go
index cde0864f8..9c2ffd589 100644
--- a/internal/processing/media/getfile_test.go
+++ b/internal/processing/media/getfile_test.go
@@ -18,7 +18,6 @@
package media_test
import (
- "context"
"io"
"path"
"testing"
@@ -36,7 +35,7 @@ type GetFileTestSuite struct {
}
func (suite *GetFileTestSuite) TestGetRemoteFileCached() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
fileName := path.Base(testAttachment.File.Path)
@@ -64,7 +63,7 @@ func (suite *GetFileTestSuite) TestGetRemoteFileCached() {
}
func (suite *GetFileTestSuite) TestGetRemoteFileUncached() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// uncache the file from local
testAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
@@ -116,7 +115,7 @@ func (suite *GetFileTestSuite) TestGetRemoteFileUncached() {
}
func (suite *GetFileTestSuite) TestGetRemoteFileUncachedInterrupted() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// uncache the file from local
testAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
@@ -163,7 +162,7 @@ func (suite *GetFileTestSuite) TestGetRemoteFileUncachedInterrupted() {
}
func (suite *GetFileTestSuite) TestGetRemoteFileThumbnailUncached() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
// fetch the existing thumbnail bytes from storage first
diff --git a/internal/processing/media/unattach_test.go b/internal/processing/media/unattach_test.go
index 02d2c7077..582e24b9a 100644
--- a/internal/processing/media/unattach_test.go
+++ b/internal/processing/media/unattach_test.go
@@ -18,7 +18,6 @@
package media_test
import (
- "context"
"testing"
"github.com/stretchr/testify/suite"
@@ -29,7 +28,7 @@ type UnattachTestSuite struct {
}
func (suite *UnattachTestSuite) TestUnattachMedia() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testAttachment := suite.testAttachments["admin_account_status_1_attachment_1"]
testAccount := suite.testAccounts["admin_account"]
diff --git a/internal/processing/parsemention_test.go b/internal/processing/parsemention_test.go
index 2c2cc3085..2eeedc2ea 100644
--- a/internal/processing/parsemention_test.go
+++ b/internal/processing/parsemention_test.go
@@ -18,7 +18,6 @@
package processing_test
import (
- "context"
"errors"
"testing"
@@ -34,7 +33,7 @@ type ParseMentionTestSuite struct {
func (suite *ParseMentionTestSuite) TestParseMentionFunc() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
parseMention = processing.GetParseMentionFunc(&suite.state, suite.federator)
originAcctID = suite.testAccounts["local_account_1"].ID
statusID = id.NewULID()
diff --git a/internal/processing/polls/poll_test.go b/internal/processing/polls/poll_test.go
index 421f05361..f7c0f9f02 100644
--- a/internal/processing/polls/poll_test.go
+++ b/internal/processing/polls/poll_test.go
@@ -68,7 +68,7 @@ func (suite *PollTestSuite) TearDownTest() {
func (suite *PollTestSuite) TestPollGet() {
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Perform test for all requester + poll combos.
@@ -111,7 +111,7 @@ func (suite *PollTestSuite) testPollGet(ctx context.Context, requester *gtsmodel
func (suite *PollTestSuite) TestPollVote() {
// Create a new context for this test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// randomChoices generates random vote choices in poll.
diff --git a/internal/processing/preferences_test.go b/internal/processing/preferences_test.go
index dc6a8d878..daaaef5c6 100644
--- a/internal/processing/preferences_test.go
+++ b/internal/processing/preferences_test.go
@@ -18,7 +18,6 @@
package processing_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/api/model"
@@ -31,7 +30,7 @@ type PreferencesTestSuite struct {
}
func (suite *PreferencesTestSuite) TestPreferencesGet() {
- ctx := context.Background()
+ ctx := suite.T().Context()
tests := []struct {
act *gtsmodel.Account
prefs *model.Preferences
diff --git a/internal/processing/status/bookmark_test.go b/internal/processing/status/bookmark_test.go
index f5ea60fe6..ad441ca0c 100644
--- a/internal/processing/status/bookmark_test.go
+++ b/internal/processing/status/bookmark_test.go
@@ -18,7 +18,6 @@
package status_test
import (
- "context"
"testing"
"github.com/stretchr/testify/suite"
@@ -29,7 +28,7 @@ type StatusBookmarkTestSuite struct {
}
func (suite *StatusBookmarkTestSuite) TestBookmark() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// bookmark a status
bookmarkingAccount1 := suite.testAccounts["local_account_1"]
@@ -43,7 +42,7 @@ func (suite *StatusBookmarkTestSuite) TestBookmark() {
}
func (suite *StatusBookmarkTestSuite) TestUnbookmark() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// bookmark a status
bookmarkingAccount1 := suite.testAccounts["local_account_1"]
diff --git a/internal/processing/status/boost_test.go b/internal/processing/status/boost_test.go
index 0249e2040..96971c05e 100644
--- a/internal/processing/status/boost_test.go
+++ b/internal/processing/status/boost_test.go
@@ -18,7 +18,6 @@
package status_test
import (
- "context"
"testing"
"github.com/stretchr/testify/suite"
@@ -29,7 +28,7 @@ type StatusBoostTestSuite struct {
}
func (suite *StatusBoostTestSuite) TestBoostOfBoost() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// first boost a status, no big deal
boostingAccount1 := suite.testAccounts["local_account_1"]
diff --git a/internal/processing/status/create_test.go b/internal/processing/status/create_test.go
index 13e066387..a2adb5f79 100644
--- a/internal/processing/status/create_test.go
+++ b/internal/processing/status/create_test.go
@@ -18,7 +18,6 @@
package status_test
import (
- "context"
"testing"
apimodel "code.superseriousbusiness.org/gotosocial/internal/api/model"
@@ -34,7 +33,7 @@ type StatusCreateTestSuite struct {
}
func (suite *StatusCreateTestSuite) TestProcessContentWarningWithQuotationMarks() {
- ctx := context.Background()
+ ctx := suite.T().Context()
creatingAccount := suite.testAccounts["local_account_1"]
creatingApplication := suite.testApplications["application_1"]
@@ -61,7 +60,7 @@ func (suite *StatusCreateTestSuite) TestProcessContentWarningWithQuotationMarks(
}
func (suite *StatusCreateTestSuite) TestProcessStatusMarkdownWithUnderscoreEmoji() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// update the shortcode of the rainbow emoji to surround it in underscores
if err := suite.db.UpdateWhere(ctx, []db.Where{{Key: "shortcode", Value: "rainbow"}}, "shortcode", "_rainbow_", >smodel.Emoji{}); err != nil {
@@ -93,7 +92,7 @@ func (suite *StatusCreateTestSuite) TestProcessStatusMarkdownWithUnderscoreEmoji
}
func (suite *StatusCreateTestSuite) TestProcessStatusMarkdownWithSpoilerTextEmoji() {
- ctx := context.Background()
+ ctx := suite.T().Context()
creatingAccount := suite.testAccounts["local_account_1"]
creatingApplication := suite.testApplications["application_1"]
@@ -121,7 +120,7 @@ func (suite *StatusCreateTestSuite) TestProcessStatusMarkdownWithSpoilerTextEmoj
}
func (suite *StatusCreateTestSuite) TestProcessMediaDescriptionTooShort() {
- ctx := context.Background()
+ ctx := suite.T().Context()
config.SetMediaDescriptionMinChars(100)
@@ -148,7 +147,7 @@ func (suite *StatusCreateTestSuite) TestProcessMediaDescriptionTooShort() {
}
func (suite *StatusCreateTestSuite) TestProcessLanguageWithScriptPart() {
- ctx := context.Background()
+ ctx := suite.T().Context()
creatingAccount := suite.testAccounts["local_account_1"]
creatingApplication := suite.testApplications["application_1"]
@@ -175,7 +174,7 @@ func (suite *StatusCreateTestSuite) TestProcessLanguageWithScriptPart() {
}
func (suite *StatusCreateTestSuite) TestProcessReplyToUnthreadedRemoteStatus() {
- ctx := context.Background()
+ ctx := suite.T().Context()
creatingAccount := suite.testAccounts["local_account_1"]
creatingApplication := suite.testApplications["application_1"]
@@ -212,7 +211,7 @@ func (suite *StatusCreateTestSuite) TestProcessReplyToUnthreadedRemoteStatus() {
}
func (suite *StatusCreateTestSuite) TestProcessNoContentTypeUsesDefault() {
- ctx := context.Background()
+ ctx := suite.T().Context()
creatingAccount := suite.testAccounts["local_account_1"]
creatingApplication := suite.testApplications["application_1"]
diff --git a/internal/processing/status/edit_test.go b/internal/processing/status/edit_test.go
index 6078a7d3e..87fb73f67 100644
--- a/internal/processing/status/edit_test.go
+++ b/internal/processing/status/edit_test.go
@@ -37,7 +37,7 @@ type StatusEditTestSuite struct {
func (suite *StatusEditTestSuite) TestSimpleEdit() {
// Create cancellable context to use for test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Get a local account to use as test requester.
@@ -100,7 +100,7 @@ func (suite *StatusEditTestSuite) TestSimpleEdit() {
func (suite *StatusEditTestSuite) TestEditChangeContentType() {
// Create cancellable context to use for test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Get a local account to use as test requester.
@@ -166,7 +166,7 @@ func (suite *StatusEditTestSuite) TestEditChangeContentType() {
func (suite *StatusEditTestSuite) TestEditOnStatusWithNoContentType() {
// Create cancellable context to use for test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Get a local account to use as test requester.
@@ -235,7 +235,7 @@ func (suite *StatusEditTestSuite) TestEditOnStatusWithNoContentType() {
func (suite *StatusEditTestSuite) TestEditAddPoll() {
// Create cancellable context to use for test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Get a local account to use as test requester.
@@ -313,7 +313,7 @@ func (suite *StatusEditTestSuite) TestEditAddPoll() {
func (suite *StatusEditTestSuite) TestEditAddPollNoExpiry() {
// Create cancellable context to use for test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Get a local account to use as test requester.
@@ -391,7 +391,7 @@ func (suite *StatusEditTestSuite) TestEditAddPollNoExpiry() {
func (suite *StatusEditTestSuite) TestEditMediaDescription() {
// Create cancellable context to use for test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Get a local account to use as test requester.
@@ -487,7 +487,7 @@ func (suite *StatusEditTestSuite) TestEditMediaDescription() {
func (suite *StatusEditTestSuite) TestEditAddMedia() {
// Create cancellable context to use for test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Get a local account to use as test requester.
@@ -562,7 +562,7 @@ func (suite *StatusEditTestSuite) TestEditAddMedia() {
func (suite *StatusEditTestSuite) TestEditRemoveMedia() {
// Create cancellable context to use for test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Get a local account to use as test requester.
@@ -628,7 +628,7 @@ func (suite *StatusEditTestSuite) TestEditRemoveMedia() {
func (suite *StatusEditTestSuite) TestEditOthersStatus1() {
// Create cancellable context to use for test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Get a local account to use as test requester.
@@ -653,7 +653,7 @@ func (suite *StatusEditTestSuite) TestEditOthersStatus1() {
func (suite *StatusEditTestSuite) TestEditOthersStatus2() {
// Create cancellable context to use for test.
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
// Get a local account to use as test requester.
diff --git a/internal/processing/stream/authorize_test.go b/internal/processing/stream/authorize_test.go
index ee0e528af..7124888d9 100644
--- a/internal/processing/stream/authorize_test.go
+++ b/internal/processing/stream/authorize_test.go
@@ -18,7 +18,6 @@
package stream_test
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/db"
@@ -30,15 +29,15 @@ type AuthorizeTestSuite struct {
}
func (suite *AuthorizeTestSuite) TestAuthorize() {
- account1, err := suite.streamProcessor.Authorize(context.Background(), suite.testTokens["local_account_1"].Access)
+ account1, err := suite.streamProcessor.Authorize(suite.T().Context(), suite.testTokens["local_account_1"].Access)
suite.NoError(err)
suite.Equal(suite.testAccounts["local_account_1"].ID, account1.ID)
- account2, err := suite.streamProcessor.Authorize(context.Background(), suite.testTokens["local_account_2"].Access)
+ account2, err := suite.streamProcessor.Authorize(suite.T().Context(), suite.testTokens["local_account_2"].Access)
suite.NoError(err)
suite.Equal(suite.testAccounts["local_account_2"].ID, account2.ID)
- noAccount, err := suite.streamProcessor.Authorize(context.Background(), "aaaaaaaaaaaaaaaaaaaaa!!")
+ noAccount, err := suite.streamProcessor.Authorize(suite.T().Context(), "aaaaaaaaaaaaaaaaaaaaa!!")
suite.EqualError(err, "could not load access token: "+db.ErrNoEntries.Error())
suite.Nil(noAccount)
}
diff --git a/internal/processing/stream/notification_test.go b/internal/processing/stream/notification_test.go
index e0874e713..70fc45397 100644
--- a/internal/processing/stream/notification_test.go
+++ b/internal/processing/stream/notification_test.go
@@ -19,7 +19,6 @@ package stream_test
import (
"bytes"
- "context"
"encoding/json"
"testing"
@@ -35,11 +34,11 @@ type NotificationTestSuite struct {
func (suite *NotificationTestSuite) TestStreamNotification() {
account := suite.testAccounts["local_account_1"]
- openStream, errWithCode := suite.streamProcessor.Open(context.Background(), account, "user")
+ openStream, errWithCode := suite.streamProcessor.Open(suite.T().Context(), account, "user")
suite.NoError(errWithCode)
followAccount := suite.testAccounts["remote_account_1"]
- followAccountAPIModel, err := typeutils.NewConverter(&suite.state).AccountToAPIAccountPublic(context.Background(), followAccount)
+ followAccountAPIModel, err := typeutils.NewConverter(&suite.state).AccountToAPIAccountPublic(suite.T().Context(), followAccount)
suite.NoError(err)
notification := &apimodel.Notification{
@@ -49,9 +48,9 @@ func (suite *NotificationTestSuite) TestStreamNotification() {
Account: followAccountAPIModel,
}
- suite.streamProcessor.Notify(context.Background(), account, notification)
+ suite.streamProcessor.Notify(suite.T().Context(), account, notification)
- msg, ok := openStream.Recv(context.Background())
+ msg, ok := openStream.Recv(suite.T().Context())
suite.True(ok)
dst := new(bytes.Buffer)
diff --git a/internal/processing/stream/open_test.go b/internal/processing/stream/open_test.go
index 21ef69154..cc08a17a7 100644
--- a/internal/processing/stream/open_test.go
+++ b/internal/processing/stream/open_test.go
@@ -18,7 +18,6 @@
package stream_test
import (
- "context"
"testing"
"github.com/stretchr/testify/suite"
@@ -31,7 +30,7 @@ type OpenStreamTestSuite struct {
func (suite *OpenStreamTestSuite) TestOpenStream() {
account := suite.testAccounts["local_account_1"]
- _, errWithCode := suite.streamProcessor.Open(context.Background(), account, "user")
+ _, errWithCode := suite.streamProcessor.Open(suite.T().Context(), account, "user")
suite.NoError(errWithCode)
}
diff --git a/internal/processing/stream/statusupdate_test.go b/internal/processing/stream/statusupdate_test.go
index f11ab40a2..483388823 100644
--- a/internal/processing/stream/statusupdate_test.go
+++ b/internal/processing/stream/statusupdate_test.go
@@ -19,7 +19,6 @@ package stream_test
import (
"bytes"
- "context"
"encoding/json"
"testing"
@@ -36,16 +35,16 @@ type StatusUpdateTestSuite struct {
func (suite *StatusUpdateTestSuite) TestStreamNotification() {
account := suite.testAccounts["local_account_1"]
- openStream, errWithCode := suite.streamProcessor.Open(context.Background(), account, "user")
+ openStream, errWithCode := suite.streamProcessor.Open(suite.T().Context(), account, "user")
suite.NoError(errWithCode)
editedStatus := suite.testStatuses["remote_account_1_status_1"]
- apiStatus, err := typeutils.NewConverter(&suite.state).StatusToAPIStatus(context.Background(), editedStatus, account, statusfilter.FilterContextNotifications, nil, nil)
+ apiStatus, err := typeutils.NewConverter(&suite.state).StatusToAPIStatus(suite.T().Context(), editedStatus, account, statusfilter.FilterContextNotifications, nil, nil)
suite.NoError(err)
- suite.streamProcessor.StatusUpdate(context.Background(), account, apiStatus, stream.TimelineHome)
+ suite.streamProcessor.StatusUpdate(suite.T().Context(), account, apiStatus, stream.TimelineHome)
- msg, ok := openStream.Recv(context.Background())
+ msg, ok := openStream.Recv(suite.T().Context())
suite.True(ok)
dst := new(bytes.Buffer)
diff --git a/internal/processing/timeline/home_test.go b/internal/processing/timeline/home_test.go
index ce255acbd..184d361f0 100644
--- a/internal/processing/timeline/home_test.go
+++ b/internal/processing/timeline/home_test.go
@@ -18,7 +18,6 @@
package timeline_test
import (
- "context"
"testing"
apimodel "code.superseriousbusiness.org/gotosocial/internal/api/model"
@@ -40,7 +39,7 @@ func (suite *HomeTestSuite) TearDownTest() {
// A timeline containing a status hidden due to filtering should return other statuses with no error.
func (suite *HomeTestSuite) TestHomeTimelineGetHideFiltered() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
requester = suite.testAccounts["local_account_1"]
maxID = ""
sinceID = ""
diff --git a/internal/processing/timeline/public_test.go b/internal/processing/timeline/public_test.go
index b8520d9c8..5aa09f138 100644
--- a/internal/processing/timeline/public_test.go
+++ b/internal/processing/timeline/public_test.go
@@ -18,7 +18,6 @@
package timeline_test
import (
- "context"
"testing"
apimodel "code.superseriousbusiness.org/gotosocial/internal/api/model"
@@ -35,7 +34,7 @@ type PublicTestSuite struct {
func (suite *PublicTestSuite) TestPublicTimelineGet() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
requester = suite.testAccounts["local_account_1"]
maxID = ""
sinceID = ""
@@ -66,7 +65,7 @@ func (suite *PublicTestSuite) TestPublicTimelineGet() {
func (suite *PublicTestSuite) TestPublicTimelineGetNotEmpty() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
requester = suite.testAccounts["local_account_1"]
// Select 1 *just above* a status we know should
// not be in the public timeline -- a public
@@ -101,7 +100,7 @@ func (suite *PublicTestSuite) TestPublicTimelineGetNotEmpty() {
// A timeline containing a status hidden due to filtering should return other statuses with no error.
func (suite *PublicTestSuite) TestPublicTimelineGetHideFiltered() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
requester = suite.testAccounts["local_account_1"]
maxID = ""
sinceID = ""
diff --git a/internal/processing/user/create_test.go b/internal/processing/user/create_test.go
index d193ab883..9babbdfd5 100644
--- a/internal/processing/user/create_test.go
+++ b/internal/processing/user/create_test.go
@@ -18,7 +18,6 @@
package user_test
import (
- "context"
"net"
"testing"
@@ -32,7 +31,7 @@ type CreateTestSuite struct {
func (suite *CreateTestSuite) TestCreateOK() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
app = suite.testApps["application_1"]
appToken = suite.testTokens["local_account_1_client_application_token"]
form = &apimodel.AccountCreateRequest{
diff --git a/internal/processing/user/email_test.go b/internal/processing/user/email_test.go
index 23d448a84..e68fe21d5 100644
--- a/internal/processing/user/email_test.go
+++ b/internal/processing/user/email_test.go
@@ -18,7 +18,6 @@
package user_test
import (
- "context"
"testing"
"time"
@@ -30,7 +29,7 @@ type EmailConfirmTestSuite struct {
}
func (suite *EmailConfirmTestSuite) TestConfirmEmail() {
- ctx := context.Background()
+ ctx := suite.T().Context()
user := suite.testUsers["local_account_1"]
@@ -58,7 +57,7 @@ func (suite *EmailConfirmTestSuite) TestConfirmEmail() {
}
func (suite *EmailConfirmTestSuite) TestConfirmEmailOldToken() {
- ctx := context.Background()
+ ctx := suite.T().Context()
user := suite.testUsers["local_account_1"]
diff --git a/internal/processing/user/password_test.go b/internal/processing/user/password_test.go
index 5f65a9e1a..dfe249058 100644
--- a/internal/processing/user/password_test.go
+++ b/internal/processing/user/password_test.go
@@ -18,7 +18,6 @@
package user_test
import (
- "context"
"net/http"
"testing"
@@ -35,7 +34,7 @@ type ChangePasswordTestSuite struct {
func (suite *ChangePasswordTestSuite) TestChangePasswordOK() {
user := suite.testUsers["local_account_1"]
- errWithCode := suite.user.PasswordChange(context.Background(), user, "password", "verygoodnewpassword")
+ errWithCode := suite.user.PasswordChange(suite.T().Context(), user, "password", "verygoodnewpassword")
suite.NoError(errWithCode)
err := bcrypt.CompareHashAndPassword(
@@ -46,7 +45,7 @@ func (suite *ChangePasswordTestSuite) TestChangePasswordOK() {
// get user from the db again
dbUser := >smodel.User{}
- err = suite.db.GetByID(context.Background(), user.ID, dbUser)
+ err = suite.db.GetByID(suite.T().Context(), user.ID, dbUser)
suite.NoError(err)
// check the password has changed
@@ -60,14 +59,14 @@ func (suite *ChangePasswordTestSuite) TestChangePasswordOK() {
func (suite *ChangePasswordTestSuite) TestChangePasswordIncorrectOld() {
user := suite.testUsers["local_account_1"]
- errWithCode := suite.user.PasswordChange(context.Background(), user, "ooooopsydoooopsy", "verygoodnewpassword")
+ errWithCode := suite.user.PasswordChange(suite.T().Context(), user, "ooooopsydoooopsy", "verygoodnewpassword")
suite.EqualError(errWithCode, "PasswordChange: crypto/bcrypt: hashedPassword is not the hash of the given password")
suite.Equal(http.StatusUnauthorized, errWithCode.Code())
suite.Equal("Unauthorized: old password was incorrect", errWithCode.Safe())
// get user from the db again
dbUser := >smodel.User{}
- err := suite.db.GetByID(context.Background(), user.ID, dbUser)
+ err := suite.db.GetByID(suite.T().Context(), user.ID, dbUser)
suite.NoError(err)
// check the password has not changed
@@ -81,14 +80,14 @@ func (suite *ChangePasswordTestSuite) TestChangePasswordIncorrectOld() {
func (suite *ChangePasswordTestSuite) TestChangePasswordWeakNew() {
user := suite.testUsers["local_account_1"]
- errWithCode := suite.user.PasswordChange(context.Background(), user, "password", "1234")
+ errWithCode := suite.user.PasswordChange(suite.T().Context(), user, "password", "1234")
suite.EqualError(errWithCode, "password is only 11% strength, try including more special characters, using lowercase letters, using uppercase letters or using a longer password")
suite.Equal(http.StatusBadRequest, errWithCode.Code())
suite.Equal("Bad Request: password is only 11% strength, try including more special characters, using lowercase letters, using uppercase letters or using a longer password", errWithCode.Safe())
// get user from the db again
dbUser := >smodel.User{}
- err := suite.db.GetByID(context.Background(), user.ID, dbUser)
+ err := suite.db.GetByID(suite.T().Context(), user.ID, dbUser)
suite.NoError(err)
// check the password has not changed
diff --git a/internal/processing/workers/fromclientapi_test.go b/internal/processing/workers/fromclientapi_test.go
index a1027f3e0..3abd05295 100644
--- a/internal/processing/workers/fromclientapi_test.go
+++ b/internal/processing/workers/fromclientapi_test.go
@@ -158,7 +158,7 @@ func (suite *FromClientAPITestSuite) checkStreamed(
) {
// Set a 5s timeout on context.
- ctx := context.Background()
+ ctx := suite.T().Context()
ctx, cncl := context.WithTimeout(ctx, time.Second*5)
defer cncl()
@@ -259,7 +259,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateStatusWithNotification() {
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["admin_account"]
receivingAccount = suite.testAccounts["local_account_1"]
testList = suite.testLists["local_account_1_list_1"]
@@ -376,7 +376,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateBackfilledStatusWithNotifi
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["admin_account"]
receivingAccount = suite.testAccounts["local_account_1"]
testList = suite.testLists["local_account_1_list_1"]
@@ -475,7 +475,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateBackfilledStatusWithRemote
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["local_account_1"]
receivingAccount = suite.testAccounts["remote_account_1"]
@@ -531,7 +531,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateStatusReply() {
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["admin_account"]
receivingAccount = suite.testAccounts["local_account_1"]
testList = suite.testLists["local_account_1_list_1"]
@@ -602,7 +602,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateStatusReplyMuted() {
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["admin_account"]
receivingAccount = suite.testAccounts["local_account_1"]
@@ -666,7 +666,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateStatusBoostMuted() {
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["admin_account"]
receivingAccount = suite.testAccounts["local_account_1"]
@@ -734,7 +734,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateStatusListRepliesPolicyLis
*testList = *suite.testLists["local_account_1_list_1"]
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["admin_account"]
receivingAccount = suite.testAccounts["local_account_1"]
streams = suite.openStreams(ctx, testStructs.Processor, receivingAccount, []string{testList.ID})
@@ -813,7 +813,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateStatusListRepliesPolicyLis
*testList = *suite.testLists["local_account_1_list_1"]
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["admin_account"]
receivingAccount = suite.testAccounts["local_account_1"]
streams = suite.openStreams(ctx, testStructs.Processor, receivingAccount, []string{testList.ID})
@@ -898,7 +898,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateStatusReplyListRepliesPoli
*testList = *suite.testLists["local_account_1_list_1"]
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["admin_account"]
receivingAccount = suite.testAccounts["local_account_1"]
streams = suite.openStreams(ctx, testStructs.Processor, receivingAccount, []string{testList.ID})
@@ -973,7 +973,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateStatusBoost() {
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["admin_account"]
receivingAccount = suite.testAccounts["local_account_1"]
testList = suite.testLists["local_account_1_list_1"]
@@ -1040,7 +1040,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateStatusBoostNoReblogs() {
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["admin_account"]
receivingAccount = suite.testAccounts["local_account_1"]
testList = suite.testLists["local_account_1_list_1"]
@@ -1107,7 +1107,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateStatusWhichBeginsConversat
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["local_account_2"]
receivingAccount = suite.testAccounts["local_account_1"]
streams = suite.openStreams(ctx,
@@ -1196,7 +1196,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateStatusWhichShouldNotCreate
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["local_account_2"]
receivingAccount = suite.testAccounts["local_account_1"]
streams = suite.openStreams(ctx,
@@ -1269,7 +1269,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateStatusWithFollowedHashtag(
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["admin_account"]
receivingAccount = suite.testAccounts["local_account_2"]
streams = suite.openStreams(ctx,
@@ -1346,7 +1346,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateStatusWithFollowedHashtagA
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["remote_account_1"]
receivingAccount = suite.testAccounts["local_account_2"]
streams = suite.openStreams(ctx,
@@ -1430,7 +1430,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateBoostWithFollowedHashtag()
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["remote_account_2"]
boostingAccount = suite.testAccounts["admin_account"]
receivingAccount = suite.testAccounts["local_account_2"]
@@ -1536,7 +1536,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateBoostWithFollowedHashtagAn
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["remote_account_1"]
boostingAccount = suite.testAccounts["admin_account"]
receivingAccount = suite.testAccounts["local_account_2"]
@@ -1649,7 +1649,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateBoostWithFollowedHashtagAn
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["admin_account"]
boostingAccount = suite.testAccounts["remote_account_1"]
receivingAccount = suite.testAccounts["local_account_2"]
@@ -1760,7 +1760,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateStatusWithAuthorOnExclusiv
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["local_account_2"]
receivingAccount = suite.testAccounts["local_account_1"]
testList = suite.testLists["local_account_1_list_1"]
@@ -1836,7 +1836,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateStatusWithAuthorOnExclusiv
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["local_account_2"]
receivingAccount = suite.testAccounts["local_account_1"]
testInclusiveList = suite.testLists["local_account_1_list_1"]
@@ -1953,7 +1953,7 @@ func (suite *FromClientAPITestSuite) TestProcessCreateStatusWithAuthorOnExclusiv
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["local_account_2"]
receivingAccount = suite.testAccounts["local_account_1"]
testFollow = suite.testFollows["local_account_1_local_account_2"]
@@ -2080,7 +2080,7 @@ func (suite *FromClientAPITestSuite) TestProcessUpdateStatusWithFollowedHashtag(
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["admin_account"]
receivingAccount = suite.testAccounts["local_account_2"]
streams = suite.openStreams(ctx,
@@ -2156,7 +2156,7 @@ func (suite *FromClientAPITestSuite) TestProcessUpdateStatusInteractedWith() {
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
postingAccount = suite.testAccounts["local_account_1"]
receivingAccount = suite.testAccounts["admin_account"]
streams = suite.openStreams(ctx,
@@ -2244,7 +2244,7 @@ func (suite *FromClientAPITestSuite) TestProcessStatusDelete() {
defer testrig.TearDownTestStructs(testStructs)
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
deletingAccount = suite.testAccounts["local_account_1"]
receivingAccount = suite.testAccounts["local_account_2"]
deletedStatus = suite.testStatuses["local_account_1_status_1"]
diff --git a/internal/processing/workers/fromfediapi_test.go b/internal/processing/workers/fromfediapi_test.go
index d197f4122..7811e9f3d 100644
--- a/internal/processing/workers/fromfediapi_test.go
+++ b/internal/processing/workers/fromfediapi_test.go
@@ -62,7 +62,7 @@ func (suite *FromFediAPITestSuite) TestProcessFederationAnnounce() {
announceStatus.Account = boostingAccount
announceStatus.Visibility = boostedStatus.Visibility
- err := testStructs.Processor.Workers().ProcessFromFediAPI(context.Background(), &messages.FromFediAPI{
+ err := testStructs.Processor.Workers().ProcessFromFediAPI(suite.T().Context(), &messages.FromFediAPI{
APObjectType: ap.ActivityAnnounce,
APActivityType: ap.ActivityCreate,
GTSModel: announceStatus,
@@ -81,7 +81,7 @@ func (suite *FromFediAPITestSuite) TestProcessFederationAnnounce() {
}
_, err = testStructs.State.DB.GetStatusByID(
- context.Background(),
+ suite.T().Context(),
announceStatus.ID,
)
return err == nil
@@ -97,7 +97,7 @@ func (suite *FromFediAPITestSuite) TestProcessFederationAnnounce() {
},
}
notif := >smodel.Notification{}
- err = testStructs.State.DB.GetWhere(context.Background(), where, notif)
+ err = testStructs.State.DB.GetWhere(suite.T().Context(), where, notif)
suite.NoError(err)
suite.Equal(gtsmodel.NotificationReblog, notif.NotificationType)
suite.Equal(boostedStatus.AccountID, notif.TargetAccountID)
@@ -125,7 +125,7 @@ func (suite *FromFediAPITestSuite) TestProcessReplyMention() {
replyingAccount.FetchedAt = time.Now()
replyingAccount.SuspendedAt = time.Time{}
replyingAccount.SuspensionOrigin = ""
- err := testStructs.State.DB.UpdateAccount(context.Background(),
+ err := testStructs.State.DB.UpdateAccount(suite.T().Context(),
replyingAccount,
"fetched_at",
"suspended_at",
@@ -139,11 +139,11 @@ func (suite *FromFediAPITestSuite) TestProcessReplyMention() {
ap.AppendInReplyTo(replyingStatusable, testrig.URLMustParse(repliedStatus.URI))
// Open a websocket stream to later test the streamed status reply.
- wssStream, errWithCode := testStructs.Processor.Stream().Open(context.Background(), repliedAccount, stream.TimelineHome)
+ wssStream, errWithCode := testStructs.Processor.Stream().Open(suite.T().Context(), repliedAccount, stream.TimelineHome)
suite.NoError(errWithCode)
// Send the replied status off to the fedi worker to be further processed.
- err = testStructs.Processor.Workers().ProcessFromFediAPI(context.Background(), &messages.FromFediAPI{
+ err = testStructs.Processor.Workers().ProcessFromFediAPI(suite.T().Context(), &messages.FromFediAPI{
APObjectType: ap.ObjectNote,
APActivityType: ap.ActivityCreate,
APObject: replyingStatusable,
@@ -158,7 +158,7 @@ func (suite *FromFediAPITestSuite) TestProcessReplyMention() {
// 1. status should be in the database
var replyingStatus *gtsmodel.Status
if !testrig.WaitFor(func() bool {
- replyingStatus, err = testStructs.State.DB.GetStatusByURI(context.Background(), replyingURI)
+ replyingStatus, err = testStructs.State.DB.GetStatusByURI(suite.T().Context(), replyingURI)
return err == nil
}) {
suite.FailNow("timed out waiting for replying status to be in the database")
@@ -166,7 +166,7 @@ func (suite *FromFediAPITestSuite) TestProcessReplyMention() {
// 2. a notification should exist for the mention
var notif gtsmodel.Notification
- err = testStructs.State.DB.GetWhere(context.Background(), []db.Where{
+ err = testStructs.State.DB.GetWhere(suite.T().Context(), []db.Where{
{Key: "status_id", Value: replyingStatus.ID},
}, ¬if)
suite.NoError(err)
@@ -176,7 +176,7 @@ func (suite *FromFediAPITestSuite) TestProcessReplyMention() {
suite.Equal(replyingStatus.ID, notif.StatusOrEditID)
suite.False(*notif.Read)
- ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
+ ctx, _ := context.WithTimeout(suite.T().Context(), time.Second*5)
msg, ok := wssStream.Recv(ctx)
suite.True(ok)
@@ -198,7 +198,7 @@ func (suite *FromFediAPITestSuite) TestProcessFave() {
favedStatus := suite.testStatuses["local_account_1_status_1"]
favingAccount := suite.testAccounts["remote_account_1"]
- wssStream, errWithCode := testStructs.Processor.Stream().Open(context.Background(), favedAccount, stream.TimelineNotifications)
+ wssStream, errWithCode := testStructs.Processor.Stream().Open(suite.T().Context(), favedAccount, stream.TimelineNotifications)
suite.NoError(errWithCode)
fave := >smodel.StatusFave{
@@ -214,10 +214,10 @@ func (suite *FromFediAPITestSuite) TestProcessFave() {
URI: favingAccount.URI + "/faves/aaaaaaaaaaaa",
}
- err := testStructs.State.DB.Put(context.Background(), fave)
+ err := testStructs.State.DB.Put(suite.T().Context(), fave)
suite.NoError(err)
- err = testStructs.Processor.Workers().ProcessFromFediAPI(context.Background(), &messages.FromFediAPI{
+ err = testStructs.Processor.Workers().ProcessFromFediAPI(suite.T().Context(), &messages.FromFediAPI{
APObjectType: ap.ActivityLike,
APActivityType: ap.ActivityCreate,
GTSModel: fave,
@@ -240,7 +240,7 @@ func (suite *FromFediAPITestSuite) TestProcessFave() {
}
notif := >smodel.Notification{}
- err = testStructs.State.DB.GetWhere(context.Background(), where, notif)
+ err = testStructs.State.DB.GetWhere(suite.T().Context(), where, notif)
suite.NoError(err)
suite.Equal(gtsmodel.NotificationFavourite, notif.NotificationType)
suite.Equal(fave.TargetAccountID, notif.TargetAccountID)
@@ -248,7 +248,7 @@ func (suite *FromFediAPITestSuite) TestProcessFave() {
suite.Equal(fave.StatusID, notif.StatusOrEditID)
suite.False(*notif.Read)
- ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
+ ctx, _ := context.WithTimeout(suite.T().Context(), time.Second*5)
msg, ok := wssStream.Recv(ctx)
suite.True(ok)
@@ -271,7 +271,7 @@ func (suite *FromFediAPITestSuite) TestProcessFaveWithDifferentReceivingAccount(
favedStatus := suite.testStatuses["local_account_1_status_1"]
favingAccount := suite.testAccounts["remote_account_1"]
- wssStream, errWithCode := testStructs.Processor.Stream().Open(context.Background(), receivingAccount, stream.TimelineHome)
+ wssStream, errWithCode := testStructs.Processor.Stream().Open(suite.T().Context(), receivingAccount, stream.TimelineHome)
suite.NoError(errWithCode)
fave := >smodel.StatusFave{
@@ -287,10 +287,10 @@ func (suite *FromFediAPITestSuite) TestProcessFaveWithDifferentReceivingAccount(
URI: favingAccount.URI + "/faves/aaaaaaaaaaaa",
}
- err := testStructs.State.DB.Put(context.Background(), fave)
+ err := testStructs.State.DB.Put(suite.T().Context(), fave)
suite.NoError(err)
- err = testStructs.Processor.Workers().ProcessFromFediAPI(context.Background(), &messages.FromFediAPI{
+ err = testStructs.Processor.Workers().ProcessFromFediAPI(suite.T().Context(), &messages.FromFediAPI{
APObjectType: ap.ActivityLike,
APActivityType: ap.ActivityCreate,
GTSModel: fave,
@@ -313,7 +313,7 @@ func (suite *FromFediAPITestSuite) TestProcessFaveWithDifferentReceivingAccount(
}
notif := >smodel.Notification{}
- err = testStructs.State.DB.GetWhere(context.Background(), where, notif)
+ err = testStructs.State.DB.GetWhere(suite.T().Context(), where, notif)
suite.NoError(err)
suite.Equal(gtsmodel.NotificationFavourite, notif.NotificationType)
suite.Equal(fave.TargetAccountID, notif.TargetAccountID)
@@ -322,7 +322,7 @@ func (suite *FromFediAPITestSuite) TestProcessFaveWithDifferentReceivingAccount(
suite.False(*notif.Read)
// 2. no notification should be streamed to the account that received the fave message, because they weren't the target
- ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
+ ctx, _ := context.WithTimeout(suite.T().Context(), time.Second*5)
_, ok := wssStream.Recv(ctx)
suite.False(ok)
}
@@ -331,7 +331,7 @@ func (suite *FromFediAPITestSuite) TestProcessAccountDelete() {
testStructs := testrig.SetupTestStructs(rMediaPath, rTemplatePath)
defer testrig.TearDownTestStructs(testStructs)
- ctx := context.Background()
+ ctx := suite.T().Context()
deletedAccount := >smodel.Account{}
*deletedAccount = *suite.testAccounts["remote_account_1"]
@@ -425,14 +425,14 @@ func (suite *FromFediAPITestSuite) TestProcessFollowRequestLocked() {
testStructs := testrig.SetupTestStructs(rMediaPath, rTemplatePath)
defer testrig.TearDownTestStructs(testStructs)
- ctx := context.Background()
+ ctx := suite.T().Context()
originAccount := suite.testAccounts["remote_account_1"]
// target is a locked account
targetAccount := suite.testAccounts["local_account_2"]
- wssStream, errWithCode := testStructs.Processor.Stream().Open(context.Background(), targetAccount, stream.TimelineHome)
+ wssStream, errWithCode := testStructs.Processor.Stream().Open(suite.T().Context(), targetAccount, stream.TimelineHome)
suite.NoError(errWithCode)
// put the follow request in the database as though it had passed through the federating db already
@@ -462,7 +462,7 @@ func (suite *FromFediAPITestSuite) TestProcessFollowRequestLocked() {
suite.NoError(err)
ctx, _ = context.WithTimeout(ctx, time.Second*5)
- msg, ok := wssStream.Recv(context.Background())
+ msg, ok := wssStream.Recv(suite.T().Context())
suite.True(ok)
suite.Equal(stream.EventTypeNotification, msg.Event)
@@ -482,14 +482,14 @@ func (suite *FromFediAPITestSuite) TestProcessFollowRequestUnlocked() {
testStructs := testrig.SetupTestStructs(rMediaPath, rTemplatePath)
defer testrig.TearDownTestStructs(testStructs)
- ctx := context.Background()
+ ctx := suite.T().Context()
originAccount := suite.testAccounts["remote_account_1"]
// target is an unlocked account
targetAccount := suite.testAccounts["local_account_1"]
- wssStream, errWithCode := testStructs.Processor.Stream().Open(context.Background(), targetAccount, stream.TimelineHome)
+ wssStream, errWithCode := testStructs.Processor.Stream().Open(suite.T().Context(), targetAccount, stream.TimelineHome)
suite.NoError(errWithCode)
// put the follow request in the database as though it had passed through the federating db already
@@ -565,7 +565,7 @@ func (suite *FromFediAPITestSuite) TestProcessFollowRequestUnlocked() {
suite.Equal("Accept", accept.Type)
ctx, _ = context.WithTimeout(ctx, time.Second*5)
- msg, ok := wssStream.Recv(context.Background())
+ msg, ok := wssStream.Recv(suite.T().Context())
suite.True(ok)
suite.Equal(stream.EventTypeNotification, msg.Event)
@@ -583,7 +583,7 @@ func (suite *FromFediAPITestSuite) TestCreateStatusFromIRI() {
testStructs := testrig.SetupTestStructs(rMediaPath, rTemplatePath)
defer testrig.TearDownTestStructs(testStructs)
- ctx := context.Background()
+ ctx := suite.T().Context()
receivingAccount := suite.testAccounts["local_account_1"]
statusCreator := suite.testAccounts["remote_account_2"]
@@ -599,7 +599,7 @@ func (suite *FromFediAPITestSuite) TestCreateStatusFromIRI() {
suite.NoError(err)
// status should now be in the database, attributed to remote_account_2
- s, err := testStructs.State.DB.GetStatusByURI(context.Background(), "http://example.org/users/Some_User/statuses/afaba698-5740-4e32-a702-af61aa543bc1")
+ s, err := testStructs.State.DB.GetStatusByURI(suite.T().Context(), "http://example.org/users/Some_User/statuses/afaba698-5740-4e32-a702-af61aa543bc1")
suite.NoError(err)
suite.Equal(statusCreator.URI, s.AccountURI)
}
@@ -609,7 +609,7 @@ func (suite *FromFediAPITestSuite) TestMoveAccount() {
defer testrig.TearDownTestStructs(testStructs)
// We're gonna migrate foss_satan to our local admin account.
- ctx := context.Background()
+ ctx := suite.T().Context()
receivingAcct := suite.testAccounts["local_account_1"]
// Copy requesting and target accounts
@@ -683,7 +683,7 @@ func (suite *FromFediAPITestSuite) TestMoveAccount() {
func (suite *FromFediAPITestSuite) TestUndoAnnounce() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
requestingAcct = suite.testAccounts["remote_account_1"]
receivingAcct = suite.testAccounts["local_account_1"]
@@ -737,7 +737,7 @@ func (suite *FromFediAPITestSuite) TestUndoAnnounce() {
func (suite *FromFediAPITestSuite) TestUpdateNote() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
requestingAcct = suite.testAccounts["remote_account_2"]
receivingAcct = suite.testAccounts["local_account_1"]
diff --git a/internal/processing/workers/surfacenotify_test.go b/internal/processing/workers/surfacenotify_test.go
index 7acea2436..459b3e125 100644
--- a/internal/processing/workers/surfacenotify_test.go
+++ b/internal/processing/workers/surfacenotify_test.go
@@ -18,7 +18,6 @@
package workers_test
import (
- "context"
"sync"
"testing"
"time"
@@ -50,7 +49,7 @@ func (suite *SurfaceNotifyTestSuite) TestSpamNotifs() {
}
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
notificationType = gtsmodel.NotificationFollow
targetAccount = suite.testAccounts["local_account_1"]
originAccount = suite.testAccounts["local_account_2"]
diff --git a/internal/subscriptions/subscriptions_test.go b/internal/subscriptions/subscriptions_test.go
index b334207e4..8e292209d 100644
--- a/internal/subscriptions/subscriptions_test.go
+++ b/internal/subscriptions/subscriptions_test.go
@@ -18,7 +18,6 @@
package subscriptions_test
import (
- "context"
"errors"
"testing"
"time"
@@ -51,7 +50,7 @@ func (suite *SubscriptionsTestSuite) SetupSuite() {
func (suite *SubscriptionsTestSuite) TestDomainBlocksCSV() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
testAccount = suite.testAccounts["admin_account"]
subscriptions = subscriptions.New(
@@ -131,7 +130,7 @@ func (suite *SubscriptionsTestSuite) TestDomainBlocksCSV() {
func (suite *SubscriptionsTestSuite) TestDomainBlocksJSON() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
testAccount = suite.testAccounts["admin_account"]
subscriptions = subscriptions.New(
@@ -211,7 +210,7 @@ func (suite *SubscriptionsTestSuite) TestDomainBlocksJSON() {
func (suite *SubscriptionsTestSuite) TestDomainBlocksPlain() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
testAccount = suite.testAccounts["admin_account"]
subscriptions = subscriptions.New(
@@ -291,7 +290,7 @@ func (suite *SubscriptionsTestSuite) TestDomainBlocksPlain() {
func (suite *SubscriptionsTestSuite) TestDomainBlocksCSVCaching() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
testAccount = suite.testAccounts["admin_account"]
subscriptions = subscriptions.New(
@@ -367,7 +366,7 @@ func (suite *SubscriptionsTestSuite) TestDomainBlocksCSVCaching() {
func (suite *SubscriptionsTestSuite) TestDomainBlocksCSVFutureLastModified() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
testAccount = suite.testAccounts["admin_account"]
subscriptions = subscriptions.New(
@@ -439,7 +438,7 @@ func (suite *SubscriptionsTestSuite) TestDomainBlocksCSVFutureLastModified() {
func (suite *SubscriptionsTestSuite) TestDomainBlocksCSVGarbageLastModified() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
testAccount = suite.testAccounts["admin_account"]
subscriptions = subscriptions.New(
@@ -511,7 +510,7 @@ func (suite *SubscriptionsTestSuite) TestDomainBlocksCSVGarbageLastModified() {
func (suite *SubscriptionsTestSuite) TestDomainBlocks404() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
testAccount = suite.testAccounts["admin_account"]
subscriptions = subscriptions.New(
@@ -569,7 +568,7 @@ func (suite *SubscriptionsTestSuite) TestDomainBlocks404() {
func (suite *SubscriptionsTestSuite) TestDomainBlocksWrongContentTypeCSV() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
testAccount = suite.testAccounts["admin_account"]
subscriptions = subscriptions.New(
@@ -627,7 +626,7 @@ func (suite *SubscriptionsTestSuite) TestDomainBlocksWrongContentTypeCSV() {
func (suite *SubscriptionsTestSuite) TestDomainBlocksWrongContentTypePlain() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
testAccount = suite.testAccounts["admin_account"]
subscriptions = subscriptions.New(
@@ -685,7 +684,7 @@ func (suite *SubscriptionsTestSuite) TestDomainBlocksWrongContentTypePlain() {
func (suite *SubscriptionsTestSuite) TestAdoption() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
testAccount = suite.testAccounts["admin_account"]
subscriptions = subscriptions.New(
@@ -817,7 +816,7 @@ func (suite *SubscriptionsTestSuite) TestAdoption() {
func (suite *SubscriptionsTestSuite) TestDomainAllowsAndBlocks() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
testAccount = suite.testAccounts["admin_account"]
subscriptions = subscriptions.New(
diff --git a/internal/text/formatter_test.go b/internal/text/formatter_test.go
index 2951ad0d2..97bd1b7d1 100644
--- a/internal/text/formatter_test.go
+++ b/internal/text/formatter_test.go
@@ -18,8 +18,6 @@
package text_test
import (
- "context"
-
"code.superseriousbusiness.org/gotosocial/internal/db"
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
"code.superseriousbusiness.org/gotosocial/internal/processing"
@@ -85,7 +83,7 @@ func (suite *TextStandardTestSuite) TearDownTest() {
func (suite *TextStandardTestSuite) FromMarkdown(input string) *text.FormatResult {
return suite.formatter.FromMarkdown(
- context.Background(),
+ suite.T().Context(),
suite.parseMention,
suite.testAccounts["local_account_1"].ID,
"dummy_status_ID",
@@ -95,7 +93,7 @@ func (suite *TextStandardTestSuite) FromMarkdown(input string) *text.FormatResul
func (suite *TextStandardTestSuite) FromMarkdownBasic(input string) *text.FormatResult {
return suite.formatter.FromMarkdownBasic(
- context.Background(),
+ suite.T().Context(),
suite.parseMention,
suite.testAccounts["local_account_1"].ID,
"dummy_status_ID",
@@ -105,7 +103,7 @@ func (suite *TextStandardTestSuite) FromMarkdownBasic(input string) *text.Format
func (suite *TextStandardTestSuite) FromPlain(input string) *text.FormatResult {
return suite.formatter.FromPlain(
- context.Background(),
+ suite.T().Context(),
suite.parseMention,
suite.testAccounts["local_account_1"].ID,
"dummy_status_ID",
@@ -115,7 +113,7 @@ func (suite *TextStandardTestSuite) FromPlain(input string) *text.FormatResult {
func (suite *TextStandardTestSuite) FromPlainNoParagraph(input string) *text.FormatResult {
return suite.formatter.FromPlainNoParagraph(
- context.Background(),
+ suite.T().Context(),
suite.parseMention,
suite.testAccounts["local_account_1"].ID,
"dummmy_status_ID",
diff --git a/internal/trans/exportminimal_test.go b/internal/trans/exportminimal_test.go
index a5183b051..7f3061371 100644
--- a/internal/trans/exportminimal_test.go
+++ b/internal/trans/exportminimal_test.go
@@ -18,7 +18,6 @@
package trans_test
import (
- "context"
"fmt"
"os"
"testing"
@@ -38,7 +37,7 @@ func (suite *ExportMinimalTestSuite) TestExportMinimalOK() {
// export to the tempFilePath
exporter := trans.NewExporter(suite.db)
- err := exporter.ExportMinimal(context.Background(), tempFilePath)
+ err := exporter.ExportMinimal(suite.T().Context(), tempFilePath)
suite.NoError(err)
// we should have some bytes in that file now
diff --git a/internal/trans/import_test.go b/internal/trans/import_test.go
index 1147bfa12..da066df81 100644
--- a/internal/trans/import_test.go
+++ b/internal/trans/import_test.go
@@ -18,7 +18,6 @@
package trans_test
import (
- "context"
"fmt"
"os"
"testing"
@@ -36,7 +35,7 @@ type ImportMinimalTestSuite struct {
}
func (suite *ImportMinimalTestSuite) TestImportMinimalOK() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testAccountBefore, err := suite.db.GetAccountByID(ctx, suite.testAccounts["local_account_1"].ID)
if err != nil {
diff --git a/internal/transport/dereference_test.go b/internal/transport/dereference_test.go
index d3778563e..7d9570923 100644
--- a/internal/transport/dereference_test.go
+++ b/internal/transport/dereference_test.go
@@ -19,7 +19,6 @@ package transport_test
import (
"bytes"
- "context"
"encoding/json"
"io"
"net/http"
@@ -37,7 +36,7 @@ type DereferenceTestSuite struct {
func (suite *DereferenceTestSuite) TestDerefLocalUser() {
iri := testrig.URLMustParse(suite.testAccounts["local_account_1"].URI)
- resp, err := suite.transport.Dereference(context.Background(), iri)
+ resp, err := suite.transport.Dereference(suite.T().Context(), iri)
if err != nil {
suite.FailNow(err.Error())
}
@@ -108,7 +107,7 @@ func (suite *DereferenceTestSuite) TestDerefLocalUser() {
func (suite *DereferenceTestSuite) TestDerefLocalStatus() {
iri := testrig.URLMustParse(suite.testStatuses["local_account_1_status_1"].URI)
- resp, err := suite.transport.Dereference(context.Background(), iri)
+ resp, err := suite.transport.Dereference(suite.T().Context(), iri)
if err != nil {
suite.FailNow(err.Error())
}
@@ -200,7 +199,7 @@ func (suite *DereferenceTestSuite) TestDerefLocalStatus() {
func (suite *DereferenceTestSuite) TestDerefLocalFollowers() {
iri := testrig.URLMustParse(suite.testAccounts["local_account_1"].FollowersURI)
- resp, err := suite.transport.Dereference(context.Background(), iri)
+ resp, err := suite.transport.Dereference(suite.T().Context(), iri)
if err != nil {
suite.FailNow(err.Error())
}
@@ -234,7 +233,7 @@ func (suite *DereferenceTestSuite) TestDerefLocalFollowers() {
func (suite *DereferenceTestSuite) TestDerefLocalFollowing() {
iri := testrig.URLMustParse(suite.testAccounts["local_account_1"].FollowingURI)
- resp, err := suite.transport.Dereference(context.Background(), iri)
+ resp, err := suite.transport.Dereference(suite.T().Context(), iri)
if err != nil {
suite.FailNow(err.Error())
}
diff --git a/internal/typeutils/astointernal_test.go b/internal/typeutils/astointernal_test.go
index fb453c89e..7e18ceefb 100644
--- a/internal/typeutils/astointernal_test.go
+++ b/internal/typeutils/astointernal_test.go
@@ -37,7 +37,7 @@ type ASToInternalTestSuite struct {
}
func (suite *ASToInternalTestSuite) jsonToType(in string) vocab.Type {
- ctx := context.Background()
+ ctx := suite.T().Context()
b := []byte(in)
if accountable, err := ap.ResolveAccountable(ctx, io.NopCloser(bytes.NewReader(b))); err == nil {
@@ -53,7 +53,7 @@ func (suite *ASToInternalTestSuite) jsonToType(in string) vocab.Type {
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())
}
@@ -64,7 +64,7 @@ func (suite *ASToInternalTestSuite) jsonToType(in string) vocab.Type {
func (suite *ASToInternalTestSuite) TestParsePerson() {
testPerson := suite.testPeople["https://unknown-instance.com/users/brand_new_person"]
- acct, err := suite.typeconverter.ASRepresentationToAccount(context.Background(), testPerson, "", "")
+ acct, err := suite.typeconverter.ASRepresentationToAccount(suite.T().Context(), testPerson, "", "")
suite.NoError(err)
suite.Equal("https://unknown-instance.com/users/brand_new_person", acct.URI)
@@ -86,7 +86,7 @@ func (suite *ASToInternalTestSuite) TestParsePerson() {
func (suite *ASToInternalTestSuite) TestParsePersonWithSharedInbox() {
testPerson := suite.testPeople["https://turnip.farm/users/turniplover6969"]
- acct, err := suite.typeconverter.ASRepresentationToAccount(context.Background(), testPerson, "", "")
+ acct, err := suite.typeconverter.ASRepresentationToAccount(suite.T().Context(), testPerson, "", "")
suite.NoError(err)
suite.Equal("https://turnip.farm/users/turniplover6969", acct.URI)
@@ -112,7 +112,7 @@ func (suite *ASToInternalTestSuite) TestParsePublicStatus() {
suite.FailNow("type not coercible")
}
- status, err := suite.typeconverter.ASStatusToStatus(context.Background(), rep)
+ status, err := suite.typeconverter.ASStatusToStatus(suite.T().Context(), rep)
suite.NoError(err)
suite.Equal("reading: Punishment and Reward in the Corporate University", status.ContentWarning)
@@ -127,7 +127,7 @@ func (suite *ASToInternalTestSuite) TestParsePublicStatusNoURL() {
suite.FailNow("type not coercible")
}
- status, err := suite.typeconverter.ASStatusToStatus(context.Background(), rep)
+ status, err := suite.typeconverter.ASStatusToStatus(suite.T().Context(), rep)
suite.NoError(err)
suite.Equal("reading: Punishment and Reward in the Corporate University", status.ContentWarning)
@@ -144,7 +144,7 @@ func (suite *ASToInternalTestSuite) TestParseGargron() {
suite.FailNow("type not coercible")
}
- acct, err := suite.typeconverter.ASRepresentationToAccount(context.Background(), rep, "", "")
+ acct, err := suite.typeconverter.ASRepresentationToAccount(suite.T().Context(), rep, "", "")
suite.NoError(err)
suite.Equal("https://mastodon.social/inbox", *acct.SharedInboxURI)
suite.Equal([]string{"https://tooting.ai/users/Gargron"}, acct.AlsoKnownAsURIs)
@@ -162,7 +162,7 @@ func (suite *ASToInternalTestSuite) TestParseReplyWithMention() {
var status *gtsmodel.Status
for i := object.Begin(); i != nil; i = i.Next() {
statusable := i.GetActivityStreamsNote()
- s, err := suite.typeconverter.ASStatusToStatus(context.Background(), statusable)
+ s, err := suite.typeconverter.ASStatusToStatus(suite.T().Context(), statusable)
suite.NoError(err)
status = s
break
@@ -195,7 +195,7 @@ func (suite *ASToInternalTestSuite) TestParseOwncastService() {
suite.FailNow("type not coercible")
}
- acct, err := suite.typeconverter.ASRepresentationToAccount(context.Background(), rep, "", "")
+ acct, err := suite.typeconverter.ASRepresentationToAccount(suite.T().Context(), rep, "", "")
suite.NoError(err)
suite.Equal("rgh", acct.Username)
@@ -216,7 +216,7 @@ func (suite *ASToInternalTestSuite) TestParseOwncastService() {
acct.ID = "01G42D57DTCJQE8XT9KD4K88RK"
- apiAcct, err := suite.typeconverter.AccountToAPIAccountPublic(context.Background(), acct)
+ apiAcct, err := suite.typeconverter.AccountToAPIAccountPublic(suite.T().Context(), acct)
suite.NoError(err)
suite.NotNil(apiAcct)
@@ -270,7 +270,7 @@ func (suite *ASToInternalTestSuite) TestParseBookwyrmStatus() {
suite.FailNow("type not coercible")
}
- status, err := suite.typeconverter.ASStatusToStatus(context.Background(), asArticle)
+ status, err := suite.typeconverter.ASStatusToStatus(suite.T().Context(), asArticle)
if err != nil {
suite.FailNow(err.Error())
}
@@ -330,7 +330,7 @@ func (suite *ASToInternalTestSuite) TestParseBandwagonAlbum() {
suite.FailNow("type not coercible")
}
- s, err := suite.typeconverter.ASStatusToStatus(context.Background(), asArticle)
+ s, err := suite.typeconverter.ASStatusToStatus(suite.T().Context(), asArticle)
if err != nil {
suite.FailNow(err.Error())
}
@@ -358,7 +358,7 @@ func (suite *ASToInternalTestSuite) TestParseFlag1() {
suite.FailNow("type not coercible")
}
- report, err := suite.typeconverter.ASFlagToReport(context.Background(), asFlag)
+ report, err := suite.typeconverter.ASFlagToReport(suite.T().Context(), asFlag)
if err != nil {
suite.FailNow(err.Error())
}
@@ -392,7 +392,7 @@ func (suite *ASToInternalTestSuite) TestParseFlag2() {
suite.FailNow("type not coercible")
}
- report, err := suite.typeconverter.ASFlagToReport(context.Background(), asFlag)
+ report, err := suite.typeconverter.ASFlagToReport(suite.T().Context(), asFlag)
if err != nil {
suite.FailNow(err.Error())
}
@@ -426,7 +426,7 @@ func (suite *ASToInternalTestSuite) TestParseFlag3() {
suite.FailNow("type not coercible")
}
- report, err := suite.typeconverter.ASFlagToReport(context.Background(), asFlag)
+ report, err := suite.typeconverter.ASFlagToReport(suite.T().Context(), asFlag)
suite.Nil(report)
suite.EqualError(err, "ASFlagToReport: error getting target account http://localhost:8080/users/mr_e_man from database: sql: no rows in result set")
}
@@ -451,7 +451,7 @@ func (suite *ASToInternalTestSuite) TestParseFlag4() {
suite.FailNow("type not coercible")
}
- report, err := suite.typeconverter.ASFlagToReport(context.Background(), asFlag)
+ report, err := suite.typeconverter.ASFlagToReport(suite.T().Context(), asFlag)
suite.Nil(report)
suite.EqualError(err, "ASFlagToReport: missing target account uri for http://fossbros-anonymous.io/db22128d-884e-4358-9935-6a7c3940535d")
}
@@ -479,7 +479,7 @@ func (suite *ASToInternalTestSuite) TestParseFlag5() {
suite.FailNow("type not coercible")
}
- report, err := suite.typeconverter.ASFlagToReport(context.Background(), asFlag)
+ report, err := suite.typeconverter.ASFlagToReport(suite.T().Context(), asFlag)
if err != nil {
suite.FailNow(err.Error())
}
@@ -516,7 +516,7 @@ func (suite *ASToInternalTestSuite) TestParseFlag6() {
suite.FailNow("type not coercible")
}
- report, err := suite.typeconverter.ASFlagToReport(context.Background(), asFlag)
+ report, err := suite.typeconverter.ASFlagToReport(suite.T().Context(), asFlag)
if err != nil {
suite.FailNow(err.Error())
}
@@ -549,7 +549,7 @@ func (suite *ASToInternalTestSuite) TestParseAnnounce() {
suite.FailNow("type not coercible")
}
- boost, isNew, err := suite.typeconverter.ASAnnounceToStatus(context.Background(), asAnnounce)
+ boost, isNew, err := suite.typeconverter.ASAnnounceToStatus(suite.T().Context(), asAnnounce)
if err != nil {
suite.FailNow(err.Error())
}
@@ -603,7 +603,7 @@ func (suite *ASToInternalTestSuite) TestParseHonkAccount() {
suite.FailNow("type not coercible")
}
- acct, err := suite.typeconverter.ASRepresentationToAccount(context.Background(), rep, "", "")
+ acct, err := suite.typeconverter.ASRepresentationToAccount(suite.T().Context(), rep, "", "")
suite.NoError(err)
suite.Equal("https://honk.example.org/u/honk_user/followers", acct.FollowersURI)
suite.Equal("https://honk.example.org/u/honk_user/following", acct.FollowingURI)
@@ -618,7 +618,7 @@ func (suite *ASToInternalTestSuite) TestParseHonkAccount() {
// Store the account representation.
acct.ID = "01HMGRMAVQMYQC3DDQ29TPQKJ3" // <- needs an ID
- ctx := context.Background()
+ ctx := suite.T().Context()
if err := suite.db.PutAccount(ctx, acct); err != nil {
suite.FailNow(err.Error())
}
@@ -708,7 +708,7 @@ func (suite *ASToInternalTestSuite) TestParseHonkAccount() {
}
func (suite *ASToInternalTestSuite) TestParseAccountableWithoutPreferredUsername() {
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
testPerson := suite.testPeople["https://unknown-instance.com/users/brand_new_person"]
@@ -726,7 +726,7 @@ func (suite *ASToInternalTestSuite) TestParseAccountableWithoutPreferredUsername
}
func (suite *ASToInternalTestSuite) TestParseAccountableWithoutAnyUsername() {
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
testPerson := suite.testPeople["https://unknown-instance.com/users/brand_new_person"]
@@ -744,7 +744,7 @@ func (suite *ASToInternalTestSuite) TestParseAccountableWithoutAnyUsername() {
}
func (suite *ASToInternalTestSuite) TestParseAccountableWithPreferredUsername() {
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
testPerson := suite.testPeople["https://unknown-instance.com/users/brand_new_person"]
diff --git a/internal/typeutils/internaltoas_test.go b/internal/typeutils/internaltoas_test.go
index 5ba23a77e..ab81095fd 100644
--- a/internal/typeutils/internaltoas_test.go
+++ b/internal/typeutils/internaltoas_test.go
@@ -18,7 +18,6 @@
package typeutils_test
import (
- "context"
"encoding/json"
"errors"
"testing"
@@ -38,7 +37,7 @@ func (suite *InternalToASTestSuite) TestAccountToAS() {
testAccount := >smodel.Account{}
*testAccount = *suite.testAccounts["local_account_1"] // take zork for this test
- accountable, err := suite.typeconverter.AccountToAS(context.Background(), testAccount)
+ accountable, err := suite.typeconverter.AccountToAS(suite.T().Context(), testAccount)
suite.NoError(err)
ser, err := ap.Serialize(accountable)
@@ -100,11 +99,11 @@ func (suite *InternalToASTestSuite) TestAccountToASBot() {
// Update zork to be a bot.
testAccount.ActorType = gtsmodel.AccountActorTypeApplication
- if err := suite.state.DB.UpdateAccount(context.Background(), testAccount); err != nil {
+ if err := suite.state.DB.UpdateAccount(suite.T().Context(), testAccount); err != nil {
suite.FailNow(err.Error())
}
- accountable, err := suite.typeconverter.AccountToAS(context.Background(), testAccount)
+ accountable, err := suite.typeconverter.AccountToAS(suite.T().Context(), testAccount)
suite.NoError(err)
ser, err := ap.Serialize(accountable)
@@ -164,7 +163,7 @@ func (suite *InternalToASTestSuite) TestAccountToASWithFields() {
testAccount := >smodel.Account{}
*testAccount = *suite.testAccounts["local_account_2"]
- accountable, err := suite.typeconverter.AccountToAS(context.Background(), testAccount)
+ accountable, err := suite.typeconverter.AccountToAS(suite.T().Context(), testAccount)
suite.NoError(err)
ser, err := ap.Serialize(accountable)
@@ -229,7 +228,7 @@ func (suite *InternalToASTestSuite) TestAccountToASAliasedAndMoved() {
testAccount := >smodel.Account{}
*testAccount = *suite.testAccounts["local_account_1"] // take zork for this test
- ctx := context.Background()
+ ctx := suite.T().Context()
// Suppose zork has moved account to turtle.
testAccount.AlsoKnownAsURIs = []string{"http://localhost:8080/users/1happyturtle"}
@@ -242,7 +241,7 @@ func (suite *InternalToASTestSuite) TestAccountToASAliasedAndMoved() {
suite.FailNow(err.Error())
}
- accountable, err := suite.typeconverter.AccountToAS(context.Background(), testAccount)
+ accountable, err := suite.typeconverter.AccountToAS(suite.T().Context(), testAccount)
suite.NoError(err)
ser, err := ap.Serialize(accountable)
@@ -312,7 +311,7 @@ func (suite *InternalToASTestSuite) TestAccountToASWithOneField() {
*testAccount = *suite.testAccounts["local_account_2"]
testAccount.Fields = testAccount.Fields[0:1] // Take only one field.
- accountable, err := suite.typeconverter.AccountToAS(context.Background(), testAccount)
+ accountable, err := suite.typeconverter.AccountToAS(suite.T().Context(), testAccount)
suite.NoError(err)
ser, err := ap.Serialize(accountable)
@@ -374,7 +373,7 @@ func (suite *InternalToASTestSuite) TestAccountToASWithEmoji() {
*testAccount = *suite.testAccounts["local_account_1"] // take zork for this test
testAccount.Emojis = []*gtsmodel.Emoji{suite.testEmojis["rainbow"]}
- accountable, err := suite.typeconverter.AccountToAS(context.Background(), testAccount)
+ accountable, err := suite.typeconverter.AccountToAS(suite.T().Context(), testAccount)
suite.NoError(err)
ser, err := ap.Serialize(accountable)
@@ -447,7 +446,7 @@ func (suite *InternalToASTestSuite) TestAccountToASWithSharedInbox() {
sharedInbox := "http://localhost:8080/sharedInbox"
testAccount.SharedInboxURI = &sharedInbox
- accountable, err := suite.typeconverter.AccountToAS(context.Background(), testAccount)
+ accountable, err := suite.typeconverter.AccountToAS(suite.T().Context(), testAccount)
suite.NoError(err)
ser, err := ap.Serialize(accountable)
@@ -508,7 +507,7 @@ func (suite *InternalToASTestSuite) TestAccountToASWithSharedInbox() {
func (suite *InternalToASTestSuite) TestStatusToAS() {
testStatus := suite.testStatuses["local_account_1_status_1"]
- ctx := context.Background()
+ ctx := suite.T().Context()
asStatus, err := suite.typeconverter.StatusToAS(ctx, testStatus)
suite.NoError(err)
@@ -590,7 +589,7 @@ func (suite *InternalToASTestSuite) TestStatusToAS() {
func (suite *InternalToASTestSuite) TestStatusWithTagsToASWithIDs() {
// use the status with just IDs of attachments and emojis pinned on it
testStatus := suite.testStatuses["admin_account_status_1"]
- ctx := context.Background()
+ ctx := suite.T().Context()
asStatus, err := suite.typeconverter.StatusToAS(ctx, testStatus)
suite.NoError(err)
@@ -707,7 +706,7 @@ func (suite *InternalToASTestSuite) TestStatusWithTagsToASWithIDs() {
}
func (suite *InternalToASTestSuite) TestStatusWithTagsToASFromDB() {
- ctx := context.Background()
+ ctx := suite.T().Context()
// get the entire status with all tags
testStatus, err := suite.db.GetStatusByID(ctx, suite.testStatuses["admin_account_status_1"].ID)
suite.NoError(err)
@@ -828,7 +827,7 @@ func (suite *InternalToASTestSuite) TestStatusWithTagsToASFromDB() {
func (suite *InternalToASTestSuite) TestStatusToASWithMentions() {
testStatusID := suite.testStatuses["admin_account_status_3"].ID
- ctx := context.Background()
+ ctx := suite.T().Context()
testStatus, err := suite.db.GetStatusByID(ctx, testStatusID)
suite.NoError(err)
@@ -920,7 +919,7 @@ func (suite *InternalToASTestSuite) TestStatusToASWithMentions() {
func (suite *InternalToASTestSuite) TestStatusToASDeletePublicReply() {
testStatus := suite.testStatuses["admin_account_status_3"]
- ctx := context.Background()
+ ctx := suite.T().Context()
asDelete, err := suite.typeconverter.StatusToASDelete(ctx, testStatus)
suite.NoError(err)
@@ -946,7 +945,7 @@ func (suite *InternalToASTestSuite) TestStatusToASDeletePublicReply() {
func (suite *InternalToASTestSuite) TestStatusToASDeletePublicReplyOriginalDeleted() {
testStatus := suite.testStatuses["admin_account_status_3"]
- ctx := context.Background()
+ ctx := suite.T().Context()
// Delete the status this replies to.
if err := suite.db.DeleteStatusByID(ctx, testStatus.ID); err != nil {
@@ -984,7 +983,7 @@ func (suite *InternalToASTestSuite) TestStatusToASDeletePublicReplyOriginalDelet
func (suite *InternalToASTestSuite) TestStatusToASDeletePublic() {
testStatus := suite.testStatuses["admin_account_status_1"]
- ctx := context.Background()
+ ctx := suite.T().Context()
asDelete, err := suite.typeconverter.StatusToASDelete(ctx, testStatus)
suite.NoError(err)
@@ -1007,7 +1006,7 @@ func (suite *InternalToASTestSuite) TestStatusToASDeletePublic() {
func (suite *InternalToASTestSuite) TestStatusToASDeleteDirectMessage() {
testStatus := suite.testStatuses["local_account_2_status_6"]
- ctx := context.Background()
+ ctx := suite.T().Context()
asDelete, err := suite.typeconverter.StatusToASDelete(ctx, testStatus)
suite.NoError(err)
@@ -1030,7 +1029,7 @@ func (suite *InternalToASTestSuite) TestStatusToASDeleteDirectMessage() {
func (suite *InternalToASTestSuite) TestStatusesToASOutboxPage() {
testAccount := suite.testAccounts["admin_account"]
- ctx := context.Background()
+ ctx := suite.T().Context()
// get public statuses from testaccount
statuses, err := suite.db.GetAccountStatuses(ctx, testAccount.ID, 30, true, true, "", "", false, true)
@@ -1076,7 +1075,7 @@ func (suite *InternalToASTestSuite) TestStatusesToASOutboxPage() {
}
func (suite *InternalToASTestSuite) TestSelfBoostFollowersOnlyToAS() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testStatus := suite.testStatuses["local_account_1_status_5"]
testAccount := suite.testAccounts["local_account_1"]
@@ -1112,7 +1111,7 @@ func (suite *InternalToASTestSuite) TestSelfBoostFollowersOnlyToAS() {
}
func (suite *InternalToASTestSuite) TestReportToAS() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testReport := suite.testReports["local_account_2_report_remote_account_1"]
account := suite.testAccounts["local_account_2"]
@@ -1146,7 +1145,7 @@ func (suite *InternalToASTestSuite) TestReportToAS() {
}
func (suite *InternalToASTestSuite) TestPinnedStatusesToASSomeItems() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testAccount := suite.testAccounts["admin_account"]
statuses, err := suite.db.GetAccountPinnedStatuses(ctx, testAccount.ID)
@@ -1178,7 +1177,7 @@ func (suite *InternalToASTestSuite) TestPinnedStatusesToASSomeItems() {
}
func (suite *InternalToASTestSuite) TestPinnedStatusesToASNoItems() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testAccount := suite.testAccounts["local_account_1"]
statuses, err := suite.db.GetAccountPinnedStatuses(ctx, testAccount.ID)
@@ -1207,7 +1206,7 @@ func (suite *InternalToASTestSuite) TestPinnedStatusesToASNoItems() {
}
func (suite *InternalToASTestSuite) TestPinnedStatusesToASOneItem() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testAccount := suite.testAccounts["local_account_2"]
statuses, err := suite.db.GetAccountPinnedStatuses(ctx, testAccount.ID)
@@ -1240,7 +1239,7 @@ func (suite *InternalToASTestSuite) TestPinnedStatusesToASOneItem() {
func (suite *InternalToASTestSuite) TestPollVoteToASCreate() {
vote := suite.testPollVotes["remote_account_1_status_2_poll_vote_local_account_1"]
- creates, err := suite.typeconverter.PollVoteToASCreates(context.Background(), vote)
+ creates, err := suite.typeconverter.PollVoteToASCreates(suite.T().Context(), vote)
suite.NoError(err)
suite.Len(creates, 2)
@@ -1311,7 +1310,7 @@ func (suite *InternalToASTestSuite) TestInteractionReqToASAcceptAnnounce() {
}
accept, err := suite.typeconverter.InteractionReqToASAccept(
- context.Background(),
+ suite.T().Context(),
req,
)
if err != nil {
@@ -1363,7 +1362,7 @@ func (suite *InternalToASTestSuite) TestInteractionReqToASAcceptLike() {
}
accept, err := suite.typeconverter.InteractionReqToASAccept(
- context.Background(),
+ suite.T().Context(),
req,
)
if err != nil {
diff --git a/internal/typeutils/internaltofrontend_test.go b/internal/typeutils/internaltofrontend_test.go
index 74250769b..c1b29ad21 100644
--- a/internal/typeutils/internaltofrontend_test.go
+++ b/internal/typeutils/internaltofrontend_test.go
@@ -41,7 +41,7 @@ type InternalToFrontendTestSuite struct {
func (suite *InternalToFrontendTestSuite) TestAccountToFrontend() {
testAccount := suite.testAccounts["local_account_1"] // take zork for this test
- apiAccount, err := suite.typeconverter.AccountToAPIAccountPublic(context.Background(), testAccount)
+ apiAccount, err := suite.typeconverter.AccountToAPIAccountPublic(suite.T().Context(), testAccount)
suite.NoError(err)
suite.NotNil(apiAccount)
@@ -88,11 +88,11 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendAliasedAndMoved()
testAccount.MovedToURI = movedTo.URI
testAccount.AlsoKnownAsURIs = []string{movedTo.URI}
- if err := suite.state.DB.UpdateAccount(context.Background(), testAccount, "moved_to_uri"); err != nil {
+ if err := suite.state.DB.UpdateAccount(suite.T().Context(), testAccount, "moved_to_uri"); err != nil {
suite.FailNow(err.Error())
}
- apiAccount, err := suite.typeconverter.AccountToAPIAccountSensitive(context.Background(), testAccount)
+ apiAccount, err := suite.typeconverter.AccountToAPIAccountSensitive(suite.T().Context(), testAccount)
suite.NoError(err)
suite.NotNil(apiAccount)
@@ -195,7 +195,7 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendWithEmojiStruct()
testAccount.Emojis = []*gtsmodel.Emoji{testEmoji}
testAccount.EmojiIDs = []string{testEmoji.ID}
- apiAccount, err := suite.typeconverter.AccountToAPIAccountPublic(context.Background(), testAccount)
+ apiAccount, err := suite.typeconverter.AccountToAPIAccountPublic(suite.T().Context(), testAccount)
suite.NoError(err)
suite.NotNil(apiAccount)
@@ -245,7 +245,7 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendWithEmojiIDs() {
testAccount.EmojiIDs = []string{testEmoji.ID}
- apiAccount, err := suite.typeconverter.AccountToAPIAccountPublic(context.Background(), testAccount)
+ apiAccount, err := suite.typeconverter.AccountToAPIAccountPublic(suite.T().Context(), testAccount)
suite.NoError(err)
suite.NotNil(apiAccount)
@@ -291,7 +291,7 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendWithEmojiIDs() {
func (suite *InternalToFrontendTestSuite) TestAccountToFrontendSensitive() {
testAccount := suite.testAccounts["local_account_1"] // take zork for this test
- apiAccount, err := suite.typeconverter.AccountToAPIAccountSensitive(context.Background(), testAccount)
+ apiAccount, err := suite.typeconverter.AccountToAPIAccountSensitive(suite.T().Context(), testAccount)
suite.NoError(err)
suite.NotNil(apiAccount)
@@ -347,7 +347,7 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendSensitive() {
func (suite *InternalToFrontendTestSuite) TestAccountToFrontendPublicPunycode() {
testAccount := suite.testAccounts["remote_account_4"]
- apiAccount, err := suite.typeconverter.AccountToAPIAccountPublic(context.Background(), testAccount)
+ apiAccount, err := suite.typeconverter.AccountToAPIAccountPublic(suite.T().Context(), testAccount)
suite.NoError(err)
suite.NotNil(apiAccount)
@@ -384,7 +384,7 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendPublicPunycode()
}
func (suite *InternalToFrontendTestSuite) TestLocalInstanceAccountToFrontendPublic() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testAccount, err := suite.db.GetInstanceAccount(ctx, "")
if err != nil {
suite.FailNow(err.Error())
@@ -424,7 +424,7 @@ func (suite *InternalToFrontendTestSuite) TestLocalInstanceAccountToFrontendPubl
}
func (suite *InternalToFrontendTestSuite) TestLocalInstanceAccountToFrontendBlocked() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testAccount, err := suite.db.GetInstanceAccount(ctx, "")
if err != nil {
suite.FailNow(err.Error())
@@ -466,7 +466,7 @@ func (suite *InternalToFrontendTestSuite) TestLocalInstanceAccountToFrontendBloc
func (suite *InternalToFrontendTestSuite) TestStatusToFrontend() {
testStatus := suite.testStatuses["admin_account_status_1"]
requestingAccount := suite.testAccounts["local_account_1"]
- apiStatus, err := suite.typeconverter.StatusToAPIStatus(context.Background(), testStatus, requestingAccount, statusfilter.FilterContextNone, nil, nil)
+ apiStatus, err := suite.typeconverter.StatusToAPIStatus(suite.T().Context(), testStatus, requestingAccount, statusfilter.FilterContextNone, nil, nil)
suite.NoError(err)
b, err := json.MarshalIndent(apiStatus, "", " ")
@@ -629,7 +629,7 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendHTMLContentWarning
testStatus.ContentWarning = `First paragraph of content warning
Here's the title!
Big boobs
Tee hee!
Some more text
And a bunch more
Hasta la victoria siempre!
`
requestingAccount := suite.testAccounts["local_account_1"]
- apiStatus, err := suite.typeconverter.StatusToAPIStatus(context.Background(), testStatus, requestingAccount, statusfilter.FilterContextNone, nil, nil)
+ apiStatus, err := suite.typeconverter.StatusToAPIStatus(suite.T().Context(), testStatus, requestingAccount, statusfilter.FilterContextNone, nil, nil)
suite.NoError(err)
b, err := json.MarshalIndent(apiStatus, "", " ")
@@ -786,7 +786,7 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendHTMLContentWarning
}
func (suite *InternalToFrontendTestSuite) TestStatusToFrontendApplicationDeleted() {
- ctx := context.Background()
+ ctx := suite.T().Context()
testStatus := suite.testStatuses["admin_account_status_1"]
// Delete the application this status was created with.
@@ -979,7 +979,7 @@ func (suite *InternalToFrontendTestSuite) filteredStatusToFrontend(action gtsmod
requestingAccountFilters := []*gtsmodel.Filter{expectedMatchingFilter}
return suite.typeconverter.StatusToAPIStatus(
- context.Background(),
+ suite.T().Context(),
testStatus,
requestingAccount,
statusfilter.FilterContextHome,
@@ -1500,7 +1500,7 @@ func (suite *InternalToFrontendTestSuite) testHashtagFilteredStatusToFrontend(wh
if boost {
boost, err := suite.typeconverter.StatusToBoost(
- context.Background(),
+ suite.T().Context(),
testStatus,
suite.testAccounts["admin_account"],
"",
@@ -1533,7 +1533,7 @@ func (suite *InternalToFrontendTestSuite) testHashtagFilteredStatusToFrontend(wh
}
apiStatus, err := suite.typeconverter.StatusToAPIStatus(
- context.Background(),
+ suite.T().Context(),
testStatus,
requestingAccount,
statusfilter.FilterContextHome,
@@ -1577,7 +1577,7 @@ func (suite *InternalToFrontendTestSuite) TestMutedStatusToFrontend() {
})
_, err := suite.typeconverter.StatusToAPIStatus(
- context.Background(),
+ suite.T().Context(),
testStatus,
requestingAccount,
statusfilter.FilterContextHome,
@@ -1604,14 +1604,14 @@ func (suite *InternalToFrontendTestSuite) TestMutedReplyStatusToFrontend() {
})
// Populate status so the converter has the account objects it needs for muting.
- err := suite.db.PopulateStatus(context.Background(), testStatus)
+ err := suite.db.PopulateStatus(suite.T().Context(), testStatus)
if err != nil {
suite.FailNow(err.Error())
}
// Convert the status to API format, which should fail.
_, err = suite.typeconverter.StatusToAPIStatus(
- context.Background(),
+ suite.T().Context(),
testStatus,
requestingAccount,
statusfilter.FilterContextHome,
@@ -1637,14 +1637,14 @@ func (suite *InternalToFrontendTestSuite) TestMutedBoostStatusToFrontend() {
})
// Populate status so the converter has the account objects it needs for muting.
- err := suite.db.PopulateStatus(context.Background(), testStatus)
+ err := suite.db.PopulateStatus(suite.T().Context(), testStatus)
if err != nil {
suite.FailNow(err.Error())
}
// Convert the status to API format, which should fail.
_, err = suite.typeconverter.StatusToAPIStatus(
- context.Background(),
+ suite.T().Context(),
testStatus,
requestingAccount,
statusfilter.FilterContextHome,
@@ -1658,7 +1658,7 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownAttachments
testStatus := suite.testStatuses["remote_account_2_status_1"]
requestingAccount := suite.testAccounts["admin_account"]
- apiStatus, err := suite.typeconverter.StatusToAPIStatus(context.Background(), testStatus, requestingAccount, statusfilter.FilterContextNone, nil, nil)
+ apiStatus, err := suite.typeconverter.StatusToAPIStatus(suite.T().Context(), testStatus, requestingAccount, statusfilter.FilterContextNone, nil, nil)
suite.NoError(err)
b, err := json.MarshalIndent(apiStatus, "", " ")
@@ -1797,7 +1797,7 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownAttachments
func (suite *InternalToFrontendTestSuite) TestStatusToWebStatus() {
testStatus := suite.testStatuses["remote_account_2_status_1"]
- apiStatus, err := suite.typeconverter.StatusToWebStatus(context.Background(), testStatus)
+ apiStatus, err := suite.typeconverter.StatusToWebStatus(suite.T().Context(), testStatus)
suite.NoError(err)
// MediaAttachments should inherit
@@ -1985,7 +1985,7 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownLanguage()
*testStatus = *suite.testStatuses["admin_account_status_1"]
testStatus.Language = ""
requestingAccount := suite.testAccounts["local_account_1"]
- apiStatus, err := suite.typeconverter.StatusToAPIStatus(context.Background(), testStatus, requestingAccount, statusfilter.FilterContextNone, nil, nil)
+ apiStatus, err := suite.typeconverter.StatusToAPIStatus(suite.T().Context(), testStatus, requestingAccount, statusfilter.FilterContextNone, nil, nil)
suite.NoError(err)
b, err := json.MarshalIndent(apiStatus, "", " ")
@@ -2146,7 +2146,7 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendPartialInteraction
*testStatus = *suite.testStatuses["local_account_1_status_3"]
testStatus.Language = ""
requestingAccount := suite.testAccounts["admin_account"]
- apiStatus, err := suite.typeconverter.StatusToAPIStatus(context.Background(), testStatus, requestingAccount, statusfilter.FilterContextNone, nil, nil)
+ apiStatus, err := suite.typeconverter.StatusToAPIStatus(suite.T().Context(), testStatus, requestingAccount, statusfilter.FilterContextNone, nil, nil)
suite.NoError(err)
b, err := json.MarshalIndent(apiStatus, "", " ")
@@ -2256,7 +2256,7 @@ func (suite *InternalToFrontendTestSuite) TestStatusToAPIStatusPendingApproval()
)
apiStatus, err := suite.typeconverter.StatusToAPIStatus(
- context.Background(),
+ suite.T().Context(),
testStatus,
requestingAccount,
statusfilter.FilterContextNone,
@@ -2394,7 +2394,7 @@ func (suite *InternalToFrontendTestSuite) TestStatusToAPIStatusPendingApproval()
func (suite *InternalToFrontendTestSuite) TestVideoAttachmentToFrontend() {
testAttachment := suite.testAttachments["local_account_1_status_4_attachment_2"]
- apiAttachment, err := suite.typeconverter.AttachmentToAPIAttachment(context.Background(), testAttachment)
+ apiAttachment, err := suite.typeconverter.AttachmentToAPIAttachment(suite.T().Context(), testAttachment)
suite.NoError(err)
b, err := json.MarshalIndent(apiAttachment, "", " ")
@@ -2435,7 +2435,7 @@ func (suite *InternalToFrontendTestSuite) TestVideoAttachmentToFrontend() {
}
func (suite *InternalToFrontendTestSuite) TestInstanceV1ToFrontend() {
- ctx := context.Background()
+ ctx := suite.T().Context()
i := >smodel.Instance{}
if err := suite.db.GetWhere(ctx, []db.Where{{Key: "domain", Value: config.GetHost()}}, i); err != nil {
@@ -2572,7 +2572,7 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV1ToFrontend() {
}
func (suite *InternalToFrontendTestSuite) TestInstanceV2ToFrontend() {
- ctx := context.Background()
+ ctx := suite.T().Context()
i := >smodel.Instance{}
if err := suite.db.GetWhere(ctx, []db.Where{{Key: "domain", Value: config.GetHost()}}, i); err != nil {
@@ -2726,7 +2726,7 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV2ToFrontend() {
}
func (suite *InternalToFrontendTestSuite) TestEmojiToFrontend() {
- emoji, err := suite.typeconverter.EmojiToAPIEmoji(context.Background(), suite.testEmojis["rainbow"])
+ emoji, err := suite.typeconverter.EmojiToAPIEmoji(suite.T().Context(), suite.testEmojis["rainbow"])
suite.NoError(err)
b, err := json.MarshalIndent(emoji, "", " ")
@@ -2742,7 +2742,7 @@ func (suite *InternalToFrontendTestSuite) TestEmojiToFrontend() {
}
func (suite *InternalToFrontendTestSuite) TestEmojiToFrontendAdmin1() {
- emoji, err := suite.typeconverter.EmojiToAdminAPIEmoji(context.Background(), suite.testEmojis["rainbow"])
+ emoji, err := suite.typeconverter.EmojiToAdminAPIEmoji(suite.T().Context(), suite.testEmojis["rainbow"])
suite.NoError(err)
b, err := json.MarshalIndent(emoji, "", " ")
@@ -2764,7 +2764,7 @@ func (suite *InternalToFrontendTestSuite) TestEmojiToFrontendAdmin1() {
}
func (suite *InternalToFrontendTestSuite) TestEmojiToFrontendAdmin2() {
- emoji, err := suite.typeconverter.EmojiToAdminAPIEmoji(context.Background(), suite.testEmojis["yell"])
+ emoji, err := suite.typeconverter.EmojiToAdminAPIEmoji(suite.T().Context(), suite.testEmojis["yell"])
suite.NoError(err)
b, err := json.MarshalIndent(emoji, "", " ")
@@ -2786,7 +2786,7 @@ func (suite *InternalToFrontendTestSuite) TestEmojiToFrontendAdmin2() {
}
func (suite *InternalToFrontendTestSuite) TestReportToFrontend1() {
- report, err := suite.typeconverter.ReportToAPIReport(context.Background(), suite.testReports["local_account_2_report_remote_account_1"])
+ report, err := suite.typeconverter.ReportToAPIReport(suite.T().Context(), suite.testReports["local_account_2_report_remote_account_1"])
suite.NoError(err)
b, err := json.MarshalIndent(report, "", " ")
@@ -2836,7 +2836,7 @@ func (suite *InternalToFrontendTestSuite) TestReportToFrontend1() {
}
func (suite *InternalToFrontendTestSuite) TestReportToFrontend2() {
- report, err := suite.typeconverter.ReportToAPIReport(context.Background(), suite.testReports["remote_account_1_report_local_account_2"])
+ report, err := suite.typeconverter.ReportToAPIReport(suite.T().Context(), suite.testReports["remote_account_1_report_local_account_2"])
suite.NoError(err)
b, err := json.MarshalIndent(report, "", " ")
@@ -2894,7 +2894,7 @@ func (suite *InternalToFrontendTestSuite) TestReportToFrontend2() {
func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() {
requestingAccount := suite.testAccounts["admin_account"]
- adminReport, err := suite.typeconverter.ReportToAdminAPIReport(context.Background(), suite.testReports["remote_account_1_report_local_account_2"], requestingAccount)
+ adminReport, err := suite.typeconverter.ReportToAdminAPIReport(suite.T().Context(), suite.testReports["remote_account_1_report_local_account_2"], requestingAccount)
suite.NoError(err)
b, err := json.MarshalIndent(adminReport, "", " ")
@@ -3136,7 +3136,7 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() {
func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() {
requestingAccount := suite.testAccounts["admin_account"]
- adminReport, err := suite.typeconverter.ReportToAdminAPIReport(context.Background(), suite.testReports["local_account_2_report_remote_account_1"], requestingAccount)
+ adminReport, err := suite.typeconverter.ReportToAdminAPIReport(suite.T().Context(), suite.testReports["local_account_2_report_remote_account_1"], requestingAccount)
suite.NoError(err)
b, err := json.MarshalIndent(adminReport, "", " ")
@@ -3398,7 +3398,7 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() {
}
func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontendSuspendedLocalAccount() {
- ctx := context.Background()
+ ctx := suite.T().Context()
requestingAccount := suite.testAccounts["admin_account"]
reportedAccount := >smodel.Account{}
*reportedAccount = *suite.testAccounts["local_account_2"]
@@ -3421,7 +3421,7 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontendSuspendedLoca
suite.FailNow("timed out waiting for account delete")
}
- adminReport, err := suite.typeconverter.ReportToAdminAPIReport(context.Background(), suite.testReports["remote_account_1_report_local_account_2"], requestingAccount)
+ adminReport, err := suite.typeconverter.ReportToAdminAPIReport(suite.T().Context(), suite.testReports["remote_account_1_report_local_account_2"], requestingAccount)
suite.NoError(err)
b, err := json.MarshalIndent(adminReport, "", " ")
@@ -3652,7 +3652,7 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontendSuspendedLoca
func (suite *InternalToFrontendTestSuite) TestRelationshipFollowRequested() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
account1 = suite.testAccounts["admin_account"]
account2 = suite.testAccounts["local_account_2"]
)
@@ -3741,7 +3741,7 @@ func (suite *InternalToFrontendTestSuite) TestRelationshipFollowRequested() {
func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() {
requestingAccount := suite.testAccounts["local_account_2"]
adminReport, err := suite.typeconverter.InteractionReqToAPIInteractionReq(
- context.Background(),
+ suite.T().Context(),
suite.testInteractionRequests["admin_account_reply_turtle"],
requestingAccount,
)
@@ -4020,7 +4020,7 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() {
func (suite *InternalToFrontendTestSuite) TestConversationToAPISelfConvo() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
requester = suite.testAccounts["local_account_1"]
lastStatus = suite.testStatuses["local_account_1_status_1"]
filters []*gtsmodel.Filter = nil
@@ -4195,7 +4195,7 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPISelfConvo() {
func (suite *InternalToFrontendTestSuite) TestConversationToAPI() {
var (
- ctx = context.Background()
+ ctx = suite.T().Context()
requester = suite.testAccounts["local_account_1"]
lastStatus = suite.testStatuses["local_account_1_status_1"]
filters []*gtsmodel.Filter = nil
@@ -4379,7 +4379,7 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPI() {
}
func (suite *InternalToFrontendTestSuite) TestStatusToAPIEdits() {
- ctx, cncl := context.WithCancel(context.Background())
+ ctx, cncl := context.WithCancel(suite.T().Context())
defer cncl()
statusID := suite.testStatuses["local_account_1_status_9"].ID
diff --git a/internal/typeutils/internaltorss_test.go b/internal/typeutils/internaltorss_test.go
index 27d22cf81..89c88be27 100644
--- a/internal/typeutils/internaltorss_test.go
+++ b/internal/typeutils/internaltorss_test.go
@@ -18,7 +18,6 @@
package typeutils_test
import (
- "context"
"encoding/xml"
"testing"
@@ -34,7 +33,7 @@ type InternalToRSSTestSuite struct {
func (suite *InternalToRSSTestSuite) TestStatusToRSSItem1() {
s := suite.testStatuses["local_account_1_status_1"]
- item, err := suite.typeconverter.StatusToRSSItem(context.Background(), s)
+ item, err := suite.typeconverter.StatusToRSSItem(suite.T().Context(), s)
suite.NoError(err)
suite.Equal("introduction post", item.Title)
@@ -59,7 +58,7 @@ func (suite *InternalToRSSTestSuite) TestStatusToRSSItem1() {
func (suite *InternalToRSSTestSuite) TestStatusToRSSItem2() {
s := suite.testStatuses["admin_account_status_1"]
- item, err := suite.typeconverter.StatusToRSSItem(context.Background(), s)
+ item, err := suite.typeconverter.StatusToRSSItem(suite.T().Context(), s)
suite.NoError(err)
suite.Equal("hello world! #welcome ! first post on the instance :rainbow: !", item.Title)
@@ -97,7 +96,7 @@ func (suite *InternalToRSSTestSuite) TestStatusToRSSItem3() {
ActivityStreamsType: ap.ObjectNote,
Federated: util.Ptr(true),
}
- item, err := suite.typeconverter.StatusToRSSItem(context.Background(), s)
+ item, err := suite.typeconverter.StatusToRSSItem(suite.T().Context(), s)
suite.NoError(err)
data, err := xml.MarshalIndent(item, "", " ")
diff --git a/internal/typeutils/util_test.go b/internal/typeutils/util_test.go
index 4f0e70db0..42a86372f 100644
--- a/internal/typeutils/util_test.go
+++ b/internal/typeutils/util_test.go
@@ -18,7 +18,6 @@
package typeutils
import (
- "context"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/config"
@@ -59,8 +58,7 @@ func TestContentToContentLanguage(t *testing.T) {
expectedLang string
}
- ctx, cncl := context.WithCancel(context.Background())
- defer cncl()
+ ctx := t.Context()
for i, testcase := range []testcase{
{
diff --git a/internal/typeutils/wrap_test.go b/internal/typeutils/wrap_test.go
index ae68d98c8..48a28e3b0 100644
--- a/internal/typeutils/wrap_test.go
+++ b/internal/typeutils/wrap_test.go
@@ -18,7 +18,6 @@
package typeutils_test
import (
- "context"
"encoding/json"
"testing"
@@ -34,7 +33,7 @@ type WrapTestSuite struct {
func (suite *WrapTestSuite) TestWrapNoteInCreateIRIOnly() {
testStatus := suite.testStatuses["local_account_1_status_1"]
- note, err := suite.typeconverter.StatusToAS(context.Background(), testStatus)
+ note, err := suite.typeconverter.StatusToAS(suite.T().Context(), testStatus)
suite.NoError(err)
create := typeutils.WrapStatusableInCreate(note, true)
@@ -62,7 +61,7 @@ func (suite *WrapTestSuite) TestWrapNoteInCreateIRIOnly() {
func (suite *WrapTestSuite) TestWrapNoteInCreate() {
testStatus := suite.testStatuses["local_account_1_status_1"]
- note, err := suite.typeconverter.StatusToAS(context.Background(), testStatus)
+ note, err := suite.typeconverter.StatusToAS(suite.T().Context(), testStatus)
suite.NoError(err)
create := typeutils.WrapStatusableInCreate(note, false)
@@ -154,7 +153,7 @@ func (suite *WrapTestSuite) TestWrapNoteInCreate() {
func (suite *WrapTestSuite) TestWrapAccountableInUpdate() {
testAccount := suite.testAccounts["local_account_1"]
- accountable, err := suite.typeconverter.AccountToAS(context.Background(), testAccount)
+ accountable, err := suite.typeconverter.AccountToAS(suite.T().Context(), testAccount)
if err != nil {
suite.FailNow(err.Error())
}
diff --git a/internal/webpush/realsender.go b/internal/webpush/realsender.go
index 0a04a2b68..075927095 100644
--- a/internal/webpush/realsender.go
+++ b/internal/webpush/realsender.go
@@ -320,9 +320,8 @@ func formatNotificationTitle(
case gtsmodel.NotificationPoll:
if subscription.AccountID == notification.TargetAccountID {
return "Your poll has ended"
- } else {
- return fmt.Sprintf("%s's poll has ended", displayNameOrAcct)
}
+ return fmt.Sprintf("%s's poll has ended", displayNameOrAcct)
case gtsmodel.NotificationStatus:
return fmt.Sprintf("%s posted", displayNameOrAcct)
case gtsmodel.NotificationAdminSignup:
diff --git a/internal/webpush/realsender_test.go b/internal/webpush/realsender_test.go
index cf9cf4cac..bddcbbc28 100644
--- a/internal/webpush/realsender_test.go
+++ b/internal/webpush/realsender_test.go
@@ -167,7 +167,7 @@ func (suite *RealSenderStandardTestSuite) simulatePushNotification(
expectDeletedSubscription bool,
) error {
// Don't let the test run forever if the push notification was not sent for some reason.
- ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
+ ctx, cancel := context.WithTimeout(suite.T().Context(), 3*time.Second)
defer cancel()
notification, err := suite.state.DB.GetNotificationByID(ctx, notificationID)
@@ -263,7 +263,7 @@ func (suite *RealSenderStandardTestSuite) TestSendPolicyMismatch() {
StatusOrEditID: "01F8MHAMCHF6Y650WCRSCP4WMY",
Read: util.Ptr(false),
}
- if err := suite.db.PutNotification(context.Background(), notification); !suite.NoError(err) {
+ if err := suite.db.PutNotification(suite.T().Context(), notification); !suite.NoError(err) {
suite.FailNow(err.Error())
return
}