diff options
Diffstat (limited to 'internal/api/client/followrequests')
-rw-r--r-- | internal/api/client/followrequests/authorize_test.go | 27 | ||||
-rw-r--r-- | internal/api/client/followrequests/get_test.go | 30 | ||||
-rw-r--r-- | internal/api/client/followrequests/reject_test.go | 25 |
3 files changed, 71 insertions, 11 deletions
diff --git a/internal/api/client/followrequests/authorize_test.go b/internal/api/client/followrequests/authorize_test.go index 4f2e69d49..e6ad1ff30 100644 --- a/internal/api/client/followrequests/authorize_test.go +++ b/internal/api/client/followrequests/authorize_test.go @@ -19,7 +19,9 @@ package followrequests_test import ( + "bytes" "context" + "encoding/json" "fmt" "io/ioutil" "net/http" @@ -28,7 +30,6 @@ import ( "time" "github.com/gin-gonic/gin" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" "github.com/superseriousbusiness/gotosocial/internal/api/client/followrequests" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" @@ -77,9 +78,25 @@ func (suite *AuthorizeTestSuite) TestAuthorize() { // check the response b, err := ioutil.ReadAll(result.Body) - assert.NoError(suite.T(), err) - - suite.Equal(`{"id":"01FHMQX3GAABWSM0S2VZEC2SWC","following":false,"showing_reblogs":false,"notifying":false,"followed_by":true,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false,"endorsed":false,"note":""}`, string(b)) + suite.NoError(err) + dst := new(bytes.Buffer) + err = json.Indent(dst, b, "", " ") + suite.NoError(err) + suite.Equal(`{ + "id": "01FHMQX3GAABWSM0S2VZEC2SWC", + "following": false, + "showing_reblogs": false, + "notifying": false, + "followed_by": true, + "blocking": false, + "blocked_by": false, + "muting": false, + "muting_notifications": false, + "requested": false, + "domain_blocking": false, + "endorsed": false, + "note": "" +}`, dst.String()) } func (suite *AuthorizeTestSuite) TestAuthorizeNoFR() { @@ -105,7 +122,7 @@ func (suite *AuthorizeTestSuite) TestAuthorizeNoFR() { // check the response b, err := ioutil.ReadAll(result.Body) - assert.NoError(suite.T(), err) + suite.NoError(err) suite.Equal(`{"error":"Not Found"}`, string(b)) } diff --git a/internal/api/client/followrequests/get_test.go b/internal/api/client/followrequests/get_test.go index 077dfdc0a..5d7feb3bf 100644 --- a/internal/api/client/followrequests/get_test.go +++ b/internal/api/client/followrequests/get_test.go @@ -19,7 +19,9 @@ package followrequests_test import ( + "bytes" "context" + "encoding/json" "fmt" "io/ioutil" "net/http" @@ -69,8 +71,32 @@ func (suite *GetTestSuite) TestGet() { // check the response b, err := ioutil.ReadAll(result.Body) assert.NoError(suite.T(), err) - - suite.Equal(`[{"id":"01FHMQX3GAABWSM0S2VZEC2SWC","username":"Some_User","acct":"Some_User@example.org","display_name":"some user","locked":true,"bot":false,"created_at":"2020-08-10T12:13:28.000Z","note":"i'm a real son of a gun","url":"http://example.org/@Some_User","avatar":"","avatar_static":"","header":"http://localhost:8080/assets/default_header.png","header_static":"http://localhost:8080/assets/default_header.png","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"emojis":[],"fields":[]}]`, string(b)) + dst := new(bytes.Buffer) + err = json.Indent(dst, b, "", " ") + suite.NoError(err) + suite.Equal(`[ + { + "id": "01FHMQX3GAABWSM0S2VZEC2SWC", + "username": "Some_User", + "acct": "Some_User@example.org", + "display_name": "some user", + "locked": true, + "bot": false, + "created_at": "2020-08-10T12:13:28.000Z", + "note": "i'm a real son of a gun", + "url": "http://example.org/@Some_User", + "avatar": "", + "avatar_static": "", + "header": "http://localhost:8080/assets/default_header.png", + "header_static": "http://localhost:8080/assets/default_header.png", + "followers_count": 0, + "following_count": 0, + "statuses_count": 0, + "last_status_at": null, + "emojis": [], + "fields": [] + } +]`, dst.String()) } func TestGetTestSuite(t *testing.T) { diff --git a/internal/api/client/followrequests/reject_test.go b/internal/api/client/followrequests/reject_test.go index 439d7424f..758cd0448 100644 --- a/internal/api/client/followrequests/reject_test.go +++ b/internal/api/client/followrequests/reject_test.go @@ -19,7 +19,9 @@ package followrequests_test import ( + "bytes" "context" + "encoding/json" "fmt" "io/ioutil" "net/http" @@ -28,7 +30,6 @@ import ( "time" "github.com/gin-gonic/gin" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" "github.com/superseriousbusiness/gotosocial/internal/api/client/followrequests" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" @@ -77,9 +78,25 @@ func (suite *RejectTestSuite) TestReject() { // check the response b, err := ioutil.ReadAll(result.Body) - assert.NoError(suite.T(), err) - - suite.Equal(`{"id":"01FHMQX3GAABWSM0S2VZEC2SWC","following":false,"showing_reblogs":false,"notifying":false,"followed_by":false,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false,"endorsed":false,"note":""}`, string(b)) + suite.NoError(err) + dst := new(bytes.Buffer) + err = json.Indent(dst, b, "", " ") + suite.NoError(err) + suite.Equal(`{ + "id": "01FHMQX3GAABWSM0S2VZEC2SWC", + "following": false, + "showing_reblogs": false, + "notifying": false, + "followed_by": false, + "blocking": false, + "blocked_by": false, + "muting": false, + "muting_notifications": false, + "requested": false, + "domain_blocking": false, + "endorsed": false, + "note": "" +}`, dst.String()) } func TestRejectTestSuite(t *testing.T) { |