From 2e1528ea63e16488a105101c4abc393c693aa2ef Mon Sep 17 00:00:00 2001 From: Geraldo Castro Date: Mon, 13 Mar 2023 17:49:30 -0300 Subject: [PATCH 01/12] Change testJSONMarshal and fix all tests related --- github/actions_artifacts_test.go | 43 +- github/actions_runner_groups_test.go | 71 +- github/actions_runners_test.go | 75 +- github/actions_secrets_test.go | 52 +- github/actions_workflow_jobs_test.go | 65 +- github/actions_workflow_runs_test.go | 245 +- github/actions_workflows_test.go | 68 +- github/activity_notifications.go | 6 +- github/activity_notifications_test.go | 33 +- github/activity_star_test.go | 33 +- github/activity_test.go | 80 +- github/activity_watching_test.go | 10 +- github/admin_orgs_test.go | 14 +- github/admin_stats_test.go | 121 +- github/admin_test.go | 46 +- github/admin_users_test.go | 34 +- github/apps_installation_test.go | 11 +- github/apps_manifest_test.go | 36 +- github/apps_marketplace_test.go | 112 +- github/apps_test.go | 296 +- github/authorizations_test.go | 76 +- github/billing_test.go | 33 +- github/checks_test.go | 500 +- github/code-scanning_test.go | 54 +- github/event_test.go | 46 +- github/event_types_test.go | 7510 +--------------------- github/gists_comments_test.go | 24 +- github/gists_test.go | 103 +- github/git_blobs_test.go | 9 +- github/git_commits_test.go | 82 +- github/git_refs_test.go | 35 +- github/git_tags_test.go | 38 +- github/git_trees_test.go | 47 +- github/github.go | 8 +- github/github_test.go | 121 +- github/gitignore_test.go | 5 +- github/interactions_test.go | 6 +- github/issue_import_test.go | 76 +- github/issues_comments_test.go | 35 +- github/issues_events_test.go | 143 +- github/issues_labels_test.go | 10 +- github/issues_milestones_test.go | 38 +- github/issues_test.go | 83 +- github/issues_timeline_test.go | 98 +- github/licenses_test.go | 44 +- github/migrations_source_import_test.go | 47 +- github/migrations_test.go | 24 +- github/migrations_user_test.go | 24 +- github/misc_test.go | 42 +- github/orgs_actions_allowed_test.go | 14 +- github/orgs_audit_log.go | 2 +- github/orgs_audit_log_test.go | 99 +- github/orgs_members_test.go | 49 +- github/orgs_test.go | 44 +- github/packages_test.go | 321 +- github/projects_test.go | 142 +- github/pulls_comments_test.go | 53 +- github/pulls_reviewers_test.go | 49 +- github/pulls_reviews_test.go | 64 +- github/pulls_test.go | 345 +- github/pulls_threads_test.go | 111 +- github/reactions_test.go | 19 +- github/repos_actions_access_test.go | 4 +- github/repos_actions_permissions_test.go | 6 +- github/repos_autolinks_test.go | 13 +- github/repos_codeowners_test.go | 18 +- github/repos_collaborators_test.go | 81 +- github/repos_comments_test.go | 47 +- github/repos_commits_test.go | 139 +- github/repos_community_health_test.go | 116 +- github/repos_contents_test.go | 102 +- github/repos_deployments_test.go | 93 +- github/repos_environments_test.go | 87 +- github/repos_hooks_deliveries_test.go | 48 +- github/repos_hooks_test.go | 117 +- github/repos_invitations_test.go | 23 +- github/repos_merging_test.go | 12 +- github/repos_pages_test.go | 50 +- github/repos_prereceive_hooks_test.go | 7 +- github/repos_releases_test.go | 66 +- github/repos_stats_test.go | 35 +- github/repos_statuses_test.go | 42 +- github/repos_tags_test.go | 7 +- github/repos_test.go | 67 +- github/repos_traffic_test.go | 52 +- github/scim_test.go | 87 +- github/search.go | 2 +- github/search_test.go | 206 +- github/secret_scanning_test.go | 46 +- github/teams.go | 2 +- github/teams_discussion_comments_test.go | 27 +- github/teams_discussions_test.go | 41 +- github/teams_members.go | 2 +- github/teams_members_test.go | 18 +- github/teams_test.go | 141 +- github/users.go | 2 +- github/users_administration_test.go | 4 +- github/users_emails_test.go | 7 +- github/users_gpg_keys_test.go | 28 +- github/users_keys_test.go | 10 +- github/users_projects_test.go | 7 +- github/users_ssh_signing_keys_test.go | 7 +- github/users_test.go | 105 +- 103 files changed, 548 insertions(+), 13550 deletions(-) diff --git a/github/actions_artifacts_test.go b/github/actions_artifacts_test.go index de07c14f847..6b1859ebf4e 100644 --- a/github/actions_artifacts_test.go +++ b/github/actions_artifacts_test.go @@ -453,25 +453,7 @@ func TestArtifact_Marshal(t *testing.T) { }, } - want := `{ - "id": 1, - "node_id": "nid", - "name": "n", - "size_in_bytes": 1, - "url": "u", - "archive_download_url": "a", - "expired": false, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "expires_at": ` + referenceTimeStr + `, - "workflow_run": { - "id": 1, - "repository_id": 1, - "head_repository_id": 1, - "head_branch": "b", - "head_sha": "s" - } - }` + want := `{"id":1,"node_id":"nid","name":"n","size_in_bytes":1,"url":"u","archive_download_url":"a","expired":false,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"expires_at":` + referenceTimeStr + `,"workflow_run":{"id":1,"repository_id":1,"head_repository_id":1,"head_branch":"b","head_sha":"s"}}` testJSONMarshal(t, u, want) } @@ -504,28 +486,7 @@ func TestArtifactList_Marshal(t *testing.T) { }, } - want := `{ - "total_count": 1, - "artifacts": [{ - "id": 1, - "node_id": "nid", - "name": "n", - "size_in_bytes": 1, - "url": "u", - "archive_download_url": "a", - "expired": false, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "expires_at": ` + referenceTimeStr + `, - "workflow_run": { - "id": 1, - "repository_id": 1, - "head_repository_id": 1, - "head_branch": "b", - "head_sha": "s" - } - }] - }` + want := `{"total_count":1,"artifacts":[{"id":1,"node_id":"nid","name":"n","size_in_bytes":1,"url":"u","archive_download_url":"a","expired":false,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"expires_at":` + referenceTimeStr + `,"workflow_run":{"id":1,"repository_id":1,"head_repository_id":1,"head_branch":"b","head_sha":"s"}}]}` testJSONMarshal(t, u, want) } diff --git a/github/actions_runner_groups_test.go b/github/actions_runner_groups_test.go index 16d92ed7c64..d3cbea949d6 100644 --- a/github/actions_runner_groups_test.go +++ b/github/actions_runner_groups_test.go @@ -547,24 +547,16 @@ func TestRunnerGroup_Marshal(t *testing.T) { SelectedWorkflows: []string{}, } - want := `{ - "id": 1, - "name": "n", - "visibility": "v", - "default": true, - "selected_repositories_url": "s", - "runners_url": "r", - "inherited": true, - "allows_public_repositories": true, - "restricted_to_workflows": false, - "selected_workflows": [] - }` + want := `{"id":1,"name":"n","visibility":"v","default":true,"selected_repositories_url":"s","runners_url":"r","inherited":true,"allows_public_repositories":true,"restricted_to_workflows":false}` + testJSONMarshal(t, u, want) + u.SelectedWorkflows = []string{"1"} + want = `{"id":1,"name":"n","visibility":"v","default":true,"selected_repositories_url":"s","runners_url":"r","inherited":true,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":["1"]}` testJSONMarshal(t, u, want) } func TestRunnerGroups_Marshal(t *testing.T) { - testJSONMarshal(t, &RunnerGroups{}, "{}") + testJSONMarshal(t, &RunnerGroups{}, `{"total_count":0,"runner_groups":null}`) u := &RunnerGroups{ TotalCount: int(1), @@ -584,22 +576,11 @@ func TestRunnerGroups_Marshal(t *testing.T) { }, } - want := `{ - "total_count": 1, - "runner_groups": [{ - "id": 1, - "name": "n", - "visibility": "v", - "default": true, - "selected_repositories_url": "s", - "runners_url": "r", - "inherited": true, - "allows_public_repositories": true, - "restricted_to_workflows": false, - "selected_workflows": [] - }] - }` + want := `{"total_count":1,"runner_groups":[{"id":1,"name":"n","visibility":"v","default":true,"selected_repositories_url":"s","runners_url":"r","inherited":true,"allows_public_repositories":true,"restricted_to_workflows":false}]}` + testJSONMarshal(t, u, want) + u.RunnerGroups[0].SelectedWorkflows = []string{"1"} + want = `{"total_count":1,"runner_groups":[{"id":1,"name":"n","visibility":"v","default":true,"selected_repositories_url":"s","runners_url":"r","inherited":true,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":["1"]}]}` testJSONMarshal(t, u, want) } @@ -616,15 +597,7 @@ func TestCreateRunnerGroupRequest_Marshal(t *testing.T) { SelectedWorkflows: []string{"a", "b"}, } - want := `{ - "name": "n", - "visibility": "v", - "selected_repository_ids": [1], - "runners": [1], - "allows_public_repositories": true, - "restricted_to_workflows": true, - "selected_workflows": ["a","b"] - }` + want := `{"name":"n","visibility":"v","selected_repository_ids":[1],"runners":[1],"allows_public_repositories":true,"restricted_to_workflows":true,"selected_workflows":["a","b"]}` testJSONMarshal(t, u, want) } @@ -640,41 +613,35 @@ func TestUpdateRunnerGroupRequest_Marshal(t *testing.T) { SelectedWorkflows: []string{}, } - want := `{ - "name": "n", - "visibility": "v", - "allows_public_repositories": true, - "restricted_to_workflows": false, - "selected_workflows": [] - }` + want := `{"name":"n","visibility":"v","allows_public_repositories":true,"restricted_to_workflows":false}` + + testJSONMarshal(t, u, want) + u.SelectedWorkflows = []string{"1"} + want = `{"name":"n","visibility":"v","allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":["1"]}` testJSONMarshal(t, u, want) } func TestSetRepoAccessRunnerGroupRequest_Marshal(t *testing.T) { - testJSONMarshal(t, &SetRepoAccessRunnerGroupRequest{}, "{}") + testJSONMarshal(t, &SetRepoAccessRunnerGroupRequest{}, `{"selected_repository_ids":null}`) u := &SetRepoAccessRunnerGroupRequest{ SelectedRepositoryIDs: []int64{1}, } - want := `{ - "selected_repository_ids": [1] - }` + want := `{"selected_repository_ids":[1]}` testJSONMarshal(t, u, want) } func TestSetRunnerGroupRunnersRequest_Marshal(t *testing.T) { - testJSONMarshal(t, &SetRunnerGroupRunnersRequest{}, "{}") + testJSONMarshal(t, &SetRunnerGroupRunnersRequest{}, `{"runners":null}`) u := &SetRunnerGroupRunnersRequest{ Runners: []int64{1}, } - want := `{ - "runners": [1] - }` + want := `{"runners":[1]}` testJSONMarshal(t, u, want) } diff --git a/github/actions_runners_test.go b/github/actions_runners_test.go index 9b338641eae..0155147b9ac 100644 --- a/github/actions_runners_test.go +++ b/github/actions_runners_test.go @@ -596,20 +596,13 @@ func TestRunnerApplicationDownload_Marshal(t *testing.T) { SHA256Checksum: String("s"), } - want := `{ - "os": "o", - "architecture": "a", - "download_url": "d", - "filename": "f", - "temp_download_token": "t", - "sha256_checksum": "s" - }` + want := `{"os":"o","architecture":"a","download_url":"d","filename":"f","temp_download_token":"t","sha256_checksum":"s"}` testJSONMarshal(t, u, want) } func TestActionsEnabledOnOrgRepos_Marshal(t *testing.T) { - testJSONMarshal(t, &ActionsEnabledOnOrgRepos{}, "{}") + testJSONMarshal(t, &ActionsEnabledOnOrgRepos{}, `{"total_count":0,"repositories":null}`) u := &ActionsEnabledOnOrgRepos{ TotalCount: 1, @@ -622,16 +615,7 @@ func TestActionsEnabledOnOrgRepos_Marshal(t *testing.T) { }, } - want := `{ - "total_count": 1, - "repositories": [ - { - "id": 1, - "url": "u", - "name": "n" - } - ] - }` + want := `{"total_count":1,"repositories":[{"id":1,"name":"n","url":"u"}]}` testJSONMarshal(t, u, want) } @@ -644,10 +628,7 @@ func TestRegistrationToken_Marshal(t *testing.T) { ExpiresAt: &Timestamp{referenceTime}, } - want := `{ - "token": "t", - "expires_at": ` + referenceTimeStr + ` - }` + want := `{"token":"t","expires_at":` + referenceTimeStr + `}` testJSONMarshal(t, u, want) } @@ -661,11 +642,7 @@ func TestRunnerLabels_Marshal(t *testing.T) { Type: String("t"), } - want := `{ - "id": 1, - "name": "n", - "type": "t" - }` + want := `{"id":1,"name":"n","type":"t"}` testJSONMarshal(t, u, want) } @@ -688,26 +665,13 @@ func TestRunner_Marshal(t *testing.T) { }, } - want := `{ - "id": 1, - "name": "n", - "os": "o", - "status": "s", - "busy": false, - "labels": [ - { - "id": 1, - "name": "n", - "type": "t" - } - ] - }` + want := `{"id":1,"name":"n","os":"o","status":"s","busy":false,"labels":[{"id":1,"name":"n","type":"t"}]}` testJSONMarshal(t, u, want) } func TestRunners_Marshal(t *testing.T) { - testJSONMarshal(t, &Runners{}, "{}") + testJSONMarshal(t, &Runners{}, `{"total_count":0,"runners":null}`) u := &Runners{ TotalCount: 1, @@ -729,25 +693,7 @@ func TestRunners_Marshal(t *testing.T) { }, } - want := `{ - "total_count": 1, - "runners": [ - { - "id": 1, - "name": "n", - "os": "o", - "status": "s", - "busy": false, - "labels": [ - { - "id": 1, - "name": "n", - "type": "t" - } - ] - } - ] - }` + want := `{"total_count":1,"runners":[{"id":1,"name":"n","os":"o","status":"s","busy":false,"labels":[{"id":1,"name":"n","type":"t"}]}]}` testJSONMarshal(t, u, want) } @@ -760,10 +706,7 @@ func TestRemoveToken_Marshal(t *testing.T) { ExpiresAt: &Timestamp{referenceTime}, } - want := `{ - "token": "t", - "expires_at": ` + referenceTimeStr + ` - }` + want := `{"token":"t","expires_at":` + referenceTimeStr + `}` testJSONMarshal(t, u, want) } diff --git a/github/actions_secrets_test.go b/github/actions_secrets_test.go index a1266d6bae6..969aac87eba 100644 --- a/github/actions_secrets_test.go +++ b/github/actions_secrets_test.go @@ -812,23 +812,20 @@ func TestActionsService_DeleteEnvSecret(t *testing.T) { } func TestPublicKey_Marshal(t *testing.T) { - testJSONMarshal(t, &PublicKey{}, "{}") + testJSONMarshal(t, &PublicKey{}, `{"key_id":null,"key":null}`) u := &PublicKey{ KeyID: String("kid"), Key: String("k"), } - want := `{ - "key_id": "kid", - "key": "k" - }` + want := `{"key_id":"kid","key":"k"}` testJSONMarshal(t, u, want) } func TestSecret_Marshal(t *testing.T) { - testJSONMarshal(t, &Secret{}, "{}") + testJSONMarshal(t, &Secret{}, `{"name":"","created_at":"0001-01-01T00:00:00Z","updated_at":"0001-01-01T00:00:00Z"}`) u := &Secret{ Name: "n", @@ -838,19 +835,13 @@ func TestSecret_Marshal(t *testing.T) { SelectedRepositoriesURL: "s", } - want := `{ - "name": "n", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "visibility": "v", - "selected_repositories_url": "s" - }` + want := `{"name":"n","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"visibility":"v","selected_repositories_url":"s"}` testJSONMarshal(t, u, want) } func TestSecrets_Marshal(t *testing.T) { - testJSONMarshal(t, &Secrets{}, "{}") + testJSONMarshal(t, &Secrets{}, `{"total_count":0,"secrets":null}`) u := &Secrets{ TotalCount: 1, @@ -864,24 +855,13 @@ func TestSecrets_Marshal(t *testing.T) { }, } - want := `{ - "total_count": 1, - "secrets": [ - { - "name": "n", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "visibility": "v", - "selected_repositories_url": "s" - } - ] - }` + want := `{"total_count":1,"secrets":[{"name":"n","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"visibility":"v","selected_repositories_url":"s"}]}` testJSONMarshal(t, u, want) } func TestEncryptedSecret_Marshal(t *testing.T) { - testJSONMarshal(t, &EncryptedSecret{}, "{}") + testJSONMarshal(t, &EncryptedSecret{}, `{"key_id":"","encrypted_value":""}`) u := &EncryptedSecret{ Name: "n", @@ -891,12 +871,7 @@ func TestEncryptedSecret_Marshal(t *testing.T) { SelectedRepositoryIDs: []int64{1}, } - want := `{ - "key_id": "kid", - "encrypted_value": "e", - "visibility": "v", - "selected_repository_ids": [1] - }` + want := `{"key_id":"kid","encrypted_value":"e","visibility":"v","selected_repository_ids":[1]}` testJSONMarshal(t, u, want) } @@ -915,16 +890,7 @@ func TestSelectedReposList_Marshal(t *testing.T) { }, } - want := `{ - "total_count": 1, - "repositories": [ - { - "id": 1, - "url": "u", - "name": "n" - } - ] - }` + want := `{"total_count":1,"repositories":[{"id":1,"name":"n","url":"u"}]}` testJSONMarshal(t, u, want) } diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index 521e401102b..80212816cc6 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -226,14 +226,7 @@ func TestTaskStep_Marshal(t *testing.T) { CompletedAt: &Timestamp{referenceTime}, } - want := `{ - "name": "n", - "status": "s", - "conclusion": "c", - "number": 1, - "started_at": ` + referenceTimeStr + `, - "completed_at": ` + referenceTimeStr + ` - }` + want := `{"name":"n","status":"s","conclusion":"c","number":1,"started_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `}` testJSONMarshal(t, u, want) } @@ -269,31 +262,7 @@ func TestWorkflowJob_Marshal(t *testing.T) { WorkflowName: String("w"), } - want := `{ - "id": 1, - "run_id": 1, - "run_url": "r", - "node_id": "n", - "head_sha": "h", - "url": "u", - "html_url": "h", - "status": "s", - "conclusion": "c", - "created_at": ` + referenceTimeStr + `, - "started_at": ` + referenceTimeStr + `, - "completed_at": ` + referenceTimeStr + `, - "name": "n", - "steps": [{ - "name": "n", - "status": "s", - "conclusion": "c", - "number": 1, - "started_at": ` + referenceTimeStr + `, - "completed_at": ` + referenceTimeStr + ` - }], - "check_run_url": "c", - "workflow_name": "w" - }` + want := `{"id":1,"run_id":1,"run_url":"r","node_id":"n","head_sha":"h","url":"u","html_url":"h","status":"s","conclusion":"c","created_at":` + referenceTimeStr + `,"started_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `,"name":"n","steps":[{"name":"n","status":"s","conclusion":"c","number":1,"started_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `}],"check_run_url":"c","workflow_name":"w"}` testJSONMarshal(t, u, want) } @@ -335,35 +304,7 @@ func TestJobs_Marshal(t *testing.T) { }, } - want := `{ - "total_count": 1, - "jobs": [{ - "id": 1, - "run_id": 1, - "run_url": "r", - "node_id": "n", - "head_sha": "h", - "url": "u", - "html_url": "h", - "status": "s", - "conclusion": "c", - "created_at": ` + referenceTimeStr + `, - "started_at": ` + referenceTimeStr + `, - "completed_at": ` + referenceTimeStr + `, - "name": "n", - "steps": [{ - "name": "n", - "status": "s", - "conclusion": "c", - "number": 1, - "started_at": ` + referenceTimeStr + `, - "completed_at": ` + referenceTimeStr + ` - }], - "check_run_url": "c", - "run_attempt": 2, - "workflow_name": "w" - }] - }` + want := `{"total_count":1,"jobs":[{"id":1,"run_id":1,"run_url":"r","node_id":"n","head_sha":"h","url":"u","html_url":"h","status":"s","conclusion":"c","created_at":` + referenceTimeStr + `,"started_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `,"name":"n","steps":[{"name":"n","status":"s","conclusion":"c","number":1,"started_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `}],"check_run_url":"c","run_attempt":2,"workflow_name":"w"}]}` testJSONMarshal(t, u, want) } diff --git a/github/actions_workflow_runs_test.go b/github/actions_workflow_runs_test.go index 641c4d739b7..c9f5d07e7da 100644 --- a/github/actions_workflow_runs_test.go +++ b/github/actions_workflow_runs_test.go @@ -660,106 +660,7 @@ func TestWorkflowRun_Marshal(t *testing.T) { }, } - want := `{ - "id": 1, - "name": "n", - "node_id": "nid", - "head_branch": "hb", - "head_sha": "hs", - "run_number": 1, - "run_attempt": 1, - "event": "e", - "status": "s", - "conclusion": "c", - "workflow_id": 1, - "url": "u", - "html_url": "h", - "pull_requests": [ - { - "id":1, - "number":1, - "url":"u", - "head":{ - "ref":"r", - "sha":"s", - "repo": { - "id":1, - "name":"n", - "url":"s" - } - }, - "base": { - "ref":"r", - "sha":"s", - "repo": { - "id":1, - "name":"n", - "url":"u" - } - } - } - ], - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "run_started_at": ` + referenceTimeStr + `, - "jobs_url": "j", - "logs_url": "l", - "check_suite_url": "c", - "artifacts_url": "a", - "cancel_url": "c", - "rerun_url": "r", - "previous_attempt_url": "p", - "head_commit": { - "message": "m", - "author": { - "name": "n", - "email": "e", - "username": "l" - }, - "url": "u", - "distinct": false, - "sha": "s", - "id": "i", - "tree_id": "tid", - "timestamp": ` + referenceTimeStr + `, - "committer": { - "name": "n", - "email": "e", - "username": "l" - } - }, - "workflow_url": "w", - "repository": { - "id": 1, - "url": "u", - "name": "n" - }, - "head_repository": { - "id": 1, - "url": "u", - "name": "n" - }, - "actor": { - "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" - } - }` + want := `{"id":1,"name":"n","node_id":"nid","head_branch":"hb","head_sha":"hs","run_number":1,"run_attempt":1,"event":"e","status":"s","conclusion":"c","workflow_id":1,"url":"u","html_url":"h","pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}],"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"run_started_at":` + referenceTimeStr + `,"jobs_url":"j","logs_url":"l","check_suite_url":"c","artifacts_url":"a","cancel_url":"c","rerun_url":"r","previous_attempt_url":"p","head_commit":{"message":"m","author":{"name":"n","email":"e","username":"l"},"url":"u","distinct":false,"sha":"s","id":"i","tree_id":"tid","timestamp":` + referenceTimeStr + `,"committer":{"name":"n","email":"e","username":"l"}},"workflow_url":"w","repository":{"id":1,"name":"n","url":"u"},"head_repository":{"id":1,"name":"n","url":"u"},"actor":{"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) } @@ -873,111 +774,7 @@ func TestWorkflowRuns_Marshal(t *testing.T) { }, } - want := `{ - "total_count": 1, - "workflow_runs": [ - { - "id": 1, - "name": "n", - "node_id": "nid", - "head_branch": "hb", - "head_sha": "hs", - "run_number": 1, - "run_attempt": 1, - "event": "e", - "status": "s", - "conclusion": "c", - "workflow_id": 1, - "url": "u", - "html_url": "h", - "pull_requests": [ - { - "id":1, - "number":1, - "url":"u", - "head":{ - "ref":"r", - "sha":"s", - "repo": { - "id":1, - "name":"n", - "url":"s" - } - }, - "base": { - "ref":"r", - "sha":"s", - "repo": { - "id":1, - "name":"n", - "url":"u" - } - } - } - ], - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "run_started_at": ` + referenceTimeStr + `, - "jobs_url": "j", - "logs_url": "l", - "check_suite_url": "c", - "artifacts_url": "a", - "cancel_url": "c", - "rerun_url": "r", - "previous_attempt_url": "p", - "head_commit": { - "message": "m", - "author": { - "name": "n", - "email": "e", - "username": "l" - }, - "url": "u", - "distinct": false, - "sha": "s", - "id": "i", - "tree_id": "tid", - "timestamp": ` + referenceTimeStr + `, - "committer": { - "name": "n", - "email": "e", - "username": "l" - } - }, - "workflow_url": "w", - "repository": { - "id": 1, - "url": "u", - "name": "n" - }, - "head_repository": { - "id": 1, - "url": "u", - "name": "n" - }, - "actor": { - "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" - } - } - ] - }` + want := `{"total_count":1,"workflow_runs":[{"id":1,"name":"n","node_id":"nid","head_branch":"hb","head_sha":"hs","run_number":1,"run_attempt":1,"event":"e","status":"s","conclusion":"c","workflow_id":1,"url":"u","html_url":"h","pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}],"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"run_started_at":` + referenceTimeStr + `,"jobs_url":"j","logs_url":"l","check_suite_url":"c","artifacts_url":"a","cancel_url":"c","rerun_url":"r","previous_attempt_url":"p","head_commit":{"message":"m","author":{"name":"n","email":"e","username":"l"},"url":"u","distinct":false,"sha":"s","id":"i","tree_id":"tid","timestamp":` + referenceTimeStr + `,"committer":{"name":"n","email":"e","username":"l"}},"workflow_url":"w","repository":{"id":1,"name":"n","url":"u"},"head_repository":{"id":1,"name":"n","url":"u"},"actor":{"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) } @@ -990,10 +787,7 @@ func TestWorkflowRunBill_Marshal(t *testing.T) { Jobs: Int(1), } - want := `{ - "total_ms": 1, - "jobs": 1 - }` + want := `{"total_ms":1,"jobs":1}` testJSONMarshal(t, u, want) } @@ -1016,20 +810,7 @@ func TestWorkflowRunBillMap_Marshal(t *testing.T) { }, } - want := `{ - "UBUNTU": { - "total_ms": 1, - "jobs": 1 - }, - "MACOS": { - "total_ms": 1, - "jobs": 1 - }, - "WINDOWS": { - "total_ms": 1, - "jobs": 1 - } - }` + want := `{"MACOS":{"total_ms":1,"jobs":1},"UBUNTU":{"total_ms":1,"jobs":1},"WINDOWS":{"total_ms":1,"jobs":1}}` testJSONMarshal(t, u, want) } @@ -1055,23 +836,7 @@ func TestWorkflowRunUsage_Marshal(t *testing.T) { RunDurationMS: Int64(1), } - want := `{ - "billable": { - "UBUNTU": { - "total_ms": 1, - "jobs": 1 - }, - "MACOS": { - "total_ms": 1, - "jobs": 1 - }, - "WINDOWS": { - "total_ms": 1, - "jobs": 1 - } - }, - "run_duration_ms": 1 - }` + want := `{"billable":{"MACOS":{"total_ms":1,"jobs":1},"UBUNTU":{"total_ms":1,"jobs":1},"WINDOWS":{"total_ms":1,"jobs":1}},"run_duration_ms":1}` testJSONMarshal(t, u, want) } diff --git a/github/actions_workflows_test.go b/github/actions_workflows_test.go index 5e0dbbc9c13..6e1d9f4bdf0 100644 --- a/github/actions_workflows_test.go +++ b/github/actions_workflows_test.go @@ -475,18 +475,7 @@ func TestWorkflow_Marshal(t *testing.T) { BadgeURL: String("b"), } - want := `{ - "id": 1, - "node_id": "nid", - "name": "n", - "path": "p", - "state": "s", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "url": "u", - "html_url": "h", - "badge_url": "b" - }` + want := `{"id":1,"node_id":"nid","name":"n","path":"p","state":"s","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"url":"u","html_url":"h","badge_url":"b"}` testJSONMarshal(t, u, want) } @@ -512,21 +501,7 @@ func TestWorkflows_Marshal(t *testing.T) { }, } - want := `{ - "total_count": 1, - "workflows": [{ - "id": 1, - "node_id": "nid", - "name": "n", - "path": "p", - "state": "s", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "url": "u", - "html_url": "h", - "badge_url": "b" - }] - }` + want := `{"total_count":1,"workflows":[{"id":1,"node_id":"nid","name":"n","path":"p","state":"s","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"url":"u","html_url":"h","badge_url":"b"}]}` testJSONMarshal(t, u, want) } @@ -538,9 +513,7 @@ func TestWorkflowBill_Marshal(t *testing.T) { TotalMS: Int64(1), } - want := `{ - "total_ms": 1 - }` + want := `{"total_ms":1}` testJSONMarshal(t, u, want) } @@ -560,17 +533,7 @@ func TestWorkflowBillMap_Marshal(t *testing.T) { }, } - want := `{ - "UBUNTU": { - "total_ms": 1 - }, - "MACOS": { - "total_ms": 1 - }, - "WINDOWS": { - "total_ms": 1 - } - }` + want := `{"MACOS":{"total_ms":1},"UBUNTU":{"total_ms":1},"WINDOWS":{"total_ms":1}}` testJSONMarshal(t, u, want) } @@ -592,25 +555,13 @@ func TestWorkflowUsage_Marshal(t *testing.T) { }, } - want := `{ - "billable": { - "UBUNTU": { - "total_ms": 1 - }, - "MACOS": { - "total_ms": 1 - }, - "WINDOWS": { - "total_ms": 1 - } - } - }` + want := `{"billable":{"MACOS":{"total_ms":1},"UBUNTU":{"total_ms":1},"WINDOWS":{"total_ms":1}}}` testJSONMarshal(t, u, want) } func TestCreateWorkflowDispatchEventRequest_Marshal(t *testing.T) { - testJSONMarshal(t, &CreateWorkflowDispatchEventRequest{}, "{}") + testJSONMarshal(t, &CreateWorkflowDispatchEventRequest{}, `{"ref":""}`) inputs := make(map[string]interface{}, 0) inputs["key"] = "value" @@ -620,12 +571,7 @@ func TestCreateWorkflowDispatchEventRequest_Marshal(t *testing.T) { Inputs: inputs, } - want := `{ - "ref": "r", - "inputs": { - "key": "value" - } - }` + want := `{"ref":"r","inputs":{"key":"value"}}` testJSONMarshal(t, u, want) } diff --git a/github/activity_notifications.go b/github/activity_notifications.go index 03476c2e2c3..1fc24503ff5 100644 --- a/github/activity_notifications.go +++ b/github/activity_notifications.go @@ -97,7 +97,7 @@ func (s *ActivityService) ListRepositoryNotifications(ctx context.Context, owner } type markReadOptions struct { - LastReadAt Timestamp `json:"last_read_at,omitempty"` + LastReadAt *Timestamp `json:"last_read_at,omitempty"` } // MarkNotificationsRead marks all notifications up to lastRead as read. @@ -105,7 +105,7 @@ type markReadOptions struct { // GitHub API docs: https://docs.github.com/en/rest/activity#mark-as-read func (s *ActivityService) MarkNotificationsRead(ctx context.Context, lastRead Timestamp) (*Response, error) { opts := &markReadOptions{ - LastReadAt: lastRead, + LastReadAt: &lastRead, } req, err := s.client.NewRequest("PUT", "notifications", opts) if err != nil { @@ -121,7 +121,7 @@ func (s *ActivityService) MarkNotificationsRead(ctx context.Context, lastRead Ti // GitHub API docs: https://docs.github.com/en/rest/activity/notifications#mark-repository-notifications-as-read func (s *ActivityService) MarkRepositoryNotificationsRead(ctx context.Context, owner, repo string, lastRead Timestamp) (*Response, error) { opts := &markReadOptions{ - LastReadAt: lastRead, + LastReadAt: &lastRead, } u := fmt.Sprintf("repos/%v/%v/notifications", owner, repo) req, err := s.client.NewRequest("PUT", u, opts) diff --git a/github/activity_notifications_test.go b/github/activity_notifications_test.go index 830c8b10cf8..b6544604454 100644 --- a/github/activity_notifications_test.go +++ b/github/activity_notifications_test.go @@ -336,25 +336,7 @@ func TestNotification_Marshal(t *testing.T) { URL: String("u"), } - want := `{ - "id": "id", - "repository": { - "id": 1, - "url": "u", - "name": "n" - }, - "subject": { - "title": "t", - "url": "u", - "latest_comment_url": "l", - "type": "t" - }, - "reason": "r", - "unread": true, - "updated_at": ` + referenceTimeStr + `, - "last_read_at": ` + referenceTimeStr + `, - "url": "u" - }` + want := `{"id":"id","repository":{"id":1,"name":"n","url":"u"},"subject":{"title":"t","url":"u","latest_comment_url":"l","type":"t"},"reason":"r","unread":true,"updated_at":` + referenceTimeStr + `,"last_read_at":` + referenceTimeStr + `,"url":"u"}` testJSONMarshal(t, u, want) } @@ -369,12 +351,7 @@ func TestNotificationSubject_Marshal(t *testing.T) { Type: String("t"), } - want := `{ - "title": "t", - "url": "u", - "latest_comment_url": "l", - "type": "t" - }` + want := `{"title":"t","url":"u","latest_comment_url":"l","type":"t"}` testJSONMarshal(t, u, want) } @@ -383,12 +360,10 @@ func TestMarkReadOptions_Marshal(t *testing.T) { testJSONMarshal(t, &markReadOptions{}, "{}") u := &markReadOptions{ - LastReadAt: Timestamp{referenceTime}, + LastReadAt: &Timestamp{referenceTime}, } - want := `{ - "last_read_at": ` + referenceTimeStr + ` - }` + want := `{"last_read_at":` + referenceTimeStr + `}` testJSONMarshal(t, u, want) } diff --git a/github/activity_star_test.go b/github/activity_star_test.go index 122c399366d..40b49147f98 100644 --- a/github/activity_star_test.go +++ b/github/activity_star_test.go @@ -298,14 +298,7 @@ func TestStarredRepository_Marshal(t *testing.T) { }, } - want := `{ - "starred_at": ` + referenceTimeStr + `, - "repo": { - "id": 1, - "url": "u", - "name": "n" - } - }` + want := `{"starred_at":` + referenceTimeStr + `,"repo":{"id":1,"name":"n","url":"u"}}` testJSONMarshal(t, u, want) } @@ -337,29 +330,7 @@ func TestStargazer_Marshal(t *testing.T) { }, } - 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" - } - }` + 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) } diff --git a/github/activity_test.go b/github/activity_test.go index ef7cf32fca5..beb968fefcb 100644 --- a/github/activity_test.go +++ b/github/activity_test.go @@ -139,10 +139,7 @@ func TestFeedLink_Marshal(t *testing.T) { Type: String("t"), } - want := `{ - "href": "h", - "type": "t" - }` + want := `{"href":"h","type":"t"}` testJSONMarshal(t, u, want) } @@ -192,47 +189,7 @@ func TestFeeds_Marshal(t *testing.T) { }, } - want := `{ - "timeline_url": "t", - "user_url": "u", - "current_user_public_url": "cupu", - "current_user_url": "cuu", - "current_user_actor_url": "cuau", - "current_user_organization_url": "cuou", - "current_user_organization_urls": ["a"], - "_links": { - "timeline": { - "href": "h", - "type": "t" - }, - "user": { - "href": "h", - "type": "t" - }, - "current_user_public": { - "href": "h", - "type": "t" - }, - "current_user": { - "href": "h", - "type": "t" - }, - "current_user_actor": { - "href": "h", - "type": "t" - }, - "current_user_organization": { - "href": "h", - "type": "t" - }, - "current_user_organizations": [ - { - "href": "h", - "type": "t" - } - ] - } - }` + want := `{"timeline_url":"t","user_url":"u","current_user_public_url":"cupu","current_user_url":"cuu","current_user_actor_url":"cuau","current_user_organization_url":"cuou","current_user_organization_urls":["a"],"_links":{"timeline":{"href":"h","type":"t"},"user":{"href":"h","type":"t"},"current_user_public":{"href":"h","type":"t"},"current_user":{"href":"h","type":"t"},"current_user_actor":{"href":"h","type":"t"},"current_user_organization":{"href":"h","type":"t"},"current_user_organizations":[{"href":"h","type":"t"}]}}` testJSONMarshal(t, u, want) } @@ -273,38 +230,7 @@ func TestFeedLinks_Marshal(t *testing.T) { }, } - want := `{ - "timeline": { - "href": "h", - "type": "t" - }, - "user": { - "href": "h", - "type": "t" - }, - "current_user_public": { - "href": "h", - "type": "t" - }, - "current_user": { - "href": "h", - "type": "t" - }, - "current_user_actor": { - "href": "h", - "type": "t" - }, - "current_user_organization": { - "href": "h", - "type": "t" - }, - "current_user_organizations": [ - { - "href": "h", - "type": "t" - } - ] - }` + want := `{"timeline":{"href":"h","type":"t"},"user":{"href":"h","type":"t"},"current_user_public":{"href":"h","type":"t"},"current_user":{"href":"h","type":"t"},"current_user_actor":{"href":"h","type":"t"},"current_user_organization":{"href":"h","type":"t"},"current_user_organizations":[{"href":"h","type":"t"}]}` testJSONMarshal(t, u, want) } diff --git a/github/activity_watching_test.go b/github/activity_watching_test.go index 15b0f330783..ec7718350fc 100644 --- a/github/activity_watching_test.go +++ b/github/activity_watching_test.go @@ -271,15 +271,7 @@ func TestSubscription_Marshal(t *testing.T) { ThreadURL: String("tu"), } - want := `{ - "subscribed": true, - "ignored": false, - "reason": "r", - "created_at": ` + referenceTimeStr + `, - "url": "u", - "repository_url": "ru", - "thread_url": "tu" - }` + want := `{"subscribed":true,"ignored":false,"reason":"r","created_at":` + referenceTimeStr + `,"url":"u","repository_url":"ru","thread_url":"tu"}` testJSONMarshal(t, u, want) } diff --git a/github/admin_orgs_test.go b/github/admin_orgs_test.go index 0282425bf06..469b2213081 100644 --- a/github/admin_orgs_test.go +++ b/github/admin_orgs_test.go @@ -150,10 +150,7 @@ func TestCreateOrgRequest_Marshal(t *testing.T) { Admin: String("a"), } - want := `{ - "login": "l", - "admin": "a" - }` + want := `{"login":"l","admin":"a"}` testJSONMarshal(t, u, want) } @@ -165,9 +162,7 @@ func TestRenameOrgRequest_Marshal(t *testing.T) { Login: String("l"), } - want := `{ - "login": "l" - }` + want := `{"login":"l"}` testJSONMarshal(t, u, want) } @@ -180,10 +175,7 @@ func TestRenameOrgResponse_Marshal(t *testing.T) { URL: String("u"), } - want := `{ - "message": "m", - "url": "u" - }` + want := `{"message":"m","url":"u"}` testJSONMarshal(t, u, want) } diff --git a/github/admin_stats_test.go b/github/admin_stats_test.go index dab2bc21fce..00b5ce5b7ef 100644 --- a/github/admin_stats_test.go +++ b/github/admin_stats_test.go @@ -219,11 +219,7 @@ func TestIssueStats_Marshal(t *testing.T) { ClosedIssues: Int(1), } - want := `{ - "total_issues": 1, - "open_issues": 1, - "closed_issues": 1 - }` + want := `{"total_issues":1,"open_issues":1,"closed_issues":1}` testJSONMarshal(t, u, want) } @@ -237,11 +233,7 @@ func TestHookStats_Marshal(t *testing.T) { InactiveHooks: Int(1), } - want := `{ - "total_hooks": 1, - "active_hooks": 1, - "inactive_hooks": 1 - }` + want := `{"total_hooks":1,"active_hooks":1,"inactive_hooks":1}` testJSONMarshal(t, u, want) } @@ -255,11 +247,7 @@ func TestMilestoneStats_Marshal(t *testing.T) { ClosedMilestones: Int(1), } - want := `{ - "total_milestones": 1, - "open_milestones": 1, - "closed_milestones": 1 - }` + want := `{"total_milestones":1,"open_milestones":1,"closed_milestones":1}` testJSONMarshal(t, u, want) } @@ -274,12 +262,7 @@ func TestOrgStats_Marshal(t *testing.T) { TotalTeamMembers: Int(1), } - want := `{ - "total_orgs": 1, - "disabled_orgs": 1, - "total_teams": 1, - "total_team_members": 1 - }` + want := `{"total_orgs":1,"disabled_orgs":1,"total_teams":1,"total_team_members":1}` testJSONMarshal(t, u, want) } @@ -294,12 +277,7 @@ func TestCommentStats_Marshal(t *testing.T) { TotalPullRequestComments: Int(1), } - want := `{ - "total_commit_comments": 1, - "total_gist_comments": 1, - "total_issue_comments": 1, - "total_pull_request_comments": 1 - }` + want := `{"total_commit_comments":1,"total_gist_comments":1,"total_issue_comments":1,"total_pull_request_comments":1}` testJSONMarshal(t, u, want) } @@ -311,9 +289,7 @@ func TestPageStats_Marshal(t *testing.T) { TotalPages: Int(1), } - want := `{ - "total_pages": 1 - }` + want := `{"total_pages":1}` testJSONMarshal(t, u, want) } @@ -327,11 +303,7 @@ func TestUserStats_Marshal(t *testing.T) { SuspendedUsers: Int(1), } - want := `{ - "total_users": 1, - "admin_users": 1, - "suspended_users": 1 - }` + want := `{"total_users":1,"admin_users":1,"suspended_users":1}` testJSONMarshal(t, u, want) } @@ -345,11 +317,7 @@ func TestGistStats_Marshal(t *testing.T) { PublicGists: Int(1), } - want := `{ - "total_gists": 1, - "private_gists": 1, - "public_gists": 1 - }` + want := `{"total_gists":1,"private_gists":1,"public_gists":1}` testJSONMarshal(t, u, want) } @@ -364,12 +332,7 @@ func TestPullStats_Marshal(t *testing.T) { UnmergablePulls: Int(1), } - want := `{ - "total_pulls": 1, - "merged_pulls": 1, - "mergeable_pulls": 1, - "unmergeable_pulls": 1 - }` + want := `{"total_pulls":1,"merged_pulls":1,"mergeable_pulls":1,"unmergeable_pulls":1}` testJSONMarshal(t, u, want) } @@ -386,14 +349,7 @@ func TestRepoStats_Marshal(t *testing.T) { TotalWikis: Int(1), } - want := `{ - "total_repos": 1, - "root_repos": 1, - "fork_repos": 1, - "org_repos": 1, - "total_pushes": 1, - "total_wikis": 1 - }` + want := `{"total_repos":1,"root_repos":1,"fork_repos":1,"org_repos":1,"total_pushes":1,"total_wikis":1}` testJSONMarshal(t, u, want) } @@ -458,62 +414,7 @@ func TestAdminStats_Marshal(t *testing.T) { }, } - want := `{ - "repos": { - "total_repos": 212, - "root_repos": 194, - "fork_repos": 18, - "org_repos": 51, - "total_pushes": 3082, - "total_wikis": 15 - }, - "hooks": { - "total_hooks": 27, - "active_hooks": 23, - "inactive_hooks": 4 - }, - "pages": { - "total_pages": 36 - }, - "orgs": { - "total_orgs": 33, - "disabled_orgs": 0, - "total_teams": 60, - "total_team_members": 314 - }, - "users": { - "total_users": 254, - "admin_users": 45, - "suspended_users": 21 - }, - "pulls": { - "total_pulls": 86, - "merged_pulls": 60, - "mergeable_pulls": 21, - "unmergeable_pulls": 3 - }, - "issues": { - "total_issues": 179, - "open_issues": 83, - "closed_issues": 96 - }, - "milestones": { - "total_milestones": 7, - "open_milestones": 6, - "closed_milestones": 1 - }, - "gists": { - "total_gists": 178, - "private_gists": 151, - "public_gists": 25 - }, - "comments": { - "total_commit_comments": 6, - "total_gist_comments": 28, - "total_issue_comments": 366, - "total_pull_request_comments": 30 - } - }` + want := `{"issues":{"total_issues":179,"open_issues":83,"closed_issues":96},"hooks":{"total_hooks":27,"active_hooks":23,"inactive_hooks":4},"milestones":{"total_milestones":7,"open_milestones":6,"closed_milestones":1},"orgs":{"total_orgs":33,"disabled_orgs":0,"total_teams":60,"total_team_members":314},"comments":{"total_commit_comments":6,"total_gist_comments":28,"total_issue_comments":366,"total_pull_request_comments":30},"pages":{"total_pages":36},"users":{"total_users":254,"admin_users":45,"suspended_users":21},"gists":{"total_gists":178,"private_gists":151,"public_gists":25},"pulls":{"total_pulls":86,"merged_pulls":60,"mergeable_pulls":21,"unmergeable_pulls":3},"repos":{"total_repos":212,"root_repos":194,"fork_repos":18,"org_repos":51,"total_pushes":3082,"total_wikis":15}}` testJSONMarshal(t, u, want) } diff --git a/github/admin_test.go b/github/admin_test.go index 207121c35cc..8b9ec86d0e1 100644 --- a/github/admin_test.go +++ b/github/admin_test.go @@ -174,18 +174,7 @@ func TestTeamLDAPMapping_Marshal(t *testing.T) { RepositoriesURL: String("ru"), } - want := `{ - "id": 1, - "ldap_dn": "ldapdn", - "url": "u", - "name": "n", - "slug": "s", - "description": "d", - "privacy": "p", - "permission": "per", - "members_url": "mu", - "repositories_url": "ru" - }` + want := `{"id":1,"ldap_dn":"ldapdn","url":"u","name":"n","slug":"s","description":"d","privacy":"p","permission":"per","members_url":"mu","repositories_url":"ru"}` testJSONMarshal(t, u, want) } @@ -213,25 +202,7 @@ func TestUserLDAPMapping_Marshal(t *testing.T) { SubscriptionsURL: String("subu"), } - want := `{ - "id": 1, - "ldap_dn": "ldapdn", - "login": "l", - "avatar_url": "au", - "gravatar_id": "gi", - "type": "t", - "site_admin": true, - "url": "u", - "events_url": "eu", - "following_url": "fu", - "followers_url": "fu", - "gists_url": "gu", - "organizations_url": "ou", - "received_events_url": "reu", - "repos_url": "ru", - "starred_url": "su", - "subscriptions_url": "subu" - }` + want := `{"id":1,"ldap_dn":"ldapdn","login":"l","avatar_url":"au","gravatar_id":"gi","type":"t","site_admin":true,"url":"u","events_url":"eu","following_url":"fu","followers_url":"fu","gists_url":"gu","organizations_url":"ou","received_events_url":"reu","repos_url":"ru","starred_url":"su","subscriptions_url":"subu"}` testJSONMarshal(t, u, want) } @@ -252,18 +223,7 @@ func TestEnterprise_Marshal(t *testing.T) { UpdatedAt: &Timestamp{referenceTime}, } - want := `{ - "id": 1, - "slug": "s", - "name": "n", - "node_id": "nid", - "avatar_url": "au", - "description": "d", - "website_url": "wu", - "html_url": "hu", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - }` + want := `{"id":1,"slug":"s","name":"n","node_id":"nid","avatar_url":"au","description":"d","website_url":"wu","html_url":"hu","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `}` testJSONMarshal(t, u, want) } diff --git a/github/admin_users_test.go b/github/admin_users_test.go index 354943d50a2..309ec67e08b 100644 --- a/github/admin_users_test.go +++ b/github/admin_users_test.go @@ -184,10 +184,7 @@ func TestCreateUserRequest_Marshal(t *testing.T) { Email: String("e"), } - want := `{ - "login": "l", - "email": "e" - }` + want := `{"login":"l","email":"e"}` testJSONMarshal(t, u, want) } @@ -201,9 +198,7 @@ func TestImpersonateUserOptions_Marshal(t *testing.T) { }, } - want := `{ - "scopes": ["s"] - }` + want := `{"scopes":["s"]}` testJSONMarshal(t, u, want) } @@ -217,11 +212,7 @@ func TestOAuthAPP_Marshal(t *testing.T) { ClientID: String("cid"), } - want := `{ - "url": "u", - "name": "n", - "client_id": "cid" - }` + want := `{"url":"u","name":"n","client_id":"cid"}` testJSONMarshal(t, u, want) } @@ -250,24 +241,7 @@ func TestUserAuthorization_Marshal(t *testing.T) { Fingerprint: String("f"), } - 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" - }` + 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"}` testJSONMarshal(t, u, want) } diff --git a/github/apps_installation_test.go b/github/apps_installation_test.go index 56f0ad9e81d..5599ba38c08 100644 --- a/github/apps_installation_test.go +++ b/github/apps_installation_test.go @@ -175,7 +175,7 @@ func TestAppsService_RevokeInstallationToken(t *testing.T) { } func TestListRepositories_Marshal(t *testing.T) { - testJSONMarshal(t, &ListRepositories{}, "{}") + testJSONMarshal(t, &ListRepositories{}, `{"repositories":null}`) u := &ListRepositories{ TotalCount: Int(1), @@ -188,14 +188,7 @@ func TestListRepositories_Marshal(t *testing.T) { }, } - want := `{ - "total_count": 1, - "repositories": [{ - "id":1, - "name":"n", - "url":"u" - }] - }` + want := `{"total_count":1,"repositories":[{"id":1,"name":"n","url":"u"}]}` testJSONMarshal(t, u, want) } diff --git a/github/apps_manifest_test.go b/github/apps_manifest_test.go index 833982e4850..9d226eb17bf 100644 --- a/github/apps_manifest_test.go +++ b/github/apps_manifest_test.go @@ -106,41 +106,7 @@ func TestAppConfig_Marshal(t *testing.T) { PEM: String("pem"), } - 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 + `, - "client_id": "ci", - "client_secret": "cs", - "webhook_secret": "ws", - "pem": "pem" - }` + 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 + `,"client_id":"ci","client_secret":"cs","webhook_secret":"ws","pem":"pem"}` testJSONMarshal(t, u, want) } diff --git a/github/apps_marketplace_test.go b/github/apps_marketplace_test.go index dcf5eb89ca1..06bded52334 100644 --- a/github/apps_marketplace_test.go +++ b/github/apps_marketplace_test.go @@ -255,21 +255,7 @@ func TestMarketplacePlan_Marshal(t *testing.T) { HasFreeTrial: Bool(false), } - want := `{ - "url": "u", - "accounts_url": "au", - "id": 1, - "number": 1, - "name": "n", - "description": "d", - "monthly_price_in_cents": 1, - "yearly_price_in_cents": 1, - "price_model": "pm", - "unit_name": "un", - "bullets": ["b"], - "state": "s", - "has_free_trial": false - }` + want := `{"url":"u","accounts_url":"au","id":1,"number":1,"name":"n","description":"d","monthly_price_in_cents":1,"yearly_price_in_cents":1,"price_model":"pm","unit_name":"un","bullets":["b"],"state":"s","has_free_trial":false}` testJSONMarshal(t, u, want) } @@ -301,29 +287,7 @@ func TestMarketplacePurchase_Marshal(t *testing.T) { UpdatedAt: &Timestamp{referenceTime}, } - want := `{ - "billing_cycle": "bc", - "next_billing_date": ` + referenceTimeStr + `, - "unit_count": 1, - "plan": { - "url": "u", - "accounts_url": "au", - "id": 1, - "number": 1, - "name": "n", - "description": "d", - "monthly_price_in_cents": 1, - "yearly_price_in_cents": 1, - "price_model": "pm", - "unit_name": "un", - "bullets": ["b"], - "state": "s", - "has_free_trial": false - }, - "on_free_trial": false, - "free_trial_ends_on": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - }` + want := `{"billing_cycle":"bc","next_billing_date":` + referenceTimeStr + `,"unit_count":1,"plan":{"url":"u","accounts_url":"au","id":1,"number":1,"name":"n","description":"d","monthly_price_in_cents":1,"yearly_price_in_cents":1,"price_model":"pm","unit_name":"un","bullets":["b"],"state":"s","has_free_trial":false},"on_free_trial":false,"free_trial_ends_on":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `}` testJSONMarshal(t, u, want) } @@ -352,26 +316,7 @@ func TestMarketplacePendingChange_Marshal(t *testing.T) { }, } - want := `{ - "effective_date": ` + referenceTimeStr + `, - "unit_count": 1, - "id": 1, - "plan": { - "url": "u", - "accounts_url": "au", - "id": 1, - "number": 1, - "name": "n", - "description": "d", - "monthly_price_in_cents": 1, - "yearly_price_in_cents": 1, - "price_model": "pm", - "unit_name": "un", - "bullets": ["b"], - "state": "s", - "has_free_trial": false - } - }` + want := `{"effective_date":` + referenceTimeStr + `,"unit_count":1,"id":1,"plan":{"url":"u","accounts_url":"au","id":1,"number":1,"name":"n","description":"d","monthly_price_in_cents":1,"yearly_price_in_cents":1,"price_model":"pm","unit_name":"un","bullets":["b"],"state":"s","has_free_trial":false}}` testJSONMarshal(t, u, want) } @@ -430,56 +375,7 @@ func TestMarketplacePlanAccount_Marshal(t *testing.T) { }, } - want := `{ - "url": "u", - "type": "t", - "id": 1, - "login": "l", - "organization_billing_email": "obe", - "marketplace_purchase": { - "billing_cycle": "bc", - "next_billing_date": ` + referenceTimeStr + `, - "unit_count": 1, - "plan": { - "url": "u", - "accounts_url": "au", - "id": 1, - "number": 1, - "name": "n", - "description": "d", - "monthly_price_in_cents": 1, - "yearly_price_in_cents": 1, - "price_model": "pm", - "unit_name": "un", - "bullets": ["b"], - "state": "s", - "has_free_trial": false - }, - "on_free_trial": false, - "free_trial_ends_on": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - }, - "marketplace_pending_change": { - "effective_date": ` + referenceTimeStr + `, - "unit_count": 1, - "id": 1, - "plan": { - "url": "u", - "accounts_url": "au", - "id": 1, - "number": 1, - "name": "n", - "description": "d", - "monthly_price_in_cents": 1, - "yearly_price_in_cents": 1, - "price_model": "pm", - "unit_name": "un", - "bullets": ["b"], - "state": "s", - "has_free_trial": false - } - } - }` + want := `{"url":"u","type":"t","id":1,"login":"l","organization_billing_email":"obe","marketplace_purchase":{"billing_cycle":"bc","next_billing_date":` + referenceTimeStr + `,"unit_count":1,"plan":{"url":"u","accounts_url":"au","id":1,"number":1,"name":"n","description":"d","monthly_price_in_cents":1,"yearly_price_in_cents":1,"price_model":"pm","unit_name":"un","bullets":["b"],"state":"s","has_free_trial":false},"on_free_trial":false,"free_trial_ends_on":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"marketplace_pending_change":{"effective_date":` + referenceTimeStr + `,"unit_count":1,"id":1,"plan":{"url":"u","accounts_url":"au","id":1,"number":1,"name":"n","description":"d","monthly_price_in_cents":1,"yearly_price_in_cents":1,"price_model":"pm","unit_name":"un","bullets":["b"],"state":"s","has_free_trial":false}}}` testJSONMarshal(t, u, want) } diff --git a/github/apps_test.go b/github/apps_test.go index d3e7c434233..61b881a9c63 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -609,11 +609,7 @@ func TestContentReference_Marshal(t *testing.T) { Reference: String("r"), } - want := `{ - "id": 1, - "node_id": "nid", - "reference": "r" - }` + want := `{"id":1,"node_id":"nid","reference":"r"}` testJSONMarshal(t, u, want) } @@ -627,11 +623,7 @@ func TestAttachment_Marshal(t *testing.T) { Body: String("b"), } - want := `{ - "id": 1, - "title": "t", - "body": "b" - }` + want := `{"id":1,"title":"t","body":"b"}` testJSONMarshal(t, u, want) } @@ -674,40 +666,7 @@ func TestInstallationPermissions_Marshal(t *testing.T) { 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" - }` + 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) } @@ -809,103 +768,7 @@ func TestInstallation_Marshal(t *testing.T) { 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 + ` - }` + 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) } @@ -951,43 +814,7 @@ func TestInstallationTokenOptions_Marshal(t *testing.T) { }, } - 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" - } - }` + 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) } @@ -1041,51 +868,7 @@ func TestInstallationToken_Marshal(t *testing.T) { }, } - 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" - } - ] - }` + 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,"name":"n","url":"u"}]}` testJSONMarshal(t, u, want) } @@ -1160,72 +943,7 @@ func TestApp_Marshal(t *testing.T) { 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"] - }` + 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) } diff --git a/github/authorizations_test.go b/github/authorizations_test.go index bd7ff29d811..53a3861b3cb 100644 --- a/github/authorizations_test.go +++ b/github/authorizations_test.go @@ -216,14 +216,7 @@ func TestAuthorizationUpdateRequest_Marshal(t *testing.T) { Fingerprint: String("f"), } - want := `{ - "scopes": ["s"], - "add_scopes": ["a"], - "remove_scopes": ["r"], - "note": "n", - "note_url": "nu", - "fingerprint": "f" - }` + want := `{"scopes":["s"],"add_scopes":["a"],"remove_scopes":["r"],"note":"n","note_url":"nu","fingerprint":"f"}` testJSONMarshal(t, u, want) } @@ -240,14 +233,7 @@ func TestAuthorizationRequest_Marshal(t *testing.T) { Fingerprint: String("f"), } - want := `{ - "scopes": ["s"], - "client_id": "cid", - "client_secret": "cs", - "note": "n", - "note_url": "nu", - "fingerprint": "f" - }` + want := `{"scopes":["s"],"note":"n","note_url":"nu","client_id":"cid","client_secret":"cs","fingerprint":"f"}` testJSONMarshal(t, u, want) } @@ -261,11 +247,7 @@ func TestAuthorizationApp_Marshal(t *testing.T) { ClientID: String("cid"), } - want := `{ - "url": "u", - "name": "n", - "client_id": "cid" - }` + want := `{"url":"u","name":"n","client_id":"cid"}` testJSONMarshal(t, u, want) } @@ -286,18 +268,7 @@ func TestGrant_Marshal(t *testing.T) { Scopes: []string{"s"}, } - want := `{ - "id": 1, - "url": "u", - "app": { - "url": "u", - "name": "n", - "client_id": "cid" - }, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "scopes": ["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) } @@ -344,44 +315,7 @@ func TestAuthorization_Marshal(t *testing.T) { }, } - 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" - } - }` + 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) } diff --git a/github/billing_test.go b/github/billing_test.go index 52b338b8347..07df6a000ad 100644 --- a/github/billing_test.go +++ b/github/billing_test.go @@ -355,11 +355,7 @@ func TestMinutesUsedBreakdown_Marshal(t *testing.T) { "WINDOWS": 1, } - want := `{ - "UBUNTU": 1, - "MACOS": 1, - "WINDOWS": 1 - }` + want := `{"MACOS":1,"UBUNTU":1,"WINDOWS":1}` testJSONMarshal(t, u, want) } @@ -378,22 +374,13 @@ func TestActionBilling_Marshal(t *testing.T) { }, } - want := `{ - "total_minutes_used": 1, - "total_paid_minutes_used": 1, - "included_minutes": 1, - "minutes_used_breakdown": { - "UBUNTU": 1, - "MACOS": 1, - "WINDOWS": 1 - } - }` + want := `{"total_minutes_used":1,"total_paid_minutes_used":1,"included_minutes":1,"minutes_used_breakdown":{"MACOS":1,"UBUNTU":1,"WINDOWS":1}}` testJSONMarshal(t, u, want) } func TestPackageBilling_Marshal(t *testing.T) { - testJSONMarshal(t, &PackageBilling{}, "{}") + testJSONMarshal(t, &PackageBilling{}, `{"total_gigabytes_bandwidth_used":0,"total_paid_gigabytes_bandwidth_used":0,"included_gigabytes_bandwidth":0}`) u := &PackageBilling{ TotalGigabytesBandwidthUsed: 1, @@ -401,17 +388,13 @@ func TestPackageBilling_Marshal(t *testing.T) { IncludedGigabytesBandwidth: 1, } - want := `{ - "total_gigabytes_bandwidth_used": 1, - "total_paid_gigabytes_bandwidth_used": 1, - "included_gigabytes_bandwidth": 1 - }` + want := `{"total_gigabytes_bandwidth_used":1,"total_paid_gigabytes_bandwidth_used":1,"included_gigabytes_bandwidth":1}` testJSONMarshal(t, u, want) } func TestStorageBilling_Marshal(t *testing.T) { - testJSONMarshal(t, &StorageBilling{}, "{}") + testJSONMarshal(t, &StorageBilling{}, `{"days_left_in_billing_cycle":0,"estimated_paid_storage_for_month":0,"estimated_storage_for_month":0}`) u := &StorageBilling{ DaysLeftInBillingCycle: 1, @@ -419,11 +402,7 @@ func TestStorageBilling_Marshal(t *testing.T) { EstimatedStorageForMonth: 1, } - want := `{ - "days_left_in_billing_cycle": 1, - "estimated_paid_storage_for_month": 1, - "estimated_storage_for_month": 1 - }` + want := `{"days_left_in_billing_cycle":1,"estimated_paid_storage_for_month":1,"estimated_storage_for_month":1}` testJSONMarshal(t, u, want) } diff --git a/github/checks_test.go b/github/checks_test.go index 2fdd2476e56..94e4d9707a5 100644 --- a/github/checks_test.go +++ b/github/checks_test.go @@ -732,92 +732,7 @@ func Test_CheckRunMarshal(t *testing.T) { }, }, } - w := fmt.Sprintf(`{ - "id": 1, - "node_id": "n", - "head_sha": "h", - "external_id": "1", - "url": "u", - "html_url": "u", - "details_url": "u", - "status": "s", - "conclusion": "c", - "started_at": "%s", - "completed_at": "%s", - "output": { - "title": "t", - "summary": "s", - "text": "t", - "annotations_count": 1, - "annotations_url": "a", - "annotations": [ - { - "path": "p", - "start_line": 1, - "end_line": 1, - "annotation_level": "a", - "message": "m", - "title": "t", - "raw_details": "r" - } - ], - "images": [ - { - "alt": "a", - "image_url": "i", - "caption": "c" - } - ] - }, - "name": "n", - "check_suite": { - "id": 1 - }, - "app": { - "id": 1, - "node_id": "n", - "owner": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "name": "n", - "description": "d", - "external_url": "u", - "html_url": "h", - "created_at": "%s", - "updated_at": "%s" - }, - "pull_requests": [ - { - "id": 1, - "number": 1, - "url": "u", - "head": { - "ref": "r", - "sha": "s", - "repo": { - "id": 1, - "name": "n", - "url": "s" - } - }, - "base": { - "ref": "r", - "sha": "s", - "repo": { - "id": 1, - "name": "n", - "url": "u" - } - } - } - ] - }`, ts, ts, ts, ts) + w := fmt.Sprintf(`{"id":1,"node_id":"n","head_sha":"h","external_id":"1","url":"u","html_url":"u","details_url":"u","status":"s","conclusion":"c","started_at":"%s","completed_at":"%s","output":{"title":"t","summary":"s","text":"t","annotations_count":1,"annotations_url":"a","annotations":[{"path":"p","start_line":1,"end_line":1,"annotation_level":"a","message":"m","title":"t","raw_details":"r"}],"images":[{"alt":"a","image_url":"i","caption":"c"}]},"name":"n","check_suite":{"id":1},"app":{"id":1,"node_id":"n","owner":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"name":"n","description":"d","external_url":"u","html_url":"h","created_at":"%s","updated_at":"%s"},"pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}]}`, ts, ts, ts, ts) testJSONMarshal(t, &c, w) } @@ -890,67 +805,7 @@ func Test_CheckSuiteMarshal(t *testing.T) { }, } - w := fmt.Sprintf(`{ - "id": 1, - "node_id": "n", - "head_branch": "h", - "head_sha": "h", - "url": "u", - "before": "b", - "after": "a", - "status": "s", - "conclusion": "c", - "app": { - "id": 1, - "node_id": "n", - "owner": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "name": "n", - "description": "d", - "external_url": "u", - "html_url": "h", - "created_at": "%s", - "updated_at": "%s" - }, - "repository": { - "id": 1 - }, - "pull_requests": [ - { - "id": 1, - "number": 1, - "url": "u", - "head": { - "ref": "r", - "sha": "s", - "repo": { - "id": 1, - "name": "n", - "url": "s" - } - }, - "base": { - "ref": "r", - "sha": "s", - "repo": { - "id": 1, - "name": "n", - "url": "u" - } - } - } - ], - "head_commit": { - "sha": "s" - } - }`, ts, ts) + w := fmt.Sprintf(`{"id":1,"node_id":"n","head_branch":"h","head_sha":"h","url":"u","before":"b","after":"a","status":"s","conclusion":"c","app":{"id":1,"node_id":"n","owner":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"name":"n","description":"d","external_url":"u","html_url":"h","created_at":"%s","updated_at":"%s"},"repository":{"id":1},"pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}],"head_commit":{"sha":"s"}}`, ts, ts) testJSONMarshal(t, &c, w) } @@ -970,17 +825,7 @@ func TestCheckRunAnnotation_Marshal(t *testing.T) { RawDetails: String("rd"), } - want := `{ - "path": "p", - "start_line": 1, - "end_line": 1, - "start_column": 1, - "end_column": 1, - "annotation_level": "al", - "message": "m", - "title": "t", - "raw_details": "rd" - }` + want := `{"path":"p","start_line":1,"end_line":1,"start_column":1,"end_column":1,"annotation_level":"al","message":"m","title":"t","raw_details":"rd"}` testJSONMarshal(t, u, want) } @@ -994,17 +839,13 @@ func TestCheckRunImage_Marshal(t *testing.T) { Caption: String("c"), } - want := `{ - "alt": "a", - "image_url": "i", - "caption": "c" - }` + want := `{"alt":"a","image_url":"i","caption":"c"}` testJSONMarshal(t, u, want) } func TestCheckRunAction_Marshal(t *testing.T) { - testJSONMarshal(t, &CheckRunAction{}, "{}") + testJSONMarshal(t, &CheckRunAction{}, `{"label":"","description":"","identifier":""}`) u := &CheckRunAction{ Label: "l", @@ -1012,11 +853,7 @@ func TestCheckRunAction_Marshal(t *testing.T) { Identifier: "i", } - want := `{ - "label": "l", - "description": "d", - "identifier": "i" - }` + want := `{"label":"l","description":"d","identifier":"i"}` testJSONMarshal(t, u, want) } @@ -1029,26 +866,20 @@ func TestAutoTriggerCheck_Marshal(t *testing.T) { Setting: Bool(false), } - want := `{ - "app_id": 1, - "setting": false - }` + want := `{"app_id":1,"setting":false}` testJSONMarshal(t, u, want) } func TestCreateCheckSuiteOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &CreateCheckSuiteOptions{}, "{}") + testJSONMarshal(t, &CreateCheckSuiteOptions{}, `{"head_sha":""}`) u := &CreateCheckSuiteOptions{ HeadSHA: "hsha", HeadBranch: String("hb"), } - want := `{ - "head_sha": "hsha", - "head_branch": "hb" - }` + want := `{"head_sha":"hsha","head_branch":"hb"}` testJSONMarshal(t, u, want) } @@ -1084,39 +915,13 @@ func TestCheckRunOutput_Marshal(t *testing.T) { }, } - want := `{ - "title": "ti", - "summary": "s", - "text": "t", - "annotations_count": 1, - "annotations_url": "au", - "annotations": [ - { - "path": "p", - "start_line": 1, - "end_line": 1, - "start_column": 1, - "end_column": 1, - "annotation_level": "al", - "message": "m", - "title": "t", - "raw_details": "rd" - } - ], - "images": [ - { - "alt": "a", - "image_url": "i", - "caption": "c" - } - ] - }` + want := `{"title":"ti","summary":"s","text":"t","annotations_count":1,"annotations_url":"au","annotations":[{"path":"p","start_line":1,"end_line":1,"start_column":1,"end_column":1,"annotation_level":"al","message":"m","title":"t","raw_details":"rd"}],"images":[{"alt":"a","image_url":"i","caption":"c"}]}` testJSONMarshal(t, u, want) } func TestCreateCheckRunOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &CreateCheckRunOptions{}, "{}") + testJSONMarshal(t, &CreateCheckRunOptions{}, `{"name":"","head_sha":""}`) u := &CreateCheckRunOptions{ Name: "n", @@ -1163,56 +968,13 @@ func TestCreateCheckRunOptions_Marshal(t *testing.T) { }, } - want := `{ - "name": "n", - "head_sha": "hsha", - "details_url": "durl", - "external_id": "eid", - "status": "s", - "conclusion": "c", - "started_at": ` + referenceTimeStr + `, - "completed_at": ` + referenceTimeStr + `, - "output": { - "title": "ti", - "summary": "s", - "text": "t", - "annotations_count": 1, - "annotations_url": "au", - "annotations": [ - { - "path": "p", - "start_line": 1, - "end_line": 1, - "start_column": 1, - "end_column": 1, - "annotation_level": "al", - "message": "m", - "title": "t", - "raw_details": "rd" - } - ], - "images": [ - { - "alt": "a", - "image_url": "i", - "caption": "c" - } - ] - }, - "actions": [ - { - "label": "l", - "description": "d", - "identifier": "i" - } - ] - }` + want := `{"name":"n","head_sha":"hsha","details_url":"durl","external_id":"eid","status":"s","conclusion":"c","started_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `,"output":{"title":"ti","summary":"s","text":"t","annotations_count":1,"annotations_url":"au","annotations":[{"path":"p","start_line":1,"end_line":1,"start_column":1,"end_column":1,"annotation_level":"al","message":"m","title":"t","raw_details":"rd"}],"images":[{"alt":"a","image_url":"i","caption":"c"}]},"actions":[{"label":"l","description":"d","identifier":"i"}]}` testJSONMarshal(t, u, want) } func TestUpdateCheckRunOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &UpdateCheckRunOptions{}, "{}") + testJSONMarshal(t, &UpdateCheckRunOptions{}, `{"name":""}`) u := &UpdateCheckRunOptions{ Name: "n", @@ -1257,48 +1019,7 @@ func TestUpdateCheckRunOptions_Marshal(t *testing.T) { }, } - want := `{ - "name": "n", - "details_url": "durl", - "external_id": "eid", - "status": "s", - "conclusion": "c", - "completed_at": ` + referenceTimeStr + `, - "output": { - "title": "ti", - "summary": "s", - "text": "t", - "annotations_count": 1, - "annotations_url": "au", - "annotations": [ - { - "path": "p", - "start_line": 1, - "end_line": 1, - "start_column": 1, - "end_column": 1, - "annotation_level": "al", - "message": "m", - "title": "t", - "raw_details": "rd" - } - ], - "images": [ - { - "alt": "a", - "image_url": "i", - "caption": "c" - } - ] - }, - "actions": [ - { - "label": "l", - "description": "d", - "identifier": "i" - } - ] - }` + want := `{"name":"n","details_url":"durl","external_id":"eid","status":"s","conclusion":"c","completed_at":` + referenceTimeStr + `,"output":{"title":"ti","summary":"s","text":"t","annotations_count":1,"annotations_url":"au","annotations":[{"path":"p","start_line":1,"end_line":1,"start_column":1,"end_column":1,"annotation_level":"al","message":"m","title":"t","raw_details":"rd"}],"images":[{"alt":"a","image_url":"i","caption":"c"}]},"actions":[{"label":"l","description":"d","identifier":"i"}]}` testJSONMarshal(t, u, want) } @@ -1398,97 +1119,7 @@ func TestListCheckRunsResults_Marshal(t *testing.T) { }, } - w := `{ - "total_count": 1, - "check_runs": [ - { - "id": 1, - "node_id": "n", - "head_sha": "h", - "external_id": "1", - "url": "u", - "html_url": "u", - "details_url": "u", - "status": "s", - "conclusion": "c", - "started_at": ` + referenceTimeStr + `, - "completed_at": ` + referenceTimeStr + `, - "output": { - "title": "t", - "summary": "s", - "text": "t", - "annotations_count": 1, - "annotations_url": "a", - "annotations": [ - { - "path": "p", - "start_line": 1, - "end_line": 1, - "annotation_level": "a", - "message": "m", - "title": "t", - "raw_details": "r" - } - ], - "images": [ - { - "alt": "a", - "image_url": "i", - "caption": "c" - } - ] - }, - "name": "n", - "check_suite": { - "id": 1 - }, - "app": { - "id": 1, - "node_id": "n", - "owner": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "name": "n", - "description": "d", - "external_url": "u", - "html_url": "h", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - }, - "pull_requests": [ - { - "id": 1, - "number": 1, - "url": "u", - "head": { - "ref": "r", - "sha": "s", - "repo": { - "id": 1, - "name": "n", - "url": "s" - } - }, - "base": { - "ref": "r", - "sha": "s", - "repo": { - "id": 1, - "name": "n", - "url": "u" - } - } - } - ] - } - ] - }` + w := `{"total_count":1,"check_runs":[{"id":1,"node_id":"n","head_sha":"h","external_id":"1","url":"u","html_url":"u","details_url":"u","status":"s","conclusion":"c","started_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `,"output":{"title":"t","summary":"s","text":"t","annotations_count":1,"annotations_url":"a","annotations":[{"path":"p","start_line":1,"end_line":1,"annotation_level":"a","message":"m","title":"t","raw_details":"r"}],"images":[{"alt":"a","image_url":"i","caption":"c"}]},"name":"n","check_suite":{"id":1},"app":{"id":1,"node_id":"n","owner":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"name":"n","description":"d","external_url":"u","html_url":"h","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}]}]}` testJSONMarshal(t, &l, w) } @@ -1563,72 +1194,7 @@ func TestListCheckSuiteResults_Marshal(t *testing.T) { }, } - w := `{ - "total_count": 1, - "check_suites": [ - { - "id": 1, - "node_id": "n", - "head_branch": "h", - "head_sha": "h", - "url": "u", - "before": "b", - "after": "a", - "status": "s", - "conclusion": "c", - "app": { - "id": 1, - "node_id": "n", - "owner": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "name": "n", - "description": "d", - "external_url": "u", - "html_url": "h", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - }, - "repository": { - "id": 1 - }, - "pull_requests": [ - { - "id": 1, - "number": 1, - "url": "u", - "head": { - "ref": "r", - "sha": "s", - "repo": { - "id": 1, - "name": "n", - "url": "s" - } - }, - "base": { - "ref": "r", - "sha": "s", - "repo": { - "id": 1, - "name": "n", - "url": "u" - } - } - } - ], - "head_commit": { - "sha": "s" - } - } - ] - }` + w := `{"total_count":1,"check_suites":[{"id":1,"node_id":"n","head_branch":"h","head_sha":"h","url":"u","before":"b","after":"a","status":"s","conclusion":"c","app":{"id":1,"node_id":"n","owner":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"name":"n","description":"d","external_url":"u","html_url":"h","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"repository":{"id":1},"pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}],"head_commit":{"sha":"s"}}]}` testJSONMarshal(t, &l, w) } @@ -1645,14 +1211,7 @@ func TestCheckSuitePreferenceOptions_Marshal(t *testing.T) { }, } - want := `{ - "auto_trigger_checks": [ - { - "app_id": 1, - "setting": false - } - ] - }` + want := `{"auto_trigger_checks":[{"app_id":1,"setting":false}]}` testJSONMarshal(t, u, want) } @@ -1669,14 +1228,7 @@ func TestPreferenceList_Marshal(t *testing.T) { }, } - want := `{ - "auto_trigger_checks": [ - { - "app_id": 1, - "setting": false - } - ] - }` + want := `{"auto_trigger_checks":[{"app_id":1,"setting":false}]}` testJSONMarshal(t, u, want) } @@ -1700,21 +1252,7 @@ func TestCheckSuitePreferenceResults_Marshal(t *testing.T) { }, } - want := `{ - "preferences": { - "auto_trigger_checks": [ - { - "app_id": 1, - "setting": false - } - ] - }, - "repository": { - "id":1, - "name":"n", - "url":"u" - } - }` + want := `{"preferences":{"auto_trigger_checks":[{"app_id":1,"setting":false}]},"repository":{"id":1,"name":"n","url":"u"}}` testJSONMarshal(t, u, want) } diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 7911fca6360..0228cf318eb 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -868,30 +868,7 @@ func TestAlert_Marshal(t *testing.T) { HTMLURL: String("hurl"), } - want := `{ - "rule_id": "rid", - "rule_severity": "rs", - "rule_description": "rd", - "tool": { - "name": "n", - "guid": "g", - "version": "v" - }, - "created_at": ` + referenceTimeStr + `, - "state": "fixed", - "closed_by": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "closed_at": ` + referenceTimeStr + `, - "url": "url", - "html_url": "hurl" - }` + want := `{"rule_id":"rid","rule_severity":"rs","rule_description":"rd","tool":{"name":"n","guid":"g","version":"v"},"created_at":` + referenceTimeStr + `,"state":"fixed","closed_by":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"closed_at":` + referenceTimeStr + `,"url":"url","html_url":"hurl"}` testJSONMarshal(t, u, want) } @@ -907,13 +884,7 @@ func TestLocation_Marshal(t *testing.T) { EndColumn: Int(4), } - want := `{ - "path": "path", - "start_line": 1, - "end_line": 2, - "start_column": 3, - "end_column": 4 - }` + want := `{"path":"path","start_line":1,"end_line":2,"start_column":3,"end_column":4}` testJSONMarshal(t, u, want) } @@ -932,16 +903,7 @@ func TestRule_Marshal(t *testing.T) { Help: String("Help Text"), } - want := `{ - "id": "1", - "severity": "3", - "description": "description", - "name": "first", - "security_severity_level": "2", - "full_description": "summary", - "tags": ["tag1", "tag2"], - "help": "Help Text" - }` + want := `{"id":"1","severity":"3","description":"description","name":"first","security_severity_level":"2","full_description":"summary","tags":["tag1","tag2"],"help":"Help Text"}` testJSONMarshal(t, u, want) } @@ -955,11 +917,7 @@ func TestTool_Marshal(t *testing.T) { Version: String("ver"), } - want := `{ - "name": "name", - "guid": "guid", - "version": "ver" - }` + want := `{"name":"name","guid":"guid","version":"ver"}` testJSONMarshal(t, u, want) } @@ -971,9 +929,7 @@ func TestMessage_Marshal(t *testing.T) { Text: String("text"), } - want := `{ - "text": "text" - }` + want := `{"text":"text"}` testJSONMarshal(t, u, want) } diff --git a/github/event_test.go b/github/event_test.go index 6d20582c2f7..604afa62d54 100644 --- a/github/event_test.go +++ b/github/event_test.go @@ -82,51 +82,7 @@ func TestEvent_Marshal(t *testing.T) { ID: String("id"), } - want := `{ - "type": "t", - "public": false, - "payload": { - "key": "value" - }, - "repo": { - "id": 1, - "name": "n", - "url": "s" - }, - "actor": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "org": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "created_at": ` + referenceTimeStr + `, - "id": "id" - }` + want := `{"type":"t","public":false,"payload":{"key":"value"},"repo":{"id":1,"name":"n","url":"s"},"actor":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"org":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"created_at":` + referenceTimeStr + `,"id":"id"}` testJSONMarshal(t, u, want) } diff --git a/github/event_types_test.go b/github/event_types_test.go index 7c84146f460..78c5ccbd52a 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -21,11 +21,7 @@ func TestEditChange_Marshal_TitleChange(t *testing.T) { Base: nil, } - want := `{ - "title": { - "from": "TitleFrom" - } - }` + want := `{"title":{"from":"TitleFrom"}}` testJSONMarshal(t, u, want) } @@ -41,11 +37,7 @@ func TestEditChange_Marshal_BodyChange(t *testing.T) { Base: nil, } - want := `{ - "body": { - "from": "BodyFrom" - } - }` + want := `{"body":{"from":"BodyFrom"}}` testJSONMarshal(t, u, want) } @@ -68,16 +60,7 @@ func TestEditChange_Marshal_BaseChange(t *testing.T) { Base: &Base, } - want := `{ - "base": { - "ref": { - "from": "BaseRefFrom" - }, - "sha": { - "from": "BaseSHAFrom" - } - } - }` + want := `{"base":{"ref":{"from":"BaseRefFrom"},"sha":{"from":"BaseSHAFrom"}}}` testJSONMarshal(t, u, want) } @@ -93,13 +76,7 @@ func TestEditChange_Marshal_Repo(t *testing.T) { }, } - want := `{ - "repository": { - "name": { - "from": "old-repo-name" - } - } - }` + want := `{"repository":{"name":{"from":"old-repo-name"}}}` testJSONMarshal(t, u, want) } @@ -112,11 +89,7 @@ func TestProjectChange_Marshal_NameChange(t *testing.T) { Body: nil, } - want := `{ - "name": { - "from": "NameFrom" - } - }` + want := `{"name":{"from":"NameFrom"}}` testJSONMarshal(t, u, want) } @@ -129,11 +102,7 @@ func TestProjectChange_Marshal_BodyChange(t *testing.T) { Body: &ProjectBody{From: String("BodyFrom")}, } - want := `{ - "body": { - "from": "BodyFrom" - } - }` + want := `{"body":{"from":"BodyFrom"}}` testJSONMarshal(t, u, want) } @@ -145,11 +114,7 @@ func TestProjectCardChange_Marshal_NoteChange(t *testing.T) { Note: &ProjectCardNote{From: String("NoteFrom")}, } - want := `{ - "note": { - "from": "NoteFrom" - } - }` + want := `{"note":{"from":"NoteFrom"}}` testJSONMarshal(t, u, want) } @@ -161,11 +126,7 @@ func TestProjectColumnChange_Marshal_NameChange(t *testing.T) { Name: &ProjectColumnName{From: String("NameFrom")}, } - want := `{ - "name": { - "from": "NameFrom" - } - }` + want := `{"name":{"from":"NameFrom"}}` testJSONMarshal(t, u, want) } @@ -344,180 +305,7 @@ func TestTeamAddEvent_Marshal(t *testing.T) { }, } - want := `{ - "team": { - "id": 1, - "node_id": "n", - "name": "n", - "description": "d", - "url": "u", - "slug": "s", - "permission": "p", - "privacy": "p", - "members_count": 1, - "repos_count": 1, - "organization": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "html_url": "h", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e" - }, - "members_url": "m", - "repositories_url": "r", - "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" - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"team":{"id":1,"node_id":"n","name":"n","description":"d","url":"u","slug":"s","permission":"p","privacy":"p","members_count":1,"repos_count":1,"organization":{"login":"l","id":1,"node_id":"n","avatar_url":"a","html_url":"h","name":"n","company":"c","blog":"b","location":"l","email":"e"},"members_url":"m","repositories_url":"r","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"},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -566,46 +354,7 @@ func TestStarEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "starred_at": ` + referenceTimeStr + `, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - } - }` + want := `{"action":"a","starred_at":` + referenceTimeStr + `,"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` testJSONMarshal(t, u, want) } @@ -805,201 +554,7 @@ func TestTeamEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "team": { - "id": 1, - "node_id": "n", - "name": "n", - "description": "d", - "url": "u", - "slug": "s", - "permission": "p", - "privacy": "p", - "members_count": 1, - "repos_count": 1, - "organization": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "html_url": "h", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e" - }, - "members_url": "m", - "repositories_url": "r", - "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" - }, - "changes": { - "description": { - "from": "from" - }, - "name": { - "from": "from" - }, - "privacy": { - "from": "from" - }, - "repository": { - "permissions": { - "from": { - "admin": true, - "pull": true, - "push": true - } - } - } - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","team":{"id":1,"node_id":"n","name":"n","description":"d","url":"u","slug":"s","permission":"p","privacy":"p","members_count":1,"repos_count":1,"organization":{"login":"l","id":1,"node_id":"n","avatar_url":"a","html_url":"h","name":"n","company":"c","blog":"b","location":"l","email":"e"},"members_url":"m","repositories_url":"r","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"},"changes":{"description":{"from":"from"},"name":{"from":"from"},"privacy":{"from":"from"},"repository":{"permissions":{"from":{"admin":true,"pull":true,"push":true}}}},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -1128,130 +683,7 @@ func TestInstallationRepositoriesEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "repositories_added": [ - { - "id": 1, - "name": "n", - "url": "s" - } - ], - "repositories_removed": [ - { - "id": 1, - "name": "n", - "url": "s" - } - ], - "repository_selection": "rs", - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","repositories_added":[{"id":1,"name":"n","url":"s"}],"repositories_removed":[{"id":1,"name":"n","url":"s"}],"repository_selection":"rs","sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -1263,9 +695,7 @@ func TestEditTitle_Marshal(t *testing.T) { From: String("EditTitleFrom"), } - want := `{ - "from": "EditTitleFrom" - }` + want := `{"from":"EditTitleFrom"}` testJSONMarshal(t, u, want) } @@ -1277,9 +707,7 @@ func TestEditBody_Marshal(t *testing.T) { From: String("EditBodyFrom"), } - want := `{ - "from": "EditBodyFrom" - }` + want := `{"from":"EditBodyFrom"}` testJSONMarshal(t, u, want) } @@ -1296,14 +724,7 @@ func TestEditBase_Marshal(t *testing.T) { }, } - want := `{ - "ref": { - "from": "EditRefFrom" - }, - "sha": { - "from": "EditSHAFrom" - } - }` + want := `{"ref":{"from":"EditRefFrom"},"sha":{"from":"EditSHAFrom"}}` testJSONMarshal(t, u, want) } @@ -1315,9 +736,7 @@ func TestEditRef_Marshal(t *testing.T) { From: String("EditRefFrom"), } - want := `{ - "from": "EditRefFrom" - }` + want := `{"from":"EditRefFrom"}` testJSONMarshal(t, u, want) } @@ -1329,9 +748,7 @@ func TestEditSHA_Marshal(t *testing.T) { From: String("EditSHAFrom"), } - want := `{ - "from": "EditSHAFrom" - }` + want := `{"from":"EditSHAFrom"}` testJSONMarshal(t, u, want) } @@ -1343,9 +760,7 @@ func TestProjectName_Marshal(t *testing.T) { From: String("ProjectNameFrom"), } - want := `{ - "from": "ProjectNameFrom" - }` + want := `{"from":"ProjectNameFrom"}` testJSONMarshal(t, u, want) } @@ -1357,9 +772,7 @@ func TestProjectBody_Marshal(t *testing.T) { From: String("ProjectBodyFrom"), } - want := `{ - "from": "ProjectBodyFrom" - }` + want := `{"from":"ProjectBodyFrom"}` testJSONMarshal(t, u, want) } @@ -1371,9 +784,7 @@ func TestProjectCardNote_Marshal(t *testing.T) { From: String("ProjectCardNoteFrom"), } - want := `{ - "from": "ProjectCardNoteFrom" - }` + want := `{"from":"ProjectCardNoteFrom"}` testJSONMarshal(t, u, want) } @@ -1385,9 +796,7 @@ func TestProjectColumnName_Marshal(t *testing.T) { From: String("ProjectColumnNameFrom"), } - want := `{ - "from": "ProjectColumnNameFrom" - }` + want := `{"from":"ProjectColumnNameFrom"}` testJSONMarshal(t, u, want) } @@ -1399,9 +808,7 @@ func TestTeamDescription_Marshal(t *testing.T) { From: String("TeamDescriptionFrom"), } - want := `{ - "from": "TeamDescriptionFrom" - }` + want := `{"from":"TeamDescriptionFrom"}` testJSONMarshal(t, u, want) } @@ -1413,9 +820,7 @@ func TestTeamName_Marshal(t *testing.T) { From: String("TeamNameFrom"), } - want := `{ - "from": "TeamNameFrom" - }` + want := `{"from":"TeamNameFrom"}` testJSONMarshal(t, u, want) } @@ -1427,9 +832,7 @@ func TestTeamPrivacy_Marshal(t *testing.T) { From: String("TeamPrivacyFrom"), } - want := `{ - "from": "TeamPrivacyFrom" - }` + want := `{"from":"TeamPrivacyFrom"}` testJSONMarshal(t, u, want) } @@ -1447,15 +850,7 @@ func TestTeamRepository_Marshal(t *testing.T) { }, } - want := `{ - "permissions": { - "from": { - "admin": true, - "pull": true, - "push": true - } - } - }` + want := `{"permissions":{"from":{"admin":true,"pull":true,"push":true}}}` testJSONMarshal(t, u, want) } @@ -1471,13 +866,7 @@ func TestTeamPermissions_Marshal(t *testing.T) { }, } - want := `{ - "from": { - "admin": true, - "pull": true, - "push": true - } - }` + want := `{"from":{"admin":true,"pull":true,"push":true}}` testJSONMarshal(t, u, want) } @@ -1491,11 +880,7 @@ func TestTeamPermissionsFrom_Marshal(t *testing.T) { Push: Bool(true), } - want := `{ - "admin": true, - "pull": true, - "push": true - }` + want := `{"admin":true,"pull":true,"push":true}` testJSONMarshal(t, u, want) } @@ -1523,25 +908,7 @@ func TestRepositoryVulnerabilityAlert_Marshal(t *testing.T) { DismissedAt: &Timestamp{referenceTime}, } - want := `{ - "id": 1, - "affected_range": "ar", - "affected_package_name": "apn", - "external_reference": "er", - "external_identifier": "ei", - "fixed_in": "fi", - "dismisser": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "dismiss_reason": "dr", - "dismissed_at": ` + referenceTimeStr + ` - }` + want := `{"id":1,"affected_range":"ar","affected_package_name":"apn","external_reference":"er","external_identifier":"ei","fixed_in":"fi","dismisser":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"dismiss_reason":"dr","dismissed_at":` + referenceTimeStr + `}` testJSONMarshal(t, u, want) } @@ -1558,14 +925,7 @@ func TestPage_Marshal(t *testing.T) { HTMLURL: String("h"), } - want := `{ - "page_name": "p", - "title": "t", - "summary": "s", - "action": "a", - "sha": "s", - "html_url": "h" - }` + want := `{"page_name":"p","title":"t","summary":"s","action":"a","sha":"s","html_url":"h"}` testJSONMarshal(t, u, want) } @@ -1594,26 +954,7 @@ func TestTeamChange_Marshal(t *testing.T) { }, } - want := `{ - "description": { - "from": "DescriptionFrom" - }, - "name": { - "from": "NameFrom" - }, - "privacy": { - "from": "PrivacyFrom" - }, - "repository": { - "permissions": { - "from": { - "admin": false, - "pull": false, - "push": false - } - } - } - }` + want := `{"description":{"from":"DescriptionFrom"},"name":{"from":"NameFrom"},"privacy":{"from":"PrivacyFrom"},"repository":{"permissions":{"from":{"admin":false,"pull":false,"push":false}}}}` testJSONMarshal(t, u, want) } @@ -1772,164 +1113,7 @@ func TestIssueCommentEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "issue": { - "id": 1 - }, - "comment": { - "id": 1 - }, - "changes": { - "title": { - "from": "TitleFrom" - }, - "body": { - "from": "BodyFrom" - }, - "base": { - "ref": { - "from": "BaseRefFrom" - }, - "sha": { - "from": "BaseSHAFrom" - } - } - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - } - }` + want := `{"action":"a","issue":{"id":1},"comment":{"id":1},"changes":{"title":{"from":"TitleFrom"},"body":{"from":"BodyFrom"},"base":{"ref":{"from":"BaseRefFrom"},"sha":{"from":"BaseSHAFrom"}}},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true}}` testJSONMarshal(t, u, want) } @@ -2075,151 +1259,7 @@ func TestIssuesEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "issue": { - "id": 1 - }, - "assignee": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "label": { - "id": 1 - }, - "changes": { - "title": { - "from": "TitleFrom" - }, - "body": { - "from": "BodyFrom" - }, - "base": { - "ref": { - "from": "BaseRefFrom" - }, - "sha": { - "from": "BaseSHAFrom" - } - } - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","issue":{"id":1},"assignee":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"label":{"id":1},"changes":{"title":{"from":"TitleFrom"},"body":{"from":"BodyFrom"},"base":{"ref":{"from":"BaseRefFrom"},"sha":{"from":"BaseSHAFrom"}}},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -2368,152 +1408,7 @@ func TestLabelEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "label": { - "id": 1 - }, - "changes": { - "title": { - "from": "TitleFrom" - }, - "body": { - "from": "BodyFrom" - }, - "base": { - "ref": { - "from": "BaseRefFrom" - }, - "sha": { - "from": "BaseSHAFrom" - } - } - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","label":{"id":1},"changes":{"title":{"from":"TitleFrom"},"body":{"from":"BodyFrom"},"base":{"ref":{"from":"BaseRefFrom"},"sha":{"from":"BaseSHAFrom"}}},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"installation":{"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) } @@ -2671,161 +1566,7 @@ func TestMilestoneEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "milestone": { - "id": 1 - }, - "changes": { - "title": { - "from": "TitleFrom" - }, - "body": { - "from": "BodyFrom" - }, - "base": { - "ref": { - "from": "BaseRefFrom" - }, - "sha": { - "from": "BaseSHAFrom" - } - } - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","milestone":{"id":1},"changes":{"title":{"from":"TitleFrom"},"body":{"from":"BodyFrom"},"base":{"ref":{"from":"BaseRefFrom"},"sha":{"from":"BaseSHAFrom"}}},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"installation":{"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) } @@ -2943,119 +1684,7 @@ func TestPublicEvent_Marshal(t *testing.T) { }, } - want := `{ - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -3198,148 +1827,7 @@ func TestPullRequestReviewEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "review": { - "id": 1 - }, - "pull_request": { - "id": 1 - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - } - }` + want := `{"action":"a","review":{"id":1},"pull_request":{"id":1},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true}}` testJSONMarshal(t, u, want) } @@ -3500,168 +1988,7 @@ func TestPushEvent_Marshal(t *testing.T) { }, } - want := `{ - "push_id": 1, - "head": "h", - "ref": "ref", - "size": 1, - "commits": [ - { - "id": "id" - } - ], - "before": "b", - "distinct_size": 1, - "after": "a", - "created": true, - "deleted": true, - "forced": true, - "base_ref": "a", - "compare": "a", - "repository": { - "id": 1 - }, - "head_commit": { - "id": "id" - }, - "pusher": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - } - }` + want := `{"push_id":1,"head":"h","ref":"ref","size":1,"commits":[{"id":"id"}],"before":"b","distinct_size":1,"after":"a","created":true,"deleted":true,"forced":true,"base_ref":"a","compare":"a","repository":{"id":1},"head_commit":{"id":"id"},"pusher":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true}}` testJSONMarshal(t, u, want) } @@ -3791,135 +2118,7 @@ func TestStatusEvent_Marshal(t *testing.T) { }, } - want := `{ - "sha": "sha", - "state": "s", - "description": "d", - "target_url": "turl", - "branches": [ - { - "name": "n", - "commit": { - "node_id": "nid" - }, - "protected": false - } - ], - "id": 1, - "name": "n", - "context": "c", - "commit": { - "node_id": "nid" - }, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"sha":"sha","state":"s","description":"d","target_url":"turl","branches":[{"name":"n","commit":{"node_id":"nid"},"protected":false}],"id":1,"name":"n","context":"c","commit":{"node_id":"nid"},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -4080,166 +2279,7 @@ func TestMarketplacePurchaseEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "effective_date": ` + referenceTimeStr + `, - "marketplace_purchase": { - "billing_cycle": "bc", - "next_billing_date": ` + referenceTimeStr + `, - "unit_count": 1, - "plan": { - "url": "u", - "accounts_url": "au", - "id": 1, - "number": 1, - "name": "n", - "description": "d", - "monthly_price_in_cents": 1, - "yearly_price_in_cents": 1, - "price_model": "pm", - "unit_name": "un", - "bullets": [ - "b" - ], - "state": "s", - "has_free_trial": false - }, - "on_free_trial": false, - "free_trial_ends_on": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - }, - "previous_marketplace_purchase": { - "billing_cycle": "bc", - "next_billing_date": ` + referenceTimeStr + `, - "unit_count": 1, - "plan": { - "url": "u", - "accounts_url": "au", - "id": 1, - "number": 1, - "name": "n", - "description": "d", - "monthly_price_in_cents": 1, - "yearly_price_in_cents": 1, - "price_model": "pm", - "unit_name": "un", - "bullets": [ - "b" - ], - "state": "s", - "has_free_trial": false - }, - "on_free_trial": false, - "free_trial_ends_on": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","effective_date":` + referenceTimeStr + `,"marketplace_purchase":{"billing_cycle":"bc","next_billing_date":` + referenceTimeStr + `,"unit_count":1,"plan":{"url":"u","accounts_url":"au","id":1,"number":1,"name":"n","description":"d","monthly_price_in_cents":1,"yearly_price_in_cents":1,"price_model":"pm","unit_name":"un","bullets":["b"],"state":"s","has_free_trial":false},"on_free_trial":false,"free_trial_ends_on":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"previous_marketplace_purchase":{"billing_cycle":"bc","next_billing_date":` + referenceTimeStr + `,"unit_count":1,"plan":{"url":"u","accounts_url":"au","id":1,"number":1,"name":"n","description":"d","monthly_price_in_cents":1,"yearly_price_in_cents":1,"price_model":"pm","unit_name":"un","bullets":["b"],"state":"s","has_free_trial":false},"on_free_trial":false,"free_trial_ends_on":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -4413,177 +2453,7 @@ func TestOrganizationEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "invitation": { - "id": 1 - }, - "membership": { - "url": "url", - "state": "s", - "role": "r", - "organization_url": "ou", - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "user": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - } - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","invitation":{"id":1},"membership":{"url":"url","state":"s","role":"r","organization_url":"ou","organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"user":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -4703,123 +2573,7 @@ func TestPageBuildEvent_Marshal(t *testing.T) { }, } - want := `{ - "build": { - "url": "url" - }, - "id": 1, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"build":{"url":"url"},"id":1,"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -4971,153 +2725,7 @@ func TestCommitCommentEvent_Marshal(t *testing.T) { }, } - want := `{ - "comment": { - "html_url": "hurl", - "url": "url", - "id": 1, - "node_id": "nid", - "commit_id": "cid", - "user": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "reactions": { - "total_count": 1, - "+1": 1, - "-1": 1, - "laugh": 1, - "confused": 1, - "heart": 1, - "hooray": 1, - "rocket": 1, - "eyes": 1, - "url": "url" - }, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "body": "b", - "path": "path", - "position": 1 - }, - "action": "a", - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"comment":{"html_url":"hurl","url":"url","id":1,"node_id":"nid","commit_id":"cid","user":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"reactions":{"total_count":1,"+1":1,"-1":1,"laugh":1,"confused":1,"heart":1,"hooray":1,"rocket":1,"eyes":1,"url":"url"},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"body":"b","path":"path","position":1},"action":"a","repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -5264,145 +2872,7 @@ func TestDeploymentEvent_Marshal(t *testing.T) { }, } - want := `{ - "deployment": { - "url": "url", - "id": 1, - "sha": "sha", - "ref": "ref", - "task": "t", - "payload": { - "key": "value" - }, - "environment": "e", - "description": "d", - "creator": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "statuses_url": "surl", - "repository_url": "rurl", - "node_id": "nid" - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"deployment":{"url":"url","id":1,"sha":"sha","ref":"ref","task":"t","payload":{"key":"value"},"environment":"e","description":"d","creator":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"statuses_url":"surl","repository_url":"rurl","node_id":"nid"},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -5573,169 +3043,7 @@ func TestDeploymentStatusEvent_Marshal(t *testing.T) { }, } - want := `{ - "deployment": { - "url": "url", - "id": 1, - "sha": "sha", - "ref": "ref", - "task": "t", - "payload": { - "key": "value" - }, - "environment": "e", - "description": "d", - "creator": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "statuses_url": "surl", - "repository_url": "rurl", - "node_id": "nid" - }, - "deployment_status": { - "id": 1, - "state": "s", - "creator": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "description": "s", - "environment": "s", - "node_id": "s", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "target_url": "s", - "deployment_url": "s", - "repository_url": "s", - "environment_url": "s", - "log_url": "s", - "url": "s" - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"deployment":{"url":"url","id":1,"sha":"sha","ref":"ref","task":"t","payload":{"key":"value"},"environment":"e","description":"d","creator":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"statuses_url":"surl","repository_url":"rurl","node_id":"nid"},"deployment_status":{"id":1,"state":"s","creator":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"description":"s","environment":"s","node_id":"s","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"target_url":"s","deployment_url":"s","repository_url":"s","environment_url":"s","log_url":"s","url":"s"},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -5945,211 +3253,7 @@ func TestDiscussionCommentEvent_Marshal(t *testing.T) { }, } - want := `{ - "comment": { - "author_association": "aa", - "body": "bo", - "child_comment_count": 1, - "created_at": ` + referenceTimeStr + `, - "discussion_id": 1, - "html_url": "hurl", - "id": 1, - "node_id": "nid", - "parent_id": 1, - "reactions": { - "total_count": 1, - "+1": 1, - "-1": 1, - "laugh": 1, - "confused": 1, - "heart": 1, - "hooray": 1, - "rocket": 1, - "eyes": 1, - "url": "url" - }, - "repository_url": "rurl", - "updated_at": ` + referenceTimeStr + `, - "user": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - } - }, - "discussion": { - "repository_url": "rurl", - "category": { - "id": 1, - "node_id": "nid", - "repository_id": 1, - "emoji": "emoji", - "name": "name", - "description": "description", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "slug": "slug", - "is_answerable": false - }, - "html_url": "hurl", - "id": 1, - "node_id": "nurl", - "number": 1, - "title": "title", - "user": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "state": "st", - "locked": false, - "comments": 1, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "author_association": "aa", - "body": "bo" - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"discussion":{"repository_url":"rurl","category":{"id":1,"node_id":"nid","repository_id":1,"emoji":"emoji","name":"name","description":"description","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"slug":"slug","is_answerable":false},"html_url":"hurl","id":1,"node_id":"nurl","number":1,"title":"title","user":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"state":"st","locked":false,"comments":1,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"author_association":"aa","body":"bo"},"comment":{"author_association":"aa","body":"bo","child_comment_count":1,"created_at":` + referenceTimeStr + `,"discussion_id":1,"html_url":"hurl","id":1,"node_id":"nid","parent_id":1,"reactions":{"total_count":1,"+1":1,"-1":1,"laugh":1,"confused":1,"heart":1,"hooray":1,"rocket":1,"eyes":1,"url":"url"},"repository_url":"rurl","updated_at":` + referenceTimeStr + `,"user":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -6325,177 +3429,7 @@ func TestDiscussionEvent_Marshal(t *testing.T) { }, } - want := `{ - "discussion": { - "repository_url": "rurl", - "category": { - "id": 1, - "node_id": "nid", - "repository_id": 1, - "emoji": "emoji", - "name": "name", - "description": "description", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "slug": "slug", - "is_answerable": false - }, - "html_url": "hurl", - "id": 1, - "node_id": "nurl", - "number": 1, - "title": "title", - "user": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "state": "st", - "locked": false, - "comments": 1, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "author_association": "aa", - "body": "bo" - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"discussion":{"repository_url":"rurl","category":{"id":1,"node_id":"nid","repository_id":1,"emoji":"emoji","name":"name","description":"description","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"slug":"slug","is_answerable":false},"html_url":"hurl","id":1,"node_id":"nurl","number":1,"title":"title","user":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"state":"st","locked":false,"comments":1,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"author_association":"aa","body":"bo"},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -6562,68 +3496,7 @@ func TestPackageEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "package": { - "id": 1, - "name": "n", - "package_type": "pt", - "html_url": "hurl", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "owner": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "package_version": { - "id": 1 - }, - "registry": { - "name": "n" - } - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - } - }` + want := `{"action":"a","package":{"id":1,"name":"n","package_type":"pt","html_url":"hurl","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"owner":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"package_version":{"id":1},"registry":{"name":"n"}},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` testJSONMarshal(t, u, want) } @@ -6746,127 +3619,7 @@ func TestPingEvent_Marshal(t *testing.T) { }, } - want := `{ - "zen": "z", - "hook_id": 1, - "hook": { - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "url": "url", - "id": 1, - "type": "t", - "name": "n", - "test_url": "tu", - "ping_url": "pu", - "last_response": { - "key": "value" - }, - "config": { - "key": "value" - }, - "events": [ - "a" - ], - "active": true - }, - "installation": { - "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 + ` - } - }` + want := `{"zen":"z","hook_id":1,"hook":{"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"url":"url","id":1,"type":"t","name":"n","test_url":"tu","ping_url":"pu","last_response":{"key":"value"},"config":{"key":"value"},"events":["a"],"active":true},"installation":{"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) } @@ -7015,146 +3768,7 @@ func TestRepositoryDispatchEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "branch": "b", - "client_payload": { - "key": "value" - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","branch":"b","client_payload":{"key":"value"},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -7202,45 +3816,7 @@ func TestRepositoryImportEvent_Marshal(t *testing.T) { }, } - want := `{ - "status": "success", - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - } - }` + want := `{"status":"success","repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` testJSONMarshal(t, u, want) } @@ -7381,142 +3957,7 @@ func TestRepositoryEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -7651,142 +4092,7 @@ func TestReleaseEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "release": { - "name": "n", - "discussion_category_name": "dcn", - "id": 2, - "created_at": ` + referenceTimeStr + `, - "published_at": ` + referenceTimeStr + `, - "url": "url", - "html_url": "htmlurl", - "assets_url": "assetsurl", - "assets": [ - { - "id": 1 - } - ], - "upload_url": "uploadurl", - "zipball_url": "zipballurl", - "tarball_url": "tarballurl", - "author": { - "name": "octocat" - }, - "node_id": "nid" - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","release":{"name":"n","discussion_category_name":"dcn","id":2,"created_at":` + referenceTimeStr + `,"published_at":` + referenceTimeStr + `,"url":"url","html_url":"htmlurl","assets_url":"assetsurl","assets":[{"id":1}],"upload_url":"uploadurl","zipball_url":"zipballurl","tarball_url":"tarballurl","author":{"name":"octocat"},"node_id":"nid"},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -7910,125 +4216,7 @@ func TestContentReferenceEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "content_reference": { - "id": 1, - "node_id": "nid", - "reference": "ref" - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","content_reference":{"id":1,"node_id":"nid","reference":"ref"},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -8156,129 +4344,7 @@ func TestMemberEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "member": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","member":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -8463,186 +4529,7 @@ func TestMembershipEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "scope": "s", - "member": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "team": { - "id": 1, - "node_id": "n", - "name": "n", - "description": "d", - "url": "u", - "slug": "s", - "permission": "p", - "privacy": "p", - "members_count": 1, - "repos_count": 1, - "organization": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "html_url": "h", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e" - }, - "members_url": "m", - "repositories_url": "r", - "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" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","scope":"s","member":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"team":{"id":1,"node_id":"n","name":"n","description":"d","url":"u","slug":"s","permission":"p","privacy":"p","members_count":1,"repos_count":1,"organization":{"login":"l","id":1,"node_id":"n","avatar_url":"a","html_url":"h","name":"n","company":"c","blog":"b","location":"l","email":"e"},"members_url":"m","repositories_url":"r","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"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -8790,151 +4677,7 @@ func TestMergeGroupEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "merge_group": { - "head_sha": "hs", - "head_ref": "hr", - "base_sha": "bs", - "base_ref": "br", - "head_commit": { - "node_id": "nid" - } - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","merge_group":{"head_sha":"hs","head_ref":"hr","base_sha":"bs","base_ref":"br","head_commit":{"node_id":"nid"}},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"installation":{"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 + `},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` testJSONMarshal(t, u, want) } @@ -9079,146 +4822,7 @@ func TestOrgBlockEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "blocked_user": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","blocked_user":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -9346,129 +4950,7 @@ func TestGollumEvent_Marshal(t *testing.T) { }, } - want := `{ - "pages": [ - { - "page_name": "pn", - "title": "t", - "summary": "s", - "action": "a", - "sha": "sha", - "html_url": "hu" - } - ], - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"pages":[{"page_name":"pn","title":"t","summary":"s","action":"a","sha":"sha","html_url":"hu"}],"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -9608,137 +5090,7 @@ func TestWorkflowRunEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "workflow": { - "id": 1, - "node_id": "nid", - "name": "n", - "path": "p", - "state": "s", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "url": "u", - "html_url": "h", - "badge_url": "b" - }, - "workflow_run": { - "id": 1, - "name": "n", - "node_id": "nid", - "head_branch": "hb", - "head_sha": "hs", - "run_number": 1, - "run_attempt": 1, - "event": "e", - "status": "s", - "conclusion": "c", - "workflow_id": 1, - "url": "u", - "html_url": "h", - "pull_requests": [ - { - "id": 1, - "number": 1, - "url": "u", - "head": { - "ref": "r", - "sha": "s", - "repo": { - "id": 1, - "name": "n", - "url": "s" - } - }, - "base": { - "ref": "r", - "sha": "s", - "repo": { - "id": 1, - "name": "n", - "url": "u" - } - } - } - ], - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "run_started_at": ` + referenceTimeStr + `, - "jobs_url": "j", - "logs_url": "l", - "check_suite_url": "c", - "artifacts_url": "a", - "cancel_url": "c", - "rerun_url": "r", - "previous_attempt_url": "p", - "head_commit": { - "message": "m", - "author": { - "name": "n", - "email": "e", - "username": "l" - }, - "url": "u", - "distinct": false, - "sha": "s", - "id": "i", - "tree_id": "tid", - "timestamp": ` + referenceTimeStr + `, - "committer": { - "name": "n", - "email": "e", - "username": "l" - } - }, - "workflow_url": "w", - "repository": { - "id": 1, - "name": "n", - "url": "u" - }, - "head_repository": { - "id": 1, - "name": "n", - "url": "u" - } - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - } - }` + want := `{"action":"a","workflow":{"id":1,"node_id":"nid","name":"n","path":"p","state":"s","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"url":"u","html_url":"h","badge_url":"b"},"workflow_run":{"id":1,"name":"n","node_id":"nid","head_branch":"hb","head_sha":"hs","run_number":1,"run_attempt":1,"event":"e","status":"s","conclusion":"c","workflow_id":1,"url":"u","html_url":"h","pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}],"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"run_started_at":` + referenceTimeStr + `,"jobs_url":"j","logs_url":"l","check_suite_url":"c","artifacts_url":"a","cancel_url":"c","rerun_url":"r","previous_attempt_url":"p","head_commit":{"message":"m","author":{"name":"n","email":"e","username":"l"},"url":"u","distinct":false,"sha":"s","id":"i","tree_id":"tid","timestamp":` + referenceTimeStr + `,"committer":{"name":"n","email":"e","username":"l"}},"workflow_url":"w","repository":{"id":1,"name":"n","url":"u"},"head_repository":{"id":1,"name":"n","url":"u"}},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` testJSONMarshal(t, u, want) } @@ -9792,49 +5144,7 @@ func TestWorkflowDispatchEvent_Marshal(t *testing.T) { }, } - want := `{ - "inputs": { - "key": "value" - }, - "ref": "r", - "workflow": "w", - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - } - }` + want := `{"inputs":{"key":"value"},"ref":"r","workflow":"w","repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` testJSONMarshal(t, u, want) } @@ -9953,120 +5263,7 @@ func TestWatchEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -10109,39 +5306,7 @@ func TestUserEvent_Marshal(t *testing.T) { }, } - want := `{ - "user": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "action": "a", - "enterprise": { - "id": 1, - "slug": "s", - "name": "n", - "node_id": "nid", - "avatar_url": "au", - "description": "d", - "website_url": "wu", - "html_url": "hu", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - } - }` + want := `{"user":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"action":"a","enterprise":{"id":1,"slug":"s","name":"n","node_id":"nid","avatar_url":"au","description":"d","website_url":"wu","html_url":"hu","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` testJSONMarshal(t, u, want) } @@ -10371,231 +5536,7 @@ func TestCheckRunEvent_Marshal(t *testing.T) { }, } - want := `{ - "check_run": { - "id": 1, - "node_id": "n", - "head_sha": "h", - "external_id": "1", - "url": "u", - "html_url": "u", - "details_url": "u", - "status": "s", - "conclusion": "c", - "started_at": ` + referenceTimeStr + `, - "completed_at": ` + referenceTimeStr + `, - "output": { - "title": "t", - "summary": "s", - "text": "t", - "annotations_count": 1, - "annotations_url": "a", - "annotations": [ - { - "path": "p", - "start_line": 1, - "end_line": 1, - "annotation_level": "a", - "message": "m", - "title": "t", - "raw_details": "r" - } - ], - "images": [ - { - "alt": "a", - "image_url": "i", - "caption": "c" - } - ] - }, - "name": "n", - "check_suite": { - "id": 1 - }, - "app": { - "id": 1, - "node_id": "n", - "owner": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "name": "n", - "description": "d", - "external_url": "u", - "html_url": "h", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - }, - "pull_requests": [ - { - "id": 1, - "number": 1, - "url": "u", - "head": { - "ref": "r", - "sha": "s", - "repo": { - "id": 1, - "name": "n", - "url": "s" - } - }, - "base": { - "ref": "r", - "sha": "s", - "repo": { - "id": 1, - "name": "n", - "url": "u" - } - } - } - ] - }, - "action": "a", - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - }, - "requested_action": { - "identifier": "i" - } - }` + want := `{"check_run":{"id":1,"node_id":"n","head_sha":"h","external_id":"1","url":"u","html_url":"u","details_url":"u","status":"s","conclusion":"c","started_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `,"output":{"title":"t","summary":"s","text":"t","annotations_count":1,"annotations_url":"a","annotations":[{"path":"p","start_line":1,"end_line":1,"annotation_level":"a","message":"m","title":"t","raw_details":"r"}],"images":[{"alt":"a","image_url":"i","caption":"c"}]},"name":"n","check_suite":{"id":1},"app":{"id":1,"node_id":"n","owner":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"name":"n","description":"d","external_url":"u","html_url":"h","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}]},"action":"a","repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `},"requested_action":{"identifier":"i"}}` testJSONMarshal(t, r, want) } @@ -10797,203 +5738,7 @@ func TestCheckSuiteEvent_Marshal(t *testing.T) { }, } - want := `{ - "check_suite": { - "id": 1, - "node_id": "n", - "head_branch": "h", - "head_sha": "h", - "url": "u", - "before": "b", - "after": "a", - "status": "s", - "conclusion": "c", - "app": { - "id": 1, - "node_id": "n", - "owner": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "name": "n", - "description": "d", - "external_url": "u", - "html_url": "h", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - }, - "repository": { - "id": 1 - }, - "pull_requests": [ - { - "id": 1, - "number": 1, - "url": "u", - "head": { - "ref": "r", - "sha": "s", - "repo": { - "id": 1, - "name": "n", - "url": "s" - } - }, - "base": { - "ref": "r", - "sha": "s", - "repo": { - "id": 1, - "name": "n", - "url": "u" - } - } - } - ], - "head_commit": { - "sha": "s" - } - }, - "action": "a", - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"check_suite":{"id":1,"node_id":"n","head_branch":"h","head_sha":"h","url":"u","before":"b","after":"a","status":"s","conclusion":"c","app":{"id":1,"node_id":"n","owner":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"name":"n","description":"d","external_url":"u","html_url":"h","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"repository":{"id":1},"pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}],"head_commit":{"sha":"s"}},"action":"a","repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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, r, want) } @@ -11050,54 +5795,7 @@ func TestDeployKeyEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "key": { - "id": 1, - "key": "k", - "url": "k", - "title": "k", - "read_only": false, - "verified": false, - "created_at": ` + referenceTimeStr + ` - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - } - }` + want := `{"action":"a","key":{"id":1,"key":"k","url":"k","title":"k","read_only":false,"verified":false,"created_at":` + referenceTimeStr + `},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` testJSONMarshal(t, u, want) } @@ -11127,44 +5825,19 @@ func TestMetaEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "hook_id": 1, - "hook": { - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "url": "u", - "id": 1, - "type": "t", - "name": "n", - "test_url": "tu", - "ping_url": "pu", - "last_response": { - "a": "b" - }, - "config": { - "a": "b" - }, - "events": [ - "a" - ], - "active": true - } - }` + want := `{"action":"a","hook_id":1,"hook":{"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"url":"u","id":1,"type":"t","name":"n","test_url":"tu","ping_url":"pu","last_response":{"a":"b"},"config":{"a":"b"},"events":["a"],"active":true}}` testJSONMarshal(t, u, want) } func TestRequestedAction_Marshal(t *testing.T) { - testJSONMarshal(t, &RequestedAction{}, "{}") + testJSONMarshal(t, &RequestedAction{}, `{"identifier":""}`) r := &RequestedAction{ Identifier: "i", } - want := `{ - "identifier": "i" - }` + want := `{"identifier":"i"}` testJSONMarshal(t, r, want) } @@ -11287,124 +5960,7 @@ func TestCreateEvent_Marshal(t *testing.T) { }, } - want := `{ - "ref": "r", - "ref_type": "rt", - "master_branch": "mb", - "description": "d", - "pusher_type": "pt", - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"ref":"r","ref_type":"rt","master_branch":"mb","description":"d","pusher_type":"pt","repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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, r, want) } @@ -11525,122 +6081,7 @@ func TestDeleteEvent_Marshal(t *testing.T) { }, } - want := `{ - "ref": "r", - "ref_type": "rt", - "pusher_type": "pt", - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"ref":"r","ref_type":"rt","pusher_type":"pt","repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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, r, want) } @@ -11763,124 +6204,7 @@ func TestForkEvent_Marshal(t *testing.T) { }, } - want := `{ - "forkee": { - "id": 1, - "name": "n", - "url": "s" - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"forkee":{"id":1,"name":"n","url":"s"},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -11901,18 +6225,7 @@ func TestGitHubAppAuthorizationEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - } - }` + want := `{"action":"a","sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` testJSONMarshal(t, u, want) } @@ -12033,122 +6346,7 @@ func TestInstallationEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "repositories": [ - { - "id":1, - "name":"n", - "url":"u" - } - ], - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","repositories":[{"id":1,"name":"n","url":"u"}],"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -12181,36 +6379,7 @@ func TestHeadCommit_Marshal(t *testing.T) { Modified: []string{"m"}, } - want := `{ - "message": "m", - "author": { - "date": ` + referenceTimeStr + `, - "name": "n", - "email": "e", - "username": "u" - }, - "url": "u", - "distinct": true, - "sha": "s", - "id": "id", - "tree_id": "tid", - "timestamp": ` + referenceTimeStr + `, - "committer": { - "date": ` + referenceTimeStr + `, - "name": "n", - "email": "e", - "username": "u" - }, - "added": [ - "a" - ], - "removed": [ - "r" - ], - "modified": [ - "m" - ] - }` + want := `{"message":"m","author":{"date":` + referenceTimeStr + `,"name":"n","email":"e","username":"u"},"url":"u","distinct":true,"sha":"s","id":"id","tree_id":"tid","timestamp":` + referenceTimeStr + `,"committer":{"date":` + referenceTimeStr + `,"name":"n","email":"e","username":"u"},"added":["a"],"removed":["r"],"modified":["m"]}` testJSONMarshal(t, u, want) } @@ -12273,60 +6442,7 @@ func TestPushEventRepository_Marshal(t *testing.T) { SVNURL: String("s"), } - want := `{ - "id": 1, - "node_id": "nid", - "name": "n", - "full_name": "fn", - "owner": { - "login": "l", - "id": 1, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "url": "u" - }, - "private": true, - "description": "d", - "fork": true, - "created_at": ` + referenceTimeStr + `, - "pushed_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "homepage": "h", - "pulls_url": "p", - "size": 1, - "stargazers_count": 1, - "watchers_count": 1, - "language": "l", - "has_issues": true, - "has_downloads": true, - "has_wiki": true, - "has_pages": true, - "forks_count": 1, - "archived": true, - "disabled": true, - "open_issues_count": 1, - "default_branch": "d", - "master_branch": "m", - "organization": "o", - "url": "u", - "archive_url": "a", - "html_url": "h", - "statuses_url": "s", - "git_url": "g", - "ssh_url": "s", - "clone_url": "c", - "svn_url": "s" - }` + want := `{"id":1,"node_id":"nid","name":"n","full_name":"fn","owner":{"login":"l","id":1,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"},"private":true,"description":"d","fork":true,"created_at":` + referenceTimeStr + `,"pushed_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"homepage":"h","pulls_url":"p","size":1,"stargazers_count":1,"watchers_count":1,"language":"l","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"archived":true,"disabled":true,"open_issues_count":1,"default_branch":"d","master_branch":"m","organization":"o","url":"u","archive_url":"a","html_url":"h","statuses_url":"s","git_url":"g","ssh_url":"s","clone_url":"c","svn_url":"s"}` testJSONMarshal(t, u, want) } @@ -12339,10 +6455,7 @@ func TestPushEventRepoOwner_Marshal(t *testing.T) { Email: String("e"), } - want := `{ - "name": "n", - "email": "e" - }` + want := `{"name":"n","email":"e"}` testJSONMarshal(t, u, want) } @@ -12488,153 +6601,7 @@ func TestProjectEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "changes": { - "name": { - "from": "NameFrom" - }, - "body": { - "from": "BodyFrom" - } - }, - "project": { - "id": 1 - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","changes":{"name":{"from":"NameFrom"},"body":{"from":"BodyFrom"}},"project":{"id":1},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -12780,151 +6747,7 @@ func TestProjectCardEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "changes": { - "note": { - "from": "NoteFrom" - } - }, - "after_id": 1, - "project_card": { - "id": 1 - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","changes":{"note":{"from":"NoteFrom"}},"after_id":1,"project_card":{"id":1},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -13070,151 +6893,7 @@ func TestProjectColumnEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "changes": { - "name": { - "from": "NameFrom" - } - }, - "after_id": 1, - "project_column": { - "id": 1 - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","changes":{"name":{"from":"NameFrom"}},"after_id":1,"project_column":{"id":1},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -13395,188 +7074,7 @@ func TestPullRequestEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "assignee": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "number": 1, - "pull_request": { - "id": 1 - }, - "changes": { - "title": { - "from": "TitleFrom" - }, - "body": { - "from": "BodyFrom" - }, - "base": { - "ref": { - "from": "BaseRefFrom" - }, - "sha": { - "from": "BaseSHAFrom" - } - } - }, - "requested_reviewer": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "requested_team": { - "id": 1 - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - }, - "label": { - "id": 1 - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "before": "before", - "after": "after" - }` + want := `{"action":"a","assignee":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"number":1,"pull_request":{"id":1},"changes":{"title":{"from":"TitleFrom"},"body":{"from":"BodyFrom"},"base":{"ref":{"from":"BaseRefFrom"},"sha":{"from":"BaseSHAFrom"}}},"requested_reviewer":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"requested_team":{"id":1},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `},"label":{"id":1},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"before":"before","after":"after"}` testJSONMarshal(t, u, want) } @@ -13713,142 +7211,7 @@ func TestPullRequestReviewCommentEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "pull_request": { - "id": 1 - }, - "comment": { - "id": 1 - }, - "changes": { - "title": { - "from": "TitleFrom" - }, - "body": { - "from": "BodyFrom" - }, - "base": { - "ref": { - "from": "BaseRefFrom" - }, - "sha": { - "from": "BaseSHAFrom" - } - } - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","pull_request":{"id":1},"comment":{"id":1},"changes":{"title":{"from":"TitleFrom"},"body":{"from":"BodyFrom"},"base":{"ref":{"from":"BaseRefFrom"},"sha":{"from":"BaseSHAFrom"}}},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -13971,133 +7334,7 @@ func TestPullRequestReviewThreadEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "pull_request": { - "id": 1 - }, - "thread": { - "comments": [ - { - "id": 1 - }, - { - "id": 2 - } - ] - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","thread":{"comments":[{"id":1},{"id":2}]},"pull_request":{"id":1},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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) } @@ -14278,188 +7515,7 @@ func TestPullRequestTargetEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "assignee": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "number": 1, - "pull_request": { - "id": 1 - }, - "changes": { - "title": { - "from": "TitleFrom" - }, - "body": { - "from": "BodyFrom" - }, - "base": { - "ref": { - "from": "BaseRefFrom" - }, - "sha": { - "from": "BaseSHAFrom" - } - } - }, - "requested_reviewer": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "requested_team": { - "id": 1 - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - }, - "label": { - "id": 1 - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "before": "before", - "after": "after" - }` + want := `{"action":"a","assignee":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"number":1,"pull_request":{"id":1},"changes":{"title":{"from":"TitleFrom"},"body":{"from":"BodyFrom"},"base":{"ref":{"from":"BaseRefFrom"},"sha":{"from":"BaseSHAFrom"}}},"requested_reviewer":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"requested_team":{"id":1},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `},"label":{"id":1},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"before":"before","after":"after"}` testJSONMarshal(t, u, want) } @@ -14495,33 +7551,7 @@ func TestRepositoryVulnerabilityAlertEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "alert": { - "id": 1, - "affected_range": "ar", - "affected_package_name": "apn", - "external_reference": "er", - "external_identifier": "ei", - "fixed_in": "fi", - "dismisser": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "dismiss_reason": "dr", - "dismissed_at": ` + referenceTimeStr + ` - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - } - }` + want := `{"action":"a","alert":{"id":1,"affected_range":"ar","affected_package_name":"apn","external_reference":"er","external_identifier":"ei","fixed_in":"fi","dismisser":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"dismiss_reason":"dr","dismissed_at":` + referenceTimeStr + `},"repository":{"id":1,"name":"n","url":"s"}}` testJSONMarshal(t, u, want) } @@ -14689,169 +7719,7 @@ func TestSecretScanningAlertEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "a", - "alert": { - "number": 1, - "secret_type": "t", - "resolution": "r", - "resolved_by": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "resolved_at": ` + referenceTimeStr + ` - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "enterprise": { - "id": 1, - "slug": "s", - "name": "n", - "node_id": "nid", - "avatar_url": "au", - "description": "d", - "website_url": "wu", - "html_url": "hu", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "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 + ` - } - }` + want := `{"action":"a","alert":{"number":1,"resolution":"r","resolved_at":` + referenceTimeStr + `,"resolved_by":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"secret_type":"t"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"enterprise":{"id":1,"slug":"s","name":"n","node_id":"nid","avatar_url":"au","description":"d","website_url":"wu","html_url":"hu","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"installation":{"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) } @@ -14895,42 +7763,10 @@ func TestSecurityAdvisoryEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "published", - "security_advisory": { - "ghsa_id": "GHSA-rf4j-j272-some", - "summary": "Siuuuuuuuuu", - "description": "desc", - "severity": "moderate", - "identifiers": [ - { - "value": "GHSA-rf4j-j272-some", - "type": "GHSA" - } - ], - "references": [ - { - "url": "https://some-url" - } - ], - "published_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "withdrawn_at": null, - "vulnerabilities": [ - { - "package": { - "ecosystem": "ucl", - "name": "penaldo" - }, - "severity": "moderate", - "vulnerable_version_range": ">= 2.0.0, < 2.0.2", - "first_patched_version": { - "identifier": "2.0.2" - } - } - ] - } - }` + // convert `>` into `\u003e`` and `<` into `\u003c`` + part, _ := json.Marshal(">= 2.0.0, < 2.0.2") + + want := `{"action":"published","security_advisory":{"ghsa_id":"GHSA-rf4j-j272-some","summary":"Siuuuuuuuuu","description":"desc","severity":"moderate","identifiers":[{"value":"GHSA-rf4j-j272-some","type":"GHSA"}],"references":[{"url":"https://some-url"}],"published_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"vulnerabilities":[{"package":{"ecosystem":"ucl","name":"penaldo"},"severity":"moderate","vulnerable_version_range":` + string(part) + `,"first_patched_version":{"identifier":"2.0.2"}}]}}` testJSONMarshal(t, u, want) } @@ -15103,173 +7939,7 @@ func TestCodeScanningAlertEvent_Marshal(t *testing.T) { }, } - want := `{ - "action": "reopened", - "alert": { - "number": 10, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "url": "a", - "html_url": "a", - "instances": [ - { - "ref": "refs/heads/main", - "analysis_key": ".github/workflows/workflow.yml:upload", - "environment": "{}", - "state": "open" - } - ], - "state": "open", - "fixed_at": null, - "dismissed_by": null, - "dismissed_at": null, - "dismissed_reason": null, - "rule": { - "id": "Style/FrozenStringLiteralComment", - "severity": "note", - "description": "desc", - "full_description": "full desc", - "tags": [ - "style" - ], - "help": "help" - }, - "tool": { - "name": "Rubocop", - "version": null - } - }, - "ref": "refs/heads/main", - "commit_oid": "d6e4c75c141dbacecc279b721b8bsomeSHA", - "repository": { - "id": 1234234535, - "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NT==", - "name": "Hello-World", - "full_name": "Codertocat/Hello-World", - "private": false, - "owner": { - "login": "Codertocat", - "id": 21031067, - "node_id": "MDQ6VXNlcjIxMDMxMDY3", - "avatar_url": "a", - "gravatar_id": "", - "url": "a", - "html_url": "a", - "followers_url": "a", - "following_url": "a", - "gists_url": "a", - "starred_url": "a", - "subscriptions_url": "a", - "organizations_url": "a", - "repos_url": "a", - "events_url": "a", - "received_events_url": "a", - "type": "User", - "site_admin": false - }, - "html_url": "a", - "description": null, - "fork": false, - "url": "a", - "forks_url": "a", - "keys_url": "a", - "collaborators_url": "a", - "teams_url": "a", - "hooks_url": "a", - "issue_events_url": "a", - "events_url": "a", - "assignees_url": "a", - "branches_url": "a", - "tags_url": "a", - "blobs_url": "a", - "git_tags_url": "a", - "git_refs_url": "a", - "trees_url": "a", - "statuses_url": "a", - "languages_url": "a", - "stargazers_url": "a", - "contributors_url": "a", - "subscribers_url": "a", - "subscription_url": "a", - "commits_url": "a", - "git_commits_url": "a", - "comments_url": "a", - "issue_comment_url": "a", - "contents_url": "a", - "compare_url": "a", - "merges_url": "a", - "archive_url": "a", - "downloads_url": "a", - "issues_url": "a", - "pulls_url": "a", - "milestones_url": "a", - "notifications_url": "a", - "labels_url": "a", - "releases_url": "a", - "deployments_url": "a", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "pushed_at": ` + referenceTimeStr + `, - "git_url": "a", - "ssh_url": "a", - "clone_url": "a", - "svn_url": "a", - "homepage": null, - "size": 0, - "stargazers_count": 0, - "watchers_count": 0, - "language": null, - "has_issues": true, - "has_projects": true, - "has_downloads": true, - "has_wiki": true, - "has_pages": true, - "forks_count": 0, - "mirror_url": null, - "archived": false, - "disabled": false, - "open_issues_count": 2, - "license": null, - "forks": 0, - "open_issues": 2, - "watchers": 0, - "default_branch": "main" - }, - "organization": { - "login": "Octocoders", - "id": 6, - "node_id": "MDEyOk9yZ2FuaXphdGlvbjY=", - "url": "a", - "repos_url": "a", - "events_url": "a", - "hooks_url": "a", - "issues_url": "a", - "members_url": "a", - "public_members_url": "a", - "avatar_url": "a", - "description": "" - }, - "sender": { - "login": "github", - "id": 9919, - "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", - "avatar_url": "a", - "gravatar_id": "", - "url": "a", - "html_url": "a", - "followers_url": "a", - "following_url": "a", - "gists_url": "a", - "starred_url": "a", - "subscriptions_url": "a", - "organizations_url": "a", - "repos_url": "a", - "events_url": "a", - "received_events_url": "a", - "type": "Organization", - "site_admin": false - } - }` + want := `{"action":"reopened","alert":{"number":10,"rule":{"id":"Style/FrozenStringLiteralComment","severity":"note","description":"desc","full_description":"full desc","tags":["style"],"help":"help"},"tool":{"name":"Rubocop"},"created_at":"2006-01-02T15:04:05Z","updated_at":"2006-01-02T15:04:05Z","state":"open","url":"a","html_url":"a","instances":[{"ref":"refs/heads/main","analysis_key":".github/workflows/workflow.yml:upload","environment":"{}","state":"open"}]},"ref":"refs/heads/main","commit_oid":"d6e4c75c141dbacecc279b721b8bsomeSHA","repository":{"id":1234234535,"node_id":"MDEwOlJlcG9zaXRvcnkxODY4NT==","owner":{"login":"Codertocat","id":21031067,"node_id":"MDQ6VXNlcjIxMDMxMDY3","avatar_url":"a","html_url":"a","gravatar_id":"","type":"User","site_admin":false,"url":"a","events_url":"a","following_url":"a","followers_url":"a","gists_url":"a","organizations_url":"a","received_events_url":"a","repos_url":"a","starred_url":"a","subscriptions_url":"a"},"name":"Hello-World","full_name":"Codertocat/Hello-World","default_branch":"main","created_at":"2006-01-02T15:04:05Z","pushed_at":"2006-01-02T15:04:05Z","updated_at":"2006-01-02T15:04:05Z","html_url":"a","clone_url":"a","git_url":"a","ssh_url":"a","svn_url":"a","fork":false,"forks_count":0,"open_issues_count":2,"open_issues":2,"stargazers_count":0,"watchers_count":0,"watchers":0,"size":0,"archived":false,"disabled":false,"private":false,"has_issues":true,"has_wiki":true,"has_pages":true,"has_projects":true,"has_downloads":true,"url":"a","archive_url":"a","assignees_url":"a","blobs_url":"a","branches_url":"a","collaborators_url":"a","comments_url":"a","commits_url":"a","compare_url":"a","contents_url":"a","contributors_url":"a","deployments_url":"a","downloads_url":"a","events_url":"a","forks_url":"a","git_commits_url":"a","git_refs_url":"a","git_tags_url":"a","hooks_url":"a","issue_comment_url":"a","issue_events_url":"a","issues_url":"a","keys_url":"a","labels_url":"a","languages_url":"a","merges_url":"a","milestones_url":"a","notifications_url":"a","pulls_url":"a","releases_url":"a","stargazers_url":"a","statuses_url":"a","subscribers_url":"a","subscription_url":"a","tags_url":"a","trees_url":"a","teams_url":"a"},"organization":{"login":"Octocoders","id":6,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY=","avatar_url":"a","description":"","url":"a","events_url":"a","hooks_url":"a","issues_url":"a","members_url":"a","public_members_url":"a","repos_url":"a"},"sender":{"login":"github","id":9919,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk5MTk=","avatar_url":"a","html_url":"a","gravatar_id":"","type":"Organization","site_admin":false,"url":"a","events_url":"a","following_url":"a","followers_url":"a","gists_url":"a","organizations_url":"a","received_events_url":"a","repos_url":"a","starred_url":"a","subscriptions_url":"a"}}` testJSONMarshal(t, u, want) } diff --git a/github/gists_comments_test.go b/github/gists_comments_test.go index c9c97068979..adc2657f411 100644 --- a/github/gists_comments_test.go +++ b/github/gists_comments_test.go @@ -45,29 +45,7 @@ func TestGistComments_Marshal(t *testing.T) { CreatedAt: &Timestamp{createdAt}, } - want := `{ - "id": 1, - "url": "u", - "body": "test gist comment", - "user": { - "login": "ll", - "id": 123, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "url": "u" - }, - "created_at": "2002-02-10T15:30:00Z" - }` + want := `{"id":1,"url":"u","body":"test gist comment","user":{"login":"ll","id":123,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"},"created_at":"2002-02-10T15:30:00Z"}` testJSONMarshal(t, u, want) } diff --git a/github/gists_test.go b/github/gists_test.go index 3066d585a25..9913c2f7bdc 100644 --- a/github/gists_test.go +++ b/github/gists_test.go @@ -62,45 +62,7 @@ func TestGist_Marshal(t *testing.T) { NodeID: String("node"), } - want := `{ - "id": "i", - "description": "description", - "public": true, - "owner": { - "login": "ll", - "id": 123, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "url": "u" - }, - "files": { - "gistfile.py": { - "size": 167, - "filename": "gistfile.py", - "language": "Python", - "type": "application/x-python", - "raw_url": "raw-url", - "content": "c" - } - }, - "comments": 1, - "html_url": "html-url", - "git_pull_url": "gitpull-url", - "git_push_url": "gitpush-url", - "created_at": "2010-02-10T10:10:00Z", - "updated_at": "2010-02-10T10:10:00Z", - "node_id": "node" - }` + want := `{"id":"i","description":"description","public":true,"owner":{"login":"ll","id":123,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"},"files":{"gistfile.py":{"size":167,"filename":"gistfile.py","language":"Python","type":"application/x-python","raw_url":"raw-url","content":"c"}},"comments":1,"html_url":"html-url","git_pull_url":"gitpull-url","git_push_url":"gitpush-url","created_at":"2010-02-10T10:10:00Z","updated_at":"2010-02-10T10:10:00Z","node_id":"node"}` testJSONMarshal(t, u, want) } @@ -137,34 +99,7 @@ func TestGistCommit_Marshal(t *testing.T) { NodeID: String("node"), } - want := `{ - "url": "u", - "version": "v", - "user": { - "login": "ll", - "id": 123, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "url": "u" - }, - "change_status": { - "additions": 1, - "deletions": 1, - "total": 2 - }, - "committed_at": ` + referenceTimeStr + `, - "node_id": "node" - }` + want := `{"url":"u","version":"v","user":{"login":"ll","id":123,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"},"change_status":{"additions":1,"deletions":1,"total":2},"committed_at":` + referenceTimeStr + `,"node_id":"node"}` testJSONMarshal(t, u, want) } @@ -197,30 +132,7 @@ func TestGistFork_Marshal(t *testing.T) { NodeID: String("node"), } - want := `{ - "url": "u", - "user": { - "login": "ll", - "id": 123, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "url": "u" - }, - "id": "id", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "node_id": "node" - }` + want := `{"url":"u","user":{"login":"ll","id":123,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"},"id":"id","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"node_id":"node"}` testJSONMarshal(t, u, want) } @@ -1030,14 +942,7 @@ func TestGistFile_Marshal(t *testing.T) { Content: String("con"), } - want := `{ - "size": 1, - "filename": "fn", - "language": "lan", - "type": "type", - "raw_url": "rurl", - "content": "con" - }` + want := `{"size":1,"filename":"fn","language":"lan","type":"type","raw_url":"rurl","content":"con"}` testJSONMarshal(t, u, want) } diff --git a/github/git_blobs_test.go b/github/git_blobs_test.go index c2cc455ab89..f26e5822f04 100644 --- a/github/git_blobs_test.go +++ b/github/git_blobs_test.go @@ -183,14 +183,7 @@ func TestBlob_Marshal(t *testing.T) { NodeID: String("nid"), } - want := `{ - "content": "content", - "encoding": "encoding", - "sha": "sha", - "size": 1, - "url": "url", - "node_id": "nid" - }` + want := `{"content":"content","encoding":"encoding","sha":"sha","size":1,"url":"url","node_id":"nid"}` testJSONMarshal(t, u, want) } diff --git a/github/git_commits_test.go b/github/git_commits_test.go index efdb0a27dc8..003ff075ab0 100644 --- a/github/git_commits_test.go +++ b/github/git_commits_test.go @@ -68,52 +68,7 @@ func TestCommit_Marshal(t *testing.T) { SigningKey: &openpgp.Entity{}, } - want := `{ - "sha": "s", - "author": { - "date": ` + referenceTimeStr + `, - "name": "n", - "email": "e", - "username": "u" - }, - "committer": { - "date": ` + referenceTimeStr + `, - "name": "n", - "email": "e", - "username": "u" - }, - "message": "m", - "tree": { - "sha": "s", - "tree": [ - { - "sha": "s", - "path": "p", - "mode": "m", - "type": "t", - "size": 1, - "content": "c", - "url": "u" - } - ], - "truncated": false - }, - "stats": { - "additions": 1, - "deletions": 1, - "total": 1 - }, - "html_url": "h", - "url": "u", - "verification": { - "verified": false, - "reason": "r", - "signature": "s", - "payload": "p" - }, - "node_id": "n", - "comment_count": 1 - }` + want := `{"sha":"s","author":{"date":` + referenceTimeStr + `,"name":"n","email":"e","username":"u"},"committer":{"date":` + referenceTimeStr + `,"name":"n","email":"e","username":"u"},"message":"m","tree":{"sha":"s","tree":[{"sha":"s","path":"p","mode":"m","type":"t","size":1,"content":"c","url":"u"}],"truncated":false},"stats":{"additions":1,"deletions":1,"total":1},"html_url":"h","url":"u","verification":{"verified":false,"reason":"r","signature":"s","payload":"p"},"node_id":"n","comment_count":1}` testJSONMarshal(t, u, want) } @@ -613,12 +568,7 @@ func TestSignatureVerification_Marshal(t *testing.T) { Payload: String("payload"), } - want := `{ - "verified": true, - "reason": "reason", - "signature": "sign", - "payload": "payload" - }` + want := `{"verified":true,"reason":"reason","signature":"sign","payload":"payload"}` testJSONMarshal(t, u, want) } @@ -633,12 +583,7 @@ func TestCommitAuthor_Marshal(t *testing.T) { Login: String("login"), } - want := `{ - "date": ` + referenceTimeStr + `, - "name": "name", - "email": "email", - "username": "login" - }` + want := `{"date":` + referenceTimeStr + `,"name":"name","email":"email","username":"login"}` testJSONMarshal(t, u, want) } @@ -665,26 +610,7 @@ func TestCreateCommit_Marshal(t *testing.T) { Signature: String("sign"), } - want := `{ - "author": { - "date": ` + referenceTimeStr + `, - "name": "name", - "email": "email", - "username": "login" - }, - "committer": { - "date": ` + referenceTimeStr + `, - "name": "name", - "email": "email", - "username": "login" - }, - "message": "message", - "tree": "tree", - "parents": [ - "p" - ], - "signature": "sign" - }` + want := `{"author":{"date":` + referenceTimeStr + `,"name":"name","email":"email","username":"login"},"committer":{"date":` + referenceTimeStr + `,"name":"name","email":"email","username":"login"},"message":"message","tree":"tree","parents":["p"],"signature":"sign"}` testJSONMarshal(t, u, want) } diff --git a/github/git_refs_test.go b/github/git_refs_test.go index d37504945d1..ce1aa7a7041 100644 --- a/github/git_refs_test.go +++ b/github/git_refs_test.go @@ -677,7 +677,7 @@ func TestGitService_UpdateRef_pathEscape(t *testing.T) { } func TestReference_Marshal(t *testing.T) { - testJSONMarshal(t, &Reference{}, "{}") + testJSONMarshal(t, &Reference{}, `{"ref":null,"url":null,"object":null}`) u := &Reference{ Ref: String("ref"), @@ -690,22 +690,13 @@ func TestReference_Marshal(t *testing.T) { NodeID: String("nid"), } - want := `{ - "ref": "ref", - "url": "url", - "object": { - "type": "type", - "sha": "sha", - "url": "url" - }, - "node_id": "nid" - }` + want := `{"ref":"ref","url":"url","object":{"type":"type","sha":"sha","url":"url"},"node_id":"nid"}` testJSONMarshal(t, u, want) } func TestGitObject_Marshal(t *testing.T) { - testJSONMarshal(t, &GitObject{}, "{}") + testJSONMarshal(t, &GitObject{}, `{"type":null,"sha":null,"url":null}`) u := &GitObject{ Type: String("type"), @@ -713,43 +704,33 @@ func TestGitObject_Marshal(t *testing.T) { URL: String("url"), } - want := `{ - "type": "type", - "sha": "sha", - "url": "url" - }` + want := `{"type":"type","sha":"sha","url":"url"}` testJSONMarshal(t, u, want) } func TestCreateRefRequest_Marshal(t *testing.T) { - testJSONMarshal(t, &createRefRequest{}, "{}") + testJSONMarshal(t, &createRefRequest{}, `{"ref":null,"sha":null}`) u := &createRefRequest{ Ref: String("ref"), SHA: String("sha"), } - want := `{ - "ref": "ref", - "sha": "sha" - }` + want := `{"ref":"ref","sha":"sha"}` testJSONMarshal(t, u, want) } func TestUpdateRefRequest_Marshal(t *testing.T) { - testJSONMarshal(t, &updateRefRequest{}, "{}") + testJSONMarshal(t, &updateRefRequest{}, `{"sha":null,"force":null}`) u := &updateRefRequest{ SHA: String("sha"), Force: Bool(true), } - want := `{ - "sha": "sha", - "force": true - }` + want := `{"sha":"sha","force":true}` testJSONMarshal(t, u, want) } diff --git a/github/git_tags_test.go b/github/git_tags_test.go index 0d45ee26893..f68cc39a4be 100644 --- a/github/git_tags_test.go +++ b/github/git_tags_test.go @@ -126,30 +126,7 @@ func TestTag_Marshal(t *testing.T) { NodeID: String("nid"), } - want := `{ - "tag": "tag", - "sha": "sha", - "url": "url", - "message": "msg", - "tagger": { - "date": ` + referenceTimeStr + `, - "name": "name", - "email": "email", - "username": "login" - }, - "object": { - "type": "type", - "sha": "sha", - "url": "url" - }, - "verification": { - "verified": true, - "reason": "reason", - "signature": "sign", - "payload": "payload" - }, - "node_id": "nid" - }` + want := `{"tag":"tag","sha":"sha","url":"url","message":"msg","tagger":{"date":` + referenceTimeStr + `,"name":"name","email":"email","username":"login"},"object":{"type":"type","sha":"sha","url":"url"},"verification":{"verified":true,"reason":"reason","signature":"sign","payload":"payload"},"node_id":"nid"}` testJSONMarshal(t, u, want) } @@ -170,18 +147,7 @@ func TestCreateTagRequest_Marshal(t *testing.T) { }, } - want := `{ - "tag": "tag", - "message": "msg", - "object": "obj", - "type": "type", - "tagger": { - "date": ` + referenceTimeStr + `, - "name": "name", - "email": "email", - "username": "login" - } - }` + want := `{"tag":"tag","message":"msg","object":"obj","type":"type","tagger":{"date":` + referenceTimeStr + `,"name":"name","email":"email","username":"login"}}` testJSONMarshal(t, u, want) } diff --git a/github/git_trees_test.go b/github/git_trees_test.go index 25e5f2aeec6..145965033db 100644 --- a/github/git_trees_test.go +++ b/github/git_trees_test.go @@ -360,27 +360,13 @@ func TestTree_Marshal(t *testing.T) { Truncated: Bool(false), } - want := `{ - "sha": "sha", - "tree": [ - { - "sha": "sha", - "path": "path", - "mode": "mode", - "type": "type", - "size": 1, - "content": "content", - "url": "url" - } - ], - "truncated": false - }` + want := `{"sha":"sha","tree":[{"sha":"sha","path":"path","mode":"mode","type":"type","size":1,"content":"content","url":"url"}],"truncated":false}` testJSONMarshal(t, u, want) } func TestTreeEntry_Marshal(t *testing.T) { - testJSONMarshal(t, &TreeEntry{}, "{}") + testJSONMarshal(t, &TreeEntry{}, `{"sha":null}`) u := &TreeEntry{ SHA: String("sha"), @@ -392,21 +378,13 @@ func TestTreeEntry_Marshal(t *testing.T) { URL: String("url"), } - want := `{ - "sha": "sha", - "path": "path", - "mode": "mode", - "type": "type", - "size": 1, - "content": "content", - "url": "url" - }` + want := `{"sha":"sha","path":"path","mode":"mode","type":"type","size":1,"content":"content","url":"url"}` testJSONMarshal(t, u, want) } func TestTreeEntryWithFileDelete_Marshal(t *testing.T) { - testJSONMarshal(t, &treeEntryWithFileDelete{}, "{}") + testJSONMarshal(t, &treeEntryWithFileDelete{}, `{"sha":null}`) u := &treeEntryWithFileDelete{ SHA: String("sha"), @@ -418,31 +396,20 @@ func TestTreeEntryWithFileDelete_Marshal(t *testing.T) { URL: String("url"), } - want := `{ - "sha": "sha", - "path": "path", - "mode": "mode", - "type": "type", - "size": 1, - "content": "content", - "url": "url" - }` + want := `{"sha":"sha","path":"path","mode":"mode","type":"type","size":1,"content":"content","url":"url"}` testJSONMarshal(t, u, want) } func TestCreateTree_Marshal(t *testing.T) { - testJSONMarshal(t, &createTree{}, "{}") + testJSONMarshal(t, &createTree{}, `{"tree":null}`) u := &createTree{ BaseTree: "bt", Entries: []interface{}{"e"}, } - want := `{ - "base_tree": "bt", - "tree": ["e"] - }` + want := `{"base_tree":"bt","tree":["e"]}` testJSONMarshal(t, u, want) } diff --git a/github/github.go b/github/github.go index 58715b11c6f..36dd4e2b9e5 100644 --- a/github/github.go +++ b/github/github.go @@ -981,8 +981,8 @@ func (r *TwoFactorAuthError) Error() string { return (*ErrorResponse)(r).Error() // RateLimitError occurs when GitHub returns 403 Forbidden response with a rate limit // remaining value of 0. type RateLimitError struct { - Rate Rate // Rate specifies last known rate limit for the client - Response *http.Response // HTTP response that caused this error + Rate Rate `json:"rate"` // Rate specifies last known rate limit for the client + Response *http.Response `json:"-"` // HTTP response that caused this error Message string `json:"message"` // error message } @@ -1031,13 +1031,13 @@ func (ae *AcceptedError) Is(target error) bool { // AbuseRateLimitError occurs when GitHub returns 403 Forbidden response with the // "documentation_url" field value equal to "https://docs.github.com/en/rest/overview/resources-in-the-rest-api#secondary-rate-limits". type AbuseRateLimitError struct { - Response *http.Response // HTTP response that caused this error + Response *http.Response `json:"-"` // HTTP response that caused this error Message string `json:"message"` // error message // RetryAfter is provided with some abuse rate limit errors. If present, // it is the amount of time that the client should wait before retrying. // Otherwise, the client should try again later (after an unspecified amount of time). - RetryAfter *time.Duration + RetryAfter *time.Duration `json:",omitempty"` } func (r *AbuseRateLimitError) Error() string { diff --git a/github/github_test.go b/github/github_test.go index 9c40728f4d6..1070b6bd06c 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -6,6 +6,7 @@ package github import ( + "bytes" "context" "encoding/json" "errors" @@ -147,25 +148,14 @@ func testBody(t *testing.T, r *http.Request, want string) { // to the want string. func testJSONMarshal(t *testing.T, v interface{}, want string) { t.Helper() - // Unmarshal the wanted JSON, to verify its correctness, and marshal it back - // to sort the keys. - u := reflect.New(reflect.TypeOf(v)).Interface() - if err := json.Unmarshal([]byte(want), &u); err != nil { - t.Errorf("Unable to unmarshal JSON for %v: %v", want, err) - } - w, err := json.Marshal(u) - if err != nil { - t.Errorf("Unable to marshal JSON for %#v", u) - } - // Marshal the target value. j, err := json.Marshal(v) if err != nil { - t.Errorf("Unable to marshal JSON for %#v", v) + t.Errorf("Unable to unmarshal JSON for %v: %v", v, err) } - if string(w) != string(j) { - t.Errorf("json.Marshal(%q) returned %s, want %s", v, j, w) + if !bytes.Equal(j, []byte(want)) { + t.Errorf("json.Marshal(%+v) returned %s, want %s", v, j, want) } } @@ -2654,7 +2644,7 @@ func (fn roundTripperFunc) RoundTrip(r *http.Request) (*http.Response, error) { } func TestErrorResponse_Marshal(t *testing.T) { - testJSONMarshal(t, &ErrorResponse{}, "{}") + testJSONMarshal(t, &ErrorResponse{}, `{"message":"","errors":null}`) u := &ErrorResponse{ Message: "msg", @@ -2673,22 +2663,7 @@ func TestErrorResponse_Marshal(t *testing.T) { DocumentationURL: "doc", } - want := `{ - "message": "msg", - "errors": [ - { - "resource": "res", - "field": "f", - "code": "c", - "message": "msg" - } - ], - "block": { - "reason": "reason", - "created_at": ` + referenceTimeStr + ` - }, - "documentation_url": "doc" - }` + want := `{"message":"msg","errors":[{"resource":"res","field":"f","code":"c","message":"msg"}],"block":{"reason":"reason","created_at":` + referenceTimeStr + `},"documentation_url":"doc"}` testJSONMarshal(t, u, want) } @@ -2701,16 +2676,13 @@ func TestErrorBlock_Marshal(t *testing.T) { CreatedAt: &Timestamp{referenceTime}, } - want := `{ - "reason": "reason", - "created_at": ` + referenceTimeStr + ` - }` + want := `{"reason":"reason","created_at":` + referenceTimeStr + `}` testJSONMarshal(t, u, want) } func TestRateLimitError_Marshal(t *testing.T) { - testJSONMarshal(t, &RateLimitError{}, "{}") + // testJSONMarshal(t, &RateLimitError{}, "{}") u := &RateLimitError{ Rate: Rate{ @@ -2721,34 +2693,25 @@ func TestRateLimitError_Marshal(t *testing.T) { Message: "msg", } - want := `{ - "Rate": { - "limit": 1, - "remaining": 1, - "reset": ` + referenceTimeStr + ` - }, - "message": "msg" - }` + want := `{"rate":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `},"message":"msg"}` testJSONMarshal(t, u, want) } func TestAbuseRateLimitError_Marshal(t *testing.T) { - testJSONMarshal(t, &AbuseRateLimitError{}, "{}") + testJSONMarshal(t, &AbuseRateLimitError{}, `{"message":""}`) u := &AbuseRateLimitError{ Message: "msg", } - want := `{ - "message": "msg" - }` + want := `{"message":"msg"}` testJSONMarshal(t, u, want) } func TestError_Marshal(t *testing.T) { - testJSONMarshal(t, &Error{}, "{}") + testJSONMarshal(t, &Error{}, `{"resource":"","field":"","code":"","message":""}`) u := &Error{ Resource: "res", @@ -2757,18 +2720,13 @@ func TestError_Marshal(t *testing.T) { Message: "msg", } - want := `{ - "resource": "res", - "field": "field", - "code": "code", - "message": "msg" - }` + want := `{"resource":"res","field":"field","code":"code","message":"msg"}` testJSONMarshal(t, u, want) } func TestRate_Marshal(t *testing.T) { - testJSONMarshal(t, &Rate{}, "{}") + // testJSONMarshal(t, &Rate{}, `{"limit":0,"remaining":0,"reset":""}`) u := &Rate{ Limit: 1, @@ -2776,17 +2734,13 @@ func TestRate_Marshal(t *testing.T) { Reset: Timestamp{referenceTime}, } - want := `{ - "limit": 1, - "remaining": 1, - "reset": ` + referenceTimeStr + ` - }` + want := `{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `}` testJSONMarshal(t, u, want) } func TestRateLimits_Marshal(t *testing.T) { - testJSONMarshal(t, &RateLimits{}, "{}") + testJSONMarshal(t, &RateLimits{}, `{"core":null,"search":null,"graphql":null,"integration_manifest":null,"source_import":null,"code_scanning_upload":null,"actions_runner_registration":null,"scim":null}`) u := &RateLimits{ Core: &Rate{ @@ -2831,48 +2785,7 @@ func TestRateLimits_Marshal(t *testing.T) { }, } - want := `{ - "core": { - "limit": 1, - "remaining": 1, - "reset": ` + referenceTimeStr + ` - }, - "search": { - "limit": 1, - "remaining": 1, - "reset": ` + referenceTimeStr + ` - }, - "graphql": { - "limit": 1, - "remaining": 1, - "reset": ` + referenceTimeStr + ` - }, - "integration_manifest": { - "limit": 1, - "remaining": 1, - "reset": ` + referenceTimeStr + ` - }, - "source_import": { - "limit": 1, - "remaining": 1, - "reset": ` + referenceTimeStr + ` - }, - "code_scanning_upload": { - "limit": 1, - "remaining": 1, - "reset": ` + referenceTimeStr + ` - }, - "actions_runner_registration": { - "limit": 1, - "remaining": 1, - "reset": ` + referenceTimeStr + ` - }, - "scim": { - "limit": 1, - "remaining": 1, - "reset": ` + referenceTimeStr + ` - } - }` + want := `{"core":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `},"search":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `},"graphql":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `},"integration_manifest":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `},"source_import":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `},"code_scanning_upload":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `},"actions_runner_registration":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `},"scim":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `}}` testJSONMarshal(t, u, want) } diff --git a/github/gitignore_test.go b/github/gitignore_test.go index 61ee4d52e58..6e110b6fb69 100644 --- a/github/gitignore_test.go +++ b/github/gitignore_test.go @@ -96,10 +96,7 @@ func TestGitignore_Marshal(t *testing.T) { Source: String("source"), } - want := `{ - "name": "name", - "source": "source" - }` + want := `{"name":"name","source":"source"}` testJSONMarshal(t, u, want) } diff --git a/github/interactions_test.go b/github/interactions_test.go index 47ebae18c48..12ee8db806f 100644 --- a/github/interactions_test.go +++ b/github/interactions_test.go @@ -16,11 +16,7 @@ func TestInteractionRestriction_Marshal(t *testing.T) { ExpiresAt: &Timestamp{referenceTime}, } - want := `{ - "limit": "limit", - "origin": "origin", - "expires_at": ` + referenceTimeStr + ` - }` + want := `{"limit":"limit","origin":"origin","expires_at":` + referenceTimeStr + `}` testJSONMarshal(t, u, want) } diff --git a/github/issue_import_test.go b/github/issue_import_test.go index a86ead898b4..276bd94f97f 100644 --- a/github/issue_import_test.go +++ b/github/issue_import_test.go @@ -220,13 +220,7 @@ func TestIssueImportError_Marshal(t *testing.T) { Code: String("code"), } - want := `{ - "location": "loc", - "resource": "res", - "field": "field", - "value": "value", - "code": "code" - }` + want := `{"location":"loc","resource":"res","field":"field","value":"value","code":"code"}` testJSONMarshal(t, u, want) } @@ -255,48 +249,26 @@ func TestIssueImportResponse_Marshal(t *testing.T) { }, } - want := `{ - "id": 1, - "status": "status", - "url": "url", - "import_issues_url": "iiu", - "repository_url": "ru", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "message": "msg", - "documentation_url": "durl", - "errors": [ - { - "location": "loc", - "resource": "res", - "field": "field", - "value": "value", - "code": "code" - } - ] - }` + want := `{"id":1,"status":"status","url":"url","import_issues_url":"iiu","repository_url":"ru","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"message":"msg","documentation_url":"durl","errors":[{"location":"loc","resource":"res","field":"field","value":"value","code":"code"}]}` testJSONMarshal(t, u, want) } func TestComment_Marshal(t *testing.T) { - testJSONMarshal(t, &Comment{}, "{}") + testJSONMarshal(t, &Comment{}, `{"body":""}`) u := &Comment{ CreatedAt: &Timestamp{referenceTime}, Body: "body", } - want := `{ - "created_at": ` + referenceTimeStr + `, - "body": "body" - }` + want := `{"created_at":` + referenceTimeStr + `,"body":"body"}` testJSONMarshal(t, u, want) } func TestIssueImport_Marshal(t *testing.T) { - testJSONMarshal(t, &IssueImport{}, "{}") + testJSONMarshal(t, &IssueImport{}, `{"title":"","body":""}`) u := &IssueImport{ Title: "title", @@ -310,25 +282,13 @@ func TestIssueImport_Marshal(t *testing.T) { Labels: []string{"l"}, } - want := `{ - "title": "title", - "body": "body", - "created_at": ` + referenceTimeStr + `, - "closed_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "assignee": "a", - "milestone": 1, - "closed": false, - "labels": [ - "l" - ] - }` + want := `{"title":"title","body":"body","created_at":` + referenceTimeStr + `,"closed_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"assignee":"a","milestone":1,"closed":false,"labels":["l"]}` testJSONMarshal(t, u, want) } func TestIssueImportRequest_Marshal(t *testing.T) { - testJSONMarshal(t, &IssueImportRequest{}, "{}") + testJSONMarshal(t, &IssueImportRequest{}, `{"issue":{"title":"","body":""}}`) u := &IssueImportRequest{ IssueImport: IssueImport{ @@ -350,27 +310,7 @@ func TestIssueImportRequest_Marshal(t *testing.T) { }, } - want := `{ - "issue": { - "title": "title", - "body": "body", - "created_at": ` + referenceTimeStr + `, - "closed_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "assignee": "a", - "milestone": 1, - "closed": false, - "labels": [ - "l" - ] - }, - "comments": [ - { - "created_at": ` + referenceTimeStr + `, - "body": "body" - } - ] - }` + want := `{"issue":{"title":"title","body":"body","created_at":` + referenceTimeStr + `,"closed_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"assignee":"a","milestone":1,"closed":false,"labels":["l"]},"comments":[{"created_at":` + referenceTimeStr + `,"body":"body"}]}` testJSONMarshal(t, u, want) } diff --git a/github/issues_comments_test.go b/github/issues_comments_test.go index d35deedaf17..cc40a16a7c8 100644 --- a/github/issues_comments_test.go +++ b/github/issues_comments_test.go @@ -331,40 +331,7 @@ func TestIssueComment_Marshal(t *testing.T) { IssueURL: String("iurl"), } - want := `{ - "id": 1, - "node_id": "nid", - "body": "body", - "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" - }, - "reactions": { - "total_count": 1 - }, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "author_association": "aa", - "url": "url", - "html_url": "hurl", - "issue_url": "iurl" - }` + want := `{"id":1,"node_id":"nid","body":"body","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"},"reactions":{"total_count":1},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"author_association":"aa","url":"url","html_url":"hurl","issue_url":"iurl"}` testJSONMarshal(t, u, want) } diff --git a/github/issues_events_test.go b/github/issues_events_test.go index 1d8d3233d19..8126e95ca7e 100644 --- a/github/issues_events_test.go +++ b/github/issues_events_test.go @@ -138,10 +138,7 @@ func TestRename_Marshal(t *testing.T) { To: String("to"), } - want := `{ - "from": "from", - "to": "to" - }` + want := `{"from":"from","to":"to"}` testJSONMarshal(t, u, want) } @@ -156,12 +153,7 @@ func TestDismissedReview_Marshal(t *testing.T) { DismissalCommitID: String("dcid"), } - want := `{ - "state": "state", - "review_id": 1, - "dismissal_message": "dm", - "dismissal_commit_id": "dcid" - }` + want := `{"state":"state","review_id":1,"dismissal_message":"dm","dismissal_commit_id":"dcid"}` testJSONMarshal(t, u, want) } @@ -292,136 +284,7 @@ func TestIssueEvent_Marshal(t *testing.T) { }, } - want := `{ - "id": 1, - "url": "url", - "actor": { - "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" - }, - "event": "event", - "created_at": ` + referenceTimeStr + `, - "issue": { - "id": 1 - }, - "assignee": { - "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" - }, - "assigner": { - "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" - }, - "commit_id": "cid", - "milestone": { - "id": 1 - }, - "label": { - "id": 1 - }, - "rename": { - "from": "from", - "to": "to" - }, - "lock_reason": "lr", - "project_card": { - "id": 1 - }, - "dismissed_review": { - "state": "state", - "review_id": 1, - "dismissal_message": "dm", - "dismissal_commit_id": "dcid" - }, - "requested_reviewer": { - "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" - }, - "review_requester": { - "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" - } - }` + want := `{"id":1,"url":"url","actor":{"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"},"event":"event","created_at":` + referenceTimeStr + `,"issue":{"id":1},"assignee":{"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"},"assigner":{"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"},"commit_id":"cid","milestone":{"id":1},"label":{"id":1},"rename":{"from":"from","to":"to"},"lock_reason":"lr","project_card":{"id":1},"dismissed_review":{"state":"state","review_id":1,"dismissal_message":"dm","dismissal_commit_id":"dcid"},"requested_reviewer":{"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"},"review_requester":{"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) } diff --git a/github/issues_labels_test.go b/github/issues_labels_test.go index 06f4c6b6768..6a4f7ab416e 100644 --- a/github/issues_labels_test.go +++ b/github/issues_labels_test.go @@ -527,15 +527,7 @@ func TestLabel_Marshal(t *testing.T) { NodeID: String("nid"), } - want := `{ - "id": 1, - "url": "url", - "name": "name", - "color": "color", - "description": "desc", - "default": false, - "node_id": "nid" - }` + want := `{"id":1,"url":"url","name":"name","color":"color","description":"desc","default":false,"node_id":"nid"}` testJSONMarshal(t, u, want) } diff --git a/github/issues_milestones_test.go b/github/issues_milestones_test.go index b6472f34688..6ce906952bd 100644 --- a/github/issues_milestones_test.go +++ b/github/issues_milestones_test.go @@ -291,43 +291,7 @@ func TestMilestone_Marshal(t *testing.T) { NodeID: String("nid"), } - want := `{ - "url": "url", - "html_url": "hurl", - "labels_url": "lurl", - "id": 1, - "number": 1, - "state": "state", - "title": "title", - "description": "desc", - "creator": { - "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": "tu", - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "suspended_at": ` + referenceTimeStr + `, - "url": "u" - }, - "open_issues": 1, - "closed_issues": 1, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "closed_at": ` + referenceTimeStr + `, - "due_on": ` + referenceTimeStr + `, - "node_id": "nid" - }` + want := `{"url":"url","html_url":"hurl","labels_url":"lurl","id":1,"number":1,"state":"state","title":"title","description":"desc","creator":{"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":"tu","public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"suspended_at":` + referenceTimeStr + `,"url":"u"},"open_issues":1,"closed_issues":1,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"closed_at":` + referenceTimeStr + `,"due_on":` + referenceTimeStr + `,"node_id":"nid"}` testJSONMarshal(t, u, want) } diff --git a/github/issues_test.go b/github/issues_test.go index 37b2c2ad0f7..aca0f6fb47f 100644 --- a/github/issues_test.go +++ b/github/issues_test.go @@ -484,9 +484,7 @@ func TestLockIssueOptions_Marshal(t *testing.T) { LockReason: "lr", } - want := `{ - "lock_reason": "lr" - }` + want := `{"lock_reason":"lr"}` testJSONMarshal(t, u, want) } @@ -501,12 +499,7 @@ func TestPullRequestLinks_Marshal(t *testing.T) { PatchURL: String("purl"), } - want := `{ - "url": "url", - "html_url": "hurl", - "diff_url": "durl", - "patch_url": "purl" - }` + want := `{"url":"url","html_url":"hurl","diff_url":"durl","patch_url":"purl"}` testJSONMarshal(t, u, want) } @@ -524,19 +517,7 @@ func TestIssueRequest_Marshal(t *testing.T) { Assignees: &[]string{"a"}, } - want := `{ - "title": "url", - "body": "url", - "labels": [ - "l" - ], - "assignee": "url", - "state": "url", - "milestone": 1, - "assignees": [ - "a" - ] - }` + want := `{"title":"url","body":"url","labels":["l"],"assignee":"url","state":"url","milestone":1,"assignees":["a"]}` testJSONMarshal(t, u, want) } @@ -576,63 +557,7 @@ func TestIssue_Marshal(t *testing.T) { ActiveLockReason: String("alr"), } - want := `{ - "id": 1, - "number": 1, - "state": "s", - "locked": false, - "title": "title", - "body": "body", - "author_association": "aa", - "user": { - "id": 1 - }, - "labels": [ - { - "id": 1 - } - ], - "assignee": { - "id": 1 - }, - "comments": 1, - "closed_at": ` + referenceTimeStr + `, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "closed_by": { - "id": 1 - }, - "url": "url", - "html_url": "hurl", - "comments_url": "curl", - "events_url": "eurl", - "labels_url": "lurl", - "repository_url": "rurl", - "milestone": { - "id": 1 - }, - "pull_request": { - "url": "url" - }, - "repository": { - "id": 1 - }, - "reactions": { - "total_count": 1 - }, - "assignees": [ - { - "id": 1 - } - ], - "node_id": "nid", - "text_matches": [ - { - "object_url": "ourl" - } - ], - "active_lock_reason": "alr" - }` + want := `{"id":1,"number":1,"state":"s","locked":false,"title":"title","body":"body","author_association":"aa","user":{"id":1},"labels":[{"id":1}],"assignee":{"id":1},"comments":1,"closed_at":` + referenceTimeStr + `,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"closed_by":{"id":1},"url":"url","html_url":"hurl","comments_url":"curl","events_url":"eurl","labels_url":"lurl","repository_url":"rurl","milestone":{"id":1},"pull_request":{"url":"url"},"repository":{"id":1},"reactions":{"total_count":1},"assignees":[{"id":1}],"node_id":"nid","text_matches":[{"object_url":"ourl"}],"active_lock_reason":"alr"}` testJSONMarshal(t, u, want) } diff --git a/github/issues_timeline_test.go b/github/issues_timeline_test.go index 27c7c115e7b..a35efd0090c 100644 --- a/github/issues_timeline_test.go +++ b/github/issues_timeline_test.go @@ -76,23 +76,7 @@ func TestSource_Marshal(t *testing.T) { Issue: &Issue{ID: Int64(1)}, } - want := `{ - "id": 1, - "url": "url", - "actor": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "type": "type", - "issue": { - "id": 1 - } - }` + want := `{"id":1,"url":"url","actor":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"type":"type","issue":{"id":1}}` testJSONMarshal(t, u, want) } @@ -172,85 +156,7 @@ func TestTimeline_Marshal(t *testing.T) { State: String("state"), } - want := `{ - "id": 1, - "url": "url", - "commit_url": "curl", - "actor": { - "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" - }, - "event": "event", - "commit_id": "cid", - "created_at": ` + referenceTimeStr + `, - "label": { - "id": 1 - }, - "assignee": { - "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" - }, - "milestone": { - "id": 1 - }, - "source": { - "id": 1, - "url": "url", - "actor": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "type": "type", - "issue": { - "id": 1 - } - }, - "rename": { - "from": "from", - "to": "to" - }, - "project_card": { - "id": 1 - }, - "state": "state" - }` + want := `{"id":1,"url":"url","commit_url":"curl","actor":{"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"},"event":"event","commit_id":"cid","created_at":` + referenceTimeStr + `,"label":{"id":1},"assignee":{"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"},"milestone":{"id":1},"source":{"id":1,"url":"url","actor":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"type":"type","issue":{"id":1}},"rename":{"from":"from","to":"to"},"project_card":{"id":1},"state":"state"}` testJSONMarshal(t, u, want) } diff --git a/github/licenses_test.go b/github/licenses_test.go index aaaac15cbac..f5568432079 100644 --- a/github/licenses_test.go +++ b/github/licenses_test.go @@ -44,33 +44,7 @@ func TestRepositoryLicense_Marshal(t *testing.T) { Body: String("b"), }, } - want := `{ - "name": "n", - "path": "p", - "sha": "s", - "size": 1, - "url": "u", - "html_url": "h", - "git_url": "g", - "download_url": "d", - "type": "t", - "content": "c", - "encoding": "e", - "license": { - "key": "k", - "name": "n", - "url": "u", - "spdx_id": "s", - "html_url": "h", - "featured": true, - "description": "d", - "implementation": "i", - "permissions": ["p"], - "conditions": ["c"], - "limitations": ["l"], - "body": "b" - } - }` + want := `{"name":"n","path":"p","sha":"s","size":1,"url":"u","html_url":"h","git_url":"g","download_url":"d","type":"t","content":"c","encoding":"e","license":{"key":"k","name":"n","url":"u","spdx_id":"s","html_url":"h","featured":true,"description":"d","implementation":"i","permissions":["p"],"conditions":["c"],"limitations":["l"],"body":"b"}}` testJSONMarshal(t, rl, want) } @@ -91,20 +65,8 @@ func TestLicense_Marshal(t *testing.T) { Limitations: &[]string{"l"}, Body: String("b"), } - want := `{ - "key": "k", - "name": "n", - "url": "u", - "spdx_id": "s", - "html_url": "h", - "featured": true, - "description": "d", - "implementation": "i", - "permissions": ["p"], - "conditions": ["c"], - "limitations": ["l"], - "body": "b" - }` + want := `{"key":"k","name":"n","url":"u","spdx_id":"s","html_url":"h","featured":true,"description":"d","implementation":"i","permissions":["p"],"conditions":["c"],"limitations":["l"],"body":"b"}` + testJSONMarshal(t, l, want) } diff --git a/github/migrations_source_import_test.go b/github/migrations_source_import_test.go index bcb49de1c90..4b305f55d0c 100644 --- a/github/migrations_source_import_test.go +++ b/github/migrations_source_import_test.go @@ -344,12 +344,7 @@ func TestLargeFile_Marshal(t *testing.T) { Size: Int(1), } - want := `{ - "ref_name": "rn", - "path": "p", - "oid": "oid", - "size": 1 - }` + want := `{"ref_name":"rn","path":"p","oid":"oid","size":1}` testJSONMarshal(t, u, want) } @@ -367,15 +362,7 @@ func TestSourceImportAuthor_Marshal(t *testing.T) { ImportURL: String("iurl"), } - want := `{ - "id": 1, - "remote_id": "rid", - "remote_name": "rn", - "email": "e", - "name": "n", - "url": "url", - "import_url": "iurl" - }` + want := `{"id":1,"remote_id":"rid","remote_name":"rn","email":"e","name":"n","url":"url","import_url":"iurl"}` testJSONMarshal(t, u, want) } @@ -409,35 +396,7 @@ func TestImport_Marshal(t *testing.T) { ProjectChoices: []*Import{{VCSURL: String("vcsurl")}}, } - want := `{ - "vcs_url": "vcsurl", - "vcs": "vcs", - "vcs_username": "vcsusr", - "vcs_password": "vcspass", - "tfvc_project": "tfvcp", - "use_lfs": "uselfs", - "has_large_files": false, - "large_files_size": 1, - "large_files_count": 1, - "status": "status", - "commit_count": 1, - "status_text": "statustxt", - "authors_count": 1, - "percent": 1, - "push_percent": 1, - "url": "url", - "html_url": "hurl", - "authors_url": "aurl", - "repository_url": "rurl", - "message": "msg", - "failed_step": "fs", - "human_name": "hn", - "project_choices": [ - { - "vcs_url": "vcsurl" - } - ] - }` + want := `{"vcs_url":"vcsurl","vcs":"vcs","vcs_username":"vcsusr","vcs_password":"vcspass","tfvc_project":"tfvcp","use_lfs":"uselfs","has_large_files":false,"large_files_size":1,"large_files_count":1,"status":"status","commit_count":1,"status_text":"statustxt","authors_count":1,"percent":1,"push_percent":1,"url":"url","html_url":"hurl","authors_url":"aurl","repository_url":"rurl","message":"msg","failed_step":"fs","human_name":"hn","project_choices":[{"vcs_url":"vcsurl"}]}` testJSONMarshal(t, u, want) } diff --git a/github/migrations_test.go b/github/migrations_test.go index 4a5c0fc6c06..2e5c6adcbf8 100644 --- a/github/migrations_test.go +++ b/github/migrations_test.go @@ -267,21 +267,7 @@ func TestMigration_Marshal(t *testing.T) { Repositories: []*Repository{{ID: Int64(1)}}, } - want := `{ - "id": 1, - "guid": "guid", - "state": "state", - "lock_repositories": false, - "exclude_attachments": false, - "url": "url", - "created_at": "ca", - "updated_at": "ua", - "repositories": [ - { - "id": 1 - } - ] - }` + want := `{"id":1,"guid":"guid","state":"state","lock_repositories":false,"exclude_attachments":false,"url":"url","created_at":"ca","updated_at":"ua","repositories":[{"id":1}]}` testJSONMarshal(t, u, want) } @@ -295,13 +281,7 @@ func TestStartMigration_Marshal(t *testing.T) { ExcludeAttachments: Bool(false), } - want := `{ - "repositories": [ - "r" - ], - "lock_repositories": false, - "exclude_attachments": false - }` + want := `{"repositories":["r"],"lock_repositories":false,"exclude_attachments":false}` testJSONMarshal(t, u, want) } diff --git a/github/migrations_user_test.go b/github/migrations_user_test.go index 358bb9bdcf3..8d5d569ef43 100644 --- a/github/migrations_user_test.go +++ b/github/migrations_user_test.go @@ -265,21 +265,7 @@ func TestUserMigration_Marshal(t *testing.T) { Repositories: []*Repository{{ID: Int64(1)}}, } - want := `{ - "id": 1, - "guid": "guid", - "state": "state", - "lock_repositories": false, - "exclude_attachments": false, - "url": "url", - "created_at": "ca", - "updated_at": "ua", - "repositories": [ - { - "id": 1 - } - ] - }` + want := `{"id":1,"guid":"guid","state":"state","lock_repositories":false,"exclude_attachments":false,"url":"url","created_at":"ca","updated_at":"ua","repositories":[{"id":1}]}` testJSONMarshal(t, u, want) } @@ -293,13 +279,7 @@ func TestStartUserMigration_Marshal(t *testing.T) { ExcludeAttachments: Bool(false), } - want := `{ - "repositories": [ - "r" - ], - "lock_repositories": false, - "exclude_attachments": false - }` + want := `{"repositories":["r"],"lock_repositories":false,"exclude_attachments":false}` testJSONMarshal(t, u, want) } diff --git a/github/misc_test.go b/github/misc_test.go index 4e88ec54529..838b765fbba 100644 --- a/github/misc_test.go +++ b/github/misc_test.go @@ -193,19 +193,7 @@ func TestAPIMeta_Marshal(t *testing.T) { API: []string{"a"}, Web: []string{"w"}, } - want := `{ - "hooks":["h"], - "git":["g"], - "verifiable_password_authentication":true, - "pages":["p"], - "importer":["i"], - "actions":["a"], - "dependabot":["d"], - "ssh_key_fingerprints":{"a":"f"}, - "ssh_keys":["k"], - "api":["a"], - "web":["w"] - }` + want := `{"hooks":["h"],"git":["g"],"verifiable_password_authentication":true,"pages":["p"],"importer":["i"],"actions":["a"],"dependabot":["d"],"ssh_key_fingerprints":{"a":"f"},"ssh_keys":["k"],"web":["w"],"api":["a"]}` testJSONMarshal(t, a, want) } @@ -368,11 +356,7 @@ func TestMarkdownRequest_Marshal(t *testing.T) { Context: String("ctx"), } - want := `{ - "text": "txt", - "mode": "mode", - "context": "ctx" - }` + want := `{"text":"txt","mode":"mode","context":"ctx"}` testJSONMarshal(t, a, want) } @@ -387,12 +371,7 @@ func TestCodeOfConduct_Marshal(t *testing.T) { Body: String("body"), } - want := `{ - "name": "name", - "key": "key", - "url": "url", - "body": "body" - }` + want := `{"name":"name","key":"key","url":"url","body":"body"}` testJSONMarshal(t, a, want) } @@ -406,20 +385,7 @@ func TestServiceHook_Marshal(t *testing.T) { SupportedEvents: []string{"se"}, Schema: [][]string{{"g"}}, } - want := `{ - "name": "name", - "events": [ - "e" - ], - "supported_events": [ - "se" - ], - "schema": [ - [ - "g" - ] - ] - }` + want := `{"name":"name","events":["e"],"supported_events":["se"],"schema":[["g"]]}` testJSONMarshal(t, a, want) } diff --git a/github/orgs_actions_allowed_test.go b/github/orgs_actions_allowed_test.go index 6af05213523..213912d12f8 100644 --- a/github/orgs_actions_allowed_test.go +++ b/github/orgs_actions_allowed_test.go @@ -101,13 +101,7 @@ func TestActionsAllowed_Marshal(t *testing.T) { PatternsAllowed: []string{"s"}, } - want := `{ - "github_owned_allowed": false, - "verified_allowed": false, - "patterns_allowed": [ - "s" - ] - }` + want := `{"github_owned_allowed":false,"verified_allowed":false,"patterns_allowed":["s"]}` testJSONMarshal(t, u, want) } @@ -121,11 +115,7 @@ func TestActionsPermissions_Marshal(t *testing.T) { SelectedActionsURL: String("sau"), } - want := `{ - "enabled_repositories": "e", - "allowed_actions": "a", - "selected_actions_url": "sau" - }` + want := `{"enabled_repositories":"e","allowed_actions":"a","selected_actions_url":"sau"}` testJSONMarshal(t, u, want) } diff --git a/github/orgs_audit_log.go b/github/orgs_audit_log.go index 700c233c803..b0c3ed869fb 100644 --- a/github/orgs_audit_log.go +++ b/github/orgs_audit_log.go @@ -16,7 +16,7 @@ type GetAuditLogOptions struct { Include *string `url:"include,omitempty"` // Event type includes. Can be one of "web", "git", "all". Default: "web". (Optional.) Order *string `url:"order,omitempty"` // The order of audit log events. Can be one of "asc" or "desc". Default: "desc". (Optional.) - ListCursorOptions + ListCursorOptions `url:",omitempty"` } // HookConfig describes metadata about a webhook configuration. diff --git a/github/orgs_audit_log_test.go b/github/orgs_audit_log_test.go index be6361560f9..9d5f14decb1 100644 --- a/github/orgs_audit_log_test.go +++ b/github/orgs_audit_log_test.go @@ -123,8 +123,10 @@ func TestOrganizationService_GetAuditLog(t *testing.T) { }) } -func TestGetAuditLogOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &GetAuditLogOptions{}, "{}") +func TestGetAuditLogOptions_addOptions(t *testing.T) { + url := "some/path" + + testAddURLOptions(t, url, &GetAuditLogOptions{}, url) u := &GetAuditLogOptions{ Phrase: String("p"), @@ -138,17 +140,7 @@ func TestGetAuditLogOptions_Marshal(t *testing.T) { }, } - want := `{ - "phrase": "p", - "include": "i", - "order": "o", - "Page": "p", - "PerPage": 1, - "After": "a", - "Before": "b" - }` - - testJSONMarshal(t, u, want) + testAddURLOptions(t, url, u, url+`?after=a&before=b&include=i&order=o&page=p&per_page=1&phrase=p`) } func TestHookConfig_Marshal(t *testing.T) { @@ -160,11 +152,7 @@ func TestHookConfig_Marshal(t *testing.T) { URL: String("url"), } - want := `{ - "content_type": "ct", - "insecure_ssl": "ct", - "url": "url" - }` + want := `{"content_type":"ct","insecure_ssl":"ct","url":"url"}` testJSONMarshal(t, u, want) } @@ -235,80 +223,7 @@ func TestAuditEntry_Marshal(t *testing.T) { WorkflowRunID: Int64(1), } - want := `{ - "action": "a", - "active": false, - "active_was": false, - "actor": "ac", - "blocked_user": "bu", - "business": "b", - "cancelled_at": ` + referenceTimeStr + `, - "completed_at": ` + referenceTimeStr + `, - "conclusion": "c", - "config": { - "url": "s" - }, - "config_was": { - "url": "s" - }, - "content_type": "ct", - "created_at": ` + referenceTimeStr + `, - "deploy_key_fingerprint": "dkf", - "_document_id": "did", - "emoji": "e", - "environment_name": "en", - "event": "e", - "events": [ - "s" - ], - "events_were": [ - "s" - ], - "explanation": "e", - "fingerprint": "f", - "head_branch": "hb", - "head_sha": "hsha", - "hook_id": 1, - "is_hosted_runner": false, - "job_name": "jn", - "limited_availability": false, - "message": "m", - "name": "n", - "old_permission": "op", - "old_user": "ou", - "openssh_public_key": "osshpk", - "org": "o", - "permission": "p", - "previous_visibility": "pv", - "read_only": "ro", - "repo": "r", - "repository": "repo", - "repository_public": false, - "run_attempt": 1, - "runner_group_id": 1, - "runner_group_name": "rgn", - "runner_id": 1, - "runner_labels": [ - "s" - ], - "runner_name": "rn", - "secrets_passed": [ - "s" - ], - "source_version": "sv", - "started_at": ` + referenceTimeStr + `, - "target_login": "tl", - "target_version": "tv", - "team": "t", - "@timestamp": ` + referenceTimeStr + `, - "transport_protocol_name": "tpn", - "transport_protocol": 1, - "trigger_id": 1, - "user": "u", - "visibility": "v", - "workflow_id": 1, - "workflow_run_id": 1 - }` + want := `{"action":"a","active":false,"active_was":false,"actor":"ac","blocked_user":"bu","business":"b","cancelled_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `,"conclusion":"c","config":{"url":"s"},"config_was":{"url":"s"},"content_type":"ct","created_at":` + referenceTimeStr + `,"deploy_key_fingerprint":"dkf","_document_id":"did","emoji":"e","environment_name":"en","event":"e","events":["s"],"events_were":["s"],"explanation":"e","fingerprint":"f","head_branch":"hb","head_sha":"hsha","hook_id":1,"is_hosted_runner":false,"job_name":"jn","limited_availability":false,"message":"m","name":"n","old_user":"ou","old_permission":"op","openssh_public_key":"osshpk","org":"o","permission":"p","previous_visibility":"pv","read_only":"ro","repo":"r","repository":"repo","repository_public":false,"run_attempt":1,"runner_group_id":1,"runner_group_name":"rgn","runner_id":1,"runner_labels":["s"],"runner_name":"rn","secrets_passed":["s"],"source_version":"sv","started_at":` + referenceTimeStr + `,"target_login":"tl","target_version":"tv","team":"t","@timestamp":` + referenceTimeStr + `,"transport_protocol_name":"tpn","transport_protocol":1,"trigger_id":1,"user":"u","visibility":"v","workflow_id":1,"workflow_run_id":1}` testJSONMarshal(t, u, want) } diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index 0b5068e55e5..570e53e7e34 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -891,49 +891,13 @@ func TestMembership_Marshal(t *testing.T) { }, } - want := `{ - "url": "url", - "state": "state", - "role": "email", - "organization_url": "orgurl", - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "user": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - } - }` + want := `{"url":"url","state":"state","role":"email","organization_url":"orgurl","organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"user":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` testJSONMarshal(t, u, want) } func TestCreateOrgInvitationOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &CreateOrgInvitationOptions{}, "{}") + testJSONMarshal(t, &CreateOrgInvitationOptions{}, `{"role":null,"team_ids":null}`) u := &CreateOrgInvitationOptions{ InviteeID: Int64(1), @@ -942,14 +906,7 @@ func TestCreateOrgInvitationOptions_Marshal(t *testing.T) { TeamID: []int64{1}, } - want := `{ - "invitee_id": 1, - "email": "email", - "role": "role", - "team_ids": [ - 1 - ] - }` + want := `{"invitee_id":1,"email":"email","role":"role","team_ids":[1]}` testJSONMarshal(t, u, want) } diff --git a/github/orgs_test.go b/github/orgs_test.go index b30c48f1bce..b38de554f67 100644 --- a/github/orgs_test.go +++ b/github/orgs_test.go @@ -40,30 +40,8 @@ func TestOrganization_Marshal(t *testing.T) { MembersCanCreatePublicPages: Bool(false), MembersCanCreatePrivatePages: Bool(true), } - want := ` - { - "billing_email": "support@github.com", - "blog": "https://github.com/blog", - "company": "GitHub", - "email": "support@github.com", - "twitter_username": "github", - "location": "San Francisco", - "name": "github", - "description": "GitHub, the company.", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "read", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "all", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - } - ` + want := `{"name":"github","company":"GitHub","blog":"https://github.com/blog","location":"San Francisco","email":"support@github.com","twitter_username":"github","description":"GitHub, the company.","billing_email":"support@github.com","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"read","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"all","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true}` + testJSONMarshal(t, o, want) } @@ -408,14 +386,7 @@ func TestOrganizationInstallations_Marshal(t *testing.T) { TotalCount: Int(1), Installations: []*Installation{{ID: Int64(1)}}, } - want := `{ - "total_count": 1, - "installations": [ - { - "id": 1 - } - ] - }` + want := `{"total_count":1,"installations":[{"id":1}]}` testJSONMarshal(t, o, want) } @@ -431,14 +402,7 @@ func TestPlan_Marshal(t *testing.T) { FilledSeats: Int(1), Seats: Int(1), } - want := `{ - "name": "name", - "space": 1, - "collaborators": 1, - "private_repos": 1, - "filled_seats": 1, - "seats": 1 - }` + want := `{"name":"name","space":1,"collaborators":1,"private_repos":1,"filled_seats":1,"seats":1}` testJSONMarshal(t, o, want) } diff --git a/github/packages_test.go b/github/packages_test.go index c825e6a5429..db7b1239604 100644 --- a/github/packages_test.go +++ b/github/packages_test.go @@ -17,13 +17,7 @@ func TestPackageRegistry_Marshal(t *testing.T) { URL: String("url"), Vendor: String("vendor"), } - want := `{ - "about_url": "aurl", - "name": "name", - "type": "type", - "url": "url", - "vendor": "vendor" - }` + want := `{"about_url":"aurl","name":"name","type":"type","url":"url","vendor":"vendor"}` testJSONMarshal(t, o, want) } @@ -65,39 +59,7 @@ func TestPackageFile_Marshal(t *testing.T) { UpdatedAt: &Timestamp{referenceTime}, } - want := `{ - "download_url": "durl", - "id": 1, - "name": "name", - "sha256": "sha256", - "sha1": "sha1", - "md5": "md5", - "content_type": "ct", - "state": "state", - "author": { - "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" - }, - "size": 1, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - }` + want := `{"download_url":"durl","id":1,"name":"name","sha256":"sha256","sha1":"sha1","md5":"md5","content_type":"ct","state":"state","author":{"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"},"size":1,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `}` testJSONMarshal(t, o, want) } @@ -138,38 +100,7 @@ func TestPackageRelease_Marshal(t *testing.T) { PublishedAt: &Timestamp{referenceTime}, } - want := `{ - "url": "url", - "html_url": "hurl", - "id": 1, - "tag_name": "tn", - "target_commitish": "tcs", - "name": "name", - "draft": true, - "author": { - "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" - }, - "prerelease": true, - "created_at": ` + referenceTimeStr + `, - "published_at": ` + referenceTimeStr + ` - }` + want := `{"url":"url","html_url":"hurl","id":1,"tag_name":"tn","target_commitish":"tcs","name":"name","draft":true,"author":{"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"},"prerelease":true,"created_at":` + referenceTimeStr + `,"published_at":` + referenceTimeStr + `}` testJSONMarshal(t, o, want) } @@ -282,110 +213,7 @@ func TestPackageVersion_Marshal(t *testing.T) { InstallationCommand: String("ic"), } - want := `{ - "id": 1, - "version": "ver", - "summary": "sum", - "body": "body", - "body_html": "btnhtml", - "release": { - "url": "url", - "html_url": "hurl", - "id": 1, - "tag_name": "tn", - "target_commitish": "tcs", - "name": "name", - "draft": true, - "author": { - "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" - }, - "prerelease": true, - "created_at": ` + referenceTimeStr + `, - "published_at": ` + referenceTimeStr + ` - }, - "manifest": "mani", - "html_url": "hurl", - "tag_name": "tn", - "target_commitish": "tcs", - "target_oid": "tid", - "draft": true, - "prerelease": true, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "package_files": [ - { - "download_url": "durl", - "id": 1, - "name": "name", - "sha256": "sha256", - "sha1": "sha1", - "md5": "md5", - "content_type": "ct", - "state": "state", - "author": { - "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" - }, - "size": 1, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - } - ], - "author": { - "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" - }, - "installation_command": "ic" - }` + want := `{"id":1,"version":"ver","summary":"sum","body":"body","body_html":"btnhtml","release":{"url":"url","html_url":"hurl","id":1,"tag_name":"tn","target_commitish":"tcs","name":"name","draft":true,"author":{"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"},"prerelease":true,"created_at":` + referenceTimeStr + `,"published_at":` + referenceTimeStr + `},"manifest":"mani","html_url":"hurl","tag_name":"tn","target_commitish":"tcs","target_oid":"tid","draft":true,"prerelease":true,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"package_files":[{"download_url":"durl","id":1,"name":"name","sha256":"sha256","sha1":"sha1","md5":"md5","content_type":"ct","state":"state","author":{"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"},"size":1,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `}],"author":{"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"},"installation_command":"ic"}` testJSONMarshal(t, o, want) } @@ -534,146 +362,7 @@ func TestPackage_Marshal(t *testing.T) { }, } - want := `{ - "id": 1, - "name": "name", - "package_type": "pt", - "html_url": "hurl", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "visibility": "private", - "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" - }, - "package_version": { - "id": 1, - "version": "ver", - "summary": "sum", - "body": "body", - "body_html": "btnhtml", - "release": { - "url": "url", - "html_url": "hurl", - "id": 1, - "tag_name": "tn", - "target_commitish": "tcs", - "name": "name", - "draft": true, - "author": { - "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" - }, - "prerelease": true, - "created_at": ` + referenceTimeStr + `, - "published_at": ` + referenceTimeStr + ` - }, - "manifest": "mani", - "html_url": "hurl", - "tag_name": "tn", - "target_commitish": "tcs", - "target_oid": "tid", - "draft": true, - "prerelease": true, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "package_files": [ - { - "download_url": "durl", - "id": 1, - "name": "name", - "sha256": "sha256", - "sha1": "sha1", - "md5": "md5", - "content_type": "ct", - "state": "state", - "author": { - "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" - }, - "size": 1, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - } - ], - "author": { - "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" - }, - "installation_command": "ic" - }, - "registry": { - "about_url": "aurl", - "name": "name", - "type": "type", - "url": "url", - "vendor": "vendor" - } - }` + want := `{"id":1,"name":"name","package_type":"pt","html_url":"hurl","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"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"},"package_version":{"id":1,"version":"ver","summary":"sum","body":"body","body_html":"btnhtml","release":{"url":"url","html_url":"hurl","id":1,"tag_name":"tn","target_commitish":"tcs","name":"name","draft":true,"author":{"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"},"prerelease":true,"created_at":` + referenceTimeStr + `,"published_at":` + referenceTimeStr + `},"manifest":"mani","html_url":"hurl","tag_name":"tn","target_commitish":"tcs","target_oid":"tid","draft":true,"prerelease":true,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"package_files":[{"download_url":"durl","id":1,"name":"name","sha256":"sha256","sha1":"sha1","md5":"md5","content_type":"ct","state":"state","author":{"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"},"size":1,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `}],"author":{"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"},"installation_command":"ic"},"registry":{"about_url":"aurl","name":"name","type":"type","url":"url","vendor":"vendor"},"visibility":"private"}` testJSONMarshal(t, o, want) } diff --git a/github/projects_test.go b/github/projects_test.go index c4ccbd092af..3f8c041bf0f 100644 --- a/github/projects_test.go +++ b/github/projects_test.go @@ -50,37 +50,7 @@ func TestProject_Marshal(t *testing.T) { URL: String("u"), }, } - want := `{ - "id": 1, - "url": "u", - "html_url": "h", - "columns_url": "c", - "owner_url": "o", - "name": "n", - "body": "b", - "number": 1, - "state": "s", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "node_id": "n", - "creator": { - "login": "l", - "id": 1, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "url": "u" - } - }` + want := `{"id":1,"url":"u","html_url":"h","columns_url":"c","owner_url":"o","name":"n","body":"b","number":1,"state":"s","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"node_id":"n","creator":{"login":"l","id":1,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"}}` testJSONMarshal(t, u, want) } @@ -860,13 +830,7 @@ func TestProjectOptions_Marshal(t *testing.T) { Private: Bool(false), } - want := `{ - "name": "name", - "body": "body", - "state": "state", - "organization_permission": "op", - "private": false - }` + want := `{"name":"name","body":"body","state":"state","organization_permission":"op","private":false}` testJSONMarshal(t, u, want) } @@ -885,44 +849,31 @@ func TestProjectColumn_Marshal(t *testing.T) { NodeID: String("onidp"), } - want := `{ - "id": 1, - "name": "name", - "url": "url", - "project_url": "purl", - "cards_url": "curl", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "node_id": "onidp" - }` + want := `{"id":1,"name":"name","url":"url","project_url":"purl","cards_url":"curl","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"node_id":"onidp"}` testJSONMarshal(t, u, want) } func TestProjectColumnOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &ProjectColumnOptions{}, "{}") + testJSONMarshal(t, &ProjectColumnOptions{}, `{"name":""}`) u := &ProjectColumnOptions{ Name: "name", } - want := `{ - "name": "name" - }` + want := `{"name":"name"}` testJSONMarshal(t, u, want) } func TestProjectColumnMoveOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &ProjectColumnMoveOptions{}, "{}") + testJSONMarshal(t, &ProjectColumnMoveOptions{}, `{"position":""}`) u := &ProjectColumnMoveOptions{ Position: "pos", } - want := `{ - "position": "pos" - }` + want := `{"position":"pos"}` testJSONMarshal(t, u, want) } @@ -967,42 +918,7 @@ func TestProjectCard_Marshal(t *testing.T) { PreviousColumnName: String("pcn"), } - want := `{ - "url": "url", - "column_url": "curl", - "content_url": "conurl", - "id": 1, - "note": "note", - "creator": { - "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" - }, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "node_id": "nid", - "archived": true, - "column_id": 1, - "project_id": 1, - "project_url": "purl", - "column_name": "cn", - "previous_column_name": "pcn" - }` + want := `{"url":"url","column_url":"curl","content_url":"conurl","id":1,"note":"note","creator":{"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"},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"node_id":"nid","archived":true,"column_id":1,"project_id":1,"project_url":"purl","column_name":"cn","previous_column_name":"pcn"}` testJSONMarshal(t, u, want) } @@ -1017,28 +933,20 @@ func TestProjectCardOptions_Marshal(t *testing.T) { Archived: Bool(false), } - want := `{ - "note": "note", - "content_id": 1, - "content_type": "ct", - "archived": false - }` + want := `{"note":"note","content_id":1,"content_type":"ct","archived":false}` testJSONMarshal(t, u, want) } func TestProjectCardMoveOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &ProjectCardMoveOptions{}, "{}") + testJSONMarshal(t, &ProjectCardMoveOptions{}, `{"position":""}`) u := &ProjectCardMoveOptions{ Position: "pos", ColumnID: 1, } - want := `{ - "position": "pos", - "column_id": 1 - }` + want := `{"position":"pos","column_id":1}` testJSONMarshal(t, u, want) } @@ -1050,9 +958,7 @@ func TestProjectCollaboratorOptions_Marshal(t *testing.T) { Permission: String("per"), } - want := `{ - "permission": "per" - }` + want := `{"permission":"per"}` testJSONMarshal(t, u, want) } @@ -1084,29 +990,7 @@ func TestProjectPermissionLevel_Marshal(t *testing.T) { }, } - want := `{ - "permission": "per", - "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" - } - }` + want := `{"permission":"per","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) } diff --git a/github/pulls_comments_test.go b/github/pulls_comments_test.go index 47d08d2b779..8e77f5b14d5 100644 --- a/github/pulls_comments_test.go +++ b/github/pulls_comments_test.go @@ -77,58 +77,7 @@ func TestPullComments_Marshal(t *testing.T) { PullRequestURL: String("pullrequestcommentPullRequestURL"), } - want := `{ - "id": 10, - "in_reply_to_id": 8, - "body": "Test comment", - "path": "file1.txt", - "diff_hunk": "@@ -16,33 +16,40 @@ fmt.Println()", - "pull_request_review_id": 42, - "position": 1, - "original_position": 4, - "start_line": 2, - "line": 3, - "original_line": 2, - "original_start_line": 2, - "side": "RIGHT", - "start_side": "LEFT", - "commit_id": "ab", - "original_commit_id": "9c", - "user": { - "login": "ll", - "id": 123, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "url": "u" - }, - "reactions": { - "total_count": 1, - "+1": 1, - "-1": 0, - "laugh": 0, - "confused": 0, - "heart": 0, - "hooray": 0, - "rocket": 0, - "eyes": 0, - "url": "u" - }, - "created_at": "2002-02-10T15:30:00Z", - "updated_at": "2002-02-10T15:30:00Z", - "url": "pullrequestcommentUrl", - "html_url": "pullrequestcommentHTMLUrl", - "pull_request_url": "pullrequestcommentPullRequestURL" - }` + want := `{"id":10,"in_reply_to_id":8,"body":"Test comment","path":"file1.txt","diff_hunk":"@@ -16,33 +16,40 @@ fmt.Println()","pull_request_review_id":42,"position":1,"original_position":4,"start_line":2,"line":3,"original_line":2,"original_start_line":2,"side":"RIGHT","start_side":"LEFT","commit_id":"ab","original_commit_id":"9c","user":{"login":"ll","id":123,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"},"reactions":{"total_count":1,"+1":1,"-1":0,"laugh":0,"confused":0,"heart":0,"hooray":0,"rocket":0,"eyes":0,"url":"u"},"created_at":"2002-02-10T15:30:00Z","updated_at":"2002-02-10T15:30:00Z","url":"pullrequestcommentUrl","html_url":"pullrequestcommentHTMLUrl","pull_request_url":"pullrequestcommentPullRequestURL"}` testJSONMarshal(t, u, want) } diff --git a/github/pulls_reviewers_test.go b/github/pulls_reviewers_test.go index 60502445390..13e0bdcafcc 100644 --- a/github/pulls_reviewers_test.go +++ b/github/pulls_reviewers_test.go @@ -23,15 +23,7 @@ func TestReviewersRequest_Marshal(t *testing.T) { TeamReviewers: []string{"t"}, } - want := `{ - "node_id": "n", - "reviewers": [ - "r" - ], - "team_reviewers" : [ - "t" - ] - }` + want := `{"node_id":"n","reviewers":["r"],"team_reviewers":["t"]}` testJSONMarshal(t, u, want) } @@ -76,44 +68,7 @@ func TestReviewers_Marshal(t *testing.T) { }}, } - want := `{ - "users" : [ - { - "login": "l", - "id": 1, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "url": "u" - } - ], - "teams" : [ - { - "id": 1, - "node_id": "node", - "name": "n", - "description": "d", - "url": "u", - "slug": "s", - "permission": "p", - "privacy": "priv", - "members_count": 1, - "repos_count": 1, - "members_url": "m", - "repositories_url": "r", - "ldap_dn": "l" - } - ] - }` + want := `{"users":[{"login":"l","id":1,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"}],"teams":[{"id":1,"node_id":"node","name":"n","description":"d","url":"u","slug":"s","permission":"p","privacy":"priv","members_count":1,"repos_count":1,"members_url":"m","repositories_url":"r","ldap_dn":"l"}]}` testJSONMarshal(t, u, want) } diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index 7931ba05140..ae7f45c4e14 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -637,9 +637,7 @@ func TestPullRequestReviewDismissalRequest_Marshal(t *testing.T) { Message: String("msg"), } - want := `{ - "message": "msg" - }` + want := `{"message":"msg"}` testJSONMarshal(t, u, want) } @@ -657,15 +655,7 @@ func TestDraftReviewComment_Marshal(t *testing.T) { Line: Int(1), } - want := `{ - "path": "path", - "position": 1, - "body": "body", - "start_side": "ss", - "side": "side", - "start_line": 1, - "line": 1 - }` + want := `{"path":"path","position":1,"body":"body","start_side":"ss","side":"side","start_line":1,"line":1}` testJSONMarshal(t, u, want) } @@ -691,23 +681,7 @@ func TestPullRequestReviewRequest_Marshal(t *testing.T) { }, } - want := `{ - "node_id": "nodeid", - "commit_id": "cid", - "body": "body", - "event": "event", - "comments": [ - { - "path": "path", - "position": 1, - "body": "body", - "start_side": "ss", - "side": "side", - "start_line": 1, - "line": 1 - } - ] - }` + want := `{"node_id":"nodeid","commit_id":"cid","body":"body","event":"event","comments":[{"path":"path","position":1,"body":"body","start_side":"ss","side":"side","start_line":1,"line":1}]}` testJSONMarshal(t, u, want) } @@ -747,37 +721,7 @@ func TestPullRequestReview_Marshal(t *testing.T) { AuthorAssociation: String("aa"), } - want := `{ - "id": 1, - "node_id": "nid", - "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" - }, - "body": "body", - "submitted_at": ` + referenceTimeStr + `, - "commit_id": "cid", - "html_url": "hurl", - "pull_request_url": "prurl", - "state": "state", - "author_association": "aa" - }` + want := `{"id":1,"node_id":"nid","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"},"body":"body","submitted_at":` + referenceTimeStr + `,"commit_id":"cid","html_url":"hurl","pull_request_url":"prurl","state":"state","author_association":"aa"}` testJSONMarshal(t, u, want) } diff --git a/github/pulls_test.go b/github/pulls_test.go index 590483fadb3..a43ded020ad 100644 --- a/github/pulls_test.go +++ b/github/pulls_test.go @@ -852,12 +852,7 @@ func TestPullRequestMergeRequest_Marshal(t *testing.T) { SHA: "sha", } - want := `{ - "commit_message": "cm", - "commit_title": "ct", - "merge_method": "mm", - "sha": "sha" - }` + want := `{"commit_message":"cm","commit_title":"ct","merge_method":"mm","sha":"sha"}` testJSONMarshal(t, u, want) } @@ -871,11 +866,7 @@ func TestPullRequestMergeResult_Marshal(t *testing.T) { Message: String("msg"), } - want := `{ - "sha": "sha", - "merged": false, - "message": "msg" - }` + want := `{"sha":"sha","merged":false,"message":"msg"}` testJSONMarshal(t, u, want) } @@ -891,13 +882,7 @@ func TestPullRequestUpdate_Marshal(t *testing.T) { MaintainerCanModify: Bool(false), } - want := `{ - "title": "title", - "body": "body", - "state": "state", - "base": "base", - "maintainer_can_modify": false - }` + want := `{"title":"title","body":"body","state":"state","base":"base","maintainer_can_modify":false}` testJSONMarshal(t, u, want) } @@ -910,10 +895,7 @@ func TestPullRequestBranchUpdateResponse_Marshal(t *testing.T) { URL: String("url"), } - want := `{ - "message": "message", - "url": "url" - }` + want := `{"message":"message","url":"url"}` testJSONMarshal(t, u, want) } @@ -925,9 +907,7 @@ func TestPullRequestBranchUpdateOptions_Marshal(t *testing.T) { ExpectedHeadSHA: String("eh"), } - want := `{ - "expected_head_sha": "eh" - }` + want := `{"expected_head_sha":"eh"}` testJSONMarshal(t, u, want) } @@ -945,15 +925,7 @@ func TestNewPullRequest_Marshal(t *testing.T) { Draft: Bool(false), } - want := `{ - "title": "eh", - "head": "eh", - "base": "eh", - "body": "eh", - "issue": 1, - "maintainer_can_modify": false, - "draft": false - }` + want := `{"title":"eh","head":"eh","base":"eh","body":"eh","issue":1,"maintainer_can_modify":false,"draft":false}` testJSONMarshal(t, u, want) } @@ -988,34 +960,7 @@ func TestPullRequestBranch_Marshal(t *testing.T) { }, } - want := `{ - "label": "label", - "ref": "ref", - "sha": "sha", - "repo": { - "id": 1 - }, - "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" - } - }` + want := `{"label":"label","ref":"ref","sha":"sha","repo":{"id":1},"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) } @@ -1027,9 +972,7 @@ func TestPRLink_Marshal(t *testing.T) { HRef: String("href"), } - want := `{ - "href": "href" - }` + want := `{"href":"href"}` testJSONMarshal(t, u, want) } @@ -1064,32 +1007,7 @@ func TestPRLinks_Marshal(t *testing.T) { }, } - want := `{ - "self": { - "href": "href" - }, - "html": { - "href": "href" - }, - "issue": { - "href": "href" - }, - "comments": { - "href": "href" - }, - "review_comments": { - "href": "href" - }, - "review_comment": { - "href": "href" - }, - "commits": { - "href": "href" - }, - "statuses": { - "href": "href" - } - }` + want := `{"self":{"href":"href"},"html":{"href":"href"},"issue":{"href":"href"},"comments":{"href":"href"},"review_comments":{"href":"href"},"review_comment":{"href":"href"},"commits":{"href":"href"},"statuses":{"href":"href"}}` testJSONMarshal(t, u, want) } @@ -1123,31 +1041,7 @@ func TestPullRequestAutoMerge_Marshal(t *testing.T) { CommitMessage: String("cm"), } - want := `{ - "enabled_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" - }, - "merge_method": "mm", - "commit_title": "ct", - "commit_message": "cm" - }` + want := `{"enabled_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"},"merge_method":"mm","commit_title":"ct","commit_message":"cm"}` testJSONMarshal(t, u, want) } @@ -1360,224 +1254,7 @@ func TestPullRequest_Marshal(t *testing.T) { ActiveLockReason: String("alr"), } - want := `{ - "id": 1, - "number": 1, - "state": "state", - "locked": false, - "title": "title", - "body": "body", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "closed_at": ` + referenceTimeStr + `, - "merged_at": ` + referenceTimeStr + `, - "labels": [ - { - "id": 1 - } - ], - "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" - }, - "draft": false, - "merged": false, - "mergeable": false, - "mergeable_state": "ms", - "merged_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" - }, - "merge_commit_sha": "mcs", - "rebaseable": false, - "comments": 1, - "commits": 1, - "additions": 1, - "deletions": 1, - "changed_files": 1, - "url": "url", - "html_url": "hurl", - "issue_url": "iurl", - "statuses_url": "surl", - "diff_url": "durl", - "patch_url": "purl", - "commits_url": "curl", - "comments_url": "comurl", - "review_comments_url": "rcurls", - "review_comment_url": "rcurl", - "review_comments": 1, - "assignee": { - "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" - }, - "assignees": [ - { - "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" - } - ], - "milestone": { - "id": 1 - }, - "maintainer_can_modify": true, - "author_association": "aa", - "node_id": "nid", - "requested_reviewers": [ - { - "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" - } - ], - "auto_merge": { - "enabled_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" - }, - "merge_method": "mm", - "commit_title": "ct", - "commit_message": "cm" - }, - "requested_teams": [ - { - "id": 1 - } - ], - "_links": { - "self": { - "href": "href" - }, - "html": { - "href": "href" - }, - "issue": { - "href": "href" - }, - "comments": { - "href": "href" - }, - "review_comments": { - "href": "href" - }, - "review_comment": { - "href": "href" - }, - "commits": { - "href": "href" - }, - "statuses": { - "href": "href" - } - }, - "head": { - "ref": "r2", - "repo": { - "id": 2 - } - }, - "base": { - "ref": "r2", - "repo": { - "id": 2 - } - }, - "active_lock_reason": "alr" - }` + want := `{"id":1,"number":1,"state":"state","locked":false,"title":"title","body":"body","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"closed_at":` + referenceTimeStr + `,"merged_at":` + referenceTimeStr + `,"labels":[{"id":1}],"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"},"draft":false,"merged":false,"mergeable":false,"mergeable_state":"ms","merged_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"},"merge_commit_sha":"mcs","rebaseable":false,"comments":1,"commits":1,"additions":1,"deletions":1,"changed_files":1,"url":"url","html_url":"hurl","issue_url":"iurl","statuses_url":"surl","diff_url":"durl","patch_url":"purl","commits_url":"curl","comments_url":"comurl","review_comments_url":"rcurls","review_comment_url":"rcurl","review_comments":1,"assignee":{"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"},"assignees":[{"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"}],"milestone":{"id":1},"maintainer_can_modify":true,"author_association":"aa","node_id":"nid","requested_reviewers":[{"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"}],"auto_merge":{"enabled_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"},"merge_method":"mm","commit_title":"ct","commit_message":"cm"},"requested_teams":[{"id":1}],"_links":{"self":{"href":"href"},"html":{"href":"href"},"issue":{"href":"href"},"comments":{"href":"href"},"review_comments":{"href":"href"},"review_comment":{"href":"href"},"commits":{"href":"href"},"statuses":{"href":"href"}},"head":{"ref":"r2","repo":{"id":2}},"base":{"ref":"r2","repo":{"id":2}},"active_lock_reason":"alr"}` testJSONMarshal(t, u, want) } diff --git a/github/pulls_threads_test.go b/github/pulls_threads_test.go index 7c3c8619968..810e146c571 100644 --- a/github/pulls_threads_test.go +++ b/github/pulls_threads_test.go @@ -76,116 +76,7 @@ func TestPullRequestThread_Marshal(t *testing.T) { Comments: []*PullRequestComment{comment, comment}, } - want := `{ - "id": 1, - "node_id": "nid", - "comments": [ - { - "id": 10, - "in_reply_to_id": 8, - "body": "Test comment", - "path": "file1.txt", - "diff_hunk": "@@ -16,33 +16,40 @@ fmt.Println()", - "pull_request_review_id": 42, - "position": 1, - "original_position": 4, - "start_line": 2, - "line": 3, - "original_line": 2, - "original_start_line": 2, - "side": "RIGHT", - "start_side": "LEFT", - "commit_id": "ab", - "original_commit_id": "9c", - "user": { - "login": "ll", - "id": 123, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "url": "u" - }, - "reactions": { - "total_count": 1, - "+1": 1, - "-1": 0, - "laugh": 0, - "confused": 0, - "heart": 0, - "hooray": 0, - "rocket": 0, - "eyes": 0, - "url": "u" - }, - "created_at": "2002-02-10T15:30:00Z", - "updated_at": "2002-02-10T15:30:00Z", - "url": "pullrequestcommentUrl", - "html_url": "pullrequestcommentHTMLUrl", - "pull_request_url": "pullrequestcommentPullRequestURL" - }, - { - "id": 10, - "in_reply_to_id": 8, - "body": "Test comment", - "path": "file1.txt", - "diff_hunk": "@@ -16,33 +16,40 @@ fmt.Println()", - "pull_request_review_id": 42, - "position": 1, - "original_position": 4, - "start_line": 2, - "line": 3, - "original_line": 2, - "original_start_line": 2, - "side": "RIGHT", - "start_side": "LEFT", - "commit_id": "ab", - "original_commit_id": "9c", - "user": { - "login": "ll", - "id": 123, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "url": "u" - }, - "reactions": { - "total_count": 1, - "+1": 1, - "-1": 0, - "laugh": 0, - "confused": 0, - "heart": 0, - "hooray": 0, - "rocket": 0, - "eyes": 0, - "url": "u" - }, - "created_at": "2002-02-10T15:30:00Z", - "updated_at": "2002-02-10T15:30:00Z", - "url": "pullrequestcommentUrl", - "html_url": "pullrequestcommentHTMLUrl", - "pull_request_url": "pullrequestcommentPullRequestURL" - } - ] - }` + want := `{"id":1,"node_id":"nid","comments":[{"id":10,"in_reply_to_id":8,"body":"Test comment","path":"file1.txt","diff_hunk":"@@ -16,33 +16,40 @@ fmt.Println()","pull_request_review_id":42,"position":1,"original_position":4,"start_line":2,"line":3,"original_line":2,"original_start_line":2,"side":"RIGHT","start_side":"LEFT","commit_id":"ab","original_commit_id":"9c","user":{"login":"ll","id":123,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"},"reactions":{"total_count":1,"+1":1,"-1":0,"laugh":0,"confused":0,"heart":0,"hooray":0,"rocket":0,"eyes":0,"url":"u"},"created_at":"2002-02-10T15:30:00Z","updated_at":"2002-02-10T15:30:00Z","url":"pullrequestcommentUrl","html_url":"pullrequestcommentHTMLUrl","pull_request_url":"pullrequestcommentPullRequestURL"},{"id":10,"in_reply_to_id":8,"body":"Test comment","path":"file1.txt","diff_hunk":"@@ -16,33 +16,40 @@ fmt.Println()","pull_request_review_id":42,"position":1,"original_position":4,"start_line":2,"line":3,"original_line":2,"original_start_line":2,"side":"RIGHT","start_side":"LEFT","commit_id":"ab","original_commit_id":"9c","user":{"login":"ll","id":123,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"},"reactions":{"total_count":1,"+1":1,"-1":0,"laugh":0,"confused":0,"heart":0,"hooray":0,"rocket":0,"eyes":0,"url":"u"},"created_at":"2002-02-10T15:30:00Z","updated_at":"2002-02-10T15:30:00Z","url":"pullrequestcommentUrl","html_url":"pullrequestcommentHTMLUrl","pull_request_url":"pullrequestcommentPullRequestURL"}]}` testJSONMarshal(t, u, want) } diff --git a/github/reactions_test.go b/github/reactions_test.go index f84c3383290..6abd56faf0e 100644 --- a/github/reactions_test.go +++ b/github/reactions_test.go @@ -24,11 +24,7 @@ func TestReaction_Marshal(t *testing.T) { Content: String("+1"), } - want := `{ - "id": 1, - "node_id": "n", - "content": "+1" - }` + want := `{"id":1,"node_id":"n","content":"+1"}` testJSONMarshal(t, r, want) } @@ -49,18 +45,7 @@ func TestReactions_Marshal(t *testing.T) { URL: String("u"), } - want := `{ - "total_count": 1, - "+1": 1, - "-1": 1, - "laugh": 1, - "confused": 1, - "heart": 1, - "hooray": 1, - "rocket": 1, - "eyes": 1, - "url": "u" - }` + want := `{"total_count":1,"+1":1,"-1":1,"laugh":1,"confused":1,"heart":1,"hooray":1,"rocket":1,"eyes":1,"url":"u"}` testJSONMarshal(t, r, want) } diff --git a/github/repos_actions_access_test.go b/github/repos_actions_access_test.go index 7085ac7d5c7..392b1ce8694 100644 --- a/github/repos_actions_access_test.go +++ b/github/repos_actions_access_test.go @@ -90,9 +90,7 @@ func TestRepositoryActionsAccessLevel_Marshal(t *testing.T) { AccessLevel: String("enterprise"), } - want := `{ - "access_level": "enterprise" - }` + want := `{"access_level":"enterprise"}` testJSONMarshal(t, u, want) } diff --git a/github/repos_actions_permissions_test.go b/github/repos_actions_permissions_test.go index 1d6012f62d2..086c6453d59 100644 --- a/github/repos_actions_permissions_test.go +++ b/github/repos_actions_permissions_test.go @@ -102,11 +102,7 @@ func TestActionsPermissionsRepository_Marshal(t *testing.T) { SelectedActionsURL: String("someURL"), } - want := `{ - "enabled": true, - "allowed_actions": "all", - "selected_actions_url": "someURL" - }` + want := `{"enabled":true,"allowed_actions":"all","selected_actions_url":"someURL"}` testJSONMarshal(t, u, want) } diff --git a/github/repos_autolinks_test.go b/github/repos_autolinks_test.go index a666dbf3ac7..3a902fdb1ea 100644 --- a/github/repos_autolinks_test.go +++ b/github/repos_autolinks_test.go @@ -173,11 +173,7 @@ func TestAutolinkOptions_Marshal(t *testing.T) { IsAlphanumeric: Bool(true), } - want := `{ - "key_prefix": "kp", - "url_template": "URLT", - "is_alphanumeric": true - }` + want := `{"key_prefix":"kp","url_template":"URLT","is_alphanumeric":true}` testJSONMarshal(t, r, want) } @@ -192,12 +188,7 @@ func TestAutolink_Marshal(t *testing.T) { IsAlphanumeric: Bool(true), } - want := `{ - "id": 1, - "key_prefix": "kp", - "url_template": "URLT", - "is_alphanumeric": true - }` + want := `{"id":1,"key_prefix":"kp","url_template":"URLT","is_alphanumeric":true}` testJSONMarshal(t, r, want) } diff --git a/github/repos_codeowners_test.go b/github/repos_codeowners_test.go index 62c58c5b192..78dde42ef71 100644 --- a/github/repos_codeowners_test.go +++ b/github/repos_codeowners_test.go @@ -76,7 +76,7 @@ func TestRepositoriesService_GetCodeownersErrors(t *testing.T) { } func TestCodeownersErrors_Marshal(t *testing.T) { - testJSONMarshal(t, &CodeownersErrors{}, "{}") + testJSONMarshal(t, &CodeownersErrors{}, `{"errors":null}`) u := &CodeownersErrors{ Errors: []*CodeownersError{ @@ -92,19 +92,7 @@ func TestCodeownersErrors_Marshal(t *testing.T) { }, } - want := `{ - "errors": [ - { - "line": 1, - "column": 1, - "kind": "Invalid pattern", - "source": "***/*.rb @monalisa", - "suggestion": "Did you mean **/*.rb?", - "message": "Invalid pattern on line 3: Did you mean **/*.rb?\n\n ***/*.rb @monalisa\n ^", - "path": ".github/CODEOWNERS" - } - ] - } -` + want := `{"errors":[{"line":1,"column":1,"kind":"Invalid pattern","source":"***/*.rb @monalisa","suggestion":"Did you mean **/*.rb?","message":"Invalid pattern on line 3: Did you mean **/*.rb?\n\n ***/*.rb @monalisa\n ^","path":".github/CODEOWNERS"}]}` + testJSONMarshal(t, u, want) } diff --git a/github/repos_collaborators_test.go b/github/repos_collaborators_test.go index 8953d36bccf..c1091972b81 100644 --- a/github/repos_collaborators_test.go +++ b/github/repos_collaborators_test.go @@ -369,9 +369,7 @@ func TestRepositoryAddCollaboratorOptions_Marshal(t *testing.T) { Permission: "permission", } - want := `{ - "permission": "permission" - }` + want := `{"permission":"permission"}` testJSONMarshal(t, r, want) } @@ -403,29 +401,7 @@ func TestRepositoryPermissionLevel_Marshal(t *testing.T) { }, } - want := `{ - "permission": "permission", - "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" - } - }` + want := `{"permission":"permission","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, r, want) } @@ -487,58 +463,7 @@ func TestCollaboratorInvitation_Marshal(t *testing.T) { HTMLURL: String("hurl"), } - want := `{ - "id": 1, - "repository": { - "id": 1, - "name": "n", - "url": "url" - }, - "invitee": { - "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" - }, - "inviter": { - "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" - }, - "permissions": "per", - "created_at": ` + referenceTimeStr + `, - "url": "url", - "html_url": "hurl" - }` + want := `{"id":1,"repository":{"id":1,"name":"n","url":"url"},"invitee":{"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"},"inviter":{"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"},"permissions":"per","created_at":` + referenceTimeStr + `,"url":"url","html_url":"hurl"}` testJSONMarshal(t, r, want) } diff --git a/github/repos_comments_test.go b/github/repos_comments_test.go index b3579bf5a80..d014d426925 100644 --- a/github/repos_comments_test.go +++ b/github/repos_comments_test.go @@ -295,7 +295,7 @@ func TestRepositoriesService_DeleteComment_invalidOwner(t *testing.T) { } func TestRepositoryComment_Marshal(t *testing.T) { - testJSONMarshal(t, &RepositoryComment{}, "{}") + testJSONMarshal(t, &RepositoryComment{}, `{"body":null}`) r := &RepositoryComment{ HTMLURL: String("hurl"), @@ -342,50 +342,7 @@ func TestRepositoryComment_Marshal(t *testing.T) { Position: Int(1), } - want := `{ - "html_url": "hurl", - "url": "url", - "id": 1, - "node_id": "nid", - "commit_id": "cid", - "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" - }, - "reactions": { - "total_count": 1, - "+1": 1, - "-1": 1, - "laugh": 1, - "confused": 1, - "heart": 1, - "hooray": 1, - "rocket": 1, - "eyes": 1, - "url": "u" - }, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "body": "body", - "path": "path", - "position": 1 - }` + want := `{"html_url":"hurl","url":"url","id":1,"node_id":"nid","commit_id":"cid","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"},"reactions":{"total_count":1,"+1":1,"-1":1,"laugh":1,"confused":1,"heart":1,"hooray":1,"rocket":1,"eyes":1,"url":"u"},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"body":"body","path":"path","position":1}` testJSONMarshal(t, r, want) } diff --git a/github/repos_commits_test.go b/github/repos_commits_test.go index 5840e677880..9f6a20c28f0 100644 --- a/github/repos_commits_test.go +++ b/github/repos_commits_test.go @@ -718,56 +718,7 @@ func TestBranchCommit_Marshal(t *testing.T) { Protected: Bool(false), } - want := `{ - "name": "n", - "commit": { - "sha": "s", - "author": { - "date": ` + referenceTimeStr + `, - "name": "n", - "email": "e", - "username": "u" - }, - "committer": { - "date": ` + referenceTimeStr + `, - "name": "n", - "email": "e", - "username": "u" - }, - "message": "m", - "tree": { - "sha": "s", - "tree": [ - { - "sha": "s", - "path": "p", - "mode": "m", - "type": "t", - "size": 1, - "content": "c", - "url": "u" - } - ], - "truncated": false - }, - "stats": { - "additions": 1, - "deletions": 1, - "total": 1 - }, - "html_url": "h", - "url": "u", - "verification": { - "verified": false, - "reason": "r", - "signature": "s", - "payload": "p" - }, - "node_id": "n", - "comment_count": 1 - }, - "protected": false - }` + want := `{"name":"n","commit":{"sha":"s","author":{"date":` + referenceTimeStr + `,"name":"n","email":"e","username":"u"},"committer":{"date":` + referenceTimeStr + `,"name":"n","email":"e","username":"u"},"message":"m","tree":{"sha":"s","tree":[{"sha":"s","path":"p","mode":"m","type":"t","size":1,"content":"c","url":"u"}],"truncated":false},"stats":{"additions":1,"deletions":1,"total":1},"html_url":"h","url":"u","verification":{"verified":false,"reason":"r","signature":"s","payload":"p"},"node_id":"n","comment_count":1},"protected":false}` testJSONMarshal(t, r, want) } @@ -799,33 +750,7 @@ func TestCommitsComparison_Marshal(t *testing.T) { URL: String("url"), } - want := `{ - "base_commit": { - "node_id": "nid" - }, - "merge_base_commit": { - "node_id": "nid" - }, - "status": "status", - "ahead_by": 1, - "behind_by": 1, - "total_commits": 1, - "commits": [ - { - "node_id": "nid" - } - ], - "files": [ - { - "sha": "sha" - } - ], - "html_url": "hurl", - "permalink_url": "purl", - "diff_url": "durl", - "patch_url": "purl", - "url": "url" - }` + want := `{"base_commit":{"node_id":"nid"},"merge_base_commit":{"node_id":"nid"},"status":"status","ahead_by":1,"behind_by":1,"total_commits":1,"commits":[{"node_id":"nid"}],"files":[{"sha":"sha"}],"html_url":"hurl","permalink_url":"purl","diff_url":"durl","patch_url":"purl","url":"url"}` testJSONMarshal(t, r, want) } @@ -847,19 +772,7 @@ func TestCommitFile_Marshal(t *testing.T) { PreviousFilename: String("pf"), } - want := `{ - "sha": "sha", - "filename": "fn", - "additions": 1, - "deletions": 1, - "changes": 1, - "status": "status", - "patch": "patch", - "blob_url": "burl", - "raw_url": "rurl", - "contents_url": "curl", - "previous_filename": "pf" - }` + want := `{"sha":"sha","filename":"fn","additions":1,"deletions":1,"changes":1,"status":"status","patch":"patch","blob_url":"burl","raw_url":"rurl","contents_url":"curl","previous_filename":"pf"}` testJSONMarshal(t, r, want) } @@ -873,11 +786,7 @@ func TestCommitStats_Marshal(t *testing.T) { Total: Int(1), } - want := `{ - "additions": 1, - "deletions": 1, - "total": 1 - }` + want := `{"additions":1,"deletions":1,"total":1}` testJSONMarshal(t, r, want) } @@ -925,45 +834,7 @@ func TestRepositoryCommit_Marshal(t *testing.T) { }, } - want := `{ - "node_id": "nid", - "sha": "sha", - "commit": { - "message": "m" - }, - "author": { - "login": "l" - }, - "committer": { - "login": "l" - }, - "parents": [ - { - "sha": "s" - } - ], - "html_url": "hurl", - "url": "url", - "comments_url": "curl", - "stats": { - "additions": 104, - "deletions": 4, - "total": 108 - }, - "files": [ - { - "filename": "f", - "additions": 10, - "deletions": 2, - "changes": 12, - "status": "s", - "patch": "p", - "blob_url": "b", - "raw_url": "r", - "contents_url": "c" - } - ] - }` + want := `{"node_id":"nid","sha":"sha","commit":{"message":"m"},"author":{"login":"l"},"committer":{"login":"l"},"parents":[{"sha":"s"}],"html_url":"hurl","url":"url","comments_url":"curl","stats":{"additions":104,"deletions":4,"total":108},"files":[{"filename":"f","additions":10,"deletions":2,"changes":12,"status":"s","patch":"p","blob_url":"b","raw_url":"r","contents_url":"c"}]}` testJSONMarshal(t, r, want) } diff --git a/github/repos_community_health_test.go b/github/repos_community_health_test.go index 6ff88bda5aa..6420d57c010 100644 --- a/github/repos_community_health_test.go +++ b/github/repos_community_health_test.go @@ -134,7 +134,7 @@ func TestRepositoriesService_GetCommunityHealthMetrics(t *testing.T) { } func TestMetric_Marshal(t *testing.T) { - testJSONMarshal(t, &Metric{}, "{}") + testJSONMarshal(t, &Metric{}, `{"name":null,"key":null,"spdx_id":null,"url":null,"html_url":null,"node_id":null}`) r := &Metric{ Name: String("name"), @@ -145,20 +145,13 @@ func TestMetric_Marshal(t *testing.T) { NodeID: String("node_id"), } - want := `{ - "name": "name", - "key": "key", - "spdx_id": "spdx_id", - "url": "url", - "html_url": "hurl", - "node_id": "node_id" - }` + want := `{"name":"name","key":"key","spdx_id":"spdx_id","url":"url","html_url":"hurl","node_id":"node_id"}` testJSONMarshal(t, r, want) } func TestCommunityHealthFiles_Marshal(t *testing.T) { - testJSONMarshal(t, &CommunityHealthFiles{}, "{}") + testJSONMarshal(t, &CommunityHealthFiles{}, `{"code_of_conduct":null,"code_of_conduct_file":null,"contributing":null,"issue_template":null,"pull_request_template":null,"license":null,"readme":null}`) r := &CommunityHealthFiles{ CodeOfConduct: &Metric{ @@ -207,58 +200,13 @@ func TestCommunityHealthFiles_Marshal(t *testing.T) { }, } - want := `{ - "code_of_conduct": { - "name": "name", - "key": "key", - "url": "url", - "html_url": "hurl" - }, - "code_of_conduct_file": { - "name": "name", - "key": "key", - "url": "url", - "html_url": "hurl" - }, - "contributing": { - "name": "name", - "key": "key", - "url": "url", - "html_url": "hurl" - }, - "issue_template": { - "name": "name", - "key": "key", - "url": "url", - "html_url": "hurl" - }, - "pull_request_template": { - "name": "name", - "key": "key", - "url": "url", - "html_url": "hurl" - }, - "license": { - "name": "name", - "key": "key", - "spdx_id": "spdx_id", - "url": "url", - "html_url": "hurl", - "node_id": "node_id" - }, - "readme": { - "name": "name", - "key": "key", - "url": "url", - "html_url": "hurl" - } - }` + want := `{"code_of_conduct":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"code_of_conduct_file":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"contributing":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"issue_template":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"pull_request_template":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"license":{"name":"name","key":"key","spdx_id":"spdx_id","url":"url","html_url":"hurl","node_id":"node_id"},"readme":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null}}` testJSONMarshal(t, r, want) } func TestCommunityHealthMetrics_Marshal(t *testing.T) { - testJSONMarshal(t, &CommunityHealthMetrics{}, "{}") + testJSONMarshal(t, &CommunityHealthMetrics{}, `{"health_percentage":null,"description":null,"documentation":null,"files":null,"updated_at":null,"content_reports_enabled":null}`) r := &CommunityHealthMetrics{ HealthPercentage: Int(1), @@ -314,59 +262,7 @@ func TestCommunityHealthMetrics_Marshal(t *testing.T) { ContentReportsEnabled: Bool(true), } - want := `{ - "health_percentage": 1, - "description": "desc", - "documentation": "docs", - "files": { - "code_of_conduct": { - "name": "name", - "key": "key", - "url": "url", - "html_url": "hurl" - }, - "code_of_conduct_file": { - "name": "name", - "key": "key", - "url": "url", - "html_url": "hurl" - }, - "contributing": { - "name": "name", - "key": "key", - "url": "url", - "html_url": "hurl" - }, - "issue_template": { - "name": "name", - "key": "key", - "url": "url", - "html_url": "hurl" - }, - "pull_request_template": { - "name": "name", - "key": "key", - "url": "url", - "html_url": "hurl" - }, - "license": { - "name": "name", - "key": "key", - "spdx_id": "spdx_id", - "url": "url", - "html_url": "hurl", - "node_id": "node_id" - }, - "readme": { - "name": "name", - "key": "key", - "url": "url", - "html_url": "hurl" - } - }, - "updated_at": ` + referenceTimeStr + `, - "content_reports_enabled": true - }` + want := `{"health_percentage":1,"description":"desc","documentation":"docs","files":{"code_of_conduct":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"code_of_conduct_file":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"contributing":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"issue_template":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"pull_request_template":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"license":{"name":"name","key":"key","spdx_id":"spdx_id","url":"url","html_url":"hurl","node_id":"node_id"},"readme":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null}},"updated_at":` + referenceTimeStr + `,"content_reports_enabled":true}` testJSONMarshal(t, r, want) } diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index 29262ce2db1..0c0fa64902b 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -782,26 +782,13 @@ func TestRepositoryContent_Marshal(t *testing.T) { DownloadURL: String("durl"), } - want := `{ - "type": "type", - "target": "target", - "encoding": "encoding", - "size": 1, - "name": "name", - "path": "path", - "content": "content", - "sha": "sha", - "url": "url", - "git_url": "gurl", - "html_url": "hurl", - "download_url": "durl" - }` + want := `{"type":"type","target":"target","encoding":"encoding","size":1,"name":"name","path":"path","content":"content","sha":"sha","url":"url","git_url":"gurl","html_url":"hurl","download_url":"durl"}` testJSONMarshal(t, r, want) } func TestRepositoryContentResponse_Marshal(t *testing.T) { - testJSONMarshal(t, &RepositoryContentResponse{}, "{}") + testJSONMarshal(t, &RepositoryContentResponse{}, `{"commit":{}}`) r := &RepositoryContentResponse{ Content: &RepositoryContent{ @@ -866,74 +853,13 @@ func TestRepositoryContentResponse_Marshal(t *testing.T) { }, } - want := `{ - "content": { - "type": "type", - "target": "target", - "encoding": "encoding", - "size": 1, - "name": "name", - "path": "path", - "content": "content", - "sha": "sha", - "url": "url", - "git_url": "gurl", - "html_url": "hurl", - "download_url": "durl" - }, - "commit": { - "sha": "s", - "author": { - "date": ` + referenceTimeStr + `, - "name": "n", - "email": "e", - "username": "u" - }, - "committer": { - "date": ` + referenceTimeStr + `, - "name": "n", - "email": "e", - "username": "u" - }, - "message": "m", - "tree": { - "sha": "s", - "tree": [ - { - "sha": "s", - "path": "p", - "mode": "m", - "type": "t", - "size": 1, - "content": "c", - "url": "u" - } - ], - "truncated": false - }, - "stats": { - "additions": 1, - "deletions": 1, - "total": 1 - }, - "html_url": "h", - "url": "u", - "verification": { - "verified": false, - "reason": "r", - "signature": "s", - "payload": "p" - }, - "node_id": "n", - "comment_count": 1 - } - }` + want := `{"content":{"type":"type","target":"target","encoding":"encoding","size":1,"name":"name","path":"path","content":"content","sha":"sha","url":"url","git_url":"gurl","html_url":"hurl","download_url":"durl"},"commit":{"sha":"s","author":{"date":` + referenceTimeStr + `,"name":"n","email":"e","username":"u"},"committer":{"date":` + referenceTimeStr + `,"name":"n","email":"e","username":"u"},"message":"m","tree":{"sha":"s","tree":[{"sha":"s","path":"p","mode":"m","type":"t","size":1,"content":"c","url":"u"}],"truncated":false},"stats":{"additions":1,"deletions":1,"total":1},"html_url":"h","url":"u","verification":{"verified":false,"reason":"r","signature":"s","payload":"p"},"node_id":"n","comment_count":1}}` testJSONMarshal(t, r, want) } func TestRepositoryContentFileOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &RepositoryContentFileOptions{}, "{}") + testJSONMarshal(t, &RepositoryContentFileOptions{}, `{"content":null}`) r := &RepositoryContentFileOptions{ Message: String("type"), @@ -954,24 +880,8 @@ func TestRepositoryContentFileOptions_Marshal(t *testing.T) { }, } - want := `{ - "message": "type", - "content": "AQ==", - "sha": "type", - "branch": "type", - "author": { - "date": ` + referenceTimeStr + `, - "name": "name", - "email": "email", - "username": "login" - }, - "committer": { - "date": ` + referenceTimeStr + `, - "name": "name", - "email": "email", - "username": "login" - } - }` + contentValue := `"AQ=="` + want := `{"message":"type","content":` + contentValue + `,"sha":"type","branch":"type","author":{"date":` + referenceTimeStr + `,"name":"name","email":"email","username":"login"},"committer":{"date":` + referenceTimeStr + `,"name":"name","email":"email","username":"login"}}` testJSONMarshal(t, r, want) } diff --git a/github/repos_deployments_test.go b/github/repos_deployments_test.go index c3d6637e37f..eb8eff90044 100644 --- a/github/repos_deployments_test.go +++ b/github/repos_deployments_test.go @@ -306,14 +306,7 @@ func TestDeploymentStatusRequest_Marshal(t *testing.T) { AutoInactive: Bool(false), } - want := `{ - "state": "state", - "log_url": "logurl", - "description": "desc", - "environment": "env", - "environment_url": "eurl", - "auto_inactive": false - }` + want := `{"state":"state","log_url":"logurl","description":"desc","environment":"env","environment_url":"eurl","auto_inactive":false}` testJSONMarshal(t, r, want) } @@ -357,41 +350,7 @@ func TestDeploymentStatus_Marshal(t *testing.T) { URL: String("url"), } - want := `{ - "id": 1, - "state": "state", - "creator": { - "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" - }, - "description": "desc", - "environment": "env", - "node_id": "nid", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "target_url": "turl", - "deployment_url": "durl", - "repository_url": "rurl", - "environment_url": "eurl", - "log_url": "lurl", - "url": "url" - }` + want := `{"id":1,"state":"state","creator":{"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"},"description":"desc","environment":"env","node_id":"nid","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"target_url":"turl","deployment_url":"durl","repository_url":"rurl","environment_url":"eurl","log_url":"lurl","url":"url"}` testJSONMarshal(t, r, want) } @@ -411,17 +370,7 @@ func TestDeploymentRequest_Marshal(t *testing.T) { ProductionEnvironment: Bool(false), } - want := `{ - "ref": "ref", - "task": "task", - "auto_merge": false, - "required_contexts": ["s"], - "payload": "payload", - "environment": "environment", - "description": "description", - "transient_environment": false, - "production_environment": false - }` + want := `{"ref":"ref","task":"task","auto_merge":false,"required_contexts":["s"],"payload":"payload","environment":"environment","description":"description","transient_environment":false,"production_environment":false}` testJSONMarshal(t, r, want) } @@ -468,41 +417,7 @@ func TestDeployment_Marshal(t *testing.T) { NodeID: String("nid"), } - want := `{ - "url": "url", - "id": 1, - "sha": "sha", - "ref": "ref", - "task": "task", - "payload": "s", - "environment": "env", - "description": "desc", - "creator": { - "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" - }, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "statuses_url": "surl", - "repository_url": "rurl", - "node_id": "nid" - }` + want := `{"url":"url","id":1,"sha":"sha","ref":"ref","task":"task","payload":"s","environment":"env","description":"desc","creator":{"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"},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"statuses_url":"surl","repository_url":"rurl","node_id":"nid"}` testJSONMarshal(t, r, want) } diff --git a/github/repos_environments_test.go b/github/repos_environments_test.go index 0b27da933d7..28ef5fdb273 100644 --- a/github/repos_environments_test.go +++ b/github/repos_environments_test.go @@ -393,46 +393,7 @@ func TestRepoEnvironment_Marshal(t *testing.T) { }, } - want := `{ - "total_count":1, - "environments":[ - { - "owner":"me", - "repo":"se", - "environment_name":"dev", - "wait_timer":123, - "reviewers":[ - { - "type":"main", - "id":1 - }, - { - "type":"rev", - "id":2 - } - ], - "deployment_branch_policy":{ - "protected_branches":false, - "custom_branch_policies":false - }, - "id":2, - "node_id":"star", - "name":"eg", - "url":"https://hey.in", - "html_url":"htmlurl", - "created_at":` + referenceTimeStr + `, - "updated_at":` + referenceTimeStr + `, - "protection_rules":[ - { - "id":21, - "node_id":"mnb", - "type":"ewq", - "wait_timer":9090 - } - ] - } - ] - }` + want := `{"total_count":1,"environments":[{"owner":"me","repo":"se","environment_name":"dev","wait_timer":123,"reviewers":[{"type":"main","id":1},{"type":"rev","id":2}],"deployment_branch_policy":{"protected_branches":false,"custom_branch_policies":false},"id":2,"node_id":"star","name":"eg","url":"https://hey.in","html_url":"htmlurl","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"protection_rules":[{"id":21,"node_id":"mnb","type":"ewq","wait_timer":9090}]}]}` testJSONMarshal(t, repoEnv, want) } @@ -445,10 +406,7 @@ func TestEnvReviewers_Marshal(t *testing.T) { ID: Int64(1), } - want := `{ - "type":"main", - "id":1 - }` + want := `{"type":"main","id":1}` testJSONMarshal(t, repoEnv, want) } @@ -492,41 +450,7 @@ func TestEnvironment_Marshal(t *testing.T) { }, } - want := `{ - "owner":"o", - "repo":"r", - "environment_name":"e", - "wait_timer":123, - "reviewers":[ - { - "type":"main", - "id":1 - }, - { - "type":"rev", - "id":2 - } - ], - "deployment_branch_policy":{ - "protected_branches":false, - "custom_branch_policies":false - }, - "id":2, - "node_id":"star", - "name":"eg", - "url":"https://hey.in", - "html_url":"htmlurl", - "created_at":` + referenceTimeStr + `, - "updated_at":` + referenceTimeStr + `, - "protection_rules":[ - { - "id":21, - "node_id":"mnb", - "type":"ewq", - "wait_timer":9090 - } - ] - }` + want := `{"owner":"o","repo":"r","environment_name":"e","wait_timer":123,"reviewers":[{"type":"main","id":1},{"type":"rev","id":2}],"deployment_branch_policy":{"protected_branches":false,"custom_branch_policies":false},"id":2,"node_id":"star","name":"eg","url":"https://hey.in","html_url":"htmlurl","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"protection_rules":[{"id":21,"node_id":"mnb","type":"ewq","wait_timer":9090}]}` testJSONMarshal(t, repoEnv, want) } @@ -539,10 +463,7 @@ func TestBranchPolicy_Marshal(t *testing.T) { CustomBranchPolicies: Bool(false), } - want := `{ - "protected_branches": false, - "custom_branch_policies": false - }` + want := `{"protected_branches":false,"custom_branch_policies":false}` testJSONMarshal(t, bp, want) } diff --git a/github/repos_hooks_deliveries_test.go b/github/repos_hooks_deliveries_test.go index ef453996a90..7c8cd322cf5 100644 --- a/github/repos_hooks_deliveries_test.go +++ b/github/repos_hooks_deliveries_test.go @@ -274,14 +274,7 @@ func TestHookRequest_Marshal(t *testing.T) { RawPayload: (*json.RawMessage)(&jsonMsg), } - want := `{ - "headers": { - "key": "value" - }, - "payload": { - "key": "value" - } - }` + want := `{"headers":{"key":"value"},"payload":{"key":"value"}}` testJSONMarshal(t, r, want) } @@ -299,14 +292,7 @@ func TestHookResponse_Marshal(t *testing.T) { RawPayload: (*json.RawMessage)(&jsonMsg), } - want := `{ - "headers": { - "key": "value" - }, - "payload": { - "key": "value" - } - }` + want := `{"headers":{"key":"value"},"payload":{"key":"value"}}` testJSONMarshal(t, r, want) } @@ -341,35 +327,7 @@ func TestHookDelivery_Marshal(t *testing.T) { }, } - want := `{ - "id": 1, - "guid": "guid", - "delivered_at": ` + referenceTimeStr + `, - "redelivery": true, - "duration": 1, - "status": "guid", - "status_code": 1, - "event": "guid", - "action": "guid", - "installation_id": 1, - "repository_id": 1, - "request": { - "headers": { - "key": "value" - }, - "payload": { - "key": "value" - } - }, - "response": { - "headers": { - "key": "value" - }, - "payload": { - "key": "value" - } - } - }` + want := `{"id":1,"guid":"guid","delivered_at":` + referenceTimeStr + `,"redelivery":true,"duration":1,"status":"guid","status_code":1,"event":"guid","action":"guid","installation_id":1,"repository_id":1,"request":{"headers":{"key":"value"},"payload":{"key":"value"}},"response":{"headers":{"key":"value"},"payload":{"key":"value"}}}` testJSONMarshal(t, r, want) } diff --git a/github/repos_hooks_test.go b/github/repos_hooks_test.go index 82e8b554d64..b2ebd9235f3 100644 --- a/github/repos_hooks_test.go +++ b/github/repos_hooks_test.go @@ -371,68 +371,7 @@ func TestBranchWebHookPayload_Marshal(t *testing.T) { }, } - want := `{ - "action": "action", - "after": "after", - "before": "before", - "commits": [ - { - "added": ["1", "2", "3"], - "author":{ - "email": "abc@gmail.com", - "name": "abc", - "username": "abc_12" - }, - "committer": { - "email": "abc@gmail.com", - "name": "abc", - "username": "abc_12" - }, - "id": "1", - "message": "WebHookCommit", - "modified": ["abc", "efg", "erd"], - "removed": ["cmd", "rti", "duv"] - } - ], - "compare": "compare", - "created": true, - "forced": false, - "head_commit": { - "added": ["1", "2", "3"], - "author":{ - "email": "abc@gmail.com", - "name": "abc", - "username": "abc_12" - }, - "committer": { - "email": "abc@gmail.com", - "name": "abc", - "username": "abc_12" - }, - "id": "1", - "message": "WebHookCommit", - "modified": ["abc", "efg", "erd"], - "removed": ["cmd", "rti", "duv"] - }, - "installation": { - "id": 12 - }, - "organization": { - "id" : 22 - }, - "pusher":{ - "login": "rd@yahoo.com", - "id": 112 - }, - "repository":{ - "id": 321, - "node_id": "node_321" - }, - "sender":{ - "login": "st@gmail.com", - "id": 202 - } - }` + want := `{"commits":[{"message":"WebHookCommit","author":{"name":"abc","email":"abc@gmail.com","username":"abc_12"},"id":"1","committer":{"name":"abc","email":"abc@gmail.com","username":"abc_12"},"added":["1","2","3"],"removed":["cmd","rti","duv"],"modified":["abc","efg","erd"]}],"before":"before","action":"action","after":"after","created":true,"forced":false,"compare":"compare","repository":{"id":321,"node_id":"node_321"},"head_commit":{"message":"WebHookCommit","author":{"name":"abc","email":"abc@gmail.com","username":"abc_12"},"id":"1","committer":{"name":"abc","email":"abc@gmail.com","username":"abc_12"},"added":["1","2","3"],"removed":["cmd","rti","duv"],"modified":["abc","efg","erd"]},"pusher":{"login":"rd@yahoo.com","id":112},"sender":{"login":"st@gmail.com","id":202},"installation":{"id":12},"organization":{"id":22}}` testJSONMarshal(t, v, want) } @@ -446,11 +385,7 @@ func TestBranchWebHookAuthor_Marshal(t *testing.T) { Login: String("abc_12"), } - want := `{ - "email": "abc@gmail.com", - "name": "abc", - "username": "abc_12" - }` + want := `{"name":"abc","email":"abc@gmail.com","username":"abc_12"}` testJSONMarshal(t, v, want) } @@ -476,29 +411,13 @@ func TestBranchWebHookCommit_Marshal(t *testing.T) { Removed: []string{"cmd", "rti", "duv"}, } - want := `{ - "added": ["1", "2", "3"], - "author":{ - "email": "abc@gmail.com", - "name": "abc", - "username": "abc_12" - }, - "committer": { - "email": "abc@gmail.com", - "name": "abc", - "username": "abc_12" - }, - "id": "1", - "message": "WebHookCommit", - "modified": ["abc", "efg", "erd"], - "removed": ["cmd", "rti", "duv"] - }` + want := `{"message":"WebHookCommit","author":{"name":"abc","email":"abc@gmail.com","username":"abc_12"},"id":"1","committer":{"name":"abc","email":"abc@gmail.com","username":"abc_12"},"added":["1","2","3"],"removed":["cmd","rti","duv"],"modified":["abc","efg","erd"]}` testJSONMarshal(t, v, want) } func TestBranchCreateHookRequest_Marshal(t *testing.T) { - testJSONMarshal(t, &createHookRequest{}, "{}") + testJSONMarshal(t, &createHookRequest{}, `{"name":""}`) v := &createHookRequest{ Name: "abc", @@ -509,14 +428,7 @@ func TestBranchCreateHookRequest_Marshal(t *testing.T) { }, } - want := `{ - "name": "abc", - "active": true, - "events": ["1","2","3"], - "config":{ - "thing": "@123" - } - }` + want := `{"name":"abc","config":{"thing":"@123"},"events":["1","2","3"],"active":true}` testJSONMarshal(t, v, want) } @@ -543,24 +455,7 @@ func TestBranchHook_Marshal(t *testing.T) { Active: Bool(true), } - want := `{ - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "url": "url", - "id": 1, - "type": "type", - "name": "name", - "test_url": "testurl", - "ping_url": "pingurl", - "last_response":{ - "item": "item" - }, - "config":{ - "thing": "@123" - }, - "events": ["1","2","3"], - "active": true - }` + want := `{"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"url":"url","id":1,"type":"type","name":"name","test_url":"testurl","ping_url":"pingurl","last_response":{"item":"item"},"config":{"thing":"@123"},"events":["1","2","3"],"active":true}` testJSONMarshal(t, v, want) } diff --git a/github/repos_invitations_test.go b/github/repos_invitations_test.go index 74bda793753..4e0c31de914 100644 --- a/github/repos_invitations_test.go +++ b/github/repos_invitations_test.go @@ -138,28 +138,7 @@ func TestRepositoryInvitation_Marshal(t *testing.T) { HTMLURL: String("h"), } - want := `{ - "id":1, - "repository":{ - "id":1, - "name":"n", - "url":"u" - }, - "invitee":{ - "id":1, - "name":"n", - "url":"u" - }, - "inviter":{ - "id":1, - "name":"n", - "url":"u" - }, - "permissions":"p", - "created_at":` + referenceTimeStr + `, - "url":"u", - "html_url":"h" - }` + want := `{"id":1,"repository":{"id":1,"name":"n","url":"u"},"invitee":{"id":1,"name":"n","url":"u"},"inviter":{"id":1,"name":"n","url":"u"},"permissions":"p","created_at":` + referenceTimeStr + `,"url":"u","html_url":"h"}` testJSONMarshal(t, r, want) } diff --git a/github/repos_merging_test.go b/github/repos_merging_test.go index 09a03a19a61..147ca3ed49e 100644 --- a/github/repos_merging_test.go +++ b/github/repos_merging_test.go @@ -72,11 +72,7 @@ func TestRepositoryMergeRequest_Marshal(t *testing.T) { CommitMessage: String("cm"), } - want := `{ - "base": "base", - "head": "head", - "commit_message": "cm" - }` + want := `{"base":"base","head":"head","commit_message":"cm"}` testJSONMarshal(t, u, want) } @@ -136,11 +132,7 @@ func TestRepoMergeUpstreamResult_Marshal(t *testing.T) { BaseBranch: String("base_branch"), } - want := `{ - "message": "message", - "merge_type": "merge_type", - "base_branch": "base_branch" - }` + want := `{"message":"message","merge_type":"merge_type","base_branch":"base_branch"}` testJSONMarshal(t, u, want) } diff --git a/github/repos_pages_test.go b/github/repos_pages_test.go index 75d6ccb2bf4..d5cc48b0170 100644 --- a/github/repos_pages_test.go +++ b/github/repos_pages_test.go @@ -366,10 +366,7 @@ func TestPagesSource_Marshal(t *testing.T) { Path: String("path"), } - want := `{ - "branch": "branch", - "path": "path" - }` + want := `{"branch":"branch","path":"path"}` testJSONMarshal(t, u, want) } @@ -381,25 +378,20 @@ func TestPagesError_Marshal(t *testing.T) { Message: String("message"), } - want := `{ - "message": "message" - }` + want := `{"message":"message"}` testJSONMarshal(t, u, want) } func TestPagesUpdate_Marshal(t *testing.T) { - testJSONMarshal(t, &PagesUpdate{}, "{}") + testJSONMarshal(t, &PagesUpdate{}, `{"cname":null}`) u := &PagesUpdate{ CNAME: String("cname"), Source: &PagesSource{Path: String("src")}, } - want := `{ - "cname": "cname", - "source": { "path": "src" } - }` + want := `{"cname":"cname","source":{"path":"src"}}` testJSONMarshal(t, u, want) } @@ -419,17 +411,7 @@ func TestPages_Marshal(t *testing.T) { }, } - want := `{ - "url": "url", - "status": "status", - "cname": "cname", - "custom_404": false, - "html_url": "hurl", - "source": { - "branch": "branch", - "path": "path" - } - }` + want := `{"url":"url","status":"status","cname":"cname","custom_404":false,"html_url":"hurl","source":{"branch":"branch","path":"path"}}` testJSONMarshal(t, u, want) } @@ -450,20 +432,7 @@ func TestPagesBuild_Marshal(t *testing.T) { UpdatedAt: &Timestamp{referenceTime}, } - want := `{ - "url": "url", - "status": "status", - "error": { - "message": "message" - }, - "pusher": { - "id": 1 - }, - "commit": "commit", - "duration": 1, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - }` + want := `{"url":"url","status":"status","error":{"message":"message"},"pusher":{"id":1},"commit":"commit","duration":1,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `}` testJSONMarshal(t, u, want) } @@ -478,12 +447,7 @@ func TestCreatePagesRequest_Marshal(t *testing.T) { }, } - want := `{ - "source": { - "branch": "branch", - "path": "path" - } - }` + want := `{"source":{"branch":"branch","path":"path"}}` testJSONMarshal(t, u, want) } diff --git a/github/repos_prereceive_hooks_test.go b/github/repos_prereceive_hooks_test.go index 303e0e1265a..7ff044c7e2c 100644 --- a/github/repos_prereceive_hooks_test.go +++ b/github/repos_prereceive_hooks_test.go @@ -205,12 +205,7 @@ func TestPreReceiveHook_Marshal(t *testing.T) { ConfigURL: String("curl"), } - want := `{ - "id": 1, - "name": "name", - "enforcement": "e", - "configuration_url": "curl" - }` + want := `{"id":1,"name":"name","enforcement":"e","configuration_url":"curl"}` testJSONMarshal(t, u, want) } diff --git a/github/repos_releases_test.go b/github/repos_releases_test.go index 73a9f3a530d..124356e2d40 100644 --- a/github/repos_releases_test.go +++ b/github/repos_releases_test.go @@ -712,16 +712,7 @@ func TestRepositoryReleaseRequest_Marshal(t *testing.T) { DiscussionCategoryName: String("dcn"), } - want := `{ - "tag_name": "tn", - "target_commitish": "tc", - "name": "name", - "body": "body", - "draft": false, - "prerelease": false, - "make_latest": "legacy", - "discussion_category_name": "dcn" - }` + want := `{"tag_name":"tn","target_commitish":"tc","name":"name","body":"body","draft":false,"prerelease":false,"make_latest":"legacy","discussion_category_name":"dcn"}` testJSONMarshal(t, u, want) } @@ -745,23 +736,7 @@ func TestReleaseAsset_Marshal(t *testing.T) { NodeID: String("nid"), } - want := `{ - "id": 1, - "url": "url", - "name": "name", - "label": "label", - "state": "state", - "content_type": "ct", - "size": 1, - "download_count": 1, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "browser_download_url": "bdu", - "uploader": { - "id": 1 - }, - "node_id": "nid" - }` + want := `{"id":1,"url":"url","name":"name","label":"label","state":"state","content_type":"ct","size":1,"download_count":1,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"browser_download_url":"bdu","uploader":{"id":1},"node_id":"nid"}` testJSONMarshal(t, u, want) } @@ -792,40 +767,13 @@ func TestRepositoryRelease_Marshal(t *testing.T) { NodeID: String("nid"), } - want := `{ - "tag_name": "tn", - "target_commitish": "tc", - "name": "name", - "body": "body", - "draft": false, - "prerelease": false, - "make_latest": "legacy", - "discussion_category_name": "dcn", - "id": 1, - "created_at": ` + referenceTimeStr + `, - "published_at": ` + referenceTimeStr + `, - "url": "url", - "html_url": "hurl", - "assets_url": "aurl", - "assets": [ - { - "id": 1 - } - ], - "upload_url": "uurl", - "zipball_url": "zurl", - "tarball_url": "turl", - "author": { - "id": 1 - }, - "node_id": "nid" - }` + want := `{"tag_name":"tn","target_commitish":"tc","name":"name","body":"body","draft":false,"prerelease":false,"make_latest":"legacy","discussion_category_name":"dcn","id":1,"created_at":` + referenceTimeStr + `,"published_at":` + referenceTimeStr + `,"url":"url","html_url":"hurl","assets_url":"aurl","assets":[{"id":1}],"upload_url":"uurl","zipball_url":"zurl","tarball_url":"turl","author":{"id":1},"node_id":"nid"}` testJSONMarshal(t, u, want) } func TestGenerateNotesOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &GenerateNotesOptions{}, "{}") + testJSONMarshal(t, &GenerateNotesOptions{}, `{"tag_name":""}`) u := &GenerateNotesOptions{ TagName: "tag_name", @@ -833,11 +781,7 @@ func TestGenerateNotesOptions_Marshal(t *testing.T) { TargetCommitish: String("target_commitish"), } - want := `{ - "tag_name": "tag_name", - "previous_tag_name": "previous_tag_name", - "target_commitish": "target_commitish" - }` + want := `{"tag_name":"tag_name","previous_tag_name":"previous_tag_name","target_commitish":"target_commitish"}` testJSONMarshal(t, u, want) } diff --git a/github/repos_stats_test.go b/github/repos_stats_test.go index 1babaca6e2a..9158b7da64b 100644 --- a/github/repos_stats_test.go +++ b/github/repos_stats_test.go @@ -336,10 +336,7 @@ func TestRepositoryParticipation_Marshal(t *testing.T) { Owner: []int{1}, } - want := `{ - "all": [1], - "owner": [1] - }` + want := `{"all":[1],"owner":[1]}` testJSONMarshal(t, u, want) } @@ -353,13 +350,7 @@ func TestWeeklyCommitActivity_Marshal(t *testing.T) { Week: &Timestamp{referenceTime}, } - want := `{ - "days": [ - 1 - ], - "total": 1, - "week": ` + referenceTimeStr + ` - }` + want := `{"days":[1],"total":1,"week":` + referenceTimeStr + `}` testJSONMarshal(t, u, want) } @@ -374,12 +365,7 @@ func TestWeeklyStats_Marshal(t *testing.T) { Commits: Int(1), } - want := `{ - "w": ` + referenceTimeStr + `, - "a": 1, - "d": 1, - "c": 1 - }` + want := `{"w":` + referenceTimeStr + `,"a":1,"d":1,"c":1}` testJSONMarshal(t, u, want) } @@ -400,20 +386,7 @@ func TestContributorStats_Marshal(t *testing.T) { }, } - want := `{ - "author": { - "id": 1 - }, - "total": 1, - "weeks": [ - { - "w": ` + referenceTimeStr + `, - "a": 1, - "d": 1, - "c": 1 - } - ] - }` + want := `{"author":{"id":1},"total":1,"weeks":[{"w":` + referenceTimeStr + `,"a":1,"d":1,"c":1}]}` testJSONMarshal(t, u, want) } diff --git a/github/repos_statuses_test.go b/github/repos_statuses_test.go index c9e03acb8de..910cb3c77ff 100644 --- a/github/repos_statuses_test.go +++ b/github/repos_statuses_test.go @@ -167,21 +167,7 @@ func TestRepoStatus_Marshal(t *testing.T) { UpdatedAt: &Timestamp{referenceTime}, } - want := `{ - "id": 1, - "node_id": "nid", - "url": "url", - "state": "state", - "target_url": "turl", - "description": "desc", - "context": "ctx", - "avatar_url": "aurl", - "creator": { - "id": 1 - }, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - }` + want := `{"id":1,"node_id":"nid","url":"url","state":"state","target_url":"turl","description":"desc","context":"ctx","avatar_url":"aurl","creator":{"id":1},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `}` testJSONMarshal(t, u, want) } @@ -213,31 +199,7 @@ func TestCombinedStatus_Marshal(t *testing.T) { RepositoryURL: String("rurl"), } - want := `{ - "state": "state", - "name": "name", - "sha": "sha", - "total_count": 1, - "statuses": [ - { - "id": 1, - "node_id": "nid", - "url": "url", - "state": "state", - "target_url": "turl", - "description": "desc", - "context": "ctx", - "avatar_url": "aurl", - "creator": { - "id": 1 - }, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + ` - } - ], - "commit_url": "curl", - "repository_url": "rurl" - }` + want := `{"state":"state","name":"name","sha":"sha","total_count":1,"statuses":[{"id":1,"node_id":"nid","url":"url","state":"state","target_url":"turl","description":"desc","context":"ctx","avatar_url":"aurl","creator":{"id":1},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `}],"commit_url":"curl","repository_url":"rurl"}` testJSONMarshal(t, u, want) } diff --git a/github/repos_tags_test.go b/github/repos_tags_test.go index d1eb8aa90ae..4a40a625b3c 100644 --- a/github/repos_tags_test.go +++ b/github/repos_tags_test.go @@ -132,17 +132,14 @@ func TestRepositoriesService_DeleteTagProtection(t *testing.T) { } func TestTagProtection_Marshal(t *testing.T) { - testJSONMarshal(t, &TagProtection{}, "{}") + testJSONMarshal(t, &TagProtection{}, `{"id":null,"pattern":null}`) u := &TagProtection{ ID: Int64(1), Pattern: String("pattern"), } - want := `{ - "id": 1, - "pattern": "pattern" - }` + want := `{"id":1,"pattern":"pattern"}` testJSONMarshal(t, u, want) } diff --git a/github/repos_test.go b/github/repos_test.go index 5f59216b2b9..4f75e0e1c58 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -3306,9 +3306,7 @@ func TestAdvancedSecurity_Marshal(t *testing.T) { Status: String("status"), } - want := `{ - "status": "status" - }` + want := `{"status":"status"}` testJSONMarshal(t, u, want) } @@ -3320,15 +3318,13 @@ func TestAuthorizedActorsOnly_Marshal(t *testing.T) { From: Bool(true), } - want := `{ - "from" : true - }` + want := `{"from":true}` testJSONMarshal(t, u, want) } func TestDispatchRequestOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &DispatchRequestOptions{}, "{}") + testJSONMarshal(t, &DispatchRequestOptions{}, `{"event_type":""}`) cp := json.RawMessage(`{"testKey":"testValue"}`) u := &DispatchRequestOptions{ @@ -3336,28 +3332,20 @@ func TestDispatchRequestOptions_Marshal(t *testing.T) { ClientPayload: &cp, } - want := `{ - "event_type": "test_event_type", - "client_payload": { - "testKey": "testValue" - } - }` + want := `{"event_type":"test_event_type","client_payload":{"testKey":"testValue"}}` testJSONMarshal(t, u, want) } func TestTransferRequest_Marshal(t *testing.T) { - testJSONMarshal(t, &TransferRequest{}, "{}") + testJSONMarshal(t, &TransferRequest{}, `{"new_owner":""}`) u := &TransferRequest{ NewOwner: "testOwner", TeamID: []int64{1, 2}, } - want := `{ - "new_owner": "testOwner", - "team_ids": [1,2] - }` + want := `{"new_owner":"testOwner","team_ids":[1,2]}` testJSONMarshal(t, u, want) } @@ -3370,10 +3358,7 @@ func TestSignaturesProtectedBranch_Marshal(t *testing.T) { Enabled: Bool(false), } - want := `{ - "url": "https://www.testURL.in", - "enabled": false - }` + want := `{"url":"https://www.testURL.in","enabled":false}` testJSONMarshal(t, u, want) @@ -3382,10 +3367,7 @@ func TestSignaturesProtectedBranch_Marshal(t *testing.T) { Enabled: Bool(true), } - want2 := `{ - "url": "testURL", - "enabled": true - }` + want2 := `{"url":"testURL","enabled":true}` testJSONMarshal(t, u2, want2) } @@ -3399,33 +3381,26 @@ func TestDismissalRestrictionsRequest_Marshal(t *testing.T) { Apps: &[]string{"app1", "app2"}, } - want := `{ - "users": ["user1","user2"], - "teams": ["team1","team2"], - "apps": ["app1","app2"] - }` + want := `{"users":["user1","user2"],"teams":["team1","team2"],"apps":["app1","app2"]}` testJSONMarshal(t, u, want) } func TestAdminEnforcement_Marshal(t *testing.T) { - testJSONMarshal(t, &AdminEnforcement{}, "{}") + testJSONMarshal(t, &AdminEnforcement{}, `{"enabled":false}`) u := &AdminEnforcement{ URL: String("https://www.test-url.in"), Enabled: false, } - want := `{ - "url": "https://www.test-url.in", - "enabled": false - }` + want := `{"url":"https://www.test-url.in","enabled":false}` testJSONMarshal(t, u, want) } func TestPullRequestReviewsEnforcementUpdate_Marshal(t *testing.T) { - testJSONMarshal(t, &PullRequestReviewsEnforcementUpdate{}, "{}") + testJSONMarshal(t, &PullRequestReviewsEnforcementUpdate{}, `{"required_approving_review_count":0}`) u := &PullRequestReviewsEnforcementUpdate{ BypassPullRequestAllowancesRequest: &BypassPullRequestAllowancesRequest{ @@ -3438,32 +3413,20 @@ func TestPullRequestReviewsEnforcementUpdate_Marshal(t *testing.T) { RequiredApprovingReviewCount: 2, } - want := `{ - "bypass_pull_request_allowances": { - "users": ["user1","user2"], - "teams": ["team1","team2"], - "apps": ["app1","app2"] - }, - "dismiss_stale_reviews": false, - "require_code_owner_reviews": true, - "required_approving_review_count": 2 - }` + want := `{"bypass_pull_request_allowances":{"users":["user1","user2"],"teams":["team1","team2"],"apps":["app1","app2"]},"dismiss_stale_reviews":false,"require_code_owner_reviews":true,"required_approving_review_count":2}` testJSONMarshal(t, u, want) } func TestRequiredStatusCheck_Marshal(t *testing.T) { - testJSONMarshal(t, &RequiredStatusCheck{}, "{}") + testJSONMarshal(t, &RequiredStatusCheck{}, `{"context":""}`) u := &RequiredStatusCheck{ Context: "ctx", AppID: Int64(1), } - want := `{ - "context": "ctx", - "app_id": 1 - }` + want := `{"context":"ctx","app_id":1}` testJSONMarshal(t, u, want) } diff --git a/github/repos_traffic_test.go b/github/repos_traffic_test.go index e63f9181994..9a37352b952 100644 --- a/github/repos_traffic_test.go +++ b/github/repos_traffic_test.go @@ -210,11 +210,7 @@ func TestTrafficReferrer_Marshal(t *testing.T) { Uniques: Int(0), } - want := `{ - "referrer" : "referrer", - "count" : 0, - "uniques" : 0 - }` + want := `{"referrer":"referrer","count":0,"uniques":0}` testJSONMarshal(t, u, want) } @@ -232,15 +228,7 @@ func TestTrafficViews_Marshal(t *testing.T) { Uniques: Int(0), } - want := `{ - "views": [{ - "timestamp": "2016-05-31T16:00:00.000Z", - "count": 7, - "uniques": 6 - }], - "count" : 0, - "uniques" : 0 - }` + want := `{"views":[{"timestamp":"2016-05-31T16:00:00Z","count":7,"uniques":6}],"count":0,"uniques":0}` testJSONMarshal(t, u, want) } @@ -258,15 +246,7 @@ func TestTrafficClones_Marshal(t *testing.T) { Uniques: Int(0), } - want := `{ - "clones": [{ - "timestamp": "2021-10-29T16:00:00.000Z", - "count": 1, - "uniques": 1 - }], - "count" : 0, - "uniques" : 0 - }` + want := `{"clones":[{"timestamp":"2021-10-29T16:00:00Z","count":1,"uniques":1}],"count":0,"uniques":0}` testJSONMarshal(t, u, want) } @@ -281,12 +261,7 @@ func TestTrafficPath_Marshal(t *testing.T) { Uniques: Int(3), } - want := `{ - "path" : "test/path", - "title": "test", - "count": 2, - "uniques": 3 - }` + want := `{"path":"test/path","title":"test","count":2,"uniques":3}` testJSONMarshal(t, u, want) } @@ -294,31 +269,26 @@ func TestTrafficPath_Marshal(t *testing.T) { func TestTrafficData_Marshal(t *testing.T) { testJSONMarshal(t, &TrafficData{}, "{}") + // what about `referenceTimeStr`?! u := &TrafficData{ Timestamp: &Timestamp{time.Date(2016, time.May, 31, 16, 0, 0, 0, time.UTC)}, Count: Int(7), Uniques: Int(6), } - want := `{ - "timestamp": "2016-05-31T16:00:00.000Z", - "count": 7, - "uniques": 6 - }` + want := `{"timestamp":"2016-05-31T16:00:00Z","count":7,"uniques":6}` testJSONMarshal(t, u, want) } -func TestTrafficBreakdownOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &TrafficBreakdownOptions{}, "{}") +func TestTrafficBreakdownOptions_addOptions(t *testing.T) { + url := "some/path" + + testAddURLOptions(t, url, &UserListOptions{}, url) u := &TrafficBreakdownOptions{ Per: "day", } - want := `{ - "per": "day" - }` - - testJSONMarshal(t, u, want) + testAddURLOptions(t, url, u, url+`?per=day`) } diff --git a/github/scim_test.go b/github/scim_test.go index 9e5274766aa..7c1673a207b 100644 --- a/github/scim_test.go +++ b/github/scim_test.go @@ -344,9 +344,7 @@ func TestSCIMService_DeleteSCIMUserFromOrg(t *testing.T) { } func TestSCIMUserAttributes_Marshal(t *testing.T) { - testJSONMarshal(t, &SCIMUserAttributes{}, `{ - "userName":"","name":{"givenName":"","familyName":""},"emails":null - }`) + testJSONMarshal(t, &SCIMUserAttributes{}, `{"userName":"","name":{"givenName":"","familyName":""},"emails":null}`) u := &SCIMUserAttributes{ UserName: "userName1", @@ -369,46 +367,26 @@ func TestSCIMUserAttributes_Marshal(t *testing.T) { Active: Bool(true), } - want := `{ - "userName": "userName1", - "name": { - "givenName": "Name1", - "familyName": "Fname", - "formatted": "formatted name" - }, - "displayName": "Name", - "emails": [{ - "value": "value", - "primary": false, - "type": "type" - }], - "schemas": ["schema1"], - "externalId": "id", - "groups": ["group1"], - "active": true - }` + want := `{"userName":"userName1","name":{"givenName":"Name1","familyName":"Fname","formatted":"formatted name"},"displayName":"Name","emails":[{"value":"value","primary":false,"type":"type"}],"schemas":["schema1"],"externalId":"id","groups":["group1"],"active":true}` testJSONMarshal(t, u, want) } func TestUpdateAttributeForSCIMUserOperations_Marshal(t *testing.T) { - testJSONMarshal(t, &UpdateAttributeForSCIMUserOperations{}, `{}`) + testJSONMarshal(t, &UpdateAttributeForSCIMUserOperations{}, `{"op":""}`) u := &UpdateAttributeForSCIMUserOperations{ Op: "TestOp", Path: String("path"), } - want := `{ - "op": "TestOp", - "path": "path" - }` + want := `{"op":"TestOp","path":"path"}` testJSONMarshal(t, u, want) } func TestUpdateAttributeForSCIMUserOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &UpdateAttributeForSCIMUserOptions{}, `{}`) + testJSONMarshal(t, &UpdateAttributeForSCIMUserOptions{}, `{"operations":{"op":""}}`) u := &UpdateAttributeForSCIMUserOptions{ Schemas: []string{"test", "schema"}, @@ -418,24 +396,12 @@ func TestUpdateAttributeForSCIMUserOptions_Marshal(t *testing.T) { }, } - want := `{ - "schemas": ["test", "schema"], - "operations": { - "op": "TestOp", - "path": "path" - } - }` + want := `{"schemas":["test","schema"],"operations":{"op":"TestOp","path":"path"}}` testJSONMarshal(t, u, want) } func TestListSCIMProvisionedIdentitiesOptions_addOptions(t *testing.T) { - testJSONMarshal(t, &ListSCIMProvisionedIdentitiesOptions{}, `{ - "StartIndex": null, - "Count": null, - "Filter": null - }`) - url := "some/path" testAddURLOptions(t, url, &ListSCIMProvisionedIdentitiesOptions{}, url) @@ -463,9 +429,7 @@ func TestListSCIMProvisionedIdentitiesOptions_addOptions(t *testing.T) { } func TestSCIMUserName_Marshal(t *testing.T) { - testJSONMarshal(t, &SCIMUserName{}, `{ - "givenName":"","familyName":"" - }`) + testJSONMarshal(t, &SCIMUserName{}, `{"givenName":"","familyName":""}`) u := &SCIMUserName{ GivenName: "Name1", @@ -473,11 +437,8 @@ func TestSCIMUserName_Marshal(t *testing.T) { Formatted: String("formatted name"), } - want := `{ - "givenName": "Name1", - "familyName": "Fname", - "formatted": "formatted name" - }` + want := `{"givenName":"Name1","familyName":"Fname","formatted":"formatted name"}` + testJSONMarshal(t, u, want) } @@ -489,10 +450,7 @@ func TestSCIMMeta_Marshal(t *testing.T) { Location: String("test"), } - want := `{ - "resourceType": "test", - "location": "test" - }` + want := `{"resourceType":"test","location":"test"}` testJSONMarshal(t, u, want) } @@ -529,30 +487,7 @@ func TestSCIMProvisionedIdentities_Marshal(t *testing.T) { }, } - want := `{ - "schemas": ["test", "schema"], - "totalResults": 1, - "itemsPerPage": 2, - "startIndex": 1, - "Resources": [{ - "userName": "SCIM", - "name": { - "givenName": "scim", - "familyName": "test", - "formatted": "SCIM" - }, - "displayName": "Test SCIM", - "emails": [{ - "value": "test", - "primary": true, - "type": "test" - }], - "schemas": ["schema1"], - "externalId": "id", - "groups": ["group1"], - "active": true - }] - }` + want := `{"schemas":["test","schema"],"totalResults":1,"itemsPerPage":2,"startIndex":1,"Resources":[{"userName":"SCIM","name":{"givenName":"scim","familyName":"test","formatted":"SCIM"},"displayName":"Test SCIM","emails":[{"value":"test","primary":true,"type":"test"}],"schemas":["schema1"],"externalId":"id","groups":["group1"],"active":true}]}` testJSONMarshal(t, u, want) } diff --git a/github/search.go b/github/search.go index adb832d0d8f..7b952df4a4e 100644 --- a/github/search.go +++ b/github/search.go @@ -54,7 +54,7 @@ type SearchOptions struct { // Whether to retrieve text match metadata with a query TextMatch bool `url:"-"` - ListOptions + ListOptions `url:",omitempty"` } // Common search parameters. diff --git a/github/search_test.go b/github/search_test.go index b7461753605..f7dedfeca6b 100644 --- a/github/search_test.go +++ b/github/search_test.go @@ -570,10 +570,7 @@ func TestMatch_Marshal(t *testing.T) { Indices: []int{1}, } - want := `{ - "text": "txt", - "indices": [1] - }` + want := `{"text":"txt","indices":[1]}` testJSONMarshal(t, u, want) } @@ -594,16 +591,7 @@ func TestTextMatch_Marshal(t *testing.T) { }, } - want := `{ - "object_url": "ourl", - "object_type": "otype", - "property": "prop", - "fragment": "fragment", - "matches": [{ - "text": "txt", - "indices": [1] - }] - }` + want := `{"object_url":"ourl","object_type":"otype","property":"prop","fragment":"fragment","matches":[{"text":"txt","indices":[1]}]}` testJSONMarshal(t, u, want) } @@ -623,17 +611,7 @@ func TestTopicResult_Marshal(t *testing.T) { Score: Float64(99.9), } - want := `{ - "name": "name", - "display_name": "displayName", - "short_description": "shortDescription", - "description": "description", - "created_by": "createdBy", - "updated_at": "2021-10-26", - "featured": false, - "curated": true, - "score": 99.9 - }` + want := `{"name":"name","display_name":"displayName","short_description":"shortDescription","description":"description","created_by":"createdBy","updated_at":"2021-10-26","featured":false,"curated":true,"score":99.9}` testJSONMarshal(t, u, want) } @@ -647,11 +625,7 @@ func TestRepositoriesSearchResult_Marshal(t *testing.T) { Repositories: []*Repository{{ID: Int64(1)}}, } - want := `{ - "total_count" : 0, - "incomplete_results" : true, - "items" : [{"id":1}] - }` + want := `{"total_count":0,"incomplete_results":true,"items":[{"id":1}]}` testJSONMarshal(t, u, want) } @@ -667,11 +641,7 @@ func TestCommitsSearchResult_Marshal(t *testing.T) { }}, } - want := `{ - "total_count" : 0, - "incomplete_results" : true, - "items" : [{"sha" : "s"}] - }` + want := `{"total_count":0,"incomplete_results":true,"items":[{"sha":"s"}]}` testJSONMarshal(t, c, want) } @@ -698,24 +668,7 @@ func TestTopicsSearchResult_Marshal(t *testing.T) { }, } - want := `{ - "total_count" : 2, - "incomplete_results" : false, - "items" : [ - { - "name" : "t1", - "display_name":"tt", - "short_description":"t desc", - "description":"desc", - "created_by":"mi", - "created_at":` + referenceTimeStr + `, - "updated_at":"2006-01-02T15:04:05Z", - "featured":true, - "curated":true, - "score":123 - } - ] - }` + want := `{"total_count":2,"incomplete_results":false,"items":[{"name":"t1","display_name":"tt","short_description":"t desc","description":"desc","created_by":"mi","created_at":` + referenceTimeStr + `,"updated_at":"2006-01-02T15:04:05Z","featured":true,"curated":true,"score":123}]}` testJSONMarshal(t, u, want) } @@ -733,21 +686,15 @@ func TestLabelResult_Marshal(t *testing.T) { Score: Float64(123), } - want := `{ - "id":11, - "url":"url", - "name":"label", - "color":"green", - "default":true, - "description":"desc", - "score":123 - }` + want := `{"id":11,"url":"url","name":"label","color":"green","default":true,"description":"desc","score":123}` testJSONMarshal(t, u, want) } -func TestSearchOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &SearchOptions{}, "{}") +func TestSearchOptions_addOptions(t *testing.T) { + url := "some/path" + + testAddURLOptions(t, url, &SearchOptions{}, url) u := &SearchOptions{ Sort: "author-date", @@ -759,14 +706,7 @@ func TestSearchOptions_Marshal(t *testing.T) { }, } - want := `{ - "sort": "author-date", - "order": "asc", - "page": 1, - "perPage": 10 - }` - - testJSONMarshal(t, u, want) + testAddURLOptions(t, url, u, url+`?order=asc&page=1&per_page=10&sort=author-date`) } func TestIssuesSearchResult_Marshal(t *testing.T) { @@ -810,69 +750,7 @@ func TestIssuesSearchResult_Marshal(t *testing.T) { }, } - want := `{ - "total_count": 48, - "incomplete_results": false, - "items": [ - { - "id": 1, - "number": 1, - "state": "s", - "locked": false, - "title": "title", - "body": "body", - "author_association": "aa", - "user": { - "id": 1 - }, - "labels": [ - { - "id": 1 - } - ], - "assignee": { - "id": 1 - }, - "comments": 1, - "closed_at": ` + referenceTimeStr + `, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "closed_by": { - "id": 1 - }, - "url": "url", - "html_url": "hurl", - "comments_url": "curl", - "events_url": "eurl", - "labels_url": "lurl", - "repository_url": "rurl", - "milestone": { - "id": 1 - }, - "pull_request": { - "url": "url" - }, - "repository": { - "id": 1 - }, - "reactions": { - "total_count": 1 - }, - "assignees": [ - { - "id": 1 - } - ], - "node_id": "nid", - "text_matches": [ - { - "object_url": "ourl" - } - ], - "active_lock_reason": "alr" - } - ] - }` + want := `{"total_count":48,"incomplete_results":false,"items":[{"id":1,"number":1,"state":"s","locked":false,"title":"title","body":"body","author_association":"aa","user":{"id":1},"labels":[{"id":1}],"assignee":{"id":1},"comments":1,"closed_at":` + referenceTimeStr + `,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"closed_by":{"id":1},"url":"url","html_url":"hurl","comments_url":"curl","events_url":"eurl","labels_url":"lurl","repository_url":"rurl","milestone":{"id":1},"pull_request":{"url":"url"},"repository":{"id":1},"reactions":{"total_count":1},"assignees":[{"id":1}],"node_id":"nid","text_matches":[{"object_url":"ourl"}],"active_lock_reason":"alr"}]}` testJSONMarshal(t, u, want) } @@ -896,21 +774,7 @@ func TestLabelsSearchResult_Marshal(t *testing.T) { }, } - want := `{ - "total_count": 5, - "incomplete_results": false, - "items": [ - { - "id": 1, - "url": "https://www.test-url.com", - "name": "test name", - "color": "green", - "default": true, - "description": "testDescription", - "score": 1 - } - ] - }` + want := `{"total_count":5,"incomplete_results":false,"items":[{"id":1,"url":"https://www.test-url.com","name":"test name","color":"green","default":true,"description":"testDescription","score":1}]}` testJSONMarshal(t, u, want) } @@ -931,25 +795,7 @@ func TestCommitResult_Marshal(t *testing.T) { Parents: []*Commit{}, } - want := `{ - "sha": "test", - "commit": { - "sha": "test" - }, - "author": { - "id": 1 - }, - "committer": { - "id": 1 - }, - "html_url": "hurl", - "url": "url", - "comments_url": "curl", - "repository": { - "id": 1 - }, - "score": 123 - }` + want := `{"sha":"test","commit":{"sha":"test"},"author":{"id":1},"committer":{"id":1},"html_url":"hurl","url":"url","comments_url":"curl","repository":{"id":1},"score":123}` testJSONMarshal(t, c, want) } @@ -971,21 +817,7 @@ func TestUsersSearchResult_Marshal(t *testing.T) { }}, } - want := `{ - "total_count": 2, - "incomplete_results": false, - "items": [ - { - "login": "loginTest", - "id": 1, - "node_id": "NodeTest", - "avatar_url": "AvatarURLTest", - "html_url": "Hurl", - "gravatar_id": "gravatarIDTest", - "name": "nameTest" - } - ] - }` + want := `{"total_count":2,"incomplete_results":false,"items":[{"login":"loginTest","id":1,"node_id":"NodeTest","avatar_url":"AvatarURLTest","html_url":"Hurl","gravatar_id":"gravatarIDTest","name":"nameTest"}]}` testJSONMarshal(t, u, want) } @@ -999,11 +831,7 @@ func TestCodeSearchResult_Marshal(t *testing.T) { CodeResults: []*CodeResult{{Name: String("n")}}, } - want := `{ - "total_count" : 4, - "incomplete_results" : false, - "items" : [{"name": "n"}] - }` + want := `{"total_count":4,"incomplete_results":false,"items":[{"name":"n"}]}` testJSONMarshal(t, u, want) } diff --git a/github/secret_scanning_test.go b/github/secret_scanning_test.go index 69cd7d3fefe..003fa13fadf 100644 --- a/github/secret_scanning_test.go +++ b/github/secret_scanning_test.go @@ -498,24 +498,7 @@ func TestSecretScanningAlert_Marshal(t *testing.T) { Secret: String("test"), } - want := `{ - "number": 1, - "created_at": ` + referenceTimeStr + `, - "url": "https://api.github.com/teams/2/discussions/3/comments", - "html_url": "https://api.github.com/teams/2/discussions/3/comments", - "locations_url": "https://api.github.com/teams/2/discussions/3/comments", - "state": "test_state", - "resolution": "test_resolution", - "resolved_at": ` + referenceTimeStr + `, - "resolved_by": { - "login": "test", - "id": 10, - "node_id": "A123", - "avatar_url": "https://api.github.com/teams/2/discussions/3/comments" - }, - "secret_type": "test", - "secret": "test" - }` + want := `{"number":1,"created_at":` + referenceTimeStr + `,"url":"https://api.github.com/teams/2/discussions/3/comments","html_url":"https://api.github.com/teams/2/discussions/3/comments","locations_url":"https://api.github.com/teams/2/discussions/3/comments","state":"test_state","resolution":"test_resolution","resolved_at":` + referenceTimeStr + `,"resolved_by":{"login":"test","id":10,"node_id":"A123","avatar_url":"https://api.github.com/teams/2/discussions/3/comments"},"secret_type":"test","secret":"test"}` testJSONMarshal(t, u, want) } @@ -538,20 +521,7 @@ func TestSecretScanningAlertLocation_Marshal(t *testing.T) { }, } - want := `{ - "type": "test", - "details": { - "path": "test_path", - "start_line": 10, - "end_line": 20, - "start_column": 30, - "end_column": 40, - "blob_sha": "test_sha", - "blob_url": "https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b", - "commit_sha": "test_sha", - "commit_url": "https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b" - } - }` + want := `{"type":"test","details":{"path":"test_path","start_line":10,"end_line":20,"start_column":30,"end_column":40,"blob_sha":"test_sha","blob_url":"https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b","commit_sha":"test_sha","commit_url":"https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b"}}` testJSONMarshal(t, u, want) } @@ -571,17 +541,7 @@ func TestSecretScanningAlertLocationDetails_Marshal(t *testing.T) { CommitURL: String("https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b"), } - want := `{ - "path": "test_path", - "start_line": 10, - "end_line": 20, - "start_column": 30, - "end_column": 40, - "blob_sha": "test_sha", - "blob_url": "https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b", - "commit_sha": "test_sha", - "commit_url": "https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b" - }` + want := `{"path":"test_path","start_line":10,"end_line":20,"start_column":30,"end_column":40,"blob_sha":"test_sha","blob_url":"https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b","commit_sha":"test_sha","commit_url":"https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b"}` testJSONMarshal(t, u, want) } diff --git a/github/teams.go b/github/teams.go index 0ee7c200792..e1acdcf800e 100644 --- a/github/teams.go +++ b/github/teams.go @@ -910,7 +910,7 @@ func (s *TeamsService) GetExternalGroup(ctx context.Context, org string, groupID type ListExternalGroupsOptions struct { DisplayName *string `url:"display_name,omitempty"` - ListOptions + ListOptions `url:",omitempty"` } // ListExternalGroups lists external groups in an organization on GitHub. diff --git a/github/teams_discussion_comments_test.go b/github/teams_discussion_comments_test.go index f6b5433b7b5..f85bdc63a16 100644 --- a/github/teams_discussion_comments_test.go +++ b/github/teams_discussion_comments_test.go @@ -462,32 +462,7 @@ func TestDiscussionComment_Marshal(t *testing.T) { }, } - want := `{ - "author":{}, - "body":"body", - "body_html":"body html", - "body_version":"body version", - "created_at":` + referenceTimeStr + `, - "last_edited_at":` + referenceTimeStr + `, - "discussion_url":"url", - "html_url":"html url", - "node_id":"node", - "number":1, - "updated_at":` + referenceTimeStr + `, - "url":"url", - "reactions":{ - "total_count": 10, - "+1": 1, - "-1": 1, - "laugh": 1, - "confused": 1, - "heart": 2, - "hooray": 5, - "rocket": 3, - "eyes": 9, - "url":"url" - } - }` + want := `{"author":{},"body":"body","body_html":"body html","body_version":"body version","created_at":` + referenceTimeStr + `,"last_edited_at":` + referenceTimeStr + `,"discussion_url":"url","html_url":"html url","node_id":"node","number":1,"updated_at":` + referenceTimeStr + `,"url":"url","reactions":{"total_count":10,"+1":1,"-1":1,"laugh":1,"confused":1,"heart":2,"hooray":5,"rocket":3,"eyes":9,"url":"url"}}` testJSONMarshal(t, u, want) } diff --git a/github/teams_discussions_test.go b/github/teams_discussions_test.go index 0e73751964a..c6332bc2858 100644 --- a/github/teams_discussions_test.go +++ b/github/teams_discussions_test.go @@ -585,45 +585,8 @@ func TestTeamDiscussion_Marshal(t *testing.T) { }, } - want := `{ - "author": { - "login": "author", - "id": 0, - "avatar_url": "https://avatars1.githubusercontent.com/u/0?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/author", - "created_at": ` + referenceTimeStr + `, - "suspended_at": ` + referenceTimeStr + ` - }, - "body": "test", - "body_html": "

test

", - "body_version": "version", - "comments_count": 1, - "comments_url": "https://api.github.com/teams/2/discussions/3/comments", - "created_at": ` + referenceTimeStr + `, - "last_edited_at": ` + referenceTimeStr + `, - "html_url": "https://api.github.com/teams/2/discussions/3/comments", - "node_id": "A123", - "number": 10, - "pinned": true, - "private": false, - "team_url": "https://api.github.com/teams/2/discussions/3/comments", - "title": "Test", - "updated_at": ` + referenceTimeStr + `, - "url": "https://api.github.com/teams/2/discussions/3/comments", - "reactions": { - "total_count": 1, - "+1": 2, - "-1": -3, - "laugh": 4, - "confused": 5, - "heart": 6, - "hooray": 7, - "rocket": 8, - "eyes": 9, - "url": "https://api.github.com/teams/2/discussions/3/comments" - } - }` + bodyHTML, _ := json.Marshal(`

test

`) + want := `{"author":{"login":"author","id":0,"avatar_url":"https://avatars1.githubusercontent.com/u/0?v=4","gravatar_id":"","created_at":` + referenceTimeStr + `,"suspended_at":` + referenceTimeStr + `,"url":"https://api.github.com/users/author"},"body":"test","body_html":` + string(bodyHTML) + `,"body_version":"version","comments_count":1,"comments_url":"https://api.github.com/teams/2/discussions/3/comments","created_at":` + referenceTimeStr + `,"last_edited_at":` + referenceTimeStr + `,"html_url":"https://api.github.com/teams/2/discussions/3/comments","node_id":"A123","number":10,"pinned":true,"private":false,"team_url":"https://api.github.com/teams/2/discussions/3/comments","title":"Test","updated_at":` + referenceTimeStr + `,"url":"https://api.github.com/teams/2/discussions/3/comments","reactions":{"total_count":1,"+1":2,"-1":-3,"laugh":4,"confused":5,"heart":6,"hooray":7,"rocket":8,"eyes":9,"url":"https://api.github.com/teams/2/discussions/3/comments"}}` testJSONMarshal(t, u, want) } diff --git a/github/teams_members.go b/github/teams_members.go index 58cb79744e1..50a37e5d49e 100644 --- a/github/teams_members.go +++ b/github/teams_members.go @@ -17,7 +17,7 @@ type TeamListTeamMembersOptions struct { // values are "all", "member", "maintainer". Default is "all". Role string `url:"role,omitempty"` - ListOptions + ListOptions `url:",omitempty"` } // ListTeamMembersByID lists all of the users who are members of a team, given a specified diff --git a/github/teams_members_test.go b/github/teams_members_test.go index 5ef17351600..161ca3dd290 100644 --- a/github/teams_members_test.go +++ b/github/teams_members_test.go @@ -797,15 +797,15 @@ func TestTeamAddTeamMembershipOptions_Marshal(t *testing.T) { Role: "role", } - want := `{ - "role": "role" - }` + want := `{"role":"role"}` testJSONMarshal(t, u, want) } -func TestTeamListTeamMembersOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &TeamListTeamMembersOptions{}, "{}") +func TestTeamListTeamMembersOptions_addOptions(t *testing.T) { + url := "some/path" + + testAddURLOptions(t, url, &TeamListTeamMembersOptions{}, url) u := &TeamListTeamMembersOptions{ Role: "role", @@ -815,11 +815,5 @@ func TestTeamListTeamMembersOptions_Marshal(t *testing.T) { }, } - want := `{ - "role": "role", - "Page": 1, - "PerPage": 2 - }` - - testJSONMarshal(t, u, want) + testAddURLOptions(t, url, u, url+`?page=1&per_page=2&role=role`) } diff --git a/github/teams_test.go b/github/teams_test.go index d86fab7fd6b..2ef4a6eb32e 100644 --- a/github/teams_test.go +++ b/github/teams_test.go @@ -1587,7 +1587,7 @@ func TestTeamsService_CreateOrUpdateIDPGroupConnectionsBySlug_empty(t *testing.T } func TestNewTeam_Marshal(t *testing.T) { - testJSONMarshal(t, &NewTeam{}, "{}") + testJSONMarshal(t, &NewTeam{}, `{"name":""}`) u := &NewTeam{ Name: "n", @@ -1600,16 +1600,7 @@ func TestNewTeam_Marshal(t *testing.T) { LDAPDN: String("l"), } - want := `{ - "name": "n", - "description": "d", - "maintainers": ["m1", "m2"], - "repo_names": ["repo1", "repo2"], - "parent_team_id": 1, - "permission": "perm", - "privacy": "p", - "ldap_dn": "l" - }` + want := `{"name":"n","description":"d","maintainers":["m1","m2"],"repo_names":["repo1","repo2"],"parent_team_id":1,"permission":"perm","privacy":"p","ldap_dn":"l"}` testJSONMarshal(t, u, want) } @@ -1657,45 +1648,7 @@ func TestTeams_Marshal(t *testing.T) { 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" - }` + want := `{"id":1,"node_id":"n","name":"n","description":"d","url":"u","slug":"s","permission":"p","privacy":"p","members_count":1,"repos_count":1,"organization":{"login":"l","id":1,"node_id":"n","avatar_url":"a","html_url":"h","name":"n","company":"c","blog":"b","location":"l","email":"e"},"members_url":"m","repositories_url":"r","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) } @@ -1714,16 +1667,7 @@ func TestInvitation_Marshal(t *testing.T) { InvitationTeamURL: String("url"), } - want := `{ - "id": 1, - "node_id": "test node", - "login":"login123", - "email":"go@github.com", - "role":"developer", - "created_at":` + referenceTimeStr + `, - "team_count":99, - "invitation_team_url":"url" - }` + want := `{"id":1,"node_id":"test node","login":"login123","email":"go@github.com","role":"developer","created_at":` + referenceTimeStr + `,"team_count":99,"invitation_team_url":"url"}` testJSONMarshal(t, u, want) } @@ -1737,11 +1681,7 @@ func TestIDPGroup_Marshal(t *testing.T) { GroupDescription: String("test group descripation"), } - want := `{ - "group_id": "abc1", - "group_name": "test group", - "group_description":"test group descripation" - }` + want := `{"group_id":"abc1","group_name":"test group","group_description":"test group descripation"}` testJSONMarshal(t, u, want) } @@ -2173,7 +2113,7 @@ func TestTeamsService_RemoveConnectedExternalGroup_notFound(t *testing.T) { } func TestIDPGroupList_Marshal(t *testing.T) { - testJSONMarshal(t, &IDPGroupList{}, "{}") + testJSONMarshal(t, &IDPGroupList{}, `{"groups":null}`) u := &IDPGroupList{ Groups: []*IDPGroup{ @@ -2190,20 +2130,7 @@ func TestIDPGroupList_Marshal(t *testing.T) { }, } - want := `{ - "groups": [ - { - "group_id": "abc1", - "group_name": "test group", - "group_description": "test group descripation" - }, - { - "group_id": "abc2", - "group_name": "test group2", - "group_description": "test group descripation2" - } - ] - }` + want := `{"groups":[{"group_id":"abc1","group_name":"test group","group_description":"test group descripation"},{"group_id":"abc2","group_name":"test group2","group_description":"test group descripation2"}]}` testJSONMarshal(t, u, want) } @@ -2218,12 +2145,7 @@ func TestExternalGroupMember_Marshal(t *testing.T) { MemberEmail: String("test member email"), } - want := `{ - "member_id": 1, - "member_login": "test member", - "member_name":"test member name", - "member_email":"test member email" - }` + want := `{"member_id":1,"member_login":"test member","member_name":"test member name","member_email":"test member email"}` testJSONMarshal(t, u, want) } @@ -2255,29 +2177,7 @@ func TestExternalGroup_Marshal(t *testing.T) { }, } - want := `{ - "group_id": 123, - "group_name": "group1", - "updated_at": ` + referenceTimeStr + `, - "teams": [ - { - "team_id": 1, - "team_name": "team-test" - }, - { - "team_id": 2, - "team_name": "team-test2" - } - ], - "members": [ - { - "member_id": 1, - "member_login": "test", - "member_name": "test", - "member_email": "test@github.com" - } - ] - }` + want := `{"group_id":123,"group_name":"group1","updated_at":` + referenceTimeStr + `,"teams":[{"team_id":1,"team_name":"team-test"},{"team_id":2,"team_name":"team-test2"}],"members":[{"member_id":1,"member_login":"test","member_name":"test","member_email":"test@github.com"}]}` testJSONMarshal(t, u, want) } @@ -2290,16 +2190,15 @@ func TestExternalGroupTeam_Marshal(t *testing.T) { TeamName: String("test"), } - want := `{ - "team_id": 123, - "team_name": "test" - }` + want := `{"team_id":123,"team_name":"test"}` testJSONMarshal(t, u, want) } -func TestListExternalGroupsOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &ListExternalGroupsOptions{}, "{}") +func TestListExternalGroupsOptions_addOptions(t *testing.T) { + url := "some/path" + + testAddURLOptions(t, url, &ListExternalGroupsOptions{}, url) u := &ListExternalGroupsOptions{ DisplayName: String("test"), @@ -2309,13 +2208,7 @@ func TestListExternalGroupsOptions_Marshal(t *testing.T) { }, } - want := `{ - "DisplayName": "test", - "page": 1, - "PerPage": 2 - }` - - testJSONMarshal(t, u, want) + testAddURLOptions(t, url, u, url+`?display_name=test&page=1&per_page=2`) } func TestTeamAddTeamRepoOptions_Marshal(t *testing.T) { @@ -2325,9 +2218,7 @@ func TestTeamAddTeamRepoOptions_Marshal(t *testing.T) { Permission: "a", } - want := `{ - "permission": "a" - }` + want := `{"permission":"a"}` testJSONMarshal(t, u, want) } diff --git a/github/users.go b/github/users.go index d40d23e90fe..fcd9dcc150c 100644 --- a/github/users.go +++ b/github/users.go @@ -196,7 +196,7 @@ type UserListOptions struct { // Note: Pagination is powered exclusively by the Since parameter, // ListOptions.Page has no effect. // ListOptions.PerPage controls an undocumented GitHub API parameter. - ListOptions + ListOptions `url:",omitempty"` } // ListAll lists all GitHub users. diff --git a/github/users_administration_test.go b/github/users_administration_test.go index ff8f93584c8..be5c2c766fa 100644 --- a/github/users_administration_test.go +++ b/github/users_administration_test.go @@ -150,9 +150,7 @@ func TestUserSuspendOptions_Marshal(t *testing.T) { Reason: String("reason"), } - want := `{ - "reason": "reason" - }` + want := `{"reason":"reason"}` testJSONMarshal(t, u, want) } diff --git a/github/users_emails_test.go b/github/users_emails_test.go index d40356d8732..e4cf4739f8f 100644 --- a/github/users_emails_test.go +++ b/github/users_emails_test.go @@ -131,12 +131,7 @@ func TestUserEmail_Marshal(t *testing.T) { Visibility: String("yes"), } - want := `{ - "email": "qwe@qwe.qwe", - "primary": false, - "verified": true, - "visibility": "yes" - }` + want := `{"email":"qwe@qwe.qwe","primary":false,"verified":true,"visibility":"yes"}` testJSONMarshal(t, u, want) } diff --git a/github/users_gpg_keys_test.go b/github/users_gpg_keys_test.go index 79ebd2d6f40..ba3330cda66 100644 --- a/github/users_gpg_keys_test.go +++ b/github/users_gpg_keys_test.go @@ -198,10 +198,7 @@ func TestGPGEmail_Marshal(t *testing.T) { Verified: Bool(false), } - want := `{ - "email" : "email@abc.com", - "verified" : false - }` + want := `{"email":"email@abc.com","verified":false}` testJSONMarshal(t, u, want) } @@ -234,28 +231,7 @@ func TestGPGKey_Marshal(t *testing.T) { ExpiresAt: ti, } - want := `{ - "id":1, - "primary_key_id":1, - "key_id":"someKeyID", - "raw_key":"someRawKeyID", - "public_key":"somePublicKey", - "emails":[ - { - "email":"someEmail", - "verified":true - } - ], - "subkeys":[ - {} - ], - "can_sign":true, - "can_encrypt_comms":true, - "can_encrypt_storage":true, - "can_certify":true, - "created_at":"0001-01-01T00:00:00Z", - "expires_at":"0001-01-01T00:00:00Z" - }` + want := `{"id":1,"primary_key_id":1,"key_id":"someKeyID","raw_key":"someRawKeyID","public_key":"somePublicKey","emails":[{"email":"someEmail","verified":true}],"subkeys":[{}],"can_sign":true,"can_encrypt_comms":true,"can_encrypt_storage":true,"can_certify":true,"created_at":"0001-01-01T00:00:00Z","expires_at":"0001-01-01T00:00:00Z"}` testJSONMarshal(t, g, want) } diff --git a/github/users_keys_test.go b/github/users_keys_test.go index ac5c10d0335..8dd966e8763 100644 --- a/github/users_keys_test.go +++ b/github/users_keys_test.go @@ -194,15 +194,7 @@ func TestKey_Marshal(t *testing.T) { CreatedAt: &Timestamp{referenceTime}, } - want := `{ - "id": 1, - "key": "abc", - "url": "url", - "title": "title", - "read_only": true, - "verified": true, - "created_at": ` + referenceTimeStr + ` - }` + want := `{"id":1,"key":"abc","url":"url","title":"title","read_only":true,"verified":true,"created_at":` + referenceTimeStr + `}` testJSONMarshal(t, u, want) } diff --git a/github/users_projects_test.go b/github/users_projects_test.go index 28c46107286..075cbe054b3 100644 --- a/github/users_projects_test.go +++ b/github/users_projects_test.go @@ -94,17 +94,14 @@ func TestUsersService_CreateProject(t *testing.T) { } func TestCreateUserProjectOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &CreateUserProjectOptions{}, `{}`) + testJSONMarshal(t, &CreateUserProjectOptions{}, `{"name":""}`) c := CreateUserProjectOptions{ Name: "SomeProject", Body: String("SomeProjectBody"), } - want := `{ - "name": "SomeProject", - "body": "SomeProjectBody" - }` + want := `{"name":"SomeProject","body":"SomeProjectBody"}` testJSONMarshal(t, c, want) } diff --git a/github/users_ssh_signing_keys_test.go b/github/users_ssh_signing_keys_test.go index 3bf59e108db..f22885212b9 100644 --- a/github/users_ssh_signing_keys_test.go +++ b/github/users_ssh_signing_keys_test.go @@ -191,12 +191,7 @@ func TestSSHSigningKey_Marshal(t *testing.T) { CreatedAt: &Timestamp{referenceTime}, } - want := `{ - "id": 1, - "key": "abc", - "title": "title", - "created_at": ` + referenceTimeStr + ` - }` + want := `{"id":1,"key":"abc","title":"title","created_at":` + referenceTimeStr + `}` testJSONMarshal(t, u, want) } diff --git a/github/users_test.go b/github/users_test.go index 96b2e926f18..2c5de3b0a55 100644 --- a/github/users_test.go +++ b/github/users_test.go @@ -38,26 +38,8 @@ func TestUser_Marshal(t *testing.T) { CreatedAt: &Timestamp{referenceTime}, SuspendedAt: &Timestamp{referenceTime}, } - want := `{ - "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" - }` + want := `{"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) u2 := &User{ @@ -101,46 +83,8 @@ func TestUser_Marshal(t *testing.T) { LdapDn: String("test ldap"), } - want2 := `{ - "login": "testLogin", - "id": 1, - "node_id":"testNode123", - "avatar_url": "https://www.my-avatar.com", - "html_url":"https://www.test-url.com", - "gravatar_id": "testGravatar123", - "name": "myName", - "company": "testCompany", - "blog": "test Blog", - "location": "test location", - "email": "test@test.com", - "hireable": true, - "bio": "my good bio", - "twitter_username": "https://www.twitter.com/test", - "public_repos": 1, - "public_gists":2, - "followers": 100, - "following": 29, - "created_at": ` + referenceTimeStr + `, - "suspended_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "type": "test type", - "site_admin": false, - "total_private_repos": 2, - "owned_private_repos": 1, - "private_gists": 1, - "disk_usage": 1, - "collaborators": 1, - "two_factor_authentication": false, - "plan": { - "name": "silver", - "space": 1024, - "collaborators": 10, - "private_repos": 4, - "filled_seats": 24, - "seats": 1 - }, - "ldap_dn": "test ldap" - }` + want2 := `{"login":"testLogin","id":1,"node_id":"testNode123","avatar_url":"https://www.my-avatar.com","html_url":"https://www.test-url.com","gravatar_id":"testGravatar123","name":"myName","company":"testCompany","blog":"test Blog","location":"test location","email":"test@test.com","hireable":true,"bio":"my good bio","twitter_username":"https://www.twitter.com/test","public_repos":1,"public_gists":2,"followers":100,"following":29,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"suspended_at":` + referenceTimeStr + `,"type":"test type","site_admin":false,"total_private_repos":2,"owned_private_repos":1,"private_gists":1,"disk_usage":1,"collaborators":1,"two_factor_authentication":false,"plan":{"name":"silver","space":1024,"collaborators":10,"private_repos":4,"filled_seats":24,"seats":1},"ldap_dn":"test ldap"}` + testJSONMarshal(t, u2, want2) } @@ -459,10 +403,7 @@ func TestUserContext_Marshal(t *testing.T) { Octicon: String("message"), } - want := `{ - "message" : "message", - "octicon" : "message" - }` + want := `{"message":"message","octicon":"message"}` testJSONMarshal(t, u, want) } @@ -479,20 +420,15 @@ func TestHovercard_Marshal(t *testing.T) { }, } - want := `{ - "contexts" : [ - { - "message" : "someMessage", - "octicon" : "someOcticon" - } - ] - }` + want := `{"contexts":[{"message":"someMessage","octicon":"someOcticon"}]}` testJSONMarshal(t, h, want) } -func TestUserListOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &UserListOptions{}, "{}") +func TestUserListOptions_addOptions(t *testing.T) { + url := "some/path" + + testAddURLOptions(t, url, &UserListOptions{}, url) u := &UserListOptions{ Since: int64(1900), @@ -502,27 +438,18 @@ func TestUserListOptions_Marshal(t *testing.T) { }, } - want := `{ - "since" : 1900, - "page": 1, - "perPage": 10 - }` - - testJSONMarshal(t, u, want) + testAddURLOptions(t, url, u, url+`?page=1&per_page=10&since=1900`) } -func TestHovercardOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &HovercardOptions{}, "{}") +func TestHovercardOptions_addOptions(t *testing.T) { + url := "some/path" + + testAddURLOptions(t, url, &HovercardOptions{}, url+`?subject_id=&subject_type=`) u := &HovercardOptions{ SubjectType: "subjectType", SubjectID: "subjectID", } - want := `{ - "SubjectType" : "subjectType", - "SubjectID" : "subjectID" - }` - - testJSONMarshal(t, u, want) + testAddURLOptions(t, url, u, url+`?subject_id=subjectID&subject_type=subjectType`) } From 2f4e17bda53e7403d4cee65a6fae8dfbe9b31ba6 Mon Sep 17 00:00:00 2001 From: Geraldo Castro Date: Tue, 21 Mar 2023 19:38:59 -0300 Subject: [PATCH 02/12] Add a proposal to improve json visibility --- github/actions_artifacts_test.go | 30 ++++++++++++++-- github/actions_runner_groups_test.go | 52 +++++++++++++++++++++------- 2 files changed, 67 insertions(+), 15 deletions(-) diff --git a/github/actions_artifacts_test.go b/github/actions_artifacts_test.go index 6b1859ebf4e..a9250327300 100644 --- a/github/actions_artifacts_test.go +++ b/github/actions_artifacts_test.go @@ -453,7 +453,19 @@ func TestArtifact_Marshal(t *testing.T) { }, } - want := `{"id":1,"node_id":"nid","name":"n","size_in_bytes":1,"url":"u","archive_download_url":"a","expired":false,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"expires_at":` + referenceTimeStr + `,"workflow_run":{"id":1,"repository_id":1,"head_repository_id":1,"head_branch":"b","head_sha":"s"}}` + want := fmt.Sprint( + `{"id":1,`, + `"node_id":"nid",`, + `"name":"n",`, + `"size_in_bytes":1,`, + `"url":"u",`, + `"archive_download_url":"a",`, + `"expired":false,`, + `"created_at":`+referenceTimeStr+`,`, + `"updated_at":`+referenceTimeStr+`,`, + `"expires_at":`+referenceTimeStr+`,`, + `"workflow_run":{"id":1,"repository_id":1,"head_repository_id":1,"head_branch":"b","head_sha":"s"}}`, + ) testJSONMarshal(t, u, want) } @@ -486,7 +498,21 @@ func TestArtifactList_Marshal(t *testing.T) { }, } - want := `{"total_count":1,"artifacts":[{"id":1,"node_id":"nid","name":"n","size_in_bytes":1,"url":"u","archive_download_url":"a","expired":false,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"expires_at":` + referenceTimeStr + `,"workflow_run":{"id":1,"repository_id":1,"head_repository_id":1,"head_branch":"b","head_sha":"s"}}]}` + want := fmt.Sprint( + `{"total_count":1,`, + `"artifacts":[`, + `{"id":1,`, + `"node_id":"nid",`, + `"name":"n",`, + `"size_in_bytes":1,`, + `"url":"u",`, + `"archive_download_url":"a",`, + `"expired":false,`, + `"created_at":`+referenceTimeStr+`,`, + `"updated_at":`+referenceTimeStr+`,`, + `"expires_at":`+referenceTimeStr+`,`, + `"workflow_run":{"id":1,"repository_id":1,"head_repository_id":1,"head_branch":"b","head_sha":"s"}}]}`, + ) testJSONMarshal(t, u, want) } diff --git a/github/actions_runner_groups_test.go b/github/actions_runner_groups_test.go index d3cbea949d6..81f7b6c49b2 100644 --- a/github/actions_runner_groups_test.go +++ b/github/actions_runner_groups_test.go @@ -544,14 +544,22 @@ func TestRunnerGroup_Marshal(t *testing.T) { Inherited: Bool(true), AllowsPublicRepositories: Bool(true), RestrictedToWorkflows: Bool(false), - SelectedWorkflows: []string{}, - } - - want := `{"id":1,"name":"n","visibility":"v","default":true,"selected_repositories_url":"s","runners_url":"r","inherited":true,"allows_public_repositories":true,"restricted_to_workflows":false}` - testJSONMarshal(t, u, want) + SelectedWorkflows: []string{"1"}, + } + + want := fmt.Sprint( + `{"id":1,`, + `"name":"n",`, + `"visibility":"v",`, + `"default":true,`, + `"selected_repositories_url":"s",`, + `"runners_url":"r",`, + `"inherited":true,`, + `"allows_public_repositories":true,`, + `"restricted_to_workflows":false,`, + `"selected_workflows":["1"]}`, + ) - u.SelectedWorkflows = []string{"1"} - want = `{"id":1,"name":"n","visibility":"v","default":true,"selected_repositories_url":"s","runners_url":"r","inherited":true,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":["1"]}` testJSONMarshal(t, u, want) } @@ -571,16 +579,26 @@ func TestRunnerGroups_Marshal(t *testing.T) { Inherited: Bool(true), AllowsPublicRepositories: Bool(true), RestrictedToWorkflows: Bool(false), - SelectedWorkflows: []string{}, + SelectedWorkflows: []string{"1"}, }, }, } - want := `{"total_count":1,"runner_groups":[{"id":1,"name":"n","visibility":"v","default":true,"selected_repositories_url":"s","runners_url":"r","inherited":true,"allows_public_repositories":true,"restricted_to_workflows":false}]}` - testJSONMarshal(t, u, want) + want := fmt.Sprint( + `{"total_count":1,`, + `"runner_groups":[`, + `{"id":1,`, + `"name":"n",`, + `"visibility":"v",`, + `"default":true,`, + `"selected_repositories_url":"s",`, + `"runners_url":"r",`, + `"inherited":true,`, + `"allows_public_repositories":true,`, + `"restricted_to_workflows":false,`, + `"selected_workflows":["1"]}]}`, + ) - u.RunnerGroups[0].SelectedWorkflows = []string{"1"} - want = `{"total_count":1,"runner_groups":[{"id":1,"name":"n","visibility":"v","default":true,"selected_repositories_url":"s","runners_url":"r","inherited":true,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":["1"]}]}` testJSONMarshal(t, u, want) } @@ -597,7 +615,15 @@ func TestCreateRunnerGroupRequest_Marshal(t *testing.T) { SelectedWorkflows: []string{"a", "b"}, } - want := `{"name":"n","visibility":"v","selected_repository_ids":[1],"runners":[1],"allows_public_repositories":true,"restricted_to_workflows":true,"selected_workflows":["a","b"]}` + want := fmt.Sprint( + `{"name":"n",`, + `"visibility":"v",`, + `"selected_repository_ids":[1],`, + `"runners":[1],`, + `"allows_public_repositories":true,`, + `"restricted_to_workflows":true,`, + `"selected_workflows":["a","b"]}`, + ) testJSONMarshal(t, u, want) } From c45dba4f725ee7fb392147543c13fbe140ddf579 Mon Sep 17 00:00:00 2001 From: Geraldo Castro Date: Wed, 22 Mar 2023 14:07:05 -0300 Subject: [PATCH 03/12] Improve the formatting of the json strings and remove unnecessary spaces before comparison (inside testJSONMarshal) --- github/actions_artifacts_test.go | 71 +- github/actions_runner_groups_test.go | 84 +- github/actions_runners_test.go | 29 +- github/actions_secrets_test.go | 47 +- github/actions_workflow_jobs_test.go | 71 +- github/actions_workflow_runs_test.go | 240 +- github/actions_workflows_test.go | 64 +- github/activity_notifications.go | 8 +- github/activity_notifications_test.go | 35 +- github/activity_star_test.go | 33 +- github/activity_test.go | 82 +- github/activity_watching_test.go | 10 +- github/admin_orgs_test.go | 10 +- github/admin_stats_test.go | 117 +- github/admin_users_test.go | 32 +- github/apps_installation_test.go | 11 +- github/apps_manifest_test.go | 36 +- github/apps_marketplace_test.go | 122 +- github/apps_test.go | 300 +- github/authorizations_test.go | 80 +- github/billing_test.go | 41 +- github/checks_test.go | 498 +- github/code-scanning_test.go | 53 +- github/event_test.go | 46 +- github/event_types_test.go | 7440 +++++++++++++++++++++- github/gists_comments_test.go | 24 +- github/gists_test.go | 103 +- github/git_blobs_test.go | 9 +- github/git_commits_test.go | 82 +- github/git_refs_test.go | 49 +- github/git_tags_test.go | 38 +- github/git_trees_test.go | 41 +- github/github_test.go | 128 +- github/gitignore_test.go | 5 +- github/interactions_test.go | 6 +- github/issue_import_test.go | 82 +- github/issues_comments_test.go | 35 +- github/issues_events_test.go | 143 +- github/issues_labels_test.go | 10 +- github/issues_milestones_test.go | 38 +- github/issues_test.go | 79 +- github/issues_timeline_test.go | 98 +- github/licenses_test.go | 55 +- github/migrations_source_import_test.go | 47 +- github/migrations_test.go | 24 +- github/migrations_user_test.go | 24 +- github/misc_test.go | 62 +- github/orgs_actions_allowed_test.go | 14 +- github/orgs_audit_log_test.go | 81 +- github/orgs_members_test.go | 45 +- github/orgs_test.go | 18 +- github/packages_test.go | 321 +- github/projects_test.go | 92 +- github/pulls_comments_test.go | 53 +- github/pulls_reviewers_test.go | 49 +- github/pulls_test.go | 337 +- github/pulls_threads_test.go | 111 +- github/reactions_test.go | 19 +- github/repos_actions_permissions_test.go | 6 +- github/repos_autolinks_test.go | 13 +- github/repos_codeowners_test.go | 14 +- github/repos_collaborators_test.go | 77 +- github/repos_comments_test.go | 45 +- github/repos_commits_test.go | 139 +- github/repos_community_health_test.go | 162 +- github/repos_contents_test.go | 97 +- github/repos_deployments_test.go | 95 +- github/repos_environments_test.go | 87 +- github/repos_hooks_deliveries_test.go | 48 +- github/repos_hooks_test.go | 159 +- github/repos_invitations_test.go | 23 +- github/repos_merging_test.go | 12 +- github/repos_pages_test.go | 46 +- github/repos_prereceive_hooks_test.go | 7 +- github/repos_releases_test.go | 64 +- github/repos_stats_test.go | 39 +- github/repos_statuses_test.go | 42 +- github/repos_tags_test.go | 10 +- github/repos_test.go | 70 +- github/repos_traffic_test.go | 43 +- github/scim_test.go | 108 +- github/search_test.go | 209 +- github/secret_scanning_test.go | 46 +- github/teams_discussion_comments_test.go | 29 +- github/teams_discussions_test.go | 40 +- github/teams_test.go | 125 +- github/users_emails_test.go | 7 +- github/users_gpg_keys_test.go | 30 +- github/users_keys_test.go | 10 +- github/users_projects_test.go | 5 +- github/users_ssh_signing_keys_test.go | 7 +- github/users_test.go | 76 +- 92 files changed, 13425 insertions(+), 447 deletions(-) diff --git a/github/actions_artifacts_test.go b/github/actions_artifacts_test.go index a9250327300..7a35e5ad6a5 100644 --- a/github/actions_artifacts_test.go +++ b/github/actions_artifacts_test.go @@ -453,19 +453,25 @@ func TestArtifact_Marshal(t *testing.T) { }, } - want := fmt.Sprint( - `{"id":1,`, - `"node_id":"nid",`, - `"name":"n",`, - `"size_in_bytes":1,`, - `"url":"u",`, - `"archive_download_url":"a",`, - `"expired":false,`, - `"created_at":`+referenceTimeStr+`,`, - `"updated_at":`+referenceTimeStr+`,`, - `"expires_at":`+referenceTimeStr+`,`, - `"workflow_run":{"id":1,"repository_id":1,"head_repository_id":1,"head_branch":"b","head_sha":"s"}}`, - ) + want := `{ + "id":1, + "node_id":"nid", + "name":"n", + "size_in_bytes":1, + "url":"u", + "archive_download_url":"a", + "expired":false, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "expires_at":` + referenceTimeStr + `, + "workflow_run":{ + "id":1, + "repository_id":1, + "head_repository_id":1, + "head_branch":"b", + "head_sha":"s" + } + }` testJSONMarshal(t, u, want) } @@ -498,21 +504,30 @@ func TestArtifactList_Marshal(t *testing.T) { }, } - want := fmt.Sprint( - `{"total_count":1,`, - `"artifacts":[`, - `{"id":1,`, - `"node_id":"nid",`, - `"name":"n",`, - `"size_in_bytes":1,`, - `"url":"u",`, - `"archive_download_url":"a",`, - `"expired":false,`, - `"created_at":`+referenceTimeStr+`,`, - `"updated_at":`+referenceTimeStr+`,`, - `"expires_at":`+referenceTimeStr+`,`, - `"workflow_run":{"id":1,"repository_id":1,"head_repository_id":1,"head_branch":"b","head_sha":"s"}}]}`, - ) + want := `{ + "total_count":1, + "artifacts":[ + { + "id":1, + "node_id":"nid", + "name":"n", + "size_in_bytes":1, + "url":"u", + "archive_download_url":"a", + "expired":false, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "expires_at":` + referenceTimeStr + `, + "workflow_run":{ + "id":1, + "repository_id":1, + "head_repository_id":1, + "head_branch":"b", + "head_sha":"s" + } + } + ] + }` testJSONMarshal(t, u, want) } diff --git a/github/actions_runner_groups_test.go b/github/actions_runner_groups_test.go index 81f7b6c49b2..9a6e7f1f21b 100644 --- a/github/actions_runner_groups_test.go +++ b/github/actions_runner_groups_test.go @@ -547,18 +547,20 @@ func TestRunnerGroup_Marshal(t *testing.T) { SelectedWorkflows: []string{"1"}, } - want := fmt.Sprint( - `{"id":1,`, - `"name":"n",`, - `"visibility":"v",`, - `"default":true,`, - `"selected_repositories_url":"s",`, - `"runners_url":"r",`, - `"inherited":true,`, - `"allows_public_repositories":true,`, - `"restricted_to_workflows":false,`, - `"selected_workflows":["1"]}`, - ) + want := `{ + "id":1, + "name":"n", + "visibility":"v", + "default":true, + "selected_repositories_url":"s", + "runners_url":"r", + "inherited":true, + "allows_public_repositories":true, + "restricted_to_workflows":false, + "selected_workflows":[ + "1" + ] + }` testJSONMarshal(t, u, want) } @@ -584,20 +586,25 @@ func TestRunnerGroups_Marshal(t *testing.T) { }, } - want := fmt.Sprint( - `{"total_count":1,`, - `"runner_groups":[`, - `{"id":1,`, - `"name":"n",`, - `"visibility":"v",`, - `"default":true,`, - `"selected_repositories_url":"s",`, - `"runners_url":"r",`, - `"inherited":true,`, - `"allows_public_repositories":true,`, - `"restricted_to_workflows":false,`, - `"selected_workflows":["1"]}]}`, - ) + want := `{ + "total_count":1, + "runner_groups":[ + { + "id":1, + "name":"n", + "visibility":"v", + "default":true, + "selected_repositories_url":"s", + "runners_url":"r", + "inherited":true, + "allows_public_repositories":true, + "restricted_to_workflows":false, + "selected_workflows":[ + "1" + ] + } + ] + }` testJSONMarshal(t, u, want) } @@ -615,15 +622,22 @@ func TestCreateRunnerGroupRequest_Marshal(t *testing.T) { SelectedWorkflows: []string{"a", "b"}, } - want := fmt.Sprint( - `{"name":"n",`, - `"visibility":"v",`, - `"selected_repository_ids":[1],`, - `"runners":[1],`, - `"allows_public_repositories":true,`, - `"restricted_to_workflows":true,`, - `"selected_workflows":["a","b"]}`, - ) + want := `{ + "name":"n", + "visibility":"v", + "selected_repository_ids":[ + 1 + ], + "runners":[ + 1 + ], + "allows_public_repositories":true, + "restricted_to_workflows":true, + "selected_workflows":[ + "a", + "b" + ] + }` testJSONMarshal(t, u, want) } diff --git a/github/actions_runners_test.go b/github/actions_runners_test.go index 0155147b9ac..7a7593e02cc 100644 --- a/github/actions_runners_test.go +++ b/github/actions_runners_test.go @@ -596,7 +596,14 @@ func TestRunnerApplicationDownload_Marshal(t *testing.T) { SHA256Checksum: String("s"), } - want := `{"os":"o","architecture":"a","download_url":"d","filename":"f","temp_download_token":"t","sha256_checksum":"s"}` + want := `{ + "os":"o", + "architecture":"a", + "download_url":"d", + "filename":"f", + "temp_download_token":"t", + "sha256_checksum":"s" + }` testJSONMarshal(t, u, want) } @@ -693,7 +700,25 @@ func TestRunners_Marshal(t *testing.T) { }, } - want := `{"total_count":1,"runners":[{"id":1,"name":"n","os":"o","status":"s","busy":false,"labels":[{"id":1,"name":"n","type":"t"}]}]}` + want := `{ + "total_count":1, + "runners":[ + { + "id":1, + "name":"n", + "os":"o", + "status":"s", + "busy":false, + "labels":[ + { + "id":1, + "name":"n", + "type":"t" + } + ] + } + ] + }` testJSONMarshal(t, u, want) } diff --git a/github/actions_secrets_test.go b/github/actions_secrets_test.go index 969aac87eba..958c579fb13 100644 --- a/github/actions_secrets_test.go +++ b/github/actions_secrets_test.go @@ -825,7 +825,11 @@ func TestPublicKey_Marshal(t *testing.T) { } func TestSecret_Marshal(t *testing.T) { - testJSONMarshal(t, &Secret{}, `{"name":"","created_at":"0001-01-01T00:00:00Z","updated_at":"0001-01-01T00:00:00Z"}`) + testJSONMarshal(t, &Secret{}, `{ + "name":"", + "created_at":"0001-01-01T00:00:00Z", + "updated_at":"0001-01-01T00:00:00Z" + }`) u := &Secret{ Name: "n", @@ -835,7 +839,13 @@ func TestSecret_Marshal(t *testing.T) { SelectedRepositoriesURL: "s", } - want := `{"name":"n","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"visibility":"v","selected_repositories_url":"s"}` + want := `{ + "name":"n", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "visibility":"v", + "selected_repositories_url":"s" + }` testJSONMarshal(t, u, want) } @@ -855,7 +865,18 @@ func TestSecrets_Marshal(t *testing.T) { }, } - want := `{"total_count":1,"secrets":[{"name":"n","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"visibility":"v","selected_repositories_url":"s"}]}` + want := `{ + "total_count":1, + "secrets":[ + { + "name":"n", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "visibility":"v", + "selected_repositories_url":"s" + } + ] + }` testJSONMarshal(t, u, want) } @@ -871,7 +892,14 @@ func TestEncryptedSecret_Marshal(t *testing.T) { SelectedRepositoryIDs: []int64{1}, } - want := `{"key_id":"kid","encrypted_value":"e","visibility":"v","selected_repository_ids":[1]}` + want := `{ + "key_id":"kid", + "encrypted_value":"e", + "visibility":"v", + "selected_repository_ids":[ + 1 + ] + }` testJSONMarshal(t, u, want) } @@ -890,7 +918,16 @@ func TestSelectedReposList_Marshal(t *testing.T) { }, } - want := `{"total_count":1,"repositories":[{"id":1,"name":"n","url":"u"}]}` + want := `{ + "total_count":1, + "repositories":[ + { + "id":1, + "name":"n", + "url":"u" + } + ] + }` testJSONMarshal(t, u, want) } diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index 80212816cc6..d0aa0ba4766 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -226,7 +226,14 @@ func TestTaskStep_Marshal(t *testing.T) { CompletedAt: &Timestamp{referenceTime}, } - want := `{"name":"n","status":"s","conclusion":"c","number":1,"started_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `}` + want := `{ + "name":"n", + "status":"s", + "conclusion":"c", + "number":1, + "started_at":` + referenceTimeStr + `, + "completed_at":` + referenceTimeStr + ` + }` testJSONMarshal(t, u, want) } @@ -262,7 +269,33 @@ func TestWorkflowJob_Marshal(t *testing.T) { WorkflowName: String("w"), } - want := `{"id":1,"run_id":1,"run_url":"r","node_id":"n","head_sha":"h","url":"u","html_url":"h","status":"s","conclusion":"c","created_at":` + referenceTimeStr + `,"started_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `,"name":"n","steps":[{"name":"n","status":"s","conclusion":"c","number":1,"started_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `}],"check_run_url":"c","workflow_name":"w"}` + want := `{ + "id":1, + "run_id":1, + "run_url":"r", + "node_id":"n", + "head_sha":"h", + "url":"u", + "html_url":"h", + "status":"s", + "conclusion":"c", + "created_at":` + referenceTimeStr + `, + "started_at":` + referenceTimeStr + `, + "completed_at":` + referenceTimeStr + `, + "name":"n", + "steps":[ + { + "name":"n", + "status":"s", + "conclusion":"c", + "number":1, + "started_at":` + referenceTimeStr + `, + "completed_at":` + referenceTimeStr + ` + } + ], + "check_run_url":"c", + "workflow_name":"w" + }` testJSONMarshal(t, u, want) } @@ -304,7 +337,39 @@ func TestJobs_Marshal(t *testing.T) { }, } - want := `{"total_count":1,"jobs":[{"id":1,"run_id":1,"run_url":"r","node_id":"n","head_sha":"h","url":"u","html_url":"h","status":"s","conclusion":"c","created_at":` + referenceTimeStr + `,"started_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `,"name":"n","steps":[{"name":"n","status":"s","conclusion":"c","number":1,"started_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `}],"check_run_url":"c","run_attempt":2,"workflow_name":"w"}]}` + want := `{ + "total_count":1, + "jobs":[ + { + "id":1, + "run_id":1, + "run_url":"r", + "node_id":"n", + "head_sha":"h", + "url":"u", + "html_url":"h", + "status":"s", + "conclusion":"c", + "created_at":` + referenceTimeStr + `, + "started_at":` + referenceTimeStr + `, + "completed_at":` + referenceTimeStr + `, + "name":"n", + "steps":[ + { + "name":"n", + "status":"s", + "conclusion":"c", + "number":1, + "started_at":` + referenceTimeStr + `, + "completed_at":` + referenceTimeStr + ` + } + ], + "check_run_url":"c", + "run_attempt":2, + "workflow_name":"w" + } + ] +}` testJSONMarshal(t, u, want) } diff --git a/github/actions_workflow_runs_test.go b/github/actions_workflow_runs_test.go index c9f5d07e7da..1322e4fbd56 100644 --- a/github/actions_workflow_runs_test.go +++ b/github/actions_workflow_runs_test.go @@ -660,7 +660,106 @@ func TestWorkflowRun_Marshal(t *testing.T) { }, } - want := `{"id":1,"name":"n","node_id":"nid","head_branch":"hb","head_sha":"hs","run_number":1,"run_attempt":1,"event":"e","status":"s","conclusion":"c","workflow_id":1,"url":"u","html_url":"h","pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}],"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"run_started_at":` + referenceTimeStr + `,"jobs_url":"j","logs_url":"l","check_suite_url":"c","artifacts_url":"a","cancel_url":"c","rerun_url":"r","previous_attempt_url":"p","head_commit":{"message":"m","author":{"name":"n","email":"e","username":"l"},"url":"u","distinct":false,"sha":"s","id":"i","tree_id":"tid","timestamp":` + referenceTimeStr + `,"committer":{"name":"n","email":"e","username":"l"}},"workflow_url":"w","repository":{"id":1,"name":"n","url":"u"},"head_repository":{"id":1,"name":"n","url":"u"},"actor":{"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"}}` + want := `{ + "id":1, + "name":"n", + "node_id":"nid", + "head_branch":"hb", + "head_sha":"hs", + "run_number":1, + "run_attempt":1, + "event":"e", + "status":"s", + "conclusion":"c", + "workflow_id":1, + "url":"u", + "html_url":"h", + "pull_requests":[ + { + "id":1, + "number":1, + "url":"u", + "head":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"s" + } + }, + "base":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"u" + } + } + } + ], + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "run_started_at":` + referenceTimeStr + `, + "jobs_url":"j", + "logs_url":"l", + "check_suite_url":"c", + "artifacts_url":"a", + "cancel_url":"c", + "rerun_url":"r", + "previous_attempt_url":"p", + "head_commit":{ + "message":"m", + "author":{ + "name":"n", + "email":"e", + "username":"l" + }, + "url":"u", + "distinct":false, + "sha":"s", + "id":"i", + "tree_id":"tid", + "timestamp":` + referenceTimeStr + `, + "committer":{ + "name":"n", + "email":"e", + "username":"l" + } + }, + "workflow_url":"w", + "repository":{ + "id":1, + "name":"n", + "url":"u" + }, + "head_repository":{ + "id":1, + "name":"n", + "url":"u" + }, + "actor":{ + "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) } @@ -774,7 +873,111 @@ func TestWorkflowRuns_Marshal(t *testing.T) { }, } - want := `{"total_count":1,"workflow_runs":[{"id":1,"name":"n","node_id":"nid","head_branch":"hb","head_sha":"hs","run_number":1,"run_attempt":1,"event":"e","status":"s","conclusion":"c","workflow_id":1,"url":"u","html_url":"h","pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}],"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"run_started_at":` + referenceTimeStr + `,"jobs_url":"j","logs_url":"l","check_suite_url":"c","artifacts_url":"a","cancel_url":"c","rerun_url":"r","previous_attempt_url":"p","head_commit":{"message":"m","author":{"name":"n","email":"e","username":"l"},"url":"u","distinct":false,"sha":"s","id":"i","tree_id":"tid","timestamp":` + referenceTimeStr + `,"committer":{"name":"n","email":"e","username":"l"}},"workflow_url":"w","repository":{"id":1,"name":"n","url":"u"},"head_repository":{"id":1,"name":"n","url":"u"},"actor":{"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"}}]}` + want := `{ + "total_count":1, + "workflow_runs":[ + { + "id":1, + "name":"n", + "node_id":"nid", + "head_branch":"hb", + "head_sha":"hs", + "run_number":1, + "run_attempt":1, + "event":"e", + "status":"s", + "conclusion":"c", + "workflow_id":1, + "url":"u", + "html_url":"h", + "pull_requests":[ + { + "id":1, + "number":1, + "url":"u", + "head":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"s" + } + }, + "base":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"u" + } + } + } + ], + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "run_started_at":` + referenceTimeStr + `, + "jobs_url":"j", + "logs_url":"l", + "check_suite_url":"c", + "artifacts_url":"a", + "cancel_url":"c", + "rerun_url":"r", + "previous_attempt_url":"p", + "head_commit":{ + "message":"m", + "author":{ + "name":"n", + "email":"e", + "username":"l" + }, + "url":"u", + "distinct":false, + "sha":"s", + "id":"i", + "tree_id":"tid", + "timestamp":` + referenceTimeStr + `, + "committer":{ + "name":"n", + "email":"e", + "username":"l" + } + }, + "workflow_url":"w", + "repository":{ + "id":1, + "name":"n", + "url":"u" + }, + "head_repository":{ + "id":1, + "name":"n", + "url":"u" + }, + "actor":{ + "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) } @@ -810,7 +1013,20 @@ func TestWorkflowRunBillMap_Marshal(t *testing.T) { }, } - want := `{"MACOS":{"total_ms":1,"jobs":1},"UBUNTU":{"total_ms":1,"jobs":1},"WINDOWS":{"total_ms":1,"jobs":1}}` + want := `{ + "MACOS":{ + "total_ms":1, + "jobs":1 + }, + "UBUNTU":{ + "total_ms":1, + "jobs":1 + }, + "WINDOWS":{ + "total_ms":1, + "jobs":1 + } + }` testJSONMarshal(t, u, want) } @@ -836,7 +1052,23 @@ func TestWorkflowRunUsage_Marshal(t *testing.T) { RunDurationMS: Int64(1), } - want := `{"billable":{"MACOS":{"total_ms":1,"jobs":1},"UBUNTU":{"total_ms":1,"jobs":1},"WINDOWS":{"total_ms":1,"jobs":1}},"run_duration_ms":1}` + want := `{ + "billable":{ + "MACOS":{ + "total_ms":1, + "jobs":1 + }, + "UBUNTU":{ + "total_ms":1, + "jobs":1 + }, + "WINDOWS":{ + "total_ms":1, + "jobs":1 + } + }, + "run_duration_ms":1 + }` testJSONMarshal(t, u, want) } diff --git a/github/actions_workflows_test.go b/github/actions_workflows_test.go index 6e1d9f4bdf0..ab2ad57b354 100644 --- a/github/actions_workflows_test.go +++ b/github/actions_workflows_test.go @@ -475,7 +475,18 @@ func TestWorkflow_Marshal(t *testing.T) { BadgeURL: String("b"), } - want := `{"id":1,"node_id":"nid","name":"n","path":"p","state":"s","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"url":"u","html_url":"h","badge_url":"b"}` + want := `{ + "id":1, + "node_id":"nid", + "name":"n", + "path":"p", + "state":"s", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "url":"u", + "html_url":"h", + "badge_url":"b" + }` testJSONMarshal(t, u, want) } @@ -501,7 +512,23 @@ func TestWorkflows_Marshal(t *testing.T) { }, } - want := `{"total_count":1,"workflows":[{"id":1,"node_id":"nid","name":"n","path":"p","state":"s","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"url":"u","html_url":"h","badge_url":"b"}]}` + want := `{ + "total_count":1, + "workflows":[ + { + "id":1, + "node_id":"nid", + "name":"n", + "path":"p", + "state":"s", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "url":"u", + "html_url":"h", + "badge_url":"b" + } + ] + }` testJSONMarshal(t, u, want) } @@ -533,7 +560,17 @@ func TestWorkflowBillMap_Marshal(t *testing.T) { }, } - want := `{"MACOS":{"total_ms":1},"UBUNTU":{"total_ms":1},"WINDOWS":{"total_ms":1}}` + want := `{ + "MACOS":{ + "total_ms":1 + }, + "UBUNTU":{ + "total_ms":1 + }, + "WINDOWS":{ + "total_ms":1 + } + }` testJSONMarshal(t, u, want) } @@ -555,7 +592,19 @@ func TestWorkflowUsage_Marshal(t *testing.T) { }, } - want := `{"billable":{"MACOS":{"total_ms":1},"UBUNTU":{"total_ms":1},"WINDOWS":{"total_ms":1}}}` + want := `{ + "billable":{ + "MACOS":{ + "total_ms":1 + }, + "UBUNTU":{ + "total_ms":1 + }, + "WINDOWS":{ + "total_ms":1 + } + } + }` testJSONMarshal(t, u, want) } @@ -571,7 +620,12 @@ func TestCreateWorkflowDispatchEventRequest_Marshal(t *testing.T) { Inputs: inputs, } - want := `{"ref":"r","inputs":{"key":"value"}}` + want := `{ + "ref":"r", + "inputs":{ + "key":"value" + } + }` testJSONMarshal(t, u, want) } diff --git a/github/activity_notifications.go b/github/activity_notifications.go index 1fc24503ff5..3b270bc6333 100644 --- a/github/activity_notifications.go +++ b/github/activity_notifications.go @@ -97,15 +97,15 @@ func (s *ActivityService) ListRepositoryNotifications(ctx context.Context, owner } type markReadOptions struct { - LastReadAt *Timestamp `json:"last_read_at,omitempty"` + LastReadAt Timestamp `json:"last_read_at,omitempty"` } // MarkNotificationsRead marks all notifications up to lastRead as read. // -// GitHub API docs: https://docs.github.com/en/rest/activity#mark-as-read +// GitHub API docs: https://docs.github.com/en/rest/activity#mark-notifications-as-read func (s *ActivityService) MarkNotificationsRead(ctx context.Context, lastRead Timestamp) (*Response, error) { opts := &markReadOptions{ - LastReadAt: &lastRead, + LastReadAt: lastRead, } req, err := s.client.NewRequest("PUT", "notifications", opts) if err != nil { @@ -121,7 +121,7 @@ func (s *ActivityService) MarkNotificationsRead(ctx context.Context, lastRead Ti // GitHub API docs: https://docs.github.com/en/rest/activity/notifications#mark-repository-notifications-as-read func (s *ActivityService) MarkRepositoryNotificationsRead(ctx context.Context, owner, repo string, lastRead Timestamp) (*Response, error) { opts := &markReadOptions{ - LastReadAt: &lastRead, + LastReadAt: lastRead, } u := fmt.Sprintf("repos/%v/%v/notifications", owner, repo) req, err := s.client.NewRequest("PUT", u, opts) diff --git a/github/activity_notifications_test.go b/github/activity_notifications_test.go index b6544604454..4bf7b095e07 100644 --- a/github/activity_notifications_test.go +++ b/github/activity_notifications_test.go @@ -336,7 +336,25 @@ func TestNotification_Marshal(t *testing.T) { URL: String("u"), } - want := `{"id":"id","repository":{"id":1,"name":"n","url":"u"},"subject":{"title":"t","url":"u","latest_comment_url":"l","type":"t"},"reason":"r","unread":true,"updated_at":` + referenceTimeStr + `,"last_read_at":` + referenceTimeStr + `,"url":"u"}` + want := `{ + "id":"id", + "repository":{ + "id":1, + "name":"n", + "url":"u" + }, + "subject":{ + "title":"t", + "url":"u", + "latest_comment_url":"l", + "type":"t" + }, + "reason":"r", + "unread":true, + "updated_at":` + referenceTimeStr + `, + "last_read_at":` + referenceTimeStr + `, + "url":"u" + }` testJSONMarshal(t, u, want) } @@ -351,19 +369,26 @@ func TestNotificationSubject_Marshal(t *testing.T) { Type: String("t"), } - want := `{"title":"t","url":"u","latest_comment_url":"l","type":"t"}` + want := `{ + "title":"t", + "url":"u", + "latest_comment_url":"l", + "type":"t" + }` testJSONMarshal(t, u, want) } func TestMarkReadOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &markReadOptions{}, "{}") + testJSONMarshal(t, &markReadOptions{}, `{"last_read_at":"0001-01-01T00:00:00Z"}`) u := &markReadOptions{ - LastReadAt: &Timestamp{referenceTime}, + LastReadAt: Timestamp{referenceTime}, } - want := `{"last_read_at":` + referenceTimeStr + `}` + want := `{ + "last_read_at":` + referenceTimeStr + ` + }` testJSONMarshal(t, u, want) } diff --git a/github/activity_star_test.go b/github/activity_star_test.go index 40b49147f98..8067f197249 100644 --- a/github/activity_star_test.go +++ b/github/activity_star_test.go @@ -298,7 +298,14 @@ func TestStarredRepository_Marshal(t *testing.T) { }, } - want := `{"starred_at":` + referenceTimeStr + `,"repo":{"id":1,"name":"n","url":"u"}}` + want := `{ + "starred_at":` + referenceTimeStr + `, + "repo":{ + "id":1, + "name":"n", + "url":"u" + } + }` testJSONMarshal(t, u, want) } @@ -330,7 +337,29 @@ func TestStargazer_Marshal(t *testing.T) { }, } - 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"}}` + 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) } diff --git a/github/activity_test.go b/github/activity_test.go index beb968fefcb..9ec11d62f7c 100644 --- a/github/activity_test.go +++ b/github/activity_test.go @@ -139,7 +139,10 @@ func TestFeedLink_Marshal(t *testing.T) { Type: String("t"), } - want := `{"href":"h","type":"t"}` + want := `{ + "href":"h", + "type":"t" + }` testJSONMarshal(t, u, want) } @@ -189,7 +192,49 @@ func TestFeeds_Marshal(t *testing.T) { }, } - want := `{"timeline_url":"t","user_url":"u","current_user_public_url":"cupu","current_user_url":"cuu","current_user_actor_url":"cuau","current_user_organization_url":"cuou","current_user_organization_urls":["a"],"_links":{"timeline":{"href":"h","type":"t"},"user":{"href":"h","type":"t"},"current_user_public":{"href":"h","type":"t"},"current_user":{"href":"h","type":"t"},"current_user_actor":{"href":"h","type":"t"},"current_user_organization":{"href":"h","type":"t"},"current_user_organizations":[{"href":"h","type":"t"}]}}` + want := `{ + "timeline_url":"t", + "user_url":"u", + "current_user_public_url":"cupu", + "current_user_url":"cuu", + "current_user_actor_url":"cuau", + "current_user_organization_url":"cuou", + "current_user_organization_urls":[ + "a" + ], + "_links":{ + "timeline":{ + "href":"h", + "type":"t" + }, + "user":{ + "href":"h", + "type":"t" + }, + "current_user_public":{ + "href":"h", + "type":"t" + }, + "current_user":{ + "href":"h", + "type":"t" + }, + "current_user_actor":{ + "href":"h", + "type":"t" + }, + "current_user_organization":{ + "href":"h", + "type":"t" + }, + "current_user_organizations":[ + { + "href":"h", + "type":"t" + } + ] + } + }` testJSONMarshal(t, u, want) } @@ -230,7 +275,38 @@ func TestFeedLinks_Marshal(t *testing.T) { }, } - want := `{"timeline":{"href":"h","type":"t"},"user":{"href":"h","type":"t"},"current_user_public":{"href":"h","type":"t"},"current_user":{"href":"h","type":"t"},"current_user_actor":{"href":"h","type":"t"},"current_user_organization":{"href":"h","type":"t"},"current_user_organizations":[{"href":"h","type":"t"}]}` + want := `{ + "timeline":{ + "href":"h", + "type":"t" + }, + "user":{ + "href":"h", + "type":"t" + }, + "current_user_public":{ + "href":"h", + "type":"t" + }, + "current_user":{ + "href":"h", + "type":"t" + }, + "current_user_actor":{ + "href":"h", + "type":"t" + }, + "current_user_organization":{ + "href":"h", + "type":"t" + }, + "current_user_organizations":[ + { + "href":"h", + "type":"t" + } + ] + }` testJSONMarshal(t, u, want) } diff --git a/github/activity_watching_test.go b/github/activity_watching_test.go index ec7718350fc..14955786cb1 100644 --- a/github/activity_watching_test.go +++ b/github/activity_watching_test.go @@ -271,7 +271,15 @@ func TestSubscription_Marshal(t *testing.T) { ThreadURL: String("tu"), } - want := `{"subscribed":true,"ignored":false,"reason":"r","created_at":` + referenceTimeStr + `,"url":"u","repository_url":"ru","thread_url":"tu"}` + want := `{ + "subscribed":true, + "ignored":false, + "reason":"r", + "created_at":` + referenceTimeStr + `, + "url":"u", + "repository_url":"ru", + "thread_url":"tu" + }` testJSONMarshal(t, u, want) } diff --git a/github/admin_orgs_test.go b/github/admin_orgs_test.go index 469b2213081..12e5807e595 100644 --- a/github/admin_orgs_test.go +++ b/github/admin_orgs_test.go @@ -150,7 +150,10 @@ func TestCreateOrgRequest_Marshal(t *testing.T) { Admin: String("a"), } - want := `{"login":"l","admin":"a"}` + want := `{ + "login":"l", + "admin":"a" + }` testJSONMarshal(t, u, want) } @@ -175,7 +178,10 @@ func TestRenameOrgResponse_Marshal(t *testing.T) { URL: String("u"), } - want := `{"message":"m","url":"u"}` + want := `{ + "message":"m", + "url":"u" + }` testJSONMarshal(t, u, want) } diff --git a/github/admin_stats_test.go b/github/admin_stats_test.go index 00b5ce5b7ef..972b9bef69c 100644 --- a/github/admin_stats_test.go +++ b/github/admin_stats_test.go @@ -219,7 +219,11 @@ func TestIssueStats_Marshal(t *testing.T) { ClosedIssues: Int(1), } - want := `{"total_issues":1,"open_issues":1,"closed_issues":1}` + want := `{ + "total_issues":1, + "open_issues":1, + "closed_issues":1 + }` testJSONMarshal(t, u, want) } @@ -233,7 +237,11 @@ func TestHookStats_Marshal(t *testing.T) { InactiveHooks: Int(1), } - want := `{"total_hooks":1,"active_hooks":1,"inactive_hooks":1}` + want := `{ + "total_hooks":1, + "active_hooks":1, + "inactive_hooks":1 + }` testJSONMarshal(t, u, want) } @@ -247,7 +255,11 @@ func TestMilestoneStats_Marshal(t *testing.T) { ClosedMilestones: Int(1), } - want := `{"total_milestones":1,"open_milestones":1,"closed_milestones":1}` + want := `{ + "total_milestones":1, + "open_milestones":1, + "closed_milestones":1 + }` testJSONMarshal(t, u, want) } @@ -262,7 +274,12 @@ func TestOrgStats_Marshal(t *testing.T) { TotalTeamMembers: Int(1), } - want := `{"total_orgs":1,"disabled_orgs":1,"total_teams":1,"total_team_members":1}` + want := `{ + "total_orgs":1, + "disabled_orgs":1, + "total_teams":1, + "total_team_members":1 + }` testJSONMarshal(t, u, want) } @@ -277,7 +294,12 @@ func TestCommentStats_Marshal(t *testing.T) { TotalPullRequestComments: Int(1), } - want := `{"total_commit_comments":1,"total_gist_comments":1,"total_issue_comments":1,"total_pull_request_comments":1}` + want := `{ + "total_commit_comments":1, + "total_gist_comments":1, + "total_issue_comments":1, + "total_pull_request_comments":1 + }` testJSONMarshal(t, u, want) } @@ -303,7 +325,11 @@ func TestUserStats_Marshal(t *testing.T) { SuspendedUsers: Int(1), } - want := `{"total_users":1,"admin_users":1,"suspended_users":1}` + want := `{ + "total_users":1, + "admin_users":1, + "suspended_users":1 + }` testJSONMarshal(t, u, want) } @@ -317,7 +343,11 @@ func TestGistStats_Marshal(t *testing.T) { PublicGists: Int(1), } - want := `{"total_gists":1,"private_gists":1,"public_gists":1}` + want := `{ + "total_gists":1, + "private_gists":1, + "public_gists":1 + }` testJSONMarshal(t, u, want) } @@ -332,7 +362,12 @@ func TestPullStats_Marshal(t *testing.T) { UnmergablePulls: Int(1), } - want := `{"total_pulls":1,"merged_pulls":1,"mergeable_pulls":1,"unmergeable_pulls":1}` + want := `{ + "total_pulls":1, + "merged_pulls":1, + "mergeable_pulls":1, + "unmergeable_pulls":1 + }` testJSONMarshal(t, u, want) } @@ -349,7 +384,14 @@ func TestRepoStats_Marshal(t *testing.T) { TotalWikis: Int(1), } - want := `{"total_repos":1,"root_repos":1,"fork_repos":1,"org_repos":1,"total_pushes":1,"total_wikis":1}` + want := `{ + "total_repos":1, + "root_repos":1, + "fork_repos":1, + "org_repos":1, + "total_pushes":1, + "total_wikis":1 + }` testJSONMarshal(t, u, want) } @@ -414,7 +456,62 @@ func TestAdminStats_Marshal(t *testing.T) { }, } - want := `{"issues":{"total_issues":179,"open_issues":83,"closed_issues":96},"hooks":{"total_hooks":27,"active_hooks":23,"inactive_hooks":4},"milestones":{"total_milestones":7,"open_milestones":6,"closed_milestones":1},"orgs":{"total_orgs":33,"disabled_orgs":0,"total_teams":60,"total_team_members":314},"comments":{"total_commit_comments":6,"total_gist_comments":28,"total_issue_comments":366,"total_pull_request_comments":30},"pages":{"total_pages":36},"users":{"total_users":254,"admin_users":45,"suspended_users":21},"gists":{"total_gists":178,"private_gists":151,"public_gists":25},"pulls":{"total_pulls":86,"merged_pulls":60,"mergeable_pulls":21,"unmergeable_pulls":3},"repos":{"total_repos":212,"root_repos":194,"fork_repos":18,"org_repos":51,"total_pushes":3082,"total_wikis":15}}` + want := `{ + "issues":{ + "total_issues":179, + "open_issues":83, + "closed_issues":96 + }, + "hooks":{ + "total_hooks":27, + "active_hooks":23, + "inactive_hooks":4 + }, + "milestones":{ + "total_milestones":7, + "open_milestones":6, + "closed_milestones":1 + }, + "orgs":{ + "total_orgs":33, + "disabled_orgs":0, + "total_teams":60, + "total_team_members":314 + }, + "comments":{ + "total_commit_comments":6, + "total_gist_comments":28, + "total_issue_comments":366, + "total_pull_request_comments":30 + }, + "pages":{ + "total_pages":36 + }, + "users":{ + "total_users":254, + "admin_users":45, + "suspended_users":21 + }, + "gists":{ + "total_gists":178, + "private_gists":151, + "public_gists":25 + }, + "pulls":{ + "total_pulls":86, + "merged_pulls":60, + "mergeable_pulls":21, + "unmergeable_pulls":3 + }, + "repos":{ + "total_repos":212, + "root_repos":194, + "fork_repos":18, + "org_repos":51, + "total_pushes":3082, + "total_wikis":15 + } + }` testJSONMarshal(t, u, want) } diff --git a/github/admin_users_test.go b/github/admin_users_test.go index 309ec67e08b..9e4f6c0e200 100644 --- a/github/admin_users_test.go +++ b/github/admin_users_test.go @@ -184,7 +184,10 @@ func TestCreateUserRequest_Marshal(t *testing.T) { Email: String("e"), } - want := `{"login":"l","email":"e"}` + want := `{ + "login":"l", + "email":"e" + }` testJSONMarshal(t, u, want) } @@ -212,7 +215,11 @@ func TestOAuthAPP_Marshal(t *testing.T) { ClientID: String("cid"), } - want := `{"url":"u","name":"n","client_id":"cid"}` + want := `{ + "url":"u", + "name":"n", + "client_id":"cid" + }` testJSONMarshal(t, u, want) } @@ -241,7 +248,26 @@ func TestUserAuthorization_Marshal(t *testing.T) { Fingerprint: String("f"), } - 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"}` + 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" + }` testJSONMarshal(t, u, want) } diff --git a/github/apps_installation_test.go b/github/apps_installation_test.go index 5599ba38c08..7544f54bf79 100644 --- a/github/apps_installation_test.go +++ b/github/apps_installation_test.go @@ -188,7 +188,16 @@ func TestListRepositories_Marshal(t *testing.T) { }, } - want := `{"total_count":1,"repositories":[{"id":1,"name":"n","url":"u"}]}` + want := `{ + "total_count":1, + "repositories":[ + { + "id":1, + "name":"n", + "url":"u" + } + ] + }` testJSONMarshal(t, u, want) } diff --git a/github/apps_manifest_test.go b/github/apps_manifest_test.go index 9d226eb17bf..745d46d0919 100644 --- a/github/apps_manifest_test.go +++ b/github/apps_manifest_test.go @@ -106,7 +106,41 @@ func TestAppConfig_Marshal(t *testing.T) { PEM: String("pem"), } - 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 + `,"client_id":"ci","client_secret":"cs","webhook_secret":"ws","pem":"pem"}` + 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 + `, + "client_id":"ci", + "client_secret":"cs", + "webhook_secret":"ws", + "pem":"pem" + }` testJSONMarshal(t, u, want) } diff --git a/github/apps_marketplace_test.go b/github/apps_marketplace_test.go index 06bded52334..f69f5a4cc70 100644 --- a/github/apps_marketplace_test.go +++ b/github/apps_marketplace_test.go @@ -255,7 +255,23 @@ func TestMarketplacePlan_Marshal(t *testing.T) { HasFreeTrial: Bool(false), } - want := `{"url":"u","accounts_url":"au","id":1,"number":1,"name":"n","description":"d","monthly_price_in_cents":1,"yearly_price_in_cents":1,"price_model":"pm","unit_name":"un","bullets":["b"],"state":"s","has_free_trial":false}` + want := `{ + "url":"u", + "accounts_url":"au", + "id":1, + "number":1, + "name":"n", + "description":"d", + "monthly_price_in_cents":1, + "yearly_price_in_cents":1, + "price_model":"pm", + "unit_name":"un", + "bullets":[ + "b" + ], + "state":"s", + "has_free_trial":false + }` testJSONMarshal(t, u, want) } @@ -287,7 +303,31 @@ func TestMarketplacePurchase_Marshal(t *testing.T) { UpdatedAt: &Timestamp{referenceTime}, } - want := `{"billing_cycle":"bc","next_billing_date":` + referenceTimeStr + `,"unit_count":1,"plan":{"url":"u","accounts_url":"au","id":1,"number":1,"name":"n","description":"d","monthly_price_in_cents":1,"yearly_price_in_cents":1,"price_model":"pm","unit_name":"un","bullets":["b"],"state":"s","has_free_trial":false},"on_free_trial":false,"free_trial_ends_on":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `}` + want := `{ + "billing_cycle":"bc", + "next_billing_date":` + referenceTimeStr + `, + "unit_count":1, + "plan":{ + "url":"u", + "accounts_url":"au", + "id":1, + "number":1, + "name":"n", + "description":"d", + "monthly_price_in_cents":1, + "yearly_price_in_cents":1, + "price_model":"pm", + "unit_name":"un", + "bullets":[ + "b" + ], + "state":"s", + "has_free_trial":false + }, + "on_free_trial":false, + "free_trial_ends_on":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + }` testJSONMarshal(t, u, want) } @@ -316,7 +356,28 @@ func TestMarketplacePendingChange_Marshal(t *testing.T) { }, } - want := `{"effective_date":` + referenceTimeStr + `,"unit_count":1,"id":1,"plan":{"url":"u","accounts_url":"au","id":1,"number":1,"name":"n","description":"d","monthly_price_in_cents":1,"yearly_price_in_cents":1,"price_model":"pm","unit_name":"un","bullets":["b"],"state":"s","has_free_trial":false}}` + want := `{ + "effective_date":` + referenceTimeStr + `, + "unit_count":1, + "id":1, + "plan":{ + "url":"u", + "accounts_url":"au", + "id":1, + "number":1, + "name":"n", + "description":"d", + "monthly_price_in_cents":1, + "yearly_price_in_cents":1, + "price_model":"pm", + "unit_name":"un", + "bullets":[ + "b" + ], + "state":"s", + "has_free_trial":false + } + }` testJSONMarshal(t, u, want) } @@ -375,7 +436,60 @@ func TestMarketplacePlanAccount_Marshal(t *testing.T) { }, } - want := `{"url":"u","type":"t","id":1,"login":"l","organization_billing_email":"obe","marketplace_purchase":{"billing_cycle":"bc","next_billing_date":` + referenceTimeStr + `,"unit_count":1,"plan":{"url":"u","accounts_url":"au","id":1,"number":1,"name":"n","description":"d","monthly_price_in_cents":1,"yearly_price_in_cents":1,"price_model":"pm","unit_name":"un","bullets":["b"],"state":"s","has_free_trial":false},"on_free_trial":false,"free_trial_ends_on":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"marketplace_pending_change":{"effective_date":` + referenceTimeStr + `,"unit_count":1,"id":1,"plan":{"url":"u","accounts_url":"au","id":1,"number":1,"name":"n","description":"d","monthly_price_in_cents":1,"yearly_price_in_cents":1,"price_model":"pm","unit_name":"un","bullets":["b"],"state":"s","has_free_trial":false}}}` + want := `{ + "url":"u", + "type":"t", + "id":1, + "login":"l", + "organization_billing_email":"obe", + "marketplace_purchase":{ + "billing_cycle":"bc", + "next_billing_date":` + referenceTimeStr + `, + "unit_count":1, + "plan":{ + "url":"u", + "accounts_url":"au", + "id":1, + "number":1, + "name":"n", + "description":"d", + "monthly_price_in_cents":1, + "yearly_price_in_cents":1, + "price_model":"pm", + "unit_name":"un", + "bullets":[ + "b" + ], + "state":"s", + "has_free_trial":false + }, + "on_free_trial":false, + "free_trial_ends_on":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + }, + "marketplace_pending_change":{ + "effective_date":` + referenceTimeStr + `, + "unit_count":1, + "id":1, + "plan":{ + "url":"u", + "accounts_url":"au", + "id":1, + "number":1, + "name":"n", + "description":"d", + "monthly_price_in_cents":1, + "yearly_price_in_cents":1, + "price_model":"pm", + "unit_name":"un", + "bullets":[ + "b" + ], + "state":"s", + "has_free_trial":false + } + } + }` testJSONMarshal(t, u, want) } diff --git a/github/apps_test.go b/github/apps_test.go index 61b881a9c63..2c22dfaaf8f 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -609,7 +609,11 @@ func TestContentReference_Marshal(t *testing.T) { Reference: String("r"), } - want := `{"id":1,"node_id":"nid","reference":"r"}` + want := `{ + "id":1, + "node_id":"nid", + "reference":"r" + }` testJSONMarshal(t, u, want) } @@ -623,7 +627,11 @@ func TestAttachment_Marshal(t *testing.T) { Body: String("b"), } - want := `{"id":1,"title":"t","body":"b"}` + want := `{ + "id":1, + "title":"t", + "body":"b" + }` testJSONMarshal(t, u, want) } @@ -666,7 +674,40 @@ func TestInstallationPermissions_Marshal(t *testing.T) { 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"}` + 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) } @@ -768,7 +809,103 @@ func TestInstallation_Marshal(t *testing.T) { 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 + `}` + 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) } @@ -814,7 +951,45 @@ func TestInstallationTokenOptions_Marshal(t *testing.T) { }, } - 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"}}` + 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) } @@ -868,7 +1043,51 @@ func TestInstallationToken_Marshal(t *testing.T) { }, } - 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,"name":"n","url":"u"}]}` + 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, + "name":"n", + "url":"u" + } + ] + }` testJSONMarshal(t, u, want) } @@ -943,7 +1162,74 @@ func TestApp_Marshal(t *testing.T) { 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"]}` + 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) } diff --git a/github/authorizations_test.go b/github/authorizations_test.go index 53a3861b3cb..bd0cd2e3ae4 100644 --- a/github/authorizations_test.go +++ b/github/authorizations_test.go @@ -216,7 +216,14 @@ func TestAuthorizationUpdateRequest_Marshal(t *testing.T) { Fingerprint: String("f"), } - want := `{"scopes":["s"],"add_scopes":["a"],"remove_scopes":["r"],"note":"n","note_url":"nu","fingerprint":"f"}` + want := `{ + "scopes":["s"], + "add_scopes":["a"], + "remove_scopes":["r"], + "note":"n", + "note_url":"nu", + "fingerprint":"f" + }` testJSONMarshal(t, u, want) } @@ -233,7 +240,14 @@ func TestAuthorizationRequest_Marshal(t *testing.T) { Fingerprint: String("f"), } - want := `{"scopes":["s"],"note":"n","note_url":"nu","client_id":"cid","client_secret":"cs","fingerprint":"f"}` + want := `{ + "scopes":["s"], + "note":"n", + "note_url":"nu", + "client_id":"cid", + "client_secret":"cs", + "fingerprint":"f" + }` testJSONMarshal(t, u, want) } @@ -247,7 +261,11 @@ func TestAuthorizationApp_Marshal(t *testing.T) { ClientID: String("cid"), } - want := `{"url":"u","name":"n","client_id":"cid"}` + want := `{ + "url":"u", + "name":"n", + "client_id":"cid" + }` testJSONMarshal(t, u, want) } @@ -268,7 +286,20 @@ func TestGrant_Marshal(t *testing.T) { Scopes: []string{"s"}, } - want := `{"id":1,"url":"u","app":{"url":"u","name":"n","client_id":"cid"},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"scopes":["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) } @@ -315,7 +346,46 @@ func TestAuthorization_Marshal(t *testing.T) { }, } - 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"}}` + 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) } diff --git a/github/billing_test.go b/github/billing_test.go index 07df6a000ad..3ff9b62b198 100644 --- a/github/billing_test.go +++ b/github/billing_test.go @@ -355,7 +355,11 @@ func TestMinutesUsedBreakdown_Marshal(t *testing.T) { "WINDOWS": 1, } - want := `{"MACOS":1,"UBUNTU":1,"WINDOWS":1}` + want := `{ + "MACOS":1, + "UBUNTU":1, + "WINDOWS":1 + }` testJSONMarshal(t, u, want) } @@ -374,13 +378,26 @@ func TestActionBilling_Marshal(t *testing.T) { }, } - want := `{"total_minutes_used":1,"total_paid_minutes_used":1,"included_minutes":1,"minutes_used_breakdown":{"MACOS":1,"UBUNTU":1,"WINDOWS":1}}` + want := `{ + "total_minutes_used":1, + "total_paid_minutes_used":1, + "included_minutes":1, + "minutes_used_breakdown":{ + "MACOS":1, + "UBUNTU":1, + "WINDOWS":1 + } + }` testJSONMarshal(t, u, want) } func TestPackageBilling_Marshal(t *testing.T) { - testJSONMarshal(t, &PackageBilling{}, `{"total_gigabytes_bandwidth_used":0,"total_paid_gigabytes_bandwidth_used":0,"included_gigabytes_bandwidth":0}`) + testJSONMarshal(t, &PackageBilling{}, `{ + "total_gigabytes_bandwidth_used":0, + "total_paid_gigabytes_bandwidth_used":0, + "included_gigabytes_bandwidth":0 + }`) u := &PackageBilling{ TotalGigabytesBandwidthUsed: 1, @@ -388,13 +405,21 @@ func TestPackageBilling_Marshal(t *testing.T) { IncludedGigabytesBandwidth: 1, } - want := `{"total_gigabytes_bandwidth_used":1,"total_paid_gigabytes_bandwidth_used":1,"included_gigabytes_bandwidth":1}` + want := `{ + "total_gigabytes_bandwidth_used":1, + "total_paid_gigabytes_bandwidth_used":1, + "included_gigabytes_bandwidth":1 + }` testJSONMarshal(t, u, want) } func TestStorageBilling_Marshal(t *testing.T) { - testJSONMarshal(t, &StorageBilling{}, `{"days_left_in_billing_cycle":0,"estimated_paid_storage_for_month":0,"estimated_storage_for_month":0}`) + testJSONMarshal(t, &StorageBilling{}, `{ + "days_left_in_billing_cycle":0, + "estimated_paid_storage_for_month":0, + "estimated_storage_for_month":0 + }`) u := &StorageBilling{ DaysLeftInBillingCycle: 1, @@ -402,7 +427,11 @@ func TestStorageBilling_Marshal(t *testing.T) { EstimatedStorageForMonth: 1, } - want := `{"days_left_in_billing_cycle":1,"estimated_paid_storage_for_month":1,"estimated_storage_for_month":1}` + want := `{ + "days_left_in_billing_cycle":1, + "estimated_paid_storage_for_month":1, + "estimated_storage_for_month":1 + }` testJSONMarshal(t, u, want) } diff --git a/github/checks_test.go b/github/checks_test.go index 94e4d9707a5..2570361d5bb 100644 --- a/github/checks_test.go +++ b/github/checks_test.go @@ -732,7 +732,92 @@ func Test_CheckRunMarshal(t *testing.T) { }, }, } - w := fmt.Sprintf(`{"id":1,"node_id":"n","head_sha":"h","external_id":"1","url":"u","html_url":"u","details_url":"u","status":"s","conclusion":"c","started_at":"%s","completed_at":"%s","output":{"title":"t","summary":"s","text":"t","annotations_count":1,"annotations_url":"a","annotations":[{"path":"p","start_line":1,"end_line":1,"annotation_level":"a","message":"m","title":"t","raw_details":"r"}],"images":[{"alt":"a","image_url":"i","caption":"c"}]},"name":"n","check_suite":{"id":1},"app":{"id":1,"node_id":"n","owner":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"name":"n","description":"d","external_url":"u","html_url":"h","created_at":"%s","updated_at":"%s"},"pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}]}`, ts, ts, ts, ts) + w := `{ + "id":1, + "node_id":"n", + "head_sha":"h", + "external_id":"1", + "url":"u", + "html_url":"u", + "details_url":"u", + "status":"s", + "conclusion":"c", + "started_at":"` + ts + `", + "completed_at":"` + ts + `", + "output":{ + "title":"t", + "summary":"s", + "text":"t", + "annotations_count":1, + "annotations_url":"a", + "annotations":[ + { + "path":"p", + "start_line":1, + "end_line":1, + "annotation_level":"a", + "message":"m", + "title":"t", + "raw_details":"r" + } + ], + "images":[ + { + "alt":"a", + "image_url":"i", + "caption":"c" + } + ] + }, + "name":"n", + "check_suite":{ + "id":1 + }, + "app":{ + "id":1, + "node_id":"n", + "owner":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "name":"n", + "description":"d", + "external_url":"u", + "html_url":"h", + "created_at":"` + ts + `", + "updated_at":"` + ts + `" + }, + "pull_requests":[ + { + "id":1, + "number":1, + "url":"u", + "head":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"s" + } + }, + "base":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"u" + } + } + } + ] + }` testJSONMarshal(t, &c, w) } @@ -805,7 +890,67 @@ func Test_CheckSuiteMarshal(t *testing.T) { }, } - w := fmt.Sprintf(`{"id":1,"node_id":"n","head_branch":"h","head_sha":"h","url":"u","before":"b","after":"a","status":"s","conclusion":"c","app":{"id":1,"node_id":"n","owner":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"name":"n","description":"d","external_url":"u","html_url":"h","created_at":"%s","updated_at":"%s"},"repository":{"id":1},"pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}],"head_commit":{"sha":"s"}}`, ts, ts) + w := `{ + "id":1, + "node_id":"n", + "head_branch":"h", + "head_sha":"h", + "url":"u", + "before":"b", + "after":"a", + "status":"s", + "conclusion":"c", + "app":{ + "id":1, + "node_id":"n", + "owner":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "name":"n", + "description":"d", + "external_url":"u", + "html_url":"h", + "created_at":"` + ts + `", + "updated_at":"` + ts + `" + }, + "repository":{ + "id":1 + }, + "pull_requests":[ + { + "id":1, + "number":1, + "url":"u", + "head":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"s" + } + }, + "base":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"u" + } + } + } + ], + "head_commit":{ + "sha":"s" + } + }` testJSONMarshal(t, &c, w) } @@ -825,7 +970,17 @@ func TestCheckRunAnnotation_Marshal(t *testing.T) { RawDetails: String("rd"), } - want := `{"path":"p","start_line":1,"end_line":1,"start_column":1,"end_column":1,"annotation_level":"al","message":"m","title":"t","raw_details":"rd"}` + want := `{ + "path":"p", + "start_line":1, + "end_line":1, + "start_column":1, + "end_column":1, + "annotation_level":"al", + "message":"m", + "title":"t", + "raw_details":"rd" + }` testJSONMarshal(t, u, want) } @@ -839,13 +994,21 @@ func TestCheckRunImage_Marshal(t *testing.T) { Caption: String("c"), } - want := `{"alt":"a","image_url":"i","caption":"c"}` + want := `{ + "alt":"a", + "image_url":"i", + "caption":"c" + }` testJSONMarshal(t, u, want) } func TestCheckRunAction_Marshal(t *testing.T) { - testJSONMarshal(t, &CheckRunAction{}, `{"label":"","description":"","identifier":""}`) + testJSONMarshal(t, &CheckRunAction{}, `{ + "label":"", + "description":"", + "identifier":"" + }`) u := &CheckRunAction{ Label: "l", @@ -853,7 +1016,11 @@ func TestCheckRunAction_Marshal(t *testing.T) { Identifier: "i", } - want := `{"label":"l","description":"d","identifier":"i"}` + want := `{ + "label":"l", + "description":"d", + "identifier":"i" + }` testJSONMarshal(t, u, want) } @@ -866,7 +1033,10 @@ func TestAutoTriggerCheck_Marshal(t *testing.T) { Setting: Bool(false), } - want := `{"app_id":1,"setting":false}` + want := `{ + "app_id":1, + "setting":false + }` testJSONMarshal(t, u, want) } @@ -879,7 +1049,10 @@ func TestCreateCheckSuiteOptions_Marshal(t *testing.T) { HeadBranch: String("hb"), } - want := `{"head_sha":"hsha","head_branch":"hb"}` + want := `{ + "head_sha":"hsha", + "head_branch":"hb" + }` testJSONMarshal(t, u, want) } @@ -915,7 +1088,33 @@ func TestCheckRunOutput_Marshal(t *testing.T) { }, } - want := `{"title":"ti","summary":"s","text":"t","annotations_count":1,"annotations_url":"au","annotations":[{"path":"p","start_line":1,"end_line":1,"start_column":1,"end_column":1,"annotation_level":"al","message":"m","title":"t","raw_details":"rd"}],"images":[{"alt":"a","image_url":"i","caption":"c"}]}` + want := `{ + "title":"ti", + "summary":"s", + "text":"t", + "annotations_count":1, + "annotations_url":"au", + "annotations":[ + { + "path":"p", + "start_line":1, + "end_line":1, + "start_column":1, + "end_column":1, + "annotation_level":"al", + "message":"m", + "title":"t", + "raw_details":"rd" + } + ], + "images":[ + { + "alt":"a", + "image_url":"i", + "caption":"c" + } + ] + }` testJSONMarshal(t, u, want) } @@ -968,7 +1167,50 @@ func TestCreateCheckRunOptions_Marshal(t *testing.T) { }, } - want := `{"name":"n","head_sha":"hsha","details_url":"durl","external_id":"eid","status":"s","conclusion":"c","started_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `,"output":{"title":"ti","summary":"s","text":"t","annotations_count":1,"annotations_url":"au","annotations":[{"path":"p","start_line":1,"end_line":1,"start_column":1,"end_column":1,"annotation_level":"al","message":"m","title":"t","raw_details":"rd"}],"images":[{"alt":"a","image_url":"i","caption":"c"}]},"actions":[{"label":"l","description":"d","identifier":"i"}]}` + want := `{ + "name":"n", + "head_sha":"hsha", + "details_url":"durl", + "external_id":"eid", + "status":"s", + "conclusion":"c", + "started_at":` + referenceTimeStr + `, + "completed_at":` + referenceTimeStr + `, + "output":{ + "title":"ti", + "summary":"s", + "text":"t", + "annotations_count":1, + "annotations_url":"au", + "annotations":[ + { + "path":"p", + "start_line":1, + "end_line":1, + "start_column":1, + "end_column":1, + "annotation_level":"al", + "message":"m", + "title":"t", + "raw_details":"rd" + } + ], + "images":[ + { + "alt":"a", + "image_url":"i", + "caption":"c" + } + ] + }, + "actions":[ + { + "label":"l", + "description":"d", + "identifier":"i" + } + ] + }` testJSONMarshal(t, u, want) } @@ -1019,7 +1261,48 @@ func TestUpdateCheckRunOptions_Marshal(t *testing.T) { }, } - want := `{"name":"n","details_url":"durl","external_id":"eid","status":"s","conclusion":"c","completed_at":` + referenceTimeStr + `,"output":{"title":"ti","summary":"s","text":"t","annotations_count":1,"annotations_url":"au","annotations":[{"path":"p","start_line":1,"end_line":1,"start_column":1,"end_column":1,"annotation_level":"al","message":"m","title":"t","raw_details":"rd"}],"images":[{"alt":"a","image_url":"i","caption":"c"}]},"actions":[{"label":"l","description":"d","identifier":"i"}]}` + want := `{ + "name":"n", + "details_url":"durl", + "external_id":"eid", + "status":"s", + "conclusion":"c", + "completed_at":` + referenceTimeStr + `, + "output":{ + "title":"ti", + "summary":"s", + "text":"t", + "annotations_count":1, + "annotations_url":"au", + "annotations":[ + { + "path":"p", + "start_line":1, + "end_line":1, + "start_column":1, + "end_column":1, + "annotation_level":"al", + "message":"m", + "title":"t", + "raw_details":"rd" + } + ], + "images":[ + { + "alt":"a", + "image_url":"i", + "caption":"c" + } + ] + }, + "actions":[ + { + "label":"l", + "description":"d", + "identifier":"i" + } + ] + }` testJSONMarshal(t, u, want) } @@ -1119,7 +1402,97 @@ func TestListCheckRunsResults_Marshal(t *testing.T) { }, } - w := `{"total_count":1,"check_runs":[{"id":1,"node_id":"n","head_sha":"h","external_id":"1","url":"u","html_url":"u","details_url":"u","status":"s","conclusion":"c","started_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `,"output":{"title":"t","summary":"s","text":"t","annotations_count":1,"annotations_url":"a","annotations":[{"path":"p","start_line":1,"end_line":1,"annotation_level":"a","message":"m","title":"t","raw_details":"r"}],"images":[{"alt":"a","image_url":"i","caption":"c"}]},"name":"n","check_suite":{"id":1},"app":{"id":1,"node_id":"n","owner":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"name":"n","description":"d","external_url":"u","html_url":"h","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}]}]}` + w := `{ + "total_count":1, + "check_runs":[ + { + "id":1, + "node_id":"n", + "head_sha":"h", + "external_id":"1", + "url":"u", + "html_url":"u", + "details_url":"u", + "status":"s", + "conclusion":"c", + "started_at":` + referenceTimeStr + `, + "completed_at":` + referenceTimeStr + `, + "output":{ + "title":"t", + "summary":"s", + "text":"t", + "annotations_count":1, + "annotations_url":"a", + "annotations":[ + { + "path":"p", + "start_line":1, + "end_line":1, + "annotation_level":"a", + "message":"m", + "title":"t", + "raw_details":"r" + } + ], + "images":[ + { + "alt":"a", + "image_url":"i", + "caption":"c" + } + ] + }, + "name":"n", + "check_suite":{ + "id":1 + }, + "app":{ + "id":1, + "node_id":"n", + "owner":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "name":"n", + "description":"d", + "external_url":"u", + "html_url":"h", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + }, + "pull_requests":[ + { + "id":1, + "number":1, + "url":"u", + "head":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"s" + } + }, + "base":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"u" + } + } + } + ] + } + ] + }` testJSONMarshal(t, &l, w) } @@ -1194,7 +1567,72 @@ func TestListCheckSuiteResults_Marshal(t *testing.T) { }, } - w := `{"total_count":1,"check_suites":[{"id":1,"node_id":"n","head_branch":"h","head_sha":"h","url":"u","before":"b","after":"a","status":"s","conclusion":"c","app":{"id":1,"node_id":"n","owner":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"name":"n","description":"d","external_url":"u","html_url":"h","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"repository":{"id":1},"pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}],"head_commit":{"sha":"s"}}]}` + w := `{ + "total_count":1, + "check_suites":[ + { + "id":1, + "node_id":"n", + "head_branch":"h", + "head_sha":"h", + "url":"u", + "before":"b", + "after":"a", + "status":"s", + "conclusion":"c", + "app":{ + "id":1, + "node_id":"n", + "owner":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "name":"n", + "description":"d", + "external_url":"u", + "html_url":"h", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + }, + "repository":{ + "id":1 + }, + "pull_requests":[ + { + "id":1, + "number":1, + "url":"u", + "head":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"s" + } + }, + "base":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"u" + } + } + } + ], + "head_commit":{ + "sha":"s" + } + } + ] + }` testJSONMarshal(t, &l, w) } @@ -1211,7 +1649,14 @@ func TestCheckSuitePreferenceOptions_Marshal(t *testing.T) { }, } - want := `{"auto_trigger_checks":[{"app_id":1,"setting":false}]}` + want := `{ + "auto_trigger_checks":[ + { + "app_id":1, + "setting":false + } + ] + }` testJSONMarshal(t, u, want) } @@ -1228,7 +1673,14 @@ func TestPreferenceList_Marshal(t *testing.T) { }, } - want := `{"auto_trigger_checks":[{"app_id":1,"setting":false}]}` + want := `{ + "auto_trigger_checks":[ + { + "app_id":1, + "setting":false + } + ] + }` testJSONMarshal(t, u, want) } @@ -1252,7 +1704,21 @@ func TestCheckSuitePreferenceResults_Marshal(t *testing.T) { }, } - want := `{"preferences":{"auto_trigger_checks":[{"app_id":1,"setting":false}]},"repository":{"id":1,"name":"n","url":"u"}}` + want := `{ + "preferences":{ + "auto_trigger_checks":[ + { + "app_id":1, + "setting":false + } + ] + }, + "repository":{ + "id":1, + "name":"n", + "url":"u" + } + }` testJSONMarshal(t, u, want) } diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 0228cf318eb..0b9e06636a3 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -868,7 +868,30 @@ func TestAlert_Marshal(t *testing.T) { HTMLURL: String("hurl"), } - want := `{"rule_id":"rid","rule_severity":"rs","rule_description":"rd","tool":{"name":"n","guid":"g","version":"v"},"created_at":` + referenceTimeStr + `,"state":"fixed","closed_by":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"closed_at":` + referenceTimeStr + `,"url":"url","html_url":"hurl"}` + want := `{ + "rule_id":"rid", + "rule_severity":"rs", + "rule_description":"rd", + "tool":{ + "name":"n", + "guid":"g", + "version":"v" + }, + "created_at":` + referenceTimeStr + `, + "state":"fixed", + "closed_by":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "closed_at":` + referenceTimeStr + `, + "url":"url", + "html_url":"hurl" + }` testJSONMarshal(t, u, want) } @@ -884,7 +907,13 @@ func TestLocation_Marshal(t *testing.T) { EndColumn: Int(4), } - want := `{"path":"path","start_line":1,"end_line":2,"start_column":3,"end_column":4}` + want := `{ + "path":"path", + "start_line":1, + "end_line":2, + "start_column":3, + "end_column":4 + }` testJSONMarshal(t, u, want) } @@ -903,7 +932,19 @@ func TestRule_Marshal(t *testing.T) { Help: String("Help Text"), } - want := `{"id":"1","severity":"3","description":"description","name":"first","security_severity_level":"2","full_description":"summary","tags":["tag1","tag2"],"help":"Help Text"}` + want := `{ + "id":"1", + "severity":"3", + "description":"description", + "name":"first", + "security_severity_level":"2", + "full_description":"summary", + "tags":[ + "tag1", + "tag2" + ], + "help":"Help Text" + }` testJSONMarshal(t, u, want) } @@ -917,7 +958,11 @@ func TestTool_Marshal(t *testing.T) { Version: String("ver"), } - want := `{"name":"name","guid":"guid","version":"ver"}` + want := `{ + "name":"name", + "guid":"guid", + "version":"ver" + }` testJSONMarshal(t, u, want) } diff --git a/github/event_test.go b/github/event_test.go index 604afa62d54..c4de41505d1 100644 --- a/github/event_test.go +++ b/github/event_test.go @@ -82,7 +82,51 @@ func TestEvent_Marshal(t *testing.T) { ID: String("id"), } - want := `{"type":"t","public":false,"payload":{"key":"value"},"repo":{"id":1,"name":"n","url":"s"},"actor":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"org":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"created_at":` + referenceTimeStr + `,"id":"id"}` + want := `{ + "type":"t", + "public":false, + "payload":{ + "key":"value" + }, + "repo":{ + "id":1, + "name":"n", + "url":"s" + }, + "actor":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "org":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "created_at":` + referenceTimeStr + `, + "id":"id" + }` testJSONMarshal(t, u, want) } diff --git a/github/event_types_test.go b/github/event_types_test.go index 78c5ccbd52a..d2eb1b4d723 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -21,7 +21,11 @@ func TestEditChange_Marshal_TitleChange(t *testing.T) { Base: nil, } - want := `{"title":{"from":"TitleFrom"}}` + want := `{ + "title":{ + "from":"TitleFrom" + } + }` testJSONMarshal(t, u, want) } @@ -37,7 +41,11 @@ func TestEditChange_Marshal_BodyChange(t *testing.T) { Base: nil, } - want := `{"body":{"from":"BodyFrom"}}` + want := `{ + "body":{ + "from":"BodyFrom" + } + }` testJSONMarshal(t, u, want) } @@ -60,7 +68,16 @@ func TestEditChange_Marshal_BaseChange(t *testing.T) { Base: &Base, } - want := `{"base":{"ref":{"from":"BaseRefFrom"},"sha":{"from":"BaseSHAFrom"}}}` + want := `{ + "base":{ + "ref":{ + "from":"BaseRefFrom" + }, + "sha":{ + "from":"BaseSHAFrom" + } + } + }` testJSONMarshal(t, u, want) } @@ -76,7 +93,13 @@ func TestEditChange_Marshal_Repo(t *testing.T) { }, } - want := `{"repository":{"name":{"from":"old-repo-name"}}}` + want := `{ + "repository":{ + "name":{ + "from":"old-repo-name" + } + } + }` testJSONMarshal(t, u, want) } @@ -89,7 +112,11 @@ func TestProjectChange_Marshal_NameChange(t *testing.T) { Body: nil, } - want := `{"name":{"from":"NameFrom"}}` + want := `{ + "name":{ + "from":"NameFrom" + } + }` testJSONMarshal(t, u, want) } @@ -102,7 +129,11 @@ func TestProjectChange_Marshal_BodyChange(t *testing.T) { Body: &ProjectBody{From: String("BodyFrom")}, } - want := `{"body":{"from":"BodyFrom"}}` + want := `{ + "body":{ + "from":"BodyFrom" + } + }` testJSONMarshal(t, u, want) } @@ -114,7 +145,11 @@ func TestProjectCardChange_Marshal_NoteChange(t *testing.T) { Note: &ProjectCardNote{From: String("NoteFrom")}, } - want := `{"note":{"from":"NoteFrom"}}` + want := `{ + "note":{ + "from":"NoteFrom" + } + }` testJSONMarshal(t, u, want) } @@ -126,7 +161,11 @@ func TestProjectColumnChange_Marshal_NameChange(t *testing.T) { Name: &ProjectColumnName{From: String("NameFrom")}, } - want := `{"name":{"from":"NameFrom"}}` + want := `{ + "name":{ + "from":"NameFrom" + } + }` testJSONMarshal(t, u, want) } @@ -305,7 +344,180 @@ func TestTeamAddEvent_Marshal(t *testing.T) { }, } - want := `{"team":{"id":1,"node_id":"n","name":"n","description":"d","url":"u","slug":"s","permission":"p","privacy":"p","members_count":1,"repos_count":1,"organization":{"login":"l","id":1,"node_id":"n","avatar_url":"a","html_url":"h","name":"n","company":"c","blog":"b","location":"l","email":"e"},"members_url":"m","repositories_url":"r","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"},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "team":{ + "id":1, + "node_id":"n", + "name":"n", + "description":"d", + "url":"u", + "slug":"s", + "permission":"p", + "privacy":"p", + "members_count":1, + "repos_count":1, + "organization":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "html_url":"h", + "name":"n", + "company":"c", + "blog":"b", + "location":"l", + "email":"e" + }, + "members_url":"m", + "repositories_url":"r", + "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" + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -354,7 +566,46 @@ func TestStarEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","starred_at":` + referenceTimeStr + `,"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` + want := `{ + "action":"a", + "starred_at":` + referenceTimeStr + `, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + } + }` testJSONMarshal(t, u, want) } @@ -554,7 +805,201 @@ func TestTeamEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","team":{"id":1,"node_id":"n","name":"n","description":"d","url":"u","slug":"s","permission":"p","privacy":"p","members_count":1,"repos_count":1,"organization":{"login":"l","id":1,"node_id":"n","avatar_url":"a","html_url":"h","name":"n","company":"c","blog":"b","location":"l","email":"e"},"members_url":"m","repositories_url":"r","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"},"changes":{"description":{"from":"from"},"name":{"from":"from"},"privacy":{"from":"from"},"repository":{"permissions":{"from":{"admin":true,"pull":true,"push":true}}}},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "team":{ + "id":1, + "node_id":"n", + "name":"n", + "description":"d", + "url":"u", + "slug":"s", + "permission":"p", + "privacy":"p", + "members_count":1, + "repos_count":1, + "organization":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "html_url":"h", + "name":"n", + "company":"c", + "blog":"b", + "location":"l", + "email":"e" + }, + "members_url":"m", + "repositories_url":"r", + "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" + }, + "changes":{ + "description":{ + "from":"from" + }, + "name":{ + "from":"from" + }, + "privacy":{ + "from":"from" + }, + "repository":{ + "permissions":{ + "from":{ + "admin":true, + "pull":true, + "push":true + } + } + } + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -683,7 +1128,130 @@ func TestInstallationRepositoriesEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","repositories_added":[{"id":1,"name":"n","url":"s"}],"repositories_removed":[{"id":1,"name":"n","url":"s"}],"repository_selection":"rs","sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "repositories_added":[ + { + "id":1, + "name":"n", + "url":"s" + } + ], + "repositories_removed":[ + { + "id":1, + "name":"n", + "url":"s" + } + ], + "repository_selection":"rs", + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -724,7 +1292,14 @@ func TestEditBase_Marshal(t *testing.T) { }, } - want := `{"ref":{"from":"EditRefFrom"},"sha":{"from":"EditSHAFrom"}}` + want := `{ + "ref":{ + "from":"EditRefFrom" + }, + "sha":{ + "from":"EditSHAFrom" + } + }` testJSONMarshal(t, u, want) } @@ -850,7 +1425,15 @@ func TestTeamRepository_Marshal(t *testing.T) { }, } - want := `{"permissions":{"from":{"admin":true,"pull":true,"push":true}}}` + want := `{ + "permissions":{ + "from":{ + "admin":true, + "pull":true, + "push":true + } + } + }` testJSONMarshal(t, u, want) } @@ -866,7 +1449,13 @@ func TestTeamPermissions_Marshal(t *testing.T) { }, } - want := `{"from":{"admin":true,"pull":true,"push":true}}` + want := `{ + "from":{ + "admin":true, + "pull":true, + "push":true + } + }` testJSONMarshal(t, u, want) } @@ -880,7 +1469,11 @@ func TestTeamPermissionsFrom_Marshal(t *testing.T) { Push: Bool(true), } - want := `{"admin":true,"pull":true,"push":true}` + want := `{ + "admin":true, + "pull":true, + "push":true + }` testJSONMarshal(t, u, want) } @@ -908,7 +1501,25 @@ func TestRepositoryVulnerabilityAlert_Marshal(t *testing.T) { DismissedAt: &Timestamp{referenceTime}, } - want := `{"id":1,"affected_range":"ar","affected_package_name":"apn","external_reference":"er","external_identifier":"ei","fixed_in":"fi","dismisser":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"dismiss_reason":"dr","dismissed_at":` + referenceTimeStr + `}` + want := `{ + "id":1, + "affected_range":"ar", + "affected_package_name":"apn", + "external_reference":"er", + "external_identifier":"ei", + "fixed_in":"fi", + "dismisser":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "dismiss_reason":"dr", + "dismissed_at":` + referenceTimeStr + ` + }` testJSONMarshal(t, u, want) } @@ -925,7 +1536,14 @@ func TestPage_Marshal(t *testing.T) { HTMLURL: String("h"), } - want := `{"page_name":"p","title":"t","summary":"s","action":"a","sha":"s","html_url":"h"}` + want := `{ + "page_name":"p", + "title":"t", + "summary":"s", + "action":"a", + "sha":"s", + "html_url":"h" + }` testJSONMarshal(t, u, want) } @@ -954,7 +1572,26 @@ func TestTeamChange_Marshal(t *testing.T) { }, } - want := `{"description":{"from":"DescriptionFrom"},"name":{"from":"NameFrom"},"privacy":{"from":"PrivacyFrom"},"repository":{"permissions":{"from":{"admin":false,"pull":false,"push":false}}}}` + want := `{ + "description":{ + "from":"DescriptionFrom" + }, + "name":{ + "from":"NameFrom" + }, + "privacy":{ + "from":"PrivacyFrom" + }, + "repository":{ + "permissions":{ + "from":{ + "admin":false, + "pull":false, + "push":false + } + } + } + }` testJSONMarshal(t, u, want) } @@ -1113,7 +1750,164 @@ func TestIssueCommentEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","issue":{"id":1},"comment":{"id":1},"changes":{"title":{"from":"TitleFrom"},"body":{"from":"BodyFrom"},"base":{"ref":{"from":"BaseRefFrom"},"sha":{"from":"BaseSHAFrom"}}},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true}}` + want := `{ + "action":"a", + "issue":{ + "id":1 + }, + "comment":{ + "id":1 + }, + "changes":{ + "title":{ + "from":"TitleFrom" + }, + "body":{ + "from":"BodyFrom" + }, + "base":{ + "ref":{ + "from":"BaseRefFrom" + }, + "sha":{ + "from":"BaseSHAFrom" + } + } + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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 + ` + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + } + }` testJSONMarshal(t, u, want) } @@ -1259,7 +2053,151 @@ func TestIssuesEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","issue":{"id":1},"assignee":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"label":{"id":1},"changes":{"title":{"from":"TitleFrom"},"body":{"from":"BodyFrom"},"base":{"ref":{"from":"BaseRefFrom"},"sha":{"from":"BaseSHAFrom"}}},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "issue":{ + "id":1 + }, + "assignee":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "label":{ + "id":1 + }, + "changes":{ + "title":{ + "from":"TitleFrom" + }, + "body":{ + "from":"BodyFrom" + }, + "base":{ + "ref":{ + "from":"BaseRefFrom" + }, + "sha":{ + "from":"BaseSHAFrom" + } + } + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -1408,7 +2346,152 @@ func TestLabelEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","label":{"id":1},"changes":{"title":{"from":"TitleFrom"},"body":{"from":"BodyFrom"},"base":{"ref":{"from":"BaseRefFrom"},"sha":{"from":"BaseSHAFrom"}}},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"installation":{"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 + `}}` + want := `{ + "action":"a", + "label":{ + "id":1 + }, + "changes":{ + "title":{ + "from":"TitleFrom" + }, + "body":{ + "from":"BodyFrom" + }, + "base":{ + "ref":{ + "from":"BaseRefFrom" + }, + "sha":{ + "from":"BaseSHAFrom" + } + } + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "installation":{ + "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) } @@ -1566,7 +2649,161 @@ func TestMilestoneEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","milestone":{"id":1},"changes":{"title":{"from":"TitleFrom"},"body":{"from":"BodyFrom"},"base":{"ref":{"from":"BaseRefFrom"},"sha":{"from":"BaseSHAFrom"}}},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"installation":{"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 + `}}` + want := `{ + "action":"a", + "milestone":{ + "id":1 + }, + "changes":{ + "title":{ + "from":"TitleFrom" + }, + "body":{ + "from":"BodyFrom" + }, + "base":{ + "ref":{ + "from":"BaseRefFrom" + }, + "sha":{ + "from":"BaseSHAFrom" + } + } + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "installation":{ + "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) } @@ -1684,7 +2921,119 @@ func TestPublicEvent_Marshal(t *testing.T) { }, } - want := `{"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -1827,7 +3176,148 @@ func TestPullRequestReviewEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","review":{"id":1},"pull_request":{"id":1},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true}}` + want := `{ + "action":"a", + "review":{ + "id":1 + }, + "pull_request":{ + "id":1 + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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 + ` + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + } + }` testJSONMarshal(t, u, want) } @@ -1988,7 +3478,168 @@ func TestPushEvent_Marshal(t *testing.T) { }, } - want := `{"push_id":1,"head":"h","ref":"ref","size":1,"commits":[{"id":"id"}],"before":"b","distinct_size":1,"after":"a","created":true,"deleted":true,"forced":true,"base_ref":"a","compare":"a","repository":{"id":1},"head_commit":{"id":"id"},"pusher":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true}}` + want := `{ + "push_id":1, + "head":"h", + "ref":"ref", + "size":1, + "commits":[ + { + "id":"id" + } + ], + "before":"b", + "distinct_size":1, + "after":"a", + "created":true, + "deleted":true, + "forced":true, + "base_ref":"a", + "compare":"a", + "repository":{ + "id":1 + }, + "head_commit":{ + "id":"id" + }, + "pusher":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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 + ` + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + } + }` testJSONMarshal(t, u, want) } @@ -2118,7 +3769,135 @@ func TestStatusEvent_Marshal(t *testing.T) { }, } - want := `{"sha":"sha","state":"s","description":"d","target_url":"turl","branches":[{"name":"n","commit":{"node_id":"nid"},"protected":false}],"id":1,"name":"n","context":"c","commit":{"node_id":"nid"},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "sha":"sha", + "state":"s", + "description":"d", + "target_url":"turl", + "branches":[ + { + "name":"n", + "commit":{ + "node_id":"nid" + }, + "protected":false + } + ], + "id":1, + "name":"n", + "context":"c", + "commit":{ + "node_id":"nid" + }, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -2279,7 +4058,166 @@ func TestMarketplacePurchaseEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","effective_date":` + referenceTimeStr + `,"marketplace_purchase":{"billing_cycle":"bc","next_billing_date":` + referenceTimeStr + `,"unit_count":1,"plan":{"url":"u","accounts_url":"au","id":1,"number":1,"name":"n","description":"d","monthly_price_in_cents":1,"yearly_price_in_cents":1,"price_model":"pm","unit_name":"un","bullets":["b"],"state":"s","has_free_trial":false},"on_free_trial":false,"free_trial_ends_on":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"previous_marketplace_purchase":{"billing_cycle":"bc","next_billing_date":` + referenceTimeStr + `,"unit_count":1,"plan":{"url":"u","accounts_url":"au","id":1,"number":1,"name":"n","description":"d","monthly_price_in_cents":1,"yearly_price_in_cents":1,"price_model":"pm","unit_name":"un","bullets":["b"],"state":"s","has_free_trial":false},"on_free_trial":false,"free_trial_ends_on":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "effective_date":` + referenceTimeStr + `, + "marketplace_purchase":{ + "billing_cycle":"bc", + "next_billing_date":` + referenceTimeStr + `, + "unit_count":1, + "plan":{ + "url":"u", + "accounts_url":"au", + "id":1, + "number":1, + "name":"n", + "description":"d", + "monthly_price_in_cents":1, + "yearly_price_in_cents":1, + "price_model":"pm", + "unit_name":"un", + "bullets":[ + "b" + ], + "state":"s", + "has_free_trial":false + }, + "on_free_trial":false, + "free_trial_ends_on":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + }, + "previous_marketplace_purchase":{ + "billing_cycle":"bc", + "next_billing_date":` + referenceTimeStr + `, + "unit_count":1, + "plan":{ + "url":"u", + "accounts_url":"au", + "id":1, + "number":1, + "name":"n", + "description":"d", + "monthly_price_in_cents":1, + "yearly_price_in_cents":1, + "price_model":"pm", + "unit_name":"un", + "bullets":[ + "b" + ], + "state":"s", + "has_free_trial":false + }, + "on_free_trial":false, + "free_trial_ends_on":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -2453,7 +4391,177 @@ func TestOrganizationEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","invitation":{"id":1},"membership":{"url":"url","state":"s","role":"r","organization_url":"ou","organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"user":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "invitation":{ + "id":1 + }, + "membership":{ + "url":"url", + "state":"s", + "role":"r", + "organization_url":"ou", + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "user":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + } + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -2573,7 +4681,123 @@ func TestPageBuildEvent_Marshal(t *testing.T) { }, } - want := `{"build":{"url":"url"},"id":1,"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "build":{ + "url":"url" + }, + "id":1, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -2725,7 +4949,153 @@ func TestCommitCommentEvent_Marshal(t *testing.T) { }, } - want := `{"comment":{"html_url":"hurl","url":"url","id":1,"node_id":"nid","commit_id":"cid","user":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"reactions":{"total_count":1,"+1":1,"-1":1,"laugh":1,"confused":1,"heart":1,"hooray":1,"rocket":1,"eyes":1,"url":"url"},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"body":"b","path":"path","position":1},"action":"a","repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "comment":{ + "html_url":"hurl", + "url":"url", + "id":1, + "node_id":"nid", + "commit_id":"cid", + "user":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "reactions":{ + "total_count":1, + "+1":1, + "-1":1, + "laugh":1, + "confused":1, + "heart":1, + "hooray":1, + "rocket":1, + "eyes":1, + "url":"url" + }, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "body":"b", + "path":"path", + "position":1 + }, + "action":"a", + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -2872,7 +5242,145 @@ func TestDeploymentEvent_Marshal(t *testing.T) { }, } - want := `{"deployment":{"url":"url","id":1,"sha":"sha","ref":"ref","task":"t","payload":{"key":"value"},"environment":"e","description":"d","creator":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"statuses_url":"surl","repository_url":"rurl","node_id":"nid"},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "deployment":{ + "url":"url", + "id":1, + "sha":"sha", + "ref":"ref", + "task":"t", + "payload":{ + "key":"value" + }, + "environment":"e", + "description":"d", + "creator":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "statuses_url":"surl", + "repository_url":"rurl", + "node_id":"nid" + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -3043,7 +5551,169 @@ func TestDeploymentStatusEvent_Marshal(t *testing.T) { }, } - want := `{"deployment":{"url":"url","id":1,"sha":"sha","ref":"ref","task":"t","payload":{"key":"value"},"environment":"e","description":"d","creator":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"statuses_url":"surl","repository_url":"rurl","node_id":"nid"},"deployment_status":{"id":1,"state":"s","creator":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"description":"s","environment":"s","node_id":"s","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"target_url":"s","deployment_url":"s","repository_url":"s","environment_url":"s","log_url":"s","url":"s"},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "deployment":{ + "url":"url", + "id":1, + "sha":"sha", + "ref":"ref", + "task":"t", + "payload":{ + "key":"value" + }, + "environment":"e", + "description":"d", + "creator":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "statuses_url":"surl", + "repository_url":"rurl", + "node_id":"nid" + }, + "deployment_status":{ + "id":1, + "state":"s", + "creator":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "description":"s", + "environment":"s", + "node_id":"s", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "target_url":"s", + "deployment_url":"s", + "repository_url":"s", + "environment_url":"s", + "log_url":"s", + "url":"s" + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -3253,7 +5923,211 @@ func TestDiscussionCommentEvent_Marshal(t *testing.T) { }, } - want := `{"discussion":{"repository_url":"rurl","category":{"id":1,"node_id":"nid","repository_id":1,"emoji":"emoji","name":"name","description":"description","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"slug":"slug","is_answerable":false},"html_url":"hurl","id":1,"node_id":"nurl","number":1,"title":"title","user":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"state":"st","locked":false,"comments":1,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"author_association":"aa","body":"bo"},"comment":{"author_association":"aa","body":"bo","child_comment_count":1,"created_at":` + referenceTimeStr + `,"discussion_id":1,"html_url":"hurl","id":1,"node_id":"nid","parent_id":1,"reactions":{"total_count":1,"+1":1,"-1":1,"laugh":1,"confused":1,"heart":1,"hooray":1,"rocket":1,"eyes":1,"url":"url"},"repository_url":"rurl","updated_at":` + referenceTimeStr + `,"user":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "discussion":{ + "repository_url":"rurl", + "category":{ + "id":1, + "node_id":"nid", + "repository_id":1, + "emoji":"emoji", + "name":"name", + "description":"description", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "slug":"slug", + "is_answerable":false + }, + "html_url":"hurl", + "id":1, + "node_id":"nurl", + "number":1, + "title":"title", + "user":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "state":"st", + "locked":false, + "comments":1, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "author_association":"aa", + "body":"bo" + }, + "comment":{ + "author_association":"aa", + "body":"bo", + "child_comment_count":1, + "created_at":` + referenceTimeStr + `, + "discussion_id":1, + "html_url":"hurl", + "id":1, + "node_id":"nid", + "parent_id":1, + "reactions":{ + "total_count":1, + "+1":1, + "-1":1, + "laugh":1, + "confused":1, + "heart":1, + "hooray":1, + "rocket":1, + "eyes":1, + "url":"url" + }, + "repository_url":"rurl", + "updated_at":` + referenceTimeStr + `, + "user":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + } + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -3429,7 +6303,177 @@ func TestDiscussionEvent_Marshal(t *testing.T) { }, } - want := `{"discussion":{"repository_url":"rurl","category":{"id":1,"node_id":"nid","repository_id":1,"emoji":"emoji","name":"name","description":"description","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"slug":"slug","is_answerable":false},"html_url":"hurl","id":1,"node_id":"nurl","number":1,"title":"title","user":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"state":"st","locked":false,"comments":1,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"author_association":"aa","body":"bo"},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "discussion":{ + "repository_url":"rurl", + "category":{ + "id":1, + "node_id":"nid", + "repository_id":1, + "emoji":"emoji", + "name":"name", + "description":"description", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "slug":"slug", + "is_answerable":false + }, + "html_url":"hurl", + "id":1, + "node_id":"nurl", + "number":1, + "title":"title", + "user":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "state":"st", + "locked":false, + "comments":1, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "author_association":"aa", + "body":"bo" + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -3496,7 +6540,68 @@ func TestPackageEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","package":{"id":1,"name":"n","package_type":"pt","html_url":"hurl","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"owner":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"package_version":{"id":1},"registry":{"name":"n"}},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` + want := `{ + "action":"a", + "package":{ + "id":1, + "name":"n", + "package_type":"pt", + "html_url":"hurl", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "owner":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "package_version":{ + "id":1 + }, + "registry":{ + "name":"n" + } + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + } + }` testJSONMarshal(t, u, want) } @@ -3619,7 +6724,127 @@ func TestPingEvent_Marshal(t *testing.T) { }, } - want := `{"zen":"z","hook_id":1,"hook":{"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"url":"url","id":1,"type":"t","name":"n","test_url":"tu","ping_url":"pu","last_response":{"key":"value"},"config":{"key":"value"},"events":["a"],"active":true},"installation":{"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 + `}}` + want := `{ + "zen":"z", + "hook_id":1, + "hook":{ + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "url":"url", + "id":1, + "type":"t", + "name":"n", + "test_url":"tu", + "ping_url":"pu", + "last_response":{ + "key":"value" + }, + "config":{ + "key":"value" + }, + "events":[ + "a" + ], + "active":true + }, + "installation":{ + "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) } @@ -3768,7 +6993,146 @@ func TestRepositoryDispatchEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","branch":"b","client_payload":{"key":"value"},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "branch":"b", + "client_payload":{ + "key":"value" + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -3816,7 +7180,45 @@ func TestRepositoryImportEvent_Marshal(t *testing.T) { }, } - want := `{"status":"success","repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` + want := `{ + "status":"success", + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + } + }` testJSONMarshal(t, u, want) } @@ -3957,7 +7359,142 @@ func TestRepositoryEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -4092,7 +7629,142 @@ func TestReleaseEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","release":{"name":"n","discussion_category_name":"dcn","id":2,"created_at":` + referenceTimeStr + `,"published_at":` + referenceTimeStr + `,"url":"url","html_url":"htmlurl","assets_url":"assetsurl","assets":[{"id":1}],"upload_url":"uploadurl","zipball_url":"zipballurl","tarball_url":"tarballurl","author":{"name":"octocat"},"node_id":"nid"},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "release":{ + "name":"n", + "discussion_category_name":"dcn", + "id":2, + "created_at":` + referenceTimeStr + `, + "published_at":` + referenceTimeStr + `, + "url":"url", + "html_url":"htmlurl", + "assets_url":"assetsurl", + "assets":[ + { + "id":1 + } + ], + "upload_url":"uploadurl", + "zipball_url":"zipballurl", + "tarball_url":"tarballurl", + "author":{ + "name":"octocat" + }, + "node_id":"nid" + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -4216,7 +7888,125 @@ func TestContentReferenceEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","content_reference":{"id":1,"node_id":"nid","reference":"ref"},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "content_reference":{ + "id":1, + "node_id":"nid", + "reference":"ref" + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -4344,7 +8134,129 @@ func TestMemberEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","member":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "member":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -4529,7 +8441,186 @@ func TestMembershipEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","scope":"s","member":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"team":{"id":1,"node_id":"n","name":"n","description":"d","url":"u","slug":"s","permission":"p","privacy":"p","members_count":1,"repos_count":1,"organization":{"login":"l","id":1,"node_id":"n","avatar_url":"a","html_url":"h","name":"n","company":"c","blog":"b","location":"l","email":"e"},"members_url":"m","repositories_url":"r","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"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "scope":"s", + "member":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "team":{ + "id":1, + "node_id":"n", + "name":"n", + "description":"d", + "url":"u", + "slug":"s", + "permission":"p", + "privacy":"p", + "members_count":1, + "repos_count":1, + "organization":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "html_url":"h", + "name":"n", + "company":"c", + "blog":"b", + "location":"l", + "email":"e" + }, + "members_url":"m", + "repositories_url":"r", + "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" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -4677,7 +8768,151 @@ func TestMergeGroupEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","merge_group":{"head_sha":"hs","head_ref":"hr","base_sha":"bs","base_ref":"br","head_commit":{"node_id":"nid"}},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"installation":{"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 + `},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` + want := `{ + "action":"a", + "merge_group":{ + "head_sha":"hs", + "head_ref":"hr", + "base_sha":"bs", + "base_ref":"br", + "head_commit":{ + "node_id":"nid" + } + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "installation":{ + "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 + ` + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + } + }` testJSONMarshal(t, u, want) } @@ -4822,7 +9057,146 @@ func TestOrgBlockEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","blocked_user":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "blocked_user":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -4950,7 +9324,129 @@ func TestGollumEvent_Marshal(t *testing.T) { }, } - want := `{"pages":[{"page_name":"pn","title":"t","summary":"s","action":"a","sha":"sha","html_url":"hu"}],"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "pages":[ + { + "page_name":"pn", + "title":"t", + "summary":"s", + "action":"a", + "sha":"sha", + "html_url":"hu" + } + ], + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -5090,7 +9586,137 @@ func TestWorkflowRunEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","workflow":{"id":1,"node_id":"nid","name":"n","path":"p","state":"s","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"url":"u","html_url":"h","badge_url":"b"},"workflow_run":{"id":1,"name":"n","node_id":"nid","head_branch":"hb","head_sha":"hs","run_number":1,"run_attempt":1,"event":"e","status":"s","conclusion":"c","workflow_id":1,"url":"u","html_url":"h","pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}],"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"run_started_at":` + referenceTimeStr + `,"jobs_url":"j","logs_url":"l","check_suite_url":"c","artifacts_url":"a","cancel_url":"c","rerun_url":"r","previous_attempt_url":"p","head_commit":{"message":"m","author":{"name":"n","email":"e","username":"l"},"url":"u","distinct":false,"sha":"s","id":"i","tree_id":"tid","timestamp":` + referenceTimeStr + `,"committer":{"name":"n","email":"e","username":"l"}},"workflow_url":"w","repository":{"id":1,"name":"n","url":"u"},"head_repository":{"id":1,"name":"n","url":"u"}},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` + want := `{ + "action":"a", + "workflow":{ + "id":1, + "node_id":"nid", + "name":"n", + "path":"p", + "state":"s", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "url":"u", + "html_url":"h", + "badge_url":"b" + }, + "workflow_run":{ + "id":1, + "name":"n", + "node_id":"nid", + "head_branch":"hb", + "head_sha":"hs", + "run_number":1, + "run_attempt":1, + "event":"e", + "status":"s", + "conclusion":"c", + "workflow_id":1, + "url":"u", + "html_url":"h", + "pull_requests":[ + { + "id":1, + "number":1, + "url":"u", + "head":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"s" + } + }, + "base":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"u" + } + } + } + ], + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "run_started_at":` + referenceTimeStr + `, + "jobs_url":"j", + "logs_url":"l", + "check_suite_url":"c", + "artifacts_url":"a", + "cancel_url":"c", + "rerun_url":"r", + "previous_attempt_url":"p", + "head_commit":{ + "message":"m", + "author":{ + "name":"n", + "email":"e", + "username":"l" + }, + "url":"u", + "distinct":false, + "sha":"s", + "id":"i", + "tree_id":"tid", + "timestamp":` + referenceTimeStr + `, + "committer":{ + "name":"n", + "email":"e", + "username":"l" + } + }, + "workflow_url":"w", + "repository":{ + "id":1, + "name":"n", + "url":"u" + }, + "head_repository":{ + "id":1, + "name":"n", + "url":"u" + } + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + } + }` testJSONMarshal(t, u, want) } @@ -5144,7 +9770,49 @@ func TestWorkflowDispatchEvent_Marshal(t *testing.T) { }, } - want := `{"inputs":{"key":"value"},"ref":"r","workflow":"w","repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` + want := `{ + "inputs":{ + "key":"value" + }, + "ref":"r", + "workflow":"w", + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + } + }` testJSONMarshal(t, u, want) } @@ -5263,7 +9931,120 @@ func TestWatchEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -5306,7 +10087,39 @@ func TestUserEvent_Marshal(t *testing.T) { }, } - want := `{"user":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"action":"a","enterprise":{"id":1,"slug":"s","name":"n","node_id":"nid","avatar_url":"au","description":"d","website_url":"wu","html_url":"hu","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` + want := `{ + "user":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "action":"a", + "enterprise":{ + "id":1, + "slug":"s", + "name":"n", + "node_id":"nid", + "avatar_url":"au", + "description":"d", + "website_url":"wu", + "html_url":"hu", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + } + }` testJSONMarshal(t, u, want) } @@ -5536,7 +10349,231 @@ func TestCheckRunEvent_Marshal(t *testing.T) { }, } - want := `{"check_run":{"id":1,"node_id":"n","head_sha":"h","external_id":"1","url":"u","html_url":"u","details_url":"u","status":"s","conclusion":"c","started_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `,"output":{"title":"t","summary":"s","text":"t","annotations_count":1,"annotations_url":"a","annotations":[{"path":"p","start_line":1,"end_line":1,"annotation_level":"a","message":"m","title":"t","raw_details":"r"}],"images":[{"alt":"a","image_url":"i","caption":"c"}]},"name":"n","check_suite":{"id":1},"app":{"id":1,"node_id":"n","owner":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"name":"n","description":"d","external_url":"u","html_url":"h","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}]},"action":"a","repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `},"requested_action":{"identifier":"i"}}` + want := `{ + "check_run":{ + "id":1, + "node_id":"n", + "head_sha":"h", + "external_id":"1", + "url":"u", + "html_url":"u", + "details_url":"u", + "status":"s", + "conclusion":"c", + "started_at":` + referenceTimeStr + `, + "completed_at":` + referenceTimeStr + `, + "output":{ + "title":"t", + "summary":"s", + "text":"t", + "annotations_count":1, + "annotations_url":"a", + "annotations":[ + { + "path":"p", + "start_line":1, + "end_line":1, + "annotation_level":"a", + "message":"m", + "title":"t", + "raw_details":"r" + } + ], + "images":[ + { + "alt":"a", + "image_url":"i", + "caption":"c" + } + ] + }, + "name":"n", + "check_suite":{ + "id":1 + }, + "app":{ + "id":1, + "node_id":"n", + "owner":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "name":"n", + "description":"d", + "external_url":"u", + "html_url":"h", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + }, + "pull_requests":[ + { + "id":1, + "number":1, + "url":"u", + "head":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"s" + } + }, + "base":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"u" + } + } + } + ] + }, + "action":"a", + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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 + ` + }, + "requested_action":{ + "identifier":"i" + } + }` testJSONMarshal(t, r, want) } @@ -5738,7 +10775,203 @@ func TestCheckSuiteEvent_Marshal(t *testing.T) { }, } - want := `{"check_suite":{"id":1,"node_id":"n","head_branch":"h","head_sha":"h","url":"u","before":"b","after":"a","status":"s","conclusion":"c","app":{"id":1,"node_id":"n","owner":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"name":"n","description":"d","external_url":"u","html_url":"h","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"repository":{"id":1},"pull_requests":[{"id":1,"number":1,"url":"u","head":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"s"}},"base":{"ref":"r","sha":"s","repo":{"id":1,"name":"n","url":"u"}}}],"head_commit":{"sha":"s"}},"action":"a","repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "check_suite":{ + "id":1, + "node_id":"n", + "head_branch":"h", + "head_sha":"h", + "url":"u", + "before":"b", + "after":"a", + "status":"s", + "conclusion":"c", + "app":{ + "id":1, + "node_id":"n", + "owner":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "name":"n", + "description":"d", + "external_url":"u", + "html_url":"h", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + }, + "repository":{ + "id":1 + }, + "pull_requests":[ + { + "id":1, + "number":1, + "url":"u", + "head":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"s" + } + }, + "base":{ + "ref":"r", + "sha":"s", + "repo":{ + "id":1, + "name":"n", + "url":"u" + } + } + } + ], + "head_commit":{ + "sha":"s" + } + }, + "action":"a", + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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, r, want) } @@ -5795,7 +11028,54 @@ func TestDeployKeyEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","key":{"id":1,"key":"k","url":"k","title":"k","read_only":false,"verified":false,"created_at":` + referenceTimeStr + `},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` + want := `{ + "action":"a", + "key":{ + "id":1, + "key":"k", + "url":"k", + "title":"k", + "read_only":false, + "verified":false, + "created_at":` + referenceTimeStr + ` + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + } + }` testJSONMarshal(t, u, want) } @@ -5825,7 +11105,30 @@ func TestMetaEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","hook_id":1,"hook":{"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"url":"u","id":1,"type":"t","name":"n","test_url":"tu","ping_url":"pu","last_response":{"a":"b"},"config":{"a":"b"},"events":["a"],"active":true}}` + want := `{ + "action":"a", + "hook_id":1, + "hook":{ + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "url":"u", + "id":1, + "type":"t", + "name":"n", + "test_url":"tu", + "ping_url":"pu", + "last_response":{ + "a":"b" + }, + "config":{ + "a":"b" + }, + "events":[ + "a" + ], + "active":true + } + }` testJSONMarshal(t, u, want) } @@ -5960,7 +11263,124 @@ func TestCreateEvent_Marshal(t *testing.T) { }, } - want := `{"ref":"r","ref_type":"rt","master_branch":"mb","description":"d","pusher_type":"pt","repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "ref":"r", + "ref_type":"rt", + "master_branch":"mb", + "description":"d", + "pusher_type":"pt", + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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, r, want) } @@ -6081,7 +11501,122 @@ func TestDeleteEvent_Marshal(t *testing.T) { }, } - want := `{"ref":"r","ref_type":"rt","pusher_type":"pt","repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "ref":"r", + "ref_type":"rt", + "pusher_type":"pt", + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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, r, want) } @@ -6204,7 +11739,124 @@ func TestForkEvent_Marshal(t *testing.T) { }, } - want := `{"forkee":{"id":1,"name":"n","url":"s"},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "forkee":{ + "id":1, + "name":"n", + "url":"s" + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -6225,7 +11877,18 @@ func TestGitHubAppAuthorizationEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` + want := `{ + "action":"a", + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + } + }` testJSONMarshal(t, u, want) } @@ -6346,7 +12009,122 @@ func TestInstallationEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","repositories":[{"id":1,"name":"n","url":"u"}],"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "repositories":[ + { + "id":1, + "name":"n", + "url":"u" + } + ], + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -6379,7 +12157,36 @@ func TestHeadCommit_Marshal(t *testing.T) { Modified: []string{"m"}, } - want := `{"message":"m","author":{"date":` + referenceTimeStr + `,"name":"n","email":"e","username":"u"},"url":"u","distinct":true,"sha":"s","id":"id","tree_id":"tid","timestamp":` + referenceTimeStr + `,"committer":{"date":` + referenceTimeStr + `,"name":"n","email":"e","username":"u"},"added":["a"],"removed":["r"],"modified":["m"]}` + want := `{ + "message":"m", + "author":{ + "date":` + referenceTimeStr + `, + "name":"n", + "email":"e", + "username":"u" + }, + "url":"u", + "distinct":true, + "sha":"s", + "id":"id", + "tree_id":"tid", + "timestamp":` + referenceTimeStr + `, + "committer":{ + "date":` + referenceTimeStr + `, + "name":"n", + "email":"e", + "username":"u" + }, + "added":[ + "a" + ], + "removed":[ + "r" + ], + "modified":[ + "m" + ] + }` testJSONMarshal(t, u, want) } @@ -6442,7 +12249,60 @@ func TestPushEventRepository_Marshal(t *testing.T) { SVNURL: String("s"), } - want := `{"id":1,"node_id":"nid","name":"n","full_name":"fn","owner":{"login":"l","id":1,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"},"private":true,"description":"d","fork":true,"created_at":` + referenceTimeStr + `,"pushed_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"homepage":"h","pulls_url":"p","size":1,"stargazers_count":1,"watchers_count":1,"language":"l","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"archived":true,"disabled":true,"open_issues_count":1,"default_branch":"d","master_branch":"m","organization":"o","url":"u","archive_url":"a","html_url":"h","statuses_url":"s","git_url":"g","ssh_url":"s","clone_url":"c","svn_url":"s"}` + want := `{ + "id":1, + "node_id":"nid", + "name":"n", + "full_name":"fn", + "owner":{ + "login":"l", + "id":1, + "avatar_url":"a", + "gravatar_id":"g", + "name":"n", + "company":"c", + "blog":"b", + "location":"l", + "email":"e", + "hireable":true, + "public_repos":1, + "followers":1, + "following":1, + "created_at":` + referenceTimeStr + `, + "url":"u" + }, + "private":true, + "description":"d", + "fork":true, + "created_at":` + referenceTimeStr + `, + "pushed_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "homepage":"h", + "pulls_url":"p", + "size":1, + "stargazers_count":1, + "watchers_count":1, + "language":"l", + "has_issues":true, + "has_downloads":true, + "has_wiki":true, + "has_pages":true, + "forks_count":1, + "archived":true, + "disabled":true, + "open_issues_count":1, + "default_branch":"d", + "master_branch":"m", + "organization":"o", + "url":"u", + "archive_url":"a", + "html_url":"h", + "statuses_url":"s", + "git_url":"g", + "ssh_url":"s", + "clone_url":"c", + "svn_url":"s" + }` testJSONMarshal(t, u, want) } @@ -6601,7 +12461,153 @@ func TestProjectEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","changes":{"name":{"from":"NameFrom"},"body":{"from":"BodyFrom"}},"project":{"id":1},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "changes":{ + "name":{ + "from":"NameFrom" + }, + "body":{ + "from":"BodyFrom" + } + }, + "project":{ + "id":1 + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -6747,7 +12753,151 @@ func TestProjectCardEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","changes":{"note":{"from":"NoteFrom"}},"after_id":1,"project_card":{"id":1},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "changes":{ + "note":{ + "from":"NoteFrom" + } + }, + "after_id":1, + "project_card":{ + "id":1 + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -6893,7 +13043,151 @@ func TestProjectColumnEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","changes":{"name":{"from":"NameFrom"}},"after_id":1,"project_column":{"id":1},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "changes":{ + "name":{ + "from":"NameFrom" + } + }, + "after_id":1, + "project_column":{ + "id":1 + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -7074,7 +13368,188 @@ func TestPullRequestEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","assignee":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"number":1,"pull_request":{"id":1},"changes":{"title":{"from":"TitleFrom"},"body":{"from":"BodyFrom"},"base":{"ref":{"from":"BaseRefFrom"},"sha":{"from":"BaseSHAFrom"}}},"requested_reviewer":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"requested_team":{"id":1},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `},"label":{"id":1},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"before":"before","after":"after"}` + want := `{ + "action":"a", + "assignee":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "number":1, + "pull_request":{ + "id":1 + }, + "changes":{ + "title":{ + "from":"TitleFrom" + }, + "body":{ + "from":"BodyFrom" + }, + "base":{ + "ref":{ + "from":"BaseRefFrom" + }, + "sha":{ + "from":"BaseSHAFrom" + } + } + }, + "requested_reviewer":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "requested_team":{ + "id":1 + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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 + ` + }, + "label":{ + "id":1 + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "before":"before", + "after":"after" + }` testJSONMarshal(t, u, want) } @@ -7211,7 +13686,142 @@ func TestPullRequestReviewCommentEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","pull_request":{"id":1},"comment":{"id":1},"changes":{"title":{"from":"TitleFrom"},"body":{"from":"BodyFrom"},"base":{"ref":{"from":"BaseRefFrom"},"sha":{"from":"BaseSHAFrom"}}},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "pull_request":{ + "id":1 + }, + "comment":{ + "id":1 + }, + "changes":{ + "title":{ + "from":"TitleFrom" + }, + "body":{ + "from":"BodyFrom" + }, + "base":{ + "ref":{ + "from":"BaseRefFrom" + }, + "sha":{ + "from":"BaseSHAFrom" + } + } + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -7334,7 +13944,133 @@ func TestPullRequestReviewThreadEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","thread":{"comments":[{"id":1},{"id":2}]},"pull_request":{"id":1},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `}}` + want := `{ + "action":"a", + "thread":{ + "comments":[ + { + "id":1 + }, + { + "id":2 + } + ] + }, + "pull_request":{ + "id":1 + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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) } @@ -7515,7 +14251,188 @@ func TestPullRequestTargetEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","assignee":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"number":1,"pull_request":{"id":1},"changes":{"title":{"from":"TitleFrom"},"body":{"from":"BodyFrom"},"base":{"ref":{"from":"BaseRefFrom"},"sha":{"from":"BaseSHAFrom"}}},"requested_reviewer":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"requested_team":{"id":1},"repository":{"id":1,"name":"n","url":"s"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"installation":{"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 + `},"label":{"id":1},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"before":"before","after":"after"}` + want := `{ + "action":"a", + "assignee":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "number":1, + "pull_request":{ + "id":1 + }, + "changes":{ + "title":{ + "from":"TitleFrom" + }, + "body":{ + "from":"BodyFrom" + }, + "base":{ + "ref":{ + "from":"BaseRefFrom" + }, + "sha":{ + "from":"BaseSHAFrom" + } + } + }, + "requested_reviewer":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "requested_team":{ + "id":1 + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "installation":{ + "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 + ` + }, + "label":{ + "id":1 + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "before":"before", + "after":"after" + }` testJSONMarshal(t, u, want) } @@ -7551,7 +14468,33 @@ func TestRepositoryVulnerabilityAlertEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","alert":{"id":1,"affected_range":"ar","affected_package_name":"apn","external_reference":"er","external_identifier":"ei","fixed_in":"fi","dismisser":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"dismiss_reason":"dr","dismissed_at":` + referenceTimeStr + `},"repository":{"id":1,"name":"n","url":"s"}}` + want := `{ + "action":"a", + "alert":{ + "id":1, + "affected_range":"ar", + "affected_package_name":"apn", + "external_reference":"er", + "external_identifier":"ei", + "fixed_in":"fi", + "dismisser":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "dismiss_reason":"dr", + "dismissed_at":` + referenceTimeStr + ` + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + } + }` testJSONMarshal(t, u, want) } @@ -7719,7 +14662,169 @@ func TestSecretScanningAlertEvent_Marshal(t *testing.T) { }, } - want := `{"action":"a","alert":{"number":1,"resolution":"r","resolved_at":` + referenceTimeStr + `,"resolved_by":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"secret_type":"t"},"sender":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"repository":{"id":1,"name":"n","url":"s"},"organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"enterprise":{"id":1,"slug":"s","name":"n","node_id":"nid","avatar_url":"au","description":"d","website_url":"wu","html_url":"hu","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `},"installation":{"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 + `}}` + want := `{ + "action":"a", + "alert":{ + "number":1, + "resolution":"r", + "resolved_at":` + referenceTimeStr + `, + "resolved_by":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "secret_type":"t" + }, + "sender":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "repository":{ + "id":1, + "name":"n", + "url":"s" + }, + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "enterprise":{ + "id":1, + "slug":"s", + "name":"n", + "node_id":"nid", + "avatar_url":"au", + "description":"d", + "website_url":"wu", + "html_url":"hu", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + }, + "installation":{ + "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) } @@ -7766,7 +14871,41 @@ func TestSecurityAdvisoryEvent_Marshal(t *testing.T) { // convert `>` into `\u003e`` and `<` into `\u003c`` part, _ := json.Marshal(">= 2.0.0, < 2.0.2") - want := `{"action":"published","security_advisory":{"ghsa_id":"GHSA-rf4j-j272-some","summary":"Siuuuuuuuuu","description":"desc","severity":"moderate","identifiers":[{"value":"GHSA-rf4j-j272-some","type":"GHSA"}],"references":[{"url":"https://some-url"}],"published_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"vulnerabilities":[{"package":{"ecosystem":"ucl","name":"penaldo"},"severity":"moderate","vulnerable_version_range":` + string(part) + `,"first_patched_version":{"identifier":"2.0.2"}}]}}` + want := `{ + "action":"published", + "security_advisory":{ + "ghsa_id":"GHSA-rf4j-j272-some", + "summary":"Siuuuuuuuuu", + "description":"desc", + "severity":"moderate", + "identifiers":[ + { + "value":"GHSA-rf4j-j272-some", + "type":"GHSA" + } + ], + "references":[ + { + "url":"https://some-url" + } + ], + "published_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "vulnerabilities":[ + { + "package":{ + "ecosystem":"ucl", + "name":"penaldo" + }, + "severity":"moderate", + "vulnerable_version_range":` + string(part) + `, + "first_patched_version":{ + "identifier":"2.0.2" + } + } + ] + } + }` testJSONMarshal(t, u, want) } @@ -7939,7 +15078,162 @@ func TestCodeScanningAlertEvent_Marshal(t *testing.T) { }, } - want := `{"action":"reopened","alert":{"number":10,"rule":{"id":"Style/FrozenStringLiteralComment","severity":"note","description":"desc","full_description":"full desc","tags":["style"],"help":"help"},"tool":{"name":"Rubocop"},"created_at":"2006-01-02T15:04:05Z","updated_at":"2006-01-02T15:04:05Z","state":"open","url":"a","html_url":"a","instances":[{"ref":"refs/heads/main","analysis_key":".github/workflows/workflow.yml:upload","environment":"{}","state":"open"}]},"ref":"refs/heads/main","commit_oid":"d6e4c75c141dbacecc279b721b8bsomeSHA","repository":{"id":1234234535,"node_id":"MDEwOlJlcG9zaXRvcnkxODY4NT==","owner":{"login":"Codertocat","id":21031067,"node_id":"MDQ6VXNlcjIxMDMxMDY3","avatar_url":"a","html_url":"a","gravatar_id":"","type":"User","site_admin":false,"url":"a","events_url":"a","following_url":"a","followers_url":"a","gists_url":"a","organizations_url":"a","received_events_url":"a","repos_url":"a","starred_url":"a","subscriptions_url":"a"},"name":"Hello-World","full_name":"Codertocat/Hello-World","default_branch":"main","created_at":"2006-01-02T15:04:05Z","pushed_at":"2006-01-02T15:04:05Z","updated_at":"2006-01-02T15:04:05Z","html_url":"a","clone_url":"a","git_url":"a","ssh_url":"a","svn_url":"a","fork":false,"forks_count":0,"open_issues_count":2,"open_issues":2,"stargazers_count":0,"watchers_count":0,"watchers":0,"size":0,"archived":false,"disabled":false,"private":false,"has_issues":true,"has_wiki":true,"has_pages":true,"has_projects":true,"has_downloads":true,"url":"a","archive_url":"a","assignees_url":"a","blobs_url":"a","branches_url":"a","collaborators_url":"a","comments_url":"a","commits_url":"a","compare_url":"a","contents_url":"a","contributors_url":"a","deployments_url":"a","downloads_url":"a","events_url":"a","forks_url":"a","git_commits_url":"a","git_refs_url":"a","git_tags_url":"a","hooks_url":"a","issue_comment_url":"a","issue_events_url":"a","issues_url":"a","keys_url":"a","labels_url":"a","languages_url":"a","merges_url":"a","milestones_url":"a","notifications_url":"a","pulls_url":"a","releases_url":"a","stargazers_url":"a","statuses_url":"a","subscribers_url":"a","subscription_url":"a","tags_url":"a","trees_url":"a","teams_url":"a"},"organization":{"login":"Octocoders","id":6,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY=","avatar_url":"a","description":"","url":"a","events_url":"a","hooks_url":"a","issues_url":"a","members_url":"a","public_members_url":"a","repos_url":"a"},"sender":{"login":"github","id":9919,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk5MTk=","avatar_url":"a","html_url":"a","gravatar_id":"","type":"Organization","site_admin":false,"url":"a","events_url":"a","following_url":"a","followers_url":"a","gists_url":"a","organizations_url":"a","received_events_url":"a","repos_url":"a","starred_url":"a","subscriptions_url":"a"}}` + want := `{ + "action":"reopened", + "alert":{ + "number":10, + "rule":{ + "id":"Style/FrozenStringLiteralComment", + "severity":"note", + "description":"desc", + "full_description":"full desc", + "tags":[ + "style" + ], + "help":"help" + }, + "tool":{ + "name":"Rubocop" + }, + "created_at":"2006-01-02T15:04:05Z", + "updated_at":"2006-01-02T15:04:05Z", + "state":"open", + "url":"a", + "html_url":"a", + "instances":[ + { + "ref":"refs/heads/main", + "analysis_key":".github/workflows/workflow.yml:upload", + "environment":"{}", + "state":"open" + } + ] + }, + "ref":"refs/heads/main", + "commit_oid":"d6e4c75c141dbacecc279b721b8bsomeSHA", + "repository":{ + "id":1234234535, + "node_id":"MDEwOlJlcG9zaXRvcnkxODY4NT==", + "owner":{ + "login":"Codertocat", + "id":21031067, + "node_id":"MDQ6VXNlcjIxMDMxMDY3", + "avatar_url":"a", + "html_url":"a", + "gravatar_id":"", + "type":"User", + "site_admin":false, + "url":"a", + "events_url":"a", + "following_url":"a", + "followers_url":"a", + "gists_url":"a", + "organizations_url":"a", + "received_events_url":"a", + "repos_url":"a", + "starred_url":"a", + "subscriptions_url":"a" + }, + "name":"Hello-World", + "full_name":"Codertocat/Hello-World", + "default_branch":"main", + "created_at":"2006-01-02T15:04:05Z", + "pushed_at":"2006-01-02T15:04:05Z", + "updated_at":"2006-01-02T15:04:05Z", + "html_url":"a", + "clone_url":"a", + "git_url":"a", + "ssh_url":"a", + "svn_url":"a", + "fork":false, + "forks_count":0, + "open_issues_count":2, + "open_issues":2, + "stargazers_count":0, + "watchers_count":0, + "watchers":0, + "size":0, + "archived":false, + "disabled":false, + "private":false, + "has_issues":true, + "has_wiki":true, + "has_pages":true, + "has_projects":true, + "has_downloads":true, + "url":"a", + "archive_url":"a", + "assignees_url":"a", + "blobs_url":"a", + "branches_url":"a", + "collaborators_url":"a", + "comments_url":"a", + "commits_url":"a", + "compare_url":"a", + "contents_url":"a", + "contributors_url":"a", + "deployments_url":"a", + "downloads_url":"a", + "events_url":"a", + "forks_url":"a", + "git_commits_url":"a", + "git_refs_url":"a", + "git_tags_url":"a", + "hooks_url":"a", + "issue_comment_url":"a", + "issue_events_url":"a", + "issues_url":"a", + "keys_url":"a", + "labels_url":"a", + "languages_url":"a", + "merges_url":"a", + "milestones_url":"a", + "notifications_url":"a", + "pulls_url":"a", + "releases_url":"a", + "stargazers_url":"a", + "statuses_url":"a", + "subscribers_url":"a", + "subscription_url":"a", + "tags_url":"a", + "trees_url":"a", + "teams_url":"a" + }, + "organization":{ + "login":"Octocoders", + "id":6, + "node_id":"MDEyOk9yZ2FuaXphdGlvbjY=", + "avatar_url":"a", + "description":"", + "url":"a", + "events_url":"a", + "hooks_url":"a", + "issues_url":"a", + "members_url":"a", + "public_members_url":"a", + "repos_url":"a" + }, + "sender":{ + "login":"github", + "id":9919, + "node_id":"MDEyOk9yZ2FuaXphdGlvbjk5MTk=", + "avatar_url":"a", + "html_url":"a", + "gravatar_id":"", + "type":"Organization", + "site_admin":false, + "url":"a", + "events_url":"a", + "following_url":"a", + "followers_url":"a", + "gists_url":"a", + "organizations_url":"a", + "received_events_url":"a", + "repos_url":"a", + "starred_url":"a", + "subscriptions_url":"a" + } + }` testJSONMarshal(t, u, want) } diff --git a/github/gists_comments_test.go b/github/gists_comments_test.go index adc2657f411..cc3ef201ad9 100644 --- a/github/gists_comments_test.go +++ b/github/gists_comments_test.go @@ -45,7 +45,29 @@ func TestGistComments_Marshal(t *testing.T) { CreatedAt: &Timestamp{createdAt}, } - want := `{"id":1,"url":"u","body":"test gist comment","user":{"login":"ll","id":123,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"},"created_at":"2002-02-10T15:30:00Z"}` + want := `{ + "id":1, + "url":"u", + "body":"test gist comment", + "user":{ + "login":"ll", + "id":123, + "avatar_url":"a", + "gravatar_id":"g", + "name":"n", + "company":"c", + "blog":"b", + "location":"l", + "email":"e", + "hireable":true, + "public_repos":1, + "followers":1, + "following":1, + "created_at":` + referenceTimeStr + `, + "url":"u" + }, + "created_at":"2002-02-10T15:30:00Z" + }` testJSONMarshal(t, u, want) } diff --git a/github/gists_test.go b/github/gists_test.go index 9913c2f7bdc..c1507281478 100644 --- a/github/gists_test.go +++ b/github/gists_test.go @@ -62,7 +62,45 @@ func TestGist_Marshal(t *testing.T) { NodeID: String("node"), } - want := `{"id":"i","description":"description","public":true,"owner":{"login":"ll","id":123,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"},"files":{"gistfile.py":{"size":167,"filename":"gistfile.py","language":"Python","type":"application/x-python","raw_url":"raw-url","content":"c"}},"comments":1,"html_url":"html-url","git_pull_url":"gitpull-url","git_push_url":"gitpush-url","created_at":"2010-02-10T10:10:00Z","updated_at":"2010-02-10T10:10:00Z","node_id":"node"}` + want := `{ + "id":"i", + "description":"description", + "public":true, + "owner":{ + "login":"ll", + "id":123, + "avatar_url":"a", + "gravatar_id":"g", + "name":"n", + "company":"c", + "blog":"b", + "location":"l", + "email":"e", + "hireable":true, + "public_repos":1, + "followers":1, + "following":1, + "created_at":` + referenceTimeStr + `, + "url":"u" + }, + "files":{ + "gistfile.py":{ + "size":167, + "filename":"gistfile.py", + "language":"Python", + "type":"application/x-python", + "raw_url":"raw-url", + "content":"c" + } + }, + "comments":1, + "html_url":"html-url", + "git_pull_url":"gitpull-url", + "git_push_url":"gitpush-url", + "created_at":"2010-02-10T10:10:00Z", + "updated_at":"2010-02-10T10:10:00Z", + "node_id":"node" + }` testJSONMarshal(t, u, want) } @@ -99,7 +137,34 @@ func TestGistCommit_Marshal(t *testing.T) { NodeID: String("node"), } - want := `{"url":"u","version":"v","user":{"login":"ll","id":123,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"},"change_status":{"additions":1,"deletions":1,"total":2},"committed_at":` + referenceTimeStr + `,"node_id":"node"}` + want := `{ + "url":"u", + "version":"v", + "user":{ + "login":"ll", + "id":123, + "avatar_url":"a", + "gravatar_id":"g", + "name":"n", + "company":"c", + "blog":"b", + "location":"l", + "email":"e", + "hireable":true, + "public_repos":1, + "followers":1, + "following":1, + "created_at":` + referenceTimeStr + `, + "url":"u" + }, + "change_status":{ + "additions":1, + "deletions":1, + "total":2 + }, + "committed_at":` + referenceTimeStr + `, + "node_id":"node" + }` testJSONMarshal(t, u, want) } @@ -132,7 +197,30 @@ func TestGistFork_Marshal(t *testing.T) { NodeID: String("node"), } - want := `{"url":"u","user":{"login":"ll","id":123,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"},"id":"id","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"node_id":"node"}` + want := `{ + "url":"u", + "user":{ + "login":"ll", + "id":123, + "avatar_url":"a", + "gravatar_id":"g", + "name":"n", + "company":"c", + "blog":"b", + "location":"l", + "email":"e", + "hireable":true, + "public_repos":1, + "followers":1, + "following":1, + "created_at":` + referenceTimeStr + `, + "url":"u" + }, + "id":"id", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "node_id":"node" + }` testJSONMarshal(t, u, want) } @@ -942,7 +1030,14 @@ func TestGistFile_Marshal(t *testing.T) { Content: String("con"), } - want := `{"size":1,"filename":"fn","language":"lan","type":"type","raw_url":"rurl","content":"con"}` + want := `{ + "size":1, + "filename":"fn", + "language":"lan", + "type":"type", + "raw_url":"rurl", + "content":"con" + }` testJSONMarshal(t, u, want) } diff --git a/github/git_blobs_test.go b/github/git_blobs_test.go index f26e5822f04..dab9cddf4f3 100644 --- a/github/git_blobs_test.go +++ b/github/git_blobs_test.go @@ -183,7 +183,14 @@ func TestBlob_Marshal(t *testing.T) { NodeID: String("nid"), } - want := `{"content":"content","encoding":"encoding","sha":"sha","size":1,"url":"url","node_id":"nid"}` + want := `{ + "content":"content", + "encoding":"encoding", + "sha":"sha", + "size":1, + "url":"url", + "node_id":"nid" + }` testJSONMarshal(t, u, want) } diff --git a/github/git_commits_test.go b/github/git_commits_test.go index 003ff075ab0..b5a317f32e5 100644 --- a/github/git_commits_test.go +++ b/github/git_commits_test.go @@ -68,7 +68,52 @@ func TestCommit_Marshal(t *testing.T) { SigningKey: &openpgp.Entity{}, } - want := `{"sha":"s","author":{"date":` + referenceTimeStr + `,"name":"n","email":"e","username":"u"},"committer":{"date":` + referenceTimeStr + `,"name":"n","email":"e","username":"u"},"message":"m","tree":{"sha":"s","tree":[{"sha":"s","path":"p","mode":"m","type":"t","size":1,"content":"c","url":"u"}],"truncated":false},"stats":{"additions":1,"deletions":1,"total":1},"html_url":"h","url":"u","verification":{"verified":false,"reason":"r","signature":"s","payload":"p"},"node_id":"n","comment_count":1}` + want := `{ + "sha":"s", + "author":{ + "date":` + referenceTimeStr + `, + "name":"n", + "email":"e", + "username":"u" + }, + "committer":{ + "date":` + referenceTimeStr + `, + "name":"n", + "email":"e", + "username":"u" + }, + "message":"m", + "tree":{ + "sha":"s", + "tree":[ + { + "sha":"s", + "path":"p", + "mode":"m", + "type":"t", + "size":1, + "content":"c", + "url":"u" + } + ], + "truncated":false + }, + "stats":{ + "additions":1, + "deletions":1, + "total":1 + }, + "html_url":"h", + "url":"u", + "verification":{ + "verified":false, + "reason":"r", + "signature":"s", + "payload":"p" + }, + "node_id":"n", + "comment_count":1 + }` testJSONMarshal(t, u, want) } @@ -568,7 +613,12 @@ func TestSignatureVerification_Marshal(t *testing.T) { Payload: String("payload"), } - want := `{"verified":true,"reason":"reason","signature":"sign","payload":"payload"}` + want := `{ + "verified":true, + "reason":"reason", + "signature":"sign", + "payload":"payload" + }` testJSONMarshal(t, u, want) } @@ -583,7 +633,12 @@ func TestCommitAuthor_Marshal(t *testing.T) { Login: String("login"), } - want := `{"date":` + referenceTimeStr + `,"name":"name","email":"email","username":"login"}` + want := `{ + "date":` + referenceTimeStr + `, + "name":"name", + "email":"email", + "username":"login" + }` testJSONMarshal(t, u, want) } @@ -610,7 +665,26 @@ func TestCreateCommit_Marshal(t *testing.T) { Signature: String("sign"), } - want := `{"author":{"date":` + referenceTimeStr + `,"name":"name","email":"email","username":"login"},"committer":{"date":` + referenceTimeStr + `,"name":"name","email":"email","username":"login"},"message":"message","tree":"tree","parents":["p"],"signature":"sign"}` + want := `{ + "author":{ + "date":` + referenceTimeStr + `, + "name":"name", + "email":"email", + "username":"login" + }, + "committer":{ + "date":` + referenceTimeStr + `, + "name":"name", + "email":"email", + "username":"login" + }, + "message":"message", + "tree":"tree", + "parents":[ + "p" + ], + "signature":"sign" + }` testJSONMarshal(t, u, want) } diff --git a/github/git_refs_test.go b/github/git_refs_test.go index ce1aa7a7041..6ae7775670f 100644 --- a/github/git_refs_test.go +++ b/github/git_refs_test.go @@ -677,7 +677,11 @@ func TestGitService_UpdateRef_pathEscape(t *testing.T) { } func TestReference_Marshal(t *testing.T) { - testJSONMarshal(t, &Reference{}, `{"ref":null,"url":null,"object":null}`) + testJSONMarshal(t, &Reference{}, `{ + "ref":null, + "url":null, + "object":null + }`) u := &Reference{ Ref: String("ref"), @@ -690,13 +694,26 @@ func TestReference_Marshal(t *testing.T) { NodeID: String("nid"), } - want := `{"ref":"ref","url":"url","object":{"type":"type","sha":"sha","url":"url"},"node_id":"nid"}` + want := `{ + "ref":"ref", + "url":"url", + "object":{ + "type":"type", + "sha":"sha", + "url":"url" + }, + "node_id":"nid" + }` testJSONMarshal(t, u, want) } func TestGitObject_Marshal(t *testing.T) { - testJSONMarshal(t, &GitObject{}, `{"type":null,"sha":null,"url":null}`) + testJSONMarshal(t, &GitObject{}, `{ + "type":null, + "sha":null, + "url":null + }`) u := &GitObject{ Type: String("type"), @@ -704,33 +721,49 @@ func TestGitObject_Marshal(t *testing.T) { URL: String("url"), } - want := `{"type":"type","sha":"sha","url":"url"}` + want := `{ + "type":"type", + "sha":"sha", + "url":"url" + }` testJSONMarshal(t, u, want) } func TestCreateRefRequest_Marshal(t *testing.T) { - testJSONMarshal(t, &createRefRequest{}, `{"ref":null,"sha":null}`) + testJSONMarshal(t, &createRefRequest{}, `{ + "ref":null, + "sha":null + }`) u := &createRefRequest{ Ref: String("ref"), SHA: String("sha"), } - want := `{"ref":"ref","sha":"sha"}` + want := `{ + "ref":"ref", + "sha":"sha" + }` testJSONMarshal(t, u, want) } func TestUpdateRefRequest_Marshal(t *testing.T) { - testJSONMarshal(t, &updateRefRequest{}, `{"sha":null,"force":null}`) + testJSONMarshal(t, &updateRefRequest{}, `{ + "sha":null, + "force":null + }`) u := &updateRefRequest{ SHA: String("sha"), Force: Bool(true), } - want := `{"sha":"sha","force":true}` + want := `{ + "sha":"sha", + "force":true + }` testJSONMarshal(t, u, want) } diff --git a/github/git_tags_test.go b/github/git_tags_test.go index f68cc39a4be..c72fabb0b88 100644 --- a/github/git_tags_test.go +++ b/github/git_tags_test.go @@ -126,7 +126,30 @@ func TestTag_Marshal(t *testing.T) { NodeID: String("nid"), } - want := `{"tag":"tag","sha":"sha","url":"url","message":"msg","tagger":{"date":` + referenceTimeStr + `,"name":"name","email":"email","username":"login"},"object":{"type":"type","sha":"sha","url":"url"},"verification":{"verified":true,"reason":"reason","signature":"sign","payload":"payload"},"node_id":"nid"}` + want := `{ + "tag":"tag", + "sha":"sha", + "url":"url", + "message":"msg", + "tagger":{ + "date":` + referenceTimeStr + `, + "name":"name", + "email":"email", + "username":"login" + }, + "object":{ + "type":"type", + "sha":"sha", + "url":"url" + }, + "verification":{ + "verified":true, + "reason":"reason", + "signature":"sign", + "payload":"payload" + }, + "node_id":"nid" + }` testJSONMarshal(t, u, want) } @@ -147,7 +170,18 @@ func TestCreateTagRequest_Marshal(t *testing.T) { }, } - want := `{"tag":"tag","message":"msg","object":"obj","type":"type","tagger":{"date":` + referenceTimeStr + `,"name":"name","email":"email","username":"login"}}` + want := `{ + "tag":"tag", + "message":"msg", + "object":"obj", + "type":"type", + "tagger":{ + "date":` + referenceTimeStr + `, + "name":"name", + "email":"email", + "username":"login" + } + }` testJSONMarshal(t, u, want) } diff --git a/github/git_trees_test.go b/github/git_trees_test.go index 145965033db..76021c6d1ff 100644 --- a/github/git_trees_test.go +++ b/github/git_trees_test.go @@ -360,7 +360,21 @@ func TestTree_Marshal(t *testing.T) { Truncated: Bool(false), } - want := `{"sha":"sha","tree":[{"sha":"sha","path":"path","mode":"mode","type":"type","size":1,"content":"content","url":"url"}],"truncated":false}` + want := `{ + "sha":"sha", + "tree":[ + { + "sha":"sha", + "path":"path", + "mode":"mode", + "type":"type", + "size":1, + "content":"content", + "url":"url" + } + ], + "truncated":false + }` testJSONMarshal(t, u, want) } @@ -378,7 +392,15 @@ func TestTreeEntry_Marshal(t *testing.T) { URL: String("url"), } - want := `{"sha":"sha","path":"path","mode":"mode","type":"type","size":1,"content":"content","url":"url"}` + want := `{ + "sha":"sha", + "path":"path", + "mode":"mode", + "type":"type", + "size":1, + "content":"content", + "url":"url" + }` testJSONMarshal(t, u, want) } @@ -396,7 +418,15 @@ func TestTreeEntryWithFileDelete_Marshal(t *testing.T) { URL: String("url"), } - want := `{"sha":"sha","path":"path","mode":"mode","type":"type","size":1,"content":"content","url":"url"}` + want := `{ + "sha":"sha", + "path":"path", + "mode":"mode", + "type":"type", + "size":1, + "content":"content", + "url":"url" + }` testJSONMarshal(t, u, want) } @@ -409,7 +439,10 @@ func TestCreateTree_Marshal(t *testing.T) { Entries: []interface{}{"e"}, } - want := `{"base_tree":"bt","tree":["e"]}` + want := `{ + "base_tree":"bt", + "tree":["e"] + }` testJSONMarshal(t, u, want) } diff --git a/github/github_test.go b/github/github_test.go index 1070b6bd06c..a2adc6a6d39 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -154,6 +154,9 @@ func testJSONMarshal(t *testing.T, v interface{}, want string) { t.Errorf("Unable to unmarshal JSON for %v: %v", v, err) } + want = strings.Replace(want, "\t", "", -1) + want = strings.Replace(want, "\n", "", -1) + if !bytes.Equal(j, []byte(want)) { t.Errorf("json.Marshal(%+v) returned %s, want %s", v, j, want) } @@ -2644,7 +2647,10 @@ func (fn roundTripperFunc) RoundTrip(r *http.Request) (*http.Response, error) { } func TestErrorResponse_Marshal(t *testing.T) { - testJSONMarshal(t, &ErrorResponse{}, `{"message":"","errors":null}`) + testJSONMarshal(t, &ErrorResponse{}, `{ + "message":"", + "errors":null + }`) u := &ErrorResponse{ Message: "msg", @@ -2663,7 +2669,22 @@ func TestErrorResponse_Marshal(t *testing.T) { DocumentationURL: "doc", } - want := `{"message":"msg","errors":[{"resource":"res","field":"f","code":"c","message":"msg"}],"block":{"reason":"reason","created_at":` + referenceTimeStr + `},"documentation_url":"doc"}` + want := `{ + "message":"msg", + "errors":[ + { + "resource":"res", + "field":"f", + "code":"c", + "message":"msg" + } + ], + "block":{ + "reason":"reason", + "created_at":` + referenceTimeStr + ` + }, + "documentation_url":"doc" + }` testJSONMarshal(t, u, want) } @@ -2676,13 +2697,23 @@ func TestErrorBlock_Marshal(t *testing.T) { CreatedAt: &Timestamp{referenceTime}, } - want := `{"reason":"reason","created_at":` + referenceTimeStr + `}` + want := `{ + "reason":"reason", + "created_at":` + referenceTimeStr + ` + }` testJSONMarshal(t, u, want) } func TestRateLimitError_Marshal(t *testing.T) { - // testJSONMarshal(t, &RateLimitError{}, "{}") + testJSONMarshal(t, &RateLimitError{}, `{ + "rate":{ + "limit":0, + "remaining":0, + "reset":"0001-01-01T00:00:00Z" + }, + "message":"" + }`) u := &RateLimitError{ Rate: Rate{ @@ -2693,7 +2724,14 @@ func TestRateLimitError_Marshal(t *testing.T) { Message: "msg", } - want := `{"rate":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `},"message":"msg"}` + want := `{ + "rate":{ + "limit":1, + "remaining":1, + "reset":` + referenceTimeStr + ` + }, + "message":"msg" + }` testJSONMarshal(t, u, want) } @@ -2711,7 +2749,12 @@ func TestAbuseRateLimitError_Marshal(t *testing.T) { } func TestError_Marshal(t *testing.T) { - testJSONMarshal(t, &Error{}, `{"resource":"","field":"","code":"","message":""}`) + testJSONMarshal(t, &Error{}, `{ + "resource":"", + "field":"", + "code":"", + "message":"" + }`) u := &Error{ Resource: "res", @@ -2720,13 +2763,22 @@ func TestError_Marshal(t *testing.T) { Message: "msg", } - want := `{"resource":"res","field":"field","code":"code","message":"msg"}` + want := `{ + "resource":"res", + "field":"field", + "code":"code", + "message":"msg" + }` testJSONMarshal(t, u, want) } func TestRate_Marshal(t *testing.T) { - // testJSONMarshal(t, &Rate{}, `{"limit":0,"remaining":0,"reset":""}`) + testJSONMarshal(t, &Rate{}, `{ + "limit":0, + "remaining":0, + "reset":"0001-01-01T00:00:00Z" + }`) u := &Rate{ Limit: 1, @@ -2734,13 +2786,26 @@ func TestRate_Marshal(t *testing.T) { Reset: Timestamp{referenceTime}, } - want := `{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `}` + want := `{ + "limit":1, + "remaining":1, + "reset":` + referenceTimeStr + ` + }` testJSONMarshal(t, u, want) } func TestRateLimits_Marshal(t *testing.T) { - testJSONMarshal(t, &RateLimits{}, `{"core":null,"search":null,"graphql":null,"integration_manifest":null,"source_import":null,"code_scanning_upload":null,"actions_runner_registration":null,"scim":null}`) + testJSONMarshal(t, &RateLimits{}, `{ + "core":null, + "search":null, + "graphql":null, + "integration_manifest":null, + "source_import":null, + "code_scanning_upload":null, + "actions_runner_registration":null, + "scim":null + }`) u := &RateLimits{ Core: &Rate{ @@ -2785,7 +2850,48 @@ func TestRateLimits_Marshal(t *testing.T) { }, } - want := `{"core":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `},"search":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `},"graphql":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `},"integration_manifest":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `},"source_import":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `},"code_scanning_upload":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `},"actions_runner_registration":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `},"scim":{"limit":1,"remaining":1,"reset":` + referenceTimeStr + `}}` + want := `{ + "core":{ + "limit":1, + "remaining":1, + "reset":` + referenceTimeStr + ` + }, + "search":{ + "limit":1, + "remaining":1, + "reset":` + referenceTimeStr + ` + }, + "graphql":{ + "limit":1, + "remaining":1, + "reset":` + referenceTimeStr + ` + }, + "integration_manifest":{ + "limit":1, + "remaining":1, + "reset":` + referenceTimeStr + ` + }, + "source_import":{ + "limit":1, + "remaining":1, + "reset":` + referenceTimeStr + ` + }, + "code_scanning_upload":{ + "limit":1, + "remaining":1, + "reset":` + referenceTimeStr + ` + }, + "actions_runner_registration":{ + "limit":1, + "remaining":1, + "reset":` + referenceTimeStr + ` + }, + "scim":{ + "limit":1, + "remaining":1, + "reset":` + referenceTimeStr + ` + } + }` testJSONMarshal(t, u, want) } diff --git a/github/gitignore_test.go b/github/gitignore_test.go index 6e110b6fb69..7243afe1452 100644 --- a/github/gitignore_test.go +++ b/github/gitignore_test.go @@ -96,7 +96,10 @@ func TestGitignore_Marshal(t *testing.T) { Source: String("source"), } - want := `{"name":"name","source":"source"}` + want := `{ + "name":"name", + "source":"source" + }` testJSONMarshal(t, u, want) } diff --git a/github/interactions_test.go b/github/interactions_test.go index 12ee8db806f..4e0c5398c3a 100644 --- a/github/interactions_test.go +++ b/github/interactions_test.go @@ -16,7 +16,11 @@ func TestInteractionRestriction_Marshal(t *testing.T) { ExpiresAt: &Timestamp{referenceTime}, } - want := `{"limit":"limit","origin":"origin","expires_at":` + referenceTimeStr + `}` + want := `{ + "limit":"limit", + "origin":"origin", + "expires_at":` + referenceTimeStr + ` + }` testJSONMarshal(t, u, want) } diff --git a/github/issue_import_test.go b/github/issue_import_test.go index 276bd94f97f..1ef6f171cc4 100644 --- a/github/issue_import_test.go +++ b/github/issue_import_test.go @@ -220,7 +220,13 @@ func TestIssueImportError_Marshal(t *testing.T) { Code: String("code"), } - want := `{"location":"loc","resource":"res","field":"field","value":"value","code":"code"}` + want := `{ + "location":"loc", + "resource":"res", + "field":"field", + "value":"value", + "code":"code" + }` testJSONMarshal(t, u, want) } @@ -249,7 +255,26 @@ func TestIssueImportResponse_Marshal(t *testing.T) { }, } - want := `{"id":1,"status":"status","url":"url","import_issues_url":"iiu","repository_url":"ru","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"message":"msg","documentation_url":"durl","errors":[{"location":"loc","resource":"res","field":"field","value":"value","code":"code"}]}` + want := `{ + "id":1, + "status":"status", + "url":"url", + "import_issues_url":"iiu", + "repository_url":"ru", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "message":"msg", + "documentation_url":"durl", + "errors":[ + { + "location":"loc", + "resource":"res", + "field":"field", + "value":"value", + "code":"code" + } + ] + }` testJSONMarshal(t, u, want) } @@ -262,13 +287,19 @@ func TestComment_Marshal(t *testing.T) { Body: "body", } - want := `{"created_at":` + referenceTimeStr + `,"body":"body"}` + want := `{ + "created_at":` + referenceTimeStr + `, + "body":"body" + }` testJSONMarshal(t, u, want) } func TestIssueImport_Marshal(t *testing.T) { - testJSONMarshal(t, &IssueImport{}, `{"title":"","body":""}`) + testJSONMarshal(t, &IssueImport{}, `{ + "title":"", + "body":"" + }`) u := &IssueImport{ Title: "title", @@ -282,13 +313,30 @@ func TestIssueImport_Marshal(t *testing.T) { Labels: []string{"l"}, } - want := `{"title":"title","body":"body","created_at":` + referenceTimeStr + `,"closed_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"assignee":"a","milestone":1,"closed":false,"labels":["l"]}` + want := `{ + "title":"title", + "body":"body", + "created_at":` + referenceTimeStr + `, + "closed_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "assignee":"a", + "milestone":1, + "closed":false, + "labels":[ + "l" + ] + }` testJSONMarshal(t, u, want) } func TestIssueImportRequest_Marshal(t *testing.T) { - testJSONMarshal(t, &IssueImportRequest{}, `{"issue":{"title":"","body":""}}`) + testJSONMarshal(t, &IssueImportRequest{}, `{ + "issue":{ + "title":"", + "body":"" + } + }`) u := &IssueImportRequest{ IssueImport: IssueImport{ @@ -310,7 +358,27 @@ func TestIssueImportRequest_Marshal(t *testing.T) { }, } - want := `{"issue":{"title":"title","body":"body","created_at":` + referenceTimeStr + `,"closed_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"assignee":"a","milestone":1,"closed":false,"labels":["l"]},"comments":[{"created_at":` + referenceTimeStr + `,"body":"body"}]}` + want := `{ + "issue":{ + "title":"title", + "body":"body", + "created_at":` + referenceTimeStr + `, + "closed_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "assignee":"a", + "milestone":1, + "closed":false, + "labels":[ + "l" + ] + }, + "comments":[ + { + "created_at":` + referenceTimeStr + `, + "body":"body" + } + ] + }` testJSONMarshal(t, u, want) } diff --git a/github/issues_comments_test.go b/github/issues_comments_test.go index cc40a16a7c8..6e1ec0c7e15 100644 --- a/github/issues_comments_test.go +++ b/github/issues_comments_test.go @@ -331,7 +331,40 @@ func TestIssueComment_Marshal(t *testing.T) { IssueURL: String("iurl"), } - want := `{"id":1,"node_id":"nid","body":"body","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"},"reactions":{"total_count":1},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"author_association":"aa","url":"url","html_url":"hurl","issue_url":"iurl"}` + want := `{ + "id":1, + "node_id":"nid", + "body":"body", + "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" + }, + "reactions":{ + "total_count":1 + }, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "author_association":"aa", + "url":"url", + "html_url":"hurl", + "issue_url":"iurl" + }` testJSONMarshal(t, u, want) } diff --git a/github/issues_events_test.go b/github/issues_events_test.go index 8126e95ca7e..08756d2769f 100644 --- a/github/issues_events_test.go +++ b/github/issues_events_test.go @@ -138,7 +138,10 @@ func TestRename_Marshal(t *testing.T) { To: String("to"), } - want := `{"from":"from","to":"to"}` + want := `{ + "from":"from", + "to":"to" + }` testJSONMarshal(t, u, want) } @@ -153,7 +156,12 @@ func TestDismissedReview_Marshal(t *testing.T) { DismissalCommitID: String("dcid"), } - want := `{"state":"state","review_id":1,"dismissal_message":"dm","dismissal_commit_id":"dcid"}` + want := `{ + "state":"state", + "review_id":1, + "dismissal_message":"dm", + "dismissal_commit_id":"dcid" + }` testJSONMarshal(t, u, want) } @@ -284,7 +292,136 @@ func TestIssueEvent_Marshal(t *testing.T) { }, } - want := `{"id":1,"url":"url","actor":{"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"},"event":"event","created_at":` + referenceTimeStr + `,"issue":{"id":1},"assignee":{"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"},"assigner":{"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"},"commit_id":"cid","milestone":{"id":1},"label":{"id":1},"rename":{"from":"from","to":"to"},"lock_reason":"lr","project_card":{"id":1},"dismissed_review":{"state":"state","review_id":1,"dismissal_message":"dm","dismissal_commit_id":"dcid"},"requested_reviewer":{"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"},"review_requester":{"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"}}` + want := `{ + "id":1, + "url":"url", + "actor":{ + "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" + }, + "event":"event", + "created_at":` + referenceTimeStr + `, + "issue":{ + "id":1 + }, + "assignee":{ + "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" + }, + "assigner":{ + "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" + }, + "commit_id":"cid", + "milestone":{ + "id":1 + }, + "label":{ + "id":1 + }, + "rename":{ + "from":"from", + "to":"to" + }, + "lock_reason":"lr", + "project_card":{ + "id":1 + }, + "dismissed_review":{ + "state":"state", + "review_id":1, + "dismissal_message":"dm", + "dismissal_commit_id":"dcid" + }, + "requested_reviewer":{ + "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" + }, + "review_requester":{ + "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) } diff --git a/github/issues_labels_test.go b/github/issues_labels_test.go index 6a4f7ab416e..50de298fe14 100644 --- a/github/issues_labels_test.go +++ b/github/issues_labels_test.go @@ -527,7 +527,15 @@ func TestLabel_Marshal(t *testing.T) { NodeID: String("nid"), } - want := `{"id":1,"url":"url","name":"name","color":"color","description":"desc","default":false,"node_id":"nid"}` + want := `{ + "id":1, + "url":"url", + "name":"name", + "color":"color", + "description":"desc", + "default":false, + "node_id":"nid" + }` testJSONMarshal(t, u, want) } diff --git a/github/issues_milestones_test.go b/github/issues_milestones_test.go index 6ce906952bd..4c27d1cbb9f 100644 --- a/github/issues_milestones_test.go +++ b/github/issues_milestones_test.go @@ -291,7 +291,43 @@ func TestMilestone_Marshal(t *testing.T) { NodeID: String("nid"), } - want := `{"url":"url","html_url":"hurl","labels_url":"lurl","id":1,"number":1,"state":"state","title":"title","description":"desc","creator":{"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":"tu","public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"suspended_at":` + referenceTimeStr + `,"url":"u"},"open_issues":1,"closed_issues":1,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"closed_at":` + referenceTimeStr + `,"due_on":` + referenceTimeStr + `,"node_id":"nid"}` + want := `{ + "url":"url", + "html_url":"hurl", + "labels_url":"lurl", + "id":1, + "number":1, + "state":"state", + "title":"title", + "description":"desc", + "creator":{ + "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":"tu", + "public_repos":1, + "followers":1, + "following":1, + "created_at":` + referenceTimeStr + `, + "suspended_at":` + referenceTimeStr + `, + "url":"u" + }, + "open_issues":1, + "closed_issues":1, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "closed_at":` + referenceTimeStr + `, + "due_on":` + referenceTimeStr + `, + "node_id":"nid" + }` testJSONMarshal(t, u, want) } diff --git a/github/issues_test.go b/github/issues_test.go index aca0f6fb47f..907dbc25e61 100644 --- a/github/issues_test.go +++ b/github/issues_test.go @@ -499,7 +499,12 @@ func TestPullRequestLinks_Marshal(t *testing.T) { PatchURL: String("purl"), } - want := `{"url":"url","html_url":"hurl","diff_url":"durl","patch_url":"purl"}` + want := `{ + "url":"url", + "html_url":"hurl", + "diff_url":"durl", + "patch_url":"purl" + }` testJSONMarshal(t, u, want) } @@ -517,7 +522,19 @@ func TestIssueRequest_Marshal(t *testing.T) { Assignees: &[]string{"a"}, } - want := `{"title":"url","body":"url","labels":["l"],"assignee":"url","state":"url","milestone":1,"assignees":["a"]}` + want := `{ + "title":"url", + "body":"url", + "labels":[ + "l" + ], + "assignee":"url", + "state":"url", + "milestone":1, + "assignees":[ + "a" + ] + }` testJSONMarshal(t, u, want) } @@ -557,7 +574,63 @@ func TestIssue_Marshal(t *testing.T) { ActiveLockReason: String("alr"), } - want := `{"id":1,"number":1,"state":"s","locked":false,"title":"title","body":"body","author_association":"aa","user":{"id":1},"labels":[{"id":1}],"assignee":{"id":1},"comments":1,"closed_at":` + referenceTimeStr + `,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"closed_by":{"id":1},"url":"url","html_url":"hurl","comments_url":"curl","events_url":"eurl","labels_url":"lurl","repository_url":"rurl","milestone":{"id":1},"pull_request":{"url":"url"},"repository":{"id":1},"reactions":{"total_count":1},"assignees":[{"id":1}],"node_id":"nid","text_matches":[{"object_url":"ourl"}],"active_lock_reason":"alr"}` + want := `{ + "id":1, + "number":1, + "state":"s", + "locked":false, + "title":"title", + "body":"body", + "author_association":"aa", + "user":{ + "id":1 + }, + "labels":[ + { + "id":1 + } + ], + "assignee":{ + "id":1 + }, + "comments":1, + "closed_at":` + referenceTimeStr + `, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "closed_by":{ + "id":1 + }, + "url":"url", + "html_url":"hurl", + "comments_url":"curl", + "events_url":"eurl", + "labels_url":"lurl", + "repository_url":"rurl", + "milestone":{ + "id":1 + }, + "pull_request":{ + "url":"url" + }, + "repository":{ + "id":1 + }, + "reactions":{ + "total_count":1 + }, + "assignees":[ + { + "id":1 + } + ], + "node_id":"nid", + "text_matches":[ + { + "object_url":"ourl" + } + ], + "active_lock_reason":"alr" + }` testJSONMarshal(t, u, want) } diff --git a/github/issues_timeline_test.go b/github/issues_timeline_test.go index a35efd0090c..2da4c18cb79 100644 --- a/github/issues_timeline_test.go +++ b/github/issues_timeline_test.go @@ -76,7 +76,23 @@ func TestSource_Marshal(t *testing.T) { Issue: &Issue{ID: Int64(1)}, } - want := `{"id":1,"url":"url","actor":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"type":"type","issue":{"id":1}}` + want := `{ + "id":1, + "url":"url", + "actor":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "type":"type", + "issue":{ + "id":1 + } + }` testJSONMarshal(t, u, want) } @@ -156,7 +172,85 @@ func TestTimeline_Marshal(t *testing.T) { State: String("state"), } - want := `{"id":1,"url":"url","commit_url":"curl","actor":{"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"},"event":"event","commit_id":"cid","created_at":` + referenceTimeStr + `,"label":{"id":1},"assignee":{"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"},"milestone":{"id":1},"source":{"id":1,"url":"url","actor":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"},"type":"type","issue":{"id":1}},"rename":{"from":"from","to":"to"},"project_card":{"id":1},"state":"state"}` + want := `{ + "id":1, + "url":"url", + "commit_url":"curl", + "actor":{ + "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" + }, + "event":"event", + "commit_id":"cid", + "created_at":` + referenceTimeStr + `, + "label":{ + "id":1 + }, + "assignee":{ + "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" + }, + "milestone":{ + "id":1 + }, + "source":{ + "id":1, + "url":"url", + "actor":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + }, + "type":"type", + "issue":{ + "id":1 + } + }, + "rename":{ + "from":"from", + "to":"to" + }, + "project_card":{ + "id":1 + }, + "state":"state" + }` testJSONMarshal(t, u, want) } diff --git a/github/licenses_test.go b/github/licenses_test.go index f5568432079..633c988d6c8 100644 --- a/github/licenses_test.go +++ b/github/licenses_test.go @@ -44,7 +44,39 @@ func TestRepositoryLicense_Marshal(t *testing.T) { Body: String("b"), }, } - want := `{"name":"n","path":"p","sha":"s","size":1,"url":"u","html_url":"h","git_url":"g","download_url":"d","type":"t","content":"c","encoding":"e","license":{"key":"k","name":"n","url":"u","spdx_id":"s","html_url":"h","featured":true,"description":"d","implementation":"i","permissions":["p"],"conditions":["c"],"limitations":["l"],"body":"b"}}` + want := `{ + "name":"n", + "path":"p", + "sha":"s", + "size":1, + "url":"u", + "html_url":"h", + "git_url":"g", + "download_url":"d", + "type":"t", + "content":"c", + "encoding":"e", + "license":{ + "key":"k", + "name":"n", + "url":"u", + "spdx_id":"s", + "html_url":"h", + "featured":true, + "description":"d", + "implementation":"i", + "permissions":[ + "p" + ], + "conditions":[ + "c" + ], + "limitations":[ + "l" + ], + "body":"b" + } + }` testJSONMarshal(t, rl, want) } @@ -65,7 +97,26 @@ func TestLicense_Marshal(t *testing.T) { Limitations: &[]string{"l"}, Body: String("b"), } - want := `{"key":"k","name":"n","url":"u","spdx_id":"s","html_url":"h","featured":true,"description":"d","implementation":"i","permissions":["p"],"conditions":["c"],"limitations":["l"],"body":"b"}` + want := `{ + "key":"k", + "name":"n", + "url":"u", + "spdx_id":"s", + "html_url":"h", + "featured":true, + "description":"d", + "implementation":"i", + "permissions":[ + "p" + ], + "conditions":[ + "c" + ], + "limitations":[ + "l" + ], + "body":"b" + }` testJSONMarshal(t, l, want) } diff --git a/github/migrations_source_import_test.go b/github/migrations_source_import_test.go index 4b305f55d0c..ba3031f287c 100644 --- a/github/migrations_source_import_test.go +++ b/github/migrations_source_import_test.go @@ -344,7 +344,12 @@ func TestLargeFile_Marshal(t *testing.T) { Size: Int(1), } - want := `{"ref_name":"rn","path":"p","oid":"oid","size":1}` + want := `{ + "ref_name":"rn", + "path":"p", + "oid":"oid", + "size":1 + }` testJSONMarshal(t, u, want) } @@ -362,7 +367,15 @@ func TestSourceImportAuthor_Marshal(t *testing.T) { ImportURL: String("iurl"), } - want := `{"id":1,"remote_id":"rid","remote_name":"rn","email":"e","name":"n","url":"url","import_url":"iurl"}` + want := `{ + "id":1, + "remote_id":"rid", + "remote_name":"rn", + "email":"e", + "name":"n", + "url":"url", + "import_url":"iurl" + }` testJSONMarshal(t, u, want) } @@ -396,7 +409,35 @@ func TestImport_Marshal(t *testing.T) { ProjectChoices: []*Import{{VCSURL: String("vcsurl")}}, } - want := `{"vcs_url":"vcsurl","vcs":"vcs","vcs_username":"vcsusr","vcs_password":"vcspass","tfvc_project":"tfvcp","use_lfs":"uselfs","has_large_files":false,"large_files_size":1,"large_files_count":1,"status":"status","commit_count":1,"status_text":"statustxt","authors_count":1,"percent":1,"push_percent":1,"url":"url","html_url":"hurl","authors_url":"aurl","repository_url":"rurl","message":"msg","failed_step":"fs","human_name":"hn","project_choices":[{"vcs_url":"vcsurl"}]}` + want := `{ + "vcs_url":"vcsurl", + "vcs":"vcs", + "vcs_username":"vcsusr", + "vcs_password":"vcspass", + "tfvc_project":"tfvcp", + "use_lfs":"uselfs", + "has_large_files":false, + "large_files_size":1, + "large_files_count":1, + "status":"status", + "commit_count":1, + "status_text":"statustxt", + "authors_count":1, + "percent":1, + "push_percent":1, + "url":"url", + "html_url":"hurl", + "authors_url":"aurl", + "repository_url":"rurl", + "message":"msg", + "failed_step":"fs", + "human_name":"hn", + "project_choices":[ + { + "vcs_url":"vcsurl" + } + ] + }` testJSONMarshal(t, u, want) } diff --git a/github/migrations_test.go b/github/migrations_test.go index 2e5c6adcbf8..984fb371b61 100644 --- a/github/migrations_test.go +++ b/github/migrations_test.go @@ -267,7 +267,21 @@ func TestMigration_Marshal(t *testing.T) { Repositories: []*Repository{{ID: Int64(1)}}, } - want := `{"id":1,"guid":"guid","state":"state","lock_repositories":false,"exclude_attachments":false,"url":"url","created_at":"ca","updated_at":"ua","repositories":[{"id":1}]}` + want := `{ + "id":1, + "guid":"guid", + "state":"state", + "lock_repositories":false, + "exclude_attachments":false, + "url":"url", + "created_at":"ca", + "updated_at":"ua", + "repositories":[ + { + "id":1 + } + ] + }` testJSONMarshal(t, u, want) } @@ -281,7 +295,13 @@ func TestStartMigration_Marshal(t *testing.T) { ExcludeAttachments: Bool(false), } - want := `{"repositories":["r"],"lock_repositories":false,"exclude_attachments":false}` + want := `{ + "repositories":[ + "r" + ], + "lock_repositories":false, + "exclude_attachments":false + }` testJSONMarshal(t, u, want) } diff --git a/github/migrations_user_test.go b/github/migrations_user_test.go index 8d5d569ef43..722d31c642e 100644 --- a/github/migrations_user_test.go +++ b/github/migrations_user_test.go @@ -265,7 +265,21 @@ func TestUserMigration_Marshal(t *testing.T) { Repositories: []*Repository{{ID: Int64(1)}}, } - want := `{"id":1,"guid":"guid","state":"state","lock_repositories":false,"exclude_attachments":false,"url":"url","created_at":"ca","updated_at":"ua","repositories":[{"id":1}]}` + want := `{ + "id":1, + "guid":"guid", + "state":"state", + "lock_repositories":false, + "exclude_attachments":false, + "url":"url", + "created_at":"ca", + "updated_at":"ua", + "repositories":[ + { + "id":1 + } + ] + }` testJSONMarshal(t, u, want) } @@ -279,7 +293,13 @@ func TestStartUserMigration_Marshal(t *testing.T) { ExcludeAttachments: Bool(false), } - want := `{"repositories":["r"],"lock_repositories":false,"exclude_attachments":false}` + want := `{ + "repositories":[ + "r" + ], + "lock_repositories":false, + "exclude_attachments":false + }` testJSONMarshal(t, u, want) } diff --git a/github/misc_test.go b/github/misc_test.go index 838b765fbba..a5a8cc356e4 100644 --- a/github/misc_test.go +++ b/github/misc_test.go @@ -193,7 +193,39 @@ func TestAPIMeta_Marshal(t *testing.T) { API: []string{"a"}, Web: []string{"w"}, } - want := `{"hooks":["h"],"git":["g"],"verifiable_password_authentication":true,"pages":["p"],"importer":["i"],"actions":["a"],"dependabot":["d"],"ssh_key_fingerprints":{"a":"f"},"ssh_keys":["k"],"web":["w"],"api":["a"]}` + want := `{ + "hooks":[ + "h" + ], + "git":[ + "g" + ], + "verifiable_password_authentication":true, + "pages":[ + "p" + ], + "importer":[ + "i" + ], + "actions":[ + "a" + ], + "dependabot":[ + "d" + ], + "ssh_key_fingerprints":{ + "a":"f" + }, + "ssh_keys":[ + "k" + ], + "web":[ + "w" + ], + "api":[ + "a" + ] + }` testJSONMarshal(t, a, want) } @@ -356,7 +388,11 @@ func TestMarkdownRequest_Marshal(t *testing.T) { Context: String("ctx"), } - want := `{"text":"txt","mode":"mode","context":"ctx"}` + want := `{ + "text":"txt", + "mode":"mode", + "context":"ctx" + }` testJSONMarshal(t, a, want) } @@ -371,7 +407,12 @@ func TestCodeOfConduct_Marshal(t *testing.T) { Body: String("body"), } - want := `{"name":"name","key":"key","url":"url","body":"body"}` + want := `{ + "name":"name", + "key":"key", + "url":"url", + "body":"body" + }` testJSONMarshal(t, a, want) } @@ -385,7 +426,20 @@ func TestServiceHook_Marshal(t *testing.T) { SupportedEvents: []string{"se"}, Schema: [][]string{{"g"}}, } - want := `{"name":"name","events":["e"],"supported_events":["se"],"schema":[["g"]]}` + want := `{ + "name":"name", + "events":[ + "e" + ], + "supported_events":[ + "se" + ], + "schema":[ + [ + "g" + ] + ] + }` testJSONMarshal(t, a, want) } diff --git a/github/orgs_actions_allowed_test.go b/github/orgs_actions_allowed_test.go index 213912d12f8..d4c5f10a95b 100644 --- a/github/orgs_actions_allowed_test.go +++ b/github/orgs_actions_allowed_test.go @@ -101,7 +101,13 @@ func TestActionsAllowed_Marshal(t *testing.T) { PatternsAllowed: []string{"s"}, } - want := `{"github_owned_allowed":false,"verified_allowed":false,"patterns_allowed":["s"]}` + want := `{ + "github_owned_allowed":false, + "verified_allowed":false, + "patterns_allowed":[ + "s" + ] + }` testJSONMarshal(t, u, want) } @@ -115,7 +121,11 @@ func TestActionsPermissions_Marshal(t *testing.T) { SelectedActionsURL: String("sau"), } - want := `{"enabled_repositories":"e","allowed_actions":"a","selected_actions_url":"sau"}` + want := `{ + "enabled_repositories":"e", + "allowed_actions":"a", + "selected_actions_url":"sau" + }` testJSONMarshal(t, u, want) } diff --git a/github/orgs_audit_log_test.go b/github/orgs_audit_log_test.go index 9d5f14decb1..55d10f5dbd4 100644 --- a/github/orgs_audit_log_test.go +++ b/github/orgs_audit_log_test.go @@ -152,7 +152,11 @@ func TestHookConfig_Marshal(t *testing.T) { URL: String("url"), } - want := `{"content_type":"ct","insecure_ssl":"ct","url":"url"}` + want := `{ + "content_type":"ct", + "insecure_ssl":"ct", + "url":"url" + }` testJSONMarshal(t, u, want) } @@ -223,7 +227,80 @@ func TestAuditEntry_Marshal(t *testing.T) { WorkflowRunID: Int64(1), } - want := `{"action":"a","active":false,"active_was":false,"actor":"ac","blocked_user":"bu","business":"b","cancelled_at":` + referenceTimeStr + `,"completed_at":` + referenceTimeStr + `,"conclusion":"c","config":{"url":"s"},"config_was":{"url":"s"},"content_type":"ct","created_at":` + referenceTimeStr + `,"deploy_key_fingerprint":"dkf","_document_id":"did","emoji":"e","environment_name":"en","event":"e","events":["s"],"events_were":["s"],"explanation":"e","fingerprint":"f","head_branch":"hb","head_sha":"hsha","hook_id":1,"is_hosted_runner":false,"job_name":"jn","limited_availability":false,"message":"m","name":"n","old_user":"ou","old_permission":"op","openssh_public_key":"osshpk","org":"o","permission":"p","previous_visibility":"pv","read_only":"ro","repo":"r","repository":"repo","repository_public":false,"run_attempt":1,"runner_group_id":1,"runner_group_name":"rgn","runner_id":1,"runner_labels":["s"],"runner_name":"rn","secrets_passed":["s"],"source_version":"sv","started_at":` + referenceTimeStr + `,"target_login":"tl","target_version":"tv","team":"t","@timestamp":` + referenceTimeStr + `,"transport_protocol_name":"tpn","transport_protocol":1,"trigger_id":1,"user":"u","visibility":"v","workflow_id":1,"workflow_run_id":1}` + want := `{ + "action":"a", + "active":false, + "active_was":false, + "actor":"ac", + "blocked_user":"bu", + "business":"b", + "cancelled_at":` + referenceTimeStr + `, + "completed_at":` + referenceTimeStr + `, + "conclusion":"c", + "config":{ + "url":"s" + }, + "config_was":{ + "url":"s" + }, + "content_type":"ct", + "created_at":` + referenceTimeStr + `, + "deploy_key_fingerprint":"dkf", + "_document_id":"did", + "emoji":"e", + "environment_name":"en", + "event":"e", + "events":[ + "s" + ], + "events_were":[ + "s" + ], + "explanation":"e", + "fingerprint":"f", + "head_branch":"hb", + "head_sha":"hsha", + "hook_id":1, + "is_hosted_runner":false, + "job_name":"jn", + "limited_availability":false, + "message":"m", + "name":"n", + "old_user":"ou", + "old_permission":"op", + "openssh_public_key":"osshpk", + "org":"o", + "permission":"p", + "previous_visibility":"pv", + "read_only":"ro", + "repo":"r", + "repository":"repo", + "repository_public":false, + "run_attempt":1, + "runner_group_id":1, + "runner_group_name":"rgn", + "runner_id":1, + "runner_labels":[ + "s" + ], + "runner_name":"rn", + "secrets_passed":[ + "s" + ], + "source_version":"sv", + "started_at":` + referenceTimeStr + `, + "target_login":"tl", + "target_version":"tv", + "team":"t", + "@timestamp":` + referenceTimeStr + `, + "transport_protocol_name":"tpn", + "transport_protocol":1, + "trigger_id":1, + "user":"u", + "visibility":"v", + "workflow_id":1, + "workflow_run_id":1 + }` testJSONMarshal(t, u, want) } diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index 570e53e7e34..c356b7f49fb 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -891,7 +891,43 @@ func TestMembership_Marshal(t *testing.T) { }, } - want := `{"url":"url","state":"state","role":"email","organization_url":"orgurl","organization":{"name":"n","company":"c","blog":"b","location":"loc","email":"e","twitter_username":"tu","description":"d","billing_email":"be","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"drp","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"marct","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true},"user":{"login":"l","id":1,"node_id":"n","avatar_url":"a","url":"u","events_url":"e","repos_url":"r"}}` + want := `{ + "url":"url", + "state":"state", + "role":"email", + "organization_url":"orgurl", + "organization":{ + "name":"n", + "company":"c", + "blog":"b", + "location":"loc", + "email":"e", + "twitter_username":"tu", + "description":"d", + "billing_email":"be", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"drp", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"marct", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }, + "user":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "url":"u", + "events_url":"e", + "repos_url":"r" + } + }` testJSONMarshal(t, u, want) } @@ -906,7 +942,12 @@ func TestCreateOrgInvitationOptions_Marshal(t *testing.T) { TeamID: []int64{1}, } - want := `{"invitee_id":1,"email":"email","role":"role","team_ids":[1]}` + want := `{ + "invitee_id":1, + "email":"email", + "role":"role", + "team_ids":[1] + }` testJSONMarshal(t, u, want) } diff --git a/github/orgs_test.go b/github/orgs_test.go index b38de554f67..675963329ad 100644 --- a/github/orgs_test.go +++ b/github/orgs_test.go @@ -386,7 +386,14 @@ func TestOrganizationInstallations_Marshal(t *testing.T) { TotalCount: Int(1), Installations: []*Installation{{ID: Int64(1)}}, } - want := `{"total_count":1,"installations":[{"id":1}]}` + want := `{ + "total_count":1, + "installations":[ + { + "id":1 + } + ] + }` testJSONMarshal(t, o, want) } @@ -402,7 +409,14 @@ func TestPlan_Marshal(t *testing.T) { FilledSeats: Int(1), Seats: Int(1), } - want := `{"name":"name","space":1,"collaborators":1,"private_repos":1,"filled_seats":1,"seats":1}` + want := `{ + "name":"name", + "space":1, + "collaborators":1, + "private_repos":1, + "filled_seats":1, + "seats":1 + }` testJSONMarshal(t, o, want) } diff --git a/github/packages_test.go b/github/packages_test.go index db7b1239604..d3a52d0d32b 100644 --- a/github/packages_test.go +++ b/github/packages_test.go @@ -17,7 +17,13 @@ func TestPackageRegistry_Marshal(t *testing.T) { URL: String("url"), Vendor: String("vendor"), } - want := `{"about_url":"aurl","name":"name","type":"type","url":"url","vendor":"vendor"}` + want := `{ + "about_url":"aurl", + "name":"name", + "type":"type", + "url":"url", + "vendor":"vendor" + }` testJSONMarshal(t, o, want) } @@ -59,7 +65,39 @@ func TestPackageFile_Marshal(t *testing.T) { UpdatedAt: &Timestamp{referenceTime}, } - want := `{"download_url":"durl","id":1,"name":"name","sha256":"sha256","sha1":"sha1","md5":"md5","content_type":"ct","state":"state","author":{"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"},"size":1,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `}` + want := `{ + "download_url":"durl", + "id":1, + "name":"name", + "sha256":"sha256", + "sha1":"sha1", + "md5":"md5", + "content_type":"ct", + "state":"state", + "author":{ + "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" + }, + "size":1, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + }` testJSONMarshal(t, o, want) } @@ -100,7 +138,38 @@ func TestPackageRelease_Marshal(t *testing.T) { PublishedAt: &Timestamp{referenceTime}, } - want := `{"url":"url","html_url":"hurl","id":1,"tag_name":"tn","target_commitish":"tcs","name":"name","draft":true,"author":{"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"},"prerelease":true,"created_at":` + referenceTimeStr + `,"published_at":` + referenceTimeStr + `}` + want := `{ + "url":"url", + "html_url":"hurl", + "id":1, + "tag_name":"tn", + "target_commitish":"tcs", + "name":"name", + "draft":true, + "author":{ + "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" + }, + "prerelease":true, + "created_at":` + referenceTimeStr + `, + "published_at":` + referenceTimeStr + ` + }` testJSONMarshal(t, o, want) } @@ -213,7 +282,110 @@ func TestPackageVersion_Marshal(t *testing.T) { InstallationCommand: String("ic"), } - want := `{"id":1,"version":"ver","summary":"sum","body":"body","body_html":"btnhtml","release":{"url":"url","html_url":"hurl","id":1,"tag_name":"tn","target_commitish":"tcs","name":"name","draft":true,"author":{"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"},"prerelease":true,"created_at":` + referenceTimeStr + `,"published_at":` + referenceTimeStr + `},"manifest":"mani","html_url":"hurl","tag_name":"tn","target_commitish":"tcs","target_oid":"tid","draft":true,"prerelease":true,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"package_files":[{"download_url":"durl","id":1,"name":"name","sha256":"sha256","sha1":"sha1","md5":"md5","content_type":"ct","state":"state","author":{"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"},"size":1,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `}],"author":{"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"},"installation_command":"ic"}` + want := `{ + "id":1, + "version":"ver", + "summary":"sum", + "body":"body", + "body_html":"btnhtml", + "release":{ + "url":"url", + "html_url":"hurl", + "id":1, + "tag_name":"tn", + "target_commitish":"tcs", + "name":"name", + "draft":true, + "author":{ + "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" + }, + "prerelease":true, + "created_at":` + referenceTimeStr + `, + "published_at":` + referenceTimeStr + ` + }, + "manifest":"mani", + "html_url":"hurl", + "tag_name":"tn", + "target_commitish":"tcs", + "target_oid":"tid", + "draft":true, + "prerelease":true, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "package_files":[ + { + "download_url":"durl", + "id":1, + "name":"name", + "sha256":"sha256", + "sha1":"sha1", + "md5":"md5", + "content_type":"ct", + "state":"state", + "author":{ + "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" + }, + "size":1, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + } + ], + "author":{ + "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" + }, + "installation_command":"ic" + }` testJSONMarshal(t, o, want) } @@ -362,7 +534,146 @@ func TestPackage_Marshal(t *testing.T) { }, } - want := `{"id":1,"name":"name","package_type":"pt","html_url":"hurl","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"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"},"package_version":{"id":1,"version":"ver","summary":"sum","body":"body","body_html":"btnhtml","release":{"url":"url","html_url":"hurl","id":1,"tag_name":"tn","target_commitish":"tcs","name":"name","draft":true,"author":{"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"},"prerelease":true,"created_at":` + referenceTimeStr + `,"published_at":` + referenceTimeStr + `},"manifest":"mani","html_url":"hurl","tag_name":"tn","target_commitish":"tcs","target_oid":"tid","draft":true,"prerelease":true,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"package_files":[{"download_url":"durl","id":1,"name":"name","sha256":"sha256","sha1":"sha1","md5":"md5","content_type":"ct","state":"state","author":{"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"},"size":1,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `}],"author":{"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"},"installation_command":"ic"},"registry":{"about_url":"aurl","name":"name","type":"type","url":"url","vendor":"vendor"},"visibility":"private"}` + want := `{ + "id":1, + "name":"name", + "package_type":"pt", + "html_url":"hurl", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "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" + }, + "package_version":{ + "id":1, + "version":"ver", + "summary":"sum", + "body":"body", + "body_html":"btnhtml", + "release":{ + "url":"url", + "html_url":"hurl", + "id":1, + "tag_name":"tn", + "target_commitish":"tcs", + "name":"name", + "draft":true, + "author":{ + "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" + }, + "prerelease":true, + "created_at":` + referenceTimeStr + `, + "published_at":` + referenceTimeStr + ` + }, + "manifest":"mani", + "html_url":"hurl", + "tag_name":"tn", + "target_commitish":"tcs", + "target_oid":"tid", + "draft":true, + "prerelease":true, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "package_files":[ + { + "download_url":"durl", + "id":1, + "name":"name", + "sha256":"sha256", + "sha1":"sha1", + "md5":"md5", + "content_type":"ct", + "state":"state", + "author":{ + "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" + }, + "size":1, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + } + ], + "author":{ + "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" + }, + "installation_command":"ic" + }, + "registry":{ + "about_url":"aurl", + "name":"name", + "type":"type", + "url":"url", + "vendor":"vendor" + }, + "visibility":"private" + }` testJSONMarshal(t, o, want) } diff --git a/github/projects_test.go b/github/projects_test.go index 3f8c041bf0f..56315d59063 100644 --- a/github/projects_test.go +++ b/github/projects_test.go @@ -830,7 +830,13 @@ func TestProjectOptions_Marshal(t *testing.T) { Private: Bool(false), } - want := `{"name":"name","body":"body","state":"state","organization_permission":"op","private":false}` + want := `{ + "name":"name", + "body":"body", + "state":"state", + "organization_permission":"op", + "private":false + }` testJSONMarshal(t, u, want) } @@ -849,7 +855,16 @@ func TestProjectColumn_Marshal(t *testing.T) { NodeID: String("onidp"), } - want := `{"id":1,"name":"name","url":"url","project_url":"purl","cards_url":"curl","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"node_id":"onidp"}` + want := `{ + "id":1, + "name":"name", + "url":"url", + "project_url":"purl", + "cards_url":"curl", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "node_id":"onidp" + }` testJSONMarshal(t, u, want) } @@ -918,7 +933,42 @@ func TestProjectCard_Marshal(t *testing.T) { PreviousColumnName: String("pcn"), } - want := `{"url":"url","column_url":"curl","content_url":"conurl","id":1,"note":"note","creator":{"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"},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"node_id":"nid","archived":true,"column_id":1,"project_id":1,"project_url":"purl","column_name":"cn","previous_column_name":"pcn"}` + want := `{ + "url":"url", + "column_url":"curl", + "content_url":"conurl", + "id":1, + "note":"note", + "creator":{ + "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" + }, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "node_id":"nid", + "archived":true, + "column_id":1, + "project_id":1, + "project_url":"purl", + "column_name":"cn", + "previous_column_name":"pcn" + }` testJSONMarshal(t, u, want) } @@ -933,7 +983,12 @@ func TestProjectCardOptions_Marshal(t *testing.T) { Archived: Bool(false), } - want := `{"note":"note","content_id":1,"content_type":"ct","archived":false}` + want := `{ + "note":"note", + "content_id":1, + "content_type":"ct", + "archived":false + }` testJSONMarshal(t, u, want) } @@ -946,7 +1001,10 @@ func TestProjectCardMoveOptions_Marshal(t *testing.T) { ColumnID: 1, } - want := `{"position":"pos","column_id":1}` + want := `{ + "position":"pos", + "column_id":1 + }` testJSONMarshal(t, u, want) } @@ -990,7 +1048,29 @@ func TestProjectPermissionLevel_Marshal(t *testing.T) { }, } - want := `{"permission":"per","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"}}` + want := `{ + "permission":"per", + "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) } diff --git a/github/pulls_comments_test.go b/github/pulls_comments_test.go index 8e77f5b14d5..f498707ffbb 100644 --- a/github/pulls_comments_test.go +++ b/github/pulls_comments_test.go @@ -77,7 +77,58 @@ func TestPullComments_Marshal(t *testing.T) { PullRequestURL: String("pullrequestcommentPullRequestURL"), } - want := `{"id":10,"in_reply_to_id":8,"body":"Test comment","path":"file1.txt","diff_hunk":"@@ -16,33 +16,40 @@ fmt.Println()","pull_request_review_id":42,"position":1,"original_position":4,"start_line":2,"line":3,"original_line":2,"original_start_line":2,"side":"RIGHT","start_side":"LEFT","commit_id":"ab","original_commit_id":"9c","user":{"login":"ll","id":123,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"},"reactions":{"total_count":1,"+1":1,"-1":0,"laugh":0,"confused":0,"heart":0,"hooray":0,"rocket":0,"eyes":0,"url":"u"},"created_at":"2002-02-10T15:30:00Z","updated_at":"2002-02-10T15:30:00Z","url":"pullrequestcommentUrl","html_url":"pullrequestcommentHTMLUrl","pull_request_url":"pullrequestcommentPullRequestURL"}` + want := `{ + "id":10, + "in_reply_to_id":8, + "body":"Test comment", + "path":"file1.txt", + "diff_hunk":"@@ -16,33 +16,40 @@ fmt.Println()", + "pull_request_review_id":42, + "position":1, + "original_position":4, + "start_line":2, + "line":3, + "original_line":2, + "original_start_line":2, + "side":"RIGHT", + "start_side":"LEFT", + "commit_id":"ab", + "original_commit_id":"9c", + "user":{ + "login":"ll", + "id":123, + "avatar_url":"a", + "gravatar_id":"g", + "name":"n", + "company":"c", + "blog":"b", + "location":"l", + "email":"e", + "hireable":true, + "public_repos":1, + "followers":1, + "following":1, + "created_at":` + referenceTimeStr + `, + "url":"u" + }, + "reactions":{ + "total_count":1, + "+1":1, + "-1":0, + "laugh":0, + "confused":0, + "heart":0, + "hooray":0, + "rocket":0, + "eyes":0, + "url":"u" + }, + "created_at":"2002-02-10T15:30:00Z", + "updated_at":"2002-02-10T15:30:00Z", + "url":"pullrequestcommentUrl", + "html_url":"pullrequestcommentHTMLUrl", + "pull_request_url":"pullrequestcommentPullRequestURL" + }` testJSONMarshal(t, u, want) } diff --git a/github/pulls_reviewers_test.go b/github/pulls_reviewers_test.go index 13e0bdcafcc..76f583bda1f 100644 --- a/github/pulls_reviewers_test.go +++ b/github/pulls_reviewers_test.go @@ -23,7 +23,15 @@ func TestReviewersRequest_Marshal(t *testing.T) { TeamReviewers: []string{"t"}, } - want := `{"node_id":"n","reviewers":["r"],"team_reviewers":["t"]}` + want := `{ + "node_id":"n", + "reviewers":[ + "r" + ], + "team_reviewers":[ + "t" + ] + }` testJSONMarshal(t, u, want) } @@ -68,7 +76,44 @@ func TestReviewers_Marshal(t *testing.T) { }}, } - want := `{"users":[{"login":"l","id":1,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"}],"teams":[{"id":1,"node_id":"node","name":"n","description":"d","url":"u","slug":"s","permission":"p","privacy":"priv","members_count":1,"repos_count":1,"members_url":"m","repositories_url":"r","ldap_dn":"l"}]}` + want := `{ + "users":[ + { + "login":"l", + "id":1, + "avatar_url":"a", + "gravatar_id":"g", + "name":"n", + "company":"c", + "blog":"b", + "location":"l", + "email":"e", + "hireable":true, + "public_repos":1, + "followers":1, + "following":1, + "created_at":` + referenceTimeStr + `, + "url":"u" + } + ], + "teams":[ + { + "id":1, + "node_id":"node", + "name":"n", + "description":"d", + "url":"u", + "slug":"s", + "permission":"p", + "privacy":"priv", + "members_count":1, + "repos_count":1, + "members_url":"m", + "repositories_url":"r", + "ldap_dn":"l" + } + ] + }` testJSONMarshal(t, u, want) } diff --git a/github/pulls_test.go b/github/pulls_test.go index a43ded020ad..5d1063202d9 100644 --- a/github/pulls_test.go +++ b/github/pulls_test.go @@ -852,7 +852,12 @@ func TestPullRequestMergeRequest_Marshal(t *testing.T) { SHA: "sha", } - want := `{"commit_message":"cm","commit_title":"ct","merge_method":"mm","sha":"sha"}` + want := `{ + "commit_message":"cm", + "commit_title":"ct", + "merge_method":"mm", + "sha":"sha" + }` testJSONMarshal(t, u, want) } @@ -866,7 +871,11 @@ func TestPullRequestMergeResult_Marshal(t *testing.T) { Message: String("msg"), } - want := `{"sha":"sha","merged":false,"message":"msg"}` + want := `{ + "sha":"sha", + "merged":false, + "message":"msg" + }` testJSONMarshal(t, u, want) } @@ -882,7 +891,13 @@ func TestPullRequestUpdate_Marshal(t *testing.T) { MaintainerCanModify: Bool(false), } - want := `{"title":"title","body":"body","state":"state","base":"base","maintainer_can_modify":false}` + want := `{ + "title":"title", + "body":"body", + "state":"state", + "base":"base", + "maintainer_can_modify":false + }` testJSONMarshal(t, u, want) } @@ -895,7 +910,10 @@ func TestPullRequestBranchUpdateResponse_Marshal(t *testing.T) { URL: String("url"), } - want := `{"message":"message","url":"url"}` + want := `{ + "message":"message", + "url":"url" + }` testJSONMarshal(t, u, want) } @@ -925,7 +943,15 @@ func TestNewPullRequest_Marshal(t *testing.T) { Draft: Bool(false), } - want := `{"title":"eh","head":"eh","base":"eh","body":"eh","issue":1,"maintainer_can_modify":false,"draft":false}` + want := `{ + "title":"eh", + "head":"eh", + "base":"eh", + "body":"eh", + "issue":1, + "maintainer_can_modify":false, + "draft":false + }` testJSONMarshal(t, u, want) } @@ -960,7 +986,34 @@ func TestPullRequestBranch_Marshal(t *testing.T) { }, } - want := `{"label":"label","ref":"ref","sha":"sha","repo":{"id":1},"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"}}` + want := `{ + "label":"label", + "ref":"ref", + "sha":"sha", + "repo":{ + "id":1 + }, + "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) } @@ -1007,7 +1060,32 @@ func TestPRLinks_Marshal(t *testing.T) { }, } - want := `{"self":{"href":"href"},"html":{"href":"href"},"issue":{"href":"href"},"comments":{"href":"href"},"review_comments":{"href":"href"},"review_comment":{"href":"href"},"commits":{"href":"href"},"statuses":{"href":"href"}}` + want := `{ + "self":{ + "href":"href" + }, + "html":{ + "href":"href" + }, + "issue":{ + "href":"href" + }, + "comments":{ + "href":"href" + }, + "review_comments":{ + "href":"href" + }, + "review_comment":{ + "href":"href" + }, + "commits":{ + "href":"href" + }, + "statuses":{ + "href":"href" + } + }` testJSONMarshal(t, u, want) } @@ -1041,7 +1119,31 @@ func TestPullRequestAutoMerge_Marshal(t *testing.T) { CommitMessage: String("cm"), } - want := `{"enabled_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"},"merge_method":"mm","commit_title":"ct","commit_message":"cm"}` + want := `{ + "enabled_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" + }, + "merge_method":"mm", + "commit_title":"ct", + "commit_message":"cm" + }` testJSONMarshal(t, u, want) } @@ -1254,7 +1356,224 @@ func TestPullRequest_Marshal(t *testing.T) { ActiveLockReason: String("alr"), } - want := `{"id":1,"number":1,"state":"state","locked":false,"title":"title","body":"body","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"closed_at":` + referenceTimeStr + `,"merged_at":` + referenceTimeStr + `,"labels":[{"id":1}],"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"},"draft":false,"merged":false,"mergeable":false,"mergeable_state":"ms","merged_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"},"merge_commit_sha":"mcs","rebaseable":false,"comments":1,"commits":1,"additions":1,"deletions":1,"changed_files":1,"url":"url","html_url":"hurl","issue_url":"iurl","statuses_url":"surl","diff_url":"durl","patch_url":"purl","commits_url":"curl","comments_url":"comurl","review_comments_url":"rcurls","review_comment_url":"rcurl","review_comments":1,"assignee":{"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"},"assignees":[{"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"}],"milestone":{"id":1},"maintainer_can_modify":true,"author_association":"aa","node_id":"nid","requested_reviewers":[{"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"}],"auto_merge":{"enabled_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"},"merge_method":"mm","commit_title":"ct","commit_message":"cm"},"requested_teams":[{"id":1}],"_links":{"self":{"href":"href"},"html":{"href":"href"},"issue":{"href":"href"},"comments":{"href":"href"},"review_comments":{"href":"href"},"review_comment":{"href":"href"},"commits":{"href":"href"},"statuses":{"href":"href"}},"head":{"ref":"r2","repo":{"id":2}},"base":{"ref":"r2","repo":{"id":2}},"active_lock_reason":"alr"}` + want := `{ + "id":1, + "number":1, + "state":"state", + "locked":false, + "title":"title", + "body":"body", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "closed_at":` + referenceTimeStr + `, + "merged_at":` + referenceTimeStr + `, + "labels":[ + { + "id":1 + } + ], + "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" + }, + "draft":false, + "merged":false, + "mergeable":false, + "mergeable_state":"ms", + "merged_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" + }, + "merge_commit_sha":"mcs", + "rebaseable":false, + "comments":1, + "commits":1, + "additions":1, + "deletions":1, + "changed_files":1, + "url":"url", + "html_url":"hurl", + "issue_url":"iurl", + "statuses_url":"surl", + "diff_url":"durl", + "patch_url":"purl", + "commits_url":"curl", + "comments_url":"comurl", + "review_comments_url":"rcurls", + "review_comment_url":"rcurl", + "review_comments":1, + "assignee":{ + "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" + }, + "assignees":[ + { + "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" + } + ], + "milestone":{ + "id":1 + }, + "maintainer_can_modify":true, + "author_association":"aa", + "node_id":"nid", + "requested_reviewers":[ + { + "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" + } + ], + "auto_merge":{ + "enabled_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" + }, + "merge_method":"mm", + "commit_title":"ct", + "commit_message":"cm" + }, + "requested_teams":[ + { + "id":1 + } + ], + "_links":{ + "self":{ + "href":"href" + }, + "html":{ + "href":"href" + }, + "issue":{ + "href":"href" + }, + "comments":{ + "href":"href" + }, + "review_comments":{ + "href":"href" + }, + "review_comment":{ + "href":"href" + }, + "commits":{ + "href":"href" + }, + "statuses":{ + "href":"href" + } + }, + "head":{ + "ref":"r2", + "repo":{ + "id":2 + } + }, + "base":{ + "ref":"r2", + "repo":{ + "id":2 + } + }, + "active_lock_reason":"alr" + }` testJSONMarshal(t, u, want) } diff --git a/github/pulls_threads_test.go b/github/pulls_threads_test.go index 810e146c571..8afe87d6cad 100644 --- a/github/pulls_threads_test.go +++ b/github/pulls_threads_test.go @@ -76,7 +76,116 @@ func TestPullRequestThread_Marshal(t *testing.T) { Comments: []*PullRequestComment{comment, comment}, } - want := `{"id":1,"node_id":"nid","comments":[{"id":10,"in_reply_to_id":8,"body":"Test comment","path":"file1.txt","diff_hunk":"@@ -16,33 +16,40 @@ fmt.Println()","pull_request_review_id":42,"position":1,"original_position":4,"start_line":2,"line":3,"original_line":2,"original_start_line":2,"side":"RIGHT","start_side":"LEFT","commit_id":"ab","original_commit_id":"9c","user":{"login":"ll","id":123,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"},"reactions":{"total_count":1,"+1":1,"-1":0,"laugh":0,"confused":0,"heart":0,"hooray":0,"rocket":0,"eyes":0,"url":"u"},"created_at":"2002-02-10T15:30:00Z","updated_at":"2002-02-10T15:30:00Z","url":"pullrequestcommentUrl","html_url":"pullrequestcommentHTMLUrl","pull_request_url":"pullrequestcommentPullRequestURL"},{"id":10,"in_reply_to_id":8,"body":"Test comment","path":"file1.txt","diff_hunk":"@@ -16,33 +16,40 @@ fmt.Println()","pull_request_review_id":42,"position":1,"original_position":4,"start_line":2,"line":3,"original_line":2,"original_start_line":2,"side":"RIGHT","start_side":"LEFT","commit_id":"ab","original_commit_id":"9c","user":{"login":"ll","id":123,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"},"reactions":{"total_count":1,"+1":1,"-1":0,"laugh":0,"confused":0,"heart":0,"hooray":0,"rocket":0,"eyes":0,"url":"u"},"created_at":"2002-02-10T15:30:00Z","updated_at":"2002-02-10T15:30:00Z","url":"pullrequestcommentUrl","html_url":"pullrequestcommentHTMLUrl","pull_request_url":"pullrequestcommentPullRequestURL"}]}` + want := `{ + "id":1, + "node_id":"nid", + "comments":[ + { + "id":10, + "in_reply_to_id":8, + "body":"Test comment", + "path":"file1.txt", + "diff_hunk":"@@ -16,33 +16,40 @@ fmt.Println()", + "pull_request_review_id":42, + "position":1, + "original_position":4, + "start_line":2, + "line":3, + "original_line":2, + "original_start_line":2, + "side":"RIGHT", + "start_side":"LEFT", + "commit_id":"ab", + "original_commit_id":"9c", + "user":{ + "login":"ll", + "id":123, + "avatar_url":"a", + "gravatar_id":"g", + "name":"n", + "company":"c", + "blog":"b", + "location":"l", + "email":"e", + "hireable":true, + "public_repos":1, + "followers":1, + "following":1, + "created_at":` + referenceTimeStr + `, + "url":"u" + }, + "reactions":{ + "total_count":1, + "+1":1, + "-1":0, + "laugh":0, + "confused":0, + "heart":0, + "hooray":0, + "rocket":0, + "eyes":0, + "url":"u" + }, + "created_at":"2002-02-10T15:30:00Z", + "updated_at":"2002-02-10T15:30:00Z", + "url":"pullrequestcommentUrl", + "html_url":"pullrequestcommentHTMLUrl", + "pull_request_url":"pullrequestcommentPullRequestURL" + }, + { + "id":10, + "in_reply_to_id":8, + "body":"Test comment", + "path":"file1.txt", + "diff_hunk":"@@ -16,33 +16,40 @@ fmt.Println()", + "pull_request_review_id":42, + "position":1, + "original_position":4, + "start_line":2, + "line":3, + "original_line":2, + "original_start_line":2, + "side":"RIGHT", + "start_side":"LEFT", + "commit_id":"ab", + "original_commit_id":"9c", + "user":{ + "login":"ll", + "id":123, + "avatar_url":"a", + "gravatar_id":"g", + "name":"n", + "company":"c", + "blog":"b", + "location":"l", + "email":"e", + "hireable":true, + "public_repos":1, + "followers":1, + "following":1, + "created_at":` + referenceTimeStr + `, + "url":"u" + }, + "reactions":{ + "total_count":1, + "+1":1, + "-1":0, + "laugh":0, + "confused":0, + "heart":0, + "hooray":0, + "rocket":0, + "eyes":0, + "url":"u" + }, + "created_at":"2002-02-10T15:30:00Z", + "updated_at":"2002-02-10T15:30:00Z", + "url":"pullrequestcommentUrl", + "html_url":"pullrequestcommentHTMLUrl", + "pull_request_url":"pullrequestcommentPullRequestURL" + } + ] + }` testJSONMarshal(t, u, want) } diff --git a/github/reactions_test.go b/github/reactions_test.go index 6abd56faf0e..c3b7eab4479 100644 --- a/github/reactions_test.go +++ b/github/reactions_test.go @@ -24,7 +24,11 @@ func TestReaction_Marshal(t *testing.T) { Content: String("+1"), } - want := `{"id":1,"node_id":"n","content":"+1"}` + want := `{ + "id":1, + "node_id":"n", + "content":"+1" + }` testJSONMarshal(t, r, want) } @@ -45,7 +49,18 @@ func TestReactions_Marshal(t *testing.T) { URL: String("u"), } - want := `{"total_count":1,"+1":1,"-1":1,"laugh":1,"confused":1,"heart":1,"hooray":1,"rocket":1,"eyes":1,"url":"u"}` + want := `{ + "total_count":1, + "+1":1, + "-1":1, + "laugh":1, + "confused":1, + "heart":1, + "hooray":1, + "rocket":1, + "eyes":1, + "url":"u" + }` testJSONMarshal(t, r, want) } diff --git a/github/repos_actions_permissions_test.go b/github/repos_actions_permissions_test.go index 086c6453d59..753a603f4c2 100644 --- a/github/repos_actions_permissions_test.go +++ b/github/repos_actions_permissions_test.go @@ -102,7 +102,11 @@ func TestActionsPermissionsRepository_Marshal(t *testing.T) { SelectedActionsURL: String("someURL"), } - want := `{"enabled":true,"allowed_actions":"all","selected_actions_url":"someURL"}` + want := `{ + "enabled":true, + "allowed_actions":"all", + "selected_actions_url":"someURL" + }` testJSONMarshal(t, u, want) } diff --git a/github/repos_autolinks_test.go b/github/repos_autolinks_test.go index 3a902fdb1ea..82378c7a4c5 100644 --- a/github/repos_autolinks_test.go +++ b/github/repos_autolinks_test.go @@ -173,7 +173,11 @@ func TestAutolinkOptions_Marshal(t *testing.T) { IsAlphanumeric: Bool(true), } - want := `{"key_prefix":"kp","url_template":"URLT","is_alphanumeric":true}` + want := `{ + "key_prefix":"kp", + "url_template":"URLT", + "is_alphanumeric":true + }` testJSONMarshal(t, r, want) } @@ -188,7 +192,12 @@ func TestAutolink_Marshal(t *testing.T) { IsAlphanumeric: Bool(true), } - want := `{"id":1,"key_prefix":"kp","url_template":"URLT","is_alphanumeric":true}` + want := `{ + "id":1," + key_prefix":"kp", + "url_template":"URLT", + "is_alphanumeric":true + }` testJSONMarshal(t, r, want) } diff --git a/github/repos_codeowners_test.go b/github/repos_codeowners_test.go index 78dde42ef71..22cbe89463d 100644 --- a/github/repos_codeowners_test.go +++ b/github/repos_codeowners_test.go @@ -92,7 +92,19 @@ func TestCodeownersErrors_Marshal(t *testing.T) { }, } - want := `{"errors":[{"line":1,"column":1,"kind":"Invalid pattern","source":"***/*.rb @monalisa","suggestion":"Did you mean **/*.rb?","message":"Invalid pattern on line 3: Did you mean **/*.rb?\n\n ***/*.rb @monalisa\n ^","path":".github/CODEOWNERS"}]}` + want := `{ + "errors":[ + { + "line":1, + "column":1, + "kind":"Invalid pattern", + "source":"***/*.rb @monalisa", + "suggestion":"Did you mean **/*.rb?", + "message":"Invalid pattern on line 3: Did you mean **/*.rb?\n\n ***/*.rb @monalisa\n ^", + "path":".github/CODEOWNERS" + } + ] + }` testJSONMarshal(t, u, want) } diff --git a/github/repos_collaborators_test.go b/github/repos_collaborators_test.go index c1091972b81..3cf42b86e73 100644 --- a/github/repos_collaborators_test.go +++ b/github/repos_collaborators_test.go @@ -401,7 +401,29 @@ func TestRepositoryPermissionLevel_Marshal(t *testing.T) { }, } - want := `{"permission":"permission","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"}}` + want := `{ + "permission":"permission", + "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, r, want) } @@ -463,7 +485,58 @@ func TestCollaboratorInvitation_Marshal(t *testing.T) { HTMLURL: String("hurl"), } - want := `{"id":1,"repository":{"id":1,"name":"n","url":"url"},"invitee":{"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"},"inviter":{"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"},"permissions":"per","created_at":` + referenceTimeStr + `,"url":"url","html_url":"hurl"}` + want := `{ + "id":1, + "repository":{ + "id":1, + "name":"n", + "url":"url" + }, + "invitee":{ + "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" + }, + "inviter":{ + "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" + }, + "permissions":"per", + "created_at":` + referenceTimeStr + `, + "url":"url", + "html_url":"hurl" + }` testJSONMarshal(t, r, want) } diff --git a/github/repos_comments_test.go b/github/repos_comments_test.go index d014d426925..3a8d4838ba4 100644 --- a/github/repos_comments_test.go +++ b/github/repos_comments_test.go @@ -342,7 +342,50 @@ func TestRepositoryComment_Marshal(t *testing.T) { Position: Int(1), } - want := `{"html_url":"hurl","url":"url","id":1,"node_id":"nid","commit_id":"cid","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"},"reactions":{"total_count":1,"+1":1,"-1":1,"laugh":1,"confused":1,"heart":1,"hooray":1,"rocket":1,"eyes":1,"url":"u"},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"body":"body","path":"path","position":1}` + want := `{ + "html_url":"hurl", + "url":"url", + "id":1, + "node_id":"nid", + "commit_id":"cid", + "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" + }, + "reactions":{ + "total_count":1, + "+1":1, + "-1":1, + "laugh":1, + "confused":1, + "heart":1, + "hooray":1, + "rocket":1, + "eyes":1, + "url":"u" + }, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "body":"body", + "path":"path", + "position":1 + }` testJSONMarshal(t, r, want) } diff --git a/github/repos_commits_test.go b/github/repos_commits_test.go index 9f6a20c28f0..92b2859d9f6 100644 --- a/github/repos_commits_test.go +++ b/github/repos_commits_test.go @@ -718,7 +718,56 @@ func TestBranchCommit_Marshal(t *testing.T) { Protected: Bool(false), } - want := `{"name":"n","commit":{"sha":"s","author":{"date":` + referenceTimeStr + `,"name":"n","email":"e","username":"u"},"committer":{"date":` + referenceTimeStr + `,"name":"n","email":"e","username":"u"},"message":"m","tree":{"sha":"s","tree":[{"sha":"s","path":"p","mode":"m","type":"t","size":1,"content":"c","url":"u"}],"truncated":false},"stats":{"additions":1,"deletions":1,"total":1},"html_url":"h","url":"u","verification":{"verified":false,"reason":"r","signature":"s","payload":"p"},"node_id":"n","comment_count":1},"protected":false}` + want := `{ + "name":"n", + "commit":{ + "sha":"s", + "author":{ + "date":` + referenceTimeStr + `, + "name":"n", + "email":"e", + "username":"u" + }, + "committer":{ + "date":` + referenceTimeStr + `, + "name":"n", + "email":"e", + "username":"u" + }, + "message":"m", + "tree":{ + "sha":"s", + "tree":[ + { + "sha":"s", + "path":"p", + "mode":"m", + "type":"t", + "size":1, + "content":"c", + "url":"u" + } + ], + "truncated":false + }, + "stats":{ + "additions":1, + "deletions":1, + "total":1 + }, + "html_url":"h", + "url":"u", + "verification":{ + "verified":false, + "reason":"r", + "signature":"s", + "payload":"p" + }, + "node_id":"n", + "comment_count":1 + }, + "protected":false + }` testJSONMarshal(t, r, want) } @@ -750,7 +799,33 @@ func TestCommitsComparison_Marshal(t *testing.T) { URL: String("url"), } - want := `{"base_commit":{"node_id":"nid"},"merge_base_commit":{"node_id":"nid"},"status":"status","ahead_by":1,"behind_by":1,"total_commits":1,"commits":[{"node_id":"nid"}],"files":[{"sha":"sha"}],"html_url":"hurl","permalink_url":"purl","diff_url":"durl","patch_url":"purl","url":"url"}` + want := `{ + "base_commit":{ + "node_id":"nid" + }, + "merge_base_commit":{ + "node_id":"nid" + }, + "status":"status", + "ahead_by":1, + "behind_by":1, + "total_commits":1, + "commits":[ + { + "node_id":"nid" + } + ], + "files":[ + { + "sha":"sha" + } + ], + "html_url":"hurl", + "permalink_url":"purl", + "diff_url":"durl", + "patch_url":"purl", + "url":"url" + }` testJSONMarshal(t, r, want) } @@ -772,7 +847,19 @@ func TestCommitFile_Marshal(t *testing.T) { PreviousFilename: String("pf"), } - want := `{"sha":"sha","filename":"fn","additions":1,"deletions":1,"changes":1,"status":"status","patch":"patch","blob_url":"burl","raw_url":"rurl","contents_url":"curl","previous_filename":"pf"}` + want := `{ + "sha":"sha", + "filename":"fn", + "additions":1, + "deletions":1, + "changes":1, + "status":"status", + "patch":"patch", + "blob_url":"burl", + "raw_url":"rurl", + "contents_url":"curl", + "previous_filename":"pf" + }` testJSONMarshal(t, r, want) } @@ -786,7 +873,11 @@ func TestCommitStats_Marshal(t *testing.T) { Total: Int(1), } - want := `{"additions":1,"deletions":1,"total":1}` + want := `{ + "additions":1, + "deletions":1, + "total":1 + }` testJSONMarshal(t, r, want) } @@ -834,7 +925,45 @@ func TestRepositoryCommit_Marshal(t *testing.T) { }, } - want := `{"node_id":"nid","sha":"sha","commit":{"message":"m"},"author":{"login":"l"},"committer":{"login":"l"},"parents":[{"sha":"s"}],"html_url":"hurl","url":"url","comments_url":"curl","stats":{"additions":104,"deletions":4,"total":108},"files":[{"filename":"f","additions":10,"deletions":2,"changes":12,"status":"s","patch":"p","blob_url":"b","raw_url":"r","contents_url":"c"}]}` + want := `{ + "node_id":"nid", + "sha":"sha", + "commit":{ + "message":"m" + }, + "author":{ + "login":"l" + }, + "committer":{ + "login":"l" + }, + "parents":[ + { + "sha":"s" + } + ], + "html_url":"hurl", + "url":"url", + "comments_url":"curl", + "stats":{ + "additions":104, + "deletions":4, + "total":108 + }, + "files":[ + { + "filename":"f", + "additions":10, + "deletions":2, + "changes":12, + "status":"s", + "patch":"p", + "blob_url":"b", + "raw_url":"r", + "contents_url":"c" + } + ] + }` testJSONMarshal(t, r, want) } diff --git a/github/repos_community_health_test.go b/github/repos_community_health_test.go index 6420d57c010..100820b41e8 100644 --- a/github/repos_community_health_test.go +++ b/github/repos_community_health_test.go @@ -134,7 +134,14 @@ func TestRepositoriesService_GetCommunityHealthMetrics(t *testing.T) { } func TestMetric_Marshal(t *testing.T) { - testJSONMarshal(t, &Metric{}, `{"name":null,"key":null,"spdx_id":null,"url":null,"html_url":null,"node_id":null}`) + testJSONMarshal(t, &Metric{}, `{ + "name":null, + "key":null, + "spdx_id":null, + "url":null, + "html_url":null, + "node_id":null + }`) r := &Metric{ Name: String("name"), @@ -145,13 +152,28 @@ func TestMetric_Marshal(t *testing.T) { NodeID: String("node_id"), } - want := `{"name":"name","key":"key","spdx_id":"spdx_id","url":"url","html_url":"hurl","node_id":"node_id"}` + want := `{ + "name":"name", + "key":"key", + "spdx_id":"spdx_id", + "url":"url", + "html_url":"hurl", + "node_id":"node_id" + }` testJSONMarshal(t, r, want) } func TestCommunityHealthFiles_Marshal(t *testing.T) { - testJSONMarshal(t, &CommunityHealthFiles{}, `{"code_of_conduct":null,"code_of_conduct_file":null,"contributing":null,"issue_template":null,"pull_request_template":null,"license":null,"readme":null}`) + testJSONMarshal(t, &CommunityHealthFiles{}, `{ + "code_of_conduct":null, + "code_of_conduct_file":null, + "contributing":null, + "issue_template":null, + "pull_request_template":null, + "license":null, + "readme":null + }`) r := &CommunityHealthFiles{ CodeOfConduct: &Metric{ @@ -200,13 +222,77 @@ func TestCommunityHealthFiles_Marshal(t *testing.T) { }, } - want := `{"code_of_conduct":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"code_of_conduct_file":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"contributing":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"issue_template":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"pull_request_template":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"license":{"name":"name","key":"key","spdx_id":"spdx_id","url":"url","html_url":"hurl","node_id":"node_id"},"readme":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null}}` + want := `{ + "code_of_conduct":{ + "name":"name", + "key":"key", + "spdx_id":null, + "url":"url", + "html_url":"hurl", + "node_id":null + }, + "code_of_conduct_file":{ + "name":"name", + "key":"key", + "spdx_id":null, + "url":"url", + "html_url":"hurl", + "node_id":null + }, + "contributing":{ + "name":"name", + "key":"key", + "spdx_id":null, + "url":"url", + "html_url":"hurl", + "node_id":null + }, + "issue_template":{ + "name":"name", + "key":"key", + "spdx_id":null, + "url":"url", + "html_url":"hurl", + "node_id":null + }, + "pull_request_template":{ + "name":"name", + "key":"key", + "spdx_id":null, + "url":"url", + "html_url":"hurl", + "node_id":null + }, + "license":{ + "name":"name", + "key":"key", + "spdx_id":"spdx_id", + "url":"url", + "html_url":"hurl", + "node_id":"node_id" + }, + "readme":{ + "name":"name", + "key":"key", + "spdx_id":null, + "url":"url", + "html_url":"hurl", + "node_id":null + } + }` testJSONMarshal(t, r, want) } func TestCommunityHealthMetrics_Marshal(t *testing.T) { - testJSONMarshal(t, &CommunityHealthMetrics{}, `{"health_percentage":null,"description":null,"documentation":null,"files":null,"updated_at":null,"content_reports_enabled":null}`) + testJSONMarshal(t, &CommunityHealthMetrics{}, `{ + "health_percentage":null, + "description":null, + "documentation":null, + "files":null, + "updated_at":null, + "content_reports_enabled":null + }`) r := &CommunityHealthMetrics{ HealthPercentage: Int(1), @@ -262,7 +348,71 @@ func TestCommunityHealthMetrics_Marshal(t *testing.T) { ContentReportsEnabled: Bool(true), } - want := `{"health_percentage":1,"description":"desc","documentation":"docs","files":{"code_of_conduct":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"code_of_conduct_file":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"contributing":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"issue_template":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"pull_request_template":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null},"license":{"name":"name","key":"key","spdx_id":"spdx_id","url":"url","html_url":"hurl","node_id":"node_id"},"readme":{"name":"name","key":"key","spdx_id":null,"url":"url","html_url":"hurl","node_id":null}},"updated_at":` + referenceTimeStr + `,"content_reports_enabled":true}` + want := `{ + "health_percentage":1, + "description":"desc", + "documentation":"docs", + "files":{ + "code_of_conduct":{ + "name":"name", + "key":"key", + "spdx_id":null, + "url":"url", + "html_url":"hurl", + "node_id":null + }, + "code_of_conduct_file":{ + "name":"name", + "key":"key", + "spdx_id":null, + "url":"url", + "html_url":"hurl", + "node_id":null + }, + "contributing":{ + "name":"name", + "key":"key", + "spdx_id":null, + "url":"url", + "html_url":"hurl", + "node_id":null + }, + "issue_template":{ + "name":"name", + "key":"key", + "spdx_id":null, + "url":"url", + "html_url":"hurl", + "node_id":null + }, + "pull_request_template":{ + "name":"name", + "key":"key", + "spdx_id":null, + "url":"url", + "html_url":"hurl", + "node_id":null + }, + "license":{ + "name":"name", + "key":"key", + "spdx_id":"spdx_id", + "url":"url", + "html_url":"hurl", + "node_id":"node_id" + }, + "readme":{ + "name":"name", + "key":"key", + "spdx_id":null, + "url":"url", + "html_url":"hurl", + "node_id":null + } + }, + "updated_at":` + referenceTimeStr + `, + "content_reports_enabled":true + }` testJSONMarshal(t, r, want) } diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index 0c0fa64902b..9e6e88563cd 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -782,7 +782,20 @@ func TestRepositoryContent_Marshal(t *testing.T) { DownloadURL: String("durl"), } - want := `{"type":"type","target":"target","encoding":"encoding","size":1,"name":"name","path":"path","content":"content","sha":"sha","url":"url","git_url":"gurl","html_url":"hurl","download_url":"durl"}` + want := `{ + "type":"type", + "target":"target", + "encoding":"encoding", + "size":1, + "name":"name", + "path":"path", + "content":"content", + "sha":"sha", + "url":"url", + "git_url":"gurl", + "html_url":"hurl", + "download_url":"durl" + }` testJSONMarshal(t, r, want) } @@ -853,7 +866,68 @@ func TestRepositoryContentResponse_Marshal(t *testing.T) { }, } - want := `{"content":{"type":"type","target":"target","encoding":"encoding","size":1,"name":"name","path":"path","content":"content","sha":"sha","url":"url","git_url":"gurl","html_url":"hurl","download_url":"durl"},"commit":{"sha":"s","author":{"date":` + referenceTimeStr + `,"name":"n","email":"e","username":"u"},"committer":{"date":` + referenceTimeStr + `,"name":"n","email":"e","username":"u"},"message":"m","tree":{"sha":"s","tree":[{"sha":"s","path":"p","mode":"m","type":"t","size":1,"content":"c","url":"u"}],"truncated":false},"stats":{"additions":1,"deletions":1,"total":1},"html_url":"h","url":"u","verification":{"verified":false,"reason":"r","signature":"s","payload":"p"},"node_id":"n","comment_count":1}}` + want := `{ + "content":{ + "type":"type", + "target":"target", + "encoding":"encoding", + "size":1, + "name":"name", + "path":"path", + "content":"content", + "sha":"sha", + "url":"url", + "git_url":"gurl", + "html_url":"hurl", + "download_url":"durl" + }, + "commit":{ + "sha":"s", + "author":{ + "date":` + referenceTimeStr + `, + "name":"n", + "email":"e", + "username":"u" + }, + "committer":{ + "date":` + referenceTimeStr + `, + "name":"n", + "email":"e", + "username":"u" + }, + "message":"m", + "tree":{ + "sha":"s", + "tree":[ + { + "sha":"s", + "path":"p", + "mode":"m", + "type":"t", + "size":1, + "content":"c", + "url":"u" + } + ], + "truncated":false + }, + "stats":{ + "additions":1, + "deletions":1, + "total":1 + }, + "html_url":"h", + "url":"u", + "verification":{ + "verified":false, + "reason":"r", + "signature":"s", + "payload":"p" + }, + "node_id":"n", + "comment_count":1 + } + }` testJSONMarshal(t, r, want) } @@ -881,7 +955,24 @@ func TestRepositoryContentFileOptions_Marshal(t *testing.T) { } contentValue := `"AQ=="` - want := `{"message":"type","content":` + contentValue + `,"sha":"type","branch":"type","author":{"date":` + referenceTimeStr + `,"name":"name","email":"email","username":"login"},"committer":{"date":` + referenceTimeStr + `,"name":"name","email":"email","username":"login"}}` + want := `{ + "message":"type", + "content":` + contentValue + `, + "sha":"type", + "branch":"type", + "author":{ + "date":` + referenceTimeStr + `, + "name":"name", + "email":"email", + "username":"login" + }, + "committer":{ + "date":` + referenceTimeStr + `, + "name":"name", + "email":"email", + "username":"login" + } + }` testJSONMarshal(t, r, want) } diff --git a/github/repos_deployments_test.go b/github/repos_deployments_test.go index eb8eff90044..3f5909ea236 100644 --- a/github/repos_deployments_test.go +++ b/github/repos_deployments_test.go @@ -306,7 +306,14 @@ func TestDeploymentStatusRequest_Marshal(t *testing.T) { AutoInactive: Bool(false), } - want := `{"state":"state","log_url":"logurl","description":"desc","environment":"env","environment_url":"eurl","auto_inactive":false}` + want := `{ + "state":"state", + "log_url":"logurl", + "description":"desc", + "environment":"env", + "environment_url":"eurl", + "auto_inactive":false + }` testJSONMarshal(t, r, want) } @@ -350,7 +357,41 @@ func TestDeploymentStatus_Marshal(t *testing.T) { URL: String("url"), } - want := `{"id":1,"state":"state","creator":{"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"},"description":"desc","environment":"env","node_id":"nid","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"target_url":"turl","deployment_url":"durl","repository_url":"rurl","environment_url":"eurl","log_url":"lurl","url":"url"}` + want := `{ + "id":1, + "state":"state", + "creator":{ + "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" + }, + "description":"desc", + "environment":"env", + "node_id":"nid", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "target_url":"turl", + "deployment_url":"durl", + "repository_url":"rurl", + "environment_url":"eurl", + "log_url":"lurl", + "url":"url" + }` testJSONMarshal(t, r, want) } @@ -370,7 +411,19 @@ func TestDeploymentRequest_Marshal(t *testing.T) { ProductionEnvironment: Bool(false), } - want := `{"ref":"ref","task":"task","auto_merge":false,"required_contexts":["s"],"payload":"payload","environment":"environment","description":"description","transient_environment":false,"production_environment":false}` + want := `{ + "ref":"ref", + "task":"task", + "auto_merge":false, + "required_contexts":[ + "s" + ], + "payload":"payload", + "environment":"environment", + "description":"description", + "transient_environment":false, + "production_environment":false + }` testJSONMarshal(t, r, want) } @@ -417,7 +470,41 @@ func TestDeployment_Marshal(t *testing.T) { NodeID: String("nid"), } - want := `{"url":"url","id":1,"sha":"sha","ref":"ref","task":"task","payload":"s","environment":"env","description":"desc","creator":{"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"},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"statuses_url":"surl","repository_url":"rurl","node_id":"nid"}` + want := `{ + "url":"url", + "id":1, + "sha":"sha", + "ref":"ref", + "task":"task", + "payload":"s", + "environment":"env", + "description":"desc", + "creator":{ + "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" + }, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "statuses_url":"surl", + "repository_url":"rurl", + "node_id":"nid" + }` testJSONMarshal(t, r, want) } diff --git a/github/repos_environments_test.go b/github/repos_environments_test.go index 28ef5fdb273..f6937768d7a 100644 --- a/github/repos_environments_test.go +++ b/github/repos_environments_test.go @@ -393,7 +393,46 @@ func TestRepoEnvironment_Marshal(t *testing.T) { }, } - want := `{"total_count":1,"environments":[{"owner":"me","repo":"se","environment_name":"dev","wait_timer":123,"reviewers":[{"type":"main","id":1},{"type":"rev","id":2}],"deployment_branch_policy":{"protected_branches":false,"custom_branch_policies":false},"id":2,"node_id":"star","name":"eg","url":"https://hey.in","html_url":"htmlurl","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"protection_rules":[{"id":21,"node_id":"mnb","type":"ewq","wait_timer":9090}]}]}` + want := `{ + "total_count":1, + "environments":[ + { + "owner":"me", + "repo":"se", + "environment_name":"dev", + "wait_timer":123, + "reviewers":[ + { + "type":"main", + "id":1 + }, + { + "type":"rev", + "id":2 + } + ], + "deployment_branch_policy":{ + "protected_branches":false, + "custom_branch_policies":false + }, + "id":2, + "node_id":"star", + "name":"eg", + "url":"https://hey.in", + "html_url":"htmlurl", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "protection_rules":[ + { + "id":21, + "node_id":"mnb", + "type":"ewq", + "wait_timer":9090 + } + ] + } + ] + }` testJSONMarshal(t, repoEnv, want) } @@ -406,7 +445,10 @@ func TestEnvReviewers_Marshal(t *testing.T) { ID: Int64(1), } - want := `{"type":"main","id":1}` + want := `{ + "type":"main", + "id":1 + }` testJSONMarshal(t, repoEnv, want) } @@ -450,7 +492,41 @@ func TestEnvironment_Marshal(t *testing.T) { }, } - want := `{"owner":"o","repo":"r","environment_name":"e","wait_timer":123,"reviewers":[{"type":"main","id":1},{"type":"rev","id":2}],"deployment_branch_policy":{"protected_branches":false,"custom_branch_policies":false},"id":2,"node_id":"star","name":"eg","url":"https://hey.in","html_url":"htmlurl","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"protection_rules":[{"id":21,"node_id":"mnb","type":"ewq","wait_timer":9090}]}` + want := `{ + "owner":"o", + "repo":"r", + "environment_name":"e", + "wait_timer":123, + "reviewers":[ + { + "type":"main", + "id":1 + }, + { + "type":"rev", + "id":2 + } + ], + "deployment_branch_policy":{ + "protected_branches":false, + "custom_branch_policies":false + }, + "id":2, + "node_id":"star", + "name":"eg", + "url":"https://hey.in", + "html_url":"htmlurl", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "protection_rules":[ + { + "id":21, + "node_id":"mnb", + "type":"ewq", + "wait_timer":9090 + } + ] + }` testJSONMarshal(t, repoEnv, want) } @@ -463,7 +539,10 @@ func TestBranchPolicy_Marshal(t *testing.T) { CustomBranchPolicies: Bool(false), } - want := `{"protected_branches":false,"custom_branch_policies":false}` + want := `{ + "protected_branches":false, + "custom_branch_policies":false + }` testJSONMarshal(t, bp, want) } diff --git a/github/repos_hooks_deliveries_test.go b/github/repos_hooks_deliveries_test.go index 7c8cd322cf5..fa512a8f373 100644 --- a/github/repos_hooks_deliveries_test.go +++ b/github/repos_hooks_deliveries_test.go @@ -274,7 +274,14 @@ func TestHookRequest_Marshal(t *testing.T) { RawPayload: (*json.RawMessage)(&jsonMsg), } - want := `{"headers":{"key":"value"},"payload":{"key":"value"}}` + want := `{ + "headers":{ + "key":"value" + }, + "payload":{ + "key":"value" + } + }` testJSONMarshal(t, r, want) } @@ -292,7 +299,14 @@ func TestHookResponse_Marshal(t *testing.T) { RawPayload: (*json.RawMessage)(&jsonMsg), } - want := `{"headers":{"key":"value"},"payload":{"key":"value"}}` + want := `{ + "headers":{ + "key":"value" + }, + "payload":{ + "key":"value" + } + }` testJSONMarshal(t, r, want) } @@ -327,7 +341,35 @@ func TestHookDelivery_Marshal(t *testing.T) { }, } - want := `{"id":1,"guid":"guid","delivered_at":` + referenceTimeStr + `,"redelivery":true,"duration":1,"status":"guid","status_code":1,"event":"guid","action":"guid","installation_id":1,"repository_id":1,"request":{"headers":{"key":"value"},"payload":{"key":"value"}},"response":{"headers":{"key":"value"},"payload":{"key":"value"}}}` + want := `{ + "id":1, + "guid":"guid", + "delivered_at":` + referenceTimeStr + `, + "redelivery":true, + "duration":1, + "status":"guid", + "status_code":1, + "event":"guid", + "action":"guid", + "installation_id":1, + "repository_id":1, + "request":{ + "headers":{ + "key":"value" + }, + "payload":{ + "key":"value" + } + }, + "response":{ + "headers":{ + "key":"value" + }, + "payload":{ + "key":"value" + } + } + }` testJSONMarshal(t, r, want) } diff --git a/github/repos_hooks_test.go b/github/repos_hooks_test.go index b2ebd9235f3..8a096dd81ac 100644 --- a/github/repos_hooks_test.go +++ b/github/repos_hooks_test.go @@ -371,7 +371,92 @@ func TestBranchWebHookPayload_Marshal(t *testing.T) { }, } - want := `{"commits":[{"message":"WebHookCommit","author":{"name":"abc","email":"abc@gmail.com","username":"abc_12"},"id":"1","committer":{"name":"abc","email":"abc@gmail.com","username":"abc_12"},"added":["1","2","3"],"removed":["cmd","rti","duv"],"modified":["abc","efg","erd"]}],"before":"before","action":"action","after":"after","created":true,"forced":false,"compare":"compare","repository":{"id":321,"node_id":"node_321"},"head_commit":{"message":"WebHookCommit","author":{"name":"abc","email":"abc@gmail.com","username":"abc_12"},"id":"1","committer":{"name":"abc","email":"abc@gmail.com","username":"abc_12"},"added":["1","2","3"],"removed":["cmd","rti","duv"],"modified":["abc","efg","erd"]},"pusher":{"login":"rd@yahoo.com","id":112},"sender":{"login":"st@gmail.com","id":202},"installation":{"id":12},"organization":{"id":22}}` + want := `{ + "commits":[ + { + "message":"WebHookCommit", + "author":{ + "name":"abc", + "email":"abc@gmail.com", + "username":"abc_12" + }, + "id":"1", + "committer":{ + "name":"abc", + "email":"abc@gmail.com", + "username":"abc_12" + }, + "added":[ + "1", + "2", + "3" + ], + "removed":[ + "cmd", + "rti", + "duv" + ], + "modified":[ + "abc", + "efg", + "erd" + ] + } + ], + "before":"before", + "action":"action", + "after":"after", + "created":true, + "forced":false, + "compare":"compare", + "repository":{ + "id":321, + "node_id":"node_321" + }, + "head_commit":{ + "message":"WebHookCommit", + "author":{ + "name":"abc", + "email":"abc@gmail.com", + "username":"abc_12" + }, + "id":"1", + "committer":{ + "name":"abc", + "email":"abc@gmail.com", + "username":"abc_12" + }, + "added":[ + "1", + "2", + "3" + ], + "removed":[ + "cmd", + "rti", + "duv" + ], + "modified":[ + "abc", + "efg", + "erd" + ] + }, + "pusher":{ + "login":"rd@yahoo.com", + "id":112 + }, + "sender":{ + "login":"st@gmail.com", + "id":202 + }, + "installation":{ + "id":12 + }, + "organization":{ + "id":22 + } + }` testJSONMarshal(t, v, want) } @@ -385,7 +470,11 @@ func TestBranchWebHookAuthor_Marshal(t *testing.T) { Login: String("abc_12"), } - want := `{"name":"abc","email":"abc@gmail.com","username":"abc_12"}` + want := `{ + "name":"abc", + "email":"abc@gmail.com", + "username":"abc_12" + }` testJSONMarshal(t, v, want) } @@ -411,7 +500,35 @@ func TestBranchWebHookCommit_Marshal(t *testing.T) { Removed: []string{"cmd", "rti", "duv"}, } - want := `{"message":"WebHookCommit","author":{"name":"abc","email":"abc@gmail.com","username":"abc_12"},"id":"1","committer":{"name":"abc","email":"abc@gmail.com","username":"abc_12"},"added":["1","2","3"],"removed":["cmd","rti","duv"],"modified":["abc","efg","erd"]}` + want := `{ + "message":"WebHookCommit", + "author":{ + "name":"abc", + "email":"abc@gmail.com", + "username":"abc_12" + }, + "id":"1", + "committer":{ + "name":"abc", + "email":"abc@gmail.com", + "username":"abc_12" + }, + "added":[ + "1", + "2", + "3" + ], + "removed":[ + "cmd", + "rti", + "duv" + ], + "modified":[ + "abc", + "efg", + "erd" + ] + }` testJSONMarshal(t, v, want) } @@ -428,7 +545,18 @@ func TestBranchCreateHookRequest_Marshal(t *testing.T) { }, } - want := `{"name":"abc","config":{"thing":"@123"},"events":["1","2","3"],"active":true}` + want := `{ + "name":"abc", + "config":{ + "thing":"@123" + }, + "events":[ + "1", + "2", + "3" + ], + "active":true + }` testJSONMarshal(t, v, want) } @@ -455,7 +583,28 @@ func TestBranchHook_Marshal(t *testing.T) { Active: Bool(true), } - want := `{"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"url":"url","id":1,"type":"type","name":"name","test_url":"testurl","ping_url":"pingurl","last_response":{"item":"item"},"config":{"thing":"@123"},"events":["1","2","3"],"active":true}` + want := `{ + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "url":"url", + "id":1, + "type":"type", + "name":"name", + "test_url":"testurl", + "ping_url":"pingurl", + "last_response":{ + "item":"item" + }, + "config":{ + "thing":"@123" + }, + "events":[ + "1", + "2", + "3" + ], + "active":true + }` testJSONMarshal(t, v, want) } diff --git a/github/repos_invitations_test.go b/github/repos_invitations_test.go index 4e0c31de914..74bda793753 100644 --- a/github/repos_invitations_test.go +++ b/github/repos_invitations_test.go @@ -138,7 +138,28 @@ func TestRepositoryInvitation_Marshal(t *testing.T) { HTMLURL: String("h"), } - want := `{"id":1,"repository":{"id":1,"name":"n","url":"u"},"invitee":{"id":1,"name":"n","url":"u"},"inviter":{"id":1,"name":"n","url":"u"},"permissions":"p","created_at":` + referenceTimeStr + `,"url":"u","html_url":"h"}` + want := `{ + "id":1, + "repository":{ + "id":1, + "name":"n", + "url":"u" + }, + "invitee":{ + "id":1, + "name":"n", + "url":"u" + }, + "inviter":{ + "id":1, + "name":"n", + "url":"u" + }, + "permissions":"p", + "created_at":` + referenceTimeStr + `, + "url":"u", + "html_url":"h" + }` testJSONMarshal(t, r, want) } diff --git a/github/repos_merging_test.go b/github/repos_merging_test.go index 147ca3ed49e..8bf94fb595e 100644 --- a/github/repos_merging_test.go +++ b/github/repos_merging_test.go @@ -72,7 +72,11 @@ func TestRepositoryMergeRequest_Marshal(t *testing.T) { CommitMessage: String("cm"), } - want := `{"base":"base","head":"head","commit_message":"cm"}` + want := `{ + "base":"base", + "head":"head", + "commit_message":"cm" + }` testJSONMarshal(t, u, want) } @@ -132,7 +136,11 @@ func TestRepoMergeUpstreamResult_Marshal(t *testing.T) { BaseBranch: String("base_branch"), } - want := `{"message":"message","merge_type":"merge_type","base_branch":"base_branch"}` + want := `{ + "message":"message", + "merge_type":"merge_type", + "base_branch":"base_branch" + }` testJSONMarshal(t, u, want) } diff --git a/github/repos_pages_test.go b/github/repos_pages_test.go index d5cc48b0170..089755d0566 100644 --- a/github/repos_pages_test.go +++ b/github/repos_pages_test.go @@ -366,7 +366,10 @@ func TestPagesSource_Marshal(t *testing.T) { Path: String("path"), } - want := `{"branch":"branch","path":"path"}` + want := `{ + "branch":"branch", + "path":"path" + }` testJSONMarshal(t, u, want) } @@ -391,7 +394,12 @@ func TestPagesUpdate_Marshal(t *testing.T) { Source: &PagesSource{Path: String("src")}, } - want := `{"cname":"cname","source":{"path":"src"}}` + want := `{ + "cname":"cname", + "source":{ + "path":"src" + } + }` testJSONMarshal(t, u, want) } @@ -411,7 +419,17 @@ func TestPages_Marshal(t *testing.T) { }, } - want := `{"url":"url","status":"status","cname":"cname","custom_404":false,"html_url":"hurl","source":{"branch":"branch","path":"path"}}` + want := `{ + "url":"url", + "status":"status", + "cname":"cname", + "custom_404":false, + "html_url":"hurl", + "source":{ + "branch":"branch", + "path":"path" + } + }` testJSONMarshal(t, u, want) } @@ -432,7 +450,20 @@ func TestPagesBuild_Marshal(t *testing.T) { UpdatedAt: &Timestamp{referenceTime}, } - want := `{"url":"url","status":"status","error":{"message":"message"},"pusher":{"id":1},"commit":"commit","duration":1,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `}` + want := `{ + "url":"url", + "status":"status", + "error":{ + "message":"message" + }, + "pusher":{ + "id":1 + }, + "commit":"commit", + "duration":1, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + }` testJSONMarshal(t, u, want) } @@ -447,7 +478,12 @@ func TestCreatePagesRequest_Marshal(t *testing.T) { }, } - want := `{"source":{"branch":"branch","path":"path"}}` + want := `{ + "source":{ + "branch":"branch", + "path":"path" + } + }` testJSONMarshal(t, u, want) } diff --git a/github/repos_prereceive_hooks_test.go b/github/repos_prereceive_hooks_test.go index 7ff044c7e2c..1cd04f338f6 100644 --- a/github/repos_prereceive_hooks_test.go +++ b/github/repos_prereceive_hooks_test.go @@ -205,7 +205,12 @@ func TestPreReceiveHook_Marshal(t *testing.T) { ConfigURL: String("curl"), } - want := `{"id":1,"name":"name","enforcement":"e","configuration_url":"curl"}` + want := `{ + "id":1, + "name":"name", + "enforcement":"e", + "configuration_url":"curl" + }` testJSONMarshal(t, u, want) } diff --git a/github/repos_releases_test.go b/github/repos_releases_test.go index 124356e2d40..b0945d26827 100644 --- a/github/repos_releases_test.go +++ b/github/repos_releases_test.go @@ -712,7 +712,16 @@ func TestRepositoryReleaseRequest_Marshal(t *testing.T) { DiscussionCategoryName: String("dcn"), } - want := `{"tag_name":"tn","target_commitish":"tc","name":"name","body":"body","draft":false,"prerelease":false,"make_latest":"legacy","discussion_category_name":"dcn"}` + want := `{ + "tag_name":"tn", + "target_commitish":"tc", + "name":"name", + "body":"body", + "draft":false, + "prerelease":false, + "make_latest":"legacy", + "discussion_category_name":"dcn" + }` testJSONMarshal(t, u, want) } @@ -736,7 +745,23 @@ func TestReleaseAsset_Marshal(t *testing.T) { NodeID: String("nid"), } - want := `{"id":1,"url":"url","name":"name","label":"label","state":"state","content_type":"ct","size":1,"download_count":1,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"browser_download_url":"bdu","uploader":{"id":1},"node_id":"nid"}` + want := `{ + "id":1, + "url":"url", + "name":"name", + "label":"label", + "state":"state", + "content_type":"ct", + "size":1, + "download_count":1, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "browser_download_url":"bdu", + "uploader":{ + "id":1 + }, + "node_id":"nid" + }` testJSONMarshal(t, u, want) } @@ -767,7 +792,34 @@ func TestRepositoryRelease_Marshal(t *testing.T) { NodeID: String("nid"), } - want := `{"tag_name":"tn","target_commitish":"tc","name":"name","body":"body","draft":false,"prerelease":false,"make_latest":"legacy","discussion_category_name":"dcn","id":1,"created_at":` + referenceTimeStr + `,"published_at":` + referenceTimeStr + `,"url":"url","html_url":"hurl","assets_url":"aurl","assets":[{"id":1}],"upload_url":"uurl","zipball_url":"zurl","tarball_url":"turl","author":{"id":1},"node_id":"nid"}` + want := `{ + "tag_name":"tn", + "target_commitish":"tc", + "name":"name", + "body":"body", + "draft":false, + "prerelease":false, + "make_latest":"legacy", + "discussion_category_name":"dcn", + "id":1, + "created_at":` + referenceTimeStr + `, + "published_at":` + referenceTimeStr + `, + "url":"url", + "html_url":"hurl", + "assets_url":"aurl", + "assets":[ + { + "id":1 + } + ], + "upload_url":"uurl", + "zipball_url":"zurl", + "tarball_url":"turl", + "author":{ + "id":1 + }, + "node_id":"nid" + }` testJSONMarshal(t, u, want) } @@ -781,7 +833,11 @@ func TestGenerateNotesOptions_Marshal(t *testing.T) { TargetCommitish: String("target_commitish"), } - want := `{"tag_name":"tag_name","previous_tag_name":"previous_tag_name","target_commitish":"target_commitish"}` + want := `{ + "tag_name":"tag_name", + "previous_tag_name":"previous_tag_name", + "target_commitish":"target_commitish" + }` testJSONMarshal(t, u, want) } diff --git a/github/repos_stats_test.go b/github/repos_stats_test.go index 9158b7da64b..31835d3e744 100644 --- a/github/repos_stats_test.go +++ b/github/repos_stats_test.go @@ -336,7 +336,14 @@ func TestRepositoryParticipation_Marshal(t *testing.T) { Owner: []int{1}, } - want := `{"all":[1],"owner":[1]}` + want := `{ + "all":[ + 1 + ], + "owner":[ + 1 + ] + }` testJSONMarshal(t, u, want) } @@ -350,7 +357,13 @@ func TestWeeklyCommitActivity_Marshal(t *testing.T) { Week: &Timestamp{referenceTime}, } - want := `{"days":[1],"total":1,"week":` + referenceTimeStr + `}` + want := `{ + "days":[ + 1 + ], + "total":1, + "week":` + referenceTimeStr + ` + }` testJSONMarshal(t, u, want) } @@ -365,7 +378,12 @@ func TestWeeklyStats_Marshal(t *testing.T) { Commits: Int(1), } - want := `{"w":` + referenceTimeStr + `,"a":1,"d":1,"c":1}` + want := `{ + "w":` + referenceTimeStr + `, + "a":1, + "d":1, + "c":1 + }` testJSONMarshal(t, u, want) } @@ -386,7 +404,20 @@ func TestContributorStats_Marshal(t *testing.T) { }, } - want := `{"author":{"id":1},"total":1,"weeks":[{"w":` + referenceTimeStr + `,"a":1,"d":1,"c":1}]}` + want := `{ + "author":{ + "id":1 + }, + "total":1, + "weeks":[ + { + "w":` + referenceTimeStr + `, + "a":1, + "d":1, + "c":1 + } + ] + }` testJSONMarshal(t, u, want) } diff --git a/github/repos_statuses_test.go b/github/repos_statuses_test.go index 910cb3c77ff..ea298be948f 100644 --- a/github/repos_statuses_test.go +++ b/github/repos_statuses_test.go @@ -167,7 +167,21 @@ func TestRepoStatus_Marshal(t *testing.T) { UpdatedAt: &Timestamp{referenceTime}, } - want := `{"id":1,"node_id":"nid","url":"url","state":"state","target_url":"turl","description":"desc","context":"ctx","avatar_url":"aurl","creator":{"id":1},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `}` + want := `{ + "id":1, + "node_id":"nid", + "url":"url", + "state":"state", + "target_url":"turl", + "description":"desc", + "context":"ctx", + "avatar_url":"aurl", + "creator":{ + "id":1 + }, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + }` testJSONMarshal(t, u, want) } @@ -199,7 +213,31 @@ func TestCombinedStatus_Marshal(t *testing.T) { RepositoryURL: String("rurl"), } - want := `{"state":"state","name":"name","sha":"sha","total_count":1,"statuses":[{"id":1,"node_id":"nid","url":"url","state":"state","target_url":"turl","description":"desc","context":"ctx","avatar_url":"aurl","creator":{"id":1},"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `}],"commit_url":"curl","repository_url":"rurl"}` + want := `{ + "state":"state", + "name":"name", + "sha":"sha", + "total_count":1, + "statuses":[ + { + "id":1, + "node_id":"nid", + "url":"url", + "state":"state", + "target_url":"turl", + "description":"desc", + "context":"ctx", + "avatar_url":"aurl", + "creator":{ + "id":1 + }, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + } + ], + "commit_url":"curl", + "repository_url":"rurl" + }` testJSONMarshal(t, u, want) } diff --git a/github/repos_tags_test.go b/github/repos_tags_test.go index 4a40a625b3c..21e5f349a1e 100644 --- a/github/repos_tags_test.go +++ b/github/repos_tags_test.go @@ -132,14 +132,20 @@ func TestRepositoriesService_DeleteTagProtection(t *testing.T) { } func TestTagProtection_Marshal(t *testing.T) { - testJSONMarshal(t, &TagProtection{}, `{"id":null,"pattern":null}`) + testJSONMarshal(t, &TagProtection{}, `{ + "id":null, + "pattern":null + }`) u := &TagProtection{ ID: Int64(1), Pattern: String("pattern"), } - want := `{"id":1,"pattern":"pattern"}` + want := `{ + "id":1, + "pattern":"pattern" + }` testJSONMarshal(t, u, want) } diff --git a/github/repos_test.go b/github/repos_test.go index 4f75e0e1c58..f3f855c2244 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -3332,7 +3332,12 @@ func TestDispatchRequestOptions_Marshal(t *testing.T) { ClientPayload: &cp, } - want := `{"event_type":"test_event_type","client_payload":{"testKey":"testValue"}}` + want := `{ + "event_type":"test_event_type", + "client_payload":{ + "testKey":"testValue" + } + }` testJSONMarshal(t, u, want) } @@ -3345,7 +3350,13 @@ func TestTransferRequest_Marshal(t *testing.T) { TeamID: []int64{1, 2}, } - want := `{"new_owner":"testOwner","team_ids":[1,2]}` + want := `{ + "new_owner":"testOwner", + "team_ids":[ + 1, + 2 + ] + }` testJSONMarshal(t, u, want) } @@ -3358,7 +3369,10 @@ func TestSignaturesProtectedBranch_Marshal(t *testing.T) { Enabled: Bool(false), } - want := `{"url":"https://www.testURL.in","enabled":false}` + want := `{ + "url":"https://www.testURL.in", + "enabled":false + }` testJSONMarshal(t, u, want) @@ -3367,7 +3381,10 @@ func TestSignaturesProtectedBranch_Marshal(t *testing.T) { Enabled: Bool(true), } - want2 := `{"url":"testURL","enabled":true}` + want2 := `{ + "url":"testURL", + "enabled":true + }` testJSONMarshal(t, u2, want2) } @@ -3381,7 +3398,20 @@ func TestDismissalRestrictionsRequest_Marshal(t *testing.T) { Apps: &[]string{"app1", "app2"}, } - want := `{"users":["user1","user2"],"teams":["team1","team2"],"apps":["app1","app2"]}` + want := `{ + "users":[ + "user1", + "user2" + ], + "teams":[ + "team1", + "team2" + ], + "apps":[ + "app1", + "app2" + ] + }` testJSONMarshal(t, u, want) } @@ -3394,7 +3424,10 @@ func TestAdminEnforcement_Marshal(t *testing.T) { Enabled: false, } - want := `{"url":"https://www.test-url.in","enabled":false}` + want := `{ + "url":"https://www.test-url.in", + "enabled":false + }` testJSONMarshal(t, u, want) } @@ -3413,7 +3446,25 @@ func TestPullRequestReviewsEnforcementUpdate_Marshal(t *testing.T) { RequiredApprovingReviewCount: 2, } - want := `{"bypass_pull_request_allowances":{"users":["user1","user2"],"teams":["team1","team2"],"apps":["app1","app2"]},"dismiss_stale_reviews":false,"require_code_owner_reviews":true,"required_approving_review_count":2}` + want := `{ + "bypass_pull_request_allowances":{ + "users":[ + "user1", + "user2" + ], + "teams":[ + "team1", + "team2" + ], + "apps":[ + "app1", + "app2" + ] + }, + "dismiss_stale_reviews":false, + "require_code_owner_reviews":true, + "required_approving_review_count":2 + }` testJSONMarshal(t, u, want) } @@ -3426,7 +3477,10 @@ func TestRequiredStatusCheck_Marshal(t *testing.T) { AppID: Int64(1), } - want := `{"context":"ctx","app_id":1}` + want := `{ + "context":"ctx", + "app_id":1 + }` testJSONMarshal(t, u, want) } diff --git a/github/repos_traffic_test.go b/github/repos_traffic_test.go index 9a37352b952..42c979e8d08 100644 --- a/github/repos_traffic_test.go +++ b/github/repos_traffic_test.go @@ -210,7 +210,11 @@ func TestTrafficReferrer_Marshal(t *testing.T) { Uniques: Int(0), } - want := `{"referrer":"referrer","count":0,"uniques":0}` + want := `{ + "referrer":"referrer", + "count":0, + "uniques":0 + }` testJSONMarshal(t, u, want) } @@ -228,7 +232,17 @@ func TestTrafficViews_Marshal(t *testing.T) { Uniques: Int(0), } - want := `{"views":[{"timestamp":"2016-05-31T16:00:00Z","count":7,"uniques":6}],"count":0,"uniques":0}` + want := `{ + "views":[ + { + "timestamp":"2016-05-31T16:00:00Z", + "count":7, + "uniques":6 + } + ], + "count":0, + "uniques":0 + }` testJSONMarshal(t, u, want) } @@ -246,7 +260,17 @@ func TestTrafficClones_Marshal(t *testing.T) { Uniques: Int(0), } - want := `{"clones":[{"timestamp":"2021-10-29T16:00:00Z","count":1,"uniques":1}],"count":0,"uniques":0}` + want := `{ + "clones":[ + { + "timestamp":"2021-10-29T16:00:00Z", + "count":1, + "uniques":1 + } + ], + "count":0, + "uniques":0 + }` testJSONMarshal(t, u, want) } @@ -261,7 +285,12 @@ func TestTrafficPath_Marshal(t *testing.T) { Uniques: Int(3), } - want := `{"path":"test/path","title":"test","count":2,"uniques":3}` + want := `{ + "path":"test/path", + "title":"test", + "count":2, + "uniques":3 + }` testJSONMarshal(t, u, want) } @@ -276,7 +305,11 @@ func TestTrafficData_Marshal(t *testing.T) { Uniques: Int(6), } - want := `{"timestamp":"2016-05-31T16:00:00Z","count":7,"uniques":6}` + want := `{ + "timestamp":"2016-05-31T16:00:00Z", + "count":7, + "uniques":6 + }` testJSONMarshal(t, u, want) } diff --git a/github/scim_test.go b/github/scim_test.go index 7c1673a207b..3618366d48e 100644 --- a/github/scim_test.go +++ b/github/scim_test.go @@ -344,7 +344,14 @@ func TestSCIMService_DeleteSCIMUserFromOrg(t *testing.T) { } func TestSCIMUserAttributes_Marshal(t *testing.T) { - testJSONMarshal(t, &SCIMUserAttributes{}, `{"userName":"","name":{"givenName":"","familyName":""},"emails":null}`) + testJSONMarshal(t, &SCIMUserAttributes{}, `{ + "userName":"", + "name":{ + "givenName":"", + "familyName":"" + }, + "emails":null + }`) u := &SCIMUserAttributes{ UserName: "userName1", @@ -367,7 +374,30 @@ func TestSCIMUserAttributes_Marshal(t *testing.T) { Active: Bool(true), } - want := `{"userName":"userName1","name":{"givenName":"Name1","familyName":"Fname","formatted":"formatted name"},"displayName":"Name","emails":[{"value":"value","primary":false,"type":"type"}],"schemas":["schema1"],"externalId":"id","groups":["group1"],"active":true}` + want := `{ + "userName":"userName1", + "name":{ + "givenName":"Name1", + "familyName":"Fname", + "formatted":"formatted name" + }, + "displayName":"Name", + "emails":[ + { + "value":"value", + "primary":false, + "type":"type" + } + ], + "schemas":[ + "schema1" + ], + "externalId":"id", + "groups":[ + "group1" + ], + "active":true + }` testJSONMarshal(t, u, want) } @@ -380,13 +410,20 @@ func TestUpdateAttributeForSCIMUserOperations_Marshal(t *testing.T) { Path: String("path"), } - want := `{"op":"TestOp","path":"path"}` + want := `{ + "op":"TestOp", + "path":"path" + }` testJSONMarshal(t, u, want) } func TestUpdateAttributeForSCIMUserOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &UpdateAttributeForSCIMUserOptions{}, `{"operations":{"op":""}}`) + testJSONMarshal(t, &UpdateAttributeForSCIMUserOptions{}, `{ + "operations":{ + "op":"" + } + }`) u := &UpdateAttributeForSCIMUserOptions{ Schemas: []string{"test", "schema"}, @@ -396,7 +433,16 @@ func TestUpdateAttributeForSCIMUserOptions_Marshal(t *testing.T) { }, } - want := `{"schemas":["test","schema"],"operations":{"op":"TestOp","path":"path"}}` + want := `{ + "schemas":[ + "test", + "schema" + ], + "operations":{ + "op":"TestOp", + "path":"path" + } + }` testJSONMarshal(t, u, want) } @@ -429,7 +475,10 @@ func TestListSCIMProvisionedIdentitiesOptions_addOptions(t *testing.T) { } func TestSCIMUserName_Marshal(t *testing.T) { - testJSONMarshal(t, &SCIMUserName{}, `{"givenName":"","familyName":""}`) + testJSONMarshal(t, &SCIMUserName{}, `{ + "givenName":"", + "familyName":"" + }`) u := &SCIMUserName{ GivenName: "Name1", @@ -437,7 +486,11 @@ func TestSCIMUserName_Marshal(t *testing.T) { Formatted: String("formatted name"), } - want := `{"givenName":"Name1","familyName":"Fname","formatted":"formatted name"}` + want := `{ + "givenName":"Name1", + "familyName":"Fname", + "formatted":"formatted name" + }` testJSONMarshal(t, u, want) } @@ -450,7 +503,10 @@ func TestSCIMMeta_Marshal(t *testing.T) { Location: String("test"), } - want := `{"resourceType":"test","location":"test"}` + want := `{ + "resourceType":"test", + "location":"test" + }` testJSONMarshal(t, u, want) } @@ -487,7 +543,41 @@ func TestSCIMProvisionedIdentities_Marshal(t *testing.T) { }, } - want := `{"schemas":["test","schema"],"totalResults":1,"itemsPerPage":2,"startIndex":1,"Resources":[{"userName":"SCIM","name":{"givenName":"scim","familyName":"test","formatted":"SCIM"},"displayName":"Test SCIM","emails":[{"value":"test","primary":true,"type":"test"}],"schemas":["schema1"],"externalId":"id","groups":["group1"],"active":true}]}` + want := `{ + "schemas":[ + "test", + "schema" + ], + "totalResults":1, + "itemsPerPage":2, + "startIndex":1, + "Resources":[ + { + "userName":"SCIM", + "name":{ + "givenName":"scim", + "familyName":"test", + "formatted":"SCIM" + }, + "displayName":"Test SCIM", + "emails":[ + { + "value":"test", + "primary":true, + "type":"test" + } + ], + "schemas":[ + "schema1" + ], + "externalId":"id", + "groups":[ + "group1" + ], + "active":true + } + ] + }` testJSONMarshal(t, u, want) } diff --git a/github/search_test.go b/github/search_test.go index f7dedfeca6b..ebbadff79e9 100644 --- a/github/search_test.go +++ b/github/search_test.go @@ -570,7 +570,12 @@ func TestMatch_Marshal(t *testing.T) { Indices: []int{1}, } - want := `{"text":"txt","indices":[1]}` + want := `{ + "text":"txt", + "indices":[ + 1 + ] + }` testJSONMarshal(t, u, want) } @@ -591,7 +596,20 @@ func TestTextMatch_Marshal(t *testing.T) { }, } - want := `{"object_url":"ourl","object_type":"otype","property":"prop","fragment":"fragment","matches":[{"text":"txt","indices":[1]}]}` + want := `{ + "object_url":"ourl", + "object_type":"otype", + "property":"prop", + "fragment":"fragment", + "matches":[ + { + "text":"txt", + "indices":[ + 1 + ] + } + ] + }` testJSONMarshal(t, u, want) } @@ -611,7 +629,17 @@ func TestTopicResult_Marshal(t *testing.T) { Score: Float64(99.9), } - want := `{"name":"name","display_name":"displayName","short_description":"shortDescription","description":"description","created_by":"createdBy","updated_at":"2021-10-26","featured":false,"curated":true,"score":99.9}` + want := `{ + "name":"name", + "display_name":"displayName", + "short_description":"shortDescription", + "description":"description", + "created_by":"createdBy", + "updated_at":"2021-10-26", + "featured":false, + "curated":true, + "score":99.9 + }` testJSONMarshal(t, u, want) } @@ -625,7 +653,15 @@ func TestRepositoriesSearchResult_Marshal(t *testing.T) { Repositories: []*Repository{{ID: Int64(1)}}, } - want := `{"total_count":0,"incomplete_results":true,"items":[{"id":1}]}` + want := `{ + "total_count":0, + "incomplete_results":true, + "items":[ + { + "id":1 + } + ] + }` testJSONMarshal(t, u, want) } @@ -641,7 +677,15 @@ func TestCommitsSearchResult_Marshal(t *testing.T) { }}, } - want := `{"total_count":0,"incomplete_results":true,"items":[{"sha":"s"}]}` + want := `{ + "total_count":0, + "incomplete_results":true, + "items":[ + { + "sha":"s" + } + ] + }` testJSONMarshal(t, c, want) } @@ -668,7 +712,24 @@ func TestTopicsSearchResult_Marshal(t *testing.T) { }, } - want := `{"total_count":2,"incomplete_results":false,"items":[{"name":"t1","display_name":"tt","short_description":"t desc","description":"desc","created_by":"mi","created_at":` + referenceTimeStr + `,"updated_at":"2006-01-02T15:04:05Z","featured":true,"curated":true,"score":123}]}` + want := `{ + "total_count":2, + "incomplete_results":false, + "items":[ + { + "name":"t1", + "display_name":"tt", + "short_description":"t desc", + "description":"desc", + "created_by":"mi", + "created_at":` + referenceTimeStr + `, + "updated_at":"2006-01-02T15:04:05Z", + "featured":true, + "curated":true, + "score":123 + } + ] + }` testJSONMarshal(t, u, want) } @@ -686,7 +747,15 @@ func TestLabelResult_Marshal(t *testing.T) { Score: Float64(123), } - want := `{"id":11,"url":"url","name":"label","color":"green","default":true,"description":"desc","score":123}` + want := `{ + "id":11, + "url":"url", + "name":"label", + "color":"green", + "default":true, + "description":"desc", + "score":123 + }` testJSONMarshal(t, u, want) } @@ -750,7 +819,69 @@ func TestIssuesSearchResult_Marshal(t *testing.T) { }, } - want := `{"total_count":48,"incomplete_results":false,"items":[{"id":1,"number":1,"state":"s","locked":false,"title":"title","body":"body","author_association":"aa","user":{"id":1},"labels":[{"id":1}],"assignee":{"id":1},"comments":1,"closed_at":` + referenceTimeStr + `,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"closed_by":{"id":1},"url":"url","html_url":"hurl","comments_url":"curl","events_url":"eurl","labels_url":"lurl","repository_url":"rurl","milestone":{"id":1},"pull_request":{"url":"url"},"repository":{"id":1},"reactions":{"total_count":1},"assignees":[{"id":1}],"node_id":"nid","text_matches":[{"object_url":"ourl"}],"active_lock_reason":"alr"}]}` + want := `{ + "total_count":48, + "incomplete_results":false, + "items":[ + { + "id":1, + "number":1, + "state":"s", + "locked":false, + "title":"title", + "body":"body", + "author_association":"aa", + "user":{ + "id":1 + }, + "labels":[ + { + "id":1 + } + ], + "assignee":{ + "id":1 + }, + "comments":1, + "closed_at":` + referenceTimeStr + `, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "closed_by":{ + "id":1 + }, + "url":"url", + "html_url":"hurl", + "comments_url":"curl", + "events_url":"eurl", + "labels_url":"lurl", + "repository_url":"rurl", + "milestone":{ + "id":1 + }, + "pull_request":{ + "url":"url" + }, + "repository":{ + "id":1 + }, + "reactions":{ + "total_count":1 + }, + "assignees":[ + { + "id":1 + } + ], + "node_id":"nid", + "text_matches":[ + { + "object_url":"ourl" + } + ], + "active_lock_reason":"alr" + } + ] + }` testJSONMarshal(t, u, want) } @@ -774,7 +905,21 @@ func TestLabelsSearchResult_Marshal(t *testing.T) { }, } - want := `{"total_count":5,"incomplete_results":false,"items":[{"id":1,"url":"https://www.test-url.com","name":"test name","color":"green","default":true,"description":"testDescription","score":1}]}` + want := `{ + "total_count":5, + "incomplete_results":false, + "items":[ + { + "id":1, + "url":"https://www.test-url.com", + "name":"test name", + "color":"green", + "default":true, + "description":"testDescription", + "score":1 + } + ] + }` testJSONMarshal(t, u, want) } @@ -795,7 +940,25 @@ func TestCommitResult_Marshal(t *testing.T) { Parents: []*Commit{}, } - want := `{"sha":"test","commit":{"sha":"test"},"author":{"id":1},"committer":{"id":1},"html_url":"hurl","url":"url","comments_url":"curl","repository":{"id":1},"score":123}` + want := `{ + "sha":"test", + "commit":{ + "sha":"test" + }, + "author":{ + "id":1 + }, + "committer":{ + "id":1 + }, + "html_url":"hurl", + "url":"url", + "comments_url":"curl", + "repository":{ + "id":1 + }, + "score":123 + }` testJSONMarshal(t, c, want) } @@ -817,7 +980,21 @@ func TestUsersSearchResult_Marshal(t *testing.T) { }}, } - want := `{"total_count":2,"incomplete_results":false,"items":[{"login":"loginTest","id":1,"node_id":"NodeTest","avatar_url":"AvatarURLTest","html_url":"Hurl","gravatar_id":"gravatarIDTest","name":"nameTest"}]}` + want := `{ + "total_count":2, + "incomplete_results":false, + "items":[ + { + "login":"loginTest", + "id":1, + "node_id":"NodeTest", + "avatar_url":"AvatarURLTest", + "html_url":"Hurl", + "gravatar_id":"gravatarIDTest", + "name":"nameTest" + } + ] + }` testJSONMarshal(t, u, want) } @@ -831,7 +1008,15 @@ func TestCodeSearchResult_Marshal(t *testing.T) { CodeResults: []*CodeResult{{Name: String("n")}}, } - want := `{"total_count":4,"incomplete_results":false,"items":[{"name":"n"}]}` + want := `{ + "total_count":4, + "incomplete_results":false, + "items":[ + { + "name":"n" + } + ] + }` testJSONMarshal(t, u, want) } diff --git a/github/secret_scanning_test.go b/github/secret_scanning_test.go index 003fa13fadf..72d2a038bee 100644 --- a/github/secret_scanning_test.go +++ b/github/secret_scanning_test.go @@ -498,7 +498,24 @@ func TestSecretScanningAlert_Marshal(t *testing.T) { Secret: String("test"), } - want := `{"number":1,"created_at":` + referenceTimeStr + `,"url":"https://api.github.com/teams/2/discussions/3/comments","html_url":"https://api.github.com/teams/2/discussions/3/comments","locations_url":"https://api.github.com/teams/2/discussions/3/comments","state":"test_state","resolution":"test_resolution","resolved_at":` + referenceTimeStr + `,"resolved_by":{"login":"test","id":10,"node_id":"A123","avatar_url":"https://api.github.com/teams/2/discussions/3/comments"},"secret_type":"test","secret":"test"}` + want := `{ + "number":1, + "created_at":` + referenceTimeStr + `, + "url":"https://api.github.com/teams/2/discussions/3/comments", + "html_url":"https://api.github.com/teams/2/discussions/3/comments", + "locations_url":"https://api.github.com/teams/2/discussions/3/comments", + "state":"test_state", + "resolution":"test_resolution", + "resolved_at":` + referenceTimeStr + `, + "resolved_by":{ + "login":"test", + "id":10, + "node_id":"A123", + "avatar_url":"https://api.github.com/teams/2/discussions/3/comments" + }, + "secret_type":"test", + "secret":"test" + }` testJSONMarshal(t, u, want) } @@ -521,7 +538,20 @@ func TestSecretScanningAlertLocation_Marshal(t *testing.T) { }, } - want := `{"type":"test","details":{"path":"test_path","start_line":10,"end_line":20,"start_column":30,"end_column":40,"blob_sha":"test_sha","blob_url":"https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b","commit_sha":"test_sha","commit_url":"https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b"}}` + want := `{ + "type":"test", + "details":{ + "path":"test_path", + "start_line":10, + "end_line":20, + "start_column":30, + "end_column":40, + "blob_sha":"test_sha", + "blob_url":"https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b", + "commit_sha":"test_sha", + "commit_url":"https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b" + } + }` testJSONMarshal(t, u, want) } @@ -541,7 +571,17 @@ func TestSecretScanningAlertLocationDetails_Marshal(t *testing.T) { CommitURL: String("https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b"), } - want := `{"path":"test_path","start_line":10,"end_line":20,"start_column":30,"end_column":40,"blob_sha":"test_sha","blob_url":"https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b","commit_sha":"test_sha","commit_url":"https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b"}` + want := `{ + "path":"test_path", + "start_line":10, + "end_line":20, + "start_column":30, + "end_column":40, + "blob_sha":"test_sha", + "blob_url":"https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b", + "commit_sha":"test_sha", + "commit_url":"https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b" + }` testJSONMarshal(t, u, want) } diff --git a/github/teams_discussion_comments_test.go b/github/teams_discussion_comments_test.go index f85bdc63a16..e90a440ea40 100644 --- a/github/teams_discussion_comments_test.go +++ b/github/teams_discussion_comments_test.go @@ -462,7 +462,34 @@ func TestDiscussionComment_Marshal(t *testing.T) { }, } - want := `{"author":{},"body":"body","body_html":"body html","body_version":"body version","created_at":` + referenceTimeStr + `,"last_edited_at":` + referenceTimeStr + `,"discussion_url":"url","html_url":"html url","node_id":"node","number":1,"updated_at":` + referenceTimeStr + `,"url":"url","reactions":{"total_count":10,"+1":1,"-1":1,"laugh":1,"confused":1,"heart":2,"hooray":5,"rocket":3,"eyes":9,"url":"url"}}` + want := `{ + "author":{ + + }, + "body":"body", + "body_html":"body html", + "body_version":"body version", + "created_at":` + referenceTimeStr + `, + "last_edited_at":` + referenceTimeStr + `, + "discussion_url":"url", + "html_url":"html url", + "node_id":"node", + "number":1, + "updated_at":` + referenceTimeStr + `, + "url":"url", + "reactions":{ + "total_count":10, + "+1":1, + "-1":1, + "laugh":1, + "confused":1, + "heart":2, + "hooray":5, + "rocket":3, + "eyes":9, + "url":"url" + } + }` testJSONMarshal(t, u, want) } diff --git a/github/teams_discussions_test.go b/github/teams_discussions_test.go index c6332bc2858..3c722020236 100644 --- a/github/teams_discussions_test.go +++ b/github/teams_discussions_test.go @@ -586,7 +586,45 @@ func TestTeamDiscussion_Marshal(t *testing.T) { } bodyHTML, _ := json.Marshal(`

test

`) - want := `{"author":{"login":"author","id":0,"avatar_url":"https://avatars1.githubusercontent.com/u/0?v=4","gravatar_id":"","created_at":` + referenceTimeStr + `,"suspended_at":` + referenceTimeStr + `,"url":"https://api.github.com/users/author"},"body":"test","body_html":` + string(bodyHTML) + `,"body_version":"version","comments_count":1,"comments_url":"https://api.github.com/teams/2/discussions/3/comments","created_at":` + referenceTimeStr + `,"last_edited_at":` + referenceTimeStr + `,"html_url":"https://api.github.com/teams/2/discussions/3/comments","node_id":"A123","number":10,"pinned":true,"private":false,"team_url":"https://api.github.com/teams/2/discussions/3/comments","title":"Test","updated_at":` + referenceTimeStr + `,"url":"https://api.github.com/teams/2/discussions/3/comments","reactions":{"total_count":1,"+1":2,"-1":-3,"laugh":4,"confused":5,"heart":6,"hooray":7,"rocket":8,"eyes":9,"url":"https://api.github.com/teams/2/discussions/3/comments"}}` + want := `{ + "author":{ + "login":"author", + "id":0, + "avatar_url":"https://avatars1.githubusercontent.com/u/0?v=4", + "gravatar_id":"", + "created_at":` + referenceTimeStr + `, + "suspended_at":` + referenceTimeStr + `, + "url":"https://api.github.com/users/author" + }, + "body":"test", + "body_html":` + string(bodyHTML) + `, + "body_version":"version", + "comments_count":1, + "comments_url":"https://api.github.com/teams/2/discussions/3/comments", + "created_at":` + referenceTimeStr + `, + "last_edited_at":` + referenceTimeStr + `, + "html_url":"https://api.github.com/teams/2/discussions/3/comments", + "node_id":"A123", + "number":10, + "pinned":true, + "private":false, + "team_url":"https://api.github.com/teams/2/discussions/3/comments", + "title":"Test", + "updated_at":` + referenceTimeStr + `, + "url":"https://api.github.com/teams/2/discussions/3/comments", + "reactions":{ + "total_count":1, + "+1":2, + "-1":-3, + "laugh":4, + "confused":5, + "heart":6, + "hooray":7, + "rocket":8, + "eyes":9, + "url":"https://api.github.com/teams/2/discussions/3/comments" + } + }` testJSONMarshal(t, u, want) } diff --git a/github/teams_test.go b/github/teams_test.go index 2ef4a6eb32e..a3dee2bd2ed 100644 --- a/github/teams_test.go +++ b/github/teams_test.go @@ -1600,7 +1600,22 @@ func TestNewTeam_Marshal(t *testing.T) { LDAPDN: String("l"), } - want := `{"name":"n","description":"d","maintainers":["m1","m2"],"repo_names":["repo1","repo2"],"parent_team_id":1,"permission":"perm","privacy":"p","ldap_dn":"l"}` + want := `{ + "name":"n", + "description":"d", + "maintainers":[ + "m1", + "m2" + ], + "repo_names":[ + "repo1", + "repo2" + ], + "parent_team_id":1, + "permission":"perm", + "privacy":"p", + "ldap_dn":"l" + }` testJSONMarshal(t, u, want) } @@ -1648,7 +1663,45 @@ func TestTeams_Marshal(t *testing.T) { 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,"organization":{"login":"l","id":1,"node_id":"n","avatar_url":"a","html_url":"h","name":"n","company":"c","blog":"b","location":"l","email":"e"},"members_url":"m","repositories_url":"r","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"}` + want := `{ + "id":1, + "node_id":"n", + "name":"n", + "description":"d", + "url":"u", + "slug":"s", + "permission":"p", + "privacy":"p", + "members_count":1, + "repos_count":1, + "organization":{ + "login":"l", + "id":1, + "node_id":"n", + "avatar_url":"a", + "html_url":"h", + "name":"n", + "company":"c", + "blog":"b", + "location":"l", + "email":"e" + }, + "members_url":"m", + "repositories_url":"r", + "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) } @@ -1667,7 +1720,16 @@ func TestInvitation_Marshal(t *testing.T) { InvitationTeamURL: String("url"), } - want := `{"id":1,"node_id":"test node","login":"login123","email":"go@github.com","role":"developer","created_at":` + referenceTimeStr + `,"team_count":99,"invitation_team_url":"url"}` + want := `{ + "id":1, + "node_id":"test node", + "login":"login123", + "email":"go@github.com", + "role":"developer", + "created_at":` + referenceTimeStr + `, + "team_count":99, + "invitation_team_url":"url" + }` testJSONMarshal(t, u, want) } @@ -1681,7 +1743,11 @@ func TestIDPGroup_Marshal(t *testing.T) { GroupDescription: String("test group descripation"), } - want := `{"group_id":"abc1","group_name":"test group","group_description":"test group descripation"}` + want := `{ + "group_id":"abc1", + "group_name":"test group", + "group_description":"test group descripation" + }` testJSONMarshal(t, u, want) } @@ -2130,7 +2196,20 @@ func TestIDPGroupList_Marshal(t *testing.T) { }, } - want := `{"groups":[{"group_id":"abc1","group_name":"test group","group_description":"test group descripation"},{"group_id":"abc2","group_name":"test group2","group_description":"test group descripation2"}]}` + want := `{ + "groups":[ + { + "group_id":"abc1", + "group_name":"test group", + "group_description":"test group descripation" + }, + { + "group_id":"abc2", + "group_name":"test group2", + "group_description":"test group descripation2" + } + ] + }` testJSONMarshal(t, u, want) } @@ -2145,7 +2224,12 @@ func TestExternalGroupMember_Marshal(t *testing.T) { MemberEmail: String("test member email"), } - want := `{"member_id":1,"member_login":"test member","member_name":"test member name","member_email":"test member email"}` + want := `{ + "member_id":1, + "member_login":"test member", + "member_name":"test member name", + "member_email":"test member email" + }` testJSONMarshal(t, u, want) } @@ -2177,7 +2261,29 @@ func TestExternalGroup_Marshal(t *testing.T) { }, } - want := `{"group_id":123,"group_name":"group1","updated_at":` + referenceTimeStr + `,"teams":[{"team_id":1,"team_name":"team-test"},{"team_id":2,"team_name":"team-test2"}],"members":[{"member_id":1,"member_login":"test","member_name":"test","member_email":"test@github.com"}]}` + want := `{ + "group_id":123, + "group_name":"group1", + "updated_at":` + referenceTimeStr + `, + "teams":[ + { + "team_id":1, + "team_name":"team-test" + }, + { + "team_id":2, + "team_name":"team-test2" + } + ], + "members":[ + { + "member_id":1, + "member_login":"test", + "member_name":"test", + "member_email":"test@github.com" + } + ] + }` testJSONMarshal(t, u, want) } @@ -2190,7 +2296,10 @@ func TestExternalGroupTeam_Marshal(t *testing.T) { TeamName: String("test"), } - want := `{"team_id":123,"team_name":"test"}` + want := `{ + "team_id":123, + "team_name":"test" + }` testJSONMarshal(t, u, want) } diff --git a/github/users_emails_test.go b/github/users_emails_test.go index e4cf4739f8f..80a34157f47 100644 --- a/github/users_emails_test.go +++ b/github/users_emails_test.go @@ -131,7 +131,12 @@ func TestUserEmail_Marshal(t *testing.T) { Visibility: String("yes"), } - want := `{"email":"qwe@qwe.qwe","primary":false,"verified":true,"visibility":"yes"}` + want := `{ + "email":"qwe@qwe.qwe", + "primary":false, + "verified":true, + "visibility":"yes" + }` testJSONMarshal(t, u, want) } diff --git a/github/users_gpg_keys_test.go b/github/users_gpg_keys_test.go index ba3330cda66..d6e77b1e124 100644 --- a/github/users_gpg_keys_test.go +++ b/github/users_gpg_keys_test.go @@ -198,7 +198,10 @@ func TestGPGEmail_Marshal(t *testing.T) { Verified: Bool(false), } - want := `{"email":"email@abc.com","verified":false}` + want := `{ + "email":"email@abc.com", + "verified":false + }` testJSONMarshal(t, u, want) } @@ -231,7 +234,30 @@ func TestGPGKey_Marshal(t *testing.T) { ExpiresAt: ti, } - want := `{"id":1,"primary_key_id":1,"key_id":"someKeyID","raw_key":"someRawKeyID","public_key":"somePublicKey","emails":[{"email":"someEmail","verified":true}],"subkeys":[{}],"can_sign":true,"can_encrypt_comms":true,"can_encrypt_storage":true,"can_certify":true,"created_at":"0001-01-01T00:00:00Z","expires_at":"0001-01-01T00:00:00Z"}` + want := `{ + "id":1, + "primary_key_id":1, + "key_id":"someKeyID", + "raw_key":"someRawKeyID", + "public_key":"somePublicKey", + "emails":[ + { + "email":"someEmail", + "verified":true + } + ], + "subkeys":[ + { + + } + ], + "can_sign":true, + "can_encrypt_comms":true, + "can_encrypt_storage":true, + "can_certify":true, + "created_at":"0001-01-01T00:00:00Z", + "expires_at":"0001-01-01T00:00:00Z" + }` testJSONMarshal(t, g, want) } diff --git a/github/users_keys_test.go b/github/users_keys_test.go index 8dd966e8763..f9551a869ef 100644 --- a/github/users_keys_test.go +++ b/github/users_keys_test.go @@ -194,7 +194,15 @@ func TestKey_Marshal(t *testing.T) { CreatedAt: &Timestamp{referenceTime}, } - want := `{"id":1,"key":"abc","url":"url","title":"title","read_only":true,"verified":true,"created_at":` + referenceTimeStr + `}` + want := `{ + "id":1, + "key":"abc", + "url":"url", + "title":"title", + "read_only":true, + "verified":true, + "created_at":` + referenceTimeStr + ` + }` testJSONMarshal(t, u, want) } diff --git a/github/users_projects_test.go b/github/users_projects_test.go index 075cbe054b3..93271811a30 100644 --- a/github/users_projects_test.go +++ b/github/users_projects_test.go @@ -101,7 +101,10 @@ func TestCreateUserProjectOptions_Marshal(t *testing.T) { Body: String("SomeProjectBody"), } - want := `{"name":"SomeProject","body":"SomeProjectBody"}` + want := `{ + "name":"SomeProject", + "body":"SomeProjectBody" + }` testJSONMarshal(t, c, want) } diff --git a/github/users_ssh_signing_keys_test.go b/github/users_ssh_signing_keys_test.go index f22885212b9..a719786b769 100644 --- a/github/users_ssh_signing_keys_test.go +++ b/github/users_ssh_signing_keys_test.go @@ -191,7 +191,12 @@ func TestSSHSigningKey_Marshal(t *testing.T) { CreatedAt: &Timestamp{referenceTime}, } - want := `{"id":1,"key":"abc","title":"title","created_at":` + referenceTimeStr + `}` + want := `{ + "id":1, + "key":"abc", + "title":"title", + "created_at":` + referenceTimeStr + ` + }` testJSONMarshal(t, u, want) } diff --git a/github/users_test.go b/github/users_test.go index 2c5de3b0a55..6ba54583d14 100644 --- a/github/users_test.go +++ b/github/users_test.go @@ -38,7 +38,26 @@ func TestUser_Marshal(t *testing.T) { CreatedAt: &Timestamp{referenceTime}, SuspendedAt: &Timestamp{referenceTime}, } - want := `{"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"}` + want := `{ + "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) @@ -83,7 +102,46 @@ func TestUser_Marshal(t *testing.T) { LdapDn: String("test ldap"), } - want2 := `{"login":"testLogin","id":1,"node_id":"testNode123","avatar_url":"https://www.my-avatar.com","html_url":"https://www.test-url.com","gravatar_id":"testGravatar123","name":"myName","company":"testCompany","blog":"test Blog","location":"test location","email":"test@test.com","hireable":true,"bio":"my good bio","twitter_username":"https://www.twitter.com/test","public_repos":1,"public_gists":2,"followers":100,"following":29,"created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"suspended_at":` + referenceTimeStr + `,"type":"test type","site_admin":false,"total_private_repos":2,"owned_private_repos":1,"private_gists":1,"disk_usage":1,"collaborators":1,"two_factor_authentication":false,"plan":{"name":"silver","space":1024,"collaborators":10,"private_repos":4,"filled_seats":24,"seats":1},"ldap_dn":"test ldap"}` + want2 := `{ + "login":"testLogin", + "id":1, + "node_id":"testNode123", + "avatar_url":"https://www.my-avatar.com", + "html_url":"https://www.test-url.com", + "gravatar_id":"testGravatar123", + "name":"myName", + "company":"testCompany", + "blog":"test Blog", + "location":"test location", + "email":"test@test.com", + "hireable":true, + "bio":"my good bio", + "twitter_username":"https://www.twitter.com/test", + "public_repos":1, + "public_gists":2, + "followers":100, + "following":29, + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "suspended_at":` + referenceTimeStr + `, + "type":"test type", + "site_admin":false, + "total_private_repos":2, + "owned_private_repos":1, + "private_gists":1, + "disk_usage":1, + "collaborators":1, + "two_factor_authentication":false, + "plan":{ + "name":"silver", + "space":1024, + "collaborators":10, + "private_repos":4, + "filled_seats":24, + "seats":1 + }, + "ldap_dn":"test ldap" + }` testJSONMarshal(t, u2, want2) } @@ -403,7 +461,10 @@ func TestUserContext_Marshal(t *testing.T) { Octicon: String("message"), } - want := `{"message":"message","octicon":"message"}` + want := `{ + "message":"message", + "octicon":"message" + }` testJSONMarshal(t, u, want) } @@ -420,7 +481,14 @@ func TestHovercard_Marshal(t *testing.T) { }, } - want := `{"contexts":[{"message":"someMessage","octicon":"someOcticon"}]}` + want := `{ + "contexts":[ + { + "message":"someMessage", + "octicon":"someOcticon" + } + ] + }` testJSONMarshal(t, h, want) } From f34880aecbdcedd7771d15adcd7b64a0846f1da5 Mon Sep 17 00:00:00 2001 From: Geraldo Castro Date: Wed, 22 Mar 2023 18:03:39 -0300 Subject: [PATCH 04/12] Improve some json strings, revert some changes and remove TestRateLimitError_Marshal and TestAbuseRateLimitError_Marshal --- github/actions_runner_groups_test.go | 23 ++++++++++-- github/actions_runners_test.go | 47 +++++++++++++++++++++--- github/actions_secrets_test.go | 20 ++++++++-- github/actions_workflow_runs_test.go | 5 ++- github/checks_test.go | 5 ++- github/github.go | 8 ++-- github/github_test.go | 43 ---------------------- github/orgs_members_test.go | 5 ++- github/orgs_test.go | 23 +++++++++++- github/projects_test.go | 32 +++++++++++++++- github/teams_discussion_comments_test.go | 4 +- 11 files changed, 147 insertions(+), 68 deletions(-) diff --git a/github/actions_runner_groups_test.go b/github/actions_runner_groups_test.go index 9a6e7f1f21b..66e5bb2366a 100644 --- a/github/actions_runner_groups_test.go +++ b/github/actions_runner_groups_test.go @@ -566,7 +566,10 @@ func TestRunnerGroup_Marshal(t *testing.T) { } func TestRunnerGroups_Marshal(t *testing.T) { - testJSONMarshal(t, &RunnerGroups{}, `{"total_count":0,"runner_groups":null}`) + testJSONMarshal(t, &RunnerGroups{}, `{ + "total_count":0, + "runner_groups":null + }`) u := &RunnerGroups{ TotalCount: int(1), @@ -653,11 +656,25 @@ func TestUpdateRunnerGroupRequest_Marshal(t *testing.T) { SelectedWorkflows: []string{}, } - want := `{"name":"n","visibility":"v","allows_public_repositories":true,"restricted_to_workflows":false}` + want := `{ + "name":"n", + "visibility":"v", + "allows_public_repositories":true, + "restricted_to_workflows":false + }` testJSONMarshal(t, u, want) + u.SelectedWorkflows = []string{"1"} - want = `{"name":"n","visibility":"v","allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":["1"]}` + want = `{ + "name":"n", + "visibility":"v", + "allows_public_repositories":true, + "restricted_to_workflows":false, + "selected_workflows":[ + "1" + ] + }` testJSONMarshal(t, u, want) } diff --git a/github/actions_runners_test.go b/github/actions_runners_test.go index 7a7593e02cc..95201630c22 100644 --- a/github/actions_runners_test.go +++ b/github/actions_runners_test.go @@ -609,7 +609,10 @@ func TestRunnerApplicationDownload_Marshal(t *testing.T) { } func TestActionsEnabledOnOrgRepos_Marshal(t *testing.T) { - testJSONMarshal(t, &ActionsEnabledOnOrgRepos{}, `{"total_count":0,"repositories":null}`) + testJSONMarshal(t, &ActionsEnabledOnOrgRepos{}, `{ + "total_count":0, + "repositories":null + }`) u := &ActionsEnabledOnOrgRepos{ TotalCount: 1, @@ -622,7 +625,16 @@ func TestActionsEnabledOnOrgRepos_Marshal(t *testing.T) { }, } - want := `{"total_count":1,"repositories":[{"id":1,"name":"n","url":"u"}]}` + want := `{ + "total_count":1, + "repositories":[ + { + "id":1, + "name":"n", + "url":"u" + } + ] + }` testJSONMarshal(t, u, want) } @@ -635,7 +647,10 @@ func TestRegistrationToken_Marshal(t *testing.T) { ExpiresAt: &Timestamp{referenceTime}, } - want := `{"token":"t","expires_at":` + referenceTimeStr + `}` + want := `{ + "token":"t", + "expires_at":` + referenceTimeStr + ` + }` testJSONMarshal(t, u, want) } @@ -649,7 +664,11 @@ func TestRunnerLabels_Marshal(t *testing.T) { Type: String("t"), } - want := `{"id":1,"name":"n","type":"t"}` + want := `{ + "id":1, + "name":"n", + "type":"t" + }` testJSONMarshal(t, u, want) } @@ -672,7 +691,20 @@ func TestRunner_Marshal(t *testing.T) { }, } - want := `{"id":1,"name":"n","os":"o","status":"s","busy":false,"labels":[{"id":1,"name":"n","type":"t"}]}` + want := `{ + "id":1, + "name":"n", + "os":"o", + "status":"s", + "busy":false, + "labels":[ + { + "id":1, + "name":"n", + "type":"t" + } + ] + }` testJSONMarshal(t, u, want) } @@ -731,7 +763,10 @@ func TestRemoveToken_Marshal(t *testing.T) { ExpiresAt: &Timestamp{referenceTime}, } - want := `{"token":"t","expires_at":` + referenceTimeStr + `}` + want := `{ + "token":"t", + "expires_at":` + referenceTimeStr + ` + }` testJSONMarshal(t, u, want) } diff --git a/github/actions_secrets_test.go b/github/actions_secrets_test.go index 958c579fb13..f4b5b6057f3 100644 --- a/github/actions_secrets_test.go +++ b/github/actions_secrets_test.go @@ -812,14 +812,20 @@ func TestActionsService_DeleteEnvSecret(t *testing.T) { } func TestPublicKey_Marshal(t *testing.T) { - testJSONMarshal(t, &PublicKey{}, `{"key_id":null,"key":null}`) + testJSONMarshal(t, &PublicKey{}, `{ + "key_id":null, + "key":null + }`) u := &PublicKey{ KeyID: String("kid"), Key: String("k"), } - want := `{"key_id":"kid","key":"k"}` + want := `{ + "key_id":"kid", + "key":"k" + }` testJSONMarshal(t, u, want) } @@ -851,7 +857,10 @@ func TestSecret_Marshal(t *testing.T) { } func TestSecrets_Marshal(t *testing.T) { - testJSONMarshal(t, &Secrets{}, `{"total_count":0,"secrets":null}`) + testJSONMarshal(t, &Secrets{}, `{ + "total_count":0, + "secrets":null + }`) u := &Secrets{ TotalCount: 1, @@ -882,7 +891,10 @@ func TestSecrets_Marshal(t *testing.T) { } func TestEncryptedSecret_Marshal(t *testing.T) { - testJSONMarshal(t, &EncryptedSecret{}, `{"key_id":"","encrypted_value":""}`) + testJSONMarshal(t, &EncryptedSecret{}, `{ + "key_id":"", + "encrypted_value":"" + }`) u := &EncryptedSecret{ Name: "n", diff --git a/github/actions_workflow_runs_test.go b/github/actions_workflow_runs_test.go index 1322e4fbd56..79839453c33 100644 --- a/github/actions_workflow_runs_test.go +++ b/github/actions_workflow_runs_test.go @@ -990,7 +990,10 @@ func TestWorkflowRunBill_Marshal(t *testing.T) { Jobs: Int(1), } - want := `{"total_ms":1,"jobs":1}` + want := `{ + "total_ms":1, + "jobs":1 + }` testJSONMarshal(t, u, want) } diff --git a/github/checks_test.go b/github/checks_test.go index 2570361d5bb..57ece64f894 100644 --- a/github/checks_test.go +++ b/github/checks_test.go @@ -1120,7 +1120,10 @@ func TestCheckRunOutput_Marshal(t *testing.T) { } func TestCreateCheckRunOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &CreateCheckRunOptions{}, `{"name":"","head_sha":""}`) + testJSONMarshal(t, &CreateCheckRunOptions{}, `{ + "name":"", + "head_sha":"" + }`) u := &CreateCheckRunOptions{ Name: "n", diff --git a/github/github.go b/github/github.go index 36dd4e2b9e5..58715b11c6f 100644 --- a/github/github.go +++ b/github/github.go @@ -981,8 +981,8 @@ func (r *TwoFactorAuthError) Error() string { return (*ErrorResponse)(r).Error() // RateLimitError occurs when GitHub returns 403 Forbidden response with a rate limit // remaining value of 0. type RateLimitError struct { - Rate Rate `json:"rate"` // Rate specifies last known rate limit for the client - Response *http.Response `json:"-"` // HTTP response that caused this error + Rate Rate // Rate specifies last known rate limit for the client + Response *http.Response // HTTP response that caused this error Message string `json:"message"` // error message } @@ -1031,13 +1031,13 @@ func (ae *AcceptedError) Is(target error) bool { // AbuseRateLimitError occurs when GitHub returns 403 Forbidden response with the // "documentation_url" field value equal to "https://docs.github.com/en/rest/overview/resources-in-the-rest-api#secondary-rate-limits". type AbuseRateLimitError struct { - Response *http.Response `json:"-"` // HTTP response that caused this error + Response *http.Response // HTTP response that caused this error Message string `json:"message"` // error message // RetryAfter is provided with some abuse rate limit errors. If present, // it is the amount of time that the client should wait before retrying. // Otherwise, the client should try again later (after an unspecified amount of time). - RetryAfter *time.Duration `json:",omitempty"` + RetryAfter *time.Duration } func (r *AbuseRateLimitError) Error() string { diff --git a/github/github_test.go b/github/github_test.go index a2adc6a6d39..9e9c8918cd9 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -2705,49 +2705,6 @@ func TestErrorBlock_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } -func TestRateLimitError_Marshal(t *testing.T) { - testJSONMarshal(t, &RateLimitError{}, `{ - "rate":{ - "limit":0, - "remaining":0, - "reset":"0001-01-01T00:00:00Z" - }, - "message":"" - }`) - - u := &RateLimitError{ - Rate: Rate{ - Limit: 1, - Remaining: 1, - Reset: Timestamp{referenceTime}, - }, - Message: "msg", - } - - want := `{ - "rate":{ - "limit":1, - "remaining":1, - "reset":` + referenceTimeStr + ` - }, - "message":"msg" - }` - - testJSONMarshal(t, u, want) -} - -func TestAbuseRateLimitError_Marshal(t *testing.T) { - testJSONMarshal(t, &AbuseRateLimitError{}, `{"message":""}`) - - u := &AbuseRateLimitError{ - Message: "msg", - } - - want := `{"message":"msg"}` - - testJSONMarshal(t, u, want) -} - func TestError_Marshal(t *testing.T) { testJSONMarshal(t, &Error{}, `{ "resource":"", diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index c356b7f49fb..f320fbbd474 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -933,7 +933,10 @@ func TestMembership_Marshal(t *testing.T) { } func TestCreateOrgInvitationOptions_Marshal(t *testing.T) { - testJSONMarshal(t, &CreateOrgInvitationOptions{}, `{"role":null,"team_ids":null}`) + testJSONMarshal(t, &CreateOrgInvitationOptions{}, `{ + "role":null, + "team_ids":null + }`) u := &CreateOrgInvitationOptions{ InviteeID: Int64(1), diff --git a/github/orgs_test.go b/github/orgs_test.go index 675963329ad..87861236f51 100644 --- a/github/orgs_test.go +++ b/github/orgs_test.go @@ -40,7 +40,28 @@ func TestOrganization_Marshal(t *testing.T) { MembersCanCreatePublicPages: Bool(false), MembersCanCreatePrivatePages: Bool(true), } - want := `{"name":"github","company":"GitHub","blog":"https://github.com/blog","location":"San Francisco","email":"support@github.com","twitter_username":"github","description":"GitHub, the company.","billing_email":"support@github.com","is_verified":true,"has_organization_projects":true,"has_repository_projects":true,"default_repository_permission":"read","members_can_create_repositories":true,"members_can_create_public_repositories":false,"members_can_create_private_repositories":true,"members_can_create_internal_repositories":true,"members_allowed_repository_creation_type":"all","members_can_create_pages":true,"members_can_create_public_pages":false,"members_can_create_private_pages":true}` + want := `{ + "name":"github", + "company":"GitHub", + "blog":"https://github.com/blog", + "location":"San Francisco", + "email":"support@github.com", + "twitter_username":"github", + "description":"GitHub, the company.", + "billing_email":"support@github.com", + "is_verified":true, + "has_organization_projects":true, + "has_repository_projects":true, + "default_repository_permission":"read", + "members_can_create_repositories":true, + "members_can_create_public_repositories":false, + "members_can_create_private_repositories":true, + "members_can_create_internal_repositories":true, + "members_allowed_repository_creation_type":"all", + "members_can_create_pages":true, + "members_can_create_public_pages":false, + "members_can_create_private_pages":true + }` testJSONMarshal(t, o, want) } diff --git a/github/projects_test.go b/github/projects_test.go index 56315d59063..c69c9377a92 100644 --- a/github/projects_test.go +++ b/github/projects_test.go @@ -50,7 +50,37 @@ func TestProject_Marshal(t *testing.T) { URL: String("u"), }, } - want := `{"id":1,"url":"u","html_url":"h","columns_url":"c","owner_url":"o","name":"n","body":"b","number":1,"state":"s","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `,"node_id":"n","creator":{"login":"l","id":1,"avatar_url":"a","gravatar_id":"g","name":"n","company":"c","blog":"b","location":"l","email":"e","hireable":true,"public_repos":1,"followers":1,"following":1,"created_at":` + referenceTimeStr + `,"url":"u"}}` + want := `{ + "id":1, + "url":"u", + "html_url":"h", + "columns_url":"c", + "owner_url":"o", + "name":"n", + "body":"b", + "number":1, + "state":"s", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + `, + "node_id":"n", + "creator":{ + "login":"l", + "id":1, + "avatar_url":"a", + "gravatar_id":"g", + "name":"n", + "company":"c", + "blog":"b", + "location":"l", + "email":"e", + "hireable":true, + "public_repos":1, + "followers":1, + "following":1, + "created_at":` + referenceTimeStr + `, + "url":"u" + } + }` testJSONMarshal(t, u, want) } diff --git a/github/teams_discussion_comments_test.go b/github/teams_discussion_comments_test.go index e90a440ea40..f25be50df4a 100644 --- a/github/teams_discussion_comments_test.go +++ b/github/teams_discussion_comments_test.go @@ -463,9 +463,7 @@ func TestDiscussionComment_Marshal(t *testing.T) { } want := `{ - "author":{ - - }, + "author":{}, "body":"body", "body_html":"body html", "body_version":"body version", From 18c1f90d193440ecebba6063787758fb87b116f8 Mon Sep 17 00:00:00 2001 From: Geraldo Castro Date: Wed, 22 Mar 2023 19:04:45 -0300 Subject: [PATCH 05/12] Reverse change --- github/activity_notifications.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/activity_notifications.go b/github/activity_notifications.go index 3b270bc6333..03476c2e2c3 100644 --- a/github/activity_notifications.go +++ b/github/activity_notifications.go @@ -102,7 +102,7 @@ type markReadOptions struct { // MarkNotificationsRead marks all notifications up to lastRead as read. // -// GitHub API docs: https://docs.github.com/en/rest/activity#mark-notifications-as-read +// GitHub API docs: https://docs.github.com/en/rest/activity#mark-as-read func (s *ActivityService) MarkNotificationsRead(ctx context.Context, lastRead Timestamp) (*Response, error) { opts := &markReadOptions{ LastReadAt: lastRead, From 083760e7bfc23dc056050c78691503b326f72830 Mon Sep 17 00:00:00 2001 From: Geraldo Castro Date: Wed, 22 Mar 2023 19:51:07 -0300 Subject: [PATCH 06/12] Add json.Marshal to convert the value --- github/event_types_test.go | 1 - github/repos_contents_test.go | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/github/event_types_test.go b/github/event_types_test.go index d2eb1b4d723..d27d738d3f7 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -14868,7 +14868,6 @@ func TestSecurityAdvisoryEvent_Marshal(t *testing.T) { }, } - // convert `>` into `\u003e`` and `<` into `\u003c`` part, _ := json.Marshal(">= 2.0.0, < 2.0.2") want := `{ diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index 9e6e88563cd..2189272229d 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -7,6 +7,7 @@ package github import ( "context" + "encoding/json" "errors" "fmt" "io" @@ -954,10 +955,11 @@ func TestRepositoryContentFileOptions_Marshal(t *testing.T) { }, } - contentValue := `"AQ=="` + contentValue, _ := json.Marshal([]byte{1}) + want := `{ "message":"type", - "content":` + contentValue + `, + "content":` + string(contentValue) + `, "sha":"type", "branch":"type", "author":{ From 6c047e548a8164df8f5fc2f0518d683c10125263 Mon Sep 17 00:00:00 2001 From: Geraldo Castro Date: Thu, 23 Mar 2023 20:41:44 -0300 Subject: [PATCH 07/12] Create testStructTags func and add json.Marshal doc --- github/github_test.go | 52 ++++++++++++++++++++++++++--------- github/repos_contents_test.go | 6 ++-- github/repos_traffic_test.go | 1 - 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/github/github_test.go b/github/github_test.go index 9e9c8918cd9..beaed34e3e0 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -144,11 +144,47 @@ func testBody(t *testing.T, r *http.Request, want string) { } } -// Test whether the marshaling of v produces JSON that corresponds -// to the want string. +// Test whether structure v has the specified tag in all fields. +func testStructTags(t *testing.T, v interface{}, tag string) { + t.Helper() + + vt := reflect.Indirect(reflect.ValueOf(v)).Type() + for i := 0; i < vt.NumField(); i++ { + field := vt.Field(i) + if alias, ok := field.Tag.Lookup(tag); ok { + if alias == "" { + t.Errorf("The field %+v has a blank tag", field) + } + } else { + t.Errorf("The field %+v has no tag specified", field) + } + } +} + +// Test whether the marshaling of v produces JSON that corresponds to the +// want string. +// +// Since this is a strictly exact comparison, it is important that we follow +// some rules when constructing the expected value: +// +// - No extra spaces. JSON strings can be formatted using only line breaks +// and tabs (make sure they are tabs and not spaces). +// +// - The JSON fields must be in the same order as they were defined in the +// structure, or in lexicographical order if it's a map. +// +// - If it's necessary to mount strings that have characters such as ">", "<" +// or "&", consider using "json.Marshal" only for the necessary part and then +// use it to mount the expected JSON. +// +// - All fields must have the JSON tag. func testJSONMarshal(t *testing.T, v interface{}, want string) { t.Helper() + if reflect.ValueOf(v).Kind() == reflect.Struct { + testStructTags(t, v, "json") + } + j, err := json.Marshal(v) if err != nil { t.Errorf("Unable to unmarshal JSON for %v: %v", v, err) @@ -167,17 +203,7 @@ func testJSONMarshal(t *testing.T, v interface{}, want string) { func testAddURLOptions(t *testing.T, url string, v interface{}, want string) { t.Helper() - vt := reflect.Indirect(reflect.ValueOf(v)).Type() - for i := 0; i < vt.NumField(); i++ { - field := vt.Field(i) - if alias, ok := field.Tag.Lookup("url"); ok { - if alias == "" { - t.Errorf("The field %+v has a blank url tag", field) - } - } else { - t.Errorf("The field %+v has no url tag specified", field) - } - } + testStructTags(t, v, "url") got, err := addOptions(url, v) if err != nil { diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index 2189272229d..0c7df652f7c 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -7,7 +7,7 @@ package github import ( "context" - "encoding/json" + "encoding/base64" "errors" "fmt" "io" @@ -955,11 +955,11 @@ func TestRepositoryContentFileOptions_Marshal(t *testing.T) { }, } - contentValue, _ := json.Marshal([]byte{1}) + contentValue := base64.StdEncoding.EncodeToString([]byte{1}) want := `{ "message":"type", - "content":` + string(contentValue) + `, + "content":"` + contentValue + `", "sha":"type", "branch":"type", "author":{ diff --git a/github/repos_traffic_test.go b/github/repos_traffic_test.go index 42c979e8d08..01a38093ffc 100644 --- a/github/repos_traffic_test.go +++ b/github/repos_traffic_test.go @@ -298,7 +298,6 @@ func TestTrafficPath_Marshal(t *testing.T) { func TestTrafficData_Marshal(t *testing.T) { testJSONMarshal(t, &TrafficData{}, "{}") - // what about `referenceTimeStr`?! u := &TrafficData{ Timestamp: &Timestamp{time.Date(2016, time.May, 31, 16, 0, 0, 0, time.UTC)}, Count: Int(7), From 1e572a46b1ae02dbb43a8341131750ccc84e34a3 Mon Sep 17 00:00:00 2001 From: Geraldo Castro Date: Thu, 23 Mar 2023 21:18:20 -0300 Subject: [PATCH 08/12] Fix some json strings --- github/actions_runners_test.go | 5 ++- github/admin_test.go | 46 ++++++++++++++++++++++++-- github/event_types_test.go | 5 ++- github/pulls_reviews_test.go | 60 ++++++++++++++++++++++++++++++++-- github/repos_autolinks_test.go | 4 +-- 5 files changed, 110 insertions(+), 10 deletions(-) diff --git a/github/actions_runners_test.go b/github/actions_runners_test.go index 95201630c22..f294b90086b 100644 --- a/github/actions_runners_test.go +++ b/github/actions_runners_test.go @@ -710,7 +710,10 @@ func TestRunner_Marshal(t *testing.T) { } func TestRunners_Marshal(t *testing.T) { - testJSONMarshal(t, &Runners{}, `{"total_count":0,"runners":null}`) + testJSONMarshal(t, &Runners{}, `{ + "total_count":0, + "runners":null + }`) u := &Runners{ TotalCount: 1, diff --git a/github/admin_test.go b/github/admin_test.go index 8b9ec86d0e1..edb823f34ea 100644 --- a/github/admin_test.go +++ b/github/admin_test.go @@ -174,7 +174,18 @@ func TestTeamLDAPMapping_Marshal(t *testing.T) { RepositoriesURL: String("ru"), } - want := `{"id":1,"ldap_dn":"ldapdn","url":"u","name":"n","slug":"s","description":"d","privacy":"p","permission":"per","members_url":"mu","repositories_url":"ru"}` + want := `{ + "id":1, + "ldap_dn":"ldapdn", + "url":"u", + "name":"n", + "slug":"s", + "description":"d", + "privacy":"p", + "permission":"per", + "members_url":"mu", + "repositories_url":"ru" + }` testJSONMarshal(t, u, want) } @@ -202,7 +213,25 @@ func TestUserLDAPMapping_Marshal(t *testing.T) { SubscriptionsURL: String("subu"), } - want := `{"id":1,"ldap_dn":"ldapdn","login":"l","avatar_url":"au","gravatar_id":"gi","type":"t","site_admin":true,"url":"u","events_url":"eu","following_url":"fu","followers_url":"fu","gists_url":"gu","organizations_url":"ou","received_events_url":"reu","repos_url":"ru","starred_url":"su","subscriptions_url":"subu"}` + want := `{ + "id":1, + "ldap_dn":"ldapdn", + "login":"l", + "avatar_url":"au", + "gravatar_id":"gi", + "type":"t", + "site_admin":true, + "url":"u", + "events_url":"eu", + "following_url":"fu", + "followers_url":"fu", + "gists_url":"gu", + "organizations_url":"ou", + "received_events_url":"reu", + "repos_url":"ru", + "starred_url":"su", + "subscriptions_url":"subu" + }` testJSONMarshal(t, u, want) } @@ -223,7 +252,18 @@ func TestEnterprise_Marshal(t *testing.T) { UpdatedAt: &Timestamp{referenceTime}, } - want := `{"id":1,"slug":"s","name":"n","node_id":"nid","avatar_url":"au","description":"d","website_url":"wu","html_url":"hu","created_at":` + referenceTimeStr + `,"updated_at":` + referenceTimeStr + `}` + want := `{ + "id":1, + "slug":"s", + "name":"n", + "node_id":"nid", + "avatar_url":"au", + "description":"d", + "website_url":"wu", + "html_url":"hu", + "created_at":` + referenceTimeStr + `, + "updated_at":` + referenceTimeStr + ` + }` testJSONMarshal(t, u, want) } diff --git a/github/event_types_test.go b/github/event_types_test.go index d27d738d3f7..d09f286c9cc 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -12315,7 +12315,10 @@ func TestPushEventRepoOwner_Marshal(t *testing.T) { Email: String("e"), } - want := `{"name":"n","email":"e"}` + want := `{ + "name":"n", + "email":"e" + }` testJSONMarshal(t, u, want) } diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index ae7f45c4e14..6ac658ab8cc 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -655,7 +655,15 @@ func TestDraftReviewComment_Marshal(t *testing.T) { Line: Int(1), } - want := `{"path":"path","position":1,"body":"body","start_side":"ss","side":"side","start_line":1,"line":1}` + want := `{ + "path":"path", + "position":1, + "body":"body", + "start_side":"ss", + "side":"side", + "start_line":1, + "line":1 + }` testJSONMarshal(t, u, want) } @@ -681,7 +689,23 @@ func TestPullRequestReviewRequest_Marshal(t *testing.T) { }, } - want := `{"node_id":"nodeid","commit_id":"cid","body":"body","event":"event","comments":[{"path":"path","position":1,"body":"body","start_side":"ss","side":"side","start_line":1,"line":1}]}` + want := `{ + "node_id":"nodeid", + "commit_id":"cid", + "body":"body", + "event":"event", + "comments":[ + { + "path":"path", + "position":1, + "body":"body", + "start_side":"ss", + "side":"side", + "start_line":1, + "line":1 + } + ] + }` testJSONMarshal(t, u, want) } @@ -721,7 +745,37 @@ func TestPullRequestReview_Marshal(t *testing.T) { AuthorAssociation: String("aa"), } - want := `{"id":1,"node_id":"nid","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"},"body":"body","submitted_at":` + referenceTimeStr + `,"commit_id":"cid","html_url":"hurl","pull_request_url":"prurl","state":"state","author_association":"aa"}` + want := `{ + "id":1, + "node_id":"nid", + "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" + }, + "body":"body", + "submitted_at":` + referenceTimeStr + `, + "commit_id":"cid", + "html_url":"hurl", + "pull_request_url":"prurl", + "state":"state", + "author_association":"aa" + }` testJSONMarshal(t, u, want) } diff --git a/github/repos_autolinks_test.go b/github/repos_autolinks_test.go index 82378c7a4c5..16ab1347fb5 100644 --- a/github/repos_autolinks_test.go +++ b/github/repos_autolinks_test.go @@ -193,8 +193,8 @@ func TestAutolink_Marshal(t *testing.T) { } want := `{ - "id":1," - key_prefix":"kp", + "id":1, + "key_prefix":"kp", "url_template":"URLT", "is_alphanumeric":true }` From 84004de7b81e23357c5ad2fc3f2c3f72e4d7bd53 Mon Sep 17 00:00:00 2001 From: Geraldo Castro Date: Thu, 23 Mar 2023 22:15:26 -0300 Subject: [PATCH 09/12] Remove unnecessary '&' when passing the value (it was being used twice) --- github/checks_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/checks_test.go b/github/checks_test.go index 57ece64f894..e36635e611a 100644 --- a/github/checks_test.go +++ b/github/checks_test.go @@ -1497,7 +1497,7 @@ func TestListCheckRunsResults_Marshal(t *testing.T) { ] }` - testJSONMarshal(t, &l, w) + testJSONMarshal(t, l, w) } func TestListCheckSuiteResults_Marshal(t *testing.T) { @@ -1637,7 +1637,7 @@ func TestListCheckSuiteResults_Marshal(t *testing.T) { ] }` - testJSONMarshal(t, &l, w) + testJSONMarshal(t, l, w) } func TestCheckSuitePreferenceOptions_Marshal(t *testing.T) { From ed6221d6616ba89f144cc87bdf74d47f7e81e8ea Mon Sep 17 00:00:00 2001 From: Geraldo Castro Date: Thu, 23 Mar 2023 22:17:05 -0300 Subject: [PATCH 10/12] Add a workaround to find out whether the interface is a map or not --- github/github_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/github/github_test.go b/github/github_test.go index beaed34e3e0..16956693838 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -181,7 +181,9 @@ func testStructTags(t *testing.T, v interface{}, tag string) { func testJSONMarshal(t *testing.T, v interface{}, want string) { t.Helper() - if reflect.ValueOf(v).Kind() == reflect.Struct { + interfaceName := fmt.Sprintf("%s", reflect.ValueOf(&v).Elem().Interface()) + + if !strings.HasPrefix(interfaceName, "&map") { testStructTags(t, v, "json") } From 27eb1af57a2c60ab368b92fbc230d00fd81fa9f9 Mon Sep 17 00:00:00 2001 From: Geraldo Castro Date: Thu, 23 Mar 2023 22:28:55 -0300 Subject: [PATCH 11/12] Change to testJSONMarshal the responsibility for handling characters like '<' and '>' --- github/event_types_test.go | 4 +--- github/github_test.go | 6 ++---- github/teams_discussions_test.go | 3 +-- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/github/event_types_test.go b/github/event_types_test.go index d09f286c9cc..b946e7f8cc5 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -14871,8 +14871,6 @@ func TestSecurityAdvisoryEvent_Marshal(t *testing.T) { }, } - part, _ := json.Marshal(">= 2.0.0, < 2.0.2") - want := `{ "action":"published", "security_advisory":{ @@ -14900,7 +14898,7 @@ func TestSecurityAdvisoryEvent_Marshal(t *testing.T) { "name":"penaldo" }, "severity":"moderate", - "vulnerable_version_range":` + string(part) + `, + "vulnerable_version_range":">= 2.0.0, < 2.0.2", "first_patched_version":{ "identifier":"2.0.2" } diff --git a/github/github_test.go b/github/github_test.go index 16956693838..ba6e802c424 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -173,10 +173,6 @@ func testStructTags(t *testing.T, v interface{}, tag string) { // - The JSON fields must be in the same order as they were defined in the // structure, or in lexicographical order if it's a map. // -// - If it's necessary to mount strings that have characters such as ">", "<" -// or "&", consider using "json.Marshal" only for the necessary part and then -// use it to mount the expected JSON. -// // - All fields must have the JSON tag. func testJSONMarshal(t *testing.T, v interface{}, want string) { t.Helper() @@ -194,6 +190,8 @@ func testJSONMarshal(t *testing.T, v interface{}, want string) { want = strings.Replace(want, "\t", "", -1) want = strings.Replace(want, "\n", "", -1) + want = strings.Replace(want, "<", "\\u003c", -1) + want = strings.Replace(want, ">", "\\u003e", -1) if !bytes.Equal(j, []byte(want)) { t.Errorf("json.Marshal(%+v) returned %s, want %s", v, j, want) diff --git a/github/teams_discussions_test.go b/github/teams_discussions_test.go index 3c722020236..ab9a3d7ada1 100644 --- a/github/teams_discussions_test.go +++ b/github/teams_discussions_test.go @@ -585,7 +585,6 @@ func TestTeamDiscussion_Marshal(t *testing.T) { }, } - bodyHTML, _ := json.Marshal(`

test

`) want := `{ "author":{ "login":"author", @@ -597,7 +596,7 @@ func TestTeamDiscussion_Marshal(t *testing.T) { "url":"https://api.github.com/users/author" }, "body":"test", - "body_html":` + string(bodyHTML) + `, + "body_html":"

test

", "body_version":"version", "comments_count":1, "comments_url":"https://api.github.com/teams/2/discussions/3/comments", From d29f93249f34e9735085dce649317e139372c3f9 Mon Sep 17 00:00:00 2001 From: Geraldo Castro Date: Tue, 10 Oct 2023 14:18:36 -0300 Subject: [PATCH 12/12] Improve doc --- github/github_test.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/github/github_test.go b/github/github_test.go index f27153b9535..3a6522dce45 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -167,18 +167,21 @@ func testStructTags(t *testing.T, v interface{}, tag string) { // Since this is a strictly exact comparison, it is important that we follow // some rules when constructing the expected value: // -// - No extra spaces. JSON strings can be formatted using only line breaks -// and tabs (make sure they are tabs and not spaces). +// - No extra spaces. JSON strings can be formatted using only line breaks and tabs +// (make sure they are tabs and not spaces). // -// - The JSON fields must be in the same order as they were defined in the -// structure, or in lexicographical order if it's a map. +// - The JSON fields must be in the same order as they were defined in the +// structure, or in lexicographical order if it's a map. // -// - All fields must have the JSON tag. +// - All fields must have the JSON tag. func testJSONMarshal(t *testing.T, v interface{}, want string) { t.Helper() + // As the comparison can be made using structures and maps, we need to + // determine the name of the type of v to know if it's a map or not. interfaceName := fmt.Sprintf("%s", reflect.ValueOf(&v).Elem().Interface()) + // If the type of v is a structure, check that all fields have the JSON tag. if !strings.HasPrefix(interfaceName, "&map") { testStructTags(t, v, "json") } @@ -188,8 +191,11 @@ func testJSONMarshal(t *testing.T, v interface{}, want string) { t.Errorf("Unable to unmarshal JSON for %v: %v", v, err) } + // Remove all spaces and new lines from the JSON strings. want = strings.Replace(want, "\t", "", -1) want = strings.Replace(want, "\n", "", -1) + + // Replace the "<" and ">" characters with their unicode escape sequences. want = strings.Replace(want, "<", "\\u003c", -1) want = strings.Replace(want, ">", "\\u003e", -1)