github.com/google/go-github/v66@v66.0.0/github/event_types_test.go (about) 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 t.Parallel() 15 testJSONMarshal(t, &EditChange{}, "{}") 16 17 u := &EditChange{ 18 Title: &EditTitle{ 19 From: String("TitleFrom"), 20 }, 21 Body: nil, 22 Base: nil, 23 } 24 25 want := `{ 26 "title": { 27 "from": "TitleFrom" 28 } 29 }` 30 31 testJSONMarshal(t, u, want) 32 } 33 34 func TestEditChange_Marshal_BodyChange(t *testing.T) { 35 t.Parallel() 36 testJSONMarshal(t, &EditChange{}, "{}") 37 38 u := &EditChange{ 39 Title: nil, 40 Body: &EditBody{ 41 From: String("BodyFrom"), 42 }, 43 Base: nil, 44 } 45 46 want := `{ 47 "body": { 48 "from": "BodyFrom" 49 } 50 }` 51 52 testJSONMarshal(t, u, want) 53 } 54 55 func TestEditChange_Marshal_BaseChange(t *testing.T) { 56 t.Parallel() 57 testJSONMarshal(t, &EditChange{}, "{}") 58 59 Base := EditBase{ 60 Ref: &EditRef{ 61 From: String("BaseRefFrom"), 62 }, 63 SHA: &EditSHA{ 64 From: String("BaseSHAFrom"), 65 }, 66 } 67 68 u := &EditChange{ 69 Title: nil, 70 Body: nil, 71 Base: &Base, 72 } 73 74 want := `{ 75 "base": { 76 "ref": { 77 "from": "BaseRefFrom" 78 }, 79 "sha": { 80 "from": "BaseSHAFrom" 81 } 82 } 83 }` 84 85 testJSONMarshal(t, u, want) 86 } 87 88 func TestEditChange_Marshal_Repo(t *testing.T) { 89 t.Parallel() 90 testJSONMarshal(t, &EditChange{}, "{}") 91 92 u := &EditChange{ 93 Repo: &EditRepo{ 94 Name: &RepoName{ 95 From: String("old-repo-name"), 96 }, 97 }, 98 Topics: &EditTopics{ 99 From: []string{"topic1", "topic2"}, 100 }, 101 } 102 103 want := `{ 104 "repository": { 105 "name": { 106 "from": "old-repo-name" 107 } 108 }, 109 "topics": { 110 "from": [ 111 "topic1", 112 "topic2" 113 ] 114 } 115 }` 116 117 testJSONMarshal(t, u, want) 118 } 119 120 func TestEditChange_Marshal_TransferFromUser(t *testing.T) { 121 t.Parallel() 122 testJSONMarshal(t, &EditChange{}, "{}") 123 124 u := &EditChange{ 125 Owner: &EditOwner{ 126 OwnerInfo: &OwnerInfo{ 127 User: &User{ 128 Login: String("l"), 129 ID: Int64(1), 130 NodeID: String("n"), 131 URL: String("u"), 132 ReposURL: String("r"), 133 EventsURL: String("e"), 134 AvatarURL: String("a"), 135 }, 136 }, 137 }, 138 } 139 140 want := `{ 141 "owner": { 142 "from": { 143 "user": { 144 "login": "l", 145 "id": 1, 146 "node_id": "n", 147 "avatar_url": "a", 148 "url": "u", 149 "repos_url": "r", 150 "events_url": "e" 151 } 152 } 153 } 154 }` 155 156 testJSONMarshal(t, u, want) 157 } 158 159 func TestEditChange_Marshal_TransferFromOrg(t *testing.T) { 160 t.Parallel() 161 testJSONMarshal(t, &EditChange{}, "{}") 162 163 u := &EditChange{ 164 Owner: &EditOwner{ 165 OwnerInfo: &OwnerInfo{ 166 Org: &User{ 167 Login: String("l"), 168 ID: Int64(1), 169 NodeID: String("n"), 170 URL: String("u"), 171 ReposURL: String("r"), 172 EventsURL: String("e"), 173 AvatarURL: String("a"), 174 }, 175 }, 176 }, 177 } 178 179 want := `{ 180 "owner": { 181 "from": { 182 "organization": { 183 "login": "l", 184 "id": 1, 185 "node_id": "n", 186 "avatar_url": "a", 187 "url": "u", 188 "repos_url": "r", 189 "events_url": "e" 190 } 191 } 192 } 193 }` 194 195 testJSONMarshal(t, u, want) 196 } 197 198 func TestProjectChange_Marshal_NameChange(t *testing.T) { 199 t.Parallel() 200 testJSONMarshal(t, &ProjectChange{}, "{}") 201 202 u := &ProjectChange{ 203 Name: &ProjectName{From: String("NameFrom")}, 204 Body: nil, 205 } 206 207 want := `{ 208 "name": { 209 "from": "NameFrom" 210 } 211 }` 212 213 testJSONMarshal(t, u, want) 214 } 215 216 func TestProjectChange_Marshal_BodyChange(t *testing.T) { 217 t.Parallel() 218 testJSONMarshal(t, &ProjectChange{}, "{}") 219 220 u := &ProjectChange{ 221 Name: nil, 222 Body: &ProjectBody{From: String("BodyFrom")}, 223 } 224 225 want := `{ 226 "body": { 227 "from": "BodyFrom" 228 } 229 }` 230 231 testJSONMarshal(t, u, want) 232 } 233 234 func TestProjectCardChange_Marshal_NoteChange(t *testing.T) { 235 t.Parallel() 236 testJSONMarshal(t, &ProjectCardChange{}, "{}") 237 238 u := &ProjectCardChange{ 239 Note: &ProjectCardNote{From: String("NoteFrom")}, 240 } 241 242 want := `{ 243 "note": { 244 "from": "NoteFrom" 245 } 246 }` 247 248 testJSONMarshal(t, u, want) 249 } 250 251 func TestProjectColumnChange_Marshal_NameChange(t *testing.T) { 252 t.Parallel() 253 testJSONMarshal(t, &ProjectColumnChange{}, "{}") 254 255 u := &ProjectColumnChange{ 256 Name: &ProjectColumnName{From: String("NameFrom")}, 257 } 258 259 want := `{ 260 "name": { 261 "from": "NameFrom" 262 } 263 }` 264 265 testJSONMarshal(t, u, want) 266 } 267 268 func TestTeamAddEvent_Marshal(t *testing.T) { 269 t.Parallel() 270 testJSONMarshal(t, &TeamAddEvent{}, "{}") 271 272 u := &TeamAddEvent{ 273 Team: &Team{ 274 ID: Int64(1), 275 NodeID: String("n"), 276 Name: String("n"), 277 Description: String("d"), 278 URL: String("u"), 279 Slug: String("s"), 280 Permission: String("p"), 281 Privacy: String("p"), 282 MembersCount: Int(1), 283 ReposCount: Int(1), 284 MembersURL: String("m"), 285 RepositoriesURL: String("r"), 286 Organization: &Organization{ 287 Login: String("l"), 288 ID: Int64(1), 289 NodeID: String("n"), 290 AvatarURL: String("a"), 291 HTMLURL: String("h"), 292 Name: String("n"), 293 Company: String("c"), 294 Blog: String("b"), 295 Location: String("l"), 296 Email: String("e"), 297 }, 298 Parent: &Team{ 299 ID: Int64(1), 300 NodeID: String("n"), 301 Name: String("n"), 302 Description: String("d"), 303 URL: String("u"), 304 Slug: String("s"), 305 Permission: String("p"), 306 Privacy: String("p"), 307 MembersCount: Int(1), 308 ReposCount: Int(1), 309 }, 310 LDAPDN: String("l"), 311 }, 312 Repo: &Repository{ 313 ID: Int64(1), 314 URL: String("s"), 315 Name: String("n"), 316 }, 317 Org: &Organization{ 318 BillingEmail: String("be"), 319 Blog: String("b"), 320 Company: String("c"), 321 Email: String("e"), 322 TwitterUsername: String("tu"), 323 Location: String("loc"), 324 Name: String("n"), 325 Description: String("d"), 326 IsVerified: Bool(true), 327 HasOrganizationProjects: Bool(true), 328 HasRepositoryProjects: Bool(true), 329 DefaultRepoPermission: String("drp"), 330 MembersCanCreateRepos: Bool(true), 331 MembersCanCreateInternalRepos: Bool(true), 332 MembersCanCreatePrivateRepos: Bool(true), 333 MembersCanCreatePublicRepos: Bool(false), 334 MembersAllowedRepositoryCreationType: String("marct"), 335 MembersCanCreatePages: Bool(true), 336 MembersCanCreatePublicPages: Bool(false), 337 MembersCanCreatePrivatePages: Bool(true), 338 }, 339 Sender: &User{ 340 Login: String("l"), 341 ID: Int64(1), 342 NodeID: String("n"), 343 URL: String("u"), 344 ReposURL: String("r"), 345 EventsURL: String("e"), 346 AvatarURL: String("a"), 347 }, 348 Installation: &Installation{ 349 ID: Int64(1), 350 NodeID: String("nid"), 351 AppID: Int64(1), 352 AppSlug: String("as"), 353 TargetID: Int64(1), 354 Account: &User{ 355 Login: String("l"), 356 ID: Int64(1), 357 URL: String("u"), 358 AvatarURL: String("a"), 359 GravatarID: String("g"), 360 Name: String("n"), 361 Company: String("c"), 362 Blog: String("b"), 363 Location: String("l"), 364 Email: String("e"), 365 Hireable: Bool(true), 366 Bio: String("b"), 367 TwitterUsername: String("t"), 368 PublicRepos: Int(1), 369 Followers: Int(1), 370 Following: Int(1), 371 CreatedAt: &Timestamp{referenceTime}, 372 SuspendedAt: &Timestamp{referenceTime}, 373 }, 374 AccessTokensURL: String("atu"), 375 RepositoriesURL: String("ru"), 376 HTMLURL: String("hu"), 377 TargetType: String("tt"), 378 SingleFileName: String("sfn"), 379 RepositorySelection: String("rs"), 380 Events: []string{"e"}, 381 SingleFilePaths: []string{"s"}, 382 Permissions: &InstallationPermissions{ 383 Actions: String("a"), 384 Administration: String("ad"), 385 Checks: String("c"), 386 Contents: String("co"), 387 ContentReferences: String("cr"), 388 Deployments: String("d"), 389 Environments: String("e"), 390 Issues: String("i"), 391 Metadata: String("md"), 392 Members: String("m"), 393 OrganizationAdministration: String("oa"), 394 OrganizationHooks: String("oh"), 395 OrganizationPlan: String("op"), 396 OrganizationPreReceiveHooks: String("opr"), 397 OrganizationProjects: String("op"), 398 OrganizationSecrets: String("os"), 399 OrganizationSelfHostedRunners: String("osh"), 400 OrganizationUserBlocking: String("oub"), 401 Packages: String("pkg"), 402 Pages: String("pg"), 403 PullRequests: String("pr"), 404 RepositoryHooks: String("rh"), 405 RepositoryProjects: String("rp"), 406 RepositoryPreReceiveHooks: String("rprh"), 407 Secrets: String("s"), 408 SecretScanningAlerts: String("ssa"), 409 SecurityEvents: String("se"), 410 SingleFile: String("sf"), 411 Statuses: String("s"), 412 TeamDiscussions: String("td"), 413 VulnerabilityAlerts: String("va"), 414 Workflows: String("w"), 415 }, 416 CreatedAt: &Timestamp{referenceTime}, 417 UpdatedAt: &Timestamp{referenceTime}, 418 HasMultipleSingleFiles: Bool(false), 419 SuspendedBy: &User{ 420 Login: String("l"), 421 ID: Int64(1), 422 URL: String("u"), 423 AvatarURL: String("a"), 424 GravatarID: String("g"), 425 Name: String("n"), 426 Company: String("c"), 427 Blog: String("b"), 428 Location: String("l"), 429 Email: String("e"), 430 Hireable: Bool(true), 431 Bio: String("b"), 432 TwitterUsername: String("t"), 433 PublicRepos: Int(1), 434 Followers: Int(1), 435 Following: Int(1), 436 CreatedAt: &Timestamp{referenceTime}, 437 SuspendedAt: &Timestamp{referenceTime}, 438 }, 439 SuspendedAt: &Timestamp{referenceTime}, 440 }, 441 } 442 443 want := `{ 444 "team": { 445 "id": 1, 446 "node_id": "n", 447 "name": "n", 448 "description": "d", 449 "url": "u", 450 "slug": "s", 451 "permission": "p", 452 "privacy": "p", 453 "members_count": 1, 454 "repos_count": 1, 455 "organization": { 456 "login": "l", 457 "id": 1, 458 "node_id": "n", 459 "avatar_url": "a", 460 "html_url": "h", 461 "name": "n", 462 "company": "c", 463 "blog": "b", 464 "location": "l", 465 "email": "e" 466 }, 467 "members_url": "m", 468 "repositories_url": "r", 469 "parent": { 470 "id": 1, 471 "node_id": "n", 472 "name": "n", 473 "description": "d", 474 "url": "u", 475 "slug": "s", 476 "permission": "p", 477 "privacy": "p", 478 "members_count": 1, 479 "repos_count": 1 480 }, 481 "ldap_dn": "l" 482 }, 483 "repository": { 484 "id": 1, 485 "name": "n", 486 "url": "s" 487 }, 488 "organization": { 489 "name": "n", 490 "company": "c", 491 "blog": "b", 492 "location": "loc", 493 "email": "e", 494 "twitter_username": "tu", 495 "description": "d", 496 "billing_email": "be", 497 "is_verified": true, 498 "has_organization_projects": true, 499 "has_repository_projects": true, 500 "default_repository_permission": "drp", 501 "members_can_create_repositories": true, 502 "members_can_create_public_repositories": false, 503 "members_can_create_private_repositories": true, 504 "members_can_create_internal_repositories": true, 505 "members_allowed_repository_creation_type": "marct", 506 "members_can_create_pages": true, 507 "members_can_create_public_pages": false, 508 "members_can_create_private_pages": true 509 }, 510 "sender": { 511 "login": "l", 512 "id": 1, 513 "node_id": "n", 514 "avatar_url": "a", 515 "url": "u", 516 "events_url": "e", 517 "repos_url": "r" 518 }, 519 "installation": { 520 "id": 1, 521 "node_id": "nid", 522 "app_id": 1, 523 "app_slug": "as", 524 "target_id": 1, 525 "account": { 526 "login": "l", 527 "id": 1, 528 "avatar_url": "a", 529 "gravatar_id": "g", 530 "name": "n", 531 "company": "c", 532 "blog": "b", 533 "location": "l", 534 "email": "e", 535 "hireable": true, 536 "bio": "b", 537 "twitter_username": "t", 538 "public_repos": 1, 539 "followers": 1, 540 "following": 1, 541 "created_at": ` + referenceTimeStr + `, 542 "suspended_at": ` + referenceTimeStr + `, 543 "url": "u" 544 }, 545 "access_tokens_url": "atu", 546 "repositories_url": "ru", 547 "html_url": "hu", 548 "target_type": "tt", 549 "single_file_name": "sfn", 550 "repository_selection": "rs", 551 "events": [ 552 "e" 553 ], 554 "single_file_paths": [ 555 "s" 556 ], 557 "permissions": { 558 "actions": "a", 559 "administration": "ad", 560 "checks": "c", 561 "contents": "co", 562 "content_references": "cr", 563 "deployments": "d", 564 "environments": "e", 565 "issues": "i", 566 "metadata": "md", 567 "members": "m", 568 "organization_administration": "oa", 569 "organization_hooks": "oh", 570 "organization_plan": "op", 571 "organization_pre_receive_hooks": "opr", 572 "organization_projects": "op", 573 "organization_secrets": "os", 574 "organization_self_hosted_runners": "osh", 575 "organization_user_blocking": "oub", 576 "packages": "pkg", 577 "pages": "pg", 578 "pull_requests": "pr", 579 "repository_hooks": "rh", 580 "repository_projects": "rp", 581 "repository_pre_receive_hooks": "rprh", 582 "secrets": "s", 583 "secret_scanning_alerts": "ssa", 584 "security_events": "se", 585 "single_file": "sf", 586 "statuses": "s", 587 "team_discussions": "td", 588 "vulnerability_alerts": "va", 589 "workflows": "w" 590 }, 591 "created_at": ` + referenceTimeStr + `, 592 "updated_at": ` + referenceTimeStr + `, 593 "has_multiple_single_files": false, 594 "suspended_by": { 595 "login": "l", 596 "id": 1, 597 "avatar_url": "a", 598 "gravatar_id": "g", 599 "name": "n", 600 "company": "c", 601 "blog": "b", 602 "location": "l", 603 "email": "e", 604 "hireable": true, 605 "bio": "b", 606 "twitter_username": "t", 607 "public_repos": 1, 608 "followers": 1, 609 "following": 1, 610 "created_at": ` + referenceTimeStr + `, 611 "suspended_at": ` + referenceTimeStr + `, 612 "url": "u" 613 }, 614 "suspended_at": ` + referenceTimeStr + ` 615 } 616 }` 617 618 testJSONMarshal(t, u, want) 619 } 620 621 func TestStarEvent_Marshal(t *testing.T) { 622 t.Parallel() 623 testJSONMarshal(t, &StarEvent{}, "{}") 624 625 u := &StarEvent{ 626 Action: String("a"), 627 StarredAt: &Timestamp{referenceTime}, 628 Org: &Organization{ 629 BillingEmail: String("be"), 630 Blog: String("b"), 631 Company: String("c"), 632 Email: String("e"), 633 TwitterUsername: String("tu"), 634 Location: String("loc"), 635 Name: String("n"), 636 Description: String("d"), 637 IsVerified: Bool(true), 638 HasOrganizationProjects: Bool(true), 639 HasRepositoryProjects: Bool(true), 640 DefaultRepoPermission: String("drp"), 641 MembersCanCreateRepos: Bool(true), 642 MembersCanCreateInternalRepos: Bool(true), 643 MembersCanCreatePrivateRepos: Bool(true), 644 MembersCanCreatePublicRepos: Bool(false), 645 MembersAllowedRepositoryCreationType: String("marct"), 646 MembersCanCreatePages: Bool(true), 647 MembersCanCreatePublicPages: Bool(false), 648 MembersCanCreatePrivatePages: Bool(true), 649 }, 650 Repo: &Repository{ 651 ID: Int64(1), 652 URL: String("s"), 653 Name: String("n"), 654 }, 655 Sender: &User{ 656 Login: String("l"), 657 ID: Int64(1), 658 NodeID: String("n"), 659 URL: String("u"), 660 ReposURL: String("r"), 661 EventsURL: String("e"), 662 AvatarURL: String("a"), 663 }, 664 } 665 666 want := `{ 667 "action": "a", 668 "starred_at": ` + referenceTimeStr + `, 669 "organization": { 670 "name": "n", 671 "company": "c", 672 "blog": "b", 673 "location": "loc", 674 "email": "e", 675 "twitter_username": "tu", 676 "description": "d", 677 "billing_email": "be", 678 "is_verified": true, 679 "has_organization_projects": true, 680 "has_repository_projects": true, 681 "default_repository_permission": "drp", 682 "members_can_create_repositories": true, 683 "members_can_create_public_repositories": false, 684 "members_can_create_private_repositories": true, 685 "members_can_create_internal_repositories": true, 686 "members_allowed_repository_creation_type": "marct", 687 "members_can_create_pages": true, 688 "members_can_create_public_pages": false, 689 "members_can_create_private_pages": true 690 }, 691 "repository": { 692 "id": 1, 693 "name": "n", 694 "url": "s" 695 }, 696 "sender": { 697 "login": "l", 698 "id": 1, 699 "node_id": "n", 700 "avatar_url": "a", 701 "url": "u", 702 "events_url": "e", 703 "repos_url": "r" 704 } 705 }` 706 707 testJSONMarshal(t, u, want) 708 } 709 710 func TestTeamEvent_Marshal(t *testing.T) { 711 t.Parallel() 712 testJSONMarshal(t, &TeamEvent{}, "{}") 713 714 u := &TeamEvent{ 715 Action: String("a"), 716 Team: &Team{ 717 ID: Int64(1), 718 NodeID: String("n"), 719 Name: String("n"), 720 Description: String("d"), 721 URL: String("u"), 722 Slug: String("s"), 723 Permission: String("p"), 724 Privacy: String("p"), 725 MembersCount: Int(1), 726 ReposCount: Int(1), 727 MembersURL: String("m"), 728 RepositoriesURL: String("r"), 729 Organization: &Organization{ 730 Login: String("l"), 731 ID: Int64(1), 732 NodeID: String("n"), 733 AvatarURL: String("a"), 734 HTMLURL: String("h"), 735 Name: String("n"), 736 Company: String("c"), 737 Blog: String("b"), 738 Location: String("l"), 739 Email: String("e"), 740 }, 741 Parent: &Team{ 742 ID: Int64(1), 743 NodeID: String("n"), 744 Name: String("n"), 745 Description: String("d"), 746 URL: String("u"), 747 Slug: String("s"), 748 Permission: String("p"), 749 Privacy: String("p"), 750 MembersCount: Int(1), 751 ReposCount: Int(1), 752 }, 753 LDAPDN: String("l"), 754 }, 755 Changes: &TeamChange{ 756 Description: &TeamDescription{ 757 From: String("from"), 758 }, 759 Name: &TeamName{ 760 From: String("from"), 761 }, 762 Privacy: &TeamPrivacy{ 763 From: String("from"), 764 }, 765 Repository: &TeamRepository{ 766 Permissions: &TeamPermissions{ 767 From: &TeamPermissionsFrom{ 768 Admin: Bool(true), 769 Pull: Bool(true), 770 Push: Bool(true), 771 }, 772 }, 773 }, 774 }, 775 Repo: &Repository{ 776 ID: Int64(1), 777 URL: String("s"), 778 Name: String("n"), 779 }, 780 Org: &Organization{ 781 BillingEmail: String("be"), 782 Blog: String("b"), 783 Company: String("c"), 784 Email: String("e"), 785 TwitterUsername: String("tu"), 786 Location: String("loc"), 787 Name: String("n"), 788 Description: String("d"), 789 IsVerified: Bool(true), 790 HasOrganizationProjects: Bool(true), 791 HasRepositoryProjects: Bool(true), 792 DefaultRepoPermission: String("drp"), 793 MembersCanCreateRepos: Bool(true), 794 MembersCanCreateInternalRepos: Bool(true), 795 MembersCanCreatePrivateRepos: Bool(true), 796 MembersCanCreatePublicRepos: Bool(false), 797 MembersAllowedRepositoryCreationType: String("marct"), 798 MembersCanCreatePages: Bool(true), 799 MembersCanCreatePublicPages: Bool(false), 800 MembersCanCreatePrivatePages: Bool(true), 801 }, 802 Sender: &User{ 803 Login: String("l"), 804 ID: Int64(1), 805 NodeID: String("n"), 806 URL: String("u"), 807 ReposURL: String("r"), 808 EventsURL: String("e"), 809 AvatarURL: String("a"), 810 }, 811 Installation: &Installation{ 812 ID: Int64(1), 813 NodeID: String("nid"), 814 AppID: Int64(1), 815 AppSlug: String("as"), 816 TargetID: Int64(1), 817 Account: &User{ 818 Login: String("l"), 819 ID: Int64(1), 820 URL: String("u"), 821 AvatarURL: String("a"), 822 GravatarID: String("g"), 823 Name: String("n"), 824 Company: String("c"), 825 Blog: String("b"), 826 Location: String("l"), 827 Email: String("e"), 828 Hireable: Bool(true), 829 Bio: String("b"), 830 TwitterUsername: String("t"), 831 PublicRepos: Int(1), 832 Followers: Int(1), 833 Following: Int(1), 834 CreatedAt: &Timestamp{referenceTime}, 835 SuspendedAt: &Timestamp{referenceTime}, 836 }, 837 AccessTokensURL: String("atu"), 838 RepositoriesURL: String("ru"), 839 HTMLURL: String("hu"), 840 TargetType: String("tt"), 841 SingleFileName: String("sfn"), 842 RepositorySelection: String("rs"), 843 Events: []string{"e"}, 844 SingleFilePaths: []string{"s"}, 845 Permissions: &InstallationPermissions{ 846 Actions: String("a"), 847 Administration: String("ad"), 848 Checks: String("c"), 849 Contents: String("co"), 850 ContentReferences: String("cr"), 851 Deployments: String("d"), 852 Environments: String("e"), 853 Issues: String("i"), 854 Metadata: String("md"), 855 Members: String("m"), 856 OrganizationAdministration: String("oa"), 857 OrganizationHooks: String("oh"), 858 OrganizationPlan: String("op"), 859 OrganizationPreReceiveHooks: String("opr"), 860 OrganizationProjects: String("op"), 861 OrganizationSecrets: String("os"), 862 OrganizationSelfHostedRunners: String("osh"), 863 OrganizationUserBlocking: String("oub"), 864 Packages: String("pkg"), 865 Pages: String("pg"), 866 PullRequests: String("pr"), 867 RepositoryHooks: String("rh"), 868 RepositoryProjects: String("rp"), 869 RepositoryPreReceiveHooks: String("rprh"), 870 Secrets: String("s"), 871 SecretScanningAlerts: String("ssa"), 872 SecurityEvents: String("se"), 873 SingleFile: String("sf"), 874 Statuses: String("s"), 875 TeamDiscussions: String("td"), 876 VulnerabilityAlerts: String("va"), 877 Workflows: String("w"), 878 }, 879 CreatedAt: &Timestamp{referenceTime}, 880 UpdatedAt: &Timestamp{referenceTime}, 881 HasMultipleSingleFiles: Bool(false), 882 SuspendedBy: &User{ 883 Login: String("l"), 884 ID: Int64(1), 885 URL: String("u"), 886 AvatarURL: String("a"), 887 GravatarID: String("g"), 888 Name: String("n"), 889 Company: String("c"), 890 Blog: String("b"), 891 Location: String("l"), 892 Email: String("e"), 893 Hireable: Bool(true), 894 Bio: String("b"), 895 TwitterUsername: String("t"), 896 PublicRepos: Int(1), 897 Followers: Int(1), 898 Following: Int(1), 899 CreatedAt: &Timestamp{referenceTime}, 900 SuspendedAt: &Timestamp{referenceTime}, 901 }, 902 SuspendedAt: &Timestamp{referenceTime}, 903 }, 904 } 905 906 want := `{ 907 "action": "a", 908 "team": { 909 "id": 1, 910 "node_id": "n", 911 "name": "n", 912 "description": "d", 913 "url": "u", 914 "slug": "s", 915 "permission": "p", 916 "privacy": "p", 917 "members_count": 1, 918 "repos_count": 1, 919 "organization": { 920 "login": "l", 921 "id": 1, 922 "node_id": "n", 923 "avatar_url": "a", 924 "html_url": "h", 925 "name": "n", 926 "company": "c", 927 "blog": "b", 928 "location": "l", 929 "email": "e" 930 }, 931 "members_url": "m", 932 "repositories_url": "r", 933 "parent": { 934 "id": 1, 935 "node_id": "n", 936 "name": "n", 937 "description": "d", 938 "url": "u", 939 "slug": "s", 940 "permission": "p", 941 "privacy": "p", 942 "members_count": 1, 943 "repos_count": 1 944 }, 945 "ldap_dn": "l" 946 }, 947 "changes": { 948 "description": { 949 "from": "from" 950 }, 951 "name": { 952 "from": "from" 953 }, 954 "privacy": { 955 "from": "from" 956 }, 957 "repository": { 958 "permissions": { 959 "from": { 960 "admin": true, 961 "pull": true, 962 "push": true 963 } 964 } 965 } 966 }, 967 "repository": { 968 "id": 1, 969 "name": "n", 970 "url": "s" 971 }, 972 "organization": { 973 "name": "n", 974 "company": "c", 975 "blog": "b", 976 "location": "loc", 977 "email": "e", 978 "twitter_username": "tu", 979 "description": "d", 980 "billing_email": "be", 981 "is_verified": true, 982 "has_organization_projects": true, 983 "has_repository_projects": true, 984 "default_repository_permission": "drp", 985 "members_can_create_repositories": true, 986 "members_can_create_public_repositories": false, 987 "members_can_create_private_repositories": true, 988 "members_can_create_internal_repositories": true, 989 "members_allowed_repository_creation_type": "marct", 990 "members_can_create_pages": true, 991 "members_can_create_public_pages": false, 992 "members_can_create_private_pages": true 993 }, 994 "sender": { 995 "login": "l", 996 "id": 1, 997 "node_id": "n", 998 "avatar_url": "a", 999 "url": "u", 1000 "events_url": "e", 1001 "repos_url": "r" 1002 }, 1003 "installation": { 1004 "id": 1, 1005 "node_id": "nid", 1006 "app_id": 1, 1007 "app_slug": "as", 1008 "target_id": 1, 1009 "account": { 1010 "login": "l", 1011 "id": 1, 1012 "avatar_url": "a", 1013 "gravatar_id": "g", 1014 "name": "n", 1015 "company": "c", 1016 "blog": "b", 1017 "location": "l", 1018 "email": "e", 1019 "hireable": true, 1020 "bio": "b", 1021 "twitter_username": "t", 1022 "public_repos": 1, 1023 "followers": 1, 1024 "following": 1, 1025 "created_at": ` + referenceTimeStr + `, 1026 "suspended_at": ` + referenceTimeStr + `, 1027 "url": "u" 1028 }, 1029 "access_tokens_url": "atu", 1030 "repositories_url": "ru", 1031 "html_url": "hu", 1032 "target_type": "tt", 1033 "single_file_name": "sfn", 1034 "repository_selection": "rs", 1035 "events": [ 1036 "e" 1037 ], 1038 "single_file_paths": [ 1039 "s" 1040 ], 1041 "permissions": { 1042 "actions": "a", 1043 "administration": "ad", 1044 "checks": "c", 1045 "contents": "co", 1046 "content_references": "cr", 1047 "deployments": "d", 1048 "environments": "e", 1049 "issues": "i", 1050 "metadata": "md", 1051 "members": "m", 1052 "organization_administration": "oa", 1053 "organization_hooks": "oh", 1054 "organization_plan": "op", 1055 "organization_pre_receive_hooks": "opr", 1056 "organization_projects": "op", 1057 "organization_secrets": "os", 1058 "organization_self_hosted_runners": "osh", 1059 "organization_user_blocking": "oub", 1060 "packages": "pkg", 1061 "pages": "pg", 1062 "pull_requests": "pr", 1063 "repository_hooks": "rh", 1064 "repository_projects": "rp", 1065 "repository_pre_receive_hooks": "rprh", 1066 "secrets": "s", 1067 "secret_scanning_alerts": "ssa", 1068 "security_events": "se", 1069 "single_file": "sf", 1070 "statuses": "s", 1071 "team_discussions": "td", 1072 "vulnerability_alerts": "va", 1073 "workflows": "w" 1074 }, 1075 "created_at": ` + referenceTimeStr + `, 1076 "updated_at": ` + referenceTimeStr + `, 1077 "has_multiple_single_files": false, 1078 "suspended_by": { 1079 "login": "l", 1080 "id": 1, 1081 "avatar_url": "a", 1082 "gravatar_id": "g", 1083 "name": "n", 1084 "company": "c", 1085 "blog": "b", 1086 "location": "l", 1087 "email": "e", 1088 "hireable": true, 1089 "bio": "b", 1090 "twitter_username": "t", 1091 "public_repos": 1, 1092 "followers": 1, 1093 "following": 1, 1094 "created_at": ` + referenceTimeStr + `, 1095 "suspended_at": ` + referenceTimeStr + `, 1096 "url": "u" 1097 }, 1098 "suspended_at": ` + referenceTimeStr + ` 1099 } 1100 }` 1101 1102 testJSONMarshal(t, u, want) 1103 } 1104 1105 func TestInstallationRepositoriesEvent_Marshal(t *testing.T) { 1106 t.Parallel() 1107 testJSONMarshal(t, &InstallationRepositoriesEvent{}, "{}") 1108 1109 u := &InstallationRepositoriesEvent{ 1110 Action: String("a"), 1111 RepositoriesAdded: []*Repository{ 1112 { 1113 ID: Int64(1), 1114 URL: String("s"), 1115 Name: String("n"), 1116 }, 1117 }, 1118 RepositoriesRemoved: []*Repository{ 1119 { 1120 ID: Int64(1), 1121 URL: String("s"), 1122 Name: String("n"), 1123 }, 1124 }, 1125 RepositorySelection: String("rs"), 1126 Sender: &User{ 1127 Login: String("l"), 1128 ID: Int64(1), 1129 NodeID: String("n"), 1130 URL: String("u"), 1131 ReposURL: String("r"), 1132 EventsURL: String("e"), 1133 AvatarURL: String("a"), 1134 }, 1135 Installation: &Installation{ 1136 ID: Int64(1), 1137 NodeID: String("nid"), 1138 AppID: Int64(1), 1139 AppSlug: String("as"), 1140 TargetID: Int64(1), 1141 Account: &User{ 1142 Login: String("l"), 1143 ID: Int64(1), 1144 URL: String("u"), 1145 AvatarURL: String("a"), 1146 GravatarID: String("g"), 1147 Name: String("n"), 1148 Company: String("c"), 1149 Blog: String("b"), 1150 Location: String("l"), 1151 Email: String("e"), 1152 Hireable: Bool(true), 1153 Bio: String("b"), 1154 TwitterUsername: String("t"), 1155 PublicRepos: Int(1), 1156 Followers: Int(1), 1157 Following: Int(1), 1158 CreatedAt: &Timestamp{referenceTime}, 1159 SuspendedAt: &Timestamp{referenceTime}, 1160 }, 1161 AccessTokensURL: String("atu"), 1162 RepositoriesURL: String("ru"), 1163 HTMLURL: String("hu"), 1164 TargetType: String("tt"), 1165 SingleFileName: String("sfn"), 1166 RepositorySelection: String("rs"), 1167 Events: []string{"e"}, 1168 SingleFilePaths: []string{"s"}, 1169 Permissions: &InstallationPermissions{ 1170 Actions: String("a"), 1171 Administration: String("ad"), 1172 Checks: String("c"), 1173 Contents: String("co"), 1174 ContentReferences: String("cr"), 1175 Deployments: String("d"), 1176 Environments: String("e"), 1177 Issues: String("i"), 1178 Metadata: String("md"), 1179 Members: String("m"), 1180 OrganizationAdministration: String("oa"), 1181 OrganizationHooks: String("oh"), 1182 OrganizationPlan: String("op"), 1183 OrganizationPreReceiveHooks: String("opr"), 1184 OrganizationProjects: String("op"), 1185 OrganizationSecrets: String("os"), 1186 OrganizationSelfHostedRunners: String("osh"), 1187 OrganizationUserBlocking: String("oub"), 1188 Packages: String("pkg"), 1189 Pages: String("pg"), 1190 PullRequests: String("pr"), 1191 RepositoryHooks: String("rh"), 1192 RepositoryProjects: String("rp"), 1193 RepositoryPreReceiveHooks: String("rprh"), 1194 Secrets: String("s"), 1195 SecretScanningAlerts: String("ssa"), 1196 SecurityEvents: String("se"), 1197 SingleFile: String("sf"), 1198 Statuses: String("s"), 1199 TeamDiscussions: String("td"), 1200 VulnerabilityAlerts: String("va"), 1201 Workflows: String("w"), 1202 }, 1203 CreatedAt: &Timestamp{referenceTime}, 1204 UpdatedAt: &Timestamp{referenceTime}, 1205 HasMultipleSingleFiles: Bool(false), 1206 SuspendedBy: &User{ 1207 Login: String("l"), 1208 ID: Int64(1), 1209 URL: String("u"), 1210 AvatarURL: String("a"), 1211 GravatarID: String("g"), 1212 Name: String("n"), 1213 Company: String("c"), 1214 Blog: String("b"), 1215 Location: String("l"), 1216 Email: String("e"), 1217 Hireable: Bool(true), 1218 Bio: String("b"), 1219 TwitterUsername: String("t"), 1220 PublicRepos: Int(1), 1221 Followers: Int(1), 1222 Following: Int(1), 1223 CreatedAt: &Timestamp{referenceTime}, 1224 SuspendedAt: &Timestamp{referenceTime}, 1225 }, 1226 SuspendedAt: &Timestamp{referenceTime}, 1227 }, 1228 } 1229 1230 want := `{ 1231 "action": "a", 1232 "repositories_added": [ 1233 { 1234 "id": 1, 1235 "name": "n", 1236 "url": "s" 1237 } 1238 ], 1239 "repositories_removed": [ 1240 { 1241 "id": 1, 1242 "name": "n", 1243 "url": "s" 1244 } 1245 ], 1246 "repository_selection": "rs", 1247 "sender": { 1248 "login": "l", 1249 "id": 1, 1250 "node_id": "n", 1251 "avatar_url": "a", 1252 "url": "u", 1253 "events_url": "e", 1254 "repos_url": "r" 1255 }, 1256 "installation": { 1257 "id": 1, 1258 "node_id": "nid", 1259 "app_id": 1, 1260 "app_slug": "as", 1261 "target_id": 1, 1262 "account": { 1263 "login": "l", 1264 "id": 1, 1265 "avatar_url": "a", 1266 "gravatar_id": "g", 1267 "name": "n", 1268 "company": "c", 1269 "blog": "b", 1270 "location": "l", 1271 "email": "e", 1272 "hireable": true, 1273 "bio": "b", 1274 "twitter_username": "t", 1275 "public_repos": 1, 1276 "followers": 1, 1277 "following": 1, 1278 "created_at": ` + referenceTimeStr + `, 1279 "suspended_at": ` + referenceTimeStr + `, 1280 "url": "u" 1281 }, 1282 "access_tokens_url": "atu", 1283 "repositories_url": "ru", 1284 "html_url": "hu", 1285 "target_type": "tt", 1286 "single_file_name": "sfn", 1287 "repository_selection": "rs", 1288 "events": [ 1289 "e" 1290 ], 1291 "single_file_paths": [ 1292 "s" 1293 ], 1294 "permissions": { 1295 "actions": "a", 1296 "administration": "ad", 1297 "checks": "c", 1298 "contents": "co", 1299 "content_references": "cr", 1300 "deployments": "d", 1301 "environments": "e", 1302 "issues": "i", 1303 "metadata": "md", 1304 "members": "m", 1305 "organization_administration": "oa", 1306 "organization_hooks": "oh", 1307 "organization_plan": "op", 1308 "organization_pre_receive_hooks": "opr", 1309 "organization_projects": "op", 1310 "organization_secrets": "os", 1311 "organization_self_hosted_runners": "osh", 1312 "organization_user_blocking": "oub", 1313 "packages": "pkg", 1314 "pages": "pg", 1315 "pull_requests": "pr", 1316 "repository_hooks": "rh", 1317 "repository_projects": "rp", 1318 "repository_pre_receive_hooks": "rprh", 1319 "secrets": "s", 1320 "secret_scanning_alerts": "ssa", 1321 "security_events": "se", 1322 "single_file": "sf", 1323 "statuses": "s", 1324 "team_discussions": "td", 1325 "vulnerability_alerts": "va", 1326 "workflows": "w" 1327 }, 1328 "created_at": ` + referenceTimeStr + `, 1329 "updated_at": ` + referenceTimeStr + `, 1330 "has_multiple_single_files": false, 1331 "suspended_by": { 1332 "login": "l", 1333 "id": 1, 1334 "avatar_url": "a", 1335 "gravatar_id": "g", 1336 "name": "n", 1337 "company": "c", 1338 "blog": "b", 1339 "location": "l", 1340 "email": "e", 1341 "hireable": true, 1342 "bio": "b", 1343 "twitter_username": "t", 1344 "public_repos": 1, 1345 "followers": 1, 1346 "following": 1, 1347 "created_at": ` + referenceTimeStr + `, 1348 "suspended_at": ` + referenceTimeStr + `, 1349 "url": "u" 1350 }, 1351 "suspended_at": ` + referenceTimeStr + ` 1352 } 1353 }` 1354 1355 testJSONMarshal(t, u, want) 1356 } 1357 1358 func TestInstallationTargetEvent_Marshal(t *testing.T) { 1359 t.Parallel() 1360 testJSONMarshal(t, &InstallationTargetEvent{}, "{}") 1361 1362 u := &InstallationTargetEvent{ 1363 Account: &User{ 1364 Login: String("u"), 1365 ID: Int64(1), 1366 NodeID: String("n"), 1367 URL: String("u"), 1368 ReposURL: String("r"), 1369 EventsURL: String("e"), 1370 AvatarURL: String("l"), 1371 }, 1372 Action: String("a"), 1373 Changes: &InstallationChanges{ 1374 Login: &InstallationLoginChange{ 1375 From: String("p"), 1376 }, 1377 Slug: &InstallationSlugChange{ 1378 From: String("j"), 1379 }, 1380 }, 1381 Enterprise: &Enterprise{ 1382 ID: Int(1), 1383 Slug: String("s"), 1384 Name: String("n"), 1385 NodeID: String("nid"), 1386 AvatarURL: String("au"), 1387 Description: String("d"), 1388 WebsiteURL: String("wu"), 1389 HTMLURL: String("hu"), 1390 CreatedAt: &Timestamp{referenceTime}, 1391 UpdatedAt: &Timestamp{referenceTime}, 1392 }, 1393 Installation: &Installation{ 1394 ID: Int64(1), 1395 NodeID: String("nid"), 1396 AppID: Int64(1), 1397 AppSlug: String("as"), 1398 TargetID: Int64(1), 1399 Account: &User{ 1400 Login: String("l"), 1401 ID: Int64(1), 1402 URL: String("u"), 1403 AvatarURL: String("a"), 1404 GravatarID: String("g"), 1405 Name: String("n"), 1406 Company: String("c"), 1407 Blog: String("b"), 1408 Location: String("l"), 1409 Email: String("e"), 1410 Hireable: Bool(true), 1411 Bio: String("b"), 1412 TwitterUsername: String("t"), 1413 PublicRepos: Int(1), 1414 Followers: Int(1), 1415 Following: Int(1), 1416 CreatedAt: &Timestamp{referenceTime}, 1417 SuspendedAt: &Timestamp{referenceTime}, 1418 }, 1419 AccessTokensURL: String("atu"), 1420 RepositoriesURL: String("ru"), 1421 HTMLURL: String("hu"), 1422 TargetType: String("tt"), 1423 SingleFileName: String("sfn"), 1424 RepositorySelection: String("rs"), 1425 Events: []string{"e"}, 1426 SingleFilePaths: []string{"s"}, 1427 Permissions: &InstallationPermissions{ 1428 Actions: String("a"), 1429 Administration: String("ad"), 1430 Checks: String("c"), 1431 Contents: String("co"), 1432 ContentReferences: String("cr"), 1433 Deployments: String("d"), 1434 Environments: String("e"), 1435 Issues: String("i"), 1436 Metadata: String("md"), 1437 Members: String("m"), 1438 OrganizationAdministration: String("oa"), 1439 OrganizationHooks: String("oh"), 1440 OrganizationPlan: String("op"), 1441 OrganizationPreReceiveHooks: String("opr"), 1442 OrganizationProjects: String("op"), 1443 OrganizationSecrets: String("os"), 1444 OrganizationSelfHostedRunners: String("osh"), 1445 OrganizationUserBlocking: String("oub"), 1446 Packages: String("pkg"), 1447 Pages: String("pg"), 1448 PullRequests: String("pr"), 1449 RepositoryHooks: String("rh"), 1450 RepositoryProjects: String("rp"), 1451 RepositoryPreReceiveHooks: String("rprh"), 1452 Secrets: String("s"), 1453 SecretScanningAlerts: String("ssa"), 1454 SecurityEvents: String("se"), 1455 SingleFile: String("sf"), 1456 Statuses: String("s"), 1457 TeamDiscussions: String("td"), 1458 VulnerabilityAlerts: String("va"), 1459 Workflows: String("w"), 1460 }, 1461 CreatedAt: &Timestamp{referenceTime}, 1462 UpdatedAt: &Timestamp{referenceTime}, 1463 HasMultipleSingleFiles: Bool(false), 1464 SuspendedBy: &User{ 1465 Login: String("l"), 1466 ID: Int64(1), 1467 URL: String("u"), 1468 AvatarURL: String("a"), 1469 GravatarID: String("g"), 1470 Name: String("n"), 1471 Company: String("c"), 1472 Blog: String("b"), 1473 Location: String("l"), 1474 Email: String("e"), 1475 Hireable: Bool(true), 1476 Bio: String("b"), 1477 TwitterUsername: String("t"), 1478 PublicRepos: Int(1), 1479 Followers: Int(1), 1480 Following: Int(1), 1481 CreatedAt: &Timestamp{referenceTime}, 1482 SuspendedAt: &Timestamp{referenceTime}, 1483 }, 1484 SuspendedAt: &Timestamp{referenceTime}, 1485 }, 1486 Organization: &Organization{ 1487 BillingEmail: String("be"), 1488 Blog: String("b"), 1489 Company: String("c"), 1490 Email: String("e"), 1491 TwitterUsername: String("tu"), 1492 Location: String("loc"), 1493 Name: String("n"), 1494 Description: String("d"), 1495 IsVerified: Bool(true), 1496 HasOrganizationProjects: Bool(true), 1497 HasRepositoryProjects: Bool(true), 1498 DefaultRepoPermission: String("drp"), 1499 MembersCanCreateRepos: Bool(true), 1500 MembersCanCreateInternalRepos: Bool(true), 1501 MembersCanCreatePrivateRepos: Bool(true), 1502 MembersCanCreatePublicRepos: Bool(false), 1503 MembersAllowedRepositoryCreationType: String("marct"), 1504 MembersCanCreatePages: Bool(true), 1505 MembersCanCreatePublicPages: Bool(false), 1506 MembersCanCreatePrivatePages: Bool(true), 1507 }, 1508 Repository: &Repository{ 1509 ID: Int64(1), 1510 URL: String("s"), 1511 Name: String("n"), 1512 }, 1513 Sender: &User{ 1514 Login: String("l"), 1515 ID: Int64(1), 1516 NodeID: String("n"), 1517 URL: String("u"), 1518 ReposURL: String("r"), 1519 EventsURL: String("e"), 1520 AvatarURL: String("a"), 1521 }, 1522 TargetType: String("running"), 1523 } 1524 1525 want := `{ 1526 "account": { 1527 "login": "u", 1528 "id": 1, 1529 "node_id": "n", 1530 "avatar_url": "l", 1531 "url": "u", 1532 "events_url": "e", 1533 "repos_url": "r" 1534 }, 1535 "action": "a", 1536 "changes": { 1537 "login": { 1538 "from": "p" 1539 }, 1540 "slug": { 1541 "from": "j" 1542 } 1543 }, 1544 "enterprise": { 1545 "id": 1, 1546 "slug": "s", 1547 "name": "n", 1548 "node_id": "nid", 1549 "avatar_url": "au", 1550 "description": "d", 1551 "website_url": "wu", 1552 "html_url": "hu", 1553 "created_at": ` + referenceTimeStr + `, 1554 "updated_at": ` + referenceTimeStr + ` 1555 }, 1556 "installation": { 1557 "id": 1, 1558 "node_id": "nid", 1559 "app_id": 1, 1560 "app_slug": "as", 1561 "target_id": 1, 1562 "account": { 1563 "login": "l", 1564 "id": 1, 1565 "avatar_url": "a", 1566 "gravatar_id": "g", 1567 "name": "n", 1568 "company": "c", 1569 "blog": "b", 1570 "location": "l", 1571 "email": "e", 1572 "hireable": true, 1573 "bio": "b", 1574 "twitter_username": "t", 1575 "public_repos": 1, 1576 "followers": 1, 1577 "following": 1, 1578 "created_at": ` + referenceTimeStr + `, 1579 "suspended_at": ` + referenceTimeStr + `, 1580 "url": "u" 1581 }, 1582 "access_tokens_url": "atu", 1583 "repositories_url": "ru", 1584 "html_url": "hu", 1585 "target_type": "tt", 1586 "single_file_name": "sfn", 1587 "repository_selection": "rs", 1588 "events": [ 1589 "e" 1590 ], 1591 "single_file_paths": [ 1592 "s" 1593 ], 1594 "permissions": { 1595 "actions": "a", 1596 "administration": "ad", 1597 "checks": "c", 1598 "contents": "co", 1599 "content_references": "cr", 1600 "deployments": "d", 1601 "environments": "e", 1602 "issues": "i", 1603 "metadata": "md", 1604 "members": "m", 1605 "organization_administration": "oa", 1606 "organization_hooks": "oh", 1607 "organization_plan": "op", 1608 "organization_pre_receive_hooks": "opr", 1609 "organization_projects": "op", 1610 "organization_secrets": "os", 1611 "organization_self_hosted_runners": "osh", 1612 "organization_user_blocking": "oub", 1613 "packages": "pkg", 1614 "pages": "pg", 1615 "pull_requests": "pr", 1616 "repository_hooks": "rh", 1617 "repository_projects": "rp", 1618 "repository_pre_receive_hooks": "rprh", 1619 "secrets": "s", 1620 "secret_scanning_alerts": "ssa", 1621 "security_events": "se", 1622 "single_file": "sf", 1623 "statuses": "s", 1624 "team_discussions": "td", 1625 "vulnerability_alerts": "va", 1626 "workflows": "w" 1627 }, 1628 "created_at": ` + referenceTimeStr + `, 1629 "updated_at": ` + referenceTimeStr + `, 1630 "has_multiple_single_files": false, 1631 "suspended_by": { 1632 "login": "l", 1633 "id": 1, 1634 "avatar_url": "a", 1635 "gravatar_id": "g", 1636 "name": "n", 1637 "company": "c", 1638 "blog": "b", 1639 "location": "l", 1640 "email": "e", 1641 "hireable": true, 1642 "bio": "b", 1643 "twitter_username": "t", 1644 "public_repos": 1, 1645 "followers": 1, 1646 "following": 1, 1647 "created_at": ` + referenceTimeStr + `, 1648 "suspended_at": ` + referenceTimeStr + `, 1649 "url": "u" 1650 }, 1651 "suspended_at": ` + referenceTimeStr + ` 1652 }, 1653 "organization": { 1654 "name": "n", 1655 "company": "c", 1656 "blog": "b", 1657 "location": "loc", 1658 "email": "e", 1659 "twitter_username": "tu", 1660 "description": "d", 1661 "billing_email": "be", 1662 "is_verified": true, 1663 "has_organization_projects": true, 1664 "has_repository_projects": true, 1665 "default_repository_permission": "drp", 1666 "members_can_create_repositories": true, 1667 "members_can_create_public_repositories": false, 1668 "members_can_create_private_repositories": true, 1669 "members_can_create_internal_repositories": true, 1670 "members_allowed_repository_creation_type": "marct", 1671 "members_can_create_pages": true, 1672 "members_can_create_public_pages": false, 1673 "members_can_create_private_pages": true 1674 }, 1675 "repository": { 1676 "id": 1, 1677 "url": "s", 1678 "name": "n" 1679 }, 1680 "sender": { 1681 "login": "l", 1682 "id": 1, 1683 "node_id": "n", 1684 "avatar_url": "a", 1685 "url": "u", 1686 "events_url": "e", 1687 "repos_url": "r" 1688 }, 1689 "target_type": "running" 1690 }` 1691 1692 testJSONMarshal(t, u, want) 1693 } 1694 1695 func TestEditTitle_Marshal(t *testing.T) { 1696 t.Parallel() 1697 testJSONMarshal(t, &EditTitle{}, "{}") 1698 1699 u := &EditTitle{ 1700 From: String("EditTitleFrom"), 1701 } 1702 1703 want := `{ 1704 "from": "EditTitleFrom" 1705 }` 1706 1707 testJSONMarshal(t, u, want) 1708 } 1709 1710 func TestEditBody_Marshal(t *testing.T) { 1711 t.Parallel() 1712 testJSONMarshal(t, &EditBody{}, "{}") 1713 1714 u := &EditBody{ 1715 From: String("EditBodyFrom"), 1716 } 1717 1718 want := `{ 1719 "from": "EditBodyFrom" 1720 }` 1721 1722 testJSONMarshal(t, u, want) 1723 } 1724 1725 func TestEditBase_Marshal(t *testing.T) { 1726 t.Parallel() 1727 testJSONMarshal(t, &EditBase{}, "{}") 1728 1729 u := &EditBase{ 1730 Ref: &EditRef{ 1731 From: String("EditRefFrom"), 1732 }, 1733 SHA: &EditSHA{ 1734 From: String("EditSHAFrom"), 1735 }, 1736 } 1737 1738 want := `{ 1739 "ref": { 1740 "from": "EditRefFrom" 1741 }, 1742 "sha": { 1743 "from": "EditSHAFrom" 1744 } 1745 }` 1746 1747 testJSONMarshal(t, u, want) 1748 } 1749 1750 func TestEditRef_Marshal(t *testing.T) { 1751 t.Parallel() 1752 testJSONMarshal(t, &EditRef{}, "{}") 1753 1754 u := &EditRef{ 1755 From: String("EditRefFrom"), 1756 } 1757 1758 want := `{ 1759 "from": "EditRefFrom" 1760 }` 1761 1762 testJSONMarshal(t, u, want) 1763 } 1764 1765 func TestEditSHA_Marshal(t *testing.T) { 1766 t.Parallel() 1767 testJSONMarshal(t, &EditSHA{}, "{}") 1768 1769 u := &EditSHA{ 1770 From: String("EditSHAFrom"), 1771 } 1772 1773 want := `{ 1774 "from": "EditSHAFrom" 1775 }` 1776 1777 testJSONMarshal(t, u, want) 1778 } 1779 1780 func TestProjectName_Marshal(t *testing.T) { 1781 t.Parallel() 1782 testJSONMarshal(t, &ProjectName{}, "{}") 1783 1784 u := &ProjectName{ 1785 From: String("ProjectNameFrom"), 1786 } 1787 1788 want := `{ 1789 "from": "ProjectNameFrom" 1790 }` 1791 1792 testJSONMarshal(t, u, want) 1793 } 1794 1795 func TestProjectBody_Marshal(t *testing.T) { 1796 t.Parallel() 1797 testJSONMarshal(t, &ProjectBody{}, "{}") 1798 1799 u := &ProjectBody{ 1800 From: String("ProjectBodyFrom"), 1801 } 1802 1803 want := `{ 1804 "from": "ProjectBodyFrom" 1805 }` 1806 1807 testJSONMarshal(t, u, want) 1808 } 1809 1810 func TestProjectCardNote_Marshal(t *testing.T) { 1811 t.Parallel() 1812 testJSONMarshal(t, &ProjectCardNote{}, "{}") 1813 1814 u := &ProjectCardNote{ 1815 From: String("ProjectCardNoteFrom"), 1816 } 1817 1818 want := `{ 1819 "from": "ProjectCardNoteFrom" 1820 }` 1821 1822 testJSONMarshal(t, u, want) 1823 } 1824 1825 func TestProjectColumnName_Marshal(t *testing.T) { 1826 t.Parallel() 1827 testJSONMarshal(t, &ProjectColumnName{}, "{}") 1828 1829 u := &ProjectColumnName{ 1830 From: String("ProjectColumnNameFrom"), 1831 } 1832 1833 want := `{ 1834 "from": "ProjectColumnNameFrom" 1835 }` 1836 1837 testJSONMarshal(t, u, want) 1838 } 1839 1840 func TestTeamDescription_Marshal(t *testing.T) { 1841 t.Parallel() 1842 testJSONMarshal(t, &TeamDescription{}, "{}") 1843 1844 u := &TeamDescription{ 1845 From: String("TeamDescriptionFrom"), 1846 } 1847 1848 want := `{ 1849 "from": "TeamDescriptionFrom" 1850 }` 1851 1852 testJSONMarshal(t, u, want) 1853 } 1854 1855 func TestTeamName_Marshal(t *testing.T) { 1856 t.Parallel() 1857 testJSONMarshal(t, &TeamName{}, "{}") 1858 1859 u := &TeamName{ 1860 From: String("TeamNameFrom"), 1861 } 1862 1863 want := `{ 1864 "from": "TeamNameFrom" 1865 }` 1866 1867 testJSONMarshal(t, u, want) 1868 } 1869 1870 func TestTeamPrivacy_Marshal(t *testing.T) { 1871 t.Parallel() 1872 testJSONMarshal(t, &TeamPrivacy{}, "{}") 1873 1874 u := &TeamPrivacy{ 1875 From: String("TeamPrivacyFrom"), 1876 } 1877 1878 want := `{ 1879 "from": "TeamPrivacyFrom" 1880 }` 1881 1882 testJSONMarshal(t, u, want) 1883 } 1884 1885 func TestTeamRepository_Marshal(t *testing.T) { 1886 t.Parallel() 1887 testJSONMarshal(t, &TeamRepository{}, "{}") 1888 1889 u := &TeamRepository{ 1890 Permissions: &TeamPermissions{ 1891 From: &TeamPermissionsFrom{ 1892 Admin: Bool(true), 1893 Pull: Bool(true), 1894 Push: Bool(true), 1895 }, 1896 }, 1897 } 1898 1899 want := `{ 1900 "permissions": { 1901 "from": { 1902 "admin": true, 1903 "pull": true, 1904 "push": true 1905 } 1906 } 1907 }` 1908 1909 testJSONMarshal(t, u, want) 1910 } 1911 1912 func TestTeamPermissions_Marshal(t *testing.T) { 1913 t.Parallel() 1914 testJSONMarshal(t, &TeamPermissions{}, "{}") 1915 1916 u := &TeamPermissions{ 1917 From: &TeamPermissionsFrom{ 1918 Admin: Bool(true), 1919 Pull: Bool(true), 1920 Push: Bool(true), 1921 }, 1922 } 1923 1924 want := `{ 1925 "from": { 1926 "admin": true, 1927 "pull": true, 1928 "push": true 1929 } 1930 }` 1931 1932 testJSONMarshal(t, u, want) 1933 } 1934 1935 func TestTeamPermissionsFrom_Marshal(t *testing.T) { 1936 t.Parallel() 1937 testJSONMarshal(t, &TeamPermissionsFrom{}, "{}") 1938 1939 u := &TeamPermissionsFrom{ 1940 Admin: Bool(true), 1941 Pull: Bool(true), 1942 Push: Bool(true), 1943 } 1944 1945 want := `{ 1946 "admin": true, 1947 "pull": true, 1948 "push": true 1949 }` 1950 1951 testJSONMarshal(t, u, want) 1952 } 1953 1954 func TestRepositoryVulnerabilityAlert_Marshal(t *testing.T) { 1955 t.Parallel() 1956 testJSONMarshal(t, &RepositoryVulnerabilityAlert{}, "{}") 1957 1958 u := &RepositoryVulnerabilityAlert{ 1959 ID: Int64(1), 1960 AffectedRange: String("ar"), 1961 AffectedPackageName: String("apn"), 1962 ExternalReference: String("er"), 1963 ExternalIdentifier: String("ei"), 1964 FixedIn: String("fi"), 1965 Dismisser: &User{ 1966 Login: String("l"), 1967 ID: Int64(1), 1968 NodeID: String("n"), 1969 URL: String("u"), 1970 ReposURL: String("r"), 1971 EventsURL: String("e"), 1972 AvatarURL: String("a"), 1973 }, 1974 DismissReason: String("dr"), 1975 DismissedAt: &Timestamp{referenceTime}, 1976 } 1977 1978 want := `{ 1979 "id": 1, 1980 "affected_range": "ar", 1981 "affected_package_name": "apn", 1982 "external_reference": "er", 1983 "external_identifier": "ei", 1984 "fixed_in": "fi", 1985 "dismisser": { 1986 "login": "l", 1987 "id": 1, 1988 "node_id": "n", 1989 "avatar_url": "a", 1990 "url": "u", 1991 "events_url": "e", 1992 "repos_url": "r" 1993 }, 1994 "dismiss_reason": "dr", 1995 "dismissed_at": ` + referenceTimeStr + ` 1996 }` 1997 1998 testJSONMarshal(t, u, want) 1999 } 2000 2001 func TestPage_Marshal(t *testing.T) { 2002 t.Parallel() 2003 testJSONMarshal(t, &Page{}, "{}") 2004 2005 u := &Page{ 2006 PageName: String("p"), 2007 Title: String("t"), 2008 Summary: String("s"), 2009 Action: String("a"), 2010 SHA: String("s"), 2011 HTMLURL: String("h"), 2012 } 2013 2014 want := `{ 2015 "page_name": "p", 2016 "title": "t", 2017 "summary": "s", 2018 "action": "a", 2019 "sha": "s", 2020 "html_url": "h" 2021 }` 2022 2023 testJSONMarshal(t, u, want) 2024 } 2025 2026 func TestTeamChange_Marshal(t *testing.T) { 2027 t.Parallel() 2028 testJSONMarshal(t, &TeamChange{}, "{}") 2029 2030 u := &TeamChange{ 2031 Description: &TeamDescription{ 2032 From: String("DescriptionFrom"), 2033 }, 2034 Name: &TeamName{ 2035 From: String("NameFrom"), 2036 }, 2037 Privacy: &TeamPrivacy{ 2038 From: String("PrivacyFrom"), 2039 }, 2040 Repository: &TeamRepository{ 2041 Permissions: &TeamPermissions{ 2042 From: &TeamPermissionsFrom{ 2043 Admin: Bool(false), 2044 Pull: Bool(false), 2045 Push: Bool(false), 2046 }, 2047 }, 2048 }, 2049 } 2050 2051 want := `{ 2052 "description": { 2053 "from": "DescriptionFrom" 2054 }, 2055 "name": { 2056 "from": "NameFrom" 2057 }, 2058 "privacy": { 2059 "from": "PrivacyFrom" 2060 }, 2061 "repository": { 2062 "permissions": { 2063 "from": { 2064 "admin": false, 2065 "pull": false, 2066 "push": false 2067 } 2068 } 2069 } 2070 }` 2071 2072 testJSONMarshal(t, u, want) 2073 } 2074 2075 func TestIssueCommentEvent_Marshal(t *testing.T) { 2076 t.Parallel() 2077 testJSONMarshal(t, &IssueCommentEvent{}, "{}") 2078 2079 u := &IssueCommentEvent{ 2080 Action: String("a"), 2081 Issue: &Issue{ID: Int64(1)}, 2082 Comment: &IssueComment{ID: Int64(1)}, 2083 Changes: &EditChange{ 2084 Title: &EditTitle{ 2085 From: String("TitleFrom"), 2086 }, 2087 Body: &EditBody{ 2088 From: String("BodyFrom"), 2089 }, 2090 Base: &EditBase{ 2091 Ref: &EditRef{ 2092 From: String("BaseRefFrom"), 2093 }, 2094 SHA: &EditSHA{ 2095 From: String("BaseSHAFrom"), 2096 }, 2097 }, 2098 }, 2099 Repo: &Repository{ 2100 ID: Int64(1), 2101 URL: String("s"), 2102 Name: String("n"), 2103 }, 2104 Sender: &User{ 2105 Login: String("l"), 2106 ID: Int64(1), 2107 NodeID: String("n"), 2108 URL: String("u"), 2109 ReposURL: String("r"), 2110 EventsURL: String("e"), 2111 AvatarURL: String("a"), 2112 }, 2113 Installation: &Installation{ 2114 ID: Int64(1), 2115 NodeID: String("nid"), 2116 AppID: Int64(1), 2117 AppSlug: String("as"), 2118 TargetID: Int64(1), 2119 Account: &User{ 2120 Login: String("l"), 2121 ID: Int64(1), 2122 URL: String("u"), 2123 AvatarURL: String("a"), 2124 GravatarID: String("g"), 2125 Name: String("n"), 2126 Company: String("c"), 2127 Blog: String("b"), 2128 Location: String("l"), 2129 Email: String("e"), 2130 Hireable: Bool(true), 2131 Bio: String("b"), 2132 TwitterUsername: String("t"), 2133 PublicRepos: Int(1), 2134 Followers: Int(1), 2135 Following: Int(1), 2136 CreatedAt: &Timestamp{referenceTime}, 2137 SuspendedAt: &Timestamp{referenceTime}, 2138 }, 2139 AccessTokensURL: String("atu"), 2140 RepositoriesURL: String("ru"), 2141 HTMLURL: String("hu"), 2142 TargetType: String("tt"), 2143 SingleFileName: String("sfn"), 2144 RepositorySelection: String("rs"), 2145 Events: []string{"e"}, 2146 SingleFilePaths: []string{"s"}, 2147 Permissions: &InstallationPermissions{ 2148 Actions: String("a"), 2149 Administration: String("ad"), 2150 Checks: String("c"), 2151 Contents: String("co"), 2152 ContentReferences: String("cr"), 2153 Deployments: String("d"), 2154 Environments: String("e"), 2155 Issues: String("i"), 2156 Metadata: String("md"), 2157 Members: String("m"), 2158 OrganizationAdministration: String("oa"), 2159 OrganizationHooks: String("oh"), 2160 OrganizationPlan: String("op"), 2161 OrganizationPreReceiveHooks: String("opr"), 2162 OrganizationProjects: String("op"), 2163 OrganizationSecrets: String("os"), 2164 OrganizationSelfHostedRunners: String("osh"), 2165 OrganizationUserBlocking: String("oub"), 2166 Packages: String("pkg"), 2167 Pages: String("pg"), 2168 PullRequests: String("pr"), 2169 RepositoryHooks: String("rh"), 2170 RepositoryProjects: String("rp"), 2171 RepositoryPreReceiveHooks: String("rprh"), 2172 Secrets: String("s"), 2173 SecretScanningAlerts: String("ssa"), 2174 SecurityEvents: String("se"), 2175 SingleFile: String("sf"), 2176 Statuses: String("s"), 2177 TeamDiscussions: String("td"), 2178 VulnerabilityAlerts: String("va"), 2179 Workflows: String("w"), 2180 }, 2181 CreatedAt: &Timestamp{referenceTime}, 2182 UpdatedAt: &Timestamp{referenceTime}, 2183 HasMultipleSingleFiles: Bool(false), 2184 SuspendedBy: &User{ 2185 Login: String("l"), 2186 ID: Int64(1), 2187 URL: String("u"), 2188 AvatarURL: String("a"), 2189 GravatarID: String("g"), 2190 Name: String("n"), 2191 Company: String("c"), 2192 Blog: String("b"), 2193 Location: String("l"), 2194 Email: String("e"), 2195 Hireable: Bool(true), 2196 Bio: String("b"), 2197 TwitterUsername: String("t"), 2198 PublicRepos: Int(1), 2199 Followers: Int(1), 2200 Following: Int(1), 2201 CreatedAt: &Timestamp{referenceTime}, 2202 SuspendedAt: &Timestamp{referenceTime}, 2203 }, 2204 SuspendedAt: &Timestamp{referenceTime}, 2205 }, 2206 Organization: &Organization{ 2207 BillingEmail: String("be"), 2208 Blog: String("b"), 2209 Company: String("c"), 2210 Email: String("e"), 2211 TwitterUsername: String("tu"), 2212 Location: String("loc"), 2213 Name: String("n"), 2214 Description: String("d"), 2215 IsVerified: Bool(true), 2216 HasOrganizationProjects: Bool(true), 2217 HasRepositoryProjects: Bool(true), 2218 DefaultRepoPermission: String("drp"), 2219 MembersCanCreateRepos: Bool(true), 2220 MembersCanCreateInternalRepos: Bool(true), 2221 MembersCanCreatePrivateRepos: Bool(true), 2222 MembersCanCreatePublicRepos: Bool(false), 2223 MembersAllowedRepositoryCreationType: String("marct"), 2224 MembersCanCreatePages: Bool(true), 2225 MembersCanCreatePublicPages: Bool(false), 2226 MembersCanCreatePrivatePages: Bool(true), 2227 }, 2228 } 2229 2230 want := `{ 2231 "action": "a", 2232 "issue": { 2233 "id": 1 2234 }, 2235 "comment": { 2236 "id": 1 2237 }, 2238 "changes": { 2239 "title": { 2240 "from": "TitleFrom" 2241 }, 2242 "body": { 2243 "from": "BodyFrom" 2244 }, 2245 "base": { 2246 "ref": { 2247 "from": "BaseRefFrom" 2248 }, 2249 "sha": { 2250 "from": "BaseSHAFrom" 2251 } 2252 } 2253 }, 2254 "repository": { 2255 "id": 1, 2256 "name": "n", 2257 "url": "s" 2258 }, 2259 "sender": { 2260 "login": "l", 2261 "id": 1, 2262 "node_id": "n", 2263 "avatar_url": "a", 2264 "url": "u", 2265 "events_url": "e", 2266 "repos_url": "r" 2267 }, 2268 "installation": { 2269 "id": 1, 2270 "node_id": "nid", 2271 "app_id": 1, 2272 "app_slug": "as", 2273 "target_id": 1, 2274 "account": { 2275 "login": "l", 2276 "id": 1, 2277 "avatar_url": "a", 2278 "gravatar_id": "g", 2279 "name": "n", 2280 "company": "c", 2281 "blog": "b", 2282 "location": "l", 2283 "email": "e", 2284 "hireable": true, 2285 "bio": "b", 2286 "twitter_username": "t", 2287 "public_repos": 1, 2288 "followers": 1, 2289 "following": 1, 2290 "created_at": ` + referenceTimeStr + `, 2291 "suspended_at": ` + referenceTimeStr + `, 2292 "url": "u" 2293 }, 2294 "access_tokens_url": "atu", 2295 "repositories_url": "ru", 2296 "html_url": "hu", 2297 "target_type": "tt", 2298 "single_file_name": "sfn", 2299 "repository_selection": "rs", 2300 "events": [ 2301 "e" 2302 ], 2303 "single_file_paths": [ 2304 "s" 2305 ], 2306 "permissions": { 2307 "actions": "a", 2308 "administration": "ad", 2309 "checks": "c", 2310 "contents": "co", 2311 "content_references": "cr", 2312 "deployments": "d", 2313 "environments": "e", 2314 "issues": "i", 2315 "metadata": "md", 2316 "members": "m", 2317 "organization_administration": "oa", 2318 "organization_hooks": "oh", 2319 "organization_plan": "op", 2320 "organization_pre_receive_hooks": "opr", 2321 "organization_projects": "op", 2322 "organization_secrets": "os", 2323 "organization_self_hosted_runners": "osh", 2324 "organization_user_blocking": "oub", 2325 "packages": "pkg", 2326 "pages": "pg", 2327 "pull_requests": "pr", 2328 "repository_hooks": "rh", 2329 "repository_projects": "rp", 2330 "repository_pre_receive_hooks": "rprh", 2331 "secrets": "s", 2332 "secret_scanning_alerts": "ssa", 2333 "security_events": "se", 2334 "single_file": "sf", 2335 "statuses": "s", 2336 "team_discussions": "td", 2337 "vulnerability_alerts": "va", 2338 "workflows": "w" 2339 }, 2340 "created_at": ` + referenceTimeStr + `, 2341 "updated_at": ` + referenceTimeStr + `, 2342 "has_multiple_single_files": false, 2343 "suspended_by": { 2344 "login": "l", 2345 "id": 1, 2346 "avatar_url": "a", 2347 "gravatar_id": "g", 2348 "name": "n", 2349 "company": "c", 2350 "blog": "b", 2351 "location": "l", 2352 "email": "e", 2353 "hireable": true, 2354 "bio": "b", 2355 "twitter_username": "t", 2356 "public_repos": 1, 2357 "followers": 1, 2358 "following": 1, 2359 "created_at": ` + referenceTimeStr + `, 2360 "suspended_at": ` + referenceTimeStr + `, 2361 "url": "u" 2362 }, 2363 "suspended_at": ` + referenceTimeStr + ` 2364 }, 2365 "organization": { 2366 "name": "n", 2367 "company": "c", 2368 "blog": "b", 2369 "location": "loc", 2370 "email": "e", 2371 "twitter_username": "tu", 2372 "description": "d", 2373 "billing_email": "be", 2374 "is_verified": true, 2375 "has_organization_projects": true, 2376 "has_repository_projects": true, 2377 "default_repository_permission": "drp", 2378 "members_can_create_repositories": true, 2379 "members_can_create_public_repositories": false, 2380 "members_can_create_private_repositories": true, 2381 "members_can_create_internal_repositories": true, 2382 "members_allowed_repository_creation_type": "marct", 2383 "members_can_create_pages": true, 2384 "members_can_create_public_pages": false, 2385 "members_can_create_private_pages": true 2386 } 2387 }` 2388 2389 testJSONMarshal(t, u, want) 2390 } 2391 2392 func TestIssuesEvent_Marshal(t *testing.T) { 2393 t.Parallel() 2394 testJSONMarshal(t, &IssuesEvent{}, "{}") 2395 2396 u := &IssuesEvent{ 2397 Action: String("a"), 2398 Issue: &Issue{ID: Int64(1)}, 2399 Assignee: &User{ 2400 Login: String("l"), 2401 ID: Int64(1), 2402 NodeID: String("n"), 2403 URL: String("u"), 2404 ReposURL: String("r"), 2405 EventsURL: String("e"), 2406 AvatarURL: String("a"), 2407 }, 2408 Label: &Label{ID: Int64(1)}, 2409 Changes: &EditChange{ 2410 Title: &EditTitle{ 2411 From: String("TitleFrom"), 2412 }, 2413 Body: &EditBody{ 2414 From: String("BodyFrom"), 2415 }, 2416 Base: &EditBase{ 2417 Ref: &EditRef{ 2418 From: String("BaseRefFrom"), 2419 }, 2420 SHA: &EditSHA{ 2421 From: String("BaseSHAFrom"), 2422 }, 2423 }, 2424 }, 2425 Repo: &Repository{ 2426 ID: Int64(1), 2427 URL: String("s"), 2428 Name: String("n"), 2429 }, 2430 Sender: &User{ 2431 Login: String("l"), 2432 ID: Int64(1), 2433 NodeID: String("n"), 2434 URL: String("u"), 2435 ReposURL: String("r"), 2436 EventsURL: String("e"), 2437 AvatarURL: String("a"), 2438 }, 2439 Installation: &Installation{ 2440 ID: Int64(1), 2441 NodeID: String("nid"), 2442 AppID: Int64(1), 2443 AppSlug: String("as"), 2444 TargetID: Int64(1), 2445 Account: &User{ 2446 Login: String("l"), 2447 ID: Int64(1), 2448 URL: String("u"), 2449 AvatarURL: String("a"), 2450 GravatarID: String("g"), 2451 Name: String("n"), 2452 Company: String("c"), 2453 Blog: String("b"), 2454 Location: String("l"), 2455 Email: String("e"), 2456 Hireable: Bool(true), 2457 Bio: String("b"), 2458 TwitterUsername: String("t"), 2459 PublicRepos: Int(1), 2460 Followers: Int(1), 2461 Following: Int(1), 2462 CreatedAt: &Timestamp{referenceTime}, 2463 SuspendedAt: &Timestamp{referenceTime}, 2464 }, 2465 AccessTokensURL: String("atu"), 2466 RepositoriesURL: String("ru"), 2467 HTMLURL: String("hu"), 2468 TargetType: String("tt"), 2469 SingleFileName: String("sfn"), 2470 RepositorySelection: String("rs"), 2471 Events: []string{"e"}, 2472 SingleFilePaths: []string{"s"}, 2473 Permissions: &InstallationPermissions{ 2474 Actions: String("a"), 2475 Administration: String("ad"), 2476 Checks: String("c"), 2477 Contents: String("co"), 2478 ContentReferences: String("cr"), 2479 Deployments: String("d"), 2480 Environments: String("e"), 2481 Issues: String("i"), 2482 Metadata: String("md"), 2483 Members: String("m"), 2484 OrganizationAdministration: String("oa"), 2485 OrganizationHooks: String("oh"), 2486 OrganizationPlan: String("op"), 2487 OrganizationPreReceiveHooks: String("opr"), 2488 OrganizationProjects: String("op"), 2489 OrganizationSecrets: String("os"), 2490 OrganizationSelfHostedRunners: String("osh"), 2491 OrganizationUserBlocking: String("oub"), 2492 Packages: String("pkg"), 2493 Pages: String("pg"), 2494 PullRequests: String("pr"), 2495 RepositoryHooks: String("rh"), 2496 RepositoryProjects: String("rp"), 2497 RepositoryPreReceiveHooks: String("rprh"), 2498 Secrets: String("s"), 2499 SecretScanningAlerts: String("ssa"), 2500 SecurityEvents: String("se"), 2501 SingleFile: String("sf"), 2502 Statuses: String("s"), 2503 TeamDiscussions: String("td"), 2504 VulnerabilityAlerts: String("va"), 2505 Workflows: String("w"), 2506 }, 2507 CreatedAt: &Timestamp{referenceTime}, 2508 UpdatedAt: &Timestamp{referenceTime}, 2509 HasMultipleSingleFiles: Bool(false), 2510 SuspendedBy: &User{ 2511 Login: String("l"), 2512 ID: Int64(1), 2513 URL: String("u"), 2514 AvatarURL: String("a"), 2515 GravatarID: String("g"), 2516 Name: String("n"), 2517 Company: String("c"), 2518 Blog: String("b"), 2519 Location: String("l"), 2520 Email: String("e"), 2521 Hireable: Bool(true), 2522 Bio: String("b"), 2523 TwitterUsername: String("t"), 2524 PublicRepos: Int(1), 2525 Followers: Int(1), 2526 Following: Int(1), 2527 CreatedAt: &Timestamp{referenceTime}, 2528 SuspendedAt: &Timestamp{referenceTime}, 2529 }, 2530 SuspendedAt: &Timestamp{referenceTime}, 2531 }, 2532 } 2533 2534 want := `{ 2535 "action": "a", 2536 "issue": { 2537 "id": 1 2538 }, 2539 "assignee": { 2540 "login": "l", 2541 "id": 1, 2542 "node_id": "n", 2543 "avatar_url": "a", 2544 "url": "u", 2545 "events_url": "e", 2546 "repos_url": "r" 2547 }, 2548 "label": { 2549 "id": 1 2550 }, 2551 "changes": { 2552 "title": { 2553 "from": "TitleFrom" 2554 }, 2555 "body": { 2556 "from": "BodyFrom" 2557 }, 2558 "base": { 2559 "ref": { 2560 "from": "BaseRefFrom" 2561 }, 2562 "sha": { 2563 "from": "BaseSHAFrom" 2564 } 2565 } 2566 }, 2567 "repository": { 2568 "id": 1, 2569 "name": "n", 2570 "url": "s" 2571 }, 2572 "sender": { 2573 "login": "l", 2574 "id": 1, 2575 "node_id": "n", 2576 "avatar_url": "a", 2577 "url": "u", 2578 "events_url": "e", 2579 "repos_url": "r" 2580 }, 2581 "installation": { 2582 "id": 1, 2583 "node_id": "nid", 2584 "app_id": 1, 2585 "app_slug": "as", 2586 "target_id": 1, 2587 "account": { 2588 "login": "l", 2589 "id": 1, 2590 "avatar_url": "a", 2591 "gravatar_id": "g", 2592 "name": "n", 2593 "company": "c", 2594 "blog": "b", 2595 "location": "l", 2596 "email": "e", 2597 "hireable": true, 2598 "bio": "b", 2599 "twitter_username": "t", 2600 "public_repos": 1, 2601 "followers": 1, 2602 "following": 1, 2603 "created_at": ` + referenceTimeStr + `, 2604 "suspended_at": ` + referenceTimeStr + `, 2605 "url": "u" 2606 }, 2607 "access_tokens_url": "atu", 2608 "repositories_url": "ru", 2609 "html_url": "hu", 2610 "target_type": "tt", 2611 "single_file_name": "sfn", 2612 "repository_selection": "rs", 2613 "events": [ 2614 "e" 2615 ], 2616 "single_file_paths": [ 2617 "s" 2618 ], 2619 "permissions": { 2620 "actions": "a", 2621 "administration": "ad", 2622 "checks": "c", 2623 "contents": "co", 2624 "content_references": "cr", 2625 "deployments": "d", 2626 "environments": "e", 2627 "issues": "i", 2628 "metadata": "md", 2629 "members": "m", 2630 "organization_administration": "oa", 2631 "organization_hooks": "oh", 2632 "organization_plan": "op", 2633 "organization_pre_receive_hooks": "opr", 2634 "organization_projects": "op", 2635 "organization_secrets": "os", 2636 "organization_self_hosted_runners": "osh", 2637 "organization_user_blocking": "oub", 2638 "packages": "pkg", 2639 "pages": "pg", 2640 "pull_requests": "pr", 2641 "repository_hooks": "rh", 2642 "repository_projects": "rp", 2643 "repository_pre_receive_hooks": "rprh", 2644 "secrets": "s", 2645 "secret_scanning_alerts": "ssa", 2646 "security_events": "se", 2647 "single_file": "sf", 2648 "statuses": "s", 2649 "team_discussions": "td", 2650 "vulnerability_alerts": "va", 2651 "workflows": "w" 2652 }, 2653 "created_at": ` + referenceTimeStr + `, 2654 "updated_at": ` + referenceTimeStr + `, 2655 "has_multiple_single_files": false, 2656 "suspended_by": { 2657 "login": "l", 2658 "id": 1, 2659 "avatar_url": "a", 2660 "gravatar_id": "g", 2661 "name": "n", 2662 "company": "c", 2663 "blog": "b", 2664 "location": "l", 2665 "email": "e", 2666 "hireable": true, 2667 "bio": "b", 2668 "twitter_username": "t", 2669 "public_repos": 1, 2670 "followers": 1, 2671 "following": 1, 2672 "created_at": ` + referenceTimeStr + `, 2673 "suspended_at": ` + referenceTimeStr + `, 2674 "url": "u" 2675 }, 2676 "suspended_at": ` + referenceTimeStr + ` 2677 } 2678 }` 2679 2680 testJSONMarshal(t, u, want) 2681 } 2682 2683 func TestLabelEvent_Marshal(t *testing.T) { 2684 t.Parallel() 2685 testJSONMarshal(t, &LabelEvent{}, "{}") 2686 2687 u := &LabelEvent{ 2688 Action: String("a"), 2689 Label: &Label{ID: Int64(1)}, 2690 Changes: &EditChange{ 2691 Title: &EditTitle{ 2692 From: String("TitleFrom"), 2693 }, 2694 Body: &EditBody{ 2695 From: String("BodyFrom"), 2696 }, 2697 Base: &EditBase{ 2698 Ref: &EditRef{ 2699 From: String("BaseRefFrom"), 2700 }, 2701 SHA: &EditSHA{ 2702 From: String("BaseSHAFrom"), 2703 }, 2704 }, 2705 }, 2706 Repo: &Repository{ 2707 ID: Int64(1), 2708 URL: String("s"), 2709 Name: String("n"), 2710 }, 2711 Org: &Organization{ 2712 BillingEmail: String("be"), 2713 Blog: String("b"), 2714 Company: String("c"), 2715 Email: String("e"), 2716 TwitterUsername: String("tu"), 2717 Location: String("loc"), 2718 Name: String("n"), 2719 Description: String("d"), 2720 IsVerified: Bool(true), 2721 HasOrganizationProjects: Bool(true), 2722 HasRepositoryProjects: Bool(true), 2723 DefaultRepoPermission: String("drp"), 2724 MembersCanCreateRepos: Bool(true), 2725 MembersCanCreateInternalRepos: Bool(true), 2726 MembersCanCreatePrivateRepos: Bool(true), 2727 MembersCanCreatePublicRepos: Bool(false), 2728 MembersAllowedRepositoryCreationType: String("marct"), 2729 MembersCanCreatePages: Bool(true), 2730 MembersCanCreatePublicPages: Bool(false), 2731 MembersCanCreatePrivatePages: Bool(true), 2732 }, 2733 Installation: &Installation{ 2734 ID: Int64(1), 2735 NodeID: String("nid"), 2736 AppID: Int64(1), 2737 AppSlug: String("as"), 2738 TargetID: Int64(1), 2739 Account: &User{ 2740 Login: String("l"), 2741 ID: Int64(1), 2742 URL: String("u"), 2743 AvatarURL: String("a"), 2744 GravatarID: String("g"), 2745 Name: String("n"), 2746 Company: String("c"), 2747 Blog: String("b"), 2748 Location: String("l"), 2749 Email: String("e"), 2750 Hireable: Bool(true), 2751 Bio: String("b"), 2752 TwitterUsername: String("t"), 2753 PublicRepos: Int(1), 2754 Followers: Int(1), 2755 Following: Int(1), 2756 CreatedAt: &Timestamp{referenceTime}, 2757 SuspendedAt: &Timestamp{referenceTime}, 2758 }, 2759 AccessTokensURL: String("atu"), 2760 RepositoriesURL: String("ru"), 2761 HTMLURL: String("hu"), 2762 TargetType: String("tt"), 2763 SingleFileName: String("sfn"), 2764 RepositorySelection: String("rs"), 2765 Events: []string{"e"}, 2766 SingleFilePaths: []string{"s"}, 2767 Permissions: &InstallationPermissions{ 2768 Actions: String("a"), 2769 Administration: String("ad"), 2770 Checks: String("c"), 2771 Contents: String("co"), 2772 ContentReferences: String("cr"), 2773 Deployments: String("d"), 2774 Environments: String("e"), 2775 Issues: String("i"), 2776 Metadata: String("md"), 2777 Members: String("m"), 2778 OrganizationAdministration: String("oa"), 2779 OrganizationHooks: String("oh"), 2780 OrganizationPlan: String("op"), 2781 OrganizationPreReceiveHooks: String("opr"), 2782 OrganizationProjects: String("op"), 2783 OrganizationSecrets: String("os"), 2784 OrganizationSelfHostedRunners: String("osh"), 2785 OrganizationUserBlocking: String("oub"), 2786 Packages: String("pkg"), 2787 Pages: String("pg"), 2788 PullRequests: String("pr"), 2789 RepositoryHooks: String("rh"), 2790 RepositoryProjects: String("rp"), 2791 RepositoryPreReceiveHooks: String("rprh"), 2792 Secrets: String("s"), 2793 SecretScanningAlerts: String("ssa"), 2794 SecurityEvents: String("se"), 2795 SingleFile: String("sf"), 2796 Statuses: String("s"), 2797 TeamDiscussions: String("td"), 2798 VulnerabilityAlerts: String("va"), 2799 Workflows: String("w"), 2800 }, 2801 CreatedAt: &Timestamp{referenceTime}, 2802 UpdatedAt: &Timestamp{referenceTime}, 2803 HasMultipleSingleFiles: Bool(false), 2804 SuspendedBy: &User{ 2805 Login: String("l"), 2806 ID: Int64(1), 2807 URL: String("u"), 2808 AvatarURL: String("a"), 2809 GravatarID: String("g"), 2810 Name: String("n"), 2811 Company: String("c"), 2812 Blog: String("b"), 2813 Location: String("l"), 2814 Email: String("e"), 2815 Hireable: Bool(true), 2816 Bio: String("b"), 2817 TwitterUsername: String("t"), 2818 PublicRepos: Int(1), 2819 Followers: Int(1), 2820 Following: Int(1), 2821 CreatedAt: &Timestamp{referenceTime}, 2822 SuspendedAt: &Timestamp{referenceTime}, 2823 }, 2824 SuspendedAt: &Timestamp{referenceTime}, 2825 }, 2826 } 2827 2828 want := `{ 2829 "action": "a", 2830 "label": { 2831 "id": 1 2832 }, 2833 "changes": { 2834 "title": { 2835 "from": "TitleFrom" 2836 }, 2837 "body": { 2838 "from": "BodyFrom" 2839 }, 2840 "base": { 2841 "ref": { 2842 "from": "BaseRefFrom" 2843 }, 2844 "sha": { 2845 "from": "BaseSHAFrom" 2846 } 2847 } 2848 }, 2849 "repository": { 2850 "id": 1, 2851 "name": "n", 2852 "url": "s" 2853 }, 2854 "organization": { 2855 "name": "n", 2856 "company": "c", 2857 "blog": "b", 2858 "location": "loc", 2859 "email": "e", 2860 "twitter_username": "tu", 2861 "description": "d", 2862 "billing_email": "be", 2863 "is_verified": true, 2864 "has_organization_projects": true, 2865 "has_repository_projects": true, 2866 "default_repository_permission": "drp", 2867 "members_can_create_repositories": true, 2868 "members_can_create_public_repositories": false, 2869 "members_can_create_private_repositories": true, 2870 "members_can_create_internal_repositories": true, 2871 "members_allowed_repository_creation_type": "marct", 2872 "members_can_create_pages": true, 2873 "members_can_create_public_pages": false, 2874 "members_can_create_private_pages": true 2875 }, 2876 "installation": { 2877 "id": 1, 2878 "node_id": "nid", 2879 "app_id": 1, 2880 "app_slug": "as", 2881 "target_id": 1, 2882 "account": { 2883 "login": "l", 2884 "id": 1, 2885 "avatar_url": "a", 2886 "gravatar_id": "g", 2887 "name": "n", 2888 "company": "c", 2889 "blog": "b", 2890 "location": "l", 2891 "email": "e", 2892 "hireable": true, 2893 "bio": "b", 2894 "twitter_username": "t", 2895 "public_repos": 1, 2896 "followers": 1, 2897 "following": 1, 2898 "created_at": ` + referenceTimeStr + `, 2899 "suspended_at": ` + referenceTimeStr + `, 2900 "url": "u" 2901 }, 2902 "access_tokens_url": "atu", 2903 "repositories_url": "ru", 2904 "html_url": "hu", 2905 "target_type": "tt", 2906 "single_file_name": "sfn", 2907 "repository_selection": "rs", 2908 "events": [ 2909 "e" 2910 ], 2911 "single_file_paths": [ 2912 "s" 2913 ], 2914 "permissions": { 2915 "actions": "a", 2916 "administration": "ad", 2917 "checks": "c", 2918 "contents": "co", 2919 "content_references": "cr", 2920 "deployments": "d", 2921 "environments": "e", 2922 "issues": "i", 2923 "metadata": "md", 2924 "members": "m", 2925 "organization_administration": "oa", 2926 "organization_hooks": "oh", 2927 "organization_plan": "op", 2928 "organization_pre_receive_hooks": "opr", 2929 "organization_projects": "op", 2930 "organization_secrets": "os", 2931 "organization_self_hosted_runners": "osh", 2932 "organization_user_blocking": "oub", 2933 "packages": "pkg", 2934 "pages": "pg", 2935 "pull_requests": "pr", 2936 "repository_hooks": "rh", 2937 "repository_projects": "rp", 2938 "repository_pre_receive_hooks": "rprh", 2939 "secrets": "s", 2940 "secret_scanning_alerts": "ssa", 2941 "security_events": "se", 2942 "single_file": "sf", 2943 "statuses": "s", 2944 "team_discussions": "td", 2945 "vulnerability_alerts": "va", 2946 "workflows": "w" 2947 }, 2948 "created_at": ` + referenceTimeStr + `, 2949 "updated_at": ` + referenceTimeStr + `, 2950 "has_multiple_single_files": false, 2951 "suspended_by": { 2952 "login": "l", 2953 "id": 1, 2954 "avatar_url": "a", 2955 "gravatar_id": "g", 2956 "name": "n", 2957 "company": "c", 2958 "blog": "b", 2959 "location": "l", 2960 "email": "e", 2961 "hireable": true, 2962 "bio": "b", 2963 "twitter_username": "t", 2964 "public_repos": 1, 2965 "followers": 1, 2966 "following": 1, 2967 "created_at": ` + referenceTimeStr + `, 2968 "suspended_at": ` + referenceTimeStr + `, 2969 "url": "u" 2970 }, 2971 "suspended_at": ` + referenceTimeStr + ` 2972 } 2973 }` 2974 2975 testJSONMarshal(t, u, want) 2976 } 2977 2978 func TestMilestoneEvent_Marshal(t *testing.T) { 2979 t.Parallel() 2980 testJSONMarshal(t, &MilestoneEvent{}, "{}") 2981 2982 u := &MilestoneEvent{ 2983 Action: String("a"), 2984 Milestone: &Milestone{ID: Int64(1)}, 2985 Changes: &EditChange{ 2986 Title: &EditTitle{ 2987 From: String("TitleFrom"), 2988 }, 2989 Body: &EditBody{ 2990 From: String("BodyFrom"), 2991 }, 2992 Base: &EditBase{ 2993 Ref: &EditRef{ 2994 From: String("BaseRefFrom"), 2995 }, 2996 SHA: &EditSHA{ 2997 From: String("BaseSHAFrom"), 2998 }, 2999 }, 3000 }, 3001 Repo: &Repository{ 3002 ID: Int64(1), 3003 URL: String("s"), 3004 Name: String("n"), 3005 }, 3006 Sender: &User{ 3007 Login: String("l"), 3008 ID: Int64(1), 3009 NodeID: String("n"), 3010 URL: String("u"), 3011 ReposURL: String("r"), 3012 EventsURL: String("e"), 3013 AvatarURL: String("a"), 3014 }, 3015 Org: &Organization{ 3016 BillingEmail: String("be"), 3017 Blog: String("b"), 3018 Company: String("c"), 3019 Email: String("e"), 3020 TwitterUsername: String("tu"), 3021 Location: String("loc"), 3022 Name: String("n"), 3023 Description: String("d"), 3024 IsVerified: Bool(true), 3025 HasOrganizationProjects: Bool(true), 3026 HasRepositoryProjects: Bool(true), 3027 DefaultRepoPermission: String("drp"), 3028 MembersCanCreateRepos: Bool(true), 3029 MembersCanCreateInternalRepos: Bool(true), 3030 MembersCanCreatePrivateRepos: Bool(true), 3031 MembersCanCreatePublicRepos: Bool(false), 3032 MembersAllowedRepositoryCreationType: String("marct"), 3033 MembersCanCreatePages: Bool(true), 3034 MembersCanCreatePublicPages: Bool(false), 3035 MembersCanCreatePrivatePages: Bool(true), 3036 }, 3037 Installation: &Installation{ 3038 ID: Int64(1), 3039 NodeID: String("nid"), 3040 AppID: Int64(1), 3041 AppSlug: String("as"), 3042 TargetID: Int64(1), 3043 Account: &User{ 3044 Login: String("l"), 3045 ID: Int64(1), 3046 URL: String("u"), 3047 AvatarURL: String("a"), 3048 GravatarID: String("g"), 3049 Name: String("n"), 3050 Company: String("c"), 3051 Blog: String("b"), 3052 Location: String("l"), 3053 Email: String("e"), 3054 Hireable: Bool(true), 3055 Bio: String("b"), 3056 TwitterUsername: String("t"), 3057 PublicRepos: Int(1), 3058 Followers: Int(1), 3059 Following: Int(1), 3060 CreatedAt: &Timestamp{referenceTime}, 3061 SuspendedAt: &Timestamp{referenceTime}, 3062 }, 3063 AccessTokensURL: String("atu"), 3064 RepositoriesURL: String("ru"), 3065 HTMLURL: String("hu"), 3066 TargetType: String("tt"), 3067 SingleFileName: String("sfn"), 3068 RepositorySelection: String("rs"), 3069 Events: []string{"e"}, 3070 SingleFilePaths: []string{"s"}, 3071 Permissions: &InstallationPermissions{ 3072 Actions: String("a"), 3073 Administration: String("ad"), 3074 Checks: String("c"), 3075 Contents: String("co"), 3076 ContentReferences: String("cr"), 3077 Deployments: String("d"), 3078 Environments: String("e"), 3079 Issues: String("i"), 3080 Metadata: String("md"), 3081 Members: String("m"), 3082 OrganizationAdministration: String("oa"), 3083 OrganizationHooks: String("oh"), 3084 OrganizationPlan: String("op"), 3085 OrganizationPreReceiveHooks: String("opr"), 3086 OrganizationProjects: String("op"), 3087 OrganizationSecrets: String("os"), 3088 OrganizationSelfHostedRunners: String("osh"), 3089 OrganizationUserBlocking: String("oub"), 3090 Packages: String("pkg"), 3091 Pages: String("pg"), 3092 PullRequests: String("pr"), 3093 RepositoryHooks: String("rh"), 3094 RepositoryProjects: String("rp"), 3095 RepositoryPreReceiveHooks: String("rprh"), 3096 Secrets: String("s"), 3097 SecretScanningAlerts: String("ssa"), 3098 SecurityEvents: String("se"), 3099 SingleFile: String("sf"), 3100 Statuses: String("s"), 3101 TeamDiscussions: String("td"), 3102 VulnerabilityAlerts: String("va"), 3103 Workflows: String("w"), 3104 }, 3105 CreatedAt: &Timestamp{referenceTime}, 3106 UpdatedAt: &Timestamp{referenceTime}, 3107 HasMultipleSingleFiles: Bool(false), 3108 SuspendedBy: &User{ 3109 Login: String("l"), 3110 ID: Int64(1), 3111 URL: String("u"), 3112 AvatarURL: String("a"), 3113 GravatarID: String("g"), 3114 Name: String("n"), 3115 Company: String("c"), 3116 Blog: String("b"), 3117 Location: String("l"), 3118 Email: String("e"), 3119 Hireable: Bool(true), 3120 Bio: String("b"), 3121 TwitterUsername: String("t"), 3122 PublicRepos: Int(1), 3123 Followers: Int(1), 3124 Following: Int(1), 3125 CreatedAt: &Timestamp{referenceTime}, 3126 SuspendedAt: &Timestamp{referenceTime}, 3127 }, 3128 SuspendedAt: &Timestamp{referenceTime}, 3129 }, 3130 } 3131 3132 want := `{ 3133 "action": "a", 3134 "milestone": { 3135 "id": 1 3136 }, 3137 "changes": { 3138 "title": { 3139 "from": "TitleFrom" 3140 }, 3141 "body": { 3142 "from": "BodyFrom" 3143 }, 3144 "base": { 3145 "ref": { 3146 "from": "BaseRefFrom" 3147 }, 3148 "sha": { 3149 "from": "BaseSHAFrom" 3150 } 3151 } 3152 }, 3153 "repository": { 3154 "id": 1, 3155 "name": "n", 3156 "url": "s" 3157 }, 3158 "sender": { 3159 "login": "l", 3160 "id": 1, 3161 "node_id": "n", 3162 "avatar_url": "a", 3163 "url": "u", 3164 "events_url": "e", 3165 "repos_url": "r" 3166 }, 3167 "organization": { 3168 "name": "n", 3169 "company": "c", 3170 "blog": "b", 3171 "location": "loc", 3172 "email": "e", 3173 "twitter_username": "tu", 3174 "description": "d", 3175 "billing_email": "be", 3176 "is_verified": true, 3177 "has_organization_projects": true, 3178 "has_repository_projects": true, 3179 "default_repository_permission": "drp", 3180 "members_can_create_repositories": true, 3181 "members_can_create_public_repositories": false, 3182 "members_can_create_private_repositories": true, 3183 "members_can_create_internal_repositories": true, 3184 "members_allowed_repository_creation_type": "marct", 3185 "members_can_create_pages": true, 3186 "members_can_create_public_pages": false, 3187 "members_can_create_private_pages": true 3188 }, 3189 "installation": { 3190 "id": 1, 3191 "node_id": "nid", 3192 "app_id": 1, 3193 "app_slug": "as", 3194 "target_id": 1, 3195 "account": { 3196 "login": "l", 3197 "id": 1, 3198 "avatar_url": "a", 3199 "gravatar_id": "g", 3200 "name": "n", 3201 "company": "c", 3202 "blog": "b", 3203 "location": "l", 3204 "email": "e", 3205 "hireable": true, 3206 "bio": "b", 3207 "twitter_username": "t", 3208 "public_repos": 1, 3209 "followers": 1, 3210 "following": 1, 3211 "created_at": ` + referenceTimeStr + `, 3212 "suspended_at": ` + referenceTimeStr + `, 3213 "url": "u" 3214 }, 3215 "access_tokens_url": "atu", 3216 "repositories_url": "ru", 3217 "html_url": "hu", 3218 "target_type": "tt", 3219 "single_file_name": "sfn", 3220 "repository_selection": "rs", 3221 "events": [ 3222 "e" 3223 ], 3224 "single_file_paths": [ 3225 "s" 3226 ], 3227 "permissions": { 3228 "actions": "a", 3229 "administration": "ad", 3230 "checks": "c", 3231 "contents": "co", 3232 "content_references": "cr", 3233 "deployments": "d", 3234 "environments": "e", 3235 "issues": "i", 3236 "metadata": "md", 3237 "members": "m", 3238 "organization_administration": "oa", 3239 "organization_hooks": "oh", 3240 "organization_plan": "op", 3241 "organization_pre_receive_hooks": "opr", 3242 "organization_projects": "op", 3243 "organization_secrets": "os", 3244 "organization_self_hosted_runners": "osh", 3245 "organization_user_blocking": "oub", 3246 "packages": "pkg", 3247 "pages": "pg", 3248 "pull_requests": "pr", 3249 "repository_hooks": "rh", 3250 "repository_projects": "rp", 3251 "repository_pre_receive_hooks": "rprh", 3252 "secrets": "s", 3253 "secret_scanning_alerts": "ssa", 3254 "security_events": "se", 3255 "single_file": "sf", 3256 "statuses": "s", 3257 "team_discussions": "td", 3258 "vulnerability_alerts": "va", 3259 "workflows": "w" 3260 }, 3261 "created_at": ` + referenceTimeStr + `, 3262 "updated_at": ` + referenceTimeStr + `, 3263 "has_multiple_single_files": false, 3264 "suspended_by": { 3265 "login": "l", 3266 "id": 1, 3267 "avatar_url": "a", 3268 "gravatar_id": "g", 3269 "name": "n", 3270 "company": "c", 3271 "blog": "b", 3272 "location": "l", 3273 "email": "e", 3274 "hireable": true, 3275 "bio": "b", 3276 "twitter_username": "t", 3277 "public_repos": 1, 3278 "followers": 1, 3279 "following": 1, 3280 "created_at": ` + referenceTimeStr + `, 3281 "suspended_at": ` + referenceTimeStr + `, 3282 "url": "u" 3283 }, 3284 "suspended_at": ` + referenceTimeStr + ` 3285 } 3286 }` 3287 3288 testJSONMarshal(t, u, want) 3289 } 3290 3291 func TestPublicEvent_Marshal(t *testing.T) { 3292 t.Parallel() 3293 testJSONMarshal(t, &PublicEvent{}, "{}") 3294 3295 u := &PublicEvent{ 3296 Repo: &Repository{ 3297 ID: Int64(1), 3298 URL: String("s"), 3299 Name: String("n"), 3300 }, 3301 Sender: &User{ 3302 Login: String("l"), 3303 ID: Int64(1), 3304 NodeID: String("n"), 3305 URL: String("u"), 3306 ReposURL: String("r"), 3307 EventsURL: String("e"), 3308 AvatarURL: String("a"), 3309 }, 3310 Installation: &Installation{ 3311 ID: Int64(1), 3312 NodeID: String("nid"), 3313 AppID: Int64(1), 3314 AppSlug: String("as"), 3315 TargetID: Int64(1), 3316 Account: &User{ 3317 Login: String("l"), 3318 ID: Int64(1), 3319 URL: String("u"), 3320 AvatarURL: String("a"), 3321 GravatarID: String("g"), 3322 Name: String("n"), 3323 Company: String("c"), 3324 Blog: String("b"), 3325 Location: String("l"), 3326 Email: String("e"), 3327 Hireable: Bool(true), 3328 Bio: String("b"), 3329 TwitterUsername: String("t"), 3330 PublicRepos: Int(1), 3331 Followers: Int(1), 3332 Following: Int(1), 3333 CreatedAt: &Timestamp{referenceTime}, 3334 SuspendedAt: &Timestamp{referenceTime}, 3335 }, 3336 AccessTokensURL: String("atu"), 3337 RepositoriesURL: String("ru"), 3338 HTMLURL: String("hu"), 3339 TargetType: String("tt"), 3340 SingleFileName: String("sfn"), 3341 RepositorySelection: String("rs"), 3342 Events: []string{"e"}, 3343 SingleFilePaths: []string{"s"}, 3344 Permissions: &InstallationPermissions{ 3345 Actions: String("a"), 3346 Administration: String("ad"), 3347 Checks: String("c"), 3348 Contents: String("co"), 3349 ContentReferences: String("cr"), 3350 Deployments: String("d"), 3351 Environments: String("e"), 3352 Issues: String("i"), 3353 Metadata: String("md"), 3354 Members: String("m"), 3355 OrganizationAdministration: String("oa"), 3356 OrganizationHooks: String("oh"), 3357 OrganizationPlan: String("op"), 3358 OrganizationPreReceiveHooks: String("opr"), 3359 OrganizationProjects: String("op"), 3360 OrganizationSecrets: String("os"), 3361 OrganizationSelfHostedRunners: String("osh"), 3362 OrganizationUserBlocking: String("oub"), 3363 Packages: String("pkg"), 3364 Pages: String("pg"), 3365 PullRequests: String("pr"), 3366 RepositoryHooks: String("rh"), 3367 RepositoryProjects: String("rp"), 3368 RepositoryPreReceiveHooks: String("rprh"), 3369 Secrets: String("s"), 3370 SecretScanningAlerts: String("ssa"), 3371 SecurityEvents: String("se"), 3372 SingleFile: String("sf"), 3373 Statuses: String("s"), 3374 TeamDiscussions: String("td"), 3375 VulnerabilityAlerts: String("va"), 3376 Workflows: String("w"), 3377 }, 3378 CreatedAt: &Timestamp{referenceTime}, 3379 UpdatedAt: &Timestamp{referenceTime}, 3380 HasMultipleSingleFiles: Bool(false), 3381 SuspendedBy: &User{ 3382 Login: String("l"), 3383 ID: Int64(1), 3384 URL: String("u"), 3385 AvatarURL: String("a"), 3386 GravatarID: String("g"), 3387 Name: String("n"), 3388 Company: String("c"), 3389 Blog: String("b"), 3390 Location: String("l"), 3391 Email: String("e"), 3392 Hireable: Bool(true), 3393 Bio: String("b"), 3394 TwitterUsername: String("t"), 3395 PublicRepos: Int(1), 3396 Followers: Int(1), 3397 Following: Int(1), 3398 CreatedAt: &Timestamp{referenceTime}, 3399 SuspendedAt: &Timestamp{referenceTime}, 3400 }, 3401 SuspendedAt: &Timestamp{referenceTime}, 3402 }, 3403 } 3404 3405 want := `{ 3406 "repository": { 3407 "id": 1, 3408 "name": "n", 3409 "url": "s" 3410 }, 3411 "sender": { 3412 "login": "l", 3413 "id": 1, 3414 "node_id": "n", 3415 "avatar_url": "a", 3416 "url": "u", 3417 "events_url": "e", 3418 "repos_url": "r" 3419 }, 3420 "installation": { 3421 "id": 1, 3422 "node_id": "nid", 3423 "app_id": 1, 3424 "app_slug": "as", 3425 "target_id": 1, 3426 "account": { 3427 "login": "l", 3428 "id": 1, 3429 "avatar_url": "a", 3430 "gravatar_id": "g", 3431 "name": "n", 3432 "company": "c", 3433 "blog": "b", 3434 "location": "l", 3435 "email": "e", 3436 "hireable": true, 3437 "bio": "b", 3438 "twitter_username": "t", 3439 "public_repos": 1, 3440 "followers": 1, 3441 "following": 1, 3442 "created_at": ` + referenceTimeStr + `, 3443 "suspended_at": ` + referenceTimeStr + `, 3444 "url": "u" 3445 }, 3446 "access_tokens_url": "atu", 3447 "repositories_url": "ru", 3448 "html_url": "hu", 3449 "target_type": "tt", 3450 "single_file_name": "sfn", 3451 "repository_selection": "rs", 3452 "events": [ 3453 "e" 3454 ], 3455 "single_file_paths": [ 3456 "s" 3457 ], 3458 "permissions": { 3459 "actions": "a", 3460 "administration": "ad", 3461 "checks": "c", 3462 "contents": "co", 3463 "content_references": "cr", 3464 "deployments": "d", 3465 "environments": "e", 3466 "issues": "i", 3467 "metadata": "md", 3468 "members": "m", 3469 "organization_administration": "oa", 3470 "organization_hooks": "oh", 3471 "organization_plan": "op", 3472 "organization_pre_receive_hooks": "opr", 3473 "organization_projects": "op", 3474 "organization_secrets": "os", 3475 "organization_self_hosted_runners": "osh", 3476 "organization_user_blocking": "oub", 3477 "packages": "pkg", 3478 "pages": "pg", 3479 "pull_requests": "pr", 3480 "repository_hooks": "rh", 3481 "repository_projects": "rp", 3482 "repository_pre_receive_hooks": "rprh", 3483 "secrets": "s", 3484 "secret_scanning_alerts": "ssa", 3485 "security_events": "se", 3486 "single_file": "sf", 3487 "statuses": "s", 3488 "team_discussions": "td", 3489 "vulnerability_alerts": "va", 3490 "workflows": "w" 3491 }, 3492 "created_at": ` + referenceTimeStr + `, 3493 "updated_at": ` + referenceTimeStr + `, 3494 "has_multiple_single_files": false, 3495 "suspended_by": { 3496 "login": "l", 3497 "id": 1, 3498 "avatar_url": "a", 3499 "gravatar_id": "g", 3500 "name": "n", 3501 "company": "c", 3502 "blog": "b", 3503 "location": "l", 3504 "email": "e", 3505 "hireable": true, 3506 "bio": "b", 3507 "twitter_username": "t", 3508 "public_repos": 1, 3509 "followers": 1, 3510 "following": 1, 3511 "created_at": ` + referenceTimeStr + `, 3512 "suspended_at": ` + referenceTimeStr + `, 3513 "url": "u" 3514 }, 3515 "suspended_at": ` + referenceTimeStr + ` 3516 } 3517 }` 3518 3519 testJSONMarshal(t, u, want) 3520 } 3521 3522 func TestPullRequestReviewEvent_Marshal(t *testing.T) { 3523 t.Parallel() 3524 testJSONMarshal(t, &PullRequestReviewEvent{}, "{}") 3525 3526 u := &PullRequestReviewEvent{ 3527 Action: String("a"), 3528 Review: &PullRequestReview{ID: Int64(1)}, 3529 PullRequest: &PullRequest{ID: Int64(1)}, 3530 Repo: &Repository{ 3531 ID: Int64(1), 3532 URL: String("s"), 3533 Name: String("n"), 3534 }, 3535 Sender: &User{ 3536 Login: String("l"), 3537 ID: Int64(1), 3538 NodeID: String("n"), 3539 URL: String("u"), 3540 ReposURL: String("r"), 3541 EventsURL: String("e"), 3542 AvatarURL: String("a"), 3543 }, 3544 Installation: &Installation{ 3545 ID: Int64(1), 3546 NodeID: String("nid"), 3547 AppID: Int64(1), 3548 AppSlug: String("as"), 3549 TargetID: Int64(1), 3550 Account: &User{ 3551 Login: String("l"), 3552 ID: Int64(1), 3553 URL: String("u"), 3554 AvatarURL: String("a"), 3555 GravatarID: String("g"), 3556 Name: String("n"), 3557 Company: String("c"), 3558 Blog: String("b"), 3559 Location: String("l"), 3560 Email: String("e"), 3561 Hireable: Bool(true), 3562 Bio: String("b"), 3563 TwitterUsername: String("t"), 3564 PublicRepos: Int(1), 3565 Followers: Int(1), 3566 Following: Int(1), 3567 CreatedAt: &Timestamp{referenceTime}, 3568 SuspendedAt: &Timestamp{referenceTime}, 3569 }, 3570 AccessTokensURL: String("atu"), 3571 RepositoriesURL: String("ru"), 3572 HTMLURL: String("hu"), 3573 TargetType: String("tt"), 3574 SingleFileName: String("sfn"), 3575 RepositorySelection: String("rs"), 3576 Events: []string{"e"}, 3577 SingleFilePaths: []string{"s"}, 3578 Permissions: &InstallationPermissions{ 3579 Actions: String("a"), 3580 Administration: String("ad"), 3581 Checks: String("c"), 3582 Contents: String("co"), 3583 ContentReferences: String("cr"), 3584 Deployments: String("d"), 3585 Environments: String("e"), 3586 Issues: String("i"), 3587 Metadata: String("md"), 3588 Members: String("m"), 3589 OrganizationAdministration: String("oa"), 3590 OrganizationHooks: String("oh"), 3591 OrganizationPlan: String("op"), 3592 OrganizationPreReceiveHooks: String("opr"), 3593 OrganizationProjects: String("op"), 3594 OrganizationSecrets: String("os"), 3595 OrganizationSelfHostedRunners: String("osh"), 3596 OrganizationUserBlocking: String("oub"), 3597 Packages: String("pkg"), 3598 Pages: String("pg"), 3599 PullRequests: String("pr"), 3600 RepositoryHooks: String("rh"), 3601 RepositoryProjects: String("rp"), 3602 RepositoryPreReceiveHooks: String("rprh"), 3603 Secrets: String("s"), 3604 SecretScanningAlerts: String("ssa"), 3605 SecurityEvents: String("se"), 3606 SingleFile: String("sf"), 3607 Statuses: String("s"), 3608 TeamDiscussions: String("td"), 3609 VulnerabilityAlerts: String("va"), 3610 Workflows: String("w"), 3611 }, 3612 CreatedAt: &Timestamp{referenceTime}, 3613 UpdatedAt: &Timestamp{referenceTime}, 3614 HasMultipleSingleFiles: Bool(false), 3615 SuspendedBy: &User{ 3616 Login: String("l"), 3617 ID: Int64(1), 3618 URL: String("u"), 3619 AvatarURL: String("a"), 3620 GravatarID: String("g"), 3621 Name: String("n"), 3622 Company: String("c"), 3623 Blog: String("b"), 3624 Location: String("l"), 3625 Email: String("e"), 3626 Hireable: Bool(true), 3627 Bio: String("b"), 3628 TwitterUsername: String("t"), 3629 PublicRepos: Int(1), 3630 Followers: Int(1), 3631 Following: Int(1), 3632 CreatedAt: &Timestamp{referenceTime}, 3633 SuspendedAt: &Timestamp{referenceTime}, 3634 }, 3635 SuspendedAt: &Timestamp{referenceTime}, 3636 }, 3637 Organization: &Organization{ 3638 BillingEmail: String("be"), 3639 Blog: String("b"), 3640 Company: String("c"), 3641 Email: String("e"), 3642 TwitterUsername: String("tu"), 3643 Location: String("loc"), 3644 Name: String("n"), 3645 Description: String("d"), 3646 IsVerified: Bool(true), 3647 HasOrganizationProjects: Bool(true), 3648 HasRepositoryProjects: Bool(true), 3649 DefaultRepoPermission: String("drp"), 3650 MembersCanCreateRepos: Bool(true), 3651 MembersCanCreateInternalRepos: Bool(true), 3652 MembersCanCreatePrivateRepos: Bool(true), 3653 MembersCanCreatePublicRepos: Bool(false), 3654 MembersAllowedRepositoryCreationType: String("marct"), 3655 MembersCanCreatePages: Bool(true), 3656 MembersCanCreatePublicPages: Bool(false), 3657 MembersCanCreatePrivatePages: Bool(true), 3658 }, 3659 } 3660 3661 want := `{ 3662 "action": "a", 3663 "review": { 3664 "id": 1 3665 }, 3666 "pull_request": { 3667 "id": 1 3668 }, 3669 "repository": { 3670 "id": 1, 3671 "name": "n", 3672 "url": "s" 3673 }, 3674 "sender": { 3675 "login": "l", 3676 "id": 1, 3677 "node_id": "n", 3678 "avatar_url": "a", 3679 "url": "u", 3680 "events_url": "e", 3681 "repos_url": "r" 3682 }, 3683 "installation": { 3684 "id": 1, 3685 "node_id": "nid", 3686 "app_id": 1, 3687 "app_slug": "as", 3688 "target_id": 1, 3689 "account": { 3690 "login": "l", 3691 "id": 1, 3692 "avatar_url": "a", 3693 "gravatar_id": "g", 3694 "name": "n", 3695 "company": "c", 3696 "blog": "b", 3697 "location": "l", 3698 "email": "e", 3699 "hireable": true, 3700 "bio": "b", 3701 "twitter_username": "t", 3702 "public_repos": 1, 3703 "followers": 1, 3704 "following": 1, 3705 "created_at": ` + referenceTimeStr + `, 3706 "suspended_at": ` + referenceTimeStr + `, 3707 "url": "u" 3708 }, 3709 "access_tokens_url": "atu", 3710 "repositories_url": "ru", 3711 "html_url": "hu", 3712 "target_type": "tt", 3713 "single_file_name": "sfn", 3714 "repository_selection": "rs", 3715 "events": [ 3716 "e" 3717 ], 3718 "single_file_paths": [ 3719 "s" 3720 ], 3721 "permissions": { 3722 "actions": "a", 3723 "administration": "ad", 3724 "checks": "c", 3725 "contents": "co", 3726 "content_references": "cr", 3727 "deployments": "d", 3728 "environments": "e", 3729 "issues": "i", 3730 "metadata": "md", 3731 "members": "m", 3732 "organization_administration": "oa", 3733 "organization_hooks": "oh", 3734 "organization_plan": "op", 3735 "organization_pre_receive_hooks": "opr", 3736 "organization_projects": "op", 3737 "organization_secrets": "os", 3738 "organization_self_hosted_runners": "osh", 3739 "organization_user_blocking": "oub", 3740 "packages": "pkg", 3741 "pages": "pg", 3742 "pull_requests": "pr", 3743 "repository_hooks": "rh", 3744 "repository_projects": "rp", 3745 "repository_pre_receive_hooks": "rprh", 3746 "secrets": "s", 3747 "secret_scanning_alerts": "ssa", 3748 "security_events": "se", 3749 "single_file": "sf", 3750 "statuses": "s", 3751 "team_discussions": "td", 3752 "vulnerability_alerts": "va", 3753 "workflows": "w" 3754 }, 3755 "created_at": ` + referenceTimeStr + `, 3756 "updated_at": ` + referenceTimeStr + `, 3757 "has_multiple_single_files": false, 3758 "suspended_by": { 3759 "login": "l", 3760 "id": 1, 3761 "avatar_url": "a", 3762 "gravatar_id": "g", 3763 "name": "n", 3764 "company": "c", 3765 "blog": "b", 3766 "location": "l", 3767 "email": "e", 3768 "hireable": true, 3769 "bio": "b", 3770 "twitter_username": "t", 3771 "public_repos": 1, 3772 "followers": 1, 3773 "following": 1, 3774 "created_at": ` + referenceTimeStr + `, 3775 "suspended_at": ` + referenceTimeStr + `, 3776 "url": "u" 3777 }, 3778 "suspended_at": ` + referenceTimeStr + ` 3779 }, 3780 "organization": { 3781 "name": "n", 3782 "company": "c", 3783 "blog": "b", 3784 "location": "loc", 3785 "email": "e", 3786 "twitter_username": "tu", 3787 "description": "d", 3788 "billing_email": "be", 3789 "is_verified": true, 3790 "has_organization_projects": true, 3791 "has_repository_projects": true, 3792 "default_repository_permission": "drp", 3793 "members_can_create_repositories": true, 3794 "members_can_create_public_repositories": false, 3795 "members_can_create_private_repositories": true, 3796 "members_can_create_internal_repositories": true, 3797 "members_allowed_repository_creation_type": "marct", 3798 "members_can_create_pages": true, 3799 "members_can_create_public_pages": false, 3800 "members_can_create_private_pages": true 3801 } 3802 }` 3803 3804 testJSONMarshal(t, u, want) 3805 } 3806 3807 func TestPushEvent_Marshal(t *testing.T) { 3808 t.Parallel() 3809 testJSONMarshal(t, &PushEvent{}, "{}") 3810 3811 u := &PushEvent{ 3812 PushID: Int64(1), 3813 Head: String("h"), 3814 Ref: String("ref"), 3815 Size: Int(1), 3816 Commits: []*HeadCommit{ 3817 {ID: String("id")}, 3818 }, 3819 Before: String("b"), 3820 DistinctSize: Int(1), 3821 After: String("a"), 3822 Created: Bool(true), 3823 Deleted: Bool(true), 3824 Forced: Bool(true), 3825 BaseRef: String("a"), 3826 Compare: String("a"), 3827 Repo: &PushEventRepository{ID: Int64(1)}, 3828 HeadCommit: &HeadCommit{ID: String("id")}, 3829 Pusher: &CommitAuthor{ 3830 Login: String("l"), 3831 Date: &Timestamp{referenceTime}, 3832 Name: String("n"), 3833 Email: String("e"), 3834 }, 3835 Sender: &User{ 3836 Login: String("l"), 3837 ID: Int64(1), 3838 NodeID: String("n"), 3839 URL: String("u"), 3840 ReposURL: String("r"), 3841 EventsURL: String("e"), 3842 AvatarURL: String("a"), 3843 }, 3844 Installation: &Installation{ 3845 ID: Int64(1), 3846 NodeID: String("nid"), 3847 AppID: Int64(1), 3848 AppSlug: String("as"), 3849 TargetID: Int64(1), 3850 Account: &User{ 3851 Login: String("l"), 3852 ID: Int64(1), 3853 URL: String("u"), 3854 AvatarURL: String("a"), 3855 GravatarID: String("g"), 3856 Name: String("n"), 3857 Company: String("c"), 3858 Blog: String("b"), 3859 Location: String("l"), 3860 Email: String("e"), 3861 Hireable: Bool(true), 3862 Bio: String("b"), 3863 TwitterUsername: String("t"), 3864 PublicRepos: Int(1), 3865 Followers: Int(1), 3866 Following: Int(1), 3867 CreatedAt: &Timestamp{referenceTime}, 3868 SuspendedAt: &Timestamp{referenceTime}, 3869 }, 3870 AccessTokensURL: String("atu"), 3871 RepositoriesURL: String("ru"), 3872 HTMLURL: String("hu"), 3873 TargetType: String("tt"), 3874 SingleFileName: String("sfn"), 3875 RepositorySelection: String("rs"), 3876 Events: []string{"e"}, 3877 SingleFilePaths: []string{"s"}, 3878 Permissions: &InstallationPermissions{ 3879 Actions: String("a"), 3880 Administration: String("ad"), 3881 Checks: String("c"), 3882 Contents: String("co"), 3883 ContentReferences: String("cr"), 3884 Deployments: String("d"), 3885 Environments: String("e"), 3886 Issues: String("i"), 3887 Metadata: String("md"), 3888 Members: String("m"), 3889 OrganizationAdministration: String("oa"), 3890 OrganizationHooks: String("oh"), 3891 OrganizationPlan: String("op"), 3892 OrganizationPreReceiveHooks: String("opr"), 3893 OrganizationProjects: String("op"), 3894 OrganizationSecrets: String("os"), 3895 OrganizationSelfHostedRunners: String("osh"), 3896 OrganizationUserBlocking: String("oub"), 3897 Packages: String("pkg"), 3898 Pages: String("pg"), 3899 PullRequests: String("pr"), 3900 RepositoryHooks: String("rh"), 3901 RepositoryProjects: String("rp"), 3902 RepositoryPreReceiveHooks: String("rprh"), 3903 Secrets: String("s"), 3904 SecretScanningAlerts: String("ssa"), 3905 SecurityEvents: String("se"), 3906 SingleFile: String("sf"), 3907 Statuses: String("s"), 3908 TeamDiscussions: String("td"), 3909 VulnerabilityAlerts: String("va"), 3910 Workflows: String("w"), 3911 }, 3912 CreatedAt: &Timestamp{referenceTime}, 3913 UpdatedAt: &Timestamp{referenceTime}, 3914 HasMultipleSingleFiles: Bool(false), 3915 SuspendedBy: &User{ 3916 Login: String("l"), 3917 ID: Int64(1), 3918 URL: String("u"), 3919 AvatarURL: String("a"), 3920 GravatarID: String("g"), 3921 Name: String("n"), 3922 Company: String("c"), 3923 Blog: String("b"), 3924 Location: String("l"), 3925 Email: String("e"), 3926 Hireable: Bool(true), 3927 Bio: String("b"), 3928 TwitterUsername: String("t"), 3929 PublicRepos: Int(1), 3930 Followers: Int(1), 3931 Following: Int(1), 3932 CreatedAt: &Timestamp{referenceTime}, 3933 SuspendedAt: &Timestamp{referenceTime}, 3934 }, 3935 SuspendedAt: &Timestamp{referenceTime}, 3936 }, 3937 Organization: &Organization{ 3938 BillingEmail: String("be"), 3939 Blog: String("b"), 3940 Company: String("c"), 3941 Email: String("e"), 3942 TwitterUsername: String("tu"), 3943 Location: String("loc"), 3944 Name: String("n"), 3945 Description: String("d"), 3946 IsVerified: Bool(true), 3947 HasOrganizationProjects: Bool(true), 3948 HasRepositoryProjects: Bool(true), 3949 DefaultRepoPermission: String("drp"), 3950 MembersCanCreateRepos: Bool(true), 3951 MembersCanCreateInternalRepos: Bool(true), 3952 MembersCanCreatePrivateRepos: Bool(true), 3953 MembersCanCreatePublicRepos: Bool(false), 3954 MembersAllowedRepositoryCreationType: String("marct"), 3955 MembersCanCreatePages: Bool(true), 3956 MembersCanCreatePublicPages: Bool(false), 3957 MembersCanCreatePrivatePages: Bool(true), 3958 }, 3959 } 3960 3961 want := `{ 3962 "push_id": 1, 3963 "head": "h", 3964 "ref": "ref", 3965 "size": 1, 3966 "commits": [ 3967 { 3968 "id": "id" 3969 } 3970 ], 3971 "before": "b", 3972 "distinct_size": 1, 3973 "after": "a", 3974 "created": true, 3975 "deleted": true, 3976 "forced": true, 3977 "base_ref": "a", 3978 "compare": "a", 3979 "repository": { 3980 "id": 1 3981 }, 3982 "head_commit": { 3983 "id": "id" 3984 }, 3985 "pusher": { 3986 "date": ` + referenceTimeStr + `, 3987 "name": "n", 3988 "email": "e", 3989 "username": "l" 3990 }, 3991 "sender": { 3992 "login": "l", 3993 "id": 1, 3994 "node_id": "n", 3995 "avatar_url": "a", 3996 "url": "u", 3997 "events_url": "e", 3998 "repos_url": "r" 3999 }, 4000 "installation": { 4001 "id": 1, 4002 "node_id": "nid", 4003 "app_id": 1, 4004 "app_slug": "as", 4005 "target_id": 1, 4006 "account": { 4007 "login": "l", 4008 "id": 1, 4009 "avatar_url": "a", 4010 "gravatar_id": "g", 4011 "name": "n", 4012 "company": "c", 4013 "blog": "b", 4014 "location": "l", 4015 "email": "e", 4016 "hireable": true, 4017 "bio": "b", 4018 "twitter_username": "t", 4019 "public_repos": 1, 4020 "followers": 1, 4021 "following": 1, 4022 "created_at": ` + referenceTimeStr + `, 4023 "suspended_at": ` + referenceTimeStr + `, 4024 "url": "u" 4025 }, 4026 "access_tokens_url": "atu", 4027 "repositories_url": "ru", 4028 "html_url": "hu", 4029 "target_type": "tt", 4030 "single_file_name": "sfn", 4031 "repository_selection": "rs", 4032 "events": [ 4033 "e" 4034 ], 4035 "single_file_paths": [ 4036 "s" 4037 ], 4038 "permissions": { 4039 "actions": "a", 4040 "administration": "ad", 4041 "checks": "c", 4042 "contents": "co", 4043 "content_references": "cr", 4044 "deployments": "d", 4045 "environments": "e", 4046 "issues": "i", 4047 "metadata": "md", 4048 "members": "m", 4049 "organization_administration": "oa", 4050 "organization_hooks": "oh", 4051 "organization_plan": "op", 4052 "organization_pre_receive_hooks": "opr", 4053 "organization_projects": "op", 4054 "organization_secrets": "os", 4055 "organization_self_hosted_runners": "osh", 4056 "organization_user_blocking": "oub", 4057 "packages": "pkg", 4058 "pages": "pg", 4059 "pull_requests": "pr", 4060 "repository_hooks": "rh", 4061 "repository_projects": "rp", 4062 "repository_pre_receive_hooks": "rprh", 4063 "secrets": "s", 4064 "secret_scanning_alerts": "ssa", 4065 "security_events": "se", 4066 "single_file": "sf", 4067 "statuses": "s", 4068 "team_discussions": "td", 4069 "vulnerability_alerts": "va", 4070 "workflows": "w" 4071 }, 4072 "created_at": ` + referenceTimeStr + `, 4073 "updated_at": ` + referenceTimeStr + `, 4074 "has_multiple_single_files": false, 4075 "suspended_by": { 4076 "login": "l", 4077 "id": 1, 4078 "avatar_url": "a", 4079 "gravatar_id": "g", 4080 "name": "n", 4081 "company": "c", 4082 "blog": "b", 4083 "location": "l", 4084 "email": "e", 4085 "hireable": true, 4086 "bio": "b", 4087 "twitter_username": "t", 4088 "public_repos": 1, 4089 "followers": 1, 4090 "following": 1, 4091 "created_at": ` + referenceTimeStr + `, 4092 "suspended_at": ` + referenceTimeStr + `, 4093 "url": "u" 4094 }, 4095 "suspended_at": ` + referenceTimeStr + ` 4096 }, 4097 "organization": { 4098 "name": "n", 4099 "company": "c", 4100 "blog": "b", 4101 "location": "loc", 4102 "email": "e", 4103 "twitter_username": "tu", 4104 "description": "d", 4105 "billing_email": "be", 4106 "is_verified": true, 4107 "has_organization_projects": true, 4108 "has_repository_projects": true, 4109 "default_repository_permission": "drp", 4110 "members_can_create_repositories": true, 4111 "members_can_create_public_repositories": false, 4112 "members_can_create_private_repositories": true, 4113 "members_can_create_internal_repositories": true, 4114 "members_allowed_repository_creation_type": "marct", 4115 "members_can_create_pages": true, 4116 "members_can_create_public_pages": false, 4117 "members_can_create_private_pages": true 4118 } 4119 }` 4120 4121 testJSONMarshal(t, u, want) 4122 } 4123 4124 func TestStatusEvent_Marshal(t *testing.T) { 4125 t.Parallel() 4126 testJSONMarshal(t, &StatusEvent{}, "{}") 4127 4128 u := &StatusEvent{ 4129 SHA: String("sha"), 4130 State: String("s"), 4131 Description: String("d"), 4132 TargetURL: String("turl"), 4133 Branches: []*Branch{ 4134 { 4135 Name: String("n"), 4136 Commit: &RepositoryCommit{NodeID: String("nid")}, 4137 Protected: Bool(false), 4138 }, 4139 }, 4140 ID: Int64(1), 4141 Name: String("n"), 4142 Context: String("c"), 4143 Commit: &RepositoryCommit{NodeID: String("nid")}, 4144 CreatedAt: &Timestamp{referenceTime}, 4145 UpdatedAt: &Timestamp{referenceTime}, 4146 Sender: &User{ 4147 Login: String("l"), 4148 ID: Int64(1), 4149 NodeID: String("n"), 4150 URL: String("u"), 4151 ReposURL: String("r"), 4152 EventsURL: String("e"), 4153 AvatarURL: String("a"), 4154 }, 4155 Installation: &Installation{ 4156 ID: Int64(1), 4157 NodeID: String("nid"), 4158 AppID: Int64(1), 4159 AppSlug: String("as"), 4160 TargetID: Int64(1), 4161 Account: &User{ 4162 Login: String("l"), 4163 ID: Int64(1), 4164 URL: String("u"), 4165 AvatarURL: String("a"), 4166 GravatarID: String("g"), 4167 Name: String("n"), 4168 Company: String("c"), 4169 Blog: String("b"), 4170 Location: String("l"), 4171 Email: String("e"), 4172 Hireable: Bool(true), 4173 Bio: String("b"), 4174 TwitterUsername: String("t"), 4175 PublicRepos: Int(1), 4176 Followers: Int(1), 4177 Following: Int(1), 4178 CreatedAt: &Timestamp{referenceTime}, 4179 SuspendedAt: &Timestamp{referenceTime}, 4180 }, 4181 AccessTokensURL: String("atu"), 4182 RepositoriesURL: String("ru"), 4183 HTMLURL: String("hu"), 4184 TargetType: String("tt"), 4185 SingleFileName: String("sfn"), 4186 RepositorySelection: String("rs"), 4187 Events: []string{"e"}, 4188 SingleFilePaths: []string{"s"}, 4189 Permissions: &InstallationPermissions{ 4190 Actions: String("a"), 4191 Administration: String("ad"), 4192 Checks: String("c"), 4193 Contents: String("co"), 4194 ContentReferences: String("cr"), 4195 Deployments: String("d"), 4196 Environments: String("e"), 4197 Issues: String("i"), 4198 Metadata: String("md"), 4199 Members: String("m"), 4200 OrganizationAdministration: String("oa"), 4201 OrganizationHooks: String("oh"), 4202 OrganizationPlan: String("op"), 4203 OrganizationPreReceiveHooks: String("opr"), 4204 OrganizationProjects: String("op"), 4205 OrganizationSecrets: String("os"), 4206 OrganizationSelfHostedRunners: String("osh"), 4207 OrganizationUserBlocking: String("oub"), 4208 Packages: String("pkg"), 4209 Pages: String("pg"), 4210 PullRequests: String("pr"), 4211 RepositoryHooks: String("rh"), 4212 RepositoryProjects: String("rp"), 4213 RepositoryPreReceiveHooks: String("rprh"), 4214 Secrets: String("s"), 4215 SecretScanningAlerts: String("ssa"), 4216 SecurityEvents: String("se"), 4217 SingleFile: String("sf"), 4218 Statuses: String("s"), 4219 TeamDiscussions: String("td"), 4220 VulnerabilityAlerts: String("va"), 4221 Workflows: String("w"), 4222 }, 4223 CreatedAt: &Timestamp{referenceTime}, 4224 UpdatedAt: &Timestamp{referenceTime}, 4225 HasMultipleSingleFiles: Bool(false), 4226 SuspendedBy: &User{ 4227 Login: String("l"), 4228 ID: Int64(1), 4229 URL: String("u"), 4230 AvatarURL: String("a"), 4231 GravatarID: String("g"), 4232 Name: String("n"), 4233 Company: String("c"), 4234 Blog: String("b"), 4235 Location: String("l"), 4236 Email: String("e"), 4237 Hireable: Bool(true), 4238 Bio: String("b"), 4239 TwitterUsername: String("t"), 4240 PublicRepos: Int(1), 4241 Followers: Int(1), 4242 Following: Int(1), 4243 CreatedAt: &Timestamp{referenceTime}, 4244 SuspendedAt: &Timestamp{referenceTime}, 4245 }, 4246 SuspendedAt: &Timestamp{referenceTime}, 4247 }, 4248 } 4249 4250 want := `{ 4251 "sha": "sha", 4252 "state": "s", 4253 "description": "d", 4254 "target_url": "turl", 4255 "branches": [ 4256 { 4257 "name": "n", 4258 "commit": { 4259 "node_id": "nid" 4260 }, 4261 "protected": false 4262 } 4263 ], 4264 "id": 1, 4265 "name": "n", 4266 "context": "c", 4267 "commit": { 4268 "node_id": "nid" 4269 }, 4270 "created_at": ` + referenceTimeStr + `, 4271 "updated_at": ` + referenceTimeStr + `, 4272 "sender": { 4273 "login": "l", 4274 "id": 1, 4275 "node_id": "n", 4276 "avatar_url": "a", 4277 "url": "u", 4278 "events_url": "e", 4279 "repos_url": "r" 4280 }, 4281 "installation": { 4282 "id": 1, 4283 "node_id": "nid", 4284 "app_id": 1, 4285 "app_slug": "as", 4286 "target_id": 1, 4287 "account": { 4288 "login": "l", 4289 "id": 1, 4290 "avatar_url": "a", 4291 "gravatar_id": "g", 4292 "name": "n", 4293 "company": "c", 4294 "blog": "b", 4295 "location": "l", 4296 "email": "e", 4297 "hireable": true, 4298 "bio": "b", 4299 "twitter_username": "t", 4300 "public_repos": 1, 4301 "followers": 1, 4302 "following": 1, 4303 "created_at": ` + referenceTimeStr + `, 4304 "suspended_at": ` + referenceTimeStr + `, 4305 "url": "u" 4306 }, 4307 "access_tokens_url": "atu", 4308 "repositories_url": "ru", 4309 "html_url": "hu", 4310 "target_type": "tt", 4311 "single_file_name": "sfn", 4312 "repository_selection": "rs", 4313 "events": [ 4314 "e" 4315 ], 4316 "single_file_paths": [ 4317 "s" 4318 ], 4319 "permissions": { 4320 "actions": "a", 4321 "administration": "ad", 4322 "checks": "c", 4323 "contents": "co", 4324 "content_references": "cr", 4325 "deployments": "d", 4326 "environments": "e", 4327 "issues": "i", 4328 "metadata": "md", 4329 "members": "m", 4330 "organization_administration": "oa", 4331 "organization_hooks": "oh", 4332 "organization_plan": "op", 4333 "organization_pre_receive_hooks": "opr", 4334 "organization_projects": "op", 4335 "organization_secrets": "os", 4336 "organization_self_hosted_runners": "osh", 4337 "organization_user_blocking": "oub", 4338 "packages": "pkg", 4339 "pages": "pg", 4340 "pull_requests": "pr", 4341 "repository_hooks": "rh", 4342 "repository_projects": "rp", 4343 "repository_pre_receive_hooks": "rprh", 4344 "secrets": "s", 4345 "secret_scanning_alerts": "ssa", 4346 "security_events": "se", 4347 "single_file": "sf", 4348 "statuses": "s", 4349 "team_discussions": "td", 4350 "vulnerability_alerts": "va", 4351 "workflows": "w" 4352 }, 4353 "created_at": ` + referenceTimeStr + `, 4354 "updated_at": ` + referenceTimeStr + `, 4355 "has_multiple_single_files": false, 4356 "suspended_by": { 4357 "login": "l", 4358 "id": 1, 4359 "avatar_url": "a", 4360 "gravatar_id": "g", 4361 "name": "n", 4362 "company": "c", 4363 "blog": "b", 4364 "location": "l", 4365 "email": "e", 4366 "hireable": true, 4367 "bio": "b", 4368 "twitter_username": "t", 4369 "public_repos": 1, 4370 "followers": 1, 4371 "following": 1, 4372 "created_at": ` + referenceTimeStr + `, 4373 "suspended_at": ` + referenceTimeStr + `, 4374 "url": "u" 4375 }, 4376 "suspended_at": ` + referenceTimeStr + ` 4377 } 4378 }` 4379 4380 testJSONMarshal(t, u, want) 4381 } 4382 4383 func TestMarketplacePurchaseEvent_Marshal(t *testing.T) { 4384 t.Parallel() 4385 testJSONMarshal(t, &MarketplacePurchaseEvent{}, "{}") 4386 4387 u := &MarketplacePurchaseEvent{ 4388 Action: String("a"), 4389 EffectiveDate: &Timestamp{referenceTime}, 4390 MarketplacePurchase: &MarketplacePurchase{ 4391 BillingCycle: String("bc"), 4392 NextBillingDate: &Timestamp{referenceTime}, 4393 UnitCount: Int(1), 4394 Plan: &MarketplacePlan{ 4395 URL: String("u"), 4396 AccountsURL: String("au"), 4397 ID: Int64(1), 4398 Number: Int(1), 4399 Name: String("n"), 4400 Description: String("d"), 4401 MonthlyPriceInCents: Int(1), 4402 YearlyPriceInCents: Int(1), 4403 PriceModel: String("pm"), 4404 UnitName: String("un"), 4405 Bullets: &[]string{"b"}, 4406 State: String("s"), 4407 HasFreeTrial: Bool(false), 4408 }, 4409 OnFreeTrial: Bool(false), 4410 FreeTrialEndsOn: &Timestamp{referenceTime}, 4411 UpdatedAt: &Timestamp{referenceTime}, 4412 }, 4413 PreviousMarketplacePurchase: &MarketplacePurchase{ 4414 BillingCycle: String("bc"), 4415 NextBillingDate: &Timestamp{referenceTime}, 4416 UnitCount: Int(1), 4417 Plan: &MarketplacePlan{ 4418 URL: String("u"), 4419 AccountsURL: String("au"), 4420 ID: Int64(1), 4421 Number: Int(1), 4422 Name: String("n"), 4423 Description: String("d"), 4424 MonthlyPriceInCents: Int(1), 4425 YearlyPriceInCents: Int(1), 4426 PriceModel: String("pm"), 4427 UnitName: String("un"), 4428 Bullets: &[]string{"b"}, 4429 State: String("s"), 4430 HasFreeTrial: Bool(false), 4431 }, 4432 OnFreeTrial: Bool(false), 4433 FreeTrialEndsOn: &Timestamp{referenceTime}, 4434 UpdatedAt: &Timestamp{referenceTime}, 4435 }, 4436 Sender: &User{ 4437 Login: String("l"), 4438 ID: Int64(1), 4439 NodeID: String("n"), 4440 URL: String("u"), 4441 ReposURL: String("r"), 4442 EventsURL: String("e"), 4443 AvatarURL: String("a"), 4444 }, 4445 Installation: &Installation{ 4446 ID: Int64(1), 4447 NodeID: String("nid"), 4448 AppID: Int64(1), 4449 AppSlug: String("as"), 4450 TargetID: Int64(1), 4451 Account: &User{ 4452 Login: String("l"), 4453 ID: Int64(1), 4454 URL: String("u"), 4455 AvatarURL: String("a"), 4456 GravatarID: String("g"), 4457 Name: String("n"), 4458 Company: String("c"), 4459 Blog: String("b"), 4460 Location: String("l"), 4461 Email: String("e"), 4462 Hireable: Bool(true), 4463 Bio: String("b"), 4464 TwitterUsername: String("t"), 4465 PublicRepos: Int(1), 4466 Followers: Int(1), 4467 Following: Int(1), 4468 CreatedAt: &Timestamp{referenceTime}, 4469 SuspendedAt: &Timestamp{referenceTime}, 4470 }, 4471 AccessTokensURL: String("atu"), 4472 RepositoriesURL: String("ru"), 4473 HTMLURL: String("hu"), 4474 TargetType: String("tt"), 4475 SingleFileName: String("sfn"), 4476 RepositorySelection: String("rs"), 4477 Events: []string{"e"}, 4478 SingleFilePaths: []string{"s"}, 4479 Permissions: &InstallationPermissions{ 4480 Actions: String("a"), 4481 Administration: String("ad"), 4482 Checks: String("c"), 4483 Contents: String("co"), 4484 ContentReferences: String("cr"), 4485 Deployments: String("d"), 4486 Environments: String("e"), 4487 Issues: String("i"), 4488 Metadata: String("md"), 4489 Members: String("m"), 4490 OrganizationAdministration: String("oa"), 4491 OrganizationHooks: String("oh"), 4492 OrganizationPlan: String("op"), 4493 OrganizationPreReceiveHooks: String("opr"), 4494 OrganizationProjects: String("op"), 4495 OrganizationSecrets: String("os"), 4496 OrganizationSelfHostedRunners: String("osh"), 4497 OrganizationUserBlocking: String("oub"), 4498 Packages: String("pkg"), 4499 Pages: String("pg"), 4500 PullRequests: String("pr"), 4501 RepositoryHooks: String("rh"), 4502 RepositoryProjects: String("rp"), 4503 RepositoryPreReceiveHooks: String("rprh"), 4504 Secrets: String("s"), 4505 SecretScanningAlerts: String("ssa"), 4506 SecurityEvents: String("se"), 4507 SingleFile: String("sf"), 4508 Statuses: String("s"), 4509 TeamDiscussions: String("td"), 4510 VulnerabilityAlerts: String("va"), 4511 Workflows: String("w"), 4512 }, 4513 CreatedAt: &Timestamp{referenceTime}, 4514 UpdatedAt: &Timestamp{referenceTime}, 4515 HasMultipleSingleFiles: Bool(false), 4516 SuspendedBy: &User{ 4517 Login: String("l"), 4518 ID: Int64(1), 4519 URL: String("u"), 4520 AvatarURL: String("a"), 4521 GravatarID: String("g"), 4522 Name: String("n"), 4523 Company: String("c"), 4524 Blog: String("b"), 4525 Location: String("l"), 4526 Email: String("e"), 4527 Hireable: Bool(true), 4528 Bio: String("b"), 4529 TwitterUsername: String("t"), 4530 PublicRepos: Int(1), 4531 Followers: Int(1), 4532 Following: Int(1), 4533 CreatedAt: &Timestamp{referenceTime}, 4534 SuspendedAt: &Timestamp{referenceTime}, 4535 }, 4536 SuspendedAt: &Timestamp{referenceTime}, 4537 }, 4538 } 4539 4540 want := `{ 4541 "action": "a", 4542 "effective_date": ` + referenceTimeStr + `, 4543 "marketplace_purchase": { 4544 "billing_cycle": "bc", 4545 "next_billing_date": ` + referenceTimeStr + `, 4546 "unit_count": 1, 4547 "plan": { 4548 "url": "u", 4549 "accounts_url": "au", 4550 "id": 1, 4551 "number": 1, 4552 "name": "n", 4553 "description": "d", 4554 "monthly_price_in_cents": 1, 4555 "yearly_price_in_cents": 1, 4556 "price_model": "pm", 4557 "unit_name": "un", 4558 "bullets": [ 4559 "b" 4560 ], 4561 "state": "s", 4562 "has_free_trial": false 4563 }, 4564 "on_free_trial": false, 4565 "free_trial_ends_on": ` + referenceTimeStr + `, 4566 "updated_at": ` + referenceTimeStr + ` 4567 }, 4568 "previous_marketplace_purchase": { 4569 "billing_cycle": "bc", 4570 "next_billing_date": ` + referenceTimeStr + `, 4571 "unit_count": 1, 4572 "plan": { 4573 "url": "u", 4574 "accounts_url": "au", 4575 "id": 1, 4576 "number": 1, 4577 "name": "n", 4578 "description": "d", 4579 "monthly_price_in_cents": 1, 4580 "yearly_price_in_cents": 1, 4581 "price_model": "pm", 4582 "unit_name": "un", 4583 "bullets": [ 4584 "b" 4585 ], 4586 "state": "s", 4587 "has_free_trial": false 4588 }, 4589 "on_free_trial": false, 4590 "free_trial_ends_on": ` + referenceTimeStr + `, 4591 "updated_at": ` + referenceTimeStr + ` 4592 }, 4593 "sender": { 4594 "login": "l", 4595 "id": 1, 4596 "node_id": "n", 4597 "avatar_url": "a", 4598 "url": "u", 4599 "events_url": "e", 4600 "repos_url": "r" 4601 }, 4602 "installation": { 4603 "id": 1, 4604 "node_id": "nid", 4605 "app_id": 1, 4606 "app_slug": "as", 4607 "target_id": 1, 4608 "account": { 4609 "login": "l", 4610 "id": 1, 4611 "avatar_url": "a", 4612 "gravatar_id": "g", 4613 "name": "n", 4614 "company": "c", 4615 "blog": "b", 4616 "location": "l", 4617 "email": "e", 4618 "hireable": true, 4619 "bio": "b", 4620 "twitter_username": "t", 4621 "public_repos": 1, 4622 "followers": 1, 4623 "following": 1, 4624 "created_at": ` + referenceTimeStr + `, 4625 "suspended_at": ` + referenceTimeStr + `, 4626 "url": "u" 4627 }, 4628 "access_tokens_url": "atu", 4629 "repositories_url": "ru", 4630 "html_url": "hu", 4631 "target_type": "tt", 4632 "single_file_name": "sfn", 4633 "repository_selection": "rs", 4634 "events": [ 4635 "e" 4636 ], 4637 "single_file_paths": [ 4638 "s" 4639 ], 4640 "permissions": { 4641 "actions": "a", 4642 "administration": "ad", 4643 "checks": "c", 4644 "contents": "co", 4645 "content_references": "cr", 4646 "deployments": "d", 4647 "environments": "e", 4648 "issues": "i", 4649 "metadata": "md", 4650 "members": "m", 4651 "organization_administration": "oa", 4652 "organization_hooks": "oh", 4653 "organization_plan": "op", 4654 "organization_pre_receive_hooks": "opr", 4655 "organization_projects": "op", 4656 "organization_secrets": "os", 4657 "organization_self_hosted_runners": "osh", 4658 "organization_user_blocking": "oub", 4659 "packages": "pkg", 4660 "pages": "pg", 4661 "pull_requests": "pr", 4662 "repository_hooks": "rh", 4663 "repository_projects": "rp", 4664 "repository_pre_receive_hooks": "rprh", 4665 "secrets": "s", 4666 "secret_scanning_alerts": "ssa", 4667 "security_events": "se", 4668 "single_file": "sf", 4669 "statuses": "s", 4670 "team_discussions": "td", 4671 "vulnerability_alerts": "va", 4672 "workflows": "w" 4673 }, 4674 "created_at": ` + referenceTimeStr + `, 4675 "updated_at": ` + referenceTimeStr + `, 4676 "has_multiple_single_files": false, 4677 "suspended_by": { 4678 "login": "l", 4679 "id": 1, 4680 "avatar_url": "a", 4681 "gravatar_id": "g", 4682 "name": "n", 4683 "company": "c", 4684 "blog": "b", 4685 "location": "l", 4686 "email": "e", 4687 "hireable": true, 4688 "bio": "b", 4689 "twitter_username": "t", 4690 "public_repos": 1, 4691 "followers": 1, 4692 "following": 1, 4693 "created_at": ` + referenceTimeStr + `, 4694 "suspended_at": ` + referenceTimeStr + `, 4695 "url": "u" 4696 }, 4697 "suspended_at": ` + referenceTimeStr + ` 4698 } 4699 }` 4700 4701 testJSONMarshal(t, u, want) 4702 } 4703 4704 func TestOrganizationEvent_Marshal(t *testing.T) { 4705 t.Parallel() 4706 testJSONMarshal(t, &OrganizationEvent{}, "{}") 4707 4708 u := &OrganizationEvent{ 4709 Action: String("a"), 4710 Invitation: &Invitation{ID: Int64(1)}, 4711 Membership: &Membership{ 4712 URL: String("url"), 4713 State: String("s"), 4714 Role: String("r"), 4715 OrganizationURL: String("ou"), 4716 Organization: &Organization{ 4717 BillingEmail: String("be"), 4718 Blog: String("b"), 4719 Company: String("c"), 4720 Email: String("e"), 4721 TwitterUsername: String("tu"), 4722 Location: String("loc"), 4723 Name: String("n"), 4724 Description: String("d"), 4725 IsVerified: Bool(true), 4726 HasOrganizationProjects: Bool(true), 4727 HasRepositoryProjects: Bool(true), 4728 DefaultRepoPermission: String("drp"), 4729 MembersCanCreateRepos: Bool(true), 4730 MembersCanCreateInternalRepos: Bool(true), 4731 MembersCanCreatePrivateRepos: Bool(true), 4732 MembersCanCreatePublicRepos: Bool(false), 4733 MembersAllowedRepositoryCreationType: String("marct"), 4734 MembersCanCreatePages: Bool(true), 4735 MembersCanCreatePublicPages: Bool(false), 4736 MembersCanCreatePrivatePages: Bool(true), 4737 }, 4738 User: &User{ 4739 Login: String("l"), 4740 ID: Int64(1), 4741 NodeID: String("n"), 4742 URL: String("u"), 4743 ReposURL: String("r"), 4744 EventsURL: String("e"), 4745 AvatarURL: String("a"), 4746 }, 4747 }, 4748 Organization: &Organization{ 4749 BillingEmail: String("be"), 4750 Blog: String("b"), 4751 Company: String("c"), 4752 Email: String("e"), 4753 TwitterUsername: String("tu"), 4754 Location: String("loc"), 4755 Name: String("n"), 4756 Description: String("d"), 4757 IsVerified: Bool(true), 4758 HasOrganizationProjects: Bool(true), 4759 HasRepositoryProjects: Bool(true), 4760 DefaultRepoPermission: String("drp"), 4761 MembersCanCreateRepos: Bool(true), 4762 MembersCanCreateInternalRepos: Bool(true), 4763 MembersCanCreatePrivateRepos: Bool(true), 4764 MembersCanCreatePublicRepos: Bool(false), 4765 MembersAllowedRepositoryCreationType: String("marct"), 4766 MembersCanCreatePages: Bool(true), 4767 MembersCanCreatePublicPages: Bool(false), 4768 MembersCanCreatePrivatePages: Bool(true), 4769 }, 4770 Sender: &User{ 4771 Login: String("l"), 4772 ID: Int64(1), 4773 NodeID: String("n"), 4774 URL: String("u"), 4775 ReposURL: String("r"), 4776 EventsURL: String("e"), 4777 AvatarURL: String("a"), 4778 }, 4779 Installation: &Installation{ 4780 ID: Int64(1), 4781 NodeID: String("nid"), 4782 AppID: Int64(1), 4783 AppSlug: String("as"), 4784 TargetID: Int64(1), 4785 Account: &User{ 4786 Login: String("l"), 4787 ID: Int64(1), 4788 URL: String("u"), 4789 AvatarURL: String("a"), 4790 GravatarID: String("g"), 4791 Name: String("n"), 4792 Company: String("c"), 4793 Blog: String("b"), 4794 Location: String("l"), 4795 Email: String("e"), 4796 Hireable: Bool(true), 4797 Bio: String("b"), 4798 TwitterUsername: String("t"), 4799 PublicRepos: Int(1), 4800 Followers: Int(1), 4801 Following: Int(1), 4802 CreatedAt: &Timestamp{referenceTime}, 4803 SuspendedAt: &Timestamp{referenceTime}, 4804 }, 4805 AccessTokensURL: String("atu"), 4806 RepositoriesURL: String("ru"), 4807 HTMLURL: String("hu"), 4808 TargetType: String("tt"), 4809 SingleFileName: String("sfn"), 4810 RepositorySelection: String("rs"), 4811 Events: []string{"e"}, 4812 SingleFilePaths: []string{"s"}, 4813 Permissions: &InstallationPermissions{ 4814 Actions: String("a"), 4815 Administration: String("ad"), 4816 Checks: String("c"), 4817 Contents: String("co"), 4818 ContentReferences: String("cr"), 4819 Deployments: String("d"), 4820 Environments: String("e"), 4821 Issues: String("i"), 4822 Metadata: String("md"), 4823 Members: String("m"), 4824 OrganizationAdministration: String("oa"), 4825 OrganizationHooks: String("oh"), 4826 OrganizationPlan: String("op"), 4827 OrganizationPreReceiveHooks: String("opr"), 4828 OrganizationProjects: String("op"), 4829 OrganizationSecrets: String("os"), 4830 OrganizationSelfHostedRunners: String("osh"), 4831 OrganizationUserBlocking: String("oub"), 4832 Packages: String("pkg"), 4833 Pages: String("pg"), 4834 PullRequests: String("pr"), 4835 RepositoryHooks: String("rh"), 4836 RepositoryProjects: String("rp"), 4837 RepositoryPreReceiveHooks: String("rprh"), 4838 Secrets: String("s"), 4839 SecretScanningAlerts: String("ssa"), 4840 SecurityEvents: String("se"), 4841 SingleFile: String("sf"), 4842 Statuses: String("s"), 4843 TeamDiscussions: String("td"), 4844 VulnerabilityAlerts: String("va"), 4845 Workflows: String("w"), 4846 }, 4847 CreatedAt: &Timestamp{referenceTime}, 4848 UpdatedAt: &Timestamp{referenceTime}, 4849 HasMultipleSingleFiles: Bool(false), 4850 SuspendedBy: &User{ 4851 Login: String("l"), 4852 ID: Int64(1), 4853 URL: String("u"), 4854 AvatarURL: String("a"), 4855 GravatarID: String("g"), 4856 Name: String("n"), 4857 Company: String("c"), 4858 Blog: String("b"), 4859 Location: String("l"), 4860 Email: String("e"), 4861 Hireable: Bool(true), 4862 Bio: String("b"), 4863 TwitterUsername: String("t"), 4864 PublicRepos: Int(1), 4865 Followers: Int(1), 4866 Following: Int(1), 4867 CreatedAt: &Timestamp{referenceTime}, 4868 SuspendedAt: &Timestamp{referenceTime}, 4869 }, 4870 SuspendedAt: &Timestamp{referenceTime}, 4871 }, 4872 } 4873 4874 want := `{ 4875 "action": "a", 4876 "invitation": { 4877 "id": 1 4878 }, 4879 "membership": { 4880 "url": "url", 4881 "state": "s", 4882 "role": "r", 4883 "organization_url": "ou", 4884 "organization": { 4885 "name": "n", 4886 "company": "c", 4887 "blog": "b", 4888 "location": "loc", 4889 "email": "e", 4890 "twitter_username": "tu", 4891 "description": "d", 4892 "billing_email": "be", 4893 "is_verified": true, 4894 "has_organization_projects": true, 4895 "has_repository_projects": true, 4896 "default_repository_permission": "drp", 4897 "members_can_create_repositories": true, 4898 "members_can_create_public_repositories": false, 4899 "members_can_create_private_repositories": true, 4900 "members_can_create_internal_repositories": true, 4901 "members_allowed_repository_creation_type": "marct", 4902 "members_can_create_pages": true, 4903 "members_can_create_public_pages": false, 4904 "members_can_create_private_pages": true 4905 }, 4906 "user": { 4907 "login": "l", 4908 "id": 1, 4909 "node_id": "n", 4910 "avatar_url": "a", 4911 "url": "u", 4912 "events_url": "e", 4913 "repos_url": "r" 4914 } 4915 }, 4916 "organization": { 4917 "name": "n", 4918 "company": "c", 4919 "blog": "b", 4920 "location": "loc", 4921 "email": "e", 4922 "twitter_username": "tu", 4923 "description": "d", 4924 "billing_email": "be", 4925 "is_verified": true, 4926 "has_organization_projects": true, 4927 "has_repository_projects": true, 4928 "default_repository_permission": "drp", 4929 "members_can_create_repositories": true, 4930 "members_can_create_public_repositories": false, 4931 "members_can_create_private_repositories": true, 4932 "members_can_create_internal_repositories": true, 4933 "members_allowed_repository_creation_type": "marct", 4934 "members_can_create_pages": true, 4935 "members_can_create_public_pages": false, 4936 "members_can_create_private_pages": true 4937 }, 4938 "sender": { 4939 "login": "l", 4940 "id": 1, 4941 "node_id": "n", 4942 "avatar_url": "a", 4943 "url": "u", 4944 "events_url": "e", 4945 "repos_url": "r" 4946 }, 4947 "installation": { 4948 "id": 1, 4949 "node_id": "nid", 4950 "app_id": 1, 4951 "app_slug": "as", 4952 "target_id": 1, 4953 "account": { 4954 "login": "l", 4955 "id": 1, 4956 "avatar_url": "a", 4957 "gravatar_id": "g", 4958 "name": "n", 4959 "company": "c", 4960 "blog": "b", 4961 "location": "l", 4962 "email": "e", 4963 "hireable": true, 4964 "bio": "b", 4965 "twitter_username": "t", 4966 "public_repos": 1, 4967 "followers": 1, 4968 "following": 1, 4969 "created_at": ` + referenceTimeStr + `, 4970 "suspended_at": ` + referenceTimeStr + `, 4971 "url": "u" 4972 }, 4973 "access_tokens_url": "atu", 4974 "repositories_url": "ru", 4975 "html_url": "hu", 4976 "target_type": "tt", 4977 "single_file_name": "sfn", 4978 "repository_selection": "rs", 4979 "events": [ 4980 "e" 4981 ], 4982 "single_file_paths": [ 4983 "s" 4984 ], 4985 "permissions": { 4986 "actions": "a", 4987 "administration": "ad", 4988 "checks": "c", 4989 "contents": "co", 4990 "content_references": "cr", 4991 "deployments": "d", 4992 "environments": "e", 4993 "issues": "i", 4994 "metadata": "md", 4995 "members": "m", 4996 "organization_administration": "oa", 4997 "organization_hooks": "oh", 4998 "organization_plan": "op", 4999 "organization_pre_receive_hooks": "opr", 5000 "organization_projects": "op", 5001 "organization_secrets": "os", 5002 "organization_self_hosted_runners": "osh", 5003 "organization_user_blocking": "oub", 5004 "packages": "pkg", 5005 "pages": "pg", 5006 "pull_requests": "pr", 5007 "repository_hooks": "rh", 5008 "repository_projects": "rp", 5009 "repository_pre_receive_hooks": "rprh", 5010 "secrets": "s", 5011 "secret_scanning_alerts": "ssa", 5012 "security_events": "se", 5013 "single_file": "sf", 5014 "statuses": "s", 5015 "team_discussions": "td", 5016 "vulnerability_alerts": "va", 5017 "workflows": "w" 5018 }, 5019 "created_at": ` + referenceTimeStr + `, 5020 "updated_at": ` + referenceTimeStr + `, 5021 "has_multiple_single_files": false, 5022 "suspended_by": { 5023 "login": "l", 5024 "id": 1, 5025 "avatar_url": "a", 5026 "gravatar_id": "g", 5027 "name": "n", 5028 "company": "c", 5029 "blog": "b", 5030 "location": "l", 5031 "email": "e", 5032 "hireable": true, 5033 "bio": "b", 5034 "twitter_username": "t", 5035 "public_repos": 1, 5036 "followers": 1, 5037 "following": 1, 5038 "created_at": ` + referenceTimeStr + `, 5039 "suspended_at": ` + referenceTimeStr + `, 5040 "url": "u" 5041 }, 5042 "suspended_at": ` + referenceTimeStr + ` 5043 } 5044 }` 5045 5046 testJSONMarshal(t, u, want) 5047 } 5048 5049 func TestPageBuildEvent_Marshal(t *testing.T) { 5050 t.Parallel() 5051 testJSONMarshal(t, &PageBuildEvent{}, "{}") 5052 5053 u := &PageBuildEvent{ 5054 Build: &PagesBuild{URL: String("url")}, 5055 ID: Int64(1), 5056 Repo: &Repository{ 5057 ID: Int64(1), 5058 URL: String("s"), 5059 Name: String("n"), 5060 }, 5061 Sender: &User{ 5062 Login: String("l"), 5063 ID: Int64(1), 5064 NodeID: String("n"), 5065 URL: String("u"), 5066 ReposURL: String("r"), 5067 EventsURL: String("e"), 5068 AvatarURL: String("a"), 5069 }, 5070 Installation: &Installation{ 5071 ID: Int64(1), 5072 NodeID: String("nid"), 5073 AppID: Int64(1), 5074 AppSlug: String("as"), 5075 TargetID: Int64(1), 5076 Account: &User{ 5077 Login: String("l"), 5078 ID: Int64(1), 5079 URL: String("u"), 5080 AvatarURL: String("a"), 5081 GravatarID: String("g"), 5082 Name: String("n"), 5083 Company: String("c"), 5084 Blog: String("b"), 5085 Location: String("l"), 5086 Email: String("e"), 5087 Hireable: Bool(true), 5088 Bio: String("b"), 5089 TwitterUsername: String("t"), 5090 PublicRepos: Int(1), 5091 Followers: Int(1), 5092 Following: Int(1), 5093 CreatedAt: &Timestamp{referenceTime}, 5094 SuspendedAt: &Timestamp{referenceTime}, 5095 }, 5096 AccessTokensURL: String("atu"), 5097 RepositoriesURL: String("ru"), 5098 HTMLURL: String("hu"), 5099 TargetType: String("tt"), 5100 SingleFileName: String("sfn"), 5101 RepositorySelection: String("rs"), 5102 Events: []string{"e"}, 5103 SingleFilePaths: []string{"s"}, 5104 Permissions: &InstallationPermissions{ 5105 Actions: String("a"), 5106 Administration: String("ad"), 5107 Checks: String("c"), 5108 Contents: String("co"), 5109 ContentReferences: String("cr"), 5110 Deployments: String("d"), 5111 Environments: String("e"), 5112 Issues: String("i"), 5113 Metadata: String("md"), 5114 Members: String("m"), 5115 OrganizationAdministration: String("oa"), 5116 OrganizationHooks: String("oh"), 5117 OrganizationPlan: String("op"), 5118 OrganizationPreReceiveHooks: String("opr"), 5119 OrganizationProjects: String("op"), 5120 OrganizationSecrets: String("os"), 5121 OrganizationSelfHostedRunners: String("osh"), 5122 OrganizationUserBlocking: String("oub"), 5123 Packages: String("pkg"), 5124 Pages: String("pg"), 5125 PullRequests: String("pr"), 5126 RepositoryHooks: String("rh"), 5127 RepositoryProjects: String("rp"), 5128 RepositoryPreReceiveHooks: String("rprh"), 5129 Secrets: String("s"), 5130 SecretScanningAlerts: String("ssa"), 5131 SecurityEvents: String("se"), 5132 SingleFile: String("sf"), 5133 Statuses: String("s"), 5134 TeamDiscussions: String("td"), 5135 VulnerabilityAlerts: String("va"), 5136 Workflows: String("w"), 5137 }, 5138 CreatedAt: &Timestamp{referenceTime}, 5139 UpdatedAt: &Timestamp{referenceTime}, 5140 HasMultipleSingleFiles: Bool(false), 5141 SuspendedBy: &User{ 5142 Login: String("l"), 5143 ID: Int64(1), 5144 URL: String("u"), 5145 AvatarURL: String("a"), 5146 GravatarID: String("g"), 5147 Name: String("n"), 5148 Company: String("c"), 5149 Blog: String("b"), 5150 Location: String("l"), 5151 Email: String("e"), 5152 Hireable: Bool(true), 5153 Bio: String("b"), 5154 TwitterUsername: String("t"), 5155 PublicRepos: Int(1), 5156 Followers: Int(1), 5157 Following: Int(1), 5158 CreatedAt: &Timestamp{referenceTime}, 5159 SuspendedAt: &Timestamp{referenceTime}, 5160 }, 5161 SuspendedAt: &Timestamp{referenceTime}, 5162 }, 5163 } 5164 5165 want := `{ 5166 "build": { 5167 "url": "url" 5168 }, 5169 "id": 1, 5170 "repository": { 5171 "id": 1, 5172 "name": "n", 5173 "url": "s" 5174 }, 5175 "sender": { 5176 "login": "l", 5177 "id": 1, 5178 "node_id": "n", 5179 "avatar_url": "a", 5180 "url": "u", 5181 "events_url": "e", 5182 "repos_url": "r" 5183 }, 5184 "installation": { 5185 "id": 1, 5186 "node_id": "nid", 5187 "app_id": 1, 5188 "app_slug": "as", 5189 "target_id": 1, 5190 "account": { 5191 "login": "l", 5192 "id": 1, 5193 "avatar_url": "a", 5194 "gravatar_id": "g", 5195 "name": "n", 5196 "company": "c", 5197 "blog": "b", 5198 "location": "l", 5199 "email": "e", 5200 "hireable": true, 5201 "bio": "b", 5202 "twitter_username": "t", 5203 "public_repos": 1, 5204 "followers": 1, 5205 "following": 1, 5206 "created_at": ` + referenceTimeStr + `, 5207 "suspended_at": ` + referenceTimeStr + `, 5208 "url": "u" 5209 }, 5210 "access_tokens_url": "atu", 5211 "repositories_url": "ru", 5212 "html_url": "hu", 5213 "target_type": "tt", 5214 "single_file_name": "sfn", 5215 "repository_selection": "rs", 5216 "events": [ 5217 "e" 5218 ], 5219 "single_file_paths": [ 5220 "s" 5221 ], 5222 "permissions": { 5223 "actions": "a", 5224 "administration": "ad", 5225 "checks": "c", 5226 "contents": "co", 5227 "content_references": "cr", 5228 "deployments": "d", 5229 "environments": "e", 5230 "issues": "i", 5231 "metadata": "md", 5232 "members": "m", 5233 "organization_administration": "oa", 5234 "organization_hooks": "oh", 5235 "organization_plan": "op", 5236 "organization_pre_receive_hooks": "opr", 5237 "organization_projects": "op", 5238 "organization_secrets": "os", 5239 "organization_self_hosted_runners": "osh", 5240 "organization_user_blocking": "oub", 5241 "packages": "pkg", 5242 "pages": "pg", 5243 "pull_requests": "pr", 5244 "repository_hooks": "rh", 5245 "repository_projects": "rp", 5246 "repository_pre_receive_hooks": "rprh", 5247 "secrets": "s", 5248 "secret_scanning_alerts": "ssa", 5249 "security_events": "se", 5250 "single_file": "sf", 5251 "statuses": "s", 5252 "team_discussions": "td", 5253 "vulnerability_alerts": "va", 5254 "workflows": "w" 5255 }, 5256 "created_at": ` + referenceTimeStr + `, 5257 "updated_at": ` + referenceTimeStr + `, 5258 "has_multiple_single_files": false, 5259 "suspended_by": { 5260 "login": "l", 5261 "id": 1, 5262 "avatar_url": "a", 5263 "gravatar_id": "g", 5264 "name": "n", 5265 "company": "c", 5266 "blog": "b", 5267 "location": "l", 5268 "email": "e", 5269 "hireable": true, 5270 "bio": "b", 5271 "twitter_username": "t", 5272 "public_repos": 1, 5273 "followers": 1, 5274 "following": 1, 5275 "created_at": ` + referenceTimeStr + `, 5276 "suspended_at": ` + referenceTimeStr + `, 5277 "url": "u" 5278 }, 5279 "suspended_at": ` + referenceTimeStr + ` 5280 } 5281 }` 5282 5283 testJSONMarshal(t, u, want) 5284 } 5285 5286 func TestCommitCommentEvent_Marshal(t *testing.T) { 5287 t.Parallel() 5288 testJSONMarshal(t, &CommitCommentEvent{}, "{}") 5289 5290 u := &CommitCommentEvent{ 5291 Comment: &RepositoryComment{ 5292 HTMLURL: String("hurl"), 5293 URL: String("url"), 5294 ID: Int64(1), 5295 NodeID: String("nid"), 5296 CommitID: String("cid"), 5297 User: &User{ 5298 Login: String("l"), 5299 ID: Int64(1), 5300 NodeID: String("n"), 5301 URL: String("u"), 5302 ReposURL: String("r"), 5303 EventsURL: String("e"), 5304 AvatarURL: String("a"), 5305 }, 5306 Reactions: &Reactions{ 5307 TotalCount: Int(1), 5308 PlusOne: Int(1), 5309 MinusOne: Int(1), 5310 Laugh: Int(1), 5311 Confused: Int(1), 5312 Heart: Int(1), 5313 Hooray: Int(1), 5314 Rocket: Int(1), 5315 Eyes: Int(1), 5316 URL: String("url"), 5317 }, 5318 CreatedAt: &Timestamp{referenceTime}, 5319 UpdatedAt: &Timestamp{referenceTime}, 5320 Body: String("b"), 5321 Path: String("path"), 5322 Position: Int(1), 5323 }, 5324 Action: String("a"), 5325 Repo: &Repository{ 5326 ID: Int64(1), 5327 URL: String("s"), 5328 Name: String("n"), 5329 }, 5330 Sender: &User{ 5331 Login: String("l"), 5332 ID: Int64(1), 5333 NodeID: String("n"), 5334 URL: String("u"), 5335 ReposURL: String("r"), 5336 EventsURL: String("e"), 5337 AvatarURL: String("a"), 5338 }, 5339 Installation: &Installation{ 5340 ID: Int64(1), 5341 NodeID: String("nid"), 5342 AppID: Int64(1), 5343 AppSlug: String("as"), 5344 TargetID: Int64(1), 5345 Account: &User{ 5346 Login: String("l"), 5347 ID: Int64(1), 5348 URL: String("u"), 5349 AvatarURL: String("a"), 5350 GravatarID: String("g"), 5351 Name: String("n"), 5352 Company: String("c"), 5353 Blog: String("b"), 5354 Location: String("l"), 5355 Email: String("e"), 5356 Hireable: Bool(true), 5357 Bio: String("b"), 5358 TwitterUsername: String("t"), 5359 PublicRepos: Int(1), 5360 Followers: Int(1), 5361 Following: Int(1), 5362 CreatedAt: &Timestamp{referenceTime}, 5363 SuspendedAt: &Timestamp{referenceTime}, 5364 }, 5365 AccessTokensURL: String("atu"), 5366 RepositoriesURL: String("ru"), 5367 HTMLURL: String("hu"), 5368 TargetType: String("tt"), 5369 SingleFileName: String("sfn"), 5370 RepositorySelection: String("rs"), 5371 Events: []string{"e"}, 5372 SingleFilePaths: []string{"s"}, 5373 Permissions: &InstallationPermissions{ 5374 Actions: String("a"), 5375 Administration: String("ad"), 5376 Checks: String("c"), 5377 Contents: String("co"), 5378 ContentReferences: String("cr"), 5379 Deployments: String("d"), 5380 Environments: String("e"), 5381 Issues: String("i"), 5382 Metadata: String("md"), 5383 Members: String("m"), 5384 OrganizationAdministration: String("oa"), 5385 OrganizationHooks: String("oh"), 5386 OrganizationPlan: String("op"), 5387 OrganizationPreReceiveHooks: String("opr"), 5388 OrganizationProjects: String("op"), 5389 OrganizationSecrets: String("os"), 5390 OrganizationSelfHostedRunners: String("osh"), 5391 OrganizationUserBlocking: String("oub"), 5392 Packages: String("pkg"), 5393 Pages: String("pg"), 5394 PullRequests: String("pr"), 5395 RepositoryHooks: String("rh"), 5396 RepositoryProjects: String("rp"), 5397 RepositoryPreReceiveHooks: String("rprh"), 5398 Secrets: String("s"), 5399 SecretScanningAlerts: String("ssa"), 5400 SecurityEvents: String("se"), 5401 SingleFile: String("sf"), 5402 Statuses: String("s"), 5403 TeamDiscussions: String("td"), 5404 VulnerabilityAlerts: String("va"), 5405 Workflows: String("w"), 5406 }, 5407 CreatedAt: &Timestamp{referenceTime}, 5408 UpdatedAt: &Timestamp{referenceTime}, 5409 HasMultipleSingleFiles: Bool(false), 5410 SuspendedBy: &User{ 5411 Login: String("l"), 5412 ID: Int64(1), 5413 URL: String("u"), 5414 AvatarURL: String("a"), 5415 GravatarID: String("g"), 5416 Name: String("n"), 5417 Company: String("c"), 5418 Blog: String("b"), 5419 Location: String("l"), 5420 Email: String("e"), 5421 Hireable: Bool(true), 5422 Bio: String("b"), 5423 TwitterUsername: String("t"), 5424 PublicRepos: Int(1), 5425 Followers: Int(1), 5426 Following: Int(1), 5427 CreatedAt: &Timestamp{referenceTime}, 5428 SuspendedAt: &Timestamp{referenceTime}, 5429 }, 5430 SuspendedAt: &Timestamp{referenceTime}, 5431 }, 5432 } 5433 5434 want := `{ 5435 "comment": { 5436 "html_url": "hurl", 5437 "url": "url", 5438 "id": 1, 5439 "node_id": "nid", 5440 "commit_id": "cid", 5441 "user": { 5442 "login": "l", 5443 "id": 1, 5444 "node_id": "n", 5445 "avatar_url": "a", 5446 "url": "u", 5447 "events_url": "e", 5448 "repos_url": "r" 5449 }, 5450 "reactions": { 5451 "total_count": 1, 5452 "+1": 1, 5453 "-1": 1, 5454 "laugh": 1, 5455 "confused": 1, 5456 "heart": 1, 5457 "hooray": 1, 5458 "rocket": 1, 5459 "eyes": 1, 5460 "url": "url" 5461 }, 5462 "created_at": ` + referenceTimeStr + `, 5463 "updated_at": ` + referenceTimeStr + `, 5464 "body": "b", 5465 "path": "path", 5466 "position": 1 5467 }, 5468 "action": "a", 5469 "repository": { 5470 "id": 1, 5471 "name": "n", 5472 "url": "s" 5473 }, 5474 "sender": { 5475 "login": "l", 5476 "id": 1, 5477 "node_id": "n", 5478 "avatar_url": "a", 5479 "url": "u", 5480 "events_url": "e", 5481 "repos_url": "r" 5482 }, 5483 "installation": { 5484 "id": 1, 5485 "node_id": "nid", 5486 "app_id": 1, 5487 "app_slug": "as", 5488 "target_id": 1, 5489 "account": { 5490 "login": "l", 5491 "id": 1, 5492 "avatar_url": "a", 5493 "gravatar_id": "g", 5494 "name": "n", 5495 "company": "c", 5496 "blog": "b", 5497 "location": "l", 5498 "email": "e", 5499 "hireable": true, 5500 "bio": "b", 5501 "twitter_username": "t", 5502 "public_repos": 1, 5503 "followers": 1, 5504 "following": 1, 5505 "created_at": ` + referenceTimeStr + `, 5506 "suspended_at": ` + referenceTimeStr + `, 5507 "url": "u" 5508 }, 5509 "access_tokens_url": "atu", 5510 "repositories_url": "ru", 5511 "html_url": "hu", 5512 "target_type": "tt", 5513 "single_file_name": "sfn", 5514 "repository_selection": "rs", 5515 "events": [ 5516 "e" 5517 ], 5518 "single_file_paths": [ 5519 "s" 5520 ], 5521 "permissions": { 5522 "actions": "a", 5523 "administration": "ad", 5524 "checks": "c", 5525 "contents": "co", 5526 "content_references": "cr", 5527 "deployments": "d", 5528 "environments": "e", 5529 "issues": "i", 5530 "metadata": "md", 5531 "members": "m", 5532 "organization_administration": "oa", 5533 "organization_hooks": "oh", 5534 "organization_plan": "op", 5535 "organization_pre_receive_hooks": "opr", 5536 "organization_projects": "op", 5537 "organization_secrets": "os", 5538 "organization_self_hosted_runners": "osh", 5539 "organization_user_blocking": "oub", 5540 "packages": "pkg", 5541 "pages": "pg", 5542 "pull_requests": "pr", 5543 "repository_hooks": "rh", 5544 "repository_projects": "rp", 5545 "repository_pre_receive_hooks": "rprh", 5546 "secrets": "s", 5547 "secret_scanning_alerts": "ssa", 5548 "security_events": "se", 5549 "single_file": "sf", 5550 "statuses": "s", 5551 "team_discussions": "td", 5552 "vulnerability_alerts": "va", 5553 "workflows": "w" 5554 }, 5555 "created_at": ` + referenceTimeStr + `, 5556 "updated_at": ` + referenceTimeStr + `, 5557 "has_multiple_single_files": false, 5558 "suspended_by": { 5559 "login": "l", 5560 "id": 1, 5561 "avatar_url": "a", 5562 "gravatar_id": "g", 5563 "name": "n", 5564 "company": "c", 5565 "blog": "b", 5566 "location": "l", 5567 "email": "e", 5568 "hireable": true, 5569 "bio": "b", 5570 "twitter_username": "t", 5571 "public_repos": 1, 5572 "followers": 1, 5573 "following": 1, 5574 "created_at": ` + referenceTimeStr + `, 5575 "suspended_at": ` + referenceTimeStr + `, 5576 "url": "u" 5577 }, 5578 "suspended_at": ` + referenceTimeStr + ` 5579 } 5580 }` 5581 5582 testJSONMarshal(t, u, want) 5583 } 5584 5585 func TestDeploymentEvent_Marshal(t *testing.T) { 5586 t.Parallel() 5587 testJSONMarshal(t, &DeploymentEvent{}, "{}") 5588 5589 l := make(map[string]interface{}) 5590 l["key"] = "value" 5591 5592 jsonMsg, _ := json.Marshal(&l) 5593 5594 u := &DeploymentEvent{ 5595 Deployment: &Deployment{ 5596 URL: String("url"), 5597 ID: Int64(1), 5598 SHA: String("sha"), 5599 Ref: String("ref"), 5600 Task: String("t"), 5601 Payload: jsonMsg, 5602 Environment: String("e"), 5603 Description: String("d"), 5604 Creator: &User{ 5605 Login: String("l"), 5606 ID: Int64(1), 5607 NodeID: String("n"), 5608 URL: String("u"), 5609 ReposURL: String("r"), 5610 EventsURL: String("e"), 5611 AvatarURL: String("a"), 5612 }, 5613 CreatedAt: &Timestamp{referenceTime}, 5614 UpdatedAt: &Timestamp{referenceTime}, 5615 StatusesURL: String("surl"), 5616 RepositoryURL: String("rurl"), 5617 NodeID: String("nid"), 5618 }, 5619 Repo: &Repository{ 5620 ID: Int64(1), 5621 URL: String("s"), 5622 Name: String("n"), 5623 }, 5624 Sender: &User{ 5625 Login: String("l"), 5626 ID: Int64(1), 5627 NodeID: String("n"), 5628 URL: String("u"), 5629 ReposURL: String("r"), 5630 EventsURL: String("e"), 5631 AvatarURL: String("a"), 5632 }, 5633 Installation: &Installation{ 5634 ID: Int64(1), 5635 NodeID: String("nid"), 5636 AppID: Int64(1), 5637 AppSlug: String("as"), 5638 TargetID: Int64(1), 5639 Account: &User{ 5640 Login: String("l"), 5641 ID: Int64(1), 5642 URL: String("u"), 5643 AvatarURL: String("a"), 5644 GravatarID: String("g"), 5645 Name: String("n"), 5646 Company: String("c"), 5647 Blog: String("b"), 5648 Location: String("l"), 5649 Email: String("e"), 5650 Hireable: Bool(true), 5651 Bio: String("b"), 5652 TwitterUsername: String("t"), 5653 PublicRepos: Int(1), 5654 Followers: Int(1), 5655 Following: Int(1), 5656 CreatedAt: &Timestamp{referenceTime}, 5657 SuspendedAt: &Timestamp{referenceTime}, 5658 }, 5659 AccessTokensURL: String("atu"), 5660 RepositoriesURL: String("ru"), 5661 HTMLURL: String("hu"), 5662 TargetType: String("tt"), 5663 SingleFileName: String("sfn"), 5664 RepositorySelection: String("rs"), 5665 Events: []string{"e"}, 5666 SingleFilePaths: []string{"s"}, 5667 Permissions: &InstallationPermissions{ 5668 Actions: String("a"), 5669 Administration: String("ad"), 5670 Checks: String("c"), 5671 Contents: String("co"), 5672 ContentReferences: String("cr"), 5673 Deployments: String("d"), 5674 Environments: String("e"), 5675 Issues: String("i"), 5676 Metadata: String("md"), 5677 Members: String("m"), 5678 OrganizationAdministration: String("oa"), 5679 OrganizationHooks: String("oh"), 5680 OrganizationPlan: String("op"), 5681 OrganizationPreReceiveHooks: String("opr"), 5682 OrganizationProjects: String("op"), 5683 OrganizationSecrets: String("os"), 5684 OrganizationSelfHostedRunners: String("osh"), 5685 OrganizationUserBlocking: String("oub"), 5686 Packages: String("pkg"), 5687 Pages: String("pg"), 5688 PullRequests: String("pr"), 5689 RepositoryHooks: String("rh"), 5690 RepositoryProjects: String("rp"), 5691 RepositoryPreReceiveHooks: String("rprh"), 5692 Secrets: String("s"), 5693 SecretScanningAlerts: String("ssa"), 5694 SecurityEvents: String("se"), 5695 SingleFile: String("sf"), 5696 Statuses: String("s"), 5697 TeamDiscussions: String("td"), 5698 VulnerabilityAlerts: String("va"), 5699 Workflows: String("w"), 5700 }, 5701 CreatedAt: &Timestamp{referenceTime}, 5702 UpdatedAt: &Timestamp{referenceTime}, 5703 HasMultipleSingleFiles: Bool(false), 5704 SuspendedBy: &User{ 5705 Login: String("l"), 5706 ID: Int64(1), 5707 URL: String("u"), 5708 AvatarURL: String("a"), 5709 GravatarID: String("g"), 5710 Name: String("n"), 5711 Company: String("c"), 5712 Blog: String("b"), 5713 Location: String("l"), 5714 Email: String("e"), 5715 Hireable: Bool(true), 5716 Bio: String("b"), 5717 TwitterUsername: String("t"), 5718 PublicRepos: Int(1), 5719 Followers: Int(1), 5720 Following: Int(1), 5721 CreatedAt: &Timestamp{referenceTime}, 5722 SuspendedAt: &Timestamp{referenceTime}, 5723 }, 5724 SuspendedAt: &Timestamp{referenceTime}, 5725 }, 5726 Workflow: &Workflow{ 5727 ID: Int64(1), 5728 NodeID: String("nid"), 5729 Name: String("n"), 5730 Path: String("p"), 5731 State: String("s"), 5732 CreatedAt: &Timestamp{referenceTime}, 5733 UpdatedAt: &Timestamp{referenceTime}, 5734 URL: String("u"), 5735 HTMLURL: String("h"), 5736 BadgeURL: String("b"), 5737 }, 5738 WorkflowRun: &WorkflowRun{ 5739 ID: Int64(1), 5740 Name: String("n"), 5741 NodeID: String("nid"), 5742 HeadBranch: String("hb"), 5743 HeadSHA: String("hs"), 5744 RunNumber: Int(1), 5745 RunAttempt: Int(1), 5746 Event: String("e"), 5747 Status: String("s"), 5748 Conclusion: String("c"), 5749 WorkflowID: Int64(1), 5750 URL: String("u"), 5751 HTMLURL: String("h"), 5752 PullRequests: []*PullRequest{ 5753 { 5754 URL: String("u"), 5755 ID: Int64(1), 5756 Number: Int(1), 5757 Head: &PullRequestBranch{ 5758 Ref: String("r"), 5759 SHA: String("s"), 5760 Repo: &Repository{ 5761 ID: Int64(1), 5762 URL: String("s"), 5763 Name: String("n"), 5764 }, 5765 }, 5766 Base: &PullRequestBranch{ 5767 Ref: String("r"), 5768 SHA: String("s"), 5769 Repo: &Repository{ 5770 ID: Int64(1), 5771 URL: String("u"), 5772 Name: String("n"), 5773 }, 5774 }, 5775 }, 5776 }, 5777 CreatedAt: &Timestamp{referenceTime}, 5778 UpdatedAt: &Timestamp{referenceTime}, 5779 RunStartedAt: &Timestamp{referenceTime}, 5780 JobsURL: String("j"), 5781 LogsURL: String("l"), 5782 CheckSuiteURL: String("c"), 5783 ArtifactsURL: String("a"), 5784 CancelURL: String("c"), 5785 RerunURL: String("r"), 5786 PreviousAttemptURL: String("p"), 5787 HeadCommit: &HeadCommit{ 5788 Message: String("m"), 5789 Author: &CommitAuthor{ 5790 Name: String("n"), 5791 Email: String("e"), 5792 Login: String("l"), 5793 }, 5794 URL: String("u"), 5795 Distinct: Bool(false), 5796 SHA: String("s"), 5797 ID: String("i"), 5798 TreeID: String("tid"), 5799 Timestamp: &Timestamp{referenceTime}, 5800 Committer: &CommitAuthor{ 5801 Name: String("n"), 5802 Email: String("e"), 5803 Login: String("l"), 5804 }, 5805 }, 5806 WorkflowURL: String("w"), 5807 Repository: &Repository{ 5808 ID: Int64(1), 5809 URL: String("u"), 5810 Name: String("n"), 5811 }, 5812 HeadRepository: &Repository{ 5813 ID: Int64(1), 5814 URL: String("u"), 5815 Name: String("n"), 5816 }, 5817 }, 5818 } 5819 5820 want := `{ 5821 "deployment": { 5822 "url": "url", 5823 "id": 1, 5824 "sha": "sha", 5825 "ref": "ref", 5826 "task": "t", 5827 "payload": { 5828 "key": "value" 5829 }, 5830 "environment": "e", 5831 "description": "d", 5832 "creator": { 5833 "login": "l", 5834 "id": 1, 5835 "node_id": "n", 5836 "avatar_url": "a", 5837 "url": "u", 5838 "events_url": "e", 5839 "repos_url": "r" 5840 }, 5841 "created_at": ` + referenceTimeStr + `, 5842 "updated_at": ` + referenceTimeStr + `, 5843 "statuses_url": "surl", 5844 "repository_url": "rurl", 5845 "node_id": "nid" 5846 }, 5847 "repository": { 5848 "id": 1, 5849 "name": "n", 5850 "url": "s" 5851 }, 5852 "sender": { 5853 "login": "l", 5854 "id": 1, 5855 "node_id": "n", 5856 "avatar_url": "a", 5857 "url": "u", 5858 "events_url": "e", 5859 "repos_url": "r" 5860 }, 5861 "installation": { 5862 "id": 1, 5863 "node_id": "nid", 5864 "app_id": 1, 5865 "app_slug": "as", 5866 "target_id": 1, 5867 "account": { 5868 "login": "l", 5869 "id": 1, 5870 "avatar_url": "a", 5871 "gravatar_id": "g", 5872 "name": "n", 5873 "company": "c", 5874 "blog": "b", 5875 "location": "l", 5876 "email": "e", 5877 "hireable": true, 5878 "bio": "b", 5879 "twitter_username": "t", 5880 "public_repos": 1, 5881 "followers": 1, 5882 "following": 1, 5883 "created_at": ` + referenceTimeStr + `, 5884 "suspended_at": ` + referenceTimeStr + `, 5885 "url": "u" 5886 }, 5887 "access_tokens_url": "atu", 5888 "repositories_url": "ru", 5889 "html_url": "hu", 5890 "target_type": "tt", 5891 "single_file_name": "sfn", 5892 "repository_selection": "rs", 5893 "events": [ 5894 "e" 5895 ], 5896 "single_file_paths": [ 5897 "s" 5898 ], 5899 "permissions": { 5900 "actions": "a", 5901 "administration": "ad", 5902 "checks": "c", 5903 "contents": "co", 5904 "content_references": "cr", 5905 "deployments": "d", 5906 "environments": "e", 5907 "issues": "i", 5908 "metadata": "md", 5909 "members": "m", 5910 "organization_administration": "oa", 5911 "organization_hooks": "oh", 5912 "organization_plan": "op", 5913 "organization_pre_receive_hooks": "opr", 5914 "organization_projects": "op", 5915 "organization_secrets": "os", 5916 "organization_self_hosted_runners": "osh", 5917 "organization_user_blocking": "oub", 5918 "packages": "pkg", 5919 "pages": "pg", 5920 "pull_requests": "pr", 5921 "repository_hooks": "rh", 5922 "repository_projects": "rp", 5923 "repository_pre_receive_hooks": "rprh", 5924 "secrets": "s", 5925 "secret_scanning_alerts": "ssa", 5926 "security_events": "se", 5927 "single_file": "sf", 5928 "statuses": "s", 5929 "team_discussions": "td", 5930 "vulnerability_alerts": "va", 5931 "workflows": "w" 5932 }, 5933 "created_at": ` + referenceTimeStr + `, 5934 "updated_at": ` + referenceTimeStr + `, 5935 "has_multiple_single_files": false, 5936 "suspended_by": { 5937 "login": "l", 5938 "id": 1, 5939 "avatar_url": "a", 5940 "gravatar_id": "g", 5941 "name": "n", 5942 "company": "c", 5943 "blog": "b", 5944 "location": "l", 5945 "email": "e", 5946 "hireable": true, 5947 "bio": "b", 5948 "twitter_username": "t", 5949 "public_repos": 1, 5950 "followers": 1, 5951 "following": 1, 5952 "created_at": ` + referenceTimeStr + `, 5953 "suspended_at": ` + referenceTimeStr + `, 5954 "url": "u" 5955 }, 5956 "suspended_at": ` + referenceTimeStr + ` 5957 }, 5958 "workflow": { 5959 "id": 1, 5960 "node_id": "nid", 5961 "name": "n", 5962 "path": "p", 5963 "state": "s", 5964 "created_at": ` + referenceTimeStr + `, 5965 "updated_at": ` + referenceTimeStr + `, 5966 "url": "u", 5967 "html_url": "h", 5968 "badge_url": "b" 5969 }, 5970 "workflow_run": { 5971 "id": 1, 5972 "name": "n", 5973 "node_id": "nid", 5974 "head_branch": "hb", 5975 "head_sha": "hs", 5976 "run_number": 1, 5977 "run_attempt": 1, 5978 "event": "e", 5979 "status": "s", 5980 "conclusion": "c", 5981 "workflow_id": 1, 5982 "url": "u", 5983 "html_url": "h", 5984 "pull_requests": [ 5985 { 5986 "id": 1, 5987 "number": 1, 5988 "url": "u", 5989 "head": { 5990 "ref": "r", 5991 "sha": "s", 5992 "repo": { 5993 "id": 1, 5994 "name": "n", 5995 "url": "s" 5996 } 5997 }, 5998 "base": { 5999 "ref": "r", 6000 "sha": "s", 6001 "repo": { 6002 "id": 1, 6003 "name": "n", 6004 "url": "u" 6005 } 6006 } 6007 } 6008 ], 6009 "created_at": ` + referenceTimeStr + `, 6010 "updated_at": ` + referenceTimeStr + `, 6011 "run_started_at": ` + referenceTimeStr + `, 6012 "jobs_url": "j", 6013 "logs_url": "l", 6014 "check_suite_url": "c", 6015 "artifacts_url": "a", 6016 "cancel_url": "c", 6017 "rerun_url": "r", 6018 "previous_attempt_url": "p", 6019 "head_commit": { 6020 "message": "m", 6021 "author": { 6022 "name": "n", 6023 "email": "e", 6024 "username": "l" 6025 }, 6026 "url": "u", 6027 "distinct": false, 6028 "sha": "s", 6029 "id": "i", 6030 "tree_id": "tid", 6031 "timestamp": ` + referenceTimeStr + `, 6032 "committer": { 6033 "name": "n", 6034 "email": "e", 6035 "username": "l" 6036 } 6037 }, 6038 "workflow_url": "w", 6039 "repository": { 6040 "id": 1, 6041 "name": "n", 6042 "url": "u" 6043 }, 6044 "head_repository": { 6045 "id": 1, 6046 "name": "n", 6047 "url": "u" 6048 } 6049 } 6050 }` 6051 6052 testJSONMarshal(t, u, want) 6053 } 6054 6055 func TestDeploymentProtectionRuleEvent_Marshal(t *testing.T) { 6056 t.Parallel() 6057 testJSONMarshal(t, &DeploymentProtectionRuleEvent{}, "{}") 6058 6059 l := make(map[string]interface{}) 6060 l["key"] = "value" 6061 6062 jsonMsg, _ := json.Marshal(&l) 6063 6064 u := &DeploymentProtectionRuleEvent{ 6065 Action: String("a"), 6066 Environment: String("e"), 6067 DeploymentCallbackURL: String("b"), 6068 Deployment: &Deployment{ 6069 URL: String("url"), 6070 ID: Int64(1), 6071 SHA: String("sha"), 6072 Ref: String("ref"), 6073 Task: String("t"), 6074 Payload: jsonMsg, 6075 Environment: String("e"), 6076 Description: String("d"), 6077 Creator: &User{ 6078 Login: String("l"), 6079 ID: Int64(1), 6080 NodeID: String("n"), 6081 URL: String("u"), 6082 ReposURL: String("r"), 6083 EventsURL: String("e"), 6084 AvatarURL: String("a"), 6085 }, 6086 CreatedAt: &Timestamp{referenceTime}, 6087 UpdatedAt: &Timestamp{referenceTime}, 6088 StatusesURL: String("surl"), 6089 RepositoryURL: String("rurl"), 6090 NodeID: String("nid"), 6091 }, 6092 Repo: &Repository{ 6093 ID: Int64(1), 6094 URL: String("s"), 6095 Name: String("n"), 6096 }, 6097 Organization: &Organization{ 6098 BillingEmail: String("be"), 6099 Blog: String("b"), 6100 Company: String("c"), 6101 Email: String("e"), 6102 TwitterUsername: String("tu"), 6103 Location: String("loc"), 6104 Name: String("n"), 6105 Description: String("d"), 6106 IsVerified: Bool(true), 6107 HasOrganizationProjects: Bool(true), 6108 HasRepositoryProjects: Bool(true), 6109 DefaultRepoPermission: String("drp"), 6110 MembersCanCreateRepos: Bool(true), 6111 MembersCanCreateInternalRepos: Bool(true), 6112 MembersCanCreatePrivateRepos: Bool(true), 6113 MembersCanCreatePublicRepos: Bool(false), 6114 MembersAllowedRepositoryCreationType: String("marct"), 6115 MembersCanCreatePages: Bool(true), 6116 MembersCanCreatePublicPages: Bool(false), 6117 MembersCanCreatePrivatePages: Bool(true), 6118 }, 6119 PullRequests: []*PullRequest{ 6120 { 6121 URL: String("u"), 6122 ID: Int64(1), 6123 Number: Int(1), 6124 Head: &PullRequestBranch{ 6125 Ref: String("r"), 6126 SHA: String("s"), 6127 Repo: &Repository{ 6128 ID: Int64(1), 6129 URL: String("s"), 6130 Name: String("n"), 6131 }, 6132 }, 6133 Base: &PullRequestBranch{ 6134 Ref: String("r"), 6135 SHA: String("s"), 6136 Repo: &Repository{ 6137 ID: Int64(1), 6138 URL: String("u"), 6139 Name: String("n"), 6140 }, 6141 }, 6142 }, 6143 }, 6144 Sender: &User{ 6145 Login: String("l"), 6146 ID: Int64(1), 6147 NodeID: String("n"), 6148 URL: String("u"), 6149 ReposURL: String("r"), 6150 EventsURL: String("e"), 6151 AvatarURL: String("a"), 6152 }, 6153 Installation: &Installation{ 6154 ID: Int64(1), 6155 NodeID: String("nid"), 6156 AppID: Int64(1), 6157 AppSlug: String("as"), 6158 TargetID: Int64(1), 6159 Account: &User{ 6160 Login: String("l"), 6161 ID: Int64(1), 6162 URL: String("u"), 6163 AvatarURL: String("a"), 6164 GravatarID: String("g"), 6165 Name: String("n"), 6166 Company: String("c"), 6167 Blog: String("b"), 6168 Location: String("l"), 6169 Email: String("e"), 6170 Hireable: Bool(true), 6171 Bio: String("b"), 6172 TwitterUsername: String("t"), 6173 PublicRepos: Int(1), 6174 Followers: Int(1), 6175 Following: Int(1), 6176 CreatedAt: &Timestamp{referenceTime}, 6177 SuspendedAt: &Timestamp{referenceTime}, 6178 }, 6179 AccessTokensURL: String("atu"), 6180 RepositoriesURL: String("ru"), 6181 HTMLURL: String("hu"), 6182 TargetType: String("tt"), 6183 SingleFileName: String("sfn"), 6184 RepositorySelection: String("rs"), 6185 Events: []string{"e"}, 6186 SingleFilePaths: []string{"s"}, 6187 Permissions: &InstallationPermissions{ 6188 Actions: String("a"), 6189 Administration: String("ad"), 6190 Checks: String("c"), 6191 Contents: String("co"), 6192 ContentReferences: String("cr"), 6193 Deployments: String("d"), 6194 Environments: String("e"), 6195 Issues: String("i"), 6196 Metadata: String("md"), 6197 Members: String("m"), 6198 OrganizationAdministration: String("oa"), 6199 OrganizationHooks: String("oh"), 6200 OrganizationPlan: String("op"), 6201 OrganizationPreReceiveHooks: String("opr"), 6202 OrganizationProjects: String("op"), 6203 OrganizationSecrets: String("os"), 6204 OrganizationSelfHostedRunners: String("osh"), 6205 OrganizationUserBlocking: String("oub"), 6206 Packages: String("pkg"), 6207 Pages: String("pg"), 6208 PullRequests: String("pr"), 6209 RepositoryHooks: String("rh"), 6210 RepositoryProjects: String("rp"), 6211 RepositoryPreReceiveHooks: String("rprh"), 6212 Secrets: String("s"), 6213 SecretScanningAlerts: String("ssa"), 6214 SecurityEvents: String("se"), 6215 SingleFile: String("sf"), 6216 Statuses: String("s"), 6217 TeamDiscussions: String("td"), 6218 VulnerabilityAlerts: String("va"), 6219 Workflows: String("w"), 6220 }, 6221 CreatedAt: &Timestamp{referenceTime}, 6222 UpdatedAt: &Timestamp{referenceTime}, 6223 HasMultipleSingleFiles: Bool(false), 6224 SuspendedBy: &User{ 6225 Login: String("l"), 6226 ID: Int64(1), 6227 URL: String("u"), 6228 AvatarURL: String("a"), 6229 GravatarID: String("g"), 6230 Name: String("n"), 6231 Company: String("c"), 6232 Blog: String("b"), 6233 Location: String("l"), 6234 Email: String("e"), 6235 Hireable: Bool(true), 6236 Bio: String("b"), 6237 TwitterUsername: String("t"), 6238 PublicRepos: Int(1), 6239 Followers: Int(1), 6240 Following: Int(1), 6241 CreatedAt: &Timestamp{referenceTime}, 6242 SuspendedAt: &Timestamp{referenceTime}, 6243 }, 6244 SuspendedAt: &Timestamp{referenceTime}, 6245 }, 6246 } 6247 6248 want := `{ 6249 "action": "a", 6250 "environment": "e", 6251 "deployment_callback_url": "b", 6252 "deployment": { 6253 "url": "url", 6254 "id": 1, 6255 "sha": "sha", 6256 "ref": "ref", 6257 "task": "t", 6258 "payload": { 6259 "key": "value" 6260 }, 6261 "environment": "e", 6262 "description": "d", 6263 "creator": { 6264 "login": "l", 6265 "id": 1, 6266 "node_id": "n", 6267 "avatar_url": "a", 6268 "url": "u", 6269 "events_url": "e", 6270 "repos_url": "r" 6271 }, 6272 "created_at": ` + referenceTimeStr + `, 6273 "updated_at": ` + referenceTimeStr + `, 6274 "statuses_url": "surl", 6275 "repository_url": "rurl", 6276 "node_id": "nid" 6277 }, 6278 "repository": { 6279 "id": 1, 6280 "name": "n", 6281 "url": "s" 6282 }, 6283 "organization": { 6284 "name": "n", 6285 "company": "c", 6286 "blog": "b", 6287 "location": "loc", 6288 "email": "e", 6289 "twitter_username": "tu", 6290 "description": "d", 6291 "billing_email": "be", 6292 "is_verified": true, 6293 "has_organization_projects": true, 6294 "has_repository_projects": true, 6295 "default_repository_permission": "drp", 6296 "members_can_create_repositories": true, 6297 "members_can_create_public_repositories": false, 6298 "members_can_create_private_repositories": true, 6299 "members_can_create_internal_repositories": true, 6300 "members_allowed_repository_creation_type": "marct", 6301 "members_can_create_pages": true, 6302 "members_can_create_public_pages": false, 6303 "members_can_create_private_pages": true 6304 }, 6305 "pull_requests": [ 6306 { 6307 "id": 1, 6308 "number": 1, 6309 "url": "u", 6310 "head": { 6311 "ref": "r", 6312 "sha": "s", 6313 "repo": { 6314 "id": 1, 6315 "name": "n", 6316 "url": "s" 6317 } 6318 }, 6319 "base": { 6320 "ref": "r", 6321 "sha": "s", 6322 "repo": { 6323 "id": 1, 6324 "name": "n", 6325 "url": "u" 6326 } 6327 } 6328 } 6329 ], 6330 "sender": { 6331 "login": "l", 6332 "id": 1, 6333 "node_id": "n", 6334 "avatar_url": "a", 6335 "url": "u", 6336 "events_url": "e", 6337 "repos_url": "r" 6338 }, 6339 "installation": { 6340 "id": 1, 6341 "node_id": "nid", 6342 "app_id": 1, 6343 "app_slug": "as", 6344 "target_id": 1, 6345 "account": { 6346 "login": "l", 6347 "id": 1, 6348 "avatar_url": "a", 6349 "gravatar_id": "g", 6350 "name": "n", 6351 "company": "c", 6352 "blog": "b", 6353 "location": "l", 6354 "email": "e", 6355 "hireable": true, 6356 "bio": "b", 6357 "twitter_username": "t", 6358 "public_repos": 1, 6359 "followers": 1, 6360 "following": 1, 6361 "created_at": ` + referenceTimeStr + `, 6362 "suspended_at": ` + referenceTimeStr + `, 6363 "url": "u" 6364 }, 6365 "access_tokens_url": "atu", 6366 "repositories_url": "ru", 6367 "html_url": "hu", 6368 "target_type": "tt", 6369 "single_file_name": "sfn", 6370 "repository_selection": "rs", 6371 "events": [ 6372 "e" 6373 ], 6374 "single_file_paths": [ 6375 "s" 6376 ], 6377 "permissions": { 6378 "actions": "a", 6379 "administration": "ad", 6380 "checks": "c", 6381 "contents": "co", 6382 "content_references": "cr", 6383 "deployments": "d", 6384 "environments": "e", 6385 "issues": "i", 6386 "metadata": "md", 6387 "members": "m", 6388 "organization_administration": "oa", 6389 "organization_hooks": "oh", 6390 "organization_plan": "op", 6391 "organization_pre_receive_hooks": "opr", 6392 "organization_projects": "op", 6393 "organization_secrets": "os", 6394 "organization_self_hosted_runners": "osh", 6395 "organization_user_blocking": "oub", 6396 "packages": "pkg", 6397 "pages": "pg", 6398 "pull_requests": "pr", 6399 "repository_hooks": "rh", 6400 "repository_projects": "rp", 6401 "repository_pre_receive_hooks": "rprh", 6402 "secrets": "s", 6403 "secret_scanning_alerts": "ssa", 6404 "security_events": "se", 6405 "single_file": "sf", 6406 "statuses": "s", 6407 "team_discussions": "td", 6408 "vulnerability_alerts": "va", 6409 "workflows": "w" 6410 }, 6411 "created_at": ` + referenceTimeStr + `, 6412 "updated_at": ` + referenceTimeStr + `, 6413 "has_multiple_single_files": false, 6414 "suspended_by": { 6415 "login": "l", 6416 "id": 1, 6417 "avatar_url": "a", 6418 "gravatar_id": "g", 6419 "name": "n", 6420 "company": "c", 6421 "blog": "b", 6422 "location": "l", 6423 "email": "e", 6424 "hireable": true, 6425 "bio": "b", 6426 "twitter_username": "t", 6427 "public_repos": 1, 6428 "followers": 1, 6429 "following": 1, 6430 "created_at": ` + referenceTimeStr + `, 6431 "suspended_at": ` + referenceTimeStr + `, 6432 "url": "u" 6433 }, 6434 "suspended_at": ` + referenceTimeStr + ` 6435 } 6436 }` 6437 6438 testJSONMarshal(t, u, want) 6439 } 6440 6441 func TestDeploymentReviewEvent_Marshal(t *testing.T) { 6442 t.Parallel() 6443 testJSONMarshal(t, &DeploymentReviewEvent{}, "{}") 6444 6445 u := &DeploymentReviewEvent{ 6446 Action: String("a"), 6447 Environment: String("e"), 6448 Requester: &User{ 6449 AvatarURL: String("a"), 6450 Email: String("e"), 6451 EventsURL: String("e"), 6452 FollowersURL: String("f"), 6453 FollowingURL: String("f"), 6454 GistsURL: String("g"), 6455 GravatarID: String("g"), 6456 HTMLURL: String("h"), 6457 ID: Int64(1), 6458 Login: String("l"), 6459 Name: String("n"), 6460 NodeID: String("n"), 6461 OrganizationsURL: String("o"), 6462 ReceivedEventsURL: String("r"), 6463 ReposURL: String("r"), 6464 SiteAdmin: Bool(false), 6465 StarredURL: String("s"), 6466 SubscriptionsURL: String("s"), 6467 Type: String("User"), 6468 URL: String("u"), 6469 }, 6470 Reviewers: []*RequiredReviewer{ 6471 { 6472 Type: String("User"), 6473 Reviewer: &User{ 6474 AvatarURL: String("a"), 6475 Email: String("e"), 6476 EventsURL: String("e"), 6477 FollowersURL: String("f"), 6478 FollowingURL: String("f"), 6479 GistsURL: String("g"), 6480 GravatarID: String("g"), 6481 HTMLURL: String("h"), 6482 ID: Int64(1), 6483 Login: String("l"), 6484 Name: String("n"), 6485 NodeID: String("n"), 6486 OrganizationsURL: String("o"), 6487 ReceivedEventsURL: String("r"), 6488 ReposURL: String("r"), 6489 SiteAdmin: Bool(false), 6490 StarredURL: String("s"), 6491 SubscriptionsURL: String("s"), 6492 Type: String("User"), 6493 URL: String("u"), 6494 }, 6495 }, 6496 { 6497 Type: String("Team"), 6498 Reviewer: &Team{ 6499 ID: Int64(1), 6500 Name: String("n"), 6501 Slug: String("s"), 6502 }, 6503 }, 6504 }, 6505 Enterprise: &Enterprise{ 6506 ID: Int(1), 6507 Slug: String("s"), 6508 Name: String("n"), 6509 NodeID: String("nid"), 6510 AvatarURL: String("au"), 6511 Description: String("d"), 6512 WebsiteURL: String("wu"), 6513 HTMLURL: String("hu"), 6514 CreatedAt: &Timestamp{referenceTime}, 6515 UpdatedAt: &Timestamp{referenceTime}, 6516 }, 6517 Installation: &Installation{ 6518 ID: Int64(1), 6519 NodeID: String("nid"), 6520 AppID: Int64(1), 6521 AppSlug: String("as"), 6522 TargetID: Int64(1), 6523 Account: &User{ 6524 Login: String("l"), 6525 ID: Int64(1), 6526 URL: String("u"), 6527 AvatarURL: String("a"), 6528 GravatarID: String("g"), 6529 Name: String("n"), 6530 Company: String("c"), 6531 Blog: String("b"), 6532 Location: String("l"), 6533 Email: String("e"), 6534 Hireable: Bool(true), 6535 Bio: String("b"), 6536 TwitterUsername: String("t"), 6537 PublicRepos: Int(1), 6538 Followers: Int(1), 6539 Following: Int(1), 6540 CreatedAt: &Timestamp{referenceTime}, 6541 SuspendedAt: &Timestamp{referenceTime}, 6542 }, 6543 AccessTokensURL: String("atu"), 6544 RepositoriesURL: String("ru"), 6545 HTMLURL: String("hu"), 6546 TargetType: String("tt"), 6547 SingleFileName: String("sfn"), 6548 RepositorySelection: String("rs"), 6549 Events: []string{"e"}, 6550 SingleFilePaths: []string{"s"}, 6551 Permissions: &InstallationPermissions{ 6552 Actions: String("a"), 6553 Administration: String("ad"), 6554 Checks: String("c"), 6555 Contents: String("co"), 6556 ContentReferences: String("cr"), 6557 Deployments: String("d"), 6558 Environments: String("e"), 6559 Issues: String("i"), 6560 Metadata: String("md"), 6561 Members: String("m"), 6562 OrganizationAdministration: String("oa"), 6563 OrganizationHooks: String("oh"), 6564 OrganizationPlan: String("op"), 6565 OrganizationPreReceiveHooks: String("opr"), 6566 OrganizationProjects: String("op"), 6567 OrganizationSecrets: String("os"), 6568 OrganizationSelfHostedRunners: String("osh"), 6569 OrganizationUserBlocking: String("oub"), 6570 Packages: String("pkg"), 6571 Pages: String("pg"), 6572 PullRequests: String("pr"), 6573 RepositoryHooks: String("rh"), 6574 RepositoryProjects: String("rp"), 6575 RepositoryPreReceiveHooks: String("rprh"), 6576 Secrets: String("s"), 6577 SecretScanningAlerts: String("ssa"), 6578 SecurityEvents: String("se"), 6579 SingleFile: String("sf"), 6580 Statuses: String("s"), 6581 TeamDiscussions: String("td"), 6582 VulnerabilityAlerts: String("va"), 6583 Workflows: String("w"), 6584 }, 6585 CreatedAt: &Timestamp{referenceTime}, 6586 UpdatedAt: &Timestamp{referenceTime}, 6587 HasMultipleSingleFiles: Bool(false), 6588 SuspendedBy: &User{ 6589 Login: String("l"), 6590 ID: Int64(1), 6591 URL: String("u"), 6592 AvatarURL: String("a"), 6593 GravatarID: String("g"), 6594 Name: String("n"), 6595 Company: String("c"), 6596 Blog: String("b"), 6597 Location: String("l"), 6598 Email: String("e"), 6599 Hireable: Bool(true), 6600 Bio: String("b"), 6601 TwitterUsername: String("t"), 6602 PublicRepos: Int(1), 6603 Followers: Int(1), 6604 Following: Int(1), 6605 CreatedAt: &Timestamp{referenceTime}, 6606 SuspendedAt: &Timestamp{referenceTime}, 6607 }, 6608 SuspendedAt: &Timestamp{referenceTime}, 6609 }, 6610 Organization: &Organization{ 6611 BillingEmail: String("be"), 6612 Blog: String("b"), 6613 Company: String("c"), 6614 Email: String("e"), 6615 TwitterUsername: String("tu"), 6616 Location: String("loc"), 6617 Name: String("n"), 6618 Description: String("d"), 6619 IsVerified: Bool(true), 6620 HasOrganizationProjects: Bool(true), 6621 HasRepositoryProjects: Bool(true), 6622 DefaultRepoPermission: String("drp"), 6623 MembersCanCreateRepos: Bool(true), 6624 MembersCanCreateInternalRepos: Bool(true), 6625 MembersCanCreatePrivateRepos: Bool(true), 6626 MembersCanCreatePublicRepos: Bool(false), 6627 MembersAllowedRepositoryCreationType: String("marct"), 6628 MembersCanCreatePages: Bool(true), 6629 MembersCanCreatePublicPages: Bool(false), 6630 MembersCanCreatePrivatePages: Bool(true), 6631 }, 6632 Repo: &Repository{ 6633 ID: Int64(1), 6634 URL: String("s"), 6635 Name: String("n"), 6636 }, 6637 Sender: &User{ 6638 Login: String("l"), 6639 ID: Int64(1), 6640 NodeID: String("n"), 6641 URL: String("u"), 6642 ReposURL: String("r"), 6643 EventsURL: String("e"), 6644 AvatarURL: String("a"), 6645 }, 6646 Since: String("s"), 6647 WorkflowJobRun: &WorkflowJobRun{ 6648 ID: Int64(1), 6649 Conclusion: String("c"), 6650 Environment: String("e"), 6651 HTMLURL: String("h"), 6652 Name: String("n"), 6653 Status: String("s"), 6654 CreatedAt: &Timestamp{referenceTime}, 6655 UpdatedAt: &Timestamp{referenceTime}, 6656 }, 6657 WorkflowRun: &WorkflowRun{ 6658 ID: Int64(1), 6659 Name: String("n"), 6660 NodeID: String("nid"), 6661 HeadBranch: String("hb"), 6662 HeadSHA: String("hs"), 6663 RunNumber: Int(1), 6664 RunAttempt: Int(1), 6665 Event: String("e"), 6666 Status: String("s"), 6667 Conclusion: String("c"), 6668 WorkflowID: Int64(1), 6669 URL: String("u"), 6670 HTMLURL: String("h"), 6671 PullRequests: []*PullRequest{ 6672 { 6673 URL: String("u"), 6674 ID: Int64(1), 6675 Number: Int(1), 6676 Head: &PullRequestBranch{ 6677 Ref: String("r"), 6678 SHA: String("s"), 6679 Repo: &Repository{ 6680 ID: Int64(1), 6681 URL: String("s"), 6682 Name: String("n"), 6683 }, 6684 }, 6685 Base: &PullRequestBranch{ 6686 Ref: String("r"), 6687 SHA: String("s"), 6688 Repo: &Repository{ 6689 ID: Int64(1), 6690 URL: String("u"), 6691 Name: String("n"), 6692 }, 6693 }, 6694 }, 6695 }, 6696 CreatedAt: &Timestamp{referenceTime}, 6697 UpdatedAt: &Timestamp{referenceTime}, 6698 RunStartedAt: &Timestamp{referenceTime}, 6699 JobsURL: String("j"), 6700 LogsURL: String("l"), 6701 CheckSuiteURL: String("c"), 6702 ArtifactsURL: String("a"), 6703 CancelURL: String("c"), 6704 RerunURL: String("r"), 6705 PreviousAttemptURL: String("p"), 6706 HeadCommit: &HeadCommit{ 6707 Message: String("m"), 6708 Author: &CommitAuthor{ 6709 Name: String("n"), 6710 Email: String("e"), 6711 Login: String("l"), 6712 }, 6713 URL: String("u"), 6714 Distinct: Bool(false), 6715 SHA: String("s"), 6716 ID: String("i"), 6717 TreeID: String("tid"), 6718 Timestamp: &Timestamp{referenceTime}, 6719 Committer: &CommitAuthor{ 6720 Name: String("n"), 6721 Email: String("e"), 6722 Login: String("l"), 6723 }, 6724 }, 6725 WorkflowURL: String("w"), 6726 Repository: &Repository{ 6727 ID: Int64(1), 6728 URL: String("u"), 6729 Name: String("n"), 6730 }, 6731 HeadRepository: &Repository{ 6732 ID: Int64(1), 6733 URL: String("u"), 6734 Name: String("n"), 6735 }, 6736 }, 6737 } 6738 6739 want := `{ 6740 "action": "a", 6741 "requester": { 6742 "login": "l", 6743 "id": 1, 6744 "node_id": "n", 6745 "avatar_url": "a", 6746 "url": "u", 6747 "html_url": "h", 6748 "followers_url": "f", 6749 "following_url": "f", 6750 "gists_url": "g", 6751 "starred_url": "s", 6752 "subscriptions_url": "s", 6753 "organizations_url": "o", 6754 "repos_url": "r", 6755 "events_url": "e", 6756 "received_events_url": "r", 6757 "type": "User", 6758 "site_admin": false, 6759 "name": "n", 6760 "email": "e", 6761 "gravatar_id": "g" 6762 }, 6763 "reviewers": [ 6764 { 6765 "type": "User", 6766 "reviewer": { 6767 "login": "l", 6768 "id": 1, 6769 "node_id": "n", 6770 "avatar_url": "a", 6771 "url": "u", 6772 "html_url": "h", 6773 "followers_url": "f", 6774 "following_url": "f", 6775 "gists_url": "g", 6776 "starred_url": "s", 6777 "subscriptions_url": "s", 6778 "organizations_url": "o", 6779 "repos_url": "r", 6780 "events_url": "e", 6781 "received_events_url": "r", 6782 "type": "User", 6783 "site_admin": false, 6784 "name": "n", 6785 "email": "e", 6786 "gravatar_id": "g" 6787 } 6788 }, 6789 { 6790 "type": "Team", 6791 "reviewer": { 6792 "id": 1, 6793 "name": "n", 6794 "slug": "s" 6795 } 6796 } 6797 ], 6798 "repository": { 6799 "id": 1, 6800 "name": "n", 6801 "url": "s" 6802 }, 6803 "organization": { 6804 "name": "n", 6805 "company": "c", 6806 "blog": "b", 6807 "location": "loc", 6808 "email": "e", 6809 "twitter_username": "tu", 6810 "description": "d", 6811 "billing_email": "be", 6812 "is_verified": true, 6813 "has_organization_projects": true, 6814 "has_repository_projects": true, 6815 "default_repository_permission": "drp", 6816 "members_can_create_repositories": true, 6817 "members_can_create_public_repositories": false, 6818 "members_can_create_private_repositories": true, 6819 "members_can_create_internal_repositories": true, 6820 "members_allowed_repository_creation_type": "marct", 6821 "members_can_create_pages": true, 6822 "members_can_create_public_pages": false, 6823 "members_can_create_private_pages": true 6824 }, 6825 "environment": "e", 6826 "enterprise": { 6827 "id": 1, 6828 "slug": "s", 6829 "name": "n", 6830 "node_id": "nid", 6831 "avatar_url": "au", 6832 "description": "d", 6833 "website_url": "wu", 6834 "html_url": "hu", 6835 "created_at": ` + referenceTimeStr + `, 6836 "updated_at": ` + referenceTimeStr + ` 6837 }, 6838 "sender": { 6839 "login": "l", 6840 "id": 1, 6841 "node_id": "n", 6842 "avatar_url": "a", 6843 "url": "u", 6844 "events_url": "e", 6845 "repos_url": "r" 6846 }, 6847 "installation": { 6848 "id": 1, 6849 "node_id": "nid", 6850 "app_id": 1, 6851 "app_slug": "as", 6852 "target_id": 1, 6853 "account": { 6854 "login": "l", 6855 "id": 1, 6856 "avatar_url": "a", 6857 "gravatar_id": "g", 6858 "name": "n", 6859 "company": "c", 6860 "blog": "b", 6861 "location": "l", 6862 "email": "e", 6863 "hireable": true, 6864 "bio": "b", 6865 "twitter_username": "t", 6866 "public_repos": 1, 6867 "followers": 1, 6868 "following": 1, 6869 "created_at": ` + referenceTimeStr + `, 6870 "suspended_at": ` + referenceTimeStr + `, 6871 "url": "u" 6872 }, 6873 "access_tokens_url": "atu", 6874 "repositories_url": "ru", 6875 "html_url": "hu", 6876 "target_type": "tt", 6877 "single_file_name": "sfn", 6878 "repository_selection": "rs", 6879 "events": [ 6880 "e" 6881 ], 6882 "single_file_paths": [ 6883 "s" 6884 ], 6885 "permissions": { 6886 "actions": "a", 6887 "administration": "ad", 6888 "checks": "c", 6889 "contents": "co", 6890 "content_references": "cr", 6891 "deployments": "d", 6892 "environments": "e", 6893 "issues": "i", 6894 "metadata": "md", 6895 "members": "m", 6896 "organization_administration": "oa", 6897 "organization_hooks": "oh", 6898 "organization_plan": "op", 6899 "organization_pre_receive_hooks": "opr", 6900 "organization_projects": "op", 6901 "organization_secrets": "os", 6902 "organization_self_hosted_runners": "osh", 6903 "organization_user_blocking": "oub", 6904 "packages": "pkg", 6905 "pages": "pg", 6906 "pull_requests": "pr", 6907 "repository_hooks": "rh", 6908 "repository_projects": "rp", 6909 "repository_pre_receive_hooks": "rprh", 6910 "secrets": "s", 6911 "secret_scanning_alerts": "ssa", 6912 "security_events": "se", 6913 "single_file": "sf", 6914 "statuses": "s", 6915 "team_discussions": "td", 6916 "vulnerability_alerts": "va", 6917 "workflows": "w" 6918 }, 6919 "created_at": ` + referenceTimeStr + `, 6920 "updated_at": ` + referenceTimeStr + `, 6921 "has_multiple_single_files": false, 6922 "suspended_by": { 6923 "login": "l", 6924 "id": 1, 6925 "avatar_url": "a", 6926 "gravatar_id": "g", 6927 "name": "n", 6928 "company": "c", 6929 "blog": "b", 6930 "location": "l", 6931 "email": "e", 6932 "hireable": true, 6933 "bio": "b", 6934 "twitter_username": "t", 6935 "public_repos": 1, 6936 "followers": 1, 6937 "following": 1, 6938 "created_at": ` + referenceTimeStr + `, 6939 "suspended_at": ` + referenceTimeStr + `, 6940 "url": "u" 6941 }, 6942 "suspended_at": ` + referenceTimeStr + ` 6943 }, 6944 "since": "s", 6945 "workflow_job_run": { 6946 "conclusion": "c", 6947 "created_at": "2006-01-02T15:04:05Z", 6948 "environment": "e", 6949 "html_url": "h", 6950 "id": 1, 6951 "name": "n", 6952 "status": "s", 6953 "updated_at": "2006-01-02T15:04:05Z" 6954 }, 6955 "workflow_run": { 6956 "id": 1, 6957 "name": "n", 6958 "node_id": "nid", 6959 "head_branch": "hb", 6960 "head_sha": "hs", 6961 "run_number": 1, 6962 "run_attempt": 1, 6963 "event": "e", 6964 "status": "s", 6965 "conclusion": "c", 6966 "workflow_id": 1, 6967 "url": "u", 6968 "html_url": "h", 6969 "pull_requests": [ 6970 { 6971 "id": 1, 6972 "number": 1, 6973 "url": "u", 6974 "head": { 6975 "ref": "r", 6976 "sha": "s", 6977 "repo": { 6978 "id": 1, 6979 "name": "n", 6980 "url": "s" 6981 } 6982 }, 6983 "base": { 6984 "ref": "r", 6985 "sha": "s", 6986 "repo": { 6987 "id": 1, 6988 "name": "n", 6989 "url": "u" 6990 } 6991 } 6992 } 6993 ], 6994 "created_at": ` + referenceTimeStr + `, 6995 "updated_at": ` + referenceTimeStr + `, 6996 "run_started_at": ` + referenceTimeStr + `, 6997 "jobs_url": "j", 6998 "logs_url": "l", 6999 "check_suite_url": "c", 7000 "artifacts_url": "a", 7001 "cancel_url": "c", 7002 "rerun_url": "r", 7003 "previous_attempt_url": "p", 7004 "head_commit": { 7005 "message": "m", 7006 "author": { 7007 "name": "n", 7008 "email": "e", 7009 "username": "l" 7010 }, 7011 "url": "u", 7012 "distinct": false, 7013 "sha": "s", 7014 "id": "i", 7015 "tree_id": "tid", 7016 "timestamp": ` + referenceTimeStr + `, 7017 "committer": { 7018 "name": "n", 7019 "email": "e", 7020 "username": "l" 7021 } 7022 }, 7023 "workflow_url": "w", 7024 "repository": { 7025 "id": 1, 7026 "name": "n", 7027 "url": "u" 7028 }, 7029 "head_repository": { 7030 "id": 1, 7031 "name": "n", 7032 "url": "u" 7033 } 7034 } 7035 }` 7036 7037 testJSONMarshal(t, u, want) 7038 } 7039 7040 func TestDeploymentStatusEvent_Marshal(t *testing.T) { 7041 t.Parallel() 7042 testJSONMarshal(t, &DeploymentStatusEvent{}, "{}") 7043 7044 l := make(map[string]interface{}) 7045 l["key"] = "value" 7046 7047 jsonMsg, _ := json.Marshal(&l) 7048 7049 u := &DeploymentStatusEvent{ 7050 Deployment: &Deployment{ 7051 URL: String("url"), 7052 ID: Int64(1), 7053 SHA: String("sha"), 7054 Ref: String("ref"), 7055 Task: String("t"), 7056 Payload: jsonMsg, 7057 Environment: String("e"), 7058 Description: String("d"), 7059 Creator: &User{ 7060 Login: String("l"), 7061 ID: Int64(1), 7062 NodeID: String("n"), 7063 URL: String("u"), 7064 ReposURL: String("r"), 7065 EventsURL: String("e"), 7066 AvatarURL: String("a"), 7067 }, 7068 CreatedAt: &Timestamp{referenceTime}, 7069 UpdatedAt: &Timestamp{referenceTime}, 7070 StatusesURL: String("surl"), 7071 RepositoryURL: String("rurl"), 7072 NodeID: String("nid"), 7073 }, 7074 DeploymentStatus: &DeploymentStatus{ 7075 ID: Int64(1), 7076 State: String("s"), 7077 Creator: &User{ 7078 Login: String("l"), 7079 ID: Int64(1), 7080 NodeID: String("n"), 7081 URL: String("u"), 7082 ReposURL: String("r"), 7083 EventsURL: String("e"), 7084 AvatarURL: String("a"), 7085 }, 7086 Description: String("s"), 7087 Environment: String("s"), 7088 NodeID: String("s"), 7089 CreatedAt: &Timestamp{referenceTime}, 7090 UpdatedAt: &Timestamp{referenceTime}, 7091 TargetURL: String("s"), 7092 DeploymentURL: String("s"), 7093 RepositoryURL: String("s"), 7094 EnvironmentURL: String("s"), 7095 LogURL: String("s"), 7096 URL: String("s"), 7097 }, 7098 Repo: &Repository{ 7099 ID: Int64(1), 7100 URL: String("s"), 7101 Name: String("n"), 7102 }, 7103 Sender: &User{ 7104 Login: String("l"), 7105 ID: Int64(1), 7106 NodeID: String("n"), 7107 URL: String("u"), 7108 ReposURL: String("r"), 7109 EventsURL: String("e"), 7110 AvatarURL: String("a"), 7111 }, 7112 Installation: &Installation{ 7113 ID: Int64(1), 7114 NodeID: String("nid"), 7115 AppID: Int64(1), 7116 AppSlug: String("as"), 7117 TargetID: Int64(1), 7118 Account: &User{ 7119 Login: String("l"), 7120 ID: Int64(1), 7121 URL: String("u"), 7122 AvatarURL: String("a"), 7123 GravatarID: String("g"), 7124 Name: String("n"), 7125 Company: String("c"), 7126 Blog: String("b"), 7127 Location: String("l"), 7128 Email: String("e"), 7129 Hireable: Bool(true), 7130 Bio: String("b"), 7131 TwitterUsername: String("t"), 7132 PublicRepos: Int(1), 7133 Followers: Int(1), 7134 Following: Int(1), 7135 CreatedAt: &Timestamp{referenceTime}, 7136 SuspendedAt: &Timestamp{referenceTime}, 7137 }, 7138 AccessTokensURL: String("atu"), 7139 RepositoriesURL: String("ru"), 7140 HTMLURL: String("hu"), 7141 TargetType: String("tt"), 7142 SingleFileName: String("sfn"), 7143 RepositorySelection: String("rs"), 7144 Events: []string{"e"}, 7145 SingleFilePaths: []string{"s"}, 7146 Permissions: &InstallationPermissions{ 7147 Actions: String("a"), 7148 Administration: String("ad"), 7149 Checks: String("c"), 7150 Contents: String("co"), 7151 ContentReferences: String("cr"), 7152 Deployments: String("d"), 7153 Environments: String("e"), 7154 Issues: String("i"), 7155 Metadata: String("md"), 7156 Members: String("m"), 7157 OrganizationAdministration: String("oa"), 7158 OrganizationHooks: String("oh"), 7159 OrganizationPlan: String("op"), 7160 OrganizationPreReceiveHooks: String("opr"), 7161 OrganizationProjects: String("op"), 7162 OrganizationSecrets: String("os"), 7163 OrganizationSelfHostedRunners: String("osh"), 7164 OrganizationUserBlocking: String("oub"), 7165 Packages: String("pkg"), 7166 Pages: String("pg"), 7167 PullRequests: String("pr"), 7168 RepositoryHooks: String("rh"), 7169 RepositoryProjects: String("rp"), 7170 RepositoryPreReceiveHooks: String("rprh"), 7171 Secrets: String("s"), 7172 SecretScanningAlerts: String("ssa"), 7173 SecurityEvents: String("se"), 7174 SingleFile: String("sf"), 7175 Statuses: String("s"), 7176 TeamDiscussions: String("td"), 7177 VulnerabilityAlerts: String("va"), 7178 Workflows: String("w"), 7179 }, 7180 CreatedAt: &Timestamp{referenceTime}, 7181 UpdatedAt: &Timestamp{referenceTime}, 7182 HasMultipleSingleFiles: Bool(false), 7183 SuspendedBy: &User{ 7184 Login: String("l"), 7185 ID: Int64(1), 7186 URL: String("u"), 7187 AvatarURL: String("a"), 7188 GravatarID: String("g"), 7189 Name: String("n"), 7190 Company: String("c"), 7191 Blog: String("b"), 7192 Location: String("l"), 7193 Email: String("e"), 7194 Hireable: Bool(true), 7195 Bio: String("b"), 7196 TwitterUsername: String("t"), 7197 PublicRepos: Int(1), 7198 Followers: Int(1), 7199 Following: Int(1), 7200 CreatedAt: &Timestamp{referenceTime}, 7201 SuspendedAt: &Timestamp{referenceTime}, 7202 }, 7203 SuspendedAt: &Timestamp{referenceTime}, 7204 }, 7205 } 7206 7207 want := `{ 7208 "deployment": { 7209 "url": "url", 7210 "id": 1, 7211 "sha": "sha", 7212 "ref": "ref", 7213 "task": "t", 7214 "payload": { 7215 "key": "value" 7216 }, 7217 "environment": "e", 7218 "description": "d", 7219 "creator": { 7220 "login": "l", 7221 "id": 1, 7222 "node_id": "n", 7223 "avatar_url": "a", 7224 "url": "u", 7225 "events_url": "e", 7226 "repos_url": "r" 7227 }, 7228 "created_at": ` + referenceTimeStr + `, 7229 "updated_at": ` + referenceTimeStr + `, 7230 "statuses_url": "surl", 7231 "repository_url": "rurl", 7232 "node_id": "nid" 7233 }, 7234 "deployment_status": { 7235 "id": 1, 7236 "state": "s", 7237 "creator": { 7238 "login": "l", 7239 "id": 1, 7240 "node_id": "n", 7241 "avatar_url": "a", 7242 "url": "u", 7243 "events_url": "e", 7244 "repos_url": "r" 7245 }, 7246 "description": "s", 7247 "environment": "s", 7248 "node_id": "s", 7249 "created_at": ` + referenceTimeStr + `, 7250 "updated_at": ` + referenceTimeStr + `, 7251 "target_url": "s", 7252 "deployment_url": "s", 7253 "repository_url": "s", 7254 "environment_url": "s", 7255 "log_url": "s", 7256 "url": "s" 7257 }, 7258 "repository": { 7259 "id": 1, 7260 "name": "n", 7261 "url": "s" 7262 }, 7263 "sender": { 7264 "login": "l", 7265 "id": 1, 7266 "node_id": "n", 7267 "avatar_url": "a", 7268 "url": "u", 7269 "events_url": "e", 7270 "repos_url": "r" 7271 }, 7272 "installation": { 7273 "id": 1, 7274 "node_id": "nid", 7275 "app_id": 1, 7276 "app_slug": "as", 7277 "target_id": 1, 7278 "account": { 7279 "login": "l", 7280 "id": 1, 7281 "avatar_url": "a", 7282 "gravatar_id": "g", 7283 "name": "n", 7284 "company": "c", 7285 "blog": "b", 7286 "location": "l", 7287 "email": "e", 7288 "hireable": true, 7289 "bio": "b", 7290 "twitter_username": "t", 7291 "public_repos": 1, 7292 "followers": 1, 7293 "following": 1, 7294 "created_at": ` + referenceTimeStr + `, 7295 "suspended_at": ` + referenceTimeStr + `, 7296 "url": "u" 7297 }, 7298 "access_tokens_url": "atu", 7299 "repositories_url": "ru", 7300 "html_url": "hu", 7301 "target_type": "tt", 7302 "single_file_name": "sfn", 7303 "repository_selection": "rs", 7304 "events": [ 7305 "e" 7306 ], 7307 "single_file_paths": [ 7308 "s" 7309 ], 7310 "permissions": { 7311 "actions": "a", 7312 "administration": "ad", 7313 "checks": "c", 7314 "contents": "co", 7315 "content_references": "cr", 7316 "deployments": "d", 7317 "environments": "e", 7318 "issues": "i", 7319 "metadata": "md", 7320 "members": "m", 7321 "organization_administration": "oa", 7322 "organization_hooks": "oh", 7323 "organization_plan": "op", 7324 "organization_pre_receive_hooks": "opr", 7325 "organization_projects": "op", 7326 "organization_secrets": "os", 7327 "organization_self_hosted_runners": "osh", 7328 "organization_user_blocking": "oub", 7329 "packages": "pkg", 7330 "pages": "pg", 7331 "pull_requests": "pr", 7332 "repository_hooks": "rh", 7333 "repository_projects": "rp", 7334 "repository_pre_receive_hooks": "rprh", 7335 "secrets": "s", 7336 "secret_scanning_alerts": "ssa", 7337 "security_events": "se", 7338 "single_file": "sf", 7339 "statuses": "s", 7340 "team_discussions": "td", 7341 "vulnerability_alerts": "va", 7342 "workflows": "w" 7343 }, 7344 "created_at": ` + referenceTimeStr + `, 7345 "updated_at": ` + referenceTimeStr + `, 7346 "has_multiple_single_files": false, 7347 "suspended_by": { 7348 "login": "l", 7349 "id": 1, 7350 "avatar_url": "a", 7351 "gravatar_id": "g", 7352 "name": "n", 7353 "company": "c", 7354 "blog": "b", 7355 "location": "l", 7356 "email": "e", 7357 "hireable": true, 7358 "bio": "b", 7359 "twitter_username": "t", 7360 "public_repos": 1, 7361 "followers": 1, 7362 "following": 1, 7363 "created_at": ` + referenceTimeStr + `, 7364 "suspended_at": ` + referenceTimeStr + `, 7365 "url": "u" 7366 }, 7367 "suspended_at": ` + referenceTimeStr + ` 7368 } 7369 }` 7370 7371 testJSONMarshal(t, u, want) 7372 } 7373 7374 func TestDiscussionCommentEvent_Marshal(t *testing.T) { 7375 t.Parallel() 7376 testJSONMarshal(t, &DiscussionCommentEvent{}, "{}") 7377 7378 u := &DiscussionCommentEvent{ 7379 Comment: &CommentDiscussion{ 7380 AuthorAssociation: String("aa"), 7381 Body: String("bo"), 7382 ChildCommentCount: Int(1), 7383 CreatedAt: &Timestamp{referenceTime}, 7384 DiscussionID: Int64(1), 7385 HTMLURL: String("hurl"), 7386 ID: Int64(1), 7387 NodeID: String("nid"), 7388 ParentID: Int64(1), 7389 Reactions: &Reactions{ 7390 TotalCount: Int(1), 7391 PlusOne: Int(1), 7392 MinusOne: Int(1), 7393 Laugh: Int(1), 7394 Confused: Int(1), 7395 Heart: Int(1), 7396 Hooray: Int(1), 7397 Rocket: Int(1), 7398 Eyes: Int(1), 7399 URL: String("url"), 7400 }, 7401 RepositoryURL: String("rurl"), 7402 UpdatedAt: &Timestamp{referenceTime}, 7403 User: &User{ 7404 Login: String("l"), 7405 ID: Int64(1), 7406 NodeID: String("n"), 7407 URL: String("u"), 7408 ReposURL: String("r"), 7409 EventsURL: String("e"), 7410 AvatarURL: String("a"), 7411 }, 7412 }, 7413 Discussion: &Discussion{ 7414 RepositoryURL: String("rurl"), 7415 DiscussionCategory: &DiscussionCategory{ 7416 ID: Int64(1), 7417 NodeID: String("nid"), 7418 RepositoryID: Int64(1), 7419 Emoji: String("emoji"), 7420 Name: String("name"), 7421 Description: String("description"), 7422 CreatedAt: &Timestamp{referenceTime}, 7423 UpdatedAt: &Timestamp{referenceTime}, 7424 Slug: String("slug"), 7425 IsAnswerable: Bool(false), 7426 }, 7427 HTMLURL: String("hurl"), 7428 ID: Int64(1), 7429 NodeID: String("nurl"), 7430 Number: Int(1), 7431 Title: String("title"), 7432 User: &User{ 7433 Login: String("l"), 7434 ID: Int64(1), 7435 NodeID: String("n"), 7436 URL: String("u"), 7437 ReposURL: String("r"), 7438 EventsURL: String("e"), 7439 AvatarURL: String("a"), 7440 }, 7441 State: String("st"), 7442 Locked: Bool(false), 7443 Comments: Int(1), 7444 CreatedAt: &Timestamp{referenceTime}, 7445 UpdatedAt: &Timestamp{referenceTime}, 7446 AuthorAssociation: String("aa"), 7447 Body: String("bo"), 7448 }, 7449 Repo: &Repository{ 7450 ID: Int64(1), 7451 URL: String("s"), 7452 Name: String("n"), 7453 }, 7454 Org: &Organization{ 7455 BillingEmail: String("be"), 7456 Blog: String("b"), 7457 Company: String("c"), 7458 Email: String("e"), 7459 TwitterUsername: String("tu"), 7460 Location: String("loc"), 7461 Name: String("n"), 7462 Description: String("d"), 7463 IsVerified: Bool(true), 7464 HasOrganizationProjects: Bool(true), 7465 HasRepositoryProjects: Bool(true), 7466 DefaultRepoPermission: String("drp"), 7467 MembersCanCreateRepos: Bool(true), 7468 MembersCanCreateInternalRepos: Bool(true), 7469 MembersCanCreatePrivateRepos: Bool(true), 7470 MembersCanCreatePublicRepos: Bool(false), 7471 MembersAllowedRepositoryCreationType: String("marct"), 7472 MembersCanCreatePages: Bool(true), 7473 MembersCanCreatePublicPages: Bool(false), 7474 MembersCanCreatePrivatePages: Bool(true), 7475 }, 7476 Sender: &User{ 7477 Login: String("l"), 7478 ID: Int64(1), 7479 NodeID: String("n"), 7480 URL: String("u"), 7481 ReposURL: String("r"), 7482 EventsURL: String("e"), 7483 AvatarURL: String("a"), 7484 }, 7485 Installation: &Installation{ 7486 ID: Int64(1), 7487 NodeID: String("nid"), 7488 AppID: Int64(1), 7489 AppSlug: String("as"), 7490 TargetID: Int64(1), 7491 Account: &User{ 7492 Login: String("l"), 7493 ID: Int64(1), 7494 URL: String("u"), 7495 AvatarURL: String("a"), 7496 GravatarID: String("g"), 7497 Name: String("n"), 7498 Company: String("c"), 7499 Blog: String("b"), 7500 Location: String("l"), 7501 Email: String("e"), 7502 Hireable: Bool(true), 7503 Bio: String("b"), 7504 TwitterUsername: String("t"), 7505 PublicRepos: Int(1), 7506 Followers: Int(1), 7507 Following: Int(1), 7508 CreatedAt: &Timestamp{referenceTime}, 7509 SuspendedAt: &Timestamp{referenceTime}, 7510 }, 7511 AccessTokensURL: String("atu"), 7512 RepositoriesURL: String("ru"), 7513 HTMLURL: String("hu"), 7514 TargetType: String("tt"), 7515 SingleFileName: String("sfn"), 7516 RepositorySelection: String("rs"), 7517 Events: []string{"e"}, 7518 SingleFilePaths: []string{"s"}, 7519 Permissions: &InstallationPermissions{ 7520 Actions: String("a"), 7521 Administration: String("ad"), 7522 Checks: String("c"), 7523 Contents: String("co"), 7524 ContentReferences: String("cr"), 7525 Deployments: String("d"), 7526 Environments: String("e"), 7527 Issues: String("i"), 7528 Metadata: String("md"), 7529 Members: String("m"), 7530 OrganizationAdministration: String("oa"), 7531 OrganizationHooks: String("oh"), 7532 OrganizationPlan: String("op"), 7533 OrganizationPreReceiveHooks: String("opr"), 7534 OrganizationProjects: String("op"), 7535 OrganizationSecrets: String("os"), 7536 OrganizationSelfHostedRunners: String("osh"), 7537 OrganizationUserBlocking: String("oub"), 7538 Packages: String("pkg"), 7539 Pages: String("pg"), 7540 PullRequests: String("pr"), 7541 RepositoryHooks: String("rh"), 7542 RepositoryProjects: String("rp"), 7543 RepositoryPreReceiveHooks: String("rprh"), 7544 Secrets: String("s"), 7545 SecretScanningAlerts: String("ssa"), 7546 SecurityEvents: String("se"), 7547 SingleFile: String("sf"), 7548 Statuses: String("s"), 7549 TeamDiscussions: String("td"), 7550 VulnerabilityAlerts: String("va"), 7551 Workflows: String("w"), 7552 }, 7553 CreatedAt: &Timestamp{referenceTime}, 7554 UpdatedAt: &Timestamp{referenceTime}, 7555 HasMultipleSingleFiles: Bool(false), 7556 SuspendedBy: &User{ 7557 Login: String("l"), 7558 ID: Int64(1), 7559 URL: String("u"), 7560 AvatarURL: String("a"), 7561 GravatarID: String("g"), 7562 Name: String("n"), 7563 Company: String("c"), 7564 Blog: String("b"), 7565 Location: String("l"), 7566 Email: String("e"), 7567 Hireable: Bool(true), 7568 Bio: String("b"), 7569 TwitterUsername: String("t"), 7570 PublicRepos: Int(1), 7571 Followers: Int(1), 7572 Following: Int(1), 7573 CreatedAt: &Timestamp{referenceTime}, 7574 SuspendedAt: &Timestamp{referenceTime}, 7575 }, 7576 SuspendedAt: &Timestamp{referenceTime}, 7577 }, 7578 } 7579 7580 want := `{ 7581 "comment": { 7582 "author_association": "aa", 7583 "body": "bo", 7584 "child_comment_count": 1, 7585 "created_at": ` + referenceTimeStr + `, 7586 "discussion_id": 1, 7587 "html_url": "hurl", 7588 "id": 1, 7589 "node_id": "nid", 7590 "parent_id": 1, 7591 "reactions": { 7592 "total_count": 1, 7593 "+1": 1, 7594 "-1": 1, 7595 "laugh": 1, 7596 "confused": 1, 7597 "heart": 1, 7598 "hooray": 1, 7599 "rocket": 1, 7600 "eyes": 1, 7601 "url": "url" 7602 }, 7603 "repository_url": "rurl", 7604 "updated_at": ` + referenceTimeStr + `, 7605 "user": { 7606 "login": "l", 7607 "id": 1, 7608 "node_id": "n", 7609 "avatar_url": "a", 7610 "url": "u", 7611 "events_url": "e", 7612 "repos_url": "r" 7613 } 7614 }, 7615 "discussion": { 7616 "repository_url": "rurl", 7617 "category": { 7618 "id": 1, 7619 "node_id": "nid", 7620 "repository_id": 1, 7621 "emoji": "emoji", 7622 "name": "name", 7623 "description": "description", 7624 "created_at": ` + referenceTimeStr + `, 7625 "updated_at": ` + referenceTimeStr + `, 7626 "slug": "slug", 7627 "is_answerable": false 7628 }, 7629 "html_url": "hurl", 7630 "id": 1, 7631 "node_id": "nurl", 7632 "number": 1, 7633 "title": "title", 7634 "user": { 7635 "login": "l", 7636 "id": 1, 7637 "node_id": "n", 7638 "avatar_url": "a", 7639 "url": "u", 7640 "events_url": "e", 7641 "repos_url": "r" 7642 }, 7643 "state": "st", 7644 "locked": false, 7645 "comments": 1, 7646 "created_at": ` + referenceTimeStr + `, 7647 "updated_at": ` + referenceTimeStr + `, 7648 "author_association": "aa", 7649 "body": "bo" 7650 }, 7651 "repository": { 7652 "id": 1, 7653 "name": "n", 7654 "url": "s" 7655 }, 7656 "organization": { 7657 "name": "n", 7658 "company": "c", 7659 "blog": "b", 7660 "location": "loc", 7661 "email": "e", 7662 "twitter_username": "tu", 7663 "description": "d", 7664 "billing_email": "be", 7665 "is_verified": true, 7666 "has_organization_projects": true, 7667 "has_repository_projects": true, 7668 "default_repository_permission": "drp", 7669 "members_can_create_repositories": true, 7670 "members_can_create_public_repositories": false, 7671 "members_can_create_private_repositories": true, 7672 "members_can_create_internal_repositories": true, 7673 "members_allowed_repository_creation_type": "marct", 7674 "members_can_create_pages": true, 7675 "members_can_create_public_pages": false, 7676 "members_can_create_private_pages": true 7677 }, 7678 "sender": { 7679 "login": "l", 7680 "id": 1, 7681 "node_id": "n", 7682 "avatar_url": "a", 7683 "url": "u", 7684 "events_url": "e", 7685 "repos_url": "r" 7686 }, 7687 "installation": { 7688 "id": 1, 7689 "node_id": "nid", 7690 "app_id": 1, 7691 "app_slug": "as", 7692 "target_id": 1, 7693 "account": { 7694 "login": "l", 7695 "id": 1, 7696 "avatar_url": "a", 7697 "gravatar_id": "g", 7698 "name": "n", 7699 "company": "c", 7700 "blog": "b", 7701 "location": "l", 7702 "email": "e", 7703 "hireable": true, 7704 "bio": "b", 7705 "twitter_username": "t", 7706 "public_repos": 1, 7707 "followers": 1, 7708 "following": 1, 7709 "created_at": ` + referenceTimeStr + `, 7710 "suspended_at": ` + referenceTimeStr + `, 7711 "url": "u" 7712 }, 7713 "access_tokens_url": "atu", 7714 "repositories_url": "ru", 7715 "html_url": "hu", 7716 "target_type": "tt", 7717 "single_file_name": "sfn", 7718 "repository_selection": "rs", 7719 "events": [ 7720 "e" 7721 ], 7722 "single_file_paths": [ 7723 "s" 7724 ], 7725 "permissions": { 7726 "actions": "a", 7727 "administration": "ad", 7728 "checks": "c", 7729 "contents": "co", 7730 "content_references": "cr", 7731 "deployments": "d", 7732 "environments": "e", 7733 "issues": "i", 7734 "metadata": "md", 7735 "members": "m", 7736 "organization_administration": "oa", 7737 "organization_hooks": "oh", 7738 "organization_plan": "op", 7739 "organization_pre_receive_hooks": "opr", 7740 "organization_projects": "op", 7741 "organization_secrets": "os", 7742 "organization_self_hosted_runners": "osh", 7743 "organization_user_blocking": "oub", 7744 "packages": "pkg", 7745 "pages": "pg", 7746 "pull_requests": "pr", 7747 "repository_hooks": "rh", 7748 "repository_projects": "rp", 7749 "repository_pre_receive_hooks": "rprh", 7750 "secrets": "s", 7751 "secret_scanning_alerts": "ssa", 7752 "security_events": "se", 7753 "single_file": "sf", 7754 "statuses": "s", 7755 "team_discussions": "td", 7756 "vulnerability_alerts": "va", 7757 "workflows": "w" 7758 }, 7759 "created_at": ` + referenceTimeStr + `, 7760 "updated_at": ` + referenceTimeStr + `, 7761 "has_multiple_single_files": false, 7762 "suspended_by": { 7763 "login": "l", 7764 "id": 1, 7765 "avatar_url": "a", 7766 "gravatar_id": "g", 7767 "name": "n", 7768 "company": "c", 7769 "blog": "b", 7770 "location": "l", 7771 "email": "e", 7772 "hireable": true, 7773 "bio": "b", 7774 "twitter_username": "t", 7775 "public_repos": 1, 7776 "followers": 1, 7777 "following": 1, 7778 "created_at": ` + referenceTimeStr + `, 7779 "suspended_at": ` + referenceTimeStr + `, 7780 "url": "u" 7781 }, 7782 "suspended_at": ` + referenceTimeStr + ` 7783 } 7784 }` 7785 7786 testJSONMarshal(t, u, want) 7787 } 7788 7789 func TestDiscussionEvent_Marshal(t *testing.T) { 7790 t.Parallel() 7791 testJSONMarshal(t, &DiscussionEvent{}, "{}") 7792 7793 u := &DiscussionEvent{ 7794 Discussion: &Discussion{ 7795 RepositoryURL: String("rurl"), 7796 DiscussionCategory: &DiscussionCategory{ 7797 ID: Int64(1), 7798 NodeID: String("nid"), 7799 RepositoryID: Int64(1), 7800 Emoji: String("emoji"), 7801 Name: String("name"), 7802 Description: String("description"), 7803 CreatedAt: &Timestamp{referenceTime}, 7804 UpdatedAt: &Timestamp{referenceTime}, 7805 Slug: String("slug"), 7806 IsAnswerable: Bool(false), 7807 }, 7808 HTMLURL: String("hurl"), 7809 ID: Int64(1), 7810 NodeID: String("nurl"), 7811 Number: Int(1), 7812 Title: String("title"), 7813 User: &User{ 7814 Login: String("l"), 7815 ID: Int64(1), 7816 NodeID: String("n"), 7817 URL: String("u"), 7818 ReposURL: String("r"), 7819 EventsURL: String("e"), 7820 AvatarURL: String("a"), 7821 }, 7822 State: String("st"), 7823 Locked: Bool(false), 7824 Comments: Int(1), 7825 CreatedAt: &Timestamp{referenceTime}, 7826 UpdatedAt: &Timestamp{referenceTime}, 7827 AuthorAssociation: String("aa"), 7828 Body: String("bo"), 7829 }, 7830 Repo: &Repository{ 7831 ID: Int64(1), 7832 URL: String("s"), 7833 Name: String("n"), 7834 }, 7835 Org: &Organization{ 7836 BillingEmail: String("be"), 7837 Blog: String("b"), 7838 Company: String("c"), 7839 Email: String("e"), 7840 TwitterUsername: String("tu"), 7841 Location: String("loc"), 7842 Name: String("n"), 7843 Description: String("d"), 7844 IsVerified: Bool(true), 7845 HasOrganizationProjects: Bool(true), 7846 HasRepositoryProjects: Bool(true), 7847 DefaultRepoPermission: String("drp"), 7848 MembersCanCreateRepos: Bool(true), 7849 MembersCanCreateInternalRepos: Bool(true), 7850 MembersCanCreatePrivateRepos: Bool(true), 7851 MembersCanCreatePublicRepos: Bool(false), 7852 MembersAllowedRepositoryCreationType: String("marct"), 7853 MembersCanCreatePages: Bool(true), 7854 MembersCanCreatePublicPages: Bool(false), 7855 MembersCanCreatePrivatePages: Bool(true), 7856 }, 7857 Sender: &User{ 7858 Login: String("l"), 7859 ID: Int64(1), 7860 NodeID: String("n"), 7861 URL: String("u"), 7862 ReposURL: String("r"), 7863 EventsURL: String("e"), 7864 AvatarURL: String("a"), 7865 }, 7866 Installation: &Installation{ 7867 ID: Int64(1), 7868 NodeID: String("nid"), 7869 AppID: Int64(1), 7870 AppSlug: String("as"), 7871 TargetID: Int64(1), 7872 Account: &User{ 7873 Login: String("l"), 7874 ID: Int64(1), 7875 URL: String("u"), 7876 AvatarURL: String("a"), 7877 GravatarID: String("g"), 7878 Name: String("n"), 7879 Company: String("c"), 7880 Blog: String("b"), 7881 Location: String("l"), 7882 Email: String("e"), 7883 Hireable: Bool(true), 7884 Bio: String("b"), 7885 TwitterUsername: String("t"), 7886 PublicRepos: Int(1), 7887 Followers: Int(1), 7888 Following: Int(1), 7889 CreatedAt: &Timestamp{referenceTime}, 7890 SuspendedAt: &Timestamp{referenceTime}, 7891 }, 7892 AccessTokensURL: String("atu"), 7893 RepositoriesURL: String("ru"), 7894 HTMLURL: String("hu"), 7895 TargetType: String("tt"), 7896 SingleFileName: String("sfn"), 7897 RepositorySelection: String("rs"), 7898 Events: []string{"e"}, 7899 SingleFilePaths: []string{"s"}, 7900 Permissions: &InstallationPermissions{ 7901 Actions: String("a"), 7902 Administration: String("ad"), 7903 Checks: String("c"), 7904 Contents: String("co"), 7905 ContentReferences: String("cr"), 7906 Deployments: String("d"), 7907 Environments: String("e"), 7908 Issues: String("i"), 7909 Metadata: String("md"), 7910 Members: String("m"), 7911 OrganizationAdministration: String("oa"), 7912 OrganizationHooks: String("oh"), 7913 OrganizationPlan: String("op"), 7914 OrganizationPreReceiveHooks: String("opr"), 7915 OrganizationProjects: String("op"), 7916 OrganizationSecrets: String("os"), 7917 OrganizationSelfHostedRunners: String("osh"), 7918 OrganizationUserBlocking: String("oub"), 7919 Packages: String("pkg"), 7920 Pages: String("pg"), 7921 PullRequests: String("pr"), 7922 RepositoryHooks: String("rh"), 7923 RepositoryProjects: String("rp"), 7924 RepositoryPreReceiveHooks: String("rprh"), 7925 Secrets: String("s"), 7926 SecretScanningAlerts: String("ssa"), 7927 SecurityEvents: String("se"), 7928 SingleFile: String("sf"), 7929 Statuses: String("s"), 7930 TeamDiscussions: String("td"), 7931 VulnerabilityAlerts: String("va"), 7932 Workflows: String("w"), 7933 }, 7934 CreatedAt: &Timestamp{referenceTime}, 7935 UpdatedAt: &Timestamp{referenceTime}, 7936 HasMultipleSingleFiles: Bool(false), 7937 SuspendedBy: &User{ 7938 Login: String("l"), 7939 ID: Int64(1), 7940 URL: String("u"), 7941 AvatarURL: String("a"), 7942 GravatarID: String("g"), 7943 Name: String("n"), 7944 Company: String("c"), 7945 Blog: String("b"), 7946 Location: String("l"), 7947 Email: String("e"), 7948 Hireable: Bool(true), 7949 Bio: String("b"), 7950 TwitterUsername: String("t"), 7951 PublicRepos: Int(1), 7952 Followers: Int(1), 7953 Following: Int(1), 7954 CreatedAt: &Timestamp{referenceTime}, 7955 SuspendedAt: &Timestamp{referenceTime}, 7956 }, 7957 SuspendedAt: &Timestamp{referenceTime}, 7958 }, 7959 } 7960 7961 want := `{ 7962 "discussion": { 7963 "repository_url": "rurl", 7964 "category": { 7965 "id": 1, 7966 "node_id": "nid", 7967 "repository_id": 1, 7968 "emoji": "emoji", 7969 "name": "name", 7970 "description": "description", 7971 "created_at": ` + referenceTimeStr + `, 7972 "updated_at": ` + referenceTimeStr + `, 7973 "slug": "slug", 7974 "is_answerable": false 7975 }, 7976 "html_url": "hurl", 7977 "id": 1, 7978 "node_id": "nurl", 7979 "number": 1, 7980 "title": "title", 7981 "user": { 7982 "login": "l", 7983 "id": 1, 7984 "node_id": "n", 7985 "avatar_url": "a", 7986 "url": "u", 7987 "events_url": "e", 7988 "repos_url": "r" 7989 }, 7990 "state": "st", 7991 "locked": false, 7992 "comments": 1, 7993 "created_at": ` + referenceTimeStr + `, 7994 "updated_at": ` + referenceTimeStr + `, 7995 "author_association": "aa", 7996 "body": "bo" 7997 }, 7998 "repository": { 7999 "id": 1, 8000 "name": "n", 8001 "url": "s" 8002 }, 8003 "organization": { 8004 "name": "n", 8005 "company": "c", 8006 "blog": "b", 8007 "location": "loc", 8008 "email": "e", 8009 "twitter_username": "tu", 8010 "description": "d", 8011 "billing_email": "be", 8012 "is_verified": true, 8013 "has_organization_projects": true, 8014 "has_repository_projects": true, 8015 "default_repository_permission": "drp", 8016 "members_can_create_repositories": true, 8017 "members_can_create_public_repositories": false, 8018 "members_can_create_private_repositories": true, 8019 "members_can_create_internal_repositories": true, 8020 "members_allowed_repository_creation_type": "marct", 8021 "members_can_create_pages": true, 8022 "members_can_create_public_pages": false, 8023 "members_can_create_private_pages": true 8024 }, 8025 "sender": { 8026 "login": "l", 8027 "id": 1, 8028 "node_id": "n", 8029 "avatar_url": "a", 8030 "url": "u", 8031 "events_url": "e", 8032 "repos_url": "r" 8033 }, 8034 "installation": { 8035 "id": 1, 8036 "node_id": "nid", 8037 "app_id": 1, 8038 "app_slug": "as", 8039 "target_id": 1, 8040 "account": { 8041 "login": "l", 8042 "id": 1, 8043 "avatar_url": "a", 8044 "gravatar_id": "g", 8045 "name": "n", 8046 "company": "c", 8047 "blog": "b", 8048 "location": "l", 8049 "email": "e", 8050 "hireable": true, 8051 "bio": "b", 8052 "twitter_username": "t", 8053 "public_repos": 1, 8054 "followers": 1, 8055 "following": 1, 8056 "created_at": ` + referenceTimeStr + `, 8057 "suspended_at": ` + referenceTimeStr + `, 8058 "url": "u" 8059 }, 8060 "access_tokens_url": "atu", 8061 "repositories_url": "ru", 8062 "html_url": "hu", 8063 "target_type": "tt", 8064 "single_file_name": "sfn", 8065 "repository_selection": "rs", 8066 "events": [ 8067 "e" 8068 ], 8069 "single_file_paths": [ 8070 "s" 8071 ], 8072 "permissions": { 8073 "actions": "a", 8074 "administration": "ad", 8075 "checks": "c", 8076 "contents": "co", 8077 "content_references": "cr", 8078 "deployments": "d", 8079 "environments": "e", 8080 "issues": "i", 8081 "metadata": "md", 8082 "members": "m", 8083 "organization_administration": "oa", 8084 "organization_hooks": "oh", 8085 "organization_plan": "op", 8086 "organization_pre_receive_hooks": "opr", 8087 "organization_projects": "op", 8088 "organization_secrets": "os", 8089 "organization_self_hosted_runners": "osh", 8090 "organization_user_blocking": "oub", 8091 "packages": "pkg", 8092 "pages": "pg", 8093 "pull_requests": "pr", 8094 "repository_hooks": "rh", 8095 "repository_projects": "rp", 8096 "repository_pre_receive_hooks": "rprh", 8097 "secrets": "s", 8098 "secret_scanning_alerts": "ssa", 8099 "security_events": "se", 8100 "single_file": "sf", 8101 "statuses": "s", 8102 "team_discussions": "td", 8103 "vulnerability_alerts": "va", 8104 "workflows": "w" 8105 }, 8106 "created_at": ` + referenceTimeStr + `, 8107 "updated_at": ` + referenceTimeStr + `, 8108 "has_multiple_single_files": false, 8109 "suspended_by": { 8110 "login": "l", 8111 "id": 1, 8112 "avatar_url": "a", 8113 "gravatar_id": "g", 8114 "name": "n", 8115 "company": "c", 8116 "blog": "b", 8117 "location": "l", 8118 "email": "e", 8119 "hireable": true, 8120 "bio": "b", 8121 "twitter_username": "t", 8122 "public_repos": 1, 8123 "followers": 1, 8124 "following": 1, 8125 "created_at": ` + referenceTimeStr + `, 8126 "suspended_at": ` + referenceTimeStr + `, 8127 "url": "u" 8128 }, 8129 "suspended_at": ` + referenceTimeStr + ` 8130 } 8131 }` 8132 8133 testJSONMarshal(t, u, want) 8134 } 8135 8136 func TestPackageEvent_Marshal(t *testing.T) { 8137 t.Parallel() 8138 testJSONMarshal(t, &PackageEvent{}, "{}") 8139 8140 u := &PackageEvent{ 8141 Action: String("a"), 8142 Package: &Package{ 8143 ID: Int64(1), 8144 Name: String("n"), 8145 PackageType: String("pt"), 8146 HTMLURL: String("hurl"), 8147 CreatedAt: &Timestamp{referenceTime}, 8148 UpdatedAt: &Timestamp{referenceTime}, 8149 Owner: &User{ 8150 Login: String("l"), 8151 ID: Int64(1), 8152 NodeID: String("n"), 8153 URL: String("u"), 8154 ReposURL: String("r"), 8155 EventsURL: String("e"), 8156 AvatarURL: String("a"), 8157 }, 8158 PackageVersion: &PackageVersion{ID: Int64(1)}, 8159 Registry: &PackageRegistry{Name: String("n")}, 8160 }, 8161 Repo: &Repository{ 8162 ID: Int64(1), 8163 URL: String("s"), 8164 Name: String("n"), 8165 }, 8166 Org: &Organization{ 8167 BillingEmail: String("be"), 8168 Blog: String("b"), 8169 Company: String("c"), 8170 Email: String("e"), 8171 TwitterUsername: String("tu"), 8172 Location: String("loc"), 8173 Name: String("n"), 8174 Description: String("d"), 8175 IsVerified: Bool(true), 8176 HasOrganizationProjects: Bool(true), 8177 HasRepositoryProjects: Bool(true), 8178 DefaultRepoPermission: String("drp"), 8179 MembersCanCreateRepos: Bool(true), 8180 MembersCanCreateInternalRepos: Bool(true), 8181 MembersCanCreatePrivateRepos: Bool(true), 8182 MembersCanCreatePublicRepos: Bool(false), 8183 MembersAllowedRepositoryCreationType: String("marct"), 8184 MembersCanCreatePages: Bool(true), 8185 MembersCanCreatePublicPages: Bool(false), 8186 MembersCanCreatePrivatePages: Bool(true), 8187 }, 8188 Sender: &User{ 8189 Login: String("l"), 8190 ID: Int64(1), 8191 NodeID: String("n"), 8192 URL: String("u"), 8193 ReposURL: String("r"), 8194 EventsURL: String("e"), 8195 AvatarURL: String("a"), 8196 }, 8197 } 8198 8199 want := `{ 8200 "action": "a", 8201 "package": { 8202 "id": 1, 8203 "name": "n", 8204 "package_type": "pt", 8205 "html_url": "hurl", 8206 "created_at": ` + referenceTimeStr + `, 8207 "updated_at": ` + referenceTimeStr + `, 8208 "owner": { 8209 "login": "l", 8210 "id": 1, 8211 "node_id": "n", 8212 "avatar_url": "a", 8213 "url": "u", 8214 "events_url": "e", 8215 "repos_url": "r" 8216 }, 8217 "package_version": { 8218 "id": 1 8219 }, 8220 "registry": { 8221 "name": "n" 8222 } 8223 }, 8224 "repository": { 8225 "id": 1, 8226 "name": "n", 8227 "url": "s" 8228 }, 8229 "organization": { 8230 "name": "n", 8231 "company": "c", 8232 "blog": "b", 8233 "location": "loc", 8234 "email": "e", 8235 "twitter_username": "tu", 8236 "description": "d", 8237 "billing_email": "be", 8238 "is_verified": true, 8239 "has_organization_projects": true, 8240 "has_repository_projects": true, 8241 "default_repository_permission": "drp", 8242 "members_can_create_repositories": true, 8243 "members_can_create_public_repositories": false, 8244 "members_can_create_private_repositories": true, 8245 "members_can_create_internal_repositories": true, 8246 "members_allowed_repository_creation_type": "marct", 8247 "members_can_create_pages": true, 8248 "members_can_create_public_pages": false, 8249 "members_can_create_private_pages": true 8250 }, 8251 "sender": { 8252 "login": "l", 8253 "id": 1, 8254 "node_id": "n", 8255 "avatar_url": "a", 8256 "url": "u", 8257 "events_url": "e", 8258 "repos_url": "r" 8259 } 8260 }` 8261 8262 testJSONMarshal(t, u, want) 8263 } 8264 8265 func TestPersonalAccessTokenRequestEvent_Marshal(t *testing.T) { 8266 t.Parallel() 8267 testJSONMarshal(t, &PersonalAccessTokenRequestEvent{}, "{}") 8268 8269 event := &PersonalAccessTokenRequestEvent{ 8270 Action: String("a"), 8271 PersonalAccessTokenRequest: &PersonalAccessTokenRequest{ 8272 ID: Int64(1), 8273 Owner: &User{Login: String("l")}, 8274 PermissionsAdded: &PersonalAccessTokenPermissions{ 8275 Org: map[string]string{"organization_events": "read"}, 8276 Repo: map[string]string{"security_events": "write"}, 8277 }, 8278 CreatedAt: &Timestamp{referenceTime}, 8279 TokenExpired: Bool(false), 8280 TokenExpiresAt: &Timestamp{referenceTime}, 8281 TokenLastUsedAt: &Timestamp{referenceTime}, 8282 RepositoryCount: Int64(1), 8283 RepositorySelection: String("rs"), 8284 Repositories: []*Repository{ 8285 { 8286 Name: String("n"), 8287 }, 8288 }, 8289 }, 8290 Org: &Organization{Name: String("n")}, 8291 Sender: &User{ 8292 Login: String("l"), 8293 }, 8294 Installation: &Installation{ 8295 ID: Int64(1), 8296 }, 8297 } 8298 8299 want := `{ 8300 "action": "a", 8301 "personal_access_token_request": { 8302 "id": 1, 8303 "owner": { 8304 "login": "l" 8305 }, 8306 "permissions_added": { 8307 "organization": { 8308 "organization_events": "read" 8309 }, 8310 "repository": { 8311 "security_events": "write" 8312 } 8313 }, 8314 "created_at": ` + referenceTimeStr + `, 8315 "token_expired": false, 8316 "token_expires_at": ` + referenceTimeStr + `, 8317 "token_last_used_at": ` + referenceTimeStr + `, 8318 "repository_count": 1, 8319 "repository_selection": "rs", 8320 "repositories": [ 8321 { 8322 "name": "n" 8323 } 8324 ] 8325 }, 8326 "organization": { 8327 "name": "n" 8328 }, 8329 "sender": { 8330 "login": "l" 8331 }, 8332 "installation": { 8333 "id": 1 8334 } 8335 }` 8336 8337 testJSONMarshal(t, event, want) 8338 } 8339 8340 func TestPingEvent_Marshal(t *testing.T) { 8341 t.Parallel() 8342 testJSONMarshal(t, &PingEvent{}, "{}") 8343 8344 l := make(map[string]interface{}) 8345 l["key"] = "value" 8346 hookConfig := new(HookConfig) 8347 8348 u := &PingEvent{ 8349 Zen: String("z"), 8350 HookID: Int64(1), 8351 Hook: &Hook{ 8352 CreatedAt: &Timestamp{referenceTime}, 8353 UpdatedAt: &Timestamp{referenceTime}, 8354 URL: String("url"), 8355 ID: Int64(1), 8356 Type: String("t"), 8357 Name: String("n"), 8358 TestURL: String("tu"), 8359 PingURL: String("pu"), 8360 LastResponse: l, 8361 Config: hookConfig, 8362 Events: []string{"a"}, 8363 Active: Bool(true), 8364 }, 8365 Installation: &Installation{ 8366 ID: Int64(1), 8367 NodeID: String("nid"), 8368 AppID: Int64(1), 8369 AppSlug: String("as"), 8370 TargetID: Int64(1), 8371 Account: &User{ 8372 Login: String("l"), 8373 ID: Int64(1), 8374 URL: String("u"), 8375 AvatarURL: String("a"), 8376 GravatarID: String("g"), 8377 Name: String("n"), 8378 Company: String("c"), 8379 Blog: String("b"), 8380 Location: String("l"), 8381 Email: String("e"), 8382 Hireable: Bool(true), 8383 Bio: String("b"), 8384 TwitterUsername: String("t"), 8385 PublicRepos: Int(1), 8386 Followers: Int(1), 8387 Following: Int(1), 8388 CreatedAt: &Timestamp{referenceTime}, 8389 SuspendedAt: &Timestamp{referenceTime}, 8390 }, 8391 AccessTokensURL: String("atu"), 8392 RepositoriesURL: String("ru"), 8393 HTMLURL: String("hu"), 8394 TargetType: String("tt"), 8395 SingleFileName: String("sfn"), 8396 RepositorySelection: String("rs"), 8397 Events: []string{"e"}, 8398 SingleFilePaths: []string{"s"}, 8399 Permissions: &InstallationPermissions{ 8400 Actions: String("a"), 8401 Administration: String("ad"), 8402 Checks: String("c"), 8403 Contents: String("co"), 8404 ContentReferences: String("cr"), 8405 Deployments: String("d"), 8406 Environments: String("e"), 8407 Issues: String("i"), 8408 Metadata: String("md"), 8409 Members: String("m"), 8410 OrganizationAdministration: String("oa"), 8411 OrganizationHooks: String("oh"), 8412 OrganizationPlan: String("op"), 8413 OrganizationPreReceiveHooks: String("opr"), 8414 OrganizationProjects: String("op"), 8415 OrganizationSecrets: String("os"), 8416 OrganizationSelfHostedRunners: String("osh"), 8417 OrganizationUserBlocking: String("oub"), 8418 Packages: String("pkg"), 8419 Pages: String("pg"), 8420 PullRequests: String("pr"), 8421 RepositoryHooks: String("rh"), 8422 RepositoryProjects: String("rp"), 8423 RepositoryPreReceiveHooks: String("rprh"), 8424 Secrets: String("s"), 8425 SecretScanningAlerts: String("ssa"), 8426 SecurityEvents: String("se"), 8427 SingleFile: String("sf"), 8428 Statuses: String("s"), 8429 TeamDiscussions: String("td"), 8430 VulnerabilityAlerts: String("va"), 8431 Workflows: String("w"), 8432 }, 8433 CreatedAt: &Timestamp{referenceTime}, 8434 UpdatedAt: &Timestamp{referenceTime}, 8435 HasMultipleSingleFiles: Bool(false), 8436 SuspendedBy: &User{ 8437 Login: String("l"), 8438 ID: Int64(1), 8439 URL: String("u"), 8440 AvatarURL: String("a"), 8441 GravatarID: String("g"), 8442 Name: String("n"), 8443 Company: String("c"), 8444 Blog: String("b"), 8445 Location: String("l"), 8446 Email: String("e"), 8447 Hireable: Bool(true), 8448 Bio: String("b"), 8449 TwitterUsername: String("t"), 8450 PublicRepos: Int(1), 8451 Followers: Int(1), 8452 Following: Int(1), 8453 CreatedAt: &Timestamp{referenceTime}, 8454 SuspendedAt: &Timestamp{referenceTime}, 8455 }, 8456 SuspendedAt: &Timestamp{referenceTime}, 8457 }, 8458 } 8459 8460 want := `{ 8461 "zen": "z", 8462 "hook_id": 1, 8463 "hook": { 8464 "created_at": ` + referenceTimeStr + `, 8465 "updated_at": ` + referenceTimeStr + `, 8466 "url": "url", 8467 "id": 1, 8468 "type": "t", 8469 "name": "n", 8470 "test_url": "tu", 8471 "ping_url": "pu", 8472 "last_response": { 8473 "key": "value" 8474 }, 8475 "config": { 8476 "key": "value" 8477 }, 8478 "events": [ 8479 "a" 8480 ], 8481 "active": true 8482 }, 8483 "installation": { 8484 "id": 1, 8485 "node_id": "nid", 8486 "app_id": 1, 8487 "app_slug": "as", 8488 "target_id": 1, 8489 "account": { 8490 "login": "l", 8491 "id": 1, 8492 "avatar_url": "a", 8493 "gravatar_id": "g", 8494 "name": "n", 8495 "company": "c", 8496 "blog": "b", 8497 "location": "l", 8498 "email": "e", 8499 "hireable": true, 8500 "bio": "b", 8501 "twitter_username": "t", 8502 "public_repos": 1, 8503 "followers": 1, 8504 "following": 1, 8505 "created_at": ` + referenceTimeStr + `, 8506 "suspended_at": ` + referenceTimeStr + `, 8507 "url": "u" 8508 }, 8509 "access_tokens_url": "atu", 8510 "repositories_url": "ru", 8511 "html_url": "hu", 8512 "target_type": "tt", 8513 "single_file_name": "sfn", 8514 "repository_selection": "rs", 8515 "events": [ 8516 "e" 8517 ], 8518 "single_file_paths": [ 8519 "s" 8520 ], 8521 "permissions": { 8522 "actions": "a", 8523 "administration": "ad", 8524 "checks": "c", 8525 "contents": "co", 8526 "content_references": "cr", 8527 "deployments": "d", 8528 "environments": "e", 8529 "issues": "i", 8530 "metadata": "md", 8531 "members": "m", 8532 "organization_administration": "oa", 8533 "organization_hooks": "oh", 8534 "organization_plan": "op", 8535 "organization_pre_receive_hooks": "opr", 8536 "organization_projects": "op", 8537 "organization_secrets": "os", 8538 "organization_self_hosted_runners": "osh", 8539 "organization_user_blocking": "oub", 8540 "packages": "pkg", 8541 "pages": "pg", 8542 "pull_requests": "pr", 8543 "repository_hooks": "rh", 8544 "repository_projects": "rp", 8545 "repository_pre_receive_hooks": "rprh", 8546 "secrets": "s", 8547 "secret_scanning_alerts": "ssa", 8548 "security_events": "se", 8549 "single_file": "sf", 8550 "statuses": "s", 8551 "team_discussions": "td", 8552 "vulnerability_alerts": "va", 8553 "workflows": "w" 8554 }, 8555 "created_at": ` + referenceTimeStr + `, 8556 "updated_at": ` + referenceTimeStr + `, 8557 "has_multiple_single_files": false, 8558 "suspended_by": { 8559 "login": "l", 8560 "id": 1, 8561 "avatar_url": "a", 8562 "gravatar_id": "g", 8563 "name": "n", 8564 "company": "c", 8565 "blog": "b", 8566 "location": "l", 8567 "email": "e", 8568 "hireable": true, 8569 "bio": "b", 8570 "twitter_username": "t", 8571 "public_repos": 1, 8572 "followers": 1, 8573 "following": 1, 8574 "created_at": ` + referenceTimeStr + `, 8575 "suspended_at": ` + referenceTimeStr + `, 8576 "url": "u" 8577 }, 8578 "suspended_at": ` + referenceTimeStr + ` 8579 } 8580 }` 8581 8582 testJSONMarshal(t, u, want) 8583 } 8584 8585 func TestRepositoryDispatchEvent_Marshal(t *testing.T) { 8586 t.Parallel() 8587 testJSONMarshal(t, &RepositoryDispatchEvent{}, "{}") 8588 8589 l := make(map[string]interface{}) 8590 l["key"] = "value" 8591 8592 jsonMsg, _ := json.Marshal(&l) 8593 8594 u := &RepositoryDispatchEvent{ 8595 Action: String("a"), 8596 Branch: String("b"), 8597 ClientPayload: jsonMsg, 8598 Repo: &Repository{ 8599 8600 ID: Int64(1), 8601 URL: String("s"), 8602 Name: String("n"), 8603 }, 8604 Org: &Organization{ 8605 BillingEmail: String("be"), 8606 Blog: String("b"), 8607 Company: String("c"), 8608 Email: String("e"), 8609 TwitterUsername: String("tu"), 8610 Location: String("loc"), 8611 Name: String("n"), 8612 Description: String("d"), 8613 IsVerified: Bool(true), 8614 HasOrganizationProjects: Bool(true), 8615 HasRepositoryProjects: Bool(true), 8616 DefaultRepoPermission: String("drp"), 8617 MembersCanCreateRepos: Bool(true), 8618 MembersCanCreateInternalRepos: Bool(true), 8619 MembersCanCreatePrivateRepos: Bool(true), 8620 MembersCanCreatePublicRepos: Bool(false), 8621 MembersAllowedRepositoryCreationType: String("marct"), 8622 MembersCanCreatePages: Bool(true), 8623 MembersCanCreatePublicPages: Bool(false), 8624 MembersCanCreatePrivatePages: Bool(true), 8625 }, 8626 Sender: &User{ 8627 Login: String("l"), 8628 ID: Int64(1), 8629 NodeID: String("n"), 8630 URL: String("u"), 8631 ReposURL: String("r"), 8632 EventsURL: String("e"), 8633 AvatarURL: String("a"), 8634 }, 8635 Installation: &Installation{ 8636 ID: Int64(1), 8637 NodeID: String("nid"), 8638 AppID: Int64(1), 8639 AppSlug: String("as"), 8640 TargetID: Int64(1), 8641 Account: &User{ 8642 Login: String("l"), 8643 ID: Int64(1), 8644 URL: String("u"), 8645 AvatarURL: String("a"), 8646 GravatarID: String("g"), 8647 Name: String("n"), 8648 Company: String("c"), 8649 Blog: String("b"), 8650 Location: String("l"), 8651 Email: String("e"), 8652 Hireable: Bool(true), 8653 Bio: String("b"), 8654 TwitterUsername: String("t"), 8655 PublicRepos: Int(1), 8656 Followers: Int(1), 8657 Following: Int(1), 8658 CreatedAt: &Timestamp{referenceTime}, 8659 SuspendedAt: &Timestamp{referenceTime}, 8660 }, 8661 AccessTokensURL: String("atu"), 8662 RepositoriesURL: String("ru"), 8663 HTMLURL: String("hu"), 8664 TargetType: String("tt"), 8665 SingleFileName: String("sfn"), 8666 RepositorySelection: String("rs"), 8667 Events: []string{"e"}, 8668 SingleFilePaths: []string{"s"}, 8669 Permissions: &InstallationPermissions{ 8670 Actions: String("a"), 8671 Administration: String("ad"), 8672 Checks: String("c"), 8673 Contents: String("co"), 8674 ContentReferences: String("cr"), 8675 Deployments: String("d"), 8676 Environments: String("e"), 8677 Issues: String("i"), 8678 Metadata: String("md"), 8679 Members: String("m"), 8680 OrganizationAdministration: String("oa"), 8681 OrganizationHooks: String("oh"), 8682 OrganizationPlan: String("op"), 8683 OrganizationPreReceiveHooks: String("opr"), 8684 OrganizationProjects: String("op"), 8685 OrganizationSecrets: String("os"), 8686 OrganizationSelfHostedRunners: String("osh"), 8687 OrganizationUserBlocking: String("oub"), 8688 Packages: String("pkg"), 8689 Pages: String("pg"), 8690 PullRequests: String("pr"), 8691 RepositoryHooks: String("rh"), 8692 RepositoryProjects: String("rp"), 8693 RepositoryPreReceiveHooks: String("rprh"), 8694 Secrets: String("s"), 8695 SecretScanningAlerts: String("ssa"), 8696 SecurityEvents: String("se"), 8697 SingleFile: String("sf"), 8698 Statuses: String("s"), 8699 TeamDiscussions: String("td"), 8700 VulnerabilityAlerts: String("va"), 8701 Workflows: String("w"), 8702 }, 8703 CreatedAt: &Timestamp{referenceTime}, 8704 UpdatedAt: &Timestamp{referenceTime}, 8705 HasMultipleSingleFiles: Bool(false), 8706 SuspendedBy: &User{ 8707 Login: String("l"), 8708 ID: Int64(1), 8709 URL: String("u"), 8710 AvatarURL: String("a"), 8711 GravatarID: String("g"), 8712 Name: String("n"), 8713 Company: String("c"), 8714 Blog: String("b"), 8715 Location: String("l"), 8716 Email: String("e"), 8717 Hireable: Bool(true), 8718 Bio: String("b"), 8719 TwitterUsername: String("t"), 8720 PublicRepos: Int(1), 8721 Followers: Int(1), 8722 Following: Int(1), 8723 CreatedAt: &Timestamp{referenceTime}, 8724 SuspendedAt: &Timestamp{referenceTime}, 8725 }, 8726 SuspendedAt: &Timestamp{referenceTime}, 8727 }, 8728 } 8729 8730 want := `{ 8731 "action": "a", 8732 "branch": "b", 8733 "client_payload": { 8734 "key": "value" 8735 }, 8736 "repository": { 8737 "id": 1, 8738 "name": "n", 8739 "url": "s" 8740 }, 8741 "organization": { 8742 "name": "n", 8743 "company": "c", 8744 "blog": "b", 8745 "location": "loc", 8746 "email": "e", 8747 "twitter_username": "tu", 8748 "description": "d", 8749 "billing_email": "be", 8750 "is_verified": true, 8751 "has_organization_projects": true, 8752 "has_repository_projects": true, 8753 "default_repository_permission": "drp", 8754 "members_can_create_repositories": true, 8755 "members_can_create_public_repositories": false, 8756 "members_can_create_private_repositories": true, 8757 "members_can_create_internal_repositories": true, 8758 "members_allowed_repository_creation_type": "marct", 8759 "members_can_create_pages": true, 8760 "members_can_create_public_pages": false, 8761 "members_can_create_private_pages": true 8762 }, 8763 "sender": { 8764 "login": "l", 8765 "id": 1, 8766 "node_id": "n", 8767 "avatar_url": "a", 8768 "url": "u", 8769 "events_url": "e", 8770 "repos_url": "r" 8771 }, 8772 "installation": { 8773 "id": 1, 8774 "node_id": "nid", 8775 "app_id": 1, 8776 "app_slug": "as", 8777 "target_id": 1, 8778 "account": { 8779 "login": "l", 8780 "id": 1, 8781 "avatar_url": "a", 8782 "gravatar_id": "g", 8783 "name": "n", 8784 "company": "c", 8785 "blog": "b", 8786 "location": "l", 8787 "email": "e", 8788 "hireable": true, 8789 "bio": "b", 8790 "twitter_username": "t", 8791 "public_repos": 1, 8792 "followers": 1, 8793 "following": 1, 8794 "created_at": ` + referenceTimeStr + `, 8795 "suspended_at": ` + referenceTimeStr + `, 8796 "url": "u" 8797 }, 8798 "access_tokens_url": "atu", 8799 "repositories_url": "ru", 8800 "html_url": "hu", 8801 "target_type": "tt", 8802 "single_file_name": "sfn", 8803 "repository_selection": "rs", 8804 "events": [ 8805 "e" 8806 ], 8807 "single_file_paths": [ 8808 "s" 8809 ], 8810 "permissions": { 8811 "actions": "a", 8812 "administration": "ad", 8813 "checks": "c", 8814 "contents": "co", 8815 "content_references": "cr", 8816 "deployments": "d", 8817 "environments": "e", 8818 "issues": "i", 8819 "metadata": "md", 8820 "members": "m", 8821 "organization_administration": "oa", 8822 "organization_hooks": "oh", 8823 "organization_plan": "op", 8824 "organization_pre_receive_hooks": "opr", 8825 "organization_projects": "op", 8826 "organization_secrets": "os", 8827 "organization_self_hosted_runners": "osh", 8828 "organization_user_blocking": "oub", 8829 "packages": "pkg", 8830 "pages": "pg", 8831 "pull_requests": "pr", 8832 "repository_hooks": "rh", 8833 "repository_projects": "rp", 8834 "repository_pre_receive_hooks": "rprh", 8835 "secrets": "s", 8836 "secret_scanning_alerts": "ssa", 8837 "security_events": "se", 8838 "single_file": "sf", 8839 "statuses": "s", 8840 "team_discussions": "td", 8841 "vulnerability_alerts": "va", 8842 "workflows": "w" 8843 }, 8844 "created_at": ` + referenceTimeStr + `, 8845 "updated_at": ` + referenceTimeStr + `, 8846 "has_multiple_single_files": false, 8847 "suspended_by": { 8848 "login": "l", 8849 "id": 1, 8850 "avatar_url": "a", 8851 "gravatar_id": "g", 8852 "name": "n", 8853 "company": "c", 8854 "blog": "b", 8855 "location": "l", 8856 "email": "e", 8857 "hireable": true, 8858 "bio": "b", 8859 "twitter_username": "t", 8860 "public_repos": 1, 8861 "followers": 1, 8862 "following": 1, 8863 "created_at": ` + referenceTimeStr + `, 8864 "suspended_at": ` + referenceTimeStr + `, 8865 "url": "u" 8866 }, 8867 "suspended_at": ` + referenceTimeStr + ` 8868 } 8869 }` 8870 8871 testJSONMarshal(t, u, want) 8872 } 8873 8874 func TestRepositoryImportEvent_Marshal(t *testing.T) { 8875 t.Parallel() 8876 testJSONMarshal(t, &RepositoryImportEvent{}, "{}") 8877 8878 u := &RepositoryImportEvent{ 8879 Status: String("success"), 8880 Repo: &Repository{ 8881 ID: Int64(1), 8882 URL: String("s"), 8883 Name: String("n"), 8884 }, 8885 Org: &Organization{ 8886 BillingEmail: String("be"), 8887 Blog: String("b"), 8888 Company: String("c"), 8889 Email: String("e"), 8890 TwitterUsername: String("tu"), 8891 Location: String("loc"), 8892 Name: String("n"), 8893 Description: String("d"), 8894 IsVerified: Bool(true), 8895 HasOrganizationProjects: Bool(true), 8896 HasRepositoryProjects: Bool(true), 8897 DefaultRepoPermission: String("drp"), 8898 MembersCanCreateRepos: Bool(true), 8899 MembersCanCreateInternalRepos: Bool(true), 8900 MembersCanCreatePrivateRepos: Bool(true), 8901 MembersCanCreatePublicRepos: Bool(false), 8902 MembersAllowedRepositoryCreationType: String("marct"), 8903 MembersCanCreatePages: Bool(true), 8904 MembersCanCreatePublicPages: Bool(false), 8905 MembersCanCreatePrivatePages: Bool(true), 8906 }, 8907 Sender: &User{ 8908 Login: String("l"), 8909 ID: Int64(1), 8910 NodeID: String("n"), 8911 URL: String("u"), 8912 ReposURL: String("r"), 8913 EventsURL: String("e"), 8914 AvatarURL: String("a"), 8915 }, 8916 } 8917 8918 want := `{ 8919 "status": "success", 8920 "repository": { 8921 "id": 1, 8922 "name": "n", 8923 "url": "s" 8924 }, 8925 "organization": { 8926 "name": "n", 8927 "company": "c", 8928 "blog": "b", 8929 "location": "loc", 8930 "email": "e", 8931 "twitter_username": "tu", 8932 "description": "d", 8933 "billing_email": "be", 8934 "is_verified": true, 8935 "has_organization_projects": true, 8936 "has_repository_projects": true, 8937 "default_repository_permission": "drp", 8938 "members_can_create_repositories": true, 8939 "members_can_create_public_repositories": false, 8940 "members_can_create_private_repositories": true, 8941 "members_can_create_internal_repositories": true, 8942 "members_allowed_repository_creation_type": "marct", 8943 "members_can_create_pages": true, 8944 "members_can_create_public_pages": false, 8945 "members_can_create_private_pages": true 8946 }, 8947 "sender": { 8948 "login": "l", 8949 "id": 1, 8950 "node_id": "n", 8951 "avatar_url": "a", 8952 "url": "u", 8953 "events_url": "e", 8954 "repos_url": "r" 8955 } 8956 }` 8957 8958 testJSONMarshal(t, u, want) 8959 } 8960 8961 func TestRepositoryEvent_Marshal(t *testing.T) { 8962 t.Parallel() 8963 testJSONMarshal(t, &RepositoryEvent{}, "{}") 8964 8965 u := &RepositoryEvent{ 8966 Action: String("a"), 8967 Repo: &Repository{ 8968 ID: Int64(1), 8969 URL: String("s"), 8970 Name: String("n"), 8971 }, 8972 Org: &Organization{ 8973 BillingEmail: String("be"), 8974 Blog: String("b"), 8975 Company: String("c"), 8976 Email: String("e"), 8977 TwitterUsername: String("tu"), 8978 Location: String("loc"), 8979 Name: String("n"), 8980 Description: String("d"), 8981 IsVerified: Bool(true), 8982 HasOrganizationProjects: Bool(true), 8983 HasRepositoryProjects: Bool(true), 8984 DefaultRepoPermission: String("drp"), 8985 MembersCanCreateRepos: Bool(true), 8986 MembersCanCreateInternalRepos: Bool(true), 8987 MembersCanCreatePrivateRepos: Bool(true), 8988 MembersCanCreatePublicRepos: Bool(false), 8989 MembersAllowedRepositoryCreationType: String("marct"), 8990 MembersCanCreatePages: Bool(true), 8991 MembersCanCreatePublicPages: Bool(false), 8992 MembersCanCreatePrivatePages: Bool(true), 8993 }, 8994 Sender: &User{ 8995 Login: String("l"), 8996 ID: Int64(1), 8997 NodeID: String("n"), 8998 URL: String("u"), 8999 ReposURL: String("r"), 9000 EventsURL: String("e"), 9001 AvatarURL: String("a"), 9002 }, 9003 Installation: &Installation{ 9004 ID: Int64(1), 9005 NodeID: String("nid"), 9006 AppID: Int64(1), 9007 AppSlug: String("as"), 9008 TargetID: Int64(1), 9009 Account: &User{ 9010 Login: String("l"), 9011 ID: Int64(1), 9012 URL: String("u"), 9013 AvatarURL: String("a"), 9014 GravatarID: String("g"), 9015 Name: String("n"), 9016 Company: String("c"), 9017 Blog: String("b"), 9018 Location: String("l"), 9019 Email: String("e"), 9020 Hireable: Bool(true), 9021 Bio: String("b"), 9022 TwitterUsername: String("t"), 9023 PublicRepos: Int(1), 9024 Followers: Int(1), 9025 Following: Int(1), 9026 CreatedAt: &Timestamp{referenceTime}, 9027 SuspendedAt: &Timestamp{referenceTime}, 9028 }, 9029 AccessTokensURL: String("atu"), 9030 RepositoriesURL: String("ru"), 9031 HTMLURL: String("hu"), 9032 TargetType: String("tt"), 9033 SingleFileName: String("sfn"), 9034 RepositorySelection: String("rs"), 9035 Events: []string{"e"}, 9036 SingleFilePaths: []string{"s"}, 9037 Permissions: &InstallationPermissions{ 9038 Actions: String("a"), 9039 Administration: String("ad"), 9040 Checks: String("c"), 9041 Contents: String("co"), 9042 ContentReferences: String("cr"), 9043 Deployments: String("d"), 9044 Environments: String("e"), 9045 Issues: String("i"), 9046 Metadata: String("md"), 9047 Members: String("m"), 9048 OrganizationAdministration: String("oa"), 9049 OrganizationHooks: String("oh"), 9050 OrganizationPlan: String("op"), 9051 OrganizationPreReceiveHooks: String("opr"), 9052 OrganizationProjects: String("op"), 9053 OrganizationSecrets: String("os"), 9054 OrganizationSelfHostedRunners: String("osh"), 9055 OrganizationUserBlocking: String("oub"), 9056 Packages: String("pkg"), 9057 Pages: String("pg"), 9058 PullRequests: String("pr"), 9059 RepositoryHooks: String("rh"), 9060 RepositoryProjects: String("rp"), 9061 RepositoryPreReceiveHooks: String("rprh"), 9062 Secrets: String("s"), 9063 SecretScanningAlerts: String("ssa"), 9064 SecurityEvents: String("se"), 9065 SingleFile: String("sf"), 9066 Statuses: String("s"), 9067 TeamDiscussions: String("td"), 9068 VulnerabilityAlerts: String("va"), 9069 Workflows: String("w"), 9070 }, 9071 CreatedAt: &Timestamp{referenceTime}, 9072 UpdatedAt: &Timestamp{referenceTime}, 9073 HasMultipleSingleFiles: Bool(false), 9074 SuspendedBy: &User{ 9075 Login: String("l"), 9076 ID: Int64(1), 9077 URL: String("u"), 9078 AvatarURL: String("a"), 9079 GravatarID: String("g"), 9080 Name: String("n"), 9081 Company: String("c"), 9082 Blog: String("b"), 9083 Location: String("l"), 9084 Email: String("e"), 9085 Hireable: Bool(true), 9086 Bio: String("b"), 9087 TwitterUsername: String("t"), 9088 PublicRepos: Int(1), 9089 Followers: Int(1), 9090 Following: Int(1), 9091 CreatedAt: &Timestamp{referenceTime}, 9092 SuspendedAt: &Timestamp{referenceTime}, 9093 }, 9094 SuspendedAt: &Timestamp{referenceTime}, 9095 }, 9096 } 9097 9098 want := `{ 9099 "action": "a", 9100 "repository": { 9101 "id": 1, 9102 "name": "n", 9103 "url": "s" 9104 }, 9105 "organization": { 9106 "name": "n", 9107 "company": "c", 9108 "blog": "b", 9109 "location": "loc", 9110 "email": "e", 9111 "twitter_username": "tu", 9112 "description": "d", 9113 "billing_email": "be", 9114 "is_verified": true, 9115 "has_organization_projects": true, 9116 "has_repository_projects": true, 9117 "default_repository_permission": "drp", 9118 "members_can_create_repositories": true, 9119 "members_can_create_public_repositories": false, 9120 "members_can_create_private_repositories": true, 9121 "members_can_create_internal_repositories": true, 9122 "members_allowed_repository_creation_type": "marct", 9123 "members_can_create_pages": true, 9124 "members_can_create_public_pages": false, 9125 "members_can_create_private_pages": true 9126 }, 9127 "sender": { 9128 "login": "l", 9129 "id": 1, 9130 "node_id": "n", 9131 "avatar_url": "a", 9132 "url": "u", 9133 "events_url": "e", 9134 "repos_url": "r" 9135 }, 9136 "installation": { 9137 "id": 1, 9138 "node_id": "nid", 9139 "app_id": 1, 9140 "app_slug": "as", 9141 "target_id": 1, 9142 "account": { 9143 "login": "l", 9144 "id": 1, 9145 "avatar_url": "a", 9146 "gravatar_id": "g", 9147 "name": "n", 9148 "company": "c", 9149 "blog": "b", 9150 "location": "l", 9151 "email": "e", 9152 "hireable": true, 9153 "bio": "b", 9154 "twitter_username": "t", 9155 "public_repos": 1, 9156 "followers": 1, 9157 "following": 1, 9158 "created_at": ` + referenceTimeStr + `, 9159 "suspended_at": ` + referenceTimeStr + `, 9160 "url": "u" 9161 }, 9162 "access_tokens_url": "atu", 9163 "repositories_url": "ru", 9164 "html_url": "hu", 9165 "target_type": "tt", 9166 "single_file_name": "sfn", 9167 "repository_selection": "rs", 9168 "events": [ 9169 "e" 9170 ], 9171 "single_file_paths": [ 9172 "s" 9173 ], 9174 "permissions": { 9175 "actions": "a", 9176 "administration": "ad", 9177 "checks": "c", 9178 "contents": "co", 9179 "content_references": "cr", 9180 "deployments": "d", 9181 "environments": "e", 9182 "issues": "i", 9183 "metadata": "md", 9184 "members": "m", 9185 "organization_administration": "oa", 9186 "organization_hooks": "oh", 9187 "organization_plan": "op", 9188 "organization_pre_receive_hooks": "opr", 9189 "organization_projects": "op", 9190 "organization_secrets": "os", 9191 "organization_self_hosted_runners": "osh", 9192 "organization_user_blocking": "oub", 9193 "packages": "pkg", 9194 "pages": "pg", 9195 "pull_requests": "pr", 9196 "repository_hooks": "rh", 9197 "repository_projects": "rp", 9198 "repository_pre_receive_hooks": "rprh", 9199 "secrets": "s", 9200 "secret_scanning_alerts": "ssa", 9201 "security_events": "se", 9202 "single_file": "sf", 9203 "statuses": "s", 9204 "team_discussions": "td", 9205 "vulnerability_alerts": "va", 9206 "workflows": "w" 9207 }, 9208 "created_at": ` + referenceTimeStr + `, 9209 "updated_at": ` + referenceTimeStr + `, 9210 "has_multiple_single_files": false, 9211 "suspended_by": { 9212 "login": "l", 9213 "id": 1, 9214 "avatar_url": "a", 9215 "gravatar_id": "g", 9216 "name": "n", 9217 "company": "c", 9218 "blog": "b", 9219 "location": "l", 9220 "email": "e", 9221 "hireable": true, 9222 "bio": "b", 9223 "twitter_username": "t", 9224 "public_repos": 1, 9225 "followers": 1, 9226 "following": 1, 9227 "created_at": ` + referenceTimeStr + `, 9228 "suspended_at": ` + referenceTimeStr + `, 9229 "url": "u" 9230 }, 9231 "suspended_at": ` + referenceTimeStr + ` 9232 } 9233 }` 9234 9235 testJSONMarshal(t, u, want) 9236 } 9237 9238 func TestReleaseEvent_Marshal(t *testing.T) { 9239 t.Parallel() 9240 testJSONMarshal(t, &ReleaseEvent{}, "{}") 9241 9242 u := &ReleaseEvent{ 9243 Action: String("a"), 9244 Release: &RepositoryRelease{ 9245 Name: String("n"), 9246 DiscussionCategoryName: String("dcn"), 9247 ID: Int64(2), 9248 CreatedAt: &Timestamp{referenceTime}, 9249 PublishedAt: &Timestamp{referenceTime}, 9250 URL: String("url"), 9251 HTMLURL: String("htmlurl"), 9252 AssetsURL: String("assetsurl"), 9253 Assets: []*ReleaseAsset{{ID: Int64(1)}}, 9254 UploadURL: String("uploadurl"), 9255 ZipballURL: String("zipballurl"), 9256 TarballURL: String("tarballurl"), 9257 Author: &User{Name: String("octocat")}, 9258 NodeID: String("nid"), 9259 }, 9260 Repo: &Repository{ 9261 ID: Int64(1), 9262 URL: String("s"), 9263 Name: String("n"), 9264 }, 9265 Sender: &User{ 9266 Login: String("l"), 9267 ID: Int64(1), 9268 NodeID: String("n"), 9269 URL: String("u"), 9270 ReposURL: String("r"), 9271 EventsURL: String("e"), 9272 AvatarURL: String("a"), 9273 }, 9274 Installation: &Installation{ 9275 ID: Int64(1), 9276 NodeID: String("nid"), 9277 AppID: Int64(1), 9278 AppSlug: String("as"), 9279 TargetID: Int64(1), 9280 Account: &User{ 9281 Login: String("l"), 9282 ID: Int64(1), 9283 URL: String("u"), 9284 AvatarURL: String("a"), 9285 GravatarID: String("g"), 9286 Name: String("n"), 9287 Company: String("c"), 9288 Blog: String("b"), 9289 Location: String("l"), 9290 Email: String("e"), 9291 Hireable: Bool(true), 9292 Bio: String("b"), 9293 TwitterUsername: String("t"), 9294 PublicRepos: Int(1), 9295 Followers: Int(1), 9296 Following: Int(1), 9297 CreatedAt: &Timestamp{referenceTime}, 9298 SuspendedAt: &Timestamp{referenceTime}, 9299 }, 9300 AccessTokensURL: String("atu"), 9301 RepositoriesURL: String("ru"), 9302 HTMLURL: String("hu"), 9303 TargetType: String("tt"), 9304 SingleFileName: String("sfn"), 9305 RepositorySelection: String("rs"), 9306 Events: []string{"e"}, 9307 SingleFilePaths: []string{"s"}, 9308 Permissions: &InstallationPermissions{ 9309 Actions: String("a"), 9310 Administration: String("ad"), 9311 Checks: String("c"), 9312 Contents: String("co"), 9313 ContentReferences: String("cr"), 9314 Deployments: String("d"), 9315 Environments: String("e"), 9316 Issues: String("i"), 9317 Metadata: String("md"), 9318 Members: String("m"), 9319 OrganizationAdministration: String("oa"), 9320 OrganizationHooks: String("oh"), 9321 OrganizationPlan: String("op"), 9322 OrganizationPreReceiveHooks: String("opr"), 9323 OrganizationProjects: String("op"), 9324 OrganizationSecrets: String("os"), 9325 OrganizationSelfHostedRunners: String("osh"), 9326 OrganizationUserBlocking: String("oub"), 9327 Packages: String("pkg"), 9328 Pages: String("pg"), 9329 PullRequests: String("pr"), 9330 RepositoryHooks: String("rh"), 9331 RepositoryProjects: String("rp"), 9332 RepositoryPreReceiveHooks: String("rprh"), 9333 Secrets: String("s"), 9334 SecretScanningAlerts: String("ssa"), 9335 SecurityEvents: String("se"), 9336 SingleFile: String("sf"), 9337 Statuses: String("s"), 9338 TeamDiscussions: String("td"), 9339 VulnerabilityAlerts: String("va"), 9340 Workflows: String("w"), 9341 }, 9342 CreatedAt: &Timestamp{referenceTime}, 9343 UpdatedAt: &Timestamp{referenceTime}, 9344 HasMultipleSingleFiles: Bool(false), 9345 SuspendedBy: &User{ 9346 Login: String("l"), 9347 ID: Int64(1), 9348 URL: String("u"), 9349 AvatarURL: String("a"), 9350 GravatarID: String("g"), 9351 Name: String("n"), 9352 Company: String("c"), 9353 Blog: String("b"), 9354 Location: String("l"), 9355 Email: String("e"), 9356 Hireable: Bool(true), 9357 Bio: String("b"), 9358 TwitterUsername: String("t"), 9359 PublicRepos: Int(1), 9360 Followers: Int(1), 9361 Following: Int(1), 9362 CreatedAt: &Timestamp{referenceTime}, 9363 SuspendedAt: &Timestamp{referenceTime}, 9364 }, 9365 SuspendedAt: &Timestamp{referenceTime}, 9366 }, 9367 } 9368 9369 want := `{ 9370 "action": "a", 9371 "release": { 9372 "name": "n", 9373 "discussion_category_name": "dcn", 9374 "id": 2, 9375 "created_at": ` + referenceTimeStr + `, 9376 "published_at": ` + referenceTimeStr + `, 9377 "url": "url", 9378 "html_url": "htmlurl", 9379 "assets_url": "assetsurl", 9380 "assets": [ 9381 { 9382 "id": 1 9383 } 9384 ], 9385 "upload_url": "uploadurl", 9386 "zipball_url": "zipballurl", 9387 "tarball_url": "tarballurl", 9388 "author": { 9389 "name": "octocat" 9390 }, 9391 "node_id": "nid" 9392 }, 9393 "repository": { 9394 "id": 1, 9395 "name": "n", 9396 "url": "s" 9397 }, 9398 "sender": { 9399 "login": "l", 9400 "id": 1, 9401 "node_id": "n", 9402 "avatar_url": "a", 9403 "url": "u", 9404 "events_url": "e", 9405 "repos_url": "r" 9406 }, 9407 "installation": { 9408 "id": 1, 9409 "node_id": "nid", 9410 "app_id": 1, 9411 "app_slug": "as", 9412 "target_id": 1, 9413 "account": { 9414 "login": "l", 9415 "id": 1, 9416 "avatar_url": "a", 9417 "gravatar_id": "g", 9418 "name": "n", 9419 "company": "c", 9420 "blog": "b", 9421 "location": "l", 9422 "email": "e", 9423 "hireable": true, 9424 "bio": "b", 9425 "twitter_username": "t", 9426 "public_repos": 1, 9427 "followers": 1, 9428 "following": 1, 9429 "created_at": ` + referenceTimeStr + `, 9430 "suspended_at": ` + referenceTimeStr + `, 9431 "url": "u" 9432 }, 9433 "access_tokens_url": "atu", 9434 "repositories_url": "ru", 9435 "html_url": "hu", 9436 "target_type": "tt", 9437 "single_file_name": "sfn", 9438 "repository_selection": "rs", 9439 "events": [ 9440 "e" 9441 ], 9442 "single_file_paths": [ 9443 "s" 9444 ], 9445 "permissions": { 9446 "actions": "a", 9447 "administration": "ad", 9448 "checks": "c", 9449 "contents": "co", 9450 "content_references": "cr", 9451 "deployments": "d", 9452 "environments": "e", 9453 "issues": "i", 9454 "metadata": "md", 9455 "members": "m", 9456 "organization_administration": "oa", 9457 "organization_hooks": "oh", 9458 "organization_plan": "op", 9459 "organization_pre_receive_hooks": "opr", 9460 "organization_projects": "op", 9461 "organization_secrets": "os", 9462 "organization_self_hosted_runners": "osh", 9463 "organization_user_blocking": "oub", 9464 "packages": "pkg", 9465 "pages": "pg", 9466 "pull_requests": "pr", 9467 "repository_hooks": "rh", 9468 "repository_projects": "rp", 9469 "repository_pre_receive_hooks": "rprh", 9470 "secrets": "s", 9471 "secret_scanning_alerts": "ssa", 9472 "security_events": "se", 9473 "single_file": "sf", 9474 "statuses": "s", 9475 "team_discussions": "td", 9476 "vulnerability_alerts": "va", 9477 "workflows": "w" 9478 }, 9479 "created_at": ` + referenceTimeStr + `, 9480 "updated_at": ` + referenceTimeStr + `, 9481 "has_multiple_single_files": false, 9482 "suspended_by": { 9483 "login": "l", 9484 "id": 1, 9485 "avatar_url": "a", 9486 "gravatar_id": "g", 9487 "name": "n", 9488 "company": "c", 9489 "blog": "b", 9490 "location": "l", 9491 "email": "e", 9492 "hireable": true, 9493 "bio": "b", 9494 "twitter_username": "t", 9495 "public_repos": 1, 9496 "followers": 1, 9497 "following": 1, 9498 "created_at": ` + referenceTimeStr + `, 9499 "suspended_at": ` + referenceTimeStr + `, 9500 "url": "u" 9501 }, 9502 "suspended_at": ` + referenceTimeStr + ` 9503 } 9504 }` 9505 9506 testJSONMarshal(t, u, want) 9507 } 9508 9509 func TestContentReferenceEvent_Marshal(t *testing.T) { 9510 t.Parallel() 9511 testJSONMarshal(t, &ContentReferenceEvent{}, "{}") 9512 9513 u := &ContentReferenceEvent{ 9514 Action: String("a"), 9515 ContentReference: &ContentReference{ 9516 ID: Int64(1), 9517 NodeID: String("nid"), 9518 Reference: String("ref"), 9519 }, 9520 Repo: &Repository{ 9521 ID: Int64(1), 9522 URL: String("s"), 9523 Name: String("n"), 9524 }, 9525 Sender: &User{ 9526 Login: String("l"), 9527 ID: Int64(1), 9528 NodeID: String("n"), 9529 URL: String("u"), 9530 ReposURL: String("r"), 9531 EventsURL: String("e"), 9532 AvatarURL: String("a"), 9533 }, 9534 Installation: &Installation{ 9535 ID: Int64(1), 9536 NodeID: String("nid"), 9537 AppID: Int64(1), 9538 AppSlug: String("as"), 9539 TargetID: Int64(1), 9540 Account: &User{ 9541 Login: String("l"), 9542 ID: Int64(1), 9543 URL: String("u"), 9544 AvatarURL: String("a"), 9545 GravatarID: String("g"), 9546 Name: String("n"), 9547 Company: String("c"), 9548 Blog: String("b"), 9549 Location: String("l"), 9550 Email: String("e"), 9551 Hireable: Bool(true), 9552 Bio: String("b"), 9553 TwitterUsername: String("t"), 9554 PublicRepos: Int(1), 9555 Followers: Int(1), 9556 Following: Int(1), 9557 CreatedAt: &Timestamp{referenceTime}, 9558 SuspendedAt: &Timestamp{referenceTime}, 9559 }, 9560 AccessTokensURL: String("atu"), 9561 RepositoriesURL: String("ru"), 9562 HTMLURL: String("hu"), 9563 TargetType: String("tt"), 9564 SingleFileName: String("sfn"), 9565 RepositorySelection: String("rs"), 9566 Events: []string{"e"}, 9567 SingleFilePaths: []string{"s"}, 9568 Permissions: &InstallationPermissions{ 9569 Actions: String("a"), 9570 Administration: String("ad"), 9571 Checks: String("c"), 9572 Contents: String("co"), 9573 ContentReferences: String("cr"), 9574 Deployments: String("d"), 9575 Environments: String("e"), 9576 Issues: String("i"), 9577 Metadata: String("md"), 9578 Members: String("m"), 9579 OrganizationAdministration: String("oa"), 9580 OrganizationHooks: String("oh"), 9581 OrganizationPlan: String("op"), 9582 OrganizationPreReceiveHooks: String("opr"), 9583 OrganizationProjects: String("op"), 9584 OrganizationSecrets: String("os"), 9585 OrganizationSelfHostedRunners: String("osh"), 9586 OrganizationUserBlocking: String("oub"), 9587 Packages: String("pkg"), 9588 Pages: String("pg"), 9589 PullRequests: String("pr"), 9590 RepositoryHooks: String("rh"), 9591 RepositoryProjects: String("rp"), 9592 RepositoryPreReceiveHooks: String("rprh"), 9593 Secrets: String("s"), 9594 SecretScanningAlerts: String("ssa"), 9595 SecurityEvents: String("se"), 9596 SingleFile: String("sf"), 9597 Statuses: String("s"), 9598 TeamDiscussions: String("td"), 9599 VulnerabilityAlerts: String("va"), 9600 Workflows: String("w"), 9601 }, 9602 CreatedAt: &Timestamp{referenceTime}, 9603 UpdatedAt: &Timestamp{referenceTime}, 9604 HasMultipleSingleFiles: Bool(false), 9605 SuspendedBy: &User{ 9606 Login: String("l"), 9607 ID: Int64(1), 9608 URL: String("u"), 9609 AvatarURL: String("a"), 9610 GravatarID: String("g"), 9611 Name: String("n"), 9612 Company: String("c"), 9613 Blog: String("b"), 9614 Location: String("l"), 9615 Email: String("e"), 9616 Hireable: Bool(true), 9617 Bio: String("b"), 9618 TwitterUsername: String("t"), 9619 PublicRepos: Int(1), 9620 Followers: Int(1), 9621 Following: Int(1), 9622 CreatedAt: &Timestamp{referenceTime}, 9623 SuspendedAt: &Timestamp{referenceTime}, 9624 }, 9625 SuspendedAt: &Timestamp{referenceTime}, 9626 }, 9627 } 9628 9629 want := `{ 9630 "action": "a", 9631 "content_reference": { 9632 "id": 1, 9633 "node_id": "nid", 9634 "reference": "ref" 9635 }, 9636 "repository": { 9637 "id": 1, 9638 "name": "n", 9639 "url": "s" 9640 }, 9641 "sender": { 9642 "login": "l", 9643 "id": 1, 9644 "node_id": "n", 9645 "avatar_url": "a", 9646 "url": "u", 9647 "events_url": "e", 9648 "repos_url": "r" 9649 }, 9650 "installation": { 9651 "id": 1, 9652 "node_id": "nid", 9653 "app_id": 1, 9654 "app_slug": "as", 9655 "target_id": 1, 9656 "account": { 9657 "login": "l", 9658 "id": 1, 9659 "avatar_url": "a", 9660 "gravatar_id": "g", 9661 "name": "n", 9662 "company": "c", 9663 "blog": "b", 9664 "location": "l", 9665 "email": "e", 9666 "hireable": true, 9667 "bio": "b", 9668 "twitter_username": "t", 9669 "public_repos": 1, 9670 "followers": 1, 9671 "following": 1, 9672 "created_at": ` + referenceTimeStr + `, 9673 "suspended_at": ` + referenceTimeStr + `, 9674 "url": "u" 9675 }, 9676 "access_tokens_url": "atu", 9677 "repositories_url": "ru", 9678 "html_url": "hu", 9679 "target_type": "tt", 9680 "single_file_name": "sfn", 9681 "repository_selection": "rs", 9682 "events": [ 9683 "e" 9684 ], 9685 "single_file_paths": [ 9686 "s" 9687 ], 9688 "permissions": { 9689 "actions": "a", 9690 "administration": "ad", 9691 "checks": "c", 9692 "contents": "co", 9693 "content_references": "cr", 9694 "deployments": "d", 9695 "environments": "e", 9696 "issues": "i", 9697 "metadata": "md", 9698 "members": "m", 9699 "organization_administration": "oa", 9700 "organization_hooks": "oh", 9701 "organization_plan": "op", 9702 "organization_pre_receive_hooks": "opr", 9703 "organization_projects": "op", 9704 "organization_secrets": "os", 9705 "organization_self_hosted_runners": "osh", 9706 "organization_user_blocking": "oub", 9707 "packages": "pkg", 9708 "pages": "pg", 9709 "pull_requests": "pr", 9710 "repository_hooks": "rh", 9711 "repository_projects": "rp", 9712 "repository_pre_receive_hooks": "rprh", 9713 "secrets": "s", 9714 "secret_scanning_alerts": "ssa", 9715 "security_events": "se", 9716 "single_file": "sf", 9717 "statuses": "s", 9718 "team_discussions": "td", 9719 "vulnerability_alerts": "va", 9720 "workflows": "w" 9721 }, 9722 "created_at": ` + referenceTimeStr + `, 9723 "updated_at": ` + referenceTimeStr + `, 9724 "has_multiple_single_files": false, 9725 "suspended_by": { 9726 "login": "l", 9727 "id": 1, 9728 "avatar_url": "a", 9729 "gravatar_id": "g", 9730 "name": "n", 9731 "company": "c", 9732 "blog": "b", 9733 "location": "l", 9734 "email": "e", 9735 "hireable": true, 9736 "bio": "b", 9737 "twitter_username": "t", 9738 "public_repos": 1, 9739 "followers": 1, 9740 "following": 1, 9741 "created_at": ` + referenceTimeStr + `, 9742 "suspended_at": ` + referenceTimeStr + `, 9743 "url": "u" 9744 }, 9745 "suspended_at": ` + referenceTimeStr + ` 9746 } 9747 }` 9748 9749 testJSONMarshal(t, u, want) 9750 } 9751 9752 func TestMemberEvent_Marshal(t *testing.T) { 9753 t.Parallel() 9754 testJSONMarshal(t, &MemberEvent{}, "{}") 9755 9756 u := &MemberEvent{ 9757 Action: String("a"), 9758 Member: &User{ 9759 Login: String("l"), 9760 ID: Int64(1), 9761 NodeID: String("n"), 9762 URL: String("u"), 9763 ReposURL: String("r"), 9764 EventsURL: String("e"), 9765 AvatarURL: String("a"), 9766 }, 9767 Changes: &MemberChanges{ 9768 Permission: &MemberChangesPermission{ 9769 From: String("f"), 9770 To: String("t"), 9771 }, 9772 RoleName: &MemberChangesRoleName{ 9773 From: String("f"), 9774 To: String("t"), 9775 }, 9776 }, 9777 Repo: &Repository{ 9778 ID: Int64(1), 9779 URL: String("s"), 9780 Name: String("n"), 9781 }, 9782 Sender: &User{ 9783 Login: String("l"), 9784 ID: Int64(1), 9785 NodeID: String("n"), 9786 URL: String("u"), 9787 ReposURL: String("r"), 9788 EventsURL: String("e"), 9789 AvatarURL: String("a"), 9790 }, 9791 Installation: &Installation{ 9792 ID: Int64(1), 9793 NodeID: String("nid"), 9794 AppID: Int64(1), 9795 AppSlug: String("as"), 9796 TargetID: Int64(1), 9797 Account: &User{ 9798 Login: String("l"), 9799 ID: Int64(1), 9800 URL: String("u"), 9801 AvatarURL: String("a"), 9802 GravatarID: String("g"), 9803 Name: String("n"), 9804 Company: String("c"), 9805 Blog: String("b"), 9806 Location: String("l"), 9807 Email: String("e"), 9808 Hireable: Bool(true), 9809 Bio: String("b"), 9810 TwitterUsername: String("t"), 9811 PublicRepos: Int(1), 9812 Followers: Int(1), 9813 Following: Int(1), 9814 CreatedAt: &Timestamp{referenceTime}, 9815 SuspendedAt: &Timestamp{referenceTime}, 9816 }, 9817 AccessTokensURL: String("atu"), 9818 RepositoriesURL: String("ru"), 9819 HTMLURL: String("hu"), 9820 TargetType: String("tt"), 9821 SingleFileName: String("sfn"), 9822 RepositorySelection: String("rs"), 9823 Events: []string{"e"}, 9824 SingleFilePaths: []string{"s"}, 9825 Permissions: &InstallationPermissions{ 9826 Actions: String("a"), 9827 Administration: String("ad"), 9828 Checks: String("c"), 9829 Contents: String("co"), 9830 ContentReferences: String("cr"), 9831 Deployments: String("d"), 9832 Environments: String("e"), 9833 Issues: String("i"), 9834 Metadata: String("md"), 9835 Members: String("m"), 9836 OrganizationAdministration: String("oa"), 9837 OrganizationHooks: String("oh"), 9838 OrganizationPlan: String("op"), 9839 OrganizationPreReceiveHooks: String("opr"), 9840 OrganizationProjects: String("op"), 9841 OrganizationSecrets: String("os"), 9842 OrganizationSelfHostedRunners: String("osh"), 9843 OrganizationUserBlocking: String("oub"), 9844 Packages: String("pkg"), 9845 Pages: String("pg"), 9846 PullRequests: String("pr"), 9847 RepositoryHooks: String("rh"), 9848 RepositoryProjects: String("rp"), 9849 RepositoryPreReceiveHooks: String("rprh"), 9850 Secrets: String("s"), 9851 SecretScanningAlerts: String("ssa"), 9852 SecurityEvents: String("se"), 9853 SingleFile: String("sf"), 9854 Statuses: String("s"), 9855 TeamDiscussions: String("td"), 9856 VulnerabilityAlerts: String("va"), 9857 Workflows: String("w"), 9858 }, 9859 CreatedAt: &Timestamp{referenceTime}, 9860 UpdatedAt: &Timestamp{referenceTime}, 9861 HasMultipleSingleFiles: Bool(false), 9862 SuspendedBy: &User{ 9863 Login: String("l"), 9864 ID: Int64(1), 9865 URL: String("u"), 9866 AvatarURL: String("a"), 9867 GravatarID: String("g"), 9868 Name: String("n"), 9869 Company: String("c"), 9870 Blog: String("b"), 9871 Location: String("l"), 9872 Email: String("e"), 9873 Hireable: Bool(true), 9874 Bio: String("b"), 9875 TwitterUsername: String("t"), 9876 PublicRepos: Int(1), 9877 Followers: Int(1), 9878 Following: Int(1), 9879 CreatedAt: &Timestamp{referenceTime}, 9880 SuspendedAt: &Timestamp{referenceTime}, 9881 }, 9882 SuspendedAt: &Timestamp{referenceTime}, 9883 }, 9884 } 9885 9886 want := `{ 9887 "action": "a", 9888 "member": { 9889 "login": "l", 9890 "id": 1, 9891 "node_id": "n", 9892 "avatar_url": "a", 9893 "url": "u", 9894 "events_url": "e", 9895 "repos_url": "r" 9896 }, 9897 "changes": { 9898 "permission": { 9899 "from": "f", 9900 "to": "t" 9901 }, 9902 "role_name": { 9903 "from": "f", 9904 "to": "t" 9905 } 9906 }, 9907 "repository": { 9908 "id": 1, 9909 "name": "n", 9910 "url": "s" 9911 }, 9912 "sender": { 9913 "login": "l", 9914 "id": 1, 9915 "node_id": "n", 9916 "avatar_url": "a", 9917 "url": "u", 9918 "events_url": "e", 9919 "repos_url": "r" 9920 }, 9921 "installation": { 9922 "id": 1, 9923 "node_id": "nid", 9924 "app_id": 1, 9925 "app_slug": "as", 9926 "target_id": 1, 9927 "account": { 9928 "login": "l", 9929 "id": 1, 9930 "avatar_url": "a", 9931 "gravatar_id": "g", 9932 "name": "n", 9933 "company": "c", 9934 "blog": "b", 9935 "location": "l", 9936 "email": "e", 9937 "hireable": true, 9938 "bio": "b", 9939 "twitter_username": "t", 9940 "public_repos": 1, 9941 "followers": 1, 9942 "following": 1, 9943 "created_at": ` + referenceTimeStr + `, 9944 "suspended_at": ` + referenceTimeStr + `, 9945 "url": "u" 9946 }, 9947 "access_tokens_url": "atu", 9948 "repositories_url": "ru", 9949 "html_url": "hu", 9950 "target_type": "tt", 9951 "single_file_name": "sfn", 9952 "repository_selection": "rs", 9953 "events": [ 9954 "e" 9955 ], 9956 "single_file_paths": [ 9957 "s" 9958 ], 9959 "permissions": { 9960 "actions": "a", 9961 "administration": "ad", 9962 "checks": "c", 9963 "contents": "co", 9964 "content_references": "cr", 9965 "deployments": "d", 9966 "environments": "e", 9967 "issues": "i", 9968 "metadata": "md", 9969 "members": "m", 9970 "organization_administration": "oa", 9971 "organization_hooks": "oh", 9972 "organization_plan": "op", 9973 "organization_pre_receive_hooks": "opr", 9974 "organization_projects": "op", 9975 "organization_secrets": "os", 9976 "organization_self_hosted_runners": "osh", 9977 "organization_user_blocking": "oub", 9978 "packages": "pkg", 9979 "pages": "pg", 9980 "pull_requests": "pr", 9981 "repository_hooks": "rh", 9982 "repository_projects": "rp", 9983 "repository_pre_receive_hooks": "rprh", 9984 "secrets": "s", 9985 "secret_scanning_alerts": "ssa", 9986 "security_events": "se", 9987 "single_file": "sf", 9988 "statuses": "s", 9989 "team_discussions": "td", 9990 "vulnerability_alerts": "va", 9991 "workflows": "w" 9992 }, 9993 "created_at": ` + referenceTimeStr + `, 9994 "updated_at": ` + referenceTimeStr + `, 9995 "has_multiple_single_files": false, 9996 "suspended_by": { 9997 "login": "l", 9998 "id": 1, 9999 "avatar_url": "a", 10000 "gravatar_id": "g", 10001 "name": "n", 10002 "company": "c", 10003 "blog": "b", 10004 "location": "l", 10005 "email": "e", 10006 "hireable": true, 10007 "bio": "b", 10008 "twitter_username": "t", 10009 "public_repos": 1, 10010 "followers": 1, 10011 "following": 1, 10012 "created_at": ` + referenceTimeStr + `, 10013 "suspended_at": ` + referenceTimeStr + `, 10014 "url": "u" 10015 }, 10016 "suspended_at": ` + referenceTimeStr + ` 10017 } 10018 }` 10019 10020 testJSONMarshal(t, u, want) 10021 } 10022 10023 func TestMembershipEvent_Marshal(t *testing.T) { 10024 t.Parallel() 10025 testJSONMarshal(t, &MembershipEvent{}, "{}") 10026 10027 u := &MembershipEvent{ 10028 Action: String("a"), 10029 Scope: String("s"), 10030 Member: &User{ 10031 Login: String("l"), 10032 ID: Int64(1), 10033 NodeID: String("n"), 10034 URL: String("u"), 10035 ReposURL: String("r"), 10036 EventsURL: String("e"), 10037 AvatarURL: String("a"), 10038 }, 10039 Team: &Team{ 10040 ID: Int64(1), 10041 NodeID: String("n"), 10042 Name: String("n"), 10043 Description: String("d"), 10044 URL: String("u"), 10045 Slug: String("s"), 10046 Permission: String("p"), 10047 Privacy: String("p"), 10048 MembersCount: Int(1), 10049 ReposCount: Int(1), 10050 MembersURL: String("m"), 10051 RepositoriesURL: String("r"), 10052 Organization: &Organization{ 10053 Login: String("l"), 10054 ID: Int64(1), 10055 NodeID: String("n"), 10056 AvatarURL: String("a"), 10057 HTMLURL: String("h"), 10058 Name: String("n"), 10059 Company: String("c"), 10060 Blog: String("b"), 10061 Location: String("l"), 10062 Email: String("e"), 10063 }, 10064 Parent: &Team{ 10065 ID: Int64(1), 10066 NodeID: String("n"), 10067 Name: String("n"), 10068 Description: String("d"), 10069 URL: String("u"), 10070 Slug: String("s"), 10071 Permission: String("p"), 10072 Privacy: String("p"), 10073 MembersCount: Int(1), 10074 ReposCount: Int(1), 10075 }, 10076 LDAPDN: String("l"), 10077 }, 10078 Org: &Organization{ 10079 BillingEmail: String("be"), 10080 Blog: String("b"), 10081 Company: String("c"), 10082 Email: String("e"), 10083 TwitterUsername: String("tu"), 10084 Location: String("loc"), 10085 Name: String("n"), 10086 Description: String("d"), 10087 IsVerified: Bool(true), 10088 HasOrganizationProjects: Bool(true), 10089 HasRepositoryProjects: Bool(true), 10090 DefaultRepoPermission: String("drp"), 10091 MembersCanCreateRepos: Bool(true), 10092 MembersCanCreateInternalRepos: Bool(true), 10093 MembersCanCreatePrivateRepos: Bool(true), 10094 MembersCanCreatePublicRepos: Bool(false), 10095 MembersAllowedRepositoryCreationType: String("marct"), 10096 MembersCanCreatePages: Bool(true), 10097 MembersCanCreatePublicPages: Bool(false), 10098 MembersCanCreatePrivatePages: Bool(true), 10099 }, 10100 Sender: &User{ 10101 Login: String("l"), 10102 ID: Int64(1), 10103 NodeID: String("n"), 10104 URL: String("u"), 10105 ReposURL: String("r"), 10106 EventsURL: String("e"), 10107 AvatarURL: String("a"), 10108 }, 10109 Installation: &Installation{ 10110 ID: Int64(1), 10111 NodeID: String("nid"), 10112 AppID: Int64(1), 10113 AppSlug: String("as"), 10114 TargetID: Int64(1), 10115 Account: &User{ 10116 Login: String("l"), 10117 ID: Int64(1), 10118 URL: String("u"), 10119 AvatarURL: String("a"), 10120 GravatarID: String("g"), 10121 Name: String("n"), 10122 Company: String("c"), 10123 Blog: String("b"), 10124 Location: String("l"), 10125 Email: String("e"), 10126 Hireable: Bool(true), 10127 Bio: String("b"), 10128 TwitterUsername: String("t"), 10129 PublicRepos: Int(1), 10130 Followers: Int(1), 10131 Following: Int(1), 10132 CreatedAt: &Timestamp{referenceTime}, 10133 SuspendedAt: &Timestamp{referenceTime}, 10134 }, 10135 AccessTokensURL: String("atu"), 10136 RepositoriesURL: String("ru"), 10137 HTMLURL: String("hu"), 10138 TargetType: String("tt"), 10139 SingleFileName: String("sfn"), 10140 RepositorySelection: String("rs"), 10141 Events: []string{"e"}, 10142 SingleFilePaths: []string{"s"}, 10143 Permissions: &InstallationPermissions{ 10144 Actions: String("a"), 10145 Administration: String("ad"), 10146 Checks: String("c"), 10147 Contents: String("co"), 10148 ContentReferences: String("cr"), 10149 Deployments: String("d"), 10150 Environments: String("e"), 10151 Issues: String("i"), 10152 Metadata: String("md"), 10153 Members: String("m"), 10154 OrganizationAdministration: String("oa"), 10155 OrganizationHooks: String("oh"), 10156 OrganizationPlan: String("op"), 10157 OrganizationPreReceiveHooks: String("opr"), 10158 OrganizationProjects: String("op"), 10159 OrganizationSecrets: String("os"), 10160 OrganizationSelfHostedRunners: String("osh"), 10161 OrganizationUserBlocking: String("oub"), 10162 Packages: String("pkg"), 10163 Pages: String("pg"), 10164 PullRequests: String("pr"), 10165 RepositoryHooks: String("rh"), 10166 RepositoryProjects: String("rp"), 10167 RepositoryPreReceiveHooks: String("rprh"), 10168 Secrets: String("s"), 10169 SecretScanningAlerts: String("ssa"), 10170 SecurityEvents: String("se"), 10171 SingleFile: String("sf"), 10172 Statuses: String("s"), 10173 TeamDiscussions: String("td"), 10174 VulnerabilityAlerts: String("va"), 10175 Workflows: String("w"), 10176 }, 10177 CreatedAt: &Timestamp{referenceTime}, 10178 UpdatedAt: &Timestamp{referenceTime}, 10179 HasMultipleSingleFiles: Bool(false), 10180 SuspendedBy: &User{ 10181 Login: String("l"), 10182 ID: Int64(1), 10183 URL: String("u"), 10184 AvatarURL: String("a"), 10185 GravatarID: String("g"), 10186 Name: String("n"), 10187 Company: String("c"), 10188 Blog: String("b"), 10189 Location: String("l"), 10190 Email: String("e"), 10191 Hireable: Bool(true), 10192 Bio: String("b"), 10193 TwitterUsername: String("t"), 10194 PublicRepos: Int(1), 10195 Followers: Int(1), 10196 Following: Int(1), 10197 CreatedAt: &Timestamp{referenceTime}, 10198 SuspendedAt: &Timestamp{referenceTime}, 10199 }, 10200 SuspendedAt: &Timestamp{referenceTime}, 10201 }, 10202 } 10203 10204 want := `{ 10205 "action": "a", 10206 "scope": "s", 10207 "member": { 10208 "login": "l", 10209 "id": 1, 10210 "node_id": "n", 10211 "avatar_url": "a", 10212 "url": "u", 10213 "events_url": "e", 10214 "repos_url": "r" 10215 }, 10216 "team": { 10217 "id": 1, 10218 "node_id": "n", 10219 "name": "n", 10220 "description": "d", 10221 "url": "u", 10222 "slug": "s", 10223 "permission": "p", 10224 "privacy": "p", 10225 "members_count": 1, 10226 "repos_count": 1, 10227 "organization": { 10228 "login": "l", 10229 "id": 1, 10230 "node_id": "n", 10231 "avatar_url": "a", 10232 "html_url": "h", 10233 "name": "n", 10234 "company": "c", 10235 "blog": "b", 10236 "location": "l", 10237 "email": "e" 10238 }, 10239 "members_url": "m", 10240 "repositories_url": "r", 10241 "parent": { 10242 "id": 1, 10243 "node_id": "n", 10244 "name": "n", 10245 "description": "d", 10246 "url": "u", 10247 "slug": "s", 10248 "permission": "p", 10249 "privacy": "p", 10250 "members_count": 1, 10251 "repos_count": 1 10252 }, 10253 "ldap_dn": "l" 10254 }, 10255 "organization": { 10256 "name": "n", 10257 "company": "c", 10258 "blog": "b", 10259 "location": "loc", 10260 "email": "e", 10261 "twitter_username": "tu", 10262 "description": "d", 10263 "billing_email": "be", 10264 "is_verified": true, 10265 "has_organization_projects": true, 10266 "has_repository_projects": true, 10267 "default_repository_permission": "drp", 10268 "members_can_create_repositories": true, 10269 "members_can_create_public_repositories": false, 10270 "members_can_create_private_repositories": true, 10271 "members_can_create_internal_repositories": true, 10272 "members_allowed_repository_creation_type": "marct", 10273 "members_can_create_pages": true, 10274 "members_can_create_public_pages": false, 10275 "members_can_create_private_pages": true 10276 }, 10277 "sender": { 10278 "login": "l", 10279 "id": 1, 10280 "node_id": "n", 10281 "avatar_url": "a", 10282 "url": "u", 10283 "events_url": "e", 10284 "repos_url": "r" 10285 }, 10286 "installation": { 10287 "id": 1, 10288 "node_id": "nid", 10289 "app_id": 1, 10290 "app_slug": "as", 10291 "target_id": 1, 10292 "account": { 10293 "login": "l", 10294 "id": 1, 10295 "avatar_url": "a", 10296 "gravatar_id": "g", 10297 "name": "n", 10298 "company": "c", 10299 "blog": "b", 10300 "location": "l", 10301 "email": "e", 10302 "hireable": true, 10303 "bio": "b", 10304 "twitter_username": "t", 10305 "public_repos": 1, 10306 "followers": 1, 10307 "following": 1, 10308 "created_at": ` + referenceTimeStr + `, 10309 "suspended_at": ` + referenceTimeStr + `, 10310 "url": "u" 10311 }, 10312 "access_tokens_url": "atu", 10313 "repositories_url": "ru", 10314 "html_url": "hu", 10315 "target_type": "tt", 10316 "single_file_name": "sfn", 10317 "repository_selection": "rs", 10318 "events": [ 10319 "e" 10320 ], 10321 "single_file_paths": [ 10322 "s" 10323 ], 10324 "permissions": { 10325 "actions": "a", 10326 "administration": "ad", 10327 "checks": "c", 10328 "contents": "co", 10329 "content_references": "cr", 10330 "deployments": "d", 10331 "environments": "e", 10332 "issues": "i", 10333 "metadata": "md", 10334 "members": "m", 10335 "organization_administration": "oa", 10336 "organization_hooks": "oh", 10337 "organization_plan": "op", 10338 "organization_pre_receive_hooks": "opr", 10339 "organization_projects": "op", 10340 "organization_secrets": "os", 10341 "organization_self_hosted_runners": "osh", 10342 "organization_user_blocking": "oub", 10343 "packages": "pkg", 10344 "pages": "pg", 10345 "pull_requests": "pr", 10346 "repository_hooks": "rh", 10347 "repository_projects": "rp", 10348 "repository_pre_receive_hooks": "rprh", 10349 "secrets": "s", 10350 "secret_scanning_alerts": "ssa", 10351 "security_events": "se", 10352 "single_file": "sf", 10353 "statuses": "s", 10354 "team_discussions": "td", 10355 "vulnerability_alerts": "va", 10356 "workflows": "w" 10357 }, 10358 "created_at": ` + referenceTimeStr + `, 10359 "updated_at": ` + referenceTimeStr + `, 10360 "has_multiple_single_files": false, 10361 "suspended_by": { 10362 "login": "l", 10363 "id": 1, 10364 "avatar_url": "a", 10365 "gravatar_id": "g", 10366 "name": "n", 10367 "company": "c", 10368 "blog": "b", 10369 "location": "l", 10370 "email": "e", 10371 "hireable": true, 10372 "bio": "b", 10373 "twitter_username": "t", 10374 "public_repos": 1, 10375 "followers": 1, 10376 "following": 1, 10377 "created_at": ` + referenceTimeStr + `, 10378 "suspended_at": ` + referenceTimeStr + `, 10379 "url": "u" 10380 }, 10381 "suspended_at": ` + referenceTimeStr + ` 10382 } 10383 }` 10384 10385 testJSONMarshal(t, u, want) 10386 } 10387 10388 func TestMergeGroupEvent_Marshal(t *testing.T) { 10389 t.Parallel() 10390 testJSONMarshal(t, &MergeGroupEvent{}, "{}") 10391 10392 u := &MergeGroupEvent{ 10393 Action: String("a"), 10394 MergeGroup: &MergeGroup{ 10395 HeadSHA: String("hs"), 10396 HeadRef: String("hr"), 10397 BaseSHA: String("bs"), 10398 BaseRef: String("br"), 10399 HeadCommit: &Commit{NodeID: String("nid")}, 10400 }, 10401 Repo: &Repository{ 10402 ID: Int64(1), 10403 URL: String("s"), 10404 Name: String("n"), 10405 }, 10406 Org: &Organization{ 10407 BillingEmail: String("be"), 10408 Blog: String("b"), 10409 Company: String("c"), 10410 Email: String("e"), 10411 TwitterUsername: String("tu"), 10412 Location: String("loc"), 10413 Name: String("n"), 10414 Description: String("d"), 10415 IsVerified: Bool(true), 10416 HasOrganizationProjects: Bool(true), 10417 HasRepositoryProjects: Bool(true), 10418 DefaultRepoPermission: String("drp"), 10419 MembersCanCreateRepos: Bool(true), 10420 MembersCanCreateInternalRepos: Bool(true), 10421 MembersCanCreatePrivateRepos: Bool(true), 10422 MembersCanCreatePublicRepos: Bool(false), 10423 MembersAllowedRepositoryCreationType: String("marct"), 10424 MembersCanCreatePages: Bool(true), 10425 MembersCanCreatePublicPages: Bool(false), 10426 MembersCanCreatePrivatePages: Bool(true), 10427 }, 10428 Sender: &User{ 10429 Login: String("l"), 10430 ID: Int64(1), 10431 NodeID: String("n"), 10432 URL: String("u"), 10433 ReposURL: String("r"), 10434 EventsURL: String("e"), 10435 AvatarURL: String("a"), 10436 }, 10437 Installation: &Installation{ 10438 ID: Int64(1), 10439 NodeID: String("nid"), 10440 AppID: Int64(1), 10441 AppSlug: String("as"), 10442 TargetID: Int64(1), 10443 Account: &User{ 10444 Login: String("l"), 10445 ID: Int64(1), 10446 URL: String("u"), 10447 AvatarURL: String("a"), 10448 GravatarID: String("g"), 10449 Name: String("n"), 10450 Company: String("c"), 10451 Blog: String("b"), 10452 Location: String("l"), 10453 Email: String("e"), 10454 Hireable: Bool(true), 10455 Bio: String("b"), 10456 TwitterUsername: String("t"), 10457 PublicRepos: Int(1), 10458 Followers: Int(1), 10459 Following: Int(1), 10460 CreatedAt: &Timestamp{referenceTime}, 10461 SuspendedAt: &Timestamp{referenceTime}, 10462 }, 10463 AccessTokensURL: String("atu"), 10464 RepositoriesURL: String("ru"), 10465 HTMLURL: String("hu"), 10466 TargetType: String("tt"), 10467 SingleFileName: String("sfn"), 10468 RepositorySelection: String("rs"), 10469 Events: []string{"e"}, 10470 SingleFilePaths: []string{"s"}, 10471 Permissions: &InstallationPermissions{ 10472 Actions: String("a"), 10473 Administration: String("ad"), 10474 Checks: String("c"), 10475 Contents: String("co"), 10476 ContentReferences: String("cr"), 10477 Deployments: String("d"), 10478 Environments: String("e"), 10479 Issues: String("i"), 10480 Metadata: String("md"), 10481 Members: String("m"), 10482 OrganizationAdministration: String("oa"), 10483 OrganizationHooks: String("oh"), 10484 OrganizationPlan: String("op"), 10485 OrganizationPreReceiveHooks: String("opr"), 10486 OrganizationProjects: String("op"), 10487 OrganizationSecrets: String("os"), 10488 OrganizationSelfHostedRunners: String("osh"), 10489 OrganizationUserBlocking: String("oub"), 10490 Packages: String("pkg"), 10491 Pages: String("pg"), 10492 PullRequests: String("pr"), 10493 RepositoryHooks: String("rh"), 10494 RepositoryProjects: String("rp"), 10495 RepositoryPreReceiveHooks: String("rprh"), 10496 Secrets: String("s"), 10497 SecretScanningAlerts: String("ssa"), 10498 SecurityEvents: String("se"), 10499 SingleFile: String("sf"), 10500 Statuses: String("s"), 10501 TeamDiscussions: String("td"), 10502 VulnerabilityAlerts: String("va"), 10503 Workflows: String("w"), 10504 }, 10505 CreatedAt: &Timestamp{referenceTime}, 10506 UpdatedAt: &Timestamp{referenceTime}, 10507 HasMultipleSingleFiles: Bool(false), 10508 SuspendedBy: &User{ 10509 Login: String("l"), 10510 ID: Int64(1), 10511 URL: String("u"), 10512 AvatarURL: String("a"), 10513 GravatarID: String("g"), 10514 Name: String("n"), 10515 Company: String("c"), 10516 Blog: String("b"), 10517 Location: String("l"), 10518 Email: String("e"), 10519 Hireable: Bool(true), 10520 Bio: String("b"), 10521 TwitterUsername: String("t"), 10522 PublicRepos: Int(1), 10523 Followers: Int(1), 10524 Following: Int(1), 10525 CreatedAt: &Timestamp{referenceTime}, 10526 SuspendedAt: &Timestamp{referenceTime}, 10527 }, 10528 SuspendedAt: &Timestamp{referenceTime}, 10529 }, 10530 } 10531 10532 want := `{ 10533 "action": "a", 10534 "merge_group": { 10535 "head_sha": "hs", 10536 "head_ref": "hr", 10537 "base_sha": "bs", 10538 "base_ref": "br", 10539 "head_commit": { 10540 "node_id": "nid" 10541 } 10542 }, 10543 "repository": { 10544 "id": 1, 10545 "name": "n", 10546 "url": "s" 10547 }, 10548 "organization": { 10549 "name": "n", 10550 "company": "c", 10551 "blog": "b", 10552 "location": "loc", 10553 "email": "e", 10554 "twitter_username": "tu", 10555 "description": "d", 10556 "billing_email": "be", 10557 "is_verified": true, 10558 "has_organization_projects": true, 10559 "has_repository_projects": true, 10560 "default_repository_permission": "drp", 10561 "members_can_create_repositories": true, 10562 "members_can_create_public_repositories": false, 10563 "members_can_create_private_repositories": true, 10564 "members_can_create_internal_repositories": true, 10565 "members_allowed_repository_creation_type": "marct", 10566 "members_can_create_pages": true, 10567 "members_can_create_public_pages": false, 10568 "members_can_create_private_pages": true 10569 }, 10570 "sender": { 10571 "login": "l", 10572 "id": 1, 10573 "node_id": "n", 10574 "avatar_url": "a", 10575 "url": "u", 10576 "events_url": "e", 10577 "repos_url": "r" 10578 }, 10579 "installation": { 10580 "id": 1, 10581 "node_id": "nid", 10582 "app_id": 1, 10583 "app_slug": "as", 10584 "target_id": 1, 10585 "account": { 10586 "login": "l", 10587 "id": 1, 10588 "avatar_url": "a", 10589 "gravatar_id": "g", 10590 "name": "n", 10591 "company": "c", 10592 "blog": "b", 10593 "location": "l", 10594 "email": "e", 10595 "hireable": true, 10596 "bio": "b", 10597 "twitter_username": "t", 10598 "public_repos": 1, 10599 "followers": 1, 10600 "following": 1, 10601 "created_at": ` + referenceTimeStr + `, 10602 "suspended_at": ` + referenceTimeStr + `, 10603 "url": "u" 10604 }, 10605 "access_tokens_url": "atu", 10606 "repositories_url": "ru", 10607 "html_url": "hu", 10608 "target_type": "tt", 10609 "single_file_name": "sfn", 10610 "repository_selection": "rs", 10611 "events": [ 10612 "e" 10613 ], 10614 "single_file_paths": [ 10615 "s" 10616 ], 10617 "permissions": { 10618 "actions": "a", 10619 "administration": "ad", 10620 "checks": "c", 10621 "contents": "co", 10622 "content_references": "cr", 10623 "deployments": "d", 10624 "environments": "e", 10625 "issues": "i", 10626 "metadata": "md", 10627 "members": "m", 10628 "organization_administration": "oa", 10629 "organization_hooks": "oh", 10630 "organization_plan": "op", 10631 "organization_pre_receive_hooks": "opr", 10632 "organization_projects": "op", 10633 "organization_secrets": "os", 10634 "organization_self_hosted_runners": "osh", 10635 "organization_user_blocking": "oub", 10636 "packages": "pkg", 10637 "pages": "pg", 10638 "pull_requests": "pr", 10639 "repository_hooks": "rh", 10640 "repository_projects": "rp", 10641 "repository_pre_receive_hooks": "rprh", 10642 "secrets": "s", 10643 "secret_scanning_alerts": "ssa", 10644 "security_events": "se", 10645 "single_file": "sf", 10646 "statuses": "s", 10647 "team_discussions": "td", 10648 "vulnerability_alerts": "va", 10649 "workflows": "w" 10650 }, 10651 "created_at": ` + referenceTimeStr + `, 10652 "updated_at": ` + referenceTimeStr + `, 10653 "has_multiple_single_files": false, 10654 "suspended_by": { 10655 "login": "l", 10656 "id": 1, 10657 "avatar_url": "a", 10658 "gravatar_id": "g", 10659 "name": "n", 10660 "company": "c", 10661 "blog": "b", 10662 "location": "l", 10663 "email": "e", 10664 "hireable": true, 10665 "bio": "b", 10666 "twitter_username": "t", 10667 "public_repos": 1, 10668 "followers": 1, 10669 "following": 1, 10670 "created_at": ` + referenceTimeStr + `, 10671 "suspended_at": ` + referenceTimeStr + `, 10672 "url": "u" 10673 }, 10674 "suspended_at": ` + referenceTimeStr + ` 10675 } 10676 }` 10677 10678 testJSONMarshal(t, u, want) 10679 } 10680 10681 func TestOrgBlockEvent_Marshal(t *testing.T) { 10682 t.Parallel() 10683 testJSONMarshal(t, &OrgBlockEvent{}, "{}") 10684 10685 u := &OrgBlockEvent{ 10686 Action: String("a"), 10687 BlockedUser: &User{ 10688 Login: String("l"), 10689 ID: Int64(1), 10690 NodeID: String("n"), 10691 URL: String("u"), 10692 ReposURL: String("r"), 10693 EventsURL: String("e"), 10694 AvatarURL: String("a"), 10695 }, 10696 Organization: &Organization{ 10697 BillingEmail: String("be"), 10698 Blog: String("b"), 10699 Company: String("c"), 10700 Email: String("e"), 10701 TwitterUsername: String("tu"), 10702 Location: String("loc"), 10703 Name: String("n"), 10704 Description: String("d"), 10705 IsVerified: Bool(true), 10706 HasOrganizationProjects: Bool(true), 10707 HasRepositoryProjects: Bool(true), 10708 DefaultRepoPermission: String("drp"), 10709 MembersCanCreateRepos: Bool(true), 10710 MembersCanCreateInternalRepos: Bool(true), 10711 MembersCanCreatePrivateRepos: Bool(true), 10712 MembersCanCreatePublicRepos: Bool(false), 10713 MembersAllowedRepositoryCreationType: String("marct"), 10714 MembersCanCreatePages: Bool(true), 10715 MembersCanCreatePublicPages: Bool(false), 10716 MembersCanCreatePrivatePages: Bool(true), 10717 }, 10718 Sender: &User{ 10719 Login: String("l"), 10720 ID: Int64(1), 10721 NodeID: String("n"), 10722 URL: String("u"), 10723 ReposURL: String("r"), 10724 EventsURL: String("e"), 10725 AvatarURL: String("a"), 10726 }, 10727 Installation: &Installation{ 10728 ID: Int64(1), 10729 NodeID: String("nid"), 10730 AppID: Int64(1), 10731 AppSlug: String("as"), 10732 TargetID: Int64(1), 10733 Account: &User{ 10734 Login: String("l"), 10735 ID: Int64(1), 10736 URL: String("u"), 10737 AvatarURL: String("a"), 10738 GravatarID: String("g"), 10739 Name: String("n"), 10740 Company: String("c"), 10741 Blog: String("b"), 10742 Location: String("l"), 10743 Email: String("e"), 10744 Hireable: Bool(true), 10745 Bio: String("b"), 10746 TwitterUsername: String("t"), 10747 PublicRepos: Int(1), 10748 Followers: Int(1), 10749 Following: Int(1), 10750 CreatedAt: &Timestamp{referenceTime}, 10751 SuspendedAt: &Timestamp{referenceTime}, 10752 }, 10753 AccessTokensURL: String("atu"), 10754 RepositoriesURL: String("ru"), 10755 HTMLURL: String("hu"), 10756 TargetType: String("tt"), 10757 SingleFileName: String("sfn"), 10758 RepositorySelection: String("rs"), 10759 Events: []string{"e"}, 10760 SingleFilePaths: []string{"s"}, 10761 Permissions: &InstallationPermissions{ 10762 Actions: String("a"), 10763 Administration: String("ad"), 10764 Checks: String("c"), 10765 Contents: String("co"), 10766 ContentReferences: String("cr"), 10767 Deployments: String("d"), 10768 Environments: String("e"), 10769 Issues: String("i"), 10770 Metadata: String("md"), 10771 Members: String("m"), 10772 OrganizationAdministration: String("oa"), 10773 OrganizationHooks: String("oh"), 10774 OrganizationPlan: String("op"), 10775 OrganizationPreReceiveHooks: String("opr"), 10776 OrganizationProjects: String("op"), 10777 OrganizationSecrets: String("os"), 10778 OrganizationSelfHostedRunners: String("osh"), 10779 OrganizationUserBlocking: String("oub"), 10780 Packages: String("pkg"), 10781 Pages: String("pg"), 10782 PullRequests: String("pr"), 10783 RepositoryHooks: String("rh"), 10784 RepositoryProjects: String("rp"), 10785 RepositoryPreReceiveHooks: String("rprh"), 10786 Secrets: String("s"), 10787 SecretScanningAlerts: String("ssa"), 10788 SecurityEvents: String("se"), 10789 SingleFile: String("sf"), 10790 Statuses: String("s"), 10791 TeamDiscussions: String("td"), 10792 VulnerabilityAlerts: String("va"), 10793 Workflows: String("w"), 10794 }, 10795 CreatedAt: &Timestamp{referenceTime}, 10796 UpdatedAt: &Timestamp{referenceTime}, 10797 HasMultipleSingleFiles: Bool(false), 10798 SuspendedBy: &User{ 10799 Login: String("l"), 10800 ID: Int64(1), 10801 URL: String("u"), 10802 AvatarURL: String("a"), 10803 GravatarID: String("g"), 10804 Name: String("n"), 10805 Company: String("c"), 10806 Blog: String("b"), 10807 Location: String("l"), 10808 Email: String("e"), 10809 Hireable: Bool(true), 10810 Bio: String("b"), 10811 TwitterUsername: String("t"), 10812 PublicRepos: Int(1), 10813 Followers: Int(1), 10814 Following: Int(1), 10815 CreatedAt: &Timestamp{referenceTime}, 10816 SuspendedAt: &Timestamp{referenceTime}, 10817 }, 10818 SuspendedAt: &Timestamp{referenceTime}, 10819 }, 10820 } 10821 10822 want := `{ 10823 "action": "a", 10824 "blocked_user": { 10825 "login": "l", 10826 "id": 1, 10827 "node_id": "n", 10828 "avatar_url": "a", 10829 "url": "u", 10830 "events_url": "e", 10831 "repos_url": "r" 10832 }, 10833 "organization": { 10834 "name": "n", 10835 "company": "c", 10836 "blog": "b", 10837 "location": "loc", 10838 "email": "e", 10839 "twitter_username": "tu", 10840 "description": "d", 10841 "billing_email": "be", 10842 "is_verified": true, 10843 "has_organization_projects": true, 10844 "has_repository_projects": true, 10845 "default_repository_permission": "drp", 10846 "members_can_create_repositories": true, 10847 "members_can_create_public_repositories": false, 10848 "members_can_create_private_repositories": true, 10849 "members_can_create_internal_repositories": true, 10850 "members_allowed_repository_creation_type": "marct", 10851 "members_can_create_pages": true, 10852 "members_can_create_public_pages": false, 10853 "members_can_create_private_pages": true 10854 }, 10855 "sender": { 10856 "login": "l", 10857 "id": 1, 10858 "node_id": "n", 10859 "avatar_url": "a", 10860 "url": "u", 10861 "events_url": "e", 10862 "repos_url": "r" 10863 }, 10864 "installation": { 10865 "id": 1, 10866 "node_id": "nid", 10867 "app_id": 1, 10868 "app_slug": "as", 10869 "target_id": 1, 10870 "account": { 10871 "login": "l", 10872 "id": 1, 10873 "avatar_url": "a", 10874 "gravatar_id": "g", 10875 "name": "n", 10876 "company": "c", 10877 "blog": "b", 10878 "location": "l", 10879 "email": "e", 10880 "hireable": true, 10881 "bio": "b", 10882 "twitter_username": "t", 10883 "public_repos": 1, 10884 "followers": 1, 10885 "following": 1, 10886 "created_at": ` + referenceTimeStr + `, 10887 "suspended_at": ` + referenceTimeStr + `, 10888 "url": "u" 10889 }, 10890 "access_tokens_url": "atu", 10891 "repositories_url": "ru", 10892 "html_url": "hu", 10893 "target_type": "tt", 10894 "single_file_name": "sfn", 10895 "repository_selection": "rs", 10896 "events": [ 10897 "e" 10898 ], 10899 "single_file_paths": [ 10900 "s" 10901 ], 10902 "permissions": { 10903 "actions": "a", 10904 "administration": "ad", 10905 "checks": "c", 10906 "contents": "co", 10907 "content_references": "cr", 10908 "deployments": "d", 10909 "environments": "e", 10910 "issues": "i", 10911 "metadata": "md", 10912 "members": "m", 10913 "organization_administration": "oa", 10914 "organization_hooks": "oh", 10915 "organization_plan": "op", 10916 "organization_pre_receive_hooks": "opr", 10917 "organization_projects": "op", 10918 "organization_secrets": "os", 10919 "organization_self_hosted_runners": "osh", 10920 "organization_user_blocking": "oub", 10921 "packages": "pkg", 10922 "pages": "pg", 10923 "pull_requests": "pr", 10924 "repository_hooks": "rh", 10925 "repository_projects": "rp", 10926 "repository_pre_receive_hooks": "rprh", 10927 "secrets": "s", 10928 "secret_scanning_alerts": "ssa", 10929 "security_events": "se", 10930 "single_file": "sf", 10931 "statuses": "s", 10932 "team_discussions": "td", 10933 "vulnerability_alerts": "va", 10934 "workflows": "w" 10935 }, 10936 "created_at": ` + referenceTimeStr + `, 10937 "updated_at": ` + referenceTimeStr + `, 10938 "has_multiple_single_files": false, 10939 "suspended_by": { 10940 "login": "l", 10941 "id": 1, 10942 "avatar_url": "a", 10943 "gravatar_id": "g", 10944 "name": "n", 10945 "company": "c", 10946 "blog": "b", 10947 "location": "l", 10948 "email": "e", 10949 "hireable": true, 10950 "bio": "b", 10951 "twitter_username": "t", 10952 "public_repos": 1, 10953 "followers": 1, 10954 "following": 1, 10955 "created_at": ` + referenceTimeStr + `, 10956 "suspended_at": ` + referenceTimeStr + `, 10957 "url": "u" 10958 }, 10959 "suspended_at": ` + referenceTimeStr + ` 10960 } 10961 }` 10962 10963 testJSONMarshal(t, u, want) 10964 } 10965 10966 func TestGollumEvent_Marshal(t *testing.T) { 10967 t.Parallel() 10968 testJSONMarshal(t, &GollumEvent{}, "{}") 10969 10970 u := &GollumEvent{ 10971 Pages: []*Page{ 10972 { 10973 PageName: String("pn"), 10974 Title: String("t"), 10975 Summary: String("s"), 10976 Action: String("a"), 10977 SHA: String("sha"), 10978 HTMLURL: String("hu"), 10979 }, 10980 }, 10981 Repo: &Repository{ 10982 ID: Int64(1), 10983 URL: String("s"), 10984 Name: String("n"), 10985 }, 10986 Sender: &User{ 10987 Login: String("l"), 10988 ID: Int64(1), 10989 NodeID: String("n"), 10990 URL: String("u"), 10991 ReposURL: String("r"), 10992 EventsURL: String("e"), 10993 AvatarURL: String("a"), 10994 }, 10995 Installation: &Installation{ 10996 ID: Int64(1), 10997 NodeID: String("nid"), 10998 AppID: Int64(1), 10999 AppSlug: String("as"), 11000 TargetID: Int64(1), 11001 Account: &User{ 11002 Login: String("l"), 11003 ID: Int64(1), 11004 URL: String("u"), 11005 AvatarURL: String("a"), 11006 GravatarID: String("g"), 11007 Name: String("n"), 11008 Company: String("c"), 11009 Blog: String("b"), 11010 Location: String("l"), 11011 Email: String("e"), 11012 Hireable: Bool(true), 11013 Bio: String("b"), 11014 TwitterUsername: String("t"), 11015 PublicRepos: Int(1), 11016 Followers: Int(1), 11017 Following: Int(1), 11018 CreatedAt: &Timestamp{referenceTime}, 11019 SuspendedAt: &Timestamp{referenceTime}, 11020 }, 11021 AccessTokensURL: String("atu"), 11022 RepositoriesURL: String("ru"), 11023 HTMLURL: String("hu"), 11024 TargetType: String("tt"), 11025 SingleFileName: String("sfn"), 11026 RepositorySelection: String("rs"), 11027 Events: []string{"e"}, 11028 SingleFilePaths: []string{"s"}, 11029 Permissions: &InstallationPermissions{ 11030 Actions: String("a"), 11031 Administration: String("ad"), 11032 Checks: String("c"), 11033 Contents: String("co"), 11034 ContentReferences: String("cr"), 11035 Deployments: String("d"), 11036 Environments: String("e"), 11037 Issues: String("i"), 11038 Metadata: String("md"), 11039 Members: String("m"), 11040 OrganizationAdministration: String("oa"), 11041 OrganizationHooks: String("oh"), 11042 OrganizationPlan: String("op"), 11043 OrganizationPreReceiveHooks: String("opr"), 11044 OrganizationProjects: String("op"), 11045 OrganizationSecrets: String("os"), 11046 OrganizationSelfHostedRunners: String("osh"), 11047 OrganizationUserBlocking: String("oub"), 11048 Packages: String("pkg"), 11049 Pages: String("pg"), 11050 PullRequests: String("pr"), 11051 RepositoryHooks: String("rh"), 11052 RepositoryProjects: String("rp"), 11053 RepositoryPreReceiveHooks: String("rprh"), 11054 Secrets: String("s"), 11055 SecretScanningAlerts: String("ssa"), 11056 SecurityEvents: String("se"), 11057 SingleFile: String("sf"), 11058 Statuses: String("s"), 11059 TeamDiscussions: String("td"), 11060 VulnerabilityAlerts: String("va"), 11061 Workflows: String("w"), 11062 }, 11063 CreatedAt: &Timestamp{referenceTime}, 11064 UpdatedAt: &Timestamp{referenceTime}, 11065 HasMultipleSingleFiles: Bool(false), 11066 SuspendedBy: &User{ 11067 Login: String("l"), 11068 ID: Int64(1), 11069 URL: String("u"), 11070 AvatarURL: String("a"), 11071 GravatarID: String("g"), 11072 Name: String("n"), 11073 Company: String("c"), 11074 Blog: String("b"), 11075 Location: String("l"), 11076 Email: String("e"), 11077 Hireable: Bool(true), 11078 Bio: String("b"), 11079 TwitterUsername: String("t"), 11080 PublicRepos: Int(1), 11081 Followers: Int(1), 11082 Following: Int(1), 11083 CreatedAt: &Timestamp{referenceTime}, 11084 SuspendedAt: &Timestamp{referenceTime}, 11085 }, 11086 SuspendedAt: &Timestamp{referenceTime}, 11087 }, 11088 } 11089 11090 want := `{ 11091 "pages": [ 11092 { 11093 "page_name": "pn", 11094 "title": "t", 11095 "summary": "s", 11096 "action": "a", 11097 "sha": "sha", 11098 "html_url": "hu" 11099 } 11100 ], 11101 "repository": { 11102 "id": 1, 11103 "name": "n", 11104 "url": "s" 11105 }, 11106 "sender": { 11107 "login": "l", 11108 "id": 1, 11109 "node_id": "n", 11110 "avatar_url": "a", 11111 "url": "u", 11112 "events_url": "e", 11113 "repos_url": "r" 11114 }, 11115 "installation": { 11116 "id": 1, 11117 "node_id": "nid", 11118 "app_id": 1, 11119 "app_slug": "as", 11120 "target_id": 1, 11121 "account": { 11122 "login": "l", 11123 "id": 1, 11124 "avatar_url": "a", 11125 "gravatar_id": "g", 11126 "name": "n", 11127 "company": "c", 11128 "blog": "b", 11129 "location": "l", 11130 "email": "e", 11131 "hireable": true, 11132 "bio": "b", 11133 "twitter_username": "t", 11134 "public_repos": 1, 11135 "followers": 1, 11136 "following": 1, 11137 "created_at": ` + referenceTimeStr + `, 11138 "suspended_at": ` + referenceTimeStr + `, 11139 "url": "u" 11140 }, 11141 "access_tokens_url": "atu", 11142 "repositories_url": "ru", 11143 "html_url": "hu", 11144 "target_type": "tt", 11145 "single_file_name": "sfn", 11146 "repository_selection": "rs", 11147 "events": [ 11148 "e" 11149 ], 11150 "single_file_paths": [ 11151 "s" 11152 ], 11153 "permissions": { 11154 "actions": "a", 11155 "administration": "ad", 11156 "checks": "c", 11157 "contents": "co", 11158 "content_references": "cr", 11159 "deployments": "d", 11160 "environments": "e", 11161 "issues": "i", 11162 "metadata": "md", 11163 "members": "m", 11164 "organization_administration": "oa", 11165 "organization_hooks": "oh", 11166 "organization_plan": "op", 11167 "organization_pre_receive_hooks": "opr", 11168 "organization_projects": "op", 11169 "organization_secrets": "os", 11170 "organization_self_hosted_runners": "osh", 11171 "organization_user_blocking": "oub", 11172 "packages": "pkg", 11173 "pages": "pg", 11174 "pull_requests": "pr", 11175 "repository_hooks": "rh", 11176 "repository_projects": "rp", 11177 "repository_pre_receive_hooks": "rprh", 11178 "secrets": "s", 11179 "secret_scanning_alerts": "ssa", 11180 "security_events": "se", 11181 "single_file": "sf", 11182 "statuses": "s", 11183 "team_discussions": "td", 11184 "vulnerability_alerts": "va", 11185 "workflows": "w" 11186 }, 11187 "created_at": ` + referenceTimeStr + `, 11188 "updated_at": ` + referenceTimeStr + `, 11189 "has_multiple_single_files": false, 11190 "suspended_by": { 11191 "login": "l", 11192 "id": 1, 11193 "avatar_url": "a", 11194 "gravatar_id": "g", 11195 "name": "n", 11196 "company": "c", 11197 "blog": "b", 11198 "location": "l", 11199 "email": "e", 11200 "hireable": true, 11201 "bio": "b", 11202 "twitter_username": "t", 11203 "public_repos": 1, 11204 "followers": 1, 11205 "following": 1, 11206 "created_at": ` + referenceTimeStr + `, 11207 "suspended_at": ` + referenceTimeStr + `, 11208 "url": "u" 11209 }, 11210 "suspended_at": ` + referenceTimeStr + ` 11211 } 11212 }` 11213 11214 testJSONMarshal(t, u, want) 11215 } 11216 11217 func TestWorkflowRunEvent_Marshal(t *testing.T) { 11218 t.Parallel() 11219 testJSONMarshal(t, &WorkflowRunEvent{}, "{}") 11220 11221 u := &WorkflowRunEvent{ 11222 Action: String("a"), 11223 Workflow: &Workflow{ 11224 ID: Int64(1), 11225 NodeID: String("nid"), 11226 Name: String("n"), 11227 Path: String("p"), 11228 State: String("s"), 11229 CreatedAt: &Timestamp{referenceTime}, 11230 UpdatedAt: &Timestamp{referenceTime}, 11231 URL: String("u"), 11232 HTMLURL: String("h"), 11233 BadgeURL: String("b"), 11234 }, 11235 WorkflowRun: &WorkflowRun{ 11236 ID: Int64(1), 11237 Name: String("n"), 11238 NodeID: String("nid"), 11239 HeadBranch: String("hb"), 11240 HeadSHA: String("hs"), 11241 RunNumber: Int(1), 11242 RunAttempt: Int(1), 11243 Event: String("e"), 11244 Status: String("s"), 11245 Conclusion: String("c"), 11246 WorkflowID: Int64(1), 11247 URL: String("u"), 11248 HTMLURL: String("h"), 11249 PullRequests: []*PullRequest{ 11250 { 11251 URL: String("u"), 11252 ID: Int64(1), 11253 Number: Int(1), 11254 Head: &PullRequestBranch{ 11255 Ref: String("r"), 11256 SHA: String("s"), 11257 Repo: &Repository{ 11258 ID: Int64(1), 11259 URL: String("s"), 11260 Name: String("n"), 11261 }, 11262 }, 11263 Base: &PullRequestBranch{ 11264 Ref: String("r"), 11265 SHA: String("s"), 11266 Repo: &Repository{ 11267 ID: Int64(1), 11268 URL: String("u"), 11269 Name: String("n"), 11270 }, 11271 }, 11272 }, 11273 }, 11274 CreatedAt: &Timestamp{referenceTime}, 11275 UpdatedAt: &Timestamp{referenceTime}, 11276 RunStartedAt: &Timestamp{referenceTime}, 11277 JobsURL: String("j"), 11278 LogsURL: String("l"), 11279 CheckSuiteURL: String("c"), 11280 ArtifactsURL: String("a"), 11281 CancelURL: String("c"), 11282 RerunURL: String("r"), 11283 PreviousAttemptURL: String("p"), 11284 HeadCommit: &HeadCommit{ 11285 Message: String("m"), 11286 Author: &CommitAuthor{ 11287 Name: String("n"), 11288 Email: String("e"), 11289 Login: String("l"), 11290 }, 11291 URL: String("u"), 11292 Distinct: Bool(false), 11293 SHA: String("s"), 11294 ID: String("i"), 11295 TreeID: String("tid"), 11296 Timestamp: &Timestamp{referenceTime}, 11297 Committer: &CommitAuthor{ 11298 Name: String("n"), 11299 Email: String("e"), 11300 Login: String("l"), 11301 }, 11302 }, 11303 WorkflowURL: String("w"), 11304 Repository: &Repository{ 11305 ID: Int64(1), 11306 URL: String("u"), 11307 Name: String("n"), 11308 }, 11309 HeadRepository: &Repository{ 11310 ID: Int64(1), 11311 URL: String("u"), 11312 Name: String("n"), 11313 }, 11314 }, 11315 Org: &Organization{ 11316 BillingEmail: String("be"), 11317 Blog: String("b"), 11318 Company: String("c"), 11319 Email: String("e"), 11320 TwitterUsername: String("tu"), 11321 Location: String("loc"), 11322 Name: String("n"), 11323 Description: String("d"), 11324 IsVerified: Bool(true), 11325 HasOrganizationProjects: Bool(true), 11326 HasRepositoryProjects: Bool(true), 11327 DefaultRepoPermission: String("drp"), 11328 MembersCanCreateRepos: Bool(true), 11329 MembersCanCreateInternalRepos: Bool(true), 11330 MembersCanCreatePrivateRepos: Bool(true), 11331 MembersCanCreatePublicRepos: Bool(false), 11332 MembersAllowedRepositoryCreationType: String("marct"), 11333 MembersCanCreatePages: Bool(true), 11334 MembersCanCreatePublicPages: Bool(false), 11335 MembersCanCreatePrivatePages: Bool(true), 11336 }, 11337 Repo: &Repository{ 11338 ID: Int64(1), 11339 URL: String("s"), 11340 Name: String("n"), 11341 }, 11342 Sender: &User{ 11343 Login: String("l"), 11344 ID: Int64(1), 11345 NodeID: String("n"), 11346 URL: String("u"), 11347 ReposURL: String("r"), 11348 EventsURL: String("e"), 11349 AvatarURL: String("a"), 11350 }, 11351 } 11352 11353 want := `{ 11354 "action": "a", 11355 "workflow": { 11356 "id": 1, 11357 "node_id": "nid", 11358 "name": "n", 11359 "path": "p", 11360 "state": "s", 11361 "created_at": ` + referenceTimeStr + `, 11362 "updated_at": ` + referenceTimeStr + `, 11363 "url": "u", 11364 "html_url": "h", 11365 "badge_url": "b" 11366 }, 11367 "workflow_run": { 11368 "id": 1, 11369 "name": "n", 11370 "node_id": "nid", 11371 "head_branch": "hb", 11372 "head_sha": "hs", 11373 "run_number": 1, 11374 "run_attempt": 1, 11375 "event": "e", 11376 "status": "s", 11377 "conclusion": "c", 11378 "workflow_id": 1, 11379 "url": "u", 11380 "html_url": "h", 11381 "pull_requests": [ 11382 { 11383 "id": 1, 11384 "number": 1, 11385 "url": "u", 11386 "head": { 11387 "ref": "r", 11388 "sha": "s", 11389 "repo": { 11390 "id": 1, 11391 "name": "n", 11392 "url": "s" 11393 } 11394 }, 11395 "base": { 11396 "ref": "r", 11397 "sha": "s", 11398 "repo": { 11399 "id": 1, 11400 "name": "n", 11401 "url": "u" 11402 } 11403 } 11404 } 11405 ], 11406 "created_at": ` + referenceTimeStr + `, 11407 "updated_at": ` + referenceTimeStr + `, 11408 "run_started_at": ` + referenceTimeStr + `, 11409 "jobs_url": "j", 11410 "logs_url": "l", 11411 "check_suite_url": "c", 11412 "artifacts_url": "a", 11413 "cancel_url": "c", 11414 "rerun_url": "r", 11415 "previous_attempt_url": "p", 11416 "head_commit": { 11417 "message": "m", 11418 "author": { 11419 "name": "n", 11420 "email": "e", 11421 "username": "l" 11422 }, 11423 "url": "u", 11424 "distinct": false, 11425 "sha": "s", 11426 "id": "i", 11427 "tree_id": "tid", 11428 "timestamp": ` + referenceTimeStr + `, 11429 "committer": { 11430 "name": "n", 11431 "email": "e", 11432 "username": "l" 11433 } 11434 }, 11435 "workflow_url": "w", 11436 "repository": { 11437 "id": 1, 11438 "name": "n", 11439 "url": "u" 11440 }, 11441 "head_repository": { 11442 "id": 1, 11443 "name": "n", 11444 "url": "u" 11445 } 11446 }, 11447 "organization": { 11448 "name": "n", 11449 "company": "c", 11450 "blog": "b", 11451 "location": "loc", 11452 "email": "e", 11453 "twitter_username": "tu", 11454 "description": "d", 11455 "billing_email": "be", 11456 "is_verified": true, 11457 "has_organization_projects": true, 11458 "has_repository_projects": true, 11459 "default_repository_permission": "drp", 11460 "members_can_create_repositories": true, 11461 "members_can_create_public_repositories": false, 11462 "members_can_create_private_repositories": true, 11463 "members_can_create_internal_repositories": true, 11464 "members_allowed_repository_creation_type": "marct", 11465 "members_can_create_pages": true, 11466 "members_can_create_public_pages": false, 11467 "members_can_create_private_pages": true 11468 }, 11469 "repository": { 11470 "id": 1, 11471 "name": "n", 11472 "url": "s" 11473 }, 11474 "sender": { 11475 "login": "l", 11476 "id": 1, 11477 "node_id": "n", 11478 "avatar_url": "a", 11479 "url": "u", 11480 "events_url": "e", 11481 "repos_url": "r" 11482 } 11483 }` 11484 11485 testJSONMarshal(t, u, want) 11486 } 11487 11488 func TestWorkflowDispatchEvent_Marshal(t *testing.T) { 11489 t.Parallel() 11490 testJSONMarshal(t, &WorkflowDispatchEvent{}, "{}") 11491 11492 i := make(map[string]interface{}) 11493 i["key"] = "value" 11494 11495 jsonMsg, _ := json.Marshal(i) 11496 u := &WorkflowDispatchEvent{ 11497 Inputs: jsonMsg, 11498 Ref: String("r"), 11499 Workflow: String("w"), 11500 Repo: &Repository{ 11501 ID: Int64(1), 11502 URL: String("s"), 11503 Name: String("n"), 11504 }, 11505 Org: &Organization{ 11506 BillingEmail: String("be"), 11507 Blog: String("b"), 11508 Company: String("c"), 11509 Email: String("e"), 11510 TwitterUsername: String("tu"), 11511 Location: String("loc"), 11512 Name: String("n"), 11513 Description: String("d"), 11514 IsVerified: Bool(true), 11515 HasOrganizationProjects: Bool(true), 11516 HasRepositoryProjects: Bool(true), 11517 DefaultRepoPermission: String("drp"), 11518 MembersCanCreateRepos: Bool(true), 11519 MembersCanCreateInternalRepos: Bool(true), 11520 MembersCanCreatePrivateRepos: Bool(true), 11521 MembersCanCreatePublicRepos: Bool(false), 11522 MembersAllowedRepositoryCreationType: String("marct"), 11523 MembersCanCreatePages: Bool(true), 11524 MembersCanCreatePublicPages: Bool(false), 11525 MembersCanCreatePrivatePages: Bool(true), 11526 }, 11527 Sender: &User{ 11528 Login: String("l"), 11529 ID: Int64(1), 11530 NodeID: String("n"), 11531 URL: String("u"), 11532 ReposURL: String("r"), 11533 EventsURL: String("e"), 11534 AvatarURL: String("a"), 11535 }, 11536 } 11537 11538 want := `{ 11539 "inputs": { 11540 "key": "value" 11541 }, 11542 "ref": "r", 11543 "workflow": "w", 11544 "repository": { 11545 "id": 1, 11546 "name": "n", 11547 "url": "s" 11548 }, 11549 "organization": { 11550 "name": "n", 11551 "company": "c", 11552 "blog": "b", 11553 "location": "loc", 11554 "email": "e", 11555 "twitter_username": "tu", 11556 "description": "d", 11557 "billing_email": "be", 11558 "is_verified": true, 11559 "has_organization_projects": true, 11560 "has_repository_projects": true, 11561 "default_repository_permission": "drp", 11562 "members_can_create_repositories": true, 11563 "members_can_create_public_repositories": false, 11564 "members_can_create_private_repositories": true, 11565 "members_can_create_internal_repositories": true, 11566 "members_allowed_repository_creation_type": "marct", 11567 "members_can_create_pages": true, 11568 "members_can_create_public_pages": false, 11569 "members_can_create_private_pages": true 11570 }, 11571 "sender": { 11572 "login": "l", 11573 "id": 1, 11574 "node_id": "n", 11575 "avatar_url": "a", 11576 "url": "u", 11577 "events_url": "e", 11578 "repos_url": "r" 11579 } 11580 }` 11581 11582 testJSONMarshal(t, u, want) 11583 } 11584 11585 func TestWatchEvent_Marshal(t *testing.T) { 11586 t.Parallel() 11587 testJSONMarshal(t, &WatchEvent{}, "{}") 11588 11589 u := &WatchEvent{ 11590 Action: String("a"), 11591 Repo: &Repository{ 11592 ID: Int64(1), 11593 URL: String("s"), 11594 Name: String("n"), 11595 }, 11596 Sender: &User{ 11597 Login: String("l"), 11598 ID: Int64(1), 11599 NodeID: String("n"), 11600 URL: String("u"), 11601 ReposURL: String("r"), 11602 EventsURL: String("e"), 11603 AvatarURL: String("a"), 11604 }, 11605 Installation: &Installation{ 11606 ID: Int64(1), 11607 NodeID: String("nid"), 11608 AppID: Int64(1), 11609 AppSlug: String("as"), 11610 TargetID: Int64(1), 11611 Account: &User{ 11612 Login: String("l"), 11613 ID: Int64(1), 11614 URL: String("u"), 11615 AvatarURL: String("a"), 11616 GravatarID: String("g"), 11617 Name: String("n"), 11618 Company: String("c"), 11619 Blog: String("b"), 11620 Location: String("l"), 11621 Email: String("e"), 11622 Hireable: Bool(true), 11623 Bio: String("b"), 11624 TwitterUsername: String("t"), 11625 PublicRepos: Int(1), 11626 Followers: Int(1), 11627 Following: Int(1), 11628 CreatedAt: &Timestamp{referenceTime}, 11629 SuspendedAt: &Timestamp{referenceTime}, 11630 }, 11631 AccessTokensURL: String("atu"), 11632 RepositoriesURL: String("ru"), 11633 HTMLURL: String("hu"), 11634 TargetType: String("tt"), 11635 SingleFileName: String("sfn"), 11636 RepositorySelection: String("rs"), 11637 Events: []string{"e"}, 11638 SingleFilePaths: []string{"s"}, 11639 Permissions: &InstallationPermissions{ 11640 Actions: String("a"), 11641 Administration: String("ad"), 11642 Checks: String("c"), 11643 Contents: String("co"), 11644 ContentReferences: String("cr"), 11645 Deployments: String("d"), 11646 Environments: String("e"), 11647 Issues: String("i"), 11648 Metadata: String("md"), 11649 Members: String("m"), 11650 OrganizationAdministration: String("oa"), 11651 OrganizationHooks: String("oh"), 11652 OrganizationPlan: String("op"), 11653 OrganizationPreReceiveHooks: String("opr"), 11654 OrganizationProjects: String("op"), 11655 OrganizationSecrets: String("os"), 11656 OrganizationSelfHostedRunners: String("osh"), 11657 OrganizationUserBlocking: String("oub"), 11658 Packages: String("pkg"), 11659 Pages: String("pg"), 11660 PullRequests: String("pr"), 11661 RepositoryHooks: String("rh"), 11662 RepositoryProjects: String("rp"), 11663 RepositoryPreReceiveHooks: String("rprh"), 11664 Secrets: String("s"), 11665 SecretScanningAlerts: String("ssa"), 11666 SecurityEvents: String("se"), 11667 SingleFile: String("sf"), 11668 Statuses: String("s"), 11669 TeamDiscussions: String("td"), 11670 VulnerabilityAlerts: String("va"), 11671 Workflows: String("w"), 11672 }, 11673 CreatedAt: &Timestamp{referenceTime}, 11674 UpdatedAt: &Timestamp{referenceTime}, 11675 HasMultipleSingleFiles: Bool(false), 11676 SuspendedBy: &User{ 11677 Login: String("l"), 11678 ID: Int64(1), 11679 URL: String("u"), 11680 AvatarURL: String("a"), 11681 GravatarID: String("g"), 11682 Name: String("n"), 11683 Company: String("c"), 11684 Blog: String("b"), 11685 Location: String("l"), 11686 Email: String("e"), 11687 Hireable: Bool(true), 11688 Bio: String("b"), 11689 TwitterUsername: String("t"), 11690 PublicRepos: Int(1), 11691 Followers: Int(1), 11692 Following: Int(1), 11693 CreatedAt: &Timestamp{referenceTime}, 11694 SuspendedAt: &Timestamp{referenceTime}, 11695 }, 11696 SuspendedAt: &Timestamp{referenceTime}, 11697 }, 11698 } 11699 11700 want := `{ 11701 "action": "a", 11702 "repository": { 11703 "id": 1, 11704 "name": "n", 11705 "url": "s" 11706 }, 11707 "sender": { 11708 "login": "l", 11709 "id": 1, 11710 "node_id": "n", 11711 "avatar_url": "a", 11712 "url": "u", 11713 "events_url": "e", 11714 "repos_url": "r" 11715 }, 11716 "installation": { 11717 "id": 1, 11718 "node_id": "nid", 11719 "app_id": 1, 11720 "app_slug": "as", 11721 "target_id": 1, 11722 "account": { 11723 "login": "l", 11724 "id": 1, 11725 "avatar_url": "a", 11726 "gravatar_id": "g", 11727 "name": "n", 11728 "company": "c", 11729 "blog": "b", 11730 "location": "l", 11731 "email": "e", 11732 "hireable": true, 11733 "bio": "b", 11734 "twitter_username": "t", 11735 "public_repos": 1, 11736 "followers": 1, 11737 "following": 1, 11738 "created_at": ` + referenceTimeStr + `, 11739 "suspended_at": ` + referenceTimeStr + `, 11740 "url": "u" 11741 }, 11742 "access_tokens_url": "atu", 11743 "repositories_url": "ru", 11744 "html_url": "hu", 11745 "target_type": "tt", 11746 "single_file_name": "sfn", 11747 "repository_selection": "rs", 11748 "events": [ 11749 "e" 11750 ], 11751 "single_file_paths": [ 11752 "s" 11753 ], 11754 "permissions": { 11755 "actions": "a", 11756 "administration": "ad", 11757 "checks": "c", 11758 "contents": "co", 11759 "content_references": "cr", 11760 "deployments": "d", 11761 "environments": "e", 11762 "issues": "i", 11763 "metadata": "md", 11764 "members": "m", 11765 "organization_administration": "oa", 11766 "organization_hooks": "oh", 11767 "organization_plan": "op", 11768 "organization_pre_receive_hooks": "opr", 11769 "organization_projects": "op", 11770 "organization_secrets": "os", 11771 "organization_self_hosted_runners": "osh", 11772 "organization_user_blocking": "oub", 11773 "packages": "pkg", 11774 "pages": "pg", 11775 "pull_requests": "pr", 11776 "repository_hooks": "rh", 11777 "repository_projects": "rp", 11778 "repository_pre_receive_hooks": "rprh", 11779 "secrets": "s", 11780 "secret_scanning_alerts": "ssa", 11781 "security_events": "se", 11782 "single_file": "sf", 11783 "statuses": "s", 11784 "team_discussions": "td", 11785 "vulnerability_alerts": "va", 11786 "workflows": "w" 11787 }, 11788 "created_at": ` + referenceTimeStr + `, 11789 "updated_at": ` + referenceTimeStr + `, 11790 "has_multiple_single_files": false, 11791 "suspended_by": { 11792 "login": "l", 11793 "id": 1, 11794 "avatar_url": "a", 11795 "gravatar_id": "g", 11796 "name": "n", 11797 "company": "c", 11798 "blog": "b", 11799 "location": "l", 11800 "email": "e", 11801 "hireable": true, 11802 "bio": "b", 11803 "twitter_username": "t", 11804 "public_repos": 1, 11805 "followers": 1, 11806 "following": 1, 11807 "created_at": ` + referenceTimeStr + `, 11808 "suspended_at": ` + referenceTimeStr + `, 11809 "url": "u" 11810 }, 11811 "suspended_at": ` + referenceTimeStr + ` 11812 } 11813 }` 11814 11815 testJSONMarshal(t, u, want) 11816 } 11817 11818 func TestUserEvent_Marshal(t *testing.T) { 11819 t.Parallel() 11820 testJSONMarshal(t, &UserEvent{}, "{}") 11821 11822 u := &UserEvent{ 11823 User: &User{ 11824 Login: String("l"), 11825 ID: Int64(1), 11826 NodeID: String("n"), 11827 URL: String("u"), 11828 ReposURL: String("r"), 11829 EventsURL: String("e"), 11830 AvatarURL: String("a"), 11831 }, 11832 // The action performed. Possible values are: "created" or "deleted". 11833 Action: String("a"), 11834 Enterprise: &Enterprise{ 11835 ID: Int(1), 11836 Slug: String("s"), 11837 Name: String("n"), 11838 NodeID: String("nid"), 11839 AvatarURL: String("au"), 11840 Description: String("d"), 11841 WebsiteURL: String("wu"), 11842 HTMLURL: String("hu"), 11843 CreatedAt: &Timestamp{referenceTime}, 11844 UpdatedAt: &Timestamp{referenceTime}, 11845 }, 11846 Sender: &User{ 11847 Login: String("l"), 11848 ID: Int64(1), 11849 NodeID: String("n"), 11850 URL: String("u"), 11851 ReposURL: String("r"), 11852 EventsURL: String("e"), 11853 AvatarURL: String("a"), 11854 }, 11855 } 11856 11857 want := `{ 11858 "user": { 11859 "login": "l", 11860 "id": 1, 11861 "node_id": "n", 11862 "avatar_url": "a", 11863 "url": "u", 11864 "events_url": "e", 11865 "repos_url": "r" 11866 }, 11867 "action": "a", 11868 "enterprise": { 11869 "id": 1, 11870 "slug": "s", 11871 "name": "n", 11872 "node_id": "nid", 11873 "avatar_url": "au", 11874 "description": "d", 11875 "website_url": "wu", 11876 "html_url": "hu", 11877 "created_at": ` + referenceTimeStr + `, 11878 "updated_at": ` + referenceTimeStr + ` 11879 }, 11880 "sender": { 11881 "login": "l", 11882 "id": 1, 11883 "node_id": "n", 11884 "avatar_url": "a", 11885 "url": "u", 11886 "events_url": "e", 11887 "repos_url": "r" 11888 } 11889 }` 11890 11891 testJSONMarshal(t, u, want) 11892 } 11893 11894 func TestCheckRunEvent_Marshal(t *testing.T) { 11895 t.Parallel() 11896 testJSONMarshal(t, &CheckRunEvent{}, "{}") 11897 11898 r := &CheckRunEvent{ 11899 CheckRun: &CheckRun{ 11900 ID: Int64(1), 11901 NodeID: String("n"), 11902 HeadSHA: String("h"), 11903 ExternalID: String("1"), 11904 URL: String("u"), 11905 HTMLURL: String("u"), 11906 DetailsURL: String("u"), 11907 Status: String("s"), 11908 Conclusion: String("c"), 11909 StartedAt: &Timestamp{referenceTime}, 11910 CompletedAt: &Timestamp{referenceTime}, 11911 Output: &CheckRunOutput{ 11912 Annotations: []*CheckRunAnnotation{ 11913 { 11914 AnnotationLevel: String("a"), 11915 EndLine: Int(1), 11916 Message: String("m"), 11917 Path: String("p"), 11918 RawDetails: String("r"), 11919 StartLine: Int(1), 11920 Title: String("t"), 11921 }, 11922 }, 11923 AnnotationsCount: Int(1), 11924 AnnotationsURL: String("a"), 11925 Images: []*CheckRunImage{ 11926 { 11927 Alt: String("a"), 11928 ImageURL: String("i"), 11929 Caption: String("c"), 11930 }, 11931 }, 11932 Title: String("t"), 11933 Summary: String("s"), 11934 Text: String("t"), 11935 }, 11936 Name: String("n"), 11937 CheckSuite: &CheckSuite{ 11938 ID: Int64(1), 11939 }, 11940 App: &App{ 11941 ID: Int64(1), 11942 NodeID: String("n"), 11943 Owner: &User{ 11944 Login: String("l"), 11945 ID: Int64(1), 11946 NodeID: String("n"), 11947 URL: String("u"), 11948 ReposURL: String("r"), 11949 EventsURL: String("e"), 11950 AvatarURL: String("a"), 11951 }, 11952 Name: String("n"), 11953 Description: String("d"), 11954 HTMLURL: String("h"), 11955 ExternalURL: String("u"), 11956 CreatedAt: &Timestamp{referenceTime}, 11957 UpdatedAt: &Timestamp{referenceTime}, 11958 }, 11959 PullRequests: []*PullRequest{ 11960 { 11961 URL: String("u"), 11962 ID: Int64(1), 11963 Number: Int(1), 11964 Head: &PullRequestBranch{ 11965 Ref: String("r"), 11966 SHA: String("s"), 11967 Repo: &Repository{ 11968 ID: Int64(1), 11969 URL: String("s"), 11970 Name: String("n"), 11971 }, 11972 }, 11973 Base: &PullRequestBranch{ 11974 Ref: String("r"), 11975 SHA: String("s"), 11976 Repo: &Repository{ 11977 ID: Int64(1), 11978 URL: String("u"), 11979 Name: String("n"), 11980 }, 11981 }, 11982 }, 11983 }, 11984 }, 11985 Action: String("a"), 11986 Repo: &Repository{ 11987 ID: Int64(1), 11988 URL: String("s"), 11989 Name: String("n"), 11990 }, 11991 Org: &Organization{ 11992 BillingEmail: String("be"), 11993 Blog: String("b"), 11994 Company: String("c"), 11995 Email: String("e"), 11996 TwitterUsername: String("tu"), 11997 Location: String("loc"), 11998 Name: String("n"), 11999 Description: String("d"), 12000 IsVerified: Bool(true), 12001 HasOrganizationProjects: Bool(true), 12002 HasRepositoryProjects: Bool(true), 12003 DefaultRepoPermission: String("drp"), 12004 MembersCanCreateRepos: Bool(true), 12005 MembersCanCreateInternalRepos: Bool(true), 12006 MembersCanCreatePrivateRepos: Bool(true), 12007 MembersCanCreatePublicRepos: Bool(false), 12008 MembersAllowedRepositoryCreationType: String("marct"), 12009 MembersCanCreatePages: Bool(true), 12010 MembersCanCreatePublicPages: Bool(false), 12011 MembersCanCreatePrivatePages: Bool(true), 12012 }, 12013 Sender: &User{ 12014 Login: String("l"), 12015 ID: Int64(1), 12016 NodeID: String("n"), 12017 URL: String("u"), 12018 ReposURL: String("r"), 12019 EventsURL: String("e"), 12020 AvatarURL: String("a"), 12021 }, 12022 Installation: &Installation{ 12023 ID: Int64(1), 12024 NodeID: String("nid"), 12025 AppID: Int64(1), 12026 AppSlug: String("as"), 12027 TargetID: Int64(1), 12028 Account: &User{ 12029 Login: String("l"), 12030 ID: Int64(1), 12031 URL: String("u"), 12032 AvatarURL: String("a"), 12033 GravatarID: String("g"), 12034 Name: String("n"), 12035 Company: String("c"), 12036 Blog: String("b"), 12037 Location: String("l"), 12038 Email: String("e"), 12039 Hireable: Bool(true), 12040 Bio: String("b"), 12041 TwitterUsername: String("t"), 12042 PublicRepos: Int(1), 12043 Followers: Int(1), 12044 Following: Int(1), 12045 CreatedAt: &Timestamp{referenceTime}, 12046 SuspendedAt: &Timestamp{referenceTime}, 12047 }, 12048 AccessTokensURL: String("atu"), 12049 RepositoriesURL: String("ru"), 12050 HTMLURL: String("hu"), 12051 TargetType: String("tt"), 12052 SingleFileName: String("sfn"), 12053 RepositorySelection: String("rs"), 12054 Events: []string{"e"}, 12055 SingleFilePaths: []string{"s"}, 12056 Permissions: &InstallationPermissions{ 12057 Actions: String("a"), 12058 Administration: String("ad"), 12059 Checks: String("c"), 12060 Contents: String("co"), 12061 ContentReferences: String("cr"), 12062 Deployments: String("d"), 12063 Environments: String("e"), 12064 Issues: String("i"), 12065 Metadata: String("md"), 12066 Members: String("m"), 12067 OrganizationAdministration: String("oa"), 12068 OrganizationHooks: String("oh"), 12069 OrganizationPlan: String("op"), 12070 OrganizationPreReceiveHooks: String("opr"), 12071 OrganizationProjects: String("op"), 12072 OrganizationSecrets: String("os"), 12073 OrganizationSelfHostedRunners: String("osh"), 12074 OrganizationUserBlocking: String("oub"), 12075 Packages: String("pkg"), 12076 Pages: String("pg"), 12077 PullRequests: String("pr"), 12078 RepositoryHooks: String("rh"), 12079 RepositoryProjects: String("rp"), 12080 RepositoryPreReceiveHooks: String("rprh"), 12081 Secrets: String("s"), 12082 SecretScanningAlerts: String("ssa"), 12083 SecurityEvents: String("se"), 12084 SingleFile: String("sf"), 12085 Statuses: String("s"), 12086 TeamDiscussions: String("td"), 12087 VulnerabilityAlerts: String("va"), 12088 Workflows: String("w"), 12089 }, 12090 CreatedAt: &Timestamp{referenceTime}, 12091 UpdatedAt: &Timestamp{referenceTime}, 12092 HasMultipleSingleFiles: Bool(false), 12093 SuspendedBy: &User{ 12094 Login: String("l"), 12095 ID: Int64(1), 12096 URL: String("u"), 12097 AvatarURL: String("a"), 12098 GravatarID: String("g"), 12099 Name: String("n"), 12100 Company: String("c"), 12101 Blog: String("b"), 12102 Location: String("l"), 12103 Email: String("e"), 12104 Hireable: Bool(true), 12105 Bio: String("b"), 12106 TwitterUsername: String("t"), 12107 PublicRepos: Int(1), 12108 Followers: Int(1), 12109 Following: Int(1), 12110 CreatedAt: &Timestamp{referenceTime}, 12111 SuspendedAt: &Timestamp{referenceTime}, 12112 }, 12113 SuspendedAt: &Timestamp{referenceTime}, 12114 }, 12115 RequestedAction: &RequestedAction{ 12116 Identifier: "i", 12117 }, 12118 } 12119 12120 want := `{ 12121 "check_run": { 12122 "id": 1, 12123 "node_id": "n", 12124 "head_sha": "h", 12125 "external_id": "1", 12126 "url": "u", 12127 "html_url": "u", 12128 "details_url": "u", 12129 "status": "s", 12130 "conclusion": "c", 12131 "started_at": ` + referenceTimeStr + `, 12132 "completed_at": ` + referenceTimeStr + `, 12133 "output": { 12134 "title": "t", 12135 "summary": "s", 12136 "text": "t", 12137 "annotations_count": 1, 12138 "annotations_url": "a", 12139 "annotations": [ 12140 { 12141 "path": "p", 12142 "start_line": 1, 12143 "end_line": 1, 12144 "annotation_level": "a", 12145 "message": "m", 12146 "title": "t", 12147 "raw_details": "r" 12148 } 12149 ], 12150 "images": [ 12151 { 12152 "alt": "a", 12153 "image_url": "i", 12154 "caption": "c" 12155 } 12156 ] 12157 }, 12158 "name": "n", 12159 "check_suite": { 12160 "id": 1 12161 }, 12162 "app": { 12163 "id": 1, 12164 "node_id": "n", 12165 "owner": { 12166 "login": "l", 12167 "id": 1, 12168 "node_id": "n", 12169 "avatar_url": "a", 12170 "url": "u", 12171 "events_url": "e", 12172 "repos_url": "r" 12173 }, 12174 "name": "n", 12175 "description": "d", 12176 "external_url": "u", 12177 "html_url": "h", 12178 "created_at": ` + referenceTimeStr + `, 12179 "updated_at": ` + referenceTimeStr + ` 12180 }, 12181 "pull_requests": [ 12182 { 12183 "id": 1, 12184 "number": 1, 12185 "url": "u", 12186 "head": { 12187 "ref": "r", 12188 "sha": "s", 12189 "repo": { 12190 "id": 1, 12191 "name": "n", 12192 "url": "s" 12193 } 12194 }, 12195 "base": { 12196 "ref": "r", 12197 "sha": "s", 12198 "repo": { 12199 "id": 1, 12200 "name": "n", 12201 "url": "u" 12202 } 12203 } 12204 } 12205 ] 12206 }, 12207 "action": "a", 12208 "repository": { 12209 "id": 1, 12210 "name": "n", 12211 "url": "s" 12212 }, 12213 "organization": { 12214 "name": "n", 12215 "company": "c", 12216 "blog": "b", 12217 "location": "loc", 12218 "email": "e", 12219 "twitter_username": "tu", 12220 "description": "d", 12221 "billing_email": "be", 12222 "is_verified": true, 12223 "has_organization_projects": true, 12224 "has_repository_projects": true, 12225 "default_repository_permission": "drp", 12226 "members_can_create_repositories": true, 12227 "members_can_create_public_repositories": false, 12228 "members_can_create_private_repositories": true, 12229 "members_can_create_internal_repositories": true, 12230 "members_allowed_repository_creation_type": "marct", 12231 "members_can_create_pages": true, 12232 "members_can_create_public_pages": false, 12233 "members_can_create_private_pages": true 12234 }, 12235 "sender": { 12236 "login": "l", 12237 "id": 1, 12238 "node_id": "n", 12239 "avatar_url": "a", 12240 "url": "u", 12241 "events_url": "e", 12242 "repos_url": "r" 12243 }, 12244 "installation": { 12245 "id": 1, 12246 "node_id": "nid", 12247 "app_id": 1, 12248 "app_slug": "as", 12249 "target_id": 1, 12250 "account": { 12251 "login": "l", 12252 "id": 1, 12253 "avatar_url": "a", 12254 "gravatar_id": "g", 12255 "name": "n", 12256 "company": "c", 12257 "blog": "b", 12258 "location": "l", 12259 "email": "e", 12260 "hireable": true, 12261 "bio": "b", 12262 "twitter_username": "t", 12263 "public_repos": 1, 12264 "followers": 1, 12265 "following": 1, 12266 "created_at": ` + referenceTimeStr + `, 12267 "suspended_at": ` + referenceTimeStr + `, 12268 "url": "u" 12269 }, 12270 "access_tokens_url": "atu", 12271 "repositories_url": "ru", 12272 "html_url": "hu", 12273 "target_type": "tt", 12274 "single_file_name": "sfn", 12275 "repository_selection": "rs", 12276 "events": [ 12277 "e" 12278 ], 12279 "single_file_paths": [ 12280 "s" 12281 ], 12282 "permissions": { 12283 "actions": "a", 12284 "administration": "ad", 12285 "checks": "c", 12286 "contents": "co", 12287 "content_references": "cr", 12288 "deployments": "d", 12289 "environments": "e", 12290 "issues": "i", 12291 "metadata": "md", 12292 "members": "m", 12293 "organization_administration": "oa", 12294 "organization_hooks": "oh", 12295 "organization_plan": "op", 12296 "organization_pre_receive_hooks": "opr", 12297 "organization_projects": "op", 12298 "organization_secrets": "os", 12299 "organization_self_hosted_runners": "osh", 12300 "organization_user_blocking": "oub", 12301 "packages": "pkg", 12302 "pages": "pg", 12303 "pull_requests": "pr", 12304 "repository_hooks": "rh", 12305 "repository_projects": "rp", 12306 "repository_pre_receive_hooks": "rprh", 12307 "secrets": "s", 12308 "secret_scanning_alerts": "ssa", 12309 "security_events": "se", 12310 "single_file": "sf", 12311 "statuses": "s", 12312 "team_discussions": "td", 12313 "vulnerability_alerts": "va", 12314 "workflows": "w" 12315 }, 12316 "created_at": ` + referenceTimeStr + `, 12317 "updated_at": ` + referenceTimeStr + `, 12318 "has_multiple_single_files": false, 12319 "suspended_by": { 12320 "login": "l", 12321 "id": 1, 12322 "avatar_url": "a", 12323 "gravatar_id": "g", 12324 "name": "n", 12325 "company": "c", 12326 "blog": "b", 12327 "location": "l", 12328 "email": "e", 12329 "hireable": true, 12330 "bio": "b", 12331 "twitter_username": "t", 12332 "public_repos": 1, 12333 "followers": 1, 12334 "following": 1, 12335 "created_at": ` + referenceTimeStr + `, 12336 "suspended_at": ` + referenceTimeStr + `, 12337 "url": "u" 12338 }, 12339 "suspended_at": ` + referenceTimeStr + ` 12340 }, 12341 "requested_action": { 12342 "identifier": "i" 12343 } 12344 }` 12345 12346 testJSONMarshal(t, r, want) 12347 } 12348 12349 func TestCheckSuiteEvent_Marshal(t *testing.T) { 12350 t.Parallel() 12351 testJSONMarshal(t, &CheckSuiteEvent{}, "{}") 12352 12353 r := &CheckSuiteEvent{ 12354 CheckSuite: &CheckSuite{ 12355 ID: Int64(1), 12356 NodeID: String("n"), 12357 HeadBranch: String("h"), 12358 HeadSHA: String("h"), 12359 URL: String("u"), 12360 BeforeSHA: String("b"), 12361 AfterSHA: String("a"), 12362 Status: String("s"), 12363 Conclusion: String("c"), 12364 App: &App{ 12365 ID: Int64(1), 12366 NodeID: String("n"), 12367 Owner: &User{ 12368 Login: String("l"), 12369 ID: Int64(1), 12370 NodeID: String("n"), 12371 URL: String("u"), 12372 ReposURL: String("r"), 12373 EventsURL: String("e"), 12374 AvatarURL: String("a"), 12375 }, 12376 Name: String("n"), 12377 Description: String("d"), 12378 HTMLURL: String("h"), 12379 ExternalURL: String("u"), 12380 CreatedAt: &Timestamp{referenceTime}, 12381 UpdatedAt: &Timestamp{referenceTime}, 12382 }, 12383 Repository: &Repository{ 12384 ID: Int64(1), 12385 }, 12386 PullRequests: []*PullRequest{ 12387 { 12388 URL: String("u"), 12389 ID: Int64(1), 12390 Number: Int(1), 12391 Head: &PullRequestBranch{ 12392 Ref: String("r"), 12393 SHA: String("s"), 12394 Repo: &Repository{ 12395 ID: Int64(1), 12396 URL: String("s"), 12397 Name: String("n"), 12398 }, 12399 }, 12400 Base: &PullRequestBranch{ 12401 Ref: String("r"), 12402 SHA: String("s"), 12403 Repo: &Repository{ 12404 ID: Int64(1), 12405 URL: String("u"), 12406 Name: String("n"), 12407 }, 12408 }, 12409 }, 12410 }, 12411 HeadCommit: &Commit{ 12412 SHA: String("s"), 12413 }, 12414 }, 12415 Action: String("a"), 12416 Repo: &Repository{ 12417 ID: Int64(1), 12418 URL: String("s"), 12419 Name: String("n"), 12420 }, 12421 Org: &Organization{ 12422 BillingEmail: String("be"), 12423 Blog: String("b"), 12424 Company: String("c"), 12425 Email: String("e"), 12426 TwitterUsername: String("tu"), 12427 Location: String("loc"), 12428 Name: String("n"), 12429 Description: String("d"), 12430 IsVerified: Bool(true), 12431 HasOrganizationProjects: Bool(true), 12432 HasRepositoryProjects: Bool(true), 12433 DefaultRepoPermission: String("drp"), 12434 MembersCanCreateRepos: Bool(true), 12435 MembersCanCreateInternalRepos: Bool(true), 12436 MembersCanCreatePrivateRepos: Bool(true), 12437 MembersCanCreatePublicRepos: Bool(false), 12438 MembersAllowedRepositoryCreationType: String("marct"), 12439 MembersCanCreatePages: Bool(true), 12440 MembersCanCreatePublicPages: Bool(false), 12441 MembersCanCreatePrivatePages: Bool(true), 12442 }, 12443 Sender: &User{ 12444 Login: String("l"), 12445 ID: Int64(1), 12446 NodeID: String("n"), 12447 URL: String("u"), 12448 ReposURL: String("r"), 12449 EventsURL: String("e"), 12450 AvatarURL: String("a"), 12451 }, 12452 Installation: &Installation{ 12453 ID: Int64(1), 12454 NodeID: String("nid"), 12455 AppID: Int64(1), 12456 AppSlug: String("as"), 12457 TargetID: Int64(1), 12458 Account: &User{ 12459 Login: String("l"), 12460 ID: Int64(1), 12461 URL: String("u"), 12462 AvatarURL: String("a"), 12463 GravatarID: String("g"), 12464 Name: String("n"), 12465 Company: String("c"), 12466 Blog: String("b"), 12467 Location: String("l"), 12468 Email: String("e"), 12469 Hireable: Bool(true), 12470 Bio: String("b"), 12471 TwitterUsername: String("t"), 12472 PublicRepos: Int(1), 12473 Followers: Int(1), 12474 Following: Int(1), 12475 CreatedAt: &Timestamp{referenceTime}, 12476 SuspendedAt: &Timestamp{referenceTime}, 12477 }, 12478 AccessTokensURL: String("atu"), 12479 RepositoriesURL: String("ru"), 12480 HTMLURL: String("hu"), 12481 TargetType: String("tt"), 12482 SingleFileName: String("sfn"), 12483 RepositorySelection: String("rs"), 12484 Events: []string{"e"}, 12485 SingleFilePaths: []string{"s"}, 12486 Permissions: &InstallationPermissions{ 12487 Actions: String("a"), 12488 Administration: String("ad"), 12489 Checks: String("c"), 12490 Contents: String("co"), 12491 ContentReferences: String("cr"), 12492 Deployments: String("d"), 12493 Environments: String("e"), 12494 Issues: String("i"), 12495 Metadata: String("md"), 12496 Members: String("m"), 12497 OrganizationAdministration: String("oa"), 12498 OrganizationHooks: String("oh"), 12499 OrganizationPlan: String("op"), 12500 OrganizationPreReceiveHooks: String("opr"), 12501 OrganizationProjects: String("op"), 12502 OrganizationSecrets: String("os"), 12503 OrganizationSelfHostedRunners: String("osh"), 12504 OrganizationUserBlocking: String("oub"), 12505 Packages: String("pkg"), 12506 Pages: String("pg"), 12507 PullRequests: String("pr"), 12508 RepositoryHooks: String("rh"), 12509 RepositoryProjects: String("rp"), 12510 RepositoryPreReceiveHooks: String("rprh"), 12511 Secrets: String("s"), 12512 SecretScanningAlerts: String("ssa"), 12513 SecurityEvents: String("se"), 12514 SingleFile: String("sf"), 12515 Statuses: String("s"), 12516 TeamDiscussions: String("td"), 12517 VulnerabilityAlerts: String("va"), 12518 Workflows: String("w"), 12519 }, 12520 CreatedAt: &Timestamp{referenceTime}, 12521 UpdatedAt: &Timestamp{referenceTime}, 12522 HasMultipleSingleFiles: Bool(false), 12523 SuspendedBy: &User{ 12524 Login: String("l"), 12525 ID: Int64(1), 12526 URL: String("u"), 12527 AvatarURL: String("a"), 12528 GravatarID: String("g"), 12529 Name: String("n"), 12530 Company: String("c"), 12531 Blog: String("b"), 12532 Location: String("l"), 12533 Email: String("e"), 12534 Hireable: Bool(true), 12535 Bio: String("b"), 12536 TwitterUsername: String("t"), 12537 PublicRepos: Int(1), 12538 Followers: Int(1), 12539 Following: Int(1), 12540 CreatedAt: &Timestamp{referenceTime}, 12541 SuspendedAt: &Timestamp{referenceTime}, 12542 }, 12543 SuspendedAt: &Timestamp{referenceTime}, 12544 }, 12545 } 12546 12547 want := `{ 12548 "check_suite": { 12549 "id": 1, 12550 "node_id": "n", 12551 "head_branch": "h", 12552 "head_sha": "h", 12553 "url": "u", 12554 "before": "b", 12555 "after": "a", 12556 "status": "s", 12557 "conclusion": "c", 12558 "app": { 12559 "id": 1, 12560 "node_id": "n", 12561 "owner": { 12562 "login": "l", 12563 "id": 1, 12564 "node_id": "n", 12565 "avatar_url": "a", 12566 "url": "u", 12567 "events_url": "e", 12568 "repos_url": "r" 12569 }, 12570 "name": "n", 12571 "description": "d", 12572 "external_url": "u", 12573 "html_url": "h", 12574 "created_at": ` + referenceTimeStr + `, 12575 "updated_at": ` + referenceTimeStr + ` 12576 }, 12577 "repository": { 12578 "id": 1 12579 }, 12580 "pull_requests": [ 12581 { 12582 "id": 1, 12583 "number": 1, 12584 "url": "u", 12585 "head": { 12586 "ref": "r", 12587 "sha": "s", 12588 "repo": { 12589 "id": 1, 12590 "name": "n", 12591 "url": "s" 12592 } 12593 }, 12594 "base": { 12595 "ref": "r", 12596 "sha": "s", 12597 "repo": { 12598 "id": 1, 12599 "name": "n", 12600 "url": "u" 12601 } 12602 } 12603 } 12604 ], 12605 "head_commit": { 12606 "sha": "s" 12607 } 12608 }, 12609 "action": "a", 12610 "repository": { 12611 "id": 1, 12612 "name": "n", 12613 "url": "s" 12614 }, 12615 "organization": { 12616 "name": "n", 12617 "company": "c", 12618 "blog": "b", 12619 "location": "loc", 12620 "email": "e", 12621 "twitter_username": "tu", 12622 "description": "d", 12623 "billing_email": "be", 12624 "is_verified": true, 12625 "has_organization_projects": true, 12626 "has_repository_projects": true, 12627 "default_repository_permission": "drp", 12628 "members_can_create_repositories": true, 12629 "members_can_create_public_repositories": false, 12630 "members_can_create_private_repositories": true, 12631 "members_can_create_internal_repositories": true, 12632 "members_allowed_repository_creation_type": "marct", 12633 "members_can_create_pages": true, 12634 "members_can_create_public_pages": false, 12635 "members_can_create_private_pages": true 12636 }, 12637 "sender": { 12638 "login": "l", 12639 "id": 1, 12640 "node_id": "n", 12641 "avatar_url": "a", 12642 "url": "u", 12643 "events_url": "e", 12644 "repos_url": "r" 12645 }, 12646 "installation": { 12647 "id": 1, 12648 "node_id": "nid", 12649 "app_id": 1, 12650 "app_slug": "as", 12651 "target_id": 1, 12652 "account": { 12653 "login": "l", 12654 "id": 1, 12655 "avatar_url": "a", 12656 "gravatar_id": "g", 12657 "name": "n", 12658 "company": "c", 12659 "blog": "b", 12660 "location": "l", 12661 "email": "e", 12662 "hireable": true, 12663 "bio": "b", 12664 "twitter_username": "t", 12665 "public_repos": 1, 12666 "followers": 1, 12667 "following": 1, 12668 "created_at": ` + referenceTimeStr + `, 12669 "suspended_at": ` + referenceTimeStr + `, 12670 "url": "u" 12671 }, 12672 "access_tokens_url": "atu", 12673 "repositories_url": "ru", 12674 "html_url": "hu", 12675 "target_type": "tt", 12676 "single_file_name": "sfn", 12677 "repository_selection": "rs", 12678 "events": [ 12679 "e" 12680 ], 12681 "single_file_paths": [ 12682 "s" 12683 ], 12684 "permissions": { 12685 "actions": "a", 12686 "administration": "ad", 12687 "checks": "c", 12688 "contents": "co", 12689 "content_references": "cr", 12690 "deployments": "d", 12691 "environments": "e", 12692 "issues": "i", 12693 "metadata": "md", 12694 "members": "m", 12695 "organization_administration": "oa", 12696 "organization_hooks": "oh", 12697 "organization_plan": "op", 12698 "organization_pre_receive_hooks": "opr", 12699 "organization_projects": "op", 12700 "organization_secrets": "os", 12701 "organization_self_hosted_runners": "osh", 12702 "organization_user_blocking": "oub", 12703 "packages": "pkg", 12704 "pages": "pg", 12705 "pull_requests": "pr", 12706 "repository_hooks": "rh", 12707 "repository_projects": "rp", 12708 "repository_pre_receive_hooks": "rprh", 12709 "secrets": "s", 12710 "secret_scanning_alerts": "ssa", 12711 "security_events": "se", 12712 "single_file": "sf", 12713 "statuses": "s", 12714 "team_discussions": "td", 12715 "vulnerability_alerts": "va", 12716 "workflows": "w" 12717 }, 12718 "created_at": ` + referenceTimeStr + `, 12719 "updated_at": ` + referenceTimeStr + `, 12720 "has_multiple_single_files": false, 12721 "suspended_by": { 12722 "login": "l", 12723 "id": 1, 12724 "avatar_url": "a", 12725 "gravatar_id": "g", 12726 "name": "n", 12727 "company": "c", 12728 "blog": "b", 12729 "location": "l", 12730 "email": "e", 12731 "hireable": true, 12732 "bio": "b", 12733 "twitter_username": "t", 12734 "public_repos": 1, 12735 "followers": 1, 12736 "following": 1, 12737 "created_at": ` + referenceTimeStr + `, 12738 "suspended_at": ` + referenceTimeStr + `, 12739 "url": "u" 12740 }, 12741 "suspended_at": ` + referenceTimeStr + ` 12742 } 12743 }` 12744 12745 testJSONMarshal(t, r, want) 12746 } 12747 12748 func TestDeployKeyEvent_Marshal(t *testing.T) { 12749 t.Parallel() 12750 testJSONMarshal(t, &DeployKeyEvent{}, "{}") 12751 12752 u := &DeployKeyEvent{ 12753 Action: String("a"), 12754 Key: &Key{ 12755 ID: Int64(1), 12756 Key: String("k"), 12757 URL: String("k"), 12758 Title: String("k"), 12759 ReadOnly: Bool(false), 12760 Verified: Bool(false), 12761 CreatedAt: &Timestamp{referenceTime}, 12762 }, 12763 Repo: &Repository{ 12764 ID: Int64(1), 12765 URL: String("s"), 12766 Name: String("n"), 12767 }, 12768 Organization: &Organization{ 12769 BillingEmail: String("be"), 12770 Blog: String("b"), 12771 Company: String("c"), 12772 Email: String("e"), 12773 TwitterUsername: String("tu"), 12774 Location: String("loc"), 12775 Name: String("n"), 12776 Description: String("d"), 12777 IsVerified: Bool(true), 12778 HasOrganizationProjects: Bool(true), 12779 HasRepositoryProjects: Bool(true), 12780 DefaultRepoPermission: String("drp"), 12781 MembersCanCreateRepos: Bool(true), 12782 MembersCanCreateInternalRepos: Bool(true), 12783 MembersCanCreatePrivateRepos: Bool(true), 12784 MembersCanCreatePublicRepos: Bool(false), 12785 MembersAllowedRepositoryCreationType: String("marct"), 12786 MembersCanCreatePages: Bool(true), 12787 MembersCanCreatePublicPages: Bool(false), 12788 MembersCanCreatePrivatePages: Bool(true), 12789 }, 12790 Sender: &User{ 12791 Login: String("l"), 12792 ID: Int64(1), 12793 NodeID: String("n"), 12794 AvatarURL: String("a"), 12795 URL: String("u"), 12796 EventsURL: String("e"), 12797 ReposURL: String("r"), 12798 }, 12799 } 12800 12801 want := `{ 12802 "action": "a", 12803 "key": { 12804 "id": 1, 12805 "key": "k", 12806 "url": "k", 12807 "title": "k", 12808 "read_only": false, 12809 "verified": false, 12810 "created_at": ` + referenceTimeStr + ` 12811 }, 12812 "repository": { 12813 "id": 1, 12814 "name": "n", 12815 "url": "s" 12816 }, 12817 "organization": { 12818 "name": "n", 12819 "company": "c", 12820 "blog": "b", 12821 "location": "loc", 12822 "email": "e", 12823 "twitter_username": "tu", 12824 "description": "d", 12825 "billing_email": "be", 12826 "is_verified": true, 12827 "has_organization_projects": true, 12828 "has_repository_projects": true, 12829 "default_repository_permission": "drp", 12830 "members_can_create_repositories": true, 12831 "members_can_create_public_repositories": false, 12832 "members_can_create_private_repositories": true, 12833 "members_can_create_internal_repositories": true, 12834 "members_allowed_repository_creation_type": "marct", 12835 "members_can_create_pages": true, 12836 "members_can_create_public_pages": false, 12837 "members_can_create_private_pages": true 12838 }, 12839 "sender": { 12840 "login": "l", 12841 "id": 1, 12842 "node_id": "n", 12843 "avatar_url": "a", 12844 "url": "u", 12845 "events_url": "e", 12846 "repos_url": "r" 12847 } 12848 }` 12849 12850 testJSONMarshal(t, u, want) 12851 } 12852 12853 func TestMetaEvent_Marshal(t *testing.T) { 12854 t.Parallel() 12855 testJSONMarshal(t, &MetaEvent{}, "{}") 12856 12857 v := make(map[string]interface{}) 12858 v["a"] = "b" 12859 hookConfig := &HookConfig{ 12860 ContentType: String("json"), 12861 } 12862 12863 u := &MetaEvent{ 12864 Action: String("a"), 12865 HookID: Int64(1), 12866 Hook: &Hook{ 12867 CreatedAt: &Timestamp{referenceTime}, 12868 UpdatedAt: &Timestamp{referenceTime}, 12869 URL: String("u"), 12870 ID: Int64(1), 12871 Type: String("t"), 12872 Name: String("n"), 12873 TestURL: String("tu"), 12874 PingURL: String("pu"), 12875 LastResponse: v, 12876 Config: hookConfig, 12877 Events: []string{"a"}, 12878 Active: Bool(true), 12879 }, 12880 } 12881 12882 want := `{ 12883 "action": "a", 12884 "hook_id": 1, 12885 "hook": { 12886 "created_at": ` + referenceTimeStr + `, 12887 "updated_at": ` + referenceTimeStr + `, 12888 "url": "u", 12889 "id": 1, 12890 "type": "t", 12891 "name": "n", 12892 "test_url": "tu", 12893 "ping_url": "pu", 12894 "last_response": { 12895 "a": "b" 12896 }, 12897 "config": { 12898 "content_type": "json" 12899 }, 12900 "events": [ 12901 "a" 12902 ], 12903 "active": true 12904 } 12905 }` 12906 12907 testJSONMarshal(t, u, want) 12908 } 12909 12910 func TestRequestedAction_Marshal(t *testing.T) { 12911 t.Parallel() 12912 testJSONMarshal(t, &RequestedAction{}, "{}") 12913 12914 r := &RequestedAction{ 12915 Identifier: "i", 12916 } 12917 12918 want := `{ 12919 "identifier": "i" 12920 }` 12921 12922 testJSONMarshal(t, r, want) 12923 } 12924 12925 func TestCreateEvent_Marshal(t *testing.T) { 12926 t.Parallel() 12927 testJSONMarshal(t, &CreateEvent{}, "{}") 12928 12929 r := &CreateEvent{ 12930 Ref: String("r"), 12931 RefType: String("rt"), 12932 MasterBranch: String("mb"), 12933 Description: String("d"), 12934 PusherType: String("pt"), 12935 Repo: &Repository{ 12936 ID: Int64(1), 12937 URL: String("s"), 12938 Name: String("n"), 12939 }, 12940 Sender: &User{ 12941 Login: String("l"), 12942 ID: Int64(1), 12943 NodeID: String("n"), 12944 URL: String("u"), 12945 ReposURL: String("r"), 12946 EventsURL: String("e"), 12947 AvatarURL: String("a"), 12948 }, 12949 Installation: &Installation{ 12950 ID: Int64(1), 12951 NodeID: String("nid"), 12952 AppID: Int64(1), 12953 AppSlug: String("as"), 12954 TargetID: Int64(1), 12955 Account: &User{ 12956 Login: String("l"), 12957 ID: Int64(1), 12958 URL: String("u"), 12959 AvatarURL: String("a"), 12960 GravatarID: String("g"), 12961 Name: String("n"), 12962 Company: String("c"), 12963 Blog: String("b"), 12964 Location: String("l"), 12965 Email: String("e"), 12966 Hireable: Bool(true), 12967 Bio: String("b"), 12968 TwitterUsername: String("t"), 12969 PublicRepos: Int(1), 12970 Followers: Int(1), 12971 Following: Int(1), 12972 CreatedAt: &Timestamp{referenceTime}, 12973 SuspendedAt: &Timestamp{referenceTime}, 12974 }, 12975 AccessTokensURL: String("atu"), 12976 RepositoriesURL: String("ru"), 12977 HTMLURL: String("hu"), 12978 TargetType: String("tt"), 12979 SingleFileName: String("sfn"), 12980 RepositorySelection: String("rs"), 12981 Events: []string{"e"}, 12982 SingleFilePaths: []string{"s"}, 12983 Permissions: &InstallationPermissions{ 12984 Actions: String("a"), 12985 Administration: String("ad"), 12986 Checks: String("c"), 12987 Contents: String("co"), 12988 ContentReferences: String("cr"), 12989 Deployments: String("d"), 12990 Environments: String("e"), 12991 Issues: String("i"), 12992 Metadata: String("md"), 12993 Members: String("m"), 12994 OrganizationAdministration: String("oa"), 12995 OrganizationHooks: String("oh"), 12996 OrganizationPlan: String("op"), 12997 OrganizationPreReceiveHooks: String("opr"), 12998 OrganizationProjects: String("op"), 12999 OrganizationSecrets: String("os"), 13000 OrganizationSelfHostedRunners: String("osh"), 13001 OrganizationUserBlocking: String("oub"), 13002 Packages: String("pkg"), 13003 Pages: String("pg"), 13004 PullRequests: String("pr"), 13005 RepositoryHooks: String("rh"), 13006 RepositoryProjects: String("rp"), 13007 RepositoryPreReceiveHooks: String("rprh"), 13008 Secrets: String("s"), 13009 SecretScanningAlerts: String("ssa"), 13010 SecurityEvents: String("se"), 13011 SingleFile: String("sf"), 13012 Statuses: String("s"), 13013 TeamDiscussions: String("td"), 13014 VulnerabilityAlerts: String("va"), 13015 Workflows: String("w"), 13016 }, 13017 CreatedAt: &Timestamp{referenceTime}, 13018 UpdatedAt: &Timestamp{referenceTime}, 13019 HasMultipleSingleFiles: Bool(false), 13020 SuspendedBy: &User{ 13021 Login: String("l"), 13022 ID: Int64(1), 13023 URL: String("u"), 13024 AvatarURL: String("a"), 13025 GravatarID: String("g"), 13026 Name: String("n"), 13027 Company: String("c"), 13028 Blog: String("b"), 13029 Location: String("l"), 13030 Email: String("e"), 13031 Hireable: Bool(true), 13032 Bio: String("b"), 13033 TwitterUsername: String("t"), 13034 PublicRepos: Int(1), 13035 Followers: Int(1), 13036 Following: Int(1), 13037 CreatedAt: &Timestamp{referenceTime}, 13038 SuspendedAt: &Timestamp{referenceTime}, 13039 }, 13040 SuspendedAt: &Timestamp{referenceTime}, 13041 }, 13042 } 13043 13044 want := `{ 13045 "ref": "r", 13046 "ref_type": "rt", 13047 "master_branch": "mb", 13048 "description": "d", 13049 "pusher_type": "pt", 13050 "repository": { 13051 "id": 1, 13052 "name": "n", 13053 "url": "s" 13054 }, 13055 "sender": { 13056 "login": "l", 13057 "id": 1, 13058 "node_id": "n", 13059 "avatar_url": "a", 13060 "url": "u", 13061 "events_url": "e", 13062 "repos_url": "r" 13063 }, 13064 "installation": { 13065 "id": 1, 13066 "node_id": "nid", 13067 "app_id": 1, 13068 "app_slug": "as", 13069 "target_id": 1, 13070 "account": { 13071 "login": "l", 13072 "id": 1, 13073 "avatar_url": "a", 13074 "gravatar_id": "g", 13075 "name": "n", 13076 "company": "c", 13077 "blog": "b", 13078 "location": "l", 13079 "email": "e", 13080 "hireable": true, 13081 "bio": "b", 13082 "twitter_username": "t", 13083 "public_repos": 1, 13084 "followers": 1, 13085 "following": 1, 13086 "created_at": ` + referenceTimeStr + `, 13087 "suspended_at": ` + referenceTimeStr + `, 13088 "url": "u" 13089 }, 13090 "access_tokens_url": "atu", 13091 "repositories_url": "ru", 13092 "html_url": "hu", 13093 "target_type": "tt", 13094 "single_file_name": "sfn", 13095 "repository_selection": "rs", 13096 "events": [ 13097 "e" 13098 ], 13099 "single_file_paths": [ 13100 "s" 13101 ], 13102 "permissions": { 13103 "actions": "a", 13104 "administration": "ad", 13105 "checks": "c", 13106 "contents": "co", 13107 "content_references": "cr", 13108 "deployments": "d", 13109 "environments": "e", 13110 "issues": "i", 13111 "metadata": "md", 13112 "members": "m", 13113 "organization_administration": "oa", 13114 "organization_hooks": "oh", 13115 "organization_plan": "op", 13116 "organization_pre_receive_hooks": "opr", 13117 "organization_projects": "op", 13118 "organization_secrets": "os", 13119 "organization_self_hosted_runners": "osh", 13120 "organization_user_blocking": "oub", 13121 "packages": "pkg", 13122 "pages": "pg", 13123 "pull_requests": "pr", 13124 "repository_hooks": "rh", 13125 "repository_projects": "rp", 13126 "repository_pre_receive_hooks": "rprh", 13127 "secrets": "s", 13128 "secret_scanning_alerts": "ssa", 13129 "security_events": "se", 13130 "single_file": "sf", 13131 "statuses": "s", 13132 "team_discussions": "td", 13133 "vulnerability_alerts": "va", 13134 "workflows": "w" 13135 }, 13136 "created_at": ` + referenceTimeStr + `, 13137 "updated_at": ` + referenceTimeStr + `, 13138 "has_multiple_single_files": false, 13139 "suspended_by": { 13140 "login": "l", 13141 "id": 1, 13142 "avatar_url": "a", 13143 "gravatar_id": "g", 13144 "name": "n", 13145 "company": "c", 13146 "blog": "b", 13147 "location": "l", 13148 "email": "e", 13149 "hireable": true, 13150 "bio": "b", 13151 "twitter_username": "t", 13152 "public_repos": 1, 13153 "followers": 1, 13154 "following": 1, 13155 "created_at": ` + referenceTimeStr + `, 13156 "suspended_at": ` + referenceTimeStr + `, 13157 "url": "u" 13158 }, 13159 "suspended_at": ` + referenceTimeStr + ` 13160 } 13161 }` 13162 13163 testJSONMarshal(t, r, want) 13164 } 13165 13166 func TestDeleteEvent_Marshal(t *testing.T) { 13167 t.Parallel() 13168 testJSONMarshal(t, &DeleteEvent{}, "{}") 13169 13170 r := &DeleteEvent{ 13171 Ref: String("r"), 13172 RefType: String("rt"), 13173 PusherType: String("pt"), 13174 Repo: &Repository{ 13175 ID: Int64(1), 13176 URL: String("s"), 13177 Name: String("n"), 13178 }, 13179 Sender: &User{ 13180 Login: String("l"), 13181 ID: Int64(1), 13182 NodeID: String("n"), 13183 URL: String("u"), 13184 ReposURL: String("r"), 13185 EventsURL: String("e"), 13186 AvatarURL: String("a"), 13187 }, 13188 Installation: &Installation{ 13189 ID: Int64(1), 13190 NodeID: String("nid"), 13191 AppID: Int64(1), 13192 AppSlug: String("as"), 13193 TargetID: Int64(1), 13194 Account: &User{ 13195 Login: String("l"), 13196 ID: Int64(1), 13197 URL: String("u"), 13198 AvatarURL: String("a"), 13199 GravatarID: String("g"), 13200 Name: String("n"), 13201 Company: String("c"), 13202 Blog: String("b"), 13203 Location: String("l"), 13204 Email: String("e"), 13205 Hireable: Bool(true), 13206 Bio: String("b"), 13207 TwitterUsername: String("t"), 13208 PublicRepos: Int(1), 13209 Followers: Int(1), 13210 Following: Int(1), 13211 CreatedAt: &Timestamp{referenceTime}, 13212 SuspendedAt: &Timestamp{referenceTime}, 13213 }, 13214 AccessTokensURL: String("atu"), 13215 RepositoriesURL: String("ru"), 13216 HTMLURL: String("hu"), 13217 TargetType: String("tt"), 13218 SingleFileName: String("sfn"), 13219 RepositorySelection: String("rs"), 13220 Events: []string{"e"}, 13221 SingleFilePaths: []string{"s"}, 13222 Permissions: &InstallationPermissions{ 13223 Actions: String("a"), 13224 Administration: String("ad"), 13225 Checks: String("c"), 13226 Contents: String("co"), 13227 ContentReferences: String("cr"), 13228 Deployments: String("d"), 13229 Environments: String("e"), 13230 Issues: String("i"), 13231 Metadata: String("md"), 13232 Members: String("m"), 13233 OrganizationAdministration: String("oa"), 13234 OrganizationHooks: String("oh"), 13235 OrganizationPlan: String("op"), 13236 OrganizationPreReceiveHooks: String("opr"), 13237 OrganizationProjects: String("op"), 13238 OrganizationSecrets: String("os"), 13239 OrganizationSelfHostedRunners: String("osh"), 13240 OrganizationUserBlocking: String("oub"), 13241 Packages: String("pkg"), 13242 Pages: String("pg"), 13243 PullRequests: String("pr"), 13244 RepositoryHooks: String("rh"), 13245 RepositoryProjects: String("rp"), 13246 RepositoryPreReceiveHooks: String("rprh"), 13247 Secrets: String("s"), 13248 SecretScanningAlerts: String("ssa"), 13249 SecurityEvents: String("se"), 13250 SingleFile: String("sf"), 13251 Statuses: String("s"), 13252 TeamDiscussions: String("td"), 13253 VulnerabilityAlerts: String("va"), 13254 Workflows: String("w"), 13255 }, 13256 CreatedAt: &Timestamp{referenceTime}, 13257 UpdatedAt: &Timestamp{referenceTime}, 13258 HasMultipleSingleFiles: Bool(false), 13259 SuspendedBy: &User{ 13260 Login: String("l"), 13261 ID: Int64(1), 13262 URL: String("u"), 13263 AvatarURL: String("a"), 13264 GravatarID: String("g"), 13265 Name: String("n"), 13266 Company: String("c"), 13267 Blog: String("b"), 13268 Location: String("l"), 13269 Email: String("e"), 13270 Hireable: Bool(true), 13271 Bio: String("b"), 13272 TwitterUsername: String("t"), 13273 PublicRepos: Int(1), 13274 Followers: Int(1), 13275 Following: Int(1), 13276 CreatedAt: &Timestamp{referenceTime}, 13277 SuspendedAt: &Timestamp{referenceTime}, 13278 }, 13279 SuspendedAt: &Timestamp{referenceTime}, 13280 }, 13281 } 13282 13283 want := `{ 13284 "ref": "r", 13285 "ref_type": "rt", 13286 "pusher_type": "pt", 13287 "repository": { 13288 "id": 1, 13289 "name": "n", 13290 "url": "s" 13291 }, 13292 "sender": { 13293 "login": "l", 13294 "id": 1, 13295 "node_id": "n", 13296 "avatar_url": "a", 13297 "url": "u", 13298 "events_url": "e", 13299 "repos_url": "r" 13300 }, 13301 "installation": { 13302 "id": 1, 13303 "node_id": "nid", 13304 "app_id": 1, 13305 "app_slug": "as", 13306 "target_id": 1, 13307 "account": { 13308 "login": "l", 13309 "id": 1, 13310 "avatar_url": "a", 13311 "gravatar_id": "g", 13312 "name": "n", 13313 "company": "c", 13314 "blog": "b", 13315 "location": "l", 13316 "email": "e", 13317 "hireable": true, 13318 "bio": "b", 13319 "twitter_username": "t", 13320 "public_repos": 1, 13321 "followers": 1, 13322 "following": 1, 13323 "created_at": ` + referenceTimeStr + `, 13324 "suspended_at": ` + referenceTimeStr + `, 13325 "url": "u" 13326 }, 13327 "access_tokens_url": "atu", 13328 "repositories_url": "ru", 13329 "html_url": "hu", 13330 "target_type": "tt", 13331 "single_file_name": "sfn", 13332 "repository_selection": "rs", 13333 "events": [ 13334 "e" 13335 ], 13336 "single_file_paths": [ 13337 "s" 13338 ], 13339 "permissions": { 13340 "actions": "a", 13341 "administration": "ad", 13342 "checks": "c", 13343 "contents": "co", 13344 "content_references": "cr", 13345 "deployments": "d", 13346 "environments": "e", 13347 "issues": "i", 13348 "metadata": "md", 13349 "members": "m", 13350 "organization_administration": "oa", 13351 "organization_hooks": "oh", 13352 "organization_plan": "op", 13353 "organization_pre_receive_hooks": "opr", 13354 "organization_projects": "op", 13355 "organization_secrets": "os", 13356 "organization_self_hosted_runners": "osh", 13357 "organization_user_blocking": "oub", 13358 "packages": "pkg", 13359 "pages": "pg", 13360 "pull_requests": "pr", 13361 "repository_hooks": "rh", 13362 "repository_projects": "rp", 13363 "repository_pre_receive_hooks": "rprh", 13364 "secrets": "s", 13365 "secret_scanning_alerts": "ssa", 13366 "security_events": "se", 13367 "single_file": "sf", 13368 "statuses": "s", 13369 "team_discussions": "td", 13370 "vulnerability_alerts": "va", 13371 "workflows": "w" 13372 }, 13373 "created_at": ` + referenceTimeStr + `, 13374 "updated_at": ` + referenceTimeStr + `, 13375 "has_multiple_single_files": false, 13376 "suspended_by": { 13377 "login": "l", 13378 "id": 1, 13379 "avatar_url": "a", 13380 "gravatar_id": "g", 13381 "name": "n", 13382 "company": "c", 13383 "blog": "b", 13384 "location": "l", 13385 "email": "e", 13386 "hireable": true, 13387 "bio": "b", 13388 "twitter_username": "t", 13389 "public_repos": 1, 13390 "followers": 1, 13391 "following": 1, 13392 "created_at": ` + referenceTimeStr + `, 13393 "suspended_at": ` + referenceTimeStr + `, 13394 "url": "u" 13395 }, 13396 "suspended_at": ` + referenceTimeStr + ` 13397 } 13398 }` 13399 13400 testJSONMarshal(t, r, want) 13401 } 13402 13403 func TestDependabotAlertEvent_Marshal(t *testing.T) { 13404 t.Parallel() 13405 testJSONMarshal(t, &DependabotAlertEvent{}, "{}") 13406 13407 e := &DependabotAlertEvent{ 13408 Action: String("a"), 13409 Alert: &DependabotAlert{ 13410 Number: Int(1), 13411 State: String("s"), 13412 Dependency: &Dependency{ 13413 Package: &VulnerabilityPackage{ 13414 Ecosystem: String("e"), 13415 Name: String("n"), 13416 }, 13417 ManifestPath: String("mp"), 13418 Scope: String("s"), 13419 }, 13420 SecurityAdvisory: &DependabotSecurityAdvisory{ 13421 GHSAID: String("ghsaid"), 13422 CVEID: String("cveid"), 13423 Summary: String("s"), 13424 Description: String("d"), 13425 Vulnerabilities: []*AdvisoryVulnerability{ 13426 { 13427 Package: &VulnerabilityPackage{ 13428 Ecosystem: String("e"), 13429 Name: String("n"), 13430 }, 13431 Severity: String("s"), 13432 }, 13433 }, 13434 Severity: String("s"), 13435 CVSS: &AdvisoryCVSS{ 13436 Score: Float64(1.0), 13437 VectorString: String("vs"), 13438 }, 13439 CWEs: []*AdvisoryCWEs{ 13440 { 13441 CWEID: String("cweid"), 13442 Name: String("n"), 13443 }, 13444 }, 13445 Identifiers: []*AdvisoryIdentifier{ 13446 { 13447 Value: String("v"), 13448 Type: String("t"), 13449 }, 13450 }, 13451 References: []*AdvisoryReference{ 13452 { 13453 URL: String("u"), 13454 }, 13455 }, 13456 PublishedAt: &Timestamp{referenceTime}, 13457 UpdatedAt: &Timestamp{referenceTime}, 13458 WithdrawnAt: &Timestamp{referenceTime}, 13459 }, 13460 SecurityVulnerability: &AdvisoryVulnerability{ 13461 Package: &VulnerabilityPackage{ 13462 Ecosystem: String("e"), 13463 Name: String("n"), 13464 }, 13465 Severity: String("s"), 13466 VulnerableVersionRange: String("vvr"), 13467 FirstPatchedVersion: &FirstPatchedVersion{ 13468 Identifier: String("i"), 13469 }, 13470 }, 13471 URL: String("u"), 13472 HTMLURL: String("hu"), 13473 CreatedAt: &Timestamp{referenceTime}, 13474 UpdatedAt: &Timestamp{referenceTime}, 13475 DismissedAt: &Timestamp{referenceTime}, 13476 DismissedBy: &User{ 13477 Login: String("l"), 13478 ID: Int64(1), 13479 NodeID: String("n"), 13480 URL: String("u"), 13481 ReposURL: String("r"), 13482 EventsURL: String("e"), 13483 AvatarURL: String("a"), 13484 }, 13485 DismissedReason: String("dr"), 13486 DismissedComment: String("dc"), 13487 FixedAt: &Timestamp{referenceTime}, 13488 AutoDismissedAt: &Timestamp{referenceTime}, 13489 }, 13490 Repo: &Repository{ 13491 ID: Int64(1), 13492 URL: String("s"), 13493 Name: String("n"), 13494 }, 13495 Organization: &Organization{ 13496 BillingEmail: String("be"), 13497 Blog: String("b"), 13498 Company: String("c"), 13499 Email: String("e"), 13500 TwitterUsername: String("tu"), 13501 Location: String("loc"), 13502 Name: String("n"), 13503 Description: String("d"), 13504 IsVerified: Bool(true), 13505 HasOrganizationProjects: Bool(true), 13506 HasRepositoryProjects: Bool(true), 13507 DefaultRepoPermission: String("drp"), 13508 MembersCanCreateRepos: Bool(true), 13509 MembersCanCreateInternalRepos: Bool(true), 13510 MembersCanCreatePrivateRepos: Bool(true), 13511 MembersCanCreatePublicRepos: Bool(false), 13512 MembersAllowedRepositoryCreationType: String("marct"), 13513 MembersCanCreatePages: Bool(true), 13514 MembersCanCreatePublicPages: Bool(false), 13515 MembersCanCreatePrivatePages: Bool(true), 13516 }, 13517 Enterprise: &Enterprise{ 13518 ID: Int(1), 13519 Slug: String("s"), 13520 Name: String("n"), 13521 NodeID: String("nid"), 13522 AvatarURL: String("au"), 13523 Description: String("d"), 13524 WebsiteURL: String("wu"), 13525 HTMLURL: String("hu"), 13526 CreatedAt: &Timestamp{referenceTime}, 13527 UpdatedAt: &Timestamp{referenceTime}, 13528 }, 13529 Sender: &User{ 13530 Login: String("l"), 13531 ID: Int64(1), 13532 NodeID: String("n"), 13533 URL: String("u"), 13534 ReposURL: String("r"), 13535 EventsURL: String("e"), 13536 AvatarURL: String("a"), 13537 }, 13538 Installation: &Installation{ 13539 ID: Int64(1), 13540 NodeID: String("nid"), 13541 AppID: Int64(1), 13542 AppSlug: String("as"), 13543 TargetID: Int64(1), 13544 Account: &User{ 13545 Login: String("l"), 13546 ID: Int64(1), 13547 URL: String("u"), 13548 AvatarURL: String("a"), 13549 GravatarID: String("g"), 13550 Name: String("n"), 13551 Company: String("c"), 13552 Blog: String("b"), 13553 Location: String("l"), 13554 Email: String("e"), 13555 Hireable: Bool(true), 13556 Bio: String("b"), 13557 TwitterUsername: String("t"), 13558 PublicRepos: Int(1), 13559 Followers: Int(1), 13560 Following: Int(1), 13561 CreatedAt: &Timestamp{referenceTime}, 13562 SuspendedAt: &Timestamp{referenceTime}, 13563 }, 13564 AccessTokensURL: String("atu"), 13565 RepositoriesURL: String("ru"), 13566 HTMLURL: String("hu"), 13567 TargetType: String("tt"), 13568 SingleFileName: String("sfn"), 13569 RepositorySelection: String("rs"), 13570 Events: []string{"e"}, 13571 SingleFilePaths: []string{"s"}, 13572 Permissions: &InstallationPermissions{ 13573 Actions: String("a"), 13574 Administration: String("ad"), 13575 Checks: String("c"), 13576 Contents: String("co"), 13577 ContentReferences: String("cr"), 13578 Deployments: String("d"), 13579 Environments: String("e"), 13580 Issues: String("i"), 13581 Metadata: String("md"), 13582 Members: String("m"), 13583 OrganizationAdministration: String("oa"), 13584 OrganizationHooks: String("oh"), 13585 OrganizationPlan: String("op"), 13586 OrganizationPreReceiveHooks: String("opr"), 13587 OrganizationProjects: String("op"), 13588 OrganizationSecrets: String("os"), 13589 OrganizationSelfHostedRunners: String("osh"), 13590 OrganizationUserBlocking: String("oub"), 13591 Packages: String("pkg"), 13592 Pages: String("pg"), 13593 PullRequests: String("pr"), 13594 RepositoryHooks: String("rh"), 13595 RepositoryProjects: String("rp"), 13596 RepositoryPreReceiveHooks: String("rprh"), 13597 Secrets: String("s"), 13598 SecretScanningAlerts: String("ssa"), 13599 SecurityEvents: String("se"), 13600 SingleFile: String("sf"), 13601 Statuses: String("s"), 13602 TeamDiscussions: String("td"), 13603 VulnerabilityAlerts: String("va"), 13604 Workflows: String("w"), 13605 }, 13606 CreatedAt: &Timestamp{referenceTime}, 13607 UpdatedAt: &Timestamp{referenceTime}, 13608 HasMultipleSingleFiles: Bool(false), 13609 SuspendedBy: &User{ 13610 Login: String("l"), 13611 ID: Int64(1), 13612 URL: String("u"), 13613 AvatarURL: String("a"), 13614 GravatarID: String("g"), 13615 Name: String("n"), 13616 Company: String("c"), 13617 Blog: String("b"), 13618 Location: String("l"), 13619 Email: String("e"), 13620 Hireable: Bool(true), 13621 Bio: String("b"), 13622 TwitterUsername: String("t"), 13623 PublicRepos: Int(1), 13624 Followers: Int(1), 13625 Following: Int(1), 13626 CreatedAt: &Timestamp{referenceTime}, 13627 SuspendedAt: &Timestamp{referenceTime}, 13628 }, 13629 SuspendedAt: &Timestamp{referenceTime}, 13630 }, 13631 } 13632 want := `{ 13633 "action": "a", 13634 "alert": { 13635 "number": 1, 13636 "state": "s", 13637 "dependency": { 13638 "package": { 13639 "ecosystem": "e", 13640 "name": "n" 13641 }, 13642 "manifest_path": "mp", 13643 "scope": "s" 13644 }, 13645 "security_advisory": { 13646 "ghsa_id": "ghsaid", 13647 "cve_id": "cveid", 13648 "summary": "s", 13649 "description": "d", 13650 "vulnerabilities": [ 13651 { 13652 "package": { 13653 "ecosystem": "e", 13654 "name": "n" 13655 }, 13656 "severity": "s" 13657 } 13658 ], 13659 "severity": "s", 13660 "cvss": { 13661 "score": 1.0, 13662 "vector_string": "vs" 13663 }, 13664 "cwes": [ 13665 { 13666 "cwe_id": "cweid", 13667 "name": "n" 13668 } 13669 ], 13670 "identifiers": [ 13671 { 13672 "value": "v", 13673 "type": "t" 13674 } 13675 ], 13676 "references": [ 13677 { 13678 "url": "u" 13679 } 13680 ], 13681 "published_at": ` + referenceTimeStr + `, 13682 "updated_at": ` + referenceTimeStr + `, 13683 "withdrawn_at": ` + referenceTimeStr + ` 13684 }, 13685 "security_vulnerability": { 13686 "package": { 13687 "ecosystem": "e", 13688 "name": "n" 13689 }, 13690 "severity": "s", 13691 "vulnerable_version_range": "vvr", 13692 "first_patched_version": { 13693 "identifier": "i" 13694 } 13695 }, 13696 "url": "u", 13697 "html_url": "hu", 13698 "created_at": ` + referenceTimeStr + `, 13699 "updated_at": ` + referenceTimeStr + `, 13700 "dismissed_at": ` + referenceTimeStr + `, 13701 "dismissed_by": { 13702 "login": "l", 13703 "id": 1, 13704 "node_id": "n", 13705 "avatar_url": "a", 13706 "url": "u", 13707 "events_url": "e", 13708 "repos_url": "r" 13709 }, 13710 "dismissed_reason": "dr", 13711 "dismissed_comment": "dc", 13712 "fixed_at": ` + referenceTimeStr + `, 13713 "auto_dismissed_at": ` + referenceTimeStr + ` 13714 }, 13715 "repository": { 13716 "id": 1, 13717 "name": "n", 13718 "url": "s" 13719 }, 13720 "organization": { 13721 "name": "n", 13722 "company": "c", 13723 "blog": "b", 13724 "location": "loc", 13725 "email": "e", 13726 "twitter_username": "tu", 13727 "description": "d", 13728 "billing_email": "be", 13729 "is_verified": true, 13730 "has_organization_projects": true, 13731 "has_repository_projects": true, 13732 "default_repository_permission": "drp", 13733 "members_can_create_repositories": true, 13734 "members_can_create_public_repositories": false, 13735 "members_can_create_private_repositories": true, 13736 "members_can_create_internal_repositories": true, 13737 "members_allowed_repository_creation_type": "marct", 13738 "members_can_create_pages": true, 13739 "members_can_create_public_pages": false, 13740 "members_can_create_private_pages": true 13741 }, 13742 "enterprise": { 13743 "id": 1, 13744 "slug": "s", 13745 "name": "n", 13746 "node_id": "nid", 13747 "avatar_url": "au", 13748 "description": "d", 13749 "website_url": "wu", 13750 "html_url": "hu", 13751 "created_at": ` + referenceTimeStr + `, 13752 "updated_at": ` + referenceTimeStr + ` 13753 }, 13754 "sender": { 13755 "login": "l", 13756 "id": 1, 13757 "node_id": "n", 13758 "avatar_url": "a", 13759 "url": "u", 13760 "events_url": "e", 13761 "repos_url": "r" 13762 }, 13763 "installation": { 13764 "id": 1, 13765 "node_id": "nid", 13766 "app_id": 1, 13767 "app_slug": "as", 13768 "target_id": 1, 13769 "account": { 13770 "login": "l", 13771 "id": 1, 13772 "avatar_url": "a", 13773 "gravatar_id": "g", 13774 "name": "n", 13775 "company": "c", 13776 "blog": "b", 13777 "location": "l", 13778 "email": "e", 13779 "hireable": true, 13780 "bio": "b", 13781 "twitter_username": "t", 13782 "public_repos": 1, 13783 "followers": 1, 13784 "following": 1, 13785 "created_at": ` + referenceTimeStr + `, 13786 "suspended_at": ` + referenceTimeStr + `, 13787 "url": "u" 13788 }, 13789 "access_tokens_url": "atu", 13790 "repositories_url": "ru", 13791 "html_url": "hu", 13792 "target_type": "tt", 13793 "single_file_name": "sfn", 13794 "repository_selection": "rs", 13795 "events": [ 13796 "e" 13797 ], 13798 "single_file_paths": [ 13799 "s" 13800 ], 13801 "permissions": { 13802 "actions": "a", 13803 "administration": "ad", 13804 "checks": "c", 13805 "contents": "co", 13806 "content_references": "cr", 13807 "deployments": "d", 13808 "environments": "e", 13809 "issues": "i", 13810 "metadata": "md", 13811 "members": "m", 13812 "organization_administration": "oa", 13813 "organization_hooks": "oh", 13814 "organization_plan": "op", 13815 "organization_pre_receive_hooks": "opr", 13816 "organization_projects": "op", 13817 "organization_secrets": "os", 13818 "organization_self_hosted_runners": "osh", 13819 "organization_user_blocking": "oub", 13820 "packages": "pkg", 13821 "pages": "pg", 13822 "pull_requests": "pr", 13823 "repository_hooks": "rh", 13824 "repository_projects": "rp", 13825 "repository_pre_receive_hooks": "rprh", 13826 "secrets": "s", 13827 "secret_scanning_alerts": "ssa", 13828 "security_events": "se", 13829 "single_file": "sf", 13830 "statuses": "s", 13831 "team_discussions": "td", 13832 "vulnerability_alerts": "va", 13833 "workflows": "w" 13834 }, 13835 "created_at": ` + referenceTimeStr + `, 13836 "updated_at": ` + referenceTimeStr + `, 13837 "has_multiple_single_files": false, 13838 "suspended_by": { 13839 "login": "l", 13840 "id": 1, 13841 "avatar_url": "a", 13842 "gravatar_id": "g", 13843 "name": "n", 13844 "company": "c", 13845 "blog": "b", 13846 "location": "l", 13847 "email": "e", 13848 "hireable": true, 13849 "bio": "b", 13850 "twitter_username": "t", 13851 "public_repos": 1, 13852 "followers": 1, 13853 "following": 1, 13854 "created_at": ` + referenceTimeStr + `, 13855 "suspended_at": ` + referenceTimeStr + `, 13856 "url": "u" 13857 }, 13858 "suspended_at": ` + referenceTimeStr + ` 13859 } 13860 }` 13861 13862 testJSONMarshal(t, e, want) 13863 } 13864 13865 func TestForkEvent_Marshal(t *testing.T) { 13866 t.Parallel() 13867 testJSONMarshal(t, &ForkEvent{}, "{}") 13868 13869 u := &ForkEvent{ 13870 Forkee: &Repository{ 13871 ID: Int64(1), 13872 URL: String("s"), 13873 Name: String("n"), 13874 }, 13875 Repo: &Repository{ 13876 ID: Int64(1), 13877 URL: String("s"), 13878 Name: String("n"), 13879 }, 13880 Sender: &User{ 13881 Login: String("l"), 13882 ID: Int64(1), 13883 NodeID: String("n"), 13884 URL: String("u"), 13885 ReposURL: String("r"), 13886 EventsURL: String("e"), 13887 AvatarURL: String("a"), 13888 }, 13889 Installation: &Installation{ 13890 ID: Int64(1), 13891 NodeID: String("nid"), 13892 AppID: Int64(1), 13893 AppSlug: String("as"), 13894 TargetID: Int64(1), 13895 Account: &User{ 13896 Login: String("l"), 13897 ID: Int64(1), 13898 URL: String("u"), 13899 AvatarURL: String("a"), 13900 GravatarID: String("g"), 13901 Name: String("n"), 13902 Company: String("c"), 13903 Blog: String("b"), 13904 Location: String("l"), 13905 Email: String("e"), 13906 Hireable: Bool(true), 13907 Bio: String("b"), 13908 TwitterUsername: String("t"), 13909 PublicRepos: Int(1), 13910 Followers: Int(1), 13911 Following: Int(1), 13912 CreatedAt: &Timestamp{referenceTime}, 13913 SuspendedAt: &Timestamp{referenceTime}, 13914 }, 13915 AccessTokensURL: String("atu"), 13916 RepositoriesURL: String("ru"), 13917 HTMLURL: String("hu"), 13918 TargetType: String("tt"), 13919 SingleFileName: String("sfn"), 13920 RepositorySelection: String("rs"), 13921 Events: []string{"e"}, 13922 SingleFilePaths: []string{"s"}, 13923 Permissions: &InstallationPermissions{ 13924 Actions: String("a"), 13925 Administration: String("ad"), 13926 Checks: String("c"), 13927 Contents: String("co"), 13928 ContentReferences: String("cr"), 13929 Deployments: String("d"), 13930 Environments: String("e"), 13931 Issues: String("i"), 13932 Metadata: String("md"), 13933 Members: String("m"), 13934 OrganizationAdministration: String("oa"), 13935 OrganizationHooks: String("oh"), 13936 OrganizationPlan: String("op"), 13937 OrganizationPreReceiveHooks: String("opr"), 13938 OrganizationProjects: String("op"), 13939 OrganizationSecrets: String("os"), 13940 OrganizationSelfHostedRunners: String("osh"), 13941 OrganizationUserBlocking: String("oub"), 13942 Packages: String("pkg"), 13943 Pages: String("pg"), 13944 PullRequests: String("pr"), 13945 RepositoryHooks: String("rh"), 13946 RepositoryProjects: String("rp"), 13947 RepositoryPreReceiveHooks: String("rprh"), 13948 Secrets: String("s"), 13949 SecretScanningAlerts: String("ssa"), 13950 SecurityEvents: String("se"), 13951 SingleFile: String("sf"), 13952 Statuses: String("s"), 13953 TeamDiscussions: String("td"), 13954 VulnerabilityAlerts: String("va"), 13955 Workflows: String("w"), 13956 }, 13957 CreatedAt: &Timestamp{referenceTime}, 13958 UpdatedAt: &Timestamp{referenceTime}, 13959 HasMultipleSingleFiles: Bool(false), 13960 SuspendedBy: &User{ 13961 Login: String("l"), 13962 ID: Int64(1), 13963 URL: String("u"), 13964 AvatarURL: String("a"), 13965 GravatarID: String("g"), 13966 Name: String("n"), 13967 Company: String("c"), 13968 Blog: String("b"), 13969 Location: String("l"), 13970 Email: String("e"), 13971 Hireable: Bool(true), 13972 Bio: String("b"), 13973 TwitterUsername: String("t"), 13974 PublicRepos: Int(1), 13975 Followers: Int(1), 13976 Following: Int(1), 13977 CreatedAt: &Timestamp{referenceTime}, 13978 SuspendedAt: &Timestamp{referenceTime}, 13979 }, 13980 SuspendedAt: &Timestamp{referenceTime}, 13981 }, 13982 } 13983 13984 want := `{ 13985 "forkee": { 13986 "id": 1, 13987 "name": "n", 13988 "url": "s" 13989 }, 13990 "repository": { 13991 "id": 1, 13992 "name": "n", 13993 "url": "s" 13994 }, 13995 "sender": { 13996 "login": "l", 13997 "id": 1, 13998 "node_id": "n", 13999 "avatar_url": "a", 14000 "url": "u", 14001 "events_url": "e", 14002 "repos_url": "r" 14003 }, 14004 "installation": { 14005 "id": 1, 14006 "node_id": "nid", 14007 "app_id": 1, 14008 "app_slug": "as", 14009 "target_id": 1, 14010 "account": { 14011 "login": "l", 14012 "id": 1, 14013 "avatar_url": "a", 14014 "gravatar_id": "g", 14015 "name": "n", 14016 "company": "c", 14017 "blog": "b", 14018 "location": "l", 14019 "email": "e", 14020 "hireable": true, 14021 "bio": "b", 14022 "twitter_username": "t", 14023 "public_repos": 1, 14024 "followers": 1, 14025 "following": 1, 14026 "created_at": ` + referenceTimeStr + `, 14027 "suspended_at": ` + referenceTimeStr + `, 14028 "url": "u" 14029 }, 14030 "access_tokens_url": "atu", 14031 "repositories_url": "ru", 14032 "html_url": "hu", 14033 "target_type": "tt", 14034 "single_file_name": "sfn", 14035 "repository_selection": "rs", 14036 "events": [ 14037 "e" 14038 ], 14039 "single_file_paths": [ 14040 "s" 14041 ], 14042 "permissions": { 14043 "actions": "a", 14044 "administration": "ad", 14045 "checks": "c", 14046 "contents": "co", 14047 "content_references": "cr", 14048 "deployments": "d", 14049 "environments": "e", 14050 "issues": "i", 14051 "metadata": "md", 14052 "members": "m", 14053 "organization_administration": "oa", 14054 "organization_hooks": "oh", 14055 "organization_plan": "op", 14056 "organization_pre_receive_hooks": "opr", 14057 "organization_projects": "op", 14058 "organization_secrets": "os", 14059 "organization_self_hosted_runners": "osh", 14060 "organization_user_blocking": "oub", 14061 "packages": "pkg", 14062 "pages": "pg", 14063 "pull_requests": "pr", 14064 "repository_hooks": "rh", 14065 "repository_projects": "rp", 14066 "repository_pre_receive_hooks": "rprh", 14067 "secrets": "s", 14068 "secret_scanning_alerts": "ssa", 14069 "security_events": "se", 14070 "single_file": "sf", 14071 "statuses": "s", 14072 "team_discussions": "td", 14073 "vulnerability_alerts": "va", 14074 "workflows": "w" 14075 }, 14076 "created_at": ` + referenceTimeStr + `, 14077 "updated_at": ` + referenceTimeStr + `, 14078 "has_multiple_single_files": false, 14079 "suspended_by": { 14080 "login": "l", 14081 "id": 1, 14082 "avatar_url": "a", 14083 "gravatar_id": "g", 14084 "name": "n", 14085 "company": "c", 14086 "blog": "b", 14087 "location": "l", 14088 "email": "e", 14089 "hireable": true, 14090 "bio": "b", 14091 "twitter_username": "t", 14092 "public_repos": 1, 14093 "followers": 1, 14094 "following": 1, 14095 "created_at": ` + referenceTimeStr + `, 14096 "suspended_at": ` + referenceTimeStr + `, 14097 "url": "u" 14098 }, 14099 "suspended_at": ` + referenceTimeStr + ` 14100 } 14101 }` 14102 14103 testJSONMarshal(t, u, want) 14104 } 14105 14106 func TestGitHubAppAuthorizationEvent_Marshal(t *testing.T) { 14107 t.Parallel() 14108 testJSONMarshal(t, &GitHubAppAuthorizationEvent{}, "{}") 14109 14110 u := &GitHubAppAuthorizationEvent{ 14111 Action: String("a"), 14112 Sender: &User{ 14113 Login: String("l"), 14114 ID: Int64(1), 14115 NodeID: String("n"), 14116 URL: String("u"), 14117 ReposURL: String("r"), 14118 EventsURL: String("e"), 14119 AvatarURL: String("a"), 14120 }, 14121 } 14122 14123 want := `{ 14124 "action": "a", 14125 "sender": { 14126 "login": "l", 14127 "id": 1, 14128 "node_id": "n", 14129 "avatar_url": "a", 14130 "url": "u", 14131 "events_url": "e", 14132 "repos_url": "r" 14133 } 14134 }` 14135 14136 testJSONMarshal(t, u, want) 14137 } 14138 14139 func TestInstallationEvent_Marshal(t *testing.T) { 14140 t.Parallel() 14141 testJSONMarshal(t, &InstallationEvent{}, "{}") 14142 14143 u := &InstallationEvent{ 14144 Action: String("a"), 14145 Repositories: []*Repository{ 14146 { 14147 ID: Int64(1), 14148 URL: String("u"), 14149 Name: String("n"), 14150 }, 14151 }, 14152 Sender: &User{ 14153 Login: String("l"), 14154 ID: Int64(1), 14155 NodeID: String("n"), 14156 URL: String("u"), 14157 ReposURL: String("r"), 14158 EventsURL: String("e"), 14159 AvatarURL: String("a"), 14160 }, 14161 Installation: &Installation{ 14162 ID: Int64(1), 14163 NodeID: String("nid"), 14164 AppID: Int64(1), 14165 AppSlug: String("as"), 14166 TargetID: Int64(1), 14167 Account: &User{ 14168 Login: String("l"), 14169 ID: Int64(1), 14170 URL: String("u"), 14171 AvatarURL: String("a"), 14172 GravatarID: String("g"), 14173 Name: String("n"), 14174 Company: String("c"), 14175 Blog: String("b"), 14176 Location: String("l"), 14177 Email: String("e"), 14178 Hireable: Bool(true), 14179 Bio: String("b"), 14180 TwitterUsername: String("t"), 14181 PublicRepos: Int(1), 14182 Followers: Int(1), 14183 Following: Int(1), 14184 CreatedAt: &Timestamp{referenceTime}, 14185 SuspendedAt: &Timestamp{referenceTime}, 14186 }, 14187 AccessTokensURL: String("atu"), 14188 RepositoriesURL: String("ru"), 14189 HTMLURL: String("hu"), 14190 TargetType: String("tt"), 14191 SingleFileName: String("sfn"), 14192 RepositorySelection: String("rs"), 14193 Events: []string{"e"}, 14194 SingleFilePaths: []string{"s"}, 14195 Permissions: &InstallationPermissions{ 14196 Actions: String("a"), 14197 Administration: String("ad"), 14198 Checks: String("c"), 14199 Contents: String("co"), 14200 ContentReferences: String("cr"), 14201 Deployments: String("d"), 14202 Environments: String("e"), 14203 Issues: String("i"), 14204 Metadata: String("md"), 14205 Members: String("m"), 14206 OrganizationAdministration: String("oa"), 14207 OrganizationHooks: String("oh"), 14208 OrganizationPlan: String("op"), 14209 OrganizationPreReceiveHooks: String("opr"), 14210 OrganizationProjects: String("op"), 14211 OrganizationSecrets: String("os"), 14212 OrganizationSelfHostedRunners: String("osh"), 14213 OrganizationUserBlocking: String("oub"), 14214 Packages: String("pkg"), 14215 Pages: String("pg"), 14216 PullRequests: String("pr"), 14217 RepositoryHooks: String("rh"), 14218 RepositoryProjects: String("rp"), 14219 RepositoryPreReceiveHooks: String("rprh"), 14220 Secrets: String("s"), 14221 SecretScanningAlerts: String("ssa"), 14222 SecurityEvents: String("se"), 14223 SingleFile: String("sf"), 14224 Statuses: String("s"), 14225 TeamDiscussions: String("td"), 14226 VulnerabilityAlerts: String("va"), 14227 Workflows: String("w"), 14228 }, 14229 CreatedAt: &Timestamp{referenceTime}, 14230 UpdatedAt: &Timestamp{referenceTime}, 14231 HasMultipleSingleFiles: Bool(false), 14232 SuspendedBy: &User{ 14233 Login: String("l"), 14234 ID: Int64(1), 14235 URL: String("u"), 14236 AvatarURL: String("a"), 14237 GravatarID: String("g"), 14238 Name: String("n"), 14239 Company: String("c"), 14240 Blog: String("b"), 14241 Location: String("l"), 14242 Email: String("e"), 14243 Hireable: Bool(true), 14244 Bio: String("b"), 14245 TwitterUsername: String("t"), 14246 PublicRepos: Int(1), 14247 Followers: Int(1), 14248 Following: Int(1), 14249 CreatedAt: &Timestamp{referenceTime}, 14250 SuspendedAt: &Timestamp{referenceTime}, 14251 }, 14252 SuspendedAt: &Timestamp{referenceTime}, 14253 }, 14254 } 14255 14256 want := `{ 14257 "action": "a", 14258 "repositories": [ 14259 { 14260 "id":1, 14261 "name":"n", 14262 "url":"u" 14263 } 14264 ], 14265 "sender": { 14266 "login": "l", 14267 "id": 1, 14268 "node_id": "n", 14269 "avatar_url": "a", 14270 "url": "u", 14271 "events_url": "e", 14272 "repos_url": "r" 14273 }, 14274 "installation": { 14275 "id": 1, 14276 "node_id": "nid", 14277 "app_id": 1, 14278 "app_slug": "as", 14279 "target_id": 1, 14280 "account": { 14281 "login": "l", 14282 "id": 1, 14283 "avatar_url": "a", 14284 "gravatar_id": "g", 14285 "name": "n", 14286 "company": "c", 14287 "blog": "b", 14288 "location": "l", 14289 "email": "e", 14290 "hireable": true, 14291 "bio": "b", 14292 "twitter_username": "t", 14293 "public_repos": 1, 14294 "followers": 1, 14295 "following": 1, 14296 "created_at": ` + referenceTimeStr + `, 14297 "suspended_at": ` + referenceTimeStr + `, 14298 "url": "u" 14299 }, 14300 "access_tokens_url": "atu", 14301 "repositories_url": "ru", 14302 "html_url": "hu", 14303 "target_type": "tt", 14304 "single_file_name": "sfn", 14305 "repository_selection": "rs", 14306 "events": [ 14307 "e" 14308 ], 14309 "single_file_paths": [ 14310 "s" 14311 ], 14312 "permissions": { 14313 "actions": "a", 14314 "administration": "ad", 14315 "checks": "c", 14316 "contents": "co", 14317 "content_references": "cr", 14318 "deployments": "d", 14319 "environments": "e", 14320 "issues": "i", 14321 "metadata": "md", 14322 "members": "m", 14323 "organization_administration": "oa", 14324 "organization_hooks": "oh", 14325 "organization_plan": "op", 14326 "organization_pre_receive_hooks": "opr", 14327 "organization_projects": "op", 14328 "organization_secrets": "os", 14329 "organization_self_hosted_runners": "osh", 14330 "organization_user_blocking": "oub", 14331 "packages": "pkg", 14332 "pages": "pg", 14333 "pull_requests": "pr", 14334 "repository_hooks": "rh", 14335 "repository_projects": "rp", 14336 "repository_pre_receive_hooks": "rprh", 14337 "secrets": "s", 14338 "secret_scanning_alerts": "ssa", 14339 "security_events": "se", 14340 "single_file": "sf", 14341 "statuses": "s", 14342 "team_discussions": "td", 14343 "vulnerability_alerts": "va", 14344 "workflows": "w" 14345 }, 14346 "created_at": ` + referenceTimeStr + `, 14347 "updated_at": ` + referenceTimeStr + `, 14348 "has_multiple_single_files": false, 14349 "suspended_by": { 14350 "login": "l", 14351 "id": 1, 14352 "avatar_url": "a", 14353 "gravatar_id": "g", 14354 "name": "n", 14355 "company": "c", 14356 "blog": "b", 14357 "location": "l", 14358 "email": "e", 14359 "hireable": true, 14360 "bio": "b", 14361 "twitter_username": "t", 14362 "public_repos": 1, 14363 "followers": 1, 14364 "following": 1, 14365 "created_at": ` + referenceTimeStr + `, 14366 "suspended_at": ` + referenceTimeStr + `, 14367 "url": "u" 14368 }, 14369 "suspended_at": ` + referenceTimeStr + ` 14370 } 14371 }` 14372 14373 testJSONMarshal(t, u, want) 14374 } 14375 14376 func TestHeadCommit_Marshal(t *testing.T) { 14377 t.Parallel() 14378 testJSONMarshal(t, &HeadCommit{}, "{}") 14379 14380 u := &HeadCommit{ 14381 Message: String("m"), 14382 Author: &CommitAuthor{ 14383 Date: &Timestamp{referenceTime}, 14384 Name: String("n"), 14385 Email: String("e"), 14386 Login: String("u"), 14387 }, 14388 URL: String("u"), 14389 Distinct: Bool(true), 14390 SHA: String("s"), 14391 ID: String("id"), 14392 TreeID: String("tid"), 14393 Timestamp: &Timestamp{referenceTime}, 14394 Committer: &CommitAuthor{ 14395 Date: &Timestamp{referenceTime}, 14396 Name: String("n"), 14397 Email: String("e"), 14398 Login: String("u"), 14399 }, 14400 Added: []string{"a"}, 14401 Removed: []string{"r"}, 14402 Modified: []string{"m"}, 14403 } 14404 14405 want := `{ 14406 "message": "m", 14407 "author": { 14408 "date": ` + referenceTimeStr + `, 14409 "name": "n", 14410 "email": "e", 14411 "username": "u" 14412 }, 14413 "url": "u", 14414 "distinct": true, 14415 "sha": "s", 14416 "id": "id", 14417 "tree_id": "tid", 14418 "timestamp": ` + referenceTimeStr + `, 14419 "committer": { 14420 "date": ` + referenceTimeStr + `, 14421 "name": "n", 14422 "email": "e", 14423 "username": "u" 14424 }, 14425 "added": [ 14426 "a" 14427 ], 14428 "removed": [ 14429 "r" 14430 ], 14431 "modified": [ 14432 "m" 14433 ] 14434 }` 14435 14436 testJSONMarshal(t, u, want) 14437 } 14438 14439 func TestPushEventRepository_Marshal(t *testing.T) { 14440 t.Parallel() 14441 testJSONMarshal(t, &PushEventRepository{}, "{}") 14442 14443 u := &PushEventRepository{ 14444 ID: Int64(1), 14445 NodeID: String("nid"), 14446 Name: String("n"), 14447 FullName: String("fn"), 14448 Owner: &User{ 14449 Login: String("l"), 14450 ID: Int64(1), 14451 AvatarURL: String("a"), 14452 GravatarID: String("g"), 14453 Name: String("n"), 14454 Company: String("c"), 14455 Blog: String("b"), 14456 Location: String("l"), 14457 Email: String("e"), 14458 Hireable: Bool(true), 14459 PublicRepos: Int(1), 14460 Followers: Int(1), 14461 Following: Int(1), 14462 CreatedAt: &Timestamp{referenceTime}, 14463 URL: String("u"), 14464 }, 14465 Private: Bool(true), 14466 Description: String("d"), 14467 Fork: Bool(true), 14468 CreatedAt: &Timestamp{referenceTime}, 14469 PushedAt: &Timestamp{referenceTime}, 14470 UpdatedAt: &Timestamp{referenceTime}, 14471 Homepage: String("h"), 14472 PullsURL: String("p"), 14473 Size: Int(1), 14474 StargazersCount: Int(1), 14475 WatchersCount: Int(1), 14476 Language: String("l"), 14477 HasIssues: Bool(true), 14478 HasDownloads: Bool(true), 14479 HasWiki: Bool(true), 14480 HasPages: Bool(true), 14481 ForksCount: Int(1), 14482 Archived: Bool(true), 14483 Disabled: Bool(true), 14484 OpenIssuesCount: Int(1), 14485 DefaultBranch: String("d"), 14486 MasterBranch: String("m"), 14487 Organization: String("o"), 14488 URL: String("u"), 14489 ArchiveURL: String("a"), 14490 HTMLURL: String("h"), 14491 StatusesURL: String("s"), 14492 GitURL: String("g"), 14493 SSHURL: String("s"), 14494 CloneURL: String("c"), 14495 SVNURL: String("s"), 14496 Topics: []string{"octocat", "api"}, 14497 } 14498 14499 want := `{ 14500 "id": 1, 14501 "node_id": "nid", 14502 "name": "n", 14503 "full_name": "fn", 14504 "owner": { 14505 "login": "l", 14506 "id": 1, 14507 "avatar_url": "a", 14508 "gravatar_id": "g", 14509 "name": "n", 14510 "company": "c", 14511 "blog": "b", 14512 "location": "l", 14513 "email": "e", 14514 "hireable": true, 14515 "public_repos": 1, 14516 "followers": 1, 14517 "following": 1, 14518 "created_at": ` + referenceTimeStr + `, 14519 "url": "u" 14520 }, 14521 "private": true, 14522 "description": "d", 14523 "fork": true, 14524 "created_at": ` + referenceTimeStr + `, 14525 "pushed_at": ` + referenceTimeStr + `, 14526 "updated_at": ` + referenceTimeStr + `, 14527 "homepage": "h", 14528 "pulls_url": "p", 14529 "size": 1, 14530 "stargazers_count": 1, 14531 "watchers_count": 1, 14532 "language": "l", 14533 "has_issues": true, 14534 "has_downloads": true, 14535 "has_wiki": true, 14536 "has_pages": true, 14537 "forks_count": 1, 14538 "archived": true, 14539 "disabled": true, 14540 "open_issues_count": 1, 14541 "default_branch": "d", 14542 "master_branch": "m", 14543 "organization": "o", 14544 "url": "u", 14545 "archive_url": "a", 14546 "html_url": "h", 14547 "statuses_url": "s", 14548 "git_url": "g", 14549 "ssh_url": "s", 14550 "clone_url": "c", 14551 "svn_url": "s", 14552 "topics": ["octocat","api"] 14553 }` 14554 14555 testJSONMarshal(t, u, want) 14556 } 14557 14558 func TestPushEventRepoOwner_Marshal(t *testing.T) { 14559 t.Parallel() 14560 testJSONMarshal(t, &PushEventRepoOwner{}, "{}") 14561 14562 u := &PushEventRepoOwner{ 14563 Name: String("n"), 14564 Email: String("e"), 14565 } 14566 14567 want := `{ 14568 "name": "n", 14569 "email": "e" 14570 }` 14571 14572 testJSONMarshal(t, u, want) 14573 } 14574 14575 func TestProjectEvent_Marshal(t *testing.T) { 14576 t.Parallel() 14577 testJSONMarshal(t, &ProjectEvent{}, "{}") 14578 14579 u := &ProjectEvent{ 14580 Project: &Project{ID: Int64(1)}, 14581 Action: String("a"), 14582 Changes: &ProjectChange{ 14583 Name: &ProjectName{From: String("NameFrom")}, 14584 Body: &ProjectBody{From: String("BodyFrom")}, 14585 }, 14586 Repo: &Repository{ 14587 ID: Int64(1), 14588 URL: String("s"), 14589 Name: String("n"), 14590 }, 14591 Org: &Organization{ 14592 BillingEmail: String("be"), 14593 Blog: String("b"), 14594 Company: String("c"), 14595 Email: String("e"), 14596 TwitterUsername: String("tu"), 14597 Location: String("loc"), 14598 Name: String("n"), 14599 Description: String("d"), 14600 IsVerified: Bool(true), 14601 HasOrganizationProjects: Bool(true), 14602 HasRepositoryProjects: Bool(true), 14603 DefaultRepoPermission: String("drp"), 14604 MembersCanCreateRepos: Bool(true), 14605 MembersCanCreateInternalRepos: Bool(true), 14606 MembersCanCreatePrivateRepos: Bool(true), 14607 MembersCanCreatePublicRepos: Bool(false), 14608 MembersAllowedRepositoryCreationType: String("marct"), 14609 MembersCanCreatePages: Bool(true), 14610 MembersCanCreatePublicPages: Bool(false), 14611 MembersCanCreatePrivatePages: Bool(true), 14612 }, 14613 Sender: &User{ 14614 Login: String("l"), 14615 ID: Int64(1), 14616 NodeID: String("n"), 14617 URL: String("u"), 14618 ReposURL: String("r"), 14619 EventsURL: String("e"), 14620 AvatarURL: String("a"), 14621 }, 14622 Installation: &Installation{ 14623 ID: Int64(1), 14624 NodeID: String("nid"), 14625 AppID: Int64(1), 14626 AppSlug: String("as"), 14627 TargetID: Int64(1), 14628 Account: &User{ 14629 Login: String("l"), 14630 ID: Int64(1), 14631 URL: String("u"), 14632 AvatarURL: String("a"), 14633 GravatarID: String("g"), 14634 Name: String("n"), 14635 Company: String("c"), 14636 Blog: String("b"), 14637 Location: String("l"), 14638 Email: String("e"), 14639 Hireable: Bool(true), 14640 Bio: String("b"), 14641 TwitterUsername: String("t"), 14642 PublicRepos: Int(1), 14643 Followers: Int(1), 14644 Following: Int(1), 14645 CreatedAt: &Timestamp{referenceTime}, 14646 SuspendedAt: &Timestamp{referenceTime}, 14647 }, 14648 AccessTokensURL: String("atu"), 14649 RepositoriesURL: String("ru"), 14650 HTMLURL: String("hu"), 14651 TargetType: String("tt"), 14652 SingleFileName: String("sfn"), 14653 RepositorySelection: String("rs"), 14654 Events: []string{"e"}, 14655 SingleFilePaths: []string{"s"}, 14656 Permissions: &InstallationPermissions{ 14657 Actions: String("a"), 14658 Administration: String("ad"), 14659 Checks: String("c"), 14660 Contents: String("co"), 14661 ContentReferences: String("cr"), 14662 Deployments: String("d"), 14663 Environments: String("e"), 14664 Issues: String("i"), 14665 Metadata: String("md"), 14666 Members: String("m"), 14667 OrganizationAdministration: String("oa"), 14668 OrganizationHooks: String("oh"), 14669 OrganizationPlan: String("op"), 14670 OrganizationPreReceiveHooks: String("opr"), 14671 OrganizationProjects: String("op"), 14672 OrganizationSecrets: String("os"), 14673 OrganizationSelfHostedRunners: String("osh"), 14674 OrganizationUserBlocking: String("oub"), 14675 Packages: String("pkg"), 14676 Pages: String("pg"), 14677 PullRequests: String("pr"), 14678 RepositoryHooks: String("rh"), 14679 RepositoryProjects: String("rp"), 14680 RepositoryPreReceiveHooks: String("rprh"), 14681 Secrets: String("s"), 14682 SecretScanningAlerts: String("ssa"), 14683 SecurityEvents: String("se"), 14684 SingleFile: String("sf"), 14685 Statuses: String("s"), 14686 TeamDiscussions: String("td"), 14687 VulnerabilityAlerts: String("va"), 14688 Workflows: String("w"), 14689 }, 14690 CreatedAt: &Timestamp{referenceTime}, 14691 UpdatedAt: &Timestamp{referenceTime}, 14692 HasMultipleSingleFiles: Bool(false), 14693 SuspendedBy: &User{ 14694 Login: String("l"), 14695 ID: Int64(1), 14696 URL: String("u"), 14697 AvatarURL: String("a"), 14698 GravatarID: String("g"), 14699 Name: String("n"), 14700 Company: String("c"), 14701 Blog: String("b"), 14702 Location: String("l"), 14703 Email: String("e"), 14704 Hireable: Bool(true), 14705 Bio: String("b"), 14706 TwitterUsername: String("t"), 14707 PublicRepos: Int(1), 14708 Followers: Int(1), 14709 Following: Int(1), 14710 CreatedAt: &Timestamp{referenceTime}, 14711 SuspendedAt: &Timestamp{referenceTime}, 14712 }, 14713 SuspendedAt: &Timestamp{referenceTime}, 14714 }, 14715 } 14716 14717 want := `{ 14718 "action": "a", 14719 "changes": { 14720 "name": { 14721 "from": "NameFrom" 14722 }, 14723 "body": { 14724 "from": "BodyFrom" 14725 } 14726 }, 14727 "project": { 14728 "id": 1 14729 }, 14730 "repository": { 14731 "id": 1, 14732 "name": "n", 14733 "url": "s" 14734 }, 14735 "organization": { 14736 "name": "n", 14737 "company": "c", 14738 "blog": "b", 14739 "location": "loc", 14740 "email": "e", 14741 "twitter_username": "tu", 14742 "description": "d", 14743 "billing_email": "be", 14744 "is_verified": true, 14745 "has_organization_projects": true, 14746 "has_repository_projects": true, 14747 "default_repository_permission": "drp", 14748 "members_can_create_repositories": true, 14749 "members_can_create_public_repositories": false, 14750 "members_can_create_private_repositories": true, 14751 "members_can_create_internal_repositories": true, 14752 "members_allowed_repository_creation_type": "marct", 14753 "members_can_create_pages": true, 14754 "members_can_create_public_pages": false, 14755 "members_can_create_private_pages": true 14756 }, 14757 "sender": { 14758 "login": "l", 14759 "id": 1, 14760 "node_id": "n", 14761 "avatar_url": "a", 14762 "url": "u", 14763 "events_url": "e", 14764 "repos_url": "r" 14765 }, 14766 "installation": { 14767 "id": 1, 14768 "node_id": "nid", 14769 "app_id": 1, 14770 "app_slug": "as", 14771 "target_id": 1, 14772 "account": { 14773 "login": "l", 14774 "id": 1, 14775 "avatar_url": "a", 14776 "gravatar_id": "g", 14777 "name": "n", 14778 "company": "c", 14779 "blog": "b", 14780 "location": "l", 14781 "email": "e", 14782 "hireable": true, 14783 "bio": "b", 14784 "twitter_username": "t", 14785 "public_repos": 1, 14786 "followers": 1, 14787 "following": 1, 14788 "created_at": ` + referenceTimeStr + `, 14789 "suspended_at": ` + referenceTimeStr + `, 14790 "url": "u" 14791 }, 14792 "access_tokens_url": "atu", 14793 "repositories_url": "ru", 14794 "html_url": "hu", 14795 "target_type": "tt", 14796 "single_file_name": "sfn", 14797 "repository_selection": "rs", 14798 "events": [ 14799 "e" 14800 ], 14801 "single_file_paths": [ 14802 "s" 14803 ], 14804 "permissions": { 14805 "actions": "a", 14806 "administration": "ad", 14807 "checks": "c", 14808 "contents": "co", 14809 "content_references": "cr", 14810 "deployments": "d", 14811 "environments": "e", 14812 "issues": "i", 14813 "metadata": "md", 14814 "members": "m", 14815 "organization_administration": "oa", 14816 "organization_hooks": "oh", 14817 "organization_plan": "op", 14818 "organization_pre_receive_hooks": "opr", 14819 "organization_projects": "op", 14820 "organization_secrets": "os", 14821 "organization_self_hosted_runners": "osh", 14822 "organization_user_blocking": "oub", 14823 "packages": "pkg", 14824 "pages": "pg", 14825 "pull_requests": "pr", 14826 "repository_hooks": "rh", 14827 "repository_projects": "rp", 14828 "repository_pre_receive_hooks": "rprh", 14829 "secrets": "s", 14830 "secret_scanning_alerts": "ssa", 14831 "security_events": "se", 14832 "single_file": "sf", 14833 "statuses": "s", 14834 "team_discussions": "td", 14835 "vulnerability_alerts": "va", 14836 "workflows": "w" 14837 }, 14838 "created_at": ` + referenceTimeStr + `, 14839 "updated_at": ` + referenceTimeStr + `, 14840 "has_multiple_single_files": false, 14841 "suspended_by": { 14842 "login": "l", 14843 "id": 1, 14844 "avatar_url": "a", 14845 "gravatar_id": "g", 14846 "name": "n", 14847 "company": "c", 14848 "blog": "b", 14849 "location": "l", 14850 "email": "e", 14851 "hireable": true, 14852 "bio": "b", 14853 "twitter_username": "t", 14854 "public_repos": 1, 14855 "followers": 1, 14856 "following": 1, 14857 "created_at": ` + referenceTimeStr + `, 14858 "suspended_at": ` + referenceTimeStr + `, 14859 "url": "u" 14860 }, 14861 "suspended_at": ` + referenceTimeStr + ` 14862 } 14863 }` 14864 14865 testJSONMarshal(t, u, want) 14866 } 14867 14868 func TestProjectCardEvent_Marshal(t *testing.T) { 14869 t.Parallel() 14870 testJSONMarshal(t, &ProjectCardEvent{}, "{}") 14871 14872 u := &ProjectCardEvent{ 14873 Action: String("a"), 14874 Changes: &ProjectCardChange{ 14875 Note: &ProjectCardNote{From: String("NoteFrom")}, 14876 }, 14877 AfterID: Int64(1), 14878 ProjectCard: &ProjectCard{ID: Int64(1)}, 14879 Repo: &Repository{ 14880 ID: Int64(1), 14881 URL: String("s"), 14882 Name: String("n"), 14883 }, 14884 Org: &Organization{ 14885 BillingEmail: String("be"), 14886 Blog: String("b"), 14887 Company: String("c"), 14888 Email: String("e"), 14889 TwitterUsername: String("tu"), 14890 Location: String("loc"), 14891 Name: String("n"), 14892 Description: String("d"), 14893 IsVerified: Bool(true), 14894 HasOrganizationProjects: Bool(true), 14895 HasRepositoryProjects: Bool(true), 14896 DefaultRepoPermission: String("drp"), 14897 MembersCanCreateRepos: Bool(true), 14898 MembersCanCreateInternalRepos: Bool(true), 14899 MembersCanCreatePrivateRepos: Bool(true), 14900 MembersCanCreatePublicRepos: Bool(false), 14901 MembersAllowedRepositoryCreationType: String("marct"), 14902 MembersCanCreatePages: Bool(true), 14903 MembersCanCreatePublicPages: Bool(false), 14904 MembersCanCreatePrivatePages: Bool(true), 14905 }, 14906 Sender: &User{ 14907 Login: String("l"), 14908 ID: Int64(1), 14909 NodeID: String("n"), 14910 URL: String("u"), 14911 ReposURL: String("r"), 14912 EventsURL: String("e"), 14913 AvatarURL: String("a"), 14914 }, 14915 Installation: &Installation{ 14916 ID: Int64(1), 14917 NodeID: String("nid"), 14918 AppID: Int64(1), 14919 AppSlug: String("as"), 14920 TargetID: Int64(1), 14921 Account: &User{ 14922 Login: String("l"), 14923 ID: Int64(1), 14924 URL: String("u"), 14925 AvatarURL: String("a"), 14926 GravatarID: String("g"), 14927 Name: String("n"), 14928 Company: String("c"), 14929 Blog: String("b"), 14930 Location: String("l"), 14931 Email: String("e"), 14932 Hireable: Bool(true), 14933 Bio: String("b"), 14934 TwitterUsername: String("t"), 14935 PublicRepos: Int(1), 14936 Followers: Int(1), 14937 Following: Int(1), 14938 CreatedAt: &Timestamp{referenceTime}, 14939 SuspendedAt: &Timestamp{referenceTime}, 14940 }, 14941 AccessTokensURL: String("atu"), 14942 RepositoriesURL: String("ru"), 14943 HTMLURL: String("hu"), 14944 TargetType: String("tt"), 14945 SingleFileName: String("sfn"), 14946 RepositorySelection: String("rs"), 14947 Events: []string{"e"}, 14948 SingleFilePaths: []string{"s"}, 14949 Permissions: &InstallationPermissions{ 14950 Actions: String("a"), 14951 Administration: String("ad"), 14952 Checks: String("c"), 14953 Contents: String("co"), 14954 ContentReferences: String("cr"), 14955 Deployments: String("d"), 14956 Environments: String("e"), 14957 Issues: String("i"), 14958 Metadata: String("md"), 14959 Members: String("m"), 14960 OrganizationAdministration: String("oa"), 14961 OrganizationHooks: String("oh"), 14962 OrganizationPlan: String("op"), 14963 OrganizationPreReceiveHooks: String("opr"), 14964 OrganizationProjects: String("op"), 14965 OrganizationSecrets: String("os"), 14966 OrganizationSelfHostedRunners: String("osh"), 14967 OrganizationUserBlocking: String("oub"), 14968 Packages: String("pkg"), 14969 Pages: String("pg"), 14970 PullRequests: String("pr"), 14971 RepositoryHooks: String("rh"), 14972 RepositoryProjects: String("rp"), 14973 RepositoryPreReceiveHooks: String("rprh"), 14974 Secrets: String("s"), 14975 SecretScanningAlerts: String("ssa"), 14976 SecurityEvents: String("se"), 14977 SingleFile: String("sf"), 14978 Statuses: String("s"), 14979 TeamDiscussions: String("td"), 14980 VulnerabilityAlerts: String("va"), 14981 Workflows: String("w"), 14982 }, 14983 CreatedAt: &Timestamp{referenceTime}, 14984 UpdatedAt: &Timestamp{referenceTime}, 14985 HasMultipleSingleFiles: Bool(false), 14986 SuspendedBy: &User{ 14987 Login: String("l"), 14988 ID: Int64(1), 14989 URL: String("u"), 14990 AvatarURL: String("a"), 14991 GravatarID: String("g"), 14992 Name: String("n"), 14993 Company: String("c"), 14994 Blog: String("b"), 14995 Location: String("l"), 14996 Email: String("e"), 14997 Hireable: Bool(true), 14998 Bio: String("b"), 14999 TwitterUsername: String("t"), 15000 PublicRepos: Int(1), 15001 Followers: Int(1), 15002 Following: Int(1), 15003 CreatedAt: &Timestamp{referenceTime}, 15004 SuspendedAt: &Timestamp{referenceTime}, 15005 }, 15006 SuspendedAt: &Timestamp{referenceTime}, 15007 }, 15008 } 15009 15010 want := `{ 15011 "action": "a", 15012 "changes": { 15013 "note": { 15014 "from": "NoteFrom" 15015 } 15016 }, 15017 "after_id": 1, 15018 "project_card": { 15019 "id": 1 15020 }, 15021 "repository": { 15022 "id": 1, 15023 "name": "n", 15024 "url": "s" 15025 }, 15026 "organization": { 15027 "name": "n", 15028 "company": "c", 15029 "blog": "b", 15030 "location": "loc", 15031 "email": "e", 15032 "twitter_username": "tu", 15033 "description": "d", 15034 "billing_email": "be", 15035 "is_verified": true, 15036 "has_organization_projects": true, 15037 "has_repository_projects": true, 15038 "default_repository_permission": "drp", 15039 "members_can_create_repositories": true, 15040 "members_can_create_public_repositories": false, 15041 "members_can_create_private_repositories": true, 15042 "members_can_create_internal_repositories": true, 15043 "members_allowed_repository_creation_type": "marct", 15044 "members_can_create_pages": true, 15045 "members_can_create_public_pages": false, 15046 "members_can_create_private_pages": true 15047 }, 15048 "sender": { 15049 "login": "l", 15050 "id": 1, 15051 "node_id": "n", 15052 "avatar_url": "a", 15053 "url": "u", 15054 "events_url": "e", 15055 "repos_url": "r" 15056 }, 15057 "installation": { 15058 "id": 1, 15059 "node_id": "nid", 15060 "app_id": 1, 15061 "app_slug": "as", 15062 "target_id": 1, 15063 "account": { 15064 "login": "l", 15065 "id": 1, 15066 "avatar_url": "a", 15067 "gravatar_id": "g", 15068 "name": "n", 15069 "company": "c", 15070 "blog": "b", 15071 "location": "l", 15072 "email": "e", 15073 "hireable": true, 15074 "bio": "b", 15075 "twitter_username": "t", 15076 "public_repos": 1, 15077 "followers": 1, 15078 "following": 1, 15079 "created_at": ` + referenceTimeStr + `, 15080 "suspended_at": ` + referenceTimeStr + `, 15081 "url": "u" 15082 }, 15083 "access_tokens_url": "atu", 15084 "repositories_url": "ru", 15085 "html_url": "hu", 15086 "target_type": "tt", 15087 "single_file_name": "sfn", 15088 "repository_selection": "rs", 15089 "events": [ 15090 "e" 15091 ], 15092 "single_file_paths": [ 15093 "s" 15094 ], 15095 "permissions": { 15096 "actions": "a", 15097 "administration": "ad", 15098 "checks": "c", 15099 "contents": "co", 15100 "content_references": "cr", 15101 "deployments": "d", 15102 "environments": "e", 15103 "issues": "i", 15104 "metadata": "md", 15105 "members": "m", 15106 "organization_administration": "oa", 15107 "organization_hooks": "oh", 15108 "organization_plan": "op", 15109 "organization_pre_receive_hooks": "opr", 15110 "organization_projects": "op", 15111 "organization_secrets": "os", 15112 "organization_self_hosted_runners": "osh", 15113 "organization_user_blocking": "oub", 15114 "packages": "pkg", 15115 "pages": "pg", 15116 "pull_requests": "pr", 15117 "repository_hooks": "rh", 15118 "repository_projects": "rp", 15119 "repository_pre_receive_hooks": "rprh", 15120 "secrets": "s", 15121 "secret_scanning_alerts": "ssa", 15122 "security_events": "se", 15123 "single_file": "sf", 15124 "statuses": "s", 15125 "team_discussions": "td", 15126 "vulnerability_alerts": "va", 15127 "workflows": "w" 15128 }, 15129 "created_at": ` + referenceTimeStr + `, 15130 "updated_at": ` + referenceTimeStr + `, 15131 "has_multiple_single_files": false, 15132 "suspended_by": { 15133 "login": "l", 15134 "id": 1, 15135 "avatar_url": "a", 15136 "gravatar_id": "g", 15137 "name": "n", 15138 "company": "c", 15139 "blog": "b", 15140 "location": "l", 15141 "email": "e", 15142 "hireable": true, 15143 "bio": "b", 15144 "twitter_username": "t", 15145 "public_repos": 1, 15146 "followers": 1, 15147 "following": 1, 15148 "created_at": ` + referenceTimeStr + `, 15149 "suspended_at": ` + referenceTimeStr + `, 15150 "url": "u" 15151 }, 15152 "suspended_at": ` + referenceTimeStr + ` 15153 } 15154 }` 15155 15156 testJSONMarshal(t, u, want) 15157 } 15158 15159 func TestProjectColumnEvent_Marshal(t *testing.T) { 15160 t.Parallel() 15161 testJSONMarshal(t, &ProjectColumnEvent{}, "{}") 15162 15163 u := &ProjectColumnEvent{ 15164 Action: String("a"), 15165 Changes: &ProjectColumnChange{ 15166 Name: &ProjectColumnName{From: String("NameFrom")}, 15167 }, 15168 AfterID: Int64(1), 15169 ProjectColumn: &ProjectColumn{ID: Int64(1)}, 15170 Repo: &Repository{ 15171 ID: Int64(1), 15172 URL: String("s"), 15173 Name: String("n"), 15174 }, 15175 Org: &Organization{ 15176 BillingEmail: String("be"), 15177 Blog: String("b"), 15178 Company: String("c"), 15179 Email: String("e"), 15180 TwitterUsername: String("tu"), 15181 Location: String("loc"), 15182 Name: String("n"), 15183 Description: String("d"), 15184 IsVerified: Bool(true), 15185 HasOrganizationProjects: Bool(true), 15186 HasRepositoryProjects: Bool(true), 15187 DefaultRepoPermission: String("drp"), 15188 MembersCanCreateRepos: Bool(true), 15189 MembersCanCreateInternalRepos: Bool(true), 15190 MembersCanCreatePrivateRepos: Bool(true), 15191 MembersCanCreatePublicRepos: Bool(false), 15192 MembersAllowedRepositoryCreationType: String("marct"), 15193 MembersCanCreatePages: Bool(true), 15194 MembersCanCreatePublicPages: Bool(false), 15195 MembersCanCreatePrivatePages: Bool(true), 15196 }, 15197 Sender: &User{ 15198 Login: String("l"), 15199 ID: Int64(1), 15200 NodeID: String("n"), 15201 URL: String("u"), 15202 ReposURL: String("r"), 15203 EventsURL: String("e"), 15204 AvatarURL: String("a"), 15205 }, 15206 Installation: &Installation{ 15207 ID: Int64(1), 15208 NodeID: String("nid"), 15209 AppID: Int64(1), 15210 AppSlug: String("as"), 15211 TargetID: Int64(1), 15212 Account: &User{ 15213 Login: String("l"), 15214 ID: Int64(1), 15215 URL: String("u"), 15216 AvatarURL: String("a"), 15217 GravatarID: String("g"), 15218 Name: String("n"), 15219 Company: String("c"), 15220 Blog: String("b"), 15221 Location: String("l"), 15222 Email: String("e"), 15223 Hireable: Bool(true), 15224 Bio: String("b"), 15225 TwitterUsername: String("t"), 15226 PublicRepos: Int(1), 15227 Followers: Int(1), 15228 Following: Int(1), 15229 CreatedAt: &Timestamp{referenceTime}, 15230 SuspendedAt: &Timestamp{referenceTime}, 15231 }, 15232 AccessTokensURL: String("atu"), 15233 RepositoriesURL: String("ru"), 15234 HTMLURL: String("hu"), 15235 TargetType: String("tt"), 15236 SingleFileName: String("sfn"), 15237 RepositorySelection: String("rs"), 15238 Events: []string{"e"}, 15239 SingleFilePaths: []string{"s"}, 15240 Permissions: &InstallationPermissions{ 15241 Actions: String("a"), 15242 Administration: String("ad"), 15243 Checks: String("c"), 15244 Contents: String("co"), 15245 ContentReferences: String("cr"), 15246 Deployments: String("d"), 15247 Environments: String("e"), 15248 Issues: String("i"), 15249 Metadata: String("md"), 15250 Members: String("m"), 15251 OrganizationAdministration: String("oa"), 15252 OrganizationHooks: String("oh"), 15253 OrganizationPlan: String("op"), 15254 OrganizationPreReceiveHooks: String("opr"), 15255 OrganizationProjects: String("op"), 15256 OrganizationSecrets: String("os"), 15257 OrganizationSelfHostedRunners: String("osh"), 15258 OrganizationUserBlocking: String("oub"), 15259 Packages: String("pkg"), 15260 Pages: String("pg"), 15261 PullRequests: String("pr"), 15262 RepositoryHooks: String("rh"), 15263 RepositoryProjects: String("rp"), 15264 RepositoryPreReceiveHooks: String("rprh"), 15265 Secrets: String("s"), 15266 SecretScanningAlerts: String("ssa"), 15267 SecurityEvents: String("se"), 15268 SingleFile: String("sf"), 15269 Statuses: String("s"), 15270 TeamDiscussions: String("td"), 15271 VulnerabilityAlerts: String("va"), 15272 Workflows: String("w"), 15273 }, 15274 CreatedAt: &Timestamp{referenceTime}, 15275 UpdatedAt: &Timestamp{referenceTime}, 15276 HasMultipleSingleFiles: Bool(false), 15277 SuspendedBy: &User{ 15278 Login: String("l"), 15279 ID: Int64(1), 15280 URL: String("u"), 15281 AvatarURL: String("a"), 15282 GravatarID: String("g"), 15283 Name: String("n"), 15284 Company: String("c"), 15285 Blog: String("b"), 15286 Location: String("l"), 15287 Email: String("e"), 15288 Hireable: Bool(true), 15289 Bio: String("b"), 15290 TwitterUsername: String("t"), 15291 PublicRepos: Int(1), 15292 Followers: Int(1), 15293 Following: Int(1), 15294 CreatedAt: &Timestamp{referenceTime}, 15295 SuspendedAt: &Timestamp{referenceTime}, 15296 }, 15297 SuspendedAt: &Timestamp{referenceTime}, 15298 }, 15299 } 15300 15301 want := `{ 15302 "action": "a", 15303 "changes": { 15304 "name": { 15305 "from": "NameFrom" 15306 } 15307 }, 15308 "after_id": 1, 15309 "project_column": { 15310 "id": 1 15311 }, 15312 "repository": { 15313 "id": 1, 15314 "name": "n", 15315 "url": "s" 15316 }, 15317 "organization": { 15318 "name": "n", 15319 "company": "c", 15320 "blog": "b", 15321 "location": "loc", 15322 "email": "e", 15323 "twitter_username": "tu", 15324 "description": "d", 15325 "billing_email": "be", 15326 "is_verified": true, 15327 "has_organization_projects": true, 15328 "has_repository_projects": true, 15329 "default_repository_permission": "drp", 15330 "members_can_create_repositories": true, 15331 "members_can_create_public_repositories": false, 15332 "members_can_create_private_repositories": true, 15333 "members_can_create_internal_repositories": true, 15334 "members_allowed_repository_creation_type": "marct", 15335 "members_can_create_pages": true, 15336 "members_can_create_public_pages": false, 15337 "members_can_create_private_pages": true 15338 }, 15339 "sender": { 15340 "login": "l", 15341 "id": 1, 15342 "node_id": "n", 15343 "avatar_url": "a", 15344 "url": "u", 15345 "events_url": "e", 15346 "repos_url": "r" 15347 }, 15348 "installation": { 15349 "id": 1, 15350 "node_id": "nid", 15351 "app_id": 1, 15352 "app_slug": "as", 15353 "target_id": 1, 15354 "account": { 15355 "login": "l", 15356 "id": 1, 15357 "avatar_url": "a", 15358 "gravatar_id": "g", 15359 "name": "n", 15360 "company": "c", 15361 "blog": "b", 15362 "location": "l", 15363 "email": "e", 15364 "hireable": true, 15365 "bio": "b", 15366 "twitter_username": "t", 15367 "public_repos": 1, 15368 "followers": 1, 15369 "following": 1, 15370 "created_at": ` + referenceTimeStr + `, 15371 "suspended_at": ` + referenceTimeStr + `, 15372 "url": "u" 15373 }, 15374 "access_tokens_url": "atu", 15375 "repositories_url": "ru", 15376 "html_url": "hu", 15377 "target_type": "tt", 15378 "single_file_name": "sfn", 15379 "repository_selection": "rs", 15380 "events": [ 15381 "e" 15382 ], 15383 "single_file_paths": [ 15384 "s" 15385 ], 15386 "permissions": { 15387 "actions": "a", 15388 "administration": "ad", 15389 "checks": "c", 15390 "contents": "co", 15391 "content_references": "cr", 15392 "deployments": "d", 15393 "environments": "e", 15394 "issues": "i", 15395 "metadata": "md", 15396 "members": "m", 15397 "organization_administration": "oa", 15398 "organization_hooks": "oh", 15399 "organization_plan": "op", 15400 "organization_pre_receive_hooks": "opr", 15401 "organization_projects": "op", 15402 "organization_secrets": "os", 15403 "organization_self_hosted_runners": "osh", 15404 "organization_user_blocking": "oub", 15405 "packages": "pkg", 15406 "pages": "pg", 15407 "pull_requests": "pr", 15408 "repository_hooks": "rh", 15409 "repository_projects": "rp", 15410 "repository_pre_receive_hooks": "rprh", 15411 "secrets": "s", 15412 "secret_scanning_alerts": "ssa", 15413 "security_events": "se", 15414 "single_file": "sf", 15415 "statuses": "s", 15416 "team_discussions": "td", 15417 "vulnerability_alerts": "va", 15418 "workflows": "w" 15419 }, 15420 "created_at": ` + referenceTimeStr + `, 15421 "updated_at": ` + referenceTimeStr + `, 15422 "has_multiple_single_files": false, 15423 "suspended_by": { 15424 "login": "l", 15425 "id": 1, 15426 "avatar_url": "a", 15427 "gravatar_id": "g", 15428 "name": "n", 15429 "company": "c", 15430 "blog": "b", 15431 "location": "l", 15432 "email": "e", 15433 "hireable": true, 15434 "bio": "b", 15435 "twitter_username": "t", 15436 "public_repos": 1, 15437 "followers": 1, 15438 "following": 1, 15439 "created_at": ` + referenceTimeStr + `, 15440 "suspended_at": ` + referenceTimeStr + `, 15441 "url": "u" 15442 }, 15443 "suspended_at": ` + referenceTimeStr + ` 15444 } 15445 }` 15446 15447 testJSONMarshal(t, u, want) 15448 } 15449 15450 func TestProjectV2Event_Marshal(t *testing.T) { 15451 t.Parallel() 15452 testJSONMarshal(t, &ProjectV2Event{}, "{}") 15453 15454 u := &ProjectV2Event{ 15455 Action: String("a"), 15456 ProjectsV2: &ProjectsV2{ 15457 ID: Int64(1), 15458 NodeID: String("nid"), 15459 Owner: &User{ 15460 Login: String("l"), 15461 ID: Int64(1), 15462 NodeID: String("n"), 15463 URL: String("u"), 15464 ReposURL: String("r"), 15465 EventsURL: String("e"), 15466 AvatarURL: String("a"), 15467 }, 15468 Creator: &User{ 15469 Login: String("l"), 15470 ID: Int64(1), 15471 NodeID: String("n"), 15472 URL: String("u"), 15473 ReposURL: String("r"), 15474 EventsURL: String("e"), 15475 AvatarURL: String("a"), 15476 }, 15477 Title: String("t"), 15478 Description: String("d"), 15479 Public: Bool(true), 15480 ClosedAt: &Timestamp{referenceTime}, 15481 CreatedAt: &Timestamp{referenceTime}, 15482 UpdatedAt: &Timestamp{referenceTime}, 15483 DeletedAt: &Timestamp{referenceTime}, 15484 Number: Int(1), 15485 ShortDescription: String("sd"), 15486 DeletedBy: &User{ 15487 Login: String("l"), 15488 ID: Int64(1), 15489 NodeID: String("n"), 15490 URL: String("u"), 15491 ReposURL: String("r"), 15492 EventsURL: String("e"), 15493 AvatarURL: String("a"), 15494 }, 15495 }, 15496 Org: &Organization{ 15497 BillingEmail: String("be"), 15498 Blog: String("b"), 15499 Company: String("c"), 15500 Email: String("e"), 15501 TwitterUsername: String("tu"), 15502 Location: String("loc"), 15503 Name: String("n"), 15504 Description: String("d"), 15505 IsVerified: Bool(true), 15506 HasOrganizationProjects: Bool(true), 15507 HasRepositoryProjects: Bool(true), 15508 DefaultRepoPermission: String("drp"), 15509 MembersCanCreateRepos: Bool(true), 15510 MembersCanCreateInternalRepos: Bool(true), 15511 MembersCanCreatePrivateRepos: Bool(true), 15512 MembersCanCreatePublicRepos: Bool(false), 15513 MembersAllowedRepositoryCreationType: String("marct"), 15514 MembersCanCreatePages: Bool(true), 15515 MembersCanCreatePublicPages: Bool(false), 15516 MembersCanCreatePrivatePages: Bool(true), 15517 }, 15518 Sender: &User{ 15519 Login: String("l"), 15520 ID: Int64(1), 15521 NodeID: String("n"), 15522 URL: String("u"), 15523 ReposURL: String("r"), 15524 EventsURL: String("e"), 15525 AvatarURL: String("a"), 15526 }, 15527 Installation: &Installation{ 15528 ID: Int64(1), 15529 NodeID: String("nid"), 15530 AppID: Int64(1), 15531 AppSlug: String("as"), 15532 TargetID: Int64(1), 15533 Account: &User{ 15534 Login: String("l"), 15535 ID: Int64(1), 15536 URL: String("u"), 15537 AvatarURL: String("a"), 15538 GravatarID: String("g"), 15539 Name: String("n"), 15540 Company: String("c"), 15541 Blog: String("b"), 15542 Location: String("l"), 15543 Email: String("e"), 15544 Hireable: Bool(true), 15545 Bio: String("b"), 15546 TwitterUsername: String("t"), 15547 PublicRepos: Int(1), 15548 Followers: Int(1), 15549 Following: Int(1), 15550 CreatedAt: &Timestamp{referenceTime}, 15551 SuspendedAt: &Timestamp{referenceTime}, 15552 }, 15553 }, 15554 } 15555 15556 want := `{ 15557 "action": "a", 15558 "projects_v2": { 15559 "id": 1, 15560 "node_id": "nid", 15561 "owner": { 15562 "login": "l", 15563 "id": 1, 15564 "node_id": "n", 15565 "avatar_url": "a", 15566 "url": "u", 15567 "events_url": "e", 15568 "repos_url": "r" 15569 }, 15570 "creator": { 15571 "login": "l", 15572 "id": 1, 15573 "node_id": "n", 15574 "avatar_url": "a", 15575 "url": "u", 15576 "events_url": "e", 15577 "repos_url": "r" 15578 }, 15579 "title": "t", 15580 "description": "d", 15581 "public": true, 15582 "closed_at": ` + referenceTimeStr + `, 15583 "created_at": ` + referenceTimeStr + `, 15584 "updated_at": ` + referenceTimeStr + `, 15585 "deleted_at": ` + referenceTimeStr + `, 15586 "number": 1, 15587 "short_description": "sd", 15588 "deleted_by": { 15589 "login": "l", 15590 "id": 1, 15591 "node_id": "n", 15592 "avatar_url": "a", 15593 "url": "u", 15594 "events_url": "e", 15595 "repos_url": "r" 15596 } 15597 }, 15598 "organization": { 15599 "name": "n", 15600 "company": "c", 15601 "blog": "b", 15602 "location": "loc", 15603 "email": "e", 15604 "twitter_username": "tu", 15605 "description": "d", 15606 "billing_email": "be", 15607 "is_verified": true, 15608 "has_organization_projects": true, 15609 "has_repository_projects": true, 15610 "default_repository_permission": "drp", 15611 "members_can_create_repositories": true, 15612 "members_can_create_public_repositories": false, 15613 "members_can_create_private_repositories": true, 15614 "members_can_create_internal_repositories": true, 15615 "members_allowed_repository_creation_type": "marct", 15616 "members_can_create_pages": true, 15617 "members_can_create_public_pages": false, 15618 "members_can_create_private_pages": true 15619 }, 15620 "sender": { 15621 "login": "l", 15622 "id": 1, 15623 "node_id": "n", 15624 "avatar_url": "a", 15625 "url": "u", 15626 "events_url": "e", 15627 "repos_url": "r" 15628 }, 15629 "installation": { 15630 "id": 1, 15631 "node_id": "nid", 15632 "app_id": 1, 15633 "app_slug": "as", 15634 "target_id": 1, 15635 "account": { 15636 "login": "l", 15637 "id": 1, 15638 "avatar_url": "a", 15639 "gravatar_id": "g", 15640 "name": "n", 15641 "company": "c", 15642 "blog": "b", 15643 "location": "l", 15644 "email": "e", 15645 "hireable": true, 15646 "bio": "b", 15647 "twitter_username": "t", 15648 "public_repos": 1, 15649 "followers": 1, 15650 "following": 1, 15651 "created_at": ` + referenceTimeStr + `, 15652 "suspended_at": ` + referenceTimeStr + `, 15653 "url": "u" 15654 } 15655 } 15656 }` 15657 15658 testJSONMarshal(t, u, want) 15659 } 15660 15661 func TestProjectV2ItemEvent_Marshal(t *testing.T) { 15662 t.Parallel() 15663 testJSONMarshal(t, &ProjectV2ItemEvent{}, "{}") 15664 15665 u := &ProjectV2ItemEvent{ 15666 Action: String("a"), 15667 Changes: &ProjectV2ItemChange{ 15668 ArchivedAt: &ArchivedAt{ 15669 From: &Timestamp{referenceTime}, 15670 To: &Timestamp{referenceTime}, 15671 }, 15672 }, 15673 ProjectV2Item: &ProjectV2Item{ 15674 ID: Int64(1), 15675 NodeID: String("nid"), 15676 ProjectNodeID: String("pnid"), 15677 ContentNodeID: String("cnid"), 15678 ContentType: String("ct"), 15679 Creator: &User{ 15680 Login: String("l"), 15681 ID: Int64(1), 15682 NodeID: String("n"), 15683 URL: String("u"), 15684 ReposURL: String("r"), 15685 EventsURL: String("e"), 15686 AvatarURL: String("a"), 15687 }, 15688 CreatedAt: &Timestamp{referenceTime}, 15689 UpdatedAt: &Timestamp{referenceTime}, 15690 ArchivedAt: &Timestamp{referenceTime}, 15691 }, 15692 Org: &Organization{ 15693 BillingEmail: String("be"), 15694 Blog: String("b"), 15695 Company: String("c"), 15696 Email: String("e"), 15697 TwitterUsername: String("tu"), 15698 Location: String("loc"), 15699 Name: String("n"), 15700 Description: String("d"), 15701 IsVerified: Bool(true), 15702 HasOrganizationProjects: Bool(true), 15703 HasRepositoryProjects: Bool(true), 15704 DefaultRepoPermission: String("drp"), 15705 MembersCanCreateRepos: Bool(true), 15706 MembersCanCreateInternalRepos: Bool(true), 15707 MembersCanCreatePrivateRepos: Bool(true), 15708 MembersCanCreatePublicRepos: Bool(false), 15709 MembersAllowedRepositoryCreationType: String("marct"), 15710 MembersCanCreatePages: Bool(true), 15711 MembersCanCreatePublicPages: Bool(false), 15712 MembersCanCreatePrivatePages: Bool(true), 15713 }, 15714 Sender: &User{ 15715 Login: String("l"), 15716 ID: Int64(1), 15717 NodeID: String("n"), 15718 URL: String("u"), 15719 ReposURL: String("r"), 15720 EventsURL: String("e"), 15721 AvatarURL: String("a"), 15722 }, 15723 Installation: &Installation{ 15724 ID: Int64(1), 15725 NodeID: String("nid"), 15726 AppID: Int64(1), 15727 AppSlug: String("as"), 15728 TargetID: Int64(1), 15729 Account: &User{ 15730 Login: String("l"), 15731 ID: Int64(1), 15732 URL: String("u"), 15733 AvatarURL: String("a"), 15734 GravatarID: String("g"), 15735 Name: String("n"), 15736 Company: String("c"), 15737 Blog: String("b"), 15738 Location: String("l"), 15739 Email: String("e"), 15740 Hireable: Bool(true), 15741 Bio: String("b"), 15742 TwitterUsername: String("t"), 15743 PublicRepos: Int(1), 15744 Followers: Int(1), 15745 Following: Int(1), 15746 CreatedAt: &Timestamp{referenceTime}, 15747 SuspendedAt: &Timestamp{referenceTime}, 15748 }, 15749 }, 15750 } 15751 15752 want := `{ 15753 "action": "a", 15754 "changes": { 15755 "archived_at": { 15756 "from": ` + referenceTimeStr + `, 15757 "to": ` + referenceTimeStr + ` 15758 } 15759 }, 15760 "projects_v2_item": { 15761 "id": 1, 15762 "node_id": "nid", 15763 "project_node_id": "pnid", 15764 "content_node_id": "cnid", 15765 "content_type": "ct", 15766 "creator": { 15767 "login": "l", 15768 "id": 1, 15769 "node_id": "n", 15770 "avatar_url": "a", 15771 "url": "u", 15772 "events_url": "e", 15773 "repos_url": "r" 15774 }, 15775 "created_at": ` + referenceTimeStr + `, 15776 "updated_at": ` + referenceTimeStr + `, 15777 "archived_at": ` + referenceTimeStr + ` 15778 }, 15779 "organization": { 15780 "name": "n", 15781 "company": "c", 15782 "blog": "b", 15783 "location": "loc", 15784 "email": "e", 15785 "twitter_username": "tu", 15786 "description": "d", 15787 "billing_email": "be", 15788 "is_verified": true, 15789 "has_organization_projects": true, 15790 "has_repository_projects": true, 15791 "default_repository_permission": "drp", 15792 "members_can_create_repositories": true, 15793 "members_can_create_public_repositories": false, 15794 "members_can_create_private_repositories": true, 15795 "members_can_create_internal_repositories": true, 15796 "members_allowed_repository_creation_type": "marct", 15797 "members_can_create_pages": true, 15798 "members_can_create_public_pages": false, 15799 "members_can_create_private_pages": true 15800 }, 15801 "sender": { 15802 "login": "l", 15803 "id": 1, 15804 "node_id": "n", 15805 "avatar_url": "a", 15806 "url": "u", 15807 "events_url": "e", 15808 "repos_url": "r" 15809 }, 15810 "installation": { 15811 "id": 1, 15812 "node_id": "nid", 15813 "app_id": 1, 15814 "app_slug": "as", 15815 "target_id": 1, 15816 "account": { 15817 "login": "l", 15818 "id": 1, 15819 "avatar_url": "a", 15820 "gravatar_id": "g", 15821 "name": "n", 15822 "company": "c", 15823 "blog": "b", 15824 "location": "l", 15825 "email": "e", 15826 "hireable": true, 15827 "bio": "b", 15828 "twitter_username": "t", 15829 "public_repos": 1, 15830 "followers": 1, 15831 "following": 1, 15832 "created_at": ` + referenceTimeStr + `, 15833 "suspended_at": ` + referenceTimeStr + `, 15834 "url": "u" 15835 } 15836 } 15837 }` 15838 15839 testJSONMarshal(t, u, want) 15840 } 15841 15842 func TestPullRequestEvent_Marshal(t *testing.T) { 15843 t.Parallel() 15844 testJSONMarshal(t, &PullRequestEvent{}, "{}") 15845 15846 u := &PullRequestEvent{ 15847 Action: String("a"), 15848 Assignee: &User{ 15849 Login: String("l"), 15850 ID: Int64(1), 15851 NodeID: String("n"), 15852 URL: String("u"), 15853 ReposURL: String("r"), 15854 EventsURL: String("e"), 15855 AvatarURL: String("a"), 15856 }, 15857 Number: Int(1), 15858 PullRequest: &PullRequest{ID: Int64(1)}, 15859 Changes: &EditChange{ 15860 Title: &EditTitle{ 15861 From: String("TitleFrom"), 15862 }, 15863 Body: &EditBody{ 15864 From: String("BodyFrom"), 15865 }, 15866 Base: &EditBase{ 15867 Ref: &EditRef{ 15868 From: String("BaseRefFrom"), 15869 }, 15870 SHA: &EditSHA{ 15871 From: String("BaseSHAFrom"), 15872 }, 15873 }, 15874 }, 15875 RequestedReviewer: &User{ 15876 Login: String("l"), 15877 ID: Int64(1), 15878 NodeID: String("n"), 15879 URL: String("u"), 15880 ReposURL: String("r"), 15881 EventsURL: String("e"), 15882 AvatarURL: String("a"), 15883 }, 15884 RequestedTeam: &Team{ID: Int64(1)}, 15885 Label: &Label{ID: Int64(1)}, 15886 Before: String("before"), 15887 After: String("after"), 15888 Repo: &Repository{ 15889 ID: Int64(1), 15890 URL: String("s"), 15891 Name: String("n"), 15892 }, 15893 PerformedViaGithubApp: &App{ 15894 ID: Int64(1), 15895 NodeID: String("n"), 15896 Slug: String("s"), 15897 Name: String("n"), 15898 Description: String("d"), 15899 ExternalURL: String("e"), 15900 HTMLURL: String("h"), 15901 }, 15902 Organization: &Organization{ 15903 BillingEmail: String("be"), 15904 Blog: String("b"), 15905 Company: String("c"), 15906 Email: String("e"), 15907 TwitterUsername: String("tu"), 15908 Location: String("loc"), 15909 Name: String("n"), 15910 Description: String("d"), 15911 IsVerified: Bool(true), 15912 HasOrganizationProjects: Bool(true), 15913 HasRepositoryProjects: Bool(true), 15914 DefaultRepoPermission: String("drp"), 15915 MembersCanCreateRepos: Bool(true), 15916 MembersCanCreateInternalRepos: Bool(true), 15917 MembersCanCreatePrivateRepos: Bool(true), 15918 MembersCanCreatePublicRepos: Bool(false), 15919 MembersAllowedRepositoryCreationType: String("marct"), 15920 MembersCanCreatePages: Bool(true), 15921 MembersCanCreatePublicPages: Bool(false), 15922 MembersCanCreatePrivatePages: Bool(true), 15923 }, 15924 Sender: &User{ 15925 Login: String("l"), 15926 ID: Int64(1), 15927 NodeID: String("n"), 15928 URL: String("u"), 15929 ReposURL: String("r"), 15930 EventsURL: String("e"), 15931 AvatarURL: String("a"), 15932 }, 15933 Installation: &Installation{ 15934 ID: Int64(1), 15935 NodeID: String("nid"), 15936 AppID: Int64(1), 15937 AppSlug: String("as"), 15938 TargetID: Int64(1), 15939 Account: &User{ 15940 Login: String("l"), 15941 ID: Int64(1), 15942 URL: String("u"), 15943 AvatarURL: String("a"), 15944 GravatarID: String("g"), 15945 Name: String("n"), 15946 Company: String("c"), 15947 Blog: String("b"), 15948 Location: String("l"), 15949 Email: String("e"), 15950 Hireable: Bool(true), 15951 Bio: String("b"), 15952 TwitterUsername: String("t"), 15953 PublicRepos: Int(1), 15954 Followers: Int(1), 15955 Following: Int(1), 15956 CreatedAt: &Timestamp{referenceTime}, 15957 SuspendedAt: &Timestamp{referenceTime}, 15958 }, 15959 AccessTokensURL: String("atu"), 15960 RepositoriesURL: String("ru"), 15961 HTMLURL: String("hu"), 15962 TargetType: String("tt"), 15963 SingleFileName: String("sfn"), 15964 RepositorySelection: String("rs"), 15965 Events: []string{"e"}, 15966 SingleFilePaths: []string{"s"}, 15967 Permissions: &InstallationPermissions{ 15968 Actions: String("a"), 15969 Administration: String("ad"), 15970 Checks: String("c"), 15971 Contents: String("co"), 15972 ContentReferences: String("cr"), 15973 Deployments: String("d"), 15974 Environments: String("e"), 15975 Issues: String("i"), 15976 Metadata: String("md"), 15977 Members: String("m"), 15978 OrganizationAdministration: String("oa"), 15979 OrganizationHooks: String("oh"), 15980 OrganizationPlan: String("op"), 15981 OrganizationPreReceiveHooks: String("opr"), 15982 OrganizationProjects: String("op"), 15983 OrganizationSecrets: String("os"), 15984 OrganizationSelfHostedRunners: String("osh"), 15985 OrganizationUserBlocking: String("oub"), 15986 Packages: String("pkg"), 15987 Pages: String("pg"), 15988 PullRequests: String("pr"), 15989 RepositoryHooks: String("rh"), 15990 RepositoryProjects: String("rp"), 15991 RepositoryPreReceiveHooks: String("rprh"), 15992 Secrets: String("s"), 15993 SecretScanningAlerts: String("ssa"), 15994 SecurityEvents: String("se"), 15995 SingleFile: String("sf"), 15996 Statuses: String("s"), 15997 TeamDiscussions: String("td"), 15998 VulnerabilityAlerts: String("va"), 15999 Workflows: String("w"), 16000 }, 16001 CreatedAt: &Timestamp{referenceTime}, 16002 UpdatedAt: &Timestamp{referenceTime}, 16003 HasMultipleSingleFiles: Bool(false), 16004 SuspendedBy: &User{ 16005 Login: String("l"), 16006 ID: Int64(1), 16007 URL: String("u"), 16008 AvatarURL: String("a"), 16009 GravatarID: String("g"), 16010 Name: String("n"), 16011 Company: String("c"), 16012 Blog: String("b"), 16013 Location: String("l"), 16014 Email: String("e"), 16015 Hireable: Bool(true), 16016 Bio: String("b"), 16017 TwitterUsername: String("t"), 16018 PublicRepos: Int(1), 16019 Followers: Int(1), 16020 Following: Int(1), 16021 CreatedAt: &Timestamp{referenceTime}, 16022 SuspendedAt: &Timestamp{referenceTime}, 16023 }, 16024 SuspendedAt: &Timestamp{referenceTime}, 16025 }, 16026 } 16027 16028 want := `{ 16029 "action": "a", 16030 "assignee": { 16031 "login": "l", 16032 "id": 1, 16033 "node_id": "n", 16034 "avatar_url": "a", 16035 "url": "u", 16036 "events_url": "e", 16037 "repos_url": "r" 16038 }, 16039 "number": 1, 16040 "pull_request": { 16041 "id": 1 16042 }, 16043 "changes": { 16044 "title": { 16045 "from": "TitleFrom" 16046 }, 16047 "body": { 16048 "from": "BodyFrom" 16049 }, 16050 "base": { 16051 "ref": { 16052 "from": "BaseRefFrom" 16053 }, 16054 "sha": { 16055 "from": "BaseSHAFrom" 16056 } 16057 } 16058 }, 16059 "requested_reviewer": { 16060 "login": "l", 16061 "id": 1, 16062 "node_id": "n", 16063 "avatar_url": "a", 16064 "url": "u", 16065 "events_url": "e", 16066 "repos_url": "r" 16067 }, 16068 "requested_team": { 16069 "id": 1 16070 }, 16071 "label": { 16072 "id": 1 16073 }, 16074 "before": "before", 16075 "after": "after", 16076 "repository": { 16077 "id": 1, 16078 "name": "n", 16079 "url": "s" 16080 }, 16081 "performed_via_github_app": { 16082 "id": 1, 16083 "node_id": "n", 16084 "slug": "s", 16085 "name": "n", 16086 "description": "d", 16087 "external_url": "e", 16088 "html_url": "h" 16089 }, 16090 "organization": { 16091 "name": "n", 16092 "company": "c", 16093 "blog": "b", 16094 "location": "loc", 16095 "email": "e", 16096 "twitter_username": "tu", 16097 "description": "d", 16098 "billing_email": "be", 16099 "is_verified": true, 16100 "has_organization_projects": true, 16101 "has_repository_projects": true, 16102 "default_repository_permission": "drp", 16103 "members_can_create_repositories": true, 16104 "members_can_create_public_repositories": false, 16105 "members_can_create_private_repositories": true, 16106 "members_can_create_internal_repositories": true, 16107 "members_allowed_repository_creation_type": "marct", 16108 "members_can_create_pages": true, 16109 "members_can_create_public_pages": false, 16110 "members_can_create_private_pages": true 16111 }, 16112 "sender": { 16113 "login": "l", 16114 "id": 1, 16115 "node_id": "n", 16116 "avatar_url": "a", 16117 "url": "u", 16118 "events_url": "e", 16119 "repos_url": "r" 16120 }, 16121 "installation": { 16122 "id": 1, 16123 "node_id": "nid", 16124 "app_id": 1, 16125 "app_slug": "as", 16126 "target_id": 1, 16127 "account": { 16128 "login": "l", 16129 "id": 1, 16130 "avatar_url": "a", 16131 "gravatar_id": "g", 16132 "name": "n", 16133 "company": "c", 16134 "blog": "b", 16135 "location": "l", 16136 "email": "e", 16137 "hireable": true, 16138 "bio": "b", 16139 "twitter_username": "t", 16140 "public_repos": 1, 16141 "followers": 1, 16142 "following": 1, 16143 "created_at": ` + referenceTimeStr + `, 16144 "suspended_at": ` + referenceTimeStr + `, 16145 "url": "u" 16146 }, 16147 "access_tokens_url": "atu", 16148 "repositories_url": "ru", 16149 "html_url": "hu", 16150 "target_type": "tt", 16151 "single_file_name": "sfn", 16152 "repository_selection": "rs", 16153 "events": [ 16154 "e" 16155 ], 16156 "single_file_paths": [ 16157 "s" 16158 ], 16159 "permissions": { 16160 "actions": "a", 16161 "administration": "ad", 16162 "checks": "c", 16163 "contents": "co", 16164 "content_references": "cr", 16165 "deployments": "d", 16166 "environments": "e", 16167 "issues": "i", 16168 "metadata": "md", 16169 "members": "m", 16170 "organization_administration": "oa", 16171 "organization_hooks": "oh", 16172 "organization_plan": "op", 16173 "organization_pre_receive_hooks": "opr", 16174 "organization_projects": "op", 16175 "organization_secrets": "os", 16176 "organization_self_hosted_runners": "osh", 16177 "organization_user_blocking": "oub", 16178 "packages": "pkg", 16179 "pages": "pg", 16180 "pull_requests": "pr", 16181 "repository_hooks": "rh", 16182 "repository_projects": "rp", 16183 "repository_pre_receive_hooks": "rprh", 16184 "secrets": "s", 16185 "secret_scanning_alerts": "ssa", 16186 "security_events": "se", 16187 "single_file": "sf", 16188 "statuses": "s", 16189 "team_discussions": "td", 16190 "vulnerability_alerts": "va", 16191 "workflows": "w" 16192 }, 16193 "created_at": ` + referenceTimeStr + `, 16194 "updated_at": ` + referenceTimeStr + `, 16195 "has_multiple_single_files": false, 16196 "suspended_by": { 16197 "login": "l", 16198 "id": 1, 16199 "avatar_url": "a", 16200 "gravatar_id": "g", 16201 "name": "n", 16202 "company": "c", 16203 "blog": "b", 16204 "location": "l", 16205 "email": "e", 16206 "hireable": true, 16207 "bio": "b", 16208 "twitter_username": "t", 16209 "public_repos": 1, 16210 "followers": 1, 16211 "following": 1, 16212 "created_at": ` + referenceTimeStr + `, 16213 "suspended_at": ` + referenceTimeStr + `, 16214 "url": "u" 16215 }, 16216 "suspended_at": ` + referenceTimeStr + ` 16217 } 16218 }` 16219 16220 testJSONMarshal(t, u, want) 16221 } 16222 16223 func TestPullRequestReviewCommentEvent_Marshal(t *testing.T) { 16224 t.Parallel() 16225 testJSONMarshal(t, &PullRequestReviewCommentEvent{}, "{}") 16226 16227 u := &PullRequestReviewCommentEvent{ 16228 Action: String("a"), 16229 PullRequest: &PullRequest{ID: Int64(1)}, 16230 Comment: &PullRequestComment{ID: Int64(1)}, 16231 Changes: &EditChange{ 16232 Title: &EditTitle{ 16233 From: String("TitleFrom"), 16234 }, 16235 Body: &EditBody{ 16236 From: String("BodyFrom"), 16237 }, 16238 Base: &EditBase{ 16239 Ref: &EditRef{ 16240 From: String("BaseRefFrom"), 16241 }, 16242 SHA: &EditSHA{ 16243 From: String("BaseSHAFrom"), 16244 }, 16245 }, 16246 }, 16247 Repo: &Repository{ 16248 ID: Int64(1), 16249 URL: String("s"), 16250 Name: String("n"), 16251 }, 16252 Sender: &User{ 16253 Login: String("l"), 16254 ID: Int64(1), 16255 NodeID: String("n"), 16256 URL: String("u"), 16257 ReposURL: String("r"), 16258 EventsURL: String("e"), 16259 AvatarURL: String("a"), 16260 }, 16261 Installation: &Installation{ 16262 ID: Int64(1), 16263 NodeID: String("nid"), 16264 AppID: Int64(1), 16265 AppSlug: String("as"), 16266 TargetID: Int64(1), 16267 Account: &User{ 16268 Login: String("l"), 16269 ID: Int64(1), 16270 URL: String("u"), 16271 AvatarURL: String("a"), 16272 GravatarID: String("g"), 16273 Name: String("n"), 16274 Company: String("c"), 16275 Blog: String("b"), 16276 Location: String("l"), 16277 Email: String("e"), 16278 Hireable: Bool(true), 16279 Bio: String("b"), 16280 TwitterUsername: String("t"), 16281 PublicRepos: Int(1), 16282 Followers: Int(1), 16283 Following: Int(1), 16284 CreatedAt: &Timestamp{referenceTime}, 16285 SuspendedAt: &Timestamp{referenceTime}, 16286 }, 16287 AccessTokensURL: String("atu"), 16288 RepositoriesURL: String("ru"), 16289 HTMLURL: String("hu"), 16290 TargetType: String("tt"), 16291 SingleFileName: String("sfn"), 16292 RepositorySelection: String("rs"), 16293 Events: []string{"e"}, 16294 SingleFilePaths: []string{"s"}, 16295 Permissions: &InstallationPermissions{ 16296 Actions: String("a"), 16297 Administration: String("ad"), 16298 Checks: String("c"), 16299 Contents: String("co"), 16300 ContentReferences: String("cr"), 16301 Deployments: String("d"), 16302 Environments: String("e"), 16303 Issues: String("i"), 16304 Metadata: String("md"), 16305 Members: String("m"), 16306 OrganizationAdministration: String("oa"), 16307 OrganizationHooks: String("oh"), 16308 OrganizationPlan: String("op"), 16309 OrganizationPreReceiveHooks: String("opr"), 16310 OrganizationProjects: String("op"), 16311 OrganizationSecrets: String("os"), 16312 OrganizationSelfHostedRunners: String("osh"), 16313 OrganizationUserBlocking: String("oub"), 16314 Packages: String("pkg"), 16315 Pages: String("pg"), 16316 PullRequests: String("pr"), 16317 RepositoryHooks: String("rh"), 16318 RepositoryProjects: String("rp"), 16319 RepositoryPreReceiveHooks: String("rprh"), 16320 Secrets: String("s"), 16321 SecretScanningAlerts: String("ssa"), 16322 SecurityEvents: String("se"), 16323 SingleFile: String("sf"), 16324 Statuses: String("s"), 16325 TeamDiscussions: String("td"), 16326 VulnerabilityAlerts: String("va"), 16327 Workflows: String("w"), 16328 }, 16329 CreatedAt: &Timestamp{referenceTime}, 16330 UpdatedAt: &Timestamp{referenceTime}, 16331 HasMultipleSingleFiles: Bool(false), 16332 SuspendedBy: &User{ 16333 Login: String("l"), 16334 ID: Int64(1), 16335 URL: String("u"), 16336 AvatarURL: String("a"), 16337 GravatarID: String("g"), 16338 Name: String("n"), 16339 Company: String("c"), 16340 Blog: String("b"), 16341 Location: String("l"), 16342 Email: String("e"), 16343 Hireable: Bool(true), 16344 Bio: String("b"), 16345 TwitterUsername: String("t"), 16346 PublicRepos: Int(1), 16347 Followers: Int(1), 16348 Following: Int(1), 16349 CreatedAt: &Timestamp{referenceTime}, 16350 SuspendedAt: &Timestamp{referenceTime}, 16351 }, 16352 SuspendedAt: &Timestamp{referenceTime}, 16353 }, 16354 } 16355 16356 want := `{ 16357 "action": "a", 16358 "pull_request": { 16359 "id": 1 16360 }, 16361 "comment": { 16362 "id": 1 16363 }, 16364 "changes": { 16365 "title": { 16366 "from": "TitleFrom" 16367 }, 16368 "body": { 16369 "from": "BodyFrom" 16370 }, 16371 "base": { 16372 "ref": { 16373 "from": "BaseRefFrom" 16374 }, 16375 "sha": { 16376 "from": "BaseSHAFrom" 16377 } 16378 } 16379 }, 16380 "repository": { 16381 "id": 1, 16382 "name": "n", 16383 "url": "s" 16384 }, 16385 "sender": { 16386 "login": "l", 16387 "id": 1, 16388 "node_id": "n", 16389 "avatar_url": "a", 16390 "url": "u", 16391 "events_url": "e", 16392 "repos_url": "r" 16393 }, 16394 "installation": { 16395 "id": 1, 16396 "node_id": "nid", 16397 "app_id": 1, 16398 "app_slug": "as", 16399 "target_id": 1, 16400 "account": { 16401 "login": "l", 16402 "id": 1, 16403 "avatar_url": "a", 16404 "gravatar_id": "g", 16405 "name": "n", 16406 "company": "c", 16407 "blog": "b", 16408 "location": "l", 16409 "email": "e", 16410 "hireable": true, 16411 "bio": "b", 16412 "twitter_username": "t", 16413 "public_repos": 1, 16414 "followers": 1, 16415 "following": 1, 16416 "created_at": ` + referenceTimeStr + `, 16417 "suspended_at": ` + referenceTimeStr + `, 16418 "url": "u" 16419 }, 16420 "access_tokens_url": "atu", 16421 "repositories_url": "ru", 16422 "html_url": "hu", 16423 "target_type": "tt", 16424 "single_file_name": "sfn", 16425 "repository_selection": "rs", 16426 "events": [ 16427 "e" 16428 ], 16429 "single_file_paths": [ 16430 "s" 16431 ], 16432 "permissions": { 16433 "actions": "a", 16434 "administration": "ad", 16435 "checks": "c", 16436 "contents": "co", 16437 "content_references": "cr", 16438 "deployments": "d", 16439 "environments": "e", 16440 "issues": "i", 16441 "metadata": "md", 16442 "members": "m", 16443 "organization_administration": "oa", 16444 "organization_hooks": "oh", 16445 "organization_plan": "op", 16446 "organization_pre_receive_hooks": "opr", 16447 "organization_projects": "op", 16448 "organization_secrets": "os", 16449 "organization_self_hosted_runners": "osh", 16450 "organization_user_blocking": "oub", 16451 "packages": "pkg", 16452 "pages": "pg", 16453 "pull_requests": "pr", 16454 "repository_hooks": "rh", 16455 "repository_projects": "rp", 16456 "repository_pre_receive_hooks": "rprh", 16457 "secrets": "s", 16458 "secret_scanning_alerts": "ssa", 16459 "security_events": "se", 16460 "single_file": "sf", 16461 "statuses": "s", 16462 "team_discussions": "td", 16463 "vulnerability_alerts": "va", 16464 "workflows": "w" 16465 }, 16466 "created_at": ` + referenceTimeStr + `, 16467 "updated_at": ` + referenceTimeStr + `, 16468 "has_multiple_single_files": false, 16469 "suspended_by": { 16470 "login": "l", 16471 "id": 1, 16472 "avatar_url": "a", 16473 "gravatar_id": "g", 16474 "name": "n", 16475 "company": "c", 16476 "blog": "b", 16477 "location": "l", 16478 "email": "e", 16479 "hireable": true, 16480 "bio": "b", 16481 "twitter_username": "t", 16482 "public_repos": 1, 16483 "followers": 1, 16484 "following": 1, 16485 "created_at": ` + referenceTimeStr + `, 16486 "suspended_at": ` + referenceTimeStr + `, 16487 "url": "u" 16488 }, 16489 "suspended_at": ` + referenceTimeStr + ` 16490 } 16491 }` 16492 16493 testJSONMarshal(t, u, want) 16494 } 16495 16496 func TestPullRequestReviewThreadEvent_Marshal(t *testing.T) { 16497 t.Parallel() 16498 testJSONMarshal(t, &PullRequestReviewThreadEvent{}, "{}") 16499 16500 u := &PullRequestReviewThreadEvent{ 16501 Action: String("a"), 16502 PullRequest: &PullRequest{ID: Int64(1)}, 16503 Thread: &PullRequestThread{ 16504 Comments: []*PullRequestComment{{ID: Int64(1)}, {ID: Int64(2)}}, 16505 }, 16506 Repo: &Repository{ 16507 ID: Int64(1), 16508 URL: String("s"), 16509 Name: String("n"), 16510 }, 16511 Sender: &User{ 16512 Login: String("l"), 16513 ID: Int64(1), 16514 NodeID: String("n"), 16515 URL: String("u"), 16516 ReposURL: String("r"), 16517 EventsURL: String("e"), 16518 AvatarURL: String("a"), 16519 }, 16520 Installation: &Installation{ 16521 ID: Int64(1), 16522 NodeID: String("nid"), 16523 AppID: Int64(1), 16524 AppSlug: String("as"), 16525 TargetID: Int64(1), 16526 Account: &User{ 16527 Login: String("l"), 16528 ID: Int64(1), 16529 URL: String("u"), 16530 AvatarURL: String("a"), 16531 GravatarID: String("g"), 16532 Name: String("n"), 16533 Company: String("c"), 16534 Blog: String("b"), 16535 Location: String("l"), 16536 Email: String("e"), 16537 Hireable: Bool(true), 16538 Bio: String("b"), 16539 TwitterUsername: String("t"), 16540 PublicRepos: Int(1), 16541 Followers: Int(1), 16542 Following: Int(1), 16543 CreatedAt: &Timestamp{referenceTime}, 16544 SuspendedAt: &Timestamp{referenceTime}, 16545 }, 16546 AccessTokensURL: String("atu"), 16547 RepositoriesURL: String("ru"), 16548 HTMLURL: String("hu"), 16549 TargetType: String("tt"), 16550 SingleFileName: String("sfn"), 16551 RepositorySelection: String("rs"), 16552 Events: []string{"e"}, 16553 SingleFilePaths: []string{"s"}, 16554 Permissions: &InstallationPermissions{ 16555 Actions: String("a"), 16556 Administration: String("ad"), 16557 Checks: String("c"), 16558 Contents: String("co"), 16559 ContentReferences: String("cr"), 16560 Deployments: String("d"), 16561 Environments: String("e"), 16562 Issues: String("i"), 16563 Metadata: String("md"), 16564 Members: String("m"), 16565 OrganizationAdministration: String("oa"), 16566 OrganizationHooks: String("oh"), 16567 OrganizationPlan: String("op"), 16568 OrganizationPreReceiveHooks: String("opr"), 16569 OrganizationProjects: String("op"), 16570 OrganizationSecrets: String("os"), 16571 OrganizationSelfHostedRunners: String("osh"), 16572 OrganizationUserBlocking: String("oub"), 16573 Packages: String("pkg"), 16574 Pages: String("pg"), 16575 PullRequests: String("pr"), 16576 RepositoryHooks: String("rh"), 16577 RepositoryProjects: String("rp"), 16578 RepositoryPreReceiveHooks: String("rprh"), 16579 Secrets: String("s"), 16580 SecretScanningAlerts: String("ssa"), 16581 SecurityEvents: String("se"), 16582 SingleFile: String("sf"), 16583 Statuses: String("s"), 16584 TeamDiscussions: String("td"), 16585 VulnerabilityAlerts: String("va"), 16586 Workflows: String("w"), 16587 }, 16588 CreatedAt: &Timestamp{referenceTime}, 16589 UpdatedAt: &Timestamp{referenceTime}, 16590 HasMultipleSingleFiles: Bool(false), 16591 SuspendedBy: &User{ 16592 Login: String("l"), 16593 ID: Int64(1), 16594 URL: String("u"), 16595 AvatarURL: String("a"), 16596 GravatarID: String("g"), 16597 Name: String("n"), 16598 Company: String("c"), 16599 Blog: String("b"), 16600 Location: String("l"), 16601 Email: String("e"), 16602 Hireable: Bool(true), 16603 Bio: String("b"), 16604 TwitterUsername: String("t"), 16605 PublicRepos: Int(1), 16606 Followers: Int(1), 16607 Following: Int(1), 16608 CreatedAt: &Timestamp{referenceTime}, 16609 SuspendedAt: &Timestamp{referenceTime}, 16610 }, 16611 SuspendedAt: &Timestamp{referenceTime}, 16612 }, 16613 } 16614 16615 want := `{ 16616 "action": "a", 16617 "pull_request": { 16618 "id": 1 16619 }, 16620 "thread": { 16621 "comments": [ 16622 { 16623 "id": 1 16624 }, 16625 { 16626 "id": 2 16627 } 16628 ] 16629 }, 16630 "repository": { 16631 "id": 1, 16632 "name": "n", 16633 "url": "s" 16634 }, 16635 "sender": { 16636 "login": "l", 16637 "id": 1, 16638 "node_id": "n", 16639 "avatar_url": "a", 16640 "url": "u", 16641 "events_url": "e", 16642 "repos_url": "r" 16643 }, 16644 "installation": { 16645 "id": 1, 16646 "node_id": "nid", 16647 "app_id": 1, 16648 "app_slug": "as", 16649 "target_id": 1, 16650 "account": { 16651 "login": "l", 16652 "id": 1, 16653 "avatar_url": "a", 16654 "gravatar_id": "g", 16655 "name": "n", 16656 "company": "c", 16657 "blog": "b", 16658 "location": "l", 16659 "email": "e", 16660 "hireable": true, 16661 "bio": "b", 16662 "twitter_username": "t", 16663 "public_repos": 1, 16664 "followers": 1, 16665 "following": 1, 16666 "created_at": ` + referenceTimeStr + `, 16667 "suspended_at": ` + referenceTimeStr + `, 16668 "url": "u" 16669 }, 16670 "access_tokens_url": "atu", 16671 "repositories_url": "ru", 16672 "html_url": "hu", 16673 "target_type": "tt", 16674 "single_file_name": "sfn", 16675 "repository_selection": "rs", 16676 "events": [ 16677 "e" 16678 ], 16679 "single_file_paths": [ 16680 "s" 16681 ], 16682 "permissions": { 16683 "actions": "a", 16684 "administration": "ad", 16685 "checks": "c", 16686 "contents": "co", 16687 "content_references": "cr", 16688 "deployments": "d", 16689 "environments": "e", 16690 "issues": "i", 16691 "metadata": "md", 16692 "members": "m", 16693 "organization_administration": "oa", 16694 "organization_hooks": "oh", 16695 "organization_plan": "op", 16696 "organization_pre_receive_hooks": "opr", 16697 "organization_projects": "op", 16698 "organization_secrets": "os", 16699 "organization_self_hosted_runners": "osh", 16700 "organization_user_blocking": "oub", 16701 "packages": "pkg", 16702 "pages": "pg", 16703 "pull_requests": "pr", 16704 "repository_hooks": "rh", 16705 "repository_projects": "rp", 16706 "repository_pre_receive_hooks": "rprh", 16707 "secrets": "s", 16708 "secret_scanning_alerts": "ssa", 16709 "security_events": "se", 16710 "single_file": "sf", 16711 "statuses": "s", 16712 "team_discussions": "td", 16713 "vulnerability_alerts": "va", 16714 "workflows": "w" 16715 }, 16716 "created_at": ` + referenceTimeStr + `, 16717 "updated_at": ` + referenceTimeStr + `, 16718 "has_multiple_single_files": false, 16719 "suspended_by": { 16720 "login": "l", 16721 "id": 1, 16722 "avatar_url": "a", 16723 "gravatar_id": "g", 16724 "name": "n", 16725 "company": "c", 16726 "blog": "b", 16727 "location": "l", 16728 "email": "e", 16729 "hireable": true, 16730 "bio": "b", 16731 "twitter_username": "t", 16732 "public_repos": 1, 16733 "followers": 1, 16734 "following": 1, 16735 "created_at": ` + referenceTimeStr + `, 16736 "suspended_at": ` + referenceTimeStr + `, 16737 "url": "u" 16738 }, 16739 "suspended_at": ` + referenceTimeStr + ` 16740 } 16741 }` 16742 16743 testJSONMarshal(t, u, want) 16744 } 16745 16746 func TestPullRequestTargetEvent_Marshal(t *testing.T) { 16747 t.Parallel() 16748 testJSONMarshal(t, &PullRequestTargetEvent{}, "{}") 16749 16750 u := &PullRequestTargetEvent{ 16751 Action: String("a"), 16752 Assignee: &User{ 16753 Login: String("l"), 16754 ID: Int64(1), 16755 NodeID: String("n"), 16756 URL: String("u"), 16757 ReposURL: String("r"), 16758 EventsURL: String("e"), 16759 AvatarURL: String("a"), 16760 }, 16761 Number: Int(1), 16762 PullRequest: &PullRequest{ID: Int64(1)}, 16763 Changes: &EditChange{ 16764 Title: &EditTitle{ 16765 From: String("TitleFrom"), 16766 }, 16767 Body: &EditBody{ 16768 From: String("BodyFrom"), 16769 }, 16770 Base: &EditBase{ 16771 Ref: &EditRef{ 16772 From: String("BaseRefFrom"), 16773 }, 16774 SHA: &EditSHA{ 16775 From: String("BaseSHAFrom"), 16776 }, 16777 }, 16778 }, 16779 RequestedReviewer: &User{ 16780 Login: String("l"), 16781 ID: Int64(1), 16782 NodeID: String("n"), 16783 URL: String("u"), 16784 ReposURL: String("r"), 16785 EventsURL: String("e"), 16786 AvatarURL: String("a"), 16787 }, 16788 RequestedTeam: &Team{ID: Int64(1)}, 16789 Label: &Label{ID: Int64(1)}, 16790 Before: String("before"), 16791 After: String("after"), 16792 Repo: &Repository{ 16793 ID: Int64(1), 16794 URL: String("s"), 16795 Name: String("n"), 16796 }, 16797 PerformedViaGithubApp: &App{ 16798 ID: Int64(1), 16799 NodeID: String("n"), 16800 Slug: String("s"), 16801 Name: String("n"), 16802 Description: String("d"), 16803 ExternalURL: String("e"), 16804 HTMLURL: String("h"), 16805 }, 16806 Organization: &Organization{ 16807 BillingEmail: String("be"), 16808 Blog: String("b"), 16809 Company: String("c"), 16810 Email: String("e"), 16811 TwitterUsername: String("tu"), 16812 Location: String("loc"), 16813 Name: String("n"), 16814 Description: String("d"), 16815 IsVerified: Bool(true), 16816 HasOrganizationProjects: Bool(true), 16817 HasRepositoryProjects: Bool(true), 16818 DefaultRepoPermission: String("drp"), 16819 MembersCanCreateRepos: Bool(true), 16820 MembersCanCreateInternalRepos: Bool(true), 16821 MembersCanCreatePrivateRepos: Bool(true), 16822 MembersCanCreatePublicRepos: Bool(false), 16823 MembersAllowedRepositoryCreationType: String("marct"), 16824 MembersCanCreatePages: Bool(true), 16825 MembersCanCreatePublicPages: Bool(false), 16826 MembersCanCreatePrivatePages: Bool(true), 16827 }, 16828 Sender: &User{ 16829 Login: String("l"), 16830 ID: Int64(1), 16831 NodeID: String("n"), 16832 URL: String("u"), 16833 ReposURL: String("r"), 16834 EventsURL: String("e"), 16835 AvatarURL: String("a"), 16836 }, 16837 Installation: &Installation{ 16838 ID: Int64(1), 16839 NodeID: String("nid"), 16840 AppID: Int64(1), 16841 AppSlug: String("as"), 16842 TargetID: Int64(1), 16843 Account: &User{ 16844 Login: String("l"), 16845 ID: Int64(1), 16846 URL: String("u"), 16847 AvatarURL: String("a"), 16848 GravatarID: String("g"), 16849 Name: String("n"), 16850 Company: String("c"), 16851 Blog: String("b"), 16852 Location: String("l"), 16853 Email: String("e"), 16854 Hireable: Bool(true), 16855 Bio: String("b"), 16856 TwitterUsername: String("t"), 16857 PublicRepos: Int(1), 16858 Followers: Int(1), 16859 Following: Int(1), 16860 CreatedAt: &Timestamp{referenceTime}, 16861 SuspendedAt: &Timestamp{referenceTime}, 16862 }, 16863 AccessTokensURL: String("atu"), 16864 RepositoriesURL: String("ru"), 16865 HTMLURL: String("hu"), 16866 TargetType: String("tt"), 16867 SingleFileName: String("sfn"), 16868 RepositorySelection: String("rs"), 16869 Events: []string{"e"}, 16870 SingleFilePaths: []string{"s"}, 16871 Permissions: &InstallationPermissions{ 16872 Actions: String("a"), 16873 Administration: String("ad"), 16874 Checks: String("c"), 16875 Contents: String("co"), 16876 ContentReferences: String("cr"), 16877 Deployments: String("d"), 16878 Environments: String("e"), 16879 Issues: String("i"), 16880 Metadata: String("md"), 16881 Members: String("m"), 16882 OrganizationAdministration: String("oa"), 16883 OrganizationHooks: String("oh"), 16884 OrganizationPlan: String("op"), 16885 OrganizationPreReceiveHooks: String("opr"), 16886 OrganizationProjects: String("op"), 16887 OrganizationSecrets: String("os"), 16888 OrganizationSelfHostedRunners: String("osh"), 16889 OrganizationUserBlocking: String("oub"), 16890 Packages: String("pkg"), 16891 Pages: String("pg"), 16892 PullRequests: String("pr"), 16893 RepositoryHooks: String("rh"), 16894 RepositoryProjects: String("rp"), 16895 RepositoryPreReceiveHooks: String("rprh"), 16896 Secrets: String("s"), 16897 SecretScanningAlerts: String("ssa"), 16898 SecurityEvents: String("se"), 16899 SingleFile: String("sf"), 16900 Statuses: String("s"), 16901 TeamDiscussions: String("td"), 16902 VulnerabilityAlerts: String("va"), 16903 Workflows: String("w"), 16904 }, 16905 CreatedAt: &Timestamp{referenceTime}, 16906 UpdatedAt: &Timestamp{referenceTime}, 16907 HasMultipleSingleFiles: Bool(false), 16908 SuspendedBy: &User{ 16909 Login: String("l"), 16910 ID: Int64(1), 16911 URL: String("u"), 16912 AvatarURL: String("a"), 16913 GravatarID: String("g"), 16914 Name: String("n"), 16915 Company: String("c"), 16916 Blog: String("b"), 16917 Location: String("l"), 16918 Email: String("e"), 16919 Hireable: Bool(true), 16920 Bio: String("b"), 16921 TwitterUsername: String("t"), 16922 PublicRepos: Int(1), 16923 Followers: Int(1), 16924 Following: Int(1), 16925 CreatedAt: &Timestamp{referenceTime}, 16926 SuspendedAt: &Timestamp{referenceTime}, 16927 }, 16928 SuspendedAt: &Timestamp{referenceTime}, 16929 }, 16930 } 16931 16932 want := `{ 16933 "action": "a", 16934 "assignee": { 16935 "login": "l", 16936 "id": 1, 16937 "node_id": "n", 16938 "avatar_url": "a", 16939 "url": "u", 16940 "events_url": "e", 16941 "repos_url": "r" 16942 }, 16943 "number": 1, 16944 "pull_request": { 16945 "id": 1 16946 }, 16947 "changes": { 16948 "title": { 16949 "from": "TitleFrom" 16950 }, 16951 "body": { 16952 "from": "BodyFrom" 16953 }, 16954 "base": { 16955 "ref": { 16956 "from": "BaseRefFrom" 16957 }, 16958 "sha": { 16959 "from": "BaseSHAFrom" 16960 } 16961 } 16962 }, 16963 "requested_reviewer": { 16964 "login": "l", 16965 "id": 1, 16966 "node_id": "n", 16967 "avatar_url": "a", 16968 "url": "u", 16969 "events_url": "e", 16970 "repos_url": "r" 16971 }, 16972 "requested_team": { 16973 "id": 1 16974 }, 16975 "label": { 16976 "id": 1 16977 }, 16978 "before": "before", 16979 "after": "after", 16980 "repository": { 16981 "id": 1, 16982 "name": "n", 16983 "url": "s" 16984 }, 16985 "performed_via_github_app": { 16986 "id": 1, 16987 "node_id": "n", 16988 "slug": "s", 16989 "name": "n", 16990 "description": "d", 16991 "external_url": "e", 16992 "html_url": "h" 16993 }, 16994 "organization": { 16995 "name": "n", 16996 "company": "c", 16997 "blog": "b", 16998 "location": "loc", 16999 "email": "e", 17000 "twitter_username": "tu", 17001 "description": "d", 17002 "billing_email": "be", 17003 "is_verified": true, 17004 "has_organization_projects": true, 17005 "has_repository_projects": true, 17006 "default_repository_permission": "drp", 17007 "members_can_create_repositories": true, 17008 "members_can_create_public_repositories": false, 17009 "members_can_create_private_repositories": true, 17010 "members_can_create_internal_repositories": true, 17011 "members_allowed_repository_creation_type": "marct", 17012 "members_can_create_pages": true, 17013 "members_can_create_public_pages": false, 17014 "members_can_create_private_pages": true 17015 }, 17016 "sender": { 17017 "login": "l", 17018 "id": 1, 17019 "node_id": "n", 17020 "avatar_url": "a", 17021 "url": "u", 17022 "events_url": "e", 17023 "repos_url": "r" 17024 }, 17025 "installation": { 17026 "id": 1, 17027 "node_id": "nid", 17028 "app_id": 1, 17029 "app_slug": "as", 17030 "target_id": 1, 17031 "account": { 17032 "login": "l", 17033 "id": 1, 17034 "avatar_url": "a", 17035 "gravatar_id": "g", 17036 "name": "n", 17037 "company": "c", 17038 "blog": "b", 17039 "location": "l", 17040 "email": "e", 17041 "hireable": true, 17042 "bio": "b", 17043 "twitter_username": "t", 17044 "public_repos": 1, 17045 "followers": 1, 17046 "following": 1, 17047 "created_at": ` + referenceTimeStr + `, 17048 "suspended_at": ` + referenceTimeStr + `, 17049 "url": "u" 17050 }, 17051 "access_tokens_url": "atu", 17052 "repositories_url": "ru", 17053 "html_url": "hu", 17054 "target_type": "tt", 17055 "single_file_name": "sfn", 17056 "repository_selection": "rs", 17057 "events": [ 17058 "e" 17059 ], 17060 "single_file_paths": [ 17061 "s" 17062 ], 17063 "permissions": { 17064 "actions": "a", 17065 "administration": "ad", 17066 "checks": "c", 17067 "contents": "co", 17068 "content_references": "cr", 17069 "deployments": "d", 17070 "environments": "e", 17071 "issues": "i", 17072 "metadata": "md", 17073 "members": "m", 17074 "organization_administration": "oa", 17075 "organization_hooks": "oh", 17076 "organization_plan": "op", 17077 "organization_pre_receive_hooks": "opr", 17078 "organization_projects": "op", 17079 "organization_secrets": "os", 17080 "organization_self_hosted_runners": "osh", 17081 "organization_user_blocking": "oub", 17082 "packages": "pkg", 17083 "pages": "pg", 17084 "pull_requests": "pr", 17085 "repository_hooks": "rh", 17086 "repository_projects": "rp", 17087 "repository_pre_receive_hooks": "rprh", 17088 "secrets": "s", 17089 "secret_scanning_alerts": "ssa", 17090 "security_events": "se", 17091 "single_file": "sf", 17092 "statuses": "s", 17093 "team_discussions": "td", 17094 "vulnerability_alerts": "va", 17095 "workflows": "w" 17096 }, 17097 "created_at": ` + referenceTimeStr + `, 17098 "updated_at": ` + referenceTimeStr + `, 17099 "has_multiple_single_files": false, 17100 "suspended_by": { 17101 "login": "l", 17102 "id": 1, 17103 "avatar_url": "a", 17104 "gravatar_id": "g", 17105 "name": "n", 17106 "company": "c", 17107 "blog": "b", 17108 "location": "l", 17109 "email": "e", 17110 "hireable": true, 17111 "bio": "b", 17112 "twitter_username": "t", 17113 "public_repos": 1, 17114 "followers": 1, 17115 "following": 1, 17116 "created_at": ` + referenceTimeStr + `, 17117 "suspended_at": ` + referenceTimeStr + `, 17118 "url": "u" 17119 }, 17120 "suspended_at": ` + referenceTimeStr + ` 17121 } 17122 }` 17123 17124 testJSONMarshal(t, u, want) 17125 } 17126 17127 func TestRepositoryVulnerabilityAlertEvent_Marshal(t *testing.T) { 17128 t.Parallel() 17129 testJSONMarshal(t, &RepositoryVulnerabilityAlertEvent{}, "{}") 17130 17131 u := &RepositoryVulnerabilityAlertEvent{ 17132 Action: String("a"), 17133 Alert: &RepositoryVulnerabilityAlert{ 17134 ID: Int64(1), 17135 AffectedRange: String("ar"), 17136 AffectedPackageName: String("apn"), 17137 ExternalReference: String("er"), 17138 ExternalIdentifier: String("ei"), 17139 FixedIn: String("fi"), 17140 Dismisser: &User{ 17141 Login: String("l"), 17142 ID: Int64(1), 17143 NodeID: String("n"), 17144 URL: String("u"), 17145 ReposURL: String("r"), 17146 EventsURL: String("e"), 17147 AvatarURL: String("a"), 17148 }, 17149 DismissReason: String("dr"), 17150 DismissedAt: &Timestamp{referenceTime}, 17151 }, 17152 Repository: &Repository{ 17153 ID: Int64(1), 17154 URL: String("s"), 17155 Name: String("n"), 17156 }, 17157 } 17158 17159 want := `{ 17160 "action": "a", 17161 "alert": { 17162 "id": 1, 17163 "affected_range": "ar", 17164 "affected_package_name": "apn", 17165 "external_reference": "er", 17166 "external_identifier": "ei", 17167 "fixed_in": "fi", 17168 "dismisser": { 17169 "login": "l", 17170 "id": 1, 17171 "node_id": "n", 17172 "avatar_url": "a", 17173 "url": "u", 17174 "events_url": "e", 17175 "repos_url": "r" 17176 }, 17177 "dismiss_reason": "dr", 17178 "dismissed_at": ` + referenceTimeStr + ` 17179 }, 17180 "repository": { 17181 "id": 1, 17182 "name": "n", 17183 "url": "s" 17184 } 17185 }` 17186 17187 testJSONMarshal(t, u, want) 17188 } 17189 17190 func TestSecretScanningAlertEvent_Marshal(t *testing.T) { 17191 t.Parallel() 17192 testJSONMarshal(t, &SecretScanningAlertEvent{}, "{}") 17193 17194 u := &SecretScanningAlertEvent{ 17195 Action: String("a"), 17196 Alert: &SecretScanningAlert{ 17197 Number: Int(1), 17198 SecretType: String("t"), 17199 Resolution: String("r"), 17200 ResolvedBy: &User{ 17201 Login: String("l"), 17202 ID: Int64(1), 17203 NodeID: String("n"), 17204 URL: String("u"), 17205 ReposURL: String("r"), 17206 EventsURL: String("e"), 17207 AvatarURL: String("a"), 17208 }, 17209 ResolvedAt: &Timestamp{referenceTime}, 17210 }, 17211 Repo: &Repository{ 17212 ID: Int64(1), 17213 URL: String("s"), 17214 Name: String("n"), 17215 }, 17216 Organization: &Organization{ 17217 BillingEmail: String("be"), 17218 Blog: String("b"), 17219 Company: String("c"), 17220 Email: String("e"), 17221 TwitterUsername: String("tu"), 17222 Location: String("loc"), 17223 Name: String("n"), 17224 Description: String("d"), 17225 IsVerified: Bool(true), 17226 HasOrganizationProjects: Bool(true), 17227 HasRepositoryProjects: Bool(true), 17228 DefaultRepoPermission: String("drp"), 17229 MembersCanCreateRepos: Bool(true), 17230 MembersCanCreateInternalRepos: Bool(true), 17231 MembersCanCreatePrivateRepos: Bool(true), 17232 MembersCanCreatePublicRepos: Bool(false), 17233 MembersAllowedRepositoryCreationType: String("marct"), 17234 MembersCanCreatePages: Bool(true), 17235 MembersCanCreatePublicPages: Bool(false), 17236 MembersCanCreatePrivatePages: Bool(true), 17237 }, 17238 Enterprise: &Enterprise{ 17239 ID: Int(1), 17240 Slug: String("s"), 17241 Name: String("n"), 17242 NodeID: String("nid"), 17243 AvatarURL: String("au"), 17244 Description: String("d"), 17245 WebsiteURL: String("wu"), 17246 HTMLURL: String("hu"), 17247 CreatedAt: &Timestamp{referenceTime}, 17248 UpdatedAt: &Timestamp{referenceTime}, 17249 }, 17250 Sender: &User{ 17251 Login: String("l"), 17252 ID: Int64(1), 17253 NodeID: String("n"), 17254 URL: String("u"), 17255 ReposURL: String("r"), 17256 EventsURL: String("e"), 17257 AvatarURL: String("a"), 17258 }, 17259 Installation: &Installation{ 17260 ID: Int64(1), 17261 NodeID: String("nid"), 17262 AppID: Int64(1), 17263 AppSlug: String("as"), 17264 TargetID: Int64(1), 17265 Account: &User{ 17266 Login: String("l"), 17267 ID: Int64(1), 17268 URL: String("u"), 17269 AvatarURL: String("a"), 17270 GravatarID: String("g"), 17271 Name: String("n"), 17272 Company: String("c"), 17273 Blog: String("b"), 17274 Location: String("l"), 17275 Email: String("e"), 17276 Hireable: Bool(true), 17277 Bio: String("b"), 17278 TwitterUsername: String("t"), 17279 PublicRepos: Int(1), 17280 Followers: Int(1), 17281 Following: Int(1), 17282 CreatedAt: &Timestamp{referenceTime}, 17283 SuspendedAt: &Timestamp{referenceTime}, 17284 }, 17285 AccessTokensURL: String("atu"), 17286 RepositoriesURL: String("ru"), 17287 HTMLURL: String("hu"), 17288 TargetType: String("tt"), 17289 SingleFileName: String("sfn"), 17290 RepositorySelection: String("rs"), 17291 Events: []string{"e"}, 17292 SingleFilePaths: []string{"s"}, 17293 Permissions: &InstallationPermissions{ 17294 Actions: String("a"), 17295 Administration: String("ad"), 17296 Checks: String("c"), 17297 Contents: String("co"), 17298 ContentReferences: String("cr"), 17299 Deployments: String("d"), 17300 Environments: String("e"), 17301 Issues: String("i"), 17302 Metadata: String("md"), 17303 Members: String("m"), 17304 OrganizationAdministration: String("oa"), 17305 OrganizationHooks: String("oh"), 17306 OrganizationPlan: String("op"), 17307 OrganizationPreReceiveHooks: String("opr"), 17308 OrganizationProjects: String("op"), 17309 OrganizationSecrets: String("os"), 17310 OrganizationSelfHostedRunners: String("osh"), 17311 OrganizationUserBlocking: String("oub"), 17312 Packages: String("pkg"), 17313 Pages: String("pg"), 17314 PullRequests: String("pr"), 17315 RepositoryHooks: String("rh"), 17316 RepositoryProjects: String("rp"), 17317 RepositoryPreReceiveHooks: String("rprh"), 17318 Secrets: String("s"), 17319 SecretScanningAlerts: String("ssa"), 17320 SecurityEvents: String("se"), 17321 SingleFile: String("sf"), 17322 Statuses: String("s"), 17323 TeamDiscussions: String("td"), 17324 VulnerabilityAlerts: String("va"), 17325 Workflows: String("w"), 17326 }, 17327 CreatedAt: &Timestamp{referenceTime}, 17328 UpdatedAt: &Timestamp{referenceTime}, 17329 HasMultipleSingleFiles: Bool(false), 17330 SuspendedBy: &User{ 17331 Login: String("l"), 17332 ID: Int64(1), 17333 URL: String("u"), 17334 AvatarURL: String("a"), 17335 GravatarID: String("g"), 17336 Name: String("n"), 17337 Company: String("c"), 17338 Blog: String("b"), 17339 Location: String("l"), 17340 Email: String("e"), 17341 Hireable: Bool(true), 17342 Bio: String("b"), 17343 TwitterUsername: String("t"), 17344 PublicRepos: Int(1), 17345 Followers: Int(1), 17346 Following: Int(1), 17347 CreatedAt: &Timestamp{referenceTime}, 17348 SuspendedAt: &Timestamp{referenceTime}, 17349 }, 17350 SuspendedAt: &Timestamp{referenceTime}, 17351 }, 17352 } 17353 17354 want := `{ 17355 "action": "a", 17356 "alert": { 17357 "number": 1, 17358 "secret_type": "t", 17359 "resolution": "r", 17360 "resolved_by": { 17361 "login": "l", 17362 "id": 1, 17363 "node_id": "n", 17364 "avatar_url": "a", 17365 "url": "u", 17366 "events_url": "e", 17367 "repos_url": "r" 17368 }, 17369 "resolved_at": ` + referenceTimeStr + ` 17370 }, 17371 "repository": { 17372 "id": 1, 17373 "name": "n", 17374 "url": "s" 17375 }, 17376 "organization": { 17377 "name": "n", 17378 "company": "c", 17379 "blog": "b", 17380 "location": "loc", 17381 "email": "e", 17382 "twitter_username": "tu", 17383 "description": "d", 17384 "billing_email": "be", 17385 "is_verified": true, 17386 "has_organization_projects": true, 17387 "has_repository_projects": true, 17388 "default_repository_permission": "drp", 17389 "members_can_create_repositories": true, 17390 "members_can_create_public_repositories": false, 17391 "members_can_create_private_repositories": true, 17392 "members_can_create_internal_repositories": true, 17393 "members_allowed_repository_creation_type": "marct", 17394 "members_can_create_pages": true, 17395 "members_can_create_public_pages": false, 17396 "members_can_create_private_pages": true 17397 }, 17398 "enterprise": { 17399 "id": 1, 17400 "slug": "s", 17401 "name": "n", 17402 "node_id": "nid", 17403 "avatar_url": "au", 17404 "description": "d", 17405 "website_url": "wu", 17406 "html_url": "hu", 17407 "created_at": ` + referenceTimeStr + `, 17408 "updated_at": ` + referenceTimeStr + ` 17409 }, 17410 "sender": { 17411 "login": "l", 17412 "id": 1, 17413 "node_id": "n", 17414 "avatar_url": "a", 17415 "url": "u", 17416 "events_url": "e", 17417 "repos_url": "r" 17418 }, 17419 "installation": { 17420 "id": 1, 17421 "node_id": "nid", 17422 "app_id": 1, 17423 "app_slug": "as", 17424 "target_id": 1, 17425 "account": { 17426 "login": "l", 17427 "id": 1, 17428 "avatar_url": "a", 17429 "gravatar_id": "g", 17430 "name": "n", 17431 "company": "c", 17432 "blog": "b", 17433 "location": "l", 17434 "email": "e", 17435 "hireable": true, 17436 "bio": "b", 17437 "twitter_username": "t", 17438 "public_repos": 1, 17439 "followers": 1, 17440 "following": 1, 17441 "created_at": ` + referenceTimeStr + `, 17442 "suspended_at": ` + referenceTimeStr + `, 17443 "url": "u" 17444 }, 17445 "access_tokens_url": "atu", 17446 "repositories_url": "ru", 17447 "html_url": "hu", 17448 "target_type": "tt", 17449 "single_file_name": "sfn", 17450 "repository_selection": "rs", 17451 "events": [ 17452 "e" 17453 ], 17454 "single_file_paths": [ 17455 "s" 17456 ], 17457 "permissions": { 17458 "actions": "a", 17459 "administration": "ad", 17460 "checks": "c", 17461 "contents": "co", 17462 "content_references": "cr", 17463 "deployments": "d", 17464 "environments": "e", 17465 "issues": "i", 17466 "metadata": "md", 17467 "members": "m", 17468 "organization_administration": "oa", 17469 "organization_hooks": "oh", 17470 "organization_plan": "op", 17471 "organization_pre_receive_hooks": "opr", 17472 "organization_projects": "op", 17473 "organization_secrets": "os", 17474 "organization_self_hosted_runners": "osh", 17475 "organization_user_blocking": "oub", 17476 "packages": "pkg", 17477 "pages": "pg", 17478 "pull_requests": "pr", 17479 "repository_hooks": "rh", 17480 "repository_projects": "rp", 17481 "repository_pre_receive_hooks": "rprh", 17482 "secrets": "s", 17483 "secret_scanning_alerts": "ssa", 17484 "security_events": "se", 17485 "single_file": "sf", 17486 "statuses": "s", 17487 "team_discussions": "td", 17488 "vulnerability_alerts": "va", 17489 "workflows": "w" 17490 }, 17491 "created_at": ` + referenceTimeStr + `, 17492 "updated_at": ` + referenceTimeStr + `, 17493 "has_multiple_single_files": false, 17494 "suspended_by": { 17495 "login": "l", 17496 "id": 1, 17497 "avatar_url": "a", 17498 "gravatar_id": "g", 17499 "name": "n", 17500 "company": "c", 17501 "blog": "b", 17502 "location": "l", 17503 "email": "e", 17504 "hireable": true, 17505 "bio": "b", 17506 "twitter_username": "t", 17507 "public_repos": 1, 17508 "followers": 1, 17509 "following": 1, 17510 "created_at": ` + referenceTimeStr + `, 17511 "suspended_at": ` + referenceTimeStr + `, 17512 "url": "u" 17513 }, 17514 "suspended_at": ` + referenceTimeStr + ` 17515 } 17516 }` 17517 17518 testJSONMarshal(t, u, want) 17519 } 17520 17521 func TestSecurityAdvisoryEvent_Marshal(t *testing.T) { 17522 t.Parallel() 17523 testJSONMarshal(t, &SecurityAdvisoryEvent{}, "{}") 17524 u := &SecurityAdvisoryEvent{ 17525 Action: String("published"), 17526 SecurityAdvisory: &SecurityAdvisory{ 17527 CVSS: &AdvisoryCVSS{ 17528 Score: Float64(1.0), 17529 VectorString: String("vs"), 17530 }, 17531 CWEs: []*AdvisoryCWEs{ 17532 { 17533 CWEID: String("cweid"), 17534 Name: String("n"), 17535 }, 17536 }, 17537 GHSAID: String("GHSA-rf4j-j272-some"), 17538 Summary: String("Siuuuuuuuuu"), 17539 Description: String("desc"), 17540 Severity: String("moderate"), 17541 Identifiers: []*AdvisoryIdentifier{ 17542 { 17543 Value: String("GHSA-rf4j-j272-some"), 17544 Type: String("GHSA"), 17545 }, 17546 }, 17547 References: []*AdvisoryReference{ 17548 { 17549 URL: String("https://some-url"), 17550 }, 17551 }, 17552 PublishedAt: &Timestamp{referenceTime}, 17553 UpdatedAt: &Timestamp{referenceTime}, 17554 WithdrawnAt: nil, 17555 Vulnerabilities: []*AdvisoryVulnerability{ 17556 { 17557 Package: &VulnerabilityPackage{ 17558 Ecosystem: String("ucl"), 17559 Name: String("penaldo"), 17560 }, 17561 Severity: String("moderate"), 17562 VulnerableVersionRange: String(">= 2.0.0, < 2.0.2"), 17563 FirstPatchedVersion: &FirstPatchedVersion{ 17564 Identifier: String("2.0.2"), 17565 }, 17566 }, 17567 }, 17568 }, 17569 Enterprise: &Enterprise{ 17570 ID: Int(1), 17571 Slug: String("s"), 17572 Name: String("n"), 17573 NodeID: String("nid"), 17574 AvatarURL: String("au"), 17575 Description: String("d"), 17576 WebsiteURL: String("wu"), 17577 HTMLURL: String("hu"), 17578 CreatedAt: &Timestamp{referenceTime}, 17579 UpdatedAt: &Timestamp{referenceTime}, 17580 }, 17581 Installation: &Installation{ 17582 ID: Int64(1), 17583 NodeID: String("nid"), 17584 AppID: Int64(1), 17585 AppSlug: String("as"), 17586 TargetID: Int64(1), 17587 Account: &User{ 17588 Login: String("l"), 17589 ID: Int64(1), 17590 URL: String("u"), 17591 AvatarURL: String("a"), 17592 GravatarID: String("g"), 17593 Name: String("n"), 17594 Company: String("c"), 17595 Blog: String("b"), 17596 Location: String("l"), 17597 Email: String("e"), 17598 Hireable: Bool(true), 17599 Bio: String("b"), 17600 TwitterUsername: String("t"), 17601 PublicRepos: Int(1), 17602 Followers: Int(1), 17603 Following: Int(1), 17604 CreatedAt: &Timestamp{referenceTime}, 17605 SuspendedAt: &Timestamp{referenceTime}, 17606 }, 17607 AccessTokensURL: String("atu"), 17608 RepositoriesURL: String("ru"), 17609 HTMLURL: String("hu"), 17610 TargetType: String("tt"), 17611 SingleFileName: String("sfn"), 17612 RepositorySelection: String("rs"), 17613 Events: []string{"e"}, 17614 SingleFilePaths: []string{"s"}, 17615 Permissions: &InstallationPermissions{ 17616 Actions: String("a"), 17617 Administration: String("ad"), 17618 Checks: String("c"), 17619 Contents: String("co"), 17620 ContentReferences: String("cr"), 17621 Deployments: String("d"), 17622 Environments: String("e"), 17623 Issues: String("i"), 17624 Metadata: String("md"), 17625 Members: String("m"), 17626 OrganizationAdministration: String("oa"), 17627 OrganizationHooks: String("oh"), 17628 OrganizationPlan: String("op"), 17629 OrganizationPreReceiveHooks: String("opr"), 17630 OrganizationProjects: String("op"), 17631 OrganizationSecrets: String("os"), 17632 OrganizationSelfHostedRunners: String("osh"), 17633 OrganizationUserBlocking: String("oub"), 17634 Packages: String("pkg"), 17635 Pages: String("pg"), 17636 PullRequests: String("pr"), 17637 RepositoryHooks: String("rh"), 17638 RepositoryProjects: String("rp"), 17639 RepositoryPreReceiveHooks: String("rprh"), 17640 Secrets: String("s"), 17641 SecretScanningAlerts: String("ssa"), 17642 SecurityEvents: String("se"), 17643 SingleFile: String("sf"), 17644 Statuses: String("s"), 17645 TeamDiscussions: String("td"), 17646 VulnerabilityAlerts: String("va"), 17647 Workflows: String("w"), 17648 }, 17649 CreatedAt: &Timestamp{referenceTime}, 17650 UpdatedAt: &Timestamp{referenceTime}, 17651 HasMultipleSingleFiles: Bool(false), 17652 SuspendedBy: &User{ 17653 Login: String("l"), 17654 ID: Int64(1), 17655 URL: String("u"), 17656 AvatarURL: String("a"), 17657 GravatarID: String("g"), 17658 Name: String("n"), 17659 Company: String("c"), 17660 Blog: String("b"), 17661 Location: String("l"), 17662 Email: String("e"), 17663 Hireable: Bool(true), 17664 Bio: String("b"), 17665 TwitterUsername: String("t"), 17666 PublicRepos: Int(1), 17667 Followers: Int(1), 17668 Following: Int(1), 17669 CreatedAt: &Timestamp{referenceTime}, 17670 SuspendedAt: &Timestamp{referenceTime}, 17671 }, 17672 SuspendedAt: &Timestamp{referenceTime}, 17673 }, 17674 Organization: &Organization{ 17675 BillingEmail: String("be"), 17676 Blog: String("b"), 17677 Company: String("c"), 17678 Email: String("e"), 17679 TwitterUsername: String("tu"), 17680 Location: String("loc"), 17681 Name: String("n"), 17682 Description: String("d"), 17683 IsVerified: Bool(true), 17684 HasOrganizationProjects: Bool(true), 17685 HasRepositoryProjects: Bool(true), 17686 DefaultRepoPermission: String("drp"), 17687 MembersCanCreateRepos: Bool(true), 17688 MembersCanCreateInternalRepos: Bool(true), 17689 MembersCanCreatePrivateRepos: Bool(true), 17690 MembersCanCreatePublicRepos: Bool(false), 17691 MembersAllowedRepositoryCreationType: String("marct"), 17692 MembersCanCreatePages: Bool(true), 17693 MembersCanCreatePublicPages: Bool(false), 17694 MembersCanCreatePrivatePages: Bool(true), 17695 }, 17696 Repository: &Repository{ 17697 ID: Int64(1), 17698 URL: String("s"), 17699 Name: String("n"), 17700 }, 17701 Sender: &User{ 17702 Login: String("l"), 17703 ID: Int64(1), 17704 NodeID: String("n"), 17705 URL: String("u"), 17706 ReposURL: String("r"), 17707 EventsURL: String("e"), 17708 AvatarURL: String("a"), 17709 }, 17710 } 17711 17712 want := `{ 17713 "action": "published", 17714 "security_advisory": { 17715 "ghsa_id": "GHSA-rf4j-j272-some", 17716 "summary": "Siuuuuuuuuu", 17717 "cvss": { 17718 "score": 1.0, 17719 "vector_string": "vs" 17720 }, 17721 "cwes": [ 17722 { 17723 "cwe_id": "cweid", 17724 "name": "n" 17725 } 17726 ], 17727 "description": "desc", 17728 "severity": "moderate", 17729 "identifiers": [ 17730 { 17731 "value": "GHSA-rf4j-j272-some", 17732 "type": "GHSA" 17733 } 17734 ], 17735 "references": [ 17736 { 17737 "url": "https://some-url" 17738 } 17739 ], 17740 "published_at": ` + referenceTimeStr + `, 17741 "updated_at": ` + referenceTimeStr + `, 17742 "withdrawn_at": null, 17743 "vulnerabilities": [ 17744 { 17745 "package": { 17746 "ecosystem": "ucl", 17747 "name": "penaldo" 17748 }, 17749 "severity": "moderate", 17750 "vulnerable_version_range": ">= 2.0.0, < 2.0.2", 17751 "first_patched_version": { 17752 "identifier": "2.0.2" 17753 } 17754 } 17755 ] 17756 }, 17757 "enterprise": { 17758 "id": 1, 17759 "slug": "s", 17760 "name": "n", 17761 "node_id": "nid", 17762 "avatar_url": "au", 17763 "description": "d", 17764 "website_url": "wu", 17765 "html_url": "hu", 17766 "created_at": ` + referenceTimeStr + `, 17767 "updated_at": ` + referenceTimeStr + ` 17768 }, 17769 "installation": { 17770 "id": 1, 17771 "node_id": "nid", 17772 "app_id": 1, 17773 "app_slug": "as", 17774 "target_id": 1, 17775 "account": { 17776 "login": "l", 17777 "id": 1, 17778 "avatar_url": "a", 17779 "gravatar_id": "g", 17780 "name": "n", 17781 "company": "c", 17782 "blog": "b", 17783 "location": "l", 17784 "email": "e", 17785 "hireable": true, 17786 "bio": "b", 17787 "twitter_username": "t", 17788 "public_repos": 1, 17789 "followers": 1, 17790 "following": 1, 17791 "created_at": ` + referenceTimeStr + `, 17792 "suspended_at": ` + referenceTimeStr + `, 17793 "url": "u" 17794 }, 17795 "access_tokens_url": "atu", 17796 "repositories_url": "ru", 17797 "html_url": "hu", 17798 "target_type": "tt", 17799 "single_file_name": "sfn", 17800 "repository_selection": "rs", 17801 "events": [ 17802 "e" 17803 ], 17804 "single_file_paths": [ 17805 "s" 17806 ], 17807 "permissions": { 17808 "actions": "a", 17809 "administration": "ad", 17810 "checks": "c", 17811 "contents": "co", 17812 "content_references": "cr", 17813 "deployments": "d", 17814 "environments": "e", 17815 "issues": "i", 17816 "metadata": "md", 17817 "members": "m", 17818 "organization_administration": "oa", 17819 "organization_hooks": "oh", 17820 "organization_plan": "op", 17821 "organization_pre_receive_hooks": "opr", 17822 "organization_projects": "op", 17823 "organization_secrets": "os", 17824 "organization_self_hosted_runners": "osh", 17825 "organization_user_blocking": "oub", 17826 "packages": "pkg", 17827 "pages": "pg", 17828 "pull_requests": "pr", 17829 "repository_hooks": "rh", 17830 "repository_projects": "rp", 17831 "repository_pre_receive_hooks": "rprh", 17832 "secrets": "s", 17833 "secret_scanning_alerts": "ssa", 17834 "security_events": "se", 17835 "single_file": "sf", 17836 "statuses": "s", 17837 "team_discussions": "td", 17838 "vulnerability_alerts": "va", 17839 "workflows": "w" 17840 }, 17841 "created_at": ` + referenceTimeStr + `, 17842 "updated_at": ` + referenceTimeStr + `, 17843 "has_multiple_single_files": false, 17844 "suspended_by": { 17845 "login": "l", 17846 "id": 1, 17847 "avatar_url": "a", 17848 "gravatar_id": "g", 17849 "name": "n", 17850 "company": "c", 17851 "blog": "b", 17852 "location": "l", 17853 "email": "e", 17854 "hireable": true, 17855 "bio": "b", 17856 "twitter_username": "t", 17857 "public_repos": 1, 17858 "followers": 1, 17859 "following": 1, 17860 "created_at": ` + referenceTimeStr + `, 17861 "suspended_at": ` + referenceTimeStr + `, 17862 "url": "u" 17863 }, 17864 "suspended_at": ` + referenceTimeStr + ` 17865 }, 17866 "organization": { 17867 "name": "n", 17868 "company": "c", 17869 "blog": "b", 17870 "location": "loc", 17871 "email": "e", 17872 "twitter_username": "tu", 17873 "description": "d", 17874 "billing_email": "be", 17875 "is_verified": true, 17876 "has_organization_projects": true, 17877 "has_repository_projects": true, 17878 "default_repository_permission": "drp", 17879 "members_can_create_repositories": true, 17880 "members_can_create_public_repositories": false, 17881 "members_can_create_private_repositories": true, 17882 "members_can_create_internal_repositories": true, 17883 "members_allowed_repository_creation_type": "marct", 17884 "members_can_create_pages": true, 17885 "members_can_create_public_pages": false, 17886 "members_can_create_private_pages": true 17887 }, 17888 "repository": { 17889 "id": 1, 17890 "url": "s", 17891 "name": "n" 17892 }, 17893 "sender": { 17894 "login": "l", 17895 "id": 1, 17896 "node_id": "n", 17897 "avatar_url": "a", 17898 "url": "u", 17899 "events_url": "e", 17900 "repos_url": "r" 17901 } 17902 }` 17903 17904 testJSONMarshal(t, u, want) 17905 } 17906 17907 func TestSecurityAndAnalysisEvent_Marshal(t *testing.T) { 17908 t.Parallel() 17909 testJSONMarshal(t, &SecurityAndAnalysisEvent{}, "{}") 17910 17911 u := &SecurityAndAnalysisEvent{ 17912 Changes: &SecurityAndAnalysisChange{ 17913 From: &SecurityAndAnalysisChangeFrom{ 17914 SecurityAndAnalysis: &SecurityAndAnalysis{ 17915 AdvancedSecurity: &AdvancedSecurity{ 17916 Status: String("enabled"), 17917 }, 17918 SecretScanning: &SecretScanning{ 17919 Status: String("enabled"), 17920 }, 17921 SecretScanningPushProtection: &SecretScanningPushProtection{ 17922 Status: String("enabled"), 17923 }, 17924 DependabotSecurityUpdates: &DependabotSecurityUpdates{ 17925 Status: String("enabled"), 17926 }, 17927 }, 17928 }, 17929 }, 17930 Enterprise: &Enterprise{ 17931 ID: Int(1), 17932 Slug: String("s"), 17933 Name: String("n"), 17934 NodeID: String("nid"), 17935 AvatarURL: String("au"), 17936 Description: String("d"), 17937 WebsiteURL: String("wu"), 17938 HTMLURL: String("hu"), 17939 CreatedAt: &Timestamp{referenceTime}, 17940 UpdatedAt: &Timestamp{referenceTime}, 17941 }, 17942 Installation: &Installation{ 17943 ID: Int64(1), 17944 NodeID: String("nid"), 17945 AppID: Int64(1), 17946 AppSlug: String("as"), 17947 TargetID: Int64(1), 17948 Account: &User{ 17949 Login: String("l"), 17950 ID: Int64(1), 17951 URL: String("u"), 17952 AvatarURL: String("a"), 17953 GravatarID: String("g"), 17954 Name: String("n"), 17955 Company: String("c"), 17956 Blog: String("b"), 17957 Location: String("l"), 17958 Email: String("e"), 17959 Hireable: Bool(true), 17960 Bio: String("b"), 17961 TwitterUsername: String("t"), 17962 PublicRepos: Int(1), 17963 Followers: Int(1), 17964 Following: Int(1), 17965 CreatedAt: &Timestamp{referenceTime}, 17966 SuspendedAt: &Timestamp{referenceTime}, 17967 }, 17968 AccessTokensURL: String("atu"), 17969 RepositoriesURL: String("ru"), 17970 HTMLURL: String("hu"), 17971 TargetType: String("tt"), 17972 SingleFileName: String("sfn"), 17973 RepositorySelection: String("rs"), 17974 Events: []string{"e"}, 17975 SingleFilePaths: []string{"s"}, 17976 Permissions: &InstallationPermissions{ 17977 Actions: String("a"), 17978 Administration: String("ad"), 17979 Checks: String("c"), 17980 Contents: String("co"), 17981 ContentReferences: String("cr"), 17982 Deployments: String("d"), 17983 Environments: String("e"), 17984 Issues: String("i"), 17985 Metadata: String("md"), 17986 Members: String("m"), 17987 OrganizationAdministration: String("oa"), 17988 OrganizationHooks: String("oh"), 17989 OrganizationPlan: String("op"), 17990 OrganizationPreReceiveHooks: String("opr"), 17991 OrganizationProjects: String("op"), 17992 OrganizationSecrets: String("os"), 17993 OrganizationSelfHostedRunners: String("osh"), 17994 OrganizationUserBlocking: String("oub"), 17995 Packages: String("pkg"), 17996 Pages: String("pg"), 17997 PullRequests: String("pr"), 17998 RepositoryHooks: String("rh"), 17999 RepositoryProjects: String("rp"), 18000 RepositoryPreReceiveHooks: String("rprh"), 18001 Secrets: String("s"), 18002 SecretScanningAlerts: String("ssa"), 18003 SecurityEvents: String("se"), 18004 SingleFile: String("sf"), 18005 Statuses: String("s"), 18006 TeamDiscussions: String("td"), 18007 VulnerabilityAlerts: String("va"), 18008 Workflows: String("w"), 18009 }, 18010 CreatedAt: &Timestamp{referenceTime}, 18011 UpdatedAt: &Timestamp{referenceTime}, 18012 HasMultipleSingleFiles: Bool(false), 18013 SuspendedBy: &User{ 18014 Login: String("l"), 18015 ID: Int64(1), 18016 URL: String("u"), 18017 AvatarURL: String("a"), 18018 GravatarID: String("g"), 18019 Name: String("n"), 18020 Company: String("c"), 18021 Blog: String("b"), 18022 Location: String("l"), 18023 Email: String("e"), 18024 Hireable: Bool(true), 18025 Bio: String("b"), 18026 TwitterUsername: String("t"), 18027 PublicRepos: Int(1), 18028 Followers: Int(1), 18029 Following: Int(1), 18030 CreatedAt: &Timestamp{referenceTime}, 18031 SuspendedAt: &Timestamp{referenceTime}, 18032 }, 18033 SuspendedAt: &Timestamp{referenceTime}, 18034 }, 18035 Organization: &Organization{ 18036 BillingEmail: String("be"), 18037 Blog: String("b"), 18038 Company: String("c"), 18039 Email: String("e"), 18040 TwitterUsername: String("tu"), 18041 Location: String("loc"), 18042 Name: String("n"), 18043 Description: String("d"), 18044 IsVerified: Bool(true), 18045 HasOrganizationProjects: Bool(true), 18046 HasRepositoryProjects: Bool(true), 18047 DefaultRepoPermission: String("drp"), 18048 MembersCanCreateRepos: Bool(true), 18049 MembersCanCreateInternalRepos: Bool(true), 18050 MembersCanCreatePrivateRepos: Bool(true), 18051 MembersCanCreatePublicRepos: Bool(false), 18052 MembersAllowedRepositoryCreationType: String("marct"), 18053 MembersCanCreatePages: Bool(true), 18054 MembersCanCreatePublicPages: Bool(false), 18055 MembersCanCreatePrivatePages: Bool(true), 18056 }, 18057 Repository: &Repository{ 18058 ID: Int64(1), 18059 URL: String("s"), 18060 Name: String("n"), 18061 }, 18062 Sender: &User{ 18063 Login: String("l"), 18064 ID: Int64(1), 18065 NodeID: String("n"), 18066 URL: String("u"), 18067 ReposURL: String("r"), 18068 EventsURL: String("e"), 18069 AvatarURL: String("a"), 18070 }, 18071 } 18072 18073 want := `{ 18074 "changes": { 18075 "from": { 18076 "security_and_analysis": { 18077 "advanced_security": { 18078 "status": "enabled" 18079 }, 18080 "secret_scanning": { 18081 "status": "enabled" 18082 }, 18083 "secret_scanning_push_protection": { 18084 "status": "enabled" 18085 }, 18086 "dependabot_security_updates": { 18087 "status": "enabled" 18088 } 18089 } 18090 } 18091 }, 18092 "enterprise": { 18093 "id": 1, 18094 "slug": "s", 18095 "name": "n", 18096 "node_id": "nid", 18097 "avatar_url": "au", 18098 "description": "d", 18099 "website_url": "wu", 18100 "html_url": "hu", 18101 "created_at": ` + referenceTimeStr + `, 18102 "updated_at": ` + referenceTimeStr + ` 18103 }, 18104 "installation": { 18105 "id": 1, 18106 "node_id": "nid", 18107 "app_id": 1, 18108 "app_slug": "as", 18109 "target_id": 1, 18110 "account": { 18111 "login": "l", 18112 "id": 1, 18113 "avatar_url": "a", 18114 "gravatar_id": "g", 18115 "name": "n", 18116 "company": "c", 18117 "blog": "b", 18118 "location": "l", 18119 "email": "e", 18120 "hireable": true, 18121 "bio": "b", 18122 "twitter_username": "t", 18123 "public_repos": 1, 18124 "followers": 1, 18125 "following": 1, 18126 "created_at": ` + referenceTimeStr + `, 18127 "suspended_at": ` + referenceTimeStr + `, 18128 "url": "u" 18129 }, 18130 "access_tokens_url": "atu", 18131 "repositories_url": "ru", 18132 "html_url": "hu", 18133 "target_type": "tt", 18134 "single_file_name": "sfn", 18135 "repository_selection": "rs", 18136 "events": [ 18137 "e" 18138 ], 18139 "single_file_paths": [ 18140 "s" 18141 ], 18142 "permissions": { 18143 "actions": "a", 18144 "administration": "ad", 18145 "checks": "c", 18146 "contents": "co", 18147 "content_references": "cr", 18148 "deployments": "d", 18149 "environments": "e", 18150 "issues": "i", 18151 "metadata": "md", 18152 "members": "m", 18153 "organization_administration": "oa", 18154 "organization_hooks": "oh", 18155 "organization_plan": "op", 18156 "organization_pre_receive_hooks": "opr", 18157 "organization_projects": "op", 18158 "organization_secrets": "os", 18159 "organization_self_hosted_runners": "osh", 18160 "organization_user_blocking": "oub", 18161 "packages": "pkg", 18162 "pages": "pg", 18163 "pull_requests": "pr", 18164 "repository_hooks": "rh", 18165 "repository_projects": "rp", 18166 "repository_pre_receive_hooks": "rprh", 18167 "secrets": "s", 18168 "secret_scanning_alerts": "ssa", 18169 "security_events": "se", 18170 "single_file": "sf", 18171 "statuses": "s", 18172 "team_discussions": "td", 18173 "vulnerability_alerts": "va", 18174 "workflows": "w" 18175 }, 18176 "created_at": ` + referenceTimeStr + `, 18177 "updated_at": ` + referenceTimeStr + `, 18178 "has_multiple_single_files": false, 18179 "suspended_by": { 18180 "login": "l", 18181 "id": 1, 18182 "avatar_url": "a", 18183 "gravatar_id": "g", 18184 "name": "n", 18185 "company": "c", 18186 "blog": "b", 18187 "location": "l", 18188 "email": "e", 18189 "hireable": true, 18190 "bio": "b", 18191 "twitter_username": "t", 18192 "public_repos": 1, 18193 "followers": 1, 18194 "following": 1, 18195 "created_at": ` + referenceTimeStr + `, 18196 "suspended_at": ` + referenceTimeStr + `, 18197 "url": "u" 18198 }, 18199 "suspended_at": ` + referenceTimeStr + ` 18200 }, 18201 "organization": { 18202 "name": "n", 18203 "company": "c", 18204 "blog": "b", 18205 "location": "loc", 18206 "email": "e", 18207 "twitter_username": "tu", 18208 "description": "d", 18209 "billing_email": "be", 18210 "is_verified": true, 18211 "has_organization_projects": true, 18212 "has_repository_projects": true, 18213 "default_repository_permission": "drp", 18214 "members_can_create_repositories": true, 18215 "members_can_create_public_repositories": false, 18216 "members_can_create_private_repositories": true, 18217 "members_can_create_internal_repositories": true, 18218 "members_allowed_repository_creation_type": "marct", 18219 "members_can_create_pages": true, 18220 "members_can_create_public_pages": false, 18221 "members_can_create_private_pages": true 18222 }, 18223 "repository": { 18224 "id": 1, 18225 "url": "s", 18226 "name": "n" 18227 }, 18228 "sender": { 18229 "login": "l", 18230 "id": 1, 18231 "node_id": "n", 18232 "avatar_url": "a", 18233 "url": "u", 18234 "events_url": "e", 18235 "repos_url": "r" 18236 }, 18237 "target_type": "running" 18238 }` 18239 18240 testJSONMarshal(t, u, want) 18241 } 18242 18243 func TestCodeScanningAlertEvent_Marshal(t *testing.T) { 18244 t.Parallel() 18245 testJSONMarshal(t, &CodeScanningAlertEvent{}, "{}") 18246 18247 u := &CodeScanningAlertEvent{ 18248 Action: String("reopened"), 18249 Alert: &Alert{ 18250 Number: Int(10), 18251 Rule: &Rule{ 18252 ID: String("Style/FrozenStringLiteralComment"), 18253 Severity: String("note"), 18254 Description: String("desc"), 18255 FullDescription: String("full desc"), 18256 Tags: []string{"style"}, 18257 Help: String("help"), 18258 }, 18259 Tool: &Tool{ 18260 Name: String("Rubocop"), 18261 Version: nil, 18262 }, 18263 CreatedAt: &Timestamp{referenceTime}, 18264 UpdatedAt: &Timestamp{referenceTime}, 18265 FixedAt: nil, 18266 State: String("open"), 18267 URL: String("a"), 18268 HTMLURL: String("a"), 18269 Instances: []*MostRecentInstance{ 18270 { 18271 Ref: String("refs/heads/main"), 18272 AnalysisKey: String(".github/workflows/workflow.yml:upload"), 18273 Environment: String("{}"), 18274 State: String("open"), 18275 }, 18276 }, 18277 DismissedBy: nil, 18278 DismissedAt: nil, 18279 DismissedReason: nil, 18280 }, 18281 Ref: String("refs/heads/main"), 18282 CommitOID: String("d6e4c75c141dbacecc279b721b8bsomeSHA"), 18283 Repo: &Repository{ 18284 ID: Int64(1234234535), 18285 NodeID: String("MDEwOlJlcG9zaXRvcnkxODY4NT=="), 18286 Owner: &User{ 18287 Login: String("Codertocat"), 18288 ID: Int64(21031067), 18289 NodeID: String("MDQ6VXNlcjIxMDMxMDY3"), 18290 AvatarURL: String("a"), 18291 GravatarID: String(""), 18292 URL: String("a"), 18293 HTMLURL: String("a"), 18294 Type: String("User"), 18295 SiteAdmin: Bool(false), 18296 FollowersURL: String("a"), 18297 FollowingURL: String("a"), 18298 EventsURL: String("a"), 18299 GistsURL: String("a"), 18300 OrganizationsURL: String("a"), 18301 ReceivedEventsURL: String("a"), 18302 ReposURL: String("a"), 18303 StarredURL: String("a"), 18304 SubscriptionsURL: String("a"), 18305 }, 18306 HTMLURL: String("a"), 18307 Name: String("Hello-World"), 18308 FullName: String("Codertocat/Hello-World"), 18309 Description: nil, 18310 Fork: Bool(false), 18311 Homepage: nil, 18312 DefaultBranch: String("main"), 18313 CreatedAt: &Timestamp{referenceTime}, 18314 PushedAt: &Timestamp{referenceTime}, 18315 UpdatedAt: &Timestamp{referenceTime}, 18316 CloneURL: String("a"), 18317 GitURL: String("a"), 18318 MirrorURL: nil, 18319 SSHURL: String("a"), 18320 SVNURL: String("a"), 18321 Language: nil, 18322 ForksCount: Int(0), 18323 OpenIssuesCount: Int(2), 18324 OpenIssues: Int(2), 18325 StargazersCount: Int(0), 18326 WatchersCount: Int(0), 18327 Watchers: Int(0), 18328 Size: Int(0), 18329 Archived: Bool(false), 18330 Disabled: Bool(false), 18331 License: nil, 18332 Private: Bool(false), 18333 HasIssues: Bool(true), 18334 HasWiki: Bool(true), 18335 HasPages: Bool(true), 18336 HasProjects: Bool(true), 18337 HasDownloads: Bool(true), 18338 URL: String("a"), 18339 ArchiveURL: String("a"), 18340 AssigneesURL: String("a"), 18341 BlobsURL: String("a"), 18342 BranchesURL: String("a"), 18343 CollaboratorsURL: String("a"), 18344 CommentsURL: String("a"), 18345 CommitsURL: String("a"), 18346 CompareURL: String("a"), 18347 ContentsURL: String("a"), 18348 ContributorsURL: String("a"), 18349 DeploymentsURL: String("a"), 18350 DownloadsURL: String("a"), 18351 EventsURL: String("a"), 18352 ForksURL: String("a"), 18353 GitCommitsURL: String("a"), 18354 GitRefsURL: String("a"), 18355 GitTagsURL: String("a"), 18356 HooksURL: String("a"), 18357 IssueCommentURL: String("a"), 18358 IssueEventsURL: String("a"), 18359 IssuesURL: String("a"), 18360 KeysURL: String("a"), 18361 LabelsURL: String("a"), 18362 LanguagesURL: String("a"), 18363 MergesURL: String("a"), 18364 MilestonesURL: String("a"), 18365 NotificationsURL: String("a"), 18366 PullsURL: String("a"), 18367 ReleasesURL: String("a"), 18368 StargazersURL: String("a"), 18369 StatusesURL: String("a"), 18370 SubscribersURL: String("a"), 18371 SubscriptionURL: String("a"), 18372 TagsURL: String("a"), 18373 TreesURL: String("a"), 18374 TeamsURL: String("a"), 18375 }, 18376 Org: &Organization{ 18377 Login: String("Octocoders"), 18378 ID: Int64(6), 18379 NodeID: String("MDEyOk9yZ2FuaXphdGlvbjY="), 18380 AvatarURL: String("a"), 18381 Description: String(""), 18382 URL: String("a"), 18383 EventsURL: String("a"), 18384 HooksURL: String("a"), 18385 IssuesURL: String("a"), 18386 MembersURL: String("a"), 18387 PublicMembersURL: String("a"), 18388 ReposURL: String("a"), 18389 }, 18390 Sender: &User{ 18391 Login: String("github"), 18392 ID: Int64(9919), 18393 NodeID: String("MDEyOk9yZ2FuaXphdGlvbjk5MTk="), 18394 AvatarURL: String("a"), 18395 HTMLURL: String("a"), 18396 GravatarID: String(""), 18397 Type: String("Organization"), 18398 SiteAdmin: Bool(false), 18399 URL: String("a"), 18400 EventsURL: String("a"), 18401 FollowingURL: String("a"), 18402 FollowersURL: String("a"), 18403 GistsURL: String("a"), 18404 OrganizationsURL: String("a"), 18405 ReceivedEventsURL: String("a"), 18406 ReposURL: String("a"), 18407 StarredURL: String("a"), 18408 SubscriptionsURL: String("a"), 18409 }, 18410 } 18411 18412 want := `{ 18413 "action": "reopened", 18414 "alert": { 18415 "number": 10, 18416 "created_at": ` + referenceTimeStr + `, 18417 "updated_at": ` + referenceTimeStr + `, 18418 "url": "a", 18419 "html_url": "a", 18420 "instances": [ 18421 { 18422 "ref": "refs/heads/main", 18423 "analysis_key": ".github/workflows/workflow.yml:upload", 18424 "environment": "{}", 18425 "state": "open" 18426 } 18427 ], 18428 "state": "open", 18429 "fixed_at": null, 18430 "dismissed_by": null, 18431 "dismissed_at": null, 18432 "dismissed_reason": null, 18433 "rule": { 18434 "id": "Style/FrozenStringLiteralComment", 18435 "severity": "note", 18436 "description": "desc", 18437 "full_description": "full desc", 18438 "tags": [ 18439 "style" 18440 ], 18441 "help": "help" 18442 }, 18443 "tool": { 18444 "name": "Rubocop", 18445 "version": null 18446 } 18447 }, 18448 "ref": "refs/heads/main", 18449 "commit_oid": "d6e4c75c141dbacecc279b721b8bsomeSHA", 18450 "repository": { 18451 "id": 1234234535, 18452 "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NT==", 18453 "name": "Hello-World", 18454 "full_name": "Codertocat/Hello-World", 18455 "private": false, 18456 "owner": { 18457 "login": "Codertocat", 18458 "id": 21031067, 18459 "node_id": "MDQ6VXNlcjIxMDMxMDY3", 18460 "avatar_url": "a", 18461 "gravatar_id": "", 18462 "url": "a", 18463 "html_url": "a", 18464 "followers_url": "a", 18465 "following_url": "a", 18466 "gists_url": "a", 18467 "starred_url": "a", 18468 "subscriptions_url": "a", 18469 "organizations_url": "a", 18470 "repos_url": "a", 18471 "events_url": "a", 18472 "received_events_url": "a", 18473 "type": "User", 18474 "site_admin": false 18475 }, 18476 "html_url": "a", 18477 "description": null, 18478 "fork": false, 18479 "url": "a", 18480 "forks_url": "a", 18481 "keys_url": "a", 18482 "collaborators_url": "a", 18483 "teams_url": "a", 18484 "hooks_url": "a", 18485 "issue_events_url": "a", 18486 "events_url": "a", 18487 "assignees_url": "a", 18488 "branches_url": "a", 18489 "tags_url": "a", 18490 "blobs_url": "a", 18491 "git_tags_url": "a", 18492 "git_refs_url": "a", 18493 "trees_url": "a", 18494 "statuses_url": "a", 18495 "languages_url": "a", 18496 "stargazers_url": "a", 18497 "contributors_url": "a", 18498 "subscribers_url": "a", 18499 "subscription_url": "a", 18500 "commits_url": "a", 18501 "git_commits_url": "a", 18502 "comments_url": "a", 18503 "issue_comment_url": "a", 18504 "contents_url": "a", 18505 "compare_url": "a", 18506 "merges_url": "a", 18507 "archive_url": "a", 18508 "downloads_url": "a", 18509 "issues_url": "a", 18510 "pulls_url": "a", 18511 "milestones_url": "a", 18512 "notifications_url": "a", 18513 "labels_url": "a", 18514 "releases_url": "a", 18515 "deployments_url": "a", 18516 "created_at": ` + referenceTimeStr + `, 18517 "updated_at": ` + referenceTimeStr + `, 18518 "pushed_at": ` + referenceTimeStr + `, 18519 "git_url": "a", 18520 "ssh_url": "a", 18521 "clone_url": "a", 18522 "svn_url": "a", 18523 "homepage": null, 18524 "size": 0, 18525 "stargazers_count": 0, 18526 "watchers_count": 0, 18527 "language": null, 18528 "has_issues": true, 18529 "has_projects": true, 18530 "has_downloads": true, 18531 "has_wiki": true, 18532 "has_pages": true, 18533 "forks_count": 0, 18534 "mirror_url": null, 18535 "archived": false, 18536 "disabled": false, 18537 "open_issues_count": 2, 18538 "license": null, 18539 "forks": 0, 18540 "open_issues": 2, 18541 "watchers": 0, 18542 "default_branch": "main" 18543 }, 18544 "organization": { 18545 "login": "Octocoders", 18546 "id": 6, 18547 "node_id": "MDEyOk9yZ2FuaXphdGlvbjY=", 18548 "url": "a", 18549 "repos_url": "a", 18550 "events_url": "a", 18551 "hooks_url": "a", 18552 "issues_url": "a", 18553 "members_url": "a", 18554 "public_members_url": "a", 18555 "avatar_url": "a", 18556 "description": "" 18557 }, 18558 "sender": { 18559 "login": "github", 18560 "id": 9919, 18561 "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", 18562 "avatar_url": "a", 18563 "gravatar_id": "", 18564 "url": "a", 18565 "html_url": "a", 18566 "followers_url": "a", 18567 "following_url": "a", 18568 "gists_url": "a", 18569 "starred_url": "a", 18570 "subscriptions_url": "a", 18571 "organizations_url": "a", 18572 "repos_url": "a", 18573 "events_url": "a", 18574 "received_events_url": "a", 18575 "type": "Organization", 18576 "site_admin": false 18577 } 18578 }` 18579 18580 testJSONMarshal(t, u, want) 18581 } 18582 18583 func TestSponsorshipEvent_Marshal(t *testing.T) { 18584 t.Parallel() 18585 testJSONMarshal(t, &SponsorshipEvent{}, "{}") 18586 18587 u := &SponsorshipEvent{ 18588 Action: String("created"), 18589 EffectiveDate: String("2023-01-01T00:00:00Z"), 18590 Changes: &SponsorshipChanges{ 18591 Tier: &SponsorshipTier{ 18592 From: String("basic"), 18593 }, 18594 PrivacyLevel: String("public"), 18595 }, 18596 Repository: &Repository{ 18597 ID: Int64(12345), 18598 NodeID: String("MDEwOlJlcG9zaXRvcnkxMjM0NQ=="), 18599 Name: String("example-repo"), 18600 }, 18601 Organization: &Organization{ 18602 Login: String("example-org"), 18603 ID: Int64(67890), 18604 }, 18605 Sender: &User{ 18606 Login: String("example-user"), 18607 ID: Int64(1111), 18608 }, 18609 Installation: &Installation{ 18610 ID: Int64(2222), 18611 }, 18612 } 18613 18614 want := `{ 18615 "action": "created", 18616 "effective_date": "2023-01-01T00:00:00Z", 18617 "changes": { 18618 "tier": { 18619 "from": "basic" 18620 }, 18621 "privacy_level": "public" 18622 }, 18623 "repository": { 18624 "id": 12345, 18625 "node_id": "MDEwOlJlcG9zaXRvcnkxMjM0NQ==", 18626 "name": "example-repo" 18627 }, 18628 "organization": { 18629 "login": "example-org", 18630 "id": 67890 18631 }, 18632 "sender": { 18633 "login": "example-user", 18634 "id": 1111 18635 }, 18636 "installation": { 18637 "id": 2222 18638 } 18639 }` 18640 18641 testJSONMarshal(t, u, want) 18642 } 18643 18644 func TestSponsorshipChanges_Marshal(t *testing.T) { 18645 t.Parallel() 18646 testJSONMarshal(t, &SponsorshipChanges{}, "{}") 18647 18648 u := &SponsorshipChanges{ 18649 Tier: &SponsorshipTier{ 18650 From: String("premium"), 18651 }, 18652 PrivacyLevel: String("private"), 18653 } 18654 18655 want := `{ 18656 "tier": { 18657 "from": "premium" 18658 }, 18659 "privacy_level": "private" 18660 }` 18661 18662 testJSONMarshal(t, u, want) 18663 } 18664 18665 func TestSponsorshipTier_Marshal(t *testing.T) { 18666 t.Parallel() 18667 testJSONMarshal(t, &SponsorshipTier{}, "{}") 18668 18669 u := &SponsorshipTier{ 18670 From: String("gold"), 18671 } 18672 18673 want := `{ 18674 "from": "gold" 18675 }` 18676 18677 testJSONMarshal(t, u, want) 18678 }