diff options
Diffstat (limited to 'internal/ap')
| -rw-r--r-- | internal/ap/ap_test.go | 14 | ||||
| -rw-r--r-- | internal/ap/extractattachments_test.go | 3 | ||||
| -rw-r--r-- | internal/ap/extractemojis_test.go | 9 | ||||
| -rw-r--r-- | internal/ap/extractfocus_test.go | 3 | ||||
| -rw-r--r-- | internal/ap/extractpolicy_test.go | 5 | ||||
| -rw-r--r-- | internal/ap/extractpubkey_test.go | 3 | ||||
| -rw-r--r-- | internal/ap/resolve_test.go | 11 |
7 files changed, 21 insertions, 27 deletions
diff --git a/internal/ap/ap_test.go b/internal/ap/ap_test.go index 06856812c..0956fee66 100644 --- a/internal/ap/ap_test.go +++ b/internal/ap/ap_test.go @@ -19,9 +19,9 @@ package ap_test import ( "bytes" - "context" "encoding/json" "io" + "testing" "code.superseriousbusiness.org/activity/streams" "code.superseriousbusiness.org/activity/streams/vocab" @@ -250,7 +250,7 @@ func (suite *APTestSuite) noteWithHashtags1() ap.Statusable { }`) statusable, err := ap.ResolveStatusable( - context.Background(), + suite.T().Context(), io.NopCloser(bytes.NewReader(noteJson)), ) if err != nil { @@ -306,7 +306,7 @@ func addressable3() ap.Addressable { return note } -func addressable4() vocab.ActivityStreamsAnnounce { +func addressable4(t *testing.T) vocab.ActivityStreamsAnnounce { // https://codeberg.org/superseriousbusiness/gotosocial/issues/267 announceJson := []byte(` { @@ -326,12 +326,12 @@ func addressable4() vocab.ActivityStreamsAnnounce { panic(err) } - t, err := streams.ToType(context.Background(), jsonAsMap) + typ, err := streams.ToType(t.Context(), jsonAsMap) if err != nil { panic(err) } - return t.(vocab.ActivityStreamsAnnounce) + return typ.(vocab.ActivityStreamsAnnounce) } func addressable5() ap.Addressable { @@ -366,7 +366,7 @@ func (suite *APTestSuite) jsonToType(rawJson string) (vocab.Type, map[string]int panic(err) } - t, err := streams.ToType(context.Background(), raw) + t, err := streams.ToType(suite.T().Context(), raw) if err != nil { panic(err) } @@ -395,7 +395,7 @@ func (suite *APTestSuite) SetupTest() { suite.addressable1 = addressable1() suite.addressable2 = addressable2() suite.addressable3 = addressable3() - suite.addressable4 = addressable4() + suite.addressable4 = addressable4(suite.T()) suite.addressable5 = addressable5() suite.testAccounts = testrig.NewTestAccounts() } diff --git a/internal/ap/extractattachments_test.go b/internal/ap/extractattachments_test.go index f3af66708..362fa1a05 100644 --- a/internal/ap/extractattachments_test.go +++ b/internal/ap/extractattachments_test.go @@ -18,7 +18,6 @@ package ap_test import ( - "context" "encoding/json" "testing" @@ -59,7 +58,7 @@ func (suite *ExtractAttachmentsTestSuite) TestExtractDescription() { suite.FailNow(err.Error()) } - t, err := streams.ToType(context.Background(), raw) + t, err := streams.ToType(suite.T().Context(), raw) if err != nil { suite.FailNow(err.Error()) } diff --git a/internal/ap/extractemojis_test.go b/internal/ap/extractemojis_test.go index eba30b8b8..21bba4219 100644 --- a/internal/ap/extractemojis_test.go +++ b/internal/ap/extractemojis_test.go @@ -19,7 +19,6 @@ package ap_test import ( "bytes" - "context" "io" "testing" @@ -61,7 +60,7 @@ func (suite *ExtractEmojisTestSuite) TestExtractEmojis() { }` statusable, err := ap.ResolveStatusable( - context.Background(), + suite.T().Context(), io.NopCloser(bytes.NewBufferString(noteWithEmojis)), ) if err != nil { @@ -115,7 +114,7 @@ func (suite *ExtractEmojisTestSuite) TestExtractEmojisNoID() { }` statusable, err := ap.ResolveStatusable( - context.Background(), + suite.T().Context(), io.NopCloser(bytes.NewBufferString(noteWithEmojis)), ) if err != nil { @@ -170,7 +169,7 @@ func (suite *ExtractEmojisTestSuite) TestExtractEmojisNullID() { }` statusable, err := ap.ResolveStatusable( - context.Background(), + suite.T().Context(), io.NopCloser(bytes.NewBufferString(noteWithEmojis)), ) if err != nil { @@ -225,7 +224,7 @@ func (suite *ExtractEmojisTestSuite) TestExtractEmojisEmptyID() { }` statusable, err := ap.ResolveStatusable( - context.Background(), + suite.T().Context(), io.NopCloser(bytes.NewBufferString(noteWithEmojis)), ) if err != nil { diff --git a/internal/ap/extractfocus_test.go b/internal/ap/extractfocus_test.go index e7f922930..3af2daa81 100644 --- a/internal/ap/extractfocus_test.go +++ b/internal/ap/extractfocus_test.go @@ -18,7 +18,6 @@ package ap_test import ( - "context" "encoding/json" "fmt" "testing" @@ -33,7 +32,7 @@ type ExtractFocusTestSuite struct { } func (suite *ExtractFocusTestSuite) TestExtractFocus() { - ctx := context.Background() + ctx := suite.T().Context() type test struct { data string diff --git a/internal/ap/extractpolicy_test.go b/internal/ap/extractpolicy_test.go index d735b9618..24b198b29 100644 --- a/internal/ap/extractpolicy_test.go +++ b/internal/ap/extractpolicy_test.go @@ -19,7 +19,6 @@ package ap_test import ( "bytes" - "context" "io" "testing" @@ -86,7 +85,7 @@ func (suite *ExtractPolicyTestSuite) TestExtractPolicy() { }` statusable, err := ap.ResolveStatusable( - context.Background(), + suite.T().Context(), io.NopCloser( bytes.NewBufferString(rawNote), ), @@ -186,7 +185,7 @@ func (suite *ExtractPolicyTestSuite) TestExtractPolicyDeprecated() { }` statusable, err := ap.ResolveStatusable( - context.Background(), + suite.T().Context(), io.NopCloser( bytes.NewBufferString(rawNote), ), diff --git a/internal/ap/extractpubkey_test.go b/internal/ap/extractpubkey_test.go index ab4f38a22..c5807cd9d 100644 --- a/internal/ap/extractpubkey_test.go +++ b/internal/ap/extractpubkey_test.go @@ -18,7 +18,6 @@ package ap_test import ( - "context" "encoding/json" "testing" @@ -62,7 +61,7 @@ func (suite *ExtractPubKeyTestSuite) TestExtractPubKeyFromStub() { suite.FailNow(err.Error()) } - t, err := streams.ToType(context.Background(), m) + t, err := streams.ToType(suite.T().Context(), m) if err != nil { suite.FailNow(err.Error()) } diff --git a/internal/ap/resolve_test.go b/internal/ap/resolve_test.go index a5e279fa2..4909a7505 100644 --- a/internal/ap/resolve_test.go +++ b/internal/ap/resolve_test.go @@ -19,7 +19,6 @@ package ap_test import ( "bytes" - "context" "io" "testing" @@ -36,7 +35,7 @@ func (suite *ResolveTestSuite) TestResolveDocumentAsStatusable() { b := []byte(suite.typeToJson(suite.document1)) statusable, err := ap.ResolveStatusable( - context.Background(), io.NopCloser(bytes.NewReader(b)), + suite.T().Context(), io.NopCloser(bytes.NewReader(b)), ) suite.NoError(err) suite.NotNil(statusable) @@ -46,7 +45,7 @@ func (suite *ResolveTestSuite) TestResolveDocumentAsAccountable() { b := []byte(suite.typeToJson(suite.document1)) accountable, err := ap.ResolveAccountable( - context.Background(), io.NopCloser(bytes.NewReader(b)), + suite.T().Context(), io.NopCloser(bytes.NewReader(b)), ) suite.True(gtserror.IsWrongType(err)) suite.EqualError(err, "ResolveAccountable: cannot resolve vocab type *typedocument.ActivityStreamsDocument as accountable") @@ -58,7 +57,7 @@ func (suite *ResolveTestSuite) TestResolveHTMLAsAccountable() { <title>.</title>`) accountable, err := ap.ResolveAccountable( - context.Background(), io.NopCloser(bytes.NewReader(b)), + suite.T().Context(), io.NopCloser(bytes.NewReader(b)), ) suite.True(gtserror.IsWrongType(err)) suite.EqualError(err, "ResolveAccountable: error decoding into json: invalid character '<' looking for beginning of value") @@ -73,7 +72,7 @@ func (suite *ResolveTestSuite) TestResolveNonAPJSONAsAccountable() { }`) accountable, err := ap.ResolveAccountable( - context.Background(), io.NopCloser(bytes.NewReader(b)), + suite.T().Context(), io.NopCloser(bytes.NewReader(b)), ) suite.True(gtserror.IsWrongType(err)) suite.EqualError(err, "ResolveAccountable: error resolving json into ap vocab type: activity stream did not match any known types") @@ -124,7 +123,7 @@ func (suite *ResolveTestSuite) TestResolveBandwagonAlbumAsStatusable() { }`) statusable, err := ap.ResolveStatusable( - context.Background(), io.NopCloser(bytes.NewReader(b)), + suite.T().Context(), io.NopCloser(bytes.NewReader(b)), ) suite.NoError(err) suite.NotNil(statusable) |
