From 92bf228712d2898bc4f4e6c580656cd30b3aaed3 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Sun, 27 Jun 2021 23:08:34 +0530 Subject: [PATCH 1/5] Resource Tested for JSON marshalling : AuthorizationUpdateRequest --- github/authorizations_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/github/authorizations_test.go b/github/authorizations_test.go index b1b3ed6c574..6d756f55c0f 100644 --- a/github/authorizations_test.go +++ b/github/authorizations_test.go @@ -203,3 +203,27 @@ func TestAuthorizationsService_DeleteImpersonation(t *testing.T) { return client.Authorizations.DeleteImpersonation(ctx, "u") }) } + +func TestAuthorizationUpdateRequest_Marshal(t *testing.T) { + testJSONMarshal(t, &AuthorizationUpdateRequest{}, "{}") + + u := &AuthorizationUpdateRequest{ + Scopes: []string{"s"}, + AddScopes: []string{"a"}, + RemoveScopes: []string{"r"}, + Note: String("n"), + NoteURL: String("nu"), + Fingerprint: String("f"), + } + + want := `{ + "scopes": ["s"], + "add_scopes": ["a"], + "remove_scopes": ["r"], + "note": "n", + "note_url": "nu", + "fingerprint": "f" + }` + + testJSONMarshal(t, u, want) +} From 5e55154a29f1cb9b4862b82aa6b8dbeb7cfe485d Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Sun, 27 Jun 2021 23:21:46 +0530 Subject: [PATCH 2/5] Resource Tested for JSON marshalling : AuthorizationRequest --- github/authorizations_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/github/authorizations_test.go b/github/authorizations_test.go index 6d756f55c0f..99b6b20958e 100644 --- a/github/authorizations_test.go +++ b/github/authorizations_test.go @@ -227,3 +227,27 @@ func TestAuthorizationUpdateRequest_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestAuthorizationRequest_Marshal(t *testing.T) { + testJSONMarshal(t, &AuthorizationRequest{}, "{}") + + u := &AuthorizationRequest{ + Scopes: []Scope{"s"}, + ClientID: String("cid"), + ClientSecret: String("cs"), + Note: String("n"), + NoteURL: String("nu"), + Fingerprint: String("f"), + } + + want := `{ + "scopes": ["s"], + "client_id": "cid", + "client_secret": "cs", + "note": "n", + "note_url": "nu", + "fingerprint": "f" + }` + + testJSONMarshal(t, u, want) +} From a3853d74f5eb36ed7955b8aa3b585d040ead9a79 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Sun, 27 Jun 2021 23:27:46 +0530 Subject: [PATCH 3/5] Resource Tested for JSON marshalling : AuthorizationApp --- github/authorizations_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/github/authorizations_test.go b/github/authorizations_test.go index 99b6b20958e..0f0d31df6f1 100644 --- a/github/authorizations_test.go +++ b/github/authorizations_test.go @@ -251,3 +251,21 @@ func TestAuthorizationRequest_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestAuthorizationApp_Marshal(t *testing.T) { + testJSONMarshal(t, &AuthorizationApp{}, "{}") + + u := &AuthorizationApp{ + URL: String("u"), + Name: String("n"), + ClientID: String("cid"), + } + + want := `{ + "url": "u", + "name": "n", + "client_id": "cid" + }` + + testJSONMarshal(t, u, want) +} From 7f48ac166f64944841ea5eda1f2f7593acca72af Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Sun, 27 Jun 2021 23:34:10 +0530 Subject: [PATCH 4/5] Resource Tested for JSON marshalling : Grant --- github/authorizations_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/github/authorizations_test.go b/github/authorizations_test.go index 0f0d31df6f1..eb35dd83e3a 100644 --- a/github/authorizations_test.go +++ b/github/authorizations_test.go @@ -269,3 +269,35 @@ func TestAuthorizationApp_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestGrant_Marshal(t *testing.T) { + testJSONMarshal(t, &Grant{}, "{}") + + u := &Grant{ + ID: Int64(1), + URL: String("u"), + App: &AuthorizationApp{ + URL: String("u"), + Name: String("n"), + ClientID: String("cid"), + }, + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, + Scopes: []string{"s"}, + } + + want := `{ + "id": 1, + "url": "u", + "app": { + "url": "u", + "name": "n", + "client_id": "cid" + }, + "created_at": ` + referenceTimeStr + `, + "updated_at": ` + referenceTimeStr + `, + "scopes": ["s"] + }` + + testJSONMarshal(t, u, want) +} From 0159d75d6c520f9f6a9902b2749246240fc51230 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Sun, 27 Jun 2021 23:48:10 +0530 Subject: [PATCH 5/5] Resource Tested for JSON marshalling : Authorization --- github/authorizations_test.go | 84 +++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/github/authorizations_test.go b/github/authorizations_test.go index eb35dd83e3a..bd7ff29d811 100644 --- a/github/authorizations_test.go +++ b/github/authorizations_test.go @@ -301,3 +301,87 @@ func TestGrant_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestAuthorization_Marshal(t *testing.T) { + testJSONMarshal(t, &Authorization{}, "{}") + + u := &Authorization{ + ID: Int64(1), + URL: String("u"), + Scopes: []Scope{"s"}, + Token: String("t"), + TokenLastEight: String("tle"), + HashedToken: String("ht"), + App: &AuthorizationApp{ + URL: String("u"), + Name: String("n"), + ClientID: String("cid"), + }, + Note: String("n"), + NoteURL: String("nu"), + UpdatedAt: &Timestamp{referenceTime}, + CreatedAt: &Timestamp{referenceTime}, + Fingerprint: String("f"), + 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 := `{ + "id": 1, + "url": "u", + "scopes": ["s"], + "token": "t", + "token_last_eight": "tle", + "hashed_token": "ht", + "app": { + "url": "u", + "name": "n", + "client_id": "cid" + }, + "note": "n", + "note_url": "nu", + "updated_at": ` + referenceTimeStr + `, + "created_at": ` + referenceTimeStr + `, + "fingerprint": "f", + "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) +}