From e9c70da846d651a1d6f922bec76b4bafb86cd607 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Thu, 24 Jun 2021 19:41:09 +0530 Subject: [PATCH 1/2] Resource Tested for JSON marshalling : StarredRepository --- github/activity_star_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/github/activity_star_test.go b/github/activity_star_test.go index 7e7a4a8ed8b..91682325f4f 100644 --- a/github/activity_star_test.go +++ b/github/activity_star_test.go @@ -285,3 +285,27 @@ func TestActivityService_Unstar_invalidID(t *testing.T) { _, err := client.Activity.Unstar(ctx, "%", "%") testURLParseError(t, err) } + +func TestStarredRepository_Marshal(t *testing.T) { + testJSONMarshal(t, &StarredRepository{}, "{}") + + u := &StarredRepository{ + StarredAt: &Timestamp{referenceTime}, + Repository: &Repository{ + ID: Int64(1), + URL: String("u"), + Name: String("n"), + }, + } + + want := `{ + "starred_at": ` + referenceTimeStr + `, + "repo": { + "id": 1, + "url": "u", + "name": "n" + } + }` + + testJSONMarshal(t, u, want) +} From 325ab0fcb4bd0548fb3c2ce45521985d136705cc Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Thu, 24 Jun 2021 19:54:53 +0530 Subject: [PATCH 2/2] Resource Tested for JSON marshalling : Stargazer --- github/activity_star_test.go | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/github/activity_star_test.go b/github/activity_star_test.go index 91682325f4f..122c399366d 100644 --- a/github/activity_star_test.go +++ b/github/activity_star_test.go @@ -309,3 +309,57 @@ func TestStarredRepository_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestStargazer_Marshal(t *testing.T) { + testJSONMarshal(t, &Stargazer{}, "{}") + + u := &Stargazer{ + StarredAt: &Timestamp{referenceTime}, + User: &User{ + Login: String("l"), + ID: Int64(1), + URL: String("u"), + AvatarURL: String("a"), + GravatarID: String("g"), + Name: String("n"), + Company: String("c"), + Blog: String("b"), + Location: String("l"), + Email: String("e"), + Hireable: Bool(true), + Bio: String("b"), + TwitterUsername: String("t"), + PublicRepos: Int(1), + Followers: Int(1), + Following: Int(1), + CreatedAt: &Timestamp{referenceTime}, + SuspendedAt: &Timestamp{referenceTime}, + }, + } + + want := `{ + "starred_at": ` + referenceTimeStr + `, + "user": { + "login": "l", + "id": 1, + "avatar_url": "a", + "gravatar_id": "g", + "name": "n", + "company": "c", + "blog": "b", + "location": "l", + "email": "e", + "hireable": true, + "bio": "b", + "twitter_username": "t", + "public_repos": 1, + "followers": 1, + "following": 1, + "created_at": ` + referenceTimeStr + `, + "suspended_at": ` + referenceTimeStr + `, + "url": "u" + } + }` + + testJSONMarshal(t, u, want) +}