mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-04 14:18:07 -06:00
[chore] Remove omitempty on account source; refactor tests to use prettyprint json (#1337)
* remove omitEmpty tag on account source items * update tests
This commit is contained in:
parent
5318054808
commit
eafd73c292
18 changed files with 1605 additions and 163 deletions
|
|
@ -19,7 +19,9 @@
|
|||
package federation_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -130,7 +132,27 @@ func (suite *FederatingActorTestSuite) TestSendRemoteFollower() {
|
|||
suite.FailNow("timed out waiting for message")
|
||||
}
|
||||
|
||||
suite.Equal(`{"@context":"https://www.w3.org/ns/activitystreams","actor":"http://localhost:8080/users/the_mighty_zork","id":"http://localhost:8080/whatever_some_create","object":{"attributedTo":"http://localhost:8080/users/the_mighty_zork","content":"boobies","id":"http://localhost:8080/users/the_mighty_zork/statuses/01G1TR6BADACCZWQMNF9X21TV5","published":"2022-06-02T12:22:21+02:00","tag":[],"to":"http://localhost:8080/users/the_mighty_zork/followers","type":"Note","url":"http://localhost:8080/@the_mighty_zork/statuses/01G1TR6BADACCZWQMNF9X21TV5"},"published":"2022-06-02T12:22:21+02:00","to":"http://localhost:8080/users/the_mighty_zork/followers","type":"Create"}`, string(sent[0]))
|
||||
dst := new(bytes.Buffer)
|
||||
err = json.Indent(dst, sent[0], "", " ")
|
||||
suite.NoError(err)
|
||||
suite.Equal(`{
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
"actor": "http://localhost:8080/users/the_mighty_zork",
|
||||
"id": "http://localhost:8080/whatever_some_create",
|
||||
"object": {
|
||||
"attributedTo": "http://localhost:8080/users/the_mighty_zork",
|
||||
"content": "boobies",
|
||||
"id": "http://localhost:8080/users/the_mighty_zork/statuses/01G1TR6BADACCZWQMNF9X21TV5",
|
||||
"published": "2022-06-02T12:22:21+02:00",
|
||||
"tag": [],
|
||||
"to": "http://localhost:8080/users/the_mighty_zork/followers",
|
||||
"type": "Note",
|
||||
"url": "http://localhost:8080/@the_mighty_zork/statuses/01G1TR6BADACCZWQMNF9X21TV5"
|
||||
},
|
||||
"published": "2022-06-02T12:22:21+02:00",
|
||||
"to": "http://localhost:8080/users/the_mighty_zork/followers",
|
||||
"type": "Create"
|
||||
}`, dst.String())
|
||||
}
|
||||
|
||||
func TestFederatingActorTestSuite(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -41,11 +41,15 @@ func (suite *FollowersTestSuite) TestGetFollowers() {
|
|||
fi, err := streams.Serialize(f)
|
||||
suite.NoError(err)
|
||||
|
||||
fJson, err := json.Marshal(fi)
|
||||
fJson, err := json.MarshalIndent(fi, "", " ")
|
||||
suite.NoError(err)
|
||||
|
||||
// zork follows local_account_2 so this should be reflected in the response
|
||||
suite.Equal(`{"@context":"https://www.w3.org/ns/activitystreams","items":"http://localhost:8080/users/the_mighty_zork","type":"Collection"}`, string(fJson))
|
||||
suite.Equal(`{
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
"items": "http://localhost:8080/users/the_mighty_zork",
|
||||
"type": "Collection"
|
||||
}`, string(fJson))
|
||||
}
|
||||
|
||||
func TestFollowersTestSuite(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -41,11 +41,18 @@ func (suite *FollowingTestSuite) TestGetFollowing() {
|
|||
fi, err := streams.Serialize(f)
|
||||
suite.NoError(err)
|
||||
|
||||
fJson, err := json.Marshal(fi)
|
||||
fJson, err := json.MarshalIndent(fi, "", " ")
|
||||
suite.NoError(err)
|
||||
|
||||
// zork follows admin account and local_account_1
|
||||
suite.Equal(`{"@context":"https://www.w3.org/ns/activitystreams","items":["http://localhost:8080/users/admin","http://localhost:8080/users/1happyturtle"],"type":"Collection"}`, string(fJson))
|
||||
suite.Equal(`{
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
"items": [
|
||||
"http://localhost:8080/users/admin",
|
||||
"http://localhost:8080/users/1happyturtle"
|
||||
],
|
||||
"type": "Collection"
|
||||
}`, string(fJson))
|
||||
}
|
||||
|
||||
func TestFollowingTestSuite(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue