From b72016d6d3a4143b2202de001a862241cbda8fad Mon Sep 17 00:00:00 2001 From: Thomas Langhorst Date: Sun, 13 Oct 2019 11:56:41 +0200 Subject: [PATCH 1/2] added test for JSON marshalling for Reviewers --- github/pulls_reviews_test.go | 82 ++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index 3b78bc9e8f4..3645aba5afc 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -14,6 +14,88 @@ import ( "testing" ) +func TestReviewers_marshall(t *testing.T) { + testJSONMarshal(t, &Reviewers{}, "{}") + + u := &Reviewers{ + Users: []*User{&User{ + Login: String("l"), + ID: Int64(1), + AvatarURL: String("a"), + GravatarID: String("g"), + Name: String("n"), + Company: String("c"), + Blog: String("b"), + Location: String("l"), + Email: String("e"), + Hireable: Bool(true), + PublicRepos: Int(1), + Followers: Int(1), + Following: Int(1), + CreatedAt: &Timestamp{referenceTime}, + URL: String("u"), + }}, + Teams: []*Team{&Team{ + ID: Int64(1), + NodeID: String("node"), + Name: String("n"), + Description: String("d"), + URL: String("u"), + Slug: String("s"), + Permission: String("p"), + Privacy: String("priv"), + MembersCount: Int(1), + ReposCount: Int(1), + Organization: nil, + MembersURL: String("m"), + RepositoriesURL: String("r"), + Parent: nil, + LDAPDN: String("l"), + }}, + } + + want := `{ + "users" : [ + { + "login": "l", + "id": 1, + "avatar_url": "a", + "gravatar_id": "g", + "name": "n", + "company": "c", + "blog": "b", + "location": "l", + "email": "e", + "hireable": true, + "public_repos": 1, + "followers": 1, + "following": 1, + "created_at": ` + referenceTimeStr + `, + "url": "u" + } + ], + "teams" : [ + { + "id": 1, + "node_id": "node", + "name": "n", + "description": "d", + "url": "u", + "slug": "s", + "permission": "p", + "privacy": "priv", + "members_count": 1, + "repos_count": 1, + "members_url": "m", + "repositories_url": "r", + "ldap_dn": "l" + } + ] + }` + + testJSONMarshal(t, u, want) +} + func TestPullRequestsService_ListReviews(t *testing.T) { client, mux, _, teardown := setup() defer teardown() From b1fd805af0ccd6c1530974de71224f6e8e761416 Mon Sep 17 00:00:00 2001 From: Thomas Langhorst Date: Sun, 13 Oct 2019 12:17:42 +0200 Subject: [PATCH 2/2] ran gofmt after travis failed --- github/pulls_reviews_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index 3645aba5afc..25aaca1c013 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -18,7 +18,7 @@ func TestReviewers_marshall(t *testing.T) { testJSONMarshal(t, &Reviewers{}, "{}") u := &Reviewers{ - Users: []*User{&User{ + Users: []*User{{ Login: String("l"), ID: Int64(1), AvatarURL: String("a"), @@ -35,7 +35,7 @@ func TestReviewers_marshall(t *testing.T) { CreatedAt: &Timestamp{referenceTime}, URL: String("u"), }}, - Teams: []*Team{&Team{ + Teams: []*Team{{ ID: Int64(1), NodeID: String("node"), Name: String("n"),