mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[chore] Upgrade to Go 1.24 (#4187)
* Set `go.mod` to 1.24 now that it's been out for 3 months. * Update all the test to use `testing.T.Context()`. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4187 Co-authored-by: Daenney <git@noreply.sourcery.dny.nu> Co-committed-by: Daenney <git@noreply.sourcery.dny.nu>
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
4
go.mod
4
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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
),
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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() {
|
||||
<title>.</title>`)
|
||||
|
||||
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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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,
|
||||
)
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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,
|
||||
)
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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"]
|
||||
)
|
||||
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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"),
|
||||
|
@ -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 {
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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())
|
||||
|
@ -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())
|
||||
|
@ -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"]
|
||||
|
@ -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(),
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
|
4
internal/cache/timeline/status_test.go
vendored
4
internal/cache/timeline/status_test.go
vendored
@ -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.
|
||||
|
@ -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),
|
||||
)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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(
|
||||
|
@ -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())
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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{
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
)
|
||||
|
||||
|
@ -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",
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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",
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
)
|
||||
|
||||
|
@ -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{
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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]
|
||||
|
@ -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",
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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"]
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
})
|
||||
|
@ -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,
|
||||
|
@ -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"]
|
||||
)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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) {
|
||||
|
@ -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"]
|
||||
|
@ -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"
|
||||
|
@ -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,
|
||||
)
|
||||
|
@ -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.
|
||||
|
@ -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"]
|
||||
|
||||
|
@ -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))
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user