From 076fc1a222deb27dc2fed70cba5adf83ecc61330 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Sun, 27 Jun 2021 21:38:18 +0530 Subject: [PATCH 1/7] Resource Tested for JSON marshalling : ContentReference --- github/apps_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/github/apps_test.go b/github/apps_test.go index 841fe173742..9c497e69e49 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -594,3 +594,21 @@ func TestAppsService_FindUserInstallation(t *testing.T) { return resp, err }) } + +func TestContentReference_Marshal(t *testing.T) { + testJSONMarshal(t, &ContentReference{}, "{}") + + u := &ContentReference{ + ID: Int64(1), + NodeID: String("nid"), + Reference: String("r"), + } + + want := `{ + "id": 1, + "node_id": "nid", + "reference": "r" + }` + + testJSONMarshal(t, u, want) +} From cbdfc6595271f9ab2242cd0a35e9cdf6f2b2ed2a Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Sun, 27 Jun 2021 21:40:52 +0530 Subject: [PATCH 2/7] Resource Tested for JSON marshalling : Attachment --- github/apps_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/github/apps_test.go b/github/apps_test.go index 9c497e69e49..0f742ef7e50 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -612,3 +612,21 @@ func TestContentReference_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestAttachment_Marshal(t *testing.T) { + testJSONMarshal(t, &Attachment{}, "{}") + + u := &Attachment{ + ID: Int64(1), + Title: String("t"), + Body: String("b"), + } + + want := `{ + "id": 1, + "title": "t", + "body": "b" + }` + + testJSONMarshal(t, u, want) +} From 6fcb9ca2524a4daf0d16a56149bc0e6c40a66d9d Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Sun, 27 Jun 2021 21:46:57 +0530 Subject: [PATCH 3/7] Resource Tested for JSON marshalling : InstallationPermissions --- github/apps_test.go | 76 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/github/apps_test.go b/github/apps_test.go index 0f742ef7e50..be98eba3e42 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -630,3 +630,79 @@ func TestAttachment_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestInstallationPermissions_Marshal(t *testing.T) { + testJSONMarshal(t, &InstallationPermissions{}, "{}") + + u := &InstallationPermissions{ + Actions: String("a"), + Administration: String("ad"), + Checks: String("c"), + Contents: String("co"), + ContentReferences: String("cr"), + Deployments: String("d"), + Environments: String("e"), + Issues: String("i"), + Metadata: String("md"), + Members: String("m"), + OrganizationAdministration: String("oa"), + OrganizationHooks: String("oh"), + OrganizationPlan: String("op"), + OrganizationPreReceiveHooks: String("opr"), + OrganizationProjects: String("op"), + OrganizationSecrets: String("os"), + OrganizationSelfHostedRunners: String("osh"), + OrganizationUserBlocking: String("oub"), + Packages: String("pkg"), + Pages: String("pg"), + PullRequests: String("pr"), + RepositoryHooks: String("rh"), + RepositoryProjects: String("rp"), + RepositoryPreReceiveHooks: String("rprh"), + Secrets: String("s"), + SecretScanningAlerts: String("ssa"), + SecurityEvents: String("se"), + SingleFile: String("sf"), + Statuses: String("s"), + TeamDiscussions: String("td"), + VulnerabilityAlerts: String("va"), + Workflows: String("w"), + } + + want := `{ + "actions": "a", + "administration": "ad", + "checks": "c", + "contents": "co", + "content_references": "cr", + "deployments": "d", + "environments": "e", + "issues": "i", + "metadata": "md", + "members": "m", + "organization_administration": "oa", + "organization_hooks": "oh", + "organization_plan": "op", + "organization_pre_receive_hooks": "opr", + "organization_projects": "op", + "organization_secrets": "os", + "organization_self_hosted_runners": "osh", + "organization_user_blocking": "oub", + "packages": "pkg", + "pages": "pg", + "pull_requests": "pr", + "repository_hooks": "rh", + "repository_projects": "rp", + "repository_pre_receive_hooks": "rprh", + "secrets": "s", + "secret_scanning_alerts": "ssa", + "security_events": "se", + "single_file": "sf", + "statuses": "s", + "team_discussions": "td", + "vulnerability_alerts":" va", + "workflows": "w" + }` + + testJSONMarshal(t, u, want) +} From 5df19750b9d5d4db9752d494341881246d7d3c38 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Sun, 27 Jun 2021 22:15:54 +0530 Subject: [PATCH 4/7] Resource Tested for JSON marshalling : Installation --- github/apps_test.go | 200 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 199 insertions(+), 1 deletion(-) diff --git a/github/apps_test.go b/github/apps_test.go index be98eba3e42..83c2d1e0522 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -700,9 +700,207 @@ func TestInstallationPermissions_Marshal(t *testing.T) { "single_file": "sf", "statuses": "s", "team_discussions": "td", - "vulnerability_alerts":" va", + "vulnerability_alerts":"va", "workflows": "w" }` testJSONMarshal(t, u, want) } + +func TestInstallation_Marshal(t *testing.T) { + testJSONMarshal(t, &Installation{}, "{}") + + u := &Installation{ + ID: Int64(1), + NodeID: String("nid"), + AppID: Int64(1), + AppSlug: String("as"), + TargetID: Int64(1), + Account: &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}, + }, + AccessTokensURL: String("atu"), + RepositoriesURL: String("ru"), + HTMLURL: String("hu"), + TargetType: String("tt"), + SingleFileName: String("sfn"), + RepositorySelection: String("rs"), + Events: []string{"e"}, + SingleFilePaths: []string{"s"}, + Permissions: &InstallationPermissions{ + Actions: String("a"), + Administration: String("ad"), + Checks: String("c"), + Contents: String("co"), + ContentReferences: String("cr"), + Deployments: String("d"), + Environments: String("e"), + Issues: String("i"), + Metadata: String("md"), + Members: String("m"), + OrganizationAdministration: String("oa"), + OrganizationHooks: String("oh"), + OrganizationPlan: String("op"), + OrganizationPreReceiveHooks: String("opr"), + OrganizationProjects: String("op"), + OrganizationSecrets: String("os"), + OrganizationSelfHostedRunners: String("osh"), + OrganizationUserBlocking: String("oub"), + Packages: String("pkg"), + Pages: String("pg"), + PullRequests: String("pr"), + RepositoryHooks: String("rh"), + RepositoryProjects: String("rp"), + RepositoryPreReceiveHooks: String("rprh"), + Secrets: String("s"), + SecretScanningAlerts: String("ssa"), + SecurityEvents: String("se"), + SingleFile: String("sf"), + Statuses: String("s"), + TeamDiscussions: String("td"), + VulnerabilityAlerts: String("va"), + Workflows: String("w"), + }, + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, + HasMultipleSingleFiles: Bool(false), + SuspendedBy: &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}, + }, + SuspendedAt: &Timestamp{referenceTime}, + } + + want := `{ + "id": 1, + "node_id": "nid", + "app_id": 1, + "app_slug": "as", + "target_id": 1, + "account": { + "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" + }, + "access_tokens_url": "atu", + "repositories_url": "ru", + "html_url": "hu", + "target_type": "tt", + "single_file_name": "sfn", + "repository_selection": "rs", + "events": [ + "e" + ], + "single_file_paths": [ + "s" + ], + "permissions": { + "actions": "a", + "administration": "ad", + "checks": "c", + "contents": "co", + "content_references": "cr", + "deployments": "d", + "environments": "e", + "issues": "i", + "metadata": "md", + "members": "m", + "organization_administration": "oa", + "organization_hooks": "oh", + "organization_plan": "op", + "organization_pre_receive_hooks": "opr", + "organization_projects": "op", + "organization_secrets": "os", + "organization_self_hosted_runners": "osh", + "organization_user_blocking": "oub", + "packages": "pkg", + "pages": "pg", + "pull_requests": "pr", + "repository_hooks": "rh", + "repository_projects": "rp", + "repository_pre_receive_hooks": "rprh", + "secrets": "s", + "secret_scanning_alerts": "ssa", + "security_events": "se", + "single_file": "sf", + "statuses": "s", + "team_discussions": "td", + "vulnerability_alerts": "va", + "workflows": "w" + }, + "created_at": ` + referenceTimeStr + `, + "updated_at": ` + referenceTimeStr + `, + "has_multiple_single_files": false, + "suspended_by": { + "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" + }, + "suspended_at": ` + referenceTimeStr + ` + }` + + testJSONMarshal(t, u, want) +} From 0e67001b83caef7124a259a993ad6405f6632534 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Sun, 27 Jun 2021 22:21:06 +0530 Subject: [PATCH 5/7] Resource Tested for JSON marshalling : InstallationTokenOptions --- github/apps_test.go | 82 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/github/apps_test.go b/github/apps_test.go index 83c2d1e0522..478646a9924 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -904,3 +904,85 @@ func TestInstallation_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestInstallationTokenOptions_Marshal(t *testing.T) { + testJSONMarshal(t, &InstallationTokenOptions{}, "{}") + + u := &InstallationTokenOptions{ + RepositoryIDs: []int64{1}, + Permissions: &InstallationPermissions{ + Actions: String("a"), + Administration: String("ad"), + Checks: String("c"), + Contents: String("co"), + ContentReferences: String("cr"), + Deployments: String("d"), + Environments: String("e"), + Issues: String("i"), + Metadata: String("md"), + Members: String("m"), + OrganizationAdministration: String("oa"), + OrganizationHooks: String("oh"), + OrganizationPlan: String("op"), + OrganizationPreReceiveHooks: String("opr"), + OrganizationProjects: String("op"), + OrganizationSecrets: String("os"), + OrganizationSelfHostedRunners: String("osh"), + OrganizationUserBlocking: String("oub"), + Packages: String("pkg"), + Pages: String("pg"), + PullRequests: String("pr"), + RepositoryHooks: String("rh"), + RepositoryProjects: String("rp"), + RepositoryPreReceiveHooks: String("rprh"), + Secrets: String("s"), + SecretScanningAlerts: String("ssa"), + SecurityEvents: String("se"), + SingleFile: String("sf"), + Statuses: String("s"), + TeamDiscussions: String("td"), + VulnerabilityAlerts: String("va"), + Workflows: String("w"), + }, + } + + want := `{ + "repository_ids": [1], + "permissions": { + "actions": "a", + "administration": "ad", + "checks": "c", + "contents": "co", + "content_references": "cr", + "deployments": "d", + "environments": "e", + "issues": "i", + "metadata": "md", + "members": "m", + "organization_administration": "oa", + "organization_hooks": "oh", + "organization_plan": "op", + "organization_pre_receive_hooks": "opr", + "organization_projects": "op", + "organization_secrets": "os", + "organization_self_hosted_runners": "osh", + "organization_user_blocking": "oub", + "packages": "pkg", + "pages": "pg", + "pull_requests": "pr", + "repository_hooks": "rh", + "repository_projects": "rp", + "repository_pre_receive_hooks": "rprh", + "secrets": "s", + "secret_scanning_alerts": "ssa", + "security_events": "se", + "single_file": "sf", + "statuses": "s", + "team_discussions": "td", + "vulnerability_alerts": "va", + "workflows": "w" + } + }` + + testJSONMarshal(t, u, want) +} From 767a8d13a0e0a88f9da73a9adafe2661756e01fb Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Sun, 27 Jun 2021 22:28:35 +0530 Subject: [PATCH 6/7] Resource Tested for JSON marshalling : InstallationToken --- github/apps_test.go | 98 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/github/apps_test.go b/github/apps_test.go index 478646a9924..26c88dd3656 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -986,3 +986,101 @@ func TestInstallationTokenOptions_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestInstallationToken_Marshal(t *testing.T) { + testJSONMarshal(t, &InstallationToken{}, "{}") + + u := &InstallationToken{ + Token: String("t"), + ExpiresAt: &referenceTime, + Permissions: &InstallationPermissions{ + Actions: String("a"), + Administration: String("ad"), + Checks: String("c"), + Contents: String("co"), + ContentReferences: String("cr"), + Deployments: String("d"), + Environments: String("e"), + Issues: String("i"), + Metadata: String("md"), + Members: String("m"), + OrganizationAdministration: String("oa"), + OrganizationHooks: String("oh"), + OrganizationPlan: String("op"), + OrganizationPreReceiveHooks: String("opr"), + OrganizationProjects: String("op"), + OrganizationSecrets: String("os"), + OrganizationSelfHostedRunners: String("osh"), + OrganizationUserBlocking: String("oub"), + Packages: String("pkg"), + Pages: String("pg"), + PullRequests: String("pr"), + RepositoryHooks: String("rh"), + RepositoryProjects: String("rp"), + RepositoryPreReceiveHooks: String("rprh"), + Secrets: String("s"), + SecretScanningAlerts: String("ssa"), + SecurityEvents: String("se"), + SingleFile: String("sf"), + Statuses: String("s"), + TeamDiscussions: String("td"), + VulnerabilityAlerts: String("va"), + Workflows: String("w"), + }, + Repositories: []*Repository{ + { + ID: Int64(1), + URL: String("u"), + Name: String("n"), + }, + }, + } + + want := `{ + "token": "t", + "expires_at": ` + referenceTimeStr + `, + "permissions": { + "actions": "a", + "administration": "ad", + "checks": "c", + "contents": "co", + "content_references": "cr", + "deployments": "d", + "environments": "e", + "issues": "i", + "metadata": "md", + "members": "m", + "organization_administration": "oa", + "organization_hooks": "oh", + "organization_plan": "op", + "organization_pre_receive_hooks": "opr", + "organization_projects": "op", + "organization_secrets": "os", + "organization_self_hosted_runners": "osh", + "organization_user_blocking": "oub", + "packages": "pkg", + "pages": "pg", + "pull_requests": "pr", + "repository_hooks": "rh", + "repository_projects": "rp", + "repository_pre_receive_hooks": "rprh", + "secrets": "s", + "secret_scanning_alerts": "ssa", + "security_events": "se", + "single_file": "sf", + "statuses": "s", + "team_discussions": "td", + "vulnerability_alerts": "va", + "workflows": "w" + }, + "repositories": [ + { + "id": 1, + "url": "u", + "name": "n" + } + ] + }` + + testJSONMarshal(t, u, want) +} From 72c1cc92412deff0ddf97440e7d4db8c65598191 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Sun, 27 Jun 2021 22:41:03 +0530 Subject: [PATCH 7/7] Resource Tested for JSON marshalling : App --- github/apps_test.go | 140 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/github/apps_test.go b/github/apps_test.go index 26c88dd3656..5079d41614a 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -1084,3 +1084,143 @@ func TestInstallationToken_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestApp_Marshal(t *testing.T) { + testJSONMarshal(t, &App{}, "{}") + + u := &App{ + ID: Int64(1), + Slug: String("s"), + NodeID: String("nid"), + Owner: &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}, + }, + Name: String("n"), + Description: String("d"), + ExternalURL: String("eu"), + HTMLURL: String("hu"), + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, + Permissions: &InstallationPermissions{ + Actions: String("a"), + Administration: String("ad"), + Checks: String("c"), + Contents: String("co"), + ContentReferences: String("cr"), + Deployments: String("d"), + Environments: String("e"), + Issues: String("i"), + Metadata: String("md"), + Members: String("m"), + OrganizationAdministration: String("oa"), + OrganizationHooks: String("oh"), + OrganizationPlan: String("op"), + OrganizationPreReceiveHooks: String("opr"), + OrganizationProjects: String("op"), + OrganizationSecrets: String("os"), + OrganizationSelfHostedRunners: String("osh"), + OrganizationUserBlocking: String("oub"), + Packages: String("pkg"), + Pages: String("pg"), + PullRequests: String("pr"), + RepositoryHooks: String("rh"), + RepositoryProjects: String("rp"), + RepositoryPreReceiveHooks: String("rprh"), + Secrets: String("s"), + SecretScanningAlerts: String("ssa"), + SecurityEvents: String("se"), + SingleFile: String("sf"), + Statuses: String("s"), + TeamDiscussions: String("td"), + VulnerabilityAlerts: String("va"), + Workflows: String("w"), + }, + Events: []string{"s"}, + } + + want := `{ + "id": 1, + "slug": "s", + "node_id": "nid", + "owner": { + "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" + }, + "name": "n", + "description": "d", + "external_url": "eu", + "html_url": "hu", + "created_at": ` + referenceTimeStr + `, + "updated_at": ` + referenceTimeStr + `, + "permissions": { + "actions": "a", + "administration": "ad", + "checks": "c", + "contents": "co", + "content_references": "cr", + "deployments": "d", + "environments": "e", + "issues": "i", + "metadata": "md", + "members": "m", + "organization_administration": "oa", + "organization_hooks": "oh", + "organization_plan": "op", + "organization_pre_receive_hooks": "opr", + "organization_projects": "op", + "organization_secrets": "os", + "organization_self_hosted_runners": "osh", + "organization_user_blocking": "oub", + "packages": "pkg", + "pages": "pg", + "pull_requests": "pr", + "repository_hooks": "rh", + "repository_projects": "rp", + "repository_pre_receive_hooks": "rprh", + "secrets": "s", + "secret_scanning_alerts": "ssa", + "security_events": "se", + "single_file": "sf", + "statuses": "s", + "team_discussions": "td", + "vulnerability_alerts": "va", + "workflows": "w" + }, + "events": ["s"] + }` + + testJSONMarshal(t, u, want) +}