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.
|
# We use golangci-lint for linting.
|
||||||
# See: https://golangci-lint.run/
|
# See: https://golangci-lint.run/
|
||||||
image: golangci/golangci-lint:v1.62.0
|
image: golangci/golangci-lint:v1.64.8
|
||||||
pull: true
|
pull: true
|
||||||
|
|
||||||
# https://woodpecker-ci.org/docs/administration/configuration/backends/docker#run-user
|
# 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/" }) ||
|
any(fromJSON(CI_PIPELINE_FILES), { # startsWith "internal/" || # startsWith "cmd/" || # startsWith "testrig/" || # startsWith "vendor/" }) ||
|
||||||
len(fromJSON(CI_PIPELINE_FILES)) == 0
|
len(fromJSON(CI_PIPELINE_FILES)) == 0
|
||||||
|
|
||||||
image: golang:1.23-alpine
|
image: golang:1.24-alpine
|
||||||
pull: true
|
pull: true
|
||||||
|
|
||||||
# https://woodpecker-ci.org/docs/administration/configuration/backends/docker#run-user
|
# https://woodpecker-ci.org/docs/administration/configuration/backends/docker#run-user
|
||||||
|
@ -13,7 +13,7 @@ clone:
|
|||||||
steps:
|
steps:
|
||||||
release:
|
release:
|
||||||
# https://codeberg.org/superseriousbusiness/gotosocial-woodpecker-build
|
# 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
|
pull: true
|
||||||
|
|
||||||
# https://woodpecker-ci.org/docs/usage/volumes
|
# https://woodpecker-ci.org/docs/usage/volumes
|
||||||
|
@ -29,7 +29,7 @@ steps:
|
|||||||
len(fromJSON(CI_PIPELINE_FILES)) == 0
|
len(fromJSON(CI_PIPELINE_FILES)) == 0
|
||||||
|
|
||||||
# https://codeberg.org/superseriousbusiness/gotosocial-woodpecker-build
|
# 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
|
pull: true
|
||||||
|
|
||||||
# https://woodpecker-ci.org/docs/usage/volumes
|
# https://woodpecker-ci.org/docs/usage/volumes
|
||||||
|
4
go.mod
4
go.mod
@ -1,8 +1,8 @@
|
|||||||
module code.superseriousbusiness.org/gotosocial
|
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 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
|
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() {
|
func (suite *ActionsTestSuite) TestActionOverlap() {
|
||||||
var (
|
var (
|
||||||
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
|
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
)
|
)
|
||||||
defer testrig.TearDownTestStructs(testStructs)
|
defer testrig.TearDownTestStructs(testStructs)
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ func (suite *ActionsTestSuite) TestActionOverlap() {
|
|||||||
func (suite *ActionsTestSuite) TestActionWithErrors() {
|
func (suite *ActionsTestSuite) TestActionWithErrors() {
|
||||||
var (
|
var (
|
||||||
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
|
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
)
|
)
|
||||||
defer testrig.TearDownTestStructs(testStructs)
|
defer testrig.TearDownTestStructs(testStructs)
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@ package ap_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
|
"testing"
|
||||||
|
|
||||||
"code.superseriousbusiness.org/activity/streams"
|
"code.superseriousbusiness.org/activity/streams"
|
||||||
"code.superseriousbusiness.org/activity/streams/vocab"
|
"code.superseriousbusiness.org/activity/streams/vocab"
|
||||||
@ -250,7 +250,7 @@ func (suite *APTestSuite) noteWithHashtags1() ap.Statusable {
|
|||||||
}`)
|
}`)
|
||||||
|
|
||||||
statusable, err := ap.ResolveStatusable(
|
statusable, err := ap.ResolveStatusable(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
io.NopCloser(bytes.NewReader(noteJson)),
|
io.NopCloser(bytes.NewReader(noteJson)),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -306,7 +306,7 @@ func addressable3() ap.Addressable {
|
|||||||
return note
|
return note
|
||||||
}
|
}
|
||||||
|
|
||||||
func addressable4() vocab.ActivityStreamsAnnounce {
|
func addressable4(t *testing.T) vocab.ActivityStreamsAnnounce {
|
||||||
// https://codeberg.org/superseriousbusiness/gotosocial/issues/267
|
// https://codeberg.org/superseriousbusiness/gotosocial/issues/267
|
||||||
announceJson := []byte(`
|
announceJson := []byte(`
|
||||||
{
|
{
|
||||||
@ -326,12 +326,12 @@ func addressable4() vocab.ActivityStreamsAnnounce {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
t, err := streams.ToType(context.Background(), jsonAsMap)
|
typ, err := streams.ToType(t.Context(), jsonAsMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return t.(vocab.ActivityStreamsAnnounce)
|
return typ.(vocab.ActivityStreamsAnnounce)
|
||||||
}
|
}
|
||||||
|
|
||||||
func addressable5() ap.Addressable {
|
func addressable5() ap.Addressable {
|
||||||
@ -366,7 +366,7 @@ func (suite *APTestSuite) jsonToType(rawJson string) (vocab.Type, map[string]int
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
t, err := streams.ToType(context.Background(), raw)
|
t, err := streams.ToType(suite.T().Context(), raw)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -395,7 +395,7 @@ func (suite *APTestSuite) SetupTest() {
|
|||||||
suite.addressable1 = addressable1()
|
suite.addressable1 = addressable1()
|
||||||
suite.addressable2 = addressable2()
|
suite.addressable2 = addressable2()
|
||||||
suite.addressable3 = addressable3()
|
suite.addressable3 = addressable3()
|
||||||
suite.addressable4 = addressable4()
|
suite.addressable4 = addressable4(suite.T())
|
||||||
suite.addressable5 = addressable5()
|
suite.addressable5 = addressable5()
|
||||||
suite.testAccounts = testrig.NewTestAccounts()
|
suite.testAccounts = testrig.NewTestAccounts()
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package ap_test
|
package ap_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -59,7 +58,7 @@ func (suite *ExtractAttachmentsTestSuite) TestExtractDescription() {
|
|||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
t, err := streams.ToType(context.Background(), raw)
|
t, err := streams.ToType(suite.T().Context(), raw)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package ap_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -61,7 +60,7 @@ func (suite *ExtractEmojisTestSuite) TestExtractEmojis() {
|
|||||||
}`
|
}`
|
||||||
|
|
||||||
statusable, err := ap.ResolveStatusable(
|
statusable, err := ap.ResolveStatusable(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
io.NopCloser(bytes.NewBufferString(noteWithEmojis)),
|
io.NopCloser(bytes.NewBufferString(noteWithEmojis)),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -115,7 +114,7 @@ func (suite *ExtractEmojisTestSuite) TestExtractEmojisNoID() {
|
|||||||
}`
|
}`
|
||||||
|
|
||||||
statusable, err := ap.ResolveStatusable(
|
statusable, err := ap.ResolveStatusable(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
io.NopCloser(bytes.NewBufferString(noteWithEmojis)),
|
io.NopCloser(bytes.NewBufferString(noteWithEmojis)),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -170,7 +169,7 @@ func (suite *ExtractEmojisTestSuite) TestExtractEmojisNullID() {
|
|||||||
}`
|
}`
|
||||||
|
|
||||||
statusable, err := ap.ResolveStatusable(
|
statusable, err := ap.ResolveStatusable(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
io.NopCloser(bytes.NewBufferString(noteWithEmojis)),
|
io.NopCloser(bytes.NewBufferString(noteWithEmojis)),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -225,7 +224,7 @@ func (suite *ExtractEmojisTestSuite) TestExtractEmojisEmptyID() {
|
|||||||
}`
|
}`
|
||||||
|
|
||||||
statusable, err := ap.ResolveStatusable(
|
statusable, err := ap.ResolveStatusable(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
io.NopCloser(bytes.NewBufferString(noteWithEmojis)),
|
io.NopCloser(bytes.NewBufferString(noteWithEmojis)),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package ap_test
|
package ap_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
@ -33,7 +32,7 @@ type ExtractFocusTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExtractFocusTestSuite) TestExtractFocus() {
|
func (suite *ExtractFocusTestSuite) TestExtractFocus() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
type test struct {
|
type test struct {
|
||||||
data string
|
data string
|
||||||
|
@ -19,7 +19,6 @@ package ap_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -86,7 +85,7 @@ func (suite *ExtractPolicyTestSuite) TestExtractPolicy() {
|
|||||||
}`
|
}`
|
||||||
|
|
||||||
statusable, err := ap.ResolveStatusable(
|
statusable, err := ap.ResolveStatusable(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
io.NopCloser(
|
io.NopCloser(
|
||||||
bytes.NewBufferString(rawNote),
|
bytes.NewBufferString(rawNote),
|
||||||
),
|
),
|
||||||
@ -186,7 +185,7 @@ func (suite *ExtractPolicyTestSuite) TestExtractPolicyDeprecated() {
|
|||||||
}`
|
}`
|
||||||
|
|
||||||
statusable, err := ap.ResolveStatusable(
|
statusable, err := ap.ResolveStatusable(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
io.NopCloser(
|
io.NopCloser(
|
||||||
bytes.NewBufferString(rawNote),
|
bytes.NewBufferString(rawNote),
|
||||||
),
|
),
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package ap_test
|
package ap_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -62,7 +61,7 @@ func (suite *ExtractPubKeyTestSuite) TestExtractPubKeyFromStub() {
|
|||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
t, err := streams.ToType(context.Background(), m)
|
t, err := streams.ToType(suite.T().Context(), m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package ap_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -36,7 +35,7 @@ func (suite *ResolveTestSuite) TestResolveDocumentAsStatusable() {
|
|||||||
b := []byte(suite.typeToJson(suite.document1))
|
b := []byte(suite.typeToJson(suite.document1))
|
||||||
|
|
||||||
statusable, err := ap.ResolveStatusable(
|
statusable, err := ap.ResolveStatusable(
|
||||||
context.Background(), io.NopCloser(bytes.NewReader(b)),
|
suite.T().Context(), io.NopCloser(bytes.NewReader(b)),
|
||||||
)
|
)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.NotNil(statusable)
|
suite.NotNil(statusable)
|
||||||
@ -46,7 +45,7 @@ func (suite *ResolveTestSuite) TestResolveDocumentAsAccountable() {
|
|||||||
b := []byte(suite.typeToJson(suite.document1))
|
b := []byte(suite.typeToJson(suite.document1))
|
||||||
|
|
||||||
accountable, err := ap.ResolveAccountable(
|
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.True(gtserror.IsWrongType(err))
|
||||||
suite.EqualError(err, "ResolveAccountable: cannot resolve vocab type *typedocument.ActivityStreamsDocument as accountable")
|
suite.EqualError(err, "ResolveAccountable: cannot resolve vocab type *typedocument.ActivityStreamsDocument as accountable")
|
||||||
@ -58,7 +57,7 @@ func (suite *ResolveTestSuite) TestResolveHTMLAsAccountable() {
|
|||||||
<title>.</title>`)
|
<title>.</title>`)
|
||||||
|
|
||||||
accountable, err := ap.ResolveAccountable(
|
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.True(gtserror.IsWrongType(err))
|
||||||
suite.EqualError(err, "ResolveAccountable: error decoding into json: invalid character '<' looking for beginning of value")
|
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(
|
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.True(gtserror.IsWrongType(err))
|
||||||
suite.EqualError(err, "ResolveAccountable: error resolving json into ap vocab type: activity stream did not match any known types")
|
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(
|
statusable, err := ap.ResolveStatusable(
|
||||||
context.Background(), io.NopCloser(bytes.NewReader(b)),
|
suite.T().Context(), io.NopCloser(bytes.NewReader(b)),
|
||||||
)
|
)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.NotNil(statusable)
|
suite.NotNil(statusable)
|
||||||
|
@ -19,7 +19,6 @@ package users_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
@ -232,7 +231,7 @@ func (suite *InboxPostTestSuite) TestPostBlock() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if !testrig.WaitFor(func() bool {
|
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
|
return err == nil && dbBlock != nil
|
||||||
}) {
|
}) {
|
||||||
suite.FailNow("timed out waiting for block to be created")
|
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.
|
// one of our instance users should be able to undo that block.
|
||||||
func (suite *InboxPostTestSuite) TestPostUnblock() {
|
func (suite *InboxPostTestSuite) TestPostUnblock() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
requestingAccount = suite.testAccounts["remote_account_1"]
|
requestingAccount = suite.testAccounts["remote_account_1"]
|
||||||
targetAccount = suite.testAccounts["local_account_1"]
|
targetAccount = suite.testAccounts["local_account_1"]
|
||||||
blockID = "http://fossbros-anonymous.io/blocks/01H1462TPRTVG2RTQCTSQ7N6Q0"
|
blockID = "http://fossbros-anonymous.io/blocks/01H1462TPRTVG2RTQCTSQ7N6Q0"
|
||||||
@ -315,7 +314,7 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
|
|||||||
requestingAccount.Emojis = []*gtsmodel.Emoji{testEmoji}
|
requestingAccount.Emojis = []*gtsmodel.Emoji{testEmoji}
|
||||||
|
|
||||||
// Create an update from the account.
|
// 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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -344,7 +343,7 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
|
|||||||
|
|
||||||
if !testrig.WaitFor(func() bool {
|
if !testrig.WaitFor(func() bool {
|
||||||
// displayName should be updated
|
// 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
|
return dbUpdatedAccount.DisplayName == updatedDisplayName
|
||||||
}) {
|
}) {
|
||||||
suite.FailNow("timed out waiting for account update")
|
suite.FailNow("timed out waiting for account update")
|
||||||
@ -399,7 +398,7 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
|
|||||||
|
|
||||||
func (suite *InboxPostTestSuite) TestPostDelete() {
|
func (suite *InboxPostTestSuite) TestPostDelete() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
requestingAccount = suite.testAccounts["remote_account_1"]
|
requestingAccount = suite.testAccounts["remote_account_1"]
|
||||||
targetAccount = suite.testAccounts["local_account_1"]
|
targetAccount = suite.testAccounts["local_account_1"]
|
||||||
activityID = requestingAccount.URI + "/some-new-activity/01FG9C441MCTW3R2W117V2PQK3"
|
activityID = requestingAccount.URI + "/some-new-activity/01FG9C441MCTW3R2W117V2PQK3"
|
||||||
@ -517,7 +516,7 @@ func (suite *InboxPostTestSuite) TestPostFromBlockedAccount() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Create an update from the account.
|
// 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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -559,7 +558,7 @@ func (suite *InboxPostTestSuite) TestPostFromBlockedAccountToOtherAccount() {
|
|||||||
suite.signatureCheck,
|
suite.signatureCheck,
|
||||||
)
|
)
|
||||||
|
|
||||||
_, err := suite.state.DB.GetStatusByURI(context.Background(), statusURI)
|
_, err := suite.state.DB.GetStatusByURI(suite.T().Context(), statusURI)
|
||||||
suite.ErrorIs(err, db.ErrNoEntries)
|
suite.ErrorIs(err, db.ErrNoEntries)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ package users_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -90,7 +89,7 @@ func (suite *OutboxGetTestSuite) TestGetOutbox() {
|
|||||||
err = json.Unmarshal(b, &m)
|
err = json.Unmarshal(b, &m)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
t, err := streams.ToType(context.Background(), m)
|
t, err := streams.ToType(suite.T().Context(), m)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
_, ok := t.(vocab.ActivityStreamsOrderedCollection)
|
_, ok := t.(vocab.ActivityStreamsOrderedCollection)
|
||||||
@ -177,7 +176,7 @@ func (suite *OutboxGetTestSuite) TestGetOutboxFirstPage() {
|
|||||||
err = json.Unmarshal(b, &m)
|
err = json.Unmarshal(b, &m)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
t, err := streams.ToType(context.Background(), m)
|
t, err := streams.ToType(suite.T().Context(), m)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
_, ok := t.(vocab.ActivityStreamsOrderedCollectionPage)
|
_, ok := t.(vocab.ActivityStreamsOrderedCollectionPage)
|
||||||
@ -240,7 +239,7 @@ func (suite *OutboxGetTestSuite) TestGetOutboxNextPage() {
|
|||||||
err = json.Unmarshal(b, &m)
|
err = json.Unmarshal(b, &m)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
t, err := streams.ToType(context.Background(), m)
|
t, err := streams.ToType(suite.T().Context(), m)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
_, ok := t.(vocab.ActivityStreamsOrderedCollectionPage)
|
_, ok := t.(vocab.ActivityStreamsOrderedCollectionPage)
|
||||||
|
@ -19,7 +19,6 @@ package users_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -101,7 +100,7 @@ func (suite *RepliesGetTestSuite) TestGetReplies() {
|
|||||||
err = json.Unmarshal(b, &m)
|
err = json.Unmarshal(b, &m)
|
||||||
assert.NoError(suite.T(), err)
|
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)
|
assert.NoError(suite.T(), err)
|
||||||
|
|
||||||
_, ok := t.(vocab.ActivityStreamsOrderedCollection)
|
_, ok := t.(vocab.ActivityStreamsOrderedCollection)
|
||||||
@ -172,7 +171,7 @@ func (suite *RepliesGetTestSuite) TestGetRepliesNext() {
|
|||||||
err = json.Unmarshal(b, &m)
|
err = json.Unmarshal(b, &m)
|
||||||
assert.NoError(suite.T(), err)
|
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)
|
assert.NoError(suite.T(), err)
|
||||||
|
|
||||||
page, ok := t.(vocab.ActivityStreamsOrderedCollectionPage)
|
page, ok := t.(vocab.ActivityStreamsOrderedCollectionPage)
|
||||||
@ -243,7 +242,7 @@ func (suite *RepliesGetTestSuite) TestGetRepliesLast() {
|
|||||||
err = json.Unmarshal(b, &m)
|
err = json.Unmarshal(b, &m)
|
||||||
assert.NoError(suite.T(), err)
|
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)
|
assert.NoError(suite.T(), err)
|
||||||
|
|
||||||
page, ok := t.(vocab.ActivityStreamsOrderedCollectionPage)
|
page, ok := t.(vocab.ActivityStreamsOrderedCollectionPage)
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package users_test
|
package users_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -85,14 +84,14 @@ func (suite *StatusGetTestSuite) TestGetStatus() {
|
|||||||
err = json.Unmarshal(b, &m)
|
err = json.Unmarshal(b, &m)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
t, err := streams.ToType(context.Background(), m)
|
t, err := streams.ToType(suite.T().Context(), m)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
note, ok := t.(vocab.ActivityStreamsNote)
|
note, ok := t.(vocab.ActivityStreamsNote)
|
||||||
suite.True(ok)
|
suite.True(ok)
|
||||||
|
|
||||||
// convert note to status
|
// 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.NoError(err)
|
||||||
suite.EqualValues(targetStatus.Content, a.Content)
|
suite.EqualValues(targetStatus.Content, a.Content)
|
||||||
}
|
}
|
||||||
@ -144,14 +143,14 @@ func (suite *StatusGetTestSuite) TestGetStatusLowercase() {
|
|||||||
err = json.Unmarshal(b, &m)
|
err = json.Unmarshal(b, &m)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
t, err := streams.ToType(context.Background(), m)
|
t, err := streams.ToType(suite.T().Context(), m)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
note, ok := t.(vocab.ActivityStreamsNote)
|
note, ok := t.(vocab.ActivityStreamsNote)
|
||||||
suite.True(ok)
|
suite.True(ok)
|
||||||
|
|
||||||
// convert note to status
|
// 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.NoError(err)
|
||||||
suite.EqualValues(targetStatus.Content, a.Content)
|
suite.EqualValues(targetStatus.Content, a.Content)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package users_test
|
package users_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -79,14 +78,14 @@ func (suite *UserGetTestSuite) TestGetUser() {
|
|||||||
err = json.Unmarshal(b, &m)
|
err = json.Unmarshal(b, &m)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
t, err := streams.ToType(context.Background(), m)
|
t, err := streams.ToType(suite.T().Context(), m)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
person, ok := t.(vocab.ActivityStreamsPerson)
|
person, ok := t.(vocab.ActivityStreamsPerson)
|
||||||
suite.True(ok)
|
suite.True(ok)
|
||||||
|
|
||||||
// convert person to account
|
// 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.NoError(err)
|
||||||
suite.EqualValues(targetAccount.Username, a.Username)
|
suite.EqualValues(targetAccount.Username, a.Username)
|
||||||
}
|
}
|
||||||
@ -97,11 +96,11 @@ func (suite *UserGetTestSuite) TestGetUserPublicKeyDeleted() {
|
|||||||
userModule := users.New(suite.processor)
|
userModule := users.New(suite.processor)
|
||||||
targetAccount := suite.testAccounts["local_account_1"]
|
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
|
// wait for the account delete to be processed
|
||||||
if !testrig.WaitFor(func() bool {
|
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()
|
return !a.SuspendedAt.IsZero()
|
||||||
}) {
|
}) {
|
||||||
suite.FailNow("delete of account timed out")
|
suite.FailNow("delete of account timed out")
|
||||||
@ -147,14 +146,14 @@ func (suite *UserGetTestSuite) TestGetUserPublicKeyDeleted() {
|
|||||||
err = json.Unmarshal(b, &m)
|
err = json.Unmarshal(b, &m)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
t, err := streams.ToType(context.Background(), m)
|
t, err := streams.ToType(suite.T().Context(), m)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
person, ok := t.(vocab.ActivityStreamsPerson)
|
person, ok := t.(vocab.ActivityStreamsPerson)
|
||||||
suite.True(ok)
|
suite.True(ok)
|
||||||
|
|
||||||
// convert person to account
|
// 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.NoError(err)
|
||||||
suite.EqualValues(targetAccount.Username, a.Username)
|
suite.EqualValues(targetAccount.Username, a.Username)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package auth_test
|
package auth_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
@ -93,9 +92,9 @@ func (suite *AuthAuthorizeTestSuite) TestAccountAuthorizeHandler() {
|
|||||||
|
|
||||||
testCase.description = fmt.Sprintf("%s, %t, %s", user.Email, *user.Disabled, account.SuspendedAt)
|
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)
|
suite.NoError(err)
|
||||||
err = suite.db.UpdateAccount(context.Background(), account)
|
err = suite.db.UpdateAccount(suite.T().Context(), account)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
// call the handler
|
// call the handler
|
||||||
|
@ -19,7 +19,6 @@ package auth_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -71,7 +70,7 @@ func (suite *RevokeTestSuite) TestRevokeOK() {
|
|||||||
|
|
||||||
// Ensure token now gone.
|
// Ensure token now gone.
|
||||||
_, err = suite.state.DB.GetTokenByAccess(
|
_, err = suite.state.DB.GetTokenByAccess(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
token.Access,
|
token.Access,
|
||||||
)
|
)
|
||||||
suite.ErrorIs(err, db.ErrNoEntries)
|
suite.ErrorIs(err, db.ErrNoEntries)
|
||||||
@ -130,7 +129,7 @@ func (suite *RevokeTestSuite) TestRevokeWrongSecret() {
|
|||||||
|
|
||||||
// Ensure token still there.
|
// Ensure token still there.
|
||||||
_, err = suite.state.DB.GetTokenByAccess(
|
_, err = suite.state.DB.GetTokenByAccess(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
token.Access,
|
token.Access,
|
||||||
)
|
)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
@ -188,7 +187,7 @@ func (suite *RevokeTestSuite) TestRevokeNoClientID() {
|
|||||||
|
|
||||||
// Ensure token still there.
|
// Ensure token still there.
|
||||||
_, err = suite.state.DB.GetTokenByAccess(
|
_, err = suite.state.DB.GetTokenByAccess(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
token.Access,
|
token.Access,
|
||||||
)
|
)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package auth_test
|
package auth_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -93,7 +92,7 @@ func (suite *TokenTestSuite) TestRetrieveClientCredentialsOK() {
|
|||||||
|
|
||||||
// there should be a token in the database now too
|
// there should be a token in the database now too
|
||||||
dbToken := >smodel.Token{}
|
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.NoError(err)
|
||||||
suite.NotNil(dbToken)
|
suite.NotNil(dbToken)
|
||||||
}
|
}
|
||||||
@ -204,7 +203,7 @@ func (suite *TokenTestSuite) TestRetrieveAuthorizationCodeOK() {
|
|||||||
suite.WithinDuration(time.Now(), time.Unix(t.CreatedAt, 0), 1*time.Minute)
|
suite.WithinDuration(time.Now(), time.Unix(t.CreatedAt, 0), 1*time.Minute)
|
||||||
|
|
||||||
dbToken := >smodel.Token{}
|
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.NoError(err)
|
||||||
suite.NotNil(dbToken)
|
suite.NotNil(dbToken)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package accounts_test
|
package accounts_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -289,7 +288,7 @@ func (suite *AccountUpdateTestSuite) TestUpdateAccountCache() {
|
|||||||
// Get the account first to make sure it's in the database
|
// Get the account first to make sure it's in the database
|
||||||
// cache. When the account is updated via the PATCH handler,
|
// cache. When the account is updated via the PATCH handler,
|
||||||
// it should invalidate the cache and return the new version.
|
// 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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +317,7 @@ func (suite *AccountUpdateTestSuite) TestUpdateAccountDiscoverableForm() {
|
|||||||
suite.False(apimodelAccount.Discoverable)
|
suite.False(apimodelAccount.Discoverable)
|
||||||
|
|
||||||
// Check the account in the database too.
|
// 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.NoError(err)
|
||||||
suite.False(*dbZork.Discoverable)
|
suite.False(*dbZork.Discoverable)
|
||||||
}
|
}
|
||||||
@ -336,7 +335,7 @@ func (suite *AccountUpdateTestSuite) TestUpdateAccountDiscoverableFormData() {
|
|||||||
suite.False(apimodelAccount.Discoverable)
|
suite.False(apimodelAccount.Discoverable)
|
||||||
|
|
||||||
// Check the account in the database too.
|
// 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.NoError(err)
|
||||||
suite.False(*dbZork.Discoverable)
|
suite.False(*dbZork.Discoverable)
|
||||||
}
|
}
|
||||||
@ -355,7 +354,7 @@ func (suite *AccountUpdateTestSuite) TestUpdateAccountDiscoverableJSON() {
|
|||||||
suite.False(apimodelAccount.Discoverable)
|
suite.False(apimodelAccount.Discoverable)
|
||||||
|
|
||||||
// Check the account in the database too.
|
// 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.NoError(err)
|
||||||
suite.False(*dbZork.Discoverable)
|
suite.False(*dbZork.Discoverable)
|
||||||
}
|
}
|
||||||
@ -477,7 +476,7 @@ func (suite *AccountUpdateTestSuite) TestUpdateAccountSourceBadContentTypeFormDa
|
|||||||
suite.Equal(data["source[status_content_type]"][0], apimodelAccount.Source.StatusContentType)
|
suite.Equal(data["source[status_content_type]"][0], apimodelAccount.Source.StatusContentType)
|
||||||
|
|
||||||
// Check the account in the database too.
|
// 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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package accounts_test
|
package accounts_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -102,7 +101,7 @@ func (suite *FollowTestSuite) TestGetFollowersPageOldestToNewestLimit6() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *FollowTestSuite) testGetFollowersPage(limit int, direction string) {
|
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
|
// The authed local account we are going to use for HTTP requests
|
||||||
requestingAccount := suite.testAccounts["local_account_1"]
|
requestingAccount := suite.testAccounts["local_account_1"]
|
||||||
@ -304,7 +303,7 @@ func (suite *FollowTestSuite) TestGetFollowingPageOldestToNewestLimit6() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *FollowTestSuite) testGetFollowingPage(limit int, direction string) {
|
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
|
// The authed local account we are going to use for HTTP requests
|
||||||
requestingAccount := suite.testAccounts["local_account_1"]
|
requestingAccount := suite.testAccounts["local_account_1"]
|
||||||
@ -483,19 +482,19 @@ func (suite *FollowTestSuite) testGetFollowingPage(limit int, direction string)
|
|||||||
func (suite *FollowTestSuite) clearAccountRelations(id string) {
|
func (suite *FollowTestSuite) clearAccountRelations(id string) {
|
||||||
// Esnure no account blocks exist between accounts.
|
// Esnure no account blocks exist between accounts.
|
||||||
_ = suite.db.DeleteAccountBlocks(
|
_ = suite.db.DeleteAccountBlocks(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
id,
|
id,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensure no account follows exist between accounts.
|
// Ensure no account follows exist between accounts.
|
||||||
_ = suite.db.DeleteAccountFollows(
|
_ = suite.db.DeleteAccountFollows(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
id,
|
id,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensure no account follow_requests exist between accounts.
|
// Ensure no account follow_requests exist between accounts.
|
||||||
_ = suite.db.DeleteAccountFollowRequests(
|
_ = suite.db.DeleteAccountFollowRequests(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
id,
|
id,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package admin_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -41,7 +40,7 @@ type DomainPermissionSubscriptionTestTestSuite struct {
|
|||||||
|
|
||||||
func (suite *DomainPermissionSubscriptionTestTestSuite) TestDomainPermissionSubscriptionTestCSV() {
|
func (suite *DomainPermissionSubscriptionTestTestSuite) TestDomainPermissionSubscriptionTestCSV() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
testAccount = suite.testAccounts["admin_account"]
|
testAccount = suite.testAccounts["admin_account"]
|
||||||
permSub = >smodel.DomainPermissionSubscription{
|
permSub = >smodel.DomainPermissionSubscription{
|
||||||
ID: "01JGE681TQSBPAV59GZXPKE62H",
|
ID: "01JGE681TQSBPAV59GZXPKE62H",
|
||||||
@ -129,7 +128,7 @@ func (suite *DomainPermissionSubscriptionTestTestSuite) TestDomainPermissionSubs
|
|||||||
|
|
||||||
func (suite *DomainPermissionSubscriptionTestTestSuite) TestDomainPermissionSubscriptionTestText() {
|
func (suite *DomainPermissionSubscriptionTestTestSuite) TestDomainPermissionSubscriptionTestText() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
testAccount = suite.testAccounts["admin_account"]
|
testAccount = suite.testAccounts["admin_account"]
|
||||||
permSub = >smodel.DomainPermissionSubscription{
|
permSub = >smodel.DomainPermissionSubscription{
|
||||||
ID: "01JGE681TQSBPAV59GZXPKE62H",
|
ID: "01JGE681TQSBPAV59GZXPKE62H",
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package admin_test
|
package admin_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -77,7 +76,7 @@ func (suite *EmojiCreateTestSuite) TestEmojiCreateNewCategory() {
|
|||||||
suite.True(apiEmoji.VisibleInPicker)
|
suite.True(apiEmoji.VisibleInPicker)
|
||||||
|
|
||||||
// emoji should be in the db
|
// 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)
|
suite.NoError(err)
|
||||||
|
|
||||||
// check fields on the emoji
|
// check fields on the emoji
|
||||||
@ -150,7 +149,7 @@ func (suite *EmojiCreateTestSuite) TestEmojiCreateExistingCategory() {
|
|||||||
suite.True(apiEmoji.VisibleInPicker)
|
suite.True(apiEmoji.VisibleInPicker)
|
||||||
|
|
||||||
// emoji should be in the db
|
// 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)
|
suite.NoError(err)
|
||||||
|
|
||||||
// check fields on the emoji
|
// check fields on the emoji
|
||||||
@ -223,7 +222,7 @@ func (suite *EmojiCreateTestSuite) TestEmojiCreateNoCategory() {
|
|||||||
suite.True(apiEmoji.VisibleInPicker)
|
suite.True(apiEmoji.VisibleInPicker)
|
||||||
|
|
||||||
// emoji should be in the db
|
// 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)
|
suite.NoError(err)
|
||||||
|
|
||||||
// check fields on the emoji
|
// check fields on the emoji
|
||||||
|
@ -19,7 +19,6 @@ package admin_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -68,7 +67,7 @@ func (suite *EmojiDeleteTestSuite) TestEmojiDelete1() {
|
|||||||
}`, dst.String())
|
}`, dst.String())
|
||||||
|
|
||||||
// emoji should no longer be in the db
|
// 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.Nil(dbEmoji)
|
||||||
suite.ErrorIs(err, db.ErrNoEntries)
|
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))
|
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
|
// 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.NoError(err)
|
||||||
suite.NotNil(dbEmoji)
|
suite.NotNil(dbEmoji)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package admin_test
|
package admin_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -84,7 +83,7 @@ func (suite *EmojiUpdateTestSuite) TestEmojiUpdateNewCategory() {
|
|||||||
suite.True(adminEmoji.VisibleInPicker)
|
suite.True(adminEmoji.VisibleInPicker)
|
||||||
|
|
||||||
// emoji should be in the db
|
// 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)
|
suite.NoError(err)
|
||||||
|
|
||||||
// check fields on the emoji
|
// check fields on the emoji
|
||||||
@ -161,7 +160,7 @@ func (suite *EmojiUpdateTestSuite) TestEmojiUpdateSwitchCategory() {
|
|||||||
suite.True(adminEmoji.VisibleInPicker)
|
suite.True(adminEmoji.VisibleInPicker)
|
||||||
|
|
||||||
// emoji should be in the db
|
// 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)
|
suite.NoError(err)
|
||||||
|
|
||||||
// check fields on the emoji
|
// check fields on the emoji
|
||||||
@ -239,7 +238,7 @@ func (suite *EmojiUpdateTestSuite) TestEmojiUpdateCopyRemoteToLocal() {
|
|||||||
suite.True(adminEmoji.VisibleInPicker)
|
suite.True(adminEmoji.VisibleInPicker)
|
||||||
|
|
||||||
// emoji should be in the db
|
// 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)
|
suite.NoError(err)
|
||||||
|
|
||||||
// check fields on the emoji
|
// check fields on the emoji
|
||||||
@ -387,7 +386,7 @@ func (suite *EmojiUpdateTestSuite) TestEmojiUpdateModify() {
|
|||||||
suite.True(adminEmoji.VisibleInPicker)
|
suite.True(adminEmoji.VisibleInPicker)
|
||||||
|
|
||||||
// emoji should be in the db
|
// 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)
|
suite.NoError(err)
|
||||||
|
|
||||||
// check fields on the emoji
|
// check fields on the emoji
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package admin_test
|
package admin_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
@ -49,7 +48,7 @@ func (suite *MediaCleanupTestSuite) TestMediaCleanup() {
|
|||||||
|
|
||||||
// the attachment should be updated in the database
|
// the attachment should be updated in the database
|
||||||
if !testrig.WaitFor(func() bool {
|
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 !*prunedAttachment.Cached
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@ -74,7 +73,7 @@ func (suite *MediaCleanupTestSuite) TestMediaCleanupNoArg() {
|
|||||||
suite.Equal(http.StatusOK, recorder.Code)
|
suite.Equal(http.StatusOK, recorder.Code)
|
||||||
|
|
||||||
if !testrig.WaitFor(func() bool {
|
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 !*prunedAttachment.Cached
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@ -101,7 +100,7 @@ func (suite *MediaCleanupTestSuite) TestMediaCleanupNotOldEnough() {
|
|||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
// Get media we pruned
|
// 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)
|
suite.NoError(err)
|
||||||
|
|
||||||
// the media should still be cached
|
// the media should still be cached
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bookmarks_test
|
package bookmarks_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -198,7 +197,7 @@ func (suite *BookmarkTestSuite) TestGetBookmarksMultiple() {
|
|||||||
testUser := suite.testUsers["local_account_1"]
|
testUser := suite.testUsers["local_account_1"]
|
||||||
|
|
||||||
// Add a few extra bookmarks for this account.
|
// Add a few extra bookmarks for this account.
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
for _, b := range []*gtsmodel.StatusBookmark{
|
for _, b := range []*gtsmodel.StatusBookmark{
|
||||||
{
|
{
|
||||||
ID: "01GSZPDQYE9WZ26T501KMM876V", // oldest
|
ID: "01GSZPDQYE9WZ26T501KMM876V", // oldest
|
||||||
@ -239,7 +238,7 @@ func (suite *BookmarkTestSuite) TestGetBookmarksMultiplePaging() {
|
|||||||
testUser := suite.testUsers["local_account_1"]
|
testUser := suite.testUsers["local_account_1"]
|
||||||
|
|
||||||
// Add a few extra bookmarks for this account.
|
// Add a few extra bookmarks for this account.
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
for _, b := range []*gtsmodel.StatusBookmark{
|
for _, b := range []*gtsmodel.StatusBookmark{
|
||||||
{
|
{
|
||||||
ID: "01GSZPDQYE9WZ26T501KMM876V", // oldest
|
ID: "01GSZPDQYE9WZ26T501KMM876V", // oldest
|
||||||
@ -280,7 +279,7 @@ func (suite *BookmarkTestSuite) TestGetBookmarksNone() {
|
|||||||
testUser := suite.testUsers["local_account_1"]
|
testUser := suite.testUsers["local_account_1"]
|
||||||
|
|
||||||
// Remove all bookmarks for this account.
|
// 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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +298,7 @@ func (suite *BookmarkTestSuite) TestGetBookmarksNonexistentStatus() {
|
|||||||
testUser := suite.testUsers["local_account_1"]
|
testUser := suite.testUsers["local_account_1"]
|
||||||
|
|
||||||
// Add a few extra bookmarks for this account.
|
// Add a few extra bookmarks for this account.
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
for _, b := range []*gtsmodel.StatusBookmark{
|
for _, b := range []*gtsmodel.StatusBookmark{
|
||||||
{
|
{
|
||||||
ID: "01GSZPDQYE9WZ26T501KMM876V", // oldest
|
ID: "01GSZPDQYE9WZ26T501KMM876V", // oldest
|
||||||
|
@ -115,7 +115,7 @@ func (suite *FiltersTestSuite) TearDownTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *FiltersTestSuite) openHomeStream(account *gtsmodel.Account) *stream.Stream {
|
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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@ func (suite *FiltersTestSuite) checkStreamed(
|
|||||||
expectEventType string,
|
expectEventType string,
|
||||||
) {
|
) {
|
||||||
// Set a 5s timeout on context.
|
// Set a 5s timeout on context.
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
ctx, cncl := context.WithTimeout(ctx, time.Second*5)
|
ctx, cncl := context.WithTimeout(ctx, time.Second*5)
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ func (suite *FiltersTestSuite) TearDownTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *FiltersTestSuite) openHomeStream(account *gtsmodel.Account) *stream.Stream {
|
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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ func (suite *FiltersTestSuite) checkStreamed(
|
|||||||
expectEventType string,
|
expectEventType string,
|
||||||
) {
|
) {
|
||||||
// Set a 5s timeout on context.
|
// Set a 5s timeout on context.
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
ctx, cncl := context.WithTimeout(ctx, time.Second*5)
|
ctx, cncl := context.WithTimeout(ctx, time.Second*5)
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package followedtags_test
|
package followedtags_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -94,7 +93,7 @@ func (suite *FollowedTagsTestSuite) TestGet() {
|
|||||||
testTag := suite.testTags["welcome"]
|
testTag := suite.testTags["welcome"]
|
||||||
|
|
||||||
// Follow an existing tag.
|
// 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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ package followrequests_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -52,7 +51,7 @@ func (suite *AuthorizeTestSuite) TestAuthorize() {
|
|||||||
TargetAccountID: targetAccount.ID,
|
TargetAccountID: targetAccount.ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := suite.db.Put(context.Background(), fr)
|
err := suite.db.Put(suite.T().Context(), fr)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
recorder := httptest.NewRecorder()
|
recorder := httptest.NewRecorder()
|
||||||
|
@ -19,7 +19,6 @@ package followrequests_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -59,7 +58,7 @@ func (suite *GetTestSuite) TestGet() {
|
|||||||
TargetAccountID: targetAccount.ID,
|
TargetAccountID: targetAccount.ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := suite.db.Put(context.Background(), fr)
|
err := suite.db.Put(suite.T().Context(), fr)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
recorder := httptest.NewRecorder()
|
recorder := httptest.NewRecorder()
|
||||||
@ -134,7 +133,7 @@ func (suite *GetTestSuite) TestGetPageOldestToNewestLimit6() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *GetTestSuite) testGetPage(limit int, direction string) {
|
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
|
// The authed local account we are going to use for HTTP requests
|
||||||
requestingAccount := suite.testAccounts["local_account_1"]
|
requestingAccount := suite.testAccounts["local_account_1"]
|
||||||
@ -312,19 +311,19 @@ func (suite *GetTestSuite) testGetPage(limit int, direction string) {
|
|||||||
func (suite *GetTestSuite) clearAccountRelations(id string) {
|
func (suite *GetTestSuite) clearAccountRelations(id string) {
|
||||||
// Esnure no account blocks exist between accounts.
|
// Esnure no account blocks exist between accounts.
|
||||||
_ = suite.db.DeleteAccountBlocks(
|
_ = suite.db.DeleteAccountBlocks(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
id,
|
id,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensure no account follows exist between accounts.
|
// Ensure no account follows exist between accounts.
|
||||||
_ = suite.db.DeleteAccountFollows(
|
_ = suite.db.DeleteAccountFollows(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
id,
|
id,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensure no account follow_requests exist between accounts.
|
// Ensure no account follow_requests exist between accounts.
|
||||||
_ = suite.db.DeleteAccountFollowRequests(
|
_ = suite.db.DeleteAccountFollowRequests(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
id,
|
id,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package followrequests_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -52,7 +51,7 @@ func (suite *RejectTestSuite) TestReject() {
|
|||||||
TargetAccountID: targetAccount.ID,
|
TargetAccountID: targetAccount.ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := suite.db.Put(context.Background(), fr)
|
err := suite.db.Put(suite.T().Context(), fr)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
recorder := httptest.NewRecorder()
|
recorder := httptest.NewRecorder()
|
||||||
|
@ -19,7 +19,6 @@ package importdata_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
@ -144,7 +143,7 @@ func (suite *ImportTestSuite) TearDownTest() {
|
|||||||
|
|
||||||
func (suite *ImportTestSuite) TestImportFollows() {
|
func (suite *ImportTestSuite) TestImportFollows() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
testAccount = suite.testAccounts["local_account_1"]
|
testAccount = suite.testAccounts["local_account_1"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -199,7 +198,7 @@ admin@localhost:8080,true
|
|||||||
|
|
||||||
func (suite *ImportTestSuite) TestImportMutes() {
|
func (suite *ImportTestSuite) TestImportMutes() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
testAccount = suite.testAccounts["local_account_1"]
|
testAccount = suite.testAccounts["local_account_1"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ package instance_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -721,7 +720,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch8() {
|
|||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
instanceAccount, err := suite.db.GetInstanceAccount(context.Background(), "")
|
instanceAccount, err := suite.db.GetInstanceAccount(suite.T().Context(), "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -859,7 +858,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch8() {
|
|||||||
}`, dst.String())
|
}`, dst.String())
|
||||||
|
|
||||||
// extra bonus: check the v2 model thumbnail after the patch
|
// 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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package instance_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -249,7 +248,7 @@ func (suite *InstancePeersGetTestSuite) TestInstancePeersGetAllowed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InstancePeersGetTestSuite) TestInstancePeersGetAllWithObfuscated() {
|
func (suite *InstancePeersGetTestSuite) TestInstancePeersGetAllWithObfuscated() {
|
||||||
err := suite.db.Put(context.Background(), >smodel.DomainBlock{
|
err := suite.db.Put(suite.T().Context(), >smodel.DomainBlock{
|
||||||
ID: "01G633XTNK51GBADQZFZQDP6WR",
|
ID: "01G633XTNK51GBADQZFZQDP6WR",
|
||||||
CreatedAt: testrig.TimeMustParse("2021-06-09T12:34:55+02:00"),
|
CreatedAt: testrig.TimeMustParse("2021-06-09T12:34:55+02:00"),
|
||||||
UpdatedAt: 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() {
|
func (suite *InstancePeersGetTestSuite) TestInstancePeersGetAllWithObfuscatedFlat() {
|
||||||
err := suite.db.Put(context.Background(), >smodel.DomainBlock{
|
err := suite.db.Put(suite.T().Context(), >smodel.DomainBlock{
|
||||||
ID: "01G633XTNK51GBADQZFZQDP6WR",
|
ID: "01G633XTNK51GBADQZFZQDP6WR",
|
||||||
CreatedAt: testrig.TimeMustParse("2021-06-09T12:34:55+02:00"),
|
CreatedAt: testrig.TimeMustParse("2021-06-09T12:34:55+02:00"),
|
||||||
UpdatedAt: 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 (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -106,7 +105,7 @@ func (suite *ListAccountsAddTestSuite) TestPostListAccountOK() {
|
|||||||
|
|
||||||
// Remove turtle from the list.
|
// Remove turtle from the list.
|
||||||
if err := suite.db.DeleteListEntry(
|
if err := suite.db.DeleteListEntry(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
entry.ListID,
|
entry.ListID,
|
||||||
entry.FollowID,
|
entry.FollowID,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package mutes_test
|
package mutes_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -96,7 +95,7 @@ func (suite *MutesTestSuite) TestGetMutedAccounts() {
|
|||||||
AccountID: suite.testAccounts["local_account_1"].ID,
|
AccountID: suite.testAccounts["local_account_1"].ID,
|
||||||
TargetAccountID: suite.testAccounts["local_account_2"].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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -107,7 +106,7 @@ func (suite *MutesTestSuite) TestGetMutedAccounts() {
|
|||||||
AccountID: suite.testAccounts["local_account_1"].ID,
|
AccountID: suite.testAccounts["local_account_1"].ID,
|
||||||
TargetAccountID: suite.testAccounts["remote_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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -141,7 +140,7 @@ func (suite *MutesTestSuite) TestIndefinitelyMutedAccountSerializesMuteExpiratio
|
|||||||
AccountID: suite.testAccounts["local_account_1"].ID,
|
AccountID: suite.testAccounts["local_account_1"].ID,
|
||||||
TargetAccountID: suite.testAccounts["remote_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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package notifications_test
|
package notifications_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -164,7 +163,7 @@ func (suite *NotificationsTestSuite) addMoreNotifications(testAccount *gtsmodel.
|
|||||||
OriginAccountID: suite.testAccounts["remote_account_2"].ID,
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package search_test
|
package search_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -160,7 +159,7 @@ func (suite *SearchGetTestSuite) bodgeLocalInstance(domain string) {
|
|||||||
|
|
||||||
// Set username of instance account to given domain.
|
// Set username of instance account to given domain.
|
||||||
instanceAccount.Username = 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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1389,7 +1388,7 @@ func (suite *SearchGetTestSuite) TestSearchRemoteInstanceAccountPartial() {
|
|||||||
suite.FailNow(err.Error())
|
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",
|
ID: "01H6RWPG8T6DNW6VNXPBCJBH5S",
|
||||||
Username: theirDomain,
|
Username: theirDomain,
|
||||||
Domain: theirDomain,
|
Domain: theirDomain,
|
||||||
@ -1724,7 +1723,7 @@ func (suite *SearchGetTestSuite) TestSearchBlockedAccountFullNamestring() {
|
|||||||
// Block the account
|
// Block the account
|
||||||
// we're about to search.
|
// we're about to search.
|
||||||
if err := suite.db.PutBlock(
|
if err := suite.db.PutBlock(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
>smodel.Block{
|
>smodel.Block{
|
||||||
ID: id.NewULID(),
|
ID: id.NewULID(),
|
||||||
URI: "https://example.org/nooooooo",
|
URI: "https://example.org/nooooooo",
|
||||||
@ -1788,7 +1787,7 @@ func (suite *SearchGetTestSuite) TestSearchBlockedAccountPartialNamestring() {
|
|||||||
// Block the account
|
// Block the account
|
||||||
// we're about to search.
|
// we're about to search.
|
||||||
if err := suite.db.PutBlock(
|
if err := suite.db.PutBlock(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
>smodel.Block{
|
>smodel.Block{
|
||||||
ID: id.NewULID(),
|
ID: id.NewULID(),
|
||||||
URI: "https://example.org/nooooooo",
|
URI: "https://example.org/nooooooo",
|
||||||
@ -1849,7 +1848,7 @@ func (suite *SearchGetTestSuite) TestSearchBlockedAccountURI() {
|
|||||||
// Block the account
|
// Block the account
|
||||||
// we're about to search.
|
// we're about to search.
|
||||||
if err := suite.db.PutBlock(
|
if err := suite.db.PutBlock(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
>smodel.Block{
|
>smodel.Block{
|
||||||
ID: id.NewULID(),
|
ID: id.NewULID(),
|
||||||
URI: "https://example.org/nooooooo",
|
URI: "https://example.org/nooooooo",
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
package statuses_test
|
package statuses_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"strings"
|
"strings"
|
||||||
@ -499,7 +498,7 @@ func (suite *StatusBoostTestSuite) TestPostUnboostable() {
|
|||||||
func (suite *StatusBoostTestSuite) TestPostNotVisible() {
|
func (suite *StatusBoostTestSuite) TestPostNotVisible() {
|
||||||
// Stop local_account_2 following zork.
|
// Stop local_account_2 following zork.
|
||||||
err := suite.db.DeleteFollowByID(
|
err := suite.db.DeleteFollowByID(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
suite.testFollows["local_account_2_local_account_1"].ID,
|
suite.testFollows["local_account_2_local_account_1"].ID,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -714,7 +713,7 @@ func (suite *StatusBoostTestSuite) TestPostBoostImplicitAccept() {
|
|||||||
// Target status should no
|
// Target status should no
|
||||||
// longer be pending approval.
|
// longer be pending approval.
|
||||||
dbStatus, err := suite.state.DB.GetStatusByID(
|
dbStatus, err := suite.state.DB.GetStatusByID(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
targetStatus.ID,
|
targetStatus.ID,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -725,7 +724,7 @@ func (suite *StatusBoostTestSuite) TestPostBoostImplicitAccept() {
|
|||||||
// There should be an Accept
|
// There should be an Accept
|
||||||
// stored for the target status.
|
// stored for the target status.
|
||||||
intReq, err := suite.state.DB.GetInteractionRequestByInteractionURI(
|
intReq, err := suite.state.DB.GetInteractionRequestByInteractionURI(
|
||||||
context.Background(), targetStatus.URI,
|
suite.T().Context(), targetStatus.URI,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
|
@ -19,7 +19,6 @@ package statuses_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -671,7 +670,7 @@ func (suite *StatusCreateTestSuite) TestMentionUnknownAccount() {
|
|||||||
// so it gets looked up again when we mention it.
|
// so it gets looked up again when we mention it.
|
||||||
remoteAccount := suite.testAccounts["remote_account_1"]
|
remoteAccount := suite.testAccounts["remote_account_1"]
|
||||||
if err := suite.db.DeleteAccount(
|
if err := suite.db.DeleteAccount(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
remoteAccount.ID,
|
remoteAccount.ID,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package statuses_test
|
package statuses_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"strings"
|
"strings"
|
||||||
@ -203,7 +202,7 @@ func (suite *StatusFaveTestSuite) TestPostUnfaveable() {
|
|||||||
// Fave a status that's pending approval by us.
|
// Fave a status that's pending approval by us.
|
||||||
func (suite *StatusFaveTestSuite) TestPostFaveImplicitAccept() {
|
func (suite *StatusFaveTestSuite) TestPostFaveImplicitAccept() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
targetStatus = suite.testStatuses["admin_account_status_5"]
|
targetStatus = suite.testStatuses["admin_account_status_5"]
|
||||||
app = suite.testApplications["application_1"]
|
app = suite.testApplications["application_1"]
|
||||||
token = suite.testTokens["local_account_2"]
|
token = suite.testTokens["local_account_2"]
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package statuses_test
|
package statuses_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -135,7 +134,7 @@ func (suite *StatusPinTestSuite) TestPinStatusTwiceError() {
|
|||||||
testAccount := new(gtsmodel.Account)
|
testAccount := new(gtsmodel.Account)
|
||||||
*testAccount = *suite.testAccounts["local_account_1"]
|
*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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +170,7 @@ func (suite *StatusPinTestSuite) TestPinStatusTooManyPins() {
|
|||||||
*testAccount = *suite.testAccounts["local_account_1"]
|
*testAccount = *suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
// Spam 10 pinned statuses into the database.
|
// Spam 10 pinned statuses into the database.
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
for i := range make([]interface{}, 10) {
|
for i := range make([]interface{}, 10) {
|
||||||
status := >smodel.Status{
|
status := >smodel.Status{
|
||||||
ID: id.NewULID(),
|
ID: id.NewULID(),
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package tags_test
|
package tags_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"code.superseriousbusiness.org/gotosocial/internal/api/client/tags"
|
"code.superseriousbusiness.org/gotosocial/internal/api/client/tags"
|
||||||
@ -65,7 +64,7 @@ func (suite *TagsTestSuite) TestFollowIdempotent() {
|
|||||||
testTag := suite.testTags["welcome"]
|
testTag := suite.testTags["welcome"]
|
||||||
|
|
||||||
// Setup: follow an existing tag.
|
// 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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package tags_test
|
package tags_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"code.superseriousbusiness.org/gotosocial/internal/api/client/tags"
|
"code.superseriousbusiness.org/gotosocial/internal/api/client/tags"
|
||||||
@ -50,7 +49,7 @@ func (suite *TagsTestSuite) TestGetFollowed() {
|
|||||||
testTag := suite.testTags["welcome"]
|
testTag := suite.testTags["welcome"]
|
||||||
|
|
||||||
// Setup: follow an existing tag.
|
// 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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package tags_test
|
package tags_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"code.superseriousbusiness.org/gotosocial/internal/api/client/tags"
|
"code.superseriousbusiness.org/gotosocial/internal/api/client/tags"
|
||||||
@ -49,7 +48,7 @@ func (suite *TagsTestSuite) TestUnfollow() {
|
|||||||
testTag := suite.testTags["welcome"]
|
testTag := suite.testTags["welcome"]
|
||||||
|
|
||||||
// Setup: follow an existing tag.
|
// 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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package tokens_test
|
package tokens_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -58,7 +57,7 @@ func (suite *TokenInvalidateTestSuite) TestTokenInvalidate() {
|
|||||||
// Check database for token we
|
// Check database for token we
|
||||||
// just invalidated, should be gone.
|
// just invalidated, should be gone.
|
||||||
_, err := suite.testStructs.State.DB.GetTokenByID(
|
_, err := suite.testStructs.State.DB.GetTokenByID(
|
||||||
context.Background(), testToken.ID,
|
suite.T().Context(), testToken.ID,
|
||||||
)
|
)
|
||||||
suite.ErrorIs(err, db.ErrNoEntries)
|
suite.ErrorIs(err, db.ErrNoEntries)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package user_test
|
package user_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
@ -45,7 +44,7 @@ func (suite *PasswordChangeTestSuite) TestPasswordChangePOST() {
|
|||||||
suite.EqualValues(http.StatusOK, code)
|
suite.EqualValues(http.StatusOK, code)
|
||||||
|
|
||||||
dbUser := >smodel.User{}
|
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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package fileserver_test
|
package fileserver_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
@ -74,7 +73,7 @@ func (suite *ServeFileTestSuite) GetFile(
|
|||||||
// UncacheAttachment is a convenience function that uncaches the targetAttachment by
|
// UncacheAttachment is a convenience function that uncaches the targetAttachment by
|
||||||
// removing its associated files from storage, and updating the database.
|
// removing its associated files from storage, and updating the database.
|
||||||
func (suite *ServeFileTestSuite) UncacheAttachment(targetAttachment *gtsmodel.MediaAttachment) {
|
func (suite *ServeFileTestSuite) UncacheAttachment(targetAttachment *gtsmodel.MediaAttachment) {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
cached := false
|
cached := false
|
||||||
targetAttachment.Cached = &cached
|
targetAttachment.Cached = &cached
|
||||||
@ -93,7 +92,7 @@ func (suite *ServeFileTestSuite) UncacheAttachment(targetAttachment *gtsmodel.Me
|
|||||||
func (suite *ServeFileTestSuite) TestServeOriginalLocalFileOK() {
|
func (suite *ServeFileTestSuite) TestServeOriginalLocalFileOK() {
|
||||||
targetAttachment := >smodel.MediaAttachment{}
|
targetAttachment := >smodel.MediaAttachment{}
|
||||||
*targetAttachment = *suite.testAttachments["admin_account_status_1_attachment_1"]
|
*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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -113,7 +112,7 @@ func (suite *ServeFileTestSuite) TestServeOriginalLocalFileOK() {
|
|||||||
func (suite *ServeFileTestSuite) TestServeSmallLocalFileOK() {
|
func (suite *ServeFileTestSuite) TestServeSmallLocalFileOK() {
|
||||||
targetAttachment := >smodel.MediaAttachment{}
|
targetAttachment := >smodel.MediaAttachment{}
|
||||||
*targetAttachment = *suite.testAttachments["admin_account_status_1_attachment_1"]
|
*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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -133,7 +132,7 @@ func (suite *ServeFileTestSuite) TestServeSmallLocalFileOK() {
|
|||||||
func (suite *ServeFileTestSuite) TestServeOriginalRemoteFileOK() {
|
func (suite *ServeFileTestSuite) TestServeOriginalRemoteFileOK() {
|
||||||
targetAttachment := >smodel.MediaAttachment{}
|
targetAttachment := >smodel.MediaAttachment{}
|
||||||
*targetAttachment = *suite.testAttachments["remote_account_1_status_1_attachment_1"]
|
*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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -153,7 +152,7 @@ func (suite *ServeFileTestSuite) TestServeOriginalRemoteFileOK() {
|
|||||||
func (suite *ServeFileTestSuite) TestServeSmallRemoteFileOK() {
|
func (suite *ServeFileTestSuite) TestServeSmallRemoteFileOK() {
|
||||||
targetAttachment := >smodel.MediaAttachment{}
|
targetAttachment := >smodel.MediaAttachment{}
|
||||||
*targetAttachment = *suite.testAttachments["remote_account_1_status_1_attachment_1"]
|
*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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -173,7 +172,7 @@ func (suite *ServeFileTestSuite) TestServeSmallRemoteFileOK() {
|
|||||||
func (suite *ServeFileTestSuite) TestServeOriginalRemoteFileRecache() {
|
func (suite *ServeFileTestSuite) TestServeOriginalRemoteFileRecache() {
|
||||||
targetAttachment := >smodel.MediaAttachment{}
|
targetAttachment := >smodel.MediaAttachment{}
|
||||||
*targetAttachment = *suite.testAttachments["remote_account_1_status_1_attachment_1"]
|
*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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -196,7 +195,7 @@ func (suite *ServeFileTestSuite) TestServeOriginalRemoteFileRecache() {
|
|||||||
func (suite *ServeFileTestSuite) TestServeSmallRemoteFileRecache() {
|
func (suite *ServeFileTestSuite) TestServeSmallRemoteFileRecache() {
|
||||||
targetAttachment := >smodel.MediaAttachment{}
|
targetAttachment := >smodel.MediaAttachment{}
|
||||||
*targetAttachment = *suite.testAttachments["remote_account_1_status_1_attachment_1"]
|
*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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
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
|
// uncache the attachment *and* set the remote URL to something that will return a 404
|
||||||
suite.UncacheAttachment(targetAttachment)
|
suite.UncacheAttachment(targetAttachment)
|
||||||
targetAttachment.RemoteURL = "http://nothing.at.this.url/weeeeeeeee"
|
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())
|
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
|
// uncache the attachment *and* set the remote URL to something that will return a 404
|
||||||
suite.UncacheAttachment(targetAttachment)
|
suite.UncacheAttachment(targetAttachment)
|
||||||
targetAttachment.RemoteURL = "http://nothing.at.this.url/weeeeeeeee"
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ package webfinger_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -129,11 +128,11 @@ func (suite *WebfingerGetTestSuite) funkifyAccountDomain(host string, accountDom
|
|||||||
PublicKeyURI: "http://" + host + "/users/new_account_domain_user/main-key",
|
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())
|
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())
|
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) {
|
func TestStatusTimelinePreloader(t *testing.T) {
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(t.Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
var tt StatusTimeline
|
var tt StatusTimeline
|
||||||
@ -154,7 +154,7 @@ func TestStatusTimelineLoadLimit(t *testing.T) {
|
|||||||
tt.Init(1000)
|
tt.Init(1000)
|
||||||
|
|
||||||
// Prepare new context for the duration of this test.
|
// Prepare new context for the duration of this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(t.Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
// Clone the input test status data.
|
// 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() {
|
func (suite *CleanerTestSuite) TestEmojiUncacheRemote() {
|
||||||
suite.testEmojiUncacheRemote(
|
suite.testEmojiUncacheRemote(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
mapvals(suite.emojis),
|
mapvals(suite.emojis),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *CleanerTestSuite) TestEmojiUncacheRemoteDryRun() {
|
func (suite *CleanerTestSuite) TestEmojiUncacheRemoteDryRun() {
|
||||||
suite.testEmojiUncacheRemote(
|
suite.testEmojiUncacheRemote(
|
||||||
gtscontext.SetDryRun(context.Background()),
|
gtscontext.SetDryRun(suite.T().Context()),
|
||||||
mapvals(suite.emojis),
|
mapvals(suite.emojis),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *CleanerTestSuite) TestEmojiFixBroken() {
|
func (suite *CleanerTestSuite) TestEmojiFixBroken() {
|
||||||
suite.testEmojiFixBroken(
|
suite.testEmojiFixBroken(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
mapvals(suite.emojis),
|
mapvals(suite.emojis),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *CleanerTestSuite) TestEmojiFixBrokenDryRun() {
|
func (suite *CleanerTestSuite) TestEmojiFixBrokenDryRun() {
|
||||||
suite.testEmojiFixBroken(
|
suite.testEmojiFixBroken(
|
||||||
gtscontext.SetDryRun(context.Background()),
|
gtscontext.SetDryRun(suite.T().Context()),
|
||||||
mapvals(suite.emojis),
|
mapvals(suite.emojis),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *CleanerTestSuite) TestEmojiPruneUnused() {
|
func (suite *CleanerTestSuite) TestEmojiPruneUnused() {
|
||||||
suite.testEmojiPruneUnused(
|
suite.testEmojiPruneUnused(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
mapvals(suite.emojis),
|
mapvals(suite.emojis),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *CleanerTestSuite) TestEmojiPruneUnusedDryRun() {
|
func (suite *CleanerTestSuite) TestEmojiPruneUnusedDryRun() {
|
||||||
suite.testEmojiPruneUnused(
|
suite.testEmojiPruneUnused(
|
||||||
gtscontext.SetDryRun(context.Background()),
|
gtscontext.SetDryRun(suite.T().Context()),
|
||||||
mapvals(suite.emojis),
|
mapvals(suite.emojis),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ func (suite *CleanerTestSuite) TestEmojiFixCacheStates() {
|
|||||||
emojis["rainbow"].Cached = util.Ptr(false)
|
emojis["rainbow"].Cached = util.Ptr(false)
|
||||||
|
|
||||||
suite.testEmojiFixCacheStates(
|
suite.testEmojiFixCacheStates(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
mapvals(emojis),
|
mapvals(emojis),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ func (suite *CleanerTestSuite) TestEmojiFixCacheStatesDryRun() {
|
|||||||
emojis["rainbow"].Cached = util.Ptr(false)
|
emojis["rainbow"].Cached = util.Ptr(false)
|
||||||
|
|
||||||
suite.testEmojiFixCacheStates(
|
suite.testEmojiFixCacheStates(
|
||||||
gtscontext.SetDryRun(context.Background()),
|
gtscontext.SetDryRun(suite.T().Context()),
|
||||||
mapvals(emojis),
|
mapvals(emojis),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -94,11 +94,11 @@ func (suite *MediaTestSuite) TearDownTest() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// pandaPath := "01GJQJ1YD9QCHCE12GG0EYHVNW/attachment/original/01GJQJ2AYM1VKSRW96YVAJ3NK3.gif"
|
// 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())
|
// suite.FailNow(err.Error())
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// ctx := context.Background()
|
// ctx := suite.T().Context()
|
||||||
|
|
||||||
// // dry run should show up 1 orphaned panda
|
// // dry run should show up 1 orphaned panda
|
||||||
// totalPruned, err := suite.cleaner.Media().PruneOrphaned(gtscontext.SetDryRun(ctx))
|
// totalPruned, err := suite.cleaner.Media().PruneOrphaned(gtscontext.SetDryRun(ctx))
|
||||||
@ -121,11 +121,11 @@ func (suite *MediaTestSuite) TearDownTest() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// pandaPath := "01GJQJ1YD9QCHCE12GG0EYHVNW/attachment/original/01GJQJ2AYM1VKSRW96YVAJ3NK3.gif"
|
// 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())
|
// suite.FailNow(err.Error())
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// ctx := context.Background()
|
// ctx := suite.T().Context()
|
||||||
|
|
||||||
// // should show up 1 orphaned panda
|
// // should show up 1 orphaned panda
|
||||||
// totalPruned, err := suite.cleaner.Media().PruneOrphaned(ctx)
|
// totalPruned, err := suite.cleaner.Media().PruneOrphaned(ctx)
|
||||||
@ -142,11 +142,11 @@ func (suite *MediaTestSuite) TearDownTest() {
|
|||||||
// testAttachment := suite.testAttachments["local_account_1_unattached_1"]
|
// testAttachment := suite.testAttachments["local_account_1_unattached_1"]
|
||||||
// suite.True(*testAttachment.Cached)
|
// 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.NoError(err)
|
||||||
// suite.Equal(1, totalPruned)
|
// 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)
|
// suite.ErrorIs(err, db.ErrNoEntries)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@ -154,27 +154,27 @@ func (suite *MediaTestSuite) TearDownTest() {
|
|||||||
// testAttachment := suite.testAttachments["local_account_1_unattached_1"]
|
// testAttachment := suite.testAttachments["local_account_1_unattached_1"]
|
||||||
// suite.True(*testAttachment.Cached)
|
// 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.NoError(err)
|
||||||
// suite.Equal(1, totalPruned)
|
// suite.Equal(1, totalPruned)
|
||||||
|
|
||||||
// _, err = suite.db.GetAttachmentByID(context.Background(), testAttachment.ID)
|
// _, err = suite.db.GetAttachmentByID(suite.T().Context(), testAttachment.ID)
|
||||||
// suite.NoError(err)
|
// suite.NoError(err)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// func (suite *MediaTestSuite) TestPruneRemoteTwice() {
|
// 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.NoError(err)
|
||||||
// suite.Equal(1, totalPruned)
|
// suite.Equal(1, totalPruned)
|
||||||
|
|
||||||
// // final prune should prune nothing, since the first prune already happened
|
// // 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.NoError(err)
|
||||||
// suite.Equal(0, totalPrunedAgain)
|
// suite.Equal(0, totalPrunedAgain)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// func (suite *MediaTestSuite) TestPruneOneNonExistent() {
|
// func (suite *MediaTestSuite) TestPruneOneNonExistent() {
|
||||||
// ctx := context.Background()
|
// ctx := suite.T().Context()
|
||||||
// testAttachment := suite.testAttachments["local_account_1_unattached_1"]
|
// testAttachment := suite.testAttachments["local_account_1_unattached_1"]
|
||||||
|
|
||||||
// // Delete this attachment cached on disk
|
// // Delete this attachment cached on disk
|
||||||
@ -191,7 +191,7 @@ func (suite *MediaTestSuite) TearDownTest() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// func (suite *MediaTestSuite) TestPruneUnusedRemote() {
|
// func (suite *MediaTestSuite) TestPruneUnusedRemote() {
|
||||||
// ctx := context.Background()
|
// ctx := suite.T().Context()
|
||||||
|
|
||||||
// // start by clearing zork's avatar + header
|
// // start by clearing zork's avatar + header
|
||||||
// zorkOldAvatar := suite.testAttachments["local_account_1_avatar"]
|
// zorkOldAvatar := suite.testAttachments["local_account_1_avatar"]
|
||||||
@ -225,7 +225,7 @@ func (suite *MediaTestSuite) TearDownTest() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// func (suite *MediaTestSuite) TestPruneUnusedRemoteTwice() {
|
// func (suite *MediaTestSuite) TestPruneUnusedRemoteTwice() {
|
||||||
// ctx := context.Background()
|
// ctx := suite.T().Context()
|
||||||
|
|
||||||
// // start by clearing zork's avatar + header
|
// // start by clearing zork's avatar + header
|
||||||
// zork := suite.testAccounts["local_account_1"]
|
// zork := suite.testAccounts["local_account_1"]
|
||||||
@ -246,7 +246,7 @@ func (suite *MediaTestSuite) TearDownTest() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// func (suite *MediaTestSuite) TestPruneUnusedRemoteMultipleAccounts() {
|
// func (suite *MediaTestSuite) TestPruneUnusedRemoteMultipleAccounts() {
|
||||||
// ctx := context.Background()
|
// ctx := suite.T().Context()
|
||||||
|
|
||||||
// // start by clearing zork's avatar + header
|
// // start by clearing zork's avatar + header
|
||||||
// zorkOldAvatar := suite.testAttachments["local_account_1_avatar"]
|
// zorkOldAvatar := suite.testAttachments["local_account_1_avatar"]
|
||||||
@ -287,7 +287,7 @@ func (suite *MediaTestSuite) TearDownTest() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
func (suite *MediaTestSuite) TestUncacheRemote() {
|
func (suite *MediaTestSuite) TestUncacheRemote() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
testStatusAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
|
testStatusAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
|
||||||
suite.True(*testStatusAttachment.Cached)
|
suite.True(*testStatusAttachment.Cached)
|
||||||
@ -310,7 +310,7 @@ func (suite *MediaTestSuite) TestUncacheRemote() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *MediaTestSuite) TestUncacheRemoteDry() {
|
func (suite *MediaTestSuite) TestUncacheRemoteDry() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
testStatusAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
|
testStatusAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
|
||||||
suite.True(*testStatusAttachment.Cached)
|
suite.True(*testStatusAttachment.Cached)
|
||||||
@ -333,7 +333,7 @@ func (suite *MediaTestSuite) TestUncacheRemoteDry() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *MediaTestSuite) TestUncacheRemoteTwice() {
|
func (suite *MediaTestSuite) TestUncacheRemoteTwice() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
after := time.Now().Add(-24 * time.Hour)
|
after := time.Now().Add(-24 * time.Hour)
|
||||||
|
|
||||||
totalUncached, err := suite.cleaner.Media().UncacheRemote(ctx, after)
|
totalUncached, err := suite.cleaner.Media().UncacheRemote(ctx, after)
|
||||||
@ -347,7 +347,7 @@ func (suite *MediaTestSuite) TestUncacheRemoteTwice() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *MediaTestSuite) TestUncacheAndRecache() {
|
func (suite *MediaTestSuite) TestUncacheAndRecache() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
testStatusAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
|
testStatusAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
|
||||||
testHeader := suite.testAttachments["remote_account_3_header"]
|
testHeader := suite.testAttachments["remote_account_3_header"]
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ func (suite *MediaTestSuite) TestUncacheAndRecache() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *MediaTestSuite) TestUncacheOneNonExistent() {
|
func (suite *MediaTestSuite) TestUncacheOneNonExistent() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
testStatusAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
|
testStatusAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
|
||||||
|
|
||||||
// Delete this attachment cached on disk
|
// Delete this attachment cached on disk
|
||||||
|
@ -43,53 +43,53 @@ type AccountTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AccountTestSuite) TestGetAccountStatuses() {
|
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.NoError(err)
|
||||||
suite.Len(statuses, 9)
|
suite.Len(statuses, 9)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AccountTestSuite) TestGetAccountWebStatusesMediaOnly() {
|
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.NoError(err)
|
||||||
suite.Len(statuses, 2)
|
suite.Len(statuses, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AccountTestSuite) TestGetAccountStatusesPageDown() {
|
func (suite *AccountTestSuite) TestGetAccountStatusesPageDown() {
|
||||||
// get the first page
|
// 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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
suite.Len(statuses, 3)
|
suite.Len(statuses, 3)
|
||||||
|
|
||||||
// get the second page
|
// 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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
suite.Len(statuses, 3)
|
suite.Len(statuses, 3)
|
||||||
|
|
||||||
// get the third page
|
// 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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
suite.Len(statuses, 3)
|
suite.Len(statuses, 3)
|
||||||
|
|
||||||
// try to get the last page (should be empty)
|
// 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.ErrorIs(err, db.ErrNoEntries)
|
||||||
suite.Empty(statuses)
|
suite.Empty(statuses)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AccountTestSuite) TestGetAccountStatusesExcludeRepliesAndReblogs() {
|
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.NoError(err)
|
||||||
suite.Len(statuses, 8)
|
suite.Len(statuses, 8)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AccountTestSuite) TestGetAccountStatusesExcludeRepliesAndReblogsPublicOnly() {
|
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.NoError(err)
|
||||||
suite.Len(statuses, 4)
|
suite.Len(statuses, 4)
|
||||||
}
|
}
|
||||||
@ -169,14 +169,14 @@ func (suite *AccountTestSuite) TestGetAccountStatusesExcludeRepliesExcludesSelfR
|
|||||||
)
|
)
|
||||||
|
|
||||||
for _, status := range []*gtsmodel.Status{post, reply, riposte, followup} {
|
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)
|
suite.FailNowf("", "Error while adding test status with ID %s: %v", status.ID, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testAccount := suite.testAccounts["local_account_1"]
|
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.NoError(err)
|
||||||
suite.Len(statuses, 9)
|
suite.Len(statuses, 9)
|
||||||
for _, status := range statuses {
|
for _, status := range statuses {
|
||||||
@ -190,7 +190,7 @@ func (suite *AccountTestSuite) TestGetAccountStatusesExcludeRepliesExcludesSelfR
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AccountTestSuite) TestGetAccountStatusesMediaOnly() {
|
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.NoError(err)
|
||||||
suite.Len(statuses, 2)
|
suite.Len(statuses, 2)
|
||||||
}
|
}
|
||||||
@ -199,7 +199,7 @@ func (suite *AccountTestSuite) TestGetAccountBy() {
|
|||||||
t := suite.T()
|
t := suite.T()
|
||||||
|
|
||||||
// Create a new context for this test.
|
// Create a new context for this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
// Sentinel error to mark avoiding a test case.
|
// Sentinel error to mark avoiding a test case.
|
||||||
@ -344,7 +344,7 @@ func (suite *AccountTestSuite) TestGetAccountBy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AccountTestSuite) TestGetAccountsByURLMulti() {
|
func (suite *AccountTestSuite) TestGetAccountsByURLMulti() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
// Update admin account to have the same url as zork.
|
// Update admin account to have the same url as zork.
|
||||||
testAccount1 := suite.testAccounts["local_account_1"]
|
testAccount1 := suite.testAccounts["local_account_1"]
|
||||||
@ -391,7 +391,7 @@ func (suite *AccountTestSuite) TestInsertAccountWithDefaults() {
|
|||||||
PublicKeyURI: "https://example.org/users/test_service#main-key",
|
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.NoError(err)
|
||||||
|
|
||||||
suite.WithinDuration(time.Now(), newAccount.CreatedAt, 30*time.Second)
|
suite.WithinDuration(time.Now(), newAccount.CreatedAt, 30*time.Second)
|
||||||
@ -403,7 +403,7 @@ func (suite *AccountTestSuite) TestInsertAccountWithDefaults() {
|
|||||||
func (suite *AccountTestSuite) TestGetAccountPinnedStatusesSomeResults() {
|
func (suite *AccountTestSuite) TestGetAccountPinnedStatusesSomeResults() {
|
||||||
testAccount := suite.testAccounts["admin_account"]
|
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.NoError(err)
|
||||||
suite.Len(statuses, 2) // This account has 2 statuses pinned.
|
suite.Len(statuses, 2) // This account has 2 statuses pinned.
|
||||||
}
|
}
|
||||||
@ -411,7 +411,7 @@ func (suite *AccountTestSuite) TestGetAccountPinnedStatusesSomeResults() {
|
|||||||
func (suite *AccountTestSuite) TestGetAccountPinnedStatusesNothingPinned() {
|
func (suite *AccountTestSuite) TestGetAccountPinnedStatusesNothingPinned() {
|
||||||
testAccount := suite.testAccounts["local_account_1"]
|
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.ErrorIs(err, db.ErrNoEntries)
|
||||||
suite.Empty(statuses) // This account has nothing pinned.
|
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.
|
// Set test account MovedToURI to something we don't have in the database.
|
||||||
// We should not get an error when populating.
|
// We should not get an error when populating.
|
||||||
testAccount.MovedToURI = "https://unknown-instance.example.org/users/someone_we_dont_know"
|
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)
|
suite.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AccountTestSuite) TestGetAccountsAll() {
|
func (suite *AccountTestSuite) TestGetAccountsAll() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
origin = ""
|
origin = ""
|
||||||
status = ""
|
status = ""
|
||||||
mods = false
|
mods = false
|
||||||
@ -464,7 +464,7 @@ func (suite *AccountTestSuite) TestGetAccountsAll() {
|
|||||||
|
|
||||||
func (suite *AccountTestSuite) TestGetAccountsMaxID() {
|
func (suite *AccountTestSuite) TestGetAccountsMaxID() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
origin = ""
|
origin = ""
|
||||||
status = ""
|
status = ""
|
||||||
mods = false
|
mods = false
|
||||||
@ -501,7 +501,7 @@ func (suite *AccountTestSuite) TestGetAccountsMaxID() {
|
|||||||
|
|
||||||
func (suite *AccountTestSuite) TestGetAccountsMinID() {
|
func (suite *AccountTestSuite) TestGetAccountsMinID() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
origin = ""
|
origin = ""
|
||||||
status = ""
|
status = ""
|
||||||
mods = false
|
mods = false
|
||||||
@ -538,7 +538,7 @@ func (suite *AccountTestSuite) TestGetAccountsMinID() {
|
|||||||
|
|
||||||
func (suite *AccountTestSuite) TestGetAccountsModsOnly() {
|
func (suite *AccountTestSuite) TestGetAccountsModsOnly() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
origin = ""
|
origin = ""
|
||||||
status = ""
|
status = ""
|
||||||
mods = true
|
mods = true
|
||||||
@ -575,7 +575,7 @@ func (suite *AccountTestSuite) TestGetAccountsModsOnly() {
|
|||||||
|
|
||||||
func (suite *AccountTestSuite) TestGetAccountsLocalWithEmail() {
|
func (suite *AccountTestSuite) TestGetAccountsLocalWithEmail() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
origin = "local"
|
origin = "local"
|
||||||
status = ""
|
status = ""
|
||||||
mods = false
|
mods = false
|
||||||
@ -612,7 +612,7 @@ func (suite *AccountTestSuite) TestGetAccountsLocalWithEmail() {
|
|||||||
|
|
||||||
func (suite *AccountTestSuite) TestGetAccountsWithIP() {
|
func (suite *AccountTestSuite) TestGetAccountsWithIP() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
origin = ""
|
origin = ""
|
||||||
status = ""
|
status = ""
|
||||||
mods = false
|
mods = false
|
||||||
@ -649,7 +649,7 @@ func (suite *AccountTestSuite) TestGetAccountsWithIP() {
|
|||||||
|
|
||||||
func (suite *AccountTestSuite) TestGetPendingAccounts() {
|
func (suite *AccountTestSuite) TestGetPendingAccounts() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
origin = ""
|
origin = ""
|
||||||
status = "pending"
|
status = "pending"
|
||||||
mods = false
|
mods = false
|
||||||
@ -685,7 +685,7 @@ func (suite *AccountTestSuite) TestGetPendingAccounts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AccountTestSuite) TestAccountStatsAll() {
|
func (suite *AccountTestSuite) TestAccountStatsAll() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
for _, account := range suite.testAccounts {
|
for _, account := range suite.testAccounts {
|
||||||
// Get stats for the first time. They
|
// Get stats for the first time. They
|
||||||
// should all be generated now since
|
// should all be generated now since
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
|
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
|
||||||
@ -31,31 +30,31 @@ type AdminTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AdminTestSuite) TestIsUsernameAvailableNo() {
|
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.NoError(err)
|
||||||
suite.False(available)
|
suite.False(available)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AdminTestSuite) TestIsUsernameAvailableYes() {
|
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.NoError(err)
|
||||||
suite.True(available)
|
suite.True(available)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AdminTestSuite) TestIsEmailAvailableNo() {
|
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.NoError(err)
|
||||||
suite.False(available)
|
suite.False(available)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AdminTestSuite) TestIsEmailAvailableYes() {
|
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.NoError(err)
|
||||||
suite.True(available)
|
suite.True(available)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AdminTestSuite) TestIsEmailAvailableDomainBlocked() {
|
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",
|
ID: "01GEEV2R2YC5GRSN96761YJE47",
|
||||||
Domain: "somewhere.com",
|
Domain: "somewhere.com",
|
||||||
CreatedByAccountID: suite.testAccounts["admin_account"].ID,
|
CreatedByAccountID: suite.testAccounts["admin_account"].ID,
|
||||||
@ -63,7 +62,7 @@ func (suite *AdminTestSuite) TestIsEmailAvailableDomainBlocked() {
|
|||||||
suite.FailNow(err.Error())
|
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.EqualError(err, "email domain somewhere.com is blocked")
|
||||||
suite.False(available)
|
suite.False(available)
|
||||||
}
|
}
|
||||||
@ -78,22 +77,22 @@ func (suite *AdminTestSuite) TestCreateInstanceAccount() {
|
|||||||
testrig.CreateTestTables(suite.db)
|
testrig.CreateTestTables(suite.db)
|
||||||
|
|
||||||
// make sure there's no instance account in the db yet
|
// 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.Error(err)
|
||||||
suite.Nil(acct)
|
suite.Nil(acct)
|
||||||
|
|
||||||
// create it
|
// create it
|
||||||
err = suite.db.CreateInstanceAccount(context.Background())
|
err = suite.db.CreateInstanceAccount(suite.T().Context())
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
// and now check it exists
|
// and now check it exists
|
||||||
acct, err = suite.db.GetInstanceAccount(context.Background(), "")
|
acct, err = suite.db.GetInstanceAccount(suite.T().Context(), "")
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.NotNil(acct)
|
suite.NotNil(acct)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AdminTestSuite) TestNewSignupWithNoInstanceApp() {
|
func (suite *AdminTestSuite) TestNewSignupWithNoInstanceApp() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
// Delete the instance app.
|
// Delete the instance app.
|
||||||
if err := suite.state.DB.DeleteApplicationByID(
|
if err := suite.state.DB.DeleteApplicationByID(
|
||||||
|
@ -36,7 +36,7 @@ func (suite *ApplicationTestSuite) TestGetApplicationBy() {
|
|||||||
t := suite.T()
|
t := suite.T()
|
||||||
|
|
||||||
// Create a new context for this test.
|
// Create a new context for this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
// Sentinel error to mark avoiding a test case.
|
// Sentinel error to mark avoiding a test case.
|
||||||
@ -86,7 +86,7 @@ func (suite *ApplicationTestSuite) TestDeleteApplicationBy() {
|
|||||||
t := suite.T()
|
t := suite.T()
|
||||||
|
|
||||||
// Create a new context for this test.
|
// Create a new context for this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
for _, app := range suite.testApplications {
|
for _, app := range suite.testApplications {
|
||||||
@ -117,7 +117,7 @@ func (suite *ApplicationTestSuite) TestDeleteApplicationBy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ApplicationTestSuite) TestGetAllTokens() {
|
func (suite *ApplicationTestSuite) TestGetAllTokens() {
|
||||||
tokens, err := suite.db.GetAllTokens(context.Background())
|
tokens, err := suite.db.GetAllTokens(suite.T().Context())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ func (suite *ApplicationTestSuite) TestGetAllTokens() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ApplicationTestSuite) TestDeleteTokensByClientID() {
|
func (suite *ApplicationTestSuite) TestDeleteTokensByClientID() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
// Delete tokens by each app.
|
// Delete tokens by each app.
|
||||||
for _, app := range suite.testApplications {
|
for _, app := range suite.testApplications {
|
||||||
@ -147,7 +147,7 @@ func (suite *ApplicationTestSuite) TestDeleteTokensByUnknownClientID() {
|
|||||||
// Should not return ErrNoRows even though
|
// Should not return ErrNoRows even though
|
||||||
// the client with given ID doesn't exist.
|
// the client with given ID doesn't exist.
|
||||||
if err := suite.state.DB.DeleteTokensByClientID(
|
if err := suite.state.DB.DeleteTokensByClientID(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
"01JPJ4NCGH6GHY7ZVYBHNP55XS",
|
"01JPJ4NCGH6GHY7ZVYBHNP55XS",
|
||||||
); err != nil {
|
); err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
"testing"
|
"testing"
|
||||||
@ -37,7 +36,7 @@ func (suite *BasicTestSuite) TestGetAccountByID() {
|
|||||||
testAccount := suite.testAccounts["local_account_1"]
|
testAccount := suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
a := >smodel.Account{}
|
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)
|
suite.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,12 +59,12 @@ func (suite *BasicTestSuite) TestPutAccountWithBunDefaultFields() {
|
|||||||
PublicKey: &key.PublicKey,
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
a := >smodel.Account{}
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +110,7 @@ func (suite *BasicTestSuite) TestPutAccountWithBunDefaultFields() {
|
|||||||
|
|
||||||
func (suite *BasicTestSuite) TestGetAllStatuses() {
|
func (suite *BasicTestSuite) TestGetAllStatuses() {
|
||||||
s := []*gtsmodel.Status{}
|
s := []*gtsmodel.Status{}
|
||||||
err := suite.db.GetAll(context.Background(), &s)
|
err := suite.db.GetAll(suite.T().Context(), &s)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.Len(s, 30)
|
suite.Len(s, 30)
|
||||||
}
|
}
|
||||||
@ -125,7 +124,7 @@ func (suite *BasicTestSuite) TestGetAllNotNull() {
|
|||||||
|
|
||||||
a := []*gtsmodel.Account{}
|
a := []*gtsmodel.Account{}
|
||||||
|
|
||||||
err := suite.db.GetWhere(context.Background(), where, &a)
|
err := suite.db.GetWhere(suite.T().Context(), where, &a)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.NotEmpty(a)
|
suite.NotEmpty(a)
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.superseriousbusiness.org/gotosocial/internal/config"
|
"code.superseriousbusiness.org/gotosocial/internal/config"
|
||||||
@ -32,7 +31,7 @@ type BundbNewTestSuite struct {
|
|||||||
|
|
||||||
func (suite *BundbNewTestSuite) TestCreateNewDB() {
|
func (suite *BundbNewTestSuite) TestCreateNewDB() {
|
||||||
// create a new db with standard test settings
|
// 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.NoError(err)
|
||||||
suite.NotNil(db)
|
suite.NotNil(db)
|
||||||
}
|
}
|
||||||
@ -41,7 +40,7 @@ func (suite *BundbNewTestSuite) TestCreateNewSqliteDBNoAddress() {
|
|||||||
// create a new db with no address specified
|
// create a new db with no address specified
|
||||||
config.SetDbAddress("")
|
config.SetDbAddress("")
|
||||||
config.SetDbType("sqlite")
|
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.EqualError(err, "'db-address' was not set when attempting to start sqlite")
|
||||||
suite.Nil(db)
|
suite.Nil(db)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -57,7 +56,7 @@ func (suite *ConversationTestSuite) SetupTest() {
|
|||||||
|
|
||||||
// deleteStatus deletes a status from conversations and ends the test if that fails.
|
// deleteStatus deletes a status from conversations and ends the test if that fails.
|
||||||
func (suite *ConversationTestSuite) deleteStatus(statusID string) {
|
func (suite *ConversationTestSuite) deleteStatus(statusID string) {
|
||||||
err := suite.db.DeleteStatusFromConversations(context.Background(), statusID)
|
err := suite.db.DeleteStatusFromConversations(suite.T().Context(), statusID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
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.
|
// getConversation fetches a conversation by ID and ends the test if that fails.
|
||||||
func (suite *ConversationTestSuite) getConversation(conversationID string) *gtsmodel.Conversation {
|
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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -106,7 +105,7 @@ func (suite *ConversationTestSuite) TestDeleteOnlyStatus() {
|
|||||||
initial := conversation.LastStatus
|
initial := conversation.LastStatus
|
||||||
|
|
||||||
suite.deleteStatus(initial.ID)
|
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)
|
suite.ErrorIs(err, db.ErrNoEntries)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"slices"
|
"slices"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -32,7 +31,7 @@ type DomainTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *DomainTestSuite) TestIsDomainBlocked() {
|
func (suite *DomainTestSuite) TestIsDomainBlocked() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
domainBlock := >smodel.DomainBlock{
|
domainBlock := >smodel.DomainBlock{
|
||||||
ID: "01G204214Y9TNJEBX39C7G88SW",
|
ID: "01G204214Y9TNJEBX39C7G88SW",
|
||||||
@ -57,7 +56,7 @@ func (suite *DomainTestSuite) TestIsDomainBlocked() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *DomainTestSuite) TestIsDomainBlockedWithAllow() {
|
func (suite *DomainTestSuite) TestIsDomainBlockedWithAllow() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
domainBlock := >smodel.DomainBlock{
|
domainBlock := >smodel.DomainBlock{
|
||||||
ID: "01G204214Y9TNJEBX39C7G88SW",
|
ID: "01G204214Y9TNJEBX39C7G88SW",
|
||||||
@ -110,7 +109,7 @@ func (suite *DomainTestSuite) TestIsDomainBlockedWithAllow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *DomainTestSuite) TestIsDomainBlockedWildcard() {
|
func (suite *DomainTestSuite) TestIsDomainBlockedWildcard() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
domainBlock := >smodel.DomainBlock{
|
domainBlock := >smodel.DomainBlock{
|
||||||
ID: "01G204214Y9TNJEBX39C7G88SW",
|
ID: "01G204214Y9TNJEBX39C7G88SW",
|
||||||
@ -142,7 +141,7 @@ func (suite *DomainTestSuite) TestIsDomainBlockedWildcard() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *DomainTestSuite) TestIsDomainBlockedNonASCII() {
|
func (suite *DomainTestSuite) TestIsDomainBlockedNonASCII() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
@ -178,7 +177,7 @@ func (suite *DomainTestSuite) TestIsDomainBlockedNonASCII() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *DomainTestSuite) TestIsDomainBlockedNonASCII2() {
|
func (suite *DomainTestSuite) TestIsDomainBlockedNonASCII2() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
@ -214,7 +213,7 @@ func (suite *DomainTestSuite) TestIsDomainBlockedNonASCII2() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *DomainTestSuite) TestIsOtherDomainBlockedWildcardAndExplicit() {
|
func (suite *DomainTestSuite) TestIsOtherDomainBlockedWildcardAndExplicit() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
blocks := []*gtsmodel.DomainBlock{
|
blocks := []*gtsmodel.DomainBlock{
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -34,7 +33,7 @@ type DomainPermissionDraftTestSuite struct {
|
|||||||
|
|
||||||
func (suite *DomainPermissionDraftTestSuite) TestPermDraftCreateGetDelete() {
|
func (suite *DomainPermissionDraftTestSuite) TestPermDraftCreateGetDelete() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
draft = >smodel.DomainPermissionDraft{
|
draft = >smodel.DomainPermissionDraft{
|
||||||
ID: "01JCZN614XG85GCGAMSV9ZZAEJ",
|
ID: "01JCZN614XG85GCGAMSV9ZZAEJ",
|
||||||
PermissionType: gtsmodel.DomainPermissionBlock,
|
PermissionType: gtsmodel.DomainPermissionBlock,
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -34,7 +33,7 @@ type DomainPermissionExcludeTestSuite struct {
|
|||||||
|
|
||||||
func (suite *DomainPermissionExcludeTestSuite) TestPermExcludeCreateGetDelete() {
|
func (suite *DomainPermissionExcludeTestSuite) TestPermExcludeCreateGetDelete() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
exclude = >smodel.DomainPermissionExclude{
|
exclude = >smodel.DomainPermissionExclude{
|
||||||
ID: "01JCZN614XG85GCGAMSV9ZZAEJ",
|
ID: "01JCZN614XG85GCGAMSV9ZZAEJ",
|
||||||
Domain: "exämple.org",
|
Domain: "exämple.org",
|
||||||
@ -103,7 +102,7 @@ func (suite *DomainPermissionExcludeTestSuite) TestPermExcludeCreateGetDelete()
|
|||||||
|
|
||||||
func (suite *DomainPermissionExcludeTestSuite) TestExcluded() {
|
func (suite *DomainPermissionExcludeTestSuite) TestExcluded() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
createdByAccountID = suite.testAccounts["admin_account"].ID
|
createdByAccountID = suite.testAccounts["admin_account"].ID
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
|
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
|
||||||
@ -31,7 +30,7 @@ type DomainPermissionSubscriptionTestSuite struct {
|
|||||||
|
|
||||||
func (suite *DomainPermissionSubscriptionTestSuite) TestCount() {
|
func (suite *DomainPermissionSubscriptionTestSuite) TestCount() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
testAccount = suite.testAccounts["admin_account"]
|
testAccount = suite.testAccounts["admin_account"]
|
||||||
permSub = >smodel.DomainPermissionSubscription{
|
permSub = >smodel.DomainPermissionSubscription{
|
||||||
ID: "01JGV3VZ72K58BYW8H5GEVBZGN",
|
ID: "01JGV3VZ72K58BYW8H5GEVBZGN",
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.superseriousbusiness.org/gotosocial/internal/db"
|
"code.superseriousbusiness.org/gotosocial/internal/db"
|
||||||
@ -32,7 +31,7 @@ type EmojiTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EmojiTestSuite) TestGetUseableEmojis() {
|
func (suite *EmojiTestSuite) TestGetUseableEmojis() {
|
||||||
emojis, err := suite.db.GetUseableEmojis(context.Background())
|
emojis, err := suite.db.GetUseableEmojis(suite.T().Context())
|
||||||
|
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.Equal(1, len(emojis))
|
suite.Equal(1, len(emojis))
|
||||||
@ -42,16 +41,16 @@ func (suite *EmojiTestSuite) TestGetUseableEmojis() {
|
|||||||
func (suite *EmojiTestSuite) TestDeleteEmojiByID() {
|
func (suite *EmojiTestSuite) TestDeleteEmojiByID() {
|
||||||
testEmoji := suite.testEmojis["rainbow"]
|
testEmoji := suite.testEmojis["rainbow"]
|
||||||
|
|
||||||
err := suite.db.DeleteEmojiByID(context.Background(), testEmoji.ID)
|
err := suite.db.DeleteEmojiByID(suite.T().Context(), testEmoji.ID)
|
||||||
suite.NoError(err)
|
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.Nil(dbEmoji)
|
||||||
suite.ErrorIs(err, db.ErrNoEntries)
|
suite.ErrorIs(err, db.ErrNoEntries)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EmojiTestSuite) TestGetEmojiByStaticURL() {
|
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.NoError(err)
|
||||||
suite.NotNil(emoji)
|
suite.NotNil(emoji)
|
||||||
suite.Equal("rainbow", emoji.Shortcode)
|
suite.Equal("rainbow", emoji.Shortcode)
|
||||||
@ -60,7 +59,7 @@ func (suite *EmojiTestSuite) TestGetEmojiByStaticURL() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EmojiTestSuite) TestGetAllEmojis() {
|
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.NoError(err)
|
||||||
suite.Equal(2, len(emojis))
|
suite.Equal(2, len(emojis))
|
||||||
@ -69,7 +68,7 @@ func (suite *EmojiTestSuite) TestGetAllEmojis() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EmojiTestSuite) TestGetAllEmojisLimit1() {
|
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.NoError(err)
|
||||||
suite.Equal(1, len(emojis))
|
suite.Equal(1, len(emojis))
|
||||||
@ -77,7 +76,7 @@ func (suite *EmojiTestSuite) TestGetAllEmojisLimit1() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EmojiTestSuite) TestGetAllEmojisMaxID() {
|
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.NoError(err)
|
||||||
suite.Equal(1, len(emojis))
|
suite.Equal(1, len(emojis))
|
||||||
@ -85,7 +84,7 @@ func (suite *EmojiTestSuite) TestGetAllEmojisMaxID() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EmojiTestSuite) TestGetAllEmojisMinID() {
|
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.NoError(err)
|
||||||
suite.Equal(1, len(emojis))
|
suite.Equal(1, len(emojis))
|
||||||
@ -93,14 +92,14 @@ func (suite *EmojiTestSuite) TestGetAllEmojisMinID() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EmojiTestSuite) TestGetAllDisabledEmojis() {
|
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.ErrorIs(err, db.ErrNoEntries)
|
||||||
suite.Equal(0, len(emojis))
|
suite.Equal(0, len(emojis))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EmojiTestSuite) TestGetAllEnabledEmojis() {
|
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.NoError(err)
|
||||||
suite.Equal(2, len(emojis))
|
suite.Equal(2, len(emojis))
|
||||||
@ -109,7 +108,7 @@ func (suite *EmojiTestSuite) TestGetAllEnabledEmojis() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EmojiTestSuite) TestGetLocalEnabledEmojis() {
|
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.NoError(err)
|
||||||
suite.Equal(1, len(emojis))
|
suite.Equal(1, len(emojis))
|
||||||
@ -117,21 +116,21 @@ func (suite *EmojiTestSuite) TestGetLocalEnabledEmojis() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EmojiTestSuite) TestGetLocalDisabledEmojis() {
|
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.ErrorIs(err, db.ErrNoEntries)
|
||||||
suite.Equal(0, len(emojis))
|
suite.Equal(0, len(emojis))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EmojiTestSuite) TestGetAllEmojisFromDomain() {
|
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.ErrorIs(err, db.ErrNoEntries)
|
||||||
suite.Equal(0, len(emojis))
|
suite.Equal(0, len(emojis))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EmojiTestSuite) TestGetAllEmojisFromDomain2() {
|
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.NoError(err)
|
||||||
suite.Equal(1, len(emojis))
|
suite.Equal(1, len(emojis))
|
||||||
@ -139,7 +138,7 @@ func (suite *EmojiTestSuite) TestGetAllEmojisFromDomain2() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EmojiTestSuite) TestGetSpecificEmojisFromDomain2() {
|
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.NoError(err)
|
||||||
suite.Equal(1, len(emojis))
|
suite.Equal(1, len(emojis))
|
||||||
@ -147,7 +146,7 @@ func (suite *EmojiTestSuite) TestGetSpecificEmojisFromDomain2() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EmojiTestSuite) TestGetEmojiCategories() {
|
func (suite *EmojiTestSuite) TestGetEmojiCategories() {
|
||||||
categories, err := suite.db.GetEmojiCategories(context.Background())
|
categories, err := suite.db.GetEmojiCategories(suite.T().Context())
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.Len(categories, 2)
|
suite.Len(categories, 2)
|
||||||
// check alphabetical order
|
// check alphabetical order
|
||||||
@ -156,7 +155,7 @@ func (suite *EmojiTestSuite) TestGetEmojiCategories() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EmojiTestSuite) TestGetEmojiCategory() {
|
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.NoError(err)
|
||||||
suite.NotNil(category)
|
suite.NotNil(category)
|
||||||
}
|
}
|
||||||
@ -167,7 +166,7 @@ func (suite *EmojiTestSuite) TestUpdateEmojiCategory() {
|
|||||||
|
|
||||||
testEmoji.CategoryID = ""
|
testEmoji.CategoryID = ""
|
||||||
|
|
||||||
err := suite.db.UpdateEmoji(context.Background(), testEmoji, "category_id")
|
err := suite.db.UpdateEmoji(suite.T().Context(), testEmoji, "category_id")
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -38,7 +37,7 @@ func (suite *ErrorsTestSuite) TestErrorAlreadyExists() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
initialFollow = >smodel.Follow{
|
initialFollow = >smodel.Follow{
|
||||||
ID: "01HD11D8JH5V64GJRFDA7VFNDX",
|
ID: "01HD11D8JH5V64GJRFDA7VFNDX",
|
||||||
URI: "https://example.org/unique_uri",
|
URI: "https://example.org/unique_uri",
|
||||||
|
@ -54,7 +54,7 @@ func (suite *FilterTestSuite) TestFilterCRUD() {
|
|||||||
filter.Keywords = []*gtsmodel.FilterKeyword{filterKeyword}
|
filter.Keywords = []*gtsmodel.FilterKeyword{filterKeyword}
|
||||||
|
|
||||||
// Create new cancellable test context.
|
// Create new cancellable test context.
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
ctx, cncl := context.WithCancel(ctx)
|
ctx, cncl := context.WithCancel(ctx)
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ func (suite *FilterTestSuite) TestFilterCRUD() {
|
|||||||
|
|
||||||
func (suite *FilterTestSuite) TestFilterTitleOverlap() {
|
func (suite *FilterTestSuite) TestFilterTitleOverlap() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
account1 = "01HNEJXCPRTJVJY9MV0VVHGD47"
|
account1 = "01HNEJXCPRTJVJY9MV0VVHGD47"
|
||||||
account2 = "01JAG5BRJPJYA0FSA5HR2MMFJH"
|
account2 = "01JAG5BRJPJYA0FSA5HR2MMFJH"
|
||||||
)
|
)
|
||||||
|
@ -41,7 +41,7 @@ func (suite *FilterTestSuite) TestFilterKeywordCRUD() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create new cancellable test context.
|
// Create new cancellable test context.
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
ctx, cncl := context.WithCancel(ctx)
|
ctx, cncl := context.WithCancel(ctx)
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ func (suite *FilterTestSuite) TestFilterStatusCRD() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create new cancellable test context.
|
// Create new cancellable test context.
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
ctx, cncl := context.WithCancel(ctx)
|
ctx, cncl := context.WithCancel(ctx)
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ func (suite *HeaderFilterTestSuite) testHeaderFilterGetPutUpdateDelete(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create new cancellable test context.
|
// Create new cancellable test context.
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
ctx, cncl := context.WithCancel(ctx)
|
ctx, cncl := context.WithCancel(ctx)
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.superseriousbusiness.org/gotosocial/internal/config"
|
"code.superseriousbusiness.org/gotosocial/internal/config"
|
||||||
@ -33,68 +32,68 @@ type InstanceTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InstanceTestSuite) TestCountInstanceUsers() {
|
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.NoError(err)
|
||||||
suite.Equal(5, count)
|
suite.Equal(5, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InstanceTestSuite) TestCountInstanceUsersRemote() {
|
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.NoError(err)
|
||||||
suite.Equal(1, count)
|
suite.Equal(1, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InstanceTestSuite) TestCountInstanceStatuses() {
|
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.NoError(err)
|
||||||
suite.Equal(23, count)
|
suite.Equal(23, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InstanceTestSuite) TestCountInstanceStatusesRemote() {
|
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.NoError(err)
|
||||||
suite.Equal(4, count)
|
suite.Equal(4, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InstanceTestSuite) TestCountInstanceDomains() {
|
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.NoError(err)
|
||||||
suite.Equal(2, count)
|
suite.Equal(2, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InstanceTestSuite) TestGetInstanceOK() {
|
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.NoError(err)
|
||||||
suite.NotNil(instance)
|
suite.NotNil(instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InstanceTestSuite) TestGetInstanceNonexistent() {
|
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.ErrorIs(err, db.ErrNoEntries)
|
||||||
suite.Nil(instance)
|
suite.Nil(instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InstanceTestSuite) TestGetInstancePeers() {
|
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.NoError(err)
|
||||||
suite.Len(peers, 2)
|
suite.Len(peers, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InstanceTestSuite) TestGetInstancePeersIncludeSuspended() {
|
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.NoError(err)
|
||||||
suite.Len(peers, 2)
|
suite.Len(peers, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InstanceTestSuite) TestGetInstanceAccounts() {
|
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.NoError(err)
|
||||||
suite.Len(accounts, 1)
|
suite.Len(accounts, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InstanceTestSuite) TestGetInstanceModeratorAddressesOK() {
|
func (suite *InstanceTestSuite) TestGetInstanceModeratorAddressesOK() {
|
||||||
// We have one admin user by default.
|
// 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.NoError(err)
|
||||||
suite.EqualValues([]string{"admin@example.org"}, addresses)
|
suite.EqualValues([]string{"admin@example.org"}, addresses)
|
||||||
}
|
}
|
||||||
@ -104,11 +103,11 @@ func (suite *InstanceTestSuite) TestGetInstanceModeratorAddressesZorkAsModerator
|
|||||||
testUser := >smodel.User{}
|
testUser := >smodel.User{}
|
||||||
*testUser = *suite.testUsers["local_account_1"]
|
*testUser = *suite.testUsers["local_account_1"]
|
||||||
testUser.Moderator = util.Ptr(true)
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
addresses, err := suite.db.GetInstanceModeratorAddresses(context.Background())
|
addresses, err := suite.db.GetInstanceModeratorAddresses(suite.T().Context())
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.EqualValues([]string{"admin@example.org", "zork@example.org"}, addresses)
|
suite.EqualValues([]string{"admin@example.org", "zork@example.org"}, addresses)
|
||||||
}
|
}
|
||||||
@ -119,11 +118,11 @@ func (suite *InstanceTestSuite) TestGetInstanceModeratorAddressesNoAdmin() {
|
|||||||
*testUser = *suite.testUsers["admin_account"]
|
*testUser = *suite.testUsers["admin_account"]
|
||||||
testUser.Admin = util.Ptr(false)
|
testUser.Admin = util.Ptr(false)
|
||||||
testUser.Moderator = 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())
|
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.ErrorIs(err, db.ErrNoEntries)
|
||||||
suite.Empty(addresses)
|
suite.Empty(addresses)
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ func (suite *InteractionTestSuite) markInteractionsPending(
|
|||||||
func (suite *InteractionTestSuite) TestGetPending() {
|
func (suite *InteractionTestSuite) TestGetPending() {
|
||||||
var (
|
var (
|
||||||
testStatus = suite.testStatuses["local_account_1_status_1"]
|
testStatus = suite.testStatuses["local_account_1_status_1"]
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
acctID = suite.testAccounts["local_account_1"].ID
|
acctID = suite.testAccounts["local_account_1"].ID
|
||||||
statusID = ""
|
statusID = ""
|
||||||
likes = true
|
likes = true
|
||||||
@ -175,7 +175,7 @@ func (suite *InteractionTestSuite) TestGetPending() {
|
|||||||
func (suite *InteractionTestSuite) TestGetPendingRepliesOnly() {
|
func (suite *InteractionTestSuite) TestGetPendingRepliesOnly() {
|
||||||
var (
|
var (
|
||||||
testStatus = suite.testStatuses["local_account_1_status_1"]
|
testStatus = suite.testStatuses["local_account_1_status_1"]
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
acctID = suite.testAccounts["local_account_1"].ID
|
acctID = suite.testAccounts["local_account_1"].ID
|
||||||
statusID = ""
|
statusID = ""
|
||||||
likes = false
|
likes = false
|
||||||
@ -211,7 +211,7 @@ func (suite *InteractionTestSuite) TestGetPendingRepliesOnly() {
|
|||||||
|
|
||||||
func (suite *InteractionTestSuite) TestInteractionRejected() {
|
func (suite *InteractionTestSuite) TestInteractionRejected() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
req = new(gtsmodel.InteractionRequest)
|
req = new(gtsmodel.InteractionRequest)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"slices"
|
"slices"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -102,7 +101,7 @@ func (suite *ListTestSuite) checkListEntries(expected []*gtsmodel.ListEntry, act
|
|||||||
func (suite *ListTestSuite) TestGetListByID() {
|
func (suite *ListTestSuite) TestGetListByID() {
|
||||||
testList, _, _ := suite.testStructs()
|
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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -113,7 +112,7 @@ func (suite *ListTestSuite) TestGetListByID() {
|
|||||||
func (suite *ListTestSuite) TestGetListsForAccountID() {
|
func (suite *ListTestSuite) TestGetListsForAccountID() {
|
||||||
testList, _, testAccount := suite.testStructs()
|
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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -126,7 +125,7 @@ func (suite *ListTestSuite) TestGetListsForAccountID() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ListTestSuite) TestPutList() {
|
func (suite *ListTestSuite) TestPutList() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
_, _, testAccount := suite.testStructs()
|
_, _, testAccount := suite.testStructs()
|
||||||
|
|
||||||
testList := >smodel.List{
|
testList := >smodel.List{
|
||||||
@ -150,7 +149,7 @@ func (suite *ListTestSuite) TestPutList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ListTestSuite) TestUpdateList() {
|
func (suite *ListTestSuite) TestUpdateList() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
testList, _, _ := suite.testStructs()
|
testList, _, _ := suite.testStructs()
|
||||||
|
|
||||||
// Get List in the cache first.
|
// Get List in the cache first.
|
||||||
@ -176,7 +175,7 @@ func (suite *ListTestSuite) TestUpdateList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ListTestSuite) TestDeleteList() {
|
func (suite *ListTestSuite) TestDeleteList() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
testList, _, _ := suite.testStructs()
|
testList, _, _ := suite.testStructs()
|
||||||
|
|
||||||
// Get List in the cache first.
|
// Get List in the cache first.
|
||||||
@ -205,7 +204,7 @@ func (suite *ListTestSuite) TestDeleteList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ListTestSuite) TestPutListEntries() {
|
func (suite *ListTestSuite) TestPutListEntries() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
testList, testEntries, _ := suite.testStructs()
|
testList, testEntries, _ := suite.testStructs()
|
||||||
|
|
||||||
listEntries := []*gtsmodel.ListEntry{
|
listEntries := []*gtsmodel.ListEntry{
|
||||||
@ -241,7 +240,7 @@ func (suite *ListTestSuite) TestPutListEntries() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ListTestSuite) TestDeleteListEntry() {
|
func (suite *ListTestSuite) TestDeleteListEntry() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
testList, testEntries, _ := suite.testStructs()
|
testList, testEntries, _ := suite.testStructs()
|
||||||
|
|
||||||
// Delete the first entry.
|
// Delete the first entry.
|
||||||
@ -261,7 +260,7 @@ func (suite *ListTestSuite) TestDeleteListEntry() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ListTestSuite) TestDeleteAllListEntriesByFollows() {
|
func (suite *ListTestSuite) TestDeleteAllListEntriesByFollows() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
testList, testEntries, _ := suite.testStructs()
|
testList, testEntries, _ := suite.testStructs()
|
||||||
|
|
||||||
// Delete the first entry.
|
// Delete the first entry.
|
||||||
@ -280,7 +279,7 @@ func (suite *ListTestSuite) TestDeleteAllListEntriesByFollows() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ListTestSuite) TestListIncludesAccount() {
|
func (suite *ListTestSuite) TestListIncludesAccount() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
testList, _, _ := suite.testStructs()
|
testList, _, _ := suite.testStructs()
|
||||||
|
|
||||||
for accountID, expected := range map[string]bool{
|
for accountID, expected := range map[string]bool{
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -35,7 +34,7 @@ type MarkersTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *MarkersTestSuite) TestGetExisting() {
|
func (suite *MarkersTestSuite) TestGetExisting() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
// This account has home and notifications markers set.
|
// This account has home and notifications markers set.
|
||||||
localAccount1 := suite.testAccounts["local_account_1"]
|
localAccount1 := suite.testAccounts["local_account_1"]
|
||||||
@ -49,7 +48,7 @@ func (suite *MarkersTestSuite) TestGetExisting() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *MarkersTestSuite) TestGetUnset() {
|
func (suite *MarkersTestSuite) TestGetUnset() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
// This account has no markers set.
|
// This account has no markers set.
|
||||||
localAccount2 := suite.testAccounts["local_account_2"]
|
localAccount2 := suite.testAccounts["local_account_2"]
|
||||||
@ -60,7 +59,7 @@ func (suite *MarkersTestSuite) TestGetUnset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *MarkersTestSuite) TestUpdateExisting() {
|
func (suite *MarkersTestSuite) TestUpdateExisting() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
// This account has home and notifications markers set.
|
// This account has home and notifications markers set.
|
||||||
@ -92,7 +91,7 @@ func (suite *MarkersTestSuite) TestUpdateExisting() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *MarkersTestSuite) TestUpdateUnset() {
|
func (suite *MarkersTestSuite) TestUpdateUnset() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
// This account has no markers set.
|
// This account has no markers set.
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -31,19 +30,19 @@ type MediaTestSuite struct {
|
|||||||
|
|
||||||
func (suite *MediaTestSuite) TestGetAttachmentByID() {
|
func (suite *MediaTestSuite) TestGetAttachmentByID() {
|
||||||
testAttachment := suite.testAttachments["admin_account_status_1_attachment_1"]
|
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.NoError(err)
|
||||||
suite.NotNil(attachment)
|
suite.NotNil(attachment)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *MediaTestSuite) TestGetOlder() {
|
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.NoError(err)
|
||||||
suite.Len(attachments, 3)
|
suite.Len(attachments, 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *MediaTestSuite) TestGetCachedAttachmentsOlderThan() {
|
func (suite *MediaTestSuite) TestGetCachedAttachmentsOlderThan() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
attachments, err := suite.db.GetCachedAttachmentsOlderThan(ctx, time.Now(), 20)
|
attachments, err := suite.db.GetCachedAttachmentsOlderThan(ctx, time.Now(), 20)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
@ -31,7 +30,7 @@ type MentionTestSuite struct {
|
|||||||
func (suite *MentionTestSuite) TestGetMention() {
|
func (suite *MentionTestSuite) TestGetMention() {
|
||||||
m := suite.testMentions["local_user_2_mention_zork"]
|
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.NoError(err)
|
||||||
suite.NotNil(dbMention)
|
suite.NotNil(dbMention)
|
||||||
suite.Equal(m.ID, dbMention.ID)
|
suite.Equal(m.ID, dbMention.ID)
|
||||||
@ -46,7 +45,7 @@ func (suite *MentionTestSuite) TestGetMention() {
|
|||||||
func (suite *MentionTestSuite) TestGetMentions() {
|
func (suite *MentionTestSuite) TestGetMentions() {
|
||||||
m := suite.testMentions["local_user_2_mention_zork"]
|
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.NoError(err)
|
||||||
suite.Len(dbMentions, 1)
|
suite.Len(dbMentions, 1)
|
||||||
dbMention := dbMentions[0]
|
dbMention := dbMentions[0]
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -32,7 +31,7 @@ type MoveTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *MoveTestSuite) TestMoveIntegration() {
|
func (suite *MoveTestSuite) TestMoveIntegration() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
firstMove := >smodel.Move{
|
firstMove := >smodel.Move{
|
||||||
ID: "01HPPN38MZYEC6WBTR21J6241N",
|
ID: "01HPPN38MZYEC6WBTR21J6241N",
|
||||||
OriginURI: "https://example.org/users/my_old_account",
|
OriginURI: "https://example.org/users/my_old_account",
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -74,7 +73,7 @@ func (suite *NotificationTestSuite) spamNotifs() {
|
|||||||
Read: util.Ptr(false),
|
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)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,7 +90,7 @@ func (suite *NotificationTestSuite) TestGetAccountNotificationsWithSpam() {
|
|||||||
testAccount := suite.testAccounts["local_account_1"]
|
testAccount := suite.testAccounts["local_account_1"]
|
||||||
before := time.Now()
|
before := time.Now()
|
||||||
notifications, err := suite.db.GetAccountNotifications(
|
notifications, err := suite.db.GetAccountNotifications(
|
||||||
gtscontext.SetBarebones(context.Background()),
|
gtscontext.SetBarebones(suite.T().Context()),
|
||||||
testAccount.ID,
|
testAccount.ID,
|
||||||
&paging.Page{
|
&paging.Page{
|
||||||
Min: paging.EitherMinID("", id.Lowest),
|
Min: paging.EitherMinID("", id.Lowest),
|
||||||
@ -115,7 +114,7 @@ func (suite *NotificationTestSuite) TestGetAccountNotificationsWithoutSpam() {
|
|||||||
testAccount := suite.testAccounts["local_account_1"]
|
testAccount := suite.testAccounts["local_account_1"]
|
||||||
before := time.Now()
|
before := time.Now()
|
||||||
notifications, err := suite.db.GetAccountNotifications(
|
notifications, err := suite.db.GetAccountNotifications(
|
||||||
gtscontext.SetBarebones(context.Background()),
|
gtscontext.SetBarebones(suite.T().Context()),
|
||||||
testAccount.ID,
|
testAccount.ID,
|
||||||
&paging.Page{
|
&paging.Page{
|
||||||
Min: paging.EitherMinID("", id.Lowest),
|
Min: paging.EitherMinID("", id.Lowest),
|
||||||
@ -141,7 +140,7 @@ func (suite *NotificationTestSuite) TestDeleteNotificationsWithSpam() {
|
|||||||
|
|
||||||
// Test getting notifs first.
|
// Test getting notifs first.
|
||||||
notifications, err := suite.db.GetAccountNotifications(
|
notifications, err := suite.db.GetAccountNotifications(
|
||||||
gtscontext.SetBarebones(context.Background()),
|
gtscontext.SetBarebones(suite.T().Context()),
|
||||||
testAccount.ID,
|
testAccount.ID,
|
||||||
&paging.Page{
|
&paging.Page{
|
||||||
Min: paging.EitherMinID("", id.Lowest),
|
Min: paging.EitherMinID("", id.Lowest),
|
||||||
@ -157,13 +156,13 @@ func (suite *NotificationTestSuite) TestDeleteNotificationsWithSpam() {
|
|||||||
suite.Len(notifications, 20)
|
suite.Len(notifications, 20)
|
||||||
|
|
||||||
// Now delete.
|
// 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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now try getting again.
|
// Now try getting again.
|
||||||
notifications, err = suite.db.GetAccountNotifications(
|
notifications, err = suite.db.GetAccountNotifications(
|
||||||
gtscontext.SetBarebones(context.Background()),
|
gtscontext.SetBarebones(suite.T().Context()),
|
||||||
testAccount.ID,
|
testAccount.ID,
|
||||||
&paging.Page{
|
&paging.Page{
|
||||||
Min: paging.EitherMinID("", id.Lowest),
|
Min: paging.EitherMinID("", id.Lowest),
|
||||||
@ -182,11 +181,11 @@ func (suite *NotificationTestSuite) TestDeleteNotificationsWithSpam() {
|
|||||||
func (suite *NotificationTestSuite) TestDeleteNotificationsWithTwoAccounts() {
|
func (suite *NotificationTestSuite) TestDeleteNotificationsWithTwoAccounts() {
|
||||||
suite.spamNotifs()
|
suite.spamNotifs()
|
||||||
testAccount := suite.testAccounts["local_account_1"]
|
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)
|
suite.NoError(err)
|
||||||
|
|
||||||
notifications, err := suite.db.GetAccountNotifications(
|
notifications, err := suite.db.GetAccountNotifications(
|
||||||
gtscontext.SetBarebones(context.Background()),
|
gtscontext.SetBarebones(suite.T().Context()),
|
||||||
testAccount.ID,
|
testAccount.ID,
|
||||||
&paging.Page{
|
&paging.Page{
|
||||||
Min: paging.EitherMinID("", id.Lowest),
|
Min: paging.EitherMinID("", id.Lowest),
|
||||||
@ -201,7 +200,7 @@ func (suite *NotificationTestSuite) TestDeleteNotificationsWithTwoAccounts() {
|
|||||||
suite.Empty(notifications)
|
suite.Empty(notifications)
|
||||||
|
|
||||||
notif := []*gtsmodel.Notification{}
|
notif := []*gtsmodel.Notification{}
|
||||||
err = suite.db.GetAll(context.Background(), ¬if)
|
err = suite.db.GetAll(suite.T().Context(), ¬if)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.NotEmpty(notif)
|
suite.NotEmpty(notif)
|
||||||
}
|
}
|
||||||
@ -209,12 +208,12 @@ func (suite *NotificationTestSuite) TestDeleteNotificationsWithTwoAccounts() {
|
|||||||
func (suite *NotificationTestSuite) TestDeleteNotificationsOriginatingFromAccount() {
|
func (suite *NotificationTestSuite) TestDeleteNotificationsOriginatingFromAccount() {
|
||||||
testAccount := suite.testAccounts["local_account_2"]
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
notif := []*gtsmodel.Notification{}
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,12 +228,12 @@ func (suite *NotificationTestSuite) TestDeleteNotificationsOriginatingFromAndTar
|
|||||||
originAccount := suite.testAccounts["local_account_2"]
|
originAccount := suite.testAccounts["local_account_2"]
|
||||||
targetAccount := suite.testAccounts["admin_account"]
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
notif := []*gtsmodel.Notification{}
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,12 +252,12 @@ func (suite *NotificationTestSuite) TestDeleteNotificationsOriginatingFromAndTar
|
|||||||
func (suite *NotificationTestSuite) TestDeleteNotificationsPertainingToStatusID() {
|
func (suite *NotificationTestSuite) TestDeleteNotificationsPertainingToStatusID() {
|
||||||
testStatus := suite.testStatuses["local_account_1_status_1"]
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
notif := []*gtsmodel.Notification{}
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ func (suite *PollTestSuite) TestGetPollBy() {
|
|||||||
t := suite.T()
|
t := suite.T()
|
||||||
|
|
||||||
// Create a new context for this test.
|
// Create a new context for this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
// Sentinel error to mark avoiding a test case.
|
// Sentinel error to mark avoiding a test case.
|
||||||
@ -103,7 +103,7 @@ func (suite *PollTestSuite) TestGetPollVoteBy() {
|
|||||||
t := suite.T()
|
t := suite.T()
|
||||||
|
|
||||||
// Create a new context for this test.
|
// Create a new context for this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
// Sentinel error to mark avoiding a test case.
|
// Sentinel error to mark avoiding a test case.
|
||||||
@ -175,7 +175,7 @@ func (suite *PollTestSuite) TestGetPollVoteBy() {
|
|||||||
|
|
||||||
func (suite *PollTestSuite) TestUpdatePoll() {
|
func (suite *PollTestSuite) TestUpdatePoll() {
|
||||||
// Create a new context for this test.
|
// Create a new context for this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
for _, poll := range suite.testPolls {
|
for _, poll := range suite.testPolls {
|
||||||
@ -200,7 +200,7 @@ func (suite *PollTestSuite) TestUpdatePoll() {
|
|||||||
|
|
||||||
func (suite *PollTestSuite) TestPutPoll() {
|
func (suite *PollTestSuite) TestPutPoll() {
|
||||||
// Create a new context for this test.
|
// Create a new context for this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
for _, poll := range suite.testPolls {
|
for _, poll := range suite.testPolls {
|
||||||
@ -220,7 +220,7 @@ func (suite *PollTestSuite) TestPutPoll() {
|
|||||||
|
|
||||||
func (suite *PollTestSuite) TestPutPollVote() {
|
func (suite *PollTestSuite) TestPutPollVote() {
|
||||||
// Create a new context for this test.
|
// Create a new context for this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
// randomChoices generates random vote choices in poll.
|
// randomChoices generates random vote choices in poll.
|
||||||
@ -271,7 +271,7 @@ func (suite *PollTestSuite) TestPutPollVote() {
|
|||||||
|
|
||||||
func (suite *PollTestSuite) TestDeletePoll() {
|
func (suite *PollTestSuite) TestDeletePoll() {
|
||||||
// Create a new context for this test.
|
// Create a new context for this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
for _, poll := range suite.testPolls {
|
for _, poll := range suite.testPolls {
|
||||||
@ -286,7 +286,7 @@ func (suite *PollTestSuite) TestDeletePoll() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *PollTestSuite) TestDeletePollVotesBy() {
|
func (suite *PollTestSuite) TestDeletePollVotesBy() {
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
for _, vote := range suite.testPollVotes {
|
for _, vote := range suite.testPollVotes {
|
||||||
@ -308,7 +308,7 @@ func (suite *PollTestSuite) TestDeletePollVotesBy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *PollTestSuite) TestDeletePollVotesByNoAccount() {
|
func (suite *PollTestSuite) TestDeletePollVotesByNoAccount() {
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
// Try to delete a poll by nonexisting account.
|
// Try to delete a poll by nonexisting account.
|
||||||
|
@ -39,7 +39,7 @@ func (suite *RelationshipTestSuite) TestGetBlockBy() {
|
|||||||
t := suite.T()
|
t := suite.T()
|
||||||
|
|
||||||
// Create a new context for this test.
|
// Create a new context for this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
// Sentinel error to mark avoiding a test case.
|
// Sentinel error to mark avoiding a test case.
|
||||||
@ -152,7 +152,7 @@ func (suite *RelationshipTestSuite) TestGetFollowBy() {
|
|||||||
t := suite.T()
|
t := suite.T()
|
||||||
|
|
||||||
// Create a new context for this test.
|
// Create a new context for this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
// Sentinel error to mark avoiding a test case.
|
// Sentinel error to mark avoiding a test case.
|
||||||
@ -264,7 +264,7 @@ func (suite *RelationshipTestSuite) TestGetFollowRequestBy() {
|
|||||||
t := suite.T()
|
t := suite.T()
|
||||||
|
|
||||||
// Create a new context for this test.
|
// Create a new context for this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
// Sentinel error to mark avoiding a test case.
|
// Sentinel error to mark avoiding a test case.
|
||||||
@ -374,7 +374,7 @@ func (suite *RelationshipTestSuite) TestGetFollowRequestBy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestIsBlocked() {
|
func (suite *RelationshipTestSuite) TestIsBlocked() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
account1 := suite.testAccounts["local_account_1"].ID
|
account1 := suite.testAccounts["local_account_1"].ID
|
||||||
account2 := suite.testAccounts["local_account_2"].ID
|
account2 := suite.testAccounts["local_account_2"].ID
|
||||||
@ -418,7 +418,7 @@ func (suite *RelationshipTestSuite) TestIsBlocked() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestDeleteBlockByID() {
|
func (suite *RelationshipTestSuite) TestDeleteBlockByID() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
// put a block in first
|
// put a block in first
|
||||||
account1 := suite.testAccounts["local_account_1"].ID
|
account1 := suite.testAccounts["local_account_1"].ID
|
||||||
@ -449,7 +449,7 @@ func (suite *RelationshipTestSuite) TestDeleteBlockByID() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestDeleteBlockByURI() {
|
func (suite *RelationshipTestSuite) TestDeleteBlockByURI() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
// put a block in first
|
// put a block in first
|
||||||
account1 := suite.testAccounts["local_account_1"].ID
|
account1 := suite.testAccounts["local_account_1"].ID
|
||||||
@ -480,7 +480,7 @@ func (suite *RelationshipTestSuite) TestDeleteBlockByURI() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestDeleteAccountBlocks() {
|
func (suite *RelationshipTestSuite) TestDeleteAccountBlocks() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
// put a block in first
|
// put a block in first
|
||||||
account1 := suite.testAccounts["local_account_1"].ID
|
account1 := suite.testAccounts["local_account_1"].ID
|
||||||
@ -511,7 +511,7 @@ func (suite *RelationshipTestSuite) TestDeleteAccountBlocks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestDeleteAccountMutes() {
|
func (suite *RelationshipTestSuite) TestDeleteAccountMutes() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
// Add a mute.
|
// Add a mute.
|
||||||
accountID1 := suite.testAccounts["local_account_1"].ID
|
accountID1 := suite.testAccounts["local_account_1"].ID
|
||||||
@ -551,7 +551,7 @@ func (suite *RelationshipTestSuite) TestGetRelationship() {
|
|||||||
requestingAccount := suite.testAccounts["local_account_1"]
|
requestingAccount := suite.testAccounts["local_account_1"]
|
||||||
targetAccount := suite.testAccounts["admin_account"]
|
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.NoError(err)
|
||||||
suite.NotNil(relationship)
|
suite.NotNil(relationship)
|
||||||
|
|
||||||
@ -572,7 +572,7 @@ func (suite *RelationshipTestSuite) TestGetRelationship() {
|
|||||||
func (suite *RelationshipTestSuite) TestIsFollowingYes() {
|
func (suite *RelationshipTestSuite) TestIsFollowingYes() {
|
||||||
requestingAccount := suite.testAccounts["local_account_1"]
|
requestingAccount := suite.testAccounts["local_account_1"]
|
||||||
targetAccount := suite.testAccounts["admin_account"]
|
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.NoError(err)
|
||||||
suite.True(isFollowing)
|
suite.True(isFollowing)
|
||||||
}
|
}
|
||||||
@ -580,7 +580,7 @@ func (suite *RelationshipTestSuite) TestIsFollowingYes() {
|
|||||||
func (suite *RelationshipTestSuite) TestIsFollowingNo() {
|
func (suite *RelationshipTestSuite) TestIsFollowingNo() {
|
||||||
requestingAccount := suite.testAccounts["admin_account"]
|
requestingAccount := suite.testAccounts["admin_account"]
|
||||||
targetAccount := suite.testAccounts["local_account_2"]
|
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.NoError(err)
|
||||||
suite.False(isFollowing)
|
suite.False(isFollowing)
|
||||||
}
|
}
|
||||||
@ -588,7 +588,7 @@ func (suite *RelationshipTestSuite) TestIsFollowingNo() {
|
|||||||
func (suite *RelationshipTestSuite) TestIsMutualFollowing() {
|
func (suite *RelationshipTestSuite) TestIsMutualFollowing() {
|
||||||
requestingAccount := suite.testAccounts["local_account_1"]
|
requestingAccount := suite.testAccounts["local_account_1"]
|
||||||
targetAccount := suite.testAccounts["admin_account"]
|
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.NoError(err)
|
||||||
suite.True(isMutualFollowing)
|
suite.True(isMutualFollowing)
|
||||||
}
|
}
|
||||||
@ -596,13 +596,13 @@ func (suite *RelationshipTestSuite) TestIsMutualFollowing() {
|
|||||||
func (suite *RelationshipTestSuite) TestIsMutualFollowingNo() {
|
func (suite *RelationshipTestSuite) TestIsMutualFollowingNo() {
|
||||||
requestingAccount := suite.testAccounts["local_account_1"]
|
requestingAccount := suite.testAccounts["local_account_1"]
|
||||||
targetAccount := suite.testAccounts["local_account_2"]
|
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.NoError(err)
|
||||||
suite.True(isMutualFollowing)
|
suite.True(isMutualFollowing)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestAcceptFollowRequestOK() {
|
func (suite *RelationshipTestSuite) TestAcceptFollowRequestOK() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
account := suite.testAccounts["admin_account"]
|
account := suite.testAccounts["admin_account"]
|
||||||
targetAccount := suite.testAccounts["local_account_2"]
|
targetAccount := suite.testAccounts["local_account_2"]
|
||||||
|
|
||||||
@ -672,7 +672,7 @@ func (suite *RelationshipTestSuite) TestAcceptFollowRequestOK() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestAcceptFollowRequestNoNotification() {
|
func (suite *RelationshipTestSuite) TestAcceptFollowRequestNoNotification() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
account := suite.testAccounts["admin_account"]
|
account := suite.testAccounts["admin_account"]
|
||||||
targetAccount := suite.testAccounts["local_account_2"]
|
targetAccount := suite.testAccounts["local_account_2"]
|
||||||
|
|
||||||
@ -697,7 +697,7 @@ func (suite *RelationshipTestSuite) TestAcceptFollowRequestNoNotification() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestAcceptFollowRequestNotExisting() {
|
func (suite *RelationshipTestSuite) TestAcceptFollowRequestNotExisting() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
account := suite.testAccounts["admin_account"]
|
account := suite.testAccounts["admin_account"]
|
||||||
targetAccount := suite.testAccounts["local_account_2"]
|
targetAccount := suite.testAccounts["local_account_2"]
|
||||||
|
|
||||||
@ -707,7 +707,7 @@ func (suite *RelationshipTestSuite) TestAcceptFollowRequestNotExisting() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestAcceptFollowRequestFollowAlreadyExists() {
|
func (suite *RelationshipTestSuite) TestAcceptFollowRequestFollowAlreadyExists() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
account := suite.testAccounts["local_account_1"]
|
account := suite.testAccounts["local_account_1"]
|
||||||
targetAccount := suite.testAccounts["admin_account"]
|
targetAccount := suite.testAccounts["admin_account"]
|
||||||
|
|
||||||
@ -738,7 +738,7 @@ func (suite *RelationshipTestSuite) TestAcceptFollowRequestFollowAlreadyExists()
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestRejectFollowRequestOK() {
|
func (suite *RelationshipTestSuite) TestRejectFollowRequestOK() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
account := suite.testAccounts["admin_account"]
|
account := suite.testAccounts["admin_account"]
|
||||||
targetAccount := suite.testAccounts["local_account_2"]
|
targetAccount := suite.testAccounts["local_account_2"]
|
||||||
|
|
||||||
@ -774,7 +774,7 @@ func (suite *RelationshipTestSuite) TestRejectFollowRequestOK() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestRejectFollowRequestNotExisting() {
|
func (suite *RelationshipTestSuite) TestRejectFollowRequestNotExisting() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
account := suite.testAccounts["admin_account"]
|
account := suite.testAccounts["admin_account"]
|
||||||
targetAccount := suite.testAccounts["local_account_2"]
|
targetAccount := suite.testAccounts["local_account_2"]
|
||||||
|
|
||||||
@ -783,7 +783,7 @@ func (suite *RelationshipTestSuite) TestRejectFollowRequestNotExisting() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestGetAccountFollowRequests() {
|
func (suite *RelationshipTestSuite) TestGetAccountFollowRequests() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
account := suite.testAccounts["admin_account"]
|
account := suite.testAccounts["admin_account"]
|
||||||
targetAccount := suite.testAccounts["local_account_2"]
|
targetAccount := suite.testAccounts["local_account_2"]
|
||||||
|
|
||||||
@ -805,14 +805,14 @@ func (suite *RelationshipTestSuite) TestGetAccountFollowRequests() {
|
|||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestGetAccountFollows() {
|
func (suite *RelationshipTestSuite) TestGetAccountFollows() {
|
||||||
account := suite.testAccounts["local_account_1"]
|
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.NoError(err)
|
||||||
suite.Len(follows, 2)
|
suite.Len(follows, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestGetAccountFollowers() {
|
func (suite *RelationshipTestSuite) TestGetAccountFollowers() {
|
||||||
account := suite.testAccounts["local_account_1"]
|
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.NoError(err)
|
||||||
suite.Len(follows, 2)
|
suite.Len(follows, 2)
|
||||||
}
|
}
|
||||||
@ -821,25 +821,25 @@ func (suite *RelationshipTestSuite) TestUnfollowExisting() {
|
|||||||
originAccount := suite.testAccounts["local_account_1"]
|
originAccount := suite.testAccounts["local_account_1"]
|
||||||
targetAccount := suite.testAccounts["admin_account"]
|
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.NoError(err)
|
||||||
suite.NotNil(follow)
|
suite.NotNil(follow)
|
||||||
followID := follow.ID
|
followID := follow.ID
|
||||||
|
|
||||||
// We should have lists that this follow is a part of.
|
// 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.NoError(err)
|
||||||
suite.NotEmpty(lists)
|
suite.NotEmpty(lists)
|
||||||
|
|
||||||
err = suite.db.DeleteFollowByID(context.Background(), followID)
|
err = suite.db.DeleteFollowByID(suite.T().Context(), followID)
|
||||||
suite.NoError(err)
|
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.EqualError(err, db.ErrNoEntries.Error())
|
||||||
suite.Nil(follow)
|
suite.Nil(follow)
|
||||||
|
|
||||||
// Lists containing this follow should return empty too.
|
// 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.NoError(err)
|
||||||
suite.Empty(lists)
|
suite.Empty(lists)
|
||||||
}
|
}
|
||||||
@ -848,13 +848,13 @@ func (suite *RelationshipTestSuite) TestGetFollowNotExisting() {
|
|||||||
originAccount := suite.testAccounts["local_account_1"]
|
originAccount := suite.testAccounts["local_account_1"]
|
||||||
targetAccountID := "01GTVD9N484CZ6AM90PGGNY7GQ"
|
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.EqualError(err, db.ErrNoEntries.Error())
|
||||||
suite.Nil(follow)
|
suite.Nil(follow)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestDeleteFollow() {
|
func (suite *RelationshipTestSuite) TestDeleteFollow() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
originAccount := suite.testAccounts["local_account_1"]
|
originAccount := suite.testAccounts["local_account_1"]
|
||||||
targetAccount := suite.testAccounts["admin_account"]
|
targetAccount := suite.testAccounts["admin_account"]
|
||||||
|
|
||||||
@ -867,7 +867,7 @@ func (suite *RelationshipTestSuite) TestDeleteFollow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestUnfollowRequestExisting() {
|
func (suite *RelationshipTestSuite) TestUnfollowRequestExisting() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
originAccount := suite.testAccounts["admin_account"]
|
originAccount := suite.testAccounts["admin_account"]
|
||||||
targetAccount := suite.testAccounts["local_account_2"]
|
targetAccount := suite.testAccounts["local_account_2"]
|
||||||
|
|
||||||
@ -882,14 +882,14 @@ func (suite *RelationshipTestSuite) TestUnfollowRequestExisting() {
|
|||||||
suite.FailNow(err.Error())
|
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.NoError(err)
|
||||||
suite.NotNil(followRequest)
|
suite.NotNil(followRequest)
|
||||||
|
|
||||||
err = suite.db.DeleteFollowRequestByID(context.Background(), followRequest.ID)
|
err = suite.db.DeleteFollowRequestByID(suite.T().Context(), followRequest.ID)
|
||||||
suite.NoError(err)
|
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.EqualError(err, db.ErrNoEntries.Error())
|
||||||
suite.Nil(followRequest)
|
suite.Nil(followRequest)
|
||||||
}
|
}
|
||||||
@ -898,13 +898,13 @@ func (suite *RelationshipTestSuite) TestUnfollowRequestNotExisting() {
|
|||||||
originAccount := suite.testAccounts["local_account_1"]
|
originAccount := suite.testAccounts["local_account_1"]
|
||||||
targetAccountID := "01GTVD9N484CZ6AM90PGGNY7GQ"
|
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.EqualError(err, db.ErrNoEntries.Error())
|
||||||
suite.Nil(followRequest)
|
suite.Nil(followRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestUpdateFollow() {
|
func (suite *RelationshipTestSuite) TestUpdateFollow() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
follow := >smodel.Follow{}
|
follow := >smodel.Follow{}
|
||||||
*follow = *suite.testFollows["local_account_1_admin_account"]
|
*follow = *suite.testFollows["local_account_1_admin_account"]
|
||||||
@ -930,7 +930,7 @@ func (suite *RelationshipTestSuite) TestUpdateFollow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestGetNote() {
|
func (suite *RelationshipTestSuite) TestGetNote() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
// Retrieve a fixture note
|
// Retrieve a fixture note
|
||||||
account1 := suite.testAccounts["local_account_1"].ID
|
account1 := suite.testAccounts["local_account_1"].ID
|
||||||
@ -944,7 +944,7 @@ func (suite *RelationshipTestSuite) TestGetNote() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RelationshipTestSuite) TestPutNote() {
|
func (suite *RelationshipTestSuite) TestPutNote() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
// put a note in
|
// put a note in
|
||||||
account1 := suite.testAccounts["local_account_1"].ID
|
account1 := suite.testAccounts["local_account_1"].ID
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.superseriousbusiness.org/gotosocial/internal/db"
|
"code.superseriousbusiness.org/gotosocial/internal/db"
|
||||||
@ -35,7 +34,7 @@ type ReportTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ReportTestSuite) TestGetReportByID() {
|
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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -49,7 +48,7 @@ func (suite *ReportTestSuite) TestGetReportByID() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ReportTestSuite) TestGetReportByURI() {
|
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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -64,7 +63,7 @@ func (suite *ReportTestSuite) TestGetReportByURI() {
|
|||||||
|
|
||||||
func (suite *ReportTestSuite) TestGetAllReports() {
|
func (suite *ReportTestSuite) TestGetAllReports() {
|
||||||
reports, err := suite.db.GetReports(
|
reports, err := suite.db.GetReports(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
nil,
|
nil,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
@ -77,7 +76,7 @@ func (suite *ReportTestSuite) TestGetAllReports() {
|
|||||||
func (suite *ReportTestSuite) TestReportPagingDown() {
|
func (suite *ReportTestSuite) TestReportPagingDown() {
|
||||||
// Get one from the top.
|
// Get one from the top.
|
||||||
reports1, err := suite.db.GetReports(
|
reports1, err := suite.db.GetReports(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
nil,
|
nil,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
@ -95,7 +94,7 @@ func (suite *ReportTestSuite) TestReportPagingDown() {
|
|||||||
|
|
||||||
// Use this one to page down.
|
// Use this one to page down.
|
||||||
reports2, err := suite.db.GetReports(
|
reports2, err := suite.db.GetReports(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
nil,
|
nil,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
@ -118,7 +117,7 @@ func (suite *ReportTestSuite) TestReportPagingDown() {
|
|||||||
func (suite *ReportTestSuite) TestReportPagingUp() {
|
func (suite *ReportTestSuite) TestReportPagingUp() {
|
||||||
// Get one from the bottom.
|
// Get one from the bottom.
|
||||||
reports1, err := suite.db.GetReports(
|
reports1, err := suite.db.GetReports(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
nil,
|
nil,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
@ -137,7 +136,7 @@ func (suite *ReportTestSuite) TestReportPagingUp() {
|
|||||||
|
|
||||||
// Use this one to page up.
|
// Use this one to page up.
|
||||||
reports2, err := suite.db.GetReports(
|
reports2, err := suite.db.GetReports(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
nil,
|
nil,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
@ -160,7 +159,7 @@ func (suite *ReportTestSuite) TestReportPagingUp() {
|
|||||||
func (suite *ReportTestSuite) TestGetAllReportsByAccountID() {
|
func (suite *ReportTestSuite) TestGetAllReportsByAccountID() {
|
||||||
accountID := suite.testAccounts["local_account_2"].ID
|
accountID := suite.testAccounts["local_account_2"].ID
|
||||||
reports, err := suite.db.GetReports(
|
reports, err := suite.db.GetReports(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
nil,
|
nil,
|
||||||
accountID,
|
accountID,
|
||||||
"",
|
"",
|
||||||
@ -174,7 +173,7 @@ func (suite *ReportTestSuite) TestGetAllReportsByAccountID() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ReportTestSuite) TestPutReport() {
|
func (suite *ReportTestSuite) TestPutReport() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
reportID := "01GP3ECY8QJD8DBJSS8B1CR0AX"
|
reportID := "01GP3ECY8QJD8DBJSS8B1CR0AX"
|
||||||
report := >smodel.Report{
|
report := >smodel.Report{
|
||||||
@ -194,7 +193,7 @@ func (suite *ReportTestSuite) TestPutReport() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ReportTestSuite) TestUpdateReport() {
|
func (suite *ReportTestSuite) TestUpdateReport() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
report := >smodel.Report{}
|
report := >smodel.Report{}
|
||||||
*report = *suite.testReports["local_account_2_report_remote_account_1"]
|
*report = *suite.testReports["local_account_2_report_remote_account_1"]
|
||||||
@ -220,7 +219,7 @@ func (suite *ReportTestSuite) TestUpdateReport() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ReportTestSuite) TestUpdateReportAllColumns() {
|
func (suite *ReportTestSuite) TestUpdateReportAllColumns() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
report := >smodel.Report{}
|
report := >smodel.Report{}
|
||||||
*report = *suite.testReports["local_account_2_report_remote_account_1"]
|
*report = *suite.testReports["local_account_2_report_remote_account_1"]
|
||||||
@ -246,11 +245,11 @@ func (suite *ReportTestSuite) TestUpdateReportAllColumns() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ReportTestSuite) TestDeleteReport() {
|
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())
|
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.ErrorIs(err, db.ErrNoEntries)
|
||||||
suite.Nil(report)
|
suite.Nil(report)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.superseriousbusiness.org/gotosocial/internal/db"
|
"code.superseriousbusiness.org/gotosocial/internal/db"
|
||||||
@ -37,7 +36,7 @@ func (suite *RuleTestSuite) TestPutRuleWithExisting() {
|
|||||||
Text: "Pee pee poo poo",
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +45,7 @@ func (suite *RuleTestSuite) TestPutRuleWithExisting() {
|
|||||||
|
|
||||||
func (suite *RuleTestSuite) TestPutRuleNoExisting() {
|
func (suite *RuleTestSuite) TestPutRuleNoExisting() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
whereAny = []db.Where{{Key: "id", Value: "", Not: true}}
|
whereAny = []db.Where{{Key: "id", Value: "", Not: true}}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -74,7 +73,7 @@ func (suite *RuleTestSuite) TestPutRuleNoExisting() {
|
|||||||
|
|
||||||
func (suite *RuleTestSuite) TestGetRuleByID() {
|
func (suite *RuleTestSuite) TestGetRuleByID() {
|
||||||
rule, err := suite.state.DB.GetRuleByID(
|
rule, err := suite.state.DB.GetRuleByID(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
suite.testRules["rule1"].ID,
|
suite.testRules["rule1"].ID,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -91,7 +90,7 @@ func (suite *RuleTestSuite) TestGetRulesByID() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rules, err := suite.state.DB.GetRulesByIDs(
|
rules, err := suite.state.DB.GetRulesByIDs(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
ruleIDs,
|
ruleIDs,
|
||||||
)
|
)
|
||||||
if err != nil {
|
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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.superseriousbusiness.org/gotosocial/internal/db"
|
"code.superseriousbusiness.org/gotosocial/internal/db"
|
||||||
@ -32,7 +31,7 @@ type SearchTestSuite struct {
|
|||||||
func (suite *SearchTestSuite) TestSearchAccountsTurtleAny() {
|
func (suite *SearchTestSuite) TestSearchAccountsTurtleAny() {
|
||||||
testAccount := suite.testAccounts["local_account_1"]
|
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.NoError(err)
|
||||||
suite.Len(accounts, 1)
|
suite.Len(accounts, 1)
|
||||||
}
|
}
|
||||||
@ -41,7 +40,7 @@ func (suite *SearchTestSuite) TestSearchAccounts1HappyWithPrefix() {
|
|||||||
testAccount := suite.testAccounts["local_account_1"]
|
testAccount := suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
// Query will just look for usernames that start with "1happy".
|
// 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.NoError(err)
|
||||||
suite.Len(accounts, 1)
|
suite.Len(accounts, 1)
|
||||||
}
|
}
|
||||||
@ -50,7 +49,7 @@ func (suite *SearchTestSuite) TestSearchAccounts1HappyWithPrefixUpper() {
|
|||||||
testAccount := suite.testAccounts["local_account_1"]
|
testAccount := suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
// Query will just look for usernames that start with "1HAPPY".
|
// 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.NoError(err)
|
||||||
suite.Len(accounts, 1)
|
suite.Len(accounts, 1)
|
||||||
}
|
}
|
||||||
@ -59,7 +58,7 @@ func (suite *SearchTestSuite) TestSearchAccounts1HappyNoPrefix() {
|
|||||||
testAccount := suite.testAccounts["local_account_1"]
|
testAccount := suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
// Query will do the full coalesce.
|
// 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.NoError(err)
|
||||||
suite.Len(accounts, 1)
|
suite.Len(accounts, 1)
|
||||||
}
|
}
|
||||||
@ -67,7 +66,7 @@ func (suite *SearchTestSuite) TestSearchAccounts1HappyNoPrefix() {
|
|||||||
func (suite *SearchTestSuite) TestSearchAccountsTurtleFollowing() {
|
func (suite *SearchTestSuite) TestSearchAccountsTurtleFollowing() {
|
||||||
testAccount := suite.testAccounts["local_account_1"]
|
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.NoError(err)
|
||||||
suite.Len(accounts, 1)
|
suite.Len(accounts, 1)
|
||||||
}
|
}
|
||||||
@ -75,7 +74,7 @@ func (suite *SearchTestSuite) TestSearchAccountsTurtleFollowing() {
|
|||||||
func (suite *SearchTestSuite) TestSearchAccountsTurtleFollowingUpper() {
|
func (suite *SearchTestSuite) TestSearchAccountsTurtleFollowingUpper() {
|
||||||
testAccount := suite.testAccounts["local_account_1"]
|
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.NoError(err)
|
||||||
suite.Len(accounts, 1)
|
suite.Len(accounts, 1)
|
||||||
}
|
}
|
||||||
@ -83,7 +82,7 @@ func (suite *SearchTestSuite) TestSearchAccountsTurtleFollowingUpper() {
|
|||||||
func (suite *SearchTestSuite) TestSearchAccountsPostFollowing() {
|
func (suite *SearchTestSuite) TestSearchAccountsPostFollowing() {
|
||||||
testAccount := suite.testAccounts["local_account_1"]
|
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.NoError(err)
|
||||||
suite.Len(accounts, 1)
|
suite.Len(accounts, 1)
|
||||||
}
|
}
|
||||||
@ -91,7 +90,7 @@ func (suite *SearchTestSuite) TestSearchAccountsPostFollowing() {
|
|||||||
func (suite *SearchTestSuite) TestSearchAccountsPostAny() {
|
func (suite *SearchTestSuite) TestSearchAccountsPostAny() {
|
||||||
testAccount := suite.testAccounts["local_account_1"]
|
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.NoError(err, db.ErrNoEntries)
|
||||||
suite.Empty(accounts)
|
suite.Empty(accounts)
|
||||||
}
|
}
|
||||||
@ -99,7 +98,7 @@ func (suite *SearchTestSuite) TestSearchAccountsPostAny() {
|
|||||||
func (suite *SearchTestSuite) TestSearchAccountsFossAny() {
|
func (suite *SearchTestSuite) TestSearchAccountsFossAny() {
|
||||||
testAccount := suite.testAccounts["local_account_1"]
|
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.NoError(err)
|
||||||
suite.Len(accounts, 1)
|
suite.Len(accounts, 1)
|
||||||
}
|
}
|
||||||
@ -107,7 +106,7 @@ func (suite *SearchTestSuite) TestSearchAccountsFossAny() {
|
|||||||
func (suite *SearchTestSuite) TestSearchStatuses() {
|
func (suite *SearchTestSuite) TestSearchStatuses() {
|
||||||
testAccount := suite.testAccounts["local_account_1"]
|
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.NoError(err)
|
||||||
suite.Len(statuses, 1)
|
suite.Len(statuses, 1)
|
||||||
}
|
}
|
||||||
@ -116,7 +115,7 @@ func (suite *SearchTestSuite) TestSearchStatusesFromAccount() {
|
|||||||
testAccount := suite.testAccounts["local_account_1"]
|
testAccount := suite.testAccounts["local_account_1"]
|
||||||
fromAccount := suite.testAccounts["local_account_2"]
|
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)
|
suite.NoError(err)
|
||||||
if suite.Len(statuses, 1) {
|
if suite.Len(statuses, 1) {
|
||||||
suite.Equal(fromAccount.ID, statuses[0].AccountID)
|
suite.Equal(fromAccount.ID, statuses[0].AccountID)
|
||||||
@ -125,17 +124,17 @@ func (suite *SearchTestSuite) TestSearchStatusesFromAccount() {
|
|||||||
|
|
||||||
func (suite *SearchTestSuite) TestSearchTags() {
|
func (suite *SearchTestSuite) TestSearchTags() {
|
||||||
// Search with full tag string.
|
// 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.NoError(err)
|
||||||
suite.Len(tags, 1)
|
suite.Len(tags, 1)
|
||||||
|
|
||||||
// Search with partial tag string.
|
// 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.NoError(err)
|
||||||
suite.Len(tags, 1)
|
suite.Len(tags, 1)
|
||||||
|
|
||||||
// Search with end of tag string.
|
// 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.NoError(err)
|
||||||
suite.Len(tags, 0)
|
suite.Len(tags, 0)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
@ -29,7 +28,7 @@ type SessionTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *SessionTestSuite) TestGetSession() {
|
func (suite *SessionTestSuite) TestGetSession() {
|
||||||
session, err := suite.db.GetSession(context.Background())
|
session, err := suite.db.GetSession(suite.T().Context())
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.NotNil(session)
|
suite.NotNil(session)
|
||||||
suite.NotEmpty(session.Auth)
|
suite.NotEmpty(session.Auth)
|
||||||
@ -37,7 +36,7 @@ func (suite *SessionTestSuite) TestGetSession() {
|
|||||||
suite.NotEmpty(session.ID)
|
suite.NotEmpty(session.ID)
|
||||||
|
|
||||||
// the same session should be returned with consecutive selects
|
// 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.NoError(err)
|
||||||
suite.NotNil(session2)
|
suite.NotNil(session2)
|
||||||
suite.Equal(session.Auth, session2.Auth)
|
suite.Equal(session.Auth, session2.Auth)
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -32,7 +31,7 @@ type StatusTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *StatusTestSuite) TestGetStatusByID() {
|
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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -52,7 +51,7 @@ func (suite *StatusTestSuite) TestGetStatusesByIDs() {
|
|||||||
suite.testStatuses["local_account_2_status_3"].ID,
|
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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -83,7 +82,7 @@ func (suite *StatusTestSuite) TestGetStatusesByIDs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *StatusTestSuite) TestGetStatusByURI() {
|
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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -98,7 +97,7 @@ func (suite *StatusTestSuite) TestGetStatusByURI() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *StatusTestSuite) TestGetStatusWithExtras() {
|
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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -112,7 +111,7 @@ func (suite *StatusTestSuite) TestGetStatusWithExtras() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *StatusTestSuite) TestGetStatusWithMention() {
|
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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -135,14 +134,14 @@ func (suite *StatusTestSuite) TestGetStatusWithMention() {
|
|||||||
/*
|
/*
|
||||||
func (suite *StatusTestSuite) TestGetStatusTwice() {
|
func (suite *StatusTestSuite) TestGetStatusTwice() {
|
||||||
before1 := time.Now()
|
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)
|
suite.NoError(err)
|
||||||
after1 := time.Now()
|
after1 := time.Now()
|
||||||
duration1 := after1.Sub(before1)
|
duration1 := after1.Sub(before1)
|
||||||
fmt.Println(duration1.Microseconds())
|
fmt.Println(duration1.Microseconds())
|
||||||
|
|
||||||
before2 := time.Now()
|
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)
|
suite.NoError(err)
|
||||||
after2 := time.Now()
|
after2 := time.Now()
|
||||||
duration2 := after2.Sub(before2)
|
duration2 := after2.Sub(before2)
|
||||||
@ -155,7 +154,7 @@ func (suite *StatusTestSuite) TestGetStatusTwice() {
|
|||||||
|
|
||||||
func (suite *StatusTestSuite) TestGetStatusReplies() {
|
func (suite *StatusTestSuite) TestGetStatusReplies() {
|
||||||
targetStatus := suite.testStatuses["local_account_1_status_1"]
|
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.NoError(err)
|
||||||
suite.Len(children, 2)
|
suite.Len(children, 2)
|
||||||
for _, c := range children {
|
for _, c := range children {
|
||||||
@ -167,7 +166,7 @@ func (suite *StatusTestSuite) TestGetStatusReplies() {
|
|||||||
|
|
||||||
func (suite *StatusTestSuite) TestGetStatusChildren() {
|
func (suite *StatusTestSuite) TestGetStatusChildren() {
|
||||||
targetStatus := suite.testStatuses["local_account_1_status_1"]
|
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.NoError(err)
|
||||||
suite.Len(children, 3)
|
suite.Len(children, 3)
|
||||||
}
|
}
|
||||||
@ -177,10 +176,10 @@ func (suite *StatusTestSuite) TestDeleteStatus() {
|
|||||||
targetStatus := >smodel.Status{}
|
targetStatus := >smodel.Status{}
|
||||||
*targetStatus = *suite.testStatuses["admin_account_status_1"]
|
*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)
|
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)
|
suite.ErrorIs(err, db.ErrNoEntries)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,16 +200,16 @@ func (suite *StatusTestSuite) TestUpdateStatus() {
|
|||||||
|
|
||||||
targetStatus.PinnedAt = time.Time{}
|
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)
|
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.NoError(err)
|
||||||
suite.True(updated.PinnedAt.IsZero())
|
suite.True(updated.PinnedAt.IsZero())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *StatusTestSuite) TestPutPopulatedStatus() {
|
func (suite *StatusTestSuite) TestPutPopulatedStatus() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
targetStatus := >smodel.Status{}
|
targetStatus := >smodel.Status{}
|
||||||
*targetStatus = *suite.testStatuses["admin_account_status_1"]
|
*targetStatus = *suite.testStatuses["admin_account_status_1"]
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -33,7 +32,7 @@ type StatusBookmarkTestSuite struct {
|
|||||||
|
|
||||||
func (suite *StatusBookmarkTestSuite) TestGetStatusBookmarkOK() {
|
func (suite *StatusBookmarkTestSuite) TestGetStatusBookmarkOK() {
|
||||||
testBookmark := suite.testBookmarks["local_account_1_admin_account_status_1"]
|
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.NoError(err)
|
||||||
suite.Equal(testBookmark.ID, bookmark.ID)
|
suite.Equal(testBookmark.ID, bookmark.ID)
|
||||||
suite.Equal(testBookmark.AccountID, bookmark.AccountID)
|
suite.Equal(testBookmark.AccountID, bookmark.AccountID)
|
||||||
@ -41,7 +40,7 @@ func (suite *StatusBookmarkTestSuite) TestGetStatusBookmarkOK() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *StatusBookmarkTestSuite) TestGetStatusBookmarkNonexisting() {
|
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.Nil(bookmark)
|
||||||
suite.ErrorIs(err, db.ErrNoEntries)
|
suite.ErrorIs(err, db.ErrNoEntries)
|
||||||
}
|
}
|
||||||
@ -49,7 +48,7 @@ func (suite *StatusBookmarkTestSuite) TestGetStatusBookmarkNonexisting() {
|
|||||||
func (suite *StatusBookmarkTestSuite) IsStatusBookmarked() {
|
func (suite *StatusBookmarkTestSuite) IsStatusBookmarked() {
|
||||||
for _, bookmark := range suite.testBookmarks {
|
for _, bookmark := range suite.testBookmarks {
|
||||||
ok, err := suite.db.IsStatusBookmarked(
|
ok, err := suite.db.IsStatusBookmarked(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
bookmark.StatusID,
|
bookmark.StatusID,
|
||||||
)
|
)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
@ -60,12 +59,12 @@ func (suite *StatusBookmarkTestSuite) IsStatusBookmarked() {
|
|||||||
func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarksOriginatingFromAccount() {
|
func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarksOriginatingFromAccount() {
|
||||||
testAccount := suite.testAccounts["local_account_1"]
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
bookmarks := []*gtsmodel.StatusBookmark{}
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,12 +78,12 @@ func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarksOriginatingFromAc
|
|||||||
func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarksTargetingAccount() {
|
func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarksTargetingAccount() {
|
||||||
testAccount := suite.testAccounts["local_account_1"]
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
bookmarks := []*gtsmodel.StatusBookmark{}
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,12 +97,12 @@ func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarksTargetingAccount(
|
|||||||
func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarksTargetingStatus() {
|
func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarksTargetingStatus() {
|
||||||
testStatus := suite.testStatuses["local_account_1_status_1"]
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
bookmarks := []*gtsmodel.StatusBookmark{}
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +115,7 @@ func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarksTargetingStatus()
|
|||||||
|
|
||||||
func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarkByID() {
|
func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarkByID() {
|
||||||
testBookmark := suite.testBookmarks["local_account_1_admin_account_status_1"]
|
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 {
|
if err := suite.db.DeleteStatusBookmarkByID(ctx, testBookmark.ID); err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
@ -128,7 +127,7 @@ func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarkByID() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarkByIDNonExisting() {
|
func (suite *StatusBookmarkTestSuite) TestDeleteStatusBookmarkByIDNonExisting() {
|
||||||
err := suite.db.DeleteStatusBookmarkByID(context.Background(), "01GVAV715K6Y2SG9ZKS9ZA8G7G")
|
err := suite.db.DeleteStatusBookmarkByID(suite.T().Context(), "01GVAV715K6Y2SG9ZKS9ZA8G7G")
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ func (suite *StatusEditTestSuite) TestGetStatusEditBy() {
|
|||||||
t := suite.T()
|
t := suite.T()
|
||||||
|
|
||||||
// Create a new context for this test.
|
// Create a new context for this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
// Sentinel error to mark avoiding a test case.
|
// Sentinel error to mark avoiding a test case.
|
||||||
@ -78,7 +78,7 @@ func (suite *StatusEditTestSuite) TestGetStatusEditsByIDs() {
|
|||||||
t := suite.T()
|
t := suite.T()
|
||||||
|
|
||||||
// Create a new context for this test.
|
// Create a new context for this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
// editsByStatus returns all test edits by the given status with ID.
|
// editsByStatus returns all test edits by the given status with ID.
|
||||||
@ -115,7 +115,7 @@ func (suite *StatusEditTestSuite) TestGetStatusEditsByIDs() {
|
|||||||
|
|
||||||
func (suite *StatusEditTestSuite) TestDeleteStatusEdits() {
|
func (suite *StatusEditTestSuite) TestDeleteStatusEdits() {
|
||||||
// Create a new context for this test.
|
// Create a new context for this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
for _, status := range suite.testStatuses {
|
for _, status := range suite.testStatuses {
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -34,7 +33,7 @@ type StatusFaveTestSuite struct {
|
|||||||
func (suite *StatusFaveTestSuite) TestGetStatusFaves() {
|
func (suite *StatusFaveTestSuite) TestGetStatusFaves() {
|
||||||
testStatus := suite.testStatuses["admin_account_status_1"]
|
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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -50,7 +49,7 @@ func (suite *StatusFaveTestSuite) TestGetStatusFaves() {
|
|||||||
func (suite *StatusFaveTestSuite) TestGetStatusFavesNone() {
|
func (suite *StatusFaveTestSuite) TestGetStatusFavesNone() {
|
||||||
testStatus := suite.testStatuses["admin_account_status_4"]
|
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 {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
@ -62,7 +61,7 @@ func (suite *StatusFaveTestSuite) TestGetStatusFaveByAccountID() {
|
|||||||
testAccount := suite.testAccounts["local_account_1"]
|
testAccount := suite.testAccounts["local_account_1"]
|
||||||
testStatus := suite.testStatuses["admin_account_status_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.NoError(err)
|
||||||
suite.NotNil(fave)
|
suite.NotNil(fave)
|
||||||
}
|
}
|
||||||
@ -70,12 +69,12 @@ func (suite *StatusFaveTestSuite) TestGetStatusFaveByAccountID() {
|
|||||||
func (suite *StatusFaveTestSuite) TestDeleteStatusFavesOriginatingFromAccount() {
|
func (suite *StatusFaveTestSuite) TestDeleteStatusFavesOriginatingFromAccount() {
|
||||||
testAccount := suite.testAccounts["local_account_1"]
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
faves := []*gtsmodel.StatusFave{}
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,12 +88,12 @@ func (suite *StatusFaveTestSuite) TestDeleteStatusFavesOriginatingFromAccount()
|
|||||||
func (suite *StatusFaveTestSuite) TestDeleteStatusFavesTargetingAccount() {
|
func (suite *StatusFaveTestSuite) TestDeleteStatusFavesTargetingAccount() {
|
||||||
testAccount := suite.testAccounts["local_account_1"]
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
faves := []*gtsmodel.StatusFave{}
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,12 +107,12 @@ func (suite *StatusFaveTestSuite) TestDeleteStatusFavesTargetingAccount() {
|
|||||||
func (suite *StatusFaveTestSuite) TestDeleteStatusFavesTargetingStatus() {
|
func (suite *StatusFaveTestSuite) TestDeleteStatusFavesTargetingStatus() {
|
||||||
testStatus := suite.testStatuses["local_account_1_status_1"]
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
faves := []*gtsmodel.StatusFave{}
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +125,7 @@ func (suite *StatusFaveTestSuite) TestDeleteStatusFavesTargetingStatus() {
|
|||||||
|
|
||||||
func (suite *StatusFaveTestSuite) TestDeleteStatusFave() {
|
func (suite *StatusFaveTestSuite) TestDeleteStatusFave() {
|
||||||
testFave := suite.testFaves["local_account_1_admin_account_status_1"]
|
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 {
|
if err := suite.db.DeleteStatusFaveByID(ctx, testFave.ID); err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
@ -138,7 +137,7 @@ func (suite *StatusFaveTestSuite) TestDeleteStatusFave() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *StatusFaveTestSuite) TestDeleteStatusFaveNonExisting() {
|
func (suite *StatusFaveTestSuite) TestDeleteStatusFaveNonExisting() {
|
||||||
err := suite.db.DeleteStatusFaveByID(context.Background(), "01GVAV715K6Y2SG9ZKS9ZA8G7G")
|
err := suite.db.DeleteStatusFaveByID(suite.T().Context(), "01GVAV715K6Y2SG9ZKS9ZA8G7G")
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -35,7 +34,7 @@ type TagTestSuite struct {
|
|||||||
func (suite *TagTestSuite) TestGetTag() {
|
func (suite *TagTestSuite) TestGetTag() {
|
||||||
testTag := suite.testTags["welcome"]
|
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.NoError(err)
|
||||||
suite.NotNil(dbTag)
|
suite.NotNil(dbTag)
|
||||||
suite.Equal(testTag.ID, dbTag.ID)
|
suite.Equal(testTag.ID, dbTag.ID)
|
||||||
@ -53,7 +52,7 @@ func (suite *TagTestSuite) TestGetTagByName() {
|
|||||||
"Welcome",
|
"Welcome",
|
||||||
"WELCoME ",
|
"WELCoME ",
|
||||||
} {
|
} {
|
||||||
dbTag, err := suite.db.GetTagByName(context.Background(), name)
|
dbTag, err := suite.db.GetTagByName(suite.T().Context(), name)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.NotNil(dbTag)
|
suite.NotNil(dbTag)
|
||||||
suite.Equal(testTag.ID, dbTag.ID)
|
suite.Equal(testTag.ID, dbTag.ID)
|
||||||
@ -70,7 +69,7 @@ func (suite *TagTestSuite) TestPutTag() {
|
|||||||
"NEWtag",
|
"NEWtag",
|
||||||
"NEWTAG ",
|
"NEWTAG ",
|
||||||
} {
|
} {
|
||||||
err := suite.db.PutTag(context.Background(), >smodel.Tag{
|
err := suite.db.PutTag(suite.T().Context(), >smodel.Tag{
|
||||||
ID: id.NewULID(),
|
ID: id.NewULID(),
|
||||||
Name: name,
|
Name: name,
|
||||||
})
|
})
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
|
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
|
||||||
@ -32,7 +31,7 @@ type ThreadTestSuite struct {
|
|||||||
func (suite *ThreadTestSuite) TestPutThread() {
|
func (suite *ThreadTestSuite) TestPutThread() {
|
||||||
suite.NoError(
|
suite.NoError(
|
||||||
suite.db.PutThread(
|
suite.db.PutThread(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
>smodel.Thread{
|
>smodel.Thread{
|
||||||
ID: "01HCWK4HVQ4VGSS1G4VQP3AXZF",
|
ID: "01HCWK4HVQ4VGSS1G4VQP3AXZF",
|
||||||
},
|
},
|
||||||
@ -44,7 +43,7 @@ func (suite *ThreadTestSuite) TestMuteUnmuteThread() {
|
|||||||
var (
|
var (
|
||||||
threadID = suite.testThreads["local_account_1_status_1"].ID
|
threadID = suite.testThreads["local_account_1_status_1"].ID
|
||||||
accountID = suite.testAccounts["local_account_1"].ID
|
accountID = suite.testAccounts["local_account_1"].ID
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
threadMute = >smodel.ThreadMute{
|
threadMute = >smodel.ThreadMute{
|
||||||
ID: "01HD3K14B62YJHH4RR0DSZ1EQ2",
|
ID: "01HD3K14B62YJHH4RR0DSZ1EQ2",
|
||||||
ThreadID: threadID,
|
ThreadID: threadID,
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.superseriousbusiness.org/gotosocial/internal/gtscontext"
|
"code.superseriousbusiness.org/gotosocial/internal/gtscontext"
|
||||||
@ -110,7 +109,7 @@ func (suite *TimelineTestSuite) checkStatuses(statuses []*gtsmodel.Status, maxID
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *TimelineTestSuite) TestGetPublicTimeline() {
|
func (suite *TimelineTestSuite) TestGetPublicTimeline() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
page := toPage("", "", "", 20)
|
page := toPage("", "", "", 20)
|
||||||
|
|
||||||
@ -123,7 +122,7 @@ func (suite *TimelineTestSuite) TestGetPublicTimeline() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *TimelineTestSuite) TestGetPublicTimelineLocal() {
|
func (suite *TimelineTestSuite) TestGetPublicTimelineLocal() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
page := toPage("", "", "", 20)
|
page := toPage("", "", "", 20)
|
||||||
|
|
||||||
@ -137,7 +136,7 @@ func (suite *TimelineTestSuite) TestGetPublicTimelineLocal() {
|
|||||||
|
|
||||||
func (suite *TimelineTestSuite) TestGetHomeTimeline() {
|
func (suite *TimelineTestSuite) TestGetHomeTimeline() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
viewingAccount = suite.testAccounts["local_account_1"]
|
viewingAccount = suite.testAccounts["local_account_1"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -153,7 +152,7 @@ func (suite *TimelineTestSuite) TestGetHomeTimeline() {
|
|||||||
|
|
||||||
func (suite *TimelineTestSuite) TestGetHomeTimelineIgnoreExclusive() {
|
func (suite *TimelineTestSuite) TestGetHomeTimelineIgnoreExclusive() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
viewingAccount = suite.testAccounts["local_account_1"]
|
viewingAccount = suite.testAccounts["local_account_1"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -195,7 +194,7 @@ func (suite *TimelineTestSuite) TestGetHomeTimelineIgnoreExclusive() {
|
|||||||
|
|
||||||
func (suite *TimelineTestSuite) TestGetHomeTimelineNoFollowing() {
|
func (suite *TimelineTestSuite) TestGetHomeTimelineNoFollowing() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
viewingAccount = suite.testAccounts["local_account_1"]
|
viewingAccount = suite.testAccounts["local_account_1"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -229,7 +228,7 @@ func (suite *TimelineTestSuite) TestGetHomeTimelineNoFollowing() {
|
|||||||
|
|
||||||
func (suite *TimelineTestSuite) TestGetHomeTimelineBackToFront() {
|
func (suite *TimelineTestSuite) TestGetHomeTimelineBackToFront() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
viewingAccount = suite.testAccounts["local_account_1"]
|
viewingAccount = suite.testAccounts["local_account_1"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -247,7 +246,7 @@ func (suite *TimelineTestSuite) TestGetHomeTimelineBackToFront() {
|
|||||||
|
|
||||||
func (suite *TimelineTestSuite) TestGetHomeTimelineFromHighest() {
|
func (suite *TimelineTestSuite) TestGetHomeTimelineFromHighest() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
viewingAccount = suite.testAccounts["local_account_1"]
|
viewingAccount = suite.testAccounts["local_account_1"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -265,7 +264,7 @@ func (suite *TimelineTestSuite) TestGetHomeTimelineFromHighest() {
|
|||||||
|
|
||||||
func (suite *TimelineTestSuite) TestGetListTimelineNoParams() {
|
func (suite *TimelineTestSuite) TestGetListTimelineNoParams() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
list = suite.testLists["local_account_1_list_1"]
|
list = suite.testLists["local_account_1_list_1"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -281,7 +280,7 @@ func (suite *TimelineTestSuite) TestGetListTimelineNoParams() {
|
|||||||
|
|
||||||
func (suite *TimelineTestSuite) TestGetListTimelineMaxID() {
|
func (suite *TimelineTestSuite) TestGetListTimelineMaxID() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
list = suite.testLists["local_account_1_list_1"]
|
list = suite.testLists["local_account_1_list_1"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -299,7 +298,7 @@ func (suite *TimelineTestSuite) TestGetListTimelineMaxID() {
|
|||||||
|
|
||||||
func (suite *TimelineTestSuite) TestGetListTimelineMinID() {
|
func (suite *TimelineTestSuite) TestGetListTimelineMinID() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
list = suite.testLists["local_account_1_list_1"]
|
list = suite.testLists["local_account_1_list_1"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -317,7 +316,7 @@ func (suite *TimelineTestSuite) TestGetListTimelineMinID() {
|
|||||||
|
|
||||||
func (suite *TimelineTestSuite) TestGetListTimelineMinIDPagingUp() {
|
func (suite *TimelineTestSuite) TestGetListTimelineMinIDPagingUp() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
list = suite.testLists["local_account_1_list_1"]
|
list = suite.testLists["local_account_1_list_1"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -335,7 +334,7 @@ func (suite *TimelineTestSuite) TestGetListTimelineMinIDPagingUp() {
|
|||||||
|
|
||||||
func (suite *TimelineTestSuite) TestGetTagTimelineNoParams() {
|
func (suite *TimelineTestSuite) TestGetTagTimelineNoParams() {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = suite.T().Context()
|
||||||
tag = suite.testTags["welcome"]
|
tag = suite.testTags["welcome"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
|
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
|
||||||
@ -30,25 +29,25 @@ type UserTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *UserTestSuite) TestGetAllUsers() {
|
func (suite *UserTestSuite) TestGetAllUsers() {
|
||||||
users, err := suite.db.GetAllUsers(context.Background())
|
users, err := suite.db.GetAllUsers(suite.T().Context())
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.Len(users, len(suite.testUsers))
|
suite.Len(users, len(suite.testUsers))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *UserTestSuite) TestGetUser() {
|
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.NoError(err)
|
||||||
suite.NotNil(user)
|
suite.NotNil(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *UserTestSuite) TestGetUserByEmailAddress() {
|
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.NoError(err)
|
||||||
suite.NotNil(user)
|
suite.NotNil(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *UserTestSuite) TestGetUserByAccountID() {
|
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.NoError(err)
|
||||||
suite.NotNil(user)
|
suite.NotNil(user)
|
||||||
}
|
}
|
||||||
@ -61,10 +60,10 @@ func (suite *UserTestSuite) TestUpdateUserSelectedColumns() {
|
|||||||
updateUser.Email = "whatever"
|
updateUser.Email = "whatever"
|
||||||
updateUser.Locale = "es"
|
updateUser.Locale = "es"
|
||||||
|
|
||||||
err := suite.db.UpdateUser(context.Background(), updateUser)
|
err := suite.db.UpdateUser(suite.T().Context(), updateUser)
|
||||||
suite.NoError(err)
|
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.NoError(err)
|
||||||
suite.NotNil(dbUser)
|
suite.NotNil(dbUser)
|
||||||
suite.Equal(updateUser.Email, dbUser.Email)
|
suite.Equal(updateUser.Email, dbUser.Email)
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bundb_test
|
package bundb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
@ -30,7 +29,7 @@ type WebPushTestSuite struct {
|
|||||||
|
|
||||||
// Get the text fixture VAPID key pair.
|
// Get the text fixture VAPID key pair.
|
||||||
func (suite *WebPushTestSuite) TestGetVAPIDKeyPair() {
|
func (suite *WebPushTestSuite) TestGetVAPIDKeyPair() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
vapidKeyPair, err := suite.db.GetVAPIDKeyPair(ctx)
|
vapidKeyPair, err := suite.db.GetVAPIDKeyPair(ctx)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
@ -51,7 +50,7 @@ func (suite *WebPushTestSuite) TestGetVAPIDKeyPair() {
|
|||||||
|
|
||||||
// Generate a VAPID key pair when there isn't one.
|
// Generate a VAPID key pair when there isn't one.
|
||||||
func (suite *WebPushTestSuite) TestGenerateVAPIDKeyPair() {
|
func (suite *WebPushTestSuite) TestGenerateVAPIDKeyPair() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
|
|
||||||
// Delete the text fixture VAPID key pair.
|
// Delete the text fixture VAPID key pair.
|
||||||
if err := suite.db.DeleteVAPIDKeyPair(ctx); !suite.NoError(err) {
|
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")
|
groupURL := testrig.URLMustParse("https://unknown-instance.com/groups/some_group")
|
||||||
group, _, err := suite.dereferencer.GetAccountByURI(
|
group, _, err := suite.dereferencer.GetAccountByURI(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
fetchingAccount.Username,
|
fetchingAccount.Username,
|
||||||
groupURL,
|
groupURL,
|
||||||
false,
|
false,
|
||||||
@ -65,7 +65,7 @@ func (suite *AccountTestSuite) TestDereferenceGroup() {
|
|||||||
suite.WithinDuration(time.Now(), group.FetchedAt, 5*time.Second)
|
suite.WithinDuration(time.Now(), group.FetchedAt, 5*time.Second)
|
||||||
|
|
||||||
// group should be in the database
|
// 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.NoError(err)
|
||||||
suite.Equal(group.ID, dbGroup.ID)
|
suite.Equal(group.ID, dbGroup.ID)
|
||||||
suite.Equal(ap.ActorGroup, dbGroup.ActorType.String())
|
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")
|
serviceURL := testrig.URLMustParse("https://owncast.example.org/federation/user/rgh")
|
||||||
service, _, err := suite.dereferencer.GetAccountByURI(
|
service, _, err := suite.dereferencer.GetAccountByURI(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
fetchingAccount.Username,
|
fetchingAccount.Username,
|
||||||
serviceURL,
|
serviceURL,
|
||||||
false,
|
false,
|
||||||
@ -90,7 +90,7 @@ func (suite *AccountTestSuite) TestDereferenceService() {
|
|||||||
suite.WithinDuration(time.Now(), service.FetchedAt, 5*time.Second)
|
suite.WithinDuration(time.Now(), service.FetchedAt, 5*time.Second)
|
||||||
|
|
||||||
// service should be in the database
|
// 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.NoError(err)
|
||||||
suite.Equal(service.ID, dbService.ID)
|
suite.Equal(service.ID, dbService.ID)
|
||||||
suite.Equal(ap.ActorService, dbService.ActorType.String())
|
suite.Equal(ap.ActorService, dbService.ActorType.String())
|
||||||
@ -109,7 +109,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountAsRemoteURL() {
|
|||||||
targetAccount := suite.testAccounts["local_account_2"]
|
targetAccount := suite.testAccounts["local_account_2"]
|
||||||
|
|
||||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
fetchingAccount.Username,
|
fetchingAccount.Username,
|
||||||
testrig.URLMustParse(targetAccount.URI),
|
testrig.URLMustParse(targetAccount.URI),
|
||||||
false,
|
false,
|
||||||
@ -124,12 +124,12 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountAsRemoteURLNoSharedInb
|
|||||||
targetAccount := suite.testAccounts["local_account_2"]
|
targetAccount := suite.testAccounts["local_account_2"]
|
||||||
|
|
||||||
targetAccount.SharedInboxURI = nil
|
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())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
fetchingAccount.Username,
|
fetchingAccount.Username,
|
||||||
testrig.URLMustParse(targetAccount.URI),
|
testrig.URLMustParse(targetAccount.URI),
|
||||||
false,
|
false,
|
||||||
@ -144,7 +144,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountAsUsername() {
|
|||||||
targetAccount := suite.testAccounts["local_account_2"]
|
targetAccount := suite.testAccounts["local_account_2"]
|
||||||
|
|
||||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
fetchingAccount.Username,
|
fetchingAccount.Username,
|
||||||
testrig.URLMustParse(targetAccount.URI),
|
testrig.URLMustParse(targetAccount.URI),
|
||||||
false,
|
false,
|
||||||
@ -159,7 +159,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountAsUsernameDomain() {
|
|||||||
targetAccount := suite.testAccounts["local_account_2"]
|
targetAccount := suite.testAccounts["local_account_2"]
|
||||||
|
|
||||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
fetchingAccount.Username,
|
fetchingAccount.Username,
|
||||||
testrig.URLMustParse(targetAccount.URI),
|
testrig.URLMustParse(targetAccount.URI),
|
||||||
false,
|
false,
|
||||||
@ -174,7 +174,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountAsUsernameDomainAndURL
|
|||||||
targetAccount := suite.testAccounts["local_account_2"]
|
targetAccount := suite.testAccounts["local_account_2"]
|
||||||
|
|
||||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByUsernameDomain(
|
fetchedAccount, _, err := suite.dereferencer.GetAccountByUsernameDomain(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
fetchingAccount.Username,
|
fetchingAccount.Username,
|
||||||
targetAccount.Username,
|
targetAccount.Username,
|
||||||
config.GetHost(),
|
config.GetHost(),
|
||||||
@ -188,7 +188,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountWithUnknownUsername()
|
|||||||
fetchingAccount := suite.testAccounts["local_account_1"]
|
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByUsernameDomain(
|
fetchedAccount, _, err := suite.dereferencer.GetAccountByUsernameDomain(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
fetchingAccount.Username,
|
fetchingAccount.Username,
|
||||||
"thisaccountdoesnotexist",
|
"thisaccountdoesnotexist",
|
||||||
config.GetHost(),
|
config.GetHost(),
|
||||||
@ -202,7 +202,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountWithUnknownUsernameDom
|
|||||||
fetchingAccount := suite.testAccounts["local_account_1"]
|
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByUsernameDomain(
|
fetchedAccount, _, err := suite.dereferencer.GetAccountByUsernameDomain(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
fetchingAccount.Username,
|
fetchingAccount.Username,
|
||||||
"thisaccountdoesnotexist",
|
"thisaccountdoesnotexist",
|
||||||
"localhost:8080",
|
"localhost:8080",
|
||||||
@ -216,7 +216,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountWithUnknownUserURI() {
|
|||||||
fetchingAccount := suite.testAccounts["local_account_1"]
|
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
fetchingAccount.Username,
|
fetchingAccount.Username,
|
||||||
testrig.URLMustParse("http://localhost:8080/users/thisaccountdoesnotexist"),
|
testrig.URLMustParse("http://localhost:8080/users/thisaccountdoesnotexist"),
|
||||||
false,
|
false,
|
||||||
@ -227,7 +227,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountWithUnknownUserURI() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AccountTestSuite) TestDereferenceLocalAccountByRedirect() {
|
func (suite *AccountTestSuite) TestDereferenceLocalAccountByRedirect() {
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
fetchingAccount := suite.testAccounts["local_account_1"]
|
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||||
@ -280,7 +280,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountByRedirect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AccountTestSuite) TestDereferenceMasqueradingLocalAccount() {
|
func (suite *AccountTestSuite) TestDereferenceMasqueradingLocalAccount() {
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
fetchingAccount := suite.testAccounts["local_account_1"]
|
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||||
@ -345,7 +345,7 @@ func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithNonMatchingURI()
|
|||||||
|
|
||||||
// Attempt to fetch account at alternative URI, it should fail!
|
// Attempt to fetch account at alternative URI, it should fail!
|
||||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
fetchingAccount.Username,
|
fetchingAccount.Username,
|
||||||
testrig.URLMustParse(remoteAltURI),
|
testrig.URLMustParse(remoteAltURI),
|
||||||
false,
|
false,
|
||||||
@ -355,7 +355,7 @@ func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithNonMatchingURI()
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithUnexpectedKeyChange() {
|
func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithUnexpectedKeyChange() {
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
fetchingAcc := suite.testAccounts["local_account_1"]
|
fetchingAcc := suite.testAccounts["local_account_1"]
|
||||||
@ -394,7 +394,7 @@ func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithUnexpectedKeyChan
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithExpectedKeyChange() {
|
func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithExpectedKeyChange() {
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
fetchingAcc := suite.testAccounts["local_account_1"]
|
fetchingAcc := suite.testAccounts["local_account_1"]
|
||||||
@ -436,7 +436,7 @@ func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithExpectedKeyChange
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *AccountTestSuite) TestRefreshFederatedRemoteAccountWithKeyChange() {
|
func (suite *AccountTestSuite) TestRefreshFederatedRemoteAccountWithKeyChange() {
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
fetchingAcc := suite.testAccounts["local_account_1"]
|
fetchingAcc := suite.testAccounts["local_account_1"]
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package dereferencing_test
|
package dereferencing_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -32,7 +31,7 @@ type EmojiTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EmojiTestSuite) TestDereferenceEmojiBlocking() {
|
func (suite *EmojiTestSuite) TestDereferenceEmojiBlocking() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
emojiImageRemoteURL := "http://example.org/media/emojis/1781772.gif"
|
emojiImageRemoteURL := "http://example.org/media/emojis/1781772.gif"
|
||||||
emojiImageStaticRemoteURL := "http://example.org/media/emojis/1781772.gif"
|
emojiImageStaticRemoteURL := "http://example.org/media/emojis/1781772.gif"
|
||||||
emojiURI := "http://example.org/emojis/1781772"
|
emojiURI := "http://example.org/emojis/1781772"
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package dereferencing_test
|
package dereferencing_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -77,7 +76,7 @@ func (suite *InstanceTestSuite) TestDerefInstance() {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
instance, err := suite.dereferencer.GetRemoteInstance(
|
instance, err := suite.dereferencer.GetRemoteInstance(
|
||||||
gtscontext.SetFastFail(context.Background()),
|
gtscontext.SetFastFail(suite.T().Context()),
|
||||||
suite.testAccounts["admin_account"].Username,
|
suite.testAccounts["admin_account"].Username,
|
||||||
tc.instanceIRI,
|
tc.instanceIRI,
|
||||||
)
|
)
|
||||||
|
@ -44,7 +44,7 @@ func (suite *StatusTestSuite) TestDereferenceSimpleStatus() {
|
|||||||
fetchingAccount := suite.testAccounts["local_account_1"]
|
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
statusURL := testrig.URLMustParse("https://unknown-instance.com/users/brand_new_person/statuses/01FE4NTHKWW7THT67EF10EB839")
|
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.NoError(err)
|
||||||
suite.NotNil(status)
|
suite.NotNil(status)
|
||||||
|
|
||||||
@ -59,13 +59,13 @@ func (suite *StatusTestSuite) TestDereferenceSimpleStatus() {
|
|||||||
suite.Equal(ap.ObjectNote, status.ActivityStreamsType)
|
suite.Equal(ap.ObjectNote, status.ActivityStreamsType)
|
||||||
|
|
||||||
// status should be in the database
|
// 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.NoError(err)
|
||||||
suite.Equal(status.ID, dbStatus.ID)
|
suite.Equal(status.ID, dbStatus.ID)
|
||||||
suite.True(*dbStatus.Federated)
|
suite.True(*dbStatus.Federated)
|
||||||
|
|
||||||
// account should be in the database now too
|
// 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.NoError(err)
|
||||||
suite.NotNil(account)
|
suite.NotNil(account)
|
||||||
suite.True(*account.Discoverable)
|
suite.True(*account.Discoverable)
|
||||||
@ -81,7 +81,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithMention() {
|
|||||||
fetchingAccount := suite.testAccounts["local_account_1"]
|
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
statusURL := testrig.URLMustParse("https://unknown-instance.com/users/brand_new_person/statuses/01FE5Y30E3W4P7TRE0R98KAYQV")
|
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.NoError(err)
|
||||||
suite.NotNil(status)
|
suite.NotNil(status)
|
||||||
|
|
||||||
@ -96,13 +96,13 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithMention() {
|
|||||||
suite.Equal(ap.ObjectNote, status.ActivityStreamsType)
|
suite.Equal(ap.ObjectNote, status.ActivityStreamsType)
|
||||||
|
|
||||||
// status should be in the database
|
// 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.NoError(err)
|
||||||
suite.Equal(status.ID, dbStatus.ID)
|
suite.Equal(status.ID, dbStatus.ID)
|
||||||
suite.True(*dbStatus.Federated)
|
suite.True(*dbStatus.Federated)
|
||||||
|
|
||||||
// account should be in the database now too
|
// 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.NoError(err)
|
||||||
suite.NotNil(account)
|
suite.NotNil(account)
|
||||||
suite.True(*account.Discoverable)
|
suite.True(*account.Discoverable)
|
||||||
@ -115,7 +115,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithMention() {
|
|||||||
|
|
||||||
// we should have a mention in the database
|
// we should have a mention in the database
|
||||||
m := >smodel.Mention{}
|
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.NoError(err)
|
||||||
suite.NotNil(m)
|
suite.NotNil(m)
|
||||||
suite.Equal(status.ID, m.StatusID)
|
suite.Equal(status.ID, m.StatusID)
|
||||||
@ -129,7 +129,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithTag() {
|
|||||||
fetchingAccount := suite.testAccounts["local_account_1"]
|
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
statusURL := testrig.URLMustParse("https://unknown-instance.com/users/brand_new_person/statuses/01H641QSRS3TCXSVC10X4GPKW7")
|
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.NoError(err)
|
||||||
suite.NotNil(status)
|
suite.NotNil(status)
|
||||||
|
|
||||||
@ -148,13 +148,13 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithTag() {
|
|||||||
suite.Len(status.TagIDs, 1)
|
suite.Len(status.TagIDs, 1)
|
||||||
|
|
||||||
// status should be in the database
|
// 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.NoError(err)
|
||||||
suite.Equal(status.ID, dbStatus.ID)
|
suite.Equal(status.ID, dbStatus.ID)
|
||||||
suite.True(*dbStatus.Federated)
|
suite.True(*dbStatus.Federated)
|
||||||
|
|
||||||
// account should be in the database now too
|
// 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.NoError(err)
|
||||||
suite.NotNil(account)
|
suite.NotNil(account)
|
||||||
suite.True(*account.Discoverable)
|
suite.True(*account.Discoverable)
|
||||||
@ -167,7 +167,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithTag() {
|
|||||||
|
|
||||||
// we should have a tag in the database
|
// we should have a tag in the database
|
||||||
t := >smodel.Tag{}
|
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.NoError(err)
|
||||||
suite.NotNil(t)
|
suite.NotNil(t)
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithImageAndNoContent() {
|
|||||||
fetchingAccount := suite.testAccounts["local_account_1"]
|
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
statusURL := testrig.URLMustParse("https://turnip.farm/users/turniplover6969/statuses/70c53e54-3146-42d5-a630-83c8b6c7c042")
|
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.NoError(err)
|
||||||
suite.NotNil(status)
|
suite.NotNil(status)
|
||||||
|
|
||||||
@ -191,13 +191,13 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithImageAndNoContent() {
|
|||||||
suite.Equal(ap.ObjectNote, status.ActivityStreamsType)
|
suite.Equal(ap.ObjectNote, status.ActivityStreamsType)
|
||||||
|
|
||||||
// status should be in the database
|
// 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.NoError(err)
|
||||||
suite.Equal(status.ID, dbStatus.ID)
|
suite.Equal(status.ID, dbStatus.ID)
|
||||||
suite.True(*dbStatus.Federated)
|
suite.True(*dbStatus.Federated)
|
||||||
|
|
||||||
// account should be in the database now too
|
// 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.NoError(err)
|
||||||
suite.NotNil(account)
|
suite.NotNil(account)
|
||||||
suite.True(*account.Discoverable)
|
suite.True(*account.Discoverable)
|
||||||
@ -210,7 +210,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithImageAndNoContent() {
|
|||||||
|
|
||||||
// we should have an attachment in the database
|
// we should have an attachment in the database
|
||||||
a := >smodel.MediaAttachment{}
|
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)
|
suite.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithNonMatchingURI() {
|
|||||||
|
|
||||||
// Attempt to fetch account at alternative URI, it should fail!
|
// Attempt to fetch account at alternative URI, it should fail!
|
||||||
fetchedStatus, _, err := suite.dereferencer.GetStatusByURI(
|
fetchedStatus, _, err := suite.dereferencer.GetStatusByURI(
|
||||||
context.Background(),
|
suite.T().Context(),
|
||||||
fetchingAccount.Username,
|
fetchingAccount.Username,
|
||||||
testrig.URLMustParse(remoteAltURI),
|
testrig.URLMustParse(remoteAltURI),
|
||||||
)
|
)
|
||||||
@ -238,7 +238,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithNonMatchingURI() {
|
|||||||
|
|
||||||
func (suite *StatusTestSuite) TestDereferencerRefreshStatusUpdated() {
|
func (suite *StatusTestSuite) TestDereferencerRefreshStatusUpdated() {
|
||||||
// Create a new context for this test.
|
// Create a new context for this test.
|
||||||
ctx, cncl := context.WithCancel(context.Background())
|
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||||
defer cncl()
|
defer cncl()
|
||||||
|
|
||||||
// The local account we will be fetching statuses as.
|
// The local account we will be fetching statuses as.
|
||||||
|
@ -19,7 +19,6 @@ package federation_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -40,7 +39,7 @@ type FederatingActorTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *FederatingActorTestSuite) TestSendNoRemoteFollowers() {
|
func (suite *FederatingActorTestSuite) TestSendNoRemoteFollowers() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
testAccount := suite.testAccounts["local_account_1"]
|
testAccount := suite.testAccounts["local_account_1"]
|
||||||
testNote := testrig.NewAPNote(
|
testNote := testrig.NewAPNote(
|
||||||
testrig.URLMustParse("http://localhost:8080/users/the_mighty_zork/statuses/01G1TR6BADACCZWQMNF9X21TV5"),
|
testrig.URLMustParse("http://localhost:8080/users/the_mighty_zork/statuses/01G1TR6BADACCZWQMNF9X21TV5"),
|
||||||
@ -82,7 +81,7 @@ func (suite *FederatingActorTestSuite) TestSendNoRemoteFollowers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *FederatingActorTestSuite) TestSendRemoteFollower() {
|
func (suite *FederatingActorTestSuite) TestSendRemoteFollower() {
|
||||||
ctx := context.Background()
|
ctx := suite.T().Context()
|
||||||
testAccount := suite.testAccounts["local_account_1"]
|
testAccount := suite.testAccounts["local_account_1"]
|
||||||
testRemoteAccount := suite.testAccounts["remote_account_1"]
|
testRemoteAccount := suite.testAccounts["remote_account_1"]
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ func (suite *AnnounceTestSuite) TestNewAnnounce() {
|
|||||||
receivingAccount1 := suite.testAccounts["local_account_1"]
|
receivingAccount1 := suite.testAccounts["local_account_1"]
|
||||||
announcingAccount := suite.testAccounts["remote_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"]
|
announce1 := suite.testActivities["announce_forwarded_1_zork"]
|
||||||
|
|
||||||
err := suite.federatingDB.Announce(ctx, announce1.Activity.(vocab.ActivityStreamsAnnounce))
|
err := suite.federatingDB.Announce(ctx, announce1.Activity.(vocab.ActivityStreamsAnnounce))
|
||||||
@ -63,7 +63,7 @@ func (suite *AnnounceTestSuite) TestAnnounceTwice() {
|
|||||||
|
|
||||||
announcingAccount := suite.testAccounts["remote_account_1"]
|
announcingAccount := suite.testAccounts["remote_account_1"]
|
||||||
|
|
||||||
ctx1 := createTestContext(receivingAccount1, announcingAccount)
|
ctx1 := createTestContext(suite.T(), receivingAccount1, announcingAccount)
|
||||||
announce1 := suite.testActivities["announce_forwarded_1_zork"]
|
announce1 := suite.testActivities["announce_forwarded_1_zork"]
|
||||||
|
|
||||||
err := suite.federatingDB.Announce(ctx1, announce1.Activity.(vocab.ActivityStreamsAnnounce))
|
err := suite.federatingDB.Announce(ctx1, announce1.Activity.(vocab.ActivityStreamsAnnounce))
|
||||||
@ -87,7 +87,7 @@ func (suite *AnnounceTestSuite) TestAnnounceTwice() {
|
|||||||
suite.Nil(boost.BoostOf)
|
suite.Nil(boost.BoostOf)
|
||||||
suite.Equal("http://example.org/users/Some_User/statuses/afaba698-5740-4e32-a702-af61aa543bc1", boost.BoostOfURI)
|
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"]
|
announce2 := suite.testActivities["announce_forwarded_1_turtle"]
|
||||||
|
|
||||||
err = suite.federatingDB.Announce(ctx2, announce2.Activity.(vocab.ActivityStreamsAnnounce))
|
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