From 9528b39aa33e3be7ee3b8d7ccb827184666845a2 Mon Sep 17 00:00:00 2001 From: Emilio Scodeler Date: Wed, 7 Jul 2021 08:43:51 -0300 Subject: [PATCH 1/2] Add test for JSON marshalling for Teams --- github/teams_test.go | 86 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/github/teams_test.go b/github/teams_test.go index 1409cf5610e..0041f917f64 100644 --- a/github/teams_test.go +++ b/github/teams_test.go @@ -1585,3 +1585,89 @@ func TestTeamsService_CreateOrUpdateIDPGroupConnectionsBySlug_empty(t *testing.T t.Errorf("Teams.CreateOrUpdateIDPGroupConnectionsBySlug returned %+v. want %+v", groups, want) } } + +func TestTeams_marshall(t *testing.T) { + testJSONMarshal(t, &Team{}, "{}") + + u := &Team{ + ID: Int64(1), + NodeID: String("n"), + Name: String("n"), + Description: String("d"), + URL: String("u"), + Slug: String("s"), + Permission: String("p"), + Privacy: String("p"), + MembersCount: Int(1), + ReposCount: Int(1), + MembersURL: String("m"), + RepositoriesURL: String("r"), + Organization: &Organization{ + Login: String("l"), + ID: Int64(1), + NodeID: String("n"), + AvatarURL: String("a"), + HTMLURL: String("h"), + Name: String("n"), + Company: String("c"), + Blog: String("b"), + Location: String("l"), + Email: String("e"), + }, + Parent: &Team{ + ID: Int64(1), + NodeID: String("n"), + Name: String("n"), + Description: String("d"), + URL: String("u"), + Slug: String("s"), + Permission: String("p"), + Privacy: String("p"), + MembersCount: Int(1), + ReposCount: Int(1), + }, + LDAPDN: String("l"), + } + + want := `{ + "id": 1, + "node_id": "n", + "name": "n", + "description": "d", + "url": "u", + "slug": "s", + "permission": "p", + "privacy": "p", + "members_count": 1, + "repos_count": 1, + "members_url": "m", + "repositories_url": "r", + "organization": { + "login": "l", + "id": 1, + "node_id": "n", + "avatar_url": "a", + "html_url": "h", + "name": "n", + "company": "c", + "blog": "b", + "location": "l", + "email": "e" + }, + "parent": { + "id": 1, + "node_id": "n", + "name": "n", + "description": "d", + "url": "u", + "slug": "s", + "permission": "p", + "privacy": "p", + "members_count": 1, + "repos_count": 1 + }, + "ldap_dn": "l" + }` + + testJSONMarshal(t, u, want) +} From 8604bc18f577650e263db0406ecbd9d1872a7921 Mon Sep 17 00:00:00 2001 From: Emilio Scodeler Date: Wed, 7 Jul 2021 12:37:27 -0300 Subject: [PATCH 2/2] Add test for JSON marshalling for Teams - Adjusted commit as per reviewer feedback and run go fmt --- github/teams_test.go | 52 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/github/teams_test.go b/github/teams_test.go index 0041f917f64..aa18e8a8af5 100644 --- a/github/teams_test.go +++ b/github/teams_test.go @@ -1590,31 +1590,31 @@ func TestTeams_marshall(t *testing.T) { testJSONMarshal(t, &Team{}, "{}") u := &Team{ - ID: Int64(1), - NodeID: String("n"), - Name: String("n"), - Description: String("d"), - URL: String("u"), - Slug: String("s"), - Permission: String("p"), - Privacy: String("p"), - MembersCount: Int(1), - ReposCount: Int(1), - MembersURL: String("m"), - RepositoriesURL: String("r"), - Organization: &Organization{ - Login: String("l"), - ID: Int64(1), - NodeID: String("n"), - AvatarURL: String("a"), - HTMLURL: String("h"), - Name: String("n"), - Company: String("c"), - Blog: String("b"), - Location: String("l"), - Email: String("e"), + ID: Int64(1), + NodeID: String("n"), + Name: String("n"), + Description: String("d"), + URL: String("u"), + Slug: String("s"), + Permission: String("p"), + Privacy: String("p"), + MembersCount: Int(1), + ReposCount: Int(1), + MembersURL: String("m"), + RepositoriesURL: String("r"), + Organization: &Organization{ + Login: String("l"), + ID: Int64(1), + NodeID: String("n"), + AvatarURL: String("a"), + HTMLURL: String("h"), + Name: String("n"), + Company: String("c"), + Blog: String("b"), + Location: String("l"), + Email: String("e"), }, - Parent: &Team{ + Parent: &Team{ ID: Int64(1), NodeID: String("n"), Name: String("n"), @@ -1626,7 +1626,7 @@ func TestTeams_marshall(t *testing.T) { MembersCount: Int(1), ReposCount: Int(1), }, - LDAPDN: String("l"), + LDAPDN: String("l"), } want := `{ @@ -1668,6 +1668,6 @@ func TestTeams_marshall(t *testing.T) { }, "ldap_dn": "l" }` - + testJSONMarshal(t, u, want) }