diff --git a/github/activity_star_test.go b/github/activity_star_test.go index 7e7a4a8ed8b..122c399366d 100644 --- a/github/activity_star_test.go +++ b/github/activity_star_test.go @@ -285,3 +285,81 @@ 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) +} + +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) +}