Debian Codegraph @

github/event_types_test.go

raw
1 // Copyright 2020 The go-github AUTHORS. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file.
5
6 package github
7
8 import (
9 "encoding/json"
10 "testing"
11 )
12
13 func TestEditChange_Marshal_TitleChange(t *testing.T) {
14 testJSONMarshal(t, &EditChange{}, "{}")
15
16 u := &EditChange{
17 Title: &EditTitle{
18 From: String("TitleFrom"),
19 },
20 Body: nil,
21 Base: nil,
22 }
23
24 want := `{
25 "title": {
26 "from": "TitleFrom"
27 }
28 }`
29
30 testJSONMarshal(t, u, want)
31 }
32
33 func TestEditChange_Marshal_BodyChange(t *testing.T) {
34 testJSONMarshal(t, &EditChange{}, "{}")
35
36 u := &EditChange{
37 Title: nil,
38 Body: &EditBody{
39 From: String("BodyFrom"),
40 },
41 Base: nil,
42 }
43
44 want := `{
45 "body": {
46 "from": "BodyFrom"
47 }
48 }`
49
50 testJSONMarshal(t, u, want)
51 }
52
53 func TestEditChange_Marshal_BaseChange(t *testing.T) {
54 testJSONMarshal(t, &EditChange{}, "{}")
55
56 Base := EditBase{
57 Ref: &EditRef{
58 From: String("BaseRefFrom"),
59 },
60 SHA: &EditSHA{
61 From: String("BaseSHAFrom"),
62 },
63 }
64
65 u := &EditChange{
66 Title: nil,
67 Body: nil,
68 Base: &Base,
69 }
70
71 want := `{
72 "base": {
73 "ref": {
74 "from": "BaseRefFrom"
75 },
76 "sha": {
77 "from": "BaseSHAFrom"
78 }
79 }
80 }`
81
82 testJSONMarshal(t, u, want)
83 }
84
85 func TestEditChange_Marshal_Repo(t *testing.T) {
86 testJSONMarshal(t, &EditChange{}, "{}")
87
88 u := &EditChange{
89 Repo: &EditRepo{
90 Name: &RepoName{
91 From: String("old-repo-name"),
92 },
93 },
94 Topics: &EditTopics{
95 From: []string{"topic1", "topic2"},
96 },
97 }
98
99 want := `{
100 "repository": {
101 "name": {
102 "from": "old-repo-name"
103 }
104 },
105 "topics": {
106 "from": [
107 "topic1",
108 "topic2"
109 ]
110 }
111 }`
112
113 testJSONMarshal(t, u, want)
114 }
115
116 func TestEditChange_Marshal_TransferFromUser(t *testing.T) {
117 testJSONMarshal(t, &EditChange{}, "{}")
118
119 u := &EditChange{
120 Owner: &EditOwner{
121 OwnerInfo: &OwnerInfo{
122 User: &User{
123 Login: String("l"),
124 ID: Int64(1),
125 NodeID: String("n"),
126 URL: String("u"),
127 ReposURL: String("r"),
128 EventsURL: String("e"),
129 AvatarURL: String("a"),
130 },
131 },
132 },
133 }
134
135 want := `{
136 "owner": {
137 "from": {
138 "user": {
139 "login": "l",
140 "id": 1,
141 "node_id": "n",
142 "avatar_url": "a",
143 "url": "u",
144 "repos_url": "r",
145 "events_url": "e"
146 }
147 }
148 }
149 }`
150
151 testJSONMarshal(t, u, want)
152 }
153
154 func TestEditChange_Marshal_TransferFromOrg(t *testing.T) {
155 testJSONMarshal(t, &EditChange{}, "{}")
156
157 u := &EditChange{
158 Owner: &EditOwner{
159 OwnerInfo: &OwnerInfo{
160 Org: &User{
161 Login: String("l"),
162 ID: Int64(1),
163 NodeID: String("n"),
164 URL: String("u"),
165 ReposURL: String("r"),
166 EventsURL: String("e"),
167 AvatarURL: String("a"),
168 },
169 },
170 },
171 }
172
173 want := `{
174 "owner": {
175 "from": {
176 "organization": {
177 "login": "l",
178 "id": 1,
179 "node_id": "n",
180 "avatar_url": "a",
181 "url": "u",
182 "repos_url": "r",
183 "events_url": "e"
184 }
185 }
186 }
187 }`
188
189 testJSONMarshal(t, u, want)
190 }
191
192 func TestProjectChange_Marshal_NameChange(t *testing.T) {
193 testJSONMarshal(t, &ProjectChange{}, "{}")
194
195 u := &ProjectChange{
196 Name: &ProjectName{From: String("NameFrom")},
197 Body: nil,
198 }
199
200 want := `{
201 "name": {
202 "from": "NameFrom"
203 }
204 }`
205
206 testJSONMarshal(t, u, want)
207 }
208
209 func TestProjectChange_Marshal_BodyChange(t *testing.T) {
210 testJSONMarshal(t, &ProjectChange{}, "{}")
211
212 u := &ProjectChange{
213 Name: nil,
214 Body: &ProjectBody{From: String("BodyFrom")},
215 }
216
217 want := `{
218 "body": {
219 "from": "BodyFrom"
220 }
221 }`
222
223 testJSONMarshal(t, u, want)
224 }
225
226 func TestProjectCardChange_Marshal_NoteChange(t *testing.T) {
227 testJSONMarshal(t, &ProjectCardChange{}, "{}")
228
229 u := &ProjectCardChange{
230 Note: &ProjectCardNote{From: String("NoteFrom")},
231 }
232
233 want := `{
234 "note": {
235 "from": "NoteFrom"
236 }
237 }`
238
239 testJSONMarshal(t, u, want)
240 }
241
242 func TestProjectColumnChange_Marshal_NameChange(t *testing.T) {
243 testJSONMarshal(t, &ProjectColumnChange{}, "{}")
244
245 u := &ProjectColumnChange{
246 Name: &ProjectColumnName{From: String("NameFrom")},
247 }
248
249 want := `{
250 "name": {
251 "from": "NameFrom"
252 }
253 }`
254
255 testJSONMarshal(t, u, want)
256 }
257
258 func TestTeamAddEvent_Marshal(t *testing.T) {
259 testJSONMarshal(t, &TeamAddEvent{}, "{}")
260
261 u := &TeamAddEvent{
262 Team: &Team{
263 ID: Int64(1),
264 NodeID: String("n"),
265 Name: String("n"),
266 Description: String("d"),
267 URL: String("u"),
268 Slug: String("s"),
269 Permission: String("p"),
270 Privacy: String("p"),
271 MembersCount: Int(1),
272 ReposCount: Int(1),
273 MembersURL: String("m"),
274 RepositoriesURL: String("r"),
275 Organization: &Organization{
276 Login: String("l"),
277 ID: Int64(1),
278 NodeID: String("n"),
279 AvatarURL: String("a"),
280 HTMLURL: String("h"),
281 Name: String("n"),
282 Company: String("c"),
283 Blog: String("b"),
284 Location: String("l"),
285 Email: String("e"),
286 },
287 Parent: &Team{
288 ID: Int64(1),
289 NodeID: String("n"),
290 Name: String("n"),
291 Description: String("d"),
292 URL: String("u"),
293 Slug: String("s"),
294 Permission: String("p"),
295 Privacy: String("p"),
296 MembersCount: Int(1),
297 ReposCount: Int(1),
298 },
299 LDAPDN: String("l"),
300 },
301 Repo: &Repository{
302 ID: Int64(1),
303 URL: String("s"),
304 Name: String("n"),
305 },
306 Org: &Organization{
307 BillingEmail: String("be"),
308 Blog: String("b"),
309 Company: String("c"),
310 Email: String("e"),
311 TwitterUsername: String("tu"),
312 Location: String("loc"),
313 Name: String("n"),
314 Description: String("d"),
315 IsVerified: Bool(true),
316 HasOrganizationProjects: Bool(true),
317 HasRepositoryProjects: Bool(true),
318 DefaultRepoPermission: String("drp"),
319 MembersCanCreateRepos: Bool(true),
320 MembersCanCreateInternalRepos: Bool(true),
321 MembersCanCreatePrivateRepos: Bool(true),
322 MembersCanCreatePublicRepos: Bool(false),
323 MembersAllowedRepositoryCreationType: String("marct"),
324 MembersCanCreatePages: Bool(true),
325 MembersCanCreatePublicPages: Bool(false),
326 MembersCanCreatePrivatePages: Bool(true),
327 },
328 Sender: &User{
329 Login: String("l"),
330 ID: Int64(1),
331 NodeID: String("n"),
332 URL: String("u"),
333 ReposURL: String("r"),
334 EventsURL: String("e"),
335 AvatarURL: String("a"),
336 },
337 Installation: &Installation{
338 ID: Int64(1),
339 NodeID: String("nid"),
340 AppID: Int64(1),
341 AppSlug: String("as"),
342 TargetID: Int64(1),
343 Account: &User{
344 Login: String("l"),
345 ID: Int64(1),
346 URL: String("u"),
347 AvatarURL: String("a"),
348 GravatarID: String("g"),
349 Name: String("n"),
350 Company: String("c"),
351 Blog: String("b"),
352 Location: String("l"),
353 Email: String("e"),
354 Hireable: Bool(true),
355 Bio: String("b"),
356 TwitterUsername: String("t"),
357 PublicRepos: Int(1),
358 Followers: Int(1),
359 Following: Int(1),
360 CreatedAt: &Timestamp{referenceTime},
361 SuspendedAt: &Timestamp{referenceTime},
362 },
363 AccessTokensURL: String("atu"),
364 RepositoriesURL: String("ru"),
365 HTMLURL: String("hu"),
366 TargetType: String("tt"),
367 SingleFileName: String("sfn"),
368 RepositorySelection: String("rs"),
369 Events: []string{"e"},
370 SingleFilePaths: []string{"s"},
371 Permissions: &InstallationPermissions{
372 Actions: String("a"),
373 Administration: String("ad"),
374 Checks: String("c"),
375 Contents: String("co"),
376 ContentReferences: String("cr"),
377 Deployments: String("d"),
378 Environments: String("e"),
379 Issues: String("i"),
380 Metadata: String("md"),
381 Members: String("m"),
382 OrganizationAdministration: String("oa"),
383 OrganizationHooks: String("oh"),
384 OrganizationPlan: String("op"),
385 OrganizationPreReceiveHooks: String("opr"),
386 OrganizationProjects: String("op"),
387 OrganizationSecrets: String("os"),
388 OrganizationSelfHostedRunners: String("osh"),
389 OrganizationUserBlocking: String("oub"),
390 Packages: String("pkg"),
391 Pages: String("pg"),
392 PullRequests: String("pr"),
393 RepositoryHooks: String("rh"),
394 RepositoryProjects: String("rp"),
395 RepositoryPreReceiveHooks: String("rprh"),
396 Secrets: String("s"),
397 SecretScanningAlerts: String("ssa"),
398 SecurityEvents: String("se"),
399 SingleFile: String("sf"),
400 Statuses: String("s"),
401 TeamDiscussions: String("td"),
402 VulnerabilityAlerts: String("va"),
403 Workflows: String("w"),
404 },
405 CreatedAt: &Timestamp{referenceTime},
406 UpdatedAt: &Timestamp{referenceTime},
407 HasMultipleSingleFiles: Bool(false),
408 SuspendedBy: &User{
409 Login: String("l"),
410 ID: Int64(1),
411 URL: String("u"),
412 AvatarURL: String("a"),
413 GravatarID: String("g"),
414 Name: String("n"),
415 Company: String("c"),
416 Blog: String("b"),
417 Location: String("l"),
418 Email: String("e"),
419 Hireable: Bool(true),
420 Bio: String("b"),
421 TwitterUsername: String("t"),
422 PublicRepos: Int(1),
423 Followers: Int(1),
424 Following: Int(1),
425 CreatedAt: &Timestamp{referenceTime},
426 SuspendedAt: &Timestamp{referenceTime},
427 },
428 SuspendedAt: &Timestamp{referenceTime},
429 },
430 }
431
432 want := `{
433 "team": {
434 "id": 1,
435 "node_id": "n",
436 "name": "n",
437 "description": "d",
438 "url": "u",
439 "slug": "s",
440 "permission": "p",
441 "privacy": "p",
442 "members_count": 1,
443 "repos_count": 1,
444 "organization": {
445 "login": "l",
446 "id": 1,
447 "node_id": "n",
448 "avatar_url": "a",
449 "html_url": "h",
450 "name": "n",
451 "company": "c",
452 "blog": "b",
453 "location": "l",
454 "email": "e"
455 },
456 "members_url": "m",
457 "repositories_url": "r",
458 "parent": {
459 "id": 1,
460 "node_id": "n",
461 "name": "n",
462 "description": "d",
463 "url": "u",
464 "slug": "s",
465 "permission": "p",
466 "privacy": "p",
467 "members_count": 1,
468 "repos_count": 1
469 },
470 "ldap_dn": "l"
471 },
472 "repository": {
473 "id": 1,
474 "name": "n",
475 "url": "s"
476 },
477 "organization": {
478 "name": "n",
479 "company": "c",
480 "blog": "b",
481 "location": "loc",
482 "email": "e",
483 "twitter_username": "tu",
484 "description": "d",
485 "billing_email": "be",
486 "is_verified": true,
487 "has_organization_projects": true,
488 "has_repository_projects": true,
489 "default_repository_permission": "drp",
490 "members_can_create_repositories": true,
491 "members_can_create_public_repositories": false,
492 "members_can_create_private_repositories": true,
493 "members_can_create_internal_repositories": true,
494 "members_allowed_repository_creation_type": "marct",
495 "members_can_create_pages": true,
496 "members_can_create_public_pages": false,
497 "members_can_create_private_pages": true
498 },
499 "sender": {
500 "login": "l",
501 "id": 1,
502 "node_id": "n",
503 "avatar_url": "a",
504 "url": "u",
505 "events_url": "e",
506 "repos_url": "r"
507 },
508 "installation": {
509 "id": 1,
510 "node_id": "nid",
511 "app_id": 1,
512 "app_slug": "as",
513 "target_id": 1,
514 "account": {
515 "login": "l",
516 "id": 1,
517 "avatar_url": "a",
518 "gravatar_id": "g",
519 "name": "n",
520 "company": "c",
521 "blog": "b",
522 "location": "l",
523 "email": "e",
524 "hireable": true,
525 "bio": "b",
526 "twitter_username": "t",
527 "public_repos": 1,
528 "followers": 1,
529 "following": 1,
530 "created_at": ` + referenceTimeStr + `,
531 "suspended_at": ` + referenceTimeStr + `,
532 "url": "u"
533 },
534 "access_tokens_url": "atu",
535 "repositories_url": "ru",
536 "html_url": "hu",
537 "target_type": "tt",
538 "single_file_name": "sfn",
539 "repository_selection": "rs",
540 "events": [
541 "e"
542 ],
543 "single_file_paths": [
544 "s"
545 ],
546 "permissions": {
547 "actions": "a",
548 "administration": "ad",
549 "checks": "c",
550 "contents": "co",
551 "content_references": "cr",
552 "deployments": "d",
553 "environments": "e",
554 "issues": "i",
555 "metadata": "md",
556 "members": "m",
557 "organization_administration": "oa",
558 "organization_hooks": "oh",
559 "organization_plan": "op",
560 "organization_pre_receive_hooks": "opr",
561 "organization_projects": "op",
562 "organization_secrets": "os",
563 "organization_self_hosted_runners": "osh",
564 "organization_user_blocking": "oub",
565 "packages": "pkg",
566 "pages": "pg",
567 "pull_requests": "pr",
568 "repository_hooks": "rh",
569 "repository_projects": "rp",
570 "repository_pre_receive_hooks": "rprh",
571 "secrets": "s",
572 "secret_scanning_alerts": "ssa",
573 "security_events": "se",
574 "single_file": "sf",
575 "statuses": "s",
576 "team_discussions": "td",
577 "vulnerability_alerts": "va",
578 "workflows": "w"
579 },
580 "created_at": ` + referenceTimeStr + `,
581 "updated_at": ` + referenceTimeStr + `,
582 "has_multiple_single_files": false,
583 "suspended_by": {
584 "login": "l",
585 "id": 1,
586 "avatar_url": "a",
587 "gravatar_id": "g",
588 "name": "n",
589 "company": "c",
590 "blog": "b",
591 "location": "l",
592 "email": "e",
593 "hireable": true,
594 "bio": "b",
595 "twitter_username": "t",
596 "public_repos": 1,
597 "followers": 1,
598 "following": 1,
599 "created_at": ` + referenceTimeStr + `,
600 "suspended_at": ` + referenceTimeStr + `,
601 "url": "u"
602 },
603 "suspended_at": ` + referenceTimeStr + `
604 }
605 }`
606
607 testJSONMarshal(t, u, want)
608 }
609
610 func TestStarEvent_Marshal(t *testing.T) {
611 testJSONMarshal(t, &StarEvent{}, "{}")
612
613 u := &StarEvent{
614 Action: String("a"),
615 StarredAt: &Timestamp{referenceTime},
616 Org: &Organization{
617 BillingEmail: String("be"),
618 Blog: String("b"),
619 Company: String("c"),
620 Email: String("e"),
621 TwitterUsername: String("tu"),
622 Location: String("loc"),
623 Name: String("n"),
624 Description: String("d"),
625 IsVerified: Bool(true),
626 HasOrganizationProjects: Bool(true),
627 HasRepositoryProjects: Bool(true),
628 DefaultRepoPermission: String("drp"),
629 MembersCanCreateRepos: Bool(true),
630 MembersCanCreateInternalRepos: Bool(true),
631 MembersCanCreatePrivateRepos: Bool(true),
632 MembersCanCreatePublicRepos: Bool(false),
633 MembersAllowedRepositoryCreationType: String("marct"),
634 MembersCanCreatePages: Bool(true),
635 MembersCanCreatePublicPages: Bool(false),
636 MembersCanCreatePrivatePages: Bool(true),
637 },
638 Repo: &Repository{
639 ID: Int64(1),
640 URL: String("s"),
641 Name: String("n"),
642 },
643 Sender: &User{
644 Login: String("l"),
645 ID: Int64(1),
646 NodeID: String("n"),
647 URL: String("u"),
648 ReposURL: String("r"),
649 EventsURL: String("e"),
650 AvatarURL: String("a"),
651 },
652 }
653
654 want := `{
655 "action": "a",
656 "starred_at": ` + referenceTimeStr + `,
657 "organization": {
658 "name": "n",
659 "company": "c",
660 "blog": "b",
661 "location": "loc",
662 "email": "e",
663 "twitter_username": "tu",
664 "description": "d",
665 "billing_email": "be",
666 "is_verified": true,
667 "has_organization_projects": true,
668 "has_repository_projects": true,
669 "default_repository_permission": "drp",
670 "members_can_create_repositories": true,
671 "members_can_create_public_repositories": false,
672 "members_can_create_private_repositories": true,
673 "members_can_create_internal_repositories": true,
674 "members_allowed_repository_creation_type": "marct",
675 "members_can_create_pages": true,
676 "members_can_create_public_pages": false,
677 "members_can_create_private_pages": true
678 },
679 "repository": {
680 "id": 1,
681 "name": "n",
682 "url": "s"
683 },
684 "sender": {
685 "login": "l",
686 "id": 1,
687 "node_id": "n",
688 "avatar_url": "a",
689 "url": "u",
690 "events_url": "e",
691 "repos_url": "r"
692 }
693 }`
694
695 testJSONMarshal(t, u, want)
696 }
697
698 func TestTeamEvent_Marshal(t *testing.T) {
699 testJSONMarshal(t, &TeamEvent{}, "{}")
700
701 u := &TeamEvent{
702 Action: String("a"),
703 Team: &Team{
704 ID: Int64(1),
705 NodeID: String("n"),
706 Name: String("n"),
707 Description: String("d"),
708 URL: String("u"),
709 Slug: String("s"),
710 Permission: String("p"),
711 Privacy: String("p"),
712 MembersCount: Int(1),
713 ReposCount: Int(1),
714 MembersURL: String("m"),
715 RepositoriesURL: String("r"),
716 Organization: &Organization{
717 Login: String("l"),
718 ID: Int64(1),
719 NodeID: String("n"),
720 AvatarURL: String("a"),
721 HTMLURL: String("h"),
722 Name: String("n"),
723 Company: String("c"),
724 Blog: String("b"),
725 Location: String("l"),
726 Email: String("e"),
727 },
728 Parent: &Team{
729 ID: Int64(1),
730 NodeID: String("n"),
731 Name: String("n"),
732 Description: String("d"),
733 URL: String("u"),
734 Slug: String("s"),
735 Permission: String("p"),
736 Privacy: String("p"),
737 MembersCount: Int(1),
738 ReposCount: Int(1),
739 },
740 LDAPDN: String("l"),
741 },
742 Changes: &TeamChange{
743 Description: &TeamDescription{
744 From: String("from"),
745 },
746 Name: &TeamName{
747 From: String("from"),
748 },
749 Privacy: &TeamPrivacy{
750 From: String("from"),
751 },
752 Repository: &TeamRepository{
753 Permissions: &TeamPermissions{
754 From: &TeamPermissionsFrom{
755 Admin: Bool(true),
756 Pull: Bool(true),
757 Push: Bool(true),
758 },
759 },
760 },
761 },
762 Repo: &Repository{
763 ID: Int64(1),
764 URL: String("s"),
765 Name: String("n"),
766 },
767 Org: &Organization{
768 BillingEmail: String("be"),
769 Blog: String("b"),
770 Company: String("c"),
771 Email: String("e"),
772 TwitterUsername: String("tu"),
773 Location: String("loc"),
774 Name: String("n"),
775 Description: String("d"),
776 IsVerified: Bool(true),
777 HasOrganizationProjects: Bool(true),
778 HasRepositoryProjects: Bool(true),
779 DefaultRepoPermission: String("drp"),
780 MembersCanCreateRepos: Bool(true),
781 MembersCanCreateInternalRepos: Bool(true),
782 MembersCanCreatePrivateRepos: Bool(true),
783 MembersCanCreatePublicRepos: Bool(false),
784 MembersAllowedRepositoryCreationType: String("marct"),
785 MembersCanCreatePages: Bool(true),
786 MembersCanCreatePublicPages: Bool(false),
787 MembersCanCreatePrivatePages: Bool(true),
788 },
789 Sender: &User{
790 Login: String("l"),
791 ID: Int64(1),
792 NodeID: String("n"),
793 URL: String("u"),
794 ReposURL: String("r"),
795 EventsURL: String("e"),
796 AvatarURL: String("a"),
797 },
798 Installation: &Installation{
799 ID: Int64(1),
800 NodeID: String("nid"),
801 AppID: Int64(1),
802 AppSlug: String("as"),
803 TargetID: Int64(1),
804 Account: &User{
805 Login: String("l"),
806 ID: Int64(1),
807 URL: String("u"),
808 AvatarURL: String("a"),
809 GravatarID: String("g"),
810 Name: String("n"),
811 Company: String("c"),
812 Blog: String("b"),
813 Location: String("l"),
814 Email: String("e"),
815 Hireable: Bool(true),
816 Bio: String("b"),
817 TwitterUsername: String("t"),
818 PublicRepos: Int(1),
819 Followers: Int(1),
820 Following: Int(1),
821 CreatedAt: &Timestamp{referenceTime},
822 SuspendedAt: &Timestamp{referenceTime},
823 },
824 AccessTokensURL: String("atu"),
825 RepositoriesURL: String("ru"),
826 HTMLURL: String("hu"),
827 TargetType: String("tt"),
828 SingleFileName: String("sfn"),
829 RepositorySelection: String("rs"),
830 Events: []string{"e"},
831 SingleFilePaths: []string{"s"},
832 Permissions: &InstallationPermissions{
833 Actions: String("a"),
834 Administration: String("ad"),
835 Checks: String("c"),
836 Contents: String("co"),
837 ContentReferences: String("cr"),
838 Deployments: String("d"),
839 Environments: String("e"),
840 Issues: String("i"),
841 Metadata: String("md"),
842 Members: String("m"),
843 OrganizationAdministration: String("oa"),
844 OrganizationHooks: String("oh"),
845 OrganizationPlan: String("op"),
846 OrganizationPreReceiveHooks: String("opr"),
847 OrganizationProjects: String("op"),
848 OrganizationSecrets: String("os"),
849 OrganizationSelfHostedRunners: String("osh"),
850 OrganizationUserBlocking: String("oub"),
851 Packages: String("pkg"),
852 Pages: String("pg"),
853 PullRequests: String("pr"),
854 RepositoryHooks: String("rh"),
855 RepositoryProjects: String("rp"),
856 RepositoryPreReceiveHooks: String("rprh"),
857 Secrets: String("s"),
858 SecretScanningAlerts: String("ssa"),
859 SecurityEvents: String("se"),
860 SingleFile: String("sf"),
861 Statuses: String("s"),
862 TeamDiscussions: String("td"),
863 VulnerabilityAlerts: String("va"),
864 Workflows: String("w"),
865 },
866 CreatedAt: &Timestamp{referenceTime},
867 UpdatedAt: &Timestamp{referenceTime},
868 HasMultipleSingleFiles: Bool(false),
869 SuspendedBy: &User{
870 Login: String("l"),
871 ID: Int64(1),
872 URL: String("u"),
873 AvatarURL: String("a"),
874 GravatarID: String("g"),
875 Name: String("n"),
876 Company: String("c"),
877 Blog: String("b"),
878 Location: String("l"),
879 Email: String("e"),
880 Hireable: Bool(true),
881 Bio: String("b"),
882 TwitterUsername: String("t"),
883 PublicRepos: Int(1),
884 Followers: Int(1),
885 Following: Int(1),
886 CreatedAt: &Timestamp{referenceTime},
887 SuspendedAt: &Timestamp{referenceTime},
888 },
889 SuspendedAt: &Timestamp{referenceTime},
890 },
891 }
892
893 want := `{
894 "action": "a",
895 "team": {
896 "id": 1,
897 "node_id": "n",
898 "name": "n",
899 "description": "d",
900 "url": "u",
901 "slug": "s",
902 "permission": "p",
903 "privacy": "p",
904 "members_count": 1,
905 "repos_count": 1,
906 "organization": {
907 "login": "l",
908 "id": 1,
909 "node_id": "n",
910 "avatar_url": "a",
911 "html_url": "h",
912 "name": "n",
913 "company": "c",
914 "blog": "b",
915 "location": "l",
916 "email": "e"
917 },
918 "members_url": "m",
919 "repositories_url": "r",
920 "parent": {
921 "id": 1,
922 "node_id": "n",
923 "name": "n",
924 "description": "d",
925 "url": "u",
926 "slug": "s",
927 "permission": "p",
928 "privacy": "p",
929 "members_count": 1,
930 "repos_count": 1
931 },
932 "ldap_dn": "l"
933 },
934 "changes": {
935 "description": {
936 "from": "from"
937 },
938 "name": {
939 "from": "from"
940 },
941 "privacy": {
942 "from": "from"
943 },
944 "repository": {
945 "permissions": {
946 "from": {
947 "admin": true,
948 "pull": true,
949 "push": true
950 }
951 }
952 }
953 },
954 "repository": {
955 "id": 1,
956 "name": "n",
957 "url": "s"
958 },
959 "organization": {
960 "name": "n",
961 "company": "c",
962 "blog": "b",
963 "location": "loc",
964 "email": "e",
965 "twitter_username": "tu",
966 "description": "d",
967 "billing_email": "be",
968 "is_verified": true,
969 "has_organization_projects": true,
970 "has_repository_projects": true,
971 "default_repository_permission": "drp",
972 "members_can_create_repositories": true,
973 "members_can_create_public_repositories": false,
974 "members_can_create_private_repositories": true,
975 "members_can_create_internal_repositories": true,
976 "members_allowed_repository_creation_type": "marct",
977 "members_can_create_pages": true,
978 "members_can_create_public_pages": false,
979 "members_can_create_private_pages": true
980 },
981 "sender": {
982 "login": "l",
983 "id": 1,
984 "node_id": "n",
985 "avatar_url": "a",
986 "url": "u",
987 "events_url": "e",
988 "repos_url": "r"
989 },
990 "installation": {
991 "id": 1,
992 "node_id": "nid",
993 "app_id": 1,
994 "app_slug": "as",
995 "target_id": 1,
996 "account": {
997 "login": "l",
998 "id": 1,
999 "avatar_url": "a",
1000 "gravatar_id": "g",
1001 "name": "n",
1002 "company": "c",
1003 "blog": "b",
1004 "location": "l",
1005 "email": "e",
1006 "hireable": true,
1007 "bio": "b",
1008 "twitter_username": "t",
1009 "public_repos": 1,
1010 "followers": 1,
1011 "following": 1,
1012 "created_at": ` + referenceTimeStr + `,
1013 "suspended_at": ` + referenceTimeStr + `,
1014 "url": "u"
1015 },
1016 "access_tokens_url": "atu",
1017 "repositories_url": "ru",
1018 "html_url": "hu",
1019 "target_type": "tt",
1020 "single_file_name": "sfn",
1021 "repository_selection": "rs",
1022 "events": [
1023 "e"
1024 ],
1025 "single_file_paths": [
1026 "s"
1027 ],
1028 "permissions": {
1029 "actions": "a",
1030 "administration": "ad",
1031 "checks": "c",
1032 "contents": "co",
1033 "content_references": "cr",
1034 "deployments": "d",
1035 "environments": "e",
1036 "issues": "i",
1037 "metadata": "md",
1038 "members": "m",
1039 "organization_administration": "oa",
1040 "organization_hooks": "oh",
1041 "organization_plan": "op",
1042 "organization_pre_receive_hooks": "opr",
1043 "organization_projects": "op",
1044 "organization_secrets": "os",
1045 "organization_self_hosted_runners": "osh",
1046 "organization_user_blocking": "oub",
1047 "packages": "pkg",
1048 "pages": "pg",
1049 "pull_requests": "pr",
1050 "repository_hooks": "rh",
1051 "repository_projects": "rp",
1052 "repository_pre_receive_hooks": "rprh",
1053 "secrets": "s",
1054 "secret_scanning_alerts": "ssa",
1055 "security_events": "se",
1056 "single_file": "sf",
1057 "statuses": "s",
1058 "team_discussions": "td",
1059 "vulnerability_alerts": "va",
1060 "workflows": "w"
1061 },
1062 "created_at": ` + referenceTimeStr + `,
1063 "updated_at": ` + referenceTimeStr + `,
1064 "has_multiple_single_files": false,
1065 "suspended_by": {
1066 "login": "l",
1067 "id": 1,
1068 "avatar_url": "a",
1069 "gravatar_id": "g",
1070 "name": "n",
1071 "company": "c",
1072 "blog": "b",
1073 "location": "l",
1074 "email": "e",
1075 "hireable": true,
1076 "bio": "b",
1077 "twitter_username": "t",
1078 "public_repos": 1,
1079 "followers": 1,
1080 "following": 1,
1081 "created_at": ` + referenceTimeStr + `,
1082 "suspended_at": ` + referenceTimeStr + `,
1083 "url": "u"
1084 },
1085 "suspended_at": ` + referenceTimeStr + `
1086 }
1087 }`
1088
1089 testJSONMarshal(t, u, want)
1090 }
1091
1092 func TestInstallationRepositoriesEvent_Marshal(t *testing.T) {
1093 testJSONMarshal(t, &InstallationRepositoriesEvent{}, "{}")
1094
1095 u := &InstallationRepositoriesEvent{
1096 Action: String("a"),
1097 RepositoriesAdded: []*Repository{
1098 {
1099 ID: Int64(1),
1100 URL: String("s"),
1101 Name: String("n"),
1102 },
1103 },
1104 RepositoriesRemoved: []*Repository{
1105 {
1106 ID: Int64(1),
1107 URL: String("s"),
1108 Name: String("n"),
1109 },
1110 },
1111 RepositorySelection: String("rs"),
1112 Sender: &User{
1113 Login: String("l"),
1114 ID: Int64(1),
1115 NodeID: String("n"),
1116 URL: String("u"),
1117 ReposURL: String("r"),
1118 EventsURL: String("e"),
1119 AvatarURL: String("a"),
1120 },
1121 Installation: &Installation{
1122 ID: Int64(1),
1123 NodeID: String("nid"),
1124 AppID: Int64(1),
1125 AppSlug: String("as"),
1126 TargetID: Int64(1),
1127 Account: &User{
1128 Login: String("l"),
1129 ID: Int64(1),
1130 URL: String("u"),
1131 AvatarURL: String("a"),
1132 GravatarID: String("g"),
1133 Name: String("n"),
1134 Company: String("c"),
1135 Blog: String("b"),
1136 Location: String("l"),
1137 Email: String("e"),
1138 Hireable: Bool(true),
1139 Bio: String("b"),
1140 TwitterUsername: String("t"),
1141 PublicRepos: Int(1),
1142 Followers: Int(1),
1143 Following: Int(1),
1144 CreatedAt: &Timestamp{referenceTime},
1145 SuspendedAt: &Timestamp{referenceTime},
1146 },
1147 AccessTokensURL: String("atu"),
1148 RepositoriesURL: String("ru"),
1149 HTMLURL: String("hu"),
1150 TargetType: String("tt"),
1151 SingleFileName: String("sfn"),
1152 RepositorySelection: String("rs"),
1153 Events: []string{"e"},
1154 SingleFilePaths: []string{"s"},
1155 Permissions: &InstallationPermissions{
1156 Actions: String("a"),
1157 Administration: String("ad"),
1158 Checks: String("c"),
1159 Contents: String("co"),
1160 ContentReferences: String("cr"),
1161 Deployments: String("d"),
1162 Environments: String("e"),
1163 Issues: String("i"),
1164 Metadata: String("md"),
1165 Members: String("m"),
1166 OrganizationAdministration: String("oa"),
1167 OrganizationHooks: String("oh"),
1168 OrganizationPlan: String("op"),
1169 OrganizationPreReceiveHooks: String("opr"),
1170 OrganizationProjects: String("op"),
1171 OrganizationSecrets: String("os"),
1172 OrganizationSelfHostedRunners: String("osh"),
1173 OrganizationUserBlocking: String("oub"),
1174 Packages: String("pkg"),
1175 Pages: String("pg"),
1176 PullRequests: String("pr"),
1177 RepositoryHooks: String("rh"),
1178 RepositoryProjects: String("rp"),
1179 RepositoryPreReceiveHooks: String("rprh"),
1180 Secrets: String("s"),
1181 SecretScanningAlerts: String("ssa"),
1182 SecurityEvents: String("se"),
1183 SingleFile: String("sf"),
1184 Statuses: String("s"),
1185 TeamDiscussions: String("td"),
1186 VulnerabilityAlerts: String("va"),
1187 Workflows: String("w"),
1188 },
1189 CreatedAt: &Timestamp{referenceTime},
1190 UpdatedAt: &Timestamp{referenceTime},
1191 HasMultipleSingleFiles: Bool(false),
1192 SuspendedBy: &User{
1193 Login: String("l"),
1194 ID: Int64(1),
1195 URL: String("u"),
1196 AvatarURL: String("a"),
1197 GravatarID: String("g"),
1198 Name: String("n"),
1199 Company: String("c"),
1200 Blog: String("b"),
1201 Location: String("l"),
1202 Email: String("e"),
1203 Hireable: Bool(true),
1204 Bio: String("b"),
1205 TwitterUsername: String("t"),
1206 PublicRepos: Int(1),
1207 Followers: Int(1),
1208 Following: Int(1),
1209 CreatedAt: &Timestamp{referenceTime},
1210 SuspendedAt: &Timestamp{referenceTime},
1211 },
1212 SuspendedAt: &Timestamp{referenceTime},
1213 },
1214 }
1215
1216 want := `{
1217 "action": "a",
1218 "repositories_added": [
1219 {
1220 "id": 1,
1221 "name": "n",
1222 "url": "s"
1223 }
1224 ],
1225 "repositories_removed": [
1226 {
1227 "id": 1,
1228 "name": "n",
1229 "url": "s"
1230 }
1231 ],
1232 "repository_selection": "rs",
1233 "sender": {
1234 "login": "l",
1235 "id": 1,
1236 "node_id": "n",
1237 "avatar_url": "a",
1238 "url": "u",
1239 "events_url": "e",
1240 "repos_url": "r"
1241 },
1242 "installation": {
1243 "id": 1,
1244 "node_id": "nid",
1245 "app_id": 1,
1246 "app_slug": "as",
1247 "target_id": 1,
1248 "account": {
1249 "login": "l",
1250 "id": 1,
1251 "avatar_url": "a",
1252 "gravatar_id": "g",
1253 "name": "n",
1254 "company": "c",
1255 "blog": "b",
1256 "location": "l",
1257 "email": "e",
1258 "hireable": true,
1259 "bio": "b",
1260 "twitter_username": "t",
1261 "public_repos": 1,
1262 "followers": 1,
1263 "following": 1,
1264 "created_at": ` + referenceTimeStr + `,
1265 "suspended_at": ` + referenceTimeStr + `,
1266 "url": "u"
1267 },
1268 "access_tokens_url": "atu",
1269 "repositories_url": "ru",
1270 "html_url": "hu",
1271 "target_type": "tt",
1272 "single_file_name": "sfn",
1273 "repository_selection": "rs",
1274 "events": [
1275 "e"
1276 ],
1277 "single_file_paths": [
1278 "s"
1279 ],
1280 "permissions": {
1281 "actions": "a",
1282 "administration": "ad",
1283 "checks": "c",
1284 "contents": "co",
1285 "content_references": "cr",
1286 "deployments": "d",
1287 "environments": "e",
1288 "issues": "i",
1289 "metadata": "md",
1290 "members": "m",
1291 "organization_administration": "oa",
1292 "organization_hooks": "oh",
1293 "organization_plan": "op",
1294 "organization_pre_receive_hooks": "opr",
1295 "organization_projects": "op",
1296 "organization_secrets": "os",
1297 "organization_self_hosted_runners": "osh",
1298 "organization_user_blocking": "oub",
1299 "packages": "pkg",
1300 "pages": "pg",
1301 "pull_requests": "pr",
1302 "repository_hooks": "rh",
1303 "repository_projects": "rp",
1304 "repository_pre_receive_hooks": "rprh",
1305 "secrets": "s",
1306 "secret_scanning_alerts": "ssa",
1307 "security_events": "se",
1308 "single_file": "sf",
1309 "statuses": "s",
1310 "team_discussions": "td",
1311 "vulnerability_alerts": "va",
1312 "workflows": "w"
1313 },
1314 "created_at": ` + referenceTimeStr + `,
1315 "updated_at": ` + referenceTimeStr + `,
1316 "has_multiple_single_files": false,
1317 "suspended_by": {
1318 "login": "l",
1319 "id": 1,
1320 "avatar_url": "a",
1321 "gravatar_id": "g",
1322 "name": "n",
1323 "company": "c",
1324 "blog": "b",
1325 "location": "l",
1326 "email": "e",
1327 "hireable": true,
1328 "bio": "b",
1329 "twitter_username": "t",
1330 "public_repos": 1,
1331 "followers": 1,
1332 "following": 1,
1333 "created_at": ` + referenceTimeStr + `,
1334 "suspended_at": ` + referenceTimeStr + `,
1335 "url": "u"
1336 },
1337 "suspended_at": ` + referenceTimeStr + `
1338 }
1339 }`
1340
1341 testJSONMarshal(t, u, want)
1342 }
1343
1344 func TestInstallationTargetEvent_Marshal(t *testing.T) {
1345 testJSONMarshal(t, &InstallationTargetEvent{}, "{}")
1346
1347 u := &InstallationTargetEvent{
1348 Account: &User{
1349 Login: String("u"),
1350 ID: Int64(1),
1351 NodeID: String("n"),
1352 URL: String("u"),
1353 ReposURL: String("r"),
1354 EventsURL: String("e"),
1355 AvatarURL: String("l"),
1356 },
1357 Action: String("a"),
1358 Changes: &InstallationChanges{
1359 Login: &InstallationLoginChange{
1360 From: String("p"),
1361 },
1362 Slug: &InstallationSlugChange{
1363 From: String("j"),
1364 },
1365 },
1366 Enterprise: &Enterprise{
1367 ID: Int(1),
1368 Slug: String("s"),
1369 Name: String("n"),
1370 NodeID: String("nid"),
1371 AvatarURL: String("au"),
1372 Description: String("d"),
1373 WebsiteURL: String("wu"),
1374 HTMLURL: String("hu"),
1375 CreatedAt: &Timestamp{referenceTime},
1376 UpdatedAt: &Timestamp{referenceTime},
1377 },
1378 Installation: &Installation{
1379 ID: Int64(1),
1380 NodeID: String("nid"),
1381 AppID: Int64(1),
1382 AppSlug: String("as"),
1383 TargetID: Int64(1),
1384 Account: &User{
1385 Login: String("l"),
1386 ID: Int64(1),
1387 URL: String("u"),
1388 AvatarURL: String("a"),
1389 GravatarID: String("g"),
1390 Name: String("n"),
1391 Company: String("c"),
1392 Blog: String("b"),
1393 Location: String("l"),
1394 Email: String("e"),
1395 Hireable: Bool(true),
1396 Bio: String("b"),
1397 TwitterUsername: String("t"),
1398 PublicRepos: Int(1),
1399 Followers: Int(1),
1400 Following: Int(1),
1401 CreatedAt: &Timestamp{referenceTime},
1402 SuspendedAt: &Timestamp{referenceTime},
1403 },
1404 AccessTokensURL: String("atu"),
1405 RepositoriesURL: String("ru"),
1406 HTMLURL: String("hu"),
1407 TargetType: String("tt"),
1408 SingleFileName: String("sfn"),
1409 RepositorySelection: String("rs"),
1410 Events: []string{"e"},
1411 SingleFilePaths: []string{"s"},
1412 Permissions: &InstallationPermissions{
1413 Actions: String("a"),
1414 Administration: String("ad"),
1415 Checks: String("c"),
1416 Contents: String("co"),
1417 ContentReferences: String("cr"),
1418 Deployments: String("d"),
1419 Environments: String("e"),
1420 Issues: String("i"),
1421 Metadata: String("md"),
1422 Members: String("m"),
1423 OrganizationAdministration: String("oa"),
1424 OrganizationHooks: String("oh"),
1425 OrganizationPlan: String("op"),
1426 OrganizationPreReceiveHooks: String("opr"),
1427 OrganizationProjects: String("op"),
1428 OrganizationSecrets: String("os"),
1429 OrganizationSelfHostedRunners: String("osh"),
1430 OrganizationUserBlocking: String("oub"),
1431 Packages: String("pkg"),
1432 Pages: String("pg"),
1433 PullRequests: String("pr"),
1434 RepositoryHooks: String("rh"),
1435 RepositoryProjects: String("rp"),
1436 RepositoryPreReceiveHooks: String("rprh"),
1437 Secrets: String("s"),
1438 SecretScanningAlerts: String("ssa"),
1439 SecurityEvents: String("se"),
1440 SingleFile: String("sf"),
1441 Statuses: String("s"),
1442 TeamDiscussions: String("td"),
1443 VulnerabilityAlerts: String("va"),
1444 Workflows: String("w"),
1445 },
1446 CreatedAt: &Timestamp{referenceTime},
1447 UpdatedAt: &Timestamp{referenceTime},
1448 HasMultipleSingleFiles: Bool(false),
1449 SuspendedBy: &User{
1450 Login: String("l"),
1451 ID: Int64(1),
1452 URL: String("u"),
1453 AvatarURL: String("a"),
1454 GravatarID: String("g"),
1455 Name: String("n"),
1456 Company: String("c"),
1457 Blog: String("b"),
1458 Location: String("l"),
1459 Email: String("e"),
1460 Hireable: Bool(true),
1461 Bio: String("b"),
1462 TwitterUsername: String("t"),
1463 PublicRepos: Int(1),
1464 Followers: Int(1),
1465 Following: Int(1),
1466 CreatedAt: &Timestamp{referenceTime},
1467 SuspendedAt: &Timestamp{referenceTime},
1468 },
1469 SuspendedAt: &Timestamp{referenceTime},
1470 },
1471 Organization: &Organization{
1472 BillingEmail: String("be"),
1473 Blog: String("b"),
1474 Company: String("c"),
1475 Email: String("e"),
1476 TwitterUsername: String("tu"),
1477 Location: String("loc"),
1478 Name: String("n"),
1479 Description: String("d"),
1480 IsVerified: Bool(true),
1481 HasOrganizationProjects: Bool(true),
1482 HasRepositoryProjects: Bool(true),
1483 DefaultRepoPermission: String("drp"),
1484 MembersCanCreateRepos: Bool(true),
1485 MembersCanCreateInternalRepos: Bool(true),
1486 MembersCanCreatePrivateRepos: Bool(true),
1487 MembersCanCreatePublicRepos: Bool(false),
1488 MembersAllowedRepositoryCreationType: String("marct"),
1489 MembersCanCreatePages: Bool(true),
1490 MembersCanCreatePublicPages: Bool(false),
1491 MembersCanCreatePrivatePages: Bool(true),
1492 },
1493 Repository: &Repository{
1494 ID: Int64(1),
1495 URL: String("s"),
1496 Name: String("n"),
1497 },
1498 Sender: &User{
1499 Login: String("l"),
1500 ID: Int64(1),
1501 NodeID: String("n"),
1502 URL: String("u"),
1503 ReposURL: String("r"),
1504 EventsURL: String("e"),
1505 AvatarURL: String("a"),
1506 },
1507 TargetType: String("running"),
1508 }
1509
1510 want := `{
1511 "account": {
1512 "login": "u",
1513 "id": 1,
1514 "node_id": "n",
1515 "avatar_url": "l",
1516 "url": "u",
1517 "events_url": "e",
1518 "repos_url": "r"
1519 },
1520 "action": "a",
1521 "changes": {
1522 "login": {
1523 "from": "p"
1524 },
1525 "slug": {
1526 "from": "j"
1527 }
1528 },
1529 "enterprise": {
1530 "id": 1,
1531 "slug": "s",
1532 "name": "n",
1533 "node_id": "nid",
1534 "avatar_url": "au",
1535 "description": "d",
1536 "website_url": "wu",
1537 "html_url": "hu",
1538 "created_at": ` + referenceTimeStr + `,
1539 "updated_at": ` + referenceTimeStr + `
1540 },
1541 "installation": {
1542 "id": 1,
1543 "node_id": "nid",
1544 "app_id": 1,
1545 "app_slug": "as",
1546 "target_id": 1,
1547 "account": {
1548 "login": "l",
1549 "id": 1,
1550 "avatar_url": "a",
1551 "gravatar_id": "g",
1552 "name": "n",
1553 "company": "c",
1554 "blog": "b",
1555 "location": "l",
1556 "email": "e",
1557 "hireable": true,
1558 "bio": "b",
1559 "twitter_username": "t",
1560 "public_repos": 1,
1561 "followers": 1,
1562 "following": 1,
1563 "created_at": ` + referenceTimeStr + `,
1564 "suspended_at": ` + referenceTimeStr + `,
1565 "url": "u"
1566 },
1567 "access_tokens_url": "atu",
1568 "repositories_url": "ru",
1569 "html_url": "hu",
1570 "target_type": "tt",
1571 "single_file_name": "sfn",
1572 "repository_selection": "rs",
1573 "events": [
1574 "e"
1575 ],
1576 "single_file_paths": [
1577 "s"
1578 ],
1579 "permissions": {
1580 "actions": "a",
1581 "administration": "ad",
1582 "checks": "c",
1583 "contents": "co",
1584 "content_references": "cr",
1585 "deployments": "d",
1586 "environments": "e",
1587 "issues": "i",
1588 "metadata": "md",
1589 "members": "m",
1590 "organization_administration": "oa",
1591 "organization_hooks": "oh",
1592 "organization_plan": "op",
1593 "organization_pre_receive_hooks": "opr",
1594 "organization_projects": "op",
1595 "organization_secrets": "os",
1596 "organization_self_hosted_runners": "osh",
1597 "organization_user_blocking": "oub",
1598 "packages": "pkg",
1599 "pages": "pg",
1600 "pull_requests": "pr",
1601 "repository_hooks": "rh",
1602 "repository_projects": "rp",
1603 "repository_pre_receive_hooks": "rprh",
1604 "secrets": "s",
1605 "secret_scanning_alerts": "ssa",
1606 "security_events": "se",
1607 "single_file": "sf",
1608 "statuses": "s",
1609 "team_discussions": "td",
1610 "vulnerability_alerts": "va",
1611 "workflows": "w"
1612 },
1613 "created_at": ` + referenceTimeStr + `,
1614 "updated_at": ` + referenceTimeStr + `,
1615 "has_multiple_single_files": false,
1616 "suspended_by": {
1617 "login": "l",
1618 "id": 1,
1619 "avatar_url": "a",
1620 "gravatar_id": "g",
1621 "name": "n",
1622 "company": "c",
1623 "blog": "b",
1624 "location": "l",
1625 "email": "e",
1626 "hireable": true,
1627 "bio": "b",
1628 "twitter_username": "t",
1629 "public_repos": 1,
1630 "followers": 1,
1631 "following": 1,
1632 "created_at": ` + referenceTimeStr + `,
1633 "suspended_at": ` + referenceTimeStr + `,
1634 "url": "u"
1635 },
1636 "suspended_at": ` + referenceTimeStr + `
1637 },
1638 "organization": {
1639 "name": "n",
1640 "company": "c",
1641 "blog": "b",
1642 "location": "loc",
1643 "email": "e",
1644 "twitter_username": "tu",
1645 "description": "d",
1646 "billing_email": "be",
1647 "is_verified": true,
1648 "has_organization_projects": true,
1649 "has_repository_projects": true,
1650 "default_repository_permission": "drp",
1651 "members_can_create_repositories": true,
1652 "members_can_create_public_repositories": false,
1653 "members_can_create_private_repositories": true,
1654 "members_can_create_internal_repositories": true,
1655 "members_allowed_repository_creation_type": "marct",
1656 "members_can_create_pages": true,
1657 "members_can_create_public_pages": false,
1658 "members_can_create_private_pages": true
1659 },
1660 "repository": {
1661 "id": 1,
1662 "url": "s",
1663 "name": "n"
1664 },
1665 "sender": {
1666 "login": "l",
1667 "id": 1,
1668 "node_id": "n",
1669 "avatar_url": "a",
1670 "url": "u",
1671 "events_url": "e",
1672 "repos_url": "r"
1673 },
1674 "target_type": "running"
1675 }`
1676
1677 testJSONMarshal(t, u, want)
1678 }
1679
1680 func TestEditTitle_Marshal(t *testing.T) {
1681 testJSONMarshal(t, &EditTitle{}, "{}")
1682
1683 u := &EditTitle{
1684 From: String("EditTitleFrom"),
1685 }
1686
1687 want := `{
1688 "from": "EditTitleFrom"
1689 }`
1690
1691 testJSONMarshal(t, u, want)
1692 }
1693
1694 func TestEditBody_Marshal(t *testing.T) {
1695 testJSONMarshal(t, &EditBody{}, "{}")
1696
1697 u := &EditBody{
1698 From: String("EditBodyFrom"),
1699 }
1700
1701 want := `{
1702 "from": "EditBodyFrom"
1703 }`
1704
1705 testJSONMarshal(t, u, want)
1706 }
1707
1708 func TestEditBase_Marshal(t *testing.T) {
1709 testJSONMarshal(t, &EditBase{}, "{}")
1710
1711 u := &EditBase{
1712 Ref: &EditRef{
1713 From: String("EditRefFrom"),
1714 },
1715 SHA: &EditSHA{
1716 From: String("EditSHAFrom"),
1717 },
1718 }
1719
1720 want := `{
1721 "ref": {
1722 "from": "EditRefFrom"
1723 },
1724 "sha": {
1725 "from": "EditSHAFrom"
1726 }
1727 }`
1728
1729 testJSONMarshal(t, u, want)
1730 }
1731
1732 func TestEditRef_Marshal(t *testing.T) {
1733 testJSONMarshal(t, &EditRef{}, "{}")
1734
1735 u := &EditRef{
1736 From: String("EditRefFrom"),
1737 }
1738
1739 want := `{
1740 "from": "EditRefFrom"
1741 }`
1742
1743 testJSONMarshal(t, u, want)
1744 }
1745
1746 func TestEditSHA_Marshal(t *testing.T) {
1747 testJSONMarshal(t, &EditSHA{}, "{}")
1748
1749 u := &EditSHA{
1750 From: String("EditSHAFrom"),
1751 }
1752
1753 want := `{
1754 "from": "EditSHAFrom"
1755 }`
1756
1757 testJSONMarshal(t, u, want)
1758 }
1759
1760 func TestProjectName_Marshal(t *testing.T) {
1761 testJSONMarshal(t, &ProjectName{}, "{}")
1762
1763 u := &ProjectName{
1764 From: String("ProjectNameFrom"),
1765 }
1766
1767 want := `{
1768 "from": "ProjectNameFrom"
1769 }`
1770
1771 testJSONMarshal(t, u, want)
1772 }
1773
1774 func TestProjectBody_Marshal(t *testing.T) {
1775 testJSONMarshal(t, &ProjectBody{}, "{}")
1776
1777 u := &ProjectBody{
1778 From: String("ProjectBodyFrom"),
1779 }
1780
1781 want := `{
1782 "from": "ProjectBodyFrom"
1783 }`
1784
1785 testJSONMarshal(t, u, want)
1786 }
1787
1788 func TestProjectCardNote_Marshal(t *testing.T) {
1789 testJSONMarshal(t, &ProjectCardNote{}, "{}")
1790
1791 u := &ProjectCardNote{
1792 From: String("ProjectCardNoteFrom"),
1793 }
1794
1795 want := `{
1796 "from": "ProjectCardNoteFrom"
1797 }`
1798
1799 testJSONMarshal(t, u, want)
1800 }
1801
1802 func TestProjectColumnName_Marshal(t *testing.T) {
1803 testJSONMarshal(t, &ProjectColumnName{}, "{}")
1804
1805 u := &ProjectColumnName{
1806 From: String("ProjectColumnNameFrom"),
1807 }
1808
1809 want := `{
1810 "from": "ProjectColumnNameFrom"
1811 }`
1812
1813 testJSONMarshal(t, u, want)
1814 }
1815
1816 func TestTeamDescription_Marshal(t *testing.T) {
1817 testJSONMarshal(t, &TeamDescription{}, "{}")
1818
1819 u := &TeamDescription{
1820 From: String("TeamDescriptionFrom"),
1821 }
1822
1823 want := `{
1824 "from": "TeamDescriptionFrom"
1825 }`
1826
1827 testJSONMarshal(t, u, want)
1828 }
1829
1830 func TestTeamName_Marshal(t *testing.T) {
1831 testJSONMarshal(t, &TeamName{}, "{}")
1832
1833 u := &TeamName{
1834 From: String("TeamNameFrom"),
1835 }
1836
1837 want := `{
1838 "from": "TeamNameFrom"
1839 }`
1840
1841 testJSONMarshal(t, u, want)
1842 }
1843
1844 func TestTeamPrivacy_Marshal(t *testing.T) {
1845 testJSONMarshal(t, &TeamPrivacy{}, "{}")
1846
1847 u := &TeamPrivacy{
1848 From: String("TeamPrivacyFrom"),
1849 }
1850
1851 want := `{
1852 "from": "TeamPrivacyFrom"
1853 }`
1854
1855 testJSONMarshal(t, u, want)
1856 }
1857
1858 func TestTeamRepository_Marshal(t *testing.T) {
1859 testJSONMarshal(t, &TeamRepository{}, "{}")
1860
1861 u := &TeamRepository{
1862 Permissions: &TeamPermissions{
1863 From: &TeamPermissionsFrom{
1864 Admin: Bool(true),
1865 Pull: Bool(true),
1866 Push: Bool(true),
1867 },
1868 },
1869 }
1870
1871 want := `{
1872 "permissions": {
1873 "from": {
1874 "admin": true,
1875 "pull": true,
1876 "push": true
1877 }
1878 }
1879 }`
1880
1881 testJSONMarshal(t, u, want)
1882 }
1883
1884 func TestTeamPermissions_Marshal(t *testing.T) {
1885 testJSONMarshal(t, &TeamPermissions{}, "{}")
1886
1887 u := &TeamPermissions{
1888 From: &TeamPermissionsFrom{
1889 Admin: Bool(true),
1890 Pull: Bool(true),
1891 Push: Bool(true),
1892 },
1893 }
1894
1895 want := `{
1896 "from": {
1897 "admin": true,
1898 "pull": true,
1899 "push": true
1900 }
1901 }`
1902
1903 testJSONMarshal(t, u, want)
1904 }
1905
1906 func TestTeamPermissionsFrom_Marshal(t *testing.T) {
1907 testJSONMarshal(t, &TeamPermissionsFrom{}, "{}")
1908
1909 u := &TeamPermissionsFrom{
1910 Admin: Bool(true),
1911 Pull: Bool(true),
1912 Push: Bool(true),
1913 }
1914
1915 want := `{
1916 "admin": true,
1917 "pull": true,
1918 "push": true
1919 }`
1920
1921 testJSONMarshal(t, u, want)
1922 }
1923
1924 func TestRepositoryVulnerabilityAlert_Marshal(t *testing.T) {
1925 testJSONMarshal(t, &RepositoryVulnerabilityAlert{}, "{}")
1926
1927 u := &RepositoryVulnerabilityAlert{
1928 ID: Int64(1),
1929 AffectedRange: String("ar"),
1930 AffectedPackageName: String("apn"),
1931 ExternalReference: String("er"),
1932 ExternalIdentifier: String("ei"),
1933 FixedIn: String("fi"),
1934 Dismisser: &User{
1935 Login: String("l"),
1936 ID: Int64(1),
1937 NodeID: String("n"),
1938 URL: String("u"),
1939 ReposURL: String("r"),
1940 EventsURL: String("e"),
1941 AvatarURL: String("a"),
1942 },
1943 DismissReason: String("dr"),
1944 DismissedAt: &Timestamp{referenceTime},
1945 }
1946
1947 want := `{
1948 "id": 1,
1949 "affected_range": "ar",
1950 "affected_package_name": "apn",
1951 "external_reference": "er",
1952 "external_identifier": "ei",
1953 "fixed_in": "fi",
1954 "dismisser": {
1955 "login": "l",
1956 "id": 1,
1957 "node_id": "n",
1958 "avatar_url": "a",
1959 "url": "u",
1960 "events_url": "e",
1961 "repos_url": "r"
1962 },
1963 "dismiss_reason": "dr",
1964 "dismissed_at": ` + referenceTimeStr + `
1965 }`
1966
1967 testJSONMarshal(t, u, want)
1968 }
1969
1970 func TestPage_Marshal(t *testing.T) {
1971 testJSONMarshal(t, &Page{}, "{}")
1972
1973 u := &Page{
1974 PageName: String("p"),
1975 Title: String("t"),
1976 Summary: String("s"),
1977 Action: String("a"),
1978 SHA: String("s"),
1979 HTMLURL: String("h"),
1980 }
1981
1982 want := `{
1983 "page_name": "p",
1984 "title": "t",
1985 "summary": "s",
1986 "action": "a",
1987 "sha": "s",
1988 "html_url": "h"
1989 }`
1990
1991 testJSONMarshal(t, u, want)
1992 }
1993
1994 func TestTeamChange_Marshal(t *testing.T) {
1995 testJSONMarshal(t, &TeamChange{}, "{}")
1996
1997 u := &TeamChange{
1998 Description: &TeamDescription{
1999 From: String("DescriptionFrom"),
2000 },
2001 Name: &TeamName{
2002 From: String("NameFrom"),
2003 },
2004 Privacy: &TeamPrivacy{
2005 From: String("PrivacyFrom"),
2006 },
2007 Repository: &TeamRepository{
2008 Permissions: &TeamPermissions{
2009 From: &TeamPermissionsFrom{
2010 Admin: Bool(false),
2011 Pull: Bool(false),
2012 Push: Bool(false),
2013 },
2014 },
2015 },
2016 }
2017
2018 want := `{
2019 "description": {
2020 "from": "DescriptionFrom"
2021 },
2022 "name": {
2023 "from": "NameFrom"
2024 },
2025 "privacy": {
2026 "from": "PrivacyFrom"
2027 },
2028 "repository": {
2029 "permissions": {
2030 "from": {
2031 "admin": false,
2032 "pull": false,
2033 "push": false
2034 }
2035 }
2036 }
2037 }`
2038
2039 testJSONMarshal(t, u, want)
2040 }
2041
2042 func TestIssueCommentEvent_Marshal(t *testing.T) {
2043 testJSONMarshal(t, &IssueCommentEvent{}, "{}")
2044
2045 u := &IssueCommentEvent{
2046 Action: String("a"),
2047 Issue: &Issue{ID: Int64(1)},
2048 Comment: &IssueComment{ID: Int64(1)},
2049 Changes: &EditChange{
2050 Title: &EditTitle{
2051 From: String("TitleFrom"),
2052 },
2053 Body: &EditBody{
2054 From: String("BodyFrom"),
2055 },
2056 Base: &EditBase{
2057 Ref: &EditRef{
2058 From: String("BaseRefFrom"),
2059 },
2060 SHA: &EditSHA{
2061 From: String("BaseSHAFrom"),
2062 },
2063 },
2064 },
2065 Repo: &Repository{
2066 ID: Int64(1),
2067 URL: String("s"),
2068 Name: String("n"),
2069 },
2070 Sender: &User{
2071 Login: String("l"),
2072 ID: Int64(1),
2073 NodeID: String("n"),
2074 URL: String("u"),
2075 ReposURL: String("r"),
2076 EventsURL: String("e"),
2077 AvatarURL: String("a"),
2078 },
2079 Installation: &Installation{
2080 ID: Int64(1),
2081 NodeID: String("nid"),
2082 AppID: Int64(1),
2083 AppSlug: String("as"),
2084 TargetID: Int64(1),
2085 Account: &User{
2086 Login: String("l"),
2087 ID: Int64(1),
2088 URL: String("u"),
2089 AvatarURL: String("a"),
2090 GravatarID: String("g"),
2091 Name: String("n"),
2092 Company: String("c"),
2093 Blog: String("b"),
2094 Location: String("l"),
2095 Email: String("e"),
2096 Hireable: Bool(true),
2097 Bio: String("b"),
2098 TwitterUsername: String("t"),
2099 PublicRepos: Int(1),
2100 Followers: Int(1),
2101 Following: Int(1),
2102 CreatedAt: &Timestamp{referenceTime},
2103 SuspendedAt: &Timestamp{referenceTime},
2104 },
2105 AccessTokensURL: String("atu"),
2106 RepositoriesURL: String("ru"),
2107 HTMLURL: String("hu"),
2108 TargetType: String("tt"),
2109 SingleFileName: String("sfn"),
2110 RepositorySelection: String("rs"),
2111 Events: []string{"e"},
2112 SingleFilePaths: []string{"s"},
2113 Permissions: &InstallationPermissions{
2114 Actions: String("a"),
2115 Administration: String("ad"),
2116 Checks: String("c"),
2117 Contents: String("co"),
2118 ContentReferences: String("cr"),
2119 Deployments: String("d"),
2120 Environments: String("e"),
2121 Issues: String("i"),
2122 Metadata: String("md"),
2123 Members: String("m"),
2124 OrganizationAdministration: String("oa"),
2125 OrganizationHooks: String("oh"),
2126 OrganizationPlan: String("op"),
2127 OrganizationPreReceiveHooks: String("opr"),
2128 OrganizationProjects: String("op"),
2129 OrganizationSecrets: String("os"),
2130 OrganizationSelfHostedRunners: String("osh"),
2131 OrganizationUserBlocking: String("oub"),
2132 Packages: String("pkg"),
2133 Pages: String("pg"),
2134 PullRequests: String("pr"),
2135 RepositoryHooks: String("rh"),
2136 RepositoryProjects: String("rp"),
2137 RepositoryPreReceiveHooks: String("rprh"),
2138 Secrets: String("s"),
2139 SecretScanningAlerts: String("ssa"),
2140 SecurityEvents: String("se"),
2141 SingleFile: String("sf"),
2142 Statuses: String("s"),
2143 TeamDiscussions: String("td"),
2144 VulnerabilityAlerts: String("va"),
2145 Workflows: String("w"),
2146 },
2147 CreatedAt: &Timestamp{referenceTime},
2148 UpdatedAt: &Timestamp{referenceTime},
2149 HasMultipleSingleFiles: Bool(false),
2150 SuspendedBy: &User{
2151 Login: String("l"),
2152 ID: Int64(1),
2153 URL: String("u"),
2154 AvatarURL: String("a"),
2155 GravatarID: String("g"),
2156 Name: String("n"),
2157 Company: String("c"),
2158 Blog: String("b"),
2159 Location: String("l"),
2160 Email: String("e"),
2161 Hireable: Bool(true),
2162 Bio: String("b"),
2163 TwitterUsername: String("t"),
2164 PublicRepos: Int(1),
2165 Followers: Int(1),
2166 Following: Int(1),
2167 CreatedAt: &Timestamp{referenceTime},
2168 SuspendedAt: &Timestamp{referenceTime},
2169 },
2170 SuspendedAt: &Timestamp{referenceTime},
2171 },
2172 Organization: &Organization{
2173 BillingEmail: String("be"),
2174 Blog: String("b"),
2175 Company: String("c"),
2176 Email: String("e"),
2177 TwitterUsername: String("tu"),
2178 Location: String("loc"),
2179 Name: String("n"),
2180 Description: String("d"),
2181 IsVerified: Bool(true),
2182 HasOrganizationProjects: Bool(true),
2183 HasRepositoryProjects: Bool(true),
2184 DefaultRepoPermission: String("drp"),
2185 MembersCanCreateRepos: Bool(true),
2186 MembersCanCreateInternalRepos: Bool(true),
2187 MembersCanCreatePrivateRepos: Bool(true),
2188 MembersCanCreatePublicRepos: Bool(false),
2189 MembersAllowedRepositoryCreationType: String("marct"),
2190 MembersCanCreatePages: Bool(true),
2191 MembersCanCreatePublicPages: Bool(false),
2192 MembersCanCreatePrivatePages: Bool(true),
2193 },
2194 }
2195
2196 want := `{
2197 "action": "a",
2198 "issue": {
2199 "id": 1
2200 },
2201 "comment": {
2202 "id": 1
2203 },
2204 "changes": {
2205 "title": {
2206 "from": "TitleFrom"
2207 },
2208 "body": {
2209 "from": "BodyFrom"
2210 },
2211 "base": {
2212 "ref": {
2213 "from": "BaseRefFrom"
2214 },
2215 "sha": {
2216 "from": "BaseSHAFrom"
2217 }
2218 }
2219 },
2220 "repository": {
2221 "id": 1,
2222 "name": "n",
2223 "url": "s"
2224 },
2225 "sender": {
2226 "login": "l",
2227 "id": 1,
2228 "node_id": "n",
2229 "avatar_url": "a",
2230 "url": "u",
2231 "events_url": "e",
2232 "repos_url": "r"
2233 },
2234 "installation": {
2235 "id": 1,
2236 "node_id": "nid",
2237 "app_id": 1,
2238 "app_slug": "as",
2239 "target_id": 1,
2240 "account": {
2241 "login": "l",
2242 "id": 1,
2243 "avatar_url": "a",
2244 "gravatar_id": "g",
2245 "name": "n",
2246 "company": "c",
2247 "blog": "b",
2248 "location": "l",
2249 "email": "e",
2250 "hireable": true,
2251 "bio": "b",
2252 "twitter_username": "t",
2253 "public_repos": 1,
2254 "followers": 1,
2255 "following": 1,
2256 "created_at": ` + referenceTimeStr + `,
2257 "suspended_at": ` + referenceTimeStr + `,
2258 "url": "u"
2259 },
2260 "access_tokens_url": "atu",
2261 "repositories_url": "ru",
2262 "html_url": "hu",
2263 "target_type": "tt",
2264 "single_file_name": "sfn",
2265 "repository_selection": "rs",
2266 "events": [
2267 "e"
2268 ],
2269 "single_file_paths": [
2270 "s"
2271 ],
2272 "permissions": {
2273 "actions": "a",
2274 "administration": "ad",
2275 "checks": "c",
2276 "contents": "co",
2277 "content_references": "cr",
2278 "deployments": "d",
2279 "environments": "e",
2280 "issues": "i",
2281 "metadata": "md",
2282 "members": "m",
2283 "organization_administration": "oa",
2284 "organization_hooks": "oh",
2285 "organization_plan": "op",
2286 "organization_pre_receive_hooks": "opr",
2287 "organization_projects": "op",
2288 "organization_secrets": "os",
2289 "organization_self_hosted_runners": "osh",
2290 "organization_user_blocking": "oub",
2291 "packages": "pkg",
2292 "pages": "pg",
2293 "pull_requests": "pr",
2294 "repository_hooks": "rh",
2295 "repository_projects": "rp",
2296 "repository_pre_receive_hooks": "rprh",
2297 "secrets": "s",
2298 "secret_scanning_alerts": "ssa",
2299 "security_events": "se",
2300 "single_file": "sf",
2301 "statuses": "s",
2302 "team_discussions": "td",
2303 "vulnerability_alerts": "va",
2304 "workflows": "w"
2305 },
2306 "created_at": ` + referenceTimeStr + `,
2307 "updated_at": ` + referenceTimeStr + `,
2308 "has_multiple_single_files": false,
2309 "suspended_by": {
2310 "login": "l",
2311 "id": 1,
2312 "avatar_url": "a",
2313 "gravatar_id": "g",
2314 "name": "n",
2315 "company": "c",
2316 "blog": "b",
2317 "location": "l",
2318 "email": "e",
2319 "hireable": true,
2320 "bio": "b",
2321 "twitter_username": "t",
2322 "public_repos": 1,
2323 "followers": 1,
2324 "following": 1,
2325 "created_at": ` + referenceTimeStr + `,
2326 "suspended_at": ` + referenceTimeStr + `,
2327 "url": "u"
2328 },
2329 "suspended_at": ` + referenceTimeStr + `
2330 },
2331 "organization": {
2332 "name": "n",
2333 "company": "c",
2334 "blog": "b",
2335 "location": "loc",
2336 "email": "e",
2337 "twitter_username": "tu",
2338 "description": "d",
2339 "billing_email": "be",
2340 "is_verified": true,
2341 "has_organization_projects": true,
2342 "has_repository_projects": true,
2343 "default_repository_permission": "drp",
2344 "members_can_create_repositories": true,
2345 "members_can_create_public_repositories": false,
2346 "members_can_create_private_repositories": true,
2347 "members_can_create_internal_repositories": true,
2348 "members_allowed_repository_creation_type": "marct",
2349 "members_can_create_pages": true,
2350 "members_can_create_public_pages": false,
2351 "members_can_create_private_pages": true
2352 }
2353 }`
2354
2355 testJSONMarshal(t, u, want)
2356 }
2357
2358 func TestIssuesEvent_Marshal(t *testing.T) {
2359 testJSONMarshal(t, &IssuesEvent{}, "{}")
2360
2361 u := &IssuesEvent{
2362 Action: String("a"),
2363 Issue: &Issue{ID: Int64(1)},
2364 Assignee: &User{
2365 Login: String("l"),
2366 ID: Int64(1),
2367 NodeID: String("n"),
2368 URL: String("u"),
2369 ReposURL: String("r"),
2370 EventsURL: String("e"),
2371 AvatarURL: String("a"),
2372 },
2373 Label: &Label{ID: Int64(1)},
2374 Changes: &EditChange{
2375 Title: &EditTitle{
2376 From: String("TitleFrom"),
2377 },
2378 Body: &EditBody{
2379 From: String("BodyFrom"),
2380 },
2381 Base: &EditBase{
2382 Ref: &EditRef{
2383 From: String("BaseRefFrom"),
2384 },
2385 SHA: &EditSHA{
2386 From: String("BaseSHAFrom"),
2387 },
2388 },
2389 },
2390 Repo: &Repository{
2391 ID: Int64(1),
2392 URL: String("s"),
2393 Name: String("n"),
2394 },
2395 Sender: &User{
2396 Login: String("l"),
2397 ID: Int64(1),
2398 NodeID: String("n"),
2399 URL: String("u"),
2400 ReposURL: String("r"),
2401 EventsURL: String("e"),
2402 AvatarURL: String("a"),
2403 },
2404 Installation: &Installation{
2405 ID: Int64(1),
2406 NodeID: String("nid"),
2407 AppID: Int64(1),
2408 AppSlug: String("as"),
2409 TargetID: Int64(1),
2410 Account: &User{
2411 Login: String("l"),
2412 ID: Int64(1),
2413 URL: String("u"),
2414 AvatarURL: String("a"),
2415 GravatarID: String("g"),
2416 Name: String("n"),
2417 Company: String("c"),
2418 Blog: String("b"),
2419 Location: String("l"),
2420 Email: String("e"),
2421 Hireable: Bool(true),
2422 Bio: String("b"),
2423 TwitterUsername: String("t"),
2424 PublicRepos: Int(1),
2425 Followers: Int(1),
2426 Following: Int(1),
2427 CreatedAt: &Timestamp{referenceTime},
2428 SuspendedAt: &Timestamp{referenceTime},
2429 },
2430 AccessTokensURL: String("atu"),
2431 RepositoriesURL: String("ru"),
2432 HTMLURL: String("hu"),
2433 TargetType: String("tt"),
2434 SingleFileName: String("sfn"),
2435 RepositorySelection: String("rs"),
2436 Events: []string{"e"},
2437 SingleFilePaths: []string{"s"},
2438 Permissions: &InstallationPermissions{
2439 Actions: String("a"),
2440 Administration: String("ad"),
2441 Checks: String("c"),
2442 Contents: String("co"),
2443 ContentReferences: String("cr"),
2444 Deployments: String("d"),
2445 Environments: String("e"),
2446 Issues: String("i"),
2447 Metadata: String("md"),
2448 Members: String("m"),
2449 OrganizationAdministration: String("oa"),
2450 OrganizationHooks: String("oh"),
2451 OrganizationPlan: String("op"),
2452 OrganizationPreReceiveHooks: String("opr"),
2453 OrganizationProjects: String("op"),
2454 OrganizationSecrets: String("os"),
2455 OrganizationSelfHostedRunners: String("osh"),
2456 OrganizationUserBlocking: String("oub"),
2457 Packages: String("pkg"),
2458 Pages: String("pg"),
2459 PullRequests: String("pr"),
2460 RepositoryHooks: String("rh"),
2461 RepositoryProjects: String("rp"),
2462 RepositoryPreReceiveHooks: String("rprh"),
2463 Secrets: String("s"),
2464 SecretScanningAlerts: String("ssa"),
2465 SecurityEvents: String("se"),
2466 SingleFile: String("sf"),
2467 Statuses: String("s"),
2468 TeamDiscussions: String("td"),
2469 VulnerabilityAlerts: String("va"),
2470 Workflows: String("w"),
2471 },
2472 CreatedAt: &Timestamp{referenceTime},
2473 UpdatedAt: &Timestamp{referenceTime},
2474 HasMultipleSingleFiles: Bool(false),
2475 SuspendedBy: &User{
2476 Login: String("l"),
2477 ID: Int64(1),
2478 URL: String("u"),
2479 AvatarURL: String("a"),
2480 GravatarID: String("g"),
2481 Name: String("n"),
2482 Company: String("c"),
2483 Blog: String("b"),
2484 Location: String("l"),
2485 Email: String("e"),
2486 Hireable: Bool(true),
2487 Bio: String("b"),
2488 TwitterUsername: String("t"),
2489 PublicRepos: Int(1),
2490 Followers: Int(1),
2491 Following: Int(1),
2492 CreatedAt: &Timestamp{referenceTime},
2493 SuspendedAt: &Timestamp{referenceTime},
2494 },
2495 SuspendedAt: &Timestamp{referenceTime},
2496 },
2497 }
2498
2499 want := `{
2500 "action": "a",
2501 "issue": {
2502 "id": 1
2503 },
2504 "assignee": {
2505 "login": "l",
2506 "id": 1,
2507 "node_id": "n",
2508 "avatar_url": "a",
2509 "url": "u",
2510 "events_url": "e",
2511 "repos_url": "r"
2512 },
2513 "label": {
2514 "id": 1
2515 },
2516 "changes": {
2517 "title": {
2518 "from": "TitleFrom"
2519 },
2520 "body": {
2521 "from": "BodyFrom"
2522 },
2523 "base": {
2524 "ref": {
2525 "from": "BaseRefFrom"
2526 },
2527 "sha": {
2528 "from": "BaseSHAFrom"
2529 }
2530 }
2531 },
2532 "repository": {
2533 "id": 1,
2534 "name": "n",
2535 "url": "s"
2536 },
2537 "sender": {
2538 "login": "l",
2539 "id": 1,
2540 "node_id": "n",
2541 "avatar_url": "a",
2542 "url": "u",
2543 "events_url": "e",
2544 "repos_url": "r"
2545 },
2546 "installation": {
2547 "id": 1,
2548 "node_id": "nid",
2549 "app_id": 1,
2550 "app_slug": "as",
2551 "target_id": 1,
2552 "account": {
2553 "login": "l",
2554 "id": 1,
2555 "avatar_url": "a",
2556 "gravatar_id": "g",
2557 "name": "n",
2558 "company": "c",
2559 "blog": "b",
2560 "location": "l",
2561 "email": "e",
2562 "hireable": true,
2563 "bio": "b",
2564 "twitter_username": "t",
2565 "public_repos": 1,
2566 "followers": 1,
2567 "following": 1,
2568 "created_at": ` + referenceTimeStr + `,
2569 "suspended_at": ` + referenceTimeStr + `,
2570 "url": "u"
2571 },
2572 "access_tokens_url": "atu",
2573 "repositories_url": "ru",
2574 "html_url": "hu",
2575 "target_type": "tt",
2576 "single_file_name": "sfn",
2577 "repository_selection": "rs",
2578 "events": [
2579 "e"
2580 ],
2581 "single_file_paths": [
2582 "s"
2583 ],
2584 "permissions": {
2585 "actions": "a",
2586 "administration": "ad",
2587 "checks": "c",
2588 "contents": "co",
2589 "content_references": "cr",
2590 "deployments": "d",
2591 "environments": "e",
2592 "issues": "i",
2593 "metadata": "md",
2594 "members": "m",
2595 "organization_administration": "oa",
2596 "organization_hooks": "oh",
2597 "organization_plan": "op",
2598 "organization_pre_receive_hooks": "opr",
2599 "organization_projects": "op",
2600 "organization_secrets": "os",
2601 "organization_self_hosted_runners": "osh",
2602 "organization_user_blocking": "oub",
2603 "packages": "pkg",
2604 "pages": "pg",
2605 "pull_requests": "pr",
2606 "repository_hooks": "rh",
2607 "repository_projects": "rp",
2608 "repository_pre_receive_hooks": "rprh",
2609 "secrets": "s",
2610 "secret_scanning_alerts": "ssa",
2611 "security_events": "se",
2612 "single_file": "sf",
2613 "statuses": "s",
2614 "team_discussions": "td",
2615 "vulnerability_alerts": "va",
2616 "workflows": "w"
2617 },
2618 "created_at": ` + referenceTimeStr + `,
2619 "updated_at": ` + referenceTimeStr + `,
2620 "has_multiple_single_files": false,
2621 "suspended_by": {
2622 "login": "l",
2623 "id": 1,
2624 "avatar_url": "a",
2625 "gravatar_id": "g",
2626 "name": "n",
2627 "company": "c",
2628 "blog": "b",
2629 "location": "l",
2630 "email": "e",
2631 "hireable": true,
2632 "bio": "b",
2633 "twitter_username": "t",
2634 "public_repos": 1,
2635 "followers": 1,
2636 "following": 1,
2637 "created_at": ` + referenceTimeStr + `,
2638 "suspended_at": ` + referenceTimeStr + `,
2639 "url": "u"
2640 },
2641 "suspended_at": ` + referenceTimeStr + `
2642 }
2643 }`
2644
2645 testJSONMarshal(t, u, want)
2646 }
2647
2648 func TestLabelEvent_Marshal(t *testing.T) {
2649 testJSONMarshal(t, &LabelEvent{}, "{}")
2650
2651 u := &LabelEvent{
2652 Action: String("a"),
2653 Label: &Label{ID: Int64(1)},
2654 Changes: &EditChange{
2655 Title: &EditTitle{
2656 From: String("TitleFrom"),
2657 },
2658 Body: &EditBody{
2659 From: String("BodyFrom"),
2660 },
2661 Base: &EditBase{
2662 Ref: &EditRef{
2663 From: String("BaseRefFrom"),
2664 },
2665 SHA: &EditSHA{
2666 From: String("BaseSHAFrom"),
2667 },
2668 },
2669 },
2670 Repo: &Repository{
2671 ID: Int64(1),
2672 URL: String("s"),
2673 Name: String("n"),
2674 },
2675 Org: &Organization{
2676 BillingEmail: String("be"),
2677 Blog: String("b"),
2678 Company: String("c"),
2679 Email: String("e"),
2680 TwitterUsername: String("tu"),
2681 Location: String("loc"),
2682 Name: String("n"),
2683 Description: String("d"),
2684 IsVerified: Bool(true),
2685 HasOrganizationProjects: Bool(true),
2686 HasRepositoryProjects: Bool(true),
2687 DefaultRepoPermission: String("drp"),
2688 MembersCanCreateRepos: Bool(true),
2689 MembersCanCreateInternalRepos: Bool(true),
2690 MembersCanCreatePrivateRepos: Bool(true),
2691 MembersCanCreatePublicRepos: Bool(false),
2692 MembersAllowedRepositoryCreationType: String("marct"),
2693 MembersCanCreatePages: Bool(true),
2694 MembersCanCreatePublicPages: Bool(false),
2695 MembersCanCreatePrivatePages: Bool(true),
2696 },
2697 Installation: &Installation{
2698 ID: Int64(1),
2699 NodeID: String("nid"),
2700 AppID: Int64(1),
2701 AppSlug: String("as"),
2702 TargetID: Int64(1),
2703 Account: &User{
2704 Login: String("l"),
2705 ID: Int64(1),
2706 URL: String("u"),
2707 AvatarURL: String("a"),
2708 GravatarID: String("g"),
2709 Name: String("n"),
2710 Company: String("c"),
2711 Blog: String("b"),
2712 Location: String("l"),
2713 Email: String("e"),
2714 Hireable: Bool(true),
2715 Bio: String("b"),
2716 TwitterUsername: String("t"),
2717 PublicRepos: Int(1),
2718 Followers: Int(1),
2719 Following: Int(1),
2720 CreatedAt: &Timestamp{referenceTime},
2721 SuspendedAt: &Timestamp{referenceTime},
2722 },
2723 AccessTokensURL: String("atu"),
2724 RepositoriesURL: String("ru"),
2725 HTMLURL: String("hu"),
2726 TargetType: String("tt"),
2727 SingleFileName: String("sfn"),
2728 RepositorySelection: String("rs"),
2729 Events: []string{"e"},
2730 SingleFilePaths: []string{"s"},
2731 Permissions: &InstallationPermissions{
2732 Actions: String("a"),
2733 Administration: String("ad"),
2734 Checks: String("c"),
2735 Contents: String("co"),
2736 ContentReferences: String("cr"),
2737 Deployments: String("d"),
2738 Environments: String("e"),
2739 Issues: String("i"),
2740 Metadata: String("md"),
2741 Members: String("m"),
2742 OrganizationAdministration: String("oa"),
2743 OrganizationHooks: String("oh"),
2744 OrganizationPlan: String("op"),
2745 OrganizationPreReceiveHooks: String("opr"),
2746 OrganizationProjects: String("op"),
2747 OrganizationSecrets: String("os"),
2748 OrganizationSelfHostedRunners: String("osh"),
2749 OrganizationUserBlocking: String("oub"),
2750 Packages: String("pkg"),
2751 Pages: String("pg"),
2752 PullRequests: String("pr"),
2753 RepositoryHooks: String("rh"),
2754 RepositoryProjects: String("rp"),
2755 RepositoryPreReceiveHooks: String("rprh"),
2756 Secrets: String("s"),
2757 SecretScanningAlerts: String("ssa"),
2758 SecurityEvents: String("se"),
2759 SingleFile: String("sf"),
2760 Statuses: String("s"),
2761 TeamDiscussions: String("td"),
2762 VulnerabilityAlerts: String("va"),
2763 Workflows: String("w"),
2764 },
2765 CreatedAt: &Timestamp{referenceTime},
2766 UpdatedAt: &Timestamp{referenceTime},
2767 HasMultipleSingleFiles: Bool(false),
2768 SuspendedBy: &User{
2769 Login: String("l"),
2770 ID: Int64(1),
2771 URL: String("u"),
2772 AvatarURL: String("a"),
2773 GravatarID: String("g"),
2774 Name: String("n"),
2775 Company: String("c"),
2776 Blog: String("b"),
2777 Location: String("l"),
2778 Email: String("e"),
2779 Hireable: Bool(true),
2780 Bio: String("b"),
2781 TwitterUsername: String("t"),
2782 PublicRepos: Int(1),
2783 Followers: Int(1),
2784 Following: Int(1),
2785 CreatedAt: &Timestamp{referenceTime},
2786 SuspendedAt: &Timestamp{referenceTime},
2787 },
2788 SuspendedAt: &Timestamp{referenceTime},
2789 },
2790 }
2791
2792 want := `{
2793 "action": "a",
2794 "label": {
2795 "id": 1
2796 },
2797 "changes": {
2798 "title": {
2799 "from": "TitleFrom"
2800 },
2801 "body": {
2802 "from": "BodyFrom"
2803 },
2804 "base": {
2805 "ref": {
2806 "from": "BaseRefFrom"
2807 },
2808 "sha": {
2809 "from": "BaseSHAFrom"
2810 }
2811 }
2812 },
2813 "repository": {
2814 "id": 1,
2815 "name": "n",
2816 "url": "s"
2817 },
2818 "organization": {
2819 "name": "n",
2820 "company": "c",
2821 "blog": "b",
2822 "location": "loc",
2823 "email": "e",
2824 "twitter_username": "tu",
2825 "description": "d",
2826 "billing_email": "be",
2827 "is_verified": true,
2828 "has_organization_projects": true,
2829 "has_repository_projects": true,
2830 "default_repository_permission": "drp",
2831 "members_can_create_repositories": true,
2832 "members_can_create_public_repositories": false,
2833 "members_can_create_private_repositories": true,
2834 "members_can_create_internal_repositories": true,
2835 "members_allowed_repository_creation_type": "marct",
2836 "members_can_create_pages": true,
2837 "members_can_create_public_pages": false,
2838 "members_can_create_private_pages": true
2839 },
2840 "installation": {
2841 "id": 1,
2842 "node_id": "nid",
2843 "app_id": 1,
2844 "app_slug": "as",
2845 "target_id": 1,
2846 "account": {
2847 "login": "l",
2848 "id": 1,
2849 "avatar_url": "a",
2850 "gravatar_id": "g",
2851 "name": "n",
2852 "company": "c",
2853 "blog": "b",
2854 "location": "l",
2855 "email": "e",
2856 "hireable": true,
2857 "bio": "b",
2858 "twitter_username": "t",
2859 "public_repos": 1,
2860 "followers": 1,
2861 "following": 1,
2862 "created_at": ` + referenceTimeStr + `,
2863 "suspended_at": ` + referenceTimeStr + `,
2864 "url": "u"
2865 },
2866 "access_tokens_url": "atu",
2867 "repositories_url": "ru",
2868 "html_url": "hu",
2869 "target_type": "tt",
2870 "single_file_name": "sfn",
2871 "repository_selection": "rs",
2872 "events": [
2873 "e"
2874 ],
2875 "single_file_paths": [
2876 "s"
2877 ],
2878 "permissions": {
2879 "actions": "a",
2880 "administration": "ad",
2881 "checks": "c",
2882 "contents": "co",
2883 "content_references": "cr",
2884 "deployments": "d",
2885 "environments": "e",
2886 "issues": "i",
2887 "metadata": "md",
2888 "members": "m",
2889 "organization_administration": "oa",
2890 "organization_hooks": "oh",
2891 "organization_plan": "op",
2892 "organization_pre_receive_hooks": "opr",
2893 "organization_projects": "op",
2894 "organization_secrets": "os",
2895 "organization_self_hosted_runners": "osh",
2896 "organization_user_blocking": "oub",
2897 "packages": "pkg",
2898 "pages": "pg",
2899 "pull_requests": "pr",
2900 "repository_hooks": "rh",
2901 "repository_projects": "rp",
2902 "repository_pre_receive_hooks": "rprh",
2903 "secrets": "s",
2904 "secret_scanning_alerts": "ssa",
2905 "security_events": "se",
2906 "single_file": "sf",
2907 "statuses": "s",
2908 "team_discussions": "td",
2909 "vulnerability_alerts": "va",
2910 "workflows": "w"
2911 },
2912 "created_at": ` + referenceTimeStr + `,
2913 "updated_at": ` + referenceTimeStr + `,
2914 "has_multiple_single_files": false,
2915 "suspended_by": {
2916 "login": "l",
2917 "id": 1,
2918 "avatar_url": "a",
2919 "gravatar_id": "g",
2920 "name": "n",
2921 "company": "c",
2922 "blog": "b",
2923 "location": "l",
2924 "email": "e",
2925 "hireable": true,
2926 "bio": "b",
2927 "twitter_username": "t",
2928 "public_repos": 1,
2929 "followers": 1,
2930 "following": 1,
2931 "created_at": ` + referenceTimeStr + `,
2932 "suspended_at": ` + referenceTimeStr + `,
2933 "url": "u"
2934 },
2935 "suspended_at": ` + referenceTimeStr + `
2936 }
2937 }`
2938
2939 testJSONMarshal(t, u, want)
2940 }
2941
2942 func TestMilestoneEvent_Marshal(t *testing.T) {
2943 testJSONMarshal(t, &MilestoneEvent{}, "{}")
2944
2945 u := &MilestoneEvent{
2946 Action: String("a"),
2947 Milestone: &Milestone{ID: Int64(1)},
2948 Changes: &EditChange{
2949 Title: &EditTitle{
2950 From: String("TitleFrom"),
2951 },
2952 Body: &EditBody{
2953 From: String("BodyFrom"),
2954 },
2955 Base: &EditBase{
2956 Ref: &EditRef{
2957 From: String("BaseRefFrom"),
2958 },
2959 SHA: &EditSHA{
2960 From: String("BaseSHAFrom"),
2961 },
2962 },
2963 },
2964 Repo: &Repository{
2965 ID: Int64(1),
2966 URL: String("s"),
2967 Name: String("n"),
2968 },
2969 Sender: &User{
2970 Login: String("l"),
2971 ID: Int64(1),
2972 NodeID: String("n"),
2973 URL: String("u"),
2974 ReposURL: String("r"),
2975 EventsURL: String("e"),
2976 AvatarURL: String("a"),
2977 },
2978 Org: &Organization{
2979 BillingEmail: String("be"),
2980 Blog: String("b"),
2981 Company: String("c"),
2982 Email: String("e"),
2983 TwitterUsername: String("tu"),
2984 Location: String("loc"),
2985 Name: String("n"),
2986 Description: String("d"),
2987 IsVerified: Bool(true),
2988 HasOrganizationProjects: Bool(true),
2989 HasRepositoryProjects: Bool(true),
2990 DefaultRepoPermission: String("drp"),
2991 MembersCanCreateRepos: Bool(true),
2992 MembersCanCreateInternalRepos: Bool(true),
2993 MembersCanCreatePrivateRepos: Bool(true),
2994 MembersCanCreatePublicRepos: Bool(false),
2995 MembersAllowedRepositoryCreationType: String("marct"),
2996 MembersCanCreatePages: Bool(true),
2997 MembersCanCreatePublicPages: Bool(false),
2998 MembersCanCreatePrivatePages: Bool(true),
2999 },
3000 Installation: &Installation{
3001 ID: Int64(1),
3002 NodeID: String("nid"),
3003 AppID: Int64(1),
3004 AppSlug: String("as"),
3005 TargetID: Int64(1),
3006 Account: &User{
3007 Login: String("l"),
3008 ID: Int64(1),
3009 URL: String("u"),
3010 AvatarURL: String("a"),
3011 GravatarID: String("g"),
3012 Name: String("n"),
3013 Company: String("c"),
3014 Blog: String("b"),
3015 Location: String("l"),
3016 Email: String("e"),
3017 Hireable: Bool(true),
3018 Bio: String("b"),
3019 TwitterUsername: String("t"),
3020 PublicRepos: Int(1),
3021 Followers: Int(1),
3022 Following: Int(1),
3023 CreatedAt: &Timestamp{referenceTime},
3024 SuspendedAt: &Timestamp{referenceTime},
3025 },
3026 AccessTokensURL: String("atu"),
3027 RepositoriesURL: String("ru"),
3028 HTMLURL: String("hu"),
3029 TargetType: String("tt"),
3030 SingleFileName: String("sfn"),
3031 RepositorySelection: String("rs"),
3032 Events: []string{"e"},
3033 SingleFilePaths: []string{"s"},
3034 Permissions: &InstallationPermissions{
3035 Actions: String("a"),
3036 Administration: String("ad"),
3037 Checks: String("c"),
3038 Contents: String("co"),
3039 ContentReferences: String("cr"),
3040 Deployments: String("d"),
3041 Environments: String("e"),
3042 Issues: String("i"),
3043 Metadata: String("md"),
3044 Members: String("m"),
3045 OrganizationAdministration: String("oa"),
3046 OrganizationHooks: String("oh"),
3047 OrganizationPlan: String("op"),
3048 OrganizationPreReceiveHooks: String("opr"),
3049 OrganizationProjects: String("op"),
3050 OrganizationSecrets: String("os"),
3051 OrganizationSelfHostedRunners: String("osh"),
3052 OrganizationUserBlocking: String("oub"),
3053 Packages: String("pkg"),
3054 Pages: String("pg"),
3055 PullRequests: String("pr"),
3056 RepositoryHooks: String("rh"),
3057 RepositoryProjects: String("rp"),
3058 RepositoryPreReceiveHooks: String("rprh"),
3059 Secrets: String("s"),
3060 SecretScanningAlerts: String("ssa"),
3061 SecurityEvents: String("se"),
3062 SingleFile: String("sf"),
3063 Statuses: String("s"),
3064 TeamDiscussions: String("td"),
3065 VulnerabilityAlerts: String("va"),
3066 Workflows: String("w"),
3067 },
3068 CreatedAt: &Timestamp{referenceTime},
3069 UpdatedAt: &Timestamp{referenceTime},
3070 HasMultipleSingleFiles: Bool(false),
3071 SuspendedBy: &User{
3072 Login: String("l"),
3073 ID: Int64(1),
3074 URL: String("u"),
3075 AvatarURL: String("a"),
3076 GravatarID: String("g"),
3077 Name: String("n"),
3078 Company: String("c"),
3079 Blog: String("b"),
3080 Location: String("l"),
3081 Email: String("e"),
3082 Hireable: Bool(true),
3083 Bio: String("b"),
3084 TwitterUsername: String("t"),
3085 PublicRepos: Int(1),
3086 Followers: Int(1),
3087 Following: Int(1),
3088 CreatedAt: &Timestamp{referenceTime},
3089 SuspendedAt: &Timestamp{referenceTime},
3090 },
3091 SuspendedAt: &Timestamp{referenceTime},
3092 },
3093 }
3094
3095 want := `{
3096 "action": "a",
3097 "milestone": {
3098 "id": 1
3099 },
3100 "changes": {
3101 "title": {
3102 "from": "TitleFrom"
3103 },
3104 "body": {
3105 "from": "BodyFrom"
3106 },
3107 "base": {
3108 "ref": {
3109 "from": "BaseRefFrom"
3110 },
3111 "sha": {
3112 "from": "BaseSHAFrom"
3113 }
3114 }
3115 },
3116 "repository": {
3117 "id": 1,
3118 "name": "n",
3119 "url": "s"
3120 },
3121 "sender": {
3122 "login": "l",
3123 "id": 1,
3124 "node_id": "n",
3125 "avatar_url": "a",
3126 "url": "u",
3127 "events_url": "e",
3128 "repos_url": "r"
3129 },
3130 "organization": {
3131 "name": "n",
3132 "company": "c",
3133 "blog": "b",
3134 "location": "loc",
3135 "email": "e",
3136 "twitter_username": "tu",
3137 "description": "d",
3138 "billing_email": "be",
3139 "is_verified": true,
3140 "has_organization_projects": true,
3141 "has_repository_projects": true,
3142 "default_repository_permission": "drp",
3143 "members_can_create_repositories": true,
3144 "members_can_create_public_repositories": false,
3145 "members_can_create_private_repositories": true,
3146 "members_can_create_internal_repositories": true,
3147 "members_allowed_repository_creation_type": "marct",
3148 "members_can_create_pages": true,
3149 "members_can_create_public_pages": false,
3150 "members_can_create_private_pages": true
3151 },
3152 "installation": {
3153 "id": 1,
3154 "node_id": "nid",
3155 "app_id": 1,
3156 "app_slug": "as",
3157 "target_id": 1,
3158 "account": {
3159 "login": "l",
3160 "id": 1,
3161 "avatar_url": "a",
3162 "gravatar_id": "g",
3163 "name": "n",
3164 "company": "c",
3165 "blog": "b",
3166 "location": "l",
3167 "email": "e",
3168 "hireable": true,
3169 "bio": "b",
3170 "twitter_username": "t",
3171 "public_repos": 1,
3172 "followers": 1,
3173 "following": 1,
3174 "created_at": ` + referenceTimeStr + `,
3175 "suspended_at": ` + referenceTimeStr + `,
3176 "url": "u"
3177 },
3178 "access_tokens_url": "atu",
3179 "repositories_url": "ru",
3180 "html_url": "hu",
3181 "target_type": "tt",
3182 "single_file_name": "sfn",
3183 "repository_selection": "rs",
3184 "events": [
3185 "e"
3186 ],
3187 "single_file_paths": [
3188 "s"
3189 ],
3190 "permissions": {
3191 "actions": "a",
3192 "administration": "ad",
3193 "checks": "c",
3194 "contents": "co",
3195 "content_references": "cr",
3196 "deployments": "d",
3197 "environments": "e",
3198 "issues": "i",
3199 "metadata": "md",
3200 "members": "m",
3201 "organization_administration": "oa",
3202 "organization_hooks": "oh",
3203 "organization_plan": "op",
3204 "organization_pre_receive_hooks": "opr",
3205 "organization_projects": "op",
3206 "organization_secrets": "os",
3207 "organization_self_hosted_runners": "osh",
3208 "organization_user_blocking": "oub",
3209 "packages": "pkg",
3210 "pages": "pg",
3211 "pull_requests": "pr",
3212 "repository_hooks": "rh",
3213 "repository_projects": "rp",
3214 "repository_pre_receive_hooks": "rprh",
3215 "secrets": "s",
3216 "secret_scanning_alerts": "ssa",
3217 "security_events": "se",
3218 "single_file": "sf",
3219 "statuses": "s",
3220 "team_discussions": "td",
3221 "vulnerability_alerts": "va",
3222 "workflows": "w"
3223 },
3224 "created_at": ` + referenceTimeStr + `,
3225 "updated_at": ` + referenceTimeStr + `,
3226 "has_multiple_single_files": false,
3227 "suspended_by": {
3228 "login": "l",
3229 "id": 1,
3230 "avatar_url": "a",
3231 "gravatar_id": "g",
3232 "name": "n",
3233 "company": "c",
3234 "blog": "b",
3235 "location": "l",
3236 "email": "e",
3237 "hireable": true,
3238 "bio": "b",
3239 "twitter_username": "t",
3240 "public_repos": 1,
3241 "followers": 1,
3242 "following": 1,
3243 "created_at": ` + referenceTimeStr + `,
3244 "suspended_at": ` + referenceTimeStr + `,
3245 "url": "u"
3246 },
3247 "suspended_at": ` + referenceTimeStr + `
3248 }
3249 }`
3250
3251 testJSONMarshal(t, u, want)
3252 }
3253
3254 func TestPublicEvent_Marshal(t *testing.T) {
3255 testJSONMarshal(t, &PublicEvent{}, "{}")
3256
3257 u := &PublicEvent{
3258 Repo: &Repository{
3259 ID: Int64(1),
3260 URL: String("s"),
3261 Name: String("n"),
3262 },
3263 Sender: &User{
3264 Login: String("l"),
3265 ID: Int64(1),
3266 NodeID: String("n"),
3267 URL: String("u"),
3268 ReposURL: String("r"),
3269 EventsURL: String("e"),
3270 AvatarURL: String("a"),
3271 },
3272 Installation: &Installation{
3273 ID: Int64(1),
3274 NodeID: String("nid"),
3275 AppID: Int64(1),
3276 AppSlug: String("as"),
3277 TargetID: Int64(1),
3278 Account: &User{
3279 Login: String("l"),
3280 ID: Int64(1),
3281 URL: String("u"),
3282 AvatarURL: String("a"),
3283 GravatarID: String("g"),
3284 Name: String("n"),
3285 Company: String("c"),
3286 Blog: String("b"),
3287 Location: String("l"),
3288 Email: String("e"),
3289 Hireable: Bool(true),
3290 Bio: String("b"),
3291 TwitterUsername: String("t"),
3292 PublicRepos: Int(1),
3293 Followers: Int(1),
3294 Following: Int(1),
3295 CreatedAt: &Timestamp{referenceTime},
3296 SuspendedAt: &Timestamp{referenceTime},
3297 },
3298 AccessTokensURL: String("atu"),
3299 RepositoriesURL: String("ru"),
3300 HTMLURL: String("hu"),
3301 TargetType: String("tt"),
3302 SingleFileName: String("sfn"),
3303 RepositorySelection: String("rs"),
3304 Events: []string{"e"},
3305 SingleFilePaths: []string{"s"},
3306 Permissions: &InstallationPermissions{
3307 Actions: String("a"),
3308 Administration: String("ad"),
3309 Checks: String("c"),
3310 Contents: String("co"),
3311 ContentReferences: String("cr"),
3312 Deployments: String("d"),
3313 Environments: String("e"),
3314 Issues: String("i"),
3315 Metadata: String("md"),
3316 Members: String("m"),
3317 OrganizationAdministration: String("oa"),
3318 OrganizationHooks: String("oh"),
3319 OrganizationPlan: String("op"),
3320 OrganizationPreReceiveHooks: String("opr"),
3321 OrganizationProjects: String("op"),
3322 OrganizationSecrets: String("os"),
3323 OrganizationSelfHostedRunners: String("osh"),
3324 OrganizationUserBlocking: String("oub"),
3325 Packages: String("pkg"),
3326 Pages: String("pg"),
3327 PullRequests: String("pr"),
3328 RepositoryHooks: String("rh"),
3329 RepositoryProjects: String("rp"),
3330 RepositoryPreReceiveHooks: String("rprh"),
3331 Secrets: String("s"),
3332 SecretScanningAlerts: String("ssa"),
3333 SecurityEvents: String("se"),
3334 SingleFile: String("sf"),
3335 Statuses: String("s"),
3336 TeamDiscussions: String("td"),
3337 VulnerabilityAlerts: String("va"),
3338 Workflows: String("w"),
3339 },
3340 CreatedAt: &Timestamp{referenceTime},
3341 UpdatedAt: &Timestamp{referenceTime},
3342 HasMultipleSingleFiles: Bool(false),
3343 SuspendedBy: &User{
3344 Login: String("l"),
3345 ID: Int64(1),
3346 URL: String("u"),
3347 AvatarURL: String("a"),
3348 GravatarID: String("g"),
3349 Name: String("n"),
3350 Company: String("c"),
3351 Blog: String("b"),
3352 Location: String("l"),
3353 Email: String("e"),
3354 Hireable: Bool(true),
3355 Bio: String("b"),
3356 TwitterUsername: String("t"),
3357 PublicRepos: Int(1),
3358 Followers: Int(1),
3359 Following: Int(1),
3360 CreatedAt: &Timestamp{referenceTime},
3361 SuspendedAt: &Timestamp{referenceTime},
3362 },
3363 SuspendedAt: &Timestamp{referenceTime},
3364 },
3365 }
3366
3367 want := `{
3368 "repository": {
3369 "id": 1,
3370 "name": "n",
3371 "url": "s"
3372 },
3373 "sender": {
3374 "login": "l",
3375 "id": 1,
3376 "node_id": "n",
3377 "avatar_url": "a",
3378 "url": "u",
3379 "events_url": "e",
3380 "repos_url": "r"
3381 },
3382 "installation": {
3383 "id": 1,
3384 "node_id": "nid",
3385 "app_id": 1,
3386 "app_slug": "as",
3387 "target_id": 1,
3388 "account": {
3389 "login": "l",
3390 "id": 1,
3391 "avatar_url": "a",
3392 "gravatar_id": "g",
3393 "name": "n",
3394 "company": "c",
3395 "blog": "b",
3396 "location": "l",
3397 "email": "e",
3398 "hireable": true,
3399 "bio": "b",
3400 "twitter_username": "t",
3401 "public_repos": 1,
3402 "followers": 1,
3403 "following": 1,
3404 "created_at": ` + referenceTimeStr + `,
3405 "suspended_at": ` + referenceTimeStr + `,
3406 "url": "u"
3407 },
3408 "access_tokens_url": "atu",
3409 "repositories_url": "ru",
3410 "html_url": "hu",
3411 "target_type": "tt",
3412 "single_file_name": "sfn",
3413 "repository_selection": "rs",
3414 "events": [
3415 "e"
3416 ],
3417 "single_file_paths": [
3418 "s"
3419 ],
3420 "permissions": {
3421 "actions": "a",
3422 "administration": "ad",
3423 "checks": "c",
3424 "contents": "co",
3425 "content_references": "cr",
3426 "deployments": "d",
3427 "environments": "e",
3428 "issues": "i",
3429 "metadata": "md",
3430 "members": "m",
3431 "organization_administration": "oa",
3432 "organization_hooks": "oh",
3433 "organization_plan": "op",
3434 "organization_pre_receive_hooks": "opr",
3435 "organization_projects": "op",
3436 "organization_secrets": "os",
3437 "organization_self_hosted_runners": "osh",
3438 "organization_user_blocking": "oub",
3439 "packages": "pkg",
3440 "pages": "pg",
3441 "pull_requests": "pr",
3442 "repository_hooks": "rh",
3443 "repository_projects": "rp",
3444 "repository_pre_receive_hooks": "rprh",
3445 "secrets": "s",
3446 "secret_scanning_alerts": "ssa",
3447 "security_events": "se",
3448 "single_file": "sf",
3449 "statuses": "s",
3450 "team_discussions": "td",
3451 "vulnerability_alerts": "va",
3452 "workflows": "w"
3453 },
3454 "created_at": ` + referenceTimeStr + `,
3455 "updated_at": ` + referenceTimeStr + `,
3456 "has_multiple_single_files": false,
3457 "suspended_by": {
3458 "login": "l",
3459 "id": 1,
3460 "avatar_url": "a",
3461 "gravatar_id": "g",
3462 "name": "n",
3463 "company": "c",
3464 "blog": "b",
3465 "location": "l",
3466 "email": "e",
3467 "hireable": true,
3468 "bio": "b",
3469 "twitter_username": "t",
3470 "public_repos": 1,
3471 "followers": 1,
3472 "following": 1,
3473 "created_at": ` + referenceTimeStr + `,
3474 "suspended_at": ` + referenceTimeStr + `,
3475 "url": "u"
3476 },
3477 "suspended_at": ` + referenceTimeStr + `
3478 }
3479 }`
3480
3481 testJSONMarshal(t, u, want)
3482 }
3483
3484 func TestPullRequestReviewEvent_Marshal(t *testing.T) {
3485 testJSONMarshal(t, &PullRequestReviewEvent{}, "{}")
3486
3487 u := &PullRequestReviewEvent{
3488 Action: String("a"),
3489 Review: &PullRequestReview{ID: Int64(1)},
3490 PullRequest: &PullRequest{ID: Int64(1)},
3491 Repo: &Repository{
3492 ID: Int64(1),
3493 URL: String("s"),
3494 Name: String("n"),
3495 },
3496 Sender: &User{
3497 Login: String("l"),
3498 ID: Int64(1),
3499 NodeID: String("n"),
3500 URL: String("u"),
3501 ReposURL: String("r"),
3502 EventsURL: String("e"),
3503 AvatarURL: String("a"),
3504 },
3505 Installation: &Installation{
3506 ID: Int64(1),
3507 NodeID: String("nid"),
3508 AppID: Int64(1),
3509 AppSlug: String("as"),
3510 TargetID: Int64(1),
3511 Account: &User{
3512 Login: String("l"),
3513 ID: Int64(1),
3514 URL: String("u"),
3515 AvatarURL: String("a"),
3516 GravatarID: String("g"),
3517 Name: String("n"),
3518 Company: String("c"),
3519 Blog: String("b"),
3520 Location: String("l"),
3521 Email: String("e"),
3522 Hireable: Bool(true),
3523 Bio: String("b"),
3524 TwitterUsername: String("t"),
3525 PublicRepos: Int(1),
3526 Followers: Int(1),
3527 Following: Int(1),
3528 CreatedAt: &Timestamp{referenceTime},
3529 SuspendedAt: &Timestamp{referenceTime},
3530 },
3531 AccessTokensURL: String("atu"),
3532 RepositoriesURL: String("ru"),
3533 HTMLURL: String("hu"),
3534 TargetType: String("tt"),
3535 SingleFileName: String("sfn"),
3536 RepositorySelection: String("rs"),
3537 Events: []string{"e"},
3538 SingleFilePaths: []string{"s"},
3539 Permissions: &InstallationPermissions{
3540 Actions: String("a"),
3541 Administration: String("ad"),
3542 Checks: String("c"),
3543 Contents: String("co"),
3544 ContentReferences: String("cr"),
3545 Deployments: String("d"),
3546 Environments: String("e"),
3547 Issues: String("i"),
3548 Metadata: String("md"),
3549 Members: String("m"),
3550 OrganizationAdministration: String("oa"),
3551 OrganizationHooks: String("oh"),
3552 OrganizationPlan: String("op"),
3553 OrganizationPreReceiveHooks: String("opr"),
3554 OrganizationProjects: String("op"),
3555 OrganizationSecrets: String("os"),
3556 OrganizationSelfHostedRunners: String("osh"),
3557 OrganizationUserBlocking: String("oub"),
3558 Packages: String("pkg"),
3559 Pages: String("pg"),
3560 PullRequests: String("pr"),
3561 RepositoryHooks: String("rh"),
3562 RepositoryProjects: String("rp"),
3563 RepositoryPreReceiveHooks: String("rprh"),
3564 Secrets: String("s"),
3565 SecretScanningAlerts: String("ssa"),
3566 SecurityEvents: String("se"),
3567 SingleFile: String("sf"),
3568 Statuses: String("s"),
3569 TeamDiscussions: String("td"),
3570 VulnerabilityAlerts: String("va"),
3571 Workflows: String("w"),
3572 },
3573 CreatedAt: &Timestamp{referenceTime},
3574 UpdatedAt: &Timestamp{referenceTime},
3575 HasMultipleSingleFiles: Bool(false),
3576 SuspendedBy: &User{
3577 Login: String("l"),
3578 ID: Int64(1),
3579 URL: String("u"),
3580 AvatarURL: String("a"),
3581 GravatarID: String("g"),
3582 Name: String("n"),
3583 Company: String("c"),
3584 Blog: String("b"),
3585 Location: String("l"),
3586 Email: String("e"),
3587 Hireable: Bool(true),
3588 Bio: String("b"),
3589 TwitterUsername: String("t"),
3590 PublicRepos: Int(1),
3591 Followers: Int(1),
3592 Following: Int(1),
3593 CreatedAt: &Timestamp{referenceTime},
3594 SuspendedAt: &Timestamp{referenceTime},
3595 },
3596 SuspendedAt: &Timestamp{referenceTime},
3597 },
3598 Organization: &Organization{
3599 BillingEmail: String("be"),
3600 Blog: String("b"),
3601 Company: String("c"),
3602 Email: String("e"),
3603 TwitterUsername: String("tu"),
3604 Location: String("loc"),
3605 Name: String("n"),
3606 Description: String("d"),
3607 IsVerified: Bool(true),
3608 HasOrganizationProjects: Bool(true),
3609 HasRepositoryProjects: Bool(true),
3610 DefaultRepoPermission: String("drp"),
3611 MembersCanCreateRepos: Bool(true),
3612 MembersCanCreateInternalRepos: Bool(true),
3613 MembersCanCreatePrivateRepos: Bool(true),
3614 MembersCanCreatePublicRepos: Bool(false),
3615 MembersAllowedRepositoryCreationType: String("marct"),
3616 MembersCanCreatePages: Bool(true),
3617 MembersCanCreatePublicPages: Bool(false),
3618 MembersCanCreatePrivatePages: Bool(true),
3619 },
3620 }
3621
3622 want := `{
3623 "action": "a",
3624 "review": {
3625 "id": 1
3626 },
3627 "pull_request": {
3628 "id": 1
3629 },
3630 "repository": {
3631 "id": 1,
3632 "name": "n",
3633 "url": "s"
3634 },
3635 "sender": {
3636 "login": "l",
3637 "id": 1,
3638 "node_id": "n",
3639 "avatar_url": "a",
3640 "url": "u",
3641 "events_url": "e",
3642 "repos_url": "r"
3643 },
3644 "installation": {
3645 "id": 1,
3646 "node_id": "nid",
3647 "app_id": 1,
3648 "app_slug": "as",
3649 "target_id": 1,
3650 "account": {
3651 "login": "l",
3652 "id": 1,
3653 "avatar_url": "a",
3654 "gravatar_id": "g",
3655 "name": "n",
3656 "company": "c",
3657 "blog": "b",
3658 "location": "l",
3659 "email": "e",
3660 "hireable": true,
3661 "bio": "b",
3662 "twitter_username": "t",
3663 "public_repos": 1,
3664 "followers": 1,
3665 "following": 1,
3666 "created_at": ` + referenceTimeStr + `,
3667 "suspended_at": ` + referenceTimeStr + `,
3668 "url": "u"
3669 },
3670 "access_tokens_url": "atu",
3671 "repositories_url": "ru",
3672 "html_url": "hu",
3673 "target_type": "tt",
3674 "single_file_name": "sfn",
3675 "repository_selection": "rs",
3676 "events": [
3677 "e"
3678 ],
3679 "single_file_paths": [
3680 "s"
3681 ],
3682 "permissions": {
3683 "actions": "a",
3684 "administration": "ad",
3685 "checks": "c",
3686 "contents": "co",
3687 "content_references": "cr",
3688 "deployments": "d",
3689 "environments": "e",
3690 "issues": "i",
3691 "metadata": "md",
3692 "members": "m",
3693 "organization_administration": "oa",
3694 "organization_hooks": "oh",
3695 "organization_plan": "op",
3696 "organization_pre_receive_hooks": "opr",
3697 "organization_projects": "op",
3698 "organization_secrets": "os",
3699 "organization_self_hosted_runners": "osh",
3700 "organization_user_blocking": "oub",
3701 "packages": "pkg",
3702 "pages": "pg",
3703 "pull_requests": "pr",
3704 "repository_hooks": "rh",
3705 "repository_projects": "rp",
3706 "repository_pre_receive_hooks": "rprh",
3707 "secrets": "s",
3708 "secret_scanning_alerts": "ssa",
3709 "security_events": "se",
3710 "single_file": "sf",
3711 "statuses": "s",
3712 "team_discussions": "td",
3713 "vulnerability_alerts": "va",
3714 "workflows": "w"
3715 },
3716 "created_at": ` + referenceTimeStr + `,
3717 "updated_at": ` + referenceTimeStr + `,
3718 "has_multiple_single_files": false,
3719 "suspended_by": {
3720 "login": "l",
3721 "id": 1,
3722 "avatar_url": "a",
3723 "gravatar_id": "g",
3724 "name": "n",
3725 "company": "c",
3726 "blog": "b",
3727 "location": "l",
3728 "email": "e",
3729 "hireable": true,
3730 "bio": "b",
3731 "twitter_username": "t",
3732 "public_repos": 1,
3733 "followers": 1,
3734 "following": 1,
3735 "created_at": ` + referenceTimeStr + `,
3736 "suspended_at": ` + referenceTimeStr + `,
3737 "url": "u"
3738 },
3739 "suspended_at": ` + referenceTimeStr + `
3740 },
3741 "organization": {
3742 "name": "n",
3743 "company": "c",
3744 "blog": "b",
3745 "location": "loc",
3746 "email": "e",
3747 "twitter_username": "tu",
3748 "description": "d",
3749 "billing_email": "be",
3750 "is_verified": true,
3751 "has_organization_projects": true,
3752 "has_repository_projects": true,
3753 "default_repository_permission": "drp",
3754 "members_can_create_repositories": true,
3755 "members_can_create_public_repositories": false,
3756 "members_can_create_private_repositories": true,
3757 "members_can_create_internal_repositories": true,
3758 "members_allowed_repository_creation_type": "marct",
3759 "members_can_create_pages": true,
3760 "members_can_create_public_pages": false,
3761 "members_can_create_private_pages": true
3762 }
3763 }`
3764
3765 testJSONMarshal(t, u, want)
3766 }
3767
3768 func TestPushEvent_Marshal(t *testing.T) {
3769 testJSONMarshal(t, &PushEvent{}, "{}")
3770
3771 u := &PushEvent{
3772 PushID: Int64(1),
3773 Head: String("h"),
3774 Ref: String("ref"),
3775 Size: Int(1),
3776 Commits: []*HeadCommit{
3777 {ID: String("id")},
3778 },
3779 Before: String("b"),
3780 DistinctSize: Int(1),
3781 After: String("a"),
3782 Created: Bool(true),
3783 Deleted: Bool(true),
3784 Forced: Bool(true),
3785 BaseRef: String("a"),
3786 Compare: String("a"),
3787 Repo: &PushEventRepository{ID: Int64(1)},
3788 HeadCommit: &HeadCommit{ID: String("id")},
3789 Pusher: &CommitAuthor{
3790 Login: String("l"),
3791 Date: &Timestamp{referenceTime},
3792 Name: String("n"),
3793 Email: String("e"),
3794 },
3795 Sender: &User{
3796 Login: String("l"),
3797 ID: Int64(1),
3798 NodeID: String("n"),
3799 URL: String("u"),
3800 ReposURL: String("r"),
3801 EventsURL: String("e"),
3802 AvatarURL: String("a"),
3803 },
3804 Installation: &Installation{
3805 ID: Int64(1),
3806 NodeID: String("nid"),
3807 AppID: Int64(1),
3808 AppSlug: String("as"),
3809 TargetID: Int64(1),
3810 Account: &User{
3811 Login: String("l"),
3812 ID: Int64(1),
3813 URL: String("u"),
3814 AvatarURL: String("a"),
3815 GravatarID: String("g"),
3816 Name: String("n"),
3817 Company: String("c"),
3818 Blog: String("b"),
3819 Location: String("l"),
3820 Email: String("e"),
3821 Hireable: Bool(true),
3822 Bio: String("b"),
3823 TwitterUsername: String("t"),
3824 PublicRepos: Int(1),
3825 Followers: Int(1),
3826 Following: Int(1),
3827 CreatedAt: &Timestamp{referenceTime},
3828 SuspendedAt: &Timestamp{referenceTime},
3829 },
3830 AccessTokensURL: String("atu"),
3831 RepositoriesURL: String("ru"),
3832 HTMLURL: String("hu"),
3833 TargetType: String("tt"),
3834 SingleFileName: String("sfn"),
3835 RepositorySelection: String("rs"),
3836 Events: []string{"e"},
3837 SingleFilePaths: []string{"s"},
3838 Permissions: &InstallationPermissions{
3839 Actions: String("a"),
3840 Administration: String("ad"),
3841 Checks: String("c"),
3842 Contents: String("co"),
3843 ContentReferences: String("cr"),
3844 Deployments: String("d"),
3845 Environments: String("e"),
3846 Issues: String("i"),
3847 Metadata: String("md"),
3848 Members: String("m"),
3849 OrganizationAdministration: String("oa"),
3850 OrganizationHooks: String("oh"),
3851 OrganizationPlan: String("op"),
3852 OrganizationPreReceiveHooks: String("opr"),
3853 OrganizationProjects: String("op"),
3854 OrganizationSecrets: String("os"),
3855 OrganizationSelfHostedRunners: String("osh"),
3856 OrganizationUserBlocking: String("oub"),
3857 Packages: String("pkg"),
3858 Pages: String("pg"),
3859 PullRequests: String("pr"),
3860 RepositoryHooks: String("rh"),
3861 RepositoryProjects: String("rp"),
3862 RepositoryPreReceiveHooks: String("rprh"),
3863 Secrets: String("s"),
3864 SecretScanningAlerts: String("ssa"),
3865 SecurityEvents: String("se"),
3866 SingleFile: String("sf"),
3867 Statuses: String("s"),
3868 TeamDiscussions: String("td"),
3869 VulnerabilityAlerts: String("va"),
3870 Workflows: String("w"),
3871 },
3872 CreatedAt: &Timestamp{referenceTime},
3873 UpdatedAt: &Timestamp{referenceTime},
3874 HasMultipleSingleFiles: Bool(false),
3875 SuspendedBy: &User{
3876 Login: String("l"),
3877 ID: Int64(1),
3878 URL: String("u"),
3879 AvatarURL: String("a"),
3880 GravatarID: String("g"),
3881 Name: String("n"),
3882 Company: String("c"),
3883 Blog: String("b"),
3884 Location: String("l"),
3885 Email: String("e"),
3886 Hireable: Bool(true),
3887 Bio: String("b"),
3888 TwitterUsername: String("t"),
3889 PublicRepos: Int(1),
3890 Followers: Int(1),
3891 Following: Int(1),
3892 CreatedAt: &Timestamp{referenceTime},
3893 SuspendedAt: &Timestamp{referenceTime},
3894 },
3895 SuspendedAt: &Timestamp{referenceTime},
3896 },
3897 Organization: &Organization{
3898 BillingEmail: String("be"),
3899 Blog: String("b"),
3900 Company: String("c"),
3901 Email: String("e"),
3902 TwitterUsername: String("tu"),
3903 Location: String("loc"),
3904 Name: String("n"),
3905 Description: String("d"),
3906 IsVerified: Bool(true),
3907 HasOrganizationProjects: Bool(true),
3908 HasRepositoryProjects: Bool(true),
3909 DefaultRepoPermission: String("drp"),
3910 MembersCanCreateRepos: Bool(true),
3911 MembersCanCreateInternalRepos: Bool(true),
3912 MembersCanCreatePrivateRepos: Bool(true),
3913 MembersCanCreatePublicRepos: Bool(false),
3914 MembersAllowedRepositoryCreationType: String("marct"),
3915 MembersCanCreatePages: Bool(true),
3916 MembersCanCreatePublicPages: Bool(false),
3917 MembersCanCreatePrivatePages: Bool(true),
3918 },
3919 }
3920
3921 want := `{
3922 "push_id": 1,
3923 "head": "h",
3924 "ref": "ref",
3925 "size": 1,
3926 "commits": [
3927 {
3928 "id": "id"
3929 }
3930 ],
3931 "before": "b",
3932 "distinct_size": 1,
3933 "after": "a",
3934 "created": true,
3935 "deleted": true,
3936 "forced": true,
3937 "base_ref": "a",
3938 "compare": "a",
3939 "repository": {
3940 "id": 1
3941 },
3942 "head_commit": {
3943 "id": "id"
3944 },
3945 "pusher": {
3946 "date": ` + referenceTimeStr + `,
3947 "name": "n",
3948 "email": "e",
3949 "username": "l"
3950 },
3951 "sender": {
3952 "login": "l",
3953 "id": 1,
3954 "node_id": "n",
3955 "avatar_url": "a",
3956 "url": "u",
3957 "events_url": "e",
3958 "repos_url": "r"
3959 },
3960 "installation": {
3961 "id": 1,
3962 "node_id": "nid",
3963 "app_id": 1,
3964 "app_slug": "as",
3965 "target_id": 1,
3966 "account": {
3967 "login": "l",
3968 "id": 1,
3969 "avatar_url": "a",
3970 "gravatar_id": "g",
3971 "name": "n",
3972 "company": "c",
3973 "blog": "b",
3974 "location": "l",
3975 "email": "e",
3976 "hireable": true,
3977 "bio": "b",
3978 "twitter_username": "t",
3979 "public_repos": 1,
3980 "followers": 1,
3981 "following": 1,
3982 "created_at": ` + referenceTimeStr + `,
3983 "suspended_at": ` + referenceTimeStr + `,
3984 "url": "u"
3985 },
3986 "access_tokens_url": "atu",
3987 "repositories_url": "ru",
3988 "html_url": "hu",
3989 "target_type": "tt",
3990 "single_file_name": "sfn",
3991 "repository_selection": "rs",
3992 "events": [
3993 "e"
3994 ],
3995 "single_file_paths": [
3996 "s"
3997 ],
3998 "permissions": {
3999 "actions": "a",
4000 "administration": "ad",
4001 "checks": "c",
4002 "contents": "co",
4003 "content_references": "cr",
4004 "deployments": "d",
4005 "environments": "e",
4006 "issues": "i",
4007 "metadata": "md",
4008 "members": "m",
4009 "organization_administration": "oa",
4010 "organization_hooks": "oh",
4011 "organization_plan": "op",
4012 "organization_pre_receive_hooks": "opr",
4013 "organization_projects": "op",
4014 "organization_secrets": "os",
4015 "organization_self_hosted_runners": "osh",
4016 "organization_user_blocking": "oub",
4017 "packages": "pkg",
4018 "pages": "pg",
4019 "pull_requests": "pr",
4020 "repository_hooks": "rh",
4021 "repository_projects": "rp",
4022 "repository_pre_receive_hooks": "rprh",
4023 "secrets": "s",
4024 "secret_scanning_alerts": "ssa",
4025 "security_events": "se",
4026 "single_file": "sf",
4027 "statuses": "s",
4028 "team_discussions": "td",
4029 "vulnerability_alerts": "va",
4030 "workflows": "w"
4031 },
4032 "created_at": ` + referenceTimeStr + `,
4033 "updated_at": ` + referenceTimeStr + `,
4034 "has_multiple_single_files": false,
4035 "suspended_by": {
4036 "login": "l",
4037 "id": 1,
4038 "avatar_url": "a",
4039 "gravatar_id": "g",
4040 "name": "n",
4041 "company": "c",
4042 "blog": "b",
4043 "location": "l",
4044 "email": "e",
4045 "hireable": true,
4046 "bio": "b",
4047 "twitter_username": "t",
4048 "public_repos": 1,
4049 "followers": 1,
4050 "following": 1,
4051 "created_at": ` + referenceTimeStr + `,
4052 "suspended_at": ` + referenceTimeStr + `,
4053 "url": "u"
4054 },
4055 "suspended_at": ` + referenceTimeStr + `
4056 },
4057 "organization": {
4058 "name": "n",
4059 "company": "c",
4060 "blog": "b",
4061 "location": "loc",
4062 "email": "e",
4063 "twitter_username": "tu",
4064 "description": "d",
4065 "billing_email": "be",
4066 "is_verified": true,
4067 "has_organization_projects": true,
4068 "has_repository_projects": true,
4069 "default_repository_permission": "drp",
4070 "members_can_create_repositories": true,
4071 "members_can_create_public_repositories": false,
4072 "members_can_create_private_repositories": true,
4073 "members_can_create_internal_repositories": true,
4074 "members_allowed_repository_creation_type": "marct",
4075 "members_can_create_pages": true,
4076 "members_can_create_public_pages": false,
4077 "members_can_create_private_pages": true
4078 }
4079 }`
4080
4081 testJSONMarshal(t, u, want)
4082 }
4083
4084 func TestStatusEvent_Marshal(t *testing.T) {
4085 testJSONMarshal(t, &StatusEvent{}, "{}")
4086
4087 u := &StatusEvent{
4088 SHA: String("sha"),
4089 State: String("s"),
4090 Description: String("d"),
4091 TargetURL: String("turl"),
4092 Branches: []*Branch{
4093 {
4094 Name: String("n"),
4095 Commit: &RepositoryCommit{NodeID: String("nid")},
4096 Protected: Bool(false),
4097 },
4098 },
4099 ID: Int64(1),
4100 Name: String("n"),
4101 Context: String("c"),
4102 Commit: &RepositoryCommit{NodeID: String("nid")},
4103 CreatedAt: &Timestamp{referenceTime},
4104 UpdatedAt: &Timestamp{referenceTime},
4105 Sender: &User{
4106 Login: String("l"),
4107 ID: Int64(1),
4108 NodeID: String("n"),
4109 URL: String("u"),
4110 ReposURL: String("r"),
4111 EventsURL: String("e"),
4112 AvatarURL: String("a"),
4113 },
4114 Installation: &Installation{
4115 ID: Int64(1),
4116 NodeID: String("nid"),
4117 AppID: Int64(1),
4118 AppSlug: String("as"),
4119 TargetID: Int64(1),
4120 Account: &User{
4121 Login: String("l"),
4122 ID: Int64(1),
4123 URL: String("u"),
4124 AvatarURL: String("a"),
4125 GravatarID: String("g"),
4126 Name: String("n"),
4127 Company: String("c"),
4128 Blog: String("b"),
4129 Location: String("l"),
4130 Email: String("e"),
4131 Hireable: Bool(true),
4132 Bio: String("b"),
4133 TwitterUsername: String("t"),
4134 PublicRepos: Int(1),
4135 Followers: Int(1),
4136 Following: Int(1),
4137 CreatedAt: &Timestamp{referenceTime},
4138 SuspendedAt: &Timestamp{referenceTime},
4139 },
4140 AccessTokensURL: String("atu"),
4141 RepositoriesURL: String("ru"),
4142 HTMLURL: String("hu"),
4143 TargetType: String("tt"),
4144 SingleFileName: String("sfn"),
4145 RepositorySelection: String("rs"),
4146 Events: []string{"e"},
4147 SingleFilePaths: []string{"s"},
4148 Permissions: &InstallationPermissions{
4149 Actions: String("a"),
4150 Administration: String("ad"),
4151 Checks: String("c"),
4152 Contents: String("co"),
4153 ContentReferences: String("cr"),
4154 Deployments: String("d"),
4155 Environments: String("e"),
4156 Issues: String("i"),
4157 Metadata: String("md"),
4158 Members: String("m"),
4159 OrganizationAdministration: String("oa"),
4160 OrganizationHooks: String("oh"),
4161 OrganizationPlan: String("op"),
4162 OrganizationPreReceiveHooks: String("opr"),
4163 OrganizationProjects: String("op"),
4164 OrganizationSecrets: String("os"),
4165 OrganizationSelfHostedRunners: String("osh"),
4166 OrganizationUserBlocking: String("oub"),
4167 Packages: String("pkg"),
4168 Pages: String("pg"),
4169 PullRequests: String("pr"),
4170 RepositoryHooks: String("rh"),
4171 RepositoryProjects: String("rp"),
4172 RepositoryPreReceiveHooks: String("rprh"),
4173 Secrets: String("s"),
4174 SecretScanningAlerts: String("ssa"),
4175 SecurityEvents: String("se"),
4176 SingleFile: String("sf"),
4177 Statuses: String("s"),
4178 TeamDiscussions: String("td"),
4179 VulnerabilityAlerts: String("va"),
4180 Workflows: String("w"),
4181 },
4182 CreatedAt: &Timestamp{referenceTime},
4183 UpdatedAt: &Timestamp{referenceTime},
4184 HasMultipleSingleFiles: Bool(false),
4185 SuspendedBy: &User{
4186 Login: String("l"),
4187 ID: Int64(1),
4188 URL: String("u"),
4189 AvatarURL: String("a"),
4190 GravatarID: String("g"),
4191 Name: String("n"),
4192 Company: String("c"),
4193 Blog: String("b"),
4194 Location: String("l"),
4195 Email: String("e"),
4196 Hireable: Bool(true),
4197 Bio: String("b"),
4198 TwitterUsername: String("t"),
4199 PublicRepos: Int(1),
4200 Followers: Int(1),
4201 Following: Int(1),
4202 CreatedAt: &Timestamp{referenceTime},
4203 SuspendedAt: &Timestamp{referenceTime},
4204 },
4205 SuspendedAt: &Timestamp{referenceTime},
4206 },
4207 }
4208
4209 want := `{
4210 "sha": "sha",
4211 "state": "s",
4212 "description": "d",
4213 "target_url": "turl",
4214 "branches": [
4215 {
4216 "name": "n",
4217 "commit": {
4218 "node_id": "nid"
4219 },
4220 "protected": false
4221 }
4222 ],
4223 "id": 1,
4224 "name": "n",
4225 "context": "c",
4226 "commit": {
4227 "node_id": "nid"
4228 },
4229 "created_at": ` + referenceTimeStr + `,
4230 "updated_at": ` + referenceTimeStr + `,
4231 "sender": {
4232 "login": "l",
4233 "id": 1,
4234 "node_id": "n",
4235 "avatar_url": "a",
4236 "url": "u",
4237 "events_url": "e",
4238 "repos_url": "r"
4239 },
4240 "installation": {
4241 "id": 1,
4242 "node_id": "nid",
4243 "app_id": 1,
4244 "app_slug": "as",
4245 "target_id": 1,
4246 "account": {
4247 "login": "l",
4248 "id": 1,
4249 "avatar_url": "a",
4250 "gravatar_id": "g",
4251 "name": "n",
4252 "company": "c",
4253 "blog": "b",
4254 "location": "l",
4255 "email": "e",
4256 "hireable": true,
4257 "bio": "b",
4258 "twitter_username": "t",
4259 "public_repos": 1,
4260 "followers": 1,
4261 "following": 1,
4262 "created_at": ` + referenceTimeStr + `,
4263 "suspended_at": ` + referenceTimeStr + `,
4264 "url": "u"
4265 },
4266 "access_tokens_url": "atu",
4267 "repositories_url": "ru",
4268 "html_url": "hu",
4269 "target_type": "tt",
4270 "single_file_name": "sfn",
4271 "repository_selection": "rs",
4272 "events": [
4273 "e"
4274 ],
4275 "single_file_paths": [
4276 "s"
4277 ],
4278 "permissions": {
4279 "actions": "a",
4280 "administration": "ad",
4281 "checks": "c",
4282 "contents": "co",
4283 "content_references": "cr",
4284 "deployments": "d",
4285 "environments": "e",
4286 "issues": "i",
4287 "metadata": "md",
4288 "members": "m",
4289 "organization_administration": "oa",
4290 "organization_hooks": "oh",
4291 "organization_plan": "op",
4292 "organization_pre_receive_hooks": "opr",
4293 "organization_projects": "op",
4294 "organization_secrets": "os",
4295 "organization_self_hosted_runners": "osh",
4296 "organization_user_blocking": "oub",
4297 "packages": "pkg",
4298 "pages": "pg",
4299 "pull_requests": "pr",
4300 "repository_hooks": "rh",
4301 "repository_projects": "rp",
4302 "repository_pre_receive_hooks": "rprh",
4303 "secrets": "s",
4304 "secret_scanning_alerts": "ssa",
4305 "security_events": "se",
4306 "single_file": "sf",
4307 "statuses": "s",
4308 "team_discussions": "td",
4309 "vulnerability_alerts": "va",
4310 "workflows": "w"
4311 },
4312 "created_at": ` + referenceTimeStr + `,
4313 "updated_at": ` + referenceTimeStr + `,
4314 "has_multiple_single_files": false,
4315 "suspended_by": {
4316 "login": "l",
4317 "id": 1,
4318 "avatar_url": "a",
4319 "gravatar_id": "g",
4320 "name": "n",
4321 "company": "c",
4322 "blog": "b",
4323 "location": "l",
4324 "email": "e",
4325 "hireable": true,
4326 "bio": "b",
4327 "twitter_username": "t",
4328 "public_repos": 1,
4329 "followers": 1,
4330 "following": 1,
4331 "created_at": ` + referenceTimeStr + `,
4332 "suspended_at": ` + referenceTimeStr + `,
4333 "url": "u"
4334 },
4335 "suspended_at": ` + referenceTimeStr + `
4336 }
4337 }`
4338
4339 testJSONMarshal(t, u, want)
4340 }
4341
4342 func TestMarketplacePurchaseEvent_Marshal(t *testing.T) {
4343 testJSONMarshal(t, &MarketplacePurchaseEvent{}, "{}")
4344
4345 u := &MarketplacePurchaseEvent{
4346 Action: String("a"),
4347 EffectiveDate: &Timestamp{referenceTime},
4348 MarketplacePurchase: &MarketplacePurchase{
4349 BillingCycle: String("bc"),
4350 NextBillingDate: &Timestamp{referenceTime},
4351 UnitCount: Int(1),
4352 Plan: &MarketplacePlan{
4353 URL: String("u"),
4354 AccountsURL: String("au"),
4355 ID: Int64(1),
4356 Number: Int(1),
4357 Name: String("n"),
4358 Description: String("d"),
4359 MonthlyPriceInCents: Int(1),
4360 YearlyPriceInCents: Int(1),
4361 PriceModel: String("pm"),
4362 UnitName: String("un"),
4363 Bullets: &[]string{"b"},
4364 State: String("s"),
4365 HasFreeTrial: Bool(false),
4366 },
4367 OnFreeTrial: Bool(false),
4368 FreeTrialEndsOn: &Timestamp{referenceTime},
4369 UpdatedAt: &Timestamp{referenceTime},
4370 },
4371 PreviousMarketplacePurchase: &MarketplacePurchase{
4372 BillingCycle: String("bc"),
4373 NextBillingDate: &Timestamp{referenceTime},
4374 UnitCount: Int(1),
4375 Plan: &MarketplacePlan{
4376 URL: String("u"),
4377 AccountsURL: String("au"),
4378 ID: Int64(1),
4379 Number: Int(1),
4380 Name: String("n"),
4381 Description: String("d"),
4382 MonthlyPriceInCents: Int(1),
4383 YearlyPriceInCents: Int(1),
4384 PriceModel: String("pm"),
4385 UnitName: String("un"),
4386 Bullets: &[]string{"b"},
4387 State: String("s"),
4388 HasFreeTrial: Bool(false),
4389 },
4390 OnFreeTrial: Bool(false),
4391 FreeTrialEndsOn: &Timestamp{referenceTime},
4392 UpdatedAt: &Timestamp{referenceTime},
4393 },
4394 Sender: &User{
4395 Login: String("l"),
4396 ID: Int64(1),
4397 NodeID: String("n"),
4398 URL: String("u"),
4399 ReposURL: String("r"),
4400 EventsURL: String("e"),
4401 AvatarURL: String("a"),
4402 },
4403 Installation: &Installation{
4404 ID: Int64(1),
4405 NodeID: String("nid"),
4406 AppID: Int64(1),
4407 AppSlug: String("as"),
4408 TargetID: Int64(1),
4409 Account: &User{
4410 Login: String("l"),
4411 ID: Int64(1),
4412 URL: String("u"),
4413 AvatarURL: String("a"),
4414 GravatarID: String("g"),
4415 Name: String("n"),
4416 Company: String("c"),
4417 Blog: String("b"),
4418 Location: String("l"),
4419 Email: String("e"),
4420 Hireable: Bool(true),
4421 Bio: String("b"),
4422 TwitterUsername: String("t"),
4423 PublicRepos: Int(1),
4424 Followers: Int(1),
4425 Following: Int(1),
4426 CreatedAt: &Timestamp{referenceTime},
4427 SuspendedAt: &Timestamp{referenceTime},
4428 },
4429 AccessTokensURL: String("atu"),
4430 RepositoriesURL: String("ru"),
4431 HTMLURL: String("hu"),
4432 TargetType: String("tt"),
4433 SingleFileName: String("sfn"),
4434 RepositorySelection: String("rs"),
4435 Events: []string{"e"},
4436 SingleFilePaths: []string{"s"},
4437 Permissions: &InstallationPermissions{
4438 Actions: String("a"),
4439 Administration: String("ad"),
4440 Checks: String("c"),
4441 Contents: String("co"),
4442 ContentReferences: String("cr"),
4443 Deployments: String("d"),
4444 Environments: String("e"),
4445 Issues: String("i"),
4446 Metadata: String("md"),
4447 Members: String("m"),
4448 OrganizationAdministration: String("oa"),
4449 OrganizationHooks: String("oh"),
4450 OrganizationPlan: String("op"),
4451 OrganizationPreReceiveHooks: String("opr"),
4452 OrganizationProjects: String("op"),
4453 OrganizationSecrets: String("os"),
4454 OrganizationSelfHostedRunners: String("osh"),
4455 OrganizationUserBlocking: String("oub"),
4456 Packages: String("pkg"),
4457 Pages: String("pg"),
4458 PullRequests: String("pr"),
4459 RepositoryHooks: String("rh"),
4460 RepositoryProjects: String("rp"),
4461 RepositoryPreReceiveHooks: String("rprh"),
4462 Secrets: String("s"),
4463 SecretScanningAlerts: String("ssa"),
4464 SecurityEvents: String("se"),
4465 SingleFile: String("sf"),
4466 Statuses: String("s"),
4467 TeamDiscussions: String("td"),
4468 VulnerabilityAlerts: String("va"),
4469 Workflows: String("w"),
4470 },
4471 CreatedAt: &Timestamp{referenceTime},
4472 UpdatedAt: &Timestamp{referenceTime},
4473 HasMultipleSingleFiles: Bool(false),
4474 SuspendedBy: &User{
4475 Login: String("l"),
4476 ID: Int64(1),
4477 URL: String("u"),
4478 AvatarURL: String("a"),
4479 GravatarID: String("g"),
4480 Name: String("n"),
4481 Company: String("c"),
4482 Blog: String("b"),
4483 Location: String("l"),
4484 Email: String("e"),
4485 Hireable: Bool(true),
4486 Bio: String("b"),
4487 TwitterUsername: String("t"),
4488 PublicRepos: Int(1),
4489 Followers: Int(1),
4490 Following: Int(1),
4491 CreatedAt: &Timestamp{referenceTime},
4492 SuspendedAt: &Timestamp{referenceTime},
4493 },
4494 SuspendedAt: &Timestamp{referenceTime},
4495 },
4496 }
4497
4498 want := `{
4499 "action": "a",
4500 "effective_date": ` + referenceTimeStr + `,
4501 "marketplace_purchase": {
4502 "billing_cycle": "bc",
4503 "next_billing_date": ` + referenceTimeStr + `,
4504 "unit_count": 1,
4505 "plan": {
4506 "url": "u",
4507 "accounts_url": "au",
4508 "id": 1,
4509 "number": 1,
4510 "name": "n",
4511 "description": "d",
4512 "monthly_price_in_cents": 1,
4513 "yearly_price_in_cents": 1,
4514 "price_model": "pm",
4515 "unit_name": "un",
4516 "bullets": [
4517 "b"
4518 ],
4519 "state": "s",
4520 "has_free_trial": false
4521 },
4522 "on_free_trial": false,
4523 "free_trial_ends_on": ` + referenceTimeStr + `,
4524 "updated_at": ` + referenceTimeStr + `
4525 },
4526 "previous_marketplace_purchase": {
4527 "billing_cycle": "bc",
4528 "next_billing_date": ` + referenceTimeStr + `,
4529 "unit_count": 1,
4530 "plan": {
4531 "url": "u",
4532 "accounts_url": "au",
4533 "id": 1,
4534 "number": 1,
4535 "name": "n",
4536 "description": "d",
4537 "monthly_price_in_cents": 1,
4538 "yearly_price_in_cents": 1,
4539 "price_model": "pm",
4540 "unit_name": "un",
4541 "bullets": [
4542 "b"
4543 ],
4544 "state": "s",
4545 "has_free_trial": false
4546 },
4547 "on_free_trial": false,
4548 "free_trial_ends_on": ` + referenceTimeStr + `,
4549 "updated_at": ` + referenceTimeStr + `
4550 },
4551 "sender": {
4552 "login": "l",
4553 "id": 1,
4554 "node_id": "n",
4555 "avatar_url": "a",
4556 "url": "u",
4557 "events_url": "e",
4558 "repos_url": "r"
4559 },
4560 "installation": {
4561 "id": 1,
4562 "node_id": "nid",
4563 "app_id": 1,
4564 "app_slug": "as",
4565 "target_id": 1,
4566 "account": {
4567 "login": "l",
4568 "id": 1,
4569 "avatar_url": "a",
4570 "gravatar_id": "g",
4571 "name": "n",
4572 "company": "c",
4573 "blog": "b",
4574 "location": "l",
4575 "email": "e",
4576 "hireable": true,
4577 "bio": "b",
4578 "twitter_username": "t",
4579 "public_repos": 1,
4580 "followers": 1,
4581 "following": 1,
4582 "created_at": ` + referenceTimeStr + `,
4583 "suspended_at": ` + referenceTimeStr + `,
4584 "url": "u"
4585 },
4586 "access_tokens_url": "atu",
4587 "repositories_url": "ru",
4588 "html_url": "hu",
4589 "target_type": "tt",
4590 "single_file_name": "sfn",
4591 "repository_selection": "rs",
4592 "events": [
4593 "e"
4594 ],
4595 "single_file_paths": [
4596 "s"
4597 ],
4598 "permissions": {
4599 "actions": "a",
4600 "administration": "ad",
4601 "checks": "c",
4602 "contents": "co",
4603 "content_references": "cr",
4604 "deployments": "d",
4605 "environments": "e",
4606 "issues": "i",
4607 "metadata": "md",
4608 "members": "m",
4609 "organization_administration": "oa",
4610 "organization_hooks": "oh",
4611 "organization_plan": "op",
4612 "organization_pre_receive_hooks": "opr",
4613 "organization_projects": "op",
4614 "organization_secrets": "os",
4615 "organization_self_hosted_runners": "osh",
4616 "organization_user_blocking": "oub",
4617 "packages": "pkg",
4618 "pages": "pg",
4619 "pull_requests": "pr",
4620 "repository_hooks": "rh",
4621 "repository_projects": "rp",
4622 "repository_pre_receive_hooks": "rprh",
4623 "secrets": "s",
4624 "secret_scanning_alerts": "ssa",
4625 "security_events": "se",
4626 "single_file": "sf",
4627 "statuses": "s",
4628 "team_discussions": "td",
4629 "vulnerability_alerts": "va",
4630 "workflows": "w"
4631 },
4632 "created_at": ` + referenceTimeStr + `,
4633 "updated_at": ` + referenceTimeStr + `,
4634 "has_multiple_single_files": false,
4635 "suspended_by": {
4636 "login": "l",
4637 "id": 1,
4638 "avatar_url": "a",
4639 "gravatar_id": "g",
4640 "name": "n",
4641 "company": "c",
4642 "blog": "b",
4643 "location": "l",
4644 "email": "e",
4645 "hireable": true,
4646 "bio": "b",
4647 "twitter_username": "t",
4648 "public_repos": 1,
4649 "followers": 1,
4650 "following": 1,
4651 "created_at": ` + referenceTimeStr + `,
4652 "suspended_at": ` + referenceTimeStr + `,
4653 "url": "u"
4654 },
4655 "suspended_at": ` + referenceTimeStr + `
4656 }
4657 }`
4658
4659 testJSONMarshal(t, u, want)
4660 }
4661
4662 func TestOrganizationEvent_Marshal(t *testing.T) {
4663 testJSONMarshal(t, &OrganizationEvent{}, "{}")
4664
4665 u := &OrganizationEvent{
4666 Action: String("a"),
4667 Invitation: &Invitation{ID: Int64(1)},
4668 Membership: &Membership{
4669 URL: String("url"),
4670 State: String("s"),
4671 Role: String("r"),
4672 OrganizationURL: String("ou"),
4673 Organization: &Organization{
4674 BillingEmail: String("be"),
4675 Blog: String("b"),
4676 Company: String("c"),
4677 Email: String("e"),
4678 TwitterUsername: String("tu"),
4679 Location: String("loc"),
4680 Name: String("n"),
4681 Description: String("d"),
4682 IsVerified: Bool(true),
4683 HasOrganizationProjects: Bool(true),
4684 HasRepositoryProjects: Bool(true),
4685 DefaultRepoPermission: String("drp"),
4686 MembersCanCreateRepos: Bool(true),
4687 MembersCanCreateInternalRepos: Bool(true),
4688 MembersCanCreatePrivateRepos: Bool(true),
4689 MembersCanCreatePublicRepos: Bool(false),
4690 MembersAllowedRepositoryCreationType: String("marct"),
4691 MembersCanCreatePages: Bool(true),
4692 MembersCanCreatePublicPages: Bool(false),
4693 MembersCanCreatePrivatePages: Bool(true),
4694 },
4695 User: &User{
4696 Login: String("l"),
4697 ID: Int64(1),
4698 NodeID: String("n"),
4699 URL: String("u"),
4700 ReposURL: String("r"),
4701 EventsURL: String("e"),
4702 AvatarURL: String("a"),
4703 },
4704 },
4705 Organization: &Organization{
4706 BillingEmail: String("be"),
4707 Blog: String("b"),
4708 Company: String("c"),
4709 Email: String("e"),
4710 TwitterUsername: String("tu"),
4711 Location: String("loc"),
4712 Name: String("n"),
4713 Description: String("d"),
4714 IsVerified: Bool(true),
4715 HasOrganizationProjects: Bool(true),
4716 HasRepositoryProjects: Bool(true),
4717 DefaultRepoPermission: String("drp"),
4718 MembersCanCreateRepos: Bool(true),
4719 MembersCanCreateInternalRepos: Bool(true),
4720 MembersCanCreatePrivateRepos: Bool(true),
4721 MembersCanCreatePublicRepos: Bool(false),
4722 MembersAllowedRepositoryCreationType: String("marct"),
4723 MembersCanCreatePages: Bool(true),
4724 MembersCanCreatePublicPages: Bool(false),
4725 MembersCanCreatePrivatePages: Bool(true),
4726 },
4727 Sender: &User{
4728 Login: String("l"),
4729 ID: Int64(1),
4730 NodeID: String("n"),
4731 URL: String("u"),
4732 ReposURL: String("r"),
4733 EventsURL: String("e"),
4734 AvatarURL: String("a"),
4735 },
4736 Installation: &Installation{
4737 ID: Int64(1),
4738 NodeID: String("nid"),
4739 AppID: Int64(1),
4740 AppSlug: String("as"),
4741 TargetID: Int64(1),
4742 Account: &User{
4743 Login: String("l"),
4744 ID: Int64(1),
4745 URL: String("u"),
4746 AvatarURL: String("a"),
4747 GravatarID: String("g"),
4748 Name: String("n"),
4749 Company: String("c"),
4750 Blog: String("b"),
4751 Location: String("l"),
4752 Email: String("e"),
4753 Hireable: Bool(true),
4754 Bio: String("b"),
4755 TwitterUsername: String("t"),
4756 PublicRepos: Int(1),
4757 Followers: Int(1),
4758 Following: Int(1),
4759 CreatedAt: &Timestamp{referenceTime},
4760 SuspendedAt: &Timestamp{referenceTime},
4761 },
4762 AccessTokensURL: String("atu"),
4763 RepositoriesURL: String("ru"),
4764 HTMLURL: String("hu"),
4765 TargetType: String("tt"),
4766 SingleFileName: String("sfn"),
4767 RepositorySelection: String("rs"),
4768 Events: []string{"e"},
4769 SingleFilePaths: []string{"s"},
4770 Permissions: &InstallationPermissions{
4771 Actions: String("a"),
4772 Administration: String("ad"),
4773 Checks: String("c"),
4774 Contents: String("co"),
4775 ContentReferences: String("cr"),
4776 Deployments: String("d"),
4777 Environments: String("e"),
4778 Issues: String("i"),
4779 Metadata: String("md"),
4780 Members: String("m"),
4781 OrganizationAdministration: String("oa"),
4782 OrganizationHooks: String("oh"),
4783 OrganizationPlan: String("op"),
4784 OrganizationPreReceiveHooks: String("opr"),
4785 OrganizationProjects: String("op"),
4786 OrganizationSecrets: String("os"),
4787 OrganizationSelfHostedRunners: String("osh"),
4788 OrganizationUserBlocking: String("oub"),
4789 Packages: String("pkg"),
4790 Pages: String("pg"),
4791 PullRequests: String("pr"),
4792 RepositoryHooks: String("rh"),
4793 RepositoryProjects: String("rp"),
4794 RepositoryPreReceiveHooks: String("rprh"),
4795 Secrets: String("s"),
4796 SecretScanningAlerts: String("ssa"),
4797 SecurityEvents: String("se"),
4798 SingleFile: String("sf"),
4799 Statuses: String("s"),
4800 TeamDiscussions: String("td"),
4801 VulnerabilityAlerts: String("va"),
4802 Workflows: String("w"),
4803 },
4804 CreatedAt: &Timestamp{referenceTime},
4805 UpdatedAt: &Timestamp{referenceTime},
4806 HasMultipleSingleFiles: Bool(false),
4807 SuspendedBy: &User{
4808 Login: String("l"),
4809 ID: Int64(1),
4810 URL: String("u"),
4811 AvatarURL: String("a"),
4812 GravatarID: String("g"),
4813 Name: String("n"),
4814 Company: String("c"),
4815 Blog: String("b"),
4816 Location: String("l"),
4817 Email: String("e"),
4818 Hireable: Bool(true),
4819 Bio: String("b"),
4820 TwitterUsername: String("t"),
4821 PublicRepos: Int(1),
4822 Followers: Int(1),
4823 Following: Int(1),
4824 CreatedAt: &Timestamp{referenceTime},
4825 SuspendedAt: &Timestamp{referenceTime},
4826 },
4827 SuspendedAt: &Timestamp{referenceTime},
4828 },
4829 }
4830
4831 want := `{
4832 "action": "a",
4833 "invitation": {
4834 "id": 1
4835 },
4836 "membership": {
4837 "url": "url",
4838 "state": "s",
4839 "role": "r",
4840 "organization_url": "ou",
4841 "organization": {
4842 "name": "n",
4843 "company": "c",
4844 "blog": "b",
4845 "location": "loc",
4846 "email": "e",
4847 "twitter_username": "tu",
4848 "description": "d",
4849 "billing_email": "be",
4850 "is_verified": true,
4851 "has_organization_projects": true,
4852 "has_repository_projects": true,
4853 "default_repository_permission": "drp",
4854 "members_can_create_repositories": true,
4855 "members_can_create_public_repositories": false,
4856 "members_can_create_private_repositories": true,
4857 "members_can_create_internal_repositories": true,
4858 "members_allowed_repository_creation_type": "marct",
4859 "members_can_create_pages": true,
4860 "members_can_create_public_pages": false,
4861 "members_can_create_private_pages": true
4862 },
4863 "user": {
4864 "login": "l",
4865 "id": 1,
4866 "node_id": "n",
4867 "avatar_url": "a",
4868 "url": "u",
4869 "events_url": "e",
4870 "repos_url": "r"
4871 }
4872 },
4873 "organization": {
4874 "name": "n",
4875 "company": "c",
4876 "blog": "b",
4877 "location": "loc",
4878 "email": "e",
4879 "twitter_username": "tu",
4880 "description": "d",
4881 "billing_email": "be",
4882 "is_verified": true,
4883 "has_organization_projects": true,
4884 "has_repository_projects": true,
4885 "default_repository_permission": "drp",
4886 "members_can_create_repositories": true,
4887 "members_can_create_public_repositories": false,
4888 "members_can_create_private_repositories": true,
4889 "members_can_create_internal_repositories": true,
4890 "members_allowed_repository_creation_type": "marct",
4891 "members_can_create_pages": true,
4892 "members_can_create_public_pages": false,
4893 "members_can_create_private_pages": true
4894 },
4895 "sender": {
4896 "login": "l",
4897 "id": 1,
4898 "node_id": "n",
4899 "avatar_url": "a",
4900 "url": "u",
4901 "events_url": "e",
4902 "repos_url": "r"
4903 },
4904 "installation": {
4905 "id": 1,
4906 "node_id": "nid",
4907 "app_id": 1,
4908 "app_slug": "as",
4909 "target_id": 1,
4910 "account": {
4911 "login": "l",
4912 "id": 1,
4913 "avatar_url": "a",
4914 "gravatar_id": "g",
4915 "name": "n",
4916 "company": "c",
4917 "blog": "b",
4918 "location": "l",
4919 "email": "e",
4920 "hireable": true,
4921 "bio": "b",
4922 "twitter_username": "t",
4923 "public_repos": 1,
4924 "followers": 1,
4925 "following": 1,
4926 "created_at": ` + referenceTimeStr + `,
4927 "suspended_at": ` + referenceTimeStr + `,
4928 "url": "u"
4929 },
4930 "access_tokens_url": "atu",
4931 "repositories_url": "ru",
4932 "html_url": "hu",
4933 "target_type": "tt",
4934 "single_file_name": "sfn",
4935 "repository_selection": "rs",
4936 "events": [
4937 "e"
4938 ],
4939 "single_file_paths": [
4940 "s"
4941 ],
4942 "permissions": {
4943 "actions": "a",
4944 "administration": "ad",
4945 "checks": "c",
4946 "contents": "co",
4947 "content_references": "cr",
4948 "deployments": "d",
4949 "environments": "e",
4950 "issues": "i",
4951 "metadata": "md",
4952 "members": "m",
4953 "organization_administration": "oa",
4954 "organization_hooks": "oh",
4955 "organization_plan": "op",
4956 "organization_pre_receive_hooks": "opr",
4957 "organization_projects": "op",
4958 "organization_secrets": "os",
4959 "organization_self_hosted_runners": "osh",
4960 "organization_user_blocking": "oub",
4961 "packages": "pkg",
4962 "pages": "pg",
4963 "pull_requests": "pr",
4964 "repository_hooks": "rh",
4965 "repository_projects": "rp",
4966 "repository_pre_receive_hooks": "rprh",
4967 "secrets": "s",
4968 "secret_scanning_alerts": "ssa",
4969 "security_events": "se",
4970 "single_file": "sf",
4971 "statuses": "s",
4972 "team_discussions": "td",
4973 "vulnerability_alerts": "va",
4974 "workflows": "w"
4975 },
4976 "created_at": ` + referenceTimeStr + `,
4977 "updated_at": ` + referenceTimeStr + `,
4978 "has_multiple_single_files": false,
4979 "suspended_by": {
4980 "login": "l",
4981 "id": 1,
4982 "avatar_url": "a",
4983 "gravatar_id": "g",
4984 "name": "n",
4985 "company": "c",
4986 "blog": "b",
4987 "location": "l",
4988 "email": "e",
4989 "hireable": true,
4990 "bio": "b",
4991 "twitter_username": "t",
4992 "public_repos": 1,
4993 "followers": 1,
4994 "following": 1,
4995 "created_at": ` + referenceTimeStr + `,
4996 "suspended_at": ` + referenceTimeStr + `,
4997 "url": "u"
4998 },
4999 "suspended_at": ` + referenceTimeStr + `
5000 }
5001 }`
5002
5003 testJSONMarshal(t, u, want)
5004 }
5005
5006 func TestPageBuildEvent_Marshal(t *testing.T) {
5007 testJSONMarshal(t, &PageBuildEvent{}, "{}")
5008
5009 u := &PageBuildEvent{
5010 Build: &PagesBuild{URL: String("url")},
5011 ID: Int64(1),
5012 Repo: &Repository{
5013 ID: Int64(1),
5014 URL: String("s"),
5015 Name: String("n"),
5016 },
5017 Sender: &User{
5018 Login: String("l"),
5019 ID: Int64(1),
5020 NodeID: String("n"),
5021 URL: String("u"),
5022 ReposURL: String("r"),
5023 EventsURL: String("e"),
5024 AvatarURL: String("a"),
5025 },
5026 Installation: &Installation{
5027 ID: Int64(1),
5028 NodeID: String("nid"),
5029 AppID: Int64(1),
5030 AppSlug: String("as"),
5031 TargetID: Int64(1),
5032 Account: &User{
5033 Login: String("l"),
5034 ID: Int64(1),
5035 URL: String("u"),
5036 AvatarURL: String("a"),
5037 GravatarID: String("g"),
5038 Name: String("n"),
5039 Company: String("c"),
5040 Blog: String("b"),
5041 Location: String("l"),
5042 Email: String("e"),
5043 Hireable: Bool(true),
5044 Bio: String("b"),
5045 TwitterUsername: String("t"),
5046 PublicRepos: Int(1),
5047 Followers: Int(1),
5048 Following: Int(1),
5049 CreatedAt: &Timestamp{referenceTime},
5050 SuspendedAt: &Timestamp{referenceTime},
5051 },
5052 AccessTokensURL: String("atu"),
5053 RepositoriesURL: String("ru"),
5054 HTMLURL: String("hu"),
5055 TargetType: String("tt"),
5056 SingleFileName: String("sfn"),
5057 RepositorySelection: String("rs"),
5058 Events: []string{"e"},
5059 SingleFilePaths: []string{"s"},
5060 Permissions: &InstallationPermissions{
5061 Actions: String("a"),
5062 Administration: String("ad"),
5063 Checks: String("c"),
5064 Contents: String("co"),
5065 ContentReferences: String("cr"),
5066 Deployments: String("d"),
5067 Environments: String("e"),
5068 Issues: String("i"),
5069 Metadata: String("md"),
5070 Members: String("m"),
5071 OrganizationAdministration: String("oa"),
5072 OrganizationHooks: String("oh"),
5073 OrganizationPlan: String("op"),
5074 OrganizationPreReceiveHooks: String("opr"),
5075 OrganizationProjects: String("op"),
5076 OrganizationSecrets: String("os"),
5077 OrganizationSelfHostedRunners: String("osh"),
5078 OrganizationUserBlocking: String("oub"),
5079 Packages: String("pkg"),
5080 Pages: String("pg"),
5081 PullRequests: String("pr"),
5082 RepositoryHooks: String("rh"),
5083 RepositoryProjects: String("rp"),
5084 RepositoryPreReceiveHooks: String("rprh"),
5085 Secrets: String("s"),
5086 SecretScanningAlerts: String("ssa"),
5087 SecurityEvents: String("se"),
5088 SingleFile: String("sf"),
5089 Statuses: String("s"),
5090 TeamDiscussions: String("td"),
5091 VulnerabilityAlerts: String("va"),
5092 Workflows: String("w"),
5093 },
5094 CreatedAt: &Timestamp{referenceTime},
5095 UpdatedAt: &Timestamp{referenceTime},
5096 HasMultipleSingleFiles: Bool(false),
5097 SuspendedBy: &User{
5098 Login: String("l"),
5099 ID: Int64(1),
5100 URL: String("u"),
5101 AvatarURL: String("a"),
5102 GravatarID: String("g"),
5103 Name: String("n"),
5104 Company: String("c"),
5105 Blog: String("b"),
5106 Location: String("l"),
5107 Email: String("e"),
5108 Hireable: Bool(true),
5109 Bio: String("b"),
5110 TwitterUsername: String("t"),
5111 PublicRepos: Int(1),
5112 Followers: Int(1),
5113 Following: Int(1),
5114 CreatedAt: &Timestamp{referenceTime},
5115 SuspendedAt: &Timestamp{referenceTime},
5116 },
5117 SuspendedAt: &Timestamp{referenceTime},
5118 },
5119 }
5120
5121 want := `{
5122 "build": {
5123 "url": "url"
5124 },
5125 "id": 1,
5126 "repository": {
5127 "id": 1,
5128 "name": "n",
5129 "url": "s"
5130 },
5131 "sender": {
5132 "login": "l",
5133 "id": 1,
5134 "node_id": "n",
5135 "avatar_url": "a",
5136 "url": "u",
5137 "events_url": "e",
5138 "repos_url": "r"
5139 },
5140 "installation": {
5141 "id": 1,
5142 "node_id": "nid",
5143 "app_id": 1,
5144 "app_slug": "as",
5145 "target_id": 1,
5146 "account": {
5147 "login": "l",
5148 "id": 1,
5149 "avatar_url": "a",
5150 "gravatar_id": "g",
5151 "name": "n",
5152 "company": "c",
5153 "blog": "b",
5154 "location": "l",
5155 "email": "e",
5156 "hireable": true,
5157 "bio": "b",
5158 "twitter_username": "t",
5159 "public_repos": 1,
5160 "followers": 1,
5161 "following": 1,
5162 "created_at": ` + referenceTimeStr + `,
5163 "suspended_at": ` + referenceTimeStr + `,
5164 "url": "u"
5165 },
5166 "access_tokens_url": "atu",
5167 "repositories_url": "ru",
5168 "html_url": "hu",
5169 "target_type": "tt",
5170 "single_file_name": "sfn",
5171 "repository_selection": "rs",
5172 "events": [
5173 "e"
5174 ],
5175 "single_file_paths": [
5176 "s"
5177 ],
5178 "permissions": {
5179 "actions": "a",
5180 "administration": "ad",
5181 "checks": "c",
5182 "contents": "co",
5183 "content_references": "cr",
5184 "deployments": "d",
5185 "environments": "e",
5186 "issues": "i",
5187 "metadata": "md",
5188 "members": "m",
5189 "organization_administration": "oa",
5190 "organization_hooks": "oh",
5191 "organization_plan": "op",
5192 "organization_pre_receive_hooks": "opr",
5193 "organization_projects": "op",
5194 "organization_secrets": "os",
5195 "organization_self_hosted_runners": "osh",
5196 "organization_user_blocking": "oub",
5197 "packages": "pkg",
5198 "pages": "pg",
5199 "pull_requests": "pr",
5200 "repository_hooks": "rh",
5201 "repository_projects": "rp",
5202 "repository_pre_receive_hooks": "rprh",
5203 "secrets": "s",
5204 "secret_scanning_alerts": "ssa",
5205 "security_events": "se",
5206 "single_file": "sf",
5207 "statuses": "s",
5208 "team_discussions": "td",
5209 "vulnerability_alerts": "va",
5210 "workflows": "w"
5211 },
5212 "created_at": ` + referenceTimeStr + `,
5213 "updated_at": ` + referenceTimeStr + `,
5214 "has_multiple_single_files": false,
5215 "suspended_by": {
5216 "login": "l",
5217 "id": 1,
5218 "avatar_url": "a",
5219 "gravatar_id": "g",
5220 "name": "n",
5221 "company": "c",
5222 "blog": "b",
5223 "location": "l",
5224 "email": "e",
5225 "hireable": true,
5226 "bio": "b",
5227 "twitter_username": "t",
5228 "public_repos": 1,
5229 "followers": 1,
5230 "following": 1,
5231 "created_at": ` + referenceTimeStr + `,
5232 "suspended_at": ` + referenceTimeStr + `,
5233 "url": "u"
5234 },
5235 "suspended_at": ` + referenceTimeStr + `
5236 }
5237 }`
5238
5239 testJSONMarshal(t, u, want)
5240 }
5241
5242 func TestCommitCommentEvent_Marshal(t *testing.T) {
5243 testJSONMarshal(t, &CommitCommentEvent{}, "{}")
5244
5245 u := &CommitCommentEvent{
5246 Comment: &RepositoryComment{
5247 HTMLURL: String("hurl"),
5248 URL: String("url"),
5249 ID: Int64(1),
5250 NodeID: String("nid"),
5251 CommitID: String("cid"),
5252 User: &User{
5253 Login: String("l"),
5254 ID: Int64(1),
5255 NodeID: String("n"),
5256 URL: String("u"),
5257 ReposURL: String("r"),
5258 EventsURL: String("e"),
5259 AvatarURL: String("a"),
5260 },
5261 Reactions: &Reactions{
5262 TotalCount: Int(1),
5263 PlusOne: Int(1),
5264 MinusOne: Int(1),
5265 Laugh: Int(1),
5266 Confused: Int(1),
5267 Heart: Int(1),
5268 Hooray: Int(1),
5269 Rocket: Int(1),
5270 Eyes: Int(1),
5271 URL: String("url"),
5272 },
5273 CreatedAt: &Timestamp{referenceTime},
5274 UpdatedAt: &Timestamp{referenceTime},
5275 Body: String("b"),
5276 Path: String("path"),
5277 Position: Int(1),
5278 },
5279 Action: String("a"),
5280 Repo: &Repository{
5281 ID: Int64(1),
5282 URL: String("s"),
5283 Name: String("n"),
5284 },
5285 Sender: &User{
5286 Login: String("l"),
5287 ID: Int64(1),
5288 NodeID: String("n"),
5289 URL: String("u"),
5290 ReposURL: String("r"),
5291 EventsURL: String("e"),
5292 AvatarURL: String("a"),
5293 },
5294 Installation: &Installation{
5295 ID: Int64(1),
5296 NodeID: String("nid"),
5297 AppID: Int64(1),
5298 AppSlug: String("as"),
5299 TargetID: Int64(1),
5300 Account: &User{
5301 Login: String("l"),
5302 ID: Int64(1),
5303 URL: String("u"),
5304 AvatarURL: String("a"),
5305 GravatarID: String("g"),
5306 Name: String("n"),
5307 Company: String("c"),
5308 Blog: String("b"),
5309 Location: String("l"),
5310 Email: String("e"),
5311 Hireable: Bool(true),
5312 Bio: String("b"),
5313 TwitterUsername: String("t"),
5314 PublicRepos: Int(1),
5315 Followers: Int(1),
5316 Following: Int(1),
5317 CreatedAt: &Timestamp{referenceTime},
5318 SuspendedAt: &Timestamp{referenceTime},
5319 },
5320 AccessTokensURL: String("atu"),
5321 RepositoriesURL: String("ru"),
5322 HTMLURL: String("hu"),
5323 TargetType: String("tt"),
5324 SingleFileName: String("sfn"),
5325 RepositorySelection: String("rs"),
5326 Events: []string{"e"},
5327 SingleFilePaths: []string{"s"},
5328 Permissions: &InstallationPermissions{
5329 Actions: String("a"),
5330 Administration: String("ad"),
5331 Checks: String("c"),
5332 Contents: String("co"),
5333 ContentReferences: String("cr"),
5334 Deployments: String("d"),
5335 Environments: String("e"),
5336 Issues: String("i"),
5337 Metadata: String("md"),
5338 Members: String("m"),
5339 OrganizationAdministration: String("oa"),
5340 OrganizationHooks: String("oh"),
5341 OrganizationPlan: String("op"),
5342 OrganizationPreReceiveHooks: String("opr"),
5343 OrganizationProjects: String("op"),
5344 OrganizationSecrets: String("os"),
5345 OrganizationSelfHostedRunners: String("osh"),
5346 OrganizationUserBlocking: String("oub"),
5347 Packages: String("pkg"),
5348 Pages: String("pg"),
5349 PullRequests: String("pr"),
5350 RepositoryHooks: String("rh"),
5351 RepositoryProjects: String("rp"),
5352 RepositoryPreReceiveHooks: String("rprh"),
5353 Secrets: String("s"),
5354 SecretScanningAlerts: String("ssa"),
5355 SecurityEvents: String("se"),
5356 SingleFile: String("sf"),
5357 Statuses: String("s"),
5358 TeamDiscussions: String("td"),
5359 VulnerabilityAlerts: String("va"),
5360 Workflows: String("w"),
5361 },
5362 CreatedAt: &Timestamp{referenceTime},
5363 UpdatedAt: &Timestamp{referenceTime},
5364 HasMultipleSingleFiles: Bool(false),
5365 SuspendedBy: &User{
5366 Login: String("l"),
5367 ID: Int64(1),
5368 URL: String("u"),
5369 AvatarURL: String("a"),
5370 GravatarID: String("g"),
5371 Name: String("n"),
5372 Company: String("c"),
5373 Blog: String("b"),
5374 Location: String("l"),
5375 Email: String("e"),
5376 Hireable: Bool(true),
5377 Bio: String("b"),
5378 TwitterUsername: String("t"),
5379 PublicRepos: Int(1),
5380 Followers: Int(1),
5381 Following: Int(1),
5382 CreatedAt: &Timestamp{referenceTime},
5383 SuspendedAt: &Timestamp{referenceTime},
5384 },
5385 SuspendedAt: &Timestamp{referenceTime},
5386 },
5387 }
5388
5389 want := `{
5390 "comment": {
5391 "html_url": "hurl",
5392 "url": "url",
5393 "id": 1,
5394 "node_id": "nid",
5395 "commit_id": "cid",
5396 "user": {
5397 "login": "l",
5398 "id": 1,
5399 "node_id": "n",
5400 "avatar_url": "a",
5401 "url": "u",
5402 "events_url": "e",
5403 "repos_url": "r"
5404 },
5405 "reactions": {
5406 "total_count": 1,
5407 "+1": 1,
5408 "-1": 1,
5409 "laugh": 1,
5410 "confused": 1,
5411 "heart": 1,
5412 "hooray": 1,
5413 "rocket": 1,
5414 "eyes": 1,
5415 "url": "url"
5416 },
5417 "created_at": ` + referenceTimeStr + `,
5418 "updated_at": ` + referenceTimeStr + `,
5419 "body": "b",
5420 "path": "path",
5421 "position": 1
5422 },
5423 "action": "a",
5424 "repository": {
5425 "id": 1,
5426 "name": "n",
5427 "url": "s"
5428 },
5429 "sender": {
5430 "login": "l",
5431 "id": 1,
5432 "node_id": "n",
5433 "avatar_url": "a",
5434 "url": "u",
5435 "events_url": "e",
5436 "repos_url": "r"
5437 },
5438 "installation": {
5439 "id": 1,
5440 "node_id": "nid",
5441 "app_id": 1,
5442 "app_slug": "as",
5443 "target_id": 1,
5444 "account": {
5445 "login": "l",
5446 "id": 1,
5447 "avatar_url": "a",
5448 "gravatar_id": "g",
5449 "name": "n",
5450 "company": "c",
5451 "blog": "b",
5452 "location": "l",
5453 "email": "e",
5454 "hireable": true,
5455 "bio": "b",
5456 "twitter_username": "t",
5457 "public_repos": 1,
5458 "followers": 1,
5459 "following": 1,
5460 "created_at": ` + referenceTimeStr + `,
5461 "suspended_at": ` + referenceTimeStr + `,
5462 "url": "u"
5463 },
5464 "access_tokens_url": "atu",
5465 "repositories_url": "ru",
5466 "html_url": "hu",
5467 "target_type": "tt",
5468 "single_file_name": "sfn",
5469 "repository_selection": "rs",
5470 "events": [
5471 "e"
5472 ],
5473 "single_file_paths": [
5474 "s"
5475 ],
5476 "permissions": {
5477 "actions": "a",
5478 "administration": "ad",
5479 "checks": "c",
5480 "contents": "co",
5481 "content_references": "cr",
5482 "deployments": "d",
5483 "environments": "e",
5484 "issues": "i",
5485 "metadata": "md",
5486 "members": "m",
5487 "organization_administration": "oa",
5488 "organization_hooks": "oh",
5489 "organization_plan": "op",
5490 "organization_pre_receive_hooks": "opr",
5491 "organization_projects": "op",
5492 "organization_secrets": "os",
5493 "organization_self_hosted_runners": "osh",
5494 "organization_user_blocking": "oub",
5495 "packages": "pkg",
5496 "pages": "pg",
5497 "pull_requests": "pr",
5498 "repository_hooks": "rh",
5499 "repository_projects": "rp",
5500 "repository_pre_receive_hooks": "rprh",
5501 "secrets": "s",
5502 "secret_scanning_alerts": "ssa",
5503 "security_events": "se",
5504 "single_file": "sf",
5505 "statuses": "s",
5506 "team_discussions": "td",
5507 "vulnerability_alerts": "va",
5508 "workflows": "w"
5509 },
5510 "created_at": ` + referenceTimeStr + `,
5511 "updated_at": ` + referenceTimeStr + `,
5512 "has_multiple_single_files": false,
5513 "suspended_by": {
5514 "login": "l",
5515 "id": 1,
5516 "avatar_url": "a",
5517 "gravatar_id": "g",
5518 "name": "n",
5519 "company": "c",
5520 "blog": "b",
5521 "location": "l",
5522 "email": "e",
5523 "hireable": true,
5524 "bio": "b",
5525 "twitter_username": "t",
5526 "public_repos": 1,
5527 "followers": 1,
5528 "following": 1,
5529 "created_at": ` + referenceTimeStr + `,
5530 "suspended_at": ` + referenceTimeStr + `,
5531 "url": "u"
5532 },
5533 "suspended_at": ` + referenceTimeStr + `
5534 }
5535 }`
5536
5537 testJSONMarshal(t, u, want)
5538 }
5539
5540 func TestDeploymentEvent_Marshal(t *testing.T) {
5541 testJSONMarshal(t, &DeploymentEvent{}, "{}")
5542
5543 l := make(map[string]interface{})
5544 l["key"] = "value"
5545
5546 jsonMsg, _ := json.Marshal(&l)
5547
5548 u := &DeploymentEvent{
5549 Deployment: &Deployment{
5550 URL: String("url"),
5551 ID: Int64(1),
5552 SHA: String("sha"),
5553 Ref: String("ref"),
5554 Task: String("t"),
5555 Payload: jsonMsg,
5556 Environment: String("e"),
5557 Description: String("d"),
5558 Creator: &User{
5559 Login: String("l"),
5560 ID: Int64(1),
5561 NodeID: String("n"),
5562 URL: String("u"),
5563 ReposURL: String("r"),
5564 EventsURL: String("e"),
5565 AvatarURL: String("a"),
5566 },
5567 CreatedAt: &Timestamp{referenceTime},
5568 UpdatedAt: &Timestamp{referenceTime},
5569 StatusesURL: String("surl"),
5570 RepositoryURL: String("rurl"),
5571 NodeID: String("nid"),
5572 },
5573 Repo: &Repository{
5574 ID: Int64(1),
5575 URL: String("s"),
5576 Name: String("n"),
5577 },
5578 Sender: &User{
5579 Login: String("l"),
5580 ID: Int64(1),
5581 NodeID: String("n"),
5582 URL: String("u"),
5583 ReposURL: String("r"),
5584 EventsURL: String("e"),
5585 AvatarURL: String("a"),
5586 },
5587 Installation: &Installation{
5588 ID: Int64(1),
5589 NodeID: String("nid"),
5590 AppID: Int64(1),
5591 AppSlug: String("as"),
5592 TargetID: Int64(1),
5593 Account: &User{
5594 Login: String("l"),
5595 ID: Int64(1),
5596 URL: String("u"),
5597 AvatarURL: String("a"),
5598 GravatarID: String("g"),
5599 Name: String("n"),
5600 Company: String("c"),
5601 Blog: String("b"),
5602 Location: String("l"),
5603 Email: String("e"),
5604 Hireable: Bool(true),
5605 Bio: String("b"),
5606 TwitterUsername: String("t"),
5607 PublicRepos: Int(1),
5608 Followers: Int(1),
5609 Following: Int(1),
5610 CreatedAt: &Timestamp{referenceTime},
5611 SuspendedAt: &Timestamp{referenceTime},
5612 },
5613 AccessTokensURL: String("atu"),
5614 RepositoriesURL: String("ru"),
5615 HTMLURL: String("hu"),
5616 TargetType: String("tt"),
5617 SingleFileName: String("sfn"),
5618 RepositorySelection: String("rs"),
5619 Events: []string{"e"},
5620 SingleFilePaths: []string{"s"},
5621 Permissions: &InstallationPermissions{
5622 Actions: String("a"),
5623 Administration: String("ad"),
5624 Checks: String("c"),
5625 Contents: String("co"),
5626 ContentReferences: String("cr"),
5627 Deployments: String("d"),
5628 Environments: String("e"),
5629 Issues: String("i"),
5630 Metadata: String("md"),
5631 Members: String("m"),
5632 OrganizationAdministration: String("oa"),
5633 OrganizationHooks: String("oh"),
5634 OrganizationPlan: String("op"),
5635 OrganizationPreReceiveHooks: String("opr"),
5636 OrganizationProjects: String("op"),
5637 OrganizationSecrets: String("os"),
5638 OrganizationSelfHostedRunners: String("osh"),
5639 OrganizationUserBlocking: String("oub"),
5640 Packages: String("pkg"),
5641 Pages: String("pg"),
5642 PullRequests: String("pr"),
5643 RepositoryHooks: String("rh"),
5644 RepositoryProjects: String("rp"),
5645 RepositoryPreReceiveHooks: String("rprh"),
5646 Secrets: String("s"),
5647 SecretScanningAlerts: String("ssa"),
5648 SecurityEvents: String("se"),
5649 SingleFile: String("sf"),
5650 Statuses: String("s"),
5651 TeamDiscussions: String("td"),
5652 VulnerabilityAlerts: String("va"),
5653 Workflows: String("w"),
5654 },
5655 CreatedAt: &Timestamp{referenceTime},
5656 UpdatedAt: &Timestamp{referenceTime},
5657 HasMultipleSingleFiles: Bool(false),
5658 SuspendedBy: &User{
5659 Login: String("l"),
5660 ID: Int64(1),
5661 URL: String("u"),
5662 AvatarURL: String("a"),
5663 GravatarID: String("g"),
5664 Name: String("n"),
5665 Company: String("c"),
5666 Blog: String("b"),
5667 Location: String("l"),
5668 Email: String("e"),
5669 Hireable: Bool(true),
5670 Bio: String("b"),
5671 TwitterUsername: String("t"),
5672 PublicRepos: Int(1),
5673 Followers: Int(1),
5674 Following: Int(1),
5675 CreatedAt: &Timestamp{referenceTime},
5676 SuspendedAt: &Timestamp{referenceTime},
5677 },
5678 SuspendedAt: &Timestamp{referenceTime},
5679 },
5680 Workflow: &Workflow{
5681 ID: Int64(1),
5682 NodeID: String("nid"),
5683 Name: String("n"),
5684 Path: String("p"),
5685 State: String("s"),
5686 CreatedAt: &Timestamp{referenceTime},
5687 UpdatedAt: &Timestamp{referenceTime},
5688 URL: String("u"),
5689 HTMLURL: String("h"),
5690 BadgeURL: String("b"),
5691 },
5692 WorkflowRun: &WorkflowRun{
5693 ID: Int64(1),
5694 Name: String("n"),
5695 NodeID: String("nid"),
5696 HeadBranch: String("hb"),
5697 HeadSHA: String("hs"),
5698 RunNumber: Int(1),
5699 RunAttempt: Int(1),
5700 Event: String("e"),
5701 Status: String("s"),
5702 Conclusion: String("c"),
5703 WorkflowID: Int64(1),
5704 URL: String("u"),
5705 HTMLURL: String("h"),
5706 PullRequests: []*PullRequest{
5707 {
5708 URL: String("u"),
5709 ID: Int64(1),
5710 Number: Int(1),
5711 Head: &PullRequestBranch{
5712 Ref: String("r"),
5713 SHA: String("s"),
5714 Repo: &Repository{
5715 ID: Int64(1),
5716 URL: String("s"),
5717 Name: String("n"),
5718 },
5719 },
5720 Base: &PullRequestBranch{
5721 Ref: String("r"),
5722 SHA: String("s"),
5723 Repo: &Repository{
5724 ID: Int64(1),
5725 URL: String("u"),
5726 Name: String("n"),
5727 },
5728 },
5729 },
5730 },
5731 CreatedAt: &Timestamp{referenceTime},
5732 UpdatedAt: &Timestamp{referenceTime},
5733 RunStartedAt: &Timestamp{referenceTime},
5734 JobsURL: String("j"),
5735 LogsURL: String("l"),
5736 CheckSuiteURL: String("c"),
5737 ArtifactsURL: String("a"),
5738 CancelURL: String("c"),
5739 RerunURL: String("r"),
5740 PreviousAttemptURL: String("p"),
5741 HeadCommit: &HeadCommit{
5742 Message: String("m"),
5743 Author: &CommitAuthor{
5744 Name: String("n"),
5745 Email: String("e"),
5746 Login: String("l"),
5747 },
5748 URL: String("u"),
5749 Distinct: Bool(false),
5750 SHA: String("s"),
5751 ID: String("i"),
5752 TreeID: String("tid"),
5753 Timestamp: &Timestamp{referenceTime},
5754 Committer: &CommitAuthor{
5755 Name: String("n"),
5756 Email: String("e"),
5757 Login: String("l"),
5758 },
5759 },
5760 WorkflowURL: String("w"),
5761 Repository: &Repository{
5762 ID: Int64(1),
5763 URL: String("u"),
5764 Name: String("n"),
5765 },
5766 HeadRepository: &Repository{
5767 ID: Int64(1),
5768 URL: String("u"),
5769 Name: String("n"),
5770 },
5771 },
5772 }
5773
5774 want := `{
5775 "deployment": {
5776 "url": "url",
5777 "id": 1,
5778 "sha": "sha",
5779 "ref": "ref",
5780 "task": "t",
5781 "payload": {
5782 "key": "value"
5783 },
5784 "environment": "e",
5785 "description": "d",
5786 "creator": {
5787 "login": "l",
5788 "id": 1,
5789 "node_id": "n",
5790 "avatar_url": "a",
5791 "url": "u",
5792 "events_url": "e",
5793 "repos_url": "r"
5794 },
5795 "created_at": ` + referenceTimeStr + `,
5796 "updated_at": ` + referenceTimeStr + `,
5797 "statuses_url": "surl",
5798 "repository_url": "rurl",
5799 "node_id": "nid"
5800 },
5801 "repository": {
5802 "id": 1,
5803 "name": "n",
5804 "url": "s"
5805 },
5806 "sender": {
5807 "login": "l",
5808 "id": 1,
5809 "node_id": "n",
5810 "avatar_url": "a",
5811 "url": "u",
5812 "events_url": "e",
5813 "repos_url": "r"
5814 },
5815 "installation": {
5816 "id": 1,
5817 "node_id": "nid",
5818 "app_id": 1,
5819 "app_slug": "as",
5820 "target_id": 1,
5821 "account": {
5822 "login": "l",
5823 "id": 1,
5824 "avatar_url": "a",
5825 "gravatar_id": "g",
5826 "name": "n",
5827 "company": "c",
5828 "blog": "b",
5829 "location": "l",
5830 "email": "e",
5831 "hireable": true,
5832 "bio": "b",
5833 "twitter_username": "t",
5834 "public_repos": 1,
5835 "followers": 1,
5836 "following": 1,
5837 "created_at": ` + referenceTimeStr + `,
5838 "suspended_at": ` + referenceTimeStr + `,
5839 "url": "u"
5840 },
5841 "access_tokens_url": "atu",
5842 "repositories_url": "ru",
5843 "html_url": "hu",
5844 "target_type": "tt",
5845 "single_file_name": "sfn",
5846 "repository_selection": "rs",
5847 "events": [
5848 "e"
5849 ],
5850 "single_file_paths": [
5851 "s"
5852 ],
5853 "permissions": {
5854 "actions": "a",
5855 "administration": "ad",
5856 "checks": "c",
5857 "contents": "co",
5858 "content_references": "cr",
5859 "deployments": "d",
5860 "environments": "e",
5861 "issues": "i",
5862 "metadata": "md",
5863 "members": "m",
5864 "organization_administration": "oa",
5865 "organization_hooks": "oh",
5866 "organization_plan": "op",
5867 "organization_pre_receive_hooks": "opr",
5868 "organization_projects": "op",
5869 "organization_secrets": "os",
5870 "organization_self_hosted_runners": "osh",
5871 "organization_user_blocking": "oub",
5872 "packages": "pkg",
5873 "pages": "pg",
5874 "pull_requests": "pr",
5875 "repository_hooks": "rh",
5876 "repository_projects": "rp",
5877 "repository_pre_receive_hooks": "rprh",
5878 "secrets": "s",
5879 "secret_scanning_alerts": "ssa",
5880 "security_events": "se",
5881 "single_file": "sf",
5882 "statuses": "s",
5883 "team_discussions": "td",
5884 "vulnerability_alerts": "va",
5885 "workflows": "w"
5886 },
5887 "created_at": ` + referenceTimeStr + `,
5888 "updated_at": ` + referenceTimeStr + `,
5889 "has_multiple_single_files": false,
5890 "suspended_by": {
5891 "login": "l",
5892 "id": 1,
5893 "avatar_url": "a",
5894 "gravatar_id": "g",
5895 "name": "n",
5896 "company": "c",
5897 "blog": "b",
5898 "location": "l",
5899 "email": "e",
5900 "hireable": true,
5901 "bio": "b",
5902 "twitter_username": "t",
5903 "public_repos": 1,
5904 "followers": 1,
5905 "following": 1,
5906 "created_at": ` + referenceTimeStr + `,
5907 "suspended_at": ` + referenceTimeStr + `,
5908 "url": "u"
5909 },
5910 "suspended_at": ` + referenceTimeStr + `
5911 },
5912 "workflow": {
5913 "id": 1,
5914 "node_id": "nid",
5915 "name": "n",
5916 "path": "p",
5917 "state": "s",
5918 "created_at": ` + referenceTimeStr + `,
5919 "updated_at": ` + referenceTimeStr + `,
5920 "url": "u",
5921 "html_url": "h",
5922 "badge_url": "b"
5923 },
5924 "workflow_run": {
5925 "id": 1,
5926 "name": "n",
5927 "node_id": "nid",
5928 "head_branch": "hb",
5929 "head_sha": "hs",
5930 "run_number": 1,
5931 "run_attempt": 1,
5932 "event": "e",
5933 "status": "s",
5934 "conclusion": "c",
5935 "workflow_id": 1,
5936 "url": "u",
5937 "html_url": "h",
5938 "pull_requests": [
5939 {
5940 "id": 1,
5941 "number": 1,
5942 "url": "u",
5943 "head": {
5944 "ref": "r",
5945 "sha": "s",
5946 "repo": {
5947 "id": 1,
5948 "name": "n",
5949 "url": "s"
5950 }
5951 },
5952 "base": {
5953 "ref": "r",
5954 "sha": "s",
5955 "repo": {
5956 "id": 1,
5957 "name": "n",
5958 "url": "u"
5959 }
5960 }
5961 }
5962 ],
5963 "created_at": ` + referenceTimeStr + `,
5964 "updated_at": ` + referenceTimeStr + `,
5965 "run_started_at": ` + referenceTimeStr + `,
5966 "jobs_url": "j",
5967 "logs_url": "l",
5968 "check_suite_url": "c",
5969 "artifacts_url": "a",
5970 "cancel_url": "c",
5971 "rerun_url": "r",
5972 "previous_attempt_url": "p",
5973 "head_commit": {
5974 "message": "m",
5975 "author": {
5976 "name": "n",
5977 "email": "e",
5978 "username": "l"
5979 },
5980 "url": "u",
5981 "distinct": false,
5982 "sha": "s",
5983 "id": "i",
5984 "tree_id": "tid",
5985 "timestamp": ` + referenceTimeStr + `,
5986 "committer": {
5987 "name": "n",
5988 "email": "e",
5989 "username": "l"
5990 }
5991 },
5992 "workflow_url": "w",
5993 "repository": {
5994 "id": 1,
5995 "name": "n",
5996 "url": "u"
5997 },
5998 "head_repository": {
5999 "id": 1,
6000 "name": "n",
6001 "url": "u"
6002 }
6003 }
6004 }`
6005
6006 testJSONMarshal(t, u, want)
6007 }
6008
6009 func TestDeploymentProtectionRuleEvent_Marshal(t *testing.T) {
6010 testJSONMarshal(t, &DeploymentProtectionRuleEvent{}, "{}")
6011
6012 l := make(map[string]interface{})
6013 l["key"] = "value"
6014
6015 jsonMsg, _ := json.Marshal(&l)
6016
6017 u := &DeploymentProtectionRuleEvent{
6018 Action: String("a"),
6019 Environment: String("e"),
6020 DeploymentCallbackURL: String("b"),
6021 Deployment: &Deployment{
6022 URL: String("url"),
6023 ID: Int64(1),
6024 SHA: String("sha"),
6025 Ref: String("ref"),
6026 Task: String("t"),
6027 Payload: jsonMsg,
6028 Environment: String("e"),
6029 Description: String("d"),
6030 Creator: &User{
6031 Login: String("l"),
6032 ID: Int64(1),
6033 NodeID: String("n"),
6034 URL: String("u"),
6035 ReposURL: String("r"),
6036 EventsURL: String("e"),
6037 AvatarURL: String("a"),
6038 },
6039 CreatedAt: &Timestamp{referenceTime},
6040 UpdatedAt: &Timestamp{referenceTime},
6041 StatusesURL: String("surl"),
6042 RepositoryURL: String("rurl"),
6043 NodeID: String("nid"),
6044 },
6045 Repo: &Repository{
6046 ID: Int64(1),
6047 URL: String("s"),
6048 Name: String("n"),
6049 },
6050 Organization: &Organization{
6051 BillingEmail: String("be"),
6052 Blog: String("b"),
6053 Company: String("c"),
6054 Email: String("e"),
6055 TwitterUsername: String("tu"),
6056 Location: String("loc"),
6057 Name: String("n"),
6058 Description: String("d"),
6059 IsVerified: Bool(true),
6060 HasOrganizationProjects: Bool(true),
6061 HasRepositoryProjects: Bool(true),
6062 DefaultRepoPermission: String("drp"),
6063 MembersCanCreateRepos: Bool(true),
6064 MembersCanCreateInternalRepos: Bool(true),
6065 MembersCanCreatePrivateRepos: Bool(true),
6066 MembersCanCreatePublicRepos: Bool(false),
6067 MembersAllowedRepositoryCreationType: String("marct"),
6068 MembersCanCreatePages: Bool(true),
6069 MembersCanCreatePublicPages: Bool(false),
6070 MembersCanCreatePrivatePages: Bool(true),
6071 },
6072 PullRequests: []*PullRequest{
6073 {
6074 URL: String("u"),
6075 ID: Int64(1),
6076 Number: Int(1),
6077 Head: &PullRequestBranch{
6078 Ref: String("r"),
6079 SHA: String("s"),
6080 Repo: &Repository{
6081 ID: Int64(1),
6082 URL: String("s"),
6083 Name: String("n"),
6084 },
6085 },
6086 Base: &PullRequestBranch{
6087 Ref: String("r"),
6088 SHA: String("s"),
6089 Repo: &Repository{
6090 ID: Int64(1),
6091 URL: String("u"),
6092 Name: String("n"),
6093 },
6094 },
6095 },
6096 },
6097 Sender: &User{
6098 Login: String("l"),
6099 ID: Int64(1),
6100 NodeID: String("n"),
6101 URL: String("u"),
6102 ReposURL: String("r"),
6103 EventsURL: String("e"),
6104 AvatarURL: String("a"),
6105 },
6106 Installation: &Installation{
6107 ID: Int64(1),
6108 NodeID: String("nid"),
6109 AppID: Int64(1),
6110 AppSlug: String("as"),
6111 TargetID: Int64(1),
6112 Account: &User{
6113 Login: String("l"),
6114 ID: Int64(1),
6115 URL: String("u"),
6116 AvatarURL: String("a"),
6117 GravatarID: String("g"),
6118 Name: String("n"),
6119 Company: String("c"),
6120 Blog: String("b"),
6121 Location: String("l"),
6122 Email: String("e"),
6123 Hireable: Bool(true),
6124 Bio: String("b"),
6125 TwitterUsername: String("t"),
6126 PublicRepos: Int(1),
6127 Followers: Int(1),
6128 Following: Int(1),
6129 CreatedAt: &Timestamp{referenceTime},
6130 SuspendedAt: &Timestamp{referenceTime},
6131 },
6132 AccessTokensURL: String("atu"),
6133 RepositoriesURL: String("ru"),
6134 HTMLURL: String("hu"),
6135 TargetType: String("tt"),
6136 SingleFileName: String("sfn"),
6137 RepositorySelection: String("rs"),
6138 Events: []string{"e"},
6139 SingleFilePaths: []string{"s"},
6140 Permissions: &InstallationPermissions{
6141 Actions: String("a"),
6142 Administration: String("ad"),
6143 Checks: String("c"),
6144 Contents: String("co"),
6145 ContentReferences: String("cr"),
6146 Deployments: String("d"),
6147 Environments: String("e"),
6148 Issues: String("i"),
6149 Metadata: String("md"),
6150 Members: String("m"),
6151 OrganizationAdministration: String("oa"),
6152 OrganizationHooks: String("oh"),
6153 OrganizationPlan: String("op"),
6154 OrganizationPreReceiveHooks: String("opr"),
6155 OrganizationProjects: String("op"),
6156 OrganizationSecrets: String("os"),
6157 OrganizationSelfHostedRunners: String("osh"),
6158 OrganizationUserBlocking: String("oub"),
6159 Packages: String("pkg"),
6160 Pages: String("pg"),
6161 PullRequests: String("pr"),
6162 RepositoryHooks: String("rh"),
6163 RepositoryProjects: String("rp"),
6164 RepositoryPreReceiveHooks: String("rprh"),
6165 Secrets: String("s"),
6166 SecretScanningAlerts: String("ssa"),
6167 SecurityEvents: String("se"),
6168 SingleFile: String("sf"),
6169 Statuses: String("s"),
6170 TeamDiscussions: String("td"),
6171 VulnerabilityAlerts: String("va"),
6172 Workflows: String("w"),
6173 },
6174 CreatedAt: &Timestamp{referenceTime},
6175 UpdatedAt: &Timestamp{referenceTime},
6176 HasMultipleSingleFiles: Bool(false),
6177 SuspendedBy: &User{
6178 Login: String("l"),
6179 ID: Int64(1),
6180 URL: String("u"),
6181 AvatarURL: String("a"),
6182 GravatarID: String("g"),
6183 Name: String("n"),
6184 Company: String("c"),
6185 Blog: String("b"),
6186 Location: String("l"),
6187 Email: String("e"),
6188 Hireable: Bool(true),
6189 Bio: String("b"),
6190 TwitterUsername: String("t"),
6191 PublicRepos: Int(1),
6192 Followers: Int(1),
6193 Following: Int(1),
6194 CreatedAt: &Timestamp{referenceTime},
6195 SuspendedAt: &Timestamp{referenceTime},
6196 },
6197 SuspendedAt: &Timestamp{referenceTime},
6198 },
6199 }
6200
6201 want := `{
6202 "action": "a",
6203 "environment": "e",
6204 "deployment_callback_url": "b",
6205 "deployment": {
6206 "url": "url",
6207 "id": 1,
6208 "sha": "sha",
6209 "ref": "ref",
6210 "task": "t",
6211 "payload": {
6212 "key": "value"
6213 },
6214 "environment": "e",
6215 "description": "d",
6216 "creator": {
6217 "login": "l",
6218 "id": 1,
6219 "node_id": "n",
6220 "avatar_url": "a",
6221 "url": "u",
6222 "events_url": "e",
6223 "repos_url": "r"
6224 },
6225 "created_at": ` + referenceTimeStr + `,
6226 "updated_at": ` + referenceTimeStr + `,
6227 "statuses_url": "surl",
6228 "repository_url": "rurl",
6229 "node_id": "nid"
6230 },
6231 "repository": {
6232 "id": 1,
6233 "name": "n",
6234 "url": "s"
6235 },
6236 "organization": {
6237 "name": "n",
6238 "company": "c",
6239 "blog": "b",
6240 "location": "loc",
6241 "email": "e",
6242 "twitter_username": "tu",
6243 "description": "d",
6244 "billing_email": "be",
6245 "is_verified": true,
6246 "has_organization_projects": true,
6247 "has_repository_projects": true,
6248 "default_repository_permission": "drp",
6249 "members_can_create_repositories": true,
6250 "members_can_create_public_repositories": false,
6251 "members_can_create_private_repositories": true,
6252 "members_can_create_internal_repositories": true,
6253 "members_allowed_repository_creation_type": "marct",
6254 "members_can_create_pages": true,
6255 "members_can_create_public_pages": false,
6256 "members_can_create_private_pages": true
6257 },
6258 "pull_requests": [
6259 {
6260 "id": 1,
6261 "number": 1,
6262 "url": "u",
6263 "head": {
6264 "ref": "r",
6265 "sha": "s",
6266 "repo": {
6267 "id": 1,
6268 "name": "n",
6269 "url": "s"
6270 }
6271 },
6272 "base": {
6273 "ref": "r",
6274 "sha": "s",
6275 "repo": {
6276 "id": 1,
6277 "name": "n",
6278 "url": "u"
6279 }
6280 }
6281 }
6282 ],
6283 "sender": {
6284 "login": "l",
6285 "id": 1,
6286 "node_id": "n",
6287 "avatar_url": "a",
6288 "url": "u",
6289 "events_url": "e",
6290 "repos_url": "r"
6291 },
6292 "installation": {
6293 "id": 1,
6294 "node_id": "nid",
6295 "app_id": 1,
6296 "app_slug": "as",
6297 "target_id": 1,
6298 "account": {
6299 "login": "l",
6300 "id": 1,
6301 "avatar_url": "a",
6302 "gravatar_id": "g",
6303 "name": "n",
6304 "company": "c",
6305 "blog": "b",
6306 "location": "l",
6307 "email": "e",
6308 "hireable": true,
6309 "bio": "b",
6310 "twitter_username": "t",
6311 "public_repos": 1,
6312 "followers": 1,
6313 "following": 1,
6314 "created_at": ` + referenceTimeStr + `,
6315 "suspended_at": ` + referenceTimeStr + `,
6316 "url": "u"
6317 },
6318 "access_tokens_url": "atu",
6319 "repositories_url": "ru",
6320 "html_url": "hu",
6321 "target_type": "tt",
6322 "single_file_name": "sfn",
6323 "repository_selection": "rs",
6324 "events": [
6325 "e"
6326 ],
6327 "single_file_paths": [
6328 "s"
6329 ],
6330 "permissions": {
6331 "actions": "a",
6332 "administration": "ad",
6333 "checks": "c",
6334 "contents": "co",
6335 "content_references": "cr",
6336 "deployments": "d",
6337 "environments": "e",
6338 "issues": "i",
6339 "metadata": "md",
6340 "members": "m",
6341 "organization_administration": "oa",
6342 "organization_hooks": "oh",
6343 "organization_plan": "op",
6344 "organization_pre_receive_hooks": "opr",
6345 "organization_projects": "op",
6346 "organization_secrets": "os",
6347 "organization_self_hosted_runners": "osh",
6348 "organization_user_blocking": "oub",
6349 "packages": "pkg",
6350 "pages": "pg",
6351 "pull_requests": "pr",
6352 "repository_hooks": "rh",
6353 "repository_projects": "rp",
6354 "repository_pre_receive_hooks": "rprh",
6355 "secrets": "s",
6356 "secret_scanning_alerts": "ssa",
6357 "security_events": "se",
6358 "single_file": "sf",
6359 "statuses": "s",
6360 "team_discussions": "td",
6361 "vulnerability_alerts": "va",
6362 "workflows": "w"
6363 },
6364 "created_at": ` + referenceTimeStr + `,
6365 "updated_at": ` + referenceTimeStr + `,
6366 "has_multiple_single_files": false,
6367 "suspended_by": {
6368 "login": "l",
6369 "id": 1,
6370 "avatar_url": "a",
6371 "gravatar_id": "g",
6372 "name": "n",
6373 "company": "c",
6374 "blog": "b",
6375 "location": "l",
6376 "email": "e",
6377 "hireable": true,
6378 "bio": "b",
6379 "twitter_username": "t",
6380 "public_repos": 1,
6381 "followers": 1,
6382 "following": 1,
6383 "created_at": ` + referenceTimeStr + `,
6384 "suspended_at": ` + referenceTimeStr + `,
6385 "url": "u"
6386 },
6387 "suspended_at": ` + referenceTimeStr + `
6388 }
6389 }`
6390
6391 testJSONMarshal(t, u, want)
6392 }
6393
6394 func TestDeploymentStatusEvent_Marshal(t *testing.T) {
6395 testJSONMarshal(t, &DeploymentStatusEvent{}, "{}")
6396
6397 l := make(map[string]interface{})
6398 l["key"] = "value"
6399
6400 jsonMsg, _ := json.Marshal(&l)
6401
6402 u := &DeploymentStatusEvent{
6403 Deployment: &Deployment{
6404 URL: String("url"),
6405 ID: Int64(1),
6406 SHA: String("sha"),
6407 Ref: String("ref"),
6408 Task: String("t"),
6409 Payload: jsonMsg,
6410 Environment: String("e"),
6411 Description: String("d"),
6412 Creator: &User{
6413 Login: String("l"),
6414 ID: Int64(1),
6415 NodeID: String("n"),
6416 URL: String("u"),
6417 ReposURL: String("r"),
6418 EventsURL: String("e"),
6419 AvatarURL: String("a"),
6420 },
6421 CreatedAt: &Timestamp{referenceTime},
6422 UpdatedAt: &Timestamp{referenceTime},
6423 StatusesURL: String("surl"),
6424 RepositoryURL: String("rurl"),
6425 NodeID: String("nid"),
6426 },
6427 DeploymentStatus: &DeploymentStatus{
6428 ID: Int64(1),
6429 State: String("s"),
6430 Creator: &User{
6431 Login: String("l"),
6432 ID: Int64(1),
6433 NodeID: String("n"),
6434 URL: String("u"),
6435 ReposURL: String("r"),
6436 EventsURL: String("e"),
6437 AvatarURL: String("a"),
6438 },
6439 Description: String("s"),
6440 Environment: String("s"),
6441 NodeID: String("s"),
6442 CreatedAt: &Timestamp{referenceTime},
6443 UpdatedAt: &Timestamp{referenceTime},
6444 TargetURL: String("s"),
6445 DeploymentURL: String("s"),
6446 RepositoryURL: String("s"),
6447 EnvironmentURL: String("s"),
6448 LogURL: String("s"),
6449 URL: String("s"),
6450 },
6451 Repo: &Repository{
6452 ID: Int64(1),
6453 URL: String("s"),
6454 Name: String("n"),
6455 },
6456 Sender: &User{
6457 Login: String("l"),
6458 ID: Int64(1),
6459 NodeID: String("n"),
6460 URL: String("u"),
6461 ReposURL: String("r"),
6462 EventsURL: String("e"),
6463 AvatarURL: String("a"),
6464 },
6465 Installation: &Installation{
6466 ID: Int64(1),
6467 NodeID: String("nid"),
6468 AppID: Int64(1),
6469 AppSlug: String("as"),
6470 TargetID: Int64(1),
6471 Account: &User{
6472 Login: String("l"),
6473 ID: Int64(1),
6474 URL: String("u"),
6475 AvatarURL: String("a"),
6476 GravatarID: String("g"),
6477 Name: String("n"),
6478 Company: String("c"),
6479 Blog: String("b"),
6480 Location: String("l"),
6481 Email: String("e"),
6482 Hireable: Bool(true),
6483 Bio: String("b"),
6484 TwitterUsername: String("t"),
6485 PublicRepos: Int(1),
6486 Followers: Int(1),
6487 Following: Int(1),
6488 CreatedAt: &Timestamp{referenceTime},
6489 SuspendedAt: &Timestamp{referenceTime},
6490 },
6491 AccessTokensURL: String("atu"),
6492 RepositoriesURL: String("ru"),
6493 HTMLURL: String("hu"),
6494 TargetType: String("tt"),
6495 SingleFileName: String("sfn"),
6496 RepositorySelection: String("rs"),
6497 Events: []string{"e"},
6498 SingleFilePaths: []string{"s"},
6499 Permissions: &InstallationPermissions{
6500 Actions: String("a"),
6501 Administration: String("ad"),
6502 Checks: String("c"),
6503 Contents: String("co"),
6504 ContentReferences: String("cr"),
6505 Deployments: String("d"),
6506 Environments: String("e"),
6507 Issues: String("i"),
6508 Metadata: String("md"),
6509 Members: String("m"),
6510 OrganizationAdministration: String("oa"),
6511 OrganizationHooks: String("oh"),
6512 OrganizationPlan: String("op"),
6513 OrganizationPreReceiveHooks: String("opr"),
6514 OrganizationProjects: String("op"),
6515 OrganizationSecrets: String("os"),
6516 OrganizationSelfHostedRunners: String("osh"),
6517 OrganizationUserBlocking: String("oub"),
6518 Packages: String("pkg"),
6519 Pages: String("pg"),
6520 PullRequests: String("pr"),
6521 RepositoryHooks: String("rh"),
6522 RepositoryProjects: String("rp"),
6523 RepositoryPreReceiveHooks: String("rprh"),
6524 Secrets: String("s"),
6525 SecretScanningAlerts: String("ssa"),
6526 SecurityEvents: String("se"),
6527 SingleFile: String("sf"),
6528 Statuses: String("s"),
6529 TeamDiscussions: String("td"),
6530 VulnerabilityAlerts: String("va"),
6531 Workflows: String("w"),
6532 },
6533 CreatedAt: &Timestamp{referenceTime},
6534 UpdatedAt: &Timestamp{referenceTime},
6535 HasMultipleSingleFiles: Bool(false),
6536 SuspendedBy: &User{
6537 Login: String("l"),
6538 ID: Int64(1),
6539 URL: String("u"),
6540 AvatarURL: String("a"),
6541 GravatarID: String("g"),
6542 Name: String("n"),
6543 Company: String("c"),
6544 Blog: String("b"),
6545 Location: String("l"),
6546 Email: String("e"),
6547 Hireable: Bool(true),
6548 Bio: String("b"),
6549 TwitterUsername: String("t"),
6550 PublicRepos: Int(1),
6551 Followers: Int(1),
6552 Following: Int(1),
6553 CreatedAt: &Timestamp{referenceTime},
6554 SuspendedAt: &Timestamp{referenceTime},
6555 },
6556 SuspendedAt: &Timestamp{referenceTime},
6557 },
6558 }
6559
6560 want := `{
6561 "deployment": {
6562 "url": "url",
6563 "id": 1,
6564 "sha": "sha",
6565 "ref": "ref",
6566 "task": "t",
6567 "payload": {
6568 "key": "value"
6569 },
6570 "environment": "e",
6571 "description": "d",
6572 "creator": {
6573 "login": "l",
6574 "id": 1,
6575 "node_id": "n",
6576 "avatar_url": "a",
6577 "url": "u",
6578 "events_url": "e",
6579 "repos_url": "r"
6580 },
6581 "created_at": ` + referenceTimeStr + `,
6582 "updated_at": ` + referenceTimeStr + `,
6583 "statuses_url": "surl",
6584 "repository_url": "rurl",
6585 "node_id": "nid"
6586 },
6587 "deployment_status": {
6588 "id": 1,
6589 "state": "s",
6590 "creator": {
6591 "login": "l",
6592 "id": 1,
6593 "node_id": "n",
6594 "avatar_url": "a",
6595 "url": "u",
6596 "events_url": "e",
6597 "repos_url": "r"
6598 },
6599 "description": "s",
6600 "environment": "s",
6601 "node_id": "s",
6602 "created_at": ` + referenceTimeStr + `,
6603 "updated_at": ` + referenceTimeStr + `,
6604 "target_url": "s",
6605 "deployment_url": "s",
6606 "repository_url": "s",
6607 "environment_url": "s",
6608 "log_url": "s",
6609 "url": "s"
6610 },
6611 "repository": {
6612 "id": 1,
6613 "name": "n",
6614 "url": "s"
6615 },
6616 "sender": {
6617 "login": "l",
6618 "id": 1,
6619 "node_id": "n",
6620 "avatar_url": "a",
6621 "url": "u",
6622 "events_url": "e",
6623 "repos_url": "r"
6624 },
6625 "installation": {
6626 "id": 1,
6627 "node_id": "nid",
6628 "app_id": 1,
6629 "app_slug": "as",
6630 "target_id": 1,
6631 "account": {
6632 "login": "l",
6633 "id": 1,
6634 "avatar_url": "a",
6635 "gravatar_id": "g",
6636 "name": "n",
6637 "company": "c",
6638 "blog": "b",
6639 "location": "l",
6640 "email": "e",
6641 "hireable": true,
6642 "bio": "b",
6643 "twitter_username": "t",
6644 "public_repos": 1,
6645 "followers": 1,
6646 "following": 1,
6647 "created_at": ` + referenceTimeStr + `,
6648 "suspended_at": ` + referenceTimeStr + `,
6649 "url": "u"
6650 },
6651 "access_tokens_url": "atu",
6652 "repositories_url": "ru",
6653 "html_url": "hu",
6654 "target_type": "tt",
6655 "single_file_name": "sfn",
6656 "repository_selection": "rs",
6657 "events": [
6658 "e"
6659 ],
6660 "single_file_paths": [
6661 "s"
6662 ],
6663 "permissions": {
6664 "actions": "a",
6665 "administration": "ad",
6666 "checks": "c",
6667 "contents": "co",
6668 "content_references": "cr",
6669 "deployments": "d",
6670 "environments": "e",
6671 "issues": "i",
6672 "metadata": "md",
6673 "members": "m",
6674 "organization_administration": "oa",
6675 "organization_hooks": "oh",
6676 "organization_plan": "op",
6677 "organization_pre_receive_hooks": "opr",
6678 "organization_projects": "op",
6679 "organization_secrets": "os",
6680 "organization_self_hosted_runners": "osh",
6681 "organization_user_blocking": "oub",
6682 "packages": "pkg",
6683 "pages": "pg",
6684 "pull_requests": "pr",
6685 "repository_hooks": "rh",
6686 "repository_projects": "rp",
6687 "repository_pre_receive_hooks": "rprh",
6688 "secrets": "s",
6689 "secret_scanning_alerts": "ssa",
6690 "security_events": "se",
6691 "single_file": "sf",
6692 "statuses": "s",
6693 "team_discussions": "td",
6694 "vulnerability_alerts": "va",
6695 "workflows": "w"
6696 },
6697 "created_at": ` + referenceTimeStr + `,
6698 "updated_at": ` + referenceTimeStr + `,
6699 "has_multiple_single_files": false,
6700 "suspended_by": {
6701 "login": "l",
6702 "id": 1,
6703 "avatar_url": "a",
6704 "gravatar_id": "g",
6705 "name": "n",
6706 "company": "c",
6707 "blog": "b",
6708 "location": "l",
6709 "email": "e",
6710 "hireable": true,
6711 "bio": "b",
6712 "twitter_username": "t",
6713 "public_repos": 1,
6714 "followers": 1,
6715 "following": 1,
6716 "created_at": ` + referenceTimeStr + `,
6717 "suspended_at": ` + referenceTimeStr + `,
6718 "url": "u"
6719 },
6720 "suspended_at": ` + referenceTimeStr + `
6721 }
6722 }`
6723
6724 testJSONMarshal(t, u, want)
6725 }
6726
6727 func TestDiscussionCommentEvent_Marshal(t *testing.T) {
6728 testJSONMarshal(t, &DiscussionCommentEvent{}, "{}")
6729
6730 u := &DiscussionCommentEvent{
6731 Comment: &CommentDiscussion{
6732 AuthorAssociation: String("aa"),
6733 Body: String("bo"),
6734 ChildCommentCount: Int(1),
6735 CreatedAt: &Timestamp{referenceTime},
6736 DiscussionID: Int64(1),
6737 HTMLURL: String("hurl"),
6738 ID: Int64(1),
6739 NodeID: String("nid"),
6740 ParentID: Int64(1),
6741 Reactions: &Reactions{
6742 TotalCount: Int(1),
6743 PlusOne: Int(1),
6744 MinusOne: Int(1),
6745 Laugh: Int(1),
6746 Confused: Int(1),
6747 Heart: Int(1),
6748 Hooray: Int(1),
6749 Rocket: Int(1),
6750 Eyes: Int(1),
6751 URL: String("url"),
6752 },
6753 RepositoryURL: String("rurl"),
6754 UpdatedAt: &Timestamp{referenceTime},
6755 User: &User{
6756 Login: String("l"),
6757 ID: Int64(1),
6758 NodeID: String("n"),
6759 URL: String("u"),
6760 ReposURL: String("r"),
6761 EventsURL: String("e"),
6762 AvatarURL: String("a"),
6763 },
6764 },
6765 Discussion: &Discussion{
6766 RepositoryURL: String("rurl"),
6767 DiscussionCategory: &DiscussionCategory{
6768 ID: Int64(1),
6769 NodeID: String("nid"),
6770 RepositoryID: Int64(1),
6771 Emoji: String("emoji"),
6772 Name: String("name"),
6773 Description: String("description"),
6774 CreatedAt: &Timestamp{referenceTime},
6775 UpdatedAt: &Timestamp{referenceTime},
6776 Slug: String("slug"),
6777 IsAnswerable: Bool(false),
6778 },
6779 HTMLURL: String("hurl"),
6780 ID: Int64(1),
6781 NodeID: String("nurl"),
6782 Number: Int(1),
6783 Title: String("title"),
6784 User: &User{
6785 Login: String("l"),
6786 ID: Int64(1),
6787 NodeID: String("n"),
6788 URL: String("u"),
6789 ReposURL: String("r"),
6790 EventsURL: String("e"),
6791 AvatarURL: String("a"),
6792 },
6793 State: String("st"),
6794 Locked: Bool(false),
6795 Comments: Int(1),
6796 CreatedAt: &Timestamp{referenceTime},
6797 UpdatedAt: &Timestamp{referenceTime},
6798 AuthorAssociation: String("aa"),
6799 Body: String("bo"),
6800 },
6801 Repo: &Repository{
6802 ID: Int64(1),
6803 URL: String("s"),
6804 Name: String("n"),
6805 },
6806 Org: &Organization{
6807 BillingEmail: String("be"),
6808 Blog: String("b"),
6809 Company: String("c"),
6810 Email: String("e"),
6811 TwitterUsername: String("tu"),
6812 Location: String("loc"),
6813 Name: String("n"),
6814 Description: String("d"),
6815 IsVerified: Bool(true),
6816 HasOrganizationProjects: Bool(true),
6817 HasRepositoryProjects: Bool(true),
6818 DefaultRepoPermission: String("drp"),
6819 MembersCanCreateRepos: Bool(true),
6820 MembersCanCreateInternalRepos: Bool(true),
6821 MembersCanCreatePrivateRepos: Bool(true),
6822 MembersCanCreatePublicRepos: Bool(false),
6823 MembersAllowedRepositoryCreationType: String("marct"),
6824 MembersCanCreatePages: Bool(true),
6825 MembersCanCreatePublicPages: Bool(false),
6826 MembersCanCreatePrivatePages: Bool(true),
6827 },
6828 Sender: &User{
6829 Login: String("l"),
6830 ID: Int64(1),
6831 NodeID: String("n"),
6832 URL: String("u"),
6833 ReposURL: String("r"),
6834 EventsURL: String("e"),
6835 AvatarURL: String("a"),
6836 },
6837 Installation: &Installation{
6838 ID: Int64(1),
6839 NodeID: String("nid"),
6840 AppID: Int64(1),
6841 AppSlug: String("as"),
6842 TargetID: Int64(1),
6843 Account: &User{
6844 Login: String("l"),
6845 ID: Int64(1),
6846 URL: String("u"),
6847 AvatarURL: String("a"),
6848 GravatarID: String("g"),
6849 Name: String("n"),
6850 Company: String("c"),
6851 Blog: String("b"),
6852 Location: String("l"),
6853 Email: String("e"),
6854 Hireable: Bool(true),
6855 Bio: String("b"),
6856 TwitterUsername: String("t"),
6857 PublicRepos: Int(1),
6858 Followers: Int(1),
6859 Following: Int(1),
6860 CreatedAt: &Timestamp{referenceTime},
6861 SuspendedAt: &Timestamp{referenceTime},
6862 },
6863 AccessTokensURL: String("atu"),
6864 RepositoriesURL: String("ru"),
6865 HTMLURL: String("hu"),
6866 TargetType: String("tt"),
6867 SingleFileName: String("sfn"),
6868 RepositorySelection: String("rs"),
6869 Events: []string{"e"},
6870 SingleFilePaths: []string{"s"},
6871 Permissions: &InstallationPermissions{
6872 Actions: String("a"),
6873 Administration: String("ad"),
6874 Checks: String("c"),
6875 Contents: String("co"),
6876 ContentReferences: String("cr"),
6877 Deployments: String("d"),
6878 Environments: String("e"),
6879 Issues: String("i"),
6880 Metadata: String("md"),
6881 Members: String("m"),
6882 OrganizationAdministration: String("oa"),
6883 OrganizationHooks: String("oh"),
6884 OrganizationPlan: String("op"),
6885 OrganizationPreReceiveHooks: String("opr"),
6886 OrganizationProjects: String("op"),
6887 OrganizationSecrets: String("os"),
6888 OrganizationSelfHostedRunners: String("osh"),
6889 OrganizationUserBlocking: String("oub"),
6890 Packages: String("pkg"),
6891 Pages: String("pg"),
6892 PullRequests: String("pr"),
6893 RepositoryHooks: String("rh"),
6894 RepositoryProjects: String("rp"),
6895 RepositoryPreReceiveHooks: String("rprh"),
6896 Secrets: String("s"),
6897 SecretScanningAlerts: String("ssa"),
6898 SecurityEvents: String("se"),
6899 SingleFile: String("sf"),
6900 Statuses: String("s"),
6901 TeamDiscussions: String("td"),
6902 VulnerabilityAlerts: String("va"),
6903 Workflows: String("w"),
6904 },
6905 CreatedAt: &Timestamp{referenceTime},
6906 UpdatedAt: &Timestamp{referenceTime},
6907 HasMultipleSingleFiles: Bool(false),
6908 SuspendedBy: &User{
6909 Login: String("l"),
6910 ID: Int64(1),
6911 URL: String("u"),
6912 AvatarURL: String("a"),
6913 GravatarID: String("g"),
6914 Name: String("n"),
6915 Company: String("c"),
6916 Blog: String("b"),
6917 Location: String("l"),
6918 Email: String("e"),
6919 Hireable: Bool(true),
6920 Bio: String("b"),
6921 TwitterUsername: String("t"),
6922 PublicRepos: Int(1),
6923 Followers: Int(1),
6924 Following: Int(1),
6925 CreatedAt: &Timestamp{referenceTime},
6926 SuspendedAt: &Timestamp{referenceTime},
6927 },
6928 SuspendedAt: &Timestamp{referenceTime},
6929 },
6930 }
6931
6932 want := `{
6933 "comment": {
6934 "author_association": "aa",
6935 "body": "bo",
6936 "child_comment_count": 1,
6937 "created_at": ` + referenceTimeStr + `,
6938 "discussion_id": 1,
6939 "html_url": "hurl",
6940 "id": 1,
6941 "node_id": "nid",
6942 "parent_id": 1,
6943 "reactions": {
6944 "total_count": 1,
6945 "+1": 1,
6946 "-1": 1,
6947 "laugh": 1,
6948 "confused": 1,
6949 "heart": 1,
6950 "hooray": 1,
6951 "rocket": 1,
6952 "eyes": 1,
6953 "url": "url"
6954 },
6955 "repository_url": "rurl",
6956 "updated_at": ` + referenceTimeStr + `,
6957 "user": {
6958 "login": "l",
6959 "id": 1,
6960 "node_id": "n",
6961 "avatar_url": "a",
6962 "url": "u",
6963 "events_url": "e",
6964 "repos_url": "r"
6965 }
6966 },
6967 "discussion": {
6968 "repository_url": "rurl",
6969 "category": {
6970 "id": 1,
6971 "node_id": "nid",
6972 "repository_id": 1,
6973 "emoji": "emoji",
6974 "name": "name",
6975 "description": "description",
6976 "created_at": ` + referenceTimeStr + `,
6977 "updated_at": ` + referenceTimeStr + `,
6978 "slug": "slug",
6979 "is_answerable": false
6980 },
6981 "html_url": "hurl",
6982 "id": 1,
6983 "node_id": "nurl",
6984 "number": 1,
6985 "title": "title",
6986 "user": {
6987 "login": "l",
6988 "id": 1,
6989 "node_id": "n",
6990 "avatar_url": "a",
6991 "url": "u",
6992 "events_url": "e",
6993 "repos_url": "r"
6994 },
6995 "state": "st",
6996 "locked": false,
6997 "comments": 1,
6998 "created_at": ` + referenceTimeStr + `,
6999 "updated_at": ` + referenceTimeStr + `,
7000 "author_association": "aa",
7001 "body": "bo"
7002 },
7003 "repository": {
7004 "id": 1,
7005 "name": "n",
7006 "url": "s"
7007 },
7008 "organization": {
7009 "name": "n",
7010 "company": "c",
7011 "blog": "b",
7012 "location": "loc",
7013 "email": "e",
7014 "twitter_username": "tu",
7015 "description": "d",
7016 "billing_email": "be",
7017 "is_verified": true,
7018 "has_organization_projects": true,
7019 "has_repository_projects": true,
7020 "default_repository_permission": "drp",
7021 "members_can_create_repositories": true,
7022 "members_can_create_public_repositories": false,
7023 "members_can_create_private_repositories": true,
7024 "members_can_create_internal_repositories": true,
7025 "members_allowed_repository_creation_type": "marct",
7026 "members_can_create_pages": true,
7027 "members_can_create_public_pages": false,
7028 "members_can_create_private_pages": true
7029 },
7030 "sender": {
7031 "login": "l",
7032 "id": 1,
7033 "node_id": "n",
7034 "avatar_url": "a",
7035 "url": "u",
7036 "events_url": "e",
7037 "repos_url": "r"
7038 },
7039 "installation": {
7040 "id": 1,
7041 "node_id": "nid",
7042 "app_id": 1,
7043 "app_slug": "as",
7044 "target_id": 1,
7045 "account": {
7046 "login": "l",
7047 "id": 1,
7048 "avatar_url": "a",
7049 "gravatar_id": "g",
7050 "name": "n",
7051 "company": "c",
7052 "blog": "b",
7053 "location": "l",
7054 "email": "e",
7055 "hireable": true,
7056 "bio": "b",
7057 "twitter_username": "t",
7058 "public_repos": 1,
7059 "followers": 1,
7060 "following": 1,
7061 "created_at": ` + referenceTimeStr + `,
7062 "suspended_at": ` + referenceTimeStr + `,
7063 "url": "u"
7064 },
7065 "access_tokens_url": "atu",
7066 "repositories_url": "ru",
7067 "html_url": "hu",
7068 "target_type": "tt",
7069 "single_file_name": "sfn",
7070 "repository_selection": "rs",
7071 "events": [
7072 "e"
7073 ],
7074 "single_file_paths": [
7075 "s"
7076 ],
7077 "permissions": {
7078 "actions": "a",
7079 "administration": "ad",
7080 "checks": "c",
7081 "contents": "co",
7082 "content_references": "cr",
7083 "deployments": "d",
7084 "environments": "e",
7085 "issues": "i",
7086 "metadata": "md",
7087 "members": "m",
7088 "organization_administration": "oa",
7089 "organization_hooks": "oh",
7090 "organization_plan": "op",
7091 "organization_pre_receive_hooks": "opr",
7092 "organization_projects": "op",
7093 "organization_secrets": "os",
7094 "organization_self_hosted_runners": "osh",
7095 "organization_user_blocking": "oub",
7096 "packages": "pkg",
7097 "pages": "pg",
7098 "pull_requests": "pr",
7099 "repository_hooks": "rh",
7100 "repository_projects": "rp",
7101 "repository_pre_receive_hooks": "rprh",
7102 "secrets": "s",
7103 "secret_scanning_alerts": "ssa",
7104 "security_events": "se",
7105 "single_file": "sf",
7106 "statuses": "s",
7107 "team_discussions": "td",
7108 "vulnerability_alerts": "va",
7109 "workflows": "w"
7110 },
7111 "created_at": ` + referenceTimeStr + `,
7112 "updated_at": ` + referenceTimeStr + `,
7113 "has_multiple_single_files": false,
7114 "suspended_by": {
7115 "login": "l",
7116 "id": 1,
7117 "avatar_url": "a",
7118 "gravatar_id": "g",
7119 "name": "n",
7120 "company": "c",
7121 "blog": "b",
7122 "location": "l",
7123 "email": "e",
7124 "hireable": true,
7125 "bio": "b",
7126 "twitter_username": "t",
7127 "public_repos": 1,
7128 "followers": 1,
7129 "following": 1,
7130 "created_at": ` + referenceTimeStr + `,
7131 "suspended_at": ` + referenceTimeStr + `,
7132 "url": "u"
7133 },
7134 "suspended_at": ` + referenceTimeStr + `
7135 }
7136 }`
7137
7138 testJSONMarshal(t, u, want)
7139 }
7140
7141 func TestDiscussionEvent_Marshal(t *testing.T) {
7142 testJSONMarshal(t, &DiscussionEvent{}, "{}")
7143
7144 u := &DiscussionEvent{
7145 Discussion: &Discussion{
7146 RepositoryURL: String("rurl"),
7147 DiscussionCategory: &DiscussionCategory{
7148 ID: Int64(1),
7149 NodeID: String("nid"),
7150 RepositoryID: Int64(1),
7151 Emoji: String("emoji"),
7152 Name: String("name"),
7153 Description: String("description"),
7154 CreatedAt: &Timestamp{referenceTime},
7155 UpdatedAt: &Timestamp{referenceTime},
7156 Slug: String("slug"),
7157 IsAnswerable: Bool(false),
7158 },
7159 HTMLURL: String("hurl"),
7160 ID: Int64(1),
7161 NodeID: String("nurl"),
7162 Number: Int(1),
7163 Title: String("title"),
7164 User: &User{
7165 Login: String("l"),
7166 ID: Int64(1),
7167 NodeID: String("n"),
7168 URL: String("u"),
7169 ReposURL: String("r"),
7170 EventsURL: String("e"),
7171 AvatarURL: String("a"),
7172 },
7173 State: String("st"),
7174 Locked: Bool(false),
7175 Comments: Int(1),
7176 CreatedAt: &Timestamp{referenceTime},
7177 UpdatedAt: &Timestamp{referenceTime},
7178 AuthorAssociation: String("aa"),
7179 Body: String("bo"),
7180 },
7181 Repo: &Repository{
7182 ID: Int64(1),
7183 URL: String("s"),
7184 Name: String("n"),
7185 },
7186 Org: &Organization{
7187 BillingEmail: String("be"),
7188 Blog: String("b"),
7189 Company: String("c"),
7190 Email: String("e"),
7191 TwitterUsername: String("tu"),
7192 Location: String("loc"),
7193 Name: String("n"),
7194 Description: String("d"),
7195 IsVerified: Bool(true),
7196 HasOrganizationProjects: Bool(true),
7197 HasRepositoryProjects: Bool(true),
7198 DefaultRepoPermission: String("drp"),
7199 MembersCanCreateRepos: Bool(true),
7200 MembersCanCreateInternalRepos: Bool(true),
7201 MembersCanCreatePrivateRepos: Bool(true),
7202 MembersCanCreatePublicRepos: Bool(false),
7203 MembersAllowedRepositoryCreationType: String("marct"),
7204 MembersCanCreatePages: Bool(true),
7205 MembersCanCreatePublicPages: Bool(false),
7206 MembersCanCreatePrivatePages: Bool(true),
7207 },
7208 Sender: &User{
7209 Login: String("l"),
7210 ID: Int64(1),
7211 NodeID: String("n"),
7212 URL: String("u"),
7213 ReposURL: String("r"),
7214 EventsURL: String("e"),
7215 AvatarURL: String("a"),
7216 },
7217 Installation: &Installation{
7218 ID: Int64(1),
7219 NodeID: String("nid"),
7220 AppID: Int64(1),
7221 AppSlug: String("as"),
7222 TargetID: Int64(1),
7223 Account: &User{
7224 Login: String("l"),
7225 ID: Int64(1),
7226 URL: String("u"),
7227 AvatarURL: String("a"),
7228 GravatarID: String("g"),
7229 Name: String("n"),
7230 Company: String("c"),
7231 Blog: String("b"),
7232 Location: String("l"),
7233 Email: String("e"),
7234 Hireable: Bool(true),
7235 Bio: String("b"),
7236 TwitterUsername: String("t"),
7237 PublicRepos: Int(1),
7238 Followers: Int(1),
7239 Following: Int(1),
7240 CreatedAt: &Timestamp{referenceTime},
7241 SuspendedAt: &Timestamp{referenceTime},
7242 },
7243 AccessTokensURL: String("atu"),
7244 RepositoriesURL: String("ru"),
7245 HTMLURL: String("hu"),
7246 TargetType: String("tt"),
7247 SingleFileName: String("sfn"),
7248 RepositorySelection: String("rs"),
7249 Events: []string{"e"},
7250 SingleFilePaths: []string{"s"},
7251 Permissions: &InstallationPermissions{
7252 Actions: String("a"),
7253 Administration: String("ad"),
7254 Checks: String("c"),
7255 Contents: String("co"),
7256 ContentReferences: String("cr"),
7257 Deployments: String("d"),
7258 Environments: String("e"),
7259 Issues: String("i"),
7260 Metadata: String("md"),
7261 Members: String("m"),
7262 OrganizationAdministration: String("oa"),
7263 OrganizationHooks: String("oh"),
7264 OrganizationPlan: String("op"),
7265 OrganizationPreReceiveHooks: String("opr"),
7266 OrganizationProjects: String("op"),
7267 OrganizationSecrets: String("os"),
7268 OrganizationSelfHostedRunners: String("osh"),
7269 OrganizationUserBlocking: String("oub"),
7270 Packages: String("pkg"),
7271 Pages: String("pg"),
7272 PullRequests: String("pr"),
7273 RepositoryHooks: String("rh"),
7274 RepositoryProjects: String("rp"),
7275 RepositoryPreReceiveHooks: String("rprh"),
7276 Secrets: String("s"),
7277 SecretScanningAlerts: String("ssa"),
7278 SecurityEvents: String("se"),
7279 SingleFile: String("sf"),
7280 Statuses: String("s"),
7281 TeamDiscussions: String("td"),
7282 VulnerabilityAlerts: String("va"),
7283 Workflows: String("w"),
7284 },
7285 CreatedAt: &Timestamp{referenceTime},
7286 UpdatedAt: &Timestamp{referenceTime},
7287 HasMultipleSingleFiles: Bool(false),
7288 SuspendedBy: &User{
7289 Login: String("l"),
7290 ID: Int64(1),
7291 URL: String("u"),
7292 AvatarURL: String("a"),
7293 GravatarID: String("g"),
7294 Name: String("n"),
7295 Company: String("c"),
7296 Blog: String("b"),
7297 Location: String("l"),
7298 Email: String("e"),
7299 Hireable: Bool(true),
7300 Bio: String("b"),
7301 TwitterUsername: String("t"),
7302 PublicRepos: Int(1),
7303 Followers: Int(1),
7304 Following: Int(1),
7305 CreatedAt: &Timestamp{referenceTime},
7306 SuspendedAt: &Timestamp{referenceTime},
7307 },
7308 SuspendedAt: &Timestamp{referenceTime},
7309 },
7310 }
7311
7312 want := `{
7313 "discussion": {
7314 "repository_url": "rurl",
7315 "category": {
7316 "id": 1,
7317 "node_id": "nid",
7318 "repository_id": 1,
7319 "emoji": "emoji",
7320 "name": "name",
7321 "description": "description",
7322 "created_at": ` + referenceTimeStr + `,
7323 "updated_at": ` + referenceTimeStr + `,
7324 "slug": "slug",
7325 "is_answerable": false
7326 },
7327 "html_url": "hurl",
7328 "id": 1,
7329 "node_id": "nurl",
7330 "number": 1,
7331 "title": "title",
7332 "user": {
7333 "login": "l",
7334 "id": 1,
7335 "node_id": "n",
7336 "avatar_url": "a",
7337 "url": "u",
7338 "events_url": "e",
7339 "repos_url": "r"
7340 },
7341 "state": "st",
7342 "locked": false,
7343 "comments": 1,
7344 "created_at": ` + referenceTimeStr + `,
7345 "updated_at": ` + referenceTimeStr + `,
7346 "author_association": "aa",
7347 "body": "bo"
7348 },
7349 "repository": {
7350 "id": 1,
7351 "name": "n",
7352 "url": "s"
7353 },
7354 "organization": {
7355 "name": "n",
7356 "company": "c",
7357 "blog": "b",
7358 "location": "loc",
7359 "email": "e",
7360 "twitter_username": "tu",
7361 "description": "d",
7362 "billing_email": "be",
7363 "is_verified": true,
7364 "has_organization_projects": true,
7365 "has_repository_projects": true,
7366 "default_repository_permission": "drp",
7367 "members_can_create_repositories": true,
7368 "members_can_create_public_repositories": false,
7369 "members_can_create_private_repositories": true,
7370 "members_can_create_internal_repositories": true,
7371 "members_allowed_repository_creation_type": "marct",
7372 "members_can_create_pages": true,
7373 "members_can_create_public_pages": false,
7374 "members_can_create_private_pages": true
7375 },
7376 "sender": {
7377 "login": "l",
7378 "id": 1,
7379 "node_id": "n",
7380 "avatar_url": "a",
7381 "url": "u",
7382 "events_url": "e",
7383 "repos_url": "r"
7384 },
7385 "installation": {
7386 "id": 1,
7387 "node_id": "nid",
7388 "app_id": 1,
7389 "app_slug": "as",
7390 "target_id": 1,
7391 "account": {
7392 "login": "l",
7393 "id": 1,
7394 "avatar_url": "a",
7395 "gravatar_id": "g",
7396 "name": "n",
7397 "company": "c",
7398 "blog": "b",
7399 "location": "l",
7400 "email": "e",
7401 "hireable": true,
7402 "bio": "b",
7403 "twitter_username": "t",
7404 "public_repos": 1,
7405 "followers": 1,
7406 "following": 1,
7407 "created_at": ` + referenceTimeStr + `,
7408 "suspended_at": ` + referenceTimeStr + `,
7409 "url": "u"
7410 },
7411 "access_tokens_url": "atu",
7412 "repositories_url": "ru",
7413 "html_url": "hu",
7414 "target_type": "tt",
7415 "single_file_name": "sfn",
7416 "repository_selection": "rs",
7417 "events": [
7418 "e"
7419 ],
7420 "single_file_paths": [
7421 "s"
7422 ],
7423 "permissions": {
7424 "actions": "a",
7425 "administration": "ad",
7426 "checks": "c",
7427 "contents": "co",
7428 "content_references": "cr",
7429 "deployments": "d",
7430 "environments": "e",
7431 "issues": "i",
7432 "metadata": "md",
7433 "members": "m",
7434 "organization_administration": "oa",
7435 "organization_hooks": "oh",
7436 "organization_plan": "op",
7437 "organization_pre_receive_hooks": "opr",
7438 "organization_projects": "op",
7439 "organization_secrets": "os",
7440 "organization_self_hosted_runners": "osh",
7441 "organization_user_blocking": "oub",
7442 "packages": "pkg",
7443 "pages": "pg",
7444 "pull_requests": "pr",
7445 "repository_hooks": "rh",
7446 "repository_projects": "rp",
7447 "repository_pre_receive_hooks": "rprh",
7448 "secrets": "s",
7449 "secret_scanning_alerts": "ssa",
7450 "security_events": "se",
7451 "single_file": "sf",
7452 "statuses": "s",
7453 "team_discussions": "td",
7454 "vulnerability_alerts": "va",
7455 "workflows": "w"
7456 },
7457 "created_at": ` + referenceTimeStr + `,
7458 "updated_at": ` + referenceTimeStr + `,
7459 "has_multiple_single_files": false,
7460 "suspended_by": {
7461 "login": "l",
7462 "id": 1,
7463 "avatar_url": "a",
7464 "gravatar_id": "g",
7465 "name": "n",
7466 "company": "c",
7467 "blog": "b",
7468 "location": "l",
7469 "email": "e",
7470 "hireable": true,
7471 "bio": "b",
7472 "twitter_username": "t",
7473 "public_repos": 1,
7474 "followers": 1,
7475 "following": 1,
7476 "created_at": ` + referenceTimeStr + `,
7477 "suspended_at": ` + referenceTimeStr + `,
7478 "url": "u"
7479 },
7480 "suspended_at": ` + referenceTimeStr + `
7481 }
7482 }`
7483
7484 testJSONMarshal(t, u, want)
7485 }
7486
7487 func TestPackageEvent_Marshal(t *testing.T) {
7488 testJSONMarshal(t, &PackageEvent{}, "{}")
7489
7490 u := &PackageEvent{
7491 Action: String("a"),
7492 Package: &Package{
7493 ID: Int64(1),
7494 Name: String("n"),
7495 PackageType: String("pt"),
7496 HTMLURL: String("hurl"),
7497 CreatedAt: &Timestamp{referenceTime},
7498 UpdatedAt: &Timestamp{referenceTime},
7499 Owner: &User{
7500 Login: String("l"),
7501 ID: Int64(1),
7502 NodeID: String("n"),
7503 URL: String("u"),
7504 ReposURL: String("r"),
7505 EventsURL: String("e"),
7506 AvatarURL: String("a"),
7507 },
7508 PackageVersion: &PackageVersion{ID: Int64(1)},
7509 Registry: &PackageRegistry{Name: String("n")},
7510 },
7511 Repo: &Repository{
7512 ID: Int64(1),
7513 URL: String("s"),
7514 Name: String("n"),
7515 },
7516 Org: &Organization{
7517 BillingEmail: String("be"),
7518 Blog: String("b"),
7519 Company: String("c"),
7520 Email: String("e"),
7521 TwitterUsername: String("tu"),
7522 Location: String("loc"),
7523 Name: String("n"),
7524 Description: String("d"),
7525 IsVerified: Bool(true),
7526 HasOrganizationProjects: Bool(true),
7527 HasRepositoryProjects: Bool(true),
7528 DefaultRepoPermission: String("drp"),
7529 MembersCanCreateRepos: Bool(true),
7530 MembersCanCreateInternalRepos: Bool(true),
7531 MembersCanCreatePrivateRepos: Bool(true),
7532 MembersCanCreatePublicRepos: Bool(false),
7533 MembersAllowedRepositoryCreationType: String("marct"),
7534 MembersCanCreatePages: Bool(true),
7535 MembersCanCreatePublicPages: Bool(false),
7536 MembersCanCreatePrivatePages: Bool(true),
7537 },
7538 Sender: &User{
7539 Login: String("l"),
7540 ID: Int64(1),
7541 NodeID: String("n"),
7542 URL: String("u"),
7543 ReposURL: String("r"),
7544 EventsURL: String("e"),
7545 AvatarURL: String("a"),
7546 },
7547 }
7548
7549 want := `{
7550 "action": "a",
7551 "package": {
7552 "id": 1,
7553 "name": "n",
7554 "package_type": "pt",
7555 "html_url": "hurl",
7556 "created_at": ` + referenceTimeStr + `,
7557 "updated_at": ` + referenceTimeStr + `,
7558 "owner": {
7559 "login": "l",
7560 "id": 1,
7561 "node_id": "n",
7562 "avatar_url": "a",
7563 "url": "u",
7564 "events_url": "e",
7565 "repos_url": "r"
7566 },
7567 "package_version": {
7568 "id": 1
7569 },
7570 "registry": {
7571 "name": "n"
7572 }
7573 },
7574 "repository": {
7575 "id": 1,
7576 "name": "n",
7577 "url": "s"
7578 },
7579 "organization": {
7580 "name": "n",
7581 "company": "c",
7582 "blog": "b",
7583 "location": "loc",
7584 "email": "e",
7585 "twitter_username": "tu",
7586 "description": "d",
7587 "billing_email": "be",
7588 "is_verified": true,
7589 "has_organization_projects": true,
7590 "has_repository_projects": true,
7591 "default_repository_permission": "drp",
7592 "members_can_create_repositories": true,
7593 "members_can_create_public_repositories": false,
7594 "members_can_create_private_repositories": true,
7595 "members_can_create_internal_repositories": true,
7596 "members_allowed_repository_creation_type": "marct",
7597 "members_can_create_pages": true,
7598 "members_can_create_public_pages": false,
7599 "members_can_create_private_pages": true
7600 },
7601 "sender": {
7602 "login": "l",
7603 "id": 1,
7604 "node_id": "n",
7605 "avatar_url": "a",
7606 "url": "u",
7607 "events_url": "e",
7608 "repos_url": "r"
7609 }
7610 }`
7611
7612 testJSONMarshal(t, u, want)
7613 }
7614
7615 func TestPersonalAccessTokenRequestEvent_Marshal(t *testing.T) {
7616 testJSONMarshal(t, &PersonalAccessTokenRequestEvent{}, "{}")
7617
7618 event := &PersonalAccessTokenRequestEvent{
7619 Action: String("a"),
7620 PersonalAccessTokenRequest: &PersonalAccessTokenRequest{
7621 ID: Int64(1),
7622 Owner: &User{Login: String("l")},
7623 PermissionsAdded: &PersonalAccessTokenPermissions{
7624 Org: map[string]string{"organization_events": "read"},
7625 Repo: map[string]string{"security_events": "write"},
7626 },
7627 CreatedAt: &Timestamp{referenceTime},
7628 TokenExpired: Bool(false),
7629 TokenExpiresAt: &Timestamp{referenceTime},
7630 TokenLastUsedAt: &Timestamp{referenceTime},
7631 RepositoryCount: Int64(1),
7632 RepositorySelection: String("rs"),
7633 Repositories: []*Repository{
7634 {
7635 Name: String("n"),
7636 },
7637 },
7638 },
7639 Org: &Organization{Name: String("n")},
7640 Sender: &User{
7641 Login: String("l"),
7642 },
7643 Installation: &Installation{
7644 ID: Int64(1),
7645 },
7646 }
7647
7648 want := `{
7649 "action": "a",
7650 "personal_access_token_request": {
7651 "id": 1,
7652 "owner": {
7653 "login": "l"
7654 },
7655 "permissions_added": {
7656 "organization": {
7657 "organization_events": "read"
7658 },
7659 "repository": {
7660 "security_events": "write"
7661 }
7662 },
7663 "created_at": ` + referenceTimeStr + `,
7664 "token_expired": false,
7665 "token_expires_at": ` + referenceTimeStr + `,
7666 "token_last_used_at": ` + referenceTimeStr + `,
7667 "repository_count": 1,
7668 "repository_selection": "rs",
7669 "repositories": [
7670 {
7671 "name": "n"
7672 }
7673 ]
7674 },
7675 "organization": {
7676 "name": "n"
7677 },
7678 "sender": {
7679 "login": "l"
7680 },
7681 "installation": {
7682 "id": 1
7683 }
7684 }`
7685
7686 testJSONMarshal(t, event, want)
7687 }
7688
7689 func TestPingEvent_Marshal(t *testing.T) {
7690 testJSONMarshal(t, &PingEvent{}, "{}")
7691
7692 l := make(map[string]interface{})
7693 l["key"] = "value"
7694 hookConfig := new(HookConfig)
7695
7696 u := &PingEvent{
7697 Zen: String("z"),
7698 HookID: Int64(1),
7699 Hook: &Hook{
7700 CreatedAt: &Timestamp{referenceTime},
7701 UpdatedAt: &Timestamp{referenceTime},
7702 URL: String("url"),
7703 ID: Int64(1),
7704 Type: String("t"),
7705 Name: String("n"),
7706 TestURL: String("tu"),
7707 PingURL: String("pu"),
7708 LastResponse: l,
7709 Config: hookConfig,
7710 Events: []string{"a"},
7711 Active: Bool(true),
7712 },
7713 Installation: &Installation{
7714 ID: Int64(1),
7715 NodeID: String("nid"),
7716 AppID: Int64(1),
7717 AppSlug: String("as"),
7718 TargetID: Int64(1),
7719 Account: &User{
7720 Login: String("l"),
7721 ID: Int64(1),
7722 URL: String("u"),
7723 AvatarURL: String("a"),
7724 GravatarID: String("g"),
7725 Name: String("n"),
7726 Company: String("c"),
7727 Blog: String("b"),
7728 Location: String("l"),
7729 Email: String("e"),
7730 Hireable: Bool(true),
7731 Bio: String("b"),
7732 TwitterUsername: String("t"),
7733 PublicRepos: Int(1),
7734 Followers: Int(1),
7735 Following: Int(1),
7736 CreatedAt: &Timestamp{referenceTime},
7737 SuspendedAt: &Timestamp{referenceTime},
7738 },
7739 AccessTokensURL: String("atu"),
7740 RepositoriesURL: String("ru"),
7741 HTMLURL: String("hu"),
7742 TargetType: String("tt"),
7743 SingleFileName: String("sfn"),
7744 RepositorySelection: String("rs"),
7745 Events: []string{"e"},
7746 SingleFilePaths: []string{"s"},
7747 Permissions: &InstallationPermissions{
7748 Actions: String("a"),
7749 Administration: String("ad"),
7750 Checks: String("c"),
7751 Contents: String("co"),
7752 ContentReferences: String("cr"),
7753 Deployments: String("d"),
7754 Environments: String("e"),
7755 Issues: String("i"),
7756 Metadata: String("md"),
7757 Members: String("m"),
7758 OrganizationAdministration: String("oa"),
7759 OrganizationHooks: String("oh"),
7760 OrganizationPlan: String("op"),
7761 OrganizationPreReceiveHooks: String("opr"),
7762 OrganizationProjects: String("op"),
7763 OrganizationSecrets: String("os"),
7764 OrganizationSelfHostedRunners: String("osh"),
7765 OrganizationUserBlocking: String("oub"),
7766 Packages: String("pkg"),
7767 Pages: String("pg"),
7768 PullRequests: String("pr"),
7769 RepositoryHooks: String("rh"),
7770 RepositoryProjects: String("rp"),
7771 RepositoryPreReceiveHooks: String("rprh"),
7772 Secrets: String("s"),
7773 SecretScanningAlerts: String("ssa"),
7774 SecurityEvents: String("se"),
7775 SingleFile: String("sf"),
7776 Statuses: String("s"),
7777 TeamDiscussions: String("td"),
7778 VulnerabilityAlerts: String("va"),
7779 Workflows: String("w"),
7780 },
7781 CreatedAt: &Timestamp{referenceTime},
7782 UpdatedAt: &Timestamp{referenceTime},
7783 HasMultipleSingleFiles: Bool(false),
7784 SuspendedBy: &User{
7785 Login: String("l"),
7786 ID: Int64(1),
7787 URL: String("u"),
7788 AvatarURL: String("a"),
7789 GravatarID: String("g"),
7790 Name: String("n"),
7791 Company: String("c"),
7792 Blog: String("b"),
7793 Location: String("l"),
7794 Email: String("e"),
7795 Hireable: Bool(true),
7796 Bio: String("b"),
7797 TwitterUsername: String("t"),
7798 PublicRepos: Int(1),
7799 Followers: Int(1),
7800 Following: Int(1),
7801 CreatedAt: &Timestamp{referenceTime},
7802 SuspendedAt: &Timestamp{referenceTime},
7803 },
7804 SuspendedAt: &Timestamp{referenceTime},
7805 },
7806 }
7807
7808 want := `{
7809 "zen": "z",
7810 "hook_id": 1,
7811 "hook": {
7812 "created_at": ` + referenceTimeStr + `,
7813 "updated_at": ` + referenceTimeStr + `,
7814 "url": "url",
7815 "id": 1,
7816 "type": "t",
7817 "name": "n",
7818 "test_url": "tu",
7819 "ping_url": "pu",
7820 "last_response": {
7821 "key": "value"
7822 },
7823 "config": {
7824 "key": "value"
7825 },
7826 "events": [
7827 "a"
7828 ],
7829 "active": true
7830 },
7831 "installation": {
7832 "id": 1,
7833 "node_id": "nid",
7834 "app_id": 1,
7835 "app_slug": "as",
7836 "target_id": 1,
7837 "account": {
7838 "login": "l",
7839 "id": 1,
7840 "avatar_url": "a",
7841 "gravatar_id": "g",
7842 "name": "n",
7843 "company": "c",
7844 "blog": "b",
7845 "location": "l",
7846 "email": "e",
7847 "hireable": true,
7848 "bio": "b",
7849 "twitter_username": "t",
7850 "public_repos": 1,
7851 "followers": 1,
7852 "following": 1,
7853 "created_at": ` + referenceTimeStr + `,
7854 "suspended_at": ` + referenceTimeStr + `,
7855 "url": "u"
7856 },
7857 "access_tokens_url": "atu",
7858 "repositories_url": "ru",
7859 "html_url": "hu",
7860 "target_type": "tt",
7861 "single_file_name": "sfn",
7862 "repository_selection": "rs",
7863 "events": [
7864 "e"
7865 ],
7866 "single_file_paths": [
7867 "s"
7868 ],
7869 "permissions": {
7870 "actions": "a",
7871 "administration": "ad",
7872 "checks": "c",
7873 "contents": "co",
7874 "content_references": "cr",
7875 "deployments": "d",
7876 "environments": "e",
7877 "issues": "i",
7878 "metadata": "md",
7879 "members": "m",
7880 "organization_administration": "oa",
7881 "organization_hooks": "oh",
7882 "organization_plan": "op",
7883 "organization_pre_receive_hooks": "opr",
7884 "organization_projects": "op",
7885 "organization_secrets": "os",
7886 "organization_self_hosted_runners": "osh",
7887 "organization_user_blocking": "oub",
7888 "packages": "pkg",
7889 "pages": "pg",
7890 "pull_requests": "pr",
7891 "repository_hooks": "rh",
7892 "repository_projects": "rp",
7893 "repository_pre_receive_hooks": "rprh",
7894 "secrets": "s",
7895 "secret_scanning_alerts": "ssa",
7896 "security_events": "se",
7897 "single_file": "sf",
7898 "statuses": "s",
7899 "team_discussions": "td",
7900 "vulnerability_alerts": "va",
7901 "workflows": "w"
7902 },
7903 "created_at": ` + referenceTimeStr + `,
7904 "updated_at": ` + referenceTimeStr + `,
7905 "has_multiple_single_files": false,
7906 "suspended_by": {
7907 "login": "l",
7908 "id": 1,
7909 "avatar_url": "a",
7910 "gravatar_id": "g",
7911 "name": "n",
7912 "company": "c",
7913 "blog": "b",
7914 "location": "l",
7915 "email": "e",
7916 "hireable": true,
7917 "bio": "b",
7918 "twitter_username": "t",
7919 "public_repos": 1,
7920 "followers": 1,
7921 "following": 1,
7922 "created_at": ` + referenceTimeStr + `,
7923 "suspended_at": ` + referenceTimeStr + `,
7924 "url": "u"
7925 },
7926 "suspended_at": ` + referenceTimeStr + `
7927 }
7928 }`
7929
7930 testJSONMarshal(t, u, want)
7931 }
7932
7933 func TestRepositoryDispatchEvent_Marshal(t *testing.T) {
7934 testJSONMarshal(t, &RepositoryDispatchEvent{}, "{}")
7935
7936 l := make(map[string]interface{})
7937 l["key"] = "value"
7938
7939 jsonMsg, _ := json.Marshal(&l)
7940
7941 u := &RepositoryDispatchEvent{
7942 Action: String("a"),
7943 Branch: String("b"),
7944 ClientPayload: jsonMsg,
7945 Repo: &Repository{
7946
7947 ID: Int64(1),
7948 URL: String("s"),
7949 Name: String("n"),
7950 },
7951 Org: &Organization{
7952 BillingEmail: String("be"),
7953 Blog: String("b"),
7954 Company: String("c"),
7955 Email: String("e"),
7956 TwitterUsername: String("tu"),
7957 Location: String("loc"),
7958 Name: String("n"),
7959 Description: String("d"),
7960 IsVerified: Bool(true),
7961 HasOrganizationProjects: Bool(true),
7962 HasRepositoryProjects: Bool(true),
7963 DefaultRepoPermission: String("drp"),
7964 MembersCanCreateRepos: Bool(true),
7965 MembersCanCreateInternalRepos: Bool(true),
7966 MembersCanCreatePrivateRepos: Bool(true),
7967 MembersCanCreatePublicRepos: Bool(false),
7968 MembersAllowedRepositoryCreationType: String("marct"),
7969 MembersCanCreatePages: Bool(true),
7970 MembersCanCreatePublicPages: Bool(false),
7971 MembersCanCreatePrivatePages: Bool(true),
7972 },
7973 Sender: &User{
7974 Login: String("l"),
7975 ID: Int64(1),
7976 NodeID: String("n"),
7977 URL: String("u"),
7978 ReposURL: String("r"),
7979 EventsURL: String("e"),
7980 AvatarURL: String("a"),
7981 },
7982 Installation: &Installation{
7983 ID: Int64(1),
7984 NodeID: String("nid"),
7985 AppID: Int64(1),
7986 AppSlug: String("as"),
7987 TargetID: Int64(1),
7988 Account: &User{
7989 Login: String("l"),
7990 ID: Int64(1),
7991 URL: String("u"),
7992 AvatarURL: String("a"),
7993 GravatarID: String("g"),
7994 Name: String("n"),
7995 Company: String("c"),
7996 Blog: String("b"),
7997 Location: String("l"),
7998 Email: String("e"),
7999 Hireable: Bool(true),
8000 Bio: String("b"),
8001 TwitterUsername: String("t"),
8002 PublicRepos: Int(1),
8003 Followers: Int(1),
8004 Following: Int(1),
8005 CreatedAt: &Timestamp{referenceTime},
8006 SuspendedAt: &Timestamp{referenceTime},
8007 },
8008 AccessTokensURL: String("atu"),
8009 RepositoriesURL: String("ru"),
8010 HTMLURL: String("hu"),
8011 TargetType: String("tt"),
8012 SingleFileName: String("sfn"),
8013 RepositorySelection: String("rs"),
8014 Events: []string{"e"},
8015 SingleFilePaths: []string{"s"},
8016 Permissions: &InstallationPermissions{
8017 Actions: String("a"),
8018 Administration: String("ad"),
8019 Checks: String("c"),
8020 Contents: String("co"),
8021 ContentReferences: String("cr"),
8022 Deployments: String("d"),
8023 Environments: String("e"),
8024 Issues: String("i"),
8025 Metadata: String("md"),
8026 Members: String("m"),
8027 OrganizationAdministration: String("oa"),
8028 OrganizationHooks: String("oh"),
8029 OrganizationPlan: String("op"),
8030 OrganizationPreReceiveHooks: String("opr"),
8031 OrganizationProjects: String("op"),
8032 OrganizationSecrets: String("os"),
8033 OrganizationSelfHostedRunners: String("osh"),
8034 OrganizationUserBlocking: String("oub"),
8035 Packages: String("pkg"),
8036 Pages: String("pg"),
8037 PullRequests: String("pr"),
8038 RepositoryHooks: String("rh"),
8039 RepositoryProjects: String("rp"),
8040 RepositoryPreReceiveHooks: String("rprh"),
8041 Secrets: String("s"),
8042 SecretScanningAlerts: String("ssa"),
8043 SecurityEvents: String("se"),
8044 SingleFile: String("sf"),
8045 Statuses: String("s"),
8046 TeamDiscussions: String("td"),
8047 VulnerabilityAlerts: String("va"),
8048 Workflows: String("w"),
8049 },
8050 CreatedAt: &Timestamp{referenceTime},
8051 UpdatedAt: &Timestamp{referenceTime},
8052 HasMultipleSingleFiles: Bool(false),
8053 SuspendedBy: &User{
8054 Login: String("l"),
8055 ID: Int64(1),
8056 URL: String("u"),
8057 AvatarURL: String("a"),
8058 GravatarID: String("g"),
8059 Name: String("n"),
8060 Company: String("c"),
8061 Blog: String("b"),
8062 Location: String("l"),
8063 Email: String("e"),
8064 Hireable: Bool(true),
8065 Bio: String("b"),
8066 TwitterUsername: String("t"),
8067 PublicRepos: Int(1),
8068 Followers: Int(1),
8069 Following: Int(1),
8070 CreatedAt: &Timestamp{referenceTime},
8071 SuspendedAt: &Timestamp{referenceTime},
8072 },
8073 SuspendedAt: &Timestamp{referenceTime},
8074 },
8075 }
8076
8077 want := `{
8078 "action": "a",
8079 "branch": "b",
8080 "client_payload": {
8081 "key": "value"
8082 },
8083 "repository": {
8084 "id": 1,
8085 "name": "n",
8086 "url": "s"
8087 },
8088 "organization": {
8089 "name": "n",
8090 "company": "c",
8091 "blog": "b",
8092 "location": "loc",
8093 "email": "e",
8094 "twitter_username": "tu",
8095 "description": "d",
8096 "billing_email": "be",
8097 "is_verified": true,
8098 "has_organization_projects": true,
8099 "has_repository_projects": true,
8100 "default_repository_permission": "drp",
8101 "members_can_create_repositories": true,
8102 "members_can_create_public_repositories": false,
8103 "members_can_create_private_repositories": true,
8104 "members_can_create_internal_repositories": true,
8105 "members_allowed_repository_creation_type": "marct",
8106 "members_can_create_pages": true,
8107 "members_can_create_public_pages": false,
8108 "members_can_create_private_pages": true
8109 },
8110 "sender": {
8111 "login": "l",
8112 "id": 1,
8113 "node_id": "n",
8114 "avatar_url": "a",
8115 "url": "u",
8116 "events_url": "e",
8117 "repos_url": "r"
8118 },
8119 "installation": {
8120 "id": 1,
8121 "node_id": "nid",
8122 "app_id": 1,
8123 "app_slug": "as",
8124 "target_id": 1,
8125 "account": {
8126 "login": "l",
8127 "id": 1,
8128 "avatar_url": "a",
8129 "gravatar_id": "g",
8130 "name": "n",
8131 "company": "c",
8132 "blog": "b",
8133 "location": "l",
8134 "email": "e",
8135 "hireable": true,
8136 "bio": "b",
8137 "twitter_username": "t",
8138 "public_repos": 1,
8139 "followers": 1,
8140 "following": 1,
8141 "created_at": ` + referenceTimeStr + `,
8142 "suspended_at": ` + referenceTimeStr + `,
8143 "url": "u"
8144 },
8145 "access_tokens_url": "atu",
8146 "repositories_url": "ru",
8147 "html_url": "hu",
8148 "target_type": "tt",
8149 "single_file_name": "sfn",
8150 "repository_selection": "rs",
8151 "events": [
8152 "e"
8153 ],
8154 "single_file_paths": [
8155 "s"
8156 ],
8157 "permissions": {
8158 "actions": "a",
8159 "administration": "ad",
8160 "checks": "c",
8161 "contents": "co",
8162 "content_references": "cr",
8163 "deployments": "d",
8164 "environments": "e",
8165 "issues": "i",
8166 "metadata": "md",
8167 "members": "m",
8168 "organization_administration": "oa",
8169 "organization_hooks": "oh",
8170 "organization_plan": "op",
8171 "organization_pre_receive_hooks": "opr",
8172 "organization_projects": "op",
8173 "organization_secrets": "os",
8174 "organization_self_hosted_runners": "osh",
8175 "organization_user_blocking": "oub",
8176 "packages": "pkg",
8177 "pages": "pg",
8178 "pull_requests": "pr",
8179 "repository_hooks": "rh",
8180 "repository_projects": "rp",
8181 "repository_pre_receive_hooks": "rprh",
8182 "secrets": "s",
8183 "secret_scanning_alerts": "ssa",
8184 "security_events": "se",
8185 "single_file": "sf",
8186 "statuses": "s",
8187 "team_discussions": "td",
8188 "vulnerability_alerts": "va",
8189 "workflows": "w"
8190 },
8191 "created_at": ` + referenceTimeStr + `,
8192 "updated_at": ` + referenceTimeStr + `,
8193 "has_multiple_single_files": false,
8194 "suspended_by": {
8195 "login": "l",
8196 "id": 1,
8197 "avatar_url": "a",
8198 "gravatar_id": "g",
8199 "name": "n",
8200 "company": "c",
8201 "blog": "b",
8202 "location": "l",
8203 "email": "e",
8204 "hireable": true,
8205 "bio": "b",
8206 "twitter_username": "t",
8207 "public_repos": 1,
8208 "followers": 1,
8209 "following": 1,
8210 "created_at": ` + referenceTimeStr + `,
8211 "suspended_at": ` + referenceTimeStr + `,
8212 "url": "u"
8213 },
8214 "suspended_at": ` + referenceTimeStr + `
8215 }
8216 }`
8217
8218 testJSONMarshal(t, u, want)
8219 }
8220
8221 func TestRepositoryImportEvent_Marshal(t *testing.T) {
8222 testJSONMarshal(t, &RepositoryImportEvent{}, "{}")
8223
8224 u := &RepositoryImportEvent{
8225 Status: String("success"),
8226 Repo: &Repository{
8227 ID: Int64(1),
8228 URL: String("s"),
8229 Name: String("n"),
8230 },
8231 Org: &Organization{
8232 BillingEmail: String("be"),
8233 Blog: String("b"),
8234 Company: String("c"),
8235 Email: String("e"),
8236 TwitterUsername: String("tu"),
8237 Location: String("loc"),
8238 Name: String("n"),
8239 Description: String("d"),
8240 IsVerified: Bool(true),
8241 HasOrganizationProjects: Bool(true),
8242 HasRepositoryProjects: Bool(true),
8243 DefaultRepoPermission: String("drp"),
8244 MembersCanCreateRepos: Bool(true),
8245 MembersCanCreateInternalRepos: Bool(true),
8246 MembersCanCreatePrivateRepos: Bool(true),
8247 MembersCanCreatePublicRepos: Bool(false),
8248 MembersAllowedRepositoryCreationType: String("marct"),
8249 MembersCanCreatePages: Bool(true),
8250 MembersCanCreatePublicPages: Bool(false),
8251 MembersCanCreatePrivatePages: Bool(true),
8252 },
8253 Sender: &User{
8254 Login: String("l"),
8255 ID: Int64(1),
8256 NodeID: String("n"),
8257 URL: String("u"),
8258 ReposURL: String("r"),
8259 EventsURL: String("e"),
8260 AvatarURL: String("a"),
8261 },
8262 }
8263
8264 want := `{
8265 "status": "success",
8266 "repository": {
8267 "id": 1,
8268 "name": "n",
8269 "url": "s"
8270 },
8271 "organization": {
8272 "name": "n",
8273 "company": "c",
8274 "blog": "b",
8275 "location": "loc",
8276 "email": "e",
8277 "twitter_username": "tu",
8278 "description": "d",
8279 "billing_email": "be",
8280 "is_verified": true,
8281 "has_organization_projects": true,
8282 "has_repository_projects": true,
8283 "default_repository_permission": "drp",
8284 "members_can_create_repositories": true,
8285 "members_can_create_public_repositories": false,
8286 "members_can_create_private_repositories": true,
8287 "members_can_create_internal_repositories": true,
8288 "members_allowed_repository_creation_type": "marct",
8289 "members_can_create_pages": true,
8290 "members_can_create_public_pages": false,
8291 "members_can_create_private_pages": true
8292 },
8293 "sender": {
8294 "login": "l",
8295 "id": 1,
8296 "node_id": "n",
8297 "avatar_url": "a",
8298 "url": "u",
8299 "events_url": "e",
8300 "repos_url": "r"
8301 }
8302 }`
8303
8304 testJSONMarshal(t, u, want)
8305 }
8306
8307 func TestRepositoryEvent_Marshal(t *testing.T) {
8308 testJSONMarshal(t, &RepositoryEvent{}, "{}")
8309
8310 u := &RepositoryEvent{
8311 Action: String("a"),
8312 Repo: &Repository{
8313 ID: Int64(1),
8314 URL: String("s"),
8315 Name: String("n"),
8316 },
8317 Org: &Organization{
8318 BillingEmail: String("be"),
8319 Blog: String("b"),
8320 Company: String("c"),
8321 Email: String("e"),
8322 TwitterUsername: String("tu"),
8323 Location: String("loc"),
8324 Name: String("n"),
8325 Description: String("d"),
8326 IsVerified: Bool(true),
8327 HasOrganizationProjects: Bool(true),
8328 HasRepositoryProjects: Bool(true),
8329 DefaultRepoPermission: String("drp"),
8330 MembersCanCreateRepos: Bool(true),
8331 MembersCanCreateInternalRepos: Bool(true),
8332 MembersCanCreatePrivateRepos: Bool(true),
8333 MembersCanCreatePublicRepos: Bool(false),
8334 MembersAllowedRepositoryCreationType: String("marct"),
8335 MembersCanCreatePages: Bool(true),
8336 MembersCanCreatePublicPages: Bool(false),
8337 MembersCanCreatePrivatePages: Bool(true),
8338 },
8339 Sender: &User{
8340 Login: String("l"),
8341 ID: Int64(1),
8342 NodeID: String("n"),
8343 URL: String("u"),
8344 ReposURL: String("r"),
8345 EventsURL: String("e"),
8346 AvatarURL: String("a"),
8347 },
8348 Installation: &Installation{
8349 ID: Int64(1),
8350 NodeID: String("nid"),
8351 AppID: Int64(1),
8352 AppSlug: String("as"),
8353 TargetID: Int64(1),
8354 Account: &User{
8355 Login: String("l"),
8356 ID: Int64(1),
8357 URL: String("u"),
8358 AvatarURL: String("a"),
8359 GravatarID: String("g"),
8360 Name: String("n"),
8361 Company: String("c"),
8362 Blog: String("b"),
8363 Location: String("l"),
8364 Email: String("e"),
8365 Hireable: Bool(true),
8366 Bio: String("b"),
8367 TwitterUsername: String("t"),
8368 PublicRepos: Int(1),
8369 Followers: Int(1),
8370 Following: Int(1),
8371 CreatedAt: &Timestamp{referenceTime},
8372 SuspendedAt: &Timestamp{referenceTime},
8373 },
8374 AccessTokensURL: String("atu"),
8375 RepositoriesURL: String("ru"),
8376 HTMLURL: String("hu"),
8377 TargetType: String("tt"),
8378 SingleFileName: String("sfn"),
8379 RepositorySelection: String("rs"),
8380 Events: []string{"e"},
8381 SingleFilePaths: []string{"s"},
8382 Permissions: &InstallationPermissions{
8383 Actions: String("a"),
8384 Administration: String("ad"),
8385 Checks: String("c"),
8386 Contents: String("co"),
8387 ContentReferences: String("cr"),
8388 Deployments: String("d"),
8389 Environments: String("e"),
8390 Issues: String("i"),
8391 Metadata: String("md"),
8392 Members: String("m"),
8393 OrganizationAdministration: String("oa"),
8394 OrganizationHooks: String("oh"),
8395 OrganizationPlan: String("op"),
8396 OrganizationPreReceiveHooks: String("opr"),
8397 OrganizationProjects: String("op"),
8398 OrganizationSecrets: String("os"),
8399 OrganizationSelfHostedRunners: String("osh"),
8400 OrganizationUserBlocking: String("oub"),
8401 Packages: String("pkg"),
8402 Pages: String("pg"),
8403 PullRequests: String("pr"),
8404 RepositoryHooks: String("rh"),
8405 RepositoryProjects: String("rp"),
8406 RepositoryPreReceiveHooks: String("rprh"),
8407 Secrets: String("s"),
8408 SecretScanningAlerts: String("ssa"),
8409 SecurityEvents: String("se"),
8410 SingleFile: String("sf"),
8411 Statuses: String("s"),
8412 TeamDiscussions: String("td"),
8413 VulnerabilityAlerts: String("va"),
8414 Workflows: String("w"),
8415 },
8416 CreatedAt: &Timestamp{referenceTime},
8417 UpdatedAt: &Timestamp{referenceTime},
8418 HasMultipleSingleFiles: Bool(false),
8419 SuspendedBy: &User{
8420 Login: String("l"),
8421 ID: Int64(1),
8422 URL: String("u"),
8423 AvatarURL: String("a"),
8424 GravatarID: String("g"),
8425 Name: String("n"),
8426 Company: String("c"),
8427 Blog: String("b"),
8428 Location: String("l"),
8429 Email: String("e"),
8430 Hireable: Bool(true),
8431 Bio: String("b"),
8432 TwitterUsername: String("t"),
8433 PublicRepos: Int(1),
8434 Followers: Int(1),
8435 Following: Int(1),
8436 CreatedAt: &Timestamp{referenceTime},
8437 SuspendedAt: &Timestamp{referenceTime},
8438 },
8439 SuspendedAt: &Timestamp{referenceTime},
8440 },
8441 }
8442
8443 want := `{
8444 "action": "a",
8445 "repository": {
8446 "id": 1,
8447 "name": "n",
8448 "url": "s"
8449 },
8450 "organization": {
8451 "name": "n",
8452 "company": "c",
8453 "blog": "b",
8454 "location": "loc",
8455 "email": "e",
8456 "twitter_username": "tu",
8457 "description": "d",
8458 "billing_email": "be",
8459 "is_verified": true,
8460 "has_organization_projects": true,
8461 "has_repository_projects": true,
8462 "default_repository_permission": "drp",
8463 "members_can_create_repositories": true,
8464 "members_can_create_public_repositories": false,
8465 "members_can_create_private_repositories": true,
8466 "members_can_create_internal_repositories": true,
8467 "members_allowed_repository_creation_type": "marct",
8468 "members_can_create_pages": true,
8469 "members_can_create_public_pages": false,
8470 "members_can_create_private_pages": true
8471 },
8472 "sender": {
8473 "login": "l",
8474 "id": 1,
8475 "node_id": "n",
8476 "avatar_url": "a",
8477 "url": "u",
8478 "events_url": "e",
8479 "repos_url": "r"
8480 },
8481 "installation": {
8482 "id": 1,
8483 "node_id": "nid",
8484 "app_id": 1,
8485 "app_slug": "as",
8486 "target_id": 1,
8487 "account": {
8488 "login": "l",
8489 "id": 1,
8490 "avatar_url": "a",
8491 "gravatar_id": "g",
8492 "name": "n",
8493 "company": "c",
8494 "blog": "b",
8495 "location": "l",
8496 "email": "e",
8497 "hireable": true,
8498 "bio": "b",
8499 "twitter_username": "t",
8500 "public_repos": 1,
8501 "followers": 1,
8502 "following": 1,
8503 "created_at": ` + referenceTimeStr + `,
8504 "suspended_at": ` + referenceTimeStr + `,
8505 "url": "u"
8506 },
8507 "access_tokens_url": "atu",
8508 "repositories_url": "ru",
8509 "html_url": "hu",
8510 "target_type": "tt",
8511 "single_file_name": "sfn",
8512 "repository_selection": "rs",
8513 "events": [
8514 "e"
8515 ],
8516 "single_file_paths": [
8517 "s"
8518 ],
8519 "permissions": {
8520 "actions": "a",
8521 "administration": "ad",
8522 "checks": "c",
8523 "contents": "co",
8524 "content_references": "cr",
8525 "deployments": "d",
8526 "environments": "e",
8527 "issues": "i",
8528 "metadata": "md",
8529 "members": "m",
8530 "organization_administration": "oa",
8531 "organization_hooks": "oh",
8532 "organization_plan": "op",
8533 "organization_pre_receive_hooks": "opr",
8534 "organization_projects": "op",
8535 "organization_secrets": "os",
8536 "organization_self_hosted_runners": "osh",
8537 "organization_user_blocking": "oub",
8538 "packages": "pkg",
8539 "pages": "pg",
8540 "pull_requests": "pr",
8541 "repository_hooks": "rh",
8542 "repository_projects": "rp",
8543 "repository_pre_receive_hooks": "rprh",
8544 "secrets": "s",
8545 "secret_scanning_alerts": "ssa",
8546 "security_events": "se",
8547 "single_file": "sf",
8548 "statuses": "s",
8549 "team_discussions": "td",
8550 "vulnerability_alerts": "va",
8551 "workflows": "w"
8552 },
8553 "created_at": ` + referenceTimeStr + `,
8554 "updated_at": ` + referenceTimeStr + `,
8555 "has_multiple_single_files": false,
8556 "suspended_by": {
8557 "login": "l",
8558 "id": 1,
8559 "avatar_url": "a",
8560 "gravatar_id": "g",
8561 "name": "n",
8562 "company": "c",
8563 "blog": "b",
8564 "location": "l",
8565 "email": "e",
8566 "hireable": true,
8567 "bio": "b",
8568 "twitter_username": "t",
8569 "public_repos": 1,
8570 "followers": 1,
8571 "following": 1,
8572 "created_at": ` + referenceTimeStr + `,
8573 "suspended_at": ` + referenceTimeStr + `,
8574 "url": "u"
8575 },
8576 "suspended_at": ` + referenceTimeStr + `
8577 }
8578 }`
8579
8580 testJSONMarshal(t, u, want)
8581 }
8582
8583 func TestReleaseEvent_Marshal(t *testing.T) {
8584 testJSONMarshal(t, &ReleaseEvent{}, "{}")
8585
8586 u := &ReleaseEvent{
8587 Action: String("a"),
8588 Release: &RepositoryRelease{
8589 Name: String("n"),
8590 DiscussionCategoryName: String("dcn"),
8591 ID: Int64(2),
8592 CreatedAt: &Timestamp{referenceTime},
8593 PublishedAt: &Timestamp{referenceTime},
8594 URL: String("url"),
8595 HTMLURL: String("htmlurl"),
8596 AssetsURL: String("assetsurl"),
8597 Assets: []*ReleaseAsset{{ID: Int64(1)}},
8598 UploadURL: String("uploadurl"),
8599 ZipballURL: String("zipballurl"),
8600 TarballURL: String("tarballurl"),
8601 Author: &User{Name: String("octocat")},
8602 NodeID: String("nid"),
8603 },
8604 Repo: &Repository{
8605 ID: Int64(1),
8606 URL: String("s"),
8607 Name: String("n"),
8608 },
8609 Sender: &User{
8610 Login: String("l"),
8611 ID: Int64(1),
8612 NodeID: String("n"),
8613 URL: String("u"),
8614 ReposURL: String("r"),
8615 EventsURL: String("e"),
8616 AvatarURL: String("a"),
8617 },
8618 Installation: &Installation{
8619 ID: Int64(1),
8620 NodeID: String("nid"),
8621 AppID: Int64(1),
8622 AppSlug: String("as"),
8623 TargetID: Int64(1),
8624 Account: &User{
8625 Login: String("l"),
8626 ID: Int64(1),
8627 URL: String("u"),
8628 AvatarURL: String("a"),
8629 GravatarID: String("g"),
8630 Name: String("n"),
8631 Company: String("c"),
8632 Blog: String("b"),
8633 Location: String("l"),
8634 Email: String("e"),
8635 Hireable: Bool(true),
8636 Bio: String("b"),
8637 TwitterUsername: String("t"),
8638 PublicRepos: Int(1),
8639 Followers: Int(1),
8640 Following: Int(1),
8641 CreatedAt: &Timestamp{referenceTime},
8642 SuspendedAt: &Timestamp{referenceTime},
8643 },
8644 AccessTokensURL: String("atu"),
8645 RepositoriesURL: String("ru"),
8646 HTMLURL: String("hu"),
8647 TargetType: String("tt"),
8648 SingleFileName: String("sfn"),
8649 RepositorySelection: String("rs"),
8650 Events: []string{"e"},
8651 SingleFilePaths: []string{"s"},
8652 Permissions: &InstallationPermissions{
8653 Actions: String("a"),
8654 Administration: String("ad"),
8655 Checks: String("c"),
8656 Contents: String("co"),
8657 ContentReferences: String("cr"),
8658 Deployments: String("d"),
8659 Environments: String("e"),
8660 Issues: String("i"),
8661 Metadata: String("md"),
8662 Members: String("m"),
8663 OrganizationAdministration: String("oa"),
8664 OrganizationHooks: String("oh"),
8665 OrganizationPlan: String("op"),
8666 OrganizationPreReceiveHooks: String("opr"),
8667 OrganizationProjects: String("op"),
8668 OrganizationSecrets: String("os"),
8669 OrganizationSelfHostedRunners: String("osh"),
8670 OrganizationUserBlocking: String("oub"),
8671 Packages: String("pkg"),
8672 Pages: String("pg"),
8673 PullRequests: String("pr"),
8674 RepositoryHooks: String("rh"),
8675 RepositoryProjects: String("rp"),
8676 RepositoryPreReceiveHooks: String("rprh"),
8677 Secrets: String("s"),
8678 SecretScanningAlerts: String("ssa"),
8679 SecurityEvents: String("se"),
8680 SingleFile: String("sf"),
8681 Statuses: String("s"),
8682 TeamDiscussions: String("td"),
8683 VulnerabilityAlerts: String("va"),
8684 Workflows: String("w"),
8685 },
8686 CreatedAt: &Timestamp{referenceTime},
8687 UpdatedAt: &Timestamp{referenceTime},
8688 HasMultipleSingleFiles: Bool(false),
8689 SuspendedBy: &User{
8690 Login: String("l"),
8691 ID: Int64(1),
8692 URL: String("u"),
8693 AvatarURL: String("a"),
8694 GravatarID: String("g"),
8695 Name: String("n"),
8696 Company: String("c"),
8697 Blog: String("b"),
8698 Location: String("l"),
8699 Email: String("e"),
8700 Hireable: Bool(true),
8701 Bio: String("b"),
8702 TwitterUsername: String("t"),
8703 PublicRepos: Int(1),
8704 Followers: Int(1),
8705 Following: Int(1),
8706 CreatedAt: &Timestamp{referenceTime},
8707 SuspendedAt: &Timestamp{referenceTime},
8708 },
8709 SuspendedAt: &Timestamp{referenceTime},
8710 },
8711 }
8712
8713 want := `{
8714 "action": "a",
8715 "release": {
8716 "name": "n",
8717 "discussion_category_name": "dcn",
8718 "id": 2,
8719 "created_at": ` + referenceTimeStr + `,
8720 "published_at": ` + referenceTimeStr + `,
8721 "url": "url",
8722 "html_url": "htmlurl",
8723 "assets_url": "assetsurl",
8724 "assets": [
8725 {
8726 "id": 1
8727 }
8728 ],
8729 "upload_url": "uploadurl",
8730 "zipball_url": "zipballurl",
8731 "tarball_url": "tarballurl",
8732 "author": {
8733 "name": "octocat"
8734 },
8735 "node_id": "nid"
8736 },
8737 "repository": {
8738 "id": 1,
8739 "name": "n",
8740 "url": "s"
8741 },
8742 "sender": {
8743 "login": "l",
8744 "id": 1,
8745 "node_id": "n",
8746 "avatar_url": "a",
8747 "url": "u",
8748 "events_url": "e",
8749 "repos_url": "r"
8750 },
8751 "installation": {
8752 "id": 1,
8753 "node_id": "nid",
8754 "app_id": 1,
8755 "app_slug": "as",
8756 "target_id": 1,
8757 "account": {
8758 "login": "l",
8759 "id": 1,
8760 "avatar_url": "a",
8761 "gravatar_id": "g",
8762 "name": "n",
8763 "company": "c",
8764 "blog": "b",
8765 "location": "l",
8766 "email": "e",
8767 "hireable": true,
8768 "bio": "b",
8769 "twitter_username": "t",
8770 "public_repos": 1,
8771 "followers": 1,
8772 "following": 1,
8773 "created_at": ` + referenceTimeStr + `,
8774 "suspended_at": ` + referenceTimeStr + `,
8775 "url": "u"
8776 },
8777 "access_tokens_url": "atu",
8778 "repositories_url": "ru",
8779 "html_url": "hu",
8780 "target_type": "tt",
8781 "single_file_name": "sfn",
8782 "repository_selection": "rs",
8783 "events": [
8784 "e"
8785 ],
8786 "single_file_paths": [
8787 "s"
8788 ],
8789 "permissions": {
8790 "actions": "a",
8791 "administration": "ad",
8792 "checks": "c",
8793 "contents": "co",
8794 "content_references": "cr",
8795 "deployments": "d",
8796 "environments": "e",
8797 "issues": "i",
8798 "metadata": "md",
8799 "members": "m",
8800 "organization_administration": "oa",
8801 "organization_hooks": "oh",
8802 "organization_plan": "op",
8803 "organization_pre_receive_hooks": "opr",
8804 "organization_projects": "op",
8805 "organization_secrets": "os",
8806 "organization_self_hosted_runners": "osh",
8807 "organization_user_blocking": "oub",
8808 "packages": "pkg",
8809 "pages": "pg",
8810 "pull_requests": "pr",
8811 "repository_hooks": "rh",
8812 "repository_projects": "rp",
8813 "repository_pre_receive_hooks": "rprh",
8814 "secrets": "s",
8815 "secret_scanning_alerts": "ssa",
8816 "security_events": "se",
8817 "single_file": "sf",
8818 "statuses": "s",
8819 "team_discussions": "td",
8820 "vulnerability_alerts": "va",
8821 "workflows": "w"
8822 },
8823 "created_at": ` + referenceTimeStr + `,
8824 "updated_at": ` + referenceTimeStr + `,
8825 "has_multiple_single_files": false,
8826 "suspended_by": {
8827 "login": "l",
8828 "id": 1,
8829 "avatar_url": "a",
8830 "gravatar_id": "g",
8831 "name": "n",
8832 "company": "c",
8833 "blog": "b",
8834 "location": "l",
8835 "email": "e",
8836 "hireable": true,
8837 "bio": "b",
8838 "twitter_username": "t",
8839 "public_repos": 1,
8840 "followers": 1,
8841 "following": 1,
8842 "created_at": ` + referenceTimeStr + `,
8843 "suspended_at": ` + referenceTimeStr + `,
8844 "url": "u"
8845 },
8846 "suspended_at": ` + referenceTimeStr + `
8847 }
8848 }`
8849
8850 testJSONMarshal(t, u, want)
8851 }
8852
8853 func TestContentReferenceEvent_Marshal(t *testing.T) {
8854 testJSONMarshal(t, &ContentReferenceEvent{}, "{}")
8855
8856 u := &ContentReferenceEvent{
8857 Action: String("a"),
8858 ContentReference: &ContentReference{
8859 ID: Int64(1),
8860 NodeID: String("nid"),
8861 Reference: String("ref"),
8862 },
8863 Repo: &Repository{
8864 ID: Int64(1),
8865 URL: String("s"),
8866 Name: String("n"),
8867 },
8868 Sender: &User{
8869 Login: String("l"),
8870 ID: Int64(1),
8871 NodeID: String("n"),
8872 URL: String("u"),
8873 ReposURL: String("r"),
8874 EventsURL: String("e"),
8875 AvatarURL: String("a"),
8876 },
8877 Installation: &Installation{
8878 ID: Int64(1),
8879 NodeID: String("nid"),
8880 AppID: Int64(1),
8881 AppSlug: String("as"),
8882 TargetID: Int64(1),
8883 Account: &User{
8884 Login: String("l"),
8885 ID: Int64(1),
8886 URL: String("u"),
8887 AvatarURL: String("a"),
8888 GravatarID: String("g"),
8889 Name: String("n"),
8890 Company: String("c"),
8891 Blog: String("b"),
8892 Location: String("l"),
8893 Email: String("e"),
8894 Hireable: Bool(true),
8895 Bio: String("b"),
8896 TwitterUsername: String("t"),
8897 PublicRepos: Int(1),
8898 Followers: Int(1),
8899 Following: Int(1),
8900 CreatedAt: &Timestamp{referenceTime},
8901 SuspendedAt: &Timestamp{referenceTime},
8902 },
8903 AccessTokensURL: String("atu"),
8904 RepositoriesURL: String("ru"),
8905 HTMLURL: String("hu"),
8906 TargetType: String("tt"),
8907 SingleFileName: String("sfn"),
8908 RepositorySelection: String("rs"),
8909 Events: []string{"e"},
8910 SingleFilePaths: []string{"s"},
8911 Permissions: &InstallationPermissions{
8912 Actions: String("a"),
8913 Administration: String("ad"),
8914 Checks: String("c"),
8915 Contents: String("co"),
8916 ContentReferences: String("cr"),
8917 Deployments: String("d"),
8918 Environments: String("e"),
8919 Issues: String("i"),
8920 Metadata: String("md"),
8921 Members: String("m"),
8922 OrganizationAdministration: String("oa"),
8923 OrganizationHooks: String("oh"),
8924 OrganizationPlan: String("op"),
8925 OrganizationPreReceiveHooks: String("opr"),
8926 OrganizationProjects: String("op"),
8927 OrganizationSecrets: String("os"),
8928 OrganizationSelfHostedRunners: String("osh"),
8929 OrganizationUserBlocking: String("oub"),
8930 Packages: String("pkg"),
8931 Pages: String("pg"),
8932 PullRequests: String("pr"),
8933 RepositoryHooks: String("rh"),
8934 RepositoryProjects: String("rp"),
8935 RepositoryPreReceiveHooks: String("rprh"),
8936 Secrets: String("s"),
8937 SecretScanningAlerts: String("ssa"),
8938 SecurityEvents: String("se"),
8939 SingleFile: String("sf"),
8940 Statuses: String("s"),
8941 TeamDiscussions: String("td"),
8942 VulnerabilityAlerts: String("va"),
8943 Workflows: String("w"),
8944 },
8945 CreatedAt: &Timestamp{referenceTime},
8946 UpdatedAt: &Timestamp{referenceTime},
8947 HasMultipleSingleFiles: Bool(false),
8948 SuspendedBy: &User{
8949 Login: String("l"),
8950 ID: Int64(1),
8951 URL: String("u"),
8952 AvatarURL: String("a"),
8953 GravatarID: String("g"),
8954 Name: String("n"),
8955 Company: String("c"),
8956 Blog: String("b"),
8957 Location: String("l"),
8958 Email: String("e"),
8959 Hireable: Bool(true),
8960 Bio: String("b"),
8961 TwitterUsername: String("t"),
8962 PublicRepos: Int(1),
8963 Followers: Int(1),
8964 Following: Int(1),
8965 CreatedAt: &Timestamp{referenceTime},
8966 SuspendedAt: &Timestamp{referenceTime},
8967 },
8968 SuspendedAt: &Timestamp{referenceTime},
8969 },
8970 }
8971
8972 want := `{
8973 "action": "a",
8974 "content_reference": {
8975 "id": 1,
8976 "node_id": "nid",
8977 "reference": "ref"
8978 },
8979 "repository": {
8980 "id": 1,
8981 "name": "n",
8982 "url": "s"
8983 },
8984 "sender": {
8985 "login": "l",
8986 "id": 1,
8987 "node_id": "n",
8988 "avatar_url": "a",
8989 "url": "u",
8990 "events_url": "e",
8991 "repos_url": "r"
8992 },
8993 "installation": {
8994 "id": 1,
8995 "node_id": "nid",
8996 "app_id": 1,
8997 "app_slug": "as",
8998 "target_id": 1,
8999 "account": {
9000 "login": "l",
9001 "id": 1,
9002 "avatar_url": "a",
9003 "gravatar_id": "g",
9004 "name": "n",
9005 "company": "c",
9006 "blog": "b",
9007 "location": "l",
9008 "email": "e",
9009 "hireable": true,
9010 "bio": "b",
9011 "twitter_username": "t",
9012 "public_repos": 1,
9013 "followers": 1,
9014 "following": 1,
9015 "created_at": ` + referenceTimeStr + `,
9016 "suspended_at": ` + referenceTimeStr + `,
9017 "url": "u"
9018 },
9019 "access_tokens_url": "atu",
9020 "repositories_url": "ru",
9021 "html_url": "hu",
9022 "target_type": "tt",
9023 "single_file_name": "sfn",
9024 "repository_selection": "rs",
9025 "events": [
9026 "e"
9027 ],
9028 "single_file_paths": [
9029 "s"
9030 ],
9031 "permissions": {
9032 "actions": "a",
9033 "administration": "ad",
9034 "checks": "c",
9035 "contents": "co",
9036 "content_references": "cr",
9037 "deployments": "d",
9038 "environments": "e",
9039 "issues": "i",
9040 "metadata": "md",
9041 "members": "m",
9042 "organization_administration": "oa",
9043 "organization_hooks": "oh",
9044 "organization_plan": "op",
9045 "organization_pre_receive_hooks": "opr",
9046 "organization_projects": "op",
9047 "organization_secrets": "os",
9048 "organization_self_hosted_runners": "osh",
9049 "organization_user_blocking": "oub",
9050 "packages": "pkg",
9051 "pages": "pg",
9052 "pull_requests": "pr",
9053 "repository_hooks": "rh",
9054 "repository_projects": "rp",
9055 "repository_pre_receive_hooks": "rprh",
9056 "secrets": "s",
9057 "secret_scanning_alerts": "ssa",
9058 "security_events": "se",
9059 "single_file": "sf",
9060 "statuses": "s",
9061 "team_discussions": "td",
9062 "vulnerability_alerts": "va",
9063 "workflows": "w"
9064 },
9065 "created_at": ` + referenceTimeStr + `,
9066 "updated_at": ` + referenceTimeStr + `,
9067 "has_multiple_single_files": false,
9068 "suspended_by": {
9069 "login": "l",
9070 "id": 1,
9071 "avatar_url": "a",
9072 "gravatar_id": "g",
9073 "name": "n",
9074 "company": "c",
9075 "blog": "b",
9076 "location": "l",
9077 "email": "e",
9078 "hireable": true,
9079 "bio": "b",
9080 "twitter_username": "t",
9081 "public_repos": 1,
9082 "followers": 1,
9083 "following": 1,
9084 "created_at": ` + referenceTimeStr + `,
9085 "suspended_at": ` + referenceTimeStr + `,
9086 "url": "u"
9087 },
9088 "suspended_at": ` + referenceTimeStr + `
9089 }
9090 }`
9091
9092 testJSONMarshal(t, u, want)
9093 }
9094
9095 func TestMemberEvent_Marshal(t *testing.T) {
9096 testJSONMarshal(t, &MemberEvent{}, "{}")
9097
9098 u := &MemberEvent{
9099 Action: String("a"),
9100 Member: &User{
9101 Login: String("l"),
9102 ID: Int64(1),
9103 NodeID: String("n"),
9104 URL: String("u"),
9105 ReposURL: String("r"),
9106 EventsURL: String("e"),
9107 AvatarURL: String("a"),
9108 },
9109 Repo: &Repository{
9110 ID: Int64(1),
9111 URL: String("s"),
9112 Name: String("n"),
9113 },
9114 Sender: &User{
9115 Login: String("l"),
9116 ID: Int64(1),
9117 NodeID: String("n"),
9118 URL: String("u"),
9119 ReposURL: String("r"),
9120 EventsURL: String("e"),
9121 AvatarURL: String("a"),
9122 },
9123 Installation: &Installation{
9124 ID: Int64(1),
9125 NodeID: String("nid"),
9126 AppID: Int64(1),
9127 AppSlug: String("as"),
9128 TargetID: Int64(1),
9129 Account: &User{
9130 Login: String("l"),
9131 ID: Int64(1),
9132 URL: String("u"),
9133 AvatarURL: String("a"),
9134 GravatarID: String("g"),
9135 Name: String("n"),
9136 Company: String("c"),
9137 Blog: String("b"),
9138 Location: String("l"),
9139 Email: String("e"),
9140 Hireable: Bool(true),
9141 Bio: String("b"),
9142 TwitterUsername: String("t"),
9143 PublicRepos: Int(1),
9144 Followers: Int(1),
9145 Following: Int(1),
9146 CreatedAt: &Timestamp{referenceTime},
9147 SuspendedAt: &Timestamp{referenceTime},
9148 },
9149 AccessTokensURL: String("atu"),
9150 RepositoriesURL: String("ru"),
9151 HTMLURL: String("hu"),
9152 TargetType: String("tt"),
9153 SingleFileName: String("sfn"),
9154 RepositorySelection: String("rs"),
9155 Events: []string{"e"},
9156 SingleFilePaths: []string{"s"},
9157 Permissions: &InstallationPermissions{
9158 Actions: String("a"),
9159 Administration: String("ad"),
9160 Checks: String("c"),
9161 Contents: String("co"),
9162 ContentReferences: String("cr"),
9163 Deployments: String("d"),
9164 Environments: String("e"),
9165 Issues: String("i"),
9166 Metadata: String("md"),
9167 Members: String("m"),
9168 OrganizationAdministration: String("oa"),
9169 OrganizationHooks: String("oh"),
9170 OrganizationPlan: String("op"),
9171 OrganizationPreReceiveHooks: String("opr"),
9172 OrganizationProjects: String("op"),
9173 OrganizationSecrets: String("os"),
9174 OrganizationSelfHostedRunners: String("osh"),
9175 OrganizationUserBlocking: String("oub"),
9176 Packages: String("pkg"),
9177 Pages: String("pg"),
9178 PullRequests: String("pr"),
9179 RepositoryHooks: String("rh"),
9180 RepositoryProjects: String("rp"),
9181 RepositoryPreReceiveHooks: String("rprh"),
9182 Secrets: String("s"),
9183 SecretScanningAlerts: String("ssa"),
9184 SecurityEvents: String("se"),
9185 SingleFile: String("sf"),
9186 Statuses: String("s"),
9187 TeamDiscussions: String("td"),
9188 VulnerabilityAlerts: String("va"),
9189 Workflows: String("w"),
9190 },
9191 CreatedAt: &Timestamp{referenceTime},
9192 UpdatedAt: &Timestamp{referenceTime},
9193 HasMultipleSingleFiles: Bool(false),
9194 SuspendedBy: &User{
9195 Login: String("l"),
9196 ID: Int64(1),
9197 URL: String("u"),
9198 AvatarURL: String("a"),
9199 GravatarID: String("g"),
9200 Name: String("n"),
9201 Company: String("c"),
9202 Blog: String("b"),
9203 Location: String("l"),
9204 Email: String("e"),
9205 Hireable: Bool(true),
9206 Bio: String("b"),
9207 TwitterUsername: String("t"),
9208 PublicRepos: Int(1),
9209 Followers: Int(1),
9210 Following: Int(1),
9211 CreatedAt: &Timestamp{referenceTime},
9212 SuspendedAt: &Timestamp{referenceTime},
9213 },
9214 SuspendedAt: &Timestamp{referenceTime},
9215 },
9216 }
9217
9218 want := `{
9219 "action": "a",
9220 "member": {
9221 "login": "l",
9222 "id": 1,
9223 "node_id": "n",
9224 "avatar_url": "a",
9225 "url": "u",
9226 "events_url": "e",
9227 "repos_url": "r"
9228 },
9229 "repository": {
9230 "id": 1,
9231 "name": "n",
9232 "url": "s"
9233 },
9234 "sender": {
9235 "login": "l",
9236 "id": 1,
9237 "node_id": "n",
9238 "avatar_url": "a",
9239 "url": "u",
9240 "events_url": "e",
9241 "repos_url": "r"
9242 },
9243 "installation": {
9244 "id": 1,
9245 "node_id": "nid",
9246 "app_id": 1,
9247 "app_slug": "as",
9248 "target_id": 1,
9249 "account": {
9250 "login": "l",
9251 "id": 1,
9252 "avatar_url": "a",
9253 "gravatar_id": "g",
9254 "name": "n",
9255 "company": "c",
9256 "blog": "b",
9257 "location": "l",
9258 "email": "e",
9259 "hireable": true,
9260 "bio": "b",
9261 "twitter_username": "t",
9262 "public_repos": 1,
9263 "followers": 1,
9264 "following": 1,
9265 "created_at": ` + referenceTimeStr + `,
9266 "suspended_at": ` + referenceTimeStr + `,
9267 "url": "u"
9268 },
9269 "access_tokens_url": "atu",
9270 "repositories_url": "ru",
9271 "html_url": "hu",
9272 "target_type": "tt",
9273 "single_file_name": "sfn",
9274 "repository_selection": "rs",
9275 "events": [
9276 "e"
9277 ],
9278 "single_file_paths": [
9279 "s"
9280 ],
9281 "permissions": {
9282 "actions": "a",
9283 "administration": "ad",
9284 "checks": "c",
9285 "contents": "co",
9286 "content_references": "cr",
9287 "deployments": "d",
9288 "environments": "e",
9289 "issues": "i",
9290 "metadata": "md",
9291 "members": "m",
9292 "organization_administration": "oa",
9293 "organization_hooks": "oh",
9294 "organization_plan": "op",
9295 "organization_pre_receive_hooks": "opr",
9296 "organization_projects": "op",
9297 "organization_secrets": "os",
9298 "organization_self_hosted_runners": "osh",
9299 "organization_user_blocking": "oub",
9300 "packages": "pkg",
9301 "pages": "pg",
9302 "pull_requests": "pr",
9303 "repository_hooks": "rh",
9304 "repository_projects": "rp",
9305 "repository_pre_receive_hooks": "rprh",
9306 "secrets": "s",
9307 "secret_scanning_alerts": "ssa",
9308 "security_events": "se",
9309 "single_file": "sf",
9310 "statuses": "s",
9311 "team_discussions": "td",
9312 "vulnerability_alerts": "va",
9313 "workflows": "w"
9314 },
9315 "created_at": ` + referenceTimeStr + `,
9316 "updated_at": ` + referenceTimeStr + `,
9317 "has_multiple_single_files": false,
9318 "suspended_by": {
9319 "login": "l",
9320 "id": 1,
9321 "avatar_url": "a",
9322 "gravatar_id": "g",
9323 "name": "n",
9324 "company": "c",
9325 "blog": "b",
9326 "location": "l",
9327 "email": "e",
9328 "hireable": true,
9329 "bio": "b",
9330 "twitter_username": "t",
9331 "public_repos": 1,
9332 "followers": 1,
9333 "following": 1,
9334 "created_at": ` + referenceTimeStr + `,
9335 "suspended_at": ` + referenceTimeStr + `,
9336 "url": "u"
9337 },
9338 "suspended_at": ` + referenceTimeStr + `
9339 }
9340 }`
9341
9342 testJSONMarshal(t, u, want)
9343 }
9344
9345 func TestMembershipEvent_Marshal(t *testing.T) {
9346 testJSONMarshal(t, &MembershipEvent{}, "{}")
9347
9348 u := &MembershipEvent{
9349 Action: String("a"),
9350 Scope: String("s"),
9351 Member: &User{
9352 Login: String("l"),
9353 ID: Int64(1),
9354 NodeID: String("n"),
9355 URL: String("u"),
9356 ReposURL: String("r"),
9357 EventsURL: String("e"),
9358 AvatarURL: String("a"),
9359 },
9360 Team: &Team{
9361 ID: Int64(1),
9362 NodeID: String("n"),
9363 Name: String("n"),
9364 Description: String("d"),
9365 URL: String("u"),
9366 Slug: String("s"),
9367 Permission: String("p"),
9368 Privacy: String("p"),
9369 MembersCount: Int(1),
9370 ReposCount: Int(1),
9371 MembersURL: String("m"),
9372 RepositoriesURL: String("r"),
9373 Organization: &Organization{
9374 Login: String("l"),
9375 ID: Int64(1),
9376 NodeID: String("n"),
9377 AvatarURL: String("a"),
9378 HTMLURL: String("h"),
9379 Name: String("n"),
9380 Company: String("c"),
9381 Blog: String("b"),
9382 Location: String("l"),
9383 Email: String("e"),
9384 },
9385 Parent: &Team{
9386 ID: Int64(1),
9387 NodeID: String("n"),
9388 Name: String("n"),
9389 Description: String("d"),
9390 URL: String("u"),
9391 Slug: String("s"),
9392 Permission: String("p"),
9393 Privacy: String("p"),
9394 MembersCount: Int(1),
9395 ReposCount: Int(1),
9396 },
9397 LDAPDN: String("l"),
9398 },
9399 Org: &Organization{
9400 BillingEmail: String("be"),
9401 Blog: String("b"),
9402 Company: String("c"),
9403 Email: String("e"),
9404 TwitterUsername: String("tu"),
9405 Location: String("loc"),
9406 Name: String("n"),
9407 Description: String("d"),
9408 IsVerified: Bool(true),
9409 HasOrganizationProjects: Bool(true),
9410 HasRepositoryProjects: Bool(true),
9411 DefaultRepoPermission: String("drp"),
9412 MembersCanCreateRepos: Bool(true),
9413 MembersCanCreateInternalRepos: Bool(true),
9414 MembersCanCreatePrivateRepos: Bool(true),
9415 MembersCanCreatePublicRepos: Bool(false),
9416 MembersAllowedRepositoryCreationType: String("marct"),
9417 MembersCanCreatePages: Bool(true),
9418 MembersCanCreatePublicPages: Bool(false),
9419 MembersCanCreatePrivatePages: Bool(true),
9420 },
9421 Sender: &User{
9422 Login: String("l"),
9423 ID: Int64(1),
9424 NodeID: String("n"),
9425 URL: String("u"),
9426 ReposURL: String("r"),
9427 EventsURL: String("e"),
9428 AvatarURL: String("a"),
9429 },
9430 Installation: &Installation{
9431 ID: Int64(1),
9432 NodeID: String("nid"),
9433 AppID: Int64(1),
9434 AppSlug: String("as"),
9435 TargetID: Int64(1),
9436 Account: &User{
9437 Login: String("l"),
9438 ID: Int64(1),
9439 URL: String("u"),
9440 AvatarURL: String("a"),
9441 GravatarID: String("g"),
9442 Name: String("n"),
9443 Company: String("c"),
9444 Blog: String("b"),
9445 Location: String("l"),
9446 Email: String("e"),
9447 Hireable: Bool(true),
9448 Bio: String("b"),
9449 TwitterUsername: String("t"),
9450 PublicRepos: Int(1),
9451 Followers: Int(1),
9452 Following: Int(1),
9453 CreatedAt: &Timestamp{referenceTime},
9454 SuspendedAt: &Timestamp{referenceTime},
9455 },
9456 AccessTokensURL: String("atu"),
9457 RepositoriesURL: String("ru"),
9458 HTMLURL: String("hu"),
9459 TargetType: String("tt"),
9460 SingleFileName: String("sfn"),
9461 RepositorySelection: String("rs"),
9462 Events: []string{"e"},
9463 SingleFilePaths: []string{"s"},
9464 Permissions: &InstallationPermissions{
9465 Actions: String("a"),
9466 Administration: String("ad"),
9467 Checks: String("c"),
9468 Contents: String("co"),
9469 ContentReferences: String("cr"),
9470 Deployments: String("d"),
9471 Environments: String("e"),
9472 Issues: String("i"),
9473 Metadata: String("md"),
9474 Members: String("m"),
9475 OrganizationAdministration: String("oa"),
9476 OrganizationHooks: String("oh"),
9477 OrganizationPlan: String("op"),
9478 OrganizationPreReceiveHooks: String("opr"),
9479 OrganizationProjects: String("op"),
9480 OrganizationSecrets: String("os"),
9481 OrganizationSelfHostedRunners: String("osh"),
9482 OrganizationUserBlocking: String("oub"),
9483 Packages: String("pkg"),
9484 Pages: String("pg"),
9485 PullRequests: String("pr"),
9486 RepositoryHooks: String("rh"),
9487 RepositoryProjects: String("rp"),
9488 RepositoryPreReceiveHooks: String("rprh"),
9489 Secrets: String("s"),
9490 SecretScanningAlerts: String("ssa"),
9491 SecurityEvents: String("se"),
9492 SingleFile: String("sf"),
9493 Statuses: String("s"),
9494 TeamDiscussions: String("td"),
9495 VulnerabilityAlerts: String("va"),
9496 Workflows: String("w"),
9497 },
9498 CreatedAt: &Timestamp{referenceTime},
9499 UpdatedAt: &Timestamp{referenceTime},
9500 HasMultipleSingleFiles: Bool(false),
9501 SuspendedBy: &User{
9502 Login: String("l"),
9503 ID: Int64(1),
9504 URL: String("u"),
9505 AvatarURL: String("a"),
9506 GravatarID: String("g"),
9507 Name: String("n"),
9508 Company: String("c"),
9509 Blog: String("b"),
9510 Location: String("l"),
9511 Email: String("e"),
9512 Hireable: Bool(true),
9513 Bio: String("b"),
9514 TwitterUsername: String("t"),
9515 PublicRepos: Int(1),
9516 Followers: Int(1),
9517 Following: Int(1),
9518 CreatedAt: &Timestamp{referenceTime},
9519 SuspendedAt: &Timestamp{referenceTime},
9520 },
9521 SuspendedAt: &Timestamp{referenceTime},
9522 },
9523 }
9524
9525 want := `{
9526 "action": "a",
9527 "scope": "s",
9528 "member": {
9529 "login": "l",
9530 "id": 1,
9531 "node_id": "n",
9532 "avatar_url": "a",
9533 "url": "u",
9534 "events_url": "e",
9535 "repos_url": "r"
9536 },
9537 "team": {
9538 "id": 1,
9539 "node_id": "n",
9540 "name": "n",
9541 "description": "d",
9542 "url": "u",
9543 "slug": "s",
9544 "permission": "p",
9545 "privacy": "p",
9546 "members_count": 1,
9547 "repos_count": 1,
9548 "organization": {
9549 "login": "l",
9550 "id": 1,
9551 "node_id": "n",
9552 "avatar_url": "a",
9553 "html_url": "h",
9554 "name": "n",
9555 "company": "c",
9556 "blog": "b",
9557 "location": "l",
9558 "email": "e"
9559 },
9560 "members_url": "m",
9561 "repositories_url": "r",
9562 "parent": {
9563 "id": 1,
9564 "node_id": "n",
9565 "name": "n",
9566 "description": "d",
9567 "url": "u",
9568 "slug": "s",
9569 "permission": "p",
9570 "privacy": "p",
9571 "members_count": 1,
9572 "repos_count": 1
9573 },
9574 "ldap_dn": "l"
9575 },
9576 "organization": {
9577 "name": "n",
9578 "company": "c",
9579 "blog": "b",
9580 "location": "loc",
9581 "email": "e",
9582 "twitter_username": "tu",
9583 "description": "d",
9584 "billing_email": "be",
9585 "is_verified": true,
9586 "has_organization_projects": true,
9587 "has_repository_projects": true,
9588 "default_repository_permission": "drp",
9589 "members_can_create_repositories": true,
9590 "members_can_create_public_repositories": false,
9591 "members_can_create_private_repositories": true,
9592 "members_can_create_internal_repositories": true,
9593 "members_allowed_repository_creation_type": "marct",
9594 "members_can_create_pages": true,
9595 "members_can_create_public_pages": false,
9596 "members_can_create_private_pages": true
9597 },
9598 "sender": {
9599 "login": "l",
9600 "id": 1,
9601 "node_id": "n",
9602 "avatar_url": "a",
9603 "url": "u",
9604 "events_url": "e",
9605 "repos_url": "r"
9606 },
9607 "installation": {
9608 "id": 1,
9609 "node_id": "nid",
9610 "app_id": 1,
9611 "app_slug": "as",
9612 "target_id": 1,
9613 "account": {
9614 "login": "l",
9615 "id": 1,
9616 "avatar_url": "a",
9617 "gravatar_id": "g",
9618 "name": "n",
9619 "company": "c",
9620 "blog": "b",
9621 "location": "l",
9622 "email": "e",
9623 "hireable": true,
9624 "bio": "b",
9625 "twitter_username": "t",
9626 "public_repos": 1,
9627 "followers": 1,
9628 "following": 1,
9629 "created_at": ` + referenceTimeStr + `,
9630 "suspended_at": ` + referenceTimeStr + `,
9631 "url": "u"
9632 },
9633 "access_tokens_url": "atu",
9634 "repositories_url": "ru",
9635 "html_url": "hu",
9636 "target_type": "tt",
9637 "single_file_name": "sfn",
9638 "repository_selection": "rs",
9639 "events": [
9640 "e"
9641 ],
9642 "single_file_paths": [
9643 "s"
9644 ],
9645 "permissions": {
9646 "actions": "a",
9647 "administration": "ad",
9648 "checks": "c",
9649 "contents": "co",
9650 "content_references": "cr",
9651 "deployments": "d",
9652 "environments": "e",
9653 "issues": "i",
9654 "metadata": "md",
9655 "members": "m",
9656 "organization_administration": "oa",
9657 "organization_hooks": "oh",
9658 "organization_plan": "op",
9659 "organization_pre_receive_hooks": "opr",
9660 "organization_projects": "op",
9661 "organization_secrets": "os",
9662 "organization_self_hosted_runners": "osh",
9663 "organization_user_blocking": "oub",
9664 "packages": "pkg",
9665 "pages": "pg",
9666 "pull_requests": "pr",
9667 "repository_hooks": "rh",
9668 "repository_projects": "rp",
9669 "repository_pre_receive_hooks": "rprh",
9670 "secrets": "s",
9671 "secret_scanning_alerts": "ssa",
9672 "security_events": "se",
9673 "single_file": "sf",
9674 "statuses": "s",
9675 "team_discussions": "td",
9676 "vulnerability_alerts": "va",
9677 "workflows": "w"
9678 },
9679 "created_at": ` + referenceTimeStr + `,
9680 "updated_at": ` + referenceTimeStr + `,
9681 "has_multiple_single_files": false,
9682 "suspended_by": {
9683 "login": "l",
9684 "id": 1,
9685 "avatar_url": "a",
9686 "gravatar_id": "g",
9687 "name": "n",
9688 "company": "c",
9689 "blog": "b",
9690 "location": "l",
9691 "email": "e",
9692 "hireable": true,
9693 "bio": "b",
9694 "twitter_username": "t",
9695 "public_repos": 1,
9696 "followers": 1,
9697 "following": 1,
9698 "created_at": ` + referenceTimeStr + `,
9699 "suspended_at": ` + referenceTimeStr + `,
9700 "url": "u"
9701 },
9702 "suspended_at": ` + referenceTimeStr + `
9703 }
9704 }`
9705
9706 testJSONMarshal(t, u, want)
9707 }
9708
9709 func TestMergeGroupEvent_Marshal(t *testing.T) {
9710 testJSONMarshal(t, &MergeGroupEvent{}, "{}")
9711
9712 u := &MergeGroupEvent{
9713 Action: String("a"),
9714 MergeGroup: &MergeGroup{
9715 HeadSHA: String("hs"),
9716 HeadRef: String("hr"),
9717 BaseSHA: String("bs"),
9718 BaseRef: String("br"),
9719 HeadCommit: &Commit{NodeID: String("nid")},
9720 },
9721 Repo: &Repository{
9722 ID: Int64(1),
9723 URL: String("s"),
9724 Name: String("n"),
9725 },
9726 Org: &Organization{
9727 BillingEmail: String("be"),
9728 Blog: String("b"),
9729 Company: String("c"),
9730 Email: String("e"),
9731 TwitterUsername: String("tu"),
9732 Location: String("loc"),
9733 Name: String("n"),
9734 Description: String("d"),
9735 IsVerified: Bool(true),
9736 HasOrganizationProjects: Bool(true),
9737 HasRepositoryProjects: Bool(true),
9738 DefaultRepoPermission: String("drp"),
9739 MembersCanCreateRepos: Bool(true),
9740 MembersCanCreateInternalRepos: Bool(true),
9741 MembersCanCreatePrivateRepos: Bool(true),
9742 MembersCanCreatePublicRepos: Bool(false),
9743 MembersAllowedRepositoryCreationType: String("marct"),
9744 MembersCanCreatePages: Bool(true),
9745 MembersCanCreatePublicPages: Bool(false),
9746 MembersCanCreatePrivatePages: Bool(true),
9747 },
9748 Sender: &User{
9749 Login: String("l"),
9750 ID: Int64(1),
9751 NodeID: String("n"),
9752 URL: String("u"),
9753 ReposURL: String("r"),
9754 EventsURL: String("e"),
9755 AvatarURL: String("a"),
9756 },
9757 Installation: &Installation{
9758 ID: Int64(1),
9759 NodeID: String("nid"),
9760 AppID: Int64(1),
9761 AppSlug: String("as"),
9762 TargetID: Int64(1),
9763 Account: &User{
9764 Login: String("l"),
9765 ID: Int64(1),
9766 URL: String("u"),
9767 AvatarURL: String("a"),
9768 GravatarID: String("g"),
9769 Name: String("n"),
9770 Company: String("c"),
9771 Blog: String("b"),
9772 Location: String("l"),
9773 Email: String("e"),
9774 Hireable: Bool(true),
9775 Bio: String("b"),
9776 TwitterUsername: String("t"),
9777 PublicRepos: Int(1),
9778 Followers: Int(1),
9779 Following: Int(1),
9780 CreatedAt: &Timestamp{referenceTime},
9781 SuspendedAt: &Timestamp{referenceTime},
9782 },
9783 AccessTokensURL: String("atu"),
9784 RepositoriesURL: String("ru"),
9785 HTMLURL: String("hu"),
9786 TargetType: String("tt"),
9787 SingleFileName: String("sfn"),
9788 RepositorySelection: String("rs"),
9789 Events: []string{"e"},
9790 SingleFilePaths: []string{"s"},
9791 Permissions: &InstallationPermissions{
9792 Actions: String("a"),
9793 Administration: String("ad"),
9794 Checks: String("c"),
9795 Contents: String("co"),
9796 ContentReferences: String("cr"),
9797 Deployments: String("d"),
9798 Environments: String("e"),
9799 Issues: String("i"),
9800 Metadata: String("md"),
9801 Members: String("m"),
9802 OrganizationAdministration: String("oa"),
9803 OrganizationHooks: String("oh"),
9804 OrganizationPlan: String("op"),
9805 OrganizationPreReceiveHooks: String("opr"),
9806 OrganizationProjects: String("op"),
9807 OrganizationSecrets: String("os"),
9808 OrganizationSelfHostedRunners: String("osh"),
9809 OrganizationUserBlocking: String("oub"),
9810 Packages: String("pkg"),
9811 Pages: String("pg"),
9812 PullRequests: String("pr"),
9813 RepositoryHooks: String("rh"),
9814 RepositoryProjects: String("rp"),
9815 RepositoryPreReceiveHooks: String("rprh"),
9816 Secrets: String("s"),
9817 SecretScanningAlerts: String("ssa"),
9818 SecurityEvents: String("se"),
9819 SingleFile: String("sf"),
9820 Statuses: String("s"),
9821 TeamDiscussions: String("td"),
9822 VulnerabilityAlerts: String("va"),
9823 Workflows: String("w"),
9824 },
9825 CreatedAt: &Timestamp{referenceTime},
9826 UpdatedAt: &Timestamp{referenceTime},
9827 HasMultipleSingleFiles: Bool(false),
9828 SuspendedBy: &User{
9829 Login: String("l"),
9830 ID: Int64(1),
9831 URL: String("u"),
9832 AvatarURL: String("a"),
9833 GravatarID: String("g"),
9834 Name: String("n"),
9835 Company: String("c"),
9836 Blog: String("b"),
9837 Location: String("l"),
9838 Email: String("e"),
9839 Hireable: Bool(true),
9840 Bio: String("b"),
9841 TwitterUsername: String("t"),
9842 PublicRepos: Int(1),
9843 Followers: Int(1),
9844 Following: Int(1),
9845 CreatedAt: &Timestamp{referenceTime},
9846 SuspendedAt: &Timestamp{referenceTime},
9847 },
9848 SuspendedAt: &Timestamp{referenceTime},
9849 },
9850 }
9851
9852 want := `{
9853 "action": "a",
9854 "merge_group": {
9855 "head_sha": "hs",
9856 "head_ref": "hr",
9857 "base_sha": "bs",
9858 "base_ref": "br",
9859 "head_commit": {
9860 "node_id": "nid"
9861 }
9862 },
9863 "repository": {
9864 "id": 1,
9865 "name": "n",
9866 "url": "s"
9867 },
9868 "organization": {
9869 "name": "n",
9870 "company": "c",
9871 "blog": "b",
9872 "location": "loc",
9873 "email": "e",
9874 "twitter_username": "tu",
9875 "description": "d",
9876 "billing_email": "be",
9877 "is_verified": true,
9878 "has_organization_projects": true,
9879 "has_repository_projects": true,
9880 "default_repository_permission": "drp",
9881 "members_can_create_repositories": true,
9882 "members_can_create_public_repositories": false,
9883 "members_can_create_private_repositories": true,
9884 "members_can_create_internal_repositories": true,
9885 "members_allowed_repository_creation_type": "marct",
9886 "members_can_create_pages": true,
9887 "members_can_create_public_pages": false,
9888 "members_can_create_private_pages": true
9889 },
9890 "sender": {
9891 "login": "l",
9892 "id": 1,
9893 "node_id": "n",
9894 "avatar_url": "a",
9895 "url": "u",
9896 "events_url": "e",
9897 "repos_url": "r"
9898 },
9899 "installation": {
9900 "id": 1,
9901 "node_id": "nid",
9902 "app_id": 1,
9903 "app_slug": "as",
9904 "target_id": 1,
9905 "account": {
9906 "login": "l",
9907 "id": 1,
9908 "avatar_url": "a",
9909 "gravatar_id": "g",
9910 "name": "n",
9911 "company": "c",
9912 "blog": "b",
9913 "location": "l",
9914 "email": "e",
9915 "hireable": true,
9916 "bio": "b",
9917 "twitter_username": "t",
9918 "public_repos": 1,
9919 "followers": 1,
9920 "following": 1,
9921 "created_at": ` + referenceTimeStr + `,
9922 "suspended_at": ` + referenceTimeStr + `,
9923 "url": "u"
9924 },
9925 "access_tokens_url": "atu",
9926 "repositories_url": "ru",
9927 "html_url": "hu",
9928 "target_type": "tt",
9929 "single_file_name": "sfn",
9930 "repository_selection": "rs",
9931 "events": [
9932 "e"
9933 ],
9934 "single_file_paths": [
9935 "s"
9936 ],
9937 "permissions": {
9938 "actions": "a",
9939 "administration": "ad",
9940 "checks": "c",
9941 "contents": "co",
9942 "content_references": "cr",
9943 "deployments": "d",
9944 "environments": "e",
9945 "issues": "i",
9946 "metadata": "md",
9947 "members": "m",
9948 "organization_administration": "oa",
9949 "organization_hooks": "oh",
9950 "organization_plan": "op",
9951 "organization_pre_receive_hooks": "opr",
9952 "organization_projects": "op",
9953 "organization_secrets": "os",
9954 "organization_self_hosted_runners": "osh",
9955 "organization_user_blocking": "oub",
9956 "packages": "pkg",
9957 "pages": "pg",
9958 "pull_requests": "pr",
9959 "repository_hooks": "rh",
9960 "repository_projects": "rp",
9961 "repository_pre_receive_hooks": "rprh",
9962 "secrets": "s",
9963 "secret_scanning_alerts": "ssa",
9964 "security_events": "se",
9965 "single_file": "sf",
9966 "statuses": "s",
9967 "team_discussions": "td",
9968 "vulnerability_alerts": "va",
9969 "workflows": "w"
9970 },
9971 "created_at": ` + referenceTimeStr + `,
9972 "updated_at": ` + referenceTimeStr + `,
9973 "has_multiple_single_files": false,
9974 "suspended_by": {
9975 "login": "l",
9976 "id": 1,
9977 "avatar_url": "a",
9978 "gravatar_id": "g",
9979 "name": "n",
9980 "company": "c",
9981 "blog": "b",
9982 "location": "l",
9983 "email": "e",
9984 "hireable": true,
9985 "bio": "b",
9986 "twitter_username": "t",
9987 "public_repos": 1,
9988 "followers": 1,
9989 "following": 1,
9990 "created_at": ` + referenceTimeStr + `,
9991 "suspended_at": ` + referenceTimeStr + `,
9992 "url": "u"
9993 },
9994 "suspended_at": ` + referenceTimeStr + `
9995 }
9996 }`
9997
9998 testJSONMarshal(t, u, want)
9999 }
10000
10001 func TestOrgBlockEvent_Marshal(t *testing.T) {
10002 testJSONMarshal(t, &OrgBlockEvent{}, "{}")
10003
10004 u := &OrgBlockEvent{
10005 Action: String("a"),
10006 BlockedUser: &User{
10007 Login: String("l"),
10008 ID: Int64(1),
10009 NodeID: String("n"),
10010 URL: String("u"),
10011 ReposURL: String("r"),
10012 EventsURL: String("e"),
10013 AvatarURL: String("a"),
10014 },
10015 Organization: &Organization{
10016 BillingEmail: String("be"),
10017 Blog: String("b"),
10018 Company: String("c"),
10019 Email: String("e"),
10020 TwitterUsername: String("tu"),
10021 Location: String("loc"),
10022 Name: String("n"),
10023 Description: String("d"),
10024 IsVerified: Bool(true),
10025 HasOrganizationProjects: Bool(true),
10026 HasRepositoryProjects: Bool(true),
10027 DefaultRepoPermission: String("drp"),
10028 MembersCanCreateRepos: Bool(true),
10029 MembersCanCreateInternalRepos: Bool(true),
10030 MembersCanCreatePrivateRepos: Bool(true),
10031 MembersCanCreatePublicRepos: Bool(false),
10032 MembersAllowedRepositoryCreationType: String("marct"),
10033 MembersCanCreatePages: Bool(true),
10034 MembersCanCreatePublicPages: Bool(false),
10035 MembersCanCreatePrivatePages: Bool(true),
10036 },
10037 Sender: &User{
10038 Login: String("l"),
10039 ID: Int64(1),
10040 NodeID: String("n"),
10041 URL: String("u"),
10042 ReposURL: String("r"),
10043 EventsURL: String("e"),
10044 AvatarURL: String("a"),
10045 },
10046 Installation: &Installation{
10047 ID: Int64(1),
10048 NodeID: String("nid"),
10049 AppID: Int64(1),
10050 AppSlug: String("as"),
10051 TargetID: Int64(1),
10052 Account: &User{
10053 Login: String("l"),
10054 ID: Int64(1),
10055 URL: String("u"),
10056 AvatarURL: String("a"),
10057 GravatarID: String("g"),
10058 Name: String("n"),
10059 Company: String("c"),
10060 Blog: String("b"),
10061 Location: String("l"),
10062 Email: String("e"),
10063 Hireable: Bool(true),
10064 Bio: String("b"),
10065 TwitterUsername: String("t"),
10066 PublicRepos: Int(1),
10067 Followers: Int(1),
10068 Following: Int(1),
10069 CreatedAt: &Timestamp{referenceTime},
10070 SuspendedAt: &Timestamp{referenceTime},
10071 },
10072 AccessTokensURL: String("atu"),
10073 RepositoriesURL: String("ru"),
10074 HTMLURL: String("hu"),
10075 TargetType: String("tt"),
10076 SingleFileName: String("sfn"),
10077 RepositorySelection: String("rs"),
10078 Events: []string{"e"},
10079 SingleFilePaths: []string{"s"},
10080 Permissions: &InstallationPermissions{
10081 Actions: String("a"),
10082 Administration: String("ad"),
10083 Checks: String("c"),
10084 Contents: String("co"),
10085 ContentReferences: String("cr"),
10086 Deployments: String("d"),
10087 Environments: String("e"),
10088 Issues: String("i"),
10089 Metadata: String("md"),
10090 Members: String("m"),
10091 OrganizationAdministration: String("oa"),
10092 OrganizationHooks: String("oh"),
10093 OrganizationPlan: String("op"),
10094 OrganizationPreReceiveHooks: String("opr"),
10095 OrganizationProjects: String("op"),
10096 OrganizationSecrets: String("os"),
10097 OrganizationSelfHostedRunners: String("osh"),
10098 OrganizationUserBlocking: String("oub"),
10099 Packages: String("pkg"),
10100 Pages: String("pg"),
10101 PullRequests: String("pr"),
10102 RepositoryHooks: String("rh"),
10103 RepositoryProjects: String("rp"),
10104 RepositoryPreReceiveHooks: String("rprh"),
10105 Secrets: String("s"),
10106 SecretScanningAlerts: String("ssa"),
10107 SecurityEvents: String("se"),
10108 SingleFile: String("sf"),
10109 Statuses: String("s"),
10110 TeamDiscussions: String("td"),
10111 VulnerabilityAlerts: String("va"),
10112 Workflows: String("w"),
10113 },
10114 CreatedAt: &Timestamp{referenceTime},
10115 UpdatedAt: &Timestamp{referenceTime},
10116 HasMultipleSingleFiles: Bool(false),
10117 SuspendedBy: &User{
10118 Login: String("l"),
10119 ID: Int64(1),
10120 URL: String("u"),
10121 AvatarURL: String("a"),
10122 GravatarID: String("g"),
10123 Name: String("n"),
10124 Company: String("c"),
10125 Blog: String("b"),
10126 Location: String("l"),
10127 Email: String("e"),
10128 Hireable: Bool(true),
10129 Bio: String("b"),
10130 TwitterUsername: String("t"),
10131 PublicRepos: Int(1),
10132 Followers: Int(1),
10133 Following: Int(1),
10134 CreatedAt: &Timestamp{referenceTime},
10135 SuspendedAt: &Timestamp{referenceTime},
10136 },
10137 SuspendedAt: &Timestamp{referenceTime},
10138 },
10139 }
10140
10141 want := `{
10142 "action": "a",
10143 "blocked_user": {
10144 "login": "l",
10145 "id": 1,
10146 "node_id": "n",
10147 "avatar_url": "a",
10148 "url": "u",
10149 "events_url": "e",
10150 "repos_url": "r"
10151 },
10152 "organization": {
10153 "name": "n",
10154 "company": "c",
10155 "blog": "b",
10156 "location": "loc",
10157 "email": "e",
10158 "twitter_username": "tu",
10159 "description": "d",
10160 "billing_email": "be",
10161 "is_verified": true,
10162 "has_organization_projects": true,
10163 "has_repository_projects": true,
10164 "default_repository_permission": "drp",
10165 "members_can_create_repositories": true,
10166 "members_can_create_public_repositories": false,
10167 "members_can_create_private_repositories": true,
10168 "members_can_create_internal_repositories": true,
10169 "members_allowed_repository_creation_type": "marct",
10170 "members_can_create_pages": true,
10171 "members_can_create_public_pages": false,
10172 "members_can_create_private_pages": true
10173 },
10174 "sender": {
10175 "login": "l",
10176 "id": 1,
10177 "node_id": "n",
10178 "avatar_url": "a",
10179 "url": "u",
10180 "events_url": "e",
10181 "repos_url": "r"
10182 },
10183 "installation": {
10184 "id": 1,
10185 "node_id": "nid",
10186 "app_id": 1,
10187 "app_slug": "as",
10188 "target_id": 1,
10189 "account": {
10190 "login": "l",
10191 "id": 1,
10192 "avatar_url": "a",
10193 "gravatar_id": "g",
10194 "name": "n",
10195 "company": "c",
10196 "blog": "b",
10197 "location": "l",
10198 "email": "e",
10199 "hireable": true,
10200 "bio": "b",
10201 "twitter_username": "t",
10202 "public_repos": 1,
10203 "followers": 1,
10204 "following": 1,
10205 "created_at": ` + referenceTimeStr + `,
10206 "suspended_at": ` + referenceTimeStr + `,
10207 "url": "u"
10208 },
10209 "access_tokens_url": "atu",
10210 "repositories_url": "ru",
10211 "html_url": "hu",
10212 "target_type": "tt",
10213 "single_file_name": "sfn",
10214 "repository_selection": "rs",
10215 "events": [
10216 "e"
10217 ],
10218 "single_file_paths": [
10219 "s"
10220 ],
10221 "permissions": {
10222 "actions": "a",
10223 "administration": "ad",
10224 "checks": "c",
10225 "contents": "co",
10226 "content_references": "cr",
10227 "deployments": "d",
10228 "environments": "e",
10229 "issues": "i",
10230 "metadata": "md",
10231 "members": "m",
10232 "organization_administration": "oa",
10233 "organization_hooks": "oh",
10234 "organization_plan": "op",
10235 "organization_pre_receive_hooks": "opr",
10236 "organization_projects": "op",
10237 "organization_secrets": "os",
10238 "organization_self_hosted_runners": "osh",
10239 "organization_user_blocking": "oub",
10240 "packages": "pkg",
10241 "pages": "pg",
10242 "pull_requests": "pr",
10243 "repository_hooks": "rh",
10244 "repository_projects": "rp",
10245 "repository_pre_receive_hooks": "rprh",
10246 "secrets": "s",
10247 "secret_scanning_alerts": "ssa",
10248 "security_events": "se",
10249 "single_file": "sf",
10250 "statuses": "s",
10251 "team_discussions": "td",
10252 "vulnerability_alerts": "va",
10253 "workflows": "w"
10254 },
10255 "created_at": ` + referenceTimeStr + `,
10256 "updated_at": ` + referenceTimeStr + `,
10257 "has_multiple_single_files": false,
10258 "suspended_by": {
10259 "login": "l",
10260 "id": 1,
10261 "avatar_url": "a",
10262 "gravatar_id": "g",
10263 "name": "n",
10264 "company": "c",
10265 "blog": "b",
10266 "location": "l",
10267 "email": "e",
10268 "hireable": true,
10269 "bio": "b",
10270 "twitter_username": "t",
10271 "public_repos": 1,
10272 "followers": 1,
10273 "following": 1,
10274 "created_at": ` + referenceTimeStr + `,
10275 "suspended_at": ` + referenceTimeStr + `,
10276 "url": "u"
10277 },
10278 "suspended_at": ` + referenceTimeStr + `
10279 }
10280 }`
10281
10282 testJSONMarshal(t, u, want)
10283 }
10284
10285 func TestGollumEvent_Marshal(t *testing.T) {
10286 testJSONMarshal(t, &GollumEvent{}, "{}")
10287
10288 u := &GollumEvent{
10289 Pages: []*Page{
10290 {
10291 PageName: String("pn"),
10292 Title: String("t"),
10293 Summary: String("s"),
10294 Action: String("a"),
10295 SHA: String("sha"),
10296 HTMLURL: String("hu"),
10297 },
10298 },
10299 Repo: &Repository{
10300 ID: Int64(1),
10301 URL: String("s"),
10302 Name: String("n"),
10303 },
10304 Sender: &User{
10305 Login: String("l"),
10306 ID: Int64(1),
10307 NodeID: String("n"),
10308 URL: String("u"),
10309 ReposURL: String("r"),
10310 EventsURL: String("e"),
10311 AvatarURL: String("a"),
10312 },
10313 Installation: &Installation{
10314 ID: Int64(1),
10315 NodeID: String("nid"),
10316 AppID: Int64(1),
10317 AppSlug: String("as"),
10318 TargetID: Int64(1),
10319 Account: &User{
10320 Login: String("l"),
10321 ID: Int64(1),
10322 URL: String("u"),
10323 AvatarURL: String("a"),
10324 GravatarID: String("g"),
10325 Name: String("n"),
10326 Company: String("c"),
10327 Blog: String("b"),
10328 Location: String("l"),
10329 Email: String("e"),
10330 Hireable: Bool(true),
10331 Bio: String("b"),
10332 TwitterUsername: String("t"),
10333 PublicRepos: Int(1),
10334 Followers: Int(1),
10335 Following: Int(1),
10336 CreatedAt: &Timestamp{referenceTime},
10337 SuspendedAt: &Timestamp{referenceTime},
10338 },
10339 AccessTokensURL: String("atu"),
10340 RepositoriesURL: String("ru"),
10341 HTMLURL: String("hu"),
10342 TargetType: String("tt"),
10343 SingleFileName: String("sfn"),
10344 RepositorySelection: String("rs"),
10345 Events: []string{"e"},
10346 SingleFilePaths: []string{"s"},
10347 Permissions: &InstallationPermissions{
10348 Actions: String("a"),
10349 Administration: String("ad"),
10350 Checks: String("c"),
10351 Contents: String("co"),
10352 ContentReferences: String("cr"),
10353 Deployments: String("d"),
10354 Environments: String("e"),
10355 Issues: String("i"),
10356 Metadata: String("md"),
10357 Members: String("m"),
10358 OrganizationAdministration: String("oa"),
10359 OrganizationHooks: String("oh"),
10360 OrganizationPlan: String("op"),
10361 OrganizationPreReceiveHooks: String("opr"),
10362 OrganizationProjects: String("op"),
10363 OrganizationSecrets: String("os"),
10364 OrganizationSelfHostedRunners: String("osh"),
10365 OrganizationUserBlocking: String("oub"),
10366 Packages: String("pkg"),
10367 Pages: String("pg"),
10368 PullRequests: String("pr"),
10369 RepositoryHooks: String("rh"),
10370 RepositoryProjects: String("rp"),
10371 RepositoryPreReceiveHooks: String("rprh"),
10372 Secrets: String("s"),
10373 SecretScanningAlerts: String("ssa"),
10374 SecurityEvents: String("se"),
10375 SingleFile: String("sf"),
10376 Statuses: String("s"),
10377 TeamDiscussions: String("td"),
10378 VulnerabilityAlerts: String("va"),
10379 Workflows: String("w"),
10380 },
10381 CreatedAt: &Timestamp{referenceTime},
10382 UpdatedAt: &Timestamp{referenceTime},
10383 HasMultipleSingleFiles: Bool(false),
10384 SuspendedBy: &User{
10385 Login: String("l"),
10386 ID: Int64(1),
10387 URL: String("u"),
10388 AvatarURL: String("a"),
10389 GravatarID: String("g"),
10390 Name: String("n"),
10391 Company: String("c"),
10392 Blog: String("b"),
10393 Location: String("l"),
10394 Email: String("e"),
10395 Hireable: Bool(true),
10396 Bio: String("b"),
10397 TwitterUsername: String("t"),
10398 PublicRepos: Int(1),
10399 Followers: Int(1),
10400 Following: Int(1),
10401 CreatedAt: &Timestamp{referenceTime},
10402 SuspendedAt: &Timestamp{referenceTime},
10403 },
10404 SuspendedAt: &Timestamp{referenceTime},
10405 },
10406 }
10407
10408 want := `{
10409 "pages": [
10410 {
10411 "page_name": "pn",
10412 "title": "t",
10413 "summary": "s",
10414 "action": "a",
10415 "sha": "sha",
10416 "html_url": "hu"
10417 }
10418 ],
10419 "repository": {
10420 "id": 1,
10421 "name": "n",
10422 "url": "s"
10423 },
10424 "sender": {
10425 "login": "l",
10426 "id": 1,
10427 "node_id": "n",
10428 "avatar_url": "a",
10429 "url": "u",
10430 "events_url": "e",
10431 "repos_url": "r"
10432 },
10433 "installation": {
10434 "id": 1,
10435 "node_id": "nid",
10436 "app_id": 1,
10437 "app_slug": "as",
10438 "target_id": 1,
10439 "account": {
10440 "login": "l",
10441 "id": 1,
10442 "avatar_url": "a",
10443 "gravatar_id": "g",
10444 "name": "n",
10445 "company": "c",
10446 "blog": "b",
10447 "location": "l",
10448 "email": "e",
10449 "hireable": true,
10450 "bio": "b",
10451 "twitter_username": "t",
10452 "public_repos": 1,
10453 "followers": 1,
10454 "following": 1,
10455 "created_at": ` + referenceTimeStr + `,
10456 "suspended_at": ` + referenceTimeStr + `,
10457 "url": "u"
10458 },
10459 "access_tokens_url": "atu",
10460 "repositories_url": "ru",
10461 "html_url": "hu",
10462 "target_type": "tt",
10463 "single_file_name": "sfn",
10464 "repository_selection": "rs",
10465 "events": [
10466 "e"
10467 ],
10468 "single_file_paths": [
10469 "s"
10470 ],
10471 "permissions": {
10472 "actions": "a",
10473 "administration": "ad",
10474 "checks": "c",
10475 "contents": "co",
10476 "content_references": "cr",
10477 "deployments": "d",
10478 "environments": "e",
10479 "issues": "i",
10480 "metadata": "md",
10481 "members": "m",
10482 "organization_administration": "oa",
10483 "organization_hooks": "oh",
10484 "organization_plan": "op",
10485 "organization_pre_receive_hooks": "opr",
10486 "organization_projects": "op",
10487 "organization_secrets": "os",
10488 "organization_self_hosted_runners": "osh",
10489 "organization_user_blocking": "oub",
10490 "packages": "pkg",
10491 "pages": "pg",
10492 "pull_requests": "pr",
10493 "repository_hooks": "rh",
10494 "repository_projects": "rp",
10495 "repository_pre_receive_hooks": "rprh",
10496 "secrets": "s",
10497 "secret_scanning_alerts": "ssa",
10498 "security_events": "se",
10499 "single_file": "sf",
10500 "statuses": "s",
10501 "team_discussions": "td",
10502 "vulnerability_alerts": "va",
10503 "workflows": "w"
10504 },
10505 "created_at": ` + referenceTimeStr + `,
10506 "updated_at": ` + referenceTimeStr + `,
10507 "has_multiple_single_files": false,
10508 "suspended_by": {
10509 "login": "l",
10510 "id": 1,
10511 "avatar_url": "a",
10512 "gravatar_id": "g",
10513 "name": "n",
10514 "company": "c",
10515 "blog": "b",
10516 "location": "l",
10517 "email": "e",
10518 "hireable": true,
10519 "bio": "b",
10520 "twitter_username": "t",
10521 "public_repos": 1,
10522 "followers": 1,
10523 "following": 1,
10524 "created_at": ` + referenceTimeStr + `,
10525 "suspended_at": ` + referenceTimeStr + `,
10526 "url": "u"
10527 },
10528 "suspended_at": ` + referenceTimeStr + `
10529 }
10530 }`
10531
10532 testJSONMarshal(t, u, want)
10533 }
10534
10535 func TestWorkflowRunEvent_Marshal(t *testing.T) {
10536 testJSONMarshal(t, &WorkflowRunEvent{}, "{}")
10537
10538 u := &WorkflowRunEvent{
10539 Action: String("a"),
10540 Workflow: &Workflow{
10541 ID: Int64(1),
10542 NodeID: String("nid"),
10543 Name: String("n"),
10544 Path: String("p"),
10545 State: String("s"),
10546 CreatedAt: &Timestamp{referenceTime},
10547 UpdatedAt: &Timestamp{referenceTime},
10548 URL: String("u"),
10549 HTMLURL: String("h"),
10550 BadgeURL: String("b"),
10551 },
10552 WorkflowRun: &WorkflowRun{
10553 ID: Int64(1),
10554 Name: String("n"),
10555 NodeID: String("nid"),
10556 HeadBranch: String("hb"),
10557 HeadSHA: String("hs"),
10558 RunNumber: Int(1),
10559 RunAttempt: Int(1),
10560 Event: String("e"),
10561 Status: String("s"),
10562 Conclusion: String("c"),
10563 WorkflowID: Int64(1),
10564 URL: String("u"),
10565 HTMLURL: String("h"),
10566 PullRequests: []*PullRequest{
10567 {
10568 URL: String("u"),
10569 ID: Int64(1),
10570 Number: Int(1),
10571 Head: &PullRequestBranch{
10572 Ref: String("r"),
10573 SHA: String("s"),
10574 Repo: &Repository{
10575 ID: Int64(1),
10576 URL: String("s"),
10577 Name: String("n"),
10578 },
10579 },
10580 Base: &PullRequestBranch{
10581 Ref: String("r"),
10582 SHA: String("s"),
10583 Repo: &Repository{
10584 ID: Int64(1),
10585 URL: String("u"),
10586 Name: String("n"),
10587 },
10588 },
10589 },
10590 },
10591 CreatedAt: &Timestamp{referenceTime},
10592 UpdatedAt: &Timestamp{referenceTime},
10593 RunStartedAt: &Timestamp{referenceTime},
10594 JobsURL: String("j"),
10595 LogsURL: String("l"),
10596 CheckSuiteURL: String("c"),
10597 ArtifactsURL: String("a"),
10598 CancelURL: String("c"),
10599 RerunURL: String("r"),
10600 PreviousAttemptURL: String("p"),
10601 HeadCommit: &HeadCommit{
10602 Message: String("m"),
10603 Author: &CommitAuthor{
10604 Name: String("n"),
10605 Email: String("e"),
10606 Login: String("l"),
10607 },
10608 URL: String("u"),
10609 Distinct: Bool(false),
10610 SHA: String("s"),
10611 ID: String("i"),
10612 TreeID: String("tid"),
10613 Timestamp: &Timestamp{referenceTime},
10614 Committer: &CommitAuthor{
10615 Name: String("n"),
10616 Email: String("e"),
10617 Login: String("l"),
10618 },
10619 },
10620 WorkflowURL: String("w"),
10621 Repository: &Repository{
10622 ID: Int64(1),
10623 URL: String("u"),
10624 Name: String("n"),
10625 },
10626 HeadRepository: &Repository{
10627 ID: Int64(1),
10628 URL: String("u"),
10629 Name: String("n"),
10630 },
10631 },
10632 Org: &Organization{
10633 BillingEmail: String("be"),
10634 Blog: String("b"),
10635 Company: String("c"),
10636 Email: String("e"),
10637 TwitterUsername: String("tu"),
10638 Location: String("loc"),
10639 Name: String("n"),
10640 Description: String("d"),
10641 IsVerified: Bool(true),
10642 HasOrganizationProjects: Bool(true),
10643 HasRepositoryProjects: Bool(true),
10644 DefaultRepoPermission: String("drp"),
10645 MembersCanCreateRepos: Bool(true),
10646 MembersCanCreateInternalRepos: Bool(true),
10647 MembersCanCreatePrivateRepos: Bool(true),
10648 MembersCanCreatePublicRepos: Bool(false),
10649 MembersAllowedRepositoryCreationType: String("marct"),
10650 MembersCanCreatePages: Bool(true),
10651 MembersCanCreatePublicPages: Bool(false),
10652 MembersCanCreatePrivatePages: Bool(true),
10653 },
10654 Repo: &Repository{
10655 ID: Int64(1),
10656 URL: String("s"),
10657 Name: String("n"),
10658 },
10659 Sender: &User{
10660 Login: String("l"),
10661 ID: Int64(1),
10662 NodeID: String("n"),
10663 URL: String("u"),
10664 ReposURL: String("r"),
10665 EventsURL: String("e"),
10666 AvatarURL: String("a"),
10667 },
10668 }
10669
10670 want := `{
10671 "action": "a",
10672 "workflow": {
10673 "id": 1,
10674 "node_id": "nid",
10675 "name": "n",
10676 "path": "p",
10677 "state": "s",
10678 "created_at": ` + referenceTimeStr + `,
10679 "updated_at": ` + referenceTimeStr + `,
10680 "url": "u",
10681 "html_url": "h",
10682 "badge_url": "b"
10683 },
10684 "workflow_run": {
10685 "id": 1,
10686 "name": "n",
10687 "node_id": "nid",
10688 "head_branch": "hb",
10689 "head_sha": "hs",
10690 "run_number": 1,
10691 "run_attempt": 1,
10692 "event": "e",
10693 "status": "s",
10694 "conclusion": "c",
10695 "workflow_id": 1,
10696 "url": "u",
10697 "html_url": "h",
10698 "pull_requests": [
10699 {
10700 "id": 1,
10701 "number": 1,
10702 "url": "u",
10703 "head": {
10704 "ref": "r",
10705 "sha": "s",
10706 "repo": {
10707 "id": 1,
10708 "name": "n",
10709 "url": "s"
10710 }
10711 },
10712 "base": {
10713 "ref": "r",
10714 "sha": "s",
10715 "repo": {
10716 "id": 1,
10717 "name": "n",
10718 "url": "u"
10719 }
10720 }
10721 }
10722 ],
10723 "created_at": ` + referenceTimeStr + `,
10724 "updated_at": ` + referenceTimeStr + `,
10725 "run_started_at": ` + referenceTimeStr + `,
10726 "jobs_url": "j",
10727 "logs_url": "l",
10728 "check_suite_url": "c",
10729 "artifacts_url": "a",
10730 "cancel_url": "c",
10731 "rerun_url": "r",
10732 "previous_attempt_url": "p",
10733 "head_commit": {
10734 "message": "m",
10735 "author": {
10736 "name": "n",
10737 "email": "e",
10738 "username": "l"
10739 },
10740 "url": "u",
10741 "distinct": false,
10742 "sha": "s",
10743 "id": "i",
10744 "tree_id": "tid",
10745 "timestamp": ` + referenceTimeStr + `,
10746 "committer": {
10747 "name": "n",
10748 "email": "e",
10749 "username": "l"
10750 }
10751 },
10752 "workflow_url": "w",
10753 "repository": {
10754 "id": 1,
10755 "name": "n",
10756 "url": "u"
10757 },
10758 "head_repository": {
10759 "id": 1,
10760 "name": "n",
10761 "url": "u"
10762 }
10763 },
10764 "organization": {
10765 "name": "n",
10766 "company": "c",
10767 "blog": "b",
10768 "location": "loc",
10769 "email": "e",
10770 "twitter_username": "tu",
10771 "description": "d",
10772 "billing_email": "be",
10773 "is_verified": true,
10774 "has_organization_projects": true,
10775 "has_repository_projects": true,
10776 "default_repository_permission": "drp",
10777 "members_can_create_repositories": true,
10778 "members_can_create_public_repositories": false,
10779 "members_can_create_private_repositories": true,
10780 "members_can_create_internal_repositories": true,
10781 "members_allowed_repository_creation_type": "marct",
10782 "members_can_create_pages": true,
10783 "members_can_create_public_pages": false,
10784 "members_can_create_private_pages": true
10785 },
10786 "repository": {
10787 "id": 1,
10788 "name": "n",
10789 "url": "s"
10790 },
10791 "sender": {
10792 "login": "l",
10793 "id": 1,
10794 "node_id": "n",
10795 "avatar_url": "a",
10796 "url": "u",
10797 "events_url": "e",
10798 "repos_url": "r"
10799 }
10800 }`
10801
10802 testJSONMarshal(t, u, want)
10803 }
10804
10805 func TestWorkflowDispatchEvent_Marshal(t *testing.T) {
10806 testJSONMarshal(t, &WorkflowDispatchEvent{}, "{}")
10807
10808 i := make(map[string]interface{})
10809 i["key"] = "value"
10810
10811 jsonMsg, _ := json.Marshal(i)
10812 u := &WorkflowDispatchEvent{
10813 Inputs: jsonMsg,
10814 Ref: String("r"),
10815 Workflow: String("w"),
10816 Repo: &Repository{
10817 ID: Int64(1),
10818 URL: String("s"),
10819 Name: String("n"),
10820 },
10821 Org: &Organization{
10822 BillingEmail: String("be"),
10823 Blog: String("b"),
10824 Company: String("c"),
10825 Email: String("e"),
10826 TwitterUsername: String("tu"),
10827 Location: String("loc"),
10828 Name: String("n"),
10829 Description: String("d"),
10830 IsVerified: Bool(true),
10831 HasOrganizationProjects: Bool(true),
10832 HasRepositoryProjects: Bool(true),
10833 DefaultRepoPermission: String("drp"),
10834 MembersCanCreateRepos: Bool(true),
10835 MembersCanCreateInternalRepos: Bool(true),
10836 MembersCanCreatePrivateRepos: Bool(true),
10837 MembersCanCreatePublicRepos: Bool(false),
10838 MembersAllowedRepositoryCreationType: String("marct"),
10839 MembersCanCreatePages: Bool(true),
10840 MembersCanCreatePublicPages: Bool(false),
10841 MembersCanCreatePrivatePages: Bool(true),
10842 },
10843 Sender: &User{
10844 Login: String("l"),
10845 ID: Int64(1),
10846 NodeID: String("n"),
10847 URL: String("u"),
10848 ReposURL: String("r"),
10849 EventsURL: String("e"),
10850 AvatarURL: String("a"),
10851 },
10852 }
10853
10854 want := `{
10855 "inputs": {
10856 "key": "value"
10857 },
10858 "ref": "r",
10859 "workflow": "w",
10860 "repository": {
10861 "id": 1,
10862 "name": "n",
10863 "url": "s"
10864 },
10865 "organization": {
10866 "name": "n",
10867 "company": "c",
10868 "blog": "b",
10869 "location": "loc",
10870 "email": "e",
10871 "twitter_username": "tu",
10872 "description": "d",
10873 "billing_email": "be",
10874 "is_verified": true,
10875 "has_organization_projects": true,
10876 "has_repository_projects": true,
10877 "default_repository_permission": "drp",
10878 "members_can_create_repositories": true,
10879 "members_can_create_public_repositories": false,
10880 "members_can_create_private_repositories": true,
10881 "members_can_create_internal_repositories": true,
10882 "members_allowed_repository_creation_type": "marct",
10883 "members_can_create_pages": true,
10884 "members_can_create_public_pages": false,
10885 "members_can_create_private_pages": true
10886 },
10887 "sender": {
10888 "login": "l",
10889 "id": 1,
10890 "node_id": "n",
10891 "avatar_url": "a",
10892 "url": "u",
10893 "events_url": "e",
10894 "repos_url": "r"
10895 }
10896 }`
10897
10898 testJSONMarshal(t, u, want)
10899 }
10900
10901 func TestWatchEvent_Marshal(t *testing.T) {
10902 testJSONMarshal(t, &WatchEvent{}, "{}")
10903
10904 u := &WatchEvent{
10905 Action: String("a"),
10906 Repo: &Repository{
10907 ID: Int64(1),
10908 URL: String("s"),
10909 Name: String("n"),
10910 },
10911 Sender: &User{
10912 Login: String("l"),
10913 ID: Int64(1),
10914 NodeID: String("n"),
10915 URL: String("u"),
10916 ReposURL: String("r"),
10917 EventsURL: String("e"),
10918 AvatarURL: String("a"),
10919 },
10920 Installation: &Installation{
10921 ID: Int64(1),
10922 NodeID: String("nid"),
10923 AppID: Int64(1),
10924 AppSlug: String("as"),
10925 TargetID: Int64(1),
10926 Account: &User{
10927 Login: String("l"),
10928 ID: Int64(1),
10929 URL: String("u"),
10930 AvatarURL: String("a"),
10931 GravatarID: String("g"),
10932 Name: String("n"),
10933 Company: String("c"),
10934 Blog: String("b"),
10935 Location: String("l"),
10936 Email: String("e"),
10937 Hireable: Bool(true),
10938 Bio: String("b"),
10939 TwitterUsername: String("t"),
10940 PublicRepos: Int(1),
10941 Followers: Int(1),
10942 Following: Int(1),
10943 CreatedAt: &Timestamp{referenceTime},
10944 SuspendedAt: &Timestamp{referenceTime},
10945 },
10946 AccessTokensURL: String("atu"),
10947 RepositoriesURL: String("ru"),
10948 HTMLURL: String("hu"),
10949 TargetType: String("tt"),
10950 SingleFileName: String("sfn"),
10951 RepositorySelection: String("rs"),
10952 Events: []string{"e"},
10953 SingleFilePaths: []string{"s"},
10954 Permissions: &InstallationPermissions{
10955 Actions: String("a"),
10956 Administration: String("ad"),
10957 Checks: String("c"),
10958 Contents: String("co"),
10959 ContentReferences: String("cr"),
10960 Deployments: String("d"),
10961 Environments: String("e"),
10962 Issues: String("i"),
10963 Metadata: String("md"),
10964 Members: String("m"),
10965 OrganizationAdministration: String("oa"),
10966 OrganizationHooks: String("oh"),
10967 OrganizationPlan: String("op"),
10968 OrganizationPreReceiveHooks: String("opr"),
10969 OrganizationProjects: String("op"),
10970 OrganizationSecrets: String("os"),
10971 OrganizationSelfHostedRunners: String("osh"),
10972 OrganizationUserBlocking: String("oub"),
10973 Packages: String("pkg"),
10974 Pages: String("pg"),
10975 PullRequests: String("pr"),
10976 RepositoryHooks: String("rh"),
10977 RepositoryProjects: String("rp"),
10978 RepositoryPreReceiveHooks: String("rprh"),
10979 Secrets: String("s"),
10980 SecretScanningAlerts: String("ssa"),
10981 SecurityEvents: String("se"),
10982 SingleFile: String("sf"),
10983 Statuses: String("s"),
10984 TeamDiscussions: String("td"),
10985 VulnerabilityAlerts: String("va"),
10986 Workflows: String("w"),
10987 },
10988 CreatedAt: &Timestamp{referenceTime},
10989 UpdatedAt: &Timestamp{referenceTime},
10990 HasMultipleSingleFiles: Bool(false),
10991 SuspendedBy: &User{
10992 Login: String("l"),
10993 ID: Int64(1),
10994 URL: String("u"),
10995 AvatarURL: String("a"),
10996 GravatarID: String("g"),
10997 Name: String("n"),
10998 Company: String("c"),
10999 Blog: String("b"),
11000 Location: String("l"),
11001 Email: String("e"),
11002 Hireable: Bool(true),
11003 Bio: String("b"),
11004 TwitterUsername: String("t"),
11005 PublicRepos: Int(1),
11006 Followers: Int(1),
11007 Following: Int(1),
11008 CreatedAt: &Timestamp{referenceTime},
11009 SuspendedAt: &Timestamp{referenceTime},
11010 },
11011 SuspendedAt: &Timestamp{referenceTime},
11012 },
11013 }
11014
11015 want := `{
11016 "action": "a",
11017 "repository": {
11018 "id": 1,
11019 "name": "n",
11020 "url": "s"
11021 },
11022 "sender": {
11023 "login": "l",
11024 "id": 1,
11025 "node_id": "n",
11026 "avatar_url": "a",
11027 "url": "u",
11028 "events_url": "e",
11029 "repos_url": "r"
11030 },
11031 "installation": {
11032 "id": 1,
11033 "node_id": "nid",
11034 "app_id": 1,
11035 "app_slug": "as",
11036 "target_id": 1,
11037 "account": {
11038 "login": "l",
11039 "id": 1,
11040 "avatar_url": "a",
11041 "gravatar_id": "g",
11042 "name": "n",
11043 "company": "c",
11044 "blog": "b",
11045 "location": "l",
11046 "email": "e",
11047 "hireable": true,
11048 "bio": "b",
11049 "twitter_username": "t",
11050 "public_repos": 1,
11051 "followers": 1,
11052 "following": 1,
11053 "created_at": ` + referenceTimeStr + `,
11054 "suspended_at": ` + referenceTimeStr + `,
11055 "url": "u"
11056 },
11057 "access_tokens_url": "atu",
11058 "repositories_url": "ru",
11059 "html_url": "hu",
11060 "target_type": "tt",
11061 "single_file_name": "sfn",
11062 "repository_selection": "rs",
11063 "events": [
11064 "e"
11065 ],
11066 "single_file_paths": [
11067 "s"
11068 ],
11069 "permissions": {
11070 "actions": "a",
11071 "administration": "ad",
11072 "checks": "c",
11073 "contents": "co",
11074 "content_references": "cr",
11075 "deployments": "d",
11076 "environments": "e",
11077 "issues": "i",
11078 "metadata": "md",
11079 "members": "m",
11080 "organization_administration": "oa",
11081 "organization_hooks": "oh",
11082 "organization_plan": "op",
11083 "organization_pre_receive_hooks": "opr",
11084 "organization_projects": "op",
11085 "organization_secrets": "os",
11086 "organization_self_hosted_runners": "osh",
11087 "organization_user_blocking": "oub",
11088 "packages": "pkg",
11089 "pages": "pg",
11090 "pull_requests": "pr",
11091 "repository_hooks": "rh",
11092 "repository_projects": "rp",
11093 "repository_pre_receive_hooks": "rprh",
11094 "secrets": "s",
11095 "secret_scanning_alerts": "ssa",
11096 "security_events": "se",
11097 "single_file": "sf",
11098 "statuses": "s",
11099 "team_discussions": "td",
11100 "vulnerability_alerts": "va",
11101 "workflows": "w"
11102 },
11103 "created_at": ` + referenceTimeStr + `,
11104 "updated_at": ` + referenceTimeStr + `,
11105 "has_multiple_single_files": false,
11106 "suspended_by": {
11107 "login": "l",
11108 "id": 1,
11109 "avatar_url": "a",
11110 "gravatar_id": "g",
11111 "name": "n",
11112 "company": "c",
11113 "blog": "b",
11114 "location": "l",
11115 "email": "e",
11116 "hireable": true,
11117 "bio": "b",
11118 "twitter_username": "t",
11119 "public_repos": 1,
11120 "followers": 1,
11121 "following": 1,
11122 "created_at": ` + referenceTimeStr + `,
11123 "suspended_at": ` + referenceTimeStr + `,
11124 "url": "u"
11125 },
11126 "suspended_at": ` + referenceTimeStr + `
11127 }
11128 }`
11129
11130 testJSONMarshal(t, u, want)
11131 }
11132
11133 func TestUserEvent_Marshal(t *testing.T) {
11134 testJSONMarshal(t, &UserEvent{}, "{}")
11135
11136 u := &UserEvent{
11137 User: &User{
11138 Login: String("l"),
11139 ID: Int64(1),
11140 NodeID: String("n"),
11141 URL: String("u"),
11142 ReposURL: String("r"),
11143 EventsURL: String("e"),
11144 AvatarURL: String("a"),
11145 },
11146 // The action performed. Possible values are: "created" or "deleted".
11147 Action: String("a"),
11148 Enterprise: &Enterprise{
11149 ID: Int(1),
11150 Slug: String("s"),
11151 Name: String("n"),
11152 NodeID: String("nid"),
11153 AvatarURL: String("au"),
11154 Description: String("d"),
11155 WebsiteURL: String("wu"),
11156 HTMLURL: String("hu"),
11157 CreatedAt: &Timestamp{referenceTime},
11158 UpdatedAt: &Timestamp{referenceTime},
11159 },
11160 Sender: &User{
11161 Login: String("l"),
11162 ID: Int64(1),
11163 NodeID: String("n"),
11164 URL: String("u"),
11165 ReposURL: String("r"),
11166 EventsURL: String("e"),
11167 AvatarURL: String("a"),
11168 },
11169 }
11170
11171 want := `{
11172 "user": {
11173 "login": "l",
11174 "id": 1,
11175 "node_id": "n",
11176 "avatar_url": "a",
11177 "url": "u",
11178 "events_url": "e",
11179 "repos_url": "r"
11180 },
11181 "action": "a",
11182 "enterprise": {
11183 "id": 1,
11184 "slug": "s",
11185 "name": "n",
11186 "node_id": "nid",
11187 "avatar_url": "au",
11188 "description": "d",
11189 "website_url": "wu",
11190 "html_url": "hu",
11191 "created_at": ` + referenceTimeStr + `,
11192 "updated_at": ` + referenceTimeStr + `
11193 },
11194 "sender": {
11195 "login": "l",
11196 "id": 1,
11197 "node_id": "n",
11198 "avatar_url": "a",
11199 "url": "u",
11200 "events_url": "e",
11201 "repos_url": "r"
11202 }
11203 }`
11204
11205 testJSONMarshal(t, u, want)
11206 }
11207
11208 func TestCheckRunEvent_Marshal(t *testing.T) {
11209 testJSONMarshal(t, &CheckRunEvent{}, "{}")
11210
11211 r := &CheckRunEvent{
11212 CheckRun: &CheckRun{
11213 ID: Int64(1),
11214 NodeID: String("n"),
11215 HeadSHA: String("h"),
11216 ExternalID: String("1"),
11217 URL: String("u"),
11218 HTMLURL: String("u"),
11219 DetailsURL: String("u"),
11220 Status: String("s"),
11221 Conclusion: String("c"),
11222 StartedAt: &Timestamp{referenceTime},
11223 CompletedAt: &Timestamp{referenceTime},
11224 Output: &CheckRunOutput{
11225 Annotations: []*CheckRunAnnotation{
11226 {
11227 AnnotationLevel: String("a"),
11228 EndLine: Int(1),
11229 Message: String("m"),
11230 Path: String("p"),
11231 RawDetails: String("r"),
11232 StartLine: Int(1),
11233 Title: String("t"),
11234 },
11235 },
11236 AnnotationsCount: Int(1),
11237 AnnotationsURL: String("a"),
11238 Images: []*CheckRunImage{
11239 {
11240 Alt: String("a"),
11241 ImageURL: String("i"),
11242 Caption: String("c"),
11243 },
11244 },
11245 Title: String("t"),
11246 Summary: String("s"),
11247 Text: String("t"),
11248 },
11249 Name: String("n"),
11250 CheckSuite: &CheckSuite{
11251 ID: Int64(1),
11252 },
11253 App: &App{
11254 ID: Int64(1),
11255 NodeID: String("n"),
11256 Owner: &User{
11257 Login: String("l"),
11258 ID: Int64(1),
11259 NodeID: String("n"),
11260 URL: String("u"),
11261 ReposURL: String("r"),
11262 EventsURL: String("e"),
11263 AvatarURL: String("a"),
11264 },
11265 Name: String("n"),
11266 Description: String("d"),
11267 HTMLURL: String("h"),
11268 ExternalURL: String("u"),
11269 CreatedAt: &Timestamp{referenceTime},
11270 UpdatedAt: &Timestamp{referenceTime},
11271 },
11272 PullRequests: []*PullRequest{
11273 {
11274 URL: String("u"),
11275 ID: Int64(1),
11276 Number: Int(1),
11277 Head: &PullRequestBranch{
11278 Ref: String("r"),
11279 SHA: String("s"),
11280 Repo: &Repository{
11281 ID: Int64(1),
11282 URL: String("s"),
11283 Name: String("n"),
11284 },
11285 },
11286 Base: &PullRequestBranch{
11287 Ref: String("r"),
11288 SHA: String("s"),
11289 Repo: &Repository{
11290 ID: Int64(1),
11291 URL: String("u"),
11292 Name: String("n"),
11293 },
11294 },
11295 },
11296 },
11297 },
11298 Action: String("a"),
11299 Repo: &Repository{
11300 ID: Int64(1),
11301 URL: String("s"),
11302 Name: String("n"),
11303 },
11304 Org: &Organization{
11305 BillingEmail: String("be"),
11306 Blog: String("b"),
11307 Company: String("c"),
11308 Email: String("e"),
11309 TwitterUsername: String("tu"),
11310 Location: String("loc"),
11311 Name: String("n"),
11312 Description: String("d"),
11313 IsVerified: Bool(true),
11314 HasOrganizationProjects: Bool(true),
11315 HasRepositoryProjects: Bool(true),
11316 DefaultRepoPermission: String("drp"),
11317 MembersCanCreateRepos: Bool(true),
11318 MembersCanCreateInternalRepos: Bool(true),
11319 MembersCanCreatePrivateRepos: Bool(true),
11320 MembersCanCreatePublicRepos: Bool(false),
11321 MembersAllowedRepositoryCreationType: String("marct"),
11322 MembersCanCreatePages: Bool(true),
11323 MembersCanCreatePublicPages: Bool(false),
11324 MembersCanCreatePrivatePages: Bool(true),
11325 },
11326 Sender: &User{
11327 Login: String("l"),
11328 ID: Int64(1),
11329 NodeID: String("n"),
11330 URL: String("u"),
11331 ReposURL: String("r"),
11332 EventsURL: String("e"),
11333 AvatarURL: String("a"),
11334 },
11335 Installation: &Installation{
11336 ID: Int64(1),
11337 NodeID: String("nid"),
11338 AppID: Int64(1),
11339 AppSlug: String("as"),
11340 TargetID: Int64(1),
11341 Account: &User{
11342 Login: String("l"),
11343 ID: Int64(1),
11344 URL: String("u"),
11345 AvatarURL: String("a"),
11346 GravatarID: String("g"),
11347 Name: String("n"),
11348 Company: String("c"),
11349 Blog: String("b"),
11350 Location: String("l"),
11351 Email: String("e"),
11352 Hireable: Bool(true),
11353 Bio: String("b"),
11354 TwitterUsername: String("t"),
11355 PublicRepos: Int(1),
11356 Followers: Int(1),
11357 Following: Int(1),
11358 CreatedAt: &Timestamp{referenceTime},
11359 SuspendedAt: &Timestamp{referenceTime},
11360 },
11361 AccessTokensURL: String("atu"),
11362 RepositoriesURL: String("ru"),
11363 HTMLURL: String("hu"),
11364 TargetType: String("tt"),
11365 SingleFileName: String("sfn"),
11366 RepositorySelection: String("rs"),
11367 Events: []string{"e"},
11368 SingleFilePaths: []string{"s"},
11369 Permissions: &InstallationPermissions{
11370 Actions: String("a"),
11371 Administration: String("ad"),
11372 Checks: String("c"),
11373 Contents: String("co"),
11374 ContentReferences: String("cr"),
11375 Deployments: String("d"),
11376 Environments: String("e"),
11377 Issues: String("i"),
11378 Metadata: String("md"),
11379 Members: String("m"),
11380 OrganizationAdministration: String("oa"),
11381 OrganizationHooks: String("oh"),
11382 OrganizationPlan: String("op"),
11383 OrganizationPreReceiveHooks: String("opr"),
11384 OrganizationProjects: String("op"),
11385 OrganizationSecrets: String("os"),
11386 OrganizationSelfHostedRunners: String("osh"),
11387 OrganizationUserBlocking: String("oub"),
11388 Packages: String("pkg"),
11389 Pages: String("pg"),
11390 PullRequests: String("pr"),
11391 RepositoryHooks: String("rh"),
11392 RepositoryProjects: String("rp"),
11393 RepositoryPreReceiveHooks: String("rprh"),
11394 Secrets: String("s"),
11395 SecretScanningAlerts: String("ssa"),
11396 SecurityEvents: String("se"),
11397 SingleFile: String("sf"),
11398 Statuses: String("s"),
11399 TeamDiscussions: String("td"),
11400 VulnerabilityAlerts: String("va"),
11401 Workflows: String("w"),
11402 },
11403 CreatedAt: &Timestamp{referenceTime},
11404 UpdatedAt: &Timestamp{referenceTime},
11405 HasMultipleSingleFiles: Bool(false),
11406 SuspendedBy: &User{
11407 Login: String("l"),
11408 ID: Int64(1),
11409 URL: String("u"),
11410 AvatarURL: String("a"),
11411 GravatarID: String("g"),
11412 Name: String("n"),
11413 Company: String("c"),
11414 Blog: String("b"),
11415 Location: String("l"),
11416 Email: String("e"),
11417 Hireable: Bool(true),
11418 Bio: String("b"),
11419 TwitterUsername: String("t"),
11420 PublicRepos: Int(1),
11421 Followers: Int(1),
11422 Following: Int(1),
11423 CreatedAt: &Timestamp{referenceTime},
11424 SuspendedAt: &Timestamp{referenceTime},
11425 },
11426 SuspendedAt: &Timestamp{referenceTime},
11427 },
11428 RequestedAction: &RequestedAction{
11429 Identifier: "i",
11430 },
11431 }
11432
11433 want := `{
11434 "check_run": {
11435 "id": 1,
11436 "node_id": "n",
11437 "head_sha": "h",
11438 "external_id": "1",
11439 "url": "u",
11440 "html_url": "u",
11441 "details_url": "u",
11442 "status": "s",
11443 "conclusion": "c",
11444 "started_at": ` + referenceTimeStr + `,
11445 "completed_at": ` + referenceTimeStr + `,
11446 "output": {
11447 "title": "t",
11448 "summary": "s",
11449 "text": "t",
11450 "annotations_count": 1,
11451 "annotations_url": "a",
11452 "annotations": [
11453 {
11454 "path": "p",
11455 "start_line": 1,
11456 "end_line": 1,
11457 "annotation_level": "a",
11458 "message": "m",
11459 "title": "t",
11460 "raw_details": "r"
11461 }
11462 ],
11463 "images": [
11464 {
11465 "alt": "a",
11466 "image_url": "i",
11467 "caption": "c"
11468 }
11469 ]
11470 },
11471 "name": "n",
11472 "check_suite": {
11473 "id": 1
11474 },
11475 "app": {
11476 "id": 1,
11477 "node_id": "n",
11478 "owner": {
11479 "login": "l",
11480 "id": 1,
11481 "node_id": "n",
11482 "avatar_url": "a",
11483 "url": "u",
11484 "events_url": "e",
11485 "repos_url": "r"
11486 },
11487 "name": "n",
11488 "description": "d",
11489 "external_url": "u",
11490 "html_url": "h",
11491 "created_at": ` + referenceTimeStr + `,
11492 "updated_at": ` + referenceTimeStr + `
11493 },
11494 "pull_requests": [
11495 {
11496 "id": 1,
11497 "number": 1,
11498 "url": "u",
11499 "head": {
11500 "ref": "r",
11501 "sha": "s",
11502 "repo": {
11503 "id": 1,
11504 "name": "n",
11505 "url": "s"
11506 }
11507 },
11508 "base": {
11509 "ref": "r",
11510 "sha": "s",
11511 "repo": {
11512 "id": 1,
11513 "name": "n",
11514 "url": "u"
11515 }
11516 }
11517 }
11518 ]
11519 },
11520 "action": "a",
11521 "repository": {
11522 "id": 1,
11523 "name": "n",
11524 "url": "s"
11525 },
11526 "organization": {
11527 "name": "n",
11528 "company": "c",
11529 "blog": "b",
11530 "location": "loc",
11531 "email": "e",
11532 "twitter_username": "tu",
11533 "description": "d",
11534 "billing_email": "be",
11535 "is_verified": true,
11536 "has_organization_projects": true,
11537 "has_repository_projects": true,
11538 "default_repository_permission": "drp",
11539 "members_can_create_repositories": true,
11540 "members_can_create_public_repositories": false,
11541 "members_can_create_private_repositories": true,
11542 "members_can_create_internal_repositories": true,
11543 "members_allowed_repository_creation_type": "marct",
11544 "members_can_create_pages": true,
11545 "members_can_create_public_pages": false,
11546 "members_can_create_private_pages": true
11547 },
11548 "sender": {
11549 "login": "l",
11550 "id": 1,
11551 "node_id": "n",
11552 "avatar_url": "a",
11553 "url": "u",
11554 "events_url": "e",
11555 "repos_url": "r"
11556 },
11557 "installation": {
11558 "id": 1,
11559 "node_id": "nid",
11560 "app_id": 1,
11561 "app_slug": "as",
11562 "target_id": 1,
11563 "account": {
11564 "login": "l",
11565 "id": 1,
11566 "avatar_url": "a",
11567 "gravatar_id": "g",
11568 "name": "n",
11569 "company": "c",
11570 "blog": "b",
11571 "location": "l",
11572 "email": "e",
11573 "hireable": true,
11574 "bio": "b",
11575 "twitter_username": "t",
11576 "public_repos": 1,
11577 "followers": 1,
11578 "following": 1,
11579 "created_at": ` + referenceTimeStr + `,
11580 "suspended_at": ` + referenceTimeStr + `,
11581 "url": "u"
11582 },
11583 "access_tokens_url": "atu",
11584 "repositories_url": "ru",
11585 "html_url": "hu",
11586 "target_type": "tt",
11587 "single_file_name": "sfn",
11588 "repository_selection": "rs",
11589 "events": [
11590 "e"
11591 ],
11592 "single_file_paths": [
11593 "s"
11594 ],
11595 "permissions": {
11596 "actions": "a",
11597 "administration": "ad",
11598 "checks": "c",
11599 "contents": "co",
11600 "content_references": "cr",
11601 "deployments": "d",
11602 "environments": "e",
11603 "issues": "i",
11604 "metadata": "md",
11605 "members": "m",
11606 "organization_administration": "oa",
11607 "organization_hooks": "oh",
11608 "organization_plan": "op",
11609 "organization_pre_receive_hooks": "opr",
11610 "organization_projects": "op",
11611 "organization_secrets": "os",
11612 "organization_self_hosted_runners": "osh",
11613 "organization_user_blocking": "oub",
11614 "packages": "pkg",
11615 "pages": "pg",
11616 "pull_requests": "pr",
11617 "repository_hooks": "rh",
11618 "repository_projects": "rp",
11619 "repository_pre_receive_hooks": "rprh",
11620 "secrets": "s",
11621 "secret_scanning_alerts": "ssa",
11622 "security_events": "se",
11623 "single_file": "sf",
11624 "statuses": "s",
11625 "team_discussions": "td",
11626 "vulnerability_alerts": "va",
11627 "workflows": "w"
11628 },
11629 "created_at": ` + referenceTimeStr + `,
11630 "updated_at": ` + referenceTimeStr + `,
11631 "has_multiple_single_files": false,
11632 "suspended_by": {
11633 "login": "l",
11634 "id": 1,
11635 "avatar_url": "a",
11636 "gravatar_id": "g",
11637 "name": "n",
11638 "company": "c",
11639 "blog": "b",
11640 "location": "l",
11641 "email": "e",
11642 "hireable": true,
11643 "bio": "b",
11644 "twitter_username": "t",
11645 "public_repos": 1,
11646 "followers": 1,
11647 "following": 1,
11648 "created_at": ` + referenceTimeStr + `,
11649 "suspended_at": ` + referenceTimeStr + `,
11650 "url": "u"
11651 },
11652 "suspended_at": ` + referenceTimeStr + `
11653 },
11654 "requested_action": {
11655 "identifier": "i"
11656 }
11657 }`
11658
11659 testJSONMarshal(t, r, want)
11660 }
11661
11662 func TestCheckSuiteEvent_Marshal(t *testing.T) {
11663 testJSONMarshal(t, &CheckSuiteEvent{}, "{}")
11664
11665 r := &CheckSuiteEvent{
11666 CheckSuite: &CheckSuite{
11667 ID: Int64(1),
11668 NodeID: String("n"),
11669 HeadBranch: String("h"),
11670 HeadSHA: String("h"),
11671 URL: String("u"),
11672 BeforeSHA: String("b"),
11673 AfterSHA: String("a"),
11674 Status: String("s"),
11675 Conclusion: String("c"),
11676 App: &App{
11677 ID: Int64(1),
11678 NodeID: String("n"),
11679 Owner: &User{
11680 Login: String("l"),
11681 ID: Int64(1),
11682 NodeID: String("n"),
11683 URL: String("u"),
11684 ReposURL: String("r"),
11685 EventsURL: String("e"),
11686 AvatarURL: String("a"),
11687 },
11688 Name: String("n"),
11689 Description: String("d"),
11690 HTMLURL: String("h"),
11691 ExternalURL: String("u"),
11692 CreatedAt: &Timestamp{referenceTime},
11693 UpdatedAt: &Timestamp{referenceTime},
11694 },
11695 Repository: &Repository{
11696 ID: Int64(1),
11697 },
11698 PullRequests: []*PullRequest{
11699 {
11700 URL: String("u"),
11701 ID: Int64(1),
11702 Number: Int(1),
11703 Head: &PullRequestBranch{
11704 Ref: String("r"),
11705 SHA: String("s"),
11706 Repo: &Repository{
11707 ID: Int64(1),
11708 URL: String("s"),
11709 Name: String("n"),
11710 },
11711 },
11712 Base: &PullRequestBranch{
11713 Ref: String("r"),
11714 SHA: String("s"),
11715 Repo: &Repository{
11716 ID: Int64(1),
11717 URL: String("u"),
11718 Name: String("n"),
11719 },
11720 },
11721 },
11722 },
11723 HeadCommit: &Commit{
11724 SHA: String("s"),
11725 },
11726 },
11727 Action: String("a"),
11728 Repo: &Repository{
11729 ID: Int64(1),
11730 URL: String("s"),
11731 Name: String("n"),
11732 },
11733 Org: &Organization{
11734 BillingEmail: String("be"),
11735 Blog: String("b"),
11736 Company: String("c"),
11737 Email: String("e"),
11738 TwitterUsername: String("tu"),
11739 Location: String("loc"),
11740 Name: String("n"),
11741 Description: String("d"),
11742 IsVerified: Bool(true),
11743 HasOrganizationProjects: Bool(true),
11744 HasRepositoryProjects: Bool(true),
11745 DefaultRepoPermission: String("drp"),
11746 MembersCanCreateRepos: Bool(true),
11747 MembersCanCreateInternalRepos: Bool(true),
11748 MembersCanCreatePrivateRepos: Bool(true),
11749 MembersCanCreatePublicRepos: Bool(false),
11750 MembersAllowedRepositoryCreationType: String("marct"),
11751 MembersCanCreatePages: Bool(true),
11752 MembersCanCreatePublicPages: Bool(false),
11753 MembersCanCreatePrivatePages: Bool(true),
11754 },
11755 Sender: &User{
11756 Login: String("l"),
11757 ID: Int64(1),
11758 NodeID: String("n"),
11759 URL: String("u"),
11760 ReposURL: String("r"),
11761 EventsURL: String("e"),
11762 AvatarURL: String("a"),
11763 },
11764 Installation: &Installation{
11765 ID: Int64(1),
11766 NodeID: String("nid"),
11767 AppID: Int64(1),
11768 AppSlug: String("as"),
11769 TargetID: Int64(1),
11770 Account: &User{
11771 Login: String("l"),
11772 ID: Int64(1),
11773 URL: String("u"),
11774 AvatarURL: String("a"),
11775 GravatarID: String("g"),
11776 Name: String("n"),
11777 Company: String("c"),
11778 Blog: String("b"),
11779 Location: String("l"),
11780 Email: String("e"),
11781 Hireable: Bool(true),
11782 Bio: String("b"),
11783 TwitterUsername: String("t"),
11784 PublicRepos: Int(1),
11785 Followers: Int(1),
11786 Following: Int(1),
11787 CreatedAt: &Timestamp{referenceTime},
11788 SuspendedAt: &Timestamp{referenceTime},
11789 },
11790 AccessTokensURL: String("atu"),
11791 RepositoriesURL: String("ru"),
11792 HTMLURL: String("hu"),
11793 TargetType: String("tt"),
11794 SingleFileName: String("sfn"),
11795 RepositorySelection: String("rs"),
11796 Events: []string{"e"},
11797 SingleFilePaths: []string{"s"},
11798 Permissions: &InstallationPermissions{
11799 Actions: String("a"),
11800 Administration: String("ad"),
11801 Checks: String("c"),
11802 Contents: String("co"),
11803 ContentReferences: String("cr"),
11804 Deployments: String("d"),
11805 Environments: String("e"),
11806 Issues: String("i"),
11807 Metadata: String("md"),
11808 Members: String("m"),
11809 OrganizationAdministration: String("oa"),
11810 OrganizationHooks: String("oh"),
11811 OrganizationPlan: String("op"),
11812 OrganizationPreReceiveHooks: String("opr"),
11813 OrganizationProjects: String("op"),
11814 OrganizationSecrets: String("os"),
11815 OrganizationSelfHostedRunners: String("osh"),
11816 OrganizationUserBlocking: String("oub"),
11817 Packages: String("pkg"),
11818 Pages: String("pg"),
11819 PullRequests: String("pr"),
11820 RepositoryHooks: String("rh"),
11821 RepositoryProjects: String("rp"),
11822 RepositoryPreReceiveHooks: String("rprh"),
11823 Secrets: String("s"),
11824 SecretScanningAlerts: String("ssa"),
11825 SecurityEvents: String("se"),
11826 SingleFile: String("sf"),
11827 Statuses: String("s"),
11828 TeamDiscussions: String("td"),
11829 VulnerabilityAlerts: String("va"),
11830 Workflows: String("w"),
11831 },
11832 CreatedAt: &Timestamp{referenceTime},
11833 UpdatedAt: &Timestamp{referenceTime},
11834 HasMultipleSingleFiles: Bool(false),
11835 SuspendedBy: &User{
11836 Login: String("l"),
11837 ID: Int64(1),
11838 URL: String("u"),
11839 AvatarURL: String("a"),
11840 GravatarID: String("g"),
11841 Name: String("n"),
11842 Company: String("c"),
11843 Blog: String("b"),
11844 Location: String("l"),
11845 Email: String("e"),
11846 Hireable: Bool(true),
11847 Bio: String("b"),
11848 TwitterUsername: String("t"),
11849 PublicRepos: Int(1),
11850 Followers: Int(1),
11851 Following: Int(1),
11852 CreatedAt: &Timestamp{referenceTime},
11853 SuspendedAt: &Timestamp{referenceTime},
11854 },
11855 SuspendedAt: &Timestamp{referenceTime},
11856 },
11857 }
11858
11859 want := `{
11860 "check_suite": {
11861 "id": 1,
11862 "node_id": "n",
11863 "head_branch": "h",
11864 "head_sha": "h",
11865 "url": "u",
11866 "before": "b",
11867 "after": "a",
11868 "status": "s",
11869 "conclusion": "c",
11870 "app": {
11871 "id": 1,
11872 "node_id": "n",
11873 "owner": {
11874 "login": "l",
11875 "id": 1,
11876 "node_id": "n",
11877 "avatar_url": "a",
11878 "url": "u",
11879 "events_url": "e",
11880 "repos_url": "r"
11881 },
11882 "name": "n",
11883 "description": "d",
11884 "external_url": "u",
11885 "html_url": "h",
11886 "created_at": ` + referenceTimeStr + `,
11887 "updated_at": ` + referenceTimeStr + `
11888 },
11889 "repository": {
11890 "id": 1
11891 },
11892 "pull_requests": [
11893 {
11894 "id": 1,
11895 "number": 1,
11896 "url": "u",
11897 "head": {
11898 "ref": "r",
11899 "sha": "s",
11900 "repo": {
11901 "id": 1,
11902 "name": "n",
11903 "url": "s"
11904 }
11905 },
11906 "base": {
11907 "ref": "r",
11908 "sha": "s",
11909 "repo": {
11910 "id": 1,
11911 "name": "n",
11912 "url": "u"
11913 }
11914 }
11915 }
11916 ],
11917 "head_commit": {
11918 "sha": "s"
11919 }
11920 },
11921 "action": "a",
11922 "repository": {
11923 "id": 1,
11924 "name": "n",
11925 "url": "s"
11926 },
11927 "organization": {
11928 "name": "n",
11929 "company": "c",
11930 "blog": "b",
11931 "location": "loc",
11932 "email": "e",
11933 "twitter_username": "tu",
11934 "description": "d",
11935 "billing_email": "be",
11936 "is_verified": true,
11937 "has_organization_projects": true,
11938 "has_repository_projects": true,
11939 "default_repository_permission": "drp",
11940 "members_can_create_repositories": true,
11941 "members_can_create_public_repositories": false,
11942 "members_can_create_private_repositories": true,
11943 "members_can_create_internal_repositories": true,
11944 "members_allowed_repository_creation_type": "marct",
11945 "members_can_create_pages": true,
11946 "members_can_create_public_pages": false,
11947 "members_can_create_private_pages": true
11948 },
11949 "sender": {
11950 "login": "l",
11951 "id": 1,
11952 "node_id": "n",
11953 "avatar_url": "a",
11954 "url": "u",
11955 "events_url": "e",
11956 "repos_url": "r"
11957 },
11958 "installation": {
11959 "id": 1,
11960 "node_id": "nid",
11961 "app_id": 1,
11962 "app_slug": "as",
11963 "target_id": 1,
11964 "account": {
11965 "login": "l",
11966 "id": 1,
11967 "avatar_url": "a",
11968 "gravatar_id": "g",
11969 "name": "n",
11970 "company": "c",
11971 "blog": "b",
11972 "location": "l",
11973 "email": "e",
11974 "hireable": true,
11975 "bio": "b",
11976 "twitter_username": "t",
11977 "public_repos": 1,
11978 "followers": 1,
11979 "following": 1,
11980 "created_at": ` + referenceTimeStr + `,
11981 "suspended_at": ` + referenceTimeStr + `,
11982 "url": "u"
11983 },
11984 "access_tokens_url": "atu",
11985 "repositories_url": "ru",
11986 "html_url": "hu",
11987 "target_type": "tt",
11988 "single_file_name": "sfn",
11989 "repository_selection": "rs",
11990 "events": [
11991 "e"
11992 ],
11993 "single_file_paths": [
11994 "s"
11995 ],
11996 "permissions": {
11997 "actions": "a",
11998 "administration": "ad",
11999 "checks": "c",
12000 "contents": "co",
12001 "content_references": "cr",
12002 "deployments": "d",
12003 "environments": "e",
12004 "issues": "i",
12005 "metadata": "md",
12006 "members": "m",
12007 "organization_administration": "oa",
12008 "organization_hooks": "oh",
12009 "organization_plan": "op",
12010 "organization_pre_receive_hooks": "opr",
12011 "organization_projects": "op",
12012 "organization_secrets": "os",
12013 "organization_self_hosted_runners": "osh",
12014 "organization_user_blocking": "oub",
12015 "packages": "pkg",
12016 "pages": "pg",
12017 "pull_requests": "pr",
12018 "repository_hooks": "rh",
12019 "repository_projects": "rp",
12020 "repository_pre_receive_hooks": "rprh",
12021 "secrets": "s",
12022 "secret_scanning_alerts": "ssa",
12023 "security_events": "se",
12024 "single_file": "sf",
12025 "statuses": "s",
12026 "team_discussions": "td",
12027 "vulnerability_alerts": "va",
12028 "workflows": "w"
12029 },
12030 "created_at": ` + referenceTimeStr + `,
12031 "updated_at": ` + referenceTimeStr + `,
12032 "has_multiple_single_files": false,
12033 "suspended_by": {
12034 "login": "l",
12035 "id": 1,
12036 "avatar_url": "a",
12037 "gravatar_id": "g",
12038 "name": "n",
12039 "company": "c",
12040 "blog": "b",
12041 "location": "l",
12042 "email": "e",
12043 "hireable": true,
12044 "bio": "b",
12045 "twitter_username": "t",
12046 "public_repos": 1,
12047 "followers": 1,
12048 "following": 1,
12049 "created_at": ` + referenceTimeStr + `,
12050 "suspended_at": ` + referenceTimeStr + `,
12051 "url": "u"
12052 },
12053 "suspended_at": ` + referenceTimeStr + `
12054 }
12055 }`
12056
12057 testJSONMarshal(t, r, want)
12058 }
12059
12060 func TestDeployKeyEvent_Marshal(t *testing.T) {
12061 testJSONMarshal(t, &DeployKeyEvent{}, "{}")
12062
12063 u := &DeployKeyEvent{
12064 Action: String("a"),
12065 Key: &Key{
12066 ID: Int64(1),
12067 Key: String("k"),
12068 URL: String("k"),
12069 Title: String("k"),
12070 ReadOnly: Bool(false),
12071 Verified: Bool(false),
12072 CreatedAt: &Timestamp{referenceTime},
12073 },
12074 Repo: &Repository{
12075 ID: Int64(1),
12076 URL: String("s"),
12077 Name: String("n"),
12078 },
12079 Organization: &Organization{
12080 BillingEmail: String("be"),
12081 Blog: String("b"),
12082 Company: String("c"),
12083 Email: String("e"),
12084 TwitterUsername: String("tu"),
12085 Location: String("loc"),
12086 Name: String("n"),
12087 Description: String("d"),
12088 IsVerified: Bool(true),
12089 HasOrganizationProjects: Bool(true),
12090 HasRepositoryProjects: Bool(true),
12091 DefaultRepoPermission: String("drp"),
12092 MembersCanCreateRepos: Bool(true),
12093 MembersCanCreateInternalRepos: Bool(true),
12094 MembersCanCreatePrivateRepos: Bool(true),
12095 MembersCanCreatePublicRepos: Bool(false),
12096 MembersAllowedRepositoryCreationType: String("marct"),
12097 MembersCanCreatePages: Bool(true),
12098 MembersCanCreatePublicPages: Bool(false),
12099 MembersCanCreatePrivatePages: Bool(true),
12100 },
12101 Sender: &User{
12102 Login: String("l"),
12103 ID: Int64(1),
12104 NodeID: String("n"),
12105 AvatarURL: String("a"),
12106 URL: String("u"),
12107 EventsURL: String("e"),
12108 ReposURL: String("r"),
12109 },
12110 }
12111
12112 want := `{
12113 "action": "a",
12114 "key": {
12115 "id": 1,
12116 "key": "k",
12117 "url": "k",
12118 "title": "k",
12119 "read_only": false,
12120 "verified": false,
12121 "created_at": ` + referenceTimeStr + `
12122 },
12123 "repository": {
12124 "id": 1,
12125 "name": "n",
12126 "url": "s"
12127 },
12128 "organization": {
12129 "name": "n",
12130 "company": "c",
12131 "blog": "b",
12132 "location": "loc",
12133 "email": "e",
12134 "twitter_username": "tu",
12135 "description": "d",
12136 "billing_email": "be",
12137 "is_verified": true,
12138 "has_organization_projects": true,
12139 "has_repository_projects": true,
12140 "default_repository_permission": "drp",
12141 "members_can_create_repositories": true,
12142 "members_can_create_public_repositories": false,
12143 "members_can_create_private_repositories": true,
12144 "members_can_create_internal_repositories": true,
12145 "members_allowed_repository_creation_type": "marct",
12146 "members_can_create_pages": true,
12147 "members_can_create_public_pages": false,
12148 "members_can_create_private_pages": true
12149 },
12150 "sender": {
12151 "login": "l",
12152 "id": 1,
12153 "node_id": "n",
12154 "avatar_url": "a",
12155 "url": "u",
12156 "events_url": "e",
12157 "repos_url": "r"
12158 }
12159 }`
12160
12161 testJSONMarshal(t, u, want)
12162 }
12163
12164 func TestMetaEvent_Marshal(t *testing.T) {
12165 testJSONMarshal(t, &MetaEvent{}, "{}")
12166
12167 v := make(map[string]interface{})
12168 v["a"] = "b"
12169 hookConfig := &HookConfig{
12170 ContentType: String("json"),
12171 }
12172
12173 u := &MetaEvent{
12174 Action: String("a"),
12175 HookID: Int64(1),
12176 Hook: &Hook{
12177 CreatedAt: &Timestamp{referenceTime},
12178 UpdatedAt: &Timestamp{referenceTime},
12179 URL: String("u"),
12180 ID: Int64(1),
12181 Type: String("t"),
12182 Name: String("n"),
12183 TestURL: String("tu"),
12184 PingURL: String("pu"),
12185 LastResponse: v,
12186 Config: hookConfig,
12187 Events: []string{"a"},
12188 Active: Bool(true),
12189 },
12190 }
12191
12192 want := `{
12193 "action": "a",
12194 "hook_id": 1,
12195 "hook": {
12196 "created_at": ` + referenceTimeStr + `,
12197 "updated_at": ` + referenceTimeStr + `,
12198 "url": "u",
12199 "id": 1,
12200 "type": "t",
12201 "name": "n",
12202 "test_url": "tu",
12203 "ping_url": "pu",
12204 "last_response": {
12205 "a": "b"
12206 },
12207 "config": {
12208 "content_type": "json"
12209 },
12210 "events": [
12211 "a"
12212 ],
12213 "active": true
12214 }
12215 }`
12216
12217 testJSONMarshal(t, u, want)
12218 }
12219
12220 func TestRequestedAction_Marshal(t *testing.T) {
12221 testJSONMarshal(t, &RequestedAction{}, "{}")
12222
12223 r := &RequestedAction{
12224 Identifier: "i",
12225 }
12226
12227 want := `{
12228 "identifier": "i"
12229 }`
12230
12231 testJSONMarshal(t, r, want)
12232 }
12233
12234 func TestCreateEvent_Marshal(t *testing.T) {
12235 testJSONMarshal(t, &CreateEvent{}, "{}")
12236
12237 r := &CreateEvent{
12238 Ref: String("r"),
12239 RefType: String("rt"),
12240 MasterBranch: String("mb"),
12241 Description: String("d"),
12242 PusherType: String("pt"),
12243 Repo: &Repository{
12244 ID: Int64(1),
12245 URL: String("s"),
12246 Name: String("n"),
12247 },
12248 Sender: &User{
12249 Login: String("l"),
12250 ID: Int64(1),
12251 NodeID: String("n"),
12252 URL: String("u"),
12253 ReposURL: String("r"),
12254 EventsURL: String("e"),
12255 AvatarURL: String("a"),
12256 },
12257 Installation: &Installation{
12258 ID: Int64(1),
12259 NodeID: String("nid"),
12260 AppID: Int64(1),
12261 AppSlug: String("as"),
12262 TargetID: Int64(1),
12263 Account: &User{
12264 Login: String("l"),
12265 ID: Int64(1),
12266 URL: String("u"),
12267 AvatarURL: String("a"),
12268 GravatarID: String("g"),
12269 Name: String("n"),
12270 Company: String("c"),
12271 Blog: String("b"),
12272 Location: String("l"),
12273 Email: String("e"),
12274 Hireable: Bool(true),
12275 Bio: String("b"),
12276 TwitterUsername: String("t"),
12277 PublicRepos: Int(1),
12278 Followers: Int(1),
12279 Following: Int(1),
12280 CreatedAt: &Timestamp{referenceTime},
12281 SuspendedAt: &Timestamp{referenceTime},
12282 },
12283 AccessTokensURL: String("atu"),
12284 RepositoriesURL: String("ru"),
12285 HTMLURL: String("hu"),
12286 TargetType: String("tt"),
12287 SingleFileName: String("sfn"),
12288 RepositorySelection: String("rs"),
12289 Events: []string{"e"},
12290 SingleFilePaths: []string{"s"},
12291 Permissions: &InstallationPermissions{
12292 Actions: String("a"),
12293 Administration: String("ad"),
12294 Checks: String("c"),
12295 Contents: String("co"),
12296 ContentReferences: String("cr"),
12297 Deployments: String("d"),
12298 Environments: String("e"),
12299 Issues: String("i"),
12300 Metadata: String("md"),
12301 Members: String("m"),
12302 OrganizationAdministration: String("oa"),
12303 OrganizationHooks: String("oh"),
12304 OrganizationPlan: String("op"),
12305 OrganizationPreReceiveHooks: String("opr"),
12306 OrganizationProjects: String("op"),
12307 OrganizationSecrets: String("os"),
12308 OrganizationSelfHostedRunners: String("osh"),
12309 OrganizationUserBlocking: String("oub"),
12310 Packages: String("pkg"),
12311 Pages: String("pg"),
12312 PullRequests: String("pr"),
12313 RepositoryHooks: String("rh"),
12314 RepositoryProjects: String("rp"),
12315 RepositoryPreReceiveHooks: String("rprh"),
12316 Secrets: String("s"),
12317 SecretScanningAlerts: String("ssa"),
12318 SecurityEvents: String("se"),
12319 SingleFile: String("sf"),
12320 Statuses: String("s"),
12321 TeamDiscussions: String("td"),
12322 VulnerabilityAlerts: String("va"),
12323 Workflows: String("w"),
12324 },
12325 CreatedAt: &Timestamp{referenceTime},
12326 UpdatedAt: &Timestamp{referenceTime},
12327 HasMultipleSingleFiles: Bool(false),
12328 SuspendedBy: &User{
12329 Login: String("l"),
12330 ID: Int64(1),
12331 URL: String("u"),
12332 AvatarURL: String("a"),
12333 GravatarID: String("g"),
12334 Name: String("n"),
12335 Company: String("c"),
12336 Blog: String("b"),
12337 Location: String("l"),
12338 Email: String("e"),
12339 Hireable: Bool(true),
12340 Bio: String("b"),
12341 TwitterUsername: String("t"),
12342 PublicRepos: Int(1),
12343 Followers: Int(1),
12344 Following: Int(1),
12345 CreatedAt: &Timestamp{referenceTime},
12346 SuspendedAt: &Timestamp{referenceTime},
12347 },
12348 SuspendedAt: &Timestamp{referenceTime},
12349 },
12350 }
12351
12352 want := `{
12353 "ref": "r",
12354 "ref_type": "rt",
12355 "master_branch": "mb",
12356 "description": "d",
12357 "pusher_type": "pt",
12358 "repository": {
12359 "id": 1,
12360 "name": "n",
12361 "url": "s"
12362 },
12363 "sender": {
12364 "login": "l",
12365 "id": 1,
12366 "node_id": "n",
12367 "avatar_url": "a",
12368 "url": "u",
12369 "events_url": "e",
12370 "repos_url": "r"
12371 },
12372 "installation": {
12373 "id": 1,
12374 "node_id": "nid",
12375 "app_id": 1,
12376 "app_slug": "as",
12377 "target_id": 1,
12378 "account": {
12379 "login": "l",
12380 "id": 1,
12381 "avatar_url": "a",
12382 "gravatar_id": "g",
12383 "name": "n",
12384 "company": "c",
12385 "blog": "b",
12386 "location": "l",
12387 "email": "e",
12388 "hireable": true,
12389 "bio": "b",
12390 "twitter_username": "t",
12391 "public_repos": 1,
12392 "followers": 1,
12393 "following": 1,
12394 "created_at": ` + referenceTimeStr + `,
12395 "suspended_at": ` + referenceTimeStr + `,
12396 "url": "u"
12397 },
12398 "access_tokens_url": "atu",
12399 "repositories_url": "ru",
12400 "html_url": "hu",
12401 "target_type": "tt",
12402 "single_file_name": "sfn",
12403 "repository_selection": "rs",
12404 "events": [
12405 "e"
12406 ],
12407 "single_file_paths": [
12408 "s"
12409 ],
12410 "permissions": {
12411 "actions": "a",
12412 "administration": "ad",
12413 "checks": "c",
12414 "contents": "co",
12415 "content_references": "cr",
12416 "deployments": "d",
12417 "environments": "e",
12418 "issues": "i",
12419 "metadata": "md",
12420 "members": "m",
12421 "organization_administration": "oa",
12422 "organization_hooks": "oh",
12423 "organization_plan": "op",
12424 "organization_pre_receive_hooks": "opr",
12425 "organization_projects": "op",
12426 "organization_secrets": "os",
12427 "organization_self_hosted_runners": "osh",
12428 "organization_user_blocking": "oub",
12429 "packages": "pkg",
12430 "pages": "pg",
12431 "pull_requests": "pr",
12432 "repository_hooks": "rh",
12433 "repository_projects": "rp",
12434 "repository_pre_receive_hooks": "rprh",
12435 "secrets": "s",
12436 "secret_scanning_alerts": "ssa",
12437 "security_events": "se",
12438 "single_file": "sf",
12439 "statuses": "s",
12440 "team_discussions": "td",
12441 "vulnerability_alerts": "va",
12442 "workflows": "w"
12443 },
12444 "created_at": ` + referenceTimeStr + `,
12445 "updated_at": ` + referenceTimeStr + `,
12446 "has_multiple_single_files": false,
12447 "suspended_by": {
12448 "login": "l",
12449 "id": 1,
12450 "avatar_url": "a",
12451 "gravatar_id": "g",
12452 "name": "n",
12453 "company": "c",
12454 "blog": "b",
12455 "location": "l",
12456 "email": "e",
12457 "hireable": true,
12458 "bio": "b",
12459 "twitter_username": "t",
12460 "public_repos": 1,
12461 "followers": 1,
12462 "following": 1,
12463 "created_at": ` + referenceTimeStr + `,
12464 "suspended_at": ` + referenceTimeStr + `,
12465 "url": "u"
12466 },
12467 "suspended_at": ` + referenceTimeStr + `
12468 }
12469 }`
12470
12471 testJSONMarshal(t, r, want)
12472 }
12473
12474 func TestDeleteEvent_Marshal(t *testing.T) {
12475 testJSONMarshal(t, &DeleteEvent{}, "{}")
12476
12477 r := &DeleteEvent{
12478 Ref: String("r"),
12479 RefType: String("rt"),
12480 PusherType: String("pt"),
12481 Repo: &Repository{
12482 ID: Int64(1),
12483 URL: String("s"),
12484 Name: String("n"),
12485 },
12486 Sender: &User{
12487 Login: String("l"),
12488 ID: Int64(1),
12489 NodeID: String("n"),
12490 URL: String("u"),
12491 ReposURL: String("r"),
12492 EventsURL: String("e"),
12493 AvatarURL: String("a"),
12494 },
12495 Installation: &Installation{
12496 ID: Int64(1),
12497 NodeID: String("nid"),
12498 AppID: Int64(1),
12499 AppSlug: String("as"),
12500 TargetID: Int64(1),
12501 Account: &User{
12502 Login: String("l"),
12503 ID: Int64(1),
12504 URL: String("u"),
12505 AvatarURL: String("a"),
12506 GravatarID: String("g"),
12507 Name: String("n"),
12508 Company: String("c"),
12509 Blog: String("b"),
12510 Location: String("l"),
12511 Email: String("e"),
12512 Hireable: Bool(true),
12513 Bio: String("b"),
12514 TwitterUsername: String("t"),
12515 PublicRepos: Int(1),
12516 Followers: Int(1),
12517 Following: Int(1),
12518 CreatedAt: &Timestamp{referenceTime},
12519 SuspendedAt: &Timestamp{referenceTime},
12520 },
12521 AccessTokensURL: String("atu"),
12522 RepositoriesURL: String("ru"),
12523 HTMLURL: String("hu"),
12524 TargetType: String("tt"),
12525 SingleFileName: String("sfn"),
12526 RepositorySelection: String("rs"),
12527 Events: []string{"e"},
12528 SingleFilePaths: []string{"s"},
12529 Permissions: &InstallationPermissions{
12530 Actions: String("a"),
12531 Administration: String("ad"),
12532 Checks: String("c"),
12533 Contents: String("co"),
12534 ContentReferences: String("cr"),
12535 Deployments: String("d"),
12536 Environments: String("e"),
12537 Issues: String("i"),
12538 Metadata: String("md"),
12539 Members: String("m"),
12540 OrganizationAdministration: String("oa"),
12541 OrganizationHooks: String("oh"),
12542 OrganizationPlan: String("op"),
12543 OrganizationPreReceiveHooks: String("opr"),
12544 OrganizationProjects: String("op"),
12545 OrganizationSecrets: String("os"),
12546 OrganizationSelfHostedRunners: String("osh"),
12547 OrganizationUserBlocking: String("oub"),
12548 Packages: String("pkg"),
12549 Pages: String("pg"),
12550 PullRequests: String("pr"),
12551 RepositoryHooks: String("rh"),
12552 RepositoryProjects: String("rp"),
12553 RepositoryPreReceiveHooks: String("rprh"),
12554 Secrets: String("s"),
12555 SecretScanningAlerts: String("ssa"),
12556 SecurityEvents: String("se"),
12557 SingleFile: String("sf"),
12558 Statuses: String("s"),
12559 TeamDiscussions: String("td"),
12560 VulnerabilityAlerts: String("va"),
12561 Workflows: String("w"),
12562 },
12563 CreatedAt: &Timestamp{referenceTime},
12564 UpdatedAt: &Timestamp{referenceTime},
12565 HasMultipleSingleFiles: Bool(false),
12566 SuspendedBy: &User{
12567 Login: String("l"),
12568 ID: Int64(1),
12569 URL: String("u"),
12570 AvatarURL: String("a"),
12571 GravatarID: String("g"),
12572 Name: String("n"),
12573 Company: String("c"),
12574 Blog: String("b"),
12575 Location: String("l"),
12576 Email: String("e"),
12577 Hireable: Bool(true),
12578 Bio: String("b"),
12579 TwitterUsername: String("t"),
12580 PublicRepos: Int(1),
12581 Followers: Int(1),
12582 Following: Int(1),
12583 CreatedAt: &Timestamp{referenceTime},
12584 SuspendedAt: &Timestamp{referenceTime},
12585 },
12586 SuspendedAt: &Timestamp{referenceTime},
12587 },
12588 }
12589
12590 want := `{
12591 "ref": "r",
12592 "ref_type": "rt",
12593 "pusher_type": "pt",
12594 "repository": {
12595 "id": 1,
12596 "name": "n",
12597 "url": "s"
12598 },
12599 "sender": {
12600 "login": "l",
12601 "id": 1,
12602 "node_id": "n",
12603 "avatar_url": "a",
12604 "url": "u",
12605 "events_url": "e",
12606 "repos_url": "r"
12607 },
12608 "installation": {
12609 "id": 1,
12610 "node_id": "nid",
12611 "app_id": 1,
12612 "app_slug": "as",
12613 "target_id": 1,
12614 "account": {
12615 "login": "l",
12616 "id": 1,
12617 "avatar_url": "a",
12618 "gravatar_id": "g",
12619 "name": "n",
12620 "company": "c",
12621 "blog": "b",
12622 "location": "l",
12623 "email": "e",
12624 "hireable": true,
12625 "bio": "b",
12626 "twitter_username": "t",
12627 "public_repos": 1,
12628 "followers": 1,
12629 "following": 1,
12630 "created_at": ` + referenceTimeStr + `,
12631 "suspended_at": ` + referenceTimeStr + `,
12632 "url": "u"
12633 },
12634 "access_tokens_url": "atu",
12635 "repositories_url": "ru",
12636 "html_url": "hu",
12637 "target_type": "tt",
12638 "single_file_name": "sfn",
12639 "repository_selection": "rs",
12640 "events": [
12641 "e"
12642 ],
12643 "single_file_paths": [
12644 "s"
12645 ],
12646 "permissions": {
12647 "actions": "a",
12648 "administration": "ad",
12649 "checks": "c",
12650 "contents": "co",
12651 "content_references": "cr",
12652 "deployments": "d",
12653 "environments": "e",
12654 "issues": "i",
12655 "metadata": "md",
12656 "members": "m",
12657 "organization_administration": "oa",
12658 "organization_hooks": "oh",
12659 "organization_plan": "op",
12660 "organization_pre_receive_hooks": "opr",
12661 "organization_projects": "op",
12662 "organization_secrets": "os",
12663 "organization_self_hosted_runners": "osh",
12664 "organization_user_blocking": "oub",
12665 "packages": "pkg",
12666 "pages": "pg",
12667 "pull_requests": "pr",
12668 "repository_hooks": "rh",
12669 "repository_projects": "rp",
12670 "repository_pre_receive_hooks": "rprh",
12671 "secrets": "s",
12672 "secret_scanning_alerts": "ssa",
12673 "security_events": "se",
12674 "single_file": "sf",
12675 "statuses": "s",
12676 "team_discussions": "td",
12677 "vulnerability_alerts": "va",
12678 "workflows": "w"
12679 },
12680 "created_at": ` + referenceTimeStr + `,
12681 "updated_at": ` + referenceTimeStr + `,
12682 "has_multiple_single_files": false,
12683 "suspended_by": {
12684 "login": "l",
12685 "id": 1,
12686 "avatar_url": "a",
12687 "gravatar_id": "g",
12688 "name": "n",
12689 "company": "c",
12690 "blog": "b",
12691 "location": "l",
12692 "email": "e",
12693 "hireable": true,
12694 "bio": "b",
12695 "twitter_username": "t",
12696 "public_repos": 1,
12697 "followers": 1,
12698 "following": 1,
12699 "created_at": ` + referenceTimeStr + `,
12700 "suspended_at": ` + referenceTimeStr + `,
12701 "url": "u"
12702 },
12703 "suspended_at": ` + referenceTimeStr + `
12704 }
12705 }`
12706
12707 testJSONMarshal(t, r, want)
12708 }
12709
12710 func TestDependabotAlertEvent_Marshal(t *testing.T) {
12711 testJSONMarshal(t, &DependabotAlertEvent{}, "{}")
12712
12713 e := &DependabotAlertEvent{
12714 Action: String("a"),
12715 Alert: &DependabotAlert{
12716 Number: Int(1),
12717 State: String("s"),
12718 Dependency: &Dependency{
12719 Package: &VulnerabilityPackage{
12720 Ecosystem: String("e"),
12721 Name: String("n"),
12722 },
12723 ManifestPath: String("mp"),
12724 Scope: String("s"),
12725 },
12726 SecurityAdvisory: &DependabotSecurityAdvisory{
12727 GHSAID: String("ghsaid"),
12728 CVEID: String("cveid"),
12729 Summary: String("s"),
12730 Description: String("d"),
12731 Vulnerabilities: []*AdvisoryVulnerability{
12732 {
12733 Package: &VulnerabilityPackage{
12734 Ecosystem: String("e"),
12735 Name: String("n"),
12736 },
12737 Severity: String("s"),
12738 },
12739 },
12740 Severity: String("s"),
12741 CVSS: &AdvisoryCVSS{
12742 Score: Float64(1.0),
12743 VectorString: String("vs"),
12744 },
12745 CWEs: []*AdvisoryCWEs{
12746 {
12747 CWEID: String("cweid"),
12748 Name: String("n"),
12749 },
12750 },
12751 Identifiers: []*AdvisoryIdentifier{
12752 {
12753 Value: String("v"),
12754 Type: String("t"),
12755 },
12756 },
12757 References: []*AdvisoryReference{
12758 {
12759 URL: String("u"),
12760 },
12761 },
12762 PublishedAt: &Timestamp{referenceTime},
12763 UpdatedAt: &Timestamp{referenceTime},
12764 WithdrawnAt: &Timestamp{referenceTime},
12765 },
12766 SecurityVulnerability: &AdvisoryVulnerability{
12767 Package: &VulnerabilityPackage{
12768 Ecosystem: String("e"),
12769 Name: String("n"),
12770 },
12771 Severity: String("s"),
12772 VulnerableVersionRange: String("vvr"),
12773 FirstPatchedVersion: &FirstPatchedVersion{
12774 Identifier: String("i"),
12775 },
12776 },
12777 URL: String("u"),
12778 HTMLURL: String("hu"),
12779 CreatedAt: &Timestamp{referenceTime},
12780 UpdatedAt: &Timestamp{referenceTime},
12781 DismissedAt: &Timestamp{referenceTime},
12782 DismissedBy: &User{
12783 Login: String("l"),
12784 ID: Int64(1),
12785 NodeID: String("n"),
12786 URL: String("u"),
12787 ReposURL: String("r"),
12788 EventsURL: String("e"),
12789 AvatarURL: String("a"),
12790 },
12791 DismissedReason: String("dr"),
12792 DismissedComment: String("dc"),
12793 FixedAt: &Timestamp{referenceTime},
12794 AutoDismissedAt: &Timestamp{referenceTime},
12795 },
12796 Repo: &Repository{
12797 ID: Int64(1),
12798 URL: String("s"),
12799 Name: String("n"),
12800 },
12801 Organization: &Organization{
12802 BillingEmail: String("be"),
12803 Blog: String("b"),
12804 Company: String("c"),
12805 Email: String("e"),
12806 TwitterUsername: String("tu"),
12807 Location: String("loc"),
12808 Name: String("n"),
12809 Description: String("d"),
12810 IsVerified: Bool(true),
12811 HasOrganizationProjects: Bool(true),
12812 HasRepositoryProjects: Bool(true),
12813 DefaultRepoPermission: String("drp"),
12814 MembersCanCreateRepos: Bool(true),
12815 MembersCanCreateInternalRepos: Bool(true),
12816 MembersCanCreatePrivateRepos: Bool(true),
12817 MembersCanCreatePublicRepos: Bool(false),
12818 MembersAllowedRepositoryCreationType: String("marct"),
12819 MembersCanCreatePages: Bool(true),
12820 MembersCanCreatePublicPages: Bool(false),
12821 MembersCanCreatePrivatePages: Bool(true),
12822 },
12823 Enterprise: &Enterprise{
12824 ID: Int(1),
12825 Slug: String("s"),
12826 Name: String("n"),
12827 NodeID: String("nid"),
12828 AvatarURL: String("au"),
12829 Description: String("d"),
12830 WebsiteURL: String("wu"),
12831 HTMLURL: String("hu"),
12832 CreatedAt: &Timestamp{referenceTime},
12833 UpdatedAt: &Timestamp{referenceTime},
12834 },
12835 Sender: &User{
12836 Login: String("l"),
12837 ID: Int64(1),
12838 NodeID: String("n"),
12839 URL: String("u"),
12840 ReposURL: String("r"),
12841 EventsURL: String("e"),
12842 AvatarURL: String("a"),
12843 },
12844 Installation: &Installation{
12845 ID: Int64(1),
12846 NodeID: String("nid"),
12847 AppID: Int64(1),
12848 AppSlug: String("as"),
12849 TargetID: Int64(1),
12850 Account: &User{
12851 Login: String("l"),
12852 ID: Int64(1),
12853 URL: String("u"),
12854 AvatarURL: String("a"),
12855 GravatarID: String("g"),
12856 Name: String("n"),
12857 Company: String("c"),
12858 Blog: String("b"),
12859 Location: String("l"),
12860 Email: String("e"),
12861 Hireable: Bool(true),
12862 Bio: String("b"),
12863 TwitterUsername: String("t"),
12864 PublicRepos: Int(1),
12865 Followers: Int(1),
12866 Following: Int(1),
12867 CreatedAt: &Timestamp{referenceTime},
12868 SuspendedAt: &Timestamp{referenceTime},
12869 },
12870 AccessTokensURL: String("atu"),
12871 RepositoriesURL: String("ru"),
12872 HTMLURL: String("hu"),
12873 TargetType: String("tt"),
12874 SingleFileName: String("sfn"),
12875 RepositorySelection: String("rs"),
12876 Events: []string{"e"},
12877 SingleFilePaths: []string{"s"},
12878 Permissions: &InstallationPermissions{
12879 Actions: String("a"),
12880 Administration: String("ad"),
12881 Checks: String("c"),
12882 Contents: String("co"),
12883 ContentReferences: String("cr"),
12884 Deployments: String("d"),
12885 Environments: String("e"),
12886 Issues: String("i"),
12887 Metadata: String("md"),
12888 Members: String("m"),
12889 OrganizationAdministration: String("oa"),
12890 OrganizationHooks: String("oh"),
12891 OrganizationPlan: String("op"),
12892 OrganizationPreReceiveHooks: String("opr"),
12893 OrganizationProjects: String("op"),
12894 OrganizationSecrets: String("os"),
12895 OrganizationSelfHostedRunners: String("osh"),
12896 OrganizationUserBlocking: String("oub"),
12897 Packages: String("pkg"),
12898 Pages: String("pg"),
12899 PullRequests: String("pr"),
12900 RepositoryHooks: String("rh"),
12901 RepositoryProjects: String("rp"),
12902 RepositoryPreReceiveHooks: String("rprh"),
12903 Secrets: String("s"),
12904 SecretScanningAlerts: String("ssa"),
12905 SecurityEvents: String("se"),
12906 SingleFile: String("sf"),
12907 Statuses: String("s"),
12908 TeamDiscussions: String("td"),
12909 VulnerabilityAlerts: String("va"),
12910 Workflows: String("w"),
12911 },
12912 CreatedAt: &Timestamp{referenceTime},
12913 UpdatedAt: &Timestamp{referenceTime},
12914 HasMultipleSingleFiles: Bool(false),
12915 SuspendedBy: &User{
12916 Login: String("l"),
12917 ID: Int64(1),
12918 URL: String("u"),
12919 AvatarURL: String("a"),
12920 GravatarID: String("g"),
12921 Name: String("n"),
12922 Company: String("c"),
12923 Blog: String("b"),
12924 Location: String("l"),
12925 Email: String("e"),
12926 Hireable: Bool(true),
12927 Bio: String("b"),
12928 TwitterUsername: String("t"),
12929 PublicRepos: Int(1),
12930 Followers: Int(1),
12931 Following: Int(1),
12932 CreatedAt: &Timestamp{referenceTime},
12933 SuspendedAt: &Timestamp{referenceTime},
12934 },
12935 SuspendedAt: &Timestamp{referenceTime},
12936 },
12937 }
12938 want := `{
12939 "action": "a",
12940 "alert": {
12941 "number": 1,
12942 "state": "s",
12943 "dependency": {
12944 "package": {
12945 "ecosystem": "e",
12946 "name": "n"
12947 },
12948 "manifest_path": "mp",
12949 "scope": "s"
12950 },
12951 "security_advisory": {
12952 "ghsa_id": "ghsaid",
12953 "cve_id": "cveid",
12954 "summary": "s",
12955 "description": "d",
12956 "vulnerabilities": [
12957 {
12958 "package": {
12959 "ecosystem": "e",
12960 "name": "n"
12961 },
12962 "severity": "s"
12963 }
12964 ],
12965 "severity": "s",
12966 "cvss": {
12967 "score": 1.0,
12968 "vector_string": "vs"
12969 },
12970 "cwes": [
12971 {
12972 "cwe_id": "cweid",
12973 "name": "n"
12974 }
12975 ],
12976 "identifiers": [
12977 {
12978 "value": "v",
12979 "type": "t"
12980 }
12981 ],
12982 "references": [
12983 {
12984 "url": "u"
12985 }
12986 ],
12987 "published_at": ` + referenceTimeStr + `,
12988 "updated_at": ` + referenceTimeStr + `,
12989 "withdrawn_at": ` + referenceTimeStr + `
12990 },
12991 "security_vulnerability": {
12992 "package": {
12993 "ecosystem": "e",
12994 "name": "n"
12995 },
12996 "severity": "s",
12997 "vulnerable_version_range": "vvr",
12998 "first_patched_version": {
12999 "identifier": "i"
13000 }
13001 },
13002 "url": "u",
13003 "html_url": "hu",
13004 "created_at": ` + referenceTimeStr + `,
13005 "updated_at": ` + referenceTimeStr + `,
13006 "dismissed_at": ` + referenceTimeStr + `,
13007 "dismissed_by": {
13008 "login": "l",
13009 "id": 1,
13010 "node_id": "n",
13011 "avatar_url": "a",
13012 "url": "u",
13013 "events_url": "e",
13014 "repos_url": "r"
13015 },
13016 "dismissed_reason": "dr",
13017 "dismissed_comment": "dc",
13018 "fixed_at": ` + referenceTimeStr + `,
13019 "auto_dismissed_at": ` + referenceTimeStr + `
13020 },
13021 "repository": {
13022 "id": 1,
13023 "name": "n",
13024 "url": "s"
13025 },
13026 "organization": {
13027 "name": "n",
13028 "company": "c",
13029 "blog": "b",
13030 "location": "loc",
13031 "email": "e",
13032 "twitter_username": "tu",
13033 "description": "d",
13034 "billing_email": "be",
13035 "is_verified": true,
13036 "has_organization_projects": true,
13037 "has_repository_projects": true,
13038 "default_repository_permission": "drp",
13039 "members_can_create_repositories": true,
13040 "members_can_create_public_repositories": false,
13041 "members_can_create_private_repositories": true,
13042 "members_can_create_internal_repositories": true,
13043 "members_allowed_repository_creation_type": "marct",
13044 "members_can_create_pages": true,
13045 "members_can_create_public_pages": false,
13046 "members_can_create_private_pages": true
13047 },
13048 "enterprise": {
13049 "id": 1,
13050 "slug": "s",
13051 "name": "n",
13052 "node_id": "nid",
13053 "avatar_url": "au",
13054 "description": "d",
13055 "website_url": "wu",
13056 "html_url": "hu",
13057 "created_at": ` + referenceTimeStr + `,
13058 "updated_at": ` + referenceTimeStr + `
13059 },
13060 "sender": {
13061 "login": "l",
13062 "id": 1,
13063 "node_id": "n",
13064 "avatar_url": "a",
13065 "url": "u",
13066 "events_url": "e",
13067 "repos_url": "r"
13068 },
13069 "installation": {
13070 "id": 1,
13071 "node_id": "nid",
13072 "app_id": 1,
13073 "app_slug": "as",
13074 "target_id": 1,
13075 "account": {
13076 "login": "l",
13077 "id": 1,
13078 "avatar_url": "a",
13079 "gravatar_id": "g",
13080 "name": "n",
13081 "company": "c",
13082 "blog": "b",
13083 "location": "l",
13084 "email": "e",
13085 "hireable": true,
13086 "bio": "b",
13087 "twitter_username": "t",
13088 "public_repos": 1,
13089 "followers": 1,
13090 "following": 1,
13091 "created_at": ` + referenceTimeStr + `,
13092 "suspended_at": ` + referenceTimeStr + `,
13093 "url": "u"
13094 },
13095 "access_tokens_url": "atu",
13096 "repositories_url": "ru",
13097 "html_url": "hu",
13098 "target_type": "tt",
13099 "single_file_name": "sfn",
13100 "repository_selection": "rs",
13101 "events": [
13102 "e"
13103 ],
13104 "single_file_paths": [
13105 "s"
13106 ],
13107 "permissions": {
13108 "actions": "a",
13109 "administration": "ad",
13110 "checks": "c",
13111 "contents": "co",
13112 "content_references": "cr",
13113 "deployments": "d",
13114 "environments": "e",
13115 "issues": "i",
13116 "metadata": "md",
13117 "members": "m",
13118 "organization_administration": "oa",
13119 "organization_hooks": "oh",
13120 "organization_plan": "op",
13121 "organization_pre_receive_hooks": "opr",
13122 "organization_projects": "op",
13123 "organization_secrets": "os",
13124 "organization_self_hosted_runners": "osh",
13125 "organization_user_blocking": "oub",
13126 "packages": "pkg",
13127 "pages": "pg",
13128 "pull_requests": "pr",
13129 "repository_hooks": "rh",
13130 "repository_projects": "rp",
13131 "repository_pre_receive_hooks": "rprh",
13132 "secrets": "s",
13133 "secret_scanning_alerts": "ssa",
13134 "security_events": "se",
13135 "single_file": "sf",
13136 "statuses": "s",
13137 "team_discussions": "td",
13138 "vulnerability_alerts": "va",
13139 "workflows": "w"
13140 },
13141 "created_at": ` + referenceTimeStr + `,
13142 "updated_at": ` + referenceTimeStr + `,
13143 "has_multiple_single_files": false,
13144 "suspended_by": {
13145 "login": "l",
13146 "id": 1,
13147 "avatar_url": "a",
13148 "gravatar_id": "g",
13149 "name": "n",
13150 "company": "c",
13151 "blog": "b",
13152 "location": "l",
13153 "email": "e",
13154 "hireable": true,
13155 "bio": "b",
13156 "twitter_username": "t",
13157 "public_repos": 1,
13158 "followers": 1,
13159 "following": 1,
13160 "created_at": ` + referenceTimeStr + `,
13161 "suspended_at": ` + referenceTimeStr + `,
13162 "url": "u"
13163 },
13164 "suspended_at": ` + referenceTimeStr + `
13165 }
13166 }`
13167
13168 testJSONMarshal(t, e, want)
13169 }
13170
13171 func TestForkEvent_Marshal(t *testing.T) {
13172 testJSONMarshal(t, &ForkEvent{}, "{}")
13173
13174 u := &ForkEvent{
13175 Forkee: &Repository{
13176 ID: Int64(1),
13177 URL: String("s"),
13178 Name: String("n"),
13179 },
13180 Repo: &Repository{
13181 ID: Int64(1),
13182 URL: String("s"),
13183 Name: String("n"),
13184 },
13185 Sender: &User{
13186 Login: String("l"),
13187 ID: Int64(1),
13188 NodeID: String("n"),
13189 URL: String("u"),
13190 ReposURL: String("r"),
13191 EventsURL: String("e"),
13192 AvatarURL: String("a"),
13193 },
13194 Installation: &Installation{
13195 ID: Int64(1),
13196 NodeID: String("nid"),
13197 AppID: Int64(1),
13198 AppSlug: String("as"),
13199 TargetID: Int64(1),
13200 Account: &User{
13201 Login: String("l"),
13202 ID: Int64(1),
13203 URL: String("u"),
13204 AvatarURL: String("a"),
13205 GravatarID: String("g"),
13206 Name: String("n"),
13207 Company: String("c"),
13208 Blog: String("b"),
13209 Location: String("l"),
13210 Email: String("e"),
13211 Hireable: Bool(true),
13212 Bio: String("b"),
13213 TwitterUsername: String("t"),
13214 PublicRepos: Int(1),
13215 Followers: Int(1),
13216 Following: Int(1),
13217 CreatedAt: &Timestamp{referenceTime},
13218 SuspendedAt: &Timestamp{referenceTime},
13219 },
13220 AccessTokensURL: String("atu"),
13221 RepositoriesURL: String("ru"),
13222 HTMLURL: String("hu"),
13223 TargetType: String("tt"),
13224 SingleFileName: String("sfn"),
13225 RepositorySelection: String("rs"),
13226 Events: []string{"e"},
13227 SingleFilePaths: []string{"s"},
13228 Permissions: &InstallationPermissions{
13229 Actions: String("a"),
13230 Administration: String("ad"),
13231 Checks: String("c"),
13232 Contents: String("co"),
13233 ContentReferences: String("cr"),
13234 Deployments: String("d"),
13235 Environments: String("e"),
13236 Issues: String("i"),
13237 Metadata: String("md"),
13238 Members: String("m"),
13239 OrganizationAdministration: String("oa"),
13240 OrganizationHooks: String("oh"),
13241 OrganizationPlan: String("op"),
13242 OrganizationPreReceiveHooks: String("opr"),
13243 OrganizationProjects: String("op"),
13244 OrganizationSecrets: String("os"),
13245 OrganizationSelfHostedRunners: String("osh"),
13246 OrganizationUserBlocking: String("oub"),
13247 Packages: String("pkg"),
13248 Pages: String("pg"),
13249 PullRequests: String("pr"),
13250 RepositoryHooks: String("rh"),
13251 RepositoryProjects: String("rp"),
13252 RepositoryPreReceiveHooks: String("rprh"),
13253 Secrets: String("s"),
13254 SecretScanningAlerts: String("ssa"),
13255 SecurityEvents: String("se"),
13256 SingleFile: String("sf"),
13257 Statuses: String("s"),
13258 TeamDiscussions: String("td"),
13259 VulnerabilityAlerts: String("va"),
13260 Workflows: String("w"),
13261 },
13262 CreatedAt: &Timestamp{referenceTime},
13263 UpdatedAt: &Timestamp{referenceTime},
13264 HasMultipleSingleFiles: Bool(false),
13265 SuspendedBy: &User{
13266 Login: String("l"),
13267 ID: Int64(1),
13268 URL: String("u"),
13269 AvatarURL: String("a"),
13270 GravatarID: String("g"),
13271 Name: String("n"),
13272 Company: String("c"),
13273 Blog: String("b"),
13274 Location: String("l"),
13275 Email: String("e"),
13276 Hireable: Bool(true),
13277 Bio: String("b"),
13278 TwitterUsername: String("t"),
13279 PublicRepos: Int(1),
13280 Followers: Int(1),
13281 Following: Int(1),
13282 CreatedAt: &Timestamp{referenceTime},
13283 SuspendedAt: &Timestamp{referenceTime},
13284 },
13285 SuspendedAt: &Timestamp{referenceTime},
13286 },
13287 }
13288
13289 want := `{
13290 "forkee": {
13291 "id": 1,
13292 "name": "n",
13293 "url": "s"
13294 },
13295 "repository": {
13296 "id": 1,
13297 "name": "n",
13298 "url": "s"
13299 },
13300 "sender": {
13301 "login": "l",
13302 "id": 1,
13303 "node_id": "n",
13304 "avatar_url": "a",
13305 "url": "u",
13306 "events_url": "e",
13307 "repos_url": "r"
13308 },
13309 "installation": {
13310 "id": 1,
13311 "node_id": "nid",
13312 "app_id": 1,
13313 "app_slug": "as",
13314 "target_id": 1,
13315 "account": {
13316 "login": "l",
13317 "id": 1,
13318 "avatar_url": "a",
13319 "gravatar_id": "g",
13320 "name": "n",
13321 "company": "c",
13322 "blog": "b",
13323 "location": "l",
13324 "email": "e",
13325 "hireable": true,
13326 "bio": "b",
13327 "twitter_username": "t",
13328 "public_repos": 1,
13329 "followers": 1,
13330 "following": 1,
13331 "created_at": ` + referenceTimeStr + `,
13332 "suspended_at": ` + referenceTimeStr + `,
13333 "url": "u"
13334 },
13335 "access_tokens_url": "atu",
13336 "repositories_url": "ru",
13337 "html_url": "hu",
13338 "target_type": "tt",
13339 "single_file_name": "sfn",
13340 "repository_selection": "rs",
13341 "events": [
13342 "e"
13343 ],
13344 "single_file_paths": [
13345 "s"
13346 ],
13347 "permissions": {
13348 "actions": "a",
13349 "administration": "ad",
13350 "checks": "c",
13351 "contents": "co",
13352 "content_references": "cr",
13353 "deployments": "d",
13354 "environments": "e",
13355 "issues": "i",
13356 "metadata": "md",
13357 "members": "m",
13358 "organization_administration": "oa",
13359 "organization_hooks": "oh",
13360 "organization_plan": "op",
13361 "organization_pre_receive_hooks": "opr",
13362 "organization_projects": "op",
13363 "organization_secrets": "os",
13364 "organization_self_hosted_runners": "osh",
13365 "organization_user_blocking": "oub",
13366 "packages": "pkg",
13367 "pages": "pg",
13368 "pull_requests": "pr",
13369 "repository_hooks": "rh",
13370 "repository_projects": "rp",
13371 "repository_pre_receive_hooks": "rprh",
13372 "secrets": "s",
13373 "secret_scanning_alerts": "ssa",
13374 "security_events": "se",
13375 "single_file": "sf",
13376 "statuses": "s",
13377 "team_discussions": "td",
13378 "vulnerability_alerts": "va",
13379 "workflows": "w"
13380 },
13381 "created_at": ` + referenceTimeStr + `,
13382 "updated_at": ` + referenceTimeStr + `,
13383 "has_multiple_single_files": false,
13384 "suspended_by": {
13385 "login": "l",
13386 "id": 1,
13387 "avatar_url": "a",
13388 "gravatar_id": "g",
13389 "name": "n",
13390 "company": "c",
13391 "blog": "b",
13392 "location": "l",
13393 "email": "e",
13394 "hireable": true,
13395 "bio": "b",
13396 "twitter_username": "t",
13397 "public_repos": 1,
13398 "followers": 1,
13399 "following": 1,
13400 "created_at": ` + referenceTimeStr + `,
13401 "suspended_at": ` + referenceTimeStr + `,
13402 "url": "u"
13403 },
13404 "suspended_at": ` + referenceTimeStr + `
13405 }
13406 }`
13407
13408 testJSONMarshal(t, u, want)
13409 }
13410
13411 func TestGitHubAppAuthorizationEvent_Marshal(t *testing.T) {
13412 testJSONMarshal(t, &GitHubAppAuthorizationEvent{}, "{}")
13413
13414 u := &GitHubAppAuthorizationEvent{
13415 Action: String("a"),
13416 Sender: &User{
13417 Login: String("l"),
13418 ID: Int64(1),
13419 NodeID: String("n"),
13420 URL: String("u"),
13421 ReposURL: String("r"),
13422 EventsURL: String("e"),
13423 AvatarURL: String("a"),
13424 },
13425 }
13426
13427 want := `{
13428 "action": "a",
13429 "sender": {
13430 "login": "l",
13431 "id": 1,
13432 "node_id": "n",
13433 "avatar_url": "a",
13434 "url": "u",
13435 "events_url": "e",
13436 "repos_url": "r"
13437 }
13438 }`
13439
13440 testJSONMarshal(t, u, want)
13441 }
13442
13443 func TestInstallationEvent_Marshal(t *testing.T) {
13444 testJSONMarshal(t, &InstallationEvent{}, "{}")
13445
13446 u := &InstallationEvent{
13447 Action: String("a"),
13448 Repositories: []*Repository{
13449 {
13450 ID: Int64(1),
13451 URL: String("u"),
13452 Name: String("n"),
13453 },
13454 },
13455 Sender: &User{
13456 Login: String("l"),
13457 ID: Int64(1),
13458 NodeID: String("n"),
13459 URL: String("u"),
13460 ReposURL: String("r"),
13461 EventsURL: String("e"),
13462 AvatarURL: String("a"),
13463 },
13464 Installation: &Installation{
13465 ID: Int64(1),
13466 NodeID: String("nid"),
13467 AppID: Int64(1),
13468 AppSlug: String("as"),
13469 TargetID: Int64(1),
13470 Account: &User{
13471 Login: String("l"),
13472 ID: Int64(1),
13473 URL: String("u"),
13474 AvatarURL: String("a"),
13475 GravatarID: String("g"),
13476 Name: String("n"),
13477 Company: String("c"),
13478 Blog: String("b"),
13479 Location: String("l"),
13480 Email: String("e"),
13481 Hireable: Bool(true),
13482 Bio: String("b"),
13483 TwitterUsername: String("t"),
13484 PublicRepos: Int(1),
13485 Followers: Int(1),
13486 Following: Int(1),
13487 CreatedAt: &Timestamp{referenceTime},
13488 SuspendedAt: &Timestamp{referenceTime},
13489 },
13490 AccessTokensURL: String("atu"),
13491 RepositoriesURL: String("ru"),
13492 HTMLURL: String("hu"),
13493 TargetType: String("tt"),
13494 SingleFileName: String("sfn"),
13495 RepositorySelection: String("rs"),
13496 Events: []string{"e"},
13497 SingleFilePaths: []string{"s"},
13498 Permissions: &InstallationPermissions{
13499 Actions: String("a"),
13500 Administration: String("ad"),
13501 Checks: String("c"),
13502 Contents: String("co"),
13503 ContentReferences: String("cr"),
13504 Deployments: String("d"),
13505 Environments: String("e"),
13506 Issues: String("i"),
13507 Metadata: String("md"),
13508 Members: String("m"),
13509 OrganizationAdministration: String("oa"),
13510 OrganizationHooks: String("oh"),
13511 OrganizationPlan: String("op"),
13512 OrganizationPreReceiveHooks: String("opr"),
13513 OrganizationProjects: String("op"),
13514 OrganizationSecrets: String("os"),
13515 OrganizationSelfHostedRunners: String("osh"),
13516 OrganizationUserBlocking: String("oub"),
13517 Packages: String("pkg"),
13518 Pages: String("pg"),
13519 PullRequests: String("pr"),
13520 RepositoryHooks: String("rh"),
13521 RepositoryProjects: String("rp"),
13522 RepositoryPreReceiveHooks: String("rprh"),
13523 Secrets: String("s"),
13524 SecretScanningAlerts: String("ssa"),
13525 SecurityEvents: String("se"),
13526 SingleFile: String("sf"),
13527 Statuses: String("s"),
13528 TeamDiscussions: String("td"),
13529 VulnerabilityAlerts: String("va"),
13530 Workflows: String("w"),
13531 },
13532 CreatedAt: &Timestamp{referenceTime},
13533 UpdatedAt: &Timestamp{referenceTime},
13534 HasMultipleSingleFiles: Bool(false),
13535 SuspendedBy: &User{
13536 Login: String("l"),
13537 ID: Int64(1),
13538 URL: String("u"),
13539 AvatarURL: String("a"),
13540 GravatarID: String("g"),
13541 Name: String("n"),
13542 Company: String("c"),
13543 Blog: String("b"),
13544 Location: String("l"),
13545 Email: String("e"),
13546 Hireable: Bool(true),
13547 Bio: String("b"),
13548 TwitterUsername: String("t"),
13549 PublicRepos: Int(1),
13550 Followers: Int(1),
13551 Following: Int(1),
13552 CreatedAt: &Timestamp{referenceTime},
13553 SuspendedAt: &Timestamp{referenceTime},
13554 },
13555 SuspendedAt: &Timestamp{referenceTime},
13556 },
13557 }
13558
13559 want := `{
13560 "action": "a",
13561 "repositories": [
13562 {
13563 "id":1,
13564 "name":"n",
13565 "url":"u"
13566 }
13567 ],
13568 "sender": {
13569 "login": "l",
13570 "id": 1,
13571 "node_id": "n",
13572 "avatar_url": "a",
13573 "url": "u",
13574 "events_url": "e",
13575 "repos_url": "r"
13576 },
13577 "installation": {
13578 "id": 1,
13579 "node_id": "nid",
13580 "app_id": 1,
13581 "app_slug": "as",
13582 "target_id": 1,
13583 "account": {
13584 "login": "l",
13585 "id": 1,
13586 "avatar_url": "a",
13587 "gravatar_id": "g",
13588 "name": "n",
13589 "company": "c",
13590 "blog": "b",
13591 "location": "l",
13592 "email": "e",
13593 "hireable": true,
13594 "bio": "b",
13595 "twitter_username": "t",
13596 "public_repos": 1,
13597 "followers": 1,
13598 "following": 1,
13599 "created_at": ` + referenceTimeStr + `,
13600 "suspended_at": ` + referenceTimeStr + `,
13601 "url": "u"
13602 },
13603 "access_tokens_url": "atu",
13604 "repositories_url": "ru",
13605 "html_url": "hu",
13606 "target_type": "tt",
13607 "single_file_name": "sfn",
13608 "repository_selection": "rs",
13609 "events": [
13610 "e"
13611 ],
13612 "single_file_paths": [
13613 "s"
13614 ],
13615 "permissions": {
13616 "actions": "a",
13617 "administration": "ad",
13618 "checks": "c",
13619 "contents": "co",
13620 "content_references": "cr",
13621 "deployments": "d",
13622 "environments": "e",
13623 "issues": "i",
13624 "metadata": "md",
13625 "members": "m",
13626 "organization_administration": "oa",
13627 "organization_hooks": "oh",
13628 "organization_plan": "op",
13629 "organization_pre_receive_hooks": "opr",
13630 "organization_projects": "op",
13631 "organization_secrets": "os",
13632 "organization_self_hosted_runners": "osh",
13633 "organization_user_blocking": "oub",
13634 "packages": "pkg",
13635 "pages": "pg",
13636 "pull_requests": "pr",
13637 "repository_hooks": "rh",
13638 "repository_projects": "rp",
13639 "repository_pre_receive_hooks": "rprh",
13640 "secrets": "s",
13641 "secret_scanning_alerts": "ssa",
13642 "security_events": "se",
13643 "single_file": "sf",
13644 "statuses": "s",
13645 "team_discussions": "td",
13646 "vulnerability_alerts": "va",
13647 "workflows": "w"
13648 },
13649 "created_at": ` + referenceTimeStr + `,
13650 "updated_at": ` + referenceTimeStr + `,
13651 "has_multiple_single_files": false,
13652 "suspended_by": {
13653 "login": "l",
13654 "id": 1,
13655 "avatar_url": "a",
13656 "gravatar_id": "g",
13657 "name": "n",
13658 "company": "c",
13659 "blog": "b",
13660 "location": "l",
13661 "email": "e",
13662 "hireable": true,
13663 "bio": "b",
13664 "twitter_username": "t",
13665 "public_repos": 1,
13666 "followers": 1,
13667 "following": 1,
13668 "created_at": ` + referenceTimeStr + `,
13669 "suspended_at": ` + referenceTimeStr + `,
13670 "url": "u"
13671 },
13672 "suspended_at": ` + referenceTimeStr + `
13673 }
13674 }`
13675
13676 testJSONMarshal(t, u, want)
13677 }
13678
13679 func TestHeadCommit_Marshal(t *testing.T) {
13680 testJSONMarshal(t, &HeadCommit{}, "{}")
13681
13682 u := &HeadCommit{
13683 Message: String("m"),
13684 Author: &CommitAuthor{
13685 Date: &Timestamp{referenceTime},
13686 Name: String("n"),
13687 Email: String("e"),
13688 Login: String("u"),
13689 },
13690 URL: String("u"),
13691 Distinct: Bool(true),
13692 SHA: String("s"),
13693 ID: String("id"),
13694 TreeID: String("tid"),
13695 Timestamp: &Timestamp{referenceTime},
13696 Committer: &CommitAuthor{
13697 Date: &Timestamp{referenceTime},
13698 Name: String("n"),
13699 Email: String("e"),
13700 Login: String("u"),
13701 },
13702 Added: []string{"a"},
13703 Removed: []string{"r"},
13704 Modified: []string{"m"},
13705 }
13706
13707 want := `{
13708 "message": "m",
13709 "author": {
13710 "date": ` + referenceTimeStr + `,
13711 "name": "n",
13712 "email": "e",
13713 "username": "u"
13714 },
13715 "url": "u",
13716 "distinct": true,
13717 "sha": "s",
13718 "id": "id",
13719 "tree_id": "tid",
13720 "timestamp": ` + referenceTimeStr + `,
13721 "committer": {
13722 "date": ` + referenceTimeStr + `,
13723 "name": "n",
13724 "email": "e",
13725 "username": "u"
13726 },
13727 "added": [
13728 "a"
13729 ],
13730 "removed": [
13731 "r"
13732 ],
13733 "modified": [
13734 "m"
13735 ]
13736 }`
13737
13738 testJSONMarshal(t, u, want)
13739 }
13740
13741 func TestPushEventRepository_Marshal(t *testing.T) {
13742 testJSONMarshal(t, &PushEventRepository{}, "{}")
13743
13744 u := &PushEventRepository{
13745 ID: Int64(1),
13746 NodeID: String("nid"),
13747 Name: String("n"),
13748 FullName: String("fn"),
13749 Owner: &User{
13750 Login: String("l"),
13751 ID: Int64(1),
13752 AvatarURL: String("a"),
13753 GravatarID: String("g"),
13754 Name: String("n"),
13755 Company: String("c"),
13756 Blog: String("b"),
13757 Location: String("l"),
13758 Email: String("e"),
13759 Hireable: Bool(true),
13760 PublicRepos: Int(1),
13761 Followers: Int(1),
13762 Following: Int(1),
13763 CreatedAt: &Timestamp{referenceTime},
13764 URL: String("u"),
13765 },
13766 Private: Bool(true),
13767 Description: String("d"),
13768 Fork: Bool(true),
13769 CreatedAt: &Timestamp{referenceTime},
13770 PushedAt: &Timestamp{referenceTime},
13771 UpdatedAt: &Timestamp{referenceTime},
13772 Homepage: String("h"),
13773 PullsURL: String("p"),
13774 Size: Int(1),
13775 StargazersCount: Int(1),
13776 WatchersCount: Int(1),
13777 Language: String("l"),
13778 HasIssues: Bool(true),
13779 HasDownloads: Bool(true),
13780 HasWiki: Bool(true),
13781 HasPages: Bool(true),
13782 ForksCount: Int(1),
13783 Archived: Bool(true),
13784 Disabled: Bool(true),
13785 OpenIssuesCount: Int(1),
13786 DefaultBranch: String("d"),
13787 MasterBranch: String("m"),
13788 Organization: String("o"),
13789 URL: String("u"),
13790 ArchiveURL: String("a"),
13791 HTMLURL: String("h"),
13792 StatusesURL: String("s"),
13793 GitURL: String("g"),
13794 SSHURL: String("s"),
13795 CloneURL: String("c"),
13796 SVNURL: String("s"),
13797 Topics: []string{"octocat", "api"},
13798 }
13799
13800 want := `{
13801 "id": 1,
13802 "node_id": "nid",
13803 "name": "n",
13804 "full_name": "fn",
13805 "owner": {
13806 "login": "l",
13807 "id": 1,
13808 "avatar_url": "a",
13809 "gravatar_id": "g",
13810 "name": "n",
13811 "company": "c",
13812 "blog": "b",
13813 "location": "l",
13814 "email": "e",
13815 "hireable": true,
13816 "public_repos": 1,
13817 "followers": 1,
13818 "following": 1,
13819 "created_at": ` + referenceTimeStr + `,
13820 "url": "u"
13821 },
13822 "private": true,
13823 "description": "d",
13824 "fork": true,
13825 "created_at": ` + referenceTimeStr + `,
13826 "pushed_at": ` + referenceTimeStr + `,
13827 "updated_at": ` + referenceTimeStr + `,
13828 "homepage": "h",
13829 "pulls_url": "p",
13830 "size": 1,
13831 "stargazers_count": 1,
13832 "watchers_count": 1,
13833 "language": "l",
13834 "has_issues": true,
13835 "has_downloads": true,
13836 "has_wiki": true,
13837 "has_pages": true,
13838 "forks_count": 1,
13839 "archived": true,
13840 "disabled": true,
13841 "open_issues_count": 1,
13842 "default_branch": "d",
13843 "master_branch": "m",
13844 "organization": "o",
13845 "url": "u",
13846 "archive_url": "a",
13847 "html_url": "h",
13848 "statuses_url": "s",
13849 "git_url": "g",
13850 "ssh_url": "s",
13851 "clone_url": "c",
13852 "svn_url": "s",
13853 "topics": ["octocat","api"]
13854 }`
13855
13856 testJSONMarshal(t, u, want)
13857 }
13858
13859 func TestPushEventRepoOwner_Marshal(t *testing.T) {
13860 testJSONMarshal(t, &PushEventRepoOwner{}, "{}")
13861
13862 u := &PushEventRepoOwner{
13863 Name: String("n"),
13864 Email: String("e"),
13865 }
13866
13867 want := `{
13868 "name": "n",
13869 "email": "e"
13870 }`
13871
13872 testJSONMarshal(t, u, want)
13873 }
13874
13875 func TestProjectEvent_Marshal(t *testing.T) {
13876 testJSONMarshal(t, &ProjectEvent{}, "{}")
13877
13878 u := &ProjectEvent{
13879 Project: &Project{ID: Int64(1)},
13880 Action: String("a"),
13881 Changes: &ProjectChange{
13882 Name: &ProjectName{From: String("NameFrom")},
13883 Body: &ProjectBody{From: String("BodyFrom")},
13884 },
13885 Repo: &Repository{
13886 ID: Int64(1),
13887 URL: String("s"),
13888 Name: String("n"),
13889 },
13890 Org: &Organization{
13891 BillingEmail: String("be"),
13892 Blog: String("b"),
13893 Company: String("c"),
13894 Email: String("e"),
13895 TwitterUsername: String("tu"),
13896 Location: String("loc"),
13897 Name: String("n"),
13898 Description: String("d"),
13899 IsVerified: Bool(true),
13900 HasOrganizationProjects: Bool(true),
13901 HasRepositoryProjects: Bool(true),
13902 DefaultRepoPermission: String("drp"),
13903 MembersCanCreateRepos: Bool(true),
13904 MembersCanCreateInternalRepos: Bool(true),
13905 MembersCanCreatePrivateRepos: Bool(true),
13906 MembersCanCreatePublicRepos: Bool(false),
13907 MembersAllowedRepositoryCreationType: String("marct"),
13908 MembersCanCreatePages: Bool(true),
13909 MembersCanCreatePublicPages: Bool(false),
13910 MembersCanCreatePrivatePages: Bool(true),
13911 },
13912 Sender: &User{
13913 Login: String("l"),
13914 ID: Int64(1),
13915 NodeID: String("n"),
13916 URL: String("u"),
13917 ReposURL: String("r"),
13918 EventsURL: String("e"),
13919 AvatarURL: String("a"),
13920 },
13921 Installation: &Installation{
13922 ID: Int64(1),
13923 NodeID: String("nid"),
13924 AppID: Int64(1),
13925 AppSlug: String("as"),
13926 TargetID: Int64(1),
13927 Account: &User{
13928 Login: String("l"),
13929 ID: Int64(1),
13930 URL: String("u"),
13931 AvatarURL: String("a"),
13932 GravatarID: String("g"),
13933 Name: String("n"),
13934 Company: String("c"),
13935 Blog: String("b"),
13936 Location: String("l"),
13937 Email: String("e"),
13938 Hireable: Bool(true),
13939 Bio: String("b"),
13940 TwitterUsername: String("t"),
13941 PublicRepos: Int(1),
13942 Followers: Int(1),
13943 Following: Int(1),
13944 CreatedAt: &Timestamp{referenceTime},
13945 SuspendedAt: &Timestamp{referenceTime},
13946 },
13947 AccessTokensURL: String("atu"),
13948 RepositoriesURL: String("ru"),
13949 HTMLURL: String("hu"),
13950 TargetType: String("tt"),
13951 SingleFileName: String("sfn"),
13952 RepositorySelection: String("rs"),
13953 Events: []string{"e"},
13954 SingleFilePaths: []string{"s"},
13955 Permissions: &InstallationPermissions{
13956 Actions: String("a"),
13957 Administration: String("ad"),
13958 Checks: String("c"),
13959 Contents: String("co"),
13960 ContentReferences: String("cr"),
13961 Deployments: String("d"),
13962 Environments: String("e"),
13963 Issues: String("i"),
13964 Metadata: String("md"),
13965 Members: String("m"),
13966 OrganizationAdministration: String("oa"),
13967 OrganizationHooks: String("oh"),
13968 OrganizationPlan: String("op"),
13969 OrganizationPreReceiveHooks: String("opr"),
13970 OrganizationProjects: String("op"),
13971 OrganizationSecrets: String("os"),
13972 OrganizationSelfHostedRunners: String("osh"),
13973 OrganizationUserBlocking: String("oub"),
13974 Packages: String("pkg"),
13975 Pages: String("pg"),
13976 PullRequests: String("pr"),
13977 RepositoryHooks: String("rh"),
13978 RepositoryProjects: String("rp"),
13979 RepositoryPreReceiveHooks: String("rprh"),
13980 Secrets: String("s"),
13981 SecretScanningAlerts: String("ssa"),
13982 SecurityEvents: String("se"),
13983 SingleFile: String("sf"),
13984 Statuses: String("s"),
13985 TeamDiscussions: String("td"),
13986 VulnerabilityAlerts: String("va"),
13987 Workflows: String("w"),
13988 },
13989 CreatedAt: &Timestamp{referenceTime},
13990 UpdatedAt: &Timestamp{referenceTime},
13991 HasMultipleSingleFiles: Bool(false),
13992 SuspendedBy: &User{
13993 Login: String("l"),
13994 ID: Int64(1),
13995 URL: String("u"),
13996 AvatarURL: String("a"),
13997 GravatarID: String("g"),
13998 Name: String("n"),
13999 Company: String("c"),
14000 Blog: String("b"),
14001 Location: String("l"),
14002 Email: String("e"),
14003 Hireable: Bool(true),
14004 Bio: String("b"),
14005 TwitterUsername: String("t"),
14006 PublicRepos: Int(1),
14007 Followers: Int(1),
14008 Following: Int(1),
14009 CreatedAt: &Timestamp{referenceTime},
14010 SuspendedAt: &Timestamp{referenceTime},
14011 },
14012 SuspendedAt: &Timestamp{referenceTime},
14013 },
14014 }
14015
14016 want := `{
14017 "action": "a",
14018 "changes": {
14019 "name": {
14020 "from": "NameFrom"
14021 },
14022 "body": {
14023 "from": "BodyFrom"
14024 }
14025 },
14026 "project": {
14027 "id": 1
14028 },
14029 "repository": {
14030 "id": 1,
14031 "name": "n",
14032 "url": "s"
14033 },
14034 "organization": {
14035 "name": "n",
14036 "company": "c",
14037 "blog": "b",
14038 "location": "loc",
14039 "email": "e",
14040 "twitter_username": "tu",
14041 "description": "d",
14042 "billing_email": "be",
14043 "is_verified": true,
14044 "has_organization_projects": true,
14045 "has_repository_projects": true,
14046 "default_repository_permission": "drp",
14047 "members_can_create_repositories": true,
14048 "members_can_create_public_repositories": false,
14049 "members_can_create_private_repositories": true,
14050 "members_can_create_internal_repositories": true,
14051 "members_allowed_repository_creation_type": "marct",
14052 "members_can_create_pages": true,
14053 "members_can_create_public_pages": false,
14054 "members_can_create_private_pages": true
14055 },
14056 "sender": {
14057 "login": "l",
14058 "id": 1,
14059 "node_id": "n",
14060 "avatar_url": "a",
14061 "url": "u",
14062 "events_url": "e",
14063 "repos_url": "r"
14064 },
14065 "installation": {
14066 "id": 1,
14067 "node_id": "nid",
14068 "app_id": 1,
14069 "app_slug": "as",
14070 "target_id": 1,
14071 "account": {
14072 "login": "l",
14073 "id": 1,
14074 "avatar_url": "a",
14075 "gravatar_id": "g",
14076 "name": "n",
14077 "company": "c",
14078 "blog": "b",
14079 "location": "l",
14080 "email": "e",
14081 "hireable": true,
14082 "bio": "b",
14083 "twitter_username": "t",
14084 "public_repos": 1,
14085 "followers": 1,
14086 "following": 1,
14087 "created_at": ` + referenceTimeStr + `,
14088 "suspended_at": ` + referenceTimeStr + `,
14089 "url": "u"
14090 },
14091 "access_tokens_url": "atu",
14092 "repositories_url": "ru",
14093 "html_url": "hu",
14094 "target_type": "tt",
14095 "single_file_name": "sfn",
14096 "repository_selection": "rs",
14097 "events": [
14098 "e"
14099 ],
14100 "single_file_paths": [
14101 "s"
14102 ],
14103 "permissions": {
14104 "actions": "a",
14105 "administration": "ad",
14106 "checks": "c",
14107 "contents": "co",
14108 "content_references": "cr",
14109 "deployments": "d",
14110 "environments": "e",
14111 "issues": "i",
14112 "metadata": "md",
14113 "members": "m",
14114 "organization_administration": "oa",
14115 "organization_hooks": "oh",
14116 "organization_plan": "op",
14117 "organization_pre_receive_hooks": "opr",
14118 "organization_projects": "op",
14119 "organization_secrets": "os",
14120 "organization_self_hosted_runners": "osh",
14121 "organization_user_blocking": "oub",
14122 "packages": "pkg",
14123 "pages": "pg",
14124 "pull_requests": "pr",
14125 "repository_hooks": "rh",
14126 "repository_projects": "rp",
14127 "repository_pre_receive_hooks": "rprh",
14128 "secrets": "s",
14129 "secret_scanning_alerts": "ssa",
14130 "security_events": "se",
14131 "single_file": "sf",
14132 "statuses": "s",
14133 "team_discussions": "td",
14134 "vulnerability_alerts": "va",
14135 "workflows": "w"
14136 },
14137 "created_at": ` + referenceTimeStr + `,
14138 "updated_at": ` + referenceTimeStr + `,
14139 "has_multiple_single_files": false,
14140 "suspended_by": {
14141 "login": "l",
14142 "id": 1,
14143 "avatar_url": "a",
14144 "gravatar_id": "g",
14145 "name": "n",
14146 "company": "c",
14147 "blog": "b",
14148 "location": "l",
14149 "email": "e",
14150 "hireable": true,
14151 "bio": "b",
14152 "twitter_username": "t",
14153 "public_repos": 1,
14154 "followers": 1,
14155 "following": 1,
14156 "created_at": ` + referenceTimeStr + `,
14157 "suspended_at": ` + referenceTimeStr + `,
14158 "url": "u"
14159 },
14160 "suspended_at": ` + referenceTimeStr + `
14161 }
14162 }`
14163
14164 testJSONMarshal(t, u, want)
14165 }
14166
14167 func TestProjectCardEvent_Marshal(t *testing.T) {
14168 testJSONMarshal(t, &ProjectCardEvent{}, "{}")
14169
14170 u := &ProjectCardEvent{
14171 Action: String("a"),
14172 Changes: &ProjectCardChange{
14173 Note: &ProjectCardNote{From: String("NoteFrom")},
14174 },
14175 AfterID: Int64(1),
14176 ProjectCard: &ProjectCard{ID: Int64(1)},
14177 Repo: &Repository{
14178 ID: Int64(1),
14179 URL: String("s"),
14180 Name: String("n"),
14181 },
14182 Org: &Organization{
14183 BillingEmail: String("be"),
14184 Blog: String("b"),
14185 Company: String("c"),
14186 Email: String("e"),
14187 TwitterUsername: String("tu"),
14188 Location: String("loc"),
14189 Name: String("n"),
14190 Description: String("d"),
14191 IsVerified: Bool(true),
14192 HasOrganizationProjects: Bool(true),
14193 HasRepositoryProjects: Bool(true),
14194 DefaultRepoPermission: String("drp"),
14195 MembersCanCreateRepos: Bool(true),
14196 MembersCanCreateInternalRepos: Bool(true),
14197 MembersCanCreatePrivateRepos: Bool(true),
14198 MembersCanCreatePublicRepos: Bool(false),
14199 MembersAllowedRepositoryCreationType: String("marct"),
14200 MembersCanCreatePages: Bool(true),
14201 MembersCanCreatePublicPages: Bool(false),
14202 MembersCanCreatePrivatePages: Bool(true),
14203 },
14204 Sender: &User{
14205 Login: String("l"),
14206 ID: Int64(1),
14207 NodeID: String("n"),
14208 URL: String("u"),
14209 ReposURL: String("r"),
14210 EventsURL: String("e"),
14211 AvatarURL: String("a"),
14212 },
14213 Installation: &Installation{
14214 ID: Int64(1),
14215 NodeID: String("nid"),
14216 AppID: Int64(1),
14217 AppSlug: String("as"),
14218 TargetID: Int64(1),
14219 Account: &User{
14220 Login: String("l"),
14221 ID: Int64(1),
14222 URL: String("u"),
14223 AvatarURL: String("a"),
14224 GravatarID: String("g"),
14225 Name: String("n"),
14226 Company: String("c"),
14227 Blog: String("b"),
14228 Location: String("l"),
14229 Email: String("e"),
14230 Hireable: Bool(true),
14231 Bio: String("b"),
14232 TwitterUsername: String("t"),
14233 PublicRepos: Int(1),
14234 Followers: Int(1),
14235 Following: Int(1),
14236 CreatedAt: &Timestamp{referenceTime},
14237 SuspendedAt: &Timestamp{referenceTime},
14238 },
14239 AccessTokensURL: String("atu"),
14240 RepositoriesURL: String("ru"),
14241 HTMLURL: String("hu"),
14242 TargetType: String("tt"),
14243 SingleFileName: String("sfn"),
14244 RepositorySelection: String("rs"),
14245 Events: []string{"e"},
14246 SingleFilePaths: []string{"s"},
14247 Permissions: &InstallationPermissions{
14248 Actions: String("a"),
14249 Administration: String("ad"),
14250 Checks: String("c"),
14251 Contents: String("co"),
14252 ContentReferences: String("cr"),
14253 Deployments: String("d"),
14254 Environments: String("e"),
14255 Issues: String("i"),
14256 Metadata: String("md"),
14257 Members: String("m"),
14258 OrganizationAdministration: String("oa"),
14259 OrganizationHooks: String("oh"),
14260 OrganizationPlan: String("op"),
14261 OrganizationPreReceiveHooks: String("opr"),
14262 OrganizationProjects: String("op"),
14263 OrganizationSecrets: String("os"),
14264 OrganizationSelfHostedRunners: String("osh"),
14265 OrganizationUserBlocking: String("oub"),
14266 Packages: String("pkg"),
14267 Pages: String("pg"),
14268 PullRequests: String("pr"),
14269 RepositoryHooks: String("rh"),
14270 RepositoryProjects: String("rp"),
14271 RepositoryPreReceiveHooks: String("rprh"),
14272 Secrets: String("s"),
14273 SecretScanningAlerts: String("ssa"),
14274 SecurityEvents: String("se"),
14275 SingleFile: String("sf"),
14276 Statuses: String("s"),
14277 TeamDiscussions: String("td"),
14278 VulnerabilityAlerts: String("va"),
14279 Workflows: String("w"),
14280 },
14281 CreatedAt: &Timestamp{referenceTime},
14282 UpdatedAt: &Timestamp{referenceTime},
14283 HasMultipleSingleFiles: Bool(false),
14284 SuspendedBy: &User{
14285 Login: String("l"),
14286 ID: Int64(1),
14287 URL: String("u"),
14288 AvatarURL: String("a"),
14289 GravatarID: String("g"),
14290 Name: String("n"),
14291 Company: String("c"),
14292 Blog: String("b"),
14293 Location: String("l"),
14294 Email: String("e"),
14295 Hireable: Bool(true),
14296 Bio: String("b"),
14297 TwitterUsername: String("t"),
14298 PublicRepos: Int(1),
14299 Followers: Int(1),
14300 Following: Int(1),
14301 CreatedAt: &Timestamp{referenceTime},
14302 SuspendedAt: &Timestamp{referenceTime},
14303 },
14304 SuspendedAt: &Timestamp{referenceTime},
14305 },
14306 }
14307
14308 want := `{
14309 "action": "a",
14310 "changes": {
14311 "note": {
14312 "from": "NoteFrom"
14313 }
14314 },
14315 "after_id": 1,
14316 "project_card": {
14317 "id": 1
14318 },
14319 "repository": {
14320 "id": 1,
14321 "name": "n",
14322 "url": "s"
14323 },
14324 "organization": {
14325 "name": "n",
14326 "company": "c",
14327 "blog": "b",
14328 "location": "loc",
14329 "email": "e",
14330 "twitter_username": "tu",
14331 "description": "d",
14332 "billing_email": "be",
14333 "is_verified": true,
14334 "has_organization_projects": true,
14335 "has_repository_projects": true,
14336 "default_repository_permission": "drp",
14337 "members_can_create_repositories": true,
14338 "members_can_create_public_repositories": false,
14339 "members_can_create_private_repositories": true,
14340 "members_can_create_internal_repositories": true,
14341 "members_allowed_repository_creation_type": "marct",
14342 "members_can_create_pages": true,
14343 "members_can_create_public_pages": false,
14344 "members_can_create_private_pages": true
14345 },
14346 "sender": {
14347 "login": "l",
14348 "id": 1,
14349 "node_id": "n",
14350 "avatar_url": "a",
14351 "url": "u",
14352 "events_url": "e",
14353 "repos_url": "r"
14354 },
14355 "installation": {
14356 "id": 1,
14357 "node_id": "nid",
14358 "app_id": 1,
14359 "app_slug": "as",
14360 "target_id": 1,
14361 "account": {
14362 "login": "l",
14363 "id": 1,
14364 "avatar_url": "a",
14365 "gravatar_id": "g",
14366 "name": "n",
14367 "company": "c",
14368 "blog": "b",
14369 "location": "l",
14370 "email": "e",
14371 "hireable": true,
14372 "bio": "b",
14373 "twitter_username": "t",
14374 "public_repos": 1,
14375 "followers": 1,
14376 "following": 1,
14377 "created_at": ` + referenceTimeStr + `,
14378 "suspended_at": ` + referenceTimeStr + `,
14379 "url": "u"
14380 },
14381 "access_tokens_url": "atu",
14382 "repositories_url": "ru",
14383 "html_url": "hu",
14384 "target_type": "tt",
14385 "single_file_name": "sfn",
14386 "repository_selection": "rs",
14387 "events": [
14388 "e"
14389 ],
14390 "single_file_paths": [
14391 "s"
14392 ],
14393 "permissions": {
14394 "actions": "a",
14395 "administration": "ad",
14396 "checks": "c",
14397 "contents": "co",
14398 "content_references": "cr",
14399 "deployments": "d",
14400 "environments": "e",
14401 "issues": "i",
14402 "metadata": "md",
14403 "members": "m",
14404 "organization_administration": "oa",
14405 "organization_hooks": "oh",
14406 "organization_plan": "op",
14407 "organization_pre_receive_hooks": "opr",
14408 "organization_projects": "op",
14409 "organization_secrets": "os",
14410 "organization_self_hosted_runners": "osh",
14411 "organization_user_blocking": "oub",
14412 "packages": "pkg",
14413 "pages": "pg",
14414 "pull_requests": "pr",
14415 "repository_hooks": "rh",
14416 "repository_projects": "rp",
14417 "repository_pre_receive_hooks": "rprh",
14418 "secrets": "s",
14419 "secret_scanning_alerts": "ssa",
14420 "security_events": "se",
14421 "single_file": "sf",
14422 "statuses": "s",
14423 "team_discussions": "td",
14424 "vulnerability_alerts": "va",
14425 "workflows": "w"
14426 },
14427 "created_at": ` + referenceTimeStr + `,
14428 "updated_at": ` + referenceTimeStr + `,
14429 "has_multiple_single_files": false,
14430 "suspended_by": {
14431 "login": "l",
14432 "id": 1,
14433 "avatar_url": "a",
14434 "gravatar_id": "g",
14435 "name": "n",
14436 "company": "c",
14437 "blog": "b",
14438 "location": "l",
14439 "email": "e",
14440 "hireable": true,
14441 "bio": "b",
14442 "twitter_username": "t",
14443 "public_repos": 1,
14444 "followers": 1,
14445 "following": 1,
14446 "created_at": ` + referenceTimeStr + `,
14447 "suspended_at": ` + referenceTimeStr + `,
14448 "url": "u"
14449 },
14450 "suspended_at": ` + referenceTimeStr + `
14451 }
14452 }`
14453
14454 testJSONMarshal(t, u, want)
14455 }
14456
14457 func TestProjectColumnEvent_Marshal(t *testing.T) {
14458 testJSONMarshal(t, &ProjectColumnEvent{}, "{}")
14459
14460 u := &ProjectColumnEvent{
14461 Action: String("a"),
14462 Changes: &ProjectColumnChange{
14463 Name: &ProjectColumnName{From: String("NameFrom")},
14464 },
14465 AfterID: Int64(1),
14466 ProjectColumn: &ProjectColumn{ID: Int64(1)},
14467 Repo: &Repository{
14468 ID: Int64(1),
14469 URL: String("s"),
14470 Name: String("n"),
14471 },
14472 Org: &Organization{
14473 BillingEmail: String("be"),
14474 Blog: String("b"),
14475 Company: String("c"),
14476 Email: String("e"),
14477 TwitterUsername: String("tu"),
14478 Location: String("loc"),
14479 Name: String("n"),
14480 Description: String("d"),
14481 IsVerified: Bool(true),
14482 HasOrganizationProjects: Bool(true),
14483 HasRepositoryProjects: Bool(true),
14484 DefaultRepoPermission: String("drp"),
14485 MembersCanCreateRepos: Bool(true),
14486 MembersCanCreateInternalRepos: Bool(true),
14487 MembersCanCreatePrivateRepos: Bool(true),
14488 MembersCanCreatePublicRepos: Bool(false),
14489 MembersAllowedRepositoryCreationType: String("marct"),
14490 MembersCanCreatePages: Bool(true),
14491 MembersCanCreatePublicPages: Bool(false),
14492 MembersCanCreatePrivatePages: Bool(true),
14493 },
14494 Sender: &User{
14495 Login: String("l"),
14496 ID: Int64(1),
14497 NodeID: String("n"),
14498 URL: String("u"),
14499 ReposURL: String("r"),
14500 EventsURL: String("e"),
14501 AvatarURL: String("a"),
14502 },
14503 Installation: &Installation{
14504 ID: Int64(1),
14505 NodeID: String("nid"),
14506 AppID: Int64(1),
14507 AppSlug: String("as"),
14508 TargetID: Int64(1),
14509 Account: &User{
14510 Login: String("l"),
14511 ID: Int64(1),
14512 URL: String("u"),
14513 AvatarURL: String("a"),
14514 GravatarID: String("g"),
14515 Name: String("n"),
14516 Company: String("c"),
14517 Blog: String("b"),
14518 Location: String("l"),
14519 Email: String("e"),
14520 Hireable: Bool(true),
14521 Bio: String("b"),
14522 TwitterUsername: String("t"),
14523 PublicRepos: Int(1),
14524 Followers: Int(1),
14525 Following: Int(1),
14526 CreatedAt: &Timestamp{referenceTime},
14527 SuspendedAt: &Timestamp{referenceTime},
14528 },
14529 AccessTokensURL: String("atu"),
14530 RepositoriesURL: String("ru"),
14531 HTMLURL: String("hu"),
14532 TargetType: String("tt"),
14533 SingleFileName: String("sfn"),
14534 RepositorySelection: String("rs"),
14535 Events: []string{"e"},
14536 SingleFilePaths: []string{"s"},
14537 Permissions: &InstallationPermissions{
14538 Actions: String("a"),
14539 Administration: String("ad"),
14540 Checks: String("c"),
14541 Contents: String("co"),
14542 ContentReferences: String("cr"),
14543 Deployments: String("d"),
14544 Environments: String("e"),
14545 Issues: String("i"),
14546 Metadata: String("md"),
14547 Members: String("m"),
14548 OrganizationAdministration: String("oa"),
14549 OrganizationHooks: String("oh"),
14550 OrganizationPlan: String("op"),
14551 OrganizationPreReceiveHooks: String("opr"),
14552 OrganizationProjects: String("op"),
14553 OrganizationSecrets: String("os"),
14554 OrganizationSelfHostedRunners: String("osh"),
14555 OrganizationUserBlocking: String("oub"),
14556 Packages: String("pkg"),
14557 Pages: String("pg"),
14558 PullRequests: String("pr"),
14559 RepositoryHooks: String("rh"),
14560 RepositoryProjects: String("rp"),
14561 RepositoryPreReceiveHooks: String("rprh"),
14562 Secrets: String("s"),
14563 SecretScanningAlerts: String("ssa"),
14564 SecurityEvents: String("se"),
14565 SingleFile: String("sf"),
14566 Statuses: String("s"),
14567 TeamDiscussions: String("td"),
14568 VulnerabilityAlerts: String("va"),
14569 Workflows: String("w"),
14570 },
14571 CreatedAt: &Timestamp{referenceTime},
14572 UpdatedAt: &Timestamp{referenceTime},
14573 HasMultipleSingleFiles: Bool(false),
14574 SuspendedBy: &User{
14575 Login: String("l"),
14576 ID: Int64(1),
14577 URL: String("u"),
14578 AvatarURL: String("a"),
14579 GravatarID: String("g"),
14580 Name: String("n"),
14581 Company: String("c"),
14582 Blog: String("b"),
14583 Location: String("l"),
14584 Email: String("e"),
14585 Hireable: Bool(true),
14586 Bio: String("b"),
14587 TwitterUsername: String("t"),
14588 PublicRepos: Int(1),
14589 Followers: Int(1),
14590 Following: Int(1),
14591 CreatedAt: &Timestamp{referenceTime},
14592 SuspendedAt: &Timestamp{referenceTime},
14593 },
14594 SuspendedAt: &Timestamp{referenceTime},
14595 },
14596 }
14597
14598 want := `{
14599 "action": "a",
14600 "changes": {
14601 "name": {
14602 "from": "NameFrom"
14603 }
14604 },
14605 "after_id": 1,
14606 "project_column": {
14607 "id": 1
14608 },
14609 "repository": {
14610 "id": 1,
14611 "name": "n",
14612 "url": "s"
14613 },
14614 "organization": {
14615 "name": "n",
14616 "company": "c",
14617 "blog": "b",
14618 "location": "loc",
14619 "email": "e",
14620 "twitter_username": "tu",
14621 "description": "d",
14622 "billing_email": "be",
14623 "is_verified": true,
14624 "has_organization_projects": true,
14625 "has_repository_projects": true,
14626 "default_repository_permission": "drp",
14627 "members_can_create_repositories": true,
14628 "members_can_create_public_repositories": false,
14629 "members_can_create_private_repositories": true,
14630 "members_can_create_internal_repositories": true,
14631 "members_allowed_repository_creation_type": "marct",
14632 "members_can_create_pages": true,
14633 "members_can_create_public_pages": false,
14634 "members_can_create_private_pages": true
14635 },
14636 "sender": {
14637 "login": "l",
14638 "id": 1,
14639 "node_id": "n",
14640 "avatar_url": "a",
14641 "url": "u",
14642 "events_url": "e",
14643 "repos_url": "r"
14644 },
14645 "installation": {
14646 "id": 1,
14647 "node_id": "nid",
14648 "app_id": 1,
14649 "app_slug": "as",
14650 "target_id": 1,
14651 "account": {
14652 "login": "l",
14653 "id": 1,
14654 "avatar_url": "a",
14655 "gravatar_id": "g",
14656 "name": "n",
14657 "company": "c",
14658 "blog": "b",
14659 "location": "l",
14660 "email": "e",
14661 "hireable": true,
14662 "bio": "b",
14663 "twitter_username": "t",
14664 "public_repos": 1,
14665 "followers": 1,
14666 "following": 1,
14667 "created_at": ` + referenceTimeStr + `,
14668 "suspended_at": ` + referenceTimeStr + `,
14669 "url": "u"
14670 },
14671 "access_tokens_url": "atu",
14672 "repositories_url": "ru",
14673 "html_url": "hu",
14674 "target_type": "tt",
14675 "single_file_name": "sfn",
14676 "repository_selection": "rs",
14677 "events": [
14678 "e"
14679 ],
14680 "single_file_paths": [
14681 "s"
14682 ],
14683 "permissions": {
14684 "actions": "a",
14685 "administration": "ad",
14686 "checks": "c",
14687 "contents": "co",
14688 "content_references": "cr",
14689 "deployments": "d",
14690 "environments": "e",
14691 "issues": "i",
14692 "metadata": "md",
14693 "members": "m",
14694 "organization_administration": "oa",
14695 "organization_hooks": "oh",
14696 "organization_plan": "op",
14697 "organization_pre_receive_hooks": "opr",
14698 "organization_projects": "op",
14699 "organization_secrets": "os",
14700 "organization_self_hosted_runners": "osh",
14701 "organization_user_blocking": "oub",
14702 "packages": "pkg",
14703 "pages": "pg",
14704 "pull_requests": "pr",
14705 "repository_hooks": "rh",
14706 "repository_projects": "rp",
14707 "repository_pre_receive_hooks": "rprh",
14708 "secrets": "s",
14709 "secret_scanning_alerts": "ssa",
14710 "security_events": "se",
14711 "single_file": "sf",
14712 "statuses": "s",
14713 "team_discussions": "td",
14714 "vulnerability_alerts": "va",
14715 "workflows": "w"
14716 },
14717 "created_at": ` + referenceTimeStr + `,
14718 "updated_at": ` + referenceTimeStr + `,
14719 "has_multiple_single_files": false,
14720 "suspended_by": {
14721 "login": "l",
14722 "id": 1,
14723 "avatar_url": "a",
14724 "gravatar_id": "g",
14725 "name": "n",
14726 "company": "c",
14727 "blog": "b",
14728 "location": "l",
14729 "email": "e",
14730 "hireable": true,
14731 "bio": "b",
14732 "twitter_username": "t",
14733 "public_repos": 1,
14734 "followers": 1,
14735 "following": 1,
14736 "created_at": ` + referenceTimeStr + `,
14737 "suspended_at": ` + referenceTimeStr + `,
14738 "url": "u"
14739 },
14740 "suspended_at": ` + referenceTimeStr + `
14741 }
14742 }`
14743
14744 testJSONMarshal(t, u, want)
14745 }
14746
14747 func TestProjectV2Event_Marshal(t *testing.T) {
14748 testJSONMarshal(t, &ProjectV2Event{}, "{}")
14749
14750 u := &ProjectV2Event{
14751 Action: String("a"),
14752 ProjectsV2: &ProjectsV2{
14753 ID: Int64(1),
14754 NodeID: String("nid"),
14755 Owner: &User{
14756 Login: String("l"),
14757 ID: Int64(1),
14758 NodeID: String("n"),
14759 URL: String("u"),
14760 ReposURL: String("r"),
14761 EventsURL: String("e"),
14762 AvatarURL: String("a"),
14763 },
14764 Creator: &User{
14765 Login: String("l"),
14766 ID: Int64(1),
14767 NodeID: String("n"),
14768 URL: String("u"),
14769 ReposURL: String("r"),
14770 EventsURL: String("e"),
14771 AvatarURL: String("a"),
14772 },
14773 Title: String("t"),
14774 Description: String("d"),
14775 Public: Bool(true),
14776 ClosedAt: &Timestamp{referenceTime},
14777 CreatedAt: &Timestamp{referenceTime},
14778 UpdatedAt: &Timestamp{referenceTime},
14779 DeletedAt: &Timestamp{referenceTime},
14780 Number: Int(1),
14781 ShortDescription: String("sd"),
14782 DeletedBy: &User{
14783 Login: String("l"),
14784 ID: Int64(1),
14785 NodeID: String("n"),
14786 URL: String("u"),
14787 ReposURL: String("r"),
14788 EventsURL: String("e"),
14789 AvatarURL: String("a"),
14790 },
14791 },
14792 Org: &Organization{
14793 BillingEmail: String("be"),
14794 Blog: String("b"),
14795 Company: String("c"),
14796 Email: String("e"),
14797 TwitterUsername: String("tu"),
14798 Location: String("loc"),
14799 Name: String("n"),
14800 Description: String("d"),
14801 IsVerified: Bool(true),
14802 HasOrganizationProjects: Bool(true),
14803 HasRepositoryProjects: Bool(true),
14804 DefaultRepoPermission: String("drp"),
14805 MembersCanCreateRepos: Bool(true),
14806 MembersCanCreateInternalRepos: Bool(true),
14807 MembersCanCreatePrivateRepos: Bool(true),
14808 MembersCanCreatePublicRepos: Bool(false),
14809 MembersAllowedRepositoryCreationType: String("marct"),
14810 MembersCanCreatePages: Bool(true),
14811 MembersCanCreatePublicPages: Bool(false),
14812 MembersCanCreatePrivatePages: Bool(true),
14813 },
14814 Sender: &User{
14815 Login: String("l"),
14816 ID: Int64(1),
14817 NodeID: String("n"),
14818 URL: String("u"),
14819 ReposURL: String("r"),
14820 EventsURL: String("e"),
14821 AvatarURL: String("a"),
14822 },
14823 Installation: &Installation{
14824 ID: Int64(1),
14825 NodeID: String("nid"),
14826 AppID: Int64(1),
14827 AppSlug: String("as"),
14828 TargetID: Int64(1),
14829 Account: &User{
14830 Login: String("l"),
14831 ID: Int64(1),
14832 URL: String("u"),
14833 AvatarURL: String("a"),
14834 GravatarID: String("g"),
14835 Name: String("n"),
14836 Company: String("c"),
14837 Blog: String("b"),
14838 Location: String("l"),
14839 Email: String("e"),
14840 Hireable: Bool(true),
14841 Bio: String("b"),
14842 TwitterUsername: String("t"),
14843 PublicRepos: Int(1),
14844 Followers: Int(1),
14845 Following: Int(1),
14846 CreatedAt: &Timestamp{referenceTime},
14847 SuspendedAt: &Timestamp{referenceTime},
14848 },
14849 },
14850 }
14851
14852 want := `{
14853 "action": "a",
14854 "projects_v2": {
14855 "id": 1,
14856 "node_id": "nid",
14857 "owner": {
14858 "login": "l",
14859 "id": 1,
14860 "node_id": "n",
14861 "avatar_url": "a",
14862 "url": "u",
14863 "events_url": "e",
14864 "repos_url": "r"
14865 },
14866 "creator": {
14867 "login": "l",
14868 "id": 1,
14869 "node_id": "n",
14870 "avatar_url": "a",
14871 "url": "u",
14872 "events_url": "e",
14873 "repos_url": "r"
14874 },
14875 "title": "t",
14876 "description": "d",
14877 "public": true,
14878 "closed_at": ` + referenceTimeStr + `,
14879 "created_at": ` + referenceTimeStr + `,
14880 "updated_at": ` + referenceTimeStr + `,
14881 "deleted_at": ` + referenceTimeStr + `,
14882 "number": 1,
14883 "short_description": "sd",
14884 "deleted_by": {
14885 "login": "l",
14886 "id": 1,
14887 "node_id": "n",
14888 "avatar_url": "a",
14889 "url": "u",
14890 "events_url": "e",
14891 "repos_url": "r"
14892 }
14893 },
14894 "organization": {
14895 "name": "n",
14896 "company": "c",
14897 "blog": "b",
14898 "location": "loc",
14899 "email": "e",
14900 "twitter_username": "tu",
14901 "description": "d",
14902 "billing_email": "be",
14903 "is_verified": true,
14904 "has_organization_projects": true,
14905 "has_repository_projects": true,
14906 "default_repository_permission": "drp",
14907 "members_can_create_repositories": true,
14908 "members_can_create_public_repositories": false,
14909 "members_can_create_private_repositories": true,
14910 "members_can_create_internal_repositories": true,
14911 "members_allowed_repository_creation_type": "marct",
14912 "members_can_create_pages": true,
14913 "members_can_create_public_pages": false,
14914 "members_can_create_private_pages": true
14915 },
14916 "sender": {
14917 "login": "l",
14918 "id": 1,
14919 "node_id": "n",
14920 "avatar_url": "a",
14921 "url": "u",
14922 "events_url": "e",
14923 "repos_url": "r"
14924 },
14925 "installation": {
14926 "id": 1,
14927 "node_id": "nid",
14928 "app_id": 1,
14929 "app_slug": "as",
14930 "target_id": 1,
14931 "account": {
14932 "login": "l",
14933 "id": 1,
14934 "avatar_url": "a",
14935 "gravatar_id": "g",
14936 "name": "n",
14937 "company": "c",
14938 "blog": "b",
14939 "location": "l",
14940 "email": "e",
14941 "hireable": true,
14942 "bio": "b",
14943 "twitter_username": "t",
14944 "public_repos": 1,
14945 "followers": 1,
14946 "following": 1,
14947 "created_at": ` + referenceTimeStr + `,
14948 "suspended_at": ` + referenceTimeStr + `,
14949 "url": "u"
14950 }
14951 }
14952 }`
14953
14954 testJSONMarshal(t, u, want)
14955 }
14956
14957 func TestProjectV2ItemEvent_Marshal(t *testing.T) {
14958 testJSONMarshal(t, &ProjectV2ItemEvent{}, "{}")
14959
14960 u := &ProjectV2ItemEvent{
14961 Action: String("a"),
14962 Changes: &ProjectV2ItemChange{
14963 ArchivedAt: &ArchivedAt{
14964 From: &Timestamp{referenceTime},
14965 To: &Timestamp{referenceTime},
14966 },
14967 },
14968 ProjectV2Item: &ProjectV2Item{
14969 ID: Int64(1),
14970 NodeID: String("nid"),
14971 ProjectNodeID: String("pnid"),
14972 ContentNodeID: String("cnid"),
14973 ContentType: String("ct"),
14974 Creator: &User{
14975 Login: String("l"),
14976 ID: Int64(1),
14977 NodeID: String("n"),
14978 URL: String("u"),
14979 ReposURL: String("r"),
14980 EventsURL: String("e"),
14981 AvatarURL: String("a"),
14982 },
14983 CreatedAt: &Timestamp{referenceTime},
14984 UpdatedAt: &Timestamp{referenceTime},
14985 ArchivedAt: &Timestamp{referenceTime},
14986 },
14987 Org: &Organization{
14988 BillingEmail: String("be"),
14989 Blog: String("b"),
14990 Company: String("c"),
14991 Email: String("e"),
14992 TwitterUsername: String("tu"),
14993 Location: String("loc"),
14994 Name: String("n"),
14995 Description: String("d"),
14996 IsVerified: Bool(true),
14997 HasOrganizationProjects: Bool(true),
14998 HasRepositoryProjects: Bool(true),
14999 DefaultRepoPermission: String("drp"),
15000 MembersCanCreateRepos: Bool(true),
15001 MembersCanCreateInternalRepos: Bool(true),
15002 MembersCanCreatePrivateRepos: Bool(true),
15003 MembersCanCreatePublicRepos: Bool(false),
15004 MembersAllowedRepositoryCreationType: String("marct"),
15005 MembersCanCreatePages: Bool(true),
15006 MembersCanCreatePublicPages: Bool(false),
15007 MembersCanCreatePrivatePages: Bool(true),
15008 },
15009 Sender: &User{
15010 Login: String("l"),
15011 ID: Int64(1),
15012 NodeID: String("n"),
15013 URL: String("u"),
15014 ReposURL: String("r"),
15015 EventsURL: String("e"),
15016 AvatarURL: String("a"),
15017 },
15018 Installation: &Installation{
15019 ID: Int64(1),
15020 NodeID: String("nid"),
15021 AppID: Int64(1),
15022 AppSlug: String("as"),
15023 TargetID: Int64(1),
15024 Account: &User{
15025 Login: String("l"),
15026 ID: Int64(1),
15027 URL: String("u"),
15028 AvatarURL: String("a"),
15029 GravatarID: String("g"),
15030 Name: String("n"),
15031 Company: String("c"),
15032 Blog: String("b"),
15033 Location: String("l"),
15034 Email: String("e"),
15035 Hireable: Bool(true),
15036 Bio: String("b"),
15037 TwitterUsername: String("t"),
15038 PublicRepos: Int(1),
15039 Followers: Int(1),
15040 Following: Int(1),
15041 CreatedAt: &Timestamp{referenceTime},
15042 SuspendedAt: &Timestamp{referenceTime},
15043 },
15044 },
15045 }
15046
15047 want := `{
15048 "action": "a",
15049 "changes": {
15050 "archived_at": {
15051 "from": ` + referenceTimeStr + `,
15052 "to": ` + referenceTimeStr + `
15053 }
15054 },
15055 "projects_v2_item": {
15056 "id": 1,
15057 "node_id": "nid",
15058 "project_node_id": "pnid",
15059 "content_node_id": "cnid",
15060 "content_type": "ct",
15061 "creator": {
15062 "login": "l",
15063 "id": 1,
15064 "node_id": "n",
15065 "avatar_url": "a",
15066 "url": "u",
15067 "events_url": "e",
15068 "repos_url": "r"
15069 },
15070 "created_at": ` + referenceTimeStr + `,
15071 "updated_at": ` + referenceTimeStr + `,
15072 "archived_at": ` + referenceTimeStr + `
15073 },
15074 "organization": {
15075 "name": "n",
15076 "company": "c",
15077 "blog": "b",
15078 "location": "loc",
15079 "email": "e",
15080 "twitter_username": "tu",
15081 "description": "d",
15082 "billing_email": "be",
15083 "is_verified": true,
15084 "has_organization_projects": true,
15085 "has_repository_projects": true,
15086 "default_repository_permission": "drp",
15087 "members_can_create_repositories": true,
15088 "members_can_create_public_repositories": false,
15089 "members_can_create_private_repositories": true,
15090 "members_can_create_internal_repositories": true,
15091 "members_allowed_repository_creation_type": "marct",
15092 "members_can_create_pages": true,
15093 "members_can_create_public_pages": false,
15094 "members_can_create_private_pages": true
15095 },
15096 "sender": {
15097 "login": "l",
15098 "id": 1,
15099 "node_id": "n",
15100 "avatar_url": "a",
15101 "url": "u",
15102 "events_url": "e",
15103 "repos_url": "r"
15104 },
15105 "installation": {
15106 "id": 1,
15107 "node_id": "nid",
15108 "app_id": 1,
15109 "app_slug": "as",
15110 "target_id": 1,
15111 "account": {
15112 "login": "l",
15113 "id": 1,
15114 "avatar_url": "a",
15115 "gravatar_id": "g",
15116 "name": "n",
15117 "company": "c",
15118 "blog": "b",
15119 "location": "l",
15120 "email": "e",
15121 "hireable": true,
15122 "bio": "b",
15123 "twitter_username": "t",
15124 "public_repos": 1,
15125 "followers": 1,
15126 "following": 1,
15127 "created_at": ` + referenceTimeStr + `,
15128 "suspended_at": ` + referenceTimeStr + `,
15129 "url": "u"
15130 }
15131 }
15132 }`
15133
15134 testJSONMarshal(t, u, want)
15135 }
15136
15137 func TestPullRequestEvent_Marshal(t *testing.T) {
15138 testJSONMarshal(t, &PullRequestEvent{}, "{}")
15139
15140 u := &PullRequestEvent{
15141 Action: String("a"),
15142 Assignee: &User{
15143 Login: String("l"),
15144 ID: Int64(1),
15145 NodeID: String("n"),
15146 URL: String("u"),
15147 ReposURL: String("r"),
15148 EventsURL: String("e"),
15149 AvatarURL: String("a"),
15150 },
15151 Number: Int(1),
15152 PullRequest: &PullRequest{ID: Int64(1)},
15153 Changes: &EditChange{
15154 Title: &EditTitle{
15155 From: String("TitleFrom"),
15156 },
15157 Body: &EditBody{
15158 From: String("BodyFrom"),
15159 },
15160 Base: &EditBase{
15161 Ref: &EditRef{
15162 From: String("BaseRefFrom"),
15163 },
15164 SHA: &EditSHA{
15165 From: String("BaseSHAFrom"),
15166 },
15167 },
15168 },
15169 RequestedReviewer: &User{
15170 Login: String("l"),
15171 ID: Int64(1),
15172 NodeID: String("n"),
15173 URL: String("u"),
15174 ReposURL: String("r"),
15175 EventsURL: String("e"),
15176 AvatarURL: String("a"),
15177 },
15178 RequestedTeam: &Team{ID: Int64(1)},
15179 Label: &Label{ID: Int64(1)},
15180 Before: String("before"),
15181 After: String("after"),
15182 Repo: &Repository{
15183 ID: Int64(1),
15184 URL: String("s"),
15185 Name: String("n"),
15186 },
15187 PerformedViaGithubApp: &App{
15188 ID: Int64(1),
15189 NodeID: String("n"),
15190 Slug: String("s"),
15191 Name: String("n"),
15192 Description: String("d"),
15193 ExternalURL: String("e"),
15194 HTMLURL: String("h"),
15195 },
15196 Organization: &Organization{
15197 BillingEmail: String("be"),
15198 Blog: String("b"),
15199 Company: String("c"),
15200 Email: String("e"),
15201 TwitterUsername: String("tu"),
15202 Location: String("loc"),
15203 Name: String("n"),
15204 Description: String("d"),
15205 IsVerified: Bool(true),
15206 HasOrganizationProjects: Bool(true),
15207 HasRepositoryProjects: Bool(true),
15208 DefaultRepoPermission: String("drp"),
15209 MembersCanCreateRepos: Bool(true),
15210 MembersCanCreateInternalRepos: Bool(true),
15211 MembersCanCreatePrivateRepos: Bool(true),
15212 MembersCanCreatePublicRepos: Bool(false),
15213 MembersAllowedRepositoryCreationType: String("marct"),
15214 MembersCanCreatePages: Bool(true),
15215 MembersCanCreatePublicPages: Bool(false),
15216 MembersCanCreatePrivatePages: Bool(true),
15217 },
15218 Sender: &User{
15219 Login: String("l"),
15220 ID: Int64(1),
15221 NodeID: String("n"),
15222 URL: String("u"),
15223 ReposURL: String("r"),
15224 EventsURL: String("e"),
15225 AvatarURL: String("a"),
15226 },
15227 Installation: &Installation{
15228 ID: Int64(1),
15229 NodeID: String("nid"),
15230 AppID: Int64(1),
15231 AppSlug: String("as"),
15232 TargetID: Int64(1),
15233 Account: &User{
15234 Login: String("l"),
15235 ID: Int64(1),
15236 URL: String("u"),
15237 AvatarURL: String("a"),
15238 GravatarID: String("g"),
15239 Name: String("n"),
15240 Company: String("c"),
15241 Blog: String("b"),
15242 Location: String("l"),
15243 Email: String("e"),
15244 Hireable: Bool(true),
15245 Bio: String("b"),
15246 TwitterUsername: String("t"),
15247 PublicRepos: Int(1),
15248 Followers: Int(1),
15249 Following: Int(1),
15250 CreatedAt: &Timestamp{referenceTime},
15251 SuspendedAt: &Timestamp{referenceTime},
15252 },
15253 AccessTokensURL: String("atu"),
15254 RepositoriesURL: String("ru"),
15255 HTMLURL: String("hu"),
15256 TargetType: String("tt"),
15257 SingleFileName: String("sfn"),
15258 RepositorySelection: String("rs"),
15259 Events: []string{"e"},
15260 SingleFilePaths: []string{"s"},
15261 Permissions: &InstallationPermissions{
15262 Actions: String("a"),
15263 Administration: String("ad"),
15264 Checks: String("c"),
15265 Contents: String("co"),
15266 ContentReferences: String("cr"),
15267 Deployments: String("d"),
15268 Environments: String("e"),
15269 Issues: String("i"),
15270 Metadata: String("md"),
15271 Members: String("m"),
15272 OrganizationAdministration: String("oa"),
15273 OrganizationHooks: String("oh"),
15274 OrganizationPlan: String("op"),
15275 OrganizationPreReceiveHooks: String("opr"),
15276 OrganizationProjects: String("op"),
15277 OrganizationSecrets: String("os"),
15278 OrganizationSelfHostedRunners: String("osh"),
15279 OrganizationUserBlocking: String("oub"),
15280 Packages: String("pkg"),
15281 Pages: String("pg"),
15282 PullRequests: String("pr"),
15283 RepositoryHooks: String("rh"),
15284 RepositoryProjects: String("rp"),
15285 RepositoryPreReceiveHooks: String("rprh"),
15286 Secrets: String("s"),
15287 SecretScanningAlerts: String("ssa"),
15288 SecurityEvents: String("se"),
15289 SingleFile: String("sf"),
15290 Statuses: String("s"),
15291 TeamDiscussions: String("td"),
15292 VulnerabilityAlerts: String("va"),
15293 Workflows: String("w"),
15294 },
15295 CreatedAt: &Timestamp{referenceTime},
15296 UpdatedAt: &Timestamp{referenceTime},
15297 HasMultipleSingleFiles: Bool(false),
15298 SuspendedBy: &User{
15299 Login: String("l"),
15300 ID: Int64(1),
15301 URL: String("u"),
15302 AvatarURL: String("a"),
15303 GravatarID: String("g"),
15304 Name: String("n"),
15305 Company: String("c"),
15306 Blog: String("b"),
15307 Location: String("l"),
15308 Email: String("e"),
15309 Hireable: Bool(true),
15310 Bio: String("b"),
15311 TwitterUsername: String("t"),
15312 PublicRepos: Int(1),
15313 Followers: Int(1),
15314 Following: Int(1),
15315 CreatedAt: &Timestamp{referenceTime},
15316 SuspendedAt: &Timestamp{referenceTime},
15317 },
15318 SuspendedAt: &Timestamp{referenceTime},
15319 },
15320 }
15321
15322 want := `{
15323 "action": "a",
15324 "assignee": {
15325 "login": "l",
15326 "id": 1,
15327 "node_id": "n",
15328 "avatar_url": "a",
15329 "url": "u",
15330 "events_url": "e",
15331 "repos_url": "r"
15332 },
15333 "number": 1,
15334 "pull_request": {
15335 "id": 1
15336 },
15337 "changes": {
15338 "title": {
15339 "from": "TitleFrom"
15340 },
15341 "body": {
15342 "from": "BodyFrom"
15343 },
15344 "base": {
15345 "ref": {
15346 "from": "BaseRefFrom"
15347 },
15348 "sha": {
15349 "from": "BaseSHAFrom"
15350 }
15351 }
15352 },
15353 "requested_reviewer": {
15354 "login": "l",
15355 "id": 1,
15356 "node_id": "n",
15357 "avatar_url": "a",
15358 "url": "u",
15359 "events_url": "e",
15360 "repos_url": "r"
15361 },
15362 "requested_team": {
15363 "id": 1
15364 },
15365 "label": {
15366 "id": 1
15367 },
15368 "before": "before",
15369 "after": "after",
15370 "repository": {
15371 "id": 1,
15372 "name": "n",
15373 "url": "s"
15374 },
15375 "performed_via_github_app": {
15376 "id": 1,
15377 "node_id": "n",
15378 "slug": "s",
15379 "name": "n",
15380 "description": "d",
15381 "external_url": "e",
15382 "html_url": "h"
15383 },
15384 "organization": {
15385 "name": "n",
15386 "company": "c",
15387 "blog": "b",
15388 "location": "loc",
15389 "email": "e",
15390 "twitter_username": "tu",
15391 "description": "d",
15392 "billing_email": "be",
15393 "is_verified": true,
15394 "has_organization_projects": true,
15395 "has_repository_projects": true,
15396 "default_repository_permission": "drp",
15397 "members_can_create_repositories": true,
15398 "members_can_create_public_repositories": false,
15399 "members_can_create_private_repositories": true,
15400 "members_can_create_internal_repositories": true,
15401 "members_allowed_repository_creation_type": "marct",
15402 "members_can_create_pages": true,
15403 "members_can_create_public_pages": false,
15404 "members_can_create_private_pages": true
15405 },
15406 "sender": {
15407 "login": "l",
15408 "id": 1,
15409 "node_id": "n",
15410 "avatar_url": "a",
15411 "url": "u",
15412 "events_url": "e",
15413 "repos_url": "r"
15414 },
15415 "installation": {
15416 "id": 1,
15417 "node_id": "nid",
15418 "app_id": 1,
15419 "app_slug": "as",
15420 "target_id": 1,
15421 "account": {
15422 "login": "l",
15423 "id": 1,
15424 "avatar_url": "a",
15425 "gravatar_id": "g",
15426 "name": "n",
15427 "company": "c",
15428 "blog": "b",
15429 "location": "l",
15430 "email": "e",
15431 "hireable": true,
15432 "bio": "b",
15433 "twitter_username": "t",
15434 "public_repos": 1,
15435 "followers": 1,
15436 "following": 1,
15437 "created_at": ` + referenceTimeStr + `,
15438 "suspended_at": ` + referenceTimeStr + `,
15439 "url": "u"
15440 },
15441 "access_tokens_url": "atu",
15442 "repositories_url": "ru",
15443 "html_url": "hu",
15444 "target_type": "tt",
15445 "single_file_name": "sfn",
15446 "repository_selection": "rs",
15447 "events": [
15448 "e"
15449 ],
15450 "single_file_paths": [
15451 "s"
15452 ],
15453 "permissions": {
15454 "actions": "a",
15455 "administration": "ad",
15456 "checks": "c",
15457 "contents": "co",
15458 "content_references": "cr",
15459 "deployments": "d",
15460 "environments": "e",
15461 "issues": "i",
15462 "metadata": "md",
15463 "members": "m",
15464 "organization_administration": "oa",
15465 "organization_hooks": "oh",
15466 "organization_plan": "op",
15467 "organization_pre_receive_hooks": "opr",
15468 "organization_projects": "op",
15469 "organization_secrets": "os",
15470 "organization_self_hosted_runners": "osh",
15471 "organization_user_blocking": "oub",
15472 "packages": "pkg",
15473 "pages": "pg",
15474 "pull_requests": "pr",
15475 "repository_hooks": "rh",
15476 "repository_projects": "rp",
15477 "repository_pre_receive_hooks": "rprh",
15478 "secrets": "s",
15479 "secret_scanning_alerts": "ssa",
15480 "security_events": "se",
15481 "single_file": "sf",
15482 "statuses": "s",
15483 "team_discussions": "td",
15484 "vulnerability_alerts": "va",
15485 "workflows": "w"
15486 },
15487 "created_at": ` + referenceTimeStr + `,
15488 "updated_at": ` + referenceTimeStr + `,
15489 "has_multiple_single_files": false,
15490 "suspended_by": {
15491 "login": "l",
15492 "id": 1,
15493 "avatar_url": "a",
15494 "gravatar_id": "g",
15495 "name": "n",
15496 "company": "c",
15497 "blog": "b",
15498 "location": "l",
15499 "email": "e",
15500 "hireable": true,
15501 "bio": "b",
15502 "twitter_username": "t",
15503 "public_repos": 1,
15504 "followers": 1,
15505 "following": 1,
15506 "created_at": ` + referenceTimeStr + `,
15507 "suspended_at": ` + referenceTimeStr + `,
15508 "url": "u"
15509 },
15510 "suspended_at": ` + referenceTimeStr + `
15511 }
15512 }`
15513
15514 testJSONMarshal(t, u, want)
15515 }
15516
15517 func TestPullRequestReviewCommentEvent_Marshal(t *testing.T) {
15518 testJSONMarshal(t, &PullRequestReviewCommentEvent{}, "{}")
15519
15520 u := &PullRequestReviewCommentEvent{
15521 Action: String("a"),
15522 PullRequest: &PullRequest{ID: Int64(1)},
15523 Comment: &PullRequestComment{ID: Int64(1)},
15524 Changes: &EditChange{
15525 Title: &EditTitle{
15526 From: String("TitleFrom"),
15527 },
15528 Body: &EditBody{
15529 From: String("BodyFrom"),
15530 },
15531 Base: &EditBase{
15532 Ref: &EditRef{
15533 From: String("BaseRefFrom"),
15534 },
15535 SHA: &EditSHA{
15536 From: String("BaseSHAFrom"),
15537 },
15538 },
15539 },
15540 Repo: &Repository{
15541 ID: Int64(1),
15542 URL: String("s"),
15543 Name: String("n"),
15544 },
15545 Sender: &User{
15546 Login: String("l"),
15547 ID: Int64(1),
15548 NodeID: String("n"),
15549 URL: String("u"),
15550 ReposURL: String("r"),
15551 EventsURL: String("e"),
15552 AvatarURL: String("a"),
15553 },
15554 Installation: &Installation{
15555 ID: Int64(1),
15556 NodeID: String("nid"),
15557 AppID: Int64(1),
15558 AppSlug: String("as"),
15559 TargetID: Int64(1),
15560 Account: &User{
15561 Login: String("l"),
15562 ID: Int64(1),
15563 URL: String("u"),
15564 AvatarURL: String("a"),
15565 GravatarID: String("g"),
15566 Name: String("n"),
15567 Company: String("c"),
15568 Blog: String("b"),
15569 Location: String("l"),
15570 Email: String("e"),
15571 Hireable: Bool(true),
15572 Bio: String("b"),
15573 TwitterUsername: String("t"),
15574 PublicRepos: Int(1),
15575 Followers: Int(1),
15576 Following: Int(1),
15577 CreatedAt: &Timestamp{referenceTime},
15578 SuspendedAt: &Timestamp{referenceTime},
15579 },
15580 AccessTokensURL: String("atu"),
15581 RepositoriesURL: String("ru"),
15582 HTMLURL: String("hu"),
15583 TargetType: String("tt"),
15584 SingleFileName: String("sfn"),
15585 RepositorySelection: String("rs"),
15586 Events: []string{"e"},
15587 SingleFilePaths: []string{"s"},
15588 Permissions: &InstallationPermissions{
15589 Actions: String("a"),
15590 Administration: String("ad"),
15591 Checks: String("c"),
15592 Contents: String("co"),
15593 ContentReferences: String("cr"),
15594 Deployments: String("d"),
15595 Environments: String("e"),
15596 Issues: String("i"),
15597 Metadata: String("md"),
15598 Members: String("m"),
15599 OrganizationAdministration: String("oa"),
15600 OrganizationHooks: String("oh"),
15601 OrganizationPlan: String("op"),
15602 OrganizationPreReceiveHooks: String("opr"),
15603 OrganizationProjects: String("op"),
15604 OrganizationSecrets: String("os"),
15605 OrganizationSelfHostedRunners: String("osh"),
15606 OrganizationUserBlocking: String("oub"),
15607 Packages: String("pkg"),
15608 Pages: String("pg"),
15609 PullRequests: String("pr"),
15610 RepositoryHooks: String("rh"),
15611 RepositoryProjects: String("rp"),
15612 RepositoryPreReceiveHooks: String("rprh"),
15613 Secrets: String("s"),
15614 SecretScanningAlerts: String("ssa"),
15615 SecurityEvents: String("se"),
15616 SingleFile: String("sf"),
15617 Statuses: String("s"),
15618 TeamDiscussions: String("td"),
15619 VulnerabilityAlerts: String("va"),
15620 Workflows: String("w"),
15621 },
15622 CreatedAt: &Timestamp{referenceTime},
15623 UpdatedAt: &Timestamp{referenceTime},
15624 HasMultipleSingleFiles: Bool(false),
15625 SuspendedBy: &User{
15626 Login: String("l"),
15627 ID: Int64(1),
15628 URL: String("u"),
15629 AvatarURL: String("a"),
15630 GravatarID: String("g"),
15631 Name: String("n"),
15632 Company: String("c"),
15633 Blog: String("b"),
15634 Location: String("l"),
15635 Email: String("e"),
15636 Hireable: Bool(true),
15637 Bio: String("b"),
15638 TwitterUsername: String("t"),
15639 PublicRepos: Int(1),
15640 Followers: Int(1),
15641 Following: Int(1),
15642 CreatedAt: &Timestamp{referenceTime},
15643 SuspendedAt: &Timestamp{referenceTime},
15644 },
15645 SuspendedAt: &Timestamp{referenceTime},
15646 },
15647 }
15648
15649 want := `{
15650 "action": "a",
15651 "pull_request": {
15652 "id": 1
15653 },
15654 "comment": {
15655 "id": 1
15656 },
15657 "changes": {
15658 "title": {
15659 "from": "TitleFrom"
15660 },
15661 "body": {
15662 "from": "BodyFrom"
15663 },
15664 "base": {
15665 "ref": {
15666 "from": "BaseRefFrom"
15667 },
15668 "sha": {
15669 "from": "BaseSHAFrom"
15670 }
15671 }
15672 },
15673 "repository": {
15674 "id": 1,
15675 "name": "n",
15676 "url": "s"
15677 },
15678 "sender": {
15679 "login": "l",
15680 "id": 1,
15681 "node_id": "n",
15682 "avatar_url": "a",
15683 "url": "u",
15684 "events_url": "e",
15685 "repos_url": "r"
15686 },
15687 "installation": {
15688 "id": 1,
15689 "node_id": "nid",
15690 "app_id": 1,
15691 "app_slug": "as",
15692 "target_id": 1,
15693 "account": {
15694 "login": "l",
15695 "id": 1,
15696 "avatar_url": "a",
15697 "gravatar_id": "g",
15698 "name": "n",
15699 "company": "c",
15700 "blog": "b",
15701 "location": "l",
15702 "email": "e",
15703 "hireable": true,
15704 "bio": "b",
15705 "twitter_username": "t",
15706 "public_repos": 1,
15707 "followers": 1,
15708 "following": 1,
15709 "created_at": ` + referenceTimeStr + `,
15710 "suspended_at": ` + referenceTimeStr + `,
15711 "url": "u"
15712 },
15713 "access_tokens_url": "atu",
15714 "repositories_url": "ru",
15715 "html_url": "hu",
15716 "target_type": "tt",
15717 "single_file_name": "sfn",
15718 "repository_selection": "rs",
15719 "events": [
15720 "e"
15721 ],
15722 "single_file_paths": [
15723 "s"
15724 ],
15725 "permissions": {
15726 "actions": "a",
15727 "administration": "ad",
15728 "checks": "c",
15729 "contents": "co",
15730 "content_references": "cr",
15731 "deployments": "d",
15732 "environments": "e",
15733 "issues": "i",
15734 "metadata": "md",
15735 "members": "m",
15736 "organization_administration": "oa",
15737 "organization_hooks": "oh",
15738 "organization_plan": "op",
15739 "organization_pre_receive_hooks": "opr",
15740 "organization_projects": "op",
15741 "organization_secrets": "os",
15742 "organization_self_hosted_runners": "osh",
15743 "organization_user_blocking": "oub",
15744 "packages": "pkg",
15745 "pages": "pg",
15746 "pull_requests": "pr",
15747 "repository_hooks": "rh",
15748 "repository_projects": "rp",
15749 "repository_pre_receive_hooks": "rprh",
15750 "secrets": "s",
15751 "secret_scanning_alerts": "ssa",
15752 "security_events": "se",
15753 "single_file": "sf",
15754 "statuses": "s",
15755 "team_discussions": "td",
15756 "vulnerability_alerts": "va",
15757 "workflows": "w"
15758 },
15759 "created_at": ` + referenceTimeStr + `,
15760 "updated_at": ` + referenceTimeStr + `,
15761 "has_multiple_single_files": false,
15762 "suspended_by": {
15763 "login": "l",
15764 "id": 1,
15765 "avatar_url": "a",
15766 "gravatar_id": "g",
15767 "name": "n",
15768 "company": "c",
15769 "blog": "b",
15770 "location": "l",
15771 "email": "e",
15772 "hireable": true,
15773 "bio": "b",
15774 "twitter_username": "t",
15775 "public_repos": 1,
15776 "followers": 1,
15777 "following": 1,
15778 "created_at": ` + referenceTimeStr + `,
15779 "suspended_at": ` + referenceTimeStr + `,
15780 "url": "u"
15781 },
15782 "suspended_at": ` + referenceTimeStr + `
15783 }
15784 }`
15785
15786 testJSONMarshal(t, u, want)
15787 }
15788
15789 func TestPullRequestReviewThreadEvent_Marshal(t *testing.T) {
15790 testJSONMarshal(t, &PullRequestReviewThreadEvent{}, "{}")
15791
15792 u := &PullRequestReviewThreadEvent{
15793 Action: String("a"),
15794 PullRequest: &PullRequest{ID: Int64(1)},
15795 Thread: &PullRequestThread{
15796 Comments: []*PullRequestComment{{ID: Int64(1)}, {ID: Int64(2)}},
15797 },
15798 Repo: &Repository{
15799 ID: Int64(1),
15800 URL: String("s"),
15801 Name: String("n"),
15802 },
15803 Sender: &User{
15804 Login: String("l"),
15805 ID: Int64(1),
15806 NodeID: String("n"),
15807 URL: String("u"),
15808 ReposURL: String("r"),
15809 EventsURL: String("e"),
15810 AvatarURL: String("a"),
15811 },
15812 Installation: &Installation{
15813 ID: Int64(1),
15814 NodeID: String("nid"),
15815 AppID: Int64(1),
15816 AppSlug: String("as"),
15817 TargetID: Int64(1),
15818 Account: &User{
15819 Login: String("l"),
15820 ID: Int64(1),
15821 URL: String("u"),
15822 AvatarURL: String("a"),
15823 GravatarID: String("g"),
15824 Name: String("n"),
15825 Company: String("c"),
15826 Blog: String("b"),
15827 Location: String("l"),
15828 Email: String("e"),
15829 Hireable: Bool(true),
15830 Bio: String("b"),
15831 TwitterUsername: String("t"),
15832 PublicRepos: Int(1),
15833 Followers: Int(1),
15834 Following: Int(1),
15835 CreatedAt: &Timestamp{referenceTime},
15836 SuspendedAt: &Timestamp{referenceTime},
15837 },
15838 AccessTokensURL: String("atu"),
15839 RepositoriesURL: String("ru"),
15840 HTMLURL: String("hu"),
15841 TargetType: String("tt"),
15842 SingleFileName: String("sfn"),
15843 RepositorySelection: String("rs"),
15844 Events: []string{"e"},
15845 SingleFilePaths: []string{"s"},
15846 Permissions: &InstallationPermissions{
15847 Actions: String("a"),
15848 Administration: String("ad"),
15849 Checks: String("c"),
15850 Contents: String("co"),
15851 ContentReferences: String("cr"),
15852 Deployments: String("d"),
15853 Environments: String("e"),
15854 Issues: String("i"),
15855 Metadata: String("md"),
15856 Members: String("m"),
15857 OrganizationAdministration: String("oa"),
15858 OrganizationHooks: String("oh"),
15859 OrganizationPlan: String("op"),
15860 OrganizationPreReceiveHooks: String("opr"),
15861 OrganizationProjects: String("op"),
15862 OrganizationSecrets: String("os"),
15863 OrganizationSelfHostedRunners: String("osh"),
15864 OrganizationUserBlocking: String("oub"),
15865 Packages: String("pkg"),
15866 Pages: String("pg"),
15867 PullRequests: String("pr"),
15868 RepositoryHooks: String("rh"),
15869 RepositoryProjects: String("rp"),
15870 RepositoryPreReceiveHooks: String("rprh"),
15871 Secrets: String("s"),
15872 SecretScanningAlerts: String("ssa"),
15873 SecurityEvents: String("se"),
15874 SingleFile: String("sf"),
15875 Statuses: String("s"),
15876 TeamDiscussions: String("td"),
15877 VulnerabilityAlerts: String("va"),
15878 Workflows: String("w"),
15879 },
15880 CreatedAt: &Timestamp{referenceTime},
15881 UpdatedAt: &Timestamp{referenceTime},
15882 HasMultipleSingleFiles: Bool(false),
15883 SuspendedBy: &User{
15884 Login: String("l"),
15885 ID: Int64(1),
15886 URL: String("u"),
15887 AvatarURL: String("a"),
15888 GravatarID: String("g"),
15889 Name: String("n"),
15890 Company: String("c"),
15891 Blog: String("b"),
15892 Location: String("l"),
15893 Email: String("e"),
15894 Hireable: Bool(true),
15895 Bio: String("b"),
15896 TwitterUsername: String("t"),
15897 PublicRepos: Int(1),
15898 Followers: Int(1),
15899 Following: Int(1),
15900 CreatedAt: &Timestamp{referenceTime},
15901 SuspendedAt: &Timestamp{referenceTime},
15902 },
15903 SuspendedAt: &Timestamp{referenceTime},
15904 },
15905 }
15906
15907 want := `{
15908 "action": "a",
15909 "pull_request": {
15910 "id": 1
15911 },
15912 "thread": {
15913 "comments": [
15914 {
15915 "id": 1
15916 },
15917 {
15918 "id": 2
15919 }
15920 ]
15921 },
15922 "repository": {
15923 "id": 1,
15924 "name": "n",
15925 "url": "s"
15926 },
15927 "sender": {
15928 "login": "l",
15929 "id": 1,
15930 "node_id": "n",
15931 "avatar_url": "a",
15932 "url": "u",
15933 "events_url": "e",
15934 "repos_url": "r"
15935 },
15936 "installation": {
15937 "id": 1,
15938 "node_id": "nid",
15939 "app_id": 1,
15940 "app_slug": "as",
15941 "target_id": 1,
15942 "account": {
15943 "login": "l",
15944 "id": 1,
15945 "avatar_url": "a",
15946 "gravatar_id": "g",
15947 "name": "n",
15948 "company": "c",
15949 "blog": "b",
15950 "location": "l",
15951 "email": "e",
15952 "hireable": true,
15953 "bio": "b",
15954 "twitter_username": "t",
15955 "public_repos": 1,
15956 "followers": 1,
15957 "following": 1,
15958 "created_at": ` + referenceTimeStr + `,
15959 "suspended_at": ` + referenceTimeStr + `,
15960 "url": "u"
15961 },
15962 "access_tokens_url": "atu",
15963 "repositories_url": "ru",
15964 "html_url": "hu",
15965 "target_type": "tt",
15966 "single_file_name": "sfn",
15967 "repository_selection": "rs",
15968 "events": [
15969 "e"
15970 ],
15971 "single_file_paths": [
15972 "s"
15973 ],
15974 "permissions": {
15975 "actions": "a",
15976 "administration": "ad",
15977 "checks": "c",
15978 "contents": "co",
15979 "content_references": "cr",
15980 "deployments": "d",
15981 "environments": "e",
15982 "issues": "i",
15983 "metadata": "md",
15984 "members": "m",
15985 "organization_administration": "oa",
15986 "organization_hooks": "oh",
15987 "organization_plan": "op",
15988 "organization_pre_receive_hooks": "opr",
15989 "organization_projects": "op",
15990 "organization_secrets": "os",
15991 "organization_self_hosted_runners": "osh",
15992 "organization_user_blocking": "oub",
15993 "packages": "pkg",
15994 "pages": "pg",
15995 "pull_requests": "pr",
15996 "repository_hooks": "rh",
15997 "repository_projects": "rp",
15998 "repository_pre_receive_hooks": "rprh",
15999 "secrets": "s",
16000 "secret_scanning_alerts": "ssa",
16001 "security_events": "se",
16002 "single_file": "sf",
16003 "statuses": "s",
16004 "team_discussions": "td",
16005 "vulnerability_alerts": "va",
16006 "workflows": "w"
16007 },
16008 "created_at": ` + referenceTimeStr + `,
16009 "updated_at": ` + referenceTimeStr + `,
16010 "has_multiple_single_files": false,
16011 "suspended_by": {
16012 "login": "l",
16013 "id": 1,
16014 "avatar_url": "a",
16015 "gravatar_id": "g",
16016 "name": "n",
16017 "company": "c",
16018 "blog": "b",
16019 "location": "l",
16020 "email": "e",
16021 "hireable": true,
16022 "bio": "b",
16023 "twitter_username": "t",
16024 "public_repos": 1,
16025 "followers": 1,
16026 "following": 1,
16027 "created_at": ` + referenceTimeStr + `,
16028 "suspended_at": ` + referenceTimeStr + `,
16029 "url": "u"
16030 },
16031 "suspended_at": ` + referenceTimeStr + `
16032 }
16033 }`
16034
16035 testJSONMarshal(t, u, want)
16036 }
16037
16038 func TestPullRequestTargetEvent_Marshal(t *testing.T) {
16039 testJSONMarshal(t, &PullRequestTargetEvent{}, "{}")
16040
16041 u := &PullRequestTargetEvent{
16042 Action: String("a"),
16043 Assignee: &User{
16044 Login: String("l"),
16045 ID: Int64(1),
16046 NodeID: String("n"),
16047 URL: String("u"),
16048 ReposURL: String("r"),
16049 EventsURL: String("e"),
16050 AvatarURL: String("a"),
16051 },
16052 Number: Int(1),
16053 PullRequest: &PullRequest{ID: Int64(1)},
16054 Changes: &EditChange{
16055 Title: &EditTitle{
16056 From: String("TitleFrom"),
16057 },
16058 Body: &EditBody{
16059 From: String("BodyFrom"),
16060 },
16061 Base: &EditBase{
16062 Ref: &EditRef{
16063 From: String("BaseRefFrom"),
16064 },
16065 SHA: &EditSHA{
16066 From: String("BaseSHAFrom"),
16067 },
16068 },
16069 },
16070 RequestedReviewer: &User{
16071 Login: String("l"),
16072 ID: Int64(1),
16073 NodeID: String("n"),
16074 URL: String("u"),
16075 ReposURL: String("r"),
16076 EventsURL: String("e"),
16077 AvatarURL: String("a"),
16078 },
16079 RequestedTeam: &Team{ID: Int64(1)},
16080 Label: &Label{ID: Int64(1)},
16081 Before: String("before"),
16082 After: String("after"),
16083 Repo: &Repository{
16084 ID: Int64(1),
16085 URL: String("s"),
16086 Name: String("n"),
16087 },
16088 PerformedViaGithubApp: &App{
16089 ID: Int64(1),
16090 NodeID: String("n"),
16091 Slug: String("s"),
16092 Name: String("n"),
16093 Description: String("d"),
16094 ExternalURL: String("e"),
16095 HTMLURL: String("h"),
16096 },
16097 Organization: &Organization{
16098 BillingEmail: String("be"),
16099 Blog: String("b"),
16100 Company: String("c"),
16101 Email: String("e"),
16102 TwitterUsername: String("tu"),
16103 Location: String("loc"),
16104 Name: String("n"),
16105 Description: String("d"),
16106 IsVerified: Bool(true),
16107 HasOrganizationProjects: Bool(true),
16108 HasRepositoryProjects: Bool(true),
16109 DefaultRepoPermission: String("drp"),
16110 MembersCanCreateRepos: Bool(true),
16111 MembersCanCreateInternalRepos: Bool(true),
16112 MembersCanCreatePrivateRepos: Bool(true),
16113 MembersCanCreatePublicRepos: Bool(false),
16114 MembersAllowedRepositoryCreationType: String("marct"),
16115 MembersCanCreatePages: Bool(true),
16116 MembersCanCreatePublicPages: Bool(false),
16117 MembersCanCreatePrivatePages: Bool(true),
16118 },
16119 Sender: &User{
16120 Login: String("l"),
16121 ID: Int64(1),
16122 NodeID: String("n"),
16123 URL: String("u"),
16124 ReposURL: String("r"),
16125 EventsURL: String("e"),
16126 AvatarURL: String("a"),
16127 },
16128 Installation: &Installation{
16129 ID: Int64(1),
16130 NodeID: String("nid"),
16131 AppID: Int64(1),
16132 AppSlug: String("as"),
16133 TargetID: Int64(1),
16134 Account: &User{
16135 Login: String("l"),
16136 ID: Int64(1),
16137 URL: String("u"),
16138 AvatarURL: String("a"),
16139 GravatarID: String("g"),
16140 Name: String("n"),
16141 Company: String("c"),
16142 Blog: String("b"),
16143 Location: String("l"),
16144 Email: String("e"),
16145 Hireable: Bool(true),
16146 Bio: String("b"),
16147 TwitterUsername: String("t"),
16148 PublicRepos: Int(1),
16149 Followers: Int(1),
16150 Following: Int(1),
16151 CreatedAt: &Timestamp{referenceTime},
16152 SuspendedAt: &Timestamp{referenceTime},
16153 },
16154 AccessTokensURL: String("atu"),
16155 RepositoriesURL: String("ru"),
16156 HTMLURL: String("hu"),
16157 TargetType: String("tt"),
16158 SingleFileName: String("sfn"),
16159 RepositorySelection: String("rs"),
16160 Events: []string{"e"},
16161 SingleFilePaths: []string{"s"},
16162 Permissions: &InstallationPermissions{
16163 Actions: String("a"),
16164 Administration: String("ad"),
16165 Checks: String("c"),
16166 Contents: String("co"),
16167 ContentReferences: String("cr"),
16168 Deployments: String("d"),
16169 Environments: String("e"),
16170 Issues: String("i"),
16171 Metadata: String("md"),
16172 Members: String("m"),
16173 OrganizationAdministration: String("oa"),
16174 OrganizationHooks: String("oh"),
16175 OrganizationPlan: String("op"),
16176 OrganizationPreReceiveHooks: String("opr"),
16177 OrganizationProjects: String("op"),
16178 OrganizationSecrets: String("os"),
16179 OrganizationSelfHostedRunners: String("osh"),
16180 OrganizationUserBlocking: String("oub"),
16181 Packages: String("pkg"),
16182 Pages: String("pg"),
16183 PullRequests: String("pr"),
16184 RepositoryHooks: String("rh"),
16185 RepositoryProjects: String("rp"),
16186 RepositoryPreReceiveHooks: String("rprh"),
16187 Secrets: String("s"),
16188 SecretScanningAlerts: String("ssa"),
16189 SecurityEvents: String("se"),
16190 SingleFile: String("sf"),
16191 Statuses: String("s"),
16192 TeamDiscussions: String("td"),
16193 VulnerabilityAlerts: String("va"),
16194 Workflows: String("w"),
16195 },
16196 CreatedAt: &Timestamp{referenceTime},
16197 UpdatedAt: &Timestamp{referenceTime},
16198 HasMultipleSingleFiles: Bool(false),
16199 SuspendedBy: &User{
16200 Login: String("l"),
16201 ID: Int64(1),
16202 URL: String("u"),
16203 AvatarURL: String("a"),
16204 GravatarID: String("g"),
16205 Name: String("n"),
16206 Company: String("c"),
16207 Blog: String("b"),
16208 Location: String("l"),
16209 Email: String("e"),
16210 Hireable: Bool(true),
16211 Bio: String("b"),
16212 TwitterUsername: String("t"),
16213 PublicRepos: Int(1),
16214 Followers: Int(1),
16215 Following: Int(1),
16216 CreatedAt: &Timestamp{referenceTime},
16217 SuspendedAt: &Timestamp{referenceTime},
16218 },
16219 SuspendedAt: &Timestamp{referenceTime},
16220 },
16221 }
16222
16223 want := `{
16224 "action": "a",
16225 "assignee": {
16226 "login": "l",
16227 "id": 1,
16228 "node_id": "n",
16229 "avatar_url": "a",
16230 "url": "u",
16231 "events_url": "e",
16232 "repos_url": "r"
16233 },
16234 "number": 1,
16235 "pull_request": {
16236 "id": 1
16237 },
16238 "changes": {
16239 "title": {
16240 "from": "TitleFrom"
16241 },
16242 "body": {
16243 "from": "BodyFrom"
16244 },
16245 "base": {
16246 "ref": {
16247 "from": "BaseRefFrom"
16248 },
16249 "sha": {
16250 "from": "BaseSHAFrom"
16251 }
16252 }
16253 },
16254 "requested_reviewer": {
16255 "login": "l",
16256 "id": 1,
16257 "node_id": "n",
16258 "avatar_url": "a",
16259 "url": "u",
16260 "events_url": "e",
16261 "repos_url": "r"
16262 },
16263 "requested_team": {
16264 "id": 1
16265 },
16266 "label": {
16267 "id": 1
16268 },
16269 "before": "before",
16270 "after": "after",
16271 "repository": {
16272 "id": 1,
16273 "name": "n",
16274 "url": "s"
16275 },
16276 "performed_via_github_app": {
16277 "id": 1,
16278 "node_id": "n",
16279 "slug": "s",
16280 "name": "n",
16281 "description": "d",
16282 "external_url": "e",
16283 "html_url": "h"
16284 },
16285 "organization": {
16286 "name": "n",
16287 "company": "c",
16288 "blog": "b",
16289 "location": "loc",
16290 "email": "e",
16291 "twitter_username": "tu",
16292 "description": "d",
16293 "billing_email": "be",
16294 "is_verified": true,
16295 "has_organization_projects": true,
16296 "has_repository_projects": true,
16297 "default_repository_permission": "drp",
16298 "members_can_create_repositories": true,
16299 "members_can_create_public_repositories": false,
16300 "members_can_create_private_repositories": true,
16301 "members_can_create_internal_repositories": true,
16302 "members_allowed_repository_creation_type": "marct",
16303 "members_can_create_pages": true,
16304 "members_can_create_public_pages": false,
16305 "members_can_create_private_pages": true
16306 },
16307 "sender": {
16308 "login": "l",
16309 "id": 1,
16310 "node_id": "n",
16311 "avatar_url": "a",
16312 "url": "u",
16313 "events_url": "e",
16314 "repos_url": "r"
16315 },
16316 "installation": {
16317 "id": 1,
16318 "node_id": "nid",
16319 "app_id": 1,
16320 "app_slug": "as",
16321 "target_id": 1,
16322 "account": {
16323 "login": "l",
16324 "id": 1,
16325 "avatar_url": "a",
16326 "gravatar_id": "g",
16327 "name": "n",
16328 "company": "c",
16329 "blog": "b",
16330 "location": "l",
16331 "email": "e",
16332 "hireable": true,
16333 "bio": "b",
16334 "twitter_username": "t",
16335 "public_repos": 1,
16336 "followers": 1,
16337 "following": 1,
16338 "created_at": ` + referenceTimeStr + `,
16339 "suspended_at": ` + referenceTimeStr + `,
16340 "url": "u"
16341 },
16342 "access_tokens_url": "atu",
16343 "repositories_url": "ru",
16344 "html_url": "hu",
16345 "target_type": "tt",
16346 "single_file_name": "sfn",
16347 "repository_selection": "rs",
16348 "events": [
16349 "e"
16350 ],
16351 "single_file_paths": [
16352 "s"
16353 ],
16354 "permissions": {
16355 "actions": "a",
16356 "administration": "ad",
16357 "checks": "c",
16358 "contents": "co",
16359 "content_references": "cr",
16360 "deployments": "d",
16361 "environments": "e",
16362 "issues": "i",
16363 "metadata": "md",
16364 "members": "m",
16365 "organization_administration": "oa",
16366 "organization_hooks": "oh",
16367 "organization_plan": "op",
16368 "organization_pre_receive_hooks": "opr",
16369 "organization_projects": "op",
16370 "organization_secrets": "os",
16371 "organization_self_hosted_runners": "osh",
16372 "organization_user_blocking": "oub",
16373 "packages": "pkg",
16374 "pages": "pg",
16375 "pull_requests": "pr",
16376 "repository_hooks": "rh",
16377 "repository_projects": "rp",
16378 "repository_pre_receive_hooks": "rprh",
16379 "secrets": "s",
16380 "secret_scanning_alerts": "ssa",
16381 "security_events": "se",
16382 "single_file": "sf",
16383 "statuses": "s",
16384 "team_discussions": "td",
16385 "vulnerability_alerts": "va",
16386 "workflows": "w"
16387 },
16388 "created_at": ` + referenceTimeStr + `,
16389 "updated_at": ` + referenceTimeStr + `,
16390 "has_multiple_single_files": false,
16391 "suspended_by": {
16392 "login": "l",
16393 "id": 1,
16394 "avatar_url": "a",
16395 "gravatar_id": "g",
16396 "name": "n",
16397 "company": "c",
16398 "blog": "b",
16399 "location": "l",
16400 "email": "e",
16401 "hireable": true,
16402 "bio": "b",
16403 "twitter_username": "t",
16404 "public_repos": 1,
16405 "followers": 1,
16406 "following": 1,
16407 "created_at": ` + referenceTimeStr + `,
16408 "suspended_at": ` + referenceTimeStr + `,
16409 "url": "u"
16410 },
16411 "suspended_at": ` + referenceTimeStr + `
16412 }
16413 }`
16414
16415 testJSONMarshal(t, u, want)
16416 }
16417
16418 func TestRepositoryVulnerabilityAlertEvent_Marshal(t *testing.T) {
16419 testJSONMarshal(t, &RepositoryVulnerabilityAlertEvent{}, "{}")
16420
16421 u := &RepositoryVulnerabilityAlertEvent{
16422 Action: String("a"),
16423 Alert: &RepositoryVulnerabilityAlert{
16424 ID: Int64(1),
16425 AffectedRange: String("ar"),
16426 AffectedPackageName: String("apn"),
16427 ExternalReference: String("er"),
16428 ExternalIdentifier: String("ei"),
16429 FixedIn: String("fi"),
16430 Dismisser: &User{
16431 Login: String("l"),
16432 ID: Int64(1),
16433 NodeID: String("n"),
16434 URL: String("u"),
16435 ReposURL: String("r"),
16436 EventsURL: String("e"),
16437 AvatarURL: String("a"),
16438 },
16439 DismissReason: String("dr"),
16440 DismissedAt: &Timestamp{referenceTime},
16441 },
16442 Repository: &Repository{
16443 ID: Int64(1),
16444 URL: String("s"),
16445 Name: String("n"),
16446 },
16447 }
16448
16449 want := `{
16450 "action": "a",
16451 "alert": {
16452 "id": 1,
16453 "affected_range": "ar",
16454 "affected_package_name": "apn",
16455 "external_reference": "er",
16456 "external_identifier": "ei",
16457 "fixed_in": "fi",
16458 "dismisser": {
16459 "login": "l",
16460 "id": 1,
16461 "node_id": "n",
16462 "avatar_url": "a",
16463 "url": "u",
16464 "events_url": "e",
16465 "repos_url": "r"
16466 },
16467 "dismiss_reason": "dr",
16468 "dismissed_at": ` + referenceTimeStr + `
16469 },
16470 "repository": {
16471 "id": 1,
16472 "name": "n",
16473 "url": "s"
16474 }
16475 }`
16476
16477 testJSONMarshal(t, u, want)
16478 }
16479
16480 func TestSecretScanningAlertEvent_Marshal(t *testing.T) {
16481 testJSONMarshal(t, &SecretScanningAlertEvent{}, "{}")
16482
16483 u := &SecretScanningAlertEvent{
16484 Action: String("a"),
16485 Alert: &SecretScanningAlert{
16486 Number: Int(1),
16487 SecretType: String("t"),
16488 Resolution: String("r"),
16489 ResolvedBy: &User{
16490 Login: String("l"),
16491 ID: Int64(1),
16492 NodeID: String("n"),
16493 URL: String("u"),
16494 ReposURL: String("r"),
16495 EventsURL: String("e"),
16496 AvatarURL: String("a"),
16497 },
16498 ResolvedAt: &Timestamp{referenceTime},
16499 },
16500 Repo: &Repository{
16501 ID: Int64(1),
16502 URL: String("s"),
16503 Name: String("n"),
16504 },
16505 Organization: &Organization{
16506 BillingEmail: String("be"),
16507 Blog: String("b"),
16508 Company: String("c"),
16509 Email: String("e"),
16510 TwitterUsername: String("tu"),
16511 Location: String("loc"),
16512 Name: String("n"),
16513 Description: String("d"),
16514 IsVerified: Bool(true),
16515 HasOrganizationProjects: Bool(true),
16516 HasRepositoryProjects: Bool(true),
16517 DefaultRepoPermission: String("drp"),
16518 MembersCanCreateRepos: Bool(true),
16519 MembersCanCreateInternalRepos: Bool(true),
16520 MembersCanCreatePrivateRepos: Bool(true),
16521 MembersCanCreatePublicRepos: Bool(false),
16522 MembersAllowedRepositoryCreationType: String("marct"),
16523 MembersCanCreatePages: Bool(true),
16524 MembersCanCreatePublicPages: Bool(false),
16525 MembersCanCreatePrivatePages: Bool(true),
16526 },
16527 Enterprise: &Enterprise{
16528 ID: Int(1),
16529 Slug: String("s"),
16530 Name: String("n"),
16531 NodeID: String("nid"),
16532 AvatarURL: String("au"),
16533 Description: String("d"),
16534 WebsiteURL: String("wu"),
16535 HTMLURL: String("hu"),
16536 CreatedAt: &Timestamp{referenceTime},
16537 UpdatedAt: &Timestamp{referenceTime},
16538 },
16539 Sender: &User{
16540 Login: String("l"),
16541 ID: Int64(1),
16542 NodeID: String("n"),
16543 URL: String("u"),
16544 ReposURL: String("r"),
16545 EventsURL: String("e"),
16546 AvatarURL: String("a"),
16547 },
16548 Installation: &Installation{
16549 ID: Int64(1),
16550 NodeID: String("nid"),
16551 AppID: Int64(1),
16552 AppSlug: String("as"),
16553 TargetID: Int64(1),
16554 Account: &User{
16555 Login: String("l"),
16556 ID: Int64(1),
16557 URL: String("u"),
16558 AvatarURL: String("a"),
16559 GravatarID: String("g"),
16560 Name: String("n"),
16561 Company: String("c"),
16562 Blog: String("b"),
16563 Location: String("l"),
16564 Email: String("e"),
16565 Hireable: Bool(true),
16566 Bio: String("b"),
16567 TwitterUsername: String("t"),
16568 PublicRepos: Int(1),
16569 Followers: Int(1),
16570 Following: Int(1),
16571 CreatedAt: &Timestamp{referenceTime},
16572 SuspendedAt: &Timestamp{referenceTime},
16573 },
16574 AccessTokensURL: String("atu"),
16575 RepositoriesURL: String("ru"),
16576 HTMLURL: String("hu"),
16577 TargetType: String("tt"),
16578 SingleFileName: String("sfn"),
16579 RepositorySelection: String("rs"),
16580 Events: []string{"e"},
16581 SingleFilePaths: []string{"s"},
16582 Permissions: &InstallationPermissions{
16583 Actions: String("a"),
16584 Administration: String("ad"),
16585 Checks: String("c"),
16586 Contents: String("co"),
16587 ContentReferences: String("cr"),
16588 Deployments: String("d"),
16589 Environments: String("e"),
16590 Issues: String("i"),
16591 Metadata: String("md"),
16592 Members: String("m"),
16593 OrganizationAdministration: String("oa"),
16594 OrganizationHooks: String("oh"),
16595 OrganizationPlan: String("op"),
16596 OrganizationPreReceiveHooks: String("opr"),
16597 OrganizationProjects: String("op"),
16598 OrganizationSecrets: String("os"),
16599 OrganizationSelfHostedRunners: String("osh"),
16600 OrganizationUserBlocking: String("oub"),
16601 Packages: String("pkg"),
16602 Pages: String("pg"),
16603 PullRequests: String("pr"),
16604 RepositoryHooks: String("rh"),
16605 RepositoryProjects: String("rp"),
16606 RepositoryPreReceiveHooks: String("rprh"),
16607 Secrets: String("s"),
16608 SecretScanningAlerts: String("ssa"),
16609 SecurityEvents: String("se"),
16610 SingleFile: String("sf"),
16611 Statuses: String("s"),
16612 TeamDiscussions: String("td"),
16613 VulnerabilityAlerts: String("va"),
16614 Workflows: String("w"),
16615 },
16616 CreatedAt: &Timestamp{referenceTime},
16617 UpdatedAt: &Timestamp{referenceTime},
16618 HasMultipleSingleFiles: Bool(false),
16619 SuspendedBy: &User{
16620 Login: String("l"),
16621 ID: Int64(1),
16622 URL: String("u"),
16623 AvatarURL: String("a"),
16624 GravatarID: String("g"),
16625 Name: String("n"),
16626 Company: String("c"),
16627 Blog: String("b"),
16628 Location: String("l"),
16629 Email: String("e"),
16630 Hireable: Bool(true),
16631 Bio: String("b"),
16632 TwitterUsername: String("t"),
16633 PublicRepos: Int(1),
16634 Followers: Int(1),
16635 Following: Int(1),
16636 CreatedAt: &Timestamp{referenceTime},
16637 SuspendedAt: &Timestamp{referenceTime},
16638 },
16639 SuspendedAt: &Timestamp{referenceTime},
16640 },
16641 }
16642
16643 want := `{
16644 "action": "a",
16645 "alert": {
16646 "number": 1,
16647 "secret_type": "t",
16648 "resolution": "r",
16649 "resolved_by": {
16650 "login": "l",
16651 "id": 1,
16652 "node_id": "n",
16653 "avatar_url": "a",
16654 "url": "u",
16655 "events_url": "e",
16656 "repos_url": "r"
16657 },
16658 "resolved_at": ` + referenceTimeStr + `
16659 },
16660 "repository": {
16661 "id": 1,
16662 "name": "n",
16663 "url": "s"
16664 },
16665 "organization": {
16666 "name": "n",
16667 "company": "c",
16668 "blog": "b",
16669 "location": "loc",
16670 "email": "e",
16671 "twitter_username": "tu",
16672 "description": "d",
16673 "billing_email": "be",
16674 "is_verified": true,
16675 "has_organization_projects": true,
16676 "has_repository_projects": true,
16677 "default_repository_permission": "drp",
16678 "members_can_create_repositories": true,
16679 "members_can_create_public_repositories": false,
16680 "members_can_create_private_repositories": true,
16681 "members_can_create_internal_repositories": true,
16682 "members_allowed_repository_creation_type": "marct",
16683 "members_can_create_pages": true,
16684 "members_can_create_public_pages": false,
16685 "members_can_create_private_pages": true
16686 },
16687 "enterprise": {
16688 "id": 1,
16689 "slug": "s",
16690 "name": "n",
16691 "node_id": "nid",
16692 "avatar_url": "au",
16693 "description": "d",
16694 "website_url": "wu",
16695 "html_url": "hu",
16696 "created_at": ` + referenceTimeStr + `,
16697 "updated_at": ` + referenceTimeStr + `
16698 },
16699 "sender": {
16700 "login": "l",
16701 "id": 1,
16702 "node_id": "n",
16703 "avatar_url": "a",
16704 "url": "u",
16705 "events_url": "e",
16706 "repos_url": "r"
16707 },
16708 "installation": {
16709 "id": 1,
16710 "node_id": "nid",
16711 "app_id": 1,
16712 "app_slug": "as",
16713 "target_id": 1,
16714 "account": {
16715 "login": "l",
16716 "id": 1,
16717 "avatar_url": "a",
16718 "gravatar_id": "g",
16719 "name": "n",
16720 "company": "c",
16721 "blog": "b",
16722 "location": "l",
16723 "email": "e",
16724 "hireable": true,
16725 "bio": "b",
16726 "twitter_username": "t",
16727 "public_repos": 1,
16728 "followers": 1,
16729 "following": 1,
16730 "created_at": ` + referenceTimeStr + `,
16731 "suspended_at": ` + referenceTimeStr + `,
16732 "url": "u"
16733 },
16734 "access_tokens_url": "atu",
16735 "repositories_url": "ru",
16736 "html_url": "hu",
16737 "target_type": "tt",
16738 "single_file_name": "sfn",
16739 "repository_selection": "rs",
16740 "events": [
16741 "e"
16742 ],
16743 "single_file_paths": [
16744 "s"
16745 ],
16746 "permissions": {
16747 "actions": "a",
16748 "administration": "ad",
16749 "checks": "c",
16750 "contents": "co",
16751 "content_references": "cr",
16752 "deployments": "d",
16753 "environments": "e",
16754 "issues": "i",
16755 "metadata": "md",
16756 "members": "m",
16757 "organization_administration": "oa",
16758 "organization_hooks": "oh",
16759 "organization_plan": "op",
16760 "organization_pre_receive_hooks": "opr",
16761 "organization_projects": "op",
16762 "organization_secrets": "os",
16763 "organization_self_hosted_runners": "osh",
16764 "organization_user_blocking": "oub",
16765 "packages": "pkg",
16766 "pages": "pg",
16767 "pull_requests": "pr",
16768 "repository_hooks": "rh",
16769 "repository_projects": "rp",
16770 "repository_pre_receive_hooks": "rprh",
16771 "secrets": "s",
16772 "secret_scanning_alerts": "ssa",
16773 "security_events": "se",
16774 "single_file": "sf",
16775 "statuses": "s",
16776 "team_discussions": "td",
16777 "vulnerability_alerts": "va",
16778 "workflows": "w"
16779 },
16780 "created_at": ` + referenceTimeStr + `,
16781 "updated_at": ` + referenceTimeStr + `,
16782 "has_multiple_single_files": false,
16783 "suspended_by": {
16784 "login": "l",
16785 "id": 1,
16786 "avatar_url": "a",
16787 "gravatar_id": "g",
16788 "name": "n",
16789 "company": "c",
16790 "blog": "b",
16791 "location": "l",
16792 "email": "e",
16793 "hireable": true,
16794 "bio": "b",
16795 "twitter_username": "t",
16796 "public_repos": 1,
16797 "followers": 1,
16798 "following": 1,
16799 "created_at": ` + referenceTimeStr + `,
16800 "suspended_at": ` + referenceTimeStr + `,
16801 "url": "u"
16802 },
16803 "suspended_at": ` + referenceTimeStr + `
16804 }
16805 }`
16806
16807 testJSONMarshal(t, u, want)
16808 }
16809
16810 func TestSecurityAdvisoryEvent_Marshal(t *testing.T) {
16811 testJSONMarshal(t, &SecurityAdvisoryEvent{}, "{}")
16812 u := &SecurityAdvisoryEvent{
16813 Action: String("published"),
16814 SecurityAdvisory: &SecurityAdvisory{
16815 CVSS: &AdvisoryCVSS{
16816 Score: Float64(1.0),
16817 VectorString: String("vs"),
16818 },
16819 CWEs: []*AdvisoryCWEs{
16820 {
16821 CWEID: String("cweid"),
16822 Name: String("n"),
16823 },
16824 },
16825 GHSAID: String("GHSA-rf4j-j272-some"),
16826 Summary: String("Siuuuuuuuuu"),
16827 Description: String("desc"),
16828 Severity: String("moderate"),
16829 Identifiers: []*AdvisoryIdentifier{
16830 {
16831 Value: String("GHSA-rf4j-j272-some"),
16832 Type: String("GHSA"),
16833 },
16834 },
16835 References: []*AdvisoryReference{
16836 {
16837 URL: String("https://some-url"),
16838 },
16839 },
16840 PublishedAt: &Timestamp{referenceTime},
16841 UpdatedAt: &Timestamp{referenceTime},
16842 WithdrawnAt: nil,
16843 Vulnerabilities: []*AdvisoryVulnerability{
16844 {
16845 Package: &VulnerabilityPackage{
16846 Ecosystem: String("ucl"),
16847 Name: String("penaldo"),
16848 },
16849 Severity: String("moderate"),
16850 VulnerableVersionRange: String(">= 2.0.0, < 2.0.2"),
16851 FirstPatchedVersion: &FirstPatchedVersion{
16852 Identifier: String("2.0.2"),
16853 },
16854 },
16855 },
16856 },
16857 Enterprise: &Enterprise{
16858 ID: Int(1),
16859 Slug: String("s"),
16860 Name: String("n"),
16861 NodeID: String("nid"),
16862 AvatarURL: String("au"),
16863 Description: String("d"),
16864 WebsiteURL: String("wu"),
16865 HTMLURL: String("hu"),
16866 CreatedAt: &Timestamp{referenceTime},
16867 UpdatedAt: &Timestamp{referenceTime},
16868 },
16869 Installation: &Installation{
16870 ID: Int64(1),
16871 NodeID: String("nid"),
16872 AppID: Int64(1),
16873 AppSlug: String("as"),
16874 TargetID: Int64(1),
16875 Account: &User{
16876 Login: String("l"),
16877 ID: Int64(1),
16878 URL: String("u"),
16879 AvatarURL: String("a"),
16880 GravatarID: String("g"),
16881 Name: String("n"),
16882 Company: String("c"),
16883 Blog: String("b"),
16884 Location: String("l"),
16885 Email: String("e"),
16886 Hireable: Bool(true),
16887 Bio: String("b"),
16888 TwitterUsername: String("t"),
16889 PublicRepos: Int(1),
16890 Followers: Int(1),
16891 Following: Int(1),
16892 CreatedAt: &Timestamp{referenceTime},
16893 SuspendedAt: &Timestamp{referenceTime},
16894 },
16895 AccessTokensURL: String("atu"),
16896 RepositoriesURL: String("ru"),
16897 HTMLURL: String("hu"),
16898 TargetType: String("tt"),
16899 SingleFileName: String("sfn"),
16900 RepositorySelection: String("rs"),
16901 Events: []string{"e"},
16902 SingleFilePaths: []string{"s"},
16903 Permissions: &InstallationPermissions{
16904 Actions: String("a"),
16905 Administration: String("ad"),
16906 Checks: String("c"),
16907 Contents: String("co"),
16908 ContentReferences: String("cr"),
16909 Deployments: String("d"),
16910 Environments: String("e"),
16911 Issues: String("i"),
16912 Metadata: String("md"),
16913 Members: String("m"),
16914 OrganizationAdministration: String("oa"),
16915 OrganizationHooks: String("oh"),
16916 OrganizationPlan: String("op"),
16917 OrganizationPreReceiveHooks: String("opr"),
16918 OrganizationProjects: String("op"),
16919 OrganizationSecrets: String("os"),
16920 OrganizationSelfHostedRunners: String("osh"),
16921 OrganizationUserBlocking: String("oub"),
16922 Packages: String("pkg"),
16923 Pages: String("pg"),
16924 PullRequests: String("pr"),
16925 RepositoryHooks: String("rh"),
16926 RepositoryProjects: String("rp"),
16927 RepositoryPreReceiveHooks: String("rprh"),
16928 Secrets: String("s"),
16929 SecretScanningAlerts: String("ssa"),
16930 SecurityEvents: String("se"),
16931 SingleFile: String("sf"),
16932 Statuses: String("s"),
16933 TeamDiscussions: String("td"),
16934 VulnerabilityAlerts: String("va"),
16935 Workflows: String("w"),
16936 },
16937 CreatedAt: &Timestamp{referenceTime},
16938 UpdatedAt: &Timestamp{referenceTime},
16939 HasMultipleSingleFiles: Bool(false),
16940 SuspendedBy: &User{
16941 Login: String("l"),
16942 ID: Int64(1),
16943 URL: String("u"),
16944 AvatarURL: String("a"),
16945 GravatarID: String("g"),
16946 Name: String("n"),
16947 Company: String("c"),
16948 Blog: String("b"),
16949 Location: String("l"),
16950 Email: String("e"),
16951 Hireable: Bool(true),
16952 Bio: String("b"),
16953 TwitterUsername: String("t"),
16954 PublicRepos: Int(1),
16955 Followers: Int(1),
16956 Following: Int(1),
16957 CreatedAt: &Timestamp{referenceTime},
16958 SuspendedAt: &Timestamp{referenceTime},
16959 },
16960 SuspendedAt: &Timestamp{referenceTime},
16961 },
16962 Organization: &Organization{
16963 BillingEmail: String("be"),
16964 Blog: String("b"),
16965 Company: String("c"),
16966 Email: String("e"),
16967 TwitterUsername: String("tu"),
16968 Location: String("loc"),
16969 Name: String("n"),
16970 Description: String("d"),
16971 IsVerified: Bool(true),
16972 HasOrganizationProjects: Bool(true),
16973 HasRepositoryProjects: Bool(true),
16974 DefaultRepoPermission: String("drp"),
16975 MembersCanCreateRepos: Bool(true),
16976 MembersCanCreateInternalRepos: Bool(true),
16977 MembersCanCreatePrivateRepos: Bool(true),
16978 MembersCanCreatePublicRepos: Bool(false),
16979 MembersAllowedRepositoryCreationType: String("marct"),
16980 MembersCanCreatePages: Bool(true),
16981 MembersCanCreatePublicPages: Bool(false),
16982 MembersCanCreatePrivatePages: Bool(true),
16983 },
16984 Repository: &Repository{
16985 ID: Int64(1),
16986 URL: String("s"),
16987 Name: String("n"),
16988 },
16989 Sender: &User{
16990 Login: String("l"),
16991 ID: Int64(1),
16992 NodeID: String("n"),
16993 URL: String("u"),
16994 ReposURL: String("r"),
16995 EventsURL: String("e"),
16996 AvatarURL: String("a"),
16997 },
16998 }
16999
17000 want := `{
17001 "action": "published",
17002 "security_advisory": {
17003 "ghsa_id": "GHSA-rf4j-j272-some",
17004 "summary": "Siuuuuuuuuu",
17005 "cvss": {
17006 "score": 1.0,
17007 "vector_string": "vs"
17008 },
17009 "cwes": [
17010 {
17011 "cwe_id": "cweid",
17012 "name": "n"
17013 }
17014 ],
17015 "description": "desc",
17016 "severity": "moderate",
17017 "identifiers": [
17018 {
17019 "value": "GHSA-rf4j-j272-some",
17020 "type": "GHSA"
17021 }
17022 ],
17023 "references": [
17024 {
17025 "url": "https://some-url"
17026 }
17027 ],
17028 "published_at": ` + referenceTimeStr + `,
17029 "updated_at": ` + referenceTimeStr + `,
17030 "withdrawn_at": null,
17031 "vulnerabilities": [
17032 {
17033 "package": {
17034 "ecosystem": "ucl",
17035 "name": "penaldo"
17036 },
17037 "severity": "moderate",
17038 "vulnerable_version_range": ">= 2.0.0, < 2.0.2",
17039 "first_patched_version": {
17040 "identifier": "2.0.2"
17041 }
17042 }
17043 ]
17044 },
17045 "enterprise": {
17046 "id": 1,
17047 "slug": "s",
17048 "name": "n",
17049 "node_id": "nid",
17050 "avatar_url": "au",
17051 "description": "d",
17052 "website_url": "wu",
17053 "html_url": "hu",
17054 "created_at": ` + referenceTimeStr + `,
17055 "updated_at": ` + referenceTimeStr + `
17056 },
17057 "installation": {
17058 "id": 1,
17059 "node_id": "nid",
17060 "app_id": 1,
17061 "app_slug": "as",
17062 "target_id": 1,
17063 "account": {
17064 "login": "l",
17065 "id": 1,
17066 "avatar_url": "a",
17067 "gravatar_id": "g",
17068 "name": "n",
17069 "company": "c",
17070 "blog": "b",
17071 "location": "l",
17072 "email": "e",
17073 "hireable": true,
17074 "bio": "b",
17075 "twitter_username": "t",
17076 "public_repos": 1,
17077 "followers": 1,
17078 "following": 1,
17079 "created_at": ` + referenceTimeStr + `,
17080 "suspended_at": ` + referenceTimeStr + `,
17081 "url": "u"
17082 },
17083 "access_tokens_url": "atu",
17084 "repositories_url": "ru",
17085 "html_url": "hu",
17086 "target_type": "tt",
17087 "single_file_name": "sfn",
17088 "repository_selection": "rs",
17089 "events": [
17090 "e"
17091 ],
17092 "single_file_paths": [
17093 "s"
17094 ],
17095 "permissions": {
17096 "actions": "a",
17097 "administration": "ad",
17098 "checks": "c",
17099 "contents": "co",
17100 "content_references": "cr",
17101 "deployments": "d",
17102 "environments": "e",
17103 "issues": "i",
17104 "metadata": "md",
17105 "members": "m",
17106 "organization_administration": "oa",
17107 "organization_hooks": "oh",
17108 "organization_plan": "op",
17109 "organization_pre_receive_hooks": "opr",
17110 "organization_projects": "op",
17111 "organization_secrets": "os",
17112 "organization_self_hosted_runners": "osh",
17113 "organization_user_blocking": "oub",
17114 "packages": "pkg",
17115 "pages": "pg",
17116 "pull_requests": "pr",
17117 "repository_hooks": "rh",
17118 "repository_projects": "rp",
17119 "repository_pre_receive_hooks": "rprh",
17120 "secrets": "s",
17121 "secret_scanning_alerts": "ssa",
17122 "security_events": "se",
17123 "single_file": "sf",
17124 "statuses": "s",
17125 "team_discussions": "td",
17126 "vulnerability_alerts": "va",
17127 "workflows": "w"
17128 },
17129 "created_at": ` + referenceTimeStr + `,
17130 "updated_at": ` + referenceTimeStr + `,
17131 "has_multiple_single_files": false,
17132 "suspended_by": {
17133 "login": "l",
17134 "id": 1,
17135 "avatar_url": "a",
17136 "gravatar_id": "g",
17137 "name": "n",
17138 "company": "c",
17139 "blog": "b",
17140 "location": "l",
17141 "email": "e",
17142 "hireable": true,
17143 "bio": "b",
17144 "twitter_username": "t",
17145 "public_repos": 1,
17146 "followers": 1,
17147 "following": 1,
17148 "created_at": ` + referenceTimeStr + `,
17149 "suspended_at": ` + referenceTimeStr + `,
17150 "url": "u"
17151 },
17152 "suspended_at": ` + referenceTimeStr + `
17153 },
17154 "organization": {
17155 "name": "n",
17156 "company": "c",
17157 "blog": "b",
17158 "location": "loc",
17159 "email": "e",
17160 "twitter_username": "tu",
17161 "description": "d",
17162 "billing_email": "be",
17163 "is_verified": true,
17164 "has_organization_projects": true,
17165 "has_repository_projects": true,
17166 "default_repository_permission": "drp",
17167 "members_can_create_repositories": true,
17168 "members_can_create_public_repositories": false,
17169 "members_can_create_private_repositories": true,
17170 "members_can_create_internal_repositories": true,
17171 "members_allowed_repository_creation_type": "marct",
17172 "members_can_create_pages": true,
17173 "members_can_create_public_pages": false,
17174 "members_can_create_private_pages": true
17175 },
17176 "repository": {
17177 "id": 1,
17178 "url": "s",
17179 "name": "n"
17180 },
17181 "sender": {
17182 "login": "l",
17183 "id": 1,
17184 "node_id": "n",
17185 "avatar_url": "a",
17186 "url": "u",
17187 "events_url": "e",
17188 "repos_url": "r"
17189 }
17190 }`
17191
17192 testJSONMarshal(t, u, want)
17193 }
17194
17195 func TestSecurityAndAnalysisEvent_Marshal(t *testing.T) {
17196 testJSONMarshal(t, &SecurityAndAnalysisEvent{}, "{}")
17197
17198 u := &SecurityAndAnalysisEvent{
17199 Changes: &SecurityAndAnalysisChange{
17200 From: &SecurityAndAnalysisChangeFrom{
17201 SecurityAndAnalysis: &SecurityAndAnalysis{
17202 AdvancedSecurity: &AdvancedSecurity{
17203 Status: String("enabled"),
17204 },
17205 SecretScanning: &SecretScanning{
17206 Status: String("enabled"),
17207 },
17208 SecretScanningPushProtection: &SecretScanningPushProtection{
17209 Status: String("enabled"),
17210 },
17211 DependabotSecurityUpdates: &DependabotSecurityUpdates{
17212 Status: String("enabled"),
17213 },
17214 },
17215 },
17216 },
17217 Enterprise: &Enterprise{
17218 ID: Int(1),
17219 Slug: String("s"),
17220 Name: String("n"),
17221 NodeID: String("nid"),
17222 AvatarURL: String("au"),
17223 Description: String("d"),
17224 WebsiteURL: String("wu"),
17225 HTMLURL: String("hu"),
17226 CreatedAt: &Timestamp{referenceTime},
17227 UpdatedAt: &Timestamp{referenceTime},
17228 },
17229 Installation: &Installation{
17230 ID: Int64(1),
17231 NodeID: String("nid"),
17232 AppID: Int64(1),
17233 AppSlug: String("as"),
17234 TargetID: Int64(1),
17235 Account: &User{
17236 Login: String("l"),
17237 ID: Int64(1),
17238 URL: String("u"),
17239 AvatarURL: String("a"),
17240 GravatarID: String("g"),
17241 Name: String("n"),
17242 Company: String("c"),
17243 Blog: String("b"),
17244 Location: String("l"),
17245 Email: String("e"),
17246 Hireable: Bool(true),
17247 Bio: String("b"),
17248 TwitterUsername: String("t"),
17249 PublicRepos: Int(1),
17250 Followers: Int(1),
17251 Following: Int(1),
17252 CreatedAt: &Timestamp{referenceTime},
17253 SuspendedAt: &Timestamp{referenceTime},
17254 },
17255 AccessTokensURL: String("atu"),
17256 RepositoriesURL: String("ru"),
17257 HTMLURL: String("hu"),
17258 TargetType: String("tt"),
17259 SingleFileName: String("sfn"),
17260 RepositorySelection: String("rs"),
17261 Events: []string{"e"},
17262 SingleFilePaths: []string{"s"},
17263 Permissions: &InstallationPermissions{
17264 Actions: String("a"),
17265 Administration: String("ad"),
17266 Checks: String("c"),
17267 Contents: String("co"),
17268 ContentReferences: String("cr"),
17269 Deployments: String("d"),
17270 Environments: String("e"),
17271 Issues: String("i"),
17272 Metadata: String("md"),
17273 Members: String("m"),
17274 OrganizationAdministration: String("oa"),
17275 OrganizationHooks: String("oh"),
17276 OrganizationPlan: String("op"),
17277 OrganizationPreReceiveHooks: String("opr"),
17278 OrganizationProjects: String("op"),
17279 OrganizationSecrets: String("os"),
17280 OrganizationSelfHostedRunners: String("osh"),
17281 OrganizationUserBlocking: String("oub"),
17282 Packages: String("pkg"),
17283 Pages: String("pg"),
17284 PullRequests: String("pr"),
17285 RepositoryHooks: String("rh"),
17286 RepositoryProjects: String("rp"),
17287 RepositoryPreReceiveHooks: String("rprh"),
17288 Secrets: String("s"),
17289 SecretScanningAlerts: String("ssa"),
17290 SecurityEvents: String("se"),
17291 SingleFile: String("sf"),
17292 Statuses: String("s"),
17293 TeamDiscussions: String("td"),
17294 VulnerabilityAlerts: String("va"),
17295 Workflows: String("w"),
17296 },
17297 CreatedAt: &Timestamp{referenceTime},
17298 UpdatedAt: &Timestamp{referenceTime},
17299 HasMultipleSingleFiles: Bool(false),
17300 SuspendedBy: &User{
17301 Login: String("l"),
17302 ID: Int64(1),
17303 URL: String("u"),
17304 AvatarURL: String("a"),
17305 GravatarID: String("g"),
17306 Name: String("n"),
17307 Company: String("c"),
17308 Blog: String("b"),
17309 Location: String("l"),
17310 Email: String("e"),
17311 Hireable: Bool(true),
17312 Bio: String("b"),
17313 TwitterUsername: String("t"),
17314 PublicRepos: Int(1),
17315 Followers: Int(1),
17316 Following: Int(1),
17317 CreatedAt: &Timestamp{referenceTime},
17318 SuspendedAt: &Timestamp{referenceTime},
17319 },
17320 SuspendedAt: &Timestamp{referenceTime},
17321 },
17322 Organization: &Organization{
17323 BillingEmail: String("be"),
17324 Blog: String("b"),
17325 Company: String("c"),
17326 Email: String("e"),
17327 TwitterUsername: String("tu"),
17328 Location: String("loc"),
17329 Name: String("n"),
17330 Description: String("d"),
17331 IsVerified: Bool(true),
17332 HasOrganizationProjects: Bool(true),
17333 HasRepositoryProjects: Bool(true),
17334 DefaultRepoPermission: String("drp"),
17335 MembersCanCreateRepos: Bool(true),
17336 MembersCanCreateInternalRepos: Bool(true),
17337 MembersCanCreatePrivateRepos: Bool(true),
17338 MembersCanCreatePublicRepos: Bool(false),
17339 MembersAllowedRepositoryCreationType: String("marct"),
17340 MembersCanCreatePages: Bool(true),
17341 MembersCanCreatePublicPages: Bool(false),
17342 MembersCanCreatePrivatePages: Bool(true),
17343 },
17344 Repository: &Repository{
17345 ID: Int64(1),
17346 URL: String("s"),
17347 Name: String("n"),
17348 },
17349 Sender: &User{
17350 Login: String("l"),
17351 ID: Int64(1),
17352 NodeID: String("n"),
17353 URL: String("u"),
17354 ReposURL: String("r"),
17355 EventsURL: String("e"),
17356 AvatarURL: String("a"),
17357 },
17358 }
17359
17360 want := `{
17361 "changes": {
17362 "from": {
17363 "security_and_analysis": {
17364 "advanced_security": {
17365 "status": "enabled"
17366 },
17367 "secret_scanning": {
17368 "status": "enabled"
17369 },
17370 "secret_scanning_push_protection": {
17371 "status": "enabled"
17372 },
17373 "dependabot_security_updates": {
17374 "status": "enabled"
17375 }
17376 }
17377 }
17378 },
17379 "enterprise": {
17380 "id": 1,
17381 "slug": "s",
17382 "name": "n",
17383 "node_id": "nid",
17384 "avatar_url": "au",
17385 "description": "d",
17386 "website_url": "wu",
17387 "html_url": "hu",
17388 "created_at": ` + referenceTimeStr + `,
17389 "updated_at": ` + referenceTimeStr + `
17390 },
17391 "installation": {
17392 "id": 1,
17393 "node_id": "nid",
17394 "app_id": 1,
17395 "app_slug": "as",
17396 "target_id": 1,
17397 "account": {
17398 "login": "l",
17399 "id": 1,
17400 "avatar_url": "a",
17401 "gravatar_id": "g",
17402 "name": "n",
17403 "company": "c",
17404 "blog": "b",
17405 "location": "l",
17406 "email": "e",
17407 "hireable": true,
17408 "bio": "b",
17409 "twitter_username": "t",
17410 "public_repos": 1,
17411 "followers": 1,
17412 "following": 1,
17413 "created_at": ` + referenceTimeStr + `,
17414 "suspended_at": ` + referenceTimeStr + `,
17415 "url": "u"
17416 },
17417 "access_tokens_url": "atu",
17418 "repositories_url": "ru",
17419 "html_url": "hu",
17420 "target_type": "tt",
17421 "single_file_name": "sfn",
17422 "repository_selection": "rs",
17423 "events": [
17424 "e"
17425 ],
17426 "single_file_paths": [
17427 "s"
17428 ],
17429 "permissions": {
17430 "actions": "a",
17431 "administration": "ad",
17432 "checks": "c",
17433 "contents": "co",
17434 "content_references": "cr",
17435 "deployments": "d",
17436 "environments": "e",
17437 "issues": "i",
17438 "metadata": "md",
17439 "members": "m",
17440 "organization_administration": "oa",
17441 "organization_hooks": "oh",
17442 "organization_plan": "op",
17443 "organization_pre_receive_hooks": "opr",
17444 "organization_projects": "op",
17445 "organization_secrets": "os",
17446 "organization_self_hosted_runners": "osh",
17447 "organization_user_blocking": "oub",
17448 "packages": "pkg",
17449 "pages": "pg",
17450 "pull_requests": "pr",
17451 "repository_hooks": "rh",
17452 "repository_projects": "rp",
17453 "repository_pre_receive_hooks": "rprh",
17454 "secrets": "s",
17455 "secret_scanning_alerts": "ssa",
17456 "security_events": "se",
17457 "single_file": "sf",
17458 "statuses": "s",
17459 "team_discussions": "td",
17460 "vulnerability_alerts": "va",
17461 "workflows": "w"
17462 },
17463 "created_at": ` + referenceTimeStr + `,
17464 "updated_at": ` + referenceTimeStr + `,
17465 "has_multiple_single_files": false,
17466 "suspended_by": {
17467 "login": "l",
17468 "id": 1,
17469 "avatar_url": "a",
17470 "gravatar_id": "g",
17471 "name": "n",
17472 "company": "c",
17473 "blog": "b",
17474 "location": "l",
17475 "email": "e",
17476 "hireable": true,
17477 "bio": "b",
17478 "twitter_username": "t",
17479 "public_repos": 1,
17480 "followers": 1,
17481 "following": 1,
17482 "created_at": ` + referenceTimeStr + `,
17483 "suspended_at": ` + referenceTimeStr + `,
17484 "url": "u"
17485 },
17486 "suspended_at": ` + referenceTimeStr + `
17487 },
17488 "organization": {
17489 "name": "n",
17490 "company": "c",
17491 "blog": "b",
17492 "location": "loc",
17493 "email": "e",
17494 "twitter_username": "tu",
17495 "description": "d",
17496 "billing_email": "be",
17497 "is_verified": true,
17498 "has_organization_projects": true,
17499 "has_repository_projects": true,
17500 "default_repository_permission": "drp",
17501 "members_can_create_repositories": true,
17502 "members_can_create_public_repositories": false,
17503 "members_can_create_private_repositories": true,
17504 "members_can_create_internal_repositories": true,
17505 "members_allowed_repository_creation_type": "marct",
17506 "members_can_create_pages": true,
17507 "members_can_create_public_pages": false,
17508 "members_can_create_private_pages": true
17509 },
17510 "repository": {
17511 "id": 1,
17512 "url": "s",
17513 "name": "n"
17514 },
17515 "sender": {
17516 "login": "l",
17517 "id": 1,
17518 "node_id": "n",
17519 "avatar_url": "a",
17520 "url": "u",
17521 "events_url": "e",
17522 "repos_url": "r"
17523 },
17524 "target_type": "running"
17525 }`
17526
17527 testJSONMarshal(t, u, want)
17528 }
17529
17530 func TestCodeScanningAlertEvent_Marshal(t *testing.T) {
17531 testJSONMarshal(t, &CodeScanningAlertEvent{}, "{}")
17532
17533 u := &CodeScanningAlertEvent{
17534 Action: String("reopened"),
17535 Alert: &Alert{
17536 Number: Int(10),
17537 Rule: &Rule{
17538 ID: String("Style/FrozenStringLiteralComment"),
17539 Severity: String("note"),
17540 Description: String("desc"),
17541 FullDescription: String("full desc"),
17542 Tags: []string{"style"},
17543 Help: String("help"),
17544 },
17545 Tool: &Tool{
17546 Name: String("Rubocop"),
17547 Version: nil,
17548 },
17549 CreatedAt: &Timestamp{referenceTime},
17550 UpdatedAt: &Timestamp{referenceTime},
17551 FixedAt: nil,
17552 State: String("open"),
17553 URL: String("a"),
17554 HTMLURL: String("a"),
17555 Instances: []*MostRecentInstance{
17556 {
17557 Ref: String("refs/heads/main"),
17558 AnalysisKey: String(".github/workflows/workflow.yml:upload"),
17559 Environment: String("{}"),
17560 State: String("open"),
17561 },
17562 },
17563 DismissedBy: nil,
17564 DismissedAt: nil,
17565 DismissedReason: nil,
17566 },
17567 Ref: String("refs/heads/main"),
17568 CommitOID: String("d6e4c75c141dbacecc279b721b8bsomeSHA"),
17569 Repo: &Repository{
17570 ID: Int64(1234234535),
17571 NodeID: String("MDEwOlJlcG9zaXRvcnkxODY4NT=="),
17572 Owner: &User{
17573 Login: String("Codertocat"),
17574 ID: Int64(21031067),
17575 NodeID: String("MDQ6VXNlcjIxMDMxMDY3"),
17576 AvatarURL: String("a"),
17577 GravatarID: String(""),
17578 URL: String("a"),
17579 HTMLURL: String("a"),
17580 Type: String("User"),
17581 SiteAdmin: Bool(false),
17582 FollowersURL: String("a"),
17583 FollowingURL: String("a"),
17584 EventsURL: String("a"),
17585 GistsURL: String("a"),
17586 OrganizationsURL: String("a"),
17587 ReceivedEventsURL: String("a"),
17588 ReposURL: String("a"),
17589 StarredURL: String("a"),
17590 SubscriptionsURL: String("a"),
17591 },
17592 HTMLURL: String("a"),
17593 Name: String("Hello-World"),
17594 FullName: String("Codertocat/Hello-World"),
17595 Description: nil,
17596 Fork: Bool(false),
17597 Homepage: nil,
17598 DefaultBranch: String("main"),
17599 CreatedAt: &Timestamp{referenceTime},
17600 PushedAt: &Timestamp{referenceTime},
17601 UpdatedAt: &Timestamp{referenceTime},
17602 CloneURL: String("a"),
17603 GitURL: String("a"),
17604 MirrorURL: nil,
17605 SSHURL: String("a"),
17606 SVNURL: String("a"),
17607 Language: nil,
17608 ForksCount: Int(0),
17609 OpenIssuesCount: Int(2),
17610 OpenIssues: Int(2),
17611 StargazersCount: Int(0),
17612 WatchersCount: Int(0),
17613 Watchers: Int(0),
17614 Size: Int(0),
17615 Archived: Bool(false),
17616 Disabled: Bool(false),
17617 License: nil,
17618 Private: Bool(false),
17619 HasIssues: Bool(true),
17620 HasWiki: Bool(true),
17621 HasPages: Bool(true),
17622 HasProjects: Bool(true),
17623 HasDownloads: Bool(true),
17624 URL: String("a"),
17625 ArchiveURL: String("a"),
17626 AssigneesURL: String("a"),
17627 BlobsURL: String("a"),
17628 BranchesURL: String("a"),
17629 CollaboratorsURL: String("a"),
17630 CommentsURL: String("a"),
17631 CommitsURL: String("a"),
17632 CompareURL: String("a"),
17633 ContentsURL: String("a"),
17634 ContributorsURL: String("a"),
17635 DeploymentsURL: String("a"),
17636 DownloadsURL: String("a"),
17637 EventsURL: String("a"),
17638 ForksURL: String("a"),
17639 GitCommitsURL: String("a"),
17640 GitRefsURL: String("a"),
17641 GitTagsURL: String("a"),
17642 HooksURL: String("a"),
17643 IssueCommentURL: String("a"),
17644 IssueEventsURL: String("a"),
17645 IssuesURL: String("a"),
17646 KeysURL: String("a"),
17647 LabelsURL: String("a"),
17648 LanguagesURL: String("a"),
17649 MergesURL: String("a"),
17650 MilestonesURL: String("a"),
17651 NotificationsURL: String("a"),
17652 PullsURL: String("a"),
17653 ReleasesURL: String("a"),
17654 StargazersURL: String("a"),
17655 StatusesURL: String("a"),
17656 SubscribersURL: String("a"),
17657 SubscriptionURL: String("a"),
17658 TagsURL: String("a"),
17659 TreesURL: String("a"),
17660 TeamsURL: String("a"),
17661 },
17662 Org: &Organization{
17663 Login: String("Octocoders"),
17664 ID: Int64(6),
17665 NodeID: String("MDEyOk9yZ2FuaXphdGlvbjY="),
17666 AvatarURL: String("a"),
17667 Description: String(""),
17668 URL: String("a"),
17669 EventsURL: String("a"),
17670 HooksURL: String("a"),
17671 IssuesURL: String("a"),
17672 MembersURL: String("a"),
17673 PublicMembersURL: String("a"),
17674 ReposURL: String("a"),
17675 },
17676 Sender: &User{
17677 Login: String("github"),
17678 ID: Int64(9919),
17679 NodeID: String("MDEyOk9yZ2FuaXphdGlvbjk5MTk="),
17680 AvatarURL: String("a"),
17681 HTMLURL: String("a"),
17682 GravatarID: String(""),
17683 Type: String("Organization"),
17684 SiteAdmin: Bool(false),
17685 URL: String("a"),
17686 EventsURL: String("a"),
17687 FollowingURL: String("a"),
17688 FollowersURL: String("a"),
17689 GistsURL: String("a"),
17690 OrganizationsURL: String("a"),
17691 ReceivedEventsURL: String("a"),
17692 ReposURL: String("a"),
17693 StarredURL: String("a"),
17694 SubscriptionsURL: String("a"),
17695 },
17696 }
17697
17698 want := `{
17699 "action": "reopened",
17700 "alert": {
17701 "number": 10,
17702 "created_at": ` + referenceTimeStr + `,
17703 "updated_at": ` + referenceTimeStr + `,
17704 "url": "a",
17705 "html_url": "a",
17706 "instances": [
17707 {
17708 "ref": "refs/heads/main",
17709 "analysis_key": ".github/workflows/workflow.yml:upload",
17710 "environment": "{}",
17711 "state": "open"
17712 }
17713 ],
17714 "state": "open",
17715 "fixed_at": null,
17716 "dismissed_by": null,
17717 "dismissed_at": null,
17718 "dismissed_reason": null,
17719 "rule": {
17720 "id": "Style/FrozenStringLiteralComment",
17721 "severity": "note",
17722 "description": "desc",
17723 "full_description": "full desc",
17724 "tags": [
17725 "style"
17726 ],
17727 "help": "help"
17728 },
17729 "tool": {
17730 "name": "Rubocop",
17731 "version": null
17732 }
17733 },
17734 "ref": "refs/heads/main",
17735 "commit_oid": "d6e4c75c141dbacecc279b721b8bsomeSHA",
17736 "repository": {
17737 "id": 1234234535,
17738 "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NT==",
17739 "name": "Hello-World",
17740 "full_name": "Codertocat/Hello-World",
17741 "private": false,
17742 "owner": {
17743 "login": "Codertocat",
17744 "id": 21031067,
17745 "node_id": "MDQ6VXNlcjIxMDMxMDY3",
17746 "avatar_url": "a",
17747 "gravatar_id": "",
17748 "url": "a",
17749 "html_url": "a",
17750 "followers_url": "a",
17751 "following_url": "a",
17752 "gists_url": "a",
17753 "starred_url": "a",
17754 "subscriptions_url": "a",
17755 "organizations_url": "a",
17756 "repos_url": "a",
17757 "events_url": "a",
17758 "received_events_url": "a",
17759 "type": "User",
17760 "site_admin": false
17761 },
17762 "html_url": "a",
17763 "description": null,
17764 "fork": false,
17765 "url": "a",
17766 "forks_url": "a",
17767 "keys_url": "a",
17768 "collaborators_url": "a",
17769 "teams_url": "a",
17770 "hooks_url": "a",
17771 "issue_events_url": "a",
17772 "events_url": "a",
17773 "assignees_url": "a",
17774 "branches_url": "a",
17775 "tags_url": "a",
17776 "blobs_url": "a",
17777 "git_tags_url": "a",
17778 "git_refs_url": "a",
17779 "trees_url": "a",
17780 "statuses_url": "a",
17781 "languages_url": "a",
17782 "stargazers_url": "a",
17783 "contributors_url": "a",
17784 "subscribers_url": "a",
17785 "subscription_url": "a",
17786 "commits_url": "a",
17787 "git_commits_url": "a",
17788 "comments_url": "a",
17789 "issue_comment_url": "a",
17790 "contents_url": "a",
17791 "compare_url": "a",
17792 "merges_url": "a",
17793 "archive_url": "a",
17794 "downloads_url": "a",
17795 "issues_url": "a",
17796 "pulls_url": "a",
17797 "milestones_url": "a",
17798 "notifications_url": "a",
17799 "labels_url": "a",
17800 "releases_url": "a",
17801 "deployments_url": "a",
17802 "created_at": ` + referenceTimeStr + `,
17803 "updated_at": ` + referenceTimeStr + `,
17804 "pushed_at": ` + referenceTimeStr + `,
17805 "git_url": "a",
17806 "ssh_url": "a",
17807 "clone_url": "a",
17808 "svn_url": "a",
17809 "homepage": null,
17810 "size": 0,
17811 "stargazers_count": 0,
17812 "watchers_count": 0,
17813 "language": null,
17814 "has_issues": true,
17815 "has_projects": true,
17816 "has_downloads": true,
17817 "has_wiki": true,
17818 "has_pages": true,
17819 "forks_count": 0,
17820 "mirror_url": null,
17821 "archived": false,
17822 "disabled": false,
17823 "open_issues_count": 2,
17824 "license": null,
17825 "forks": 0,
17826 "open_issues": 2,
17827 "watchers": 0,
17828 "default_branch": "main"
17829 },
17830 "organization": {
17831 "login": "Octocoders",
17832 "id": 6,
17833 "node_id": "MDEyOk9yZ2FuaXphdGlvbjY=",
17834 "url": "a",
17835 "repos_url": "a",
17836 "events_url": "a",
17837 "hooks_url": "a",
17838 "issues_url": "a",
17839 "members_url": "a",
17840 "public_members_url": "a",
17841 "avatar_url": "a",
17842 "description": ""
17843 },
17844 "sender": {
17845 "login": "github",
17846 "id": 9919,
17847 "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=",
17848 "avatar_url": "a",
17849 "gravatar_id": "",
17850 "url": "a",
17851 "html_url": "a",
17852 "followers_url": "a",
17853 "following_url": "a",
17854 "gists_url": "a",
17855 "starred_url": "a",
17856 "subscriptions_url": "a",
17857 "organizations_url": "a",
17858 "repos_url": "a",
17859 "events_url": "a",
17860 "received_events_url": "a",
17861 "type": "Organization",
17862 "site_admin": false
17863 }
17864 }`
17865
17866 testJSONMarshal(t, u, want)
17867 }