github.com/google/go-github/v68@v68.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: Ptr("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: Ptr("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: Ptr("BaseRefFrom"), 62 }, 63 SHA: &EditSHA{ 64 From: Ptr("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: Ptr("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: Ptr("l"), 129 ID: Ptr(int64(1)), 130 NodeID: Ptr("n"), 131 URL: Ptr("u"), 132 ReposURL: Ptr("r"), 133 EventsURL: Ptr("e"), 134 AvatarURL: Ptr("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: Ptr("l"), 168 ID: Ptr(int64(1)), 169 NodeID: Ptr("n"), 170 URL: Ptr("u"), 171 ReposURL: Ptr("r"), 172 EventsURL: Ptr("e"), 173 AvatarURL: Ptr("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: Ptr("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: Ptr("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: Ptr("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: Ptr("NameFrom")}, 257 } 258 259 want := `{ 260 "name": { 261 "from": "NameFrom" 262 } 263 }` 264 265 testJSONMarshal(t, u, want) 266 } 267 268 func TestBranchProtectionConfigurationEvent_Marshal(t *testing.T) { 269 t.Parallel() 270 testJSONMarshal(t, &BranchProtectionConfigurationEvent{}, "{}") 271 u := &BranchProtectionConfigurationEvent{ 272 Action: Ptr("enabled"), 273 Repo: &Repository{ 274 ID: Ptr(int64(12345)), 275 NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjM0NQ=="), 276 Name: Ptr("example-repo"), 277 }, 278 Org: &Organization{ 279 Login: Ptr("example-org"), 280 ID: Ptr(int64(67890)), 281 }, 282 Sender: &User{ 283 Login: Ptr("example-user"), 284 ID: Ptr(int64(1111)), 285 }, 286 Installation: &Installation{ 287 ID: Ptr(int64(2222)), 288 }, 289 Enterprise: &Enterprise{ 290 ID: Ptr(3333), 291 Slug: Ptr("example-enterprise"), 292 Name: Ptr("Example Enterprise"), 293 }, 294 } 295 296 want := `{ 297 "action": "enabled", 298 "repository": { 299 "id": 12345, 300 "node_id": "MDEwOlJlcG9zaXRvcnkxMjM0NQ==", 301 "name": "example-repo" 302 }, 303 "organization": { 304 "login": "example-org", 305 "id": 67890 306 }, 307 "sender": { 308 "login": "example-user", 309 "id": 1111 310 }, 311 "installation": { 312 "id": 2222 313 }, 314 "enterprise": { 315 "id": 3333, 316 "slug": "example-enterprise", 317 "name": "Example Enterprise" 318 } 319 }` 320 testJSONMarshal(t, u, want) 321 } 322 323 func TestTeamAddEvent_Marshal(t *testing.T) { 324 t.Parallel() 325 testJSONMarshal(t, &TeamAddEvent{}, "{}") 326 327 u := &TeamAddEvent{ 328 Team: &Team{ 329 ID: Ptr(int64(1)), 330 NodeID: Ptr("n"), 331 Name: Ptr("n"), 332 Description: Ptr("d"), 333 URL: Ptr("u"), 334 Slug: Ptr("s"), 335 Permission: Ptr("p"), 336 Privacy: Ptr("p"), 337 MembersCount: Ptr(1), 338 ReposCount: Ptr(1), 339 MembersURL: Ptr("m"), 340 RepositoriesURL: Ptr("r"), 341 Organization: &Organization{ 342 Login: Ptr("l"), 343 ID: Ptr(int64(1)), 344 NodeID: Ptr("n"), 345 AvatarURL: Ptr("a"), 346 HTMLURL: Ptr("h"), 347 Name: Ptr("n"), 348 Company: Ptr("c"), 349 Blog: Ptr("b"), 350 Location: Ptr("l"), 351 Email: Ptr("e"), 352 }, 353 Parent: &Team{ 354 ID: Ptr(int64(1)), 355 NodeID: Ptr("n"), 356 Name: Ptr("n"), 357 Description: Ptr("d"), 358 URL: Ptr("u"), 359 Slug: Ptr("s"), 360 Permission: Ptr("p"), 361 Privacy: Ptr("p"), 362 MembersCount: Ptr(1), 363 ReposCount: Ptr(1), 364 }, 365 LDAPDN: Ptr("l"), 366 }, 367 Repo: &Repository{ 368 ID: Ptr(int64(1)), 369 URL: Ptr("s"), 370 Name: Ptr("n"), 371 }, 372 Org: &Organization{ 373 BillingEmail: Ptr("be"), 374 Blog: Ptr("b"), 375 Company: Ptr("c"), 376 Email: Ptr("e"), 377 TwitterUsername: Ptr("tu"), 378 Location: Ptr("loc"), 379 Name: Ptr("n"), 380 Description: Ptr("d"), 381 IsVerified: Ptr(true), 382 HasOrganizationProjects: Ptr(true), 383 HasRepositoryProjects: Ptr(true), 384 DefaultRepoPermission: Ptr("drp"), 385 MembersCanCreateRepos: Ptr(true), 386 MembersCanCreateInternalRepos: Ptr(true), 387 MembersCanCreatePrivateRepos: Ptr(true), 388 MembersCanCreatePublicRepos: Ptr(false), 389 MembersAllowedRepositoryCreationType: Ptr("marct"), 390 MembersCanCreatePages: Ptr(true), 391 MembersCanCreatePublicPages: Ptr(false), 392 MembersCanCreatePrivatePages: Ptr(true), 393 }, 394 Sender: &User{ 395 Login: Ptr("l"), 396 ID: Ptr(int64(1)), 397 NodeID: Ptr("n"), 398 URL: Ptr("u"), 399 ReposURL: Ptr("r"), 400 EventsURL: Ptr("e"), 401 AvatarURL: Ptr("a"), 402 }, 403 Installation: &Installation{ 404 ID: Ptr(int64(1)), 405 NodeID: Ptr("nid"), 406 AppID: Ptr(int64(1)), 407 AppSlug: Ptr("as"), 408 TargetID: Ptr(int64(1)), 409 Account: &User{ 410 Login: Ptr("l"), 411 ID: Ptr(int64(1)), 412 URL: Ptr("u"), 413 AvatarURL: Ptr("a"), 414 GravatarID: Ptr("g"), 415 Name: Ptr("n"), 416 Company: Ptr("c"), 417 Blog: Ptr("b"), 418 Location: Ptr("l"), 419 Email: Ptr("e"), 420 Hireable: Ptr(true), 421 Bio: Ptr("b"), 422 TwitterUsername: Ptr("t"), 423 PublicRepos: Ptr(1), 424 Followers: Ptr(1), 425 Following: Ptr(1), 426 CreatedAt: &Timestamp{referenceTime}, 427 SuspendedAt: &Timestamp{referenceTime}, 428 }, 429 AccessTokensURL: Ptr("atu"), 430 RepositoriesURL: Ptr("ru"), 431 HTMLURL: Ptr("hu"), 432 TargetType: Ptr("tt"), 433 SingleFileName: Ptr("sfn"), 434 RepositorySelection: Ptr("rs"), 435 Events: []string{"e"}, 436 SingleFilePaths: []string{"s"}, 437 Permissions: &InstallationPermissions{ 438 Actions: Ptr("a"), 439 Administration: Ptr("ad"), 440 Checks: Ptr("c"), 441 Contents: Ptr("co"), 442 ContentReferences: Ptr("cr"), 443 Deployments: Ptr("d"), 444 Environments: Ptr("e"), 445 Issues: Ptr("i"), 446 Metadata: Ptr("md"), 447 Members: Ptr("m"), 448 OrganizationAdministration: Ptr("oa"), 449 OrganizationHooks: Ptr("oh"), 450 OrganizationPlan: Ptr("op"), 451 OrganizationPreReceiveHooks: Ptr("opr"), 452 OrganizationProjects: Ptr("op"), 453 OrganizationSecrets: Ptr("os"), 454 OrganizationSelfHostedRunners: Ptr("osh"), 455 OrganizationUserBlocking: Ptr("oub"), 456 Packages: Ptr("pkg"), 457 Pages: Ptr("pg"), 458 PullRequests: Ptr("pr"), 459 RepositoryHooks: Ptr("rh"), 460 RepositoryProjects: Ptr("rp"), 461 RepositoryPreReceiveHooks: Ptr("rprh"), 462 Secrets: Ptr("s"), 463 SecretScanningAlerts: Ptr("ssa"), 464 SecurityEvents: Ptr("se"), 465 SingleFile: Ptr("sf"), 466 Statuses: Ptr("s"), 467 TeamDiscussions: Ptr("td"), 468 VulnerabilityAlerts: Ptr("va"), 469 Workflows: Ptr("w"), 470 }, 471 CreatedAt: &Timestamp{referenceTime}, 472 UpdatedAt: &Timestamp{referenceTime}, 473 HasMultipleSingleFiles: Ptr(false), 474 SuspendedBy: &User{ 475 Login: Ptr("l"), 476 ID: Ptr(int64(1)), 477 URL: Ptr("u"), 478 AvatarURL: Ptr("a"), 479 GravatarID: Ptr("g"), 480 Name: Ptr("n"), 481 Company: Ptr("c"), 482 Blog: Ptr("b"), 483 Location: Ptr("l"), 484 Email: Ptr("e"), 485 Hireable: Ptr(true), 486 Bio: Ptr("b"), 487 TwitterUsername: Ptr("t"), 488 PublicRepos: Ptr(1), 489 Followers: Ptr(1), 490 Following: Ptr(1), 491 CreatedAt: &Timestamp{referenceTime}, 492 SuspendedAt: &Timestamp{referenceTime}, 493 }, 494 SuspendedAt: &Timestamp{referenceTime}, 495 }, 496 } 497 498 want := `{ 499 "team": { 500 "id": 1, 501 "node_id": "n", 502 "name": "n", 503 "description": "d", 504 "url": "u", 505 "slug": "s", 506 "permission": "p", 507 "privacy": "p", 508 "members_count": 1, 509 "repos_count": 1, 510 "organization": { 511 "login": "l", 512 "id": 1, 513 "node_id": "n", 514 "avatar_url": "a", 515 "html_url": "h", 516 "name": "n", 517 "company": "c", 518 "blog": "b", 519 "location": "l", 520 "email": "e" 521 }, 522 "members_url": "m", 523 "repositories_url": "r", 524 "parent": { 525 "id": 1, 526 "node_id": "n", 527 "name": "n", 528 "description": "d", 529 "url": "u", 530 "slug": "s", 531 "permission": "p", 532 "privacy": "p", 533 "members_count": 1, 534 "repos_count": 1 535 }, 536 "ldap_dn": "l" 537 }, 538 "repository": { 539 "id": 1, 540 "name": "n", 541 "url": "s" 542 }, 543 "organization": { 544 "name": "n", 545 "company": "c", 546 "blog": "b", 547 "location": "loc", 548 "email": "e", 549 "twitter_username": "tu", 550 "description": "d", 551 "billing_email": "be", 552 "is_verified": true, 553 "has_organization_projects": true, 554 "has_repository_projects": true, 555 "default_repository_permission": "drp", 556 "members_can_create_repositories": true, 557 "members_can_create_public_repositories": false, 558 "members_can_create_private_repositories": true, 559 "members_can_create_internal_repositories": true, 560 "members_allowed_repository_creation_type": "marct", 561 "members_can_create_pages": true, 562 "members_can_create_public_pages": false, 563 "members_can_create_private_pages": true 564 }, 565 "sender": { 566 "login": "l", 567 "id": 1, 568 "node_id": "n", 569 "avatar_url": "a", 570 "url": "u", 571 "events_url": "e", 572 "repos_url": "r" 573 }, 574 "installation": { 575 "id": 1, 576 "node_id": "nid", 577 "app_id": 1, 578 "app_slug": "as", 579 "target_id": 1, 580 "account": { 581 "login": "l", 582 "id": 1, 583 "avatar_url": "a", 584 "gravatar_id": "g", 585 "name": "n", 586 "company": "c", 587 "blog": "b", 588 "location": "l", 589 "email": "e", 590 "hireable": true, 591 "bio": "b", 592 "twitter_username": "t", 593 "public_repos": 1, 594 "followers": 1, 595 "following": 1, 596 "created_at": ` + referenceTimeStr + `, 597 "suspended_at": ` + referenceTimeStr + `, 598 "url": "u" 599 }, 600 "access_tokens_url": "atu", 601 "repositories_url": "ru", 602 "html_url": "hu", 603 "target_type": "tt", 604 "single_file_name": "sfn", 605 "repository_selection": "rs", 606 "events": [ 607 "e" 608 ], 609 "single_file_paths": [ 610 "s" 611 ], 612 "permissions": { 613 "actions": "a", 614 "administration": "ad", 615 "checks": "c", 616 "contents": "co", 617 "content_references": "cr", 618 "deployments": "d", 619 "environments": "e", 620 "issues": "i", 621 "metadata": "md", 622 "members": "m", 623 "organization_administration": "oa", 624 "organization_hooks": "oh", 625 "organization_plan": "op", 626 "organization_pre_receive_hooks": "opr", 627 "organization_projects": "op", 628 "organization_secrets": "os", 629 "organization_self_hosted_runners": "osh", 630 "organization_user_blocking": "oub", 631 "packages": "pkg", 632 "pages": "pg", 633 "pull_requests": "pr", 634 "repository_hooks": "rh", 635 "repository_projects": "rp", 636 "repository_pre_receive_hooks": "rprh", 637 "secrets": "s", 638 "secret_scanning_alerts": "ssa", 639 "security_events": "se", 640 "single_file": "sf", 641 "statuses": "s", 642 "team_discussions": "td", 643 "vulnerability_alerts": "va", 644 "workflows": "w" 645 }, 646 "created_at": ` + referenceTimeStr + `, 647 "updated_at": ` + referenceTimeStr + `, 648 "has_multiple_single_files": false, 649 "suspended_by": { 650 "login": "l", 651 "id": 1, 652 "avatar_url": "a", 653 "gravatar_id": "g", 654 "name": "n", 655 "company": "c", 656 "blog": "b", 657 "location": "l", 658 "email": "e", 659 "hireable": true, 660 "bio": "b", 661 "twitter_username": "t", 662 "public_repos": 1, 663 "followers": 1, 664 "following": 1, 665 "created_at": ` + referenceTimeStr + `, 666 "suspended_at": ` + referenceTimeStr + `, 667 "url": "u" 668 }, 669 "suspended_at": ` + referenceTimeStr + ` 670 } 671 }` 672 673 testJSONMarshal(t, u, want) 674 } 675 676 func TestStarEvent_Marshal(t *testing.T) { 677 t.Parallel() 678 testJSONMarshal(t, &StarEvent{}, "{}") 679 680 u := &StarEvent{ 681 Action: Ptr("a"), 682 StarredAt: &Timestamp{referenceTime}, 683 Org: &Organization{ 684 BillingEmail: Ptr("be"), 685 Blog: Ptr("b"), 686 Company: Ptr("c"), 687 Email: Ptr("e"), 688 TwitterUsername: Ptr("tu"), 689 Location: Ptr("loc"), 690 Name: Ptr("n"), 691 Description: Ptr("d"), 692 IsVerified: Ptr(true), 693 HasOrganizationProjects: Ptr(true), 694 HasRepositoryProjects: Ptr(true), 695 DefaultRepoPermission: Ptr("drp"), 696 MembersCanCreateRepos: Ptr(true), 697 MembersCanCreateInternalRepos: Ptr(true), 698 MembersCanCreatePrivateRepos: Ptr(true), 699 MembersCanCreatePublicRepos: Ptr(false), 700 MembersAllowedRepositoryCreationType: Ptr("marct"), 701 MembersCanCreatePages: Ptr(true), 702 MembersCanCreatePublicPages: Ptr(false), 703 MembersCanCreatePrivatePages: Ptr(true), 704 }, 705 Repo: &Repository{ 706 ID: Ptr(int64(1)), 707 URL: Ptr("s"), 708 Name: Ptr("n"), 709 }, 710 Sender: &User{ 711 Login: Ptr("l"), 712 ID: Ptr(int64(1)), 713 NodeID: Ptr("n"), 714 URL: Ptr("u"), 715 ReposURL: Ptr("r"), 716 EventsURL: Ptr("e"), 717 AvatarURL: Ptr("a"), 718 }, 719 } 720 721 want := `{ 722 "action": "a", 723 "starred_at": ` + referenceTimeStr + `, 724 "organization": { 725 "name": "n", 726 "company": "c", 727 "blog": "b", 728 "location": "loc", 729 "email": "e", 730 "twitter_username": "tu", 731 "description": "d", 732 "billing_email": "be", 733 "is_verified": true, 734 "has_organization_projects": true, 735 "has_repository_projects": true, 736 "default_repository_permission": "drp", 737 "members_can_create_repositories": true, 738 "members_can_create_public_repositories": false, 739 "members_can_create_private_repositories": true, 740 "members_can_create_internal_repositories": true, 741 "members_allowed_repository_creation_type": "marct", 742 "members_can_create_pages": true, 743 "members_can_create_public_pages": false, 744 "members_can_create_private_pages": true 745 }, 746 "repository": { 747 "id": 1, 748 "name": "n", 749 "url": "s" 750 }, 751 "sender": { 752 "login": "l", 753 "id": 1, 754 "node_id": "n", 755 "avatar_url": "a", 756 "url": "u", 757 "events_url": "e", 758 "repos_url": "r" 759 } 760 }` 761 762 testJSONMarshal(t, u, want) 763 } 764 765 func TestTeamEvent_Marshal(t *testing.T) { 766 t.Parallel() 767 testJSONMarshal(t, &TeamEvent{}, "{}") 768 769 u := &TeamEvent{ 770 Action: Ptr("a"), 771 Team: &Team{ 772 ID: Ptr(int64(1)), 773 NodeID: Ptr("n"), 774 Name: Ptr("n"), 775 Description: Ptr("d"), 776 URL: Ptr("u"), 777 Slug: Ptr("s"), 778 Permission: Ptr("p"), 779 Privacy: Ptr("p"), 780 MembersCount: Ptr(1), 781 ReposCount: Ptr(1), 782 MembersURL: Ptr("m"), 783 RepositoriesURL: Ptr("r"), 784 Organization: &Organization{ 785 Login: Ptr("l"), 786 ID: Ptr(int64(1)), 787 NodeID: Ptr("n"), 788 AvatarURL: Ptr("a"), 789 HTMLURL: Ptr("h"), 790 Name: Ptr("n"), 791 Company: Ptr("c"), 792 Blog: Ptr("b"), 793 Location: Ptr("l"), 794 Email: Ptr("e"), 795 }, 796 Parent: &Team{ 797 ID: Ptr(int64(1)), 798 NodeID: Ptr("n"), 799 Name: Ptr("n"), 800 Description: Ptr("d"), 801 URL: Ptr("u"), 802 Slug: Ptr("s"), 803 Permission: Ptr("p"), 804 Privacy: Ptr("p"), 805 MembersCount: Ptr(1), 806 ReposCount: Ptr(1), 807 }, 808 LDAPDN: Ptr("l"), 809 }, 810 Changes: &TeamChange{ 811 Description: &TeamDescription{ 812 From: Ptr("from"), 813 }, 814 Name: &TeamName{ 815 From: Ptr("from"), 816 }, 817 Privacy: &TeamPrivacy{ 818 From: Ptr("from"), 819 }, 820 Repository: &TeamRepository{ 821 Permissions: &TeamPermissions{ 822 From: &TeamPermissionsFrom{ 823 Admin: Ptr(true), 824 Pull: Ptr(true), 825 Push: Ptr(true), 826 }, 827 }, 828 }, 829 }, 830 Repo: &Repository{ 831 ID: Ptr(int64(1)), 832 URL: Ptr("s"), 833 Name: Ptr("n"), 834 }, 835 Org: &Organization{ 836 BillingEmail: Ptr("be"), 837 Blog: Ptr("b"), 838 Company: Ptr("c"), 839 Email: Ptr("e"), 840 TwitterUsername: Ptr("tu"), 841 Location: Ptr("loc"), 842 Name: Ptr("n"), 843 Description: Ptr("d"), 844 IsVerified: Ptr(true), 845 HasOrganizationProjects: Ptr(true), 846 HasRepositoryProjects: Ptr(true), 847 DefaultRepoPermission: Ptr("drp"), 848 MembersCanCreateRepos: Ptr(true), 849 MembersCanCreateInternalRepos: Ptr(true), 850 MembersCanCreatePrivateRepos: Ptr(true), 851 MembersCanCreatePublicRepos: Ptr(false), 852 MembersAllowedRepositoryCreationType: Ptr("marct"), 853 MembersCanCreatePages: Ptr(true), 854 MembersCanCreatePublicPages: Ptr(false), 855 MembersCanCreatePrivatePages: Ptr(true), 856 }, 857 Sender: &User{ 858 Login: Ptr("l"), 859 ID: Ptr(int64(1)), 860 NodeID: Ptr("n"), 861 URL: Ptr("u"), 862 ReposURL: Ptr("r"), 863 EventsURL: Ptr("e"), 864 AvatarURL: Ptr("a"), 865 }, 866 Installation: &Installation{ 867 ID: Ptr(int64(1)), 868 NodeID: Ptr("nid"), 869 AppID: Ptr(int64(1)), 870 AppSlug: Ptr("as"), 871 TargetID: Ptr(int64(1)), 872 Account: &User{ 873 Login: Ptr("l"), 874 ID: Ptr(int64(1)), 875 URL: Ptr("u"), 876 AvatarURL: Ptr("a"), 877 GravatarID: Ptr("g"), 878 Name: Ptr("n"), 879 Company: Ptr("c"), 880 Blog: Ptr("b"), 881 Location: Ptr("l"), 882 Email: Ptr("e"), 883 Hireable: Ptr(true), 884 Bio: Ptr("b"), 885 TwitterUsername: Ptr("t"), 886 PublicRepos: Ptr(1), 887 Followers: Ptr(1), 888 Following: Ptr(1), 889 CreatedAt: &Timestamp{referenceTime}, 890 SuspendedAt: &Timestamp{referenceTime}, 891 }, 892 AccessTokensURL: Ptr("atu"), 893 RepositoriesURL: Ptr("ru"), 894 HTMLURL: Ptr("hu"), 895 TargetType: Ptr("tt"), 896 SingleFileName: Ptr("sfn"), 897 RepositorySelection: Ptr("rs"), 898 Events: []string{"e"}, 899 SingleFilePaths: []string{"s"}, 900 Permissions: &InstallationPermissions{ 901 Actions: Ptr("a"), 902 Administration: Ptr("ad"), 903 Checks: Ptr("c"), 904 Contents: Ptr("co"), 905 ContentReferences: Ptr("cr"), 906 Deployments: Ptr("d"), 907 Environments: Ptr("e"), 908 Issues: Ptr("i"), 909 Metadata: Ptr("md"), 910 Members: Ptr("m"), 911 OrganizationAdministration: Ptr("oa"), 912 OrganizationHooks: Ptr("oh"), 913 OrganizationPlan: Ptr("op"), 914 OrganizationPreReceiveHooks: Ptr("opr"), 915 OrganizationProjects: Ptr("op"), 916 OrganizationSecrets: Ptr("os"), 917 OrganizationSelfHostedRunners: Ptr("osh"), 918 OrganizationUserBlocking: Ptr("oub"), 919 Packages: Ptr("pkg"), 920 Pages: Ptr("pg"), 921 PullRequests: Ptr("pr"), 922 RepositoryHooks: Ptr("rh"), 923 RepositoryProjects: Ptr("rp"), 924 RepositoryPreReceiveHooks: Ptr("rprh"), 925 Secrets: Ptr("s"), 926 SecretScanningAlerts: Ptr("ssa"), 927 SecurityEvents: Ptr("se"), 928 SingleFile: Ptr("sf"), 929 Statuses: Ptr("s"), 930 TeamDiscussions: Ptr("td"), 931 VulnerabilityAlerts: Ptr("va"), 932 Workflows: Ptr("w"), 933 }, 934 CreatedAt: &Timestamp{referenceTime}, 935 UpdatedAt: &Timestamp{referenceTime}, 936 HasMultipleSingleFiles: Ptr(false), 937 SuspendedBy: &User{ 938 Login: Ptr("l"), 939 ID: Ptr(int64(1)), 940 URL: Ptr("u"), 941 AvatarURL: Ptr("a"), 942 GravatarID: Ptr("g"), 943 Name: Ptr("n"), 944 Company: Ptr("c"), 945 Blog: Ptr("b"), 946 Location: Ptr("l"), 947 Email: Ptr("e"), 948 Hireable: Ptr(true), 949 Bio: Ptr("b"), 950 TwitterUsername: Ptr("t"), 951 PublicRepos: Ptr(1), 952 Followers: Ptr(1), 953 Following: Ptr(1), 954 CreatedAt: &Timestamp{referenceTime}, 955 SuspendedAt: &Timestamp{referenceTime}, 956 }, 957 SuspendedAt: &Timestamp{referenceTime}, 958 }, 959 } 960 961 want := `{ 962 "action": "a", 963 "team": { 964 "id": 1, 965 "node_id": "n", 966 "name": "n", 967 "description": "d", 968 "url": "u", 969 "slug": "s", 970 "permission": "p", 971 "privacy": "p", 972 "members_count": 1, 973 "repos_count": 1, 974 "organization": { 975 "login": "l", 976 "id": 1, 977 "node_id": "n", 978 "avatar_url": "a", 979 "html_url": "h", 980 "name": "n", 981 "company": "c", 982 "blog": "b", 983 "location": "l", 984 "email": "e" 985 }, 986 "members_url": "m", 987 "repositories_url": "r", 988 "parent": { 989 "id": 1, 990 "node_id": "n", 991 "name": "n", 992 "description": "d", 993 "url": "u", 994 "slug": "s", 995 "permission": "p", 996 "privacy": "p", 997 "members_count": 1, 998 "repos_count": 1 999 }, 1000 "ldap_dn": "l" 1001 }, 1002 "changes": { 1003 "description": { 1004 "from": "from" 1005 }, 1006 "name": { 1007 "from": "from" 1008 }, 1009 "privacy": { 1010 "from": "from" 1011 }, 1012 "repository": { 1013 "permissions": { 1014 "from": { 1015 "admin": true, 1016 "pull": true, 1017 "push": true 1018 } 1019 } 1020 } 1021 }, 1022 "repository": { 1023 "id": 1, 1024 "name": "n", 1025 "url": "s" 1026 }, 1027 "organization": { 1028 "name": "n", 1029 "company": "c", 1030 "blog": "b", 1031 "location": "loc", 1032 "email": "e", 1033 "twitter_username": "tu", 1034 "description": "d", 1035 "billing_email": "be", 1036 "is_verified": true, 1037 "has_organization_projects": true, 1038 "has_repository_projects": true, 1039 "default_repository_permission": "drp", 1040 "members_can_create_repositories": true, 1041 "members_can_create_public_repositories": false, 1042 "members_can_create_private_repositories": true, 1043 "members_can_create_internal_repositories": true, 1044 "members_allowed_repository_creation_type": "marct", 1045 "members_can_create_pages": true, 1046 "members_can_create_public_pages": false, 1047 "members_can_create_private_pages": true 1048 }, 1049 "sender": { 1050 "login": "l", 1051 "id": 1, 1052 "node_id": "n", 1053 "avatar_url": "a", 1054 "url": "u", 1055 "events_url": "e", 1056 "repos_url": "r" 1057 }, 1058 "installation": { 1059 "id": 1, 1060 "node_id": "nid", 1061 "app_id": 1, 1062 "app_slug": "as", 1063 "target_id": 1, 1064 "account": { 1065 "login": "l", 1066 "id": 1, 1067 "avatar_url": "a", 1068 "gravatar_id": "g", 1069 "name": "n", 1070 "company": "c", 1071 "blog": "b", 1072 "location": "l", 1073 "email": "e", 1074 "hireable": true, 1075 "bio": "b", 1076 "twitter_username": "t", 1077 "public_repos": 1, 1078 "followers": 1, 1079 "following": 1, 1080 "created_at": ` + referenceTimeStr + `, 1081 "suspended_at": ` + referenceTimeStr + `, 1082 "url": "u" 1083 }, 1084 "access_tokens_url": "atu", 1085 "repositories_url": "ru", 1086 "html_url": "hu", 1087 "target_type": "tt", 1088 "single_file_name": "sfn", 1089 "repository_selection": "rs", 1090 "events": [ 1091 "e" 1092 ], 1093 "single_file_paths": [ 1094 "s" 1095 ], 1096 "permissions": { 1097 "actions": "a", 1098 "administration": "ad", 1099 "checks": "c", 1100 "contents": "co", 1101 "content_references": "cr", 1102 "deployments": "d", 1103 "environments": "e", 1104 "issues": "i", 1105 "metadata": "md", 1106 "members": "m", 1107 "organization_administration": "oa", 1108 "organization_hooks": "oh", 1109 "organization_plan": "op", 1110 "organization_pre_receive_hooks": "opr", 1111 "organization_projects": "op", 1112 "organization_secrets": "os", 1113 "organization_self_hosted_runners": "osh", 1114 "organization_user_blocking": "oub", 1115 "packages": "pkg", 1116 "pages": "pg", 1117 "pull_requests": "pr", 1118 "repository_hooks": "rh", 1119 "repository_projects": "rp", 1120 "repository_pre_receive_hooks": "rprh", 1121 "secrets": "s", 1122 "secret_scanning_alerts": "ssa", 1123 "security_events": "se", 1124 "single_file": "sf", 1125 "statuses": "s", 1126 "team_discussions": "td", 1127 "vulnerability_alerts": "va", 1128 "workflows": "w" 1129 }, 1130 "created_at": ` + referenceTimeStr + `, 1131 "updated_at": ` + referenceTimeStr + `, 1132 "has_multiple_single_files": false, 1133 "suspended_by": { 1134 "login": "l", 1135 "id": 1, 1136 "avatar_url": "a", 1137 "gravatar_id": "g", 1138 "name": "n", 1139 "company": "c", 1140 "blog": "b", 1141 "location": "l", 1142 "email": "e", 1143 "hireable": true, 1144 "bio": "b", 1145 "twitter_username": "t", 1146 "public_repos": 1, 1147 "followers": 1, 1148 "following": 1, 1149 "created_at": ` + referenceTimeStr + `, 1150 "suspended_at": ` + referenceTimeStr + `, 1151 "url": "u" 1152 }, 1153 "suspended_at": ` + referenceTimeStr + ` 1154 } 1155 }` 1156 1157 testJSONMarshal(t, u, want) 1158 } 1159 1160 func TestInstallationRepositoriesEvent_Marshal(t *testing.T) { 1161 t.Parallel() 1162 testJSONMarshal(t, &InstallationRepositoriesEvent{}, "{}") 1163 1164 u := &InstallationRepositoriesEvent{ 1165 Action: Ptr("a"), 1166 RepositoriesAdded: []*Repository{ 1167 { 1168 ID: Ptr(int64(1)), 1169 URL: Ptr("s"), 1170 Name: Ptr("n"), 1171 }, 1172 }, 1173 RepositoriesRemoved: []*Repository{ 1174 { 1175 ID: Ptr(int64(1)), 1176 URL: Ptr("s"), 1177 Name: Ptr("n"), 1178 }, 1179 }, 1180 RepositorySelection: Ptr("rs"), 1181 Sender: &User{ 1182 Login: Ptr("l"), 1183 ID: Ptr(int64(1)), 1184 NodeID: Ptr("n"), 1185 URL: Ptr("u"), 1186 ReposURL: Ptr("r"), 1187 EventsURL: Ptr("e"), 1188 AvatarURL: Ptr("a"), 1189 }, 1190 Installation: &Installation{ 1191 ID: Ptr(int64(1)), 1192 NodeID: Ptr("nid"), 1193 AppID: Ptr(int64(1)), 1194 AppSlug: Ptr("as"), 1195 TargetID: Ptr(int64(1)), 1196 Account: &User{ 1197 Login: Ptr("l"), 1198 ID: Ptr(int64(1)), 1199 URL: Ptr("u"), 1200 AvatarURL: Ptr("a"), 1201 GravatarID: Ptr("g"), 1202 Name: Ptr("n"), 1203 Company: Ptr("c"), 1204 Blog: Ptr("b"), 1205 Location: Ptr("l"), 1206 Email: Ptr("e"), 1207 Hireable: Ptr(true), 1208 Bio: Ptr("b"), 1209 TwitterUsername: Ptr("t"), 1210 PublicRepos: Ptr(1), 1211 Followers: Ptr(1), 1212 Following: Ptr(1), 1213 CreatedAt: &Timestamp{referenceTime}, 1214 SuspendedAt: &Timestamp{referenceTime}, 1215 }, 1216 AccessTokensURL: Ptr("atu"), 1217 RepositoriesURL: Ptr("ru"), 1218 HTMLURL: Ptr("hu"), 1219 TargetType: Ptr("tt"), 1220 SingleFileName: Ptr("sfn"), 1221 RepositorySelection: Ptr("rs"), 1222 Events: []string{"e"}, 1223 SingleFilePaths: []string{"s"}, 1224 Permissions: &InstallationPermissions{ 1225 Actions: Ptr("a"), 1226 Administration: Ptr("ad"), 1227 Checks: Ptr("c"), 1228 Contents: Ptr("co"), 1229 ContentReferences: Ptr("cr"), 1230 Deployments: Ptr("d"), 1231 Environments: Ptr("e"), 1232 Issues: Ptr("i"), 1233 Metadata: Ptr("md"), 1234 Members: Ptr("m"), 1235 OrganizationAdministration: Ptr("oa"), 1236 OrganizationHooks: Ptr("oh"), 1237 OrganizationPlan: Ptr("op"), 1238 OrganizationPreReceiveHooks: Ptr("opr"), 1239 OrganizationProjects: Ptr("op"), 1240 OrganizationSecrets: Ptr("os"), 1241 OrganizationSelfHostedRunners: Ptr("osh"), 1242 OrganizationUserBlocking: Ptr("oub"), 1243 Packages: Ptr("pkg"), 1244 Pages: Ptr("pg"), 1245 PullRequests: Ptr("pr"), 1246 RepositoryHooks: Ptr("rh"), 1247 RepositoryProjects: Ptr("rp"), 1248 RepositoryPreReceiveHooks: Ptr("rprh"), 1249 Secrets: Ptr("s"), 1250 SecretScanningAlerts: Ptr("ssa"), 1251 SecurityEvents: Ptr("se"), 1252 SingleFile: Ptr("sf"), 1253 Statuses: Ptr("s"), 1254 TeamDiscussions: Ptr("td"), 1255 VulnerabilityAlerts: Ptr("va"), 1256 Workflows: Ptr("w"), 1257 }, 1258 CreatedAt: &Timestamp{referenceTime}, 1259 UpdatedAt: &Timestamp{referenceTime}, 1260 HasMultipleSingleFiles: Ptr(false), 1261 SuspendedBy: &User{ 1262 Login: Ptr("l"), 1263 ID: Ptr(int64(1)), 1264 URL: Ptr("u"), 1265 AvatarURL: Ptr("a"), 1266 GravatarID: Ptr("g"), 1267 Name: Ptr("n"), 1268 Company: Ptr("c"), 1269 Blog: Ptr("b"), 1270 Location: Ptr("l"), 1271 Email: Ptr("e"), 1272 Hireable: Ptr(true), 1273 Bio: Ptr("b"), 1274 TwitterUsername: Ptr("t"), 1275 PublicRepos: Ptr(1), 1276 Followers: Ptr(1), 1277 Following: Ptr(1), 1278 CreatedAt: &Timestamp{referenceTime}, 1279 SuspendedAt: &Timestamp{referenceTime}, 1280 }, 1281 SuspendedAt: &Timestamp{referenceTime}, 1282 }, 1283 } 1284 1285 want := `{ 1286 "action": "a", 1287 "repositories_added": [ 1288 { 1289 "id": 1, 1290 "name": "n", 1291 "url": "s" 1292 } 1293 ], 1294 "repositories_removed": [ 1295 { 1296 "id": 1, 1297 "name": "n", 1298 "url": "s" 1299 } 1300 ], 1301 "repository_selection": "rs", 1302 "sender": { 1303 "login": "l", 1304 "id": 1, 1305 "node_id": "n", 1306 "avatar_url": "a", 1307 "url": "u", 1308 "events_url": "e", 1309 "repos_url": "r" 1310 }, 1311 "installation": { 1312 "id": 1, 1313 "node_id": "nid", 1314 "app_id": 1, 1315 "app_slug": "as", 1316 "target_id": 1, 1317 "account": { 1318 "login": "l", 1319 "id": 1, 1320 "avatar_url": "a", 1321 "gravatar_id": "g", 1322 "name": "n", 1323 "company": "c", 1324 "blog": "b", 1325 "location": "l", 1326 "email": "e", 1327 "hireable": true, 1328 "bio": "b", 1329 "twitter_username": "t", 1330 "public_repos": 1, 1331 "followers": 1, 1332 "following": 1, 1333 "created_at": ` + referenceTimeStr + `, 1334 "suspended_at": ` + referenceTimeStr + `, 1335 "url": "u" 1336 }, 1337 "access_tokens_url": "atu", 1338 "repositories_url": "ru", 1339 "html_url": "hu", 1340 "target_type": "tt", 1341 "single_file_name": "sfn", 1342 "repository_selection": "rs", 1343 "events": [ 1344 "e" 1345 ], 1346 "single_file_paths": [ 1347 "s" 1348 ], 1349 "permissions": { 1350 "actions": "a", 1351 "administration": "ad", 1352 "checks": "c", 1353 "contents": "co", 1354 "content_references": "cr", 1355 "deployments": "d", 1356 "environments": "e", 1357 "issues": "i", 1358 "metadata": "md", 1359 "members": "m", 1360 "organization_administration": "oa", 1361 "organization_hooks": "oh", 1362 "organization_plan": "op", 1363 "organization_pre_receive_hooks": "opr", 1364 "organization_projects": "op", 1365 "organization_secrets": "os", 1366 "organization_self_hosted_runners": "osh", 1367 "organization_user_blocking": "oub", 1368 "packages": "pkg", 1369 "pages": "pg", 1370 "pull_requests": "pr", 1371 "repository_hooks": "rh", 1372 "repository_projects": "rp", 1373 "repository_pre_receive_hooks": "rprh", 1374 "secrets": "s", 1375 "secret_scanning_alerts": "ssa", 1376 "security_events": "se", 1377 "single_file": "sf", 1378 "statuses": "s", 1379 "team_discussions": "td", 1380 "vulnerability_alerts": "va", 1381 "workflows": "w" 1382 }, 1383 "created_at": ` + referenceTimeStr + `, 1384 "updated_at": ` + referenceTimeStr + `, 1385 "has_multiple_single_files": false, 1386 "suspended_by": { 1387 "login": "l", 1388 "id": 1, 1389 "avatar_url": "a", 1390 "gravatar_id": "g", 1391 "name": "n", 1392 "company": "c", 1393 "blog": "b", 1394 "location": "l", 1395 "email": "e", 1396 "hireable": true, 1397 "bio": "b", 1398 "twitter_username": "t", 1399 "public_repos": 1, 1400 "followers": 1, 1401 "following": 1, 1402 "created_at": ` + referenceTimeStr + `, 1403 "suspended_at": ` + referenceTimeStr + `, 1404 "url": "u" 1405 }, 1406 "suspended_at": ` + referenceTimeStr + ` 1407 } 1408 }` 1409 1410 testJSONMarshal(t, u, want) 1411 } 1412 1413 func TestInstallationTargetEvent_Marshal(t *testing.T) { 1414 t.Parallel() 1415 testJSONMarshal(t, &InstallationTargetEvent{}, "{}") 1416 1417 u := &InstallationTargetEvent{ 1418 Account: &User{ 1419 Login: Ptr("u"), 1420 ID: Ptr(int64(1)), 1421 NodeID: Ptr("n"), 1422 URL: Ptr("u"), 1423 ReposURL: Ptr("r"), 1424 EventsURL: Ptr("e"), 1425 AvatarURL: Ptr("l"), 1426 }, 1427 Action: Ptr("a"), 1428 Changes: &InstallationChanges{ 1429 Login: &InstallationLoginChange{ 1430 From: Ptr("p"), 1431 }, 1432 Slug: &InstallationSlugChange{ 1433 From: Ptr("j"), 1434 }, 1435 }, 1436 Enterprise: &Enterprise{ 1437 ID: Ptr(1), 1438 Slug: Ptr("s"), 1439 Name: Ptr("n"), 1440 NodeID: Ptr("nid"), 1441 AvatarURL: Ptr("au"), 1442 Description: Ptr("d"), 1443 WebsiteURL: Ptr("wu"), 1444 HTMLURL: Ptr("hu"), 1445 CreatedAt: &Timestamp{referenceTime}, 1446 UpdatedAt: &Timestamp{referenceTime}, 1447 }, 1448 Installation: &Installation{ 1449 ID: Ptr(int64(1)), 1450 NodeID: Ptr("nid"), 1451 AppID: Ptr(int64(1)), 1452 AppSlug: Ptr("as"), 1453 TargetID: Ptr(int64(1)), 1454 Account: &User{ 1455 Login: Ptr("l"), 1456 ID: Ptr(int64(1)), 1457 URL: Ptr("u"), 1458 AvatarURL: Ptr("a"), 1459 GravatarID: Ptr("g"), 1460 Name: Ptr("n"), 1461 Company: Ptr("c"), 1462 Blog: Ptr("b"), 1463 Location: Ptr("l"), 1464 Email: Ptr("e"), 1465 Hireable: Ptr(true), 1466 Bio: Ptr("b"), 1467 TwitterUsername: Ptr("t"), 1468 PublicRepos: Ptr(1), 1469 Followers: Ptr(1), 1470 Following: Ptr(1), 1471 CreatedAt: &Timestamp{referenceTime}, 1472 SuspendedAt: &Timestamp{referenceTime}, 1473 }, 1474 AccessTokensURL: Ptr("atu"), 1475 RepositoriesURL: Ptr("ru"), 1476 HTMLURL: Ptr("hu"), 1477 TargetType: Ptr("tt"), 1478 SingleFileName: Ptr("sfn"), 1479 RepositorySelection: Ptr("rs"), 1480 Events: []string{"e"}, 1481 SingleFilePaths: []string{"s"}, 1482 Permissions: &InstallationPermissions{ 1483 Actions: Ptr("a"), 1484 Administration: Ptr("ad"), 1485 Checks: Ptr("c"), 1486 Contents: Ptr("co"), 1487 ContentReferences: Ptr("cr"), 1488 Deployments: Ptr("d"), 1489 Environments: Ptr("e"), 1490 Issues: Ptr("i"), 1491 Metadata: Ptr("md"), 1492 Members: Ptr("m"), 1493 OrganizationAdministration: Ptr("oa"), 1494 OrganizationHooks: Ptr("oh"), 1495 OrganizationPlan: Ptr("op"), 1496 OrganizationPreReceiveHooks: Ptr("opr"), 1497 OrganizationProjects: Ptr("op"), 1498 OrganizationSecrets: Ptr("os"), 1499 OrganizationSelfHostedRunners: Ptr("osh"), 1500 OrganizationUserBlocking: Ptr("oub"), 1501 Packages: Ptr("pkg"), 1502 Pages: Ptr("pg"), 1503 PullRequests: Ptr("pr"), 1504 RepositoryHooks: Ptr("rh"), 1505 RepositoryProjects: Ptr("rp"), 1506 RepositoryPreReceiveHooks: Ptr("rprh"), 1507 Secrets: Ptr("s"), 1508 SecretScanningAlerts: Ptr("ssa"), 1509 SecurityEvents: Ptr("se"), 1510 SingleFile: Ptr("sf"), 1511 Statuses: Ptr("s"), 1512 TeamDiscussions: Ptr("td"), 1513 VulnerabilityAlerts: Ptr("va"), 1514 Workflows: Ptr("w"), 1515 }, 1516 CreatedAt: &Timestamp{referenceTime}, 1517 UpdatedAt: &Timestamp{referenceTime}, 1518 HasMultipleSingleFiles: Ptr(false), 1519 SuspendedBy: &User{ 1520 Login: Ptr("l"), 1521 ID: Ptr(int64(1)), 1522 URL: Ptr("u"), 1523 AvatarURL: Ptr("a"), 1524 GravatarID: Ptr("g"), 1525 Name: Ptr("n"), 1526 Company: Ptr("c"), 1527 Blog: Ptr("b"), 1528 Location: Ptr("l"), 1529 Email: Ptr("e"), 1530 Hireable: Ptr(true), 1531 Bio: Ptr("b"), 1532 TwitterUsername: Ptr("t"), 1533 PublicRepos: Ptr(1), 1534 Followers: Ptr(1), 1535 Following: Ptr(1), 1536 CreatedAt: &Timestamp{referenceTime}, 1537 SuspendedAt: &Timestamp{referenceTime}, 1538 }, 1539 SuspendedAt: &Timestamp{referenceTime}, 1540 }, 1541 Organization: &Organization{ 1542 BillingEmail: Ptr("be"), 1543 Blog: Ptr("b"), 1544 Company: Ptr("c"), 1545 Email: Ptr("e"), 1546 TwitterUsername: Ptr("tu"), 1547 Location: Ptr("loc"), 1548 Name: Ptr("n"), 1549 Description: Ptr("d"), 1550 IsVerified: Ptr(true), 1551 HasOrganizationProjects: Ptr(true), 1552 HasRepositoryProjects: Ptr(true), 1553 DefaultRepoPermission: Ptr("drp"), 1554 MembersCanCreateRepos: Ptr(true), 1555 MembersCanCreateInternalRepos: Ptr(true), 1556 MembersCanCreatePrivateRepos: Ptr(true), 1557 MembersCanCreatePublicRepos: Ptr(false), 1558 MembersAllowedRepositoryCreationType: Ptr("marct"), 1559 MembersCanCreatePages: Ptr(true), 1560 MembersCanCreatePublicPages: Ptr(false), 1561 MembersCanCreatePrivatePages: Ptr(true), 1562 }, 1563 Repository: &Repository{ 1564 ID: Ptr(int64(1)), 1565 URL: Ptr("s"), 1566 Name: Ptr("n"), 1567 }, 1568 Sender: &User{ 1569 Login: Ptr("l"), 1570 ID: Ptr(int64(1)), 1571 NodeID: Ptr("n"), 1572 URL: Ptr("u"), 1573 ReposURL: Ptr("r"), 1574 EventsURL: Ptr("e"), 1575 AvatarURL: Ptr("a"), 1576 }, 1577 TargetType: Ptr("running"), 1578 } 1579 1580 want := `{ 1581 "account": { 1582 "login": "u", 1583 "id": 1, 1584 "node_id": "n", 1585 "avatar_url": "l", 1586 "url": "u", 1587 "events_url": "e", 1588 "repos_url": "r" 1589 }, 1590 "action": "a", 1591 "changes": { 1592 "login": { 1593 "from": "p" 1594 }, 1595 "slug": { 1596 "from": "j" 1597 } 1598 }, 1599 "enterprise": { 1600 "id": 1, 1601 "slug": "s", 1602 "name": "n", 1603 "node_id": "nid", 1604 "avatar_url": "au", 1605 "description": "d", 1606 "website_url": "wu", 1607 "html_url": "hu", 1608 "created_at": ` + referenceTimeStr + `, 1609 "updated_at": ` + referenceTimeStr + ` 1610 }, 1611 "installation": { 1612 "id": 1, 1613 "node_id": "nid", 1614 "app_id": 1, 1615 "app_slug": "as", 1616 "target_id": 1, 1617 "account": { 1618 "login": "l", 1619 "id": 1, 1620 "avatar_url": "a", 1621 "gravatar_id": "g", 1622 "name": "n", 1623 "company": "c", 1624 "blog": "b", 1625 "location": "l", 1626 "email": "e", 1627 "hireable": true, 1628 "bio": "b", 1629 "twitter_username": "t", 1630 "public_repos": 1, 1631 "followers": 1, 1632 "following": 1, 1633 "created_at": ` + referenceTimeStr + `, 1634 "suspended_at": ` + referenceTimeStr + `, 1635 "url": "u" 1636 }, 1637 "access_tokens_url": "atu", 1638 "repositories_url": "ru", 1639 "html_url": "hu", 1640 "target_type": "tt", 1641 "single_file_name": "sfn", 1642 "repository_selection": "rs", 1643 "events": [ 1644 "e" 1645 ], 1646 "single_file_paths": [ 1647 "s" 1648 ], 1649 "permissions": { 1650 "actions": "a", 1651 "administration": "ad", 1652 "checks": "c", 1653 "contents": "co", 1654 "content_references": "cr", 1655 "deployments": "d", 1656 "environments": "e", 1657 "issues": "i", 1658 "metadata": "md", 1659 "members": "m", 1660 "organization_administration": "oa", 1661 "organization_hooks": "oh", 1662 "organization_plan": "op", 1663 "organization_pre_receive_hooks": "opr", 1664 "organization_projects": "op", 1665 "organization_secrets": "os", 1666 "organization_self_hosted_runners": "osh", 1667 "organization_user_blocking": "oub", 1668 "packages": "pkg", 1669 "pages": "pg", 1670 "pull_requests": "pr", 1671 "repository_hooks": "rh", 1672 "repository_projects": "rp", 1673 "repository_pre_receive_hooks": "rprh", 1674 "secrets": "s", 1675 "secret_scanning_alerts": "ssa", 1676 "security_events": "se", 1677 "single_file": "sf", 1678 "statuses": "s", 1679 "team_discussions": "td", 1680 "vulnerability_alerts": "va", 1681 "workflows": "w" 1682 }, 1683 "created_at": ` + referenceTimeStr + `, 1684 "updated_at": ` + referenceTimeStr + `, 1685 "has_multiple_single_files": false, 1686 "suspended_by": { 1687 "login": "l", 1688 "id": 1, 1689 "avatar_url": "a", 1690 "gravatar_id": "g", 1691 "name": "n", 1692 "company": "c", 1693 "blog": "b", 1694 "location": "l", 1695 "email": "e", 1696 "hireable": true, 1697 "bio": "b", 1698 "twitter_username": "t", 1699 "public_repos": 1, 1700 "followers": 1, 1701 "following": 1, 1702 "created_at": ` + referenceTimeStr + `, 1703 "suspended_at": ` + referenceTimeStr + `, 1704 "url": "u" 1705 }, 1706 "suspended_at": ` + referenceTimeStr + ` 1707 }, 1708 "organization": { 1709 "name": "n", 1710 "company": "c", 1711 "blog": "b", 1712 "location": "loc", 1713 "email": "e", 1714 "twitter_username": "tu", 1715 "description": "d", 1716 "billing_email": "be", 1717 "is_verified": true, 1718 "has_organization_projects": true, 1719 "has_repository_projects": true, 1720 "default_repository_permission": "drp", 1721 "members_can_create_repositories": true, 1722 "members_can_create_public_repositories": false, 1723 "members_can_create_private_repositories": true, 1724 "members_can_create_internal_repositories": true, 1725 "members_allowed_repository_creation_type": "marct", 1726 "members_can_create_pages": true, 1727 "members_can_create_public_pages": false, 1728 "members_can_create_private_pages": true 1729 }, 1730 "repository": { 1731 "id": 1, 1732 "url": "s", 1733 "name": "n" 1734 }, 1735 "sender": { 1736 "login": "l", 1737 "id": 1, 1738 "node_id": "n", 1739 "avatar_url": "a", 1740 "url": "u", 1741 "events_url": "e", 1742 "repos_url": "r" 1743 }, 1744 "target_type": "running" 1745 }` 1746 1747 testJSONMarshal(t, u, want) 1748 } 1749 1750 func TestEditTitle_Marshal(t *testing.T) { 1751 t.Parallel() 1752 testJSONMarshal(t, &EditTitle{}, "{}") 1753 1754 u := &EditTitle{ 1755 From: Ptr("EditTitleFrom"), 1756 } 1757 1758 want := `{ 1759 "from": "EditTitleFrom" 1760 }` 1761 1762 testJSONMarshal(t, u, want) 1763 } 1764 1765 func TestEditBody_Marshal(t *testing.T) { 1766 t.Parallel() 1767 testJSONMarshal(t, &EditBody{}, "{}") 1768 1769 u := &EditBody{ 1770 From: Ptr("EditBodyFrom"), 1771 } 1772 1773 want := `{ 1774 "from": "EditBodyFrom" 1775 }` 1776 1777 testJSONMarshal(t, u, want) 1778 } 1779 1780 func TestEditBase_Marshal(t *testing.T) { 1781 t.Parallel() 1782 testJSONMarshal(t, &EditBase{}, "{}") 1783 1784 u := &EditBase{ 1785 Ref: &EditRef{ 1786 From: Ptr("EditRefFrom"), 1787 }, 1788 SHA: &EditSHA{ 1789 From: Ptr("EditSHAFrom"), 1790 }, 1791 } 1792 1793 want := `{ 1794 "ref": { 1795 "from": "EditRefFrom" 1796 }, 1797 "sha": { 1798 "from": "EditSHAFrom" 1799 } 1800 }` 1801 1802 testJSONMarshal(t, u, want) 1803 } 1804 1805 func TestEditRef_Marshal(t *testing.T) { 1806 t.Parallel() 1807 testJSONMarshal(t, &EditRef{}, "{}") 1808 1809 u := &EditRef{ 1810 From: Ptr("EditRefFrom"), 1811 } 1812 1813 want := `{ 1814 "from": "EditRefFrom" 1815 }` 1816 1817 testJSONMarshal(t, u, want) 1818 } 1819 1820 func TestEditSHA_Marshal(t *testing.T) { 1821 t.Parallel() 1822 testJSONMarshal(t, &EditSHA{}, "{}") 1823 1824 u := &EditSHA{ 1825 From: Ptr("EditSHAFrom"), 1826 } 1827 1828 want := `{ 1829 "from": "EditSHAFrom" 1830 }` 1831 1832 testJSONMarshal(t, u, want) 1833 } 1834 1835 func TestProjectName_Marshal(t *testing.T) { 1836 t.Parallel() 1837 testJSONMarshal(t, &ProjectName{}, "{}") 1838 1839 u := &ProjectName{ 1840 From: Ptr("ProjectNameFrom"), 1841 } 1842 1843 want := `{ 1844 "from": "ProjectNameFrom" 1845 }` 1846 1847 testJSONMarshal(t, u, want) 1848 } 1849 1850 func TestProjectBody_Marshal(t *testing.T) { 1851 t.Parallel() 1852 testJSONMarshal(t, &ProjectBody{}, "{}") 1853 1854 u := &ProjectBody{ 1855 From: Ptr("ProjectBodyFrom"), 1856 } 1857 1858 want := `{ 1859 "from": "ProjectBodyFrom" 1860 }` 1861 1862 testJSONMarshal(t, u, want) 1863 } 1864 1865 func TestProjectCardNote_Marshal(t *testing.T) { 1866 t.Parallel() 1867 testJSONMarshal(t, &ProjectCardNote{}, "{}") 1868 1869 u := &ProjectCardNote{ 1870 From: Ptr("ProjectCardNoteFrom"), 1871 } 1872 1873 want := `{ 1874 "from": "ProjectCardNoteFrom" 1875 }` 1876 1877 testJSONMarshal(t, u, want) 1878 } 1879 1880 func TestProjectColumnName_Marshal(t *testing.T) { 1881 t.Parallel() 1882 testJSONMarshal(t, &ProjectColumnName{}, "{}") 1883 1884 u := &ProjectColumnName{ 1885 From: Ptr("ProjectColumnNameFrom"), 1886 } 1887 1888 want := `{ 1889 "from": "ProjectColumnNameFrom" 1890 }` 1891 1892 testJSONMarshal(t, u, want) 1893 } 1894 1895 func TestTeamDescription_Marshal(t *testing.T) { 1896 t.Parallel() 1897 testJSONMarshal(t, &TeamDescription{}, "{}") 1898 1899 u := &TeamDescription{ 1900 From: Ptr("TeamDescriptionFrom"), 1901 } 1902 1903 want := `{ 1904 "from": "TeamDescriptionFrom" 1905 }` 1906 1907 testJSONMarshal(t, u, want) 1908 } 1909 1910 func TestTeamName_Marshal(t *testing.T) { 1911 t.Parallel() 1912 testJSONMarshal(t, &TeamName{}, "{}") 1913 1914 u := &TeamName{ 1915 From: Ptr("TeamNameFrom"), 1916 } 1917 1918 want := `{ 1919 "from": "TeamNameFrom" 1920 }` 1921 1922 testJSONMarshal(t, u, want) 1923 } 1924 1925 func TestTeamPrivacy_Marshal(t *testing.T) { 1926 t.Parallel() 1927 testJSONMarshal(t, &TeamPrivacy{}, "{}") 1928 1929 u := &TeamPrivacy{ 1930 From: Ptr("TeamPrivacyFrom"), 1931 } 1932 1933 want := `{ 1934 "from": "TeamPrivacyFrom" 1935 }` 1936 1937 testJSONMarshal(t, u, want) 1938 } 1939 1940 func TestTeamRepository_Marshal(t *testing.T) { 1941 t.Parallel() 1942 testJSONMarshal(t, &TeamRepository{}, "{}") 1943 1944 u := &TeamRepository{ 1945 Permissions: &TeamPermissions{ 1946 From: &TeamPermissionsFrom{ 1947 Admin: Ptr(true), 1948 Pull: Ptr(true), 1949 Push: Ptr(true), 1950 }, 1951 }, 1952 } 1953 1954 want := `{ 1955 "permissions": { 1956 "from": { 1957 "admin": true, 1958 "pull": true, 1959 "push": true 1960 } 1961 } 1962 }` 1963 1964 testJSONMarshal(t, u, want) 1965 } 1966 1967 func TestTeamPermissions_Marshal(t *testing.T) { 1968 t.Parallel() 1969 testJSONMarshal(t, &TeamPermissions{}, "{}") 1970 1971 u := &TeamPermissions{ 1972 From: &TeamPermissionsFrom{ 1973 Admin: Ptr(true), 1974 Pull: Ptr(true), 1975 Push: Ptr(true), 1976 }, 1977 } 1978 1979 want := `{ 1980 "from": { 1981 "admin": true, 1982 "pull": true, 1983 "push": true 1984 } 1985 }` 1986 1987 testJSONMarshal(t, u, want) 1988 } 1989 1990 func TestTeamPermissionsFrom_Marshal(t *testing.T) { 1991 t.Parallel() 1992 testJSONMarshal(t, &TeamPermissionsFrom{}, "{}") 1993 1994 u := &TeamPermissionsFrom{ 1995 Admin: Ptr(true), 1996 Pull: Ptr(true), 1997 Push: Ptr(true), 1998 } 1999 2000 want := `{ 2001 "admin": true, 2002 "pull": true, 2003 "push": true 2004 }` 2005 2006 testJSONMarshal(t, u, want) 2007 } 2008 2009 func TestRepositoryVulnerabilityAlert_Marshal(t *testing.T) { 2010 t.Parallel() 2011 testJSONMarshal(t, &RepositoryVulnerabilityAlert{}, "{}") 2012 2013 u := &RepositoryVulnerabilityAlert{ 2014 ID: Ptr(int64(1)), 2015 AffectedRange: Ptr("ar"), 2016 AffectedPackageName: Ptr("apn"), 2017 ExternalReference: Ptr("er"), 2018 ExternalIdentifier: Ptr("ei"), 2019 FixedIn: Ptr("fi"), 2020 Dismisser: &User{ 2021 Login: Ptr("l"), 2022 ID: Ptr(int64(1)), 2023 NodeID: Ptr("n"), 2024 URL: Ptr("u"), 2025 ReposURL: Ptr("r"), 2026 EventsURL: Ptr("e"), 2027 AvatarURL: Ptr("a"), 2028 }, 2029 DismissReason: Ptr("dr"), 2030 DismissedAt: &Timestamp{referenceTime}, 2031 } 2032 2033 want := `{ 2034 "id": 1, 2035 "affected_range": "ar", 2036 "affected_package_name": "apn", 2037 "external_reference": "er", 2038 "external_identifier": "ei", 2039 "fixed_in": "fi", 2040 "dismisser": { 2041 "login": "l", 2042 "id": 1, 2043 "node_id": "n", 2044 "avatar_url": "a", 2045 "url": "u", 2046 "events_url": "e", 2047 "repos_url": "r" 2048 }, 2049 "dismiss_reason": "dr", 2050 "dismissed_at": ` + referenceTimeStr + ` 2051 }` 2052 2053 testJSONMarshal(t, u, want) 2054 } 2055 2056 func TestPage_Marshal(t *testing.T) { 2057 t.Parallel() 2058 testJSONMarshal(t, &Page{}, "{}") 2059 2060 u := &Page{ 2061 PageName: Ptr("p"), 2062 Title: Ptr("t"), 2063 Summary: Ptr("s"), 2064 Action: Ptr("a"), 2065 SHA: Ptr("s"), 2066 HTMLURL: Ptr("h"), 2067 } 2068 2069 want := `{ 2070 "page_name": "p", 2071 "title": "t", 2072 "summary": "s", 2073 "action": "a", 2074 "sha": "s", 2075 "html_url": "h" 2076 }` 2077 2078 testJSONMarshal(t, u, want) 2079 } 2080 2081 func TestTeamChange_Marshal(t *testing.T) { 2082 t.Parallel() 2083 testJSONMarshal(t, &TeamChange{}, "{}") 2084 2085 u := &TeamChange{ 2086 Description: &TeamDescription{ 2087 From: Ptr("DescriptionFrom"), 2088 }, 2089 Name: &TeamName{ 2090 From: Ptr("NameFrom"), 2091 }, 2092 Privacy: &TeamPrivacy{ 2093 From: Ptr("PrivacyFrom"), 2094 }, 2095 Repository: &TeamRepository{ 2096 Permissions: &TeamPermissions{ 2097 From: &TeamPermissionsFrom{ 2098 Admin: Ptr(false), 2099 Pull: Ptr(false), 2100 Push: Ptr(false), 2101 }, 2102 }, 2103 }, 2104 } 2105 2106 want := `{ 2107 "description": { 2108 "from": "DescriptionFrom" 2109 }, 2110 "name": { 2111 "from": "NameFrom" 2112 }, 2113 "privacy": { 2114 "from": "PrivacyFrom" 2115 }, 2116 "repository": { 2117 "permissions": { 2118 "from": { 2119 "admin": false, 2120 "pull": false, 2121 "push": false 2122 } 2123 } 2124 } 2125 }` 2126 2127 testJSONMarshal(t, u, want) 2128 } 2129 2130 func TestIssueCommentEvent_Marshal(t *testing.T) { 2131 t.Parallel() 2132 testJSONMarshal(t, &IssueCommentEvent{}, "{}") 2133 2134 u := &IssueCommentEvent{ 2135 Action: Ptr("a"), 2136 Issue: &Issue{ID: Ptr(int64(1))}, 2137 Comment: &IssueComment{ID: Ptr(int64(1))}, 2138 Changes: &EditChange{ 2139 Title: &EditTitle{ 2140 From: Ptr("TitleFrom"), 2141 }, 2142 Body: &EditBody{ 2143 From: Ptr("BodyFrom"), 2144 }, 2145 Base: &EditBase{ 2146 Ref: &EditRef{ 2147 From: Ptr("BaseRefFrom"), 2148 }, 2149 SHA: &EditSHA{ 2150 From: Ptr("BaseSHAFrom"), 2151 }, 2152 }, 2153 }, 2154 Repo: &Repository{ 2155 ID: Ptr(int64(1)), 2156 URL: Ptr("s"), 2157 Name: Ptr("n"), 2158 }, 2159 Sender: &User{ 2160 Login: Ptr("l"), 2161 ID: Ptr(int64(1)), 2162 NodeID: Ptr("n"), 2163 URL: Ptr("u"), 2164 ReposURL: Ptr("r"), 2165 EventsURL: Ptr("e"), 2166 AvatarURL: Ptr("a"), 2167 }, 2168 Installation: &Installation{ 2169 ID: Ptr(int64(1)), 2170 NodeID: Ptr("nid"), 2171 AppID: Ptr(int64(1)), 2172 AppSlug: Ptr("as"), 2173 TargetID: Ptr(int64(1)), 2174 Account: &User{ 2175 Login: Ptr("l"), 2176 ID: Ptr(int64(1)), 2177 URL: Ptr("u"), 2178 AvatarURL: Ptr("a"), 2179 GravatarID: Ptr("g"), 2180 Name: Ptr("n"), 2181 Company: Ptr("c"), 2182 Blog: Ptr("b"), 2183 Location: Ptr("l"), 2184 Email: Ptr("e"), 2185 Hireable: Ptr(true), 2186 Bio: Ptr("b"), 2187 TwitterUsername: Ptr("t"), 2188 PublicRepos: Ptr(1), 2189 Followers: Ptr(1), 2190 Following: Ptr(1), 2191 CreatedAt: &Timestamp{referenceTime}, 2192 SuspendedAt: &Timestamp{referenceTime}, 2193 }, 2194 AccessTokensURL: Ptr("atu"), 2195 RepositoriesURL: Ptr("ru"), 2196 HTMLURL: Ptr("hu"), 2197 TargetType: Ptr("tt"), 2198 SingleFileName: Ptr("sfn"), 2199 RepositorySelection: Ptr("rs"), 2200 Events: []string{"e"}, 2201 SingleFilePaths: []string{"s"}, 2202 Permissions: &InstallationPermissions{ 2203 Actions: Ptr("a"), 2204 Administration: Ptr("ad"), 2205 Checks: Ptr("c"), 2206 Contents: Ptr("co"), 2207 ContentReferences: Ptr("cr"), 2208 Deployments: Ptr("d"), 2209 Environments: Ptr("e"), 2210 Issues: Ptr("i"), 2211 Metadata: Ptr("md"), 2212 Members: Ptr("m"), 2213 OrganizationAdministration: Ptr("oa"), 2214 OrganizationHooks: Ptr("oh"), 2215 OrganizationPlan: Ptr("op"), 2216 OrganizationPreReceiveHooks: Ptr("opr"), 2217 OrganizationProjects: Ptr("op"), 2218 OrganizationSecrets: Ptr("os"), 2219 OrganizationSelfHostedRunners: Ptr("osh"), 2220 OrganizationUserBlocking: Ptr("oub"), 2221 Packages: Ptr("pkg"), 2222 Pages: Ptr("pg"), 2223 PullRequests: Ptr("pr"), 2224 RepositoryHooks: Ptr("rh"), 2225 RepositoryProjects: Ptr("rp"), 2226 RepositoryPreReceiveHooks: Ptr("rprh"), 2227 Secrets: Ptr("s"), 2228 SecretScanningAlerts: Ptr("ssa"), 2229 SecurityEvents: Ptr("se"), 2230 SingleFile: Ptr("sf"), 2231 Statuses: Ptr("s"), 2232 TeamDiscussions: Ptr("td"), 2233 VulnerabilityAlerts: Ptr("va"), 2234 Workflows: Ptr("w"), 2235 }, 2236 CreatedAt: &Timestamp{referenceTime}, 2237 UpdatedAt: &Timestamp{referenceTime}, 2238 HasMultipleSingleFiles: Ptr(false), 2239 SuspendedBy: &User{ 2240 Login: Ptr("l"), 2241 ID: Ptr(int64(1)), 2242 URL: Ptr("u"), 2243 AvatarURL: Ptr("a"), 2244 GravatarID: Ptr("g"), 2245 Name: Ptr("n"), 2246 Company: Ptr("c"), 2247 Blog: Ptr("b"), 2248 Location: Ptr("l"), 2249 Email: Ptr("e"), 2250 Hireable: Ptr(true), 2251 Bio: Ptr("b"), 2252 TwitterUsername: Ptr("t"), 2253 PublicRepos: Ptr(1), 2254 Followers: Ptr(1), 2255 Following: Ptr(1), 2256 CreatedAt: &Timestamp{referenceTime}, 2257 SuspendedAt: &Timestamp{referenceTime}, 2258 }, 2259 SuspendedAt: &Timestamp{referenceTime}, 2260 }, 2261 Organization: &Organization{ 2262 BillingEmail: Ptr("be"), 2263 Blog: Ptr("b"), 2264 Company: Ptr("c"), 2265 Email: Ptr("e"), 2266 TwitterUsername: Ptr("tu"), 2267 Location: Ptr("loc"), 2268 Name: Ptr("n"), 2269 Description: Ptr("d"), 2270 IsVerified: Ptr(true), 2271 HasOrganizationProjects: Ptr(true), 2272 HasRepositoryProjects: Ptr(true), 2273 DefaultRepoPermission: Ptr("drp"), 2274 MembersCanCreateRepos: Ptr(true), 2275 MembersCanCreateInternalRepos: Ptr(true), 2276 MembersCanCreatePrivateRepos: Ptr(true), 2277 MembersCanCreatePublicRepos: Ptr(false), 2278 MembersAllowedRepositoryCreationType: Ptr("marct"), 2279 MembersCanCreatePages: Ptr(true), 2280 MembersCanCreatePublicPages: Ptr(false), 2281 MembersCanCreatePrivatePages: Ptr(true), 2282 }, 2283 } 2284 2285 want := `{ 2286 "action": "a", 2287 "issue": { 2288 "id": 1 2289 }, 2290 "comment": { 2291 "id": 1 2292 }, 2293 "changes": { 2294 "title": { 2295 "from": "TitleFrom" 2296 }, 2297 "body": { 2298 "from": "BodyFrom" 2299 }, 2300 "base": { 2301 "ref": { 2302 "from": "BaseRefFrom" 2303 }, 2304 "sha": { 2305 "from": "BaseSHAFrom" 2306 } 2307 } 2308 }, 2309 "repository": { 2310 "id": 1, 2311 "name": "n", 2312 "url": "s" 2313 }, 2314 "sender": { 2315 "login": "l", 2316 "id": 1, 2317 "node_id": "n", 2318 "avatar_url": "a", 2319 "url": "u", 2320 "events_url": "e", 2321 "repos_url": "r" 2322 }, 2323 "installation": { 2324 "id": 1, 2325 "node_id": "nid", 2326 "app_id": 1, 2327 "app_slug": "as", 2328 "target_id": 1, 2329 "account": { 2330 "login": "l", 2331 "id": 1, 2332 "avatar_url": "a", 2333 "gravatar_id": "g", 2334 "name": "n", 2335 "company": "c", 2336 "blog": "b", 2337 "location": "l", 2338 "email": "e", 2339 "hireable": true, 2340 "bio": "b", 2341 "twitter_username": "t", 2342 "public_repos": 1, 2343 "followers": 1, 2344 "following": 1, 2345 "created_at": ` + referenceTimeStr + `, 2346 "suspended_at": ` + referenceTimeStr + `, 2347 "url": "u" 2348 }, 2349 "access_tokens_url": "atu", 2350 "repositories_url": "ru", 2351 "html_url": "hu", 2352 "target_type": "tt", 2353 "single_file_name": "sfn", 2354 "repository_selection": "rs", 2355 "events": [ 2356 "e" 2357 ], 2358 "single_file_paths": [ 2359 "s" 2360 ], 2361 "permissions": { 2362 "actions": "a", 2363 "administration": "ad", 2364 "checks": "c", 2365 "contents": "co", 2366 "content_references": "cr", 2367 "deployments": "d", 2368 "environments": "e", 2369 "issues": "i", 2370 "metadata": "md", 2371 "members": "m", 2372 "organization_administration": "oa", 2373 "organization_hooks": "oh", 2374 "organization_plan": "op", 2375 "organization_pre_receive_hooks": "opr", 2376 "organization_projects": "op", 2377 "organization_secrets": "os", 2378 "organization_self_hosted_runners": "osh", 2379 "organization_user_blocking": "oub", 2380 "packages": "pkg", 2381 "pages": "pg", 2382 "pull_requests": "pr", 2383 "repository_hooks": "rh", 2384 "repository_projects": "rp", 2385 "repository_pre_receive_hooks": "rprh", 2386 "secrets": "s", 2387 "secret_scanning_alerts": "ssa", 2388 "security_events": "se", 2389 "single_file": "sf", 2390 "statuses": "s", 2391 "team_discussions": "td", 2392 "vulnerability_alerts": "va", 2393 "workflows": "w" 2394 }, 2395 "created_at": ` + referenceTimeStr + `, 2396 "updated_at": ` + referenceTimeStr + `, 2397 "has_multiple_single_files": false, 2398 "suspended_by": { 2399 "login": "l", 2400 "id": 1, 2401 "avatar_url": "a", 2402 "gravatar_id": "g", 2403 "name": "n", 2404 "company": "c", 2405 "blog": "b", 2406 "location": "l", 2407 "email": "e", 2408 "hireable": true, 2409 "bio": "b", 2410 "twitter_username": "t", 2411 "public_repos": 1, 2412 "followers": 1, 2413 "following": 1, 2414 "created_at": ` + referenceTimeStr + `, 2415 "suspended_at": ` + referenceTimeStr + `, 2416 "url": "u" 2417 }, 2418 "suspended_at": ` + referenceTimeStr + ` 2419 }, 2420 "organization": { 2421 "name": "n", 2422 "company": "c", 2423 "blog": "b", 2424 "location": "loc", 2425 "email": "e", 2426 "twitter_username": "tu", 2427 "description": "d", 2428 "billing_email": "be", 2429 "is_verified": true, 2430 "has_organization_projects": true, 2431 "has_repository_projects": true, 2432 "default_repository_permission": "drp", 2433 "members_can_create_repositories": true, 2434 "members_can_create_public_repositories": false, 2435 "members_can_create_private_repositories": true, 2436 "members_can_create_internal_repositories": true, 2437 "members_allowed_repository_creation_type": "marct", 2438 "members_can_create_pages": true, 2439 "members_can_create_public_pages": false, 2440 "members_can_create_private_pages": true 2441 } 2442 }` 2443 2444 testJSONMarshal(t, u, want) 2445 } 2446 2447 func TestIssuesEvent_Marshal(t *testing.T) { 2448 t.Parallel() 2449 testJSONMarshal(t, &IssuesEvent{}, "{}") 2450 2451 u := &IssuesEvent{ 2452 Action: Ptr("a"), 2453 Issue: &Issue{ID: Ptr(int64(1))}, 2454 Assignee: &User{ 2455 Login: Ptr("l"), 2456 ID: Ptr(int64(1)), 2457 NodeID: Ptr("n"), 2458 URL: Ptr("u"), 2459 ReposURL: Ptr("r"), 2460 EventsURL: Ptr("e"), 2461 AvatarURL: Ptr("a"), 2462 }, 2463 Label: &Label{ID: Ptr(int64(1))}, 2464 Changes: &EditChange{ 2465 Title: &EditTitle{ 2466 From: Ptr("TitleFrom"), 2467 }, 2468 Body: &EditBody{ 2469 From: Ptr("BodyFrom"), 2470 }, 2471 Base: &EditBase{ 2472 Ref: &EditRef{ 2473 From: Ptr("BaseRefFrom"), 2474 }, 2475 SHA: &EditSHA{ 2476 From: Ptr("BaseSHAFrom"), 2477 }, 2478 }, 2479 }, 2480 Repo: &Repository{ 2481 ID: Ptr(int64(1)), 2482 URL: Ptr("s"), 2483 Name: Ptr("n"), 2484 }, 2485 Sender: &User{ 2486 Login: Ptr("l"), 2487 ID: Ptr(int64(1)), 2488 NodeID: Ptr("n"), 2489 URL: Ptr("u"), 2490 ReposURL: Ptr("r"), 2491 EventsURL: Ptr("e"), 2492 AvatarURL: Ptr("a"), 2493 }, 2494 Installation: &Installation{ 2495 ID: Ptr(int64(1)), 2496 NodeID: Ptr("nid"), 2497 AppID: Ptr(int64(1)), 2498 AppSlug: Ptr("as"), 2499 TargetID: Ptr(int64(1)), 2500 Account: &User{ 2501 Login: Ptr("l"), 2502 ID: Ptr(int64(1)), 2503 URL: Ptr("u"), 2504 AvatarURL: Ptr("a"), 2505 GravatarID: Ptr("g"), 2506 Name: Ptr("n"), 2507 Company: Ptr("c"), 2508 Blog: Ptr("b"), 2509 Location: Ptr("l"), 2510 Email: Ptr("e"), 2511 Hireable: Ptr(true), 2512 Bio: Ptr("b"), 2513 TwitterUsername: Ptr("t"), 2514 PublicRepos: Ptr(1), 2515 Followers: Ptr(1), 2516 Following: Ptr(1), 2517 CreatedAt: &Timestamp{referenceTime}, 2518 SuspendedAt: &Timestamp{referenceTime}, 2519 }, 2520 AccessTokensURL: Ptr("atu"), 2521 RepositoriesURL: Ptr("ru"), 2522 HTMLURL: Ptr("hu"), 2523 TargetType: Ptr("tt"), 2524 SingleFileName: Ptr("sfn"), 2525 RepositorySelection: Ptr("rs"), 2526 Events: []string{"e"}, 2527 SingleFilePaths: []string{"s"}, 2528 Permissions: &InstallationPermissions{ 2529 Actions: Ptr("a"), 2530 Administration: Ptr("ad"), 2531 Checks: Ptr("c"), 2532 Contents: Ptr("co"), 2533 ContentReferences: Ptr("cr"), 2534 Deployments: Ptr("d"), 2535 Environments: Ptr("e"), 2536 Issues: Ptr("i"), 2537 Metadata: Ptr("md"), 2538 Members: Ptr("m"), 2539 OrganizationAdministration: Ptr("oa"), 2540 OrganizationHooks: Ptr("oh"), 2541 OrganizationPlan: Ptr("op"), 2542 OrganizationPreReceiveHooks: Ptr("opr"), 2543 OrganizationProjects: Ptr("op"), 2544 OrganizationSecrets: Ptr("os"), 2545 OrganizationSelfHostedRunners: Ptr("osh"), 2546 OrganizationUserBlocking: Ptr("oub"), 2547 Packages: Ptr("pkg"), 2548 Pages: Ptr("pg"), 2549 PullRequests: Ptr("pr"), 2550 RepositoryHooks: Ptr("rh"), 2551 RepositoryProjects: Ptr("rp"), 2552 RepositoryPreReceiveHooks: Ptr("rprh"), 2553 Secrets: Ptr("s"), 2554 SecretScanningAlerts: Ptr("ssa"), 2555 SecurityEvents: Ptr("se"), 2556 SingleFile: Ptr("sf"), 2557 Statuses: Ptr("s"), 2558 TeamDiscussions: Ptr("td"), 2559 VulnerabilityAlerts: Ptr("va"), 2560 Workflows: Ptr("w"), 2561 }, 2562 CreatedAt: &Timestamp{referenceTime}, 2563 UpdatedAt: &Timestamp{referenceTime}, 2564 HasMultipleSingleFiles: Ptr(false), 2565 SuspendedBy: &User{ 2566 Login: Ptr("l"), 2567 ID: Ptr(int64(1)), 2568 URL: Ptr("u"), 2569 AvatarURL: Ptr("a"), 2570 GravatarID: Ptr("g"), 2571 Name: Ptr("n"), 2572 Company: Ptr("c"), 2573 Blog: Ptr("b"), 2574 Location: Ptr("l"), 2575 Email: Ptr("e"), 2576 Hireable: Ptr(true), 2577 Bio: Ptr("b"), 2578 TwitterUsername: Ptr("t"), 2579 PublicRepos: Ptr(1), 2580 Followers: Ptr(1), 2581 Following: Ptr(1), 2582 CreatedAt: &Timestamp{referenceTime}, 2583 SuspendedAt: &Timestamp{referenceTime}, 2584 }, 2585 SuspendedAt: &Timestamp{referenceTime}, 2586 }, 2587 } 2588 2589 want := `{ 2590 "action": "a", 2591 "issue": { 2592 "id": 1 2593 }, 2594 "assignee": { 2595 "login": "l", 2596 "id": 1, 2597 "node_id": "n", 2598 "avatar_url": "a", 2599 "url": "u", 2600 "events_url": "e", 2601 "repos_url": "r" 2602 }, 2603 "label": { 2604 "id": 1 2605 }, 2606 "changes": { 2607 "title": { 2608 "from": "TitleFrom" 2609 }, 2610 "body": { 2611 "from": "BodyFrom" 2612 }, 2613 "base": { 2614 "ref": { 2615 "from": "BaseRefFrom" 2616 }, 2617 "sha": { 2618 "from": "BaseSHAFrom" 2619 } 2620 } 2621 }, 2622 "repository": { 2623 "id": 1, 2624 "name": "n", 2625 "url": "s" 2626 }, 2627 "sender": { 2628 "login": "l", 2629 "id": 1, 2630 "node_id": "n", 2631 "avatar_url": "a", 2632 "url": "u", 2633 "events_url": "e", 2634 "repos_url": "r" 2635 }, 2636 "installation": { 2637 "id": 1, 2638 "node_id": "nid", 2639 "app_id": 1, 2640 "app_slug": "as", 2641 "target_id": 1, 2642 "account": { 2643 "login": "l", 2644 "id": 1, 2645 "avatar_url": "a", 2646 "gravatar_id": "g", 2647 "name": "n", 2648 "company": "c", 2649 "blog": "b", 2650 "location": "l", 2651 "email": "e", 2652 "hireable": true, 2653 "bio": "b", 2654 "twitter_username": "t", 2655 "public_repos": 1, 2656 "followers": 1, 2657 "following": 1, 2658 "created_at": ` + referenceTimeStr + `, 2659 "suspended_at": ` + referenceTimeStr + `, 2660 "url": "u" 2661 }, 2662 "access_tokens_url": "atu", 2663 "repositories_url": "ru", 2664 "html_url": "hu", 2665 "target_type": "tt", 2666 "single_file_name": "sfn", 2667 "repository_selection": "rs", 2668 "events": [ 2669 "e" 2670 ], 2671 "single_file_paths": [ 2672 "s" 2673 ], 2674 "permissions": { 2675 "actions": "a", 2676 "administration": "ad", 2677 "checks": "c", 2678 "contents": "co", 2679 "content_references": "cr", 2680 "deployments": "d", 2681 "environments": "e", 2682 "issues": "i", 2683 "metadata": "md", 2684 "members": "m", 2685 "organization_administration": "oa", 2686 "organization_hooks": "oh", 2687 "organization_plan": "op", 2688 "organization_pre_receive_hooks": "opr", 2689 "organization_projects": "op", 2690 "organization_secrets": "os", 2691 "organization_self_hosted_runners": "osh", 2692 "organization_user_blocking": "oub", 2693 "packages": "pkg", 2694 "pages": "pg", 2695 "pull_requests": "pr", 2696 "repository_hooks": "rh", 2697 "repository_projects": "rp", 2698 "repository_pre_receive_hooks": "rprh", 2699 "secrets": "s", 2700 "secret_scanning_alerts": "ssa", 2701 "security_events": "se", 2702 "single_file": "sf", 2703 "statuses": "s", 2704 "team_discussions": "td", 2705 "vulnerability_alerts": "va", 2706 "workflows": "w" 2707 }, 2708 "created_at": ` + referenceTimeStr + `, 2709 "updated_at": ` + referenceTimeStr + `, 2710 "has_multiple_single_files": false, 2711 "suspended_by": { 2712 "login": "l", 2713 "id": 1, 2714 "avatar_url": "a", 2715 "gravatar_id": "g", 2716 "name": "n", 2717 "company": "c", 2718 "blog": "b", 2719 "location": "l", 2720 "email": "e", 2721 "hireable": true, 2722 "bio": "b", 2723 "twitter_username": "t", 2724 "public_repos": 1, 2725 "followers": 1, 2726 "following": 1, 2727 "created_at": ` + referenceTimeStr + `, 2728 "suspended_at": ` + referenceTimeStr + `, 2729 "url": "u" 2730 }, 2731 "suspended_at": ` + referenceTimeStr + ` 2732 } 2733 }` 2734 2735 testJSONMarshal(t, u, want) 2736 } 2737 2738 func TestLabelEvent_Marshal(t *testing.T) { 2739 t.Parallel() 2740 testJSONMarshal(t, &LabelEvent{}, "{}") 2741 2742 u := &LabelEvent{ 2743 Action: Ptr("a"), 2744 Label: &Label{ID: Ptr(int64(1))}, 2745 Changes: &EditChange{ 2746 Title: &EditTitle{ 2747 From: Ptr("TitleFrom"), 2748 }, 2749 Body: &EditBody{ 2750 From: Ptr("BodyFrom"), 2751 }, 2752 Base: &EditBase{ 2753 Ref: &EditRef{ 2754 From: Ptr("BaseRefFrom"), 2755 }, 2756 SHA: &EditSHA{ 2757 From: Ptr("BaseSHAFrom"), 2758 }, 2759 }, 2760 }, 2761 Repo: &Repository{ 2762 ID: Ptr(int64(1)), 2763 URL: Ptr("s"), 2764 Name: Ptr("n"), 2765 }, 2766 Org: &Organization{ 2767 BillingEmail: Ptr("be"), 2768 Blog: Ptr("b"), 2769 Company: Ptr("c"), 2770 Email: Ptr("e"), 2771 TwitterUsername: Ptr("tu"), 2772 Location: Ptr("loc"), 2773 Name: Ptr("n"), 2774 Description: Ptr("d"), 2775 IsVerified: Ptr(true), 2776 HasOrganizationProjects: Ptr(true), 2777 HasRepositoryProjects: Ptr(true), 2778 DefaultRepoPermission: Ptr("drp"), 2779 MembersCanCreateRepos: Ptr(true), 2780 MembersCanCreateInternalRepos: Ptr(true), 2781 MembersCanCreatePrivateRepos: Ptr(true), 2782 MembersCanCreatePublicRepos: Ptr(false), 2783 MembersAllowedRepositoryCreationType: Ptr("marct"), 2784 MembersCanCreatePages: Ptr(true), 2785 MembersCanCreatePublicPages: Ptr(false), 2786 MembersCanCreatePrivatePages: Ptr(true), 2787 }, 2788 Installation: &Installation{ 2789 ID: Ptr(int64(1)), 2790 NodeID: Ptr("nid"), 2791 AppID: Ptr(int64(1)), 2792 AppSlug: Ptr("as"), 2793 TargetID: Ptr(int64(1)), 2794 Account: &User{ 2795 Login: Ptr("l"), 2796 ID: Ptr(int64(1)), 2797 URL: Ptr("u"), 2798 AvatarURL: Ptr("a"), 2799 GravatarID: Ptr("g"), 2800 Name: Ptr("n"), 2801 Company: Ptr("c"), 2802 Blog: Ptr("b"), 2803 Location: Ptr("l"), 2804 Email: Ptr("e"), 2805 Hireable: Ptr(true), 2806 Bio: Ptr("b"), 2807 TwitterUsername: Ptr("t"), 2808 PublicRepos: Ptr(1), 2809 Followers: Ptr(1), 2810 Following: Ptr(1), 2811 CreatedAt: &Timestamp{referenceTime}, 2812 SuspendedAt: &Timestamp{referenceTime}, 2813 }, 2814 AccessTokensURL: Ptr("atu"), 2815 RepositoriesURL: Ptr("ru"), 2816 HTMLURL: Ptr("hu"), 2817 TargetType: Ptr("tt"), 2818 SingleFileName: Ptr("sfn"), 2819 RepositorySelection: Ptr("rs"), 2820 Events: []string{"e"}, 2821 SingleFilePaths: []string{"s"}, 2822 Permissions: &InstallationPermissions{ 2823 Actions: Ptr("a"), 2824 Administration: Ptr("ad"), 2825 Checks: Ptr("c"), 2826 Contents: Ptr("co"), 2827 ContentReferences: Ptr("cr"), 2828 Deployments: Ptr("d"), 2829 Environments: Ptr("e"), 2830 Issues: Ptr("i"), 2831 Metadata: Ptr("md"), 2832 Members: Ptr("m"), 2833 OrganizationAdministration: Ptr("oa"), 2834 OrganizationHooks: Ptr("oh"), 2835 OrganizationPlan: Ptr("op"), 2836 OrganizationPreReceiveHooks: Ptr("opr"), 2837 OrganizationProjects: Ptr("op"), 2838 OrganizationSecrets: Ptr("os"), 2839 OrganizationSelfHostedRunners: Ptr("osh"), 2840 OrganizationUserBlocking: Ptr("oub"), 2841 Packages: Ptr("pkg"), 2842 Pages: Ptr("pg"), 2843 PullRequests: Ptr("pr"), 2844 RepositoryHooks: Ptr("rh"), 2845 RepositoryProjects: Ptr("rp"), 2846 RepositoryPreReceiveHooks: Ptr("rprh"), 2847 Secrets: Ptr("s"), 2848 SecretScanningAlerts: Ptr("ssa"), 2849 SecurityEvents: Ptr("se"), 2850 SingleFile: Ptr("sf"), 2851 Statuses: Ptr("s"), 2852 TeamDiscussions: Ptr("td"), 2853 VulnerabilityAlerts: Ptr("va"), 2854 Workflows: Ptr("w"), 2855 }, 2856 CreatedAt: &Timestamp{referenceTime}, 2857 UpdatedAt: &Timestamp{referenceTime}, 2858 HasMultipleSingleFiles: Ptr(false), 2859 SuspendedBy: &User{ 2860 Login: Ptr("l"), 2861 ID: Ptr(int64(1)), 2862 URL: Ptr("u"), 2863 AvatarURL: Ptr("a"), 2864 GravatarID: Ptr("g"), 2865 Name: Ptr("n"), 2866 Company: Ptr("c"), 2867 Blog: Ptr("b"), 2868 Location: Ptr("l"), 2869 Email: Ptr("e"), 2870 Hireable: Ptr(true), 2871 Bio: Ptr("b"), 2872 TwitterUsername: Ptr("t"), 2873 PublicRepos: Ptr(1), 2874 Followers: Ptr(1), 2875 Following: Ptr(1), 2876 CreatedAt: &Timestamp{referenceTime}, 2877 SuspendedAt: &Timestamp{referenceTime}, 2878 }, 2879 SuspendedAt: &Timestamp{referenceTime}, 2880 }, 2881 } 2882 2883 want := `{ 2884 "action": "a", 2885 "label": { 2886 "id": 1 2887 }, 2888 "changes": { 2889 "title": { 2890 "from": "TitleFrom" 2891 }, 2892 "body": { 2893 "from": "BodyFrom" 2894 }, 2895 "base": { 2896 "ref": { 2897 "from": "BaseRefFrom" 2898 }, 2899 "sha": { 2900 "from": "BaseSHAFrom" 2901 } 2902 } 2903 }, 2904 "repository": { 2905 "id": 1, 2906 "name": "n", 2907 "url": "s" 2908 }, 2909 "organization": { 2910 "name": "n", 2911 "company": "c", 2912 "blog": "b", 2913 "location": "loc", 2914 "email": "e", 2915 "twitter_username": "tu", 2916 "description": "d", 2917 "billing_email": "be", 2918 "is_verified": true, 2919 "has_organization_projects": true, 2920 "has_repository_projects": true, 2921 "default_repository_permission": "drp", 2922 "members_can_create_repositories": true, 2923 "members_can_create_public_repositories": false, 2924 "members_can_create_private_repositories": true, 2925 "members_can_create_internal_repositories": true, 2926 "members_allowed_repository_creation_type": "marct", 2927 "members_can_create_pages": true, 2928 "members_can_create_public_pages": false, 2929 "members_can_create_private_pages": true 2930 }, 2931 "installation": { 2932 "id": 1, 2933 "node_id": "nid", 2934 "app_id": 1, 2935 "app_slug": "as", 2936 "target_id": 1, 2937 "account": { 2938 "login": "l", 2939 "id": 1, 2940 "avatar_url": "a", 2941 "gravatar_id": "g", 2942 "name": "n", 2943 "company": "c", 2944 "blog": "b", 2945 "location": "l", 2946 "email": "e", 2947 "hireable": true, 2948 "bio": "b", 2949 "twitter_username": "t", 2950 "public_repos": 1, 2951 "followers": 1, 2952 "following": 1, 2953 "created_at": ` + referenceTimeStr + `, 2954 "suspended_at": ` + referenceTimeStr + `, 2955 "url": "u" 2956 }, 2957 "access_tokens_url": "atu", 2958 "repositories_url": "ru", 2959 "html_url": "hu", 2960 "target_type": "tt", 2961 "single_file_name": "sfn", 2962 "repository_selection": "rs", 2963 "events": [ 2964 "e" 2965 ], 2966 "single_file_paths": [ 2967 "s" 2968 ], 2969 "permissions": { 2970 "actions": "a", 2971 "administration": "ad", 2972 "checks": "c", 2973 "contents": "co", 2974 "content_references": "cr", 2975 "deployments": "d", 2976 "environments": "e", 2977 "issues": "i", 2978 "metadata": "md", 2979 "members": "m", 2980 "organization_administration": "oa", 2981 "organization_hooks": "oh", 2982 "organization_plan": "op", 2983 "organization_pre_receive_hooks": "opr", 2984 "organization_projects": "op", 2985 "organization_secrets": "os", 2986 "organization_self_hosted_runners": "osh", 2987 "organization_user_blocking": "oub", 2988 "packages": "pkg", 2989 "pages": "pg", 2990 "pull_requests": "pr", 2991 "repository_hooks": "rh", 2992 "repository_projects": "rp", 2993 "repository_pre_receive_hooks": "rprh", 2994 "secrets": "s", 2995 "secret_scanning_alerts": "ssa", 2996 "security_events": "se", 2997 "single_file": "sf", 2998 "statuses": "s", 2999 "team_discussions": "td", 3000 "vulnerability_alerts": "va", 3001 "workflows": "w" 3002 }, 3003 "created_at": ` + referenceTimeStr + `, 3004 "updated_at": ` + referenceTimeStr + `, 3005 "has_multiple_single_files": false, 3006 "suspended_by": { 3007 "login": "l", 3008 "id": 1, 3009 "avatar_url": "a", 3010 "gravatar_id": "g", 3011 "name": "n", 3012 "company": "c", 3013 "blog": "b", 3014 "location": "l", 3015 "email": "e", 3016 "hireable": true, 3017 "bio": "b", 3018 "twitter_username": "t", 3019 "public_repos": 1, 3020 "followers": 1, 3021 "following": 1, 3022 "created_at": ` + referenceTimeStr + `, 3023 "suspended_at": ` + referenceTimeStr + `, 3024 "url": "u" 3025 }, 3026 "suspended_at": ` + referenceTimeStr + ` 3027 } 3028 }` 3029 3030 testJSONMarshal(t, u, want) 3031 } 3032 3033 func TestMilestoneEvent_Marshal(t *testing.T) { 3034 t.Parallel() 3035 testJSONMarshal(t, &MilestoneEvent{}, "{}") 3036 3037 u := &MilestoneEvent{ 3038 Action: Ptr("a"), 3039 Milestone: &Milestone{ID: Ptr(int64(1))}, 3040 Changes: &EditChange{ 3041 Title: &EditTitle{ 3042 From: Ptr("TitleFrom"), 3043 }, 3044 Body: &EditBody{ 3045 From: Ptr("BodyFrom"), 3046 }, 3047 Base: &EditBase{ 3048 Ref: &EditRef{ 3049 From: Ptr("BaseRefFrom"), 3050 }, 3051 SHA: &EditSHA{ 3052 From: Ptr("BaseSHAFrom"), 3053 }, 3054 }, 3055 }, 3056 Repo: &Repository{ 3057 ID: Ptr(int64(1)), 3058 URL: Ptr("s"), 3059 Name: Ptr("n"), 3060 }, 3061 Sender: &User{ 3062 Login: Ptr("l"), 3063 ID: Ptr(int64(1)), 3064 NodeID: Ptr("n"), 3065 URL: Ptr("u"), 3066 ReposURL: Ptr("r"), 3067 EventsURL: Ptr("e"), 3068 AvatarURL: Ptr("a"), 3069 }, 3070 Org: &Organization{ 3071 BillingEmail: Ptr("be"), 3072 Blog: Ptr("b"), 3073 Company: Ptr("c"), 3074 Email: Ptr("e"), 3075 TwitterUsername: Ptr("tu"), 3076 Location: Ptr("loc"), 3077 Name: Ptr("n"), 3078 Description: Ptr("d"), 3079 IsVerified: Ptr(true), 3080 HasOrganizationProjects: Ptr(true), 3081 HasRepositoryProjects: Ptr(true), 3082 DefaultRepoPermission: Ptr("drp"), 3083 MembersCanCreateRepos: Ptr(true), 3084 MembersCanCreateInternalRepos: Ptr(true), 3085 MembersCanCreatePrivateRepos: Ptr(true), 3086 MembersCanCreatePublicRepos: Ptr(false), 3087 MembersAllowedRepositoryCreationType: Ptr("marct"), 3088 MembersCanCreatePages: Ptr(true), 3089 MembersCanCreatePublicPages: Ptr(false), 3090 MembersCanCreatePrivatePages: Ptr(true), 3091 }, 3092 Installation: &Installation{ 3093 ID: Ptr(int64(1)), 3094 NodeID: Ptr("nid"), 3095 AppID: Ptr(int64(1)), 3096 AppSlug: Ptr("as"), 3097 TargetID: Ptr(int64(1)), 3098 Account: &User{ 3099 Login: Ptr("l"), 3100 ID: Ptr(int64(1)), 3101 URL: Ptr("u"), 3102 AvatarURL: Ptr("a"), 3103 GravatarID: Ptr("g"), 3104 Name: Ptr("n"), 3105 Company: Ptr("c"), 3106 Blog: Ptr("b"), 3107 Location: Ptr("l"), 3108 Email: Ptr("e"), 3109 Hireable: Ptr(true), 3110 Bio: Ptr("b"), 3111 TwitterUsername: Ptr("t"), 3112 PublicRepos: Ptr(1), 3113 Followers: Ptr(1), 3114 Following: Ptr(1), 3115 CreatedAt: &Timestamp{referenceTime}, 3116 SuspendedAt: &Timestamp{referenceTime}, 3117 }, 3118 AccessTokensURL: Ptr("atu"), 3119 RepositoriesURL: Ptr("ru"), 3120 HTMLURL: Ptr("hu"), 3121 TargetType: Ptr("tt"), 3122 SingleFileName: Ptr("sfn"), 3123 RepositorySelection: Ptr("rs"), 3124 Events: []string{"e"}, 3125 SingleFilePaths: []string{"s"}, 3126 Permissions: &InstallationPermissions{ 3127 Actions: Ptr("a"), 3128 Administration: Ptr("ad"), 3129 Checks: Ptr("c"), 3130 Contents: Ptr("co"), 3131 ContentReferences: Ptr("cr"), 3132 Deployments: Ptr("d"), 3133 Environments: Ptr("e"), 3134 Issues: Ptr("i"), 3135 Metadata: Ptr("md"), 3136 Members: Ptr("m"), 3137 OrganizationAdministration: Ptr("oa"), 3138 OrganizationHooks: Ptr("oh"), 3139 OrganizationPlan: Ptr("op"), 3140 OrganizationPreReceiveHooks: Ptr("opr"), 3141 OrganizationProjects: Ptr("op"), 3142 OrganizationSecrets: Ptr("os"), 3143 OrganizationSelfHostedRunners: Ptr("osh"), 3144 OrganizationUserBlocking: Ptr("oub"), 3145 Packages: Ptr("pkg"), 3146 Pages: Ptr("pg"), 3147 PullRequests: Ptr("pr"), 3148 RepositoryHooks: Ptr("rh"), 3149 RepositoryProjects: Ptr("rp"), 3150 RepositoryPreReceiveHooks: Ptr("rprh"), 3151 Secrets: Ptr("s"), 3152 SecretScanningAlerts: Ptr("ssa"), 3153 SecurityEvents: Ptr("se"), 3154 SingleFile: Ptr("sf"), 3155 Statuses: Ptr("s"), 3156 TeamDiscussions: Ptr("td"), 3157 VulnerabilityAlerts: Ptr("va"), 3158 Workflows: Ptr("w"), 3159 }, 3160 CreatedAt: &Timestamp{referenceTime}, 3161 UpdatedAt: &Timestamp{referenceTime}, 3162 HasMultipleSingleFiles: Ptr(false), 3163 SuspendedBy: &User{ 3164 Login: Ptr("l"), 3165 ID: Ptr(int64(1)), 3166 URL: Ptr("u"), 3167 AvatarURL: Ptr("a"), 3168 GravatarID: Ptr("g"), 3169 Name: Ptr("n"), 3170 Company: Ptr("c"), 3171 Blog: Ptr("b"), 3172 Location: Ptr("l"), 3173 Email: Ptr("e"), 3174 Hireable: Ptr(true), 3175 Bio: Ptr("b"), 3176 TwitterUsername: Ptr("t"), 3177 PublicRepos: Ptr(1), 3178 Followers: Ptr(1), 3179 Following: Ptr(1), 3180 CreatedAt: &Timestamp{referenceTime}, 3181 SuspendedAt: &Timestamp{referenceTime}, 3182 }, 3183 SuspendedAt: &Timestamp{referenceTime}, 3184 }, 3185 } 3186 3187 want := `{ 3188 "action": "a", 3189 "milestone": { 3190 "id": 1 3191 }, 3192 "changes": { 3193 "title": { 3194 "from": "TitleFrom" 3195 }, 3196 "body": { 3197 "from": "BodyFrom" 3198 }, 3199 "base": { 3200 "ref": { 3201 "from": "BaseRefFrom" 3202 }, 3203 "sha": { 3204 "from": "BaseSHAFrom" 3205 } 3206 } 3207 }, 3208 "repository": { 3209 "id": 1, 3210 "name": "n", 3211 "url": "s" 3212 }, 3213 "sender": { 3214 "login": "l", 3215 "id": 1, 3216 "node_id": "n", 3217 "avatar_url": "a", 3218 "url": "u", 3219 "events_url": "e", 3220 "repos_url": "r" 3221 }, 3222 "organization": { 3223 "name": "n", 3224 "company": "c", 3225 "blog": "b", 3226 "location": "loc", 3227 "email": "e", 3228 "twitter_username": "tu", 3229 "description": "d", 3230 "billing_email": "be", 3231 "is_verified": true, 3232 "has_organization_projects": true, 3233 "has_repository_projects": true, 3234 "default_repository_permission": "drp", 3235 "members_can_create_repositories": true, 3236 "members_can_create_public_repositories": false, 3237 "members_can_create_private_repositories": true, 3238 "members_can_create_internal_repositories": true, 3239 "members_allowed_repository_creation_type": "marct", 3240 "members_can_create_pages": true, 3241 "members_can_create_public_pages": false, 3242 "members_can_create_private_pages": true 3243 }, 3244 "installation": { 3245 "id": 1, 3246 "node_id": "nid", 3247 "app_id": 1, 3248 "app_slug": "as", 3249 "target_id": 1, 3250 "account": { 3251 "login": "l", 3252 "id": 1, 3253 "avatar_url": "a", 3254 "gravatar_id": "g", 3255 "name": "n", 3256 "company": "c", 3257 "blog": "b", 3258 "location": "l", 3259 "email": "e", 3260 "hireable": true, 3261 "bio": "b", 3262 "twitter_username": "t", 3263 "public_repos": 1, 3264 "followers": 1, 3265 "following": 1, 3266 "created_at": ` + referenceTimeStr + `, 3267 "suspended_at": ` + referenceTimeStr + `, 3268 "url": "u" 3269 }, 3270 "access_tokens_url": "atu", 3271 "repositories_url": "ru", 3272 "html_url": "hu", 3273 "target_type": "tt", 3274 "single_file_name": "sfn", 3275 "repository_selection": "rs", 3276 "events": [ 3277 "e" 3278 ], 3279 "single_file_paths": [ 3280 "s" 3281 ], 3282 "permissions": { 3283 "actions": "a", 3284 "administration": "ad", 3285 "checks": "c", 3286 "contents": "co", 3287 "content_references": "cr", 3288 "deployments": "d", 3289 "environments": "e", 3290 "issues": "i", 3291 "metadata": "md", 3292 "members": "m", 3293 "organization_administration": "oa", 3294 "organization_hooks": "oh", 3295 "organization_plan": "op", 3296 "organization_pre_receive_hooks": "opr", 3297 "organization_projects": "op", 3298 "organization_secrets": "os", 3299 "organization_self_hosted_runners": "osh", 3300 "organization_user_blocking": "oub", 3301 "packages": "pkg", 3302 "pages": "pg", 3303 "pull_requests": "pr", 3304 "repository_hooks": "rh", 3305 "repository_projects": "rp", 3306 "repository_pre_receive_hooks": "rprh", 3307 "secrets": "s", 3308 "secret_scanning_alerts": "ssa", 3309 "security_events": "se", 3310 "single_file": "sf", 3311 "statuses": "s", 3312 "team_discussions": "td", 3313 "vulnerability_alerts": "va", 3314 "workflows": "w" 3315 }, 3316 "created_at": ` + referenceTimeStr + `, 3317 "updated_at": ` + referenceTimeStr + `, 3318 "has_multiple_single_files": false, 3319 "suspended_by": { 3320 "login": "l", 3321 "id": 1, 3322 "avatar_url": "a", 3323 "gravatar_id": "g", 3324 "name": "n", 3325 "company": "c", 3326 "blog": "b", 3327 "location": "l", 3328 "email": "e", 3329 "hireable": true, 3330 "bio": "b", 3331 "twitter_username": "t", 3332 "public_repos": 1, 3333 "followers": 1, 3334 "following": 1, 3335 "created_at": ` + referenceTimeStr + `, 3336 "suspended_at": ` + referenceTimeStr + `, 3337 "url": "u" 3338 }, 3339 "suspended_at": ` + referenceTimeStr + ` 3340 } 3341 }` 3342 3343 testJSONMarshal(t, u, want) 3344 } 3345 3346 func TestPublicEvent_Marshal(t *testing.T) { 3347 t.Parallel() 3348 testJSONMarshal(t, &PublicEvent{}, "{}") 3349 3350 u := &PublicEvent{ 3351 Repo: &Repository{ 3352 ID: Ptr(int64(1)), 3353 URL: Ptr("s"), 3354 Name: Ptr("n"), 3355 }, 3356 Sender: &User{ 3357 Login: Ptr("l"), 3358 ID: Ptr(int64(1)), 3359 NodeID: Ptr("n"), 3360 URL: Ptr("u"), 3361 ReposURL: Ptr("r"), 3362 EventsURL: Ptr("e"), 3363 AvatarURL: Ptr("a"), 3364 }, 3365 Installation: &Installation{ 3366 ID: Ptr(int64(1)), 3367 NodeID: Ptr("nid"), 3368 AppID: Ptr(int64(1)), 3369 AppSlug: Ptr("as"), 3370 TargetID: Ptr(int64(1)), 3371 Account: &User{ 3372 Login: Ptr("l"), 3373 ID: Ptr(int64(1)), 3374 URL: Ptr("u"), 3375 AvatarURL: Ptr("a"), 3376 GravatarID: Ptr("g"), 3377 Name: Ptr("n"), 3378 Company: Ptr("c"), 3379 Blog: Ptr("b"), 3380 Location: Ptr("l"), 3381 Email: Ptr("e"), 3382 Hireable: Ptr(true), 3383 Bio: Ptr("b"), 3384 TwitterUsername: Ptr("t"), 3385 PublicRepos: Ptr(1), 3386 Followers: Ptr(1), 3387 Following: Ptr(1), 3388 CreatedAt: &Timestamp{referenceTime}, 3389 SuspendedAt: &Timestamp{referenceTime}, 3390 }, 3391 AccessTokensURL: Ptr("atu"), 3392 RepositoriesURL: Ptr("ru"), 3393 HTMLURL: Ptr("hu"), 3394 TargetType: Ptr("tt"), 3395 SingleFileName: Ptr("sfn"), 3396 RepositorySelection: Ptr("rs"), 3397 Events: []string{"e"}, 3398 SingleFilePaths: []string{"s"}, 3399 Permissions: &InstallationPermissions{ 3400 Actions: Ptr("a"), 3401 Administration: Ptr("ad"), 3402 Checks: Ptr("c"), 3403 Contents: Ptr("co"), 3404 ContentReferences: Ptr("cr"), 3405 Deployments: Ptr("d"), 3406 Environments: Ptr("e"), 3407 Issues: Ptr("i"), 3408 Metadata: Ptr("md"), 3409 Members: Ptr("m"), 3410 OrganizationAdministration: Ptr("oa"), 3411 OrganizationHooks: Ptr("oh"), 3412 OrganizationPlan: Ptr("op"), 3413 OrganizationPreReceiveHooks: Ptr("opr"), 3414 OrganizationProjects: Ptr("op"), 3415 OrganizationSecrets: Ptr("os"), 3416 OrganizationSelfHostedRunners: Ptr("osh"), 3417 OrganizationUserBlocking: Ptr("oub"), 3418 Packages: Ptr("pkg"), 3419 Pages: Ptr("pg"), 3420 PullRequests: Ptr("pr"), 3421 RepositoryHooks: Ptr("rh"), 3422 RepositoryProjects: Ptr("rp"), 3423 RepositoryPreReceiveHooks: Ptr("rprh"), 3424 Secrets: Ptr("s"), 3425 SecretScanningAlerts: Ptr("ssa"), 3426 SecurityEvents: Ptr("se"), 3427 SingleFile: Ptr("sf"), 3428 Statuses: Ptr("s"), 3429 TeamDiscussions: Ptr("td"), 3430 VulnerabilityAlerts: Ptr("va"), 3431 Workflows: Ptr("w"), 3432 }, 3433 CreatedAt: &Timestamp{referenceTime}, 3434 UpdatedAt: &Timestamp{referenceTime}, 3435 HasMultipleSingleFiles: Ptr(false), 3436 SuspendedBy: &User{ 3437 Login: Ptr("l"), 3438 ID: Ptr(int64(1)), 3439 URL: Ptr("u"), 3440 AvatarURL: Ptr("a"), 3441 GravatarID: Ptr("g"), 3442 Name: Ptr("n"), 3443 Company: Ptr("c"), 3444 Blog: Ptr("b"), 3445 Location: Ptr("l"), 3446 Email: Ptr("e"), 3447 Hireable: Ptr(true), 3448 Bio: Ptr("b"), 3449 TwitterUsername: Ptr("t"), 3450 PublicRepos: Ptr(1), 3451 Followers: Ptr(1), 3452 Following: Ptr(1), 3453 CreatedAt: &Timestamp{referenceTime}, 3454 SuspendedAt: &Timestamp{referenceTime}, 3455 }, 3456 SuspendedAt: &Timestamp{referenceTime}, 3457 }, 3458 } 3459 3460 want := `{ 3461 "repository": { 3462 "id": 1, 3463 "name": "n", 3464 "url": "s" 3465 }, 3466 "sender": { 3467 "login": "l", 3468 "id": 1, 3469 "node_id": "n", 3470 "avatar_url": "a", 3471 "url": "u", 3472 "events_url": "e", 3473 "repos_url": "r" 3474 }, 3475 "installation": { 3476 "id": 1, 3477 "node_id": "nid", 3478 "app_id": 1, 3479 "app_slug": "as", 3480 "target_id": 1, 3481 "account": { 3482 "login": "l", 3483 "id": 1, 3484 "avatar_url": "a", 3485 "gravatar_id": "g", 3486 "name": "n", 3487 "company": "c", 3488 "blog": "b", 3489 "location": "l", 3490 "email": "e", 3491 "hireable": true, 3492 "bio": "b", 3493 "twitter_username": "t", 3494 "public_repos": 1, 3495 "followers": 1, 3496 "following": 1, 3497 "created_at": ` + referenceTimeStr + `, 3498 "suspended_at": ` + referenceTimeStr + `, 3499 "url": "u" 3500 }, 3501 "access_tokens_url": "atu", 3502 "repositories_url": "ru", 3503 "html_url": "hu", 3504 "target_type": "tt", 3505 "single_file_name": "sfn", 3506 "repository_selection": "rs", 3507 "events": [ 3508 "e" 3509 ], 3510 "single_file_paths": [ 3511 "s" 3512 ], 3513 "permissions": { 3514 "actions": "a", 3515 "administration": "ad", 3516 "checks": "c", 3517 "contents": "co", 3518 "content_references": "cr", 3519 "deployments": "d", 3520 "environments": "e", 3521 "issues": "i", 3522 "metadata": "md", 3523 "members": "m", 3524 "organization_administration": "oa", 3525 "organization_hooks": "oh", 3526 "organization_plan": "op", 3527 "organization_pre_receive_hooks": "opr", 3528 "organization_projects": "op", 3529 "organization_secrets": "os", 3530 "organization_self_hosted_runners": "osh", 3531 "organization_user_blocking": "oub", 3532 "packages": "pkg", 3533 "pages": "pg", 3534 "pull_requests": "pr", 3535 "repository_hooks": "rh", 3536 "repository_projects": "rp", 3537 "repository_pre_receive_hooks": "rprh", 3538 "secrets": "s", 3539 "secret_scanning_alerts": "ssa", 3540 "security_events": "se", 3541 "single_file": "sf", 3542 "statuses": "s", 3543 "team_discussions": "td", 3544 "vulnerability_alerts": "va", 3545 "workflows": "w" 3546 }, 3547 "created_at": ` + referenceTimeStr + `, 3548 "updated_at": ` + referenceTimeStr + `, 3549 "has_multiple_single_files": false, 3550 "suspended_by": { 3551 "login": "l", 3552 "id": 1, 3553 "avatar_url": "a", 3554 "gravatar_id": "g", 3555 "name": "n", 3556 "company": "c", 3557 "blog": "b", 3558 "location": "l", 3559 "email": "e", 3560 "hireable": true, 3561 "bio": "b", 3562 "twitter_username": "t", 3563 "public_repos": 1, 3564 "followers": 1, 3565 "following": 1, 3566 "created_at": ` + referenceTimeStr + `, 3567 "suspended_at": ` + referenceTimeStr + `, 3568 "url": "u" 3569 }, 3570 "suspended_at": ` + referenceTimeStr + ` 3571 } 3572 }` 3573 3574 testJSONMarshal(t, u, want) 3575 } 3576 3577 func TestPullRequestReviewEvent_Marshal(t *testing.T) { 3578 t.Parallel() 3579 testJSONMarshal(t, &PullRequestReviewEvent{}, "{}") 3580 3581 u := &PullRequestReviewEvent{ 3582 Action: Ptr("a"), 3583 Review: &PullRequestReview{ID: Ptr(int64(1))}, 3584 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 3585 Repo: &Repository{ 3586 ID: Ptr(int64(1)), 3587 URL: Ptr("s"), 3588 Name: Ptr("n"), 3589 }, 3590 Sender: &User{ 3591 Login: Ptr("l"), 3592 ID: Ptr(int64(1)), 3593 NodeID: Ptr("n"), 3594 URL: Ptr("u"), 3595 ReposURL: Ptr("r"), 3596 EventsURL: Ptr("e"), 3597 AvatarURL: Ptr("a"), 3598 }, 3599 Installation: &Installation{ 3600 ID: Ptr(int64(1)), 3601 NodeID: Ptr("nid"), 3602 AppID: Ptr(int64(1)), 3603 AppSlug: Ptr("as"), 3604 TargetID: Ptr(int64(1)), 3605 Account: &User{ 3606 Login: Ptr("l"), 3607 ID: Ptr(int64(1)), 3608 URL: Ptr("u"), 3609 AvatarURL: Ptr("a"), 3610 GravatarID: Ptr("g"), 3611 Name: Ptr("n"), 3612 Company: Ptr("c"), 3613 Blog: Ptr("b"), 3614 Location: Ptr("l"), 3615 Email: Ptr("e"), 3616 Hireable: Ptr(true), 3617 Bio: Ptr("b"), 3618 TwitterUsername: Ptr("t"), 3619 PublicRepos: Ptr(1), 3620 Followers: Ptr(1), 3621 Following: Ptr(1), 3622 CreatedAt: &Timestamp{referenceTime}, 3623 SuspendedAt: &Timestamp{referenceTime}, 3624 }, 3625 AccessTokensURL: Ptr("atu"), 3626 RepositoriesURL: Ptr("ru"), 3627 HTMLURL: Ptr("hu"), 3628 TargetType: Ptr("tt"), 3629 SingleFileName: Ptr("sfn"), 3630 RepositorySelection: Ptr("rs"), 3631 Events: []string{"e"}, 3632 SingleFilePaths: []string{"s"}, 3633 Permissions: &InstallationPermissions{ 3634 Actions: Ptr("a"), 3635 Administration: Ptr("ad"), 3636 Checks: Ptr("c"), 3637 Contents: Ptr("co"), 3638 ContentReferences: Ptr("cr"), 3639 Deployments: Ptr("d"), 3640 Environments: Ptr("e"), 3641 Issues: Ptr("i"), 3642 Metadata: Ptr("md"), 3643 Members: Ptr("m"), 3644 OrganizationAdministration: Ptr("oa"), 3645 OrganizationHooks: Ptr("oh"), 3646 OrganizationPlan: Ptr("op"), 3647 OrganizationPreReceiveHooks: Ptr("opr"), 3648 OrganizationProjects: Ptr("op"), 3649 OrganizationSecrets: Ptr("os"), 3650 OrganizationSelfHostedRunners: Ptr("osh"), 3651 OrganizationUserBlocking: Ptr("oub"), 3652 Packages: Ptr("pkg"), 3653 Pages: Ptr("pg"), 3654 PullRequests: Ptr("pr"), 3655 RepositoryHooks: Ptr("rh"), 3656 RepositoryProjects: Ptr("rp"), 3657 RepositoryPreReceiveHooks: Ptr("rprh"), 3658 Secrets: Ptr("s"), 3659 SecretScanningAlerts: Ptr("ssa"), 3660 SecurityEvents: Ptr("se"), 3661 SingleFile: Ptr("sf"), 3662 Statuses: Ptr("s"), 3663 TeamDiscussions: Ptr("td"), 3664 VulnerabilityAlerts: Ptr("va"), 3665 Workflows: Ptr("w"), 3666 }, 3667 CreatedAt: &Timestamp{referenceTime}, 3668 UpdatedAt: &Timestamp{referenceTime}, 3669 HasMultipleSingleFiles: Ptr(false), 3670 SuspendedBy: &User{ 3671 Login: Ptr("l"), 3672 ID: Ptr(int64(1)), 3673 URL: Ptr("u"), 3674 AvatarURL: Ptr("a"), 3675 GravatarID: Ptr("g"), 3676 Name: Ptr("n"), 3677 Company: Ptr("c"), 3678 Blog: Ptr("b"), 3679 Location: Ptr("l"), 3680 Email: Ptr("e"), 3681 Hireable: Ptr(true), 3682 Bio: Ptr("b"), 3683 TwitterUsername: Ptr("t"), 3684 PublicRepos: Ptr(1), 3685 Followers: Ptr(1), 3686 Following: Ptr(1), 3687 CreatedAt: &Timestamp{referenceTime}, 3688 SuspendedAt: &Timestamp{referenceTime}, 3689 }, 3690 SuspendedAt: &Timestamp{referenceTime}, 3691 }, 3692 Organization: &Organization{ 3693 BillingEmail: Ptr("be"), 3694 Blog: Ptr("b"), 3695 Company: Ptr("c"), 3696 Email: Ptr("e"), 3697 TwitterUsername: Ptr("tu"), 3698 Location: Ptr("loc"), 3699 Name: Ptr("n"), 3700 Description: Ptr("d"), 3701 IsVerified: Ptr(true), 3702 HasOrganizationProjects: Ptr(true), 3703 HasRepositoryProjects: Ptr(true), 3704 DefaultRepoPermission: Ptr("drp"), 3705 MembersCanCreateRepos: Ptr(true), 3706 MembersCanCreateInternalRepos: Ptr(true), 3707 MembersCanCreatePrivateRepos: Ptr(true), 3708 MembersCanCreatePublicRepos: Ptr(false), 3709 MembersAllowedRepositoryCreationType: Ptr("marct"), 3710 MembersCanCreatePages: Ptr(true), 3711 MembersCanCreatePublicPages: Ptr(false), 3712 MembersCanCreatePrivatePages: Ptr(true), 3713 }, 3714 } 3715 3716 want := `{ 3717 "action": "a", 3718 "review": { 3719 "id": 1 3720 }, 3721 "pull_request": { 3722 "id": 1 3723 }, 3724 "repository": { 3725 "id": 1, 3726 "name": "n", 3727 "url": "s" 3728 }, 3729 "sender": { 3730 "login": "l", 3731 "id": 1, 3732 "node_id": "n", 3733 "avatar_url": "a", 3734 "url": "u", 3735 "events_url": "e", 3736 "repos_url": "r" 3737 }, 3738 "installation": { 3739 "id": 1, 3740 "node_id": "nid", 3741 "app_id": 1, 3742 "app_slug": "as", 3743 "target_id": 1, 3744 "account": { 3745 "login": "l", 3746 "id": 1, 3747 "avatar_url": "a", 3748 "gravatar_id": "g", 3749 "name": "n", 3750 "company": "c", 3751 "blog": "b", 3752 "location": "l", 3753 "email": "e", 3754 "hireable": true, 3755 "bio": "b", 3756 "twitter_username": "t", 3757 "public_repos": 1, 3758 "followers": 1, 3759 "following": 1, 3760 "created_at": ` + referenceTimeStr + `, 3761 "suspended_at": ` + referenceTimeStr + `, 3762 "url": "u" 3763 }, 3764 "access_tokens_url": "atu", 3765 "repositories_url": "ru", 3766 "html_url": "hu", 3767 "target_type": "tt", 3768 "single_file_name": "sfn", 3769 "repository_selection": "rs", 3770 "events": [ 3771 "e" 3772 ], 3773 "single_file_paths": [ 3774 "s" 3775 ], 3776 "permissions": { 3777 "actions": "a", 3778 "administration": "ad", 3779 "checks": "c", 3780 "contents": "co", 3781 "content_references": "cr", 3782 "deployments": "d", 3783 "environments": "e", 3784 "issues": "i", 3785 "metadata": "md", 3786 "members": "m", 3787 "organization_administration": "oa", 3788 "organization_hooks": "oh", 3789 "organization_plan": "op", 3790 "organization_pre_receive_hooks": "opr", 3791 "organization_projects": "op", 3792 "organization_secrets": "os", 3793 "organization_self_hosted_runners": "osh", 3794 "organization_user_blocking": "oub", 3795 "packages": "pkg", 3796 "pages": "pg", 3797 "pull_requests": "pr", 3798 "repository_hooks": "rh", 3799 "repository_projects": "rp", 3800 "repository_pre_receive_hooks": "rprh", 3801 "secrets": "s", 3802 "secret_scanning_alerts": "ssa", 3803 "security_events": "se", 3804 "single_file": "sf", 3805 "statuses": "s", 3806 "team_discussions": "td", 3807 "vulnerability_alerts": "va", 3808 "workflows": "w" 3809 }, 3810 "created_at": ` + referenceTimeStr + `, 3811 "updated_at": ` + referenceTimeStr + `, 3812 "has_multiple_single_files": false, 3813 "suspended_by": { 3814 "login": "l", 3815 "id": 1, 3816 "avatar_url": "a", 3817 "gravatar_id": "g", 3818 "name": "n", 3819 "company": "c", 3820 "blog": "b", 3821 "location": "l", 3822 "email": "e", 3823 "hireable": true, 3824 "bio": "b", 3825 "twitter_username": "t", 3826 "public_repos": 1, 3827 "followers": 1, 3828 "following": 1, 3829 "created_at": ` + referenceTimeStr + `, 3830 "suspended_at": ` + referenceTimeStr + `, 3831 "url": "u" 3832 }, 3833 "suspended_at": ` + referenceTimeStr + ` 3834 }, 3835 "organization": { 3836 "name": "n", 3837 "company": "c", 3838 "blog": "b", 3839 "location": "loc", 3840 "email": "e", 3841 "twitter_username": "tu", 3842 "description": "d", 3843 "billing_email": "be", 3844 "is_verified": true, 3845 "has_organization_projects": true, 3846 "has_repository_projects": true, 3847 "default_repository_permission": "drp", 3848 "members_can_create_repositories": true, 3849 "members_can_create_public_repositories": false, 3850 "members_can_create_private_repositories": true, 3851 "members_can_create_internal_repositories": true, 3852 "members_allowed_repository_creation_type": "marct", 3853 "members_can_create_pages": true, 3854 "members_can_create_public_pages": false, 3855 "members_can_create_private_pages": true 3856 } 3857 }` 3858 3859 testJSONMarshal(t, u, want) 3860 } 3861 3862 func TestPushEvent_Marshal(t *testing.T) { 3863 t.Parallel() 3864 testJSONMarshal(t, &PushEvent{}, "{}") 3865 3866 u := &PushEvent{ 3867 PushID: Ptr(int64(1)), 3868 Head: Ptr("h"), 3869 Ref: Ptr("ref"), 3870 Size: Ptr(1), 3871 Commits: []*HeadCommit{ 3872 {ID: Ptr("id")}, 3873 }, 3874 Before: Ptr("b"), 3875 DistinctSize: Ptr(1), 3876 After: Ptr("a"), 3877 Created: Ptr(true), 3878 Deleted: Ptr(true), 3879 Forced: Ptr(true), 3880 BaseRef: Ptr("a"), 3881 Compare: Ptr("a"), 3882 Repo: &PushEventRepository{ID: Ptr(int64(1))}, 3883 HeadCommit: &HeadCommit{ID: Ptr("id")}, 3884 Pusher: &CommitAuthor{ 3885 Login: Ptr("l"), 3886 Date: &Timestamp{referenceTime}, 3887 Name: Ptr("n"), 3888 Email: Ptr("e"), 3889 }, 3890 Sender: &User{ 3891 Login: Ptr("l"), 3892 ID: Ptr(int64(1)), 3893 NodeID: Ptr("n"), 3894 URL: Ptr("u"), 3895 ReposURL: Ptr("r"), 3896 EventsURL: Ptr("e"), 3897 AvatarURL: Ptr("a"), 3898 }, 3899 Installation: &Installation{ 3900 ID: Ptr(int64(1)), 3901 NodeID: Ptr("nid"), 3902 AppID: Ptr(int64(1)), 3903 AppSlug: Ptr("as"), 3904 TargetID: Ptr(int64(1)), 3905 Account: &User{ 3906 Login: Ptr("l"), 3907 ID: Ptr(int64(1)), 3908 URL: Ptr("u"), 3909 AvatarURL: Ptr("a"), 3910 GravatarID: Ptr("g"), 3911 Name: Ptr("n"), 3912 Company: Ptr("c"), 3913 Blog: Ptr("b"), 3914 Location: Ptr("l"), 3915 Email: Ptr("e"), 3916 Hireable: Ptr(true), 3917 Bio: Ptr("b"), 3918 TwitterUsername: Ptr("t"), 3919 PublicRepos: Ptr(1), 3920 Followers: Ptr(1), 3921 Following: Ptr(1), 3922 CreatedAt: &Timestamp{referenceTime}, 3923 SuspendedAt: &Timestamp{referenceTime}, 3924 }, 3925 AccessTokensURL: Ptr("atu"), 3926 RepositoriesURL: Ptr("ru"), 3927 HTMLURL: Ptr("hu"), 3928 TargetType: Ptr("tt"), 3929 SingleFileName: Ptr("sfn"), 3930 RepositorySelection: Ptr("rs"), 3931 Events: []string{"e"}, 3932 SingleFilePaths: []string{"s"}, 3933 Permissions: &InstallationPermissions{ 3934 Actions: Ptr("a"), 3935 Administration: Ptr("ad"), 3936 Checks: Ptr("c"), 3937 Contents: Ptr("co"), 3938 ContentReferences: Ptr("cr"), 3939 Deployments: Ptr("d"), 3940 Environments: Ptr("e"), 3941 Issues: Ptr("i"), 3942 Metadata: Ptr("md"), 3943 Members: Ptr("m"), 3944 OrganizationAdministration: Ptr("oa"), 3945 OrganizationHooks: Ptr("oh"), 3946 OrganizationPlan: Ptr("op"), 3947 OrganizationPreReceiveHooks: Ptr("opr"), 3948 OrganizationProjects: Ptr("op"), 3949 OrganizationSecrets: Ptr("os"), 3950 OrganizationSelfHostedRunners: Ptr("osh"), 3951 OrganizationUserBlocking: Ptr("oub"), 3952 Packages: Ptr("pkg"), 3953 Pages: Ptr("pg"), 3954 PullRequests: Ptr("pr"), 3955 RepositoryHooks: Ptr("rh"), 3956 RepositoryProjects: Ptr("rp"), 3957 RepositoryPreReceiveHooks: Ptr("rprh"), 3958 Secrets: Ptr("s"), 3959 SecretScanningAlerts: Ptr("ssa"), 3960 SecurityEvents: Ptr("se"), 3961 SingleFile: Ptr("sf"), 3962 Statuses: Ptr("s"), 3963 TeamDiscussions: Ptr("td"), 3964 VulnerabilityAlerts: Ptr("va"), 3965 Workflows: Ptr("w"), 3966 }, 3967 CreatedAt: &Timestamp{referenceTime}, 3968 UpdatedAt: &Timestamp{referenceTime}, 3969 HasMultipleSingleFiles: Ptr(false), 3970 SuspendedBy: &User{ 3971 Login: Ptr("l"), 3972 ID: Ptr(int64(1)), 3973 URL: Ptr("u"), 3974 AvatarURL: Ptr("a"), 3975 GravatarID: Ptr("g"), 3976 Name: Ptr("n"), 3977 Company: Ptr("c"), 3978 Blog: Ptr("b"), 3979 Location: Ptr("l"), 3980 Email: Ptr("e"), 3981 Hireable: Ptr(true), 3982 Bio: Ptr("b"), 3983 TwitterUsername: Ptr("t"), 3984 PublicRepos: Ptr(1), 3985 Followers: Ptr(1), 3986 Following: Ptr(1), 3987 CreatedAt: &Timestamp{referenceTime}, 3988 SuspendedAt: &Timestamp{referenceTime}, 3989 }, 3990 SuspendedAt: &Timestamp{referenceTime}, 3991 }, 3992 Organization: &Organization{ 3993 BillingEmail: Ptr("be"), 3994 Blog: Ptr("b"), 3995 Company: Ptr("c"), 3996 Email: Ptr("e"), 3997 TwitterUsername: Ptr("tu"), 3998 Location: Ptr("loc"), 3999 Name: Ptr("n"), 4000 Description: Ptr("d"), 4001 IsVerified: Ptr(true), 4002 HasOrganizationProjects: Ptr(true), 4003 HasRepositoryProjects: Ptr(true), 4004 DefaultRepoPermission: Ptr("drp"), 4005 MembersCanCreateRepos: Ptr(true), 4006 MembersCanCreateInternalRepos: Ptr(true), 4007 MembersCanCreatePrivateRepos: Ptr(true), 4008 MembersCanCreatePublicRepos: Ptr(false), 4009 MembersAllowedRepositoryCreationType: Ptr("marct"), 4010 MembersCanCreatePages: Ptr(true), 4011 MembersCanCreatePublicPages: Ptr(false), 4012 MembersCanCreatePrivatePages: Ptr(true), 4013 }, 4014 } 4015 4016 want := `{ 4017 "push_id": 1, 4018 "head": "h", 4019 "ref": "ref", 4020 "size": 1, 4021 "commits": [ 4022 { 4023 "id": "id" 4024 } 4025 ], 4026 "before": "b", 4027 "distinct_size": 1, 4028 "after": "a", 4029 "created": true, 4030 "deleted": true, 4031 "forced": true, 4032 "base_ref": "a", 4033 "compare": "a", 4034 "repository": { 4035 "id": 1 4036 }, 4037 "head_commit": { 4038 "id": "id" 4039 }, 4040 "pusher": { 4041 "date": ` + referenceTimeStr + `, 4042 "name": "n", 4043 "email": "e", 4044 "username": "l" 4045 }, 4046 "sender": { 4047 "login": "l", 4048 "id": 1, 4049 "node_id": "n", 4050 "avatar_url": "a", 4051 "url": "u", 4052 "events_url": "e", 4053 "repos_url": "r" 4054 }, 4055 "installation": { 4056 "id": 1, 4057 "node_id": "nid", 4058 "app_id": 1, 4059 "app_slug": "as", 4060 "target_id": 1, 4061 "account": { 4062 "login": "l", 4063 "id": 1, 4064 "avatar_url": "a", 4065 "gravatar_id": "g", 4066 "name": "n", 4067 "company": "c", 4068 "blog": "b", 4069 "location": "l", 4070 "email": "e", 4071 "hireable": true, 4072 "bio": "b", 4073 "twitter_username": "t", 4074 "public_repos": 1, 4075 "followers": 1, 4076 "following": 1, 4077 "created_at": ` + referenceTimeStr + `, 4078 "suspended_at": ` + referenceTimeStr + `, 4079 "url": "u" 4080 }, 4081 "access_tokens_url": "atu", 4082 "repositories_url": "ru", 4083 "html_url": "hu", 4084 "target_type": "tt", 4085 "single_file_name": "sfn", 4086 "repository_selection": "rs", 4087 "events": [ 4088 "e" 4089 ], 4090 "single_file_paths": [ 4091 "s" 4092 ], 4093 "permissions": { 4094 "actions": "a", 4095 "administration": "ad", 4096 "checks": "c", 4097 "contents": "co", 4098 "content_references": "cr", 4099 "deployments": "d", 4100 "environments": "e", 4101 "issues": "i", 4102 "metadata": "md", 4103 "members": "m", 4104 "organization_administration": "oa", 4105 "organization_hooks": "oh", 4106 "organization_plan": "op", 4107 "organization_pre_receive_hooks": "opr", 4108 "organization_projects": "op", 4109 "organization_secrets": "os", 4110 "organization_self_hosted_runners": "osh", 4111 "organization_user_blocking": "oub", 4112 "packages": "pkg", 4113 "pages": "pg", 4114 "pull_requests": "pr", 4115 "repository_hooks": "rh", 4116 "repository_projects": "rp", 4117 "repository_pre_receive_hooks": "rprh", 4118 "secrets": "s", 4119 "secret_scanning_alerts": "ssa", 4120 "security_events": "se", 4121 "single_file": "sf", 4122 "statuses": "s", 4123 "team_discussions": "td", 4124 "vulnerability_alerts": "va", 4125 "workflows": "w" 4126 }, 4127 "created_at": ` + referenceTimeStr + `, 4128 "updated_at": ` + referenceTimeStr + `, 4129 "has_multiple_single_files": false, 4130 "suspended_by": { 4131 "login": "l", 4132 "id": 1, 4133 "avatar_url": "a", 4134 "gravatar_id": "g", 4135 "name": "n", 4136 "company": "c", 4137 "blog": "b", 4138 "location": "l", 4139 "email": "e", 4140 "hireable": true, 4141 "bio": "b", 4142 "twitter_username": "t", 4143 "public_repos": 1, 4144 "followers": 1, 4145 "following": 1, 4146 "created_at": ` + referenceTimeStr + `, 4147 "suspended_at": ` + referenceTimeStr + `, 4148 "url": "u" 4149 }, 4150 "suspended_at": ` + referenceTimeStr + ` 4151 }, 4152 "organization": { 4153 "name": "n", 4154 "company": "c", 4155 "blog": "b", 4156 "location": "loc", 4157 "email": "e", 4158 "twitter_username": "tu", 4159 "description": "d", 4160 "billing_email": "be", 4161 "is_verified": true, 4162 "has_organization_projects": true, 4163 "has_repository_projects": true, 4164 "default_repository_permission": "drp", 4165 "members_can_create_repositories": true, 4166 "members_can_create_public_repositories": false, 4167 "members_can_create_private_repositories": true, 4168 "members_can_create_internal_repositories": true, 4169 "members_allowed_repository_creation_type": "marct", 4170 "members_can_create_pages": true, 4171 "members_can_create_public_pages": false, 4172 "members_can_create_private_pages": true 4173 } 4174 }` 4175 4176 testJSONMarshal(t, u, want) 4177 } 4178 4179 func TestStatusEvent_Marshal(t *testing.T) { 4180 t.Parallel() 4181 testJSONMarshal(t, &StatusEvent{}, "{}") 4182 4183 u := &StatusEvent{ 4184 SHA: Ptr("sha"), 4185 State: Ptr("s"), 4186 Description: Ptr("d"), 4187 TargetURL: Ptr("turl"), 4188 Branches: []*Branch{ 4189 { 4190 Name: Ptr("n"), 4191 Commit: &RepositoryCommit{NodeID: Ptr("nid")}, 4192 Protected: Ptr(false), 4193 }, 4194 }, 4195 ID: Ptr(int64(1)), 4196 Name: Ptr("n"), 4197 Context: Ptr("c"), 4198 Commit: &RepositoryCommit{NodeID: Ptr("nid")}, 4199 CreatedAt: &Timestamp{referenceTime}, 4200 UpdatedAt: &Timestamp{referenceTime}, 4201 Sender: &User{ 4202 Login: Ptr("l"), 4203 ID: Ptr(int64(1)), 4204 NodeID: Ptr("n"), 4205 URL: Ptr("u"), 4206 ReposURL: Ptr("r"), 4207 EventsURL: Ptr("e"), 4208 AvatarURL: Ptr("a"), 4209 }, 4210 Installation: &Installation{ 4211 ID: Ptr(int64(1)), 4212 NodeID: Ptr("nid"), 4213 AppID: Ptr(int64(1)), 4214 AppSlug: Ptr("as"), 4215 TargetID: Ptr(int64(1)), 4216 Account: &User{ 4217 Login: Ptr("l"), 4218 ID: Ptr(int64(1)), 4219 URL: Ptr("u"), 4220 AvatarURL: Ptr("a"), 4221 GravatarID: Ptr("g"), 4222 Name: Ptr("n"), 4223 Company: Ptr("c"), 4224 Blog: Ptr("b"), 4225 Location: Ptr("l"), 4226 Email: Ptr("e"), 4227 Hireable: Ptr(true), 4228 Bio: Ptr("b"), 4229 TwitterUsername: Ptr("t"), 4230 PublicRepos: Ptr(1), 4231 Followers: Ptr(1), 4232 Following: Ptr(1), 4233 CreatedAt: &Timestamp{referenceTime}, 4234 SuspendedAt: &Timestamp{referenceTime}, 4235 }, 4236 AccessTokensURL: Ptr("atu"), 4237 RepositoriesURL: Ptr("ru"), 4238 HTMLURL: Ptr("hu"), 4239 TargetType: Ptr("tt"), 4240 SingleFileName: Ptr("sfn"), 4241 RepositorySelection: Ptr("rs"), 4242 Events: []string{"e"}, 4243 SingleFilePaths: []string{"s"}, 4244 Permissions: &InstallationPermissions{ 4245 Actions: Ptr("a"), 4246 Administration: Ptr("ad"), 4247 Checks: Ptr("c"), 4248 Contents: Ptr("co"), 4249 ContentReferences: Ptr("cr"), 4250 Deployments: Ptr("d"), 4251 Environments: Ptr("e"), 4252 Issues: Ptr("i"), 4253 Metadata: Ptr("md"), 4254 Members: Ptr("m"), 4255 OrganizationAdministration: Ptr("oa"), 4256 OrganizationHooks: Ptr("oh"), 4257 OrganizationPlan: Ptr("op"), 4258 OrganizationPreReceiveHooks: Ptr("opr"), 4259 OrganizationProjects: Ptr("op"), 4260 OrganizationSecrets: Ptr("os"), 4261 OrganizationSelfHostedRunners: Ptr("osh"), 4262 OrganizationUserBlocking: Ptr("oub"), 4263 Packages: Ptr("pkg"), 4264 Pages: Ptr("pg"), 4265 PullRequests: Ptr("pr"), 4266 RepositoryHooks: Ptr("rh"), 4267 RepositoryProjects: Ptr("rp"), 4268 RepositoryPreReceiveHooks: Ptr("rprh"), 4269 Secrets: Ptr("s"), 4270 SecretScanningAlerts: Ptr("ssa"), 4271 SecurityEvents: Ptr("se"), 4272 SingleFile: Ptr("sf"), 4273 Statuses: Ptr("s"), 4274 TeamDiscussions: Ptr("td"), 4275 VulnerabilityAlerts: Ptr("va"), 4276 Workflows: Ptr("w"), 4277 }, 4278 CreatedAt: &Timestamp{referenceTime}, 4279 UpdatedAt: &Timestamp{referenceTime}, 4280 HasMultipleSingleFiles: Ptr(false), 4281 SuspendedBy: &User{ 4282 Login: Ptr("l"), 4283 ID: Ptr(int64(1)), 4284 URL: Ptr("u"), 4285 AvatarURL: Ptr("a"), 4286 GravatarID: Ptr("g"), 4287 Name: Ptr("n"), 4288 Company: Ptr("c"), 4289 Blog: Ptr("b"), 4290 Location: Ptr("l"), 4291 Email: Ptr("e"), 4292 Hireable: Ptr(true), 4293 Bio: Ptr("b"), 4294 TwitterUsername: Ptr("t"), 4295 PublicRepos: Ptr(1), 4296 Followers: Ptr(1), 4297 Following: Ptr(1), 4298 CreatedAt: &Timestamp{referenceTime}, 4299 SuspendedAt: &Timestamp{referenceTime}, 4300 }, 4301 SuspendedAt: &Timestamp{referenceTime}, 4302 }, 4303 } 4304 4305 want := `{ 4306 "sha": "sha", 4307 "state": "s", 4308 "description": "d", 4309 "target_url": "turl", 4310 "branches": [ 4311 { 4312 "name": "n", 4313 "commit": { 4314 "node_id": "nid" 4315 }, 4316 "protected": false 4317 } 4318 ], 4319 "id": 1, 4320 "name": "n", 4321 "context": "c", 4322 "commit": { 4323 "node_id": "nid" 4324 }, 4325 "created_at": ` + referenceTimeStr + `, 4326 "updated_at": ` + referenceTimeStr + `, 4327 "sender": { 4328 "login": "l", 4329 "id": 1, 4330 "node_id": "n", 4331 "avatar_url": "a", 4332 "url": "u", 4333 "events_url": "e", 4334 "repos_url": "r" 4335 }, 4336 "installation": { 4337 "id": 1, 4338 "node_id": "nid", 4339 "app_id": 1, 4340 "app_slug": "as", 4341 "target_id": 1, 4342 "account": { 4343 "login": "l", 4344 "id": 1, 4345 "avatar_url": "a", 4346 "gravatar_id": "g", 4347 "name": "n", 4348 "company": "c", 4349 "blog": "b", 4350 "location": "l", 4351 "email": "e", 4352 "hireable": true, 4353 "bio": "b", 4354 "twitter_username": "t", 4355 "public_repos": 1, 4356 "followers": 1, 4357 "following": 1, 4358 "created_at": ` + referenceTimeStr + `, 4359 "suspended_at": ` + referenceTimeStr + `, 4360 "url": "u" 4361 }, 4362 "access_tokens_url": "atu", 4363 "repositories_url": "ru", 4364 "html_url": "hu", 4365 "target_type": "tt", 4366 "single_file_name": "sfn", 4367 "repository_selection": "rs", 4368 "events": [ 4369 "e" 4370 ], 4371 "single_file_paths": [ 4372 "s" 4373 ], 4374 "permissions": { 4375 "actions": "a", 4376 "administration": "ad", 4377 "checks": "c", 4378 "contents": "co", 4379 "content_references": "cr", 4380 "deployments": "d", 4381 "environments": "e", 4382 "issues": "i", 4383 "metadata": "md", 4384 "members": "m", 4385 "organization_administration": "oa", 4386 "organization_hooks": "oh", 4387 "organization_plan": "op", 4388 "organization_pre_receive_hooks": "opr", 4389 "organization_projects": "op", 4390 "organization_secrets": "os", 4391 "organization_self_hosted_runners": "osh", 4392 "organization_user_blocking": "oub", 4393 "packages": "pkg", 4394 "pages": "pg", 4395 "pull_requests": "pr", 4396 "repository_hooks": "rh", 4397 "repository_projects": "rp", 4398 "repository_pre_receive_hooks": "rprh", 4399 "secrets": "s", 4400 "secret_scanning_alerts": "ssa", 4401 "security_events": "se", 4402 "single_file": "sf", 4403 "statuses": "s", 4404 "team_discussions": "td", 4405 "vulnerability_alerts": "va", 4406 "workflows": "w" 4407 }, 4408 "created_at": ` + referenceTimeStr + `, 4409 "updated_at": ` + referenceTimeStr + `, 4410 "has_multiple_single_files": false, 4411 "suspended_by": { 4412 "login": "l", 4413 "id": 1, 4414 "avatar_url": "a", 4415 "gravatar_id": "g", 4416 "name": "n", 4417 "company": "c", 4418 "blog": "b", 4419 "location": "l", 4420 "email": "e", 4421 "hireable": true, 4422 "bio": "b", 4423 "twitter_username": "t", 4424 "public_repos": 1, 4425 "followers": 1, 4426 "following": 1, 4427 "created_at": ` + referenceTimeStr + `, 4428 "suspended_at": ` + referenceTimeStr + `, 4429 "url": "u" 4430 }, 4431 "suspended_at": ` + referenceTimeStr + ` 4432 } 4433 }` 4434 4435 testJSONMarshal(t, u, want) 4436 } 4437 4438 func TestMarketplacePurchaseEvent_Marshal(t *testing.T) { 4439 t.Parallel() 4440 testJSONMarshal(t, &MarketplacePurchaseEvent{}, "{}") 4441 4442 u := &MarketplacePurchaseEvent{ 4443 Action: Ptr("a"), 4444 EffectiveDate: &Timestamp{referenceTime}, 4445 MarketplacePurchase: &MarketplacePurchase{ 4446 BillingCycle: Ptr("bc"), 4447 NextBillingDate: &Timestamp{referenceTime}, 4448 UnitCount: Ptr(1), 4449 Plan: &MarketplacePlan{ 4450 URL: Ptr("u"), 4451 AccountsURL: Ptr("au"), 4452 ID: Ptr(int64(1)), 4453 Number: Ptr(1), 4454 Name: Ptr("n"), 4455 Description: Ptr("d"), 4456 MonthlyPriceInCents: Ptr(1), 4457 YearlyPriceInCents: Ptr(1), 4458 PriceModel: Ptr("pm"), 4459 UnitName: Ptr("un"), 4460 Bullets: &[]string{"b"}, 4461 State: Ptr("s"), 4462 HasFreeTrial: Ptr(false), 4463 }, 4464 OnFreeTrial: Ptr(false), 4465 FreeTrialEndsOn: &Timestamp{referenceTime}, 4466 UpdatedAt: &Timestamp{referenceTime}, 4467 }, 4468 PreviousMarketplacePurchase: &MarketplacePurchase{ 4469 BillingCycle: Ptr("bc"), 4470 NextBillingDate: &Timestamp{referenceTime}, 4471 UnitCount: Ptr(1), 4472 Plan: &MarketplacePlan{ 4473 URL: Ptr("u"), 4474 AccountsURL: Ptr("au"), 4475 ID: Ptr(int64(1)), 4476 Number: Ptr(1), 4477 Name: Ptr("n"), 4478 Description: Ptr("d"), 4479 MonthlyPriceInCents: Ptr(1), 4480 YearlyPriceInCents: Ptr(1), 4481 PriceModel: Ptr("pm"), 4482 UnitName: Ptr("un"), 4483 Bullets: &[]string{"b"}, 4484 State: Ptr("s"), 4485 HasFreeTrial: Ptr(false), 4486 }, 4487 OnFreeTrial: Ptr(false), 4488 FreeTrialEndsOn: &Timestamp{referenceTime}, 4489 UpdatedAt: &Timestamp{referenceTime}, 4490 }, 4491 Sender: &User{ 4492 Login: Ptr("l"), 4493 ID: Ptr(int64(1)), 4494 NodeID: Ptr("n"), 4495 URL: Ptr("u"), 4496 ReposURL: Ptr("r"), 4497 EventsURL: Ptr("e"), 4498 AvatarURL: Ptr("a"), 4499 }, 4500 Installation: &Installation{ 4501 ID: Ptr(int64(1)), 4502 NodeID: Ptr("nid"), 4503 AppID: Ptr(int64(1)), 4504 AppSlug: Ptr("as"), 4505 TargetID: Ptr(int64(1)), 4506 Account: &User{ 4507 Login: Ptr("l"), 4508 ID: Ptr(int64(1)), 4509 URL: Ptr("u"), 4510 AvatarURL: Ptr("a"), 4511 GravatarID: Ptr("g"), 4512 Name: Ptr("n"), 4513 Company: Ptr("c"), 4514 Blog: Ptr("b"), 4515 Location: Ptr("l"), 4516 Email: Ptr("e"), 4517 Hireable: Ptr(true), 4518 Bio: Ptr("b"), 4519 TwitterUsername: Ptr("t"), 4520 PublicRepos: Ptr(1), 4521 Followers: Ptr(1), 4522 Following: Ptr(1), 4523 CreatedAt: &Timestamp{referenceTime}, 4524 SuspendedAt: &Timestamp{referenceTime}, 4525 }, 4526 AccessTokensURL: Ptr("atu"), 4527 RepositoriesURL: Ptr("ru"), 4528 HTMLURL: Ptr("hu"), 4529 TargetType: Ptr("tt"), 4530 SingleFileName: Ptr("sfn"), 4531 RepositorySelection: Ptr("rs"), 4532 Events: []string{"e"}, 4533 SingleFilePaths: []string{"s"}, 4534 Permissions: &InstallationPermissions{ 4535 Actions: Ptr("a"), 4536 Administration: Ptr("ad"), 4537 Checks: Ptr("c"), 4538 Contents: Ptr("co"), 4539 ContentReferences: Ptr("cr"), 4540 Deployments: Ptr("d"), 4541 Environments: Ptr("e"), 4542 Issues: Ptr("i"), 4543 Metadata: Ptr("md"), 4544 Members: Ptr("m"), 4545 OrganizationAdministration: Ptr("oa"), 4546 OrganizationHooks: Ptr("oh"), 4547 OrganizationPlan: Ptr("op"), 4548 OrganizationPreReceiveHooks: Ptr("opr"), 4549 OrganizationProjects: Ptr("op"), 4550 OrganizationSecrets: Ptr("os"), 4551 OrganizationSelfHostedRunners: Ptr("osh"), 4552 OrganizationUserBlocking: Ptr("oub"), 4553 Packages: Ptr("pkg"), 4554 Pages: Ptr("pg"), 4555 PullRequests: Ptr("pr"), 4556 RepositoryHooks: Ptr("rh"), 4557 RepositoryProjects: Ptr("rp"), 4558 RepositoryPreReceiveHooks: Ptr("rprh"), 4559 Secrets: Ptr("s"), 4560 SecretScanningAlerts: Ptr("ssa"), 4561 SecurityEvents: Ptr("se"), 4562 SingleFile: Ptr("sf"), 4563 Statuses: Ptr("s"), 4564 TeamDiscussions: Ptr("td"), 4565 VulnerabilityAlerts: Ptr("va"), 4566 Workflows: Ptr("w"), 4567 }, 4568 CreatedAt: &Timestamp{referenceTime}, 4569 UpdatedAt: &Timestamp{referenceTime}, 4570 HasMultipleSingleFiles: Ptr(false), 4571 SuspendedBy: &User{ 4572 Login: Ptr("l"), 4573 ID: Ptr(int64(1)), 4574 URL: Ptr("u"), 4575 AvatarURL: Ptr("a"), 4576 GravatarID: Ptr("g"), 4577 Name: Ptr("n"), 4578 Company: Ptr("c"), 4579 Blog: Ptr("b"), 4580 Location: Ptr("l"), 4581 Email: Ptr("e"), 4582 Hireable: Ptr(true), 4583 Bio: Ptr("b"), 4584 TwitterUsername: Ptr("t"), 4585 PublicRepos: Ptr(1), 4586 Followers: Ptr(1), 4587 Following: Ptr(1), 4588 CreatedAt: &Timestamp{referenceTime}, 4589 SuspendedAt: &Timestamp{referenceTime}, 4590 }, 4591 SuspendedAt: &Timestamp{referenceTime}, 4592 }, 4593 } 4594 4595 want := `{ 4596 "action": "a", 4597 "effective_date": ` + referenceTimeStr + `, 4598 "marketplace_purchase": { 4599 "billing_cycle": "bc", 4600 "next_billing_date": ` + referenceTimeStr + `, 4601 "unit_count": 1, 4602 "plan": { 4603 "url": "u", 4604 "accounts_url": "au", 4605 "id": 1, 4606 "number": 1, 4607 "name": "n", 4608 "description": "d", 4609 "monthly_price_in_cents": 1, 4610 "yearly_price_in_cents": 1, 4611 "price_model": "pm", 4612 "unit_name": "un", 4613 "bullets": [ 4614 "b" 4615 ], 4616 "state": "s", 4617 "has_free_trial": false 4618 }, 4619 "on_free_trial": false, 4620 "free_trial_ends_on": ` + referenceTimeStr + `, 4621 "updated_at": ` + referenceTimeStr + ` 4622 }, 4623 "previous_marketplace_purchase": { 4624 "billing_cycle": "bc", 4625 "next_billing_date": ` + referenceTimeStr + `, 4626 "unit_count": 1, 4627 "plan": { 4628 "url": "u", 4629 "accounts_url": "au", 4630 "id": 1, 4631 "number": 1, 4632 "name": "n", 4633 "description": "d", 4634 "monthly_price_in_cents": 1, 4635 "yearly_price_in_cents": 1, 4636 "price_model": "pm", 4637 "unit_name": "un", 4638 "bullets": [ 4639 "b" 4640 ], 4641 "state": "s", 4642 "has_free_trial": false 4643 }, 4644 "on_free_trial": false, 4645 "free_trial_ends_on": ` + referenceTimeStr + `, 4646 "updated_at": ` + referenceTimeStr + ` 4647 }, 4648 "sender": { 4649 "login": "l", 4650 "id": 1, 4651 "node_id": "n", 4652 "avatar_url": "a", 4653 "url": "u", 4654 "events_url": "e", 4655 "repos_url": "r" 4656 }, 4657 "installation": { 4658 "id": 1, 4659 "node_id": "nid", 4660 "app_id": 1, 4661 "app_slug": "as", 4662 "target_id": 1, 4663 "account": { 4664 "login": "l", 4665 "id": 1, 4666 "avatar_url": "a", 4667 "gravatar_id": "g", 4668 "name": "n", 4669 "company": "c", 4670 "blog": "b", 4671 "location": "l", 4672 "email": "e", 4673 "hireable": true, 4674 "bio": "b", 4675 "twitter_username": "t", 4676 "public_repos": 1, 4677 "followers": 1, 4678 "following": 1, 4679 "created_at": ` + referenceTimeStr + `, 4680 "suspended_at": ` + referenceTimeStr + `, 4681 "url": "u" 4682 }, 4683 "access_tokens_url": "atu", 4684 "repositories_url": "ru", 4685 "html_url": "hu", 4686 "target_type": "tt", 4687 "single_file_name": "sfn", 4688 "repository_selection": "rs", 4689 "events": [ 4690 "e" 4691 ], 4692 "single_file_paths": [ 4693 "s" 4694 ], 4695 "permissions": { 4696 "actions": "a", 4697 "administration": "ad", 4698 "checks": "c", 4699 "contents": "co", 4700 "content_references": "cr", 4701 "deployments": "d", 4702 "environments": "e", 4703 "issues": "i", 4704 "metadata": "md", 4705 "members": "m", 4706 "organization_administration": "oa", 4707 "organization_hooks": "oh", 4708 "organization_plan": "op", 4709 "organization_pre_receive_hooks": "opr", 4710 "organization_projects": "op", 4711 "organization_secrets": "os", 4712 "organization_self_hosted_runners": "osh", 4713 "organization_user_blocking": "oub", 4714 "packages": "pkg", 4715 "pages": "pg", 4716 "pull_requests": "pr", 4717 "repository_hooks": "rh", 4718 "repository_projects": "rp", 4719 "repository_pre_receive_hooks": "rprh", 4720 "secrets": "s", 4721 "secret_scanning_alerts": "ssa", 4722 "security_events": "se", 4723 "single_file": "sf", 4724 "statuses": "s", 4725 "team_discussions": "td", 4726 "vulnerability_alerts": "va", 4727 "workflows": "w" 4728 }, 4729 "created_at": ` + referenceTimeStr + `, 4730 "updated_at": ` + referenceTimeStr + `, 4731 "has_multiple_single_files": false, 4732 "suspended_by": { 4733 "login": "l", 4734 "id": 1, 4735 "avatar_url": "a", 4736 "gravatar_id": "g", 4737 "name": "n", 4738 "company": "c", 4739 "blog": "b", 4740 "location": "l", 4741 "email": "e", 4742 "hireable": true, 4743 "bio": "b", 4744 "twitter_username": "t", 4745 "public_repos": 1, 4746 "followers": 1, 4747 "following": 1, 4748 "created_at": ` + referenceTimeStr + `, 4749 "suspended_at": ` + referenceTimeStr + `, 4750 "url": "u" 4751 }, 4752 "suspended_at": ` + referenceTimeStr + ` 4753 } 4754 }` 4755 4756 testJSONMarshal(t, u, want) 4757 } 4758 4759 func TestOrganizationEvent_Marshal(t *testing.T) { 4760 t.Parallel() 4761 testJSONMarshal(t, &OrganizationEvent{}, "{}") 4762 4763 u := &OrganizationEvent{ 4764 Action: Ptr("a"), 4765 Invitation: &Invitation{ID: Ptr(int64(1))}, 4766 Membership: &Membership{ 4767 URL: Ptr("url"), 4768 State: Ptr("s"), 4769 Role: Ptr("r"), 4770 OrganizationURL: Ptr("ou"), 4771 Organization: &Organization{ 4772 BillingEmail: Ptr("be"), 4773 Blog: Ptr("b"), 4774 Company: Ptr("c"), 4775 Email: Ptr("e"), 4776 TwitterUsername: Ptr("tu"), 4777 Location: Ptr("loc"), 4778 Name: Ptr("n"), 4779 Description: Ptr("d"), 4780 IsVerified: Ptr(true), 4781 HasOrganizationProjects: Ptr(true), 4782 HasRepositoryProjects: Ptr(true), 4783 DefaultRepoPermission: Ptr("drp"), 4784 MembersCanCreateRepos: Ptr(true), 4785 MembersCanCreateInternalRepos: Ptr(true), 4786 MembersCanCreatePrivateRepos: Ptr(true), 4787 MembersCanCreatePublicRepos: Ptr(false), 4788 MembersAllowedRepositoryCreationType: Ptr("marct"), 4789 MembersCanCreatePages: Ptr(true), 4790 MembersCanCreatePublicPages: Ptr(false), 4791 MembersCanCreatePrivatePages: Ptr(true), 4792 }, 4793 User: &User{ 4794 Login: Ptr("l"), 4795 ID: Ptr(int64(1)), 4796 NodeID: Ptr("n"), 4797 URL: Ptr("u"), 4798 ReposURL: Ptr("r"), 4799 EventsURL: Ptr("e"), 4800 AvatarURL: Ptr("a"), 4801 }, 4802 }, 4803 Organization: &Organization{ 4804 BillingEmail: Ptr("be"), 4805 Blog: Ptr("b"), 4806 Company: Ptr("c"), 4807 Email: Ptr("e"), 4808 TwitterUsername: Ptr("tu"), 4809 Location: Ptr("loc"), 4810 Name: Ptr("n"), 4811 Description: Ptr("d"), 4812 IsVerified: Ptr(true), 4813 HasOrganizationProjects: Ptr(true), 4814 HasRepositoryProjects: Ptr(true), 4815 DefaultRepoPermission: Ptr("drp"), 4816 MembersCanCreateRepos: Ptr(true), 4817 MembersCanCreateInternalRepos: Ptr(true), 4818 MembersCanCreatePrivateRepos: Ptr(true), 4819 MembersCanCreatePublicRepos: Ptr(false), 4820 MembersAllowedRepositoryCreationType: Ptr("marct"), 4821 MembersCanCreatePages: Ptr(true), 4822 MembersCanCreatePublicPages: Ptr(false), 4823 MembersCanCreatePrivatePages: Ptr(true), 4824 }, 4825 Sender: &User{ 4826 Login: Ptr("l"), 4827 ID: Ptr(int64(1)), 4828 NodeID: Ptr("n"), 4829 URL: Ptr("u"), 4830 ReposURL: Ptr("r"), 4831 EventsURL: Ptr("e"), 4832 AvatarURL: Ptr("a"), 4833 }, 4834 Installation: &Installation{ 4835 ID: Ptr(int64(1)), 4836 NodeID: Ptr("nid"), 4837 AppID: Ptr(int64(1)), 4838 AppSlug: Ptr("as"), 4839 TargetID: Ptr(int64(1)), 4840 Account: &User{ 4841 Login: Ptr("l"), 4842 ID: Ptr(int64(1)), 4843 URL: Ptr("u"), 4844 AvatarURL: Ptr("a"), 4845 GravatarID: Ptr("g"), 4846 Name: Ptr("n"), 4847 Company: Ptr("c"), 4848 Blog: Ptr("b"), 4849 Location: Ptr("l"), 4850 Email: Ptr("e"), 4851 Hireable: Ptr(true), 4852 Bio: Ptr("b"), 4853 TwitterUsername: Ptr("t"), 4854 PublicRepos: Ptr(1), 4855 Followers: Ptr(1), 4856 Following: Ptr(1), 4857 CreatedAt: &Timestamp{referenceTime}, 4858 SuspendedAt: &Timestamp{referenceTime}, 4859 }, 4860 AccessTokensURL: Ptr("atu"), 4861 RepositoriesURL: Ptr("ru"), 4862 HTMLURL: Ptr("hu"), 4863 TargetType: Ptr("tt"), 4864 SingleFileName: Ptr("sfn"), 4865 RepositorySelection: Ptr("rs"), 4866 Events: []string{"e"}, 4867 SingleFilePaths: []string{"s"}, 4868 Permissions: &InstallationPermissions{ 4869 Actions: Ptr("a"), 4870 Administration: Ptr("ad"), 4871 Checks: Ptr("c"), 4872 Contents: Ptr("co"), 4873 ContentReferences: Ptr("cr"), 4874 Deployments: Ptr("d"), 4875 Environments: Ptr("e"), 4876 Issues: Ptr("i"), 4877 Metadata: Ptr("md"), 4878 Members: Ptr("m"), 4879 OrganizationAdministration: Ptr("oa"), 4880 OrganizationHooks: Ptr("oh"), 4881 OrganizationPlan: Ptr("op"), 4882 OrganizationPreReceiveHooks: Ptr("opr"), 4883 OrganizationProjects: Ptr("op"), 4884 OrganizationSecrets: Ptr("os"), 4885 OrganizationSelfHostedRunners: Ptr("osh"), 4886 OrganizationUserBlocking: Ptr("oub"), 4887 Packages: Ptr("pkg"), 4888 Pages: Ptr("pg"), 4889 PullRequests: Ptr("pr"), 4890 RepositoryHooks: Ptr("rh"), 4891 RepositoryProjects: Ptr("rp"), 4892 RepositoryPreReceiveHooks: Ptr("rprh"), 4893 Secrets: Ptr("s"), 4894 SecretScanningAlerts: Ptr("ssa"), 4895 SecurityEvents: Ptr("se"), 4896 SingleFile: Ptr("sf"), 4897 Statuses: Ptr("s"), 4898 TeamDiscussions: Ptr("td"), 4899 VulnerabilityAlerts: Ptr("va"), 4900 Workflows: Ptr("w"), 4901 }, 4902 CreatedAt: &Timestamp{referenceTime}, 4903 UpdatedAt: &Timestamp{referenceTime}, 4904 HasMultipleSingleFiles: Ptr(false), 4905 SuspendedBy: &User{ 4906 Login: Ptr("l"), 4907 ID: Ptr(int64(1)), 4908 URL: Ptr("u"), 4909 AvatarURL: Ptr("a"), 4910 GravatarID: Ptr("g"), 4911 Name: Ptr("n"), 4912 Company: Ptr("c"), 4913 Blog: Ptr("b"), 4914 Location: Ptr("l"), 4915 Email: Ptr("e"), 4916 Hireable: Ptr(true), 4917 Bio: Ptr("b"), 4918 TwitterUsername: Ptr("t"), 4919 PublicRepos: Ptr(1), 4920 Followers: Ptr(1), 4921 Following: Ptr(1), 4922 CreatedAt: &Timestamp{referenceTime}, 4923 SuspendedAt: &Timestamp{referenceTime}, 4924 }, 4925 SuspendedAt: &Timestamp{referenceTime}, 4926 }, 4927 } 4928 4929 want := `{ 4930 "action": "a", 4931 "invitation": { 4932 "id": 1 4933 }, 4934 "membership": { 4935 "url": "url", 4936 "state": "s", 4937 "role": "r", 4938 "organization_url": "ou", 4939 "organization": { 4940 "name": "n", 4941 "company": "c", 4942 "blog": "b", 4943 "location": "loc", 4944 "email": "e", 4945 "twitter_username": "tu", 4946 "description": "d", 4947 "billing_email": "be", 4948 "is_verified": true, 4949 "has_organization_projects": true, 4950 "has_repository_projects": true, 4951 "default_repository_permission": "drp", 4952 "members_can_create_repositories": true, 4953 "members_can_create_public_repositories": false, 4954 "members_can_create_private_repositories": true, 4955 "members_can_create_internal_repositories": true, 4956 "members_allowed_repository_creation_type": "marct", 4957 "members_can_create_pages": true, 4958 "members_can_create_public_pages": false, 4959 "members_can_create_private_pages": true 4960 }, 4961 "user": { 4962 "login": "l", 4963 "id": 1, 4964 "node_id": "n", 4965 "avatar_url": "a", 4966 "url": "u", 4967 "events_url": "e", 4968 "repos_url": "r" 4969 } 4970 }, 4971 "organization": { 4972 "name": "n", 4973 "company": "c", 4974 "blog": "b", 4975 "location": "loc", 4976 "email": "e", 4977 "twitter_username": "tu", 4978 "description": "d", 4979 "billing_email": "be", 4980 "is_verified": true, 4981 "has_organization_projects": true, 4982 "has_repository_projects": true, 4983 "default_repository_permission": "drp", 4984 "members_can_create_repositories": true, 4985 "members_can_create_public_repositories": false, 4986 "members_can_create_private_repositories": true, 4987 "members_can_create_internal_repositories": true, 4988 "members_allowed_repository_creation_type": "marct", 4989 "members_can_create_pages": true, 4990 "members_can_create_public_pages": false, 4991 "members_can_create_private_pages": true 4992 }, 4993 "sender": { 4994 "login": "l", 4995 "id": 1, 4996 "node_id": "n", 4997 "avatar_url": "a", 4998 "url": "u", 4999 "events_url": "e", 5000 "repos_url": "r" 5001 }, 5002 "installation": { 5003 "id": 1, 5004 "node_id": "nid", 5005 "app_id": 1, 5006 "app_slug": "as", 5007 "target_id": 1, 5008 "account": { 5009 "login": "l", 5010 "id": 1, 5011 "avatar_url": "a", 5012 "gravatar_id": "g", 5013 "name": "n", 5014 "company": "c", 5015 "blog": "b", 5016 "location": "l", 5017 "email": "e", 5018 "hireable": true, 5019 "bio": "b", 5020 "twitter_username": "t", 5021 "public_repos": 1, 5022 "followers": 1, 5023 "following": 1, 5024 "created_at": ` + referenceTimeStr + `, 5025 "suspended_at": ` + referenceTimeStr + `, 5026 "url": "u" 5027 }, 5028 "access_tokens_url": "atu", 5029 "repositories_url": "ru", 5030 "html_url": "hu", 5031 "target_type": "tt", 5032 "single_file_name": "sfn", 5033 "repository_selection": "rs", 5034 "events": [ 5035 "e" 5036 ], 5037 "single_file_paths": [ 5038 "s" 5039 ], 5040 "permissions": { 5041 "actions": "a", 5042 "administration": "ad", 5043 "checks": "c", 5044 "contents": "co", 5045 "content_references": "cr", 5046 "deployments": "d", 5047 "environments": "e", 5048 "issues": "i", 5049 "metadata": "md", 5050 "members": "m", 5051 "organization_administration": "oa", 5052 "organization_hooks": "oh", 5053 "organization_plan": "op", 5054 "organization_pre_receive_hooks": "opr", 5055 "organization_projects": "op", 5056 "organization_secrets": "os", 5057 "organization_self_hosted_runners": "osh", 5058 "organization_user_blocking": "oub", 5059 "packages": "pkg", 5060 "pages": "pg", 5061 "pull_requests": "pr", 5062 "repository_hooks": "rh", 5063 "repository_projects": "rp", 5064 "repository_pre_receive_hooks": "rprh", 5065 "secrets": "s", 5066 "secret_scanning_alerts": "ssa", 5067 "security_events": "se", 5068 "single_file": "sf", 5069 "statuses": "s", 5070 "team_discussions": "td", 5071 "vulnerability_alerts": "va", 5072 "workflows": "w" 5073 }, 5074 "created_at": ` + referenceTimeStr + `, 5075 "updated_at": ` + referenceTimeStr + `, 5076 "has_multiple_single_files": false, 5077 "suspended_by": { 5078 "login": "l", 5079 "id": 1, 5080 "avatar_url": "a", 5081 "gravatar_id": "g", 5082 "name": "n", 5083 "company": "c", 5084 "blog": "b", 5085 "location": "l", 5086 "email": "e", 5087 "hireable": true, 5088 "bio": "b", 5089 "twitter_username": "t", 5090 "public_repos": 1, 5091 "followers": 1, 5092 "following": 1, 5093 "created_at": ` + referenceTimeStr + `, 5094 "suspended_at": ` + referenceTimeStr + `, 5095 "url": "u" 5096 }, 5097 "suspended_at": ` + referenceTimeStr + ` 5098 } 5099 }` 5100 5101 testJSONMarshal(t, u, want) 5102 } 5103 5104 func TestPageBuildEvent_Marshal(t *testing.T) { 5105 t.Parallel() 5106 testJSONMarshal(t, &PageBuildEvent{}, "{}") 5107 5108 u := &PageBuildEvent{ 5109 Build: &PagesBuild{URL: Ptr("url")}, 5110 ID: Ptr(int64(1)), 5111 Repo: &Repository{ 5112 ID: Ptr(int64(1)), 5113 URL: Ptr("s"), 5114 Name: Ptr("n"), 5115 }, 5116 Sender: &User{ 5117 Login: Ptr("l"), 5118 ID: Ptr(int64(1)), 5119 NodeID: Ptr("n"), 5120 URL: Ptr("u"), 5121 ReposURL: Ptr("r"), 5122 EventsURL: Ptr("e"), 5123 AvatarURL: Ptr("a"), 5124 }, 5125 Installation: &Installation{ 5126 ID: Ptr(int64(1)), 5127 NodeID: Ptr("nid"), 5128 AppID: Ptr(int64(1)), 5129 AppSlug: Ptr("as"), 5130 TargetID: Ptr(int64(1)), 5131 Account: &User{ 5132 Login: Ptr("l"), 5133 ID: Ptr(int64(1)), 5134 URL: Ptr("u"), 5135 AvatarURL: Ptr("a"), 5136 GravatarID: Ptr("g"), 5137 Name: Ptr("n"), 5138 Company: Ptr("c"), 5139 Blog: Ptr("b"), 5140 Location: Ptr("l"), 5141 Email: Ptr("e"), 5142 Hireable: Ptr(true), 5143 Bio: Ptr("b"), 5144 TwitterUsername: Ptr("t"), 5145 PublicRepos: Ptr(1), 5146 Followers: Ptr(1), 5147 Following: Ptr(1), 5148 CreatedAt: &Timestamp{referenceTime}, 5149 SuspendedAt: &Timestamp{referenceTime}, 5150 }, 5151 AccessTokensURL: Ptr("atu"), 5152 RepositoriesURL: Ptr("ru"), 5153 HTMLURL: Ptr("hu"), 5154 TargetType: Ptr("tt"), 5155 SingleFileName: Ptr("sfn"), 5156 RepositorySelection: Ptr("rs"), 5157 Events: []string{"e"}, 5158 SingleFilePaths: []string{"s"}, 5159 Permissions: &InstallationPermissions{ 5160 Actions: Ptr("a"), 5161 Administration: Ptr("ad"), 5162 Checks: Ptr("c"), 5163 Contents: Ptr("co"), 5164 ContentReferences: Ptr("cr"), 5165 Deployments: Ptr("d"), 5166 Environments: Ptr("e"), 5167 Issues: Ptr("i"), 5168 Metadata: Ptr("md"), 5169 Members: Ptr("m"), 5170 OrganizationAdministration: Ptr("oa"), 5171 OrganizationHooks: Ptr("oh"), 5172 OrganizationPlan: Ptr("op"), 5173 OrganizationPreReceiveHooks: Ptr("opr"), 5174 OrganizationProjects: Ptr("op"), 5175 OrganizationSecrets: Ptr("os"), 5176 OrganizationSelfHostedRunners: Ptr("osh"), 5177 OrganizationUserBlocking: Ptr("oub"), 5178 Packages: Ptr("pkg"), 5179 Pages: Ptr("pg"), 5180 PullRequests: Ptr("pr"), 5181 RepositoryHooks: Ptr("rh"), 5182 RepositoryProjects: Ptr("rp"), 5183 RepositoryPreReceiveHooks: Ptr("rprh"), 5184 Secrets: Ptr("s"), 5185 SecretScanningAlerts: Ptr("ssa"), 5186 SecurityEvents: Ptr("se"), 5187 SingleFile: Ptr("sf"), 5188 Statuses: Ptr("s"), 5189 TeamDiscussions: Ptr("td"), 5190 VulnerabilityAlerts: Ptr("va"), 5191 Workflows: Ptr("w"), 5192 }, 5193 CreatedAt: &Timestamp{referenceTime}, 5194 UpdatedAt: &Timestamp{referenceTime}, 5195 HasMultipleSingleFiles: Ptr(false), 5196 SuspendedBy: &User{ 5197 Login: Ptr("l"), 5198 ID: Ptr(int64(1)), 5199 URL: Ptr("u"), 5200 AvatarURL: Ptr("a"), 5201 GravatarID: Ptr("g"), 5202 Name: Ptr("n"), 5203 Company: Ptr("c"), 5204 Blog: Ptr("b"), 5205 Location: Ptr("l"), 5206 Email: Ptr("e"), 5207 Hireable: Ptr(true), 5208 Bio: Ptr("b"), 5209 TwitterUsername: Ptr("t"), 5210 PublicRepos: Ptr(1), 5211 Followers: Ptr(1), 5212 Following: Ptr(1), 5213 CreatedAt: &Timestamp{referenceTime}, 5214 SuspendedAt: &Timestamp{referenceTime}, 5215 }, 5216 SuspendedAt: &Timestamp{referenceTime}, 5217 }, 5218 } 5219 5220 want := `{ 5221 "build": { 5222 "url": "url" 5223 }, 5224 "id": 1, 5225 "repository": { 5226 "id": 1, 5227 "name": "n", 5228 "url": "s" 5229 }, 5230 "sender": { 5231 "login": "l", 5232 "id": 1, 5233 "node_id": "n", 5234 "avatar_url": "a", 5235 "url": "u", 5236 "events_url": "e", 5237 "repos_url": "r" 5238 }, 5239 "installation": { 5240 "id": 1, 5241 "node_id": "nid", 5242 "app_id": 1, 5243 "app_slug": "as", 5244 "target_id": 1, 5245 "account": { 5246 "login": "l", 5247 "id": 1, 5248 "avatar_url": "a", 5249 "gravatar_id": "g", 5250 "name": "n", 5251 "company": "c", 5252 "blog": "b", 5253 "location": "l", 5254 "email": "e", 5255 "hireable": true, 5256 "bio": "b", 5257 "twitter_username": "t", 5258 "public_repos": 1, 5259 "followers": 1, 5260 "following": 1, 5261 "created_at": ` + referenceTimeStr + `, 5262 "suspended_at": ` + referenceTimeStr + `, 5263 "url": "u" 5264 }, 5265 "access_tokens_url": "atu", 5266 "repositories_url": "ru", 5267 "html_url": "hu", 5268 "target_type": "tt", 5269 "single_file_name": "sfn", 5270 "repository_selection": "rs", 5271 "events": [ 5272 "e" 5273 ], 5274 "single_file_paths": [ 5275 "s" 5276 ], 5277 "permissions": { 5278 "actions": "a", 5279 "administration": "ad", 5280 "checks": "c", 5281 "contents": "co", 5282 "content_references": "cr", 5283 "deployments": "d", 5284 "environments": "e", 5285 "issues": "i", 5286 "metadata": "md", 5287 "members": "m", 5288 "organization_administration": "oa", 5289 "organization_hooks": "oh", 5290 "organization_plan": "op", 5291 "organization_pre_receive_hooks": "opr", 5292 "organization_projects": "op", 5293 "organization_secrets": "os", 5294 "organization_self_hosted_runners": "osh", 5295 "organization_user_blocking": "oub", 5296 "packages": "pkg", 5297 "pages": "pg", 5298 "pull_requests": "pr", 5299 "repository_hooks": "rh", 5300 "repository_projects": "rp", 5301 "repository_pre_receive_hooks": "rprh", 5302 "secrets": "s", 5303 "secret_scanning_alerts": "ssa", 5304 "security_events": "se", 5305 "single_file": "sf", 5306 "statuses": "s", 5307 "team_discussions": "td", 5308 "vulnerability_alerts": "va", 5309 "workflows": "w" 5310 }, 5311 "created_at": ` + referenceTimeStr + `, 5312 "updated_at": ` + referenceTimeStr + `, 5313 "has_multiple_single_files": false, 5314 "suspended_by": { 5315 "login": "l", 5316 "id": 1, 5317 "avatar_url": "a", 5318 "gravatar_id": "g", 5319 "name": "n", 5320 "company": "c", 5321 "blog": "b", 5322 "location": "l", 5323 "email": "e", 5324 "hireable": true, 5325 "bio": "b", 5326 "twitter_username": "t", 5327 "public_repos": 1, 5328 "followers": 1, 5329 "following": 1, 5330 "created_at": ` + referenceTimeStr + `, 5331 "suspended_at": ` + referenceTimeStr + `, 5332 "url": "u" 5333 }, 5334 "suspended_at": ` + referenceTimeStr + ` 5335 } 5336 }` 5337 5338 testJSONMarshal(t, u, want) 5339 } 5340 5341 func TestCommitCommentEvent_Marshal(t *testing.T) { 5342 t.Parallel() 5343 testJSONMarshal(t, &CommitCommentEvent{}, "{}") 5344 5345 u := &CommitCommentEvent{ 5346 Comment: &RepositoryComment{ 5347 HTMLURL: Ptr("hurl"), 5348 URL: Ptr("url"), 5349 ID: Ptr(int64(1)), 5350 NodeID: Ptr("nid"), 5351 CommitID: Ptr("cid"), 5352 User: &User{ 5353 Login: Ptr("l"), 5354 ID: Ptr(int64(1)), 5355 NodeID: Ptr("n"), 5356 URL: Ptr("u"), 5357 ReposURL: Ptr("r"), 5358 EventsURL: Ptr("e"), 5359 AvatarURL: Ptr("a"), 5360 }, 5361 Reactions: &Reactions{ 5362 TotalCount: Ptr(1), 5363 PlusOne: Ptr(1), 5364 MinusOne: Ptr(1), 5365 Laugh: Ptr(1), 5366 Confused: Ptr(1), 5367 Heart: Ptr(1), 5368 Hooray: Ptr(1), 5369 Rocket: Ptr(1), 5370 Eyes: Ptr(1), 5371 URL: Ptr("url"), 5372 }, 5373 CreatedAt: &Timestamp{referenceTime}, 5374 UpdatedAt: &Timestamp{referenceTime}, 5375 Body: Ptr("b"), 5376 Path: Ptr("path"), 5377 Position: Ptr(1), 5378 }, 5379 Action: Ptr("a"), 5380 Repo: &Repository{ 5381 ID: Ptr(int64(1)), 5382 URL: Ptr("s"), 5383 Name: Ptr("n"), 5384 }, 5385 Sender: &User{ 5386 Login: Ptr("l"), 5387 ID: Ptr(int64(1)), 5388 NodeID: Ptr("n"), 5389 URL: Ptr("u"), 5390 ReposURL: Ptr("r"), 5391 EventsURL: Ptr("e"), 5392 AvatarURL: Ptr("a"), 5393 }, 5394 Installation: &Installation{ 5395 ID: Ptr(int64(1)), 5396 NodeID: Ptr("nid"), 5397 AppID: Ptr(int64(1)), 5398 AppSlug: Ptr("as"), 5399 TargetID: Ptr(int64(1)), 5400 Account: &User{ 5401 Login: Ptr("l"), 5402 ID: Ptr(int64(1)), 5403 URL: Ptr("u"), 5404 AvatarURL: Ptr("a"), 5405 GravatarID: Ptr("g"), 5406 Name: Ptr("n"), 5407 Company: Ptr("c"), 5408 Blog: Ptr("b"), 5409 Location: Ptr("l"), 5410 Email: Ptr("e"), 5411 Hireable: Ptr(true), 5412 Bio: Ptr("b"), 5413 TwitterUsername: Ptr("t"), 5414 PublicRepos: Ptr(1), 5415 Followers: Ptr(1), 5416 Following: Ptr(1), 5417 CreatedAt: &Timestamp{referenceTime}, 5418 SuspendedAt: &Timestamp{referenceTime}, 5419 }, 5420 AccessTokensURL: Ptr("atu"), 5421 RepositoriesURL: Ptr("ru"), 5422 HTMLURL: Ptr("hu"), 5423 TargetType: Ptr("tt"), 5424 SingleFileName: Ptr("sfn"), 5425 RepositorySelection: Ptr("rs"), 5426 Events: []string{"e"}, 5427 SingleFilePaths: []string{"s"}, 5428 Permissions: &InstallationPermissions{ 5429 Actions: Ptr("a"), 5430 Administration: Ptr("ad"), 5431 Checks: Ptr("c"), 5432 Contents: Ptr("co"), 5433 ContentReferences: Ptr("cr"), 5434 Deployments: Ptr("d"), 5435 Environments: Ptr("e"), 5436 Issues: Ptr("i"), 5437 Metadata: Ptr("md"), 5438 Members: Ptr("m"), 5439 OrganizationAdministration: Ptr("oa"), 5440 OrganizationHooks: Ptr("oh"), 5441 OrganizationPlan: Ptr("op"), 5442 OrganizationPreReceiveHooks: Ptr("opr"), 5443 OrganizationProjects: Ptr("op"), 5444 OrganizationSecrets: Ptr("os"), 5445 OrganizationSelfHostedRunners: Ptr("osh"), 5446 OrganizationUserBlocking: Ptr("oub"), 5447 Packages: Ptr("pkg"), 5448 Pages: Ptr("pg"), 5449 PullRequests: Ptr("pr"), 5450 RepositoryHooks: Ptr("rh"), 5451 RepositoryProjects: Ptr("rp"), 5452 RepositoryPreReceiveHooks: Ptr("rprh"), 5453 Secrets: Ptr("s"), 5454 SecretScanningAlerts: Ptr("ssa"), 5455 SecurityEvents: Ptr("se"), 5456 SingleFile: Ptr("sf"), 5457 Statuses: Ptr("s"), 5458 TeamDiscussions: Ptr("td"), 5459 VulnerabilityAlerts: Ptr("va"), 5460 Workflows: Ptr("w"), 5461 }, 5462 CreatedAt: &Timestamp{referenceTime}, 5463 UpdatedAt: &Timestamp{referenceTime}, 5464 HasMultipleSingleFiles: Ptr(false), 5465 SuspendedBy: &User{ 5466 Login: Ptr("l"), 5467 ID: Ptr(int64(1)), 5468 URL: Ptr("u"), 5469 AvatarURL: Ptr("a"), 5470 GravatarID: Ptr("g"), 5471 Name: Ptr("n"), 5472 Company: Ptr("c"), 5473 Blog: Ptr("b"), 5474 Location: Ptr("l"), 5475 Email: Ptr("e"), 5476 Hireable: Ptr(true), 5477 Bio: Ptr("b"), 5478 TwitterUsername: Ptr("t"), 5479 PublicRepos: Ptr(1), 5480 Followers: Ptr(1), 5481 Following: Ptr(1), 5482 CreatedAt: &Timestamp{referenceTime}, 5483 SuspendedAt: &Timestamp{referenceTime}, 5484 }, 5485 SuspendedAt: &Timestamp{referenceTime}, 5486 }, 5487 } 5488 5489 want := `{ 5490 "comment": { 5491 "html_url": "hurl", 5492 "url": "url", 5493 "id": 1, 5494 "node_id": "nid", 5495 "commit_id": "cid", 5496 "user": { 5497 "login": "l", 5498 "id": 1, 5499 "node_id": "n", 5500 "avatar_url": "a", 5501 "url": "u", 5502 "events_url": "e", 5503 "repos_url": "r" 5504 }, 5505 "reactions": { 5506 "total_count": 1, 5507 "+1": 1, 5508 "-1": 1, 5509 "laugh": 1, 5510 "confused": 1, 5511 "heart": 1, 5512 "hooray": 1, 5513 "rocket": 1, 5514 "eyes": 1, 5515 "url": "url" 5516 }, 5517 "created_at": ` + referenceTimeStr + `, 5518 "updated_at": ` + referenceTimeStr + `, 5519 "body": "b", 5520 "path": "path", 5521 "position": 1 5522 }, 5523 "action": "a", 5524 "repository": { 5525 "id": 1, 5526 "name": "n", 5527 "url": "s" 5528 }, 5529 "sender": { 5530 "login": "l", 5531 "id": 1, 5532 "node_id": "n", 5533 "avatar_url": "a", 5534 "url": "u", 5535 "events_url": "e", 5536 "repos_url": "r" 5537 }, 5538 "installation": { 5539 "id": 1, 5540 "node_id": "nid", 5541 "app_id": 1, 5542 "app_slug": "as", 5543 "target_id": 1, 5544 "account": { 5545 "login": "l", 5546 "id": 1, 5547 "avatar_url": "a", 5548 "gravatar_id": "g", 5549 "name": "n", 5550 "company": "c", 5551 "blog": "b", 5552 "location": "l", 5553 "email": "e", 5554 "hireable": true, 5555 "bio": "b", 5556 "twitter_username": "t", 5557 "public_repos": 1, 5558 "followers": 1, 5559 "following": 1, 5560 "created_at": ` + referenceTimeStr + `, 5561 "suspended_at": ` + referenceTimeStr + `, 5562 "url": "u" 5563 }, 5564 "access_tokens_url": "atu", 5565 "repositories_url": "ru", 5566 "html_url": "hu", 5567 "target_type": "tt", 5568 "single_file_name": "sfn", 5569 "repository_selection": "rs", 5570 "events": [ 5571 "e" 5572 ], 5573 "single_file_paths": [ 5574 "s" 5575 ], 5576 "permissions": { 5577 "actions": "a", 5578 "administration": "ad", 5579 "checks": "c", 5580 "contents": "co", 5581 "content_references": "cr", 5582 "deployments": "d", 5583 "environments": "e", 5584 "issues": "i", 5585 "metadata": "md", 5586 "members": "m", 5587 "organization_administration": "oa", 5588 "organization_hooks": "oh", 5589 "organization_plan": "op", 5590 "organization_pre_receive_hooks": "opr", 5591 "organization_projects": "op", 5592 "organization_secrets": "os", 5593 "organization_self_hosted_runners": "osh", 5594 "organization_user_blocking": "oub", 5595 "packages": "pkg", 5596 "pages": "pg", 5597 "pull_requests": "pr", 5598 "repository_hooks": "rh", 5599 "repository_projects": "rp", 5600 "repository_pre_receive_hooks": "rprh", 5601 "secrets": "s", 5602 "secret_scanning_alerts": "ssa", 5603 "security_events": "se", 5604 "single_file": "sf", 5605 "statuses": "s", 5606 "team_discussions": "td", 5607 "vulnerability_alerts": "va", 5608 "workflows": "w" 5609 }, 5610 "created_at": ` + referenceTimeStr + `, 5611 "updated_at": ` + referenceTimeStr + `, 5612 "has_multiple_single_files": false, 5613 "suspended_by": { 5614 "login": "l", 5615 "id": 1, 5616 "avatar_url": "a", 5617 "gravatar_id": "g", 5618 "name": "n", 5619 "company": "c", 5620 "blog": "b", 5621 "location": "l", 5622 "email": "e", 5623 "hireable": true, 5624 "bio": "b", 5625 "twitter_username": "t", 5626 "public_repos": 1, 5627 "followers": 1, 5628 "following": 1, 5629 "created_at": ` + referenceTimeStr + `, 5630 "suspended_at": ` + referenceTimeStr + `, 5631 "url": "u" 5632 }, 5633 "suspended_at": ` + referenceTimeStr + ` 5634 } 5635 }` 5636 5637 testJSONMarshal(t, u, want) 5638 } 5639 5640 func TestDeploymentEvent_Marshal(t *testing.T) { 5641 t.Parallel() 5642 testJSONMarshal(t, &DeploymentEvent{}, "{}") 5643 5644 l := make(map[string]interface{}) 5645 l["key"] = "value" 5646 5647 jsonMsg, _ := json.Marshal(&l) 5648 5649 u := &DeploymentEvent{ 5650 Deployment: &Deployment{ 5651 URL: Ptr("url"), 5652 ID: Ptr(int64(1)), 5653 SHA: Ptr("sha"), 5654 Ref: Ptr("ref"), 5655 Task: Ptr("t"), 5656 Payload: jsonMsg, 5657 Environment: Ptr("e"), 5658 Description: Ptr("d"), 5659 Creator: &User{ 5660 Login: Ptr("l"), 5661 ID: Ptr(int64(1)), 5662 NodeID: Ptr("n"), 5663 URL: Ptr("u"), 5664 ReposURL: Ptr("r"), 5665 EventsURL: Ptr("e"), 5666 AvatarURL: Ptr("a"), 5667 }, 5668 CreatedAt: &Timestamp{referenceTime}, 5669 UpdatedAt: &Timestamp{referenceTime}, 5670 StatusesURL: Ptr("surl"), 5671 RepositoryURL: Ptr("rurl"), 5672 NodeID: Ptr("nid"), 5673 }, 5674 Repo: &Repository{ 5675 ID: Ptr(int64(1)), 5676 URL: Ptr("s"), 5677 Name: Ptr("n"), 5678 }, 5679 Sender: &User{ 5680 Login: Ptr("l"), 5681 ID: Ptr(int64(1)), 5682 NodeID: Ptr("n"), 5683 URL: Ptr("u"), 5684 ReposURL: Ptr("r"), 5685 EventsURL: Ptr("e"), 5686 AvatarURL: Ptr("a"), 5687 }, 5688 Installation: &Installation{ 5689 ID: Ptr(int64(1)), 5690 NodeID: Ptr("nid"), 5691 AppID: Ptr(int64(1)), 5692 AppSlug: Ptr("as"), 5693 TargetID: Ptr(int64(1)), 5694 Account: &User{ 5695 Login: Ptr("l"), 5696 ID: Ptr(int64(1)), 5697 URL: Ptr("u"), 5698 AvatarURL: Ptr("a"), 5699 GravatarID: Ptr("g"), 5700 Name: Ptr("n"), 5701 Company: Ptr("c"), 5702 Blog: Ptr("b"), 5703 Location: Ptr("l"), 5704 Email: Ptr("e"), 5705 Hireable: Ptr(true), 5706 Bio: Ptr("b"), 5707 TwitterUsername: Ptr("t"), 5708 PublicRepos: Ptr(1), 5709 Followers: Ptr(1), 5710 Following: Ptr(1), 5711 CreatedAt: &Timestamp{referenceTime}, 5712 SuspendedAt: &Timestamp{referenceTime}, 5713 }, 5714 AccessTokensURL: Ptr("atu"), 5715 RepositoriesURL: Ptr("ru"), 5716 HTMLURL: Ptr("hu"), 5717 TargetType: Ptr("tt"), 5718 SingleFileName: Ptr("sfn"), 5719 RepositorySelection: Ptr("rs"), 5720 Events: []string{"e"}, 5721 SingleFilePaths: []string{"s"}, 5722 Permissions: &InstallationPermissions{ 5723 Actions: Ptr("a"), 5724 Administration: Ptr("ad"), 5725 Checks: Ptr("c"), 5726 Contents: Ptr("co"), 5727 ContentReferences: Ptr("cr"), 5728 Deployments: Ptr("d"), 5729 Environments: Ptr("e"), 5730 Issues: Ptr("i"), 5731 Metadata: Ptr("md"), 5732 Members: Ptr("m"), 5733 OrganizationAdministration: Ptr("oa"), 5734 OrganizationHooks: Ptr("oh"), 5735 OrganizationPlan: Ptr("op"), 5736 OrganizationPreReceiveHooks: Ptr("opr"), 5737 OrganizationProjects: Ptr("op"), 5738 OrganizationSecrets: Ptr("os"), 5739 OrganizationSelfHostedRunners: Ptr("osh"), 5740 OrganizationUserBlocking: Ptr("oub"), 5741 Packages: Ptr("pkg"), 5742 Pages: Ptr("pg"), 5743 PullRequests: Ptr("pr"), 5744 RepositoryHooks: Ptr("rh"), 5745 RepositoryProjects: Ptr("rp"), 5746 RepositoryPreReceiveHooks: Ptr("rprh"), 5747 Secrets: Ptr("s"), 5748 SecretScanningAlerts: Ptr("ssa"), 5749 SecurityEvents: Ptr("se"), 5750 SingleFile: Ptr("sf"), 5751 Statuses: Ptr("s"), 5752 TeamDiscussions: Ptr("td"), 5753 VulnerabilityAlerts: Ptr("va"), 5754 Workflows: Ptr("w"), 5755 }, 5756 CreatedAt: &Timestamp{referenceTime}, 5757 UpdatedAt: &Timestamp{referenceTime}, 5758 HasMultipleSingleFiles: Ptr(false), 5759 SuspendedBy: &User{ 5760 Login: Ptr("l"), 5761 ID: Ptr(int64(1)), 5762 URL: Ptr("u"), 5763 AvatarURL: Ptr("a"), 5764 GravatarID: Ptr("g"), 5765 Name: Ptr("n"), 5766 Company: Ptr("c"), 5767 Blog: Ptr("b"), 5768 Location: Ptr("l"), 5769 Email: Ptr("e"), 5770 Hireable: Ptr(true), 5771 Bio: Ptr("b"), 5772 TwitterUsername: Ptr("t"), 5773 PublicRepos: Ptr(1), 5774 Followers: Ptr(1), 5775 Following: Ptr(1), 5776 CreatedAt: &Timestamp{referenceTime}, 5777 SuspendedAt: &Timestamp{referenceTime}, 5778 }, 5779 SuspendedAt: &Timestamp{referenceTime}, 5780 }, 5781 Workflow: &Workflow{ 5782 ID: Ptr(int64(1)), 5783 NodeID: Ptr("nid"), 5784 Name: Ptr("n"), 5785 Path: Ptr("p"), 5786 State: Ptr("s"), 5787 CreatedAt: &Timestamp{referenceTime}, 5788 UpdatedAt: &Timestamp{referenceTime}, 5789 URL: Ptr("u"), 5790 HTMLURL: Ptr("h"), 5791 BadgeURL: Ptr("b"), 5792 }, 5793 WorkflowRun: &WorkflowRun{ 5794 ID: Ptr(int64(1)), 5795 Name: Ptr("n"), 5796 NodeID: Ptr("nid"), 5797 HeadBranch: Ptr("hb"), 5798 HeadSHA: Ptr("hs"), 5799 RunNumber: Ptr(1), 5800 RunAttempt: Ptr(1), 5801 Event: Ptr("e"), 5802 Status: Ptr("s"), 5803 Conclusion: Ptr("c"), 5804 WorkflowID: Ptr(int64(1)), 5805 URL: Ptr("u"), 5806 HTMLURL: Ptr("h"), 5807 PullRequests: []*PullRequest{ 5808 { 5809 URL: Ptr("u"), 5810 ID: Ptr(int64(1)), 5811 Number: Ptr(1), 5812 Head: &PullRequestBranch{ 5813 Ref: Ptr("r"), 5814 SHA: Ptr("s"), 5815 Repo: &Repository{ 5816 ID: Ptr(int64(1)), 5817 URL: Ptr("s"), 5818 Name: Ptr("n"), 5819 }, 5820 }, 5821 Base: &PullRequestBranch{ 5822 Ref: Ptr("r"), 5823 SHA: Ptr("s"), 5824 Repo: &Repository{ 5825 ID: Ptr(int64(1)), 5826 URL: Ptr("u"), 5827 Name: Ptr("n"), 5828 }, 5829 }, 5830 }, 5831 }, 5832 CreatedAt: &Timestamp{referenceTime}, 5833 UpdatedAt: &Timestamp{referenceTime}, 5834 RunStartedAt: &Timestamp{referenceTime}, 5835 JobsURL: Ptr("j"), 5836 LogsURL: Ptr("l"), 5837 CheckSuiteURL: Ptr("c"), 5838 ArtifactsURL: Ptr("a"), 5839 CancelURL: Ptr("c"), 5840 RerunURL: Ptr("r"), 5841 PreviousAttemptURL: Ptr("p"), 5842 HeadCommit: &HeadCommit{ 5843 Message: Ptr("m"), 5844 Author: &CommitAuthor{ 5845 Name: Ptr("n"), 5846 Email: Ptr("e"), 5847 Login: Ptr("l"), 5848 }, 5849 URL: Ptr("u"), 5850 Distinct: Ptr(false), 5851 SHA: Ptr("s"), 5852 ID: Ptr("i"), 5853 TreeID: Ptr("tid"), 5854 Timestamp: &Timestamp{referenceTime}, 5855 Committer: &CommitAuthor{ 5856 Name: Ptr("n"), 5857 Email: Ptr("e"), 5858 Login: Ptr("l"), 5859 }, 5860 }, 5861 WorkflowURL: Ptr("w"), 5862 Repository: &Repository{ 5863 ID: Ptr(int64(1)), 5864 URL: Ptr("u"), 5865 Name: Ptr("n"), 5866 }, 5867 HeadRepository: &Repository{ 5868 ID: Ptr(int64(1)), 5869 URL: Ptr("u"), 5870 Name: Ptr("n"), 5871 }, 5872 }, 5873 } 5874 5875 want := `{ 5876 "deployment": { 5877 "url": "url", 5878 "id": 1, 5879 "sha": "sha", 5880 "ref": "ref", 5881 "task": "t", 5882 "payload": { 5883 "key": "value" 5884 }, 5885 "environment": "e", 5886 "description": "d", 5887 "creator": { 5888 "login": "l", 5889 "id": 1, 5890 "node_id": "n", 5891 "avatar_url": "a", 5892 "url": "u", 5893 "events_url": "e", 5894 "repos_url": "r" 5895 }, 5896 "created_at": ` + referenceTimeStr + `, 5897 "updated_at": ` + referenceTimeStr + `, 5898 "statuses_url": "surl", 5899 "repository_url": "rurl", 5900 "node_id": "nid" 5901 }, 5902 "repository": { 5903 "id": 1, 5904 "name": "n", 5905 "url": "s" 5906 }, 5907 "sender": { 5908 "login": "l", 5909 "id": 1, 5910 "node_id": "n", 5911 "avatar_url": "a", 5912 "url": "u", 5913 "events_url": "e", 5914 "repos_url": "r" 5915 }, 5916 "installation": { 5917 "id": 1, 5918 "node_id": "nid", 5919 "app_id": 1, 5920 "app_slug": "as", 5921 "target_id": 1, 5922 "account": { 5923 "login": "l", 5924 "id": 1, 5925 "avatar_url": "a", 5926 "gravatar_id": "g", 5927 "name": "n", 5928 "company": "c", 5929 "blog": "b", 5930 "location": "l", 5931 "email": "e", 5932 "hireable": true, 5933 "bio": "b", 5934 "twitter_username": "t", 5935 "public_repos": 1, 5936 "followers": 1, 5937 "following": 1, 5938 "created_at": ` + referenceTimeStr + `, 5939 "suspended_at": ` + referenceTimeStr + `, 5940 "url": "u" 5941 }, 5942 "access_tokens_url": "atu", 5943 "repositories_url": "ru", 5944 "html_url": "hu", 5945 "target_type": "tt", 5946 "single_file_name": "sfn", 5947 "repository_selection": "rs", 5948 "events": [ 5949 "e" 5950 ], 5951 "single_file_paths": [ 5952 "s" 5953 ], 5954 "permissions": { 5955 "actions": "a", 5956 "administration": "ad", 5957 "checks": "c", 5958 "contents": "co", 5959 "content_references": "cr", 5960 "deployments": "d", 5961 "environments": "e", 5962 "issues": "i", 5963 "metadata": "md", 5964 "members": "m", 5965 "organization_administration": "oa", 5966 "organization_hooks": "oh", 5967 "organization_plan": "op", 5968 "organization_pre_receive_hooks": "opr", 5969 "organization_projects": "op", 5970 "organization_secrets": "os", 5971 "organization_self_hosted_runners": "osh", 5972 "organization_user_blocking": "oub", 5973 "packages": "pkg", 5974 "pages": "pg", 5975 "pull_requests": "pr", 5976 "repository_hooks": "rh", 5977 "repository_projects": "rp", 5978 "repository_pre_receive_hooks": "rprh", 5979 "secrets": "s", 5980 "secret_scanning_alerts": "ssa", 5981 "security_events": "se", 5982 "single_file": "sf", 5983 "statuses": "s", 5984 "team_discussions": "td", 5985 "vulnerability_alerts": "va", 5986 "workflows": "w" 5987 }, 5988 "created_at": ` + referenceTimeStr + `, 5989 "updated_at": ` + referenceTimeStr + `, 5990 "has_multiple_single_files": false, 5991 "suspended_by": { 5992 "login": "l", 5993 "id": 1, 5994 "avatar_url": "a", 5995 "gravatar_id": "g", 5996 "name": "n", 5997 "company": "c", 5998 "blog": "b", 5999 "location": "l", 6000 "email": "e", 6001 "hireable": true, 6002 "bio": "b", 6003 "twitter_username": "t", 6004 "public_repos": 1, 6005 "followers": 1, 6006 "following": 1, 6007 "created_at": ` + referenceTimeStr + `, 6008 "suspended_at": ` + referenceTimeStr + `, 6009 "url": "u" 6010 }, 6011 "suspended_at": ` + referenceTimeStr + ` 6012 }, 6013 "workflow": { 6014 "id": 1, 6015 "node_id": "nid", 6016 "name": "n", 6017 "path": "p", 6018 "state": "s", 6019 "created_at": ` + referenceTimeStr + `, 6020 "updated_at": ` + referenceTimeStr + `, 6021 "url": "u", 6022 "html_url": "h", 6023 "badge_url": "b" 6024 }, 6025 "workflow_run": { 6026 "id": 1, 6027 "name": "n", 6028 "node_id": "nid", 6029 "head_branch": "hb", 6030 "head_sha": "hs", 6031 "run_number": 1, 6032 "run_attempt": 1, 6033 "event": "e", 6034 "status": "s", 6035 "conclusion": "c", 6036 "workflow_id": 1, 6037 "url": "u", 6038 "html_url": "h", 6039 "pull_requests": [ 6040 { 6041 "id": 1, 6042 "number": 1, 6043 "url": "u", 6044 "head": { 6045 "ref": "r", 6046 "sha": "s", 6047 "repo": { 6048 "id": 1, 6049 "name": "n", 6050 "url": "s" 6051 } 6052 }, 6053 "base": { 6054 "ref": "r", 6055 "sha": "s", 6056 "repo": { 6057 "id": 1, 6058 "name": "n", 6059 "url": "u" 6060 } 6061 } 6062 } 6063 ], 6064 "created_at": ` + referenceTimeStr + `, 6065 "updated_at": ` + referenceTimeStr + `, 6066 "run_started_at": ` + referenceTimeStr + `, 6067 "jobs_url": "j", 6068 "logs_url": "l", 6069 "check_suite_url": "c", 6070 "artifacts_url": "a", 6071 "cancel_url": "c", 6072 "rerun_url": "r", 6073 "previous_attempt_url": "p", 6074 "head_commit": { 6075 "message": "m", 6076 "author": { 6077 "name": "n", 6078 "email": "e", 6079 "username": "l" 6080 }, 6081 "url": "u", 6082 "distinct": false, 6083 "sha": "s", 6084 "id": "i", 6085 "tree_id": "tid", 6086 "timestamp": ` + referenceTimeStr + `, 6087 "committer": { 6088 "name": "n", 6089 "email": "e", 6090 "username": "l" 6091 } 6092 }, 6093 "workflow_url": "w", 6094 "repository": { 6095 "id": 1, 6096 "name": "n", 6097 "url": "u" 6098 }, 6099 "head_repository": { 6100 "id": 1, 6101 "name": "n", 6102 "url": "u" 6103 } 6104 } 6105 }` 6106 6107 testJSONMarshal(t, u, want) 6108 } 6109 6110 func TestDeploymentProtectionRuleEvent_Marshal(t *testing.T) { 6111 t.Parallel() 6112 testJSONMarshal(t, &DeploymentProtectionRuleEvent{}, "{}") 6113 6114 l := make(map[string]interface{}) 6115 l["key"] = "value" 6116 6117 jsonMsg, _ := json.Marshal(&l) 6118 6119 u := &DeploymentProtectionRuleEvent{ 6120 Action: Ptr("a"), 6121 Environment: Ptr("e"), 6122 DeploymentCallbackURL: Ptr("b"), 6123 Deployment: &Deployment{ 6124 URL: Ptr("url"), 6125 ID: Ptr(int64(1)), 6126 SHA: Ptr("sha"), 6127 Ref: Ptr("ref"), 6128 Task: Ptr("t"), 6129 Payload: jsonMsg, 6130 Environment: Ptr("e"), 6131 Description: Ptr("d"), 6132 Creator: &User{ 6133 Login: Ptr("l"), 6134 ID: Ptr(int64(1)), 6135 NodeID: Ptr("n"), 6136 URL: Ptr("u"), 6137 ReposURL: Ptr("r"), 6138 EventsURL: Ptr("e"), 6139 AvatarURL: Ptr("a"), 6140 }, 6141 CreatedAt: &Timestamp{referenceTime}, 6142 UpdatedAt: &Timestamp{referenceTime}, 6143 StatusesURL: Ptr("surl"), 6144 RepositoryURL: Ptr("rurl"), 6145 NodeID: Ptr("nid"), 6146 }, 6147 Repo: &Repository{ 6148 ID: Ptr(int64(1)), 6149 URL: Ptr("s"), 6150 Name: Ptr("n"), 6151 }, 6152 Organization: &Organization{ 6153 BillingEmail: Ptr("be"), 6154 Blog: Ptr("b"), 6155 Company: Ptr("c"), 6156 Email: Ptr("e"), 6157 TwitterUsername: Ptr("tu"), 6158 Location: Ptr("loc"), 6159 Name: Ptr("n"), 6160 Description: Ptr("d"), 6161 IsVerified: Ptr(true), 6162 HasOrganizationProjects: Ptr(true), 6163 HasRepositoryProjects: Ptr(true), 6164 DefaultRepoPermission: Ptr("drp"), 6165 MembersCanCreateRepos: Ptr(true), 6166 MembersCanCreateInternalRepos: Ptr(true), 6167 MembersCanCreatePrivateRepos: Ptr(true), 6168 MembersCanCreatePublicRepos: Ptr(false), 6169 MembersAllowedRepositoryCreationType: Ptr("marct"), 6170 MembersCanCreatePages: Ptr(true), 6171 MembersCanCreatePublicPages: Ptr(false), 6172 MembersCanCreatePrivatePages: Ptr(true), 6173 }, 6174 PullRequests: []*PullRequest{ 6175 { 6176 URL: Ptr("u"), 6177 ID: Ptr(int64(1)), 6178 Number: Ptr(1), 6179 Head: &PullRequestBranch{ 6180 Ref: Ptr("r"), 6181 SHA: Ptr("s"), 6182 Repo: &Repository{ 6183 ID: Ptr(int64(1)), 6184 URL: Ptr("s"), 6185 Name: Ptr("n"), 6186 }, 6187 }, 6188 Base: &PullRequestBranch{ 6189 Ref: Ptr("r"), 6190 SHA: Ptr("s"), 6191 Repo: &Repository{ 6192 ID: Ptr(int64(1)), 6193 URL: Ptr("u"), 6194 Name: Ptr("n"), 6195 }, 6196 }, 6197 }, 6198 }, 6199 Sender: &User{ 6200 Login: Ptr("l"), 6201 ID: Ptr(int64(1)), 6202 NodeID: Ptr("n"), 6203 URL: Ptr("u"), 6204 ReposURL: Ptr("r"), 6205 EventsURL: Ptr("e"), 6206 AvatarURL: Ptr("a"), 6207 }, 6208 Installation: &Installation{ 6209 ID: Ptr(int64(1)), 6210 NodeID: Ptr("nid"), 6211 AppID: Ptr(int64(1)), 6212 AppSlug: Ptr("as"), 6213 TargetID: Ptr(int64(1)), 6214 Account: &User{ 6215 Login: Ptr("l"), 6216 ID: Ptr(int64(1)), 6217 URL: Ptr("u"), 6218 AvatarURL: Ptr("a"), 6219 GravatarID: Ptr("g"), 6220 Name: Ptr("n"), 6221 Company: Ptr("c"), 6222 Blog: Ptr("b"), 6223 Location: Ptr("l"), 6224 Email: Ptr("e"), 6225 Hireable: Ptr(true), 6226 Bio: Ptr("b"), 6227 TwitterUsername: Ptr("t"), 6228 PublicRepos: Ptr(1), 6229 Followers: Ptr(1), 6230 Following: Ptr(1), 6231 CreatedAt: &Timestamp{referenceTime}, 6232 SuspendedAt: &Timestamp{referenceTime}, 6233 }, 6234 AccessTokensURL: Ptr("atu"), 6235 RepositoriesURL: Ptr("ru"), 6236 HTMLURL: Ptr("hu"), 6237 TargetType: Ptr("tt"), 6238 SingleFileName: Ptr("sfn"), 6239 RepositorySelection: Ptr("rs"), 6240 Events: []string{"e"}, 6241 SingleFilePaths: []string{"s"}, 6242 Permissions: &InstallationPermissions{ 6243 Actions: Ptr("a"), 6244 Administration: Ptr("ad"), 6245 Checks: Ptr("c"), 6246 Contents: Ptr("co"), 6247 ContentReferences: Ptr("cr"), 6248 Deployments: Ptr("d"), 6249 Environments: Ptr("e"), 6250 Issues: Ptr("i"), 6251 Metadata: Ptr("md"), 6252 Members: Ptr("m"), 6253 OrganizationAdministration: Ptr("oa"), 6254 OrganizationHooks: Ptr("oh"), 6255 OrganizationPlan: Ptr("op"), 6256 OrganizationPreReceiveHooks: Ptr("opr"), 6257 OrganizationProjects: Ptr("op"), 6258 OrganizationSecrets: Ptr("os"), 6259 OrganizationSelfHostedRunners: Ptr("osh"), 6260 OrganizationUserBlocking: Ptr("oub"), 6261 Packages: Ptr("pkg"), 6262 Pages: Ptr("pg"), 6263 PullRequests: Ptr("pr"), 6264 RepositoryHooks: Ptr("rh"), 6265 RepositoryProjects: Ptr("rp"), 6266 RepositoryPreReceiveHooks: Ptr("rprh"), 6267 Secrets: Ptr("s"), 6268 SecretScanningAlerts: Ptr("ssa"), 6269 SecurityEvents: Ptr("se"), 6270 SingleFile: Ptr("sf"), 6271 Statuses: Ptr("s"), 6272 TeamDiscussions: Ptr("td"), 6273 VulnerabilityAlerts: Ptr("va"), 6274 Workflows: Ptr("w"), 6275 }, 6276 CreatedAt: &Timestamp{referenceTime}, 6277 UpdatedAt: &Timestamp{referenceTime}, 6278 HasMultipleSingleFiles: Ptr(false), 6279 SuspendedBy: &User{ 6280 Login: Ptr("l"), 6281 ID: Ptr(int64(1)), 6282 URL: Ptr("u"), 6283 AvatarURL: Ptr("a"), 6284 GravatarID: Ptr("g"), 6285 Name: Ptr("n"), 6286 Company: Ptr("c"), 6287 Blog: Ptr("b"), 6288 Location: Ptr("l"), 6289 Email: Ptr("e"), 6290 Hireable: Ptr(true), 6291 Bio: Ptr("b"), 6292 TwitterUsername: Ptr("t"), 6293 PublicRepos: Ptr(1), 6294 Followers: Ptr(1), 6295 Following: Ptr(1), 6296 CreatedAt: &Timestamp{referenceTime}, 6297 SuspendedAt: &Timestamp{referenceTime}, 6298 }, 6299 SuspendedAt: &Timestamp{referenceTime}, 6300 }, 6301 } 6302 6303 want := `{ 6304 "action": "a", 6305 "environment": "e", 6306 "deployment_callback_url": "b", 6307 "deployment": { 6308 "url": "url", 6309 "id": 1, 6310 "sha": "sha", 6311 "ref": "ref", 6312 "task": "t", 6313 "payload": { 6314 "key": "value" 6315 }, 6316 "environment": "e", 6317 "description": "d", 6318 "creator": { 6319 "login": "l", 6320 "id": 1, 6321 "node_id": "n", 6322 "avatar_url": "a", 6323 "url": "u", 6324 "events_url": "e", 6325 "repos_url": "r" 6326 }, 6327 "created_at": ` + referenceTimeStr + `, 6328 "updated_at": ` + referenceTimeStr + `, 6329 "statuses_url": "surl", 6330 "repository_url": "rurl", 6331 "node_id": "nid" 6332 }, 6333 "repository": { 6334 "id": 1, 6335 "name": "n", 6336 "url": "s" 6337 }, 6338 "organization": { 6339 "name": "n", 6340 "company": "c", 6341 "blog": "b", 6342 "location": "loc", 6343 "email": "e", 6344 "twitter_username": "tu", 6345 "description": "d", 6346 "billing_email": "be", 6347 "is_verified": true, 6348 "has_organization_projects": true, 6349 "has_repository_projects": true, 6350 "default_repository_permission": "drp", 6351 "members_can_create_repositories": true, 6352 "members_can_create_public_repositories": false, 6353 "members_can_create_private_repositories": true, 6354 "members_can_create_internal_repositories": true, 6355 "members_allowed_repository_creation_type": "marct", 6356 "members_can_create_pages": true, 6357 "members_can_create_public_pages": false, 6358 "members_can_create_private_pages": true 6359 }, 6360 "pull_requests": [ 6361 { 6362 "id": 1, 6363 "number": 1, 6364 "url": "u", 6365 "head": { 6366 "ref": "r", 6367 "sha": "s", 6368 "repo": { 6369 "id": 1, 6370 "name": "n", 6371 "url": "s" 6372 } 6373 }, 6374 "base": { 6375 "ref": "r", 6376 "sha": "s", 6377 "repo": { 6378 "id": 1, 6379 "name": "n", 6380 "url": "u" 6381 } 6382 } 6383 } 6384 ], 6385 "sender": { 6386 "login": "l", 6387 "id": 1, 6388 "node_id": "n", 6389 "avatar_url": "a", 6390 "url": "u", 6391 "events_url": "e", 6392 "repos_url": "r" 6393 }, 6394 "installation": { 6395 "id": 1, 6396 "node_id": "nid", 6397 "app_id": 1, 6398 "app_slug": "as", 6399 "target_id": 1, 6400 "account": { 6401 "login": "l", 6402 "id": 1, 6403 "avatar_url": "a", 6404 "gravatar_id": "g", 6405 "name": "n", 6406 "company": "c", 6407 "blog": "b", 6408 "location": "l", 6409 "email": "e", 6410 "hireable": true, 6411 "bio": "b", 6412 "twitter_username": "t", 6413 "public_repos": 1, 6414 "followers": 1, 6415 "following": 1, 6416 "created_at": ` + referenceTimeStr + `, 6417 "suspended_at": ` + referenceTimeStr + `, 6418 "url": "u" 6419 }, 6420 "access_tokens_url": "atu", 6421 "repositories_url": "ru", 6422 "html_url": "hu", 6423 "target_type": "tt", 6424 "single_file_name": "sfn", 6425 "repository_selection": "rs", 6426 "events": [ 6427 "e" 6428 ], 6429 "single_file_paths": [ 6430 "s" 6431 ], 6432 "permissions": { 6433 "actions": "a", 6434 "administration": "ad", 6435 "checks": "c", 6436 "contents": "co", 6437 "content_references": "cr", 6438 "deployments": "d", 6439 "environments": "e", 6440 "issues": "i", 6441 "metadata": "md", 6442 "members": "m", 6443 "organization_administration": "oa", 6444 "organization_hooks": "oh", 6445 "organization_plan": "op", 6446 "organization_pre_receive_hooks": "opr", 6447 "organization_projects": "op", 6448 "organization_secrets": "os", 6449 "organization_self_hosted_runners": "osh", 6450 "organization_user_blocking": "oub", 6451 "packages": "pkg", 6452 "pages": "pg", 6453 "pull_requests": "pr", 6454 "repository_hooks": "rh", 6455 "repository_projects": "rp", 6456 "repository_pre_receive_hooks": "rprh", 6457 "secrets": "s", 6458 "secret_scanning_alerts": "ssa", 6459 "security_events": "se", 6460 "single_file": "sf", 6461 "statuses": "s", 6462 "team_discussions": "td", 6463 "vulnerability_alerts": "va", 6464 "workflows": "w" 6465 }, 6466 "created_at": ` + referenceTimeStr + `, 6467 "updated_at": ` + referenceTimeStr + `, 6468 "has_multiple_single_files": false, 6469 "suspended_by": { 6470 "login": "l", 6471 "id": 1, 6472 "avatar_url": "a", 6473 "gravatar_id": "g", 6474 "name": "n", 6475 "company": "c", 6476 "blog": "b", 6477 "location": "l", 6478 "email": "e", 6479 "hireable": true, 6480 "bio": "b", 6481 "twitter_username": "t", 6482 "public_repos": 1, 6483 "followers": 1, 6484 "following": 1, 6485 "created_at": ` + referenceTimeStr + `, 6486 "suspended_at": ` + referenceTimeStr + `, 6487 "url": "u" 6488 }, 6489 "suspended_at": ` + referenceTimeStr + ` 6490 } 6491 }` 6492 6493 testJSONMarshal(t, u, want) 6494 } 6495 6496 func TestDeploymentReviewEvent_Marshal(t *testing.T) { 6497 t.Parallel() 6498 testJSONMarshal(t, &DeploymentReviewEvent{}, "{}") 6499 6500 u := &DeploymentReviewEvent{ 6501 Action: Ptr("a"), 6502 Environment: Ptr("e"), 6503 Requester: &User{ 6504 AvatarURL: Ptr("a"), 6505 Email: Ptr("e"), 6506 EventsURL: Ptr("e"), 6507 FollowersURL: Ptr("f"), 6508 FollowingURL: Ptr("f"), 6509 GistsURL: Ptr("g"), 6510 GravatarID: Ptr("g"), 6511 HTMLURL: Ptr("h"), 6512 ID: Ptr(int64(1)), 6513 Login: Ptr("l"), 6514 Name: Ptr("n"), 6515 NodeID: Ptr("n"), 6516 OrganizationsURL: Ptr("o"), 6517 ReceivedEventsURL: Ptr("r"), 6518 ReposURL: Ptr("r"), 6519 SiteAdmin: Ptr(false), 6520 StarredURL: Ptr("s"), 6521 SubscriptionsURL: Ptr("s"), 6522 Type: Ptr("User"), 6523 URL: Ptr("u"), 6524 }, 6525 Reviewers: []*RequiredReviewer{ 6526 { 6527 Type: Ptr("User"), 6528 Reviewer: &User{ 6529 AvatarURL: Ptr("a"), 6530 Email: Ptr("e"), 6531 EventsURL: Ptr("e"), 6532 FollowersURL: Ptr("f"), 6533 FollowingURL: Ptr("f"), 6534 GistsURL: Ptr("g"), 6535 GravatarID: Ptr("g"), 6536 HTMLURL: Ptr("h"), 6537 ID: Ptr(int64(1)), 6538 Login: Ptr("l"), 6539 Name: Ptr("n"), 6540 NodeID: Ptr("n"), 6541 OrganizationsURL: Ptr("o"), 6542 ReceivedEventsURL: Ptr("r"), 6543 ReposURL: Ptr("r"), 6544 SiteAdmin: Ptr(false), 6545 StarredURL: Ptr("s"), 6546 SubscriptionsURL: Ptr("s"), 6547 Type: Ptr("User"), 6548 URL: Ptr("u"), 6549 }, 6550 }, 6551 { 6552 Type: Ptr("Team"), 6553 Reviewer: &Team{ 6554 ID: Ptr(int64(1)), 6555 Name: Ptr("n"), 6556 Slug: Ptr("s"), 6557 }, 6558 }, 6559 }, 6560 Enterprise: &Enterprise{ 6561 ID: Ptr(1), 6562 Slug: Ptr("s"), 6563 Name: Ptr("n"), 6564 NodeID: Ptr("nid"), 6565 AvatarURL: Ptr("au"), 6566 Description: Ptr("d"), 6567 WebsiteURL: Ptr("wu"), 6568 HTMLURL: Ptr("hu"), 6569 CreatedAt: &Timestamp{referenceTime}, 6570 UpdatedAt: &Timestamp{referenceTime}, 6571 }, 6572 Installation: &Installation{ 6573 ID: Ptr(int64(1)), 6574 NodeID: Ptr("nid"), 6575 AppID: Ptr(int64(1)), 6576 AppSlug: Ptr("as"), 6577 TargetID: Ptr(int64(1)), 6578 Account: &User{ 6579 Login: Ptr("l"), 6580 ID: Ptr(int64(1)), 6581 URL: Ptr("u"), 6582 AvatarURL: Ptr("a"), 6583 GravatarID: Ptr("g"), 6584 Name: Ptr("n"), 6585 Company: Ptr("c"), 6586 Blog: Ptr("b"), 6587 Location: Ptr("l"), 6588 Email: Ptr("e"), 6589 Hireable: Ptr(true), 6590 Bio: Ptr("b"), 6591 TwitterUsername: Ptr("t"), 6592 PublicRepos: Ptr(1), 6593 Followers: Ptr(1), 6594 Following: Ptr(1), 6595 CreatedAt: &Timestamp{referenceTime}, 6596 SuspendedAt: &Timestamp{referenceTime}, 6597 }, 6598 AccessTokensURL: Ptr("atu"), 6599 RepositoriesURL: Ptr("ru"), 6600 HTMLURL: Ptr("hu"), 6601 TargetType: Ptr("tt"), 6602 SingleFileName: Ptr("sfn"), 6603 RepositorySelection: Ptr("rs"), 6604 Events: []string{"e"}, 6605 SingleFilePaths: []string{"s"}, 6606 Permissions: &InstallationPermissions{ 6607 Actions: Ptr("a"), 6608 Administration: Ptr("ad"), 6609 Checks: Ptr("c"), 6610 Contents: Ptr("co"), 6611 ContentReferences: Ptr("cr"), 6612 Deployments: Ptr("d"), 6613 Environments: Ptr("e"), 6614 Issues: Ptr("i"), 6615 Metadata: Ptr("md"), 6616 Members: Ptr("m"), 6617 OrganizationAdministration: Ptr("oa"), 6618 OrganizationHooks: Ptr("oh"), 6619 OrganizationPlan: Ptr("op"), 6620 OrganizationPreReceiveHooks: Ptr("opr"), 6621 OrganizationProjects: Ptr("op"), 6622 OrganizationSecrets: Ptr("os"), 6623 OrganizationSelfHostedRunners: Ptr("osh"), 6624 OrganizationUserBlocking: Ptr("oub"), 6625 Packages: Ptr("pkg"), 6626 Pages: Ptr("pg"), 6627 PullRequests: Ptr("pr"), 6628 RepositoryHooks: Ptr("rh"), 6629 RepositoryProjects: Ptr("rp"), 6630 RepositoryPreReceiveHooks: Ptr("rprh"), 6631 Secrets: Ptr("s"), 6632 SecretScanningAlerts: Ptr("ssa"), 6633 SecurityEvents: Ptr("se"), 6634 SingleFile: Ptr("sf"), 6635 Statuses: Ptr("s"), 6636 TeamDiscussions: Ptr("td"), 6637 VulnerabilityAlerts: Ptr("va"), 6638 Workflows: Ptr("w"), 6639 }, 6640 CreatedAt: &Timestamp{referenceTime}, 6641 UpdatedAt: &Timestamp{referenceTime}, 6642 HasMultipleSingleFiles: Ptr(false), 6643 SuspendedBy: &User{ 6644 Login: Ptr("l"), 6645 ID: Ptr(int64(1)), 6646 URL: Ptr("u"), 6647 AvatarURL: Ptr("a"), 6648 GravatarID: Ptr("g"), 6649 Name: Ptr("n"), 6650 Company: Ptr("c"), 6651 Blog: Ptr("b"), 6652 Location: Ptr("l"), 6653 Email: Ptr("e"), 6654 Hireable: Ptr(true), 6655 Bio: Ptr("b"), 6656 TwitterUsername: Ptr("t"), 6657 PublicRepos: Ptr(1), 6658 Followers: Ptr(1), 6659 Following: Ptr(1), 6660 CreatedAt: &Timestamp{referenceTime}, 6661 SuspendedAt: &Timestamp{referenceTime}, 6662 }, 6663 SuspendedAt: &Timestamp{referenceTime}, 6664 }, 6665 Organization: &Organization{ 6666 BillingEmail: Ptr("be"), 6667 Blog: Ptr("b"), 6668 Company: Ptr("c"), 6669 Email: Ptr("e"), 6670 TwitterUsername: Ptr("tu"), 6671 Location: Ptr("loc"), 6672 Name: Ptr("n"), 6673 Description: Ptr("d"), 6674 IsVerified: Ptr(true), 6675 HasOrganizationProjects: Ptr(true), 6676 HasRepositoryProjects: Ptr(true), 6677 DefaultRepoPermission: Ptr("drp"), 6678 MembersCanCreateRepos: Ptr(true), 6679 MembersCanCreateInternalRepos: Ptr(true), 6680 MembersCanCreatePrivateRepos: Ptr(true), 6681 MembersCanCreatePublicRepos: Ptr(false), 6682 MembersAllowedRepositoryCreationType: Ptr("marct"), 6683 MembersCanCreatePages: Ptr(true), 6684 MembersCanCreatePublicPages: Ptr(false), 6685 MembersCanCreatePrivatePages: Ptr(true), 6686 }, 6687 Repo: &Repository{ 6688 ID: Ptr(int64(1)), 6689 URL: Ptr("s"), 6690 Name: Ptr("n"), 6691 }, 6692 Sender: &User{ 6693 Login: Ptr("l"), 6694 ID: Ptr(int64(1)), 6695 NodeID: Ptr("n"), 6696 URL: Ptr("u"), 6697 ReposURL: Ptr("r"), 6698 EventsURL: Ptr("e"), 6699 AvatarURL: Ptr("a"), 6700 }, 6701 Since: Ptr("s"), 6702 WorkflowJobRun: &WorkflowJobRun{ 6703 ID: Ptr(int64(1)), 6704 Conclusion: Ptr("c"), 6705 Environment: Ptr("e"), 6706 HTMLURL: Ptr("h"), 6707 Name: Ptr("n"), 6708 Status: Ptr("s"), 6709 CreatedAt: &Timestamp{referenceTime}, 6710 UpdatedAt: &Timestamp{referenceTime}, 6711 }, 6712 WorkflowRun: &WorkflowRun{ 6713 ID: Ptr(int64(1)), 6714 Name: Ptr("n"), 6715 NodeID: Ptr("nid"), 6716 HeadBranch: Ptr("hb"), 6717 HeadSHA: Ptr("hs"), 6718 RunNumber: Ptr(1), 6719 RunAttempt: Ptr(1), 6720 Event: Ptr("e"), 6721 Status: Ptr("s"), 6722 Conclusion: Ptr("c"), 6723 WorkflowID: Ptr(int64(1)), 6724 URL: Ptr("u"), 6725 HTMLURL: Ptr("h"), 6726 PullRequests: []*PullRequest{ 6727 { 6728 URL: Ptr("u"), 6729 ID: Ptr(int64(1)), 6730 Number: Ptr(1), 6731 Head: &PullRequestBranch{ 6732 Ref: Ptr("r"), 6733 SHA: Ptr("s"), 6734 Repo: &Repository{ 6735 ID: Ptr(int64(1)), 6736 URL: Ptr("s"), 6737 Name: Ptr("n"), 6738 }, 6739 }, 6740 Base: &PullRequestBranch{ 6741 Ref: Ptr("r"), 6742 SHA: Ptr("s"), 6743 Repo: &Repository{ 6744 ID: Ptr(int64(1)), 6745 URL: Ptr("u"), 6746 Name: Ptr("n"), 6747 }, 6748 }, 6749 }, 6750 }, 6751 CreatedAt: &Timestamp{referenceTime}, 6752 UpdatedAt: &Timestamp{referenceTime}, 6753 RunStartedAt: &Timestamp{referenceTime}, 6754 JobsURL: Ptr("j"), 6755 LogsURL: Ptr("l"), 6756 CheckSuiteURL: Ptr("c"), 6757 ArtifactsURL: Ptr("a"), 6758 CancelURL: Ptr("c"), 6759 RerunURL: Ptr("r"), 6760 PreviousAttemptURL: Ptr("p"), 6761 HeadCommit: &HeadCommit{ 6762 Message: Ptr("m"), 6763 Author: &CommitAuthor{ 6764 Name: Ptr("n"), 6765 Email: Ptr("e"), 6766 Login: Ptr("l"), 6767 }, 6768 URL: Ptr("u"), 6769 Distinct: Ptr(false), 6770 SHA: Ptr("s"), 6771 ID: Ptr("i"), 6772 TreeID: Ptr("tid"), 6773 Timestamp: &Timestamp{referenceTime}, 6774 Committer: &CommitAuthor{ 6775 Name: Ptr("n"), 6776 Email: Ptr("e"), 6777 Login: Ptr("l"), 6778 }, 6779 }, 6780 WorkflowURL: Ptr("w"), 6781 Repository: &Repository{ 6782 ID: Ptr(int64(1)), 6783 URL: Ptr("u"), 6784 Name: Ptr("n"), 6785 }, 6786 HeadRepository: &Repository{ 6787 ID: Ptr(int64(1)), 6788 URL: Ptr("u"), 6789 Name: Ptr("n"), 6790 }, 6791 }, 6792 } 6793 6794 want := `{ 6795 "action": "a", 6796 "requester": { 6797 "login": "l", 6798 "id": 1, 6799 "node_id": "n", 6800 "avatar_url": "a", 6801 "url": "u", 6802 "html_url": "h", 6803 "followers_url": "f", 6804 "following_url": "f", 6805 "gists_url": "g", 6806 "starred_url": "s", 6807 "subscriptions_url": "s", 6808 "organizations_url": "o", 6809 "repos_url": "r", 6810 "events_url": "e", 6811 "received_events_url": "r", 6812 "type": "User", 6813 "site_admin": false, 6814 "name": "n", 6815 "email": "e", 6816 "gravatar_id": "g" 6817 }, 6818 "reviewers": [ 6819 { 6820 "type": "User", 6821 "reviewer": { 6822 "login": "l", 6823 "id": 1, 6824 "node_id": "n", 6825 "avatar_url": "a", 6826 "url": "u", 6827 "html_url": "h", 6828 "followers_url": "f", 6829 "following_url": "f", 6830 "gists_url": "g", 6831 "starred_url": "s", 6832 "subscriptions_url": "s", 6833 "organizations_url": "o", 6834 "repos_url": "r", 6835 "events_url": "e", 6836 "received_events_url": "r", 6837 "type": "User", 6838 "site_admin": false, 6839 "name": "n", 6840 "email": "e", 6841 "gravatar_id": "g" 6842 } 6843 }, 6844 { 6845 "type": "Team", 6846 "reviewer": { 6847 "id": 1, 6848 "name": "n", 6849 "slug": "s" 6850 } 6851 } 6852 ], 6853 "repository": { 6854 "id": 1, 6855 "name": "n", 6856 "url": "s" 6857 }, 6858 "organization": { 6859 "name": "n", 6860 "company": "c", 6861 "blog": "b", 6862 "location": "loc", 6863 "email": "e", 6864 "twitter_username": "tu", 6865 "description": "d", 6866 "billing_email": "be", 6867 "is_verified": true, 6868 "has_organization_projects": true, 6869 "has_repository_projects": true, 6870 "default_repository_permission": "drp", 6871 "members_can_create_repositories": true, 6872 "members_can_create_public_repositories": false, 6873 "members_can_create_private_repositories": true, 6874 "members_can_create_internal_repositories": true, 6875 "members_allowed_repository_creation_type": "marct", 6876 "members_can_create_pages": true, 6877 "members_can_create_public_pages": false, 6878 "members_can_create_private_pages": true 6879 }, 6880 "environment": "e", 6881 "enterprise": { 6882 "id": 1, 6883 "slug": "s", 6884 "name": "n", 6885 "node_id": "nid", 6886 "avatar_url": "au", 6887 "description": "d", 6888 "website_url": "wu", 6889 "html_url": "hu", 6890 "created_at": ` + referenceTimeStr + `, 6891 "updated_at": ` + referenceTimeStr + ` 6892 }, 6893 "sender": { 6894 "login": "l", 6895 "id": 1, 6896 "node_id": "n", 6897 "avatar_url": "a", 6898 "url": "u", 6899 "events_url": "e", 6900 "repos_url": "r" 6901 }, 6902 "installation": { 6903 "id": 1, 6904 "node_id": "nid", 6905 "app_id": 1, 6906 "app_slug": "as", 6907 "target_id": 1, 6908 "account": { 6909 "login": "l", 6910 "id": 1, 6911 "avatar_url": "a", 6912 "gravatar_id": "g", 6913 "name": "n", 6914 "company": "c", 6915 "blog": "b", 6916 "location": "l", 6917 "email": "e", 6918 "hireable": true, 6919 "bio": "b", 6920 "twitter_username": "t", 6921 "public_repos": 1, 6922 "followers": 1, 6923 "following": 1, 6924 "created_at": ` + referenceTimeStr + `, 6925 "suspended_at": ` + referenceTimeStr + `, 6926 "url": "u" 6927 }, 6928 "access_tokens_url": "atu", 6929 "repositories_url": "ru", 6930 "html_url": "hu", 6931 "target_type": "tt", 6932 "single_file_name": "sfn", 6933 "repository_selection": "rs", 6934 "events": [ 6935 "e" 6936 ], 6937 "single_file_paths": [ 6938 "s" 6939 ], 6940 "permissions": { 6941 "actions": "a", 6942 "administration": "ad", 6943 "checks": "c", 6944 "contents": "co", 6945 "content_references": "cr", 6946 "deployments": "d", 6947 "environments": "e", 6948 "issues": "i", 6949 "metadata": "md", 6950 "members": "m", 6951 "organization_administration": "oa", 6952 "organization_hooks": "oh", 6953 "organization_plan": "op", 6954 "organization_pre_receive_hooks": "opr", 6955 "organization_projects": "op", 6956 "organization_secrets": "os", 6957 "organization_self_hosted_runners": "osh", 6958 "organization_user_blocking": "oub", 6959 "packages": "pkg", 6960 "pages": "pg", 6961 "pull_requests": "pr", 6962 "repository_hooks": "rh", 6963 "repository_projects": "rp", 6964 "repository_pre_receive_hooks": "rprh", 6965 "secrets": "s", 6966 "secret_scanning_alerts": "ssa", 6967 "security_events": "se", 6968 "single_file": "sf", 6969 "statuses": "s", 6970 "team_discussions": "td", 6971 "vulnerability_alerts": "va", 6972 "workflows": "w" 6973 }, 6974 "created_at": ` + referenceTimeStr + `, 6975 "updated_at": ` + referenceTimeStr + `, 6976 "has_multiple_single_files": false, 6977 "suspended_by": { 6978 "login": "l", 6979 "id": 1, 6980 "avatar_url": "a", 6981 "gravatar_id": "g", 6982 "name": "n", 6983 "company": "c", 6984 "blog": "b", 6985 "location": "l", 6986 "email": "e", 6987 "hireable": true, 6988 "bio": "b", 6989 "twitter_username": "t", 6990 "public_repos": 1, 6991 "followers": 1, 6992 "following": 1, 6993 "created_at": ` + referenceTimeStr + `, 6994 "suspended_at": ` + referenceTimeStr + `, 6995 "url": "u" 6996 }, 6997 "suspended_at": ` + referenceTimeStr + ` 6998 }, 6999 "since": "s", 7000 "workflow_job_run": { 7001 "conclusion": "c", 7002 "created_at": "2006-01-02T15:04:05Z", 7003 "environment": "e", 7004 "html_url": "h", 7005 "id": 1, 7006 "name": "n", 7007 "status": "s", 7008 "updated_at": "2006-01-02T15:04:05Z" 7009 }, 7010 "workflow_run": { 7011 "id": 1, 7012 "name": "n", 7013 "node_id": "nid", 7014 "head_branch": "hb", 7015 "head_sha": "hs", 7016 "run_number": 1, 7017 "run_attempt": 1, 7018 "event": "e", 7019 "status": "s", 7020 "conclusion": "c", 7021 "workflow_id": 1, 7022 "url": "u", 7023 "html_url": "h", 7024 "pull_requests": [ 7025 { 7026 "id": 1, 7027 "number": 1, 7028 "url": "u", 7029 "head": { 7030 "ref": "r", 7031 "sha": "s", 7032 "repo": { 7033 "id": 1, 7034 "name": "n", 7035 "url": "s" 7036 } 7037 }, 7038 "base": { 7039 "ref": "r", 7040 "sha": "s", 7041 "repo": { 7042 "id": 1, 7043 "name": "n", 7044 "url": "u" 7045 } 7046 } 7047 } 7048 ], 7049 "created_at": ` + referenceTimeStr + `, 7050 "updated_at": ` + referenceTimeStr + `, 7051 "run_started_at": ` + referenceTimeStr + `, 7052 "jobs_url": "j", 7053 "logs_url": "l", 7054 "check_suite_url": "c", 7055 "artifacts_url": "a", 7056 "cancel_url": "c", 7057 "rerun_url": "r", 7058 "previous_attempt_url": "p", 7059 "head_commit": { 7060 "message": "m", 7061 "author": { 7062 "name": "n", 7063 "email": "e", 7064 "username": "l" 7065 }, 7066 "url": "u", 7067 "distinct": false, 7068 "sha": "s", 7069 "id": "i", 7070 "tree_id": "tid", 7071 "timestamp": ` + referenceTimeStr + `, 7072 "committer": { 7073 "name": "n", 7074 "email": "e", 7075 "username": "l" 7076 } 7077 }, 7078 "workflow_url": "w", 7079 "repository": { 7080 "id": 1, 7081 "name": "n", 7082 "url": "u" 7083 }, 7084 "head_repository": { 7085 "id": 1, 7086 "name": "n", 7087 "url": "u" 7088 } 7089 } 7090 }` 7091 7092 testJSONMarshal(t, u, want) 7093 } 7094 7095 func TestDeploymentStatusEvent_Marshal(t *testing.T) { 7096 t.Parallel() 7097 testJSONMarshal(t, &DeploymentStatusEvent{}, "{}") 7098 7099 l := make(map[string]interface{}) 7100 l["key"] = "value" 7101 7102 jsonMsg, _ := json.Marshal(&l) 7103 7104 u := &DeploymentStatusEvent{ 7105 Deployment: &Deployment{ 7106 URL: Ptr("url"), 7107 ID: Ptr(int64(1)), 7108 SHA: Ptr("sha"), 7109 Ref: Ptr("ref"), 7110 Task: Ptr("t"), 7111 Payload: jsonMsg, 7112 Environment: Ptr("e"), 7113 Description: Ptr("d"), 7114 Creator: &User{ 7115 Login: Ptr("l"), 7116 ID: Ptr(int64(1)), 7117 NodeID: Ptr("n"), 7118 URL: Ptr("u"), 7119 ReposURL: Ptr("r"), 7120 EventsURL: Ptr("e"), 7121 AvatarURL: Ptr("a"), 7122 }, 7123 CreatedAt: &Timestamp{referenceTime}, 7124 UpdatedAt: &Timestamp{referenceTime}, 7125 StatusesURL: Ptr("surl"), 7126 RepositoryURL: Ptr("rurl"), 7127 NodeID: Ptr("nid"), 7128 }, 7129 DeploymentStatus: &DeploymentStatus{ 7130 ID: Ptr(int64(1)), 7131 State: Ptr("s"), 7132 Creator: &User{ 7133 Login: Ptr("l"), 7134 ID: Ptr(int64(1)), 7135 NodeID: Ptr("n"), 7136 URL: Ptr("u"), 7137 ReposURL: Ptr("r"), 7138 EventsURL: Ptr("e"), 7139 AvatarURL: Ptr("a"), 7140 }, 7141 Description: Ptr("s"), 7142 Environment: Ptr("s"), 7143 NodeID: Ptr("s"), 7144 CreatedAt: &Timestamp{referenceTime}, 7145 UpdatedAt: &Timestamp{referenceTime}, 7146 TargetURL: Ptr("s"), 7147 DeploymentURL: Ptr("s"), 7148 RepositoryURL: Ptr("s"), 7149 EnvironmentURL: Ptr("s"), 7150 LogURL: Ptr("s"), 7151 URL: Ptr("s"), 7152 }, 7153 Repo: &Repository{ 7154 ID: Ptr(int64(1)), 7155 URL: Ptr("s"), 7156 Name: Ptr("n"), 7157 }, 7158 Sender: &User{ 7159 Login: Ptr("l"), 7160 ID: Ptr(int64(1)), 7161 NodeID: Ptr("n"), 7162 URL: Ptr("u"), 7163 ReposURL: Ptr("r"), 7164 EventsURL: Ptr("e"), 7165 AvatarURL: Ptr("a"), 7166 }, 7167 Installation: &Installation{ 7168 ID: Ptr(int64(1)), 7169 NodeID: Ptr("nid"), 7170 AppID: Ptr(int64(1)), 7171 AppSlug: Ptr("as"), 7172 TargetID: Ptr(int64(1)), 7173 Account: &User{ 7174 Login: Ptr("l"), 7175 ID: Ptr(int64(1)), 7176 URL: Ptr("u"), 7177 AvatarURL: Ptr("a"), 7178 GravatarID: Ptr("g"), 7179 Name: Ptr("n"), 7180 Company: Ptr("c"), 7181 Blog: Ptr("b"), 7182 Location: Ptr("l"), 7183 Email: Ptr("e"), 7184 Hireable: Ptr(true), 7185 Bio: Ptr("b"), 7186 TwitterUsername: Ptr("t"), 7187 PublicRepos: Ptr(1), 7188 Followers: Ptr(1), 7189 Following: Ptr(1), 7190 CreatedAt: &Timestamp{referenceTime}, 7191 SuspendedAt: &Timestamp{referenceTime}, 7192 }, 7193 AccessTokensURL: Ptr("atu"), 7194 RepositoriesURL: Ptr("ru"), 7195 HTMLURL: Ptr("hu"), 7196 TargetType: Ptr("tt"), 7197 SingleFileName: Ptr("sfn"), 7198 RepositorySelection: Ptr("rs"), 7199 Events: []string{"e"}, 7200 SingleFilePaths: []string{"s"}, 7201 Permissions: &InstallationPermissions{ 7202 Actions: Ptr("a"), 7203 Administration: Ptr("ad"), 7204 Checks: Ptr("c"), 7205 Contents: Ptr("co"), 7206 ContentReferences: Ptr("cr"), 7207 Deployments: Ptr("d"), 7208 Environments: Ptr("e"), 7209 Issues: Ptr("i"), 7210 Metadata: Ptr("md"), 7211 Members: Ptr("m"), 7212 OrganizationAdministration: Ptr("oa"), 7213 OrganizationHooks: Ptr("oh"), 7214 OrganizationPlan: Ptr("op"), 7215 OrganizationPreReceiveHooks: Ptr("opr"), 7216 OrganizationProjects: Ptr("op"), 7217 OrganizationSecrets: Ptr("os"), 7218 OrganizationSelfHostedRunners: Ptr("osh"), 7219 OrganizationUserBlocking: Ptr("oub"), 7220 Packages: Ptr("pkg"), 7221 Pages: Ptr("pg"), 7222 PullRequests: Ptr("pr"), 7223 RepositoryHooks: Ptr("rh"), 7224 RepositoryProjects: Ptr("rp"), 7225 RepositoryPreReceiveHooks: Ptr("rprh"), 7226 Secrets: Ptr("s"), 7227 SecretScanningAlerts: Ptr("ssa"), 7228 SecurityEvents: Ptr("se"), 7229 SingleFile: Ptr("sf"), 7230 Statuses: Ptr("s"), 7231 TeamDiscussions: Ptr("td"), 7232 VulnerabilityAlerts: Ptr("va"), 7233 Workflows: Ptr("w"), 7234 }, 7235 CreatedAt: &Timestamp{referenceTime}, 7236 UpdatedAt: &Timestamp{referenceTime}, 7237 HasMultipleSingleFiles: Ptr(false), 7238 SuspendedBy: &User{ 7239 Login: Ptr("l"), 7240 ID: Ptr(int64(1)), 7241 URL: Ptr("u"), 7242 AvatarURL: Ptr("a"), 7243 GravatarID: Ptr("g"), 7244 Name: Ptr("n"), 7245 Company: Ptr("c"), 7246 Blog: Ptr("b"), 7247 Location: Ptr("l"), 7248 Email: Ptr("e"), 7249 Hireable: Ptr(true), 7250 Bio: Ptr("b"), 7251 TwitterUsername: Ptr("t"), 7252 PublicRepos: Ptr(1), 7253 Followers: Ptr(1), 7254 Following: Ptr(1), 7255 CreatedAt: &Timestamp{referenceTime}, 7256 SuspendedAt: &Timestamp{referenceTime}, 7257 }, 7258 SuspendedAt: &Timestamp{referenceTime}, 7259 }, 7260 } 7261 7262 want := `{ 7263 "deployment": { 7264 "url": "url", 7265 "id": 1, 7266 "sha": "sha", 7267 "ref": "ref", 7268 "task": "t", 7269 "payload": { 7270 "key": "value" 7271 }, 7272 "environment": "e", 7273 "description": "d", 7274 "creator": { 7275 "login": "l", 7276 "id": 1, 7277 "node_id": "n", 7278 "avatar_url": "a", 7279 "url": "u", 7280 "events_url": "e", 7281 "repos_url": "r" 7282 }, 7283 "created_at": ` + referenceTimeStr + `, 7284 "updated_at": ` + referenceTimeStr + `, 7285 "statuses_url": "surl", 7286 "repository_url": "rurl", 7287 "node_id": "nid" 7288 }, 7289 "deployment_status": { 7290 "id": 1, 7291 "state": "s", 7292 "creator": { 7293 "login": "l", 7294 "id": 1, 7295 "node_id": "n", 7296 "avatar_url": "a", 7297 "url": "u", 7298 "events_url": "e", 7299 "repos_url": "r" 7300 }, 7301 "description": "s", 7302 "environment": "s", 7303 "node_id": "s", 7304 "created_at": ` + referenceTimeStr + `, 7305 "updated_at": ` + referenceTimeStr + `, 7306 "target_url": "s", 7307 "deployment_url": "s", 7308 "repository_url": "s", 7309 "environment_url": "s", 7310 "log_url": "s", 7311 "url": "s" 7312 }, 7313 "repository": { 7314 "id": 1, 7315 "name": "n", 7316 "url": "s" 7317 }, 7318 "sender": { 7319 "login": "l", 7320 "id": 1, 7321 "node_id": "n", 7322 "avatar_url": "a", 7323 "url": "u", 7324 "events_url": "e", 7325 "repos_url": "r" 7326 }, 7327 "installation": { 7328 "id": 1, 7329 "node_id": "nid", 7330 "app_id": 1, 7331 "app_slug": "as", 7332 "target_id": 1, 7333 "account": { 7334 "login": "l", 7335 "id": 1, 7336 "avatar_url": "a", 7337 "gravatar_id": "g", 7338 "name": "n", 7339 "company": "c", 7340 "blog": "b", 7341 "location": "l", 7342 "email": "e", 7343 "hireable": true, 7344 "bio": "b", 7345 "twitter_username": "t", 7346 "public_repos": 1, 7347 "followers": 1, 7348 "following": 1, 7349 "created_at": ` + referenceTimeStr + `, 7350 "suspended_at": ` + referenceTimeStr + `, 7351 "url": "u" 7352 }, 7353 "access_tokens_url": "atu", 7354 "repositories_url": "ru", 7355 "html_url": "hu", 7356 "target_type": "tt", 7357 "single_file_name": "sfn", 7358 "repository_selection": "rs", 7359 "events": [ 7360 "e" 7361 ], 7362 "single_file_paths": [ 7363 "s" 7364 ], 7365 "permissions": { 7366 "actions": "a", 7367 "administration": "ad", 7368 "checks": "c", 7369 "contents": "co", 7370 "content_references": "cr", 7371 "deployments": "d", 7372 "environments": "e", 7373 "issues": "i", 7374 "metadata": "md", 7375 "members": "m", 7376 "organization_administration": "oa", 7377 "organization_hooks": "oh", 7378 "organization_plan": "op", 7379 "organization_pre_receive_hooks": "opr", 7380 "organization_projects": "op", 7381 "organization_secrets": "os", 7382 "organization_self_hosted_runners": "osh", 7383 "organization_user_blocking": "oub", 7384 "packages": "pkg", 7385 "pages": "pg", 7386 "pull_requests": "pr", 7387 "repository_hooks": "rh", 7388 "repository_projects": "rp", 7389 "repository_pre_receive_hooks": "rprh", 7390 "secrets": "s", 7391 "secret_scanning_alerts": "ssa", 7392 "security_events": "se", 7393 "single_file": "sf", 7394 "statuses": "s", 7395 "team_discussions": "td", 7396 "vulnerability_alerts": "va", 7397 "workflows": "w" 7398 }, 7399 "created_at": ` + referenceTimeStr + `, 7400 "updated_at": ` + referenceTimeStr + `, 7401 "has_multiple_single_files": false, 7402 "suspended_by": { 7403 "login": "l", 7404 "id": 1, 7405 "avatar_url": "a", 7406 "gravatar_id": "g", 7407 "name": "n", 7408 "company": "c", 7409 "blog": "b", 7410 "location": "l", 7411 "email": "e", 7412 "hireable": true, 7413 "bio": "b", 7414 "twitter_username": "t", 7415 "public_repos": 1, 7416 "followers": 1, 7417 "following": 1, 7418 "created_at": ` + referenceTimeStr + `, 7419 "suspended_at": ` + referenceTimeStr + `, 7420 "url": "u" 7421 }, 7422 "suspended_at": ` + referenceTimeStr + ` 7423 } 7424 }` 7425 7426 testJSONMarshal(t, u, want) 7427 } 7428 7429 func TestDiscussionCommentEvent_Marshal(t *testing.T) { 7430 t.Parallel() 7431 testJSONMarshal(t, &DiscussionCommentEvent{}, "{}") 7432 7433 u := &DiscussionCommentEvent{ 7434 Comment: &CommentDiscussion{ 7435 AuthorAssociation: Ptr("aa"), 7436 Body: Ptr("bo"), 7437 ChildCommentCount: Ptr(1), 7438 CreatedAt: &Timestamp{referenceTime}, 7439 DiscussionID: Ptr(int64(1)), 7440 HTMLURL: Ptr("hurl"), 7441 ID: Ptr(int64(1)), 7442 NodeID: Ptr("nid"), 7443 ParentID: Ptr(int64(1)), 7444 Reactions: &Reactions{ 7445 TotalCount: Ptr(1), 7446 PlusOne: Ptr(1), 7447 MinusOne: Ptr(1), 7448 Laugh: Ptr(1), 7449 Confused: Ptr(1), 7450 Heart: Ptr(1), 7451 Hooray: Ptr(1), 7452 Rocket: Ptr(1), 7453 Eyes: Ptr(1), 7454 URL: Ptr("url"), 7455 }, 7456 RepositoryURL: Ptr("rurl"), 7457 UpdatedAt: &Timestamp{referenceTime}, 7458 User: &User{ 7459 Login: Ptr("l"), 7460 ID: Ptr(int64(1)), 7461 NodeID: Ptr("n"), 7462 URL: Ptr("u"), 7463 ReposURL: Ptr("r"), 7464 EventsURL: Ptr("e"), 7465 AvatarURL: Ptr("a"), 7466 }, 7467 }, 7468 Discussion: &Discussion{ 7469 RepositoryURL: Ptr("rurl"), 7470 DiscussionCategory: &DiscussionCategory{ 7471 ID: Ptr(int64(1)), 7472 NodeID: Ptr("nid"), 7473 RepositoryID: Ptr(int64(1)), 7474 Emoji: Ptr("emoji"), 7475 Name: Ptr("name"), 7476 Description: Ptr("description"), 7477 CreatedAt: &Timestamp{referenceTime}, 7478 UpdatedAt: &Timestamp{referenceTime}, 7479 Slug: Ptr("slug"), 7480 IsAnswerable: Ptr(false), 7481 }, 7482 HTMLURL: Ptr("hurl"), 7483 ID: Ptr(int64(1)), 7484 NodeID: Ptr("nurl"), 7485 Number: Ptr(1), 7486 Title: Ptr("title"), 7487 User: &User{ 7488 Login: Ptr("l"), 7489 ID: Ptr(int64(1)), 7490 NodeID: Ptr("n"), 7491 URL: Ptr("u"), 7492 ReposURL: Ptr("r"), 7493 EventsURL: Ptr("e"), 7494 AvatarURL: Ptr("a"), 7495 }, 7496 State: Ptr("st"), 7497 Locked: Ptr(false), 7498 Comments: Ptr(1), 7499 CreatedAt: &Timestamp{referenceTime}, 7500 UpdatedAt: &Timestamp{referenceTime}, 7501 AuthorAssociation: Ptr("aa"), 7502 Body: Ptr("bo"), 7503 }, 7504 Repo: &Repository{ 7505 ID: Ptr(int64(1)), 7506 URL: Ptr("s"), 7507 Name: Ptr("n"), 7508 }, 7509 Org: &Organization{ 7510 BillingEmail: Ptr("be"), 7511 Blog: Ptr("b"), 7512 Company: Ptr("c"), 7513 Email: Ptr("e"), 7514 TwitterUsername: Ptr("tu"), 7515 Location: Ptr("loc"), 7516 Name: Ptr("n"), 7517 Description: Ptr("d"), 7518 IsVerified: Ptr(true), 7519 HasOrganizationProjects: Ptr(true), 7520 HasRepositoryProjects: Ptr(true), 7521 DefaultRepoPermission: Ptr("drp"), 7522 MembersCanCreateRepos: Ptr(true), 7523 MembersCanCreateInternalRepos: Ptr(true), 7524 MembersCanCreatePrivateRepos: Ptr(true), 7525 MembersCanCreatePublicRepos: Ptr(false), 7526 MembersAllowedRepositoryCreationType: Ptr("marct"), 7527 MembersCanCreatePages: Ptr(true), 7528 MembersCanCreatePublicPages: Ptr(false), 7529 MembersCanCreatePrivatePages: Ptr(true), 7530 }, 7531 Sender: &User{ 7532 Login: Ptr("l"), 7533 ID: Ptr(int64(1)), 7534 NodeID: Ptr("n"), 7535 URL: Ptr("u"), 7536 ReposURL: Ptr("r"), 7537 EventsURL: Ptr("e"), 7538 AvatarURL: Ptr("a"), 7539 }, 7540 Installation: &Installation{ 7541 ID: Ptr(int64(1)), 7542 NodeID: Ptr("nid"), 7543 AppID: Ptr(int64(1)), 7544 AppSlug: Ptr("as"), 7545 TargetID: Ptr(int64(1)), 7546 Account: &User{ 7547 Login: Ptr("l"), 7548 ID: Ptr(int64(1)), 7549 URL: Ptr("u"), 7550 AvatarURL: Ptr("a"), 7551 GravatarID: Ptr("g"), 7552 Name: Ptr("n"), 7553 Company: Ptr("c"), 7554 Blog: Ptr("b"), 7555 Location: Ptr("l"), 7556 Email: Ptr("e"), 7557 Hireable: Ptr(true), 7558 Bio: Ptr("b"), 7559 TwitterUsername: Ptr("t"), 7560 PublicRepos: Ptr(1), 7561 Followers: Ptr(1), 7562 Following: Ptr(1), 7563 CreatedAt: &Timestamp{referenceTime}, 7564 SuspendedAt: &Timestamp{referenceTime}, 7565 }, 7566 AccessTokensURL: Ptr("atu"), 7567 RepositoriesURL: Ptr("ru"), 7568 HTMLURL: Ptr("hu"), 7569 TargetType: Ptr("tt"), 7570 SingleFileName: Ptr("sfn"), 7571 RepositorySelection: Ptr("rs"), 7572 Events: []string{"e"}, 7573 SingleFilePaths: []string{"s"}, 7574 Permissions: &InstallationPermissions{ 7575 Actions: Ptr("a"), 7576 Administration: Ptr("ad"), 7577 Checks: Ptr("c"), 7578 Contents: Ptr("co"), 7579 ContentReferences: Ptr("cr"), 7580 Deployments: Ptr("d"), 7581 Environments: Ptr("e"), 7582 Issues: Ptr("i"), 7583 Metadata: Ptr("md"), 7584 Members: Ptr("m"), 7585 OrganizationAdministration: Ptr("oa"), 7586 OrganizationHooks: Ptr("oh"), 7587 OrganizationPlan: Ptr("op"), 7588 OrganizationPreReceiveHooks: Ptr("opr"), 7589 OrganizationProjects: Ptr("op"), 7590 OrganizationSecrets: Ptr("os"), 7591 OrganizationSelfHostedRunners: Ptr("osh"), 7592 OrganizationUserBlocking: Ptr("oub"), 7593 Packages: Ptr("pkg"), 7594 Pages: Ptr("pg"), 7595 PullRequests: Ptr("pr"), 7596 RepositoryHooks: Ptr("rh"), 7597 RepositoryProjects: Ptr("rp"), 7598 RepositoryPreReceiveHooks: Ptr("rprh"), 7599 Secrets: Ptr("s"), 7600 SecretScanningAlerts: Ptr("ssa"), 7601 SecurityEvents: Ptr("se"), 7602 SingleFile: Ptr("sf"), 7603 Statuses: Ptr("s"), 7604 TeamDiscussions: Ptr("td"), 7605 VulnerabilityAlerts: Ptr("va"), 7606 Workflows: Ptr("w"), 7607 }, 7608 CreatedAt: &Timestamp{referenceTime}, 7609 UpdatedAt: &Timestamp{referenceTime}, 7610 HasMultipleSingleFiles: Ptr(false), 7611 SuspendedBy: &User{ 7612 Login: Ptr("l"), 7613 ID: Ptr(int64(1)), 7614 URL: Ptr("u"), 7615 AvatarURL: Ptr("a"), 7616 GravatarID: Ptr("g"), 7617 Name: Ptr("n"), 7618 Company: Ptr("c"), 7619 Blog: Ptr("b"), 7620 Location: Ptr("l"), 7621 Email: Ptr("e"), 7622 Hireable: Ptr(true), 7623 Bio: Ptr("b"), 7624 TwitterUsername: Ptr("t"), 7625 PublicRepos: Ptr(1), 7626 Followers: Ptr(1), 7627 Following: Ptr(1), 7628 CreatedAt: &Timestamp{referenceTime}, 7629 SuspendedAt: &Timestamp{referenceTime}, 7630 }, 7631 SuspendedAt: &Timestamp{referenceTime}, 7632 }, 7633 } 7634 7635 want := `{ 7636 "comment": { 7637 "author_association": "aa", 7638 "body": "bo", 7639 "child_comment_count": 1, 7640 "created_at": ` + referenceTimeStr + `, 7641 "discussion_id": 1, 7642 "html_url": "hurl", 7643 "id": 1, 7644 "node_id": "nid", 7645 "parent_id": 1, 7646 "reactions": { 7647 "total_count": 1, 7648 "+1": 1, 7649 "-1": 1, 7650 "laugh": 1, 7651 "confused": 1, 7652 "heart": 1, 7653 "hooray": 1, 7654 "rocket": 1, 7655 "eyes": 1, 7656 "url": "url" 7657 }, 7658 "repository_url": "rurl", 7659 "updated_at": ` + referenceTimeStr + `, 7660 "user": { 7661 "login": "l", 7662 "id": 1, 7663 "node_id": "n", 7664 "avatar_url": "a", 7665 "url": "u", 7666 "events_url": "e", 7667 "repos_url": "r" 7668 } 7669 }, 7670 "discussion": { 7671 "repository_url": "rurl", 7672 "category": { 7673 "id": 1, 7674 "node_id": "nid", 7675 "repository_id": 1, 7676 "emoji": "emoji", 7677 "name": "name", 7678 "description": "description", 7679 "created_at": ` + referenceTimeStr + `, 7680 "updated_at": ` + referenceTimeStr + `, 7681 "slug": "slug", 7682 "is_answerable": false 7683 }, 7684 "html_url": "hurl", 7685 "id": 1, 7686 "node_id": "nurl", 7687 "number": 1, 7688 "title": "title", 7689 "user": { 7690 "login": "l", 7691 "id": 1, 7692 "node_id": "n", 7693 "avatar_url": "a", 7694 "url": "u", 7695 "events_url": "e", 7696 "repos_url": "r" 7697 }, 7698 "state": "st", 7699 "locked": false, 7700 "comments": 1, 7701 "created_at": ` + referenceTimeStr + `, 7702 "updated_at": ` + referenceTimeStr + `, 7703 "author_association": "aa", 7704 "body": "bo" 7705 }, 7706 "repository": { 7707 "id": 1, 7708 "name": "n", 7709 "url": "s" 7710 }, 7711 "organization": { 7712 "name": "n", 7713 "company": "c", 7714 "blog": "b", 7715 "location": "loc", 7716 "email": "e", 7717 "twitter_username": "tu", 7718 "description": "d", 7719 "billing_email": "be", 7720 "is_verified": true, 7721 "has_organization_projects": true, 7722 "has_repository_projects": true, 7723 "default_repository_permission": "drp", 7724 "members_can_create_repositories": true, 7725 "members_can_create_public_repositories": false, 7726 "members_can_create_private_repositories": true, 7727 "members_can_create_internal_repositories": true, 7728 "members_allowed_repository_creation_type": "marct", 7729 "members_can_create_pages": true, 7730 "members_can_create_public_pages": false, 7731 "members_can_create_private_pages": true 7732 }, 7733 "sender": { 7734 "login": "l", 7735 "id": 1, 7736 "node_id": "n", 7737 "avatar_url": "a", 7738 "url": "u", 7739 "events_url": "e", 7740 "repos_url": "r" 7741 }, 7742 "installation": { 7743 "id": 1, 7744 "node_id": "nid", 7745 "app_id": 1, 7746 "app_slug": "as", 7747 "target_id": 1, 7748 "account": { 7749 "login": "l", 7750 "id": 1, 7751 "avatar_url": "a", 7752 "gravatar_id": "g", 7753 "name": "n", 7754 "company": "c", 7755 "blog": "b", 7756 "location": "l", 7757 "email": "e", 7758 "hireable": true, 7759 "bio": "b", 7760 "twitter_username": "t", 7761 "public_repos": 1, 7762 "followers": 1, 7763 "following": 1, 7764 "created_at": ` + referenceTimeStr + `, 7765 "suspended_at": ` + referenceTimeStr + `, 7766 "url": "u" 7767 }, 7768 "access_tokens_url": "atu", 7769 "repositories_url": "ru", 7770 "html_url": "hu", 7771 "target_type": "tt", 7772 "single_file_name": "sfn", 7773 "repository_selection": "rs", 7774 "events": [ 7775 "e" 7776 ], 7777 "single_file_paths": [ 7778 "s" 7779 ], 7780 "permissions": { 7781 "actions": "a", 7782 "administration": "ad", 7783 "checks": "c", 7784 "contents": "co", 7785 "content_references": "cr", 7786 "deployments": "d", 7787 "environments": "e", 7788 "issues": "i", 7789 "metadata": "md", 7790 "members": "m", 7791 "organization_administration": "oa", 7792 "organization_hooks": "oh", 7793 "organization_plan": "op", 7794 "organization_pre_receive_hooks": "opr", 7795 "organization_projects": "op", 7796 "organization_secrets": "os", 7797 "organization_self_hosted_runners": "osh", 7798 "organization_user_blocking": "oub", 7799 "packages": "pkg", 7800 "pages": "pg", 7801 "pull_requests": "pr", 7802 "repository_hooks": "rh", 7803 "repository_projects": "rp", 7804 "repository_pre_receive_hooks": "rprh", 7805 "secrets": "s", 7806 "secret_scanning_alerts": "ssa", 7807 "security_events": "se", 7808 "single_file": "sf", 7809 "statuses": "s", 7810 "team_discussions": "td", 7811 "vulnerability_alerts": "va", 7812 "workflows": "w" 7813 }, 7814 "created_at": ` + referenceTimeStr + `, 7815 "updated_at": ` + referenceTimeStr + `, 7816 "has_multiple_single_files": false, 7817 "suspended_by": { 7818 "login": "l", 7819 "id": 1, 7820 "avatar_url": "a", 7821 "gravatar_id": "g", 7822 "name": "n", 7823 "company": "c", 7824 "blog": "b", 7825 "location": "l", 7826 "email": "e", 7827 "hireable": true, 7828 "bio": "b", 7829 "twitter_username": "t", 7830 "public_repos": 1, 7831 "followers": 1, 7832 "following": 1, 7833 "created_at": ` + referenceTimeStr + `, 7834 "suspended_at": ` + referenceTimeStr + `, 7835 "url": "u" 7836 }, 7837 "suspended_at": ` + referenceTimeStr + ` 7838 } 7839 }` 7840 7841 testJSONMarshal(t, u, want) 7842 } 7843 7844 func TestDiscussionEvent_Marshal(t *testing.T) { 7845 t.Parallel() 7846 testJSONMarshal(t, &DiscussionEvent{}, "{}") 7847 7848 u := &DiscussionEvent{ 7849 Discussion: &Discussion{ 7850 RepositoryURL: Ptr("rurl"), 7851 DiscussionCategory: &DiscussionCategory{ 7852 ID: Ptr(int64(1)), 7853 NodeID: Ptr("nid"), 7854 RepositoryID: Ptr(int64(1)), 7855 Emoji: Ptr("emoji"), 7856 Name: Ptr("name"), 7857 Description: Ptr("description"), 7858 CreatedAt: &Timestamp{referenceTime}, 7859 UpdatedAt: &Timestamp{referenceTime}, 7860 Slug: Ptr("slug"), 7861 IsAnswerable: Ptr(false), 7862 }, 7863 HTMLURL: Ptr("hurl"), 7864 ID: Ptr(int64(1)), 7865 NodeID: Ptr("nurl"), 7866 Number: Ptr(1), 7867 Title: Ptr("title"), 7868 User: &User{ 7869 Login: Ptr("l"), 7870 ID: Ptr(int64(1)), 7871 NodeID: Ptr("n"), 7872 URL: Ptr("u"), 7873 ReposURL: Ptr("r"), 7874 EventsURL: Ptr("e"), 7875 AvatarURL: Ptr("a"), 7876 }, 7877 State: Ptr("st"), 7878 Locked: Ptr(false), 7879 Comments: Ptr(1), 7880 CreatedAt: &Timestamp{referenceTime}, 7881 UpdatedAt: &Timestamp{referenceTime}, 7882 AuthorAssociation: Ptr("aa"), 7883 Body: Ptr("bo"), 7884 }, 7885 Repo: &Repository{ 7886 ID: Ptr(int64(1)), 7887 URL: Ptr("s"), 7888 Name: Ptr("n"), 7889 }, 7890 Org: &Organization{ 7891 BillingEmail: Ptr("be"), 7892 Blog: Ptr("b"), 7893 Company: Ptr("c"), 7894 Email: Ptr("e"), 7895 TwitterUsername: Ptr("tu"), 7896 Location: Ptr("loc"), 7897 Name: Ptr("n"), 7898 Description: Ptr("d"), 7899 IsVerified: Ptr(true), 7900 HasOrganizationProjects: Ptr(true), 7901 HasRepositoryProjects: Ptr(true), 7902 DefaultRepoPermission: Ptr("drp"), 7903 MembersCanCreateRepos: Ptr(true), 7904 MembersCanCreateInternalRepos: Ptr(true), 7905 MembersCanCreatePrivateRepos: Ptr(true), 7906 MembersCanCreatePublicRepos: Ptr(false), 7907 MembersAllowedRepositoryCreationType: Ptr("marct"), 7908 MembersCanCreatePages: Ptr(true), 7909 MembersCanCreatePublicPages: Ptr(false), 7910 MembersCanCreatePrivatePages: Ptr(true), 7911 }, 7912 Sender: &User{ 7913 Login: Ptr("l"), 7914 ID: Ptr(int64(1)), 7915 NodeID: Ptr("n"), 7916 URL: Ptr("u"), 7917 ReposURL: Ptr("r"), 7918 EventsURL: Ptr("e"), 7919 AvatarURL: Ptr("a"), 7920 }, 7921 Installation: &Installation{ 7922 ID: Ptr(int64(1)), 7923 NodeID: Ptr("nid"), 7924 AppID: Ptr(int64(1)), 7925 AppSlug: Ptr("as"), 7926 TargetID: Ptr(int64(1)), 7927 Account: &User{ 7928 Login: Ptr("l"), 7929 ID: Ptr(int64(1)), 7930 URL: Ptr("u"), 7931 AvatarURL: Ptr("a"), 7932 GravatarID: Ptr("g"), 7933 Name: Ptr("n"), 7934 Company: Ptr("c"), 7935 Blog: Ptr("b"), 7936 Location: Ptr("l"), 7937 Email: Ptr("e"), 7938 Hireable: Ptr(true), 7939 Bio: Ptr("b"), 7940 TwitterUsername: Ptr("t"), 7941 PublicRepos: Ptr(1), 7942 Followers: Ptr(1), 7943 Following: Ptr(1), 7944 CreatedAt: &Timestamp{referenceTime}, 7945 SuspendedAt: &Timestamp{referenceTime}, 7946 }, 7947 AccessTokensURL: Ptr("atu"), 7948 RepositoriesURL: Ptr("ru"), 7949 HTMLURL: Ptr("hu"), 7950 TargetType: Ptr("tt"), 7951 SingleFileName: Ptr("sfn"), 7952 RepositorySelection: Ptr("rs"), 7953 Events: []string{"e"}, 7954 SingleFilePaths: []string{"s"}, 7955 Permissions: &InstallationPermissions{ 7956 Actions: Ptr("a"), 7957 Administration: Ptr("ad"), 7958 Checks: Ptr("c"), 7959 Contents: Ptr("co"), 7960 ContentReferences: Ptr("cr"), 7961 Deployments: Ptr("d"), 7962 Environments: Ptr("e"), 7963 Issues: Ptr("i"), 7964 Metadata: Ptr("md"), 7965 Members: Ptr("m"), 7966 OrganizationAdministration: Ptr("oa"), 7967 OrganizationHooks: Ptr("oh"), 7968 OrganizationPlan: Ptr("op"), 7969 OrganizationPreReceiveHooks: Ptr("opr"), 7970 OrganizationProjects: Ptr("op"), 7971 OrganizationSecrets: Ptr("os"), 7972 OrganizationSelfHostedRunners: Ptr("osh"), 7973 OrganizationUserBlocking: Ptr("oub"), 7974 Packages: Ptr("pkg"), 7975 Pages: Ptr("pg"), 7976 PullRequests: Ptr("pr"), 7977 RepositoryHooks: Ptr("rh"), 7978 RepositoryProjects: Ptr("rp"), 7979 RepositoryPreReceiveHooks: Ptr("rprh"), 7980 Secrets: Ptr("s"), 7981 SecretScanningAlerts: Ptr("ssa"), 7982 SecurityEvents: Ptr("se"), 7983 SingleFile: Ptr("sf"), 7984 Statuses: Ptr("s"), 7985 TeamDiscussions: Ptr("td"), 7986 VulnerabilityAlerts: Ptr("va"), 7987 Workflows: Ptr("w"), 7988 }, 7989 CreatedAt: &Timestamp{referenceTime}, 7990 UpdatedAt: &Timestamp{referenceTime}, 7991 HasMultipleSingleFiles: Ptr(false), 7992 SuspendedBy: &User{ 7993 Login: Ptr("l"), 7994 ID: Ptr(int64(1)), 7995 URL: Ptr("u"), 7996 AvatarURL: Ptr("a"), 7997 GravatarID: Ptr("g"), 7998 Name: Ptr("n"), 7999 Company: Ptr("c"), 8000 Blog: Ptr("b"), 8001 Location: Ptr("l"), 8002 Email: Ptr("e"), 8003 Hireable: Ptr(true), 8004 Bio: Ptr("b"), 8005 TwitterUsername: Ptr("t"), 8006 PublicRepos: Ptr(1), 8007 Followers: Ptr(1), 8008 Following: Ptr(1), 8009 CreatedAt: &Timestamp{referenceTime}, 8010 SuspendedAt: &Timestamp{referenceTime}, 8011 }, 8012 SuspendedAt: &Timestamp{referenceTime}, 8013 }, 8014 } 8015 8016 want := `{ 8017 "discussion": { 8018 "repository_url": "rurl", 8019 "category": { 8020 "id": 1, 8021 "node_id": "nid", 8022 "repository_id": 1, 8023 "emoji": "emoji", 8024 "name": "name", 8025 "description": "description", 8026 "created_at": ` + referenceTimeStr + `, 8027 "updated_at": ` + referenceTimeStr + `, 8028 "slug": "slug", 8029 "is_answerable": false 8030 }, 8031 "html_url": "hurl", 8032 "id": 1, 8033 "node_id": "nurl", 8034 "number": 1, 8035 "title": "title", 8036 "user": { 8037 "login": "l", 8038 "id": 1, 8039 "node_id": "n", 8040 "avatar_url": "a", 8041 "url": "u", 8042 "events_url": "e", 8043 "repos_url": "r" 8044 }, 8045 "state": "st", 8046 "locked": false, 8047 "comments": 1, 8048 "created_at": ` + referenceTimeStr + `, 8049 "updated_at": ` + referenceTimeStr + `, 8050 "author_association": "aa", 8051 "body": "bo" 8052 }, 8053 "repository": { 8054 "id": 1, 8055 "name": "n", 8056 "url": "s" 8057 }, 8058 "organization": { 8059 "name": "n", 8060 "company": "c", 8061 "blog": "b", 8062 "location": "loc", 8063 "email": "e", 8064 "twitter_username": "tu", 8065 "description": "d", 8066 "billing_email": "be", 8067 "is_verified": true, 8068 "has_organization_projects": true, 8069 "has_repository_projects": true, 8070 "default_repository_permission": "drp", 8071 "members_can_create_repositories": true, 8072 "members_can_create_public_repositories": false, 8073 "members_can_create_private_repositories": true, 8074 "members_can_create_internal_repositories": true, 8075 "members_allowed_repository_creation_type": "marct", 8076 "members_can_create_pages": true, 8077 "members_can_create_public_pages": false, 8078 "members_can_create_private_pages": true 8079 }, 8080 "sender": { 8081 "login": "l", 8082 "id": 1, 8083 "node_id": "n", 8084 "avatar_url": "a", 8085 "url": "u", 8086 "events_url": "e", 8087 "repos_url": "r" 8088 }, 8089 "installation": { 8090 "id": 1, 8091 "node_id": "nid", 8092 "app_id": 1, 8093 "app_slug": "as", 8094 "target_id": 1, 8095 "account": { 8096 "login": "l", 8097 "id": 1, 8098 "avatar_url": "a", 8099 "gravatar_id": "g", 8100 "name": "n", 8101 "company": "c", 8102 "blog": "b", 8103 "location": "l", 8104 "email": "e", 8105 "hireable": true, 8106 "bio": "b", 8107 "twitter_username": "t", 8108 "public_repos": 1, 8109 "followers": 1, 8110 "following": 1, 8111 "created_at": ` + referenceTimeStr + `, 8112 "suspended_at": ` + referenceTimeStr + `, 8113 "url": "u" 8114 }, 8115 "access_tokens_url": "atu", 8116 "repositories_url": "ru", 8117 "html_url": "hu", 8118 "target_type": "tt", 8119 "single_file_name": "sfn", 8120 "repository_selection": "rs", 8121 "events": [ 8122 "e" 8123 ], 8124 "single_file_paths": [ 8125 "s" 8126 ], 8127 "permissions": { 8128 "actions": "a", 8129 "administration": "ad", 8130 "checks": "c", 8131 "contents": "co", 8132 "content_references": "cr", 8133 "deployments": "d", 8134 "environments": "e", 8135 "issues": "i", 8136 "metadata": "md", 8137 "members": "m", 8138 "organization_administration": "oa", 8139 "organization_hooks": "oh", 8140 "organization_plan": "op", 8141 "organization_pre_receive_hooks": "opr", 8142 "organization_projects": "op", 8143 "organization_secrets": "os", 8144 "organization_self_hosted_runners": "osh", 8145 "organization_user_blocking": "oub", 8146 "packages": "pkg", 8147 "pages": "pg", 8148 "pull_requests": "pr", 8149 "repository_hooks": "rh", 8150 "repository_projects": "rp", 8151 "repository_pre_receive_hooks": "rprh", 8152 "secrets": "s", 8153 "secret_scanning_alerts": "ssa", 8154 "security_events": "se", 8155 "single_file": "sf", 8156 "statuses": "s", 8157 "team_discussions": "td", 8158 "vulnerability_alerts": "va", 8159 "workflows": "w" 8160 }, 8161 "created_at": ` + referenceTimeStr + `, 8162 "updated_at": ` + referenceTimeStr + `, 8163 "has_multiple_single_files": false, 8164 "suspended_by": { 8165 "login": "l", 8166 "id": 1, 8167 "avatar_url": "a", 8168 "gravatar_id": "g", 8169 "name": "n", 8170 "company": "c", 8171 "blog": "b", 8172 "location": "l", 8173 "email": "e", 8174 "hireable": true, 8175 "bio": "b", 8176 "twitter_username": "t", 8177 "public_repos": 1, 8178 "followers": 1, 8179 "following": 1, 8180 "created_at": ` + referenceTimeStr + `, 8181 "suspended_at": ` + referenceTimeStr + `, 8182 "url": "u" 8183 }, 8184 "suspended_at": ` + referenceTimeStr + ` 8185 } 8186 }` 8187 8188 testJSONMarshal(t, u, want) 8189 } 8190 8191 func TestPackageEvent_Marshal(t *testing.T) { 8192 t.Parallel() 8193 testJSONMarshal(t, &PackageEvent{}, "{}") 8194 8195 u := &PackageEvent{ 8196 Action: Ptr("a"), 8197 Package: &Package{ 8198 ID: Ptr(int64(1)), 8199 Name: Ptr("n"), 8200 PackageType: Ptr("pt"), 8201 HTMLURL: Ptr("hurl"), 8202 CreatedAt: &Timestamp{referenceTime}, 8203 UpdatedAt: &Timestamp{referenceTime}, 8204 Owner: &User{ 8205 Login: Ptr("l"), 8206 ID: Ptr(int64(1)), 8207 NodeID: Ptr("n"), 8208 URL: Ptr("u"), 8209 ReposURL: Ptr("r"), 8210 EventsURL: Ptr("e"), 8211 AvatarURL: Ptr("a"), 8212 }, 8213 PackageVersion: &PackageVersion{ID: Ptr(int64(1))}, 8214 Registry: &PackageRegistry{Name: Ptr("n")}, 8215 }, 8216 Repo: &Repository{ 8217 ID: Ptr(int64(1)), 8218 URL: Ptr("s"), 8219 Name: Ptr("n"), 8220 }, 8221 Org: &Organization{ 8222 BillingEmail: Ptr("be"), 8223 Blog: Ptr("b"), 8224 Company: Ptr("c"), 8225 Email: Ptr("e"), 8226 TwitterUsername: Ptr("tu"), 8227 Location: Ptr("loc"), 8228 Name: Ptr("n"), 8229 Description: Ptr("d"), 8230 IsVerified: Ptr(true), 8231 HasOrganizationProjects: Ptr(true), 8232 HasRepositoryProjects: Ptr(true), 8233 DefaultRepoPermission: Ptr("drp"), 8234 MembersCanCreateRepos: Ptr(true), 8235 MembersCanCreateInternalRepos: Ptr(true), 8236 MembersCanCreatePrivateRepos: Ptr(true), 8237 MembersCanCreatePublicRepos: Ptr(false), 8238 MembersAllowedRepositoryCreationType: Ptr("marct"), 8239 MembersCanCreatePages: Ptr(true), 8240 MembersCanCreatePublicPages: Ptr(false), 8241 MembersCanCreatePrivatePages: Ptr(true), 8242 }, 8243 Sender: &User{ 8244 Login: Ptr("l"), 8245 ID: Ptr(int64(1)), 8246 NodeID: Ptr("n"), 8247 URL: Ptr("u"), 8248 ReposURL: Ptr("r"), 8249 EventsURL: Ptr("e"), 8250 AvatarURL: Ptr("a"), 8251 }, 8252 } 8253 8254 want := `{ 8255 "action": "a", 8256 "package": { 8257 "id": 1, 8258 "name": "n", 8259 "package_type": "pt", 8260 "html_url": "hurl", 8261 "created_at": ` + referenceTimeStr + `, 8262 "updated_at": ` + referenceTimeStr + `, 8263 "owner": { 8264 "login": "l", 8265 "id": 1, 8266 "node_id": "n", 8267 "avatar_url": "a", 8268 "url": "u", 8269 "events_url": "e", 8270 "repos_url": "r" 8271 }, 8272 "package_version": { 8273 "id": 1 8274 }, 8275 "registry": { 8276 "name": "n" 8277 } 8278 }, 8279 "repository": { 8280 "id": 1, 8281 "name": "n", 8282 "url": "s" 8283 }, 8284 "organization": { 8285 "name": "n", 8286 "company": "c", 8287 "blog": "b", 8288 "location": "loc", 8289 "email": "e", 8290 "twitter_username": "tu", 8291 "description": "d", 8292 "billing_email": "be", 8293 "is_verified": true, 8294 "has_organization_projects": true, 8295 "has_repository_projects": true, 8296 "default_repository_permission": "drp", 8297 "members_can_create_repositories": true, 8298 "members_can_create_public_repositories": false, 8299 "members_can_create_private_repositories": true, 8300 "members_can_create_internal_repositories": true, 8301 "members_allowed_repository_creation_type": "marct", 8302 "members_can_create_pages": true, 8303 "members_can_create_public_pages": false, 8304 "members_can_create_private_pages": true 8305 }, 8306 "sender": { 8307 "login": "l", 8308 "id": 1, 8309 "node_id": "n", 8310 "avatar_url": "a", 8311 "url": "u", 8312 "events_url": "e", 8313 "repos_url": "r" 8314 } 8315 }` 8316 8317 testJSONMarshal(t, u, want) 8318 } 8319 8320 func TestPersonalAccessTokenRequestEvent_Marshal(t *testing.T) { 8321 t.Parallel() 8322 testJSONMarshal(t, &PersonalAccessTokenRequestEvent{}, "{}") 8323 8324 event := &PersonalAccessTokenRequestEvent{ 8325 Action: Ptr("a"), 8326 PersonalAccessTokenRequest: &PersonalAccessTokenRequest{ 8327 ID: Ptr(int64(1)), 8328 Owner: &User{Login: Ptr("l")}, 8329 PermissionsAdded: &PersonalAccessTokenPermissions{ 8330 Org: map[string]string{"organization_events": "read"}, 8331 Repo: map[string]string{"security_events": "write"}, 8332 }, 8333 CreatedAt: &Timestamp{referenceTime}, 8334 TokenExpired: Ptr(false), 8335 TokenExpiresAt: &Timestamp{referenceTime}, 8336 TokenLastUsedAt: &Timestamp{referenceTime}, 8337 RepositoryCount: Ptr(int64(1)), 8338 RepositorySelection: Ptr("rs"), 8339 Repositories: []*Repository{ 8340 { 8341 Name: Ptr("n"), 8342 }, 8343 }, 8344 }, 8345 Org: &Organization{Name: Ptr("n")}, 8346 Sender: &User{ 8347 Login: Ptr("l"), 8348 }, 8349 Installation: &Installation{ 8350 ID: Ptr(int64(1)), 8351 }, 8352 } 8353 8354 want := `{ 8355 "action": "a", 8356 "personal_access_token_request": { 8357 "id": 1, 8358 "owner": { 8359 "login": "l" 8360 }, 8361 "permissions_added": { 8362 "organization": { 8363 "organization_events": "read" 8364 }, 8365 "repository": { 8366 "security_events": "write" 8367 } 8368 }, 8369 "created_at": ` + referenceTimeStr + `, 8370 "token_expired": false, 8371 "token_expires_at": ` + referenceTimeStr + `, 8372 "token_last_used_at": ` + referenceTimeStr + `, 8373 "repository_count": 1, 8374 "repository_selection": "rs", 8375 "repositories": [ 8376 { 8377 "name": "n" 8378 } 8379 ] 8380 }, 8381 "organization": { 8382 "name": "n" 8383 }, 8384 "sender": { 8385 "login": "l" 8386 }, 8387 "installation": { 8388 "id": 1 8389 } 8390 }` 8391 8392 testJSONMarshal(t, event, want) 8393 } 8394 8395 func TestPingEvent_Marshal(t *testing.T) { 8396 t.Parallel() 8397 testJSONMarshal(t, &PingEvent{}, "{}") 8398 8399 l := make(map[string]interface{}) 8400 l["key"] = "value" 8401 hookConfig := new(HookConfig) 8402 8403 u := &PingEvent{ 8404 Zen: Ptr("z"), 8405 HookID: Ptr(int64(1)), 8406 Hook: &Hook{ 8407 CreatedAt: &Timestamp{referenceTime}, 8408 UpdatedAt: &Timestamp{referenceTime}, 8409 URL: Ptr("url"), 8410 ID: Ptr(int64(1)), 8411 Type: Ptr("t"), 8412 Name: Ptr("n"), 8413 TestURL: Ptr("tu"), 8414 PingURL: Ptr("pu"), 8415 LastResponse: l, 8416 Config: hookConfig, 8417 Events: []string{"a"}, 8418 Active: Ptr(true), 8419 }, 8420 Installation: &Installation{ 8421 ID: Ptr(int64(1)), 8422 NodeID: Ptr("nid"), 8423 AppID: Ptr(int64(1)), 8424 AppSlug: Ptr("as"), 8425 TargetID: Ptr(int64(1)), 8426 Account: &User{ 8427 Login: Ptr("l"), 8428 ID: Ptr(int64(1)), 8429 URL: Ptr("u"), 8430 AvatarURL: Ptr("a"), 8431 GravatarID: Ptr("g"), 8432 Name: Ptr("n"), 8433 Company: Ptr("c"), 8434 Blog: Ptr("b"), 8435 Location: Ptr("l"), 8436 Email: Ptr("e"), 8437 Hireable: Ptr(true), 8438 Bio: Ptr("b"), 8439 TwitterUsername: Ptr("t"), 8440 PublicRepos: Ptr(1), 8441 Followers: Ptr(1), 8442 Following: Ptr(1), 8443 CreatedAt: &Timestamp{referenceTime}, 8444 SuspendedAt: &Timestamp{referenceTime}, 8445 }, 8446 AccessTokensURL: Ptr("atu"), 8447 RepositoriesURL: Ptr("ru"), 8448 HTMLURL: Ptr("hu"), 8449 TargetType: Ptr("tt"), 8450 SingleFileName: Ptr("sfn"), 8451 RepositorySelection: Ptr("rs"), 8452 Events: []string{"e"}, 8453 SingleFilePaths: []string{"s"}, 8454 Permissions: &InstallationPermissions{ 8455 Actions: Ptr("a"), 8456 Administration: Ptr("ad"), 8457 Checks: Ptr("c"), 8458 Contents: Ptr("co"), 8459 ContentReferences: Ptr("cr"), 8460 Deployments: Ptr("d"), 8461 Environments: Ptr("e"), 8462 Issues: Ptr("i"), 8463 Metadata: Ptr("md"), 8464 Members: Ptr("m"), 8465 OrganizationAdministration: Ptr("oa"), 8466 OrganizationHooks: Ptr("oh"), 8467 OrganizationPlan: Ptr("op"), 8468 OrganizationPreReceiveHooks: Ptr("opr"), 8469 OrganizationProjects: Ptr("op"), 8470 OrganizationSecrets: Ptr("os"), 8471 OrganizationSelfHostedRunners: Ptr("osh"), 8472 OrganizationUserBlocking: Ptr("oub"), 8473 Packages: Ptr("pkg"), 8474 Pages: Ptr("pg"), 8475 PullRequests: Ptr("pr"), 8476 RepositoryHooks: Ptr("rh"), 8477 RepositoryProjects: Ptr("rp"), 8478 RepositoryPreReceiveHooks: Ptr("rprh"), 8479 Secrets: Ptr("s"), 8480 SecretScanningAlerts: Ptr("ssa"), 8481 SecurityEvents: Ptr("se"), 8482 SingleFile: Ptr("sf"), 8483 Statuses: Ptr("s"), 8484 TeamDiscussions: Ptr("td"), 8485 VulnerabilityAlerts: Ptr("va"), 8486 Workflows: Ptr("w"), 8487 }, 8488 CreatedAt: &Timestamp{referenceTime}, 8489 UpdatedAt: &Timestamp{referenceTime}, 8490 HasMultipleSingleFiles: Ptr(false), 8491 SuspendedBy: &User{ 8492 Login: Ptr("l"), 8493 ID: Ptr(int64(1)), 8494 URL: Ptr("u"), 8495 AvatarURL: Ptr("a"), 8496 GravatarID: Ptr("g"), 8497 Name: Ptr("n"), 8498 Company: Ptr("c"), 8499 Blog: Ptr("b"), 8500 Location: Ptr("l"), 8501 Email: Ptr("e"), 8502 Hireable: Ptr(true), 8503 Bio: Ptr("b"), 8504 TwitterUsername: Ptr("t"), 8505 PublicRepos: Ptr(1), 8506 Followers: Ptr(1), 8507 Following: Ptr(1), 8508 CreatedAt: &Timestamp{referenceTime}, 8509 SuspendedAt: &Timestamp{referenceTime}, 8510 }, 8511 SuspendedAt: &Timestamp{referenceTime}, 8512 }, 8513 } 8514 8515 want := `{ 8516 "zen": "z", 8517 "hook_id": 1, 8518 "hook": { 8519 "created_at": ` + referenceTimeStr + `, 8520 "updated_at": ` + referenceTimeStr + `, 8521 "url": "url", 8522 "id": 1, 8523 "type": "t", 8524 "name": "n", 8525 "test_url": "tu", 8526 "ping_url": "pu", 8527 "last_response": { 8528 "key": "value" 8529 }, 8530 "config": { 8531 "key": "value" 8532 }, 8533 "events": [ 8534 "a" 8535 ], 8536 "active": true 8537 }, 8538 "installation": { 8539 "id": 1, 8540 "node_id": "nid", 8541 "app_id": 1, 8542 "app_slug": "as", 8543 "target_id": 1, 8544 "account": { 8545 "login": "l", 8546 "id": 1, 8547 "avatar_url": "a", 8548 "gravatar_id": "g", 8549 "name": "n", 8550 "company": "c", 8551 "blog": "b", 8552 "location": "l", 8553 "email": "e", 8554 "hireable": true, 8555 "bio": "b", 8556 "twitter_username": "t", 8557 "public_repos": 1, 8558 "followers": 1, 8559 "following": 1, 8560 "created_at": ` + referenceTimeStr + `, 8561 "suspended_at": ` + referenceTimeStr + `, 8562 "url": "u" 8563 }, 8564 "access_tokens_url": "atu", 8565 "repositories_url": "ru", 8566 "html_url": "hu", 8567 "target_type": "tt", 8568 "single_file_name": "sfn", 8569 "repository_selection": "rs", 8570 "events": [ 8571 "e" 8572 ], 8573 "single_file_paths": [ 8574 "s" 8575 ], 8576 "permissions": { 8577 "actions": "a", 8578 "administration": "ad", 8579 "checks": "c", 8580 "contents": "co", 8581 "content_references": "cr", 8582 "deployments": "d", 8583 "environments": "e", 8584 "issues": "i", 8585 "metadata": "md", 8586 "members": "m", 8587 "organization_administration": "oa", 8588 "organization_hooks": "oh", 8589 "organization_plan": "op", 8590 "organization_pre_receive_hooks": "opr", 8591 "organization_projects": "op", 8592 "organization_secrets": "os", 8593 "organization_self_hosted_runners": "osh", 8594 "organization_user_blocking": "oub", 8595 "packages": "pkg", 8596 "pages": "pg", 8597 "pull_requests": "pr", 8598 "repository_hooks": "rh", 8599 "repository_projects": "rp", 8600 "repository_pre_receive_hooks": "rprh", 8601 "secrets": "s", 8602 "secret_scanning_alerts": "ssa", 8603 "security_events": "se", 8604 "single_file": "sf", 8605 "statuses": "s", 8606 "team_discussions": "td", 8607 "vulnerability_alerts": "va", 8608 "workflows": "w" 8609 }, 8610 "created_at": ` + referenceTimeStr + `, 8611 "updated_at": ` + referenceTimeStr + `, 8612 "has_multiple_single_files": false, 8613 "suspended_by": { 8614 "login": "l", 8615 "id": 1, 8616 "avatar_url": "a", 8617 "gravatar_id": "g", 8618 "name": "n", 8619 "company": "c", 8620 "blog": "b", 8621 "location": "l", 8622 "email": "e", 8623 "hireable": true, 8624 "bio": "b", 8625 "twitter_username": "t", 8626 "public_repos": 1, 8627 "followers": 1, 8628 "following": 1, 8629 "created_at": ` + referenceTimeStr + `, 8630 "suspended_at": ` + referenceTimeStr + `, 8631 "url": "u" 8632 }, 8633 "suspended_at": ` + referenceTimeStr + ` 8634 } 8635 }` 8636 8637 testJSONMarshal(t, u, want) 8638 } 8639 8640 func TestRepositoryDispatchEvent_Marshal(t *testing.T) { 8641 t.Parallel() 8642 testJSONMarshal(t, &RepositoryDispatchEvent{}, "{}") 8643 8644 l := make(map[string]interface{}) 8645 l["key"] = "value" 8646 8647 jsonMsg, _ := json.Marshal(&l) 8648 8649 u := &RepositoryDispatchEvent{ 8650 Action: Ptr("a"), 8651 Branch: Ptr("b"), 8652 ClientPayload: jsonMsg, 8653 Repo: &Repository{ 8654 8655 ID: Ptr(int64(1)), 8656 URL: Ptr("s"), 8657 Name: Ptr("n"), 8658 }, 8659 Org: &Organization{ 8660 BillingEmail: Ptr("be"), 8661 Blog: Ptr("b"), 8662 Company: Ptr("c"), 8663 Email: Ptr("e"), 8664 TwitterUsername: Ptr("tu"), 8665 Location: Ptr("loc"), 8666 Name: Ptr("n"), 8667 Description: Ptr("d"), 8668 IsVerified: Ptr(true), 8669 HasOrganizationProjects: Ptr(true), 8670 HasRepositoryProjects: Ptr(true), 8671 DefaultRepoPermission: Ptr("drp"), 8672 MembersCanCreateRepos: Ptr(true), 8673 MembersCanCreateInternalRepos: Ptr(true), 8674 MembersCanCreatePrivateRepos: Ptr(true), 8675 MembersCanCreatePublicRepos: Ptr(false), 8676 MembersAllowedRepositoryCreationType: Ptr("marct"), 8677 MembersCanCreatePages: Ptr(true), 8678 MembersCanCreatePublicPages: Ptr(false), 8679 MembersCanCreatePrivatePages: Ptr(true), 8680 }, 8681 Sender: &User{ 8682 Login: Ptr("l"), 8683 ID: Ptr(int64(1)), 8684 NodeID: Ptr("n"), 8685 URL: Ptr("u"), 8686 ReposURL: Ptr("r"), 8687 EventsURL: Ptr("e"), 8688 AvatarURL: Ptr("a"), 8689 }, 8690 Installation: &Installation{ 8691 ID: Ptr(int64(1)), 8692 NodeID: Ptr("nid"), 8693 AppID: Ptr(int64(1)), 8694 AppSlug: Ptr("as"), 8695 TargetID: Ptr(int64(1)), 8696 Account: &User{ 8697 Login: Ptr("l"), 8698 ID: Ptr(int64(1)), 8699 URL: Ptr("u"), 8700 AvatarURL: Ptr("a"), 8701 GravatarID: Ptr("g"), 8702 Name: Ptr("n"), 8703 Company: Ptr("c"), 8704 Blog: Ptr("b"), 8705 Location: Ptr("l"), 8706 Email: Ptr("e"), 8707 Hireable: Ptr(true), 8708 Bio: Ptr("b"), 8709 TwitterUsername: Ptr("t"), 8710 PublicRepos: Ptr(1), 8711 Followers: Ptr(1), 8712 Following: Ptr(1), 8713 CreatedAt: &Timestamp{referenceTime}, 8714 SuspendedAt: &Timestamp{referenceTime}, 8715 }, 8716 AccessTokensURL: Ptr("atu"), 8717 RepositoriesURL: Ptr("ru"), 8718 HTMLURL: Ptr("hu"), 8719 TargetType: Ptr("tt"), 8720 SingleFileName: Ptr("sfn"), 8721 RepositorySelection: Ptr("rs"), 8722 Events: []string{"e"}, 8723 SingleFilePaths: []string{"s"}, 8724 Permissions: &InstallationPermissions{ 8725 Actions: Ptr("a"), 8726 Administration: Ptr("ad"), 8727 Checks: Ptr("c"), 8728 Contents: Ptr("co"), 8729 ContentReferences: Ptr("cr"), 8730 Deployments: Ptr("d"), 8731 Environments: Ptr("e"), 8732 Issues: Ptr("i"), 8733 Metadata: Ptr("md"), 8734 Members: Ptr("m"), 8735 OrganizationAdministration: Ptr("oa"), 8736 OrganizationHooks: Ptr("oh"), 8737 OrganizationPlan: Ptr("op"), 8738 OrganizationPreReceiveHooks: Ptr("opr"), 8739 OrganizationProjects: Ptr("op"), 8740 OrganizationSecrets: Ptr("os"), 8741 OrganizationSelfHostedRunners: Ptr("osh"), 8742 OrganizationUserBlocking: Ptr("oub"), 8743 Packages: Ptr("pkg"), 8744 Pages: Ptr("pg"), 8745 PullRequests: Ptr("pr"), 8746 RepositoryHooks: Ptr("rh"), 8747 RepositoryProjects: Ptr("rp"), 8748 RepositoryPreReceiveHooks: Ptr("rprh"), 8749 Secrets: Ptr("s"), 8750 SecretScanningAlerts: Ptr("ssa"), 8751 SecurityEvents: Ptr("se"), 8752 SingleFile: Ptr("sf"), 8753 Statuses: Ptr("s"), 8754 TeamDiscussions: Ptr("td"), 8755 VulnerabilityAlerts: Ptr("va"), 8756 Workflows: Ptr("w"), 8757 }, 8758 CreatedAt: &Timestamp{referenceTime}, 8759 UpdatedAt: &Timestamp{referenceTime}, 8760 HasMultipleSingleFiles: Ptr(false), 8761 SuspendedBy: &User{ 8762 Login: Ptr("l"), 8763 ID: Ptr(int64(1)), 8764 URL: Ptr("u"), 8765 AvatarURL: Ptr("a"), 8766 GravatarID: Ptr("g"), 8767 Name: Ptr("n"), 8768 Company: Ptr("c"), 8769 Blog: Ptr("b"), 8770 Location: Ptr("l"), 8771 Email: Ptr("e"), 8772 Hireable: Ptr(true), 8773 Bio: Ptr("b"), 8774 TwitterUsername: Ptr("t"), 8775 PublicRepos: Ptr(1), 8776 Followers: Ptr(1), 8777 Following: Ptr(1), 8778 CreatedAt: &Timestamp{referenceTime}, 8779 SuspendedAt: &Timestamp{referenceTime}, 8780 }, 8781 SuspendedAt: &Timestamp{referenceTime}, 8782 }, 8783 } 8784 8785 want := `{ 8786 "action": "a", 8787 "branch": "b", 8788 "client_payload": { 8789 "key": "value" 8790 }, 8791 "repository": { 8792 "id": 1, 8793 "name": "n", 8794 "url": "s" 8795 }, 8796 "organization": { 8797 "name": "n", 8798 "company": "c", 8799 "blog": "b", 8800 "location": "loc", 8801 "email": "e", 8802 "twitter_username": "tu", 8803 "description": "d", 8804 "billing_email": "be", 8805 "is_verified": true, 8806 "has_organization_projects": true, 8807 "has_repository_projects": true, 8808 "default_repository_permission": "drp", 8809 "members_can_create_repositories": true, 8810 "members_can_create_public_repositories": false, 8811 "members_can_create_private_repositories": true, 8812 "members_can_create_internal_repositories": true, 8813 "members_allowed_repository_creation_type": "marct", 8814 "members_can_create_pages": true, 8815 "members_can_create_public_pages": false, 8816 "members_can_create_private_pages": true 8817 }, 8818 "sender": { 8819 "login": "l", 8820 "id": 1, 8821 "node_id": "n", 8822 "avatar_url": "a", 8823 "url": "u", 8824 "events_url": "e", 8825 "repos_url": "r" 8826 }, 8827 "installation": { 8828 "id": 1, 8829 "node_id": "nid", 8830 "app_id": 1, 8831 "app_slug": "as", 8832 "target_id": 1, 8833 "account": { 8834 "login": "l", 8835 "id": 1, 8836 "avatar_url": "a", 8837 "gravatar_id": "g", 8838 "name": "n", 8839 "company": "c", 8840 "blog": "b", 8841 "location": "l", 8842 "email": "e", 8843 "hireable": true, 8844 "bio": "b", 8845 "twitter_username": "t", 8846 "public_repos": 1, 8847 "followers": 1, 8848 "following": 1, 8849 "created_at": ` + referenceTimeStr + `, 8850 "suspended_at": ` + referenceTimeStr + `, 8851 "url": "u" 8852 }, 8853 "access_tokens_url": "atu", 8854 "repositories_url": "ru", 8855 "html_url": "hu", 8856 "target_type": "tt", 8857 "single_file_name": "sfn", 8858 "repository_selection": "rs", 8859 "events": [ 8860 "e" 8861 ], 8862 "single_file_paths": [ 8863 "s" 8864 ], 8865 "permissions": { 8866 "actions": "a", 8867 "administration": "ad", 8868 "checks": "c", 8869 "contents": "co", 8870 "content_references": "cr", 8871 "deployments": "d", 8872 "environments": "e", 8873 "issues": "i", 8874 "metadata": "md", 8875 "members": "m", 8876 "organization_administration": "oa", 8877 "organization_hooks": "oh", 8878 "organization_plan": "op", 8879 "organization_pre_receive_hooks": "opr", 8880 "organization_projects": "op", 8881 "organization_secrets": "os", 8882 "organization_self_hosted_runners": "osh", 8883 "organization_user_blocking": "oub", 8884 "packages": "pkg", 8885 "pages": "pg", 8886 "pull_requests": "pr", 8887 "repository_hooks": "rh", 8888 "repository_projects": "rp", 8889 "repository_pre_receive_hooks": "rprh", 8890 "secrets": "s", 8891 "secret_scanning_alerts": "ssa", 8892 "security_events": "se", 8893 "single_file": "sf", 8894 "statuses": "s", 8895 "team_discussions": "td", 8896 "vulnerability_alerts": "va", 8897 "workflows": "w" 8898 }, 8899 "created_at": ` + referenceTimeStr + `, 8900 "updated_at": ` + referenceTimeStr + `, 8901 "has_multiple_single_files": false, 8902 "suspended_by": { 8903 "login": "l", 8904 "id": 1, 8905 "avatar_url": "a", 8906 "gravatar_id": "g", 8907 "name": "n", 8908 "company": "c", 8909 "blog": "b", 8910 "location": "l", 8911 "email": "e", 8912 "hireable": true, 8913 "bio": "b", 8914 "twitter_username": "t", 8915 "public_repos": 1, 8916 "followers": 1, 8917 "following": 1, 8918 "created_at": ` + referenceTimeStr + `, 8919 "suspended_at": ` + referenceTimeStr + `, 8920 "url": "u" 8921 }, 8922 "suspended_at": ` + referenceTimeStr + ` 8923 } 8924 }` 8925 8926 testJSONMarshal(t, u, want) 8927 } 8928 8929 func TestRepositoryImportEvent_Marshal(t *testing.T) { 8930 t.Parallel() 8931 testJSONMarshal(t, &RepositoryImportEvent{}, "{}") 8932 8933 u := &RepositoryImportEvent{ 8934 Status: Ptr("success"), 8935 Repo: &Repository{ 8936 ID: Ptr(int64(1)), 8937 URL: Ptr("s"), 8938 Name: Ptr("n"), 8939 }, 8940 Org: &Organization{ 8941 BillingEmail: Ptr("be"), 8942 Blog: Ptr("b"), 8943 Company: Ptr("c"), 8944 Email: Ptr("e"), 8945 TwitterUsername: Ptr("tu"), 8946 Location: Ptr("loc"), 8947 Name: Ptr("n"), 8948 Description: Ptr("d"), 8949 IsVerified: Ptr(true), 8950 HasOrganizationProjects: Ptr(true), 8951 HasRepositoryProjects: Ptr(true), 8952 DefaultRepoPermission: Ptr("drp"), 8953 MembersCanCreateRepos: Ptr(true), 8954 MembersCanCreateInternalRepos: Ptr(true), 8955 MembersCanCreatePrivateRepos: Ptr(true), 8956 MembersCanCreatePublicRepos: Ptr(false), 8957 MembersAllowedRepositoryCreationType: Ptr("marct"), 8958 MembersCanCreatePages: Ptr(true), 8959 MembersCanCreatePublicPages: Ptr(false), 8960 MembersCanCreatePrivatePages: Ptr(true), 8961 }, 8962 Sender: &User{ 8963 Login: Ptr("l"), 8964 ID: Ptr(int64(1)), 8965 NodeID: Ptr("n"), 8966 URL: Ptr("u"), 8967 ReposURL: Ptr("r"), 8968 EventsURL: Ptr("e"), 8969 AvatarURL: Ptr("a"), 8970 }, 8971 } 8972 8973 want := `{ 8974 "status": "success", 8975 "repository": { 8976 "id": 1, 8977 "name": "n", 8978 "url": "s" 8979 }, 8980 "organization": { 8981 "name": "n", 8982 "company": "c", 8983 "blog": "b", 8984 "location": "loc", 8985 "email": "e", 8986 "twitter_username": "tu", 8987 "description": "d", 8988 "billing_email": "be", 8989 "is_verified": true, 8990 "has_organization_projects": true, 8991 "has_repository_projects": true, 8992 "default_repository_permission": "drp", 8993 "members_can_create_repositories": true, 8994 "members_can_create_public_repositories": false, 8995 "members_can_create_private_repositories": true, 8996 "members_can_create_internal_repositories": true, 8997 "members_allowed_repository_creation_type": "marct", 8998 "members_can_create_pages": true, 8999 "members_can_create_public_pages": false, 9000 "members_can_create_private_pages": true 9001 }, 9002 "sender": { 9003 "login": "l", 9004 "id": 1, 9005 "node_id": "n", 9006 "avatar_url": "a", 9007 "url": "u", 9008 "events_url": "e", 9009 "repos_url": "r" 9010 } 9011 }` 9012 9013 testJSONMarshal(t, u, want) 9014 } 9015 9016 func TestRepositoryEvent_Marshal(t *testing.T) { 9017 t.Parallel() 9018 testJSONMarshal(t, &RepositoryEvent{}, "{}") 9019 9020 u := &RepositoryEvent{ 9021 Action: Ptr("a"), 9022 Repo: &Repository{ 9023 ID: Ptr(int64(1)), 9024 URL: Ptr("s"), 9025 Name: Ptr("n"), 9026 }, 9027 Org: &Organization{ 9028 BillingEmail: Ptr("be"), 9029 Blog: Ptr("b"), 9030 Company: Ptr("c"), 9031 Email: Ptr("e"), 9032 TwitterUsername: Ptr("tu"), 9033 Location: Ptr("loc"), 9034 Name: Ptr("n"), 9035 Description: Ptr("d"), 9036 IsVerified: Ptr(true), 9037 HasOrganizationProjects: Ptr(true), 9038 HasRepositoryProjects: Ptr(true), 9039 DefaultRepoPermission: Ptr("drp"), 9040 MembersCanCreateRepos: Ptr(true), 9041 MembersCanCreateInternalRepos: Ptr(true), 9042 MembersCanCreatePrivateRepos: Ptr(true), 9043 MembersCanCreatePublicRepos: Ptr(false), 9044 MembersAllowedRepositoryCreationType: Ptr("marct"), 9045 MembersCanCreatePages: Ptr(true), 9046 MembersCanCreatePublicPages: Ptr(false), 9047 MembersCanCreatePrivatePages: Ptr(true), 9048 }, 9049 Sender: &User{ 9050 Login: Ptr("l"), 9051 ID: Ptr(int64(1)), 9052 NodeID: Ptr("n"), 9053 URL: Ptr("u"), 9054 ReposURL: Ptr("r"), 9055 EventsURL: Ptr("e"), 9056 AvatarURL: Ptr("a"), 9057 }, 9058 Installation: &Installation{ 9059 ID: Ptr(int64(1)), 9060 NodeID: Ptr("nid"), 9061 AppID: Ptr(int64(1)), 9062 AppSlug: Ptr("as"), 9063 TargetID: Ptr(int64(1)), 9064 Account: &User{ 9065 Login: Ptr("l"), 9066 ID: Ptr(int64(1)), 9067 URL: Ptr("u"), 9068 AvatarURL: Ptr("a"), 9069 GravatarID: Ptr("g"), 9070 Name: Ptr("n"), 9071 Company: Ptr("c"), 9072 Blog: Ptr("b"), 9073 Location: Ptr("l"), 9074 Email: Ptr("e"), 9075 Hireable: Ptr(true), 9076 Bio: Ptr("b"), 9077 TwitterUsername: Ptr("t"), 9078 PublicRepos: Ptr(1), 9079 Followers: Ptr(1), 9080 Following: Ptr(1), 9081 CreatedAt: &Timestamp{referenceTime}, 9082 SuspendedAt: &Timestamp{referenceTime}, 9083 }, 9084 AccessTokensURL: Ptr("atu"), 9085 RepositoriesURL: Ptr("ru"), 9086 HTMLURL: Ptr("hu"), 9087 TargetType: Ptr("tt"), 9088 SingleFileName: Ptr("sfn"), 9089 RepositorySelection: Ptr("rs"), 9090 Events: []string{"e"}, 9091 SingleFilePaths: []string{"s"}, 9092 Permissions: &InstallationPermissions{ 9093 Actions: Ptr("a"), 9094 Administration: Ptr("ad"), 9095 Checks: Ptr("c"), 9096 Contents: Ptr("co"), 9097 ContentReferences: Ptr("cr"), 9098 Deployments: Ptr("d"), 9099 Environments: Ptr("e"), 9100 Issues: Ptr("i"), 9101 Metadata: Ptr("md"), 9102 Members: Ptr("m"), 9103 OrganizationAdministration: Ptr("oa"), 9104 OrganizationHooks: Ptr("oh"), 9105 OrganizationPlan: Ptr("op"), 9106 OrganizationPreReceiveHooks: Ptr("opr"), 9107 OrganizationProjects: Ptr("op"), 9108 OrganizationSecrets: Ptr("os"), 9109 OrganizationSelfHostedRunners: Ptr("osh"), 9110 OrganizationUserBlocking: Ptr("oub"), 9111 Packages: Ptr("pkg"), 9112 Pages: Ptr("pg"), 9113 PullRequests: Ptr("pr"), 9114 RepositoryHooks: Ptr("rh"), 9115 RepositoryProjects: Ptr("rp"), 9116 RepositoryPreReceiveHooks: Ptr("rprh"), 9117 Secrets: Ptr("s"), 9118 SecretScanningAlerts: Ptr("ssa"), 9119 SecurityEvents: Ptr("se"), 9120 SingleFile: Ptr("sf"), 9121 Statuses: Ptr("s"), 9122 TeamDiscussions: Ptr("td"), 9123 VulnerabilityAlerts: Ptr("va"), 9124 Workflows: Ptr("w"), 9125 }, 9126 CreatedAt: &Timestamp{referenceTime}, 9127 UpdatedAt: &Timestamp{referenceTime}, 9128 HasMultipleSingleFiles: Ptr(false), 9129 SuspendedBy: &User{ 9130 Login: Ptr("l"), 9131 ID: Ptr(int64(1)), 9132 URL: Ptr("u"), 9133 AvatarURL: Ptr("a"), 9134 GravatarID: Ptr("g"), 9135 Name: Ptr("n"), 9136 Company: Ptr("c"), 9137 Blog: Ptr("b"), 9138 Location: Ptr("l"), 9139 Email: Ptr("e"), 9140 Hireable: Ptr(true), 9141 Bio: Ptr("b"), 9142 TwitterUsername: Ptr("t"), 9143 PublicRepos: Ptr(1), 9144 Followers: Ptr(1), 9145 Following: Ptr(1), 9146 CreatedAt: &Timestamp{referenceTime}, 9147 SuspendedAt: &Timestamp{referenceTime}, 9148 }, 9149 SuspendedAt: &Timestamp{referenceTime}, 9150 }, 9151 } 9152 9153 want := `{ 9154 "action": "a", 9155 "repository": { 9156 "id": 1, 9157 "name": "n", 9158 "url": "s" 9159 }, 9160 "organization": { 9161 "name": "n", 9162 "company": "c", 9163 "blog": "b", 9164 "location": "loc", 9165 "email": "e", 9166 "twitter_username": "tu", 9167 "description": "d", 9168 "billing_email": "be", 9169 "is_verified": true, 9170 "has_organization_projects": true, 9171 "has_repository_projects": true, 9172 "default_repository_permission": "drp", 9173 "members_can_create_repositories": true, 9174 "members_can_create_public_repositories": false, 9175 "members_can_create_private_repositories": true, 9176 "members_can_create_internal_repositories": true, 9177 "members_allowed_repository_creation_type": "marct", 9178 "members_can_create_pages": true, 9179 "members_can_create_public_pages": false, 9180 "members_can_create_private_pages": true 9181 }, 9182 "sender": { 9183 "login": "l", 9184 "id": 1, 9185 "node_id": "n", 9186 "avatar_url": "a", 9187 "url": "u", 9188 "events_url": "e", 9189 "repos_url": "r" 9190 }, 9191 "installation": { 9192 "id": 1, 9193 "node_id": "nid", 9194 "app_id": 1, 9195 "app_slug": "as", 9196 "target_id": 1, 9197 "account": { 9198 "login": "l", 9199 "id": 1, 9200 "avatar_url": "a", 9201 "gravatar_id": "g", 9202 "name": "n", 9203 "company": "c", 9204 "blog": "b", 9205 "location": "l", 9206 "email": "e", 9207 "hireable": true, 9208 "bio": "b", 9209 "twitter_username": "t", 9210 "public_repos": 1, 9211 "followers": 1, 9212 "following": 1, 9213 "created_at": ` + referenceTimeStr + `, 9214 "suspended_at": ` + referenceTimeStr + `, 9215 "url": "u" 9216 }, 9217 "access_tokens_url": "atu", 9218 "repositories_url": "ru", 9219 "html_url": "hu", 9220 "target_type": "tt", 9221 "single_file_name": "sfn", 9222 "repository_selection": "rs", 9223 "events": [ 9224 "e" 9225 ], 9226 "single_file_paths": [ 9227 "s" 9228 ], 9229 "permissions": { 9230 "actions": "a", 9231 "administration": "ad", 9232 "checks": "c", 9233 "contents": "co", 9234 "content_references": "cr", 9235 "deployments": "d", 9236 "environments": "e", 9237 "issues": "i", 9238 "metadata": "md", 9239 "members": "m", 9240 "organization_administration": "oa", 9241 "organization_hooks": "oh", 9242 "organization_plan": "op", 9243 "organization_pre_receive_hooks": "opr", 9244 "organization_projects": "op", 9245 "organization_secrets": "os", 9246 "organization_self_hosted_runners": "osh", 9247 "organization_user_blocking": "oub", 9248 "packages": "pkg", 9249 "pages": "pg", 9250 "pull_requests": "pr", 9251 "repository_hooks": "rh", 9252 "repository_projects": "rp", 9253 "repository_pre_receive_hooks": "rprh", 9254 "secrets": "s", 9255 "secret_scanning_alerts": "ssa", 9256 "security_events": "se", 9257 "single_file": "sf", 9258 "statuses": "s", 9259 "team_discussions": "td", 9260 "vulnerability_alerts": "va", 9261 "workflows": "w" 9262 }, 9263 "created_at": ` + referenceTimeStr + `, 9264 "updated_at": ` + referenceTimeStr + `, 9265 "has_multiple_single_files": false, 9266 "suspended_by": { 9267 "login": "l", 9268 "id": 1, 9269 "avatar_url": "a", 9270 "gravatar_id": "g", 9271 "name": "n", 9272 "company": "c", 9273 "blog": "b", 9274 "location": "l", 9275 "email": "e", 9276 "hireable": true, 9277 "bio": "b", 9278 "twitter_username": "t", 9279 "public_repos": 1, 9280 "followers": 1, 9281 "following": 1, 9282 "created_at": ` + referenceTimeStr + `, 9283 "suspended_at": ` + referenceTimeStr + `, 9284 "url": "u" 9285 }, 9286 "suspended_at": ` + referenceTimeStr + ` 9287 } 9288 }` 9289 9290 testJSONMarshal(t, u, want) 9291 } 9292 9293 func TestReleaseEvent_Marshal(t *testing.T) { 9294 t.Parallel() 9295 testJSONMarshal(t, &ReleaseEvent{}, "{}") 9296 9297 u := &ReleaseEvent{ 9298 Action: Ptr("a"), 9299 Release: &RepositoryRelease{ 9300 Name: Ptr("n"), 9301 DiscussionCategoryName: Ptr("dcn"), 9302 ID: Ptr(int64(2)), 9303 CreatedAt: &Timestamp{referenceTime}, 9304 PublishedAt: &Timestamp{referenceTime}, 9305 URL: Ptr("url"), 9306 HTMLURL: Ptr("htmlurl"), 9307 AssetsURL: Ptr("assetsurl"), 9308 Assets: []*ReleaseAsset{{ID: Ptr(int64(1))}}, 9309 UploadURL: Ptr("uploadurl"), 9310 ZipballURL: Ptr("zipballurl"), 9311 TarballURL: Ptr("tarballurl"), 9312 Author: &User{Name: Ptr("octocat")}, 9313 NodeID: Ptr("nid"), 9314 }, 9315 Repo: &Repository{ 9316 ID: Ptr(int64(1)), 9317 URL: Ptr("s"), 9318 Name: Ptr("n"), 9319 }, 9320 Sender: &User{ 9321 Login: Ptr("l"), 9322 ID: Ptr(int64(1)), 9323 NodeID: Ptr("n"), 9324 URL: Ptr("u"), 9325 ReposURL: Ptr("r"), 9326 EventsURL: Ptr("e"), 9327 AvatarURL: Ptr("a"), 9328 }, 9329 Installation: &Installation{ 9330 ID: Ptr(int64(1)), 9331 NodeID: Ptr("nid"), 9332 AppID: Ptr(int64(1)), 9333 AppSlug: Ptr("as"), 9334 TargetID: Ptr(int64(1)), 9335 Account: &User{ 9336 Login: Ptr("l"), 9337 ID: Ptr(int64(1)), 9338 URL: Ptr("u"), 9339 AvatarURL: Ptr("a"), 9340 GravatarID: Ptr("g"), 9341 Name: Ptr("n"), 9342 Company: Ptr("c"), 9343 Blog: Ptr("b"), 9344 Location: Ptr("l"), 9345 Email: Ptr("e"), 9346 Hireable: Ptr(true), 9347 Bio: Ptr("b"), 9348 TwitterUsername: Ptr("t"), 9349 PublicRepos: Ptr(1), 9350 Followers: Ptr(1), 9351 Following: Ptr(1), 9352 CreatedAt: &Timestamp{referenceTime}, 9353 SuspendedAt: &Timestamp{referenceTime}, 9354 }, 9355 AccessTokensURL: Ptr("atu"), 9356 RepositoriesURL: Ptr("ru"), 9357 HTMLURL: Ptr("hu"), 9358 TargetType: Ptr("tt"), 9359 SingleFileName: Ptr("sfn"), 9360 RepositorySelection: Ptr("rs"), 9361 Events: []string{"e"}, 9362 SingleFilePaths: []string{"s"}, 9363 Permissions: &InstallationPermissions{ 9364 Actions: Ptr("a"), 9365 Administration: Ptr("ad"), 9366 Checks: Ptr("c"), 9367 Contents: Ptr("co"), 9368 ContentReferences: Ptr("cr"), 9369 Deployments: Ptr("d"), 9370 Environments: Ptr("e"), 9371 Issues: Ptr("i"), 9372 Metadata: Ptr("md"), 9373 Members: Ptr("m"), 9374 OrganizationAdministration: Ptr("oa"), 9375 OrganizationHooks: Ptr("oh"), 9376 OrganizationPlan: Ptr("op"), 9377 OrganizationPreReceiveHooks: Ptr("opr"), 9378 OrganizationProjects: Ptr("op"), 9379 OrganizationSecrets: Ptr("os"), 9380 OrganizationSelfHostedRunners: Ptr("osh"), 9381 OrganizationUserBlocking: Ptr("oub"), 9382 Packages: Ptr("pkg"), 9383 Pages: Ptr("pg"), 9384 PullRequests: Ptr("pr"), 9385 RepositoryHooks: Ptr("rh"), 9386 RepositoryProjects: Ptr("rp"), 9387 RepositoryPreReceiveHooks: Ptr("rprh"), 9388 Secrets: Ptr("s"), 9389 SecretScanningAlerts: Ptr("ssa"), 9390 SecurityEvents: Ptr("se"), 9391 SingleFile: Ptr("sf"), 9392 Statuses: Ptr("s"), 9393 TeamDiscussions: Ptr("td"), 9394 VulnerabilityAlerts: Ptr("va"), 9395 Workflows: Ptr("w"), 9396 }, 9397 CreatedAt: &Timestamp{referenceTime}, 9398 UpdatedAt: &Timestamp{referenceTime}, 9399 HasMultipleSingleFiles: Ptr(false), 9400 SuspendedBy: &User{ 9401 Login: Ptr("l"), 9402 ID: Ptr(int64(1)), 9403 URL: Ptr("u"), 9404 AvatarURL: Ptr("a"), 9405 GravatarID: Ptr("g"), 9406 Name: Ptr("n"), 9407 Company: Ptr("c"), 9408 Blog: Ptr("b"), 9409 Location: Ptr("l"), 9410 Email: Ptr("e"), 9411 Hireable: Ptr(true), 9412 Bio: Ptr("b"), 9413 TwitterUsername: Ptr("t"), 9414 PublicRepos: Ptr(1), 9415 Followers: Ptr(1), 9416 Following: Ptr(1), 9417 CreatedAt: &Timestamp{referenceTime}, 9418 SuspendedAt: &Timestamp{referenceTime}, 9419 }, 9420 SuspendedAt: &Timestamp{referenceTime}, 9421 }, 9422 } 9423 9424 want := `{ 9425 "action": "a", 9426 "release": { 9427 "name": "n", 9428 "discussion_category_name": "dcn", 9429 "id": 2, 9430 "created_at": ` + referenceTimeStr + `, 9431 "published_at": ` + referenceTimeStr + `, 9432 "url": "url", 9433 "html_url": "htmlurl", 9434 "assets_url": "assetsurl", 9435 "assets": [ 9436 { 9437 "id": 1 9438 } 9439 ], 9440 "upload_url": "uploadurl", 9441 "zipball_url": "zipballurl", 9442 "tarball_url": "tarballurl", 9443 "author": { 9444 "name": "octocat" 9445 }, 9446 "node_id": "nid" 9447 }, 9448 "repository": { 9449 "id": 1, 9450 "name": "n", 9451 "url": "s" 9452 }, 9453 "sender": { 9454 "login": "l", 9455 "id": 1, 9456 "node_id": "n", 9457 "avatar_url": "a", 9458 "url": "u", 9459 "events_url": "e", 9460 "repos_url": "r" 9461 }, 9462 "installation": { 9463 "id": 1, 9464 "node_id": "nid", 9465 "app_id": 1, 9466 "app_slug": "as", 9467 "target_id": 1, 9468 "account": { 9469 "login": "l", 9470 "id": 1, 9471 "avatar_url": "a", 9472 "gravatar_id": "g", 9473 "name": "n", 9474 "company": "c", 9475 "blog": "b", 9476 "location": "l", 9477 "email": "e", 9478 "hireable": true, 9479 "bio": "b", 9480 "twitter_username": "t", 9481 "public_repos": 1, 9482 "followers": 1, 9483 "following": 1, 9484 "created_at": ` + referenceTimeStr + `, 9485 "suspended_at": ` + referenceTimeStr + `, 9486 "url": "u" 9487 }, 9488 "access_tokens_url": "atu", 9489 "repositories_url": "ru", 9490 "html_url": "hu", 9491 "target_type": "tt", 9492 "single_file_name": "sfn", 9493 "repository_selection": "rs", 9494 "events": [ 9495 "e" 9496 ], 9497 "single_file_paths": [ 9498 "s" 9499 ], 9500 "permissions": { 9501 "actions": "a", 9502 "administration": "ad", 9503 "checks": "c", 9504 "contents": "co", 9505 "content_references": "cr", 9506 "deployments": "d", 9507 "environments": "e", 9508 "issues": "i", 9509 "metadata": "md", 9510 "members": "m", 9511 "organization_administration": "oa", 9512 "organization_hooks": "oh", 9513 "organization_plan": "op", 9514 "organization_pre_receive_hooks": "opr", 9515 "organization_projects": "op", 9516 "organization_secrets": "os", 9517 "organization_self_hosted_runners": "osh", 9518 "organization_user_blocking": "oub", 9519 "packages": "pkg", 9520 "pages": "pg", 9521 "pull_requests": "pr", 9522 "repository_hooks": "rh", 9523 "repository_projects": "rp", 9524 "repository_pre_receive_hooks": "rprh", 9525 "secrets": "s", 9526 "secret_scanning_alerts": "ssa", 9527 "security_events": "se", 9528 "single_file": "sf", 9529 "statuses": "s", 9530 "team_discussions": "td", 9531 "vulnerability_alerts": "va", 9532 "workflows": "w" 9533 }, 9534 "created_at": ` + referenceTimeStr + `, 9535 "updated_at": ` + referenceTimeStr + `, 9536 "has_multiple_single_files": false, 9537 "suspended_by": { 9538 "login": "l", 9539 "id": 1, 9540 "avatar_url": "a", 9541 "gravatar_id": "g", 9542 "name": "n", 9543 "company": "c", 9544 "blog": "b", 9545 "location": "l", 9546 "email": "e", 9547 "hireable": true, 9548 "bio": "b", 9549 "twitter_username": "t", 9550 "public_repos": 1, 9551 "followers": 1, 9552 "following": 1, 9553 "created_at": ` + referenceTimeStr + `, 9554 "suspended_at": ` + referenceTimeStr + `, 9555 "url": "u" 9556 }, 9557 "suspended_at": ` + referenceTimeStr + ` 9558 } 9559 }` 9560 9561 testJSONMarshal(t, u, want) 9562 } 9563 9564 func TestRepositoryRulesetEvent_Marshal(t *testing.T) { 9565 t.Parallel() 9566 testJSONMarshal(t, &RepositoryRulesetEvent{}, "{}") 9567 9568 l := make(map[string]interface{}) 9569 l["key"] = "value" 9570 9571 jsonMsg, _ := json.Marshal(&l) 9572 9573 u := &RepositoryRulesetEvent{ 9574 Action: Ptr("a"), 9575 Enterprise: &Enterprise{ 9576 ID: Ptr(1), 9577 Slug: Ptr("s"), 9578 Name: Ptr("n"), 9579 NodeID: Ptr("nid"), 9580 AvatarURL: Ptr("au"), 9581 Description: Ptr("d"), 9582 WebsiteURL: Ptr("wu"), 9583 HTMLURL: Ptr("hu"), 9584 CreatedAt: &Timestamp{referenceTime}, 9585 UpdatedAt: &Timestamp{referenceTime}, 9586 }, 9587 Installation: &Installation{ 9588 ID: Ptr(int64(1)), 9589 NodeID: Ptr("nid"), 9590 AppID: Ptr(int64(1)), 9591 AppSlug: Ptr("as"), 9592 TargetID: Ptr(int64(1)), 9593 Account: &User{ 9594 Login: Ptr("l"), 9595 ID: Ptr(int64(1)), 9596 URL: Ptr("u"), 9597 AvatarURL: Ptr("a"), 9598 GravatarID: Ptr("g"), 9599 Name: Ptr("n"), 9600 Company: Ptr("c"), 9601 Blog: Ptr("b"), 9602 Location: Ptr("l"), 9603 Email: Ptr("e"), 9604 Hireable: Ptr(true), 9605 Bio: Ptr("b"), 9606 TwitterUsername: Ptr("t"), 9607 PublicRepos: Ptr(1), 9608 Followers: Ptr(1), 9609 Following: Ptr(1), 9610 CreatedAt: &Timestamp{referenceTime}, 9611 SuspendedAt: &Timestamp{referenceTime}, 9612 }, 9613 AccessTokensURL: Ptr("atu"), 9614 RepositoriesURL: Ptr("ru"), 9615 HTMLURL: Ptr("hu"), 9616 TargetType: Ptr("tt"), 9617 SingleFileName: Ptr("sfn"), 9618 RepositorySelection: Ptr("rs"), 9619 Events: []string{"e"}, 9620 SingleFilePaths: []string{"s"}, 9621 Permissions: &InstallationPermissions{ 9622 Actions: Ptr("a"), 9623 Administration: Ptr("ad"), 9624 Checks: Ptr("c"), 9625 Contents: Ptr("co"), 9626 ContentReferences: Ptr("cr"), 9627 Deployments: Ptr("d"), 9628 Environments: Ptr("e"), 9629 Issues: Ptr("i"), 9630 Metadata: Ptr("md"), 9631 Members: Ptr("m"), 9632 OrganizationAdministration: Ptr("oa"), 9633 OrganizationHooks: Ptr("oh"), 9634 OrganizationPlan: Ptr("op"), 9635 OrganizationPreReceiveHooks: Ptr("opr"), 9636 OrganizationProjects: Ptr("op"), 9637 OrganizationSecrets: Ptr("os"), 9638 OrganizationSelfHostedRunners: Ptr("osh"), 9639 OrganizationUserBlocking: Ptr("oub"), 9640 Packages: Ptr("pkg"), 9641 Pages: Ptr("pg"), 9642 PullRequests: Ptr("pr"), 9643 RepositoryHooks: Ptr("rh"), 9644 RepositoryProjects: Ptr("rp"), 9645 RepositoryPreReceiveHooks: Ptr("rprh"), 9646 Secrets: Ptr("s"), 9647 SecretScanningAlerts: Ptr("ssa"), 9648 SecurityEvents: Ptr("se"), 9649 SingleFile: Ptr("sf"), 9650 Statuses: Ptr("s"), 9651 TeamDiscussions: Ptr("td"), 9652 VulnerabilityAlerts: Ptr("va"), 9653 Workflows: Ptr("w"), 9654 }, 9655 CreatedAt: &Timestamp{referenceTime}, 9656 UpdatedAt: &Timestamp{referenceTime}, 9657 HasMultipleSingleFiles: Ptr(false), 9658 SuspendedBy: &User{ 9659 Login: Ptr("l"), 9660 ID: Ptr(int64(1)), 9661 URL: Ptr("u"), 9662 AvatarURL: Ptr("a"), 9663 GravatarID: Ptr("g"), 9664 Name: Ptr("n"), 9665 Company: Ptr("c"), 9666 Blog: Ptr("b"), 9667 Location: Ptr("l"), 9668 Email: Ptr("e"), 9669 Hireable: Ptr(true), 9670 Bio: Ptr("b"), 9671 TwitterUsername: Ptr("t"), 9672 PublicRepos: Ptr(1), 9673 Followers: Ptr(1), 9674 Following: Ptr(1), 9675 CreatedAt: &Timestamp{referenceTime}, 9676 SuspendedAt: &Timestamp{referenceTime}, 9677 }, 9678 SuspendedAt: &Timestamp{referenceTime}, 9679 }, 9680 Organization: &Organization{ 9681 BillingEmail: Ptr("be"), 9682 Blog: Ptr("b"), 9683 Company: Ptr("c"), 9684 Email: Ptr("e"), 9685 TwitterUsername: Ptr("tu"), 9686 Location: Ptr("loc"), 9687 Name: Ptr("n"), 9688 Description: Ptr("d"), 9689 IsVerified: Ptr(true), 9690 HasOrganizationProjects: Ptr(true), 9691 HasRepositoryProjects: Ptr(true), 9692 DefaultRepoPermission: Ptr("drp"), 9693 MembersCanCreateRepos: Ptr(true), 9694 MembersCanCreateInternalRepos: Ptr(true), 9695 MembersCanCreatePrivateRepos: Ptr(true), 9696 MembersCanCreatePublicRepos: Ptr(false), 9697 MembersAllowedRepositoryCreationType: Ptr("marct"), 9698 MembersCanCreatePages: Ptr(true), 9699 MembersCanCreatePublicPages: Ptr(false), 9700 MembersCanCreatePrivatePages: Ptr(true), 9701 }, 9702 Repository: &Repository{ 9703 ID: Ptr(int64(1)), 9704 URL: Ptr("u"), 9705 Name: Ptr("n"), 9706 }, 9707 RepositoryRuleset: &RepositoryRuleset{ 9708 ID: 1, 9709 Name: "n", 9710 Target: Ptr("branch"), 9711 SourceType: Ptr("Repository"), 9712 Source: "s", 9713 Enforcement: "disabled", 9714 BypassActors: []*BypassActor{ 9715 { 9716 ActorID: Ptr(int64(234)), 9717 ActorType: Ptr("Team"), 9718 BypassMode: Ptr("Always"), 9719 }, 9720 }, 9721 CurrentUserCanBypass: Ptr("always"), 9722 NodeID: Ptr("n"), 9723 Links: &RepositoryRulesetLink{ 9724 Self: &RulesetLink{ 9725 HRef: Ptr("href"), 9726 }, 9727 HTML: &RulesetLink{ 9728 HRef: Ptr("href"), 9729 }, 9730 }, 9731 Conditions: json.RawMessage(jsonMsg), 9732 Rules: []*RepositoryRulesetRule{ 9733 { 9734 Creation: &RepositoryRulesetRuleType{ 9735 Type: "creation", 9736 }, 9737 Update: &RepositoryRulesetUpdateRule{ 9738 Type: "update", 9739 Parameters: &UpdateAllowsFetchAndMergeRuleParameters{ 9740 UpdateAllowsFetchAndMerge: true, 9741 }, 9742 }, 9743 Deletion: &RepositoryRulesetRuleType{ 9744 Type: "deletion", 9745 }, 9746 RequiredLinearHistory: &RepositoryRulesetRuleType{ 9747 Type: "required_linear_history", 9748 }, 9749 MergeQueue: &RepositoryRulesetMergeQueueRule{ 9750 Type: "merge_queue", 9751 Parameters: &MergeQueueRuleParameters{ 9752 CheckResponseTimeoutMinutes: 35, 9753 GroupingStrategy: "HEADGREEN", 9754 MaxEntriesToBuild: 8, 9755 MaxEntriesToMerge: 4, 9756 MergeMethod: "SQUASH", 9757 MinEntriesToMerge: 2, 9758 MinEntriesToMergeWaitMinutes: 13, 9759 }, 9760 }, 9761 RequiredDeployments: &RepositoryRulesetRequiredDeploymentsRule{ 9762 Type: "required_deployments", 9763 Parameters: &RequiredDeploymentEnvironmentsRuleParameters{ 9764 RequiredDeploymentEnvironments: []string{"test"}, 9765 }, 9766 }, 9767 RequiredSignatures: &RepositoryRulesetRuleType{ 9768 Type: "required_signatures", 9769 }, 9770 PullRequest: &RepositoryRulesetPullRequestRule{ 9771 Type: "pull_request", 9772 Parameters: &PullRequestRuleParameters{ 9773 RequireCodeOwnerReview: true, 9774 RequireLastPushApproval: true, 9775 RequiredApprovingReviewCount: 1, 9776 RequiredReviewThreadResolution: true, 9777 DismissStaleReviewsOnPush: true, 9778 }, 9779 }, 9780 RequiredStatusChecks: &RepositoryRulesetRequiredStatusChecksRule{ 9781 Type: "required_status_checks", 9782 Parameters: &RequiredStatusChecksRuleParameters{ 9783 RequiredStatusChecks: []RuleRequiredStatusChecks{ 9784 { 9785 Context: "test", 9786 IntegrationID: Ptr(int64(1)), 9787 }, 9788 }, 9789 StrictRequiredStatusChecksPolicy: true, 9790 }, 9791 }, 9792 NonFastForward: &RepositoryRulesetRuleType{ 9793 Type: "non_fast_forward", 9794 }, 9795 CommitMessagePattern: &RepositoryRulesetPatternRule{ 9796 Type: "commit_message_pattern", 9797 Parameters: &RulePatternParameters{ 9798 Name: Ptr("avoid test commits"), 9799 Negate: Ptr(true), 9800 Operator: "starts_with", 9801 Pattern: "[test]", 9802 }, 9803 }, 9804 CommitAuthorEmailPattern: &RepositoryRulesetPatternRule{ 9805 Type: "commit_author_email_pattern", 9806 Parameters: &RulePatternParameters{ 9807 Operator: "contains", 9808 Pattern: "github", 9809 }, 9810 }, 9811 CommitterEmailPattern: &RepositoryRulesetPatternRule{ 9812 Type: "committer_email_pattern", 9813 Parameters: &RulePatternParameters{ 9814 Name: Ptr("avoid commit emails"), 9815 Negate: Ptr(true), 9816 Operator: "ends_with", 9817 Pattern: "abc", 9818 }, 9819 }, 9820 BranchNamePattern: &RepositoryRulesetPatternRule{ 9821 Type: "branch_name_pattern", 9822 Parameters: &RulePatternParameters{ 9823 Name: Ptr("avoid branch names"), 9824 Negate: Ptr(true), 9825 Operator: "regex", 9826 Pattern: "github$", 9827 }, 9828 }, 9829 TagNamePattern: &RepositoryRulesetPatternRule{ 9830 Type: "tag_name_pattern", 9831 Parameters: &RulePatternParameters{ 9832 Name: Ptr("avoid tag names"), 9833 Negate: Ptr(true), 9834 Operator: "contains", 9835 Pattern: "github", 9836 }, 9837 }, 9838 FilePathRestriction: &RepositoryRulesetFilePathRestrictionRule{ 9839 Type: "file_path_restriction", 9840 Parameters: &RuleFileParameters{ 9841 RestrictedFilePaths: &[]string{"/a/file"}, 9842 }, 9843 }, 9844 MaxFilePathLength: &RepositoryRulesetMaxFilePathLengthRule{ 9845 Type: "max_file_path_length", 9846 Parameters: &RuleMaxFilePathLengthParameters{ 9847 MaxFilePathLength: 255, 9848 }, 9849 }, 9850 FileExtensionRestriction: &RepositoryRulesetFileExtensionRestrictionRule{ 9851 Type: "file_extension_restriction", 9852 Parameters: &RuleFileExtensionRestrictionParameters{ 9853 RestrictedFileExtensions: []string{".exe"}, 9854 }, 9855 }, 9856 MaxFileSize: &RepositoryRulesetMaxFileSizeRule{ 9857 Type: "max_file_size", 9858 Parameters: &RuleMaxFileSizeParameters{ 9859 MaxFileSize: 1024, 9860 }, 9861 }, 9862 Workflows: &RepositoryRulesetWorkflowsRule{ 9863 Type: "workflows", 9864 Parameters: &RequiredWorkflowsRuleParameters{ 9865 RequiredWorkflows: []*RuleRequiredWorkflow{ 9866 { 9867 Path: ".github/workflows/test.yml", 9868 RepositoryID: Ptr(int64(1)), 9869 }, 9870 }, 9871 }, 9872 }, 9873 CodeScanning: &RepositoryRulesetCodeScanningRule{ 9874 Type: "code_scanning", 9875 Parameters: &RuleCodeScanningParameters{ 9876 CodeScanningTools: []*CodeScanningTool{{ 9877 AlertsThreshold: "alert", 9878 SecurityAlertsThreshold: "security", 9879 Tool: "tool", 9880 }}, 9881 }, 9882 }, 9883 }, 9884 }, 9885 CreatedAt: &Timestamp{referenceTime}, 9886 UpdatedAt: &Timestamp{referenceTime}, 9887 }, 9888 Changes: &RepositoryRulesetEditedChanges{ 9889 Name: &RepositoryRulesetEditedSource{ 9890 From: Ptr("f"), 9891 }, 9892 Enforcement: &RepositoryRulesetEditedSource{ 9893 From: Ptr("e"), 9894 }, 9895 Conditions: &RepositoryRulesetEditedConditions{ 9896 Added: []*RepositoryRulesetRefCondition{ 9897 { 9898 RefName: &RulesetRefConditionParameters{ 9899 Include: []string{"refs/heads/main", "refs/heads/master"}, 9900 Exclude: []string{"refs/heads/dev*"}, 9901 }, 9902 }, 9903 }, 9904 Deleted: []*RepositoryRulesetRefCondition{ 9905 { 9906 RefName: &RulesetRefConditionParameters{ 9907 Include: []string{"refs/heads/main", "refs/heads/master"}, 9908 Exclude: []string{"refs/heads/dev*"}, 9909 }, 9910 }, 9911 }, 9912 Updated: []*RepositoryRulesetEditedUpdatedConditions{ 9913 { 9914 Condition: &RepositoryRulesetRefCondition{ 9915 RefName: &RulesetRefConditionParameters{ 9916 Include: []string{"refs/heads/main", "refs/heads/master"}, 9917 Exclude: []string{"refs/heads/dev*"}, 9918 }, 9919 }, 9920 Changes: &RepositoryRulesetUpdatedConditionsEdited{ 9921 ConditionType: &RepositoryRulesetEditedSource{ 9922 From: Ptr("c"), 9923 }, 9924 Target: &RepositoryRulesetEditedSource{ 9925 From: Ptr("t"), 9926 }, 9927 Include: &RepositoryRulesetEditedSources{ 9928 From: []string{"from"}, 9929 }, 9930 Exclude: &RepositoryRulesetEditedSources{ 9931 From: []string{"to"}, 9932 }, 9933 }, 9934 }, 9935 }, 9936 }, 9937 Rules: &RepositoryRulesetEditedRules{ 9938 Added: []*RepositoryRulesetRule{ 9939 // Creating just one object with all the possible rules for testing 9940 { 9941 Creation: &RepositoryRulesetRuleType{ 9942 Type: "creation", 9943 }, 9944 Update: &RepositoryRulesetUpdateRule{ 9945 Type: "update", 9946 Parameters: &UpdateAllowsFetchAndMergeRuleParameters{ 9947 UpdateAllowsFetchAndMerge: true, 9948 }, 9949 }, 9950 Deletion: &RepositoryRulesetRuleType{ 9951 Type: "deletion", 9952 }, 9953 RequiredLinearHistory: &RepositoryRulesetRuleType{ 9954 Type: "required_linear_history", 9955 }, 9956 MergeQueue: &RepositoryRulesetMergeQueueRule{ 9957 Type: "merge_queue", 9958 Parameters: &MergeQueueRuleParameters{ 9959 CheckResponseTimeoutMinutes: 35, 9960 GroupingStrategy: "HEADGREEN", 9961 MaxEntriesToBuild: 8, 9962 MaxEntriesToMerge: 4, 9963 MergeMethod: "SQUASH", 9964 MinEntriesToMerge: 2, 9965 MinEntriesToMergeWaitMinutes: 13, 9966 }, 9967 }, 9968 RequiredDeployments: &RepositoryRulesetRequiredDeploymentsRule{ 9969 Type: "required_deployments", 9970 Parameters: &RequiredDeploymentEnvironmentsRuleParameters{ 9971 RequiredDeploymentEnvironments: []string{"test"}, 9972 }, 9973 }, 9974 RequiredSignatures: &RepositoryRulesetRuleType{ 9975 Type: "required_signatures", 9976 }, 9977 PullRequest: &RepositoryRulesetPullRequestRule{ 9978 Type: "pull_request", 9979 Parameters: &PullRequestRuleParameters{ 9980 RequireCodeOwnerReview: true, 9981 RequireLastPushApproval: true, 9982 RequiredApprovingReviewCount: 1, 9983 RequiredReviewThreadResolution: true, 9984 DismissStaleReviewsOnPush: true, 9985 }, 9986 }, 9987 RequiredStatusChecks: &RepositoryRulesetRequiredStatusChecksRule{ 9988 Type: "required_status_checks", 9989 Parameters: &RequiredStatusChecksRuleParameters{ 9990 RequiredStatusChecks: []RuleRequiredStatusChecks{ 9991 { 9992 Context: "test", 9993 IntegrationID: Ptr(int64(1)), 9994 }, 9995 }, 9996 StrictRequiredStatusChecksPolicy: true, 9997 }, 9998 }, 9999 NonFastForward: &RepositoryRulesetRuleType{ 10000 Type: "non_fast_forward", 10001 }, 10002 CommitMessagePattern: &RepositoryRulesetPatternRule{ 10003 Type: "commit_message_pattern", 10004 Parameters: &RulePatternParameters{ 10005 Name: Ptr("avoid test commits"), 10006 Negate: Ptr(true), 10007 Operator: "starts_with", 10008 Pattern: "[test]", 10009 }, 10010 }, 10011 CommitAuthorEmailPattern: &RepositoryRulesetPatternRule{ 10012 Type: "commit_author_email_pattern", 10013 Parameters: &RulePatternParameters{ 10014 Operator: "contains", 10015 Pattern: "github", 10016 }, 10017 }, 10018 CommitterEmailPattern: &RepositoryRulesetPatternRule{ 10019 Type: "committer_email_pattern", 10020 Parameters: &RulePatternParameters{ 10021 Name: Ptr("avoid commit emails"), 10022 Negate: Ptr(true), 10023 Operator: "ends_with", 10024 Pattern: "abc", 10025 }, 10026 }, 10027 BranchNamePattern: &RepositoryRulesetPatternRule{ 10028 Type: "branch_name_pattern", 10029 Parameters: &RulePatternParameters{ 10030 Name: Ptr("avoid branch names"), 10031 Negate: Ptr(true), 10032 Operator: "regex", 10033 Pattern: "github$", 10034 }, 10035 }, 10036 TagNamePattern: &RepositoryRulesetPatternRule{ 10037 Type: "tag_name_pattern", 10038 Parameters: &RulePatternParameters{ 10039 Name: Ptr("avoid tag names"), 10040 Negate: Ptr(true), 10041 Operator: "contains", 10042 Pattern: "github", 10043 }, 10044 }, 10045 FilePathRestriction: &RepositoryRulesetFilePathRestrictionRule{ 10046 Type: "file_path_restriction", 10047 Parameters: &RuleFileParameters{ 10048 RestrictedFilePaths: &[]string{"/a/file"}, 10049 }, 10050 }, 10051 MaxFilePathLength: &RepositoryRulesetMaxFilePathLengthRule{ 10052 Type: "max_file_path_length", 10053 Parameters: &RuleMaxFilePathLengthParameters{ 10054 MaxFilePathLength: 255, 10055 }, 10056 }, 10057 FileExtensionRestriction: &RepositoryRulesetFileExtensionRestrictionRule{ 10058 Type: "file_extension_restriction", 10059 Parameters: &RuleFileExtensionRestrictionParameters{ 10060 RestrictedFileExtensions: []string{".exe"}, 10061 }, 10062 }, 10063 MaxFileSize: &RepositoryRulesetMaxFileSizeRule{ 10064 Type: "max_file_size", 10065 Parameters: &RuleMaxFileSizeParameters{ 10066 MaxFileSize: 1024, 10067 }, 10068 }, 10069 Workflows: &RepositoryRulesetWorkflowsRule{ 10070 Type: "workflows", 10071 Parameters: &RequiredWorkflowsRuleParameters{ 10072 RequiredWorkflows: []*RuleRequiredWorkflow{ 10073 { 10074 Path: ".github/workflows/test.yml", 10075 RepositoryID: Ptr(int64(1)), 10076 }, 10077 }, 10078 }, 10079 }, 10080 CodeScanning: &RepositoryRulesetCodeScanningRule{ 10081 Type: "code_scanning", 10082 Parameters: &RuleCodeScanningParameters{ 10083 CodeScanningTools: []*CodeScanningTool{{ 10084 AlertsThreshold: "alert", 10085 SecurityAlertsThreshold: "security", 10086 Tool: "tool", 10087 }}, 10088 }, 10089 }, 10090 }, 10091 }, 10092 Deleted: []*RepositoryRulesetRule{ 10093 // Creating just one object with all the possible rules for testing 10094 { 10095 Creation: &RepositoryRulesetRuleType{ 10096 Type: "creation", 10097 }, 10098 Update: &RepositoryRulesetUpdateRule{ 10099 Type: "update", 10100 Parameters: &UpdateAllowsFetchAndMergeRuleParameters{ 10101 UpdateAllowsFetchAndMerge: true, 10102 }, 10103 }, 10104 Deletion: &RepositoryRulesetRuleType{ 10105 Type: "deletion", 10106 }, 10107 RequiredLinearHistory: &RepositoryRulesetRuleType{ 10108 Type: "required_linear_history", 10109 }, 10110 MergeQueue: &RepositoryRulesetMergeQueueRule{ 10111 Type: "merge_queue", 10112 Parameters: &MergeQueueRuleParameters{ 10113 CheckResponseTimeoutMinutes: 35, 10114 GroupingStrategy: "HEADGREEN", 10115 MaxEntriesToBuild: 8, 10116 MaxEntriesToMerge: 4, 10117 MergeMethod: "SQUASH", 10118 MinEntriesToMerge: 2, 10119 MinEntriesToMergeWaitMinutes: 13, 10120 }, 10121 }, 10122 RequiredDeployments: &RepositoryRulesetRequiredDeploymentsRule{ 10123 Type: "required_deployments", 10124 Parameters: &RequiredDeploymentEnvironmentsRuleParameters{ 10125 RequiredDeploymentEnvironments: []string{"test"}, 10126 }, 10127 }, 10128 RequiredSignatures: &RepositoryRulesetRuleType{ 10129 Type: "required_signatures", 10130 }, 10131 PullRequest: &RepositoryRulesetPullRequestRule{ 10132 Type: "pull_request", 10133 Parameters: &PullRequestRuleParameters{ 10134 RequireCodeOwnerReview: true, 10135 RequireLastPushApproval: true, 10136 RequiredApprovingReviewCount: 1, 10137 RequiredReviewThreadResolution: true, 10138 DismissStaleReviewsOnPush: true, 10139 }, 10140 }, 10141 RequiredStatusChecks: &RepositoryRulesetRequiredStatusChecksRule{ 10142 Type: "required_status_checks", 10143 Parameters: &RequiredStatusChecksRuleParameters{ 10144 RequiredStatusChecks: []RuleRequiredStatusChecks{ 10145 { 10146 Context: "test", 10147 IntegrationID: Ptr(int64(1)), 10148 }, 10149 }, 10150 StrictRequiredStatusChecksPolicy: true, 10151 }, 10152 }, 10153 NonFastForward: &RepositoryRulesetRuleType{ 10154 Type: "non_fast_forward", 10155 }, 10156 CommitMessagePattern: &RepositoryRulesetPatternRule{ 10157 Type: "commit_message_pattern", 10158 Parameters: &RulePatternParameters{ 10159 Name: Ptr("avoid test commits"), 10160 Negate: Ptr(true), 10161 Operator: "starts_with", 10162 Pattern: "[test]", 10163 }, 10164 }, 10165 CommitAuthorEmailPattern: &RepositoryRulesetPatternRule{ 10166 Type: "commit_author_email_pattern", 10167 Parameters: &RulePatternParameters{ 10168 Operator: "contains", 10169 Pattern: "github", 10170 }, 10171 }, 10172 CommitterEmailPattern: &RepositoryRulesetPatternRule{ 10173 Type: "committer_email_pattern", 10174 Parameters: &RulePatternParameters{ 10175 Name: Ptr("avoid commit emails"), 10176 Negate: Ptr(true), 10177 Operator: "ends_with", 10178 Pattern: "abc", 10179 }, 10180 }, 10181 BranchNamePattern: &RepositoryRulesetPatternRule{ 10182 Type: "branch_name_pattern", 10183 Parameters: &RulePatternParameters{ 10184 Name: Ptr("avoid branch names"), 10185 Negate: Ptr(true), 10186 Operator: "regex", 10187 Pattern: "github$", 10188 }, 10189 }, 10190 TagNamePattern: &RepositoryRulesetPatternRule{ 10191 Type: "tag_name_pattern", 10192 Parameters: &RulePatternParameters{ 10193 Name: Ptr("avoid tag names"), 10194 Negate: Ptr(true), 10195 Operator: "contains", 10196 Pattern: "github", 10197 }, 10198 }, 10199 FilePathRestriction: &RepositoryRulesetFilePathRestrictionRule{ 10200 Type: "file_path_restriction", 10201 Parameters: &RuleFileParameters{ 10202 RestrictedFilePaths: &[]string{"/a/file"}, 10203 }, 10204 }, 10205 MaxFilePathLength: &RepositoryRulesetMaxFilePathLengthRule{ 10206 Type: "max_file_path_length", 10207 Parameters: &RuleMaxFilePathLengthParameters{ 10208 MaxFilePathLength: 255, 10209 }, 10210 }, 10211 FileExtensionRestriction: &RepositoryRulesetFileExtensionRestrictionRule{ 10212 Type: "file_extension_restriction", 10213 Parameters: &RuleFileExtensionRestrictionParameters{ 10214 RestrictedFileExtensions: []string{".exe"}, 10215 }, 10216 }, 10217 MaxFileSize: &RepositoryRulesetMaxFileSizeRule{ 10218 Type: "max_file_size", 10219 Parameters: &RuleMaxFileSizeParameters{ 10220 MaxFileSize: 1024, 10221 }, 10222 }, 10223 Workflows: &RepositoryRulesetWorkflowsRule{ 10224 Type: "workflows", 10225 Parameters: &RequiredWorkflowsRuleParameters{ 10226 RequiredWorkflows: []*RuleRequiredWorkflow{ 10227 { 10228 Path: ".github/workflows/test.yml", 10229 RepositoryID: Ptr(int64(1)), 10230 }, 10231 }, 10232 }, 10233 }, 10234 CodeScanning: &RepositoryRulesetCodeScanningRule{ 10235 Type: "code_scanning", 10236 Parameters: &RuleCodeScanningParameters{ 10237 CodeScanningTools: []*CodeScanningTool{{ 10238 AlertsThreshold: "alert", 10239 SecurityAlertsThreshold: "security", 10240 Tool: "tool", 10241 }}, 10242 }, 10243 }, 10244 }, 10245 }, 10246 Updated: []*RepositoryRulesetUpdatedRules{ 10247 { 10248 Rule: &RepositoryRulesetRule{ 10249 Creation: &RepositoryRulesetRuleType{ 10250 Type: "creation", 10251 }, 10252 Update: &RepositoryRulesetUpdateRule{ 10253 Type: "update", 10254 Parameters: &UpdateAllowsFetchAndMergeRuleParameters{ 10255 UpdateAllowsFetchAndMerge: true, 10256 }, 10257 }, 10258 Deletion: &RepositoryRulesetRuleType{ 10259 Type: "deletion", 10260 }, 10261 RequiredLinearHistory: &RepositoryRulesetRuleType{ 10262 Type: "required_linear_history", 10263 }, 10264 MergeQueue: &RepositoryRulesetMergeQueueRule{ 10265 Type: "merge_queue", 10266 Parameters: &MergeQueueRuleParameters{ 10267 CheckResponseTimeoutMinutes: 35, 10268 GroupingStrategy: "HEADGREEN", 10269 MaxEntriesToBuild: 8, 10270 MaxEntriesToMerge: 4, 10271 MergeMethod: "SQUASH", 10272 MinEntriesToMerge: 2, 10273 MinEntriesToMergeWaitMinutes: 13, 10274 }, 10275 }, 10276 RequiredDeployments: &RepositoryRulesetRequiredDeploymentsRule{ 10277 Type: "required_deployments", 10278 Parameters: &RequiredDeploymentEnvironmentsRuleParameters{ 10279 RequiredDeploymentEnvironments: []string{"test"}, 10280 }, 10281 }, 10282 RequiredSignatures: &RepositoryRulesetRuleType{ 10283 Type: "required_signatures", 10284 }, 10285 PullRequest: &RepositoryRulesetPullRequestRule{ 10286 Type: "pull_request", 10287 Parameters: &PullRequestRuleParameters{ 10288 RequireCodeOwnerReview: true, 10289 RequireLastPushApproval: true, 10290 RequiredApprovingReviewCount: 1, 10291 RequiredReviewThreadResolution: true, 10292 DismissStaleReviewsOnPush: true, 10293 }, 10294 }, 10295 RequiredStatusChecks: &RepositoryRulesetRequiredStatusChecksRule{ 10296 Type: "required_status_checks", 10297 Parameters: &RequiredStatusChecksRuleParameters{ 10298 RequiredStatusChecks: []RuleRequiredStatusChecks{ 10299 { 10300 Context: "test", 10301 IntegrationID: Ptr(int64(1)), 10302 }, 10303 }, 10304 StrictRequiredStatusChecksPolicy: true, 10305 }, 10306 }, 10307 NonFastForward: &RepositoryRulesetRuleType{ 10308 Type: "non_fast_forward", 10309 }, 10310 CommitMessagePattern: &RepositoryRulesetPatternRule{ 10311 Type: "commit_message_pattern", 10312 Parameters: &RulePatternParameters{ 10313 Name: Ptr("avoid test commits"), 10314 Negate: Ptr(true), 10315 Operator: "starts_with", 10316 Pattern: "[test]", 10317 }, 10318 }, 10319 CommitAuthorEmailPattern: &RepositoryRulesetPatternRule{ 10320 Type: "commit_author_email_pattern", 10321 Parameters: &RulePatternParameters{ 10322 Operator: "contains", 10323 Pattern: "github", 10324 }, 10325 }, 10326 CommitterEmailPattern: &RepositoryRulesetPatternRule{ 10327 Type: "committer_email_pattern", 10328 Parameters: &RulePatternParameters{ 10329 Name: Ptr("avoid commit emails"), 10330 Negate: Ptr(true), 10331 Operator: "ends_with", 10332 Pattern: "abc", 10333 }, 10334 }, 10335 BranchNamePattern: &RepositoryRulesetPatternRule{ 10336 Type: "branch_name_pattern", 10337 Parameters: &RulePatternParameters{ 10338 Name: Ptr("avoid branch names"), 10339 Negate: Ptr(true), 10340 Operator: "regex", 10341 Pattern: "github$", 10342 }, 10343 }, 10344 TagNamePattern: &RepositoryRulesetPatternRule{ 10345 Type: "tag_name_pattern", 10346 Parameters: &RulePatternParameters{ 10347 Name: Ptr("avoid tag names"), 10348 Negate: Ptr(true), 10349 Operator: "contains", 10350 Pattern: "github", 10351 }, 10352 }, 10353 FilePathRestriction: &RepositoryRulesetFilePathRestrictionRule{ 10354 Type: "file_path_restriction", 10355 Parameters: &RuleFileParameters{ 10356 RestrictedFilePaths: &[]string{"/a/file"}, 10357 }, 10358 }, 10359 MaxFilePathLength: &RepositoryRulesetMaxFilePathLengthRule{ 10360 Type: "max_file_path_length", 10361 Parameters: &RuleMaxFilePathLengthParameters{ 10362 MaxFilePathLength: 255, 10363 }, 10364 }, 10365 FileExtensionRestriction: &RepositoryRulesetFileExtensionRestrictionRule{ 10366 Type: "file_extension_restriction", 10367 Parameters: &RuleFileExtensionRestrictionParameters{ 10368 RestrictedFileExtensions: []string{".exe"}, 10369 }, 10370 }, 10371 MaxFileSize: &RepositoryRulesetMaxFileSizeRule{ 10372 Type: "max_file_size", 10373 Parameters: &RuleMaxFileSizeParameters{ 10374 MaxFileSize: 1024, 10375 }, 10376 }, 10377 Workflows: &RepositoryRulesetWorkflowsRule{ 10378 Type: "workflows", 10379 Parameters: &RequiredWorkflowsRuleParameters{ 10380 RequiredWorkflows: []*RuleRequiredWorkflow{ 10381 { 10382 Path: ".github/workflows/test.yml", 10383 RepositoryID: Ptr(int64(1)), 10384 }, 10385 }, 10386 }, 10387 }, 10388 CodeScanning: &RepositoryRulesetCodeScanningRule{ 10389 Type: "code_scanning", 10390 Parameters: &RuleCodeScanningParameters{ 10391 CodeScanningTools: []*CodeScanningTool{{ 10392 AlertsThreshold: "alert", 10393 SecurityAlertsThreshold: "security", 10394 Tool: "tool", 10395 }}, 10396 }, 10397 }, 10398 }, 10399 Changes: &RepositoryRulesetEditedRuleChanges{ 10400 Configuration: &RepositoryRulesetEditedSources{ 10401 From: []string{"from"}, 10402 }, 10403 RuleType: &RepositoryRulesetEditedSources{ 10404 From: []string{"from"}, 10405 }, 10406 Pattern: &RepositoryRulesetEditedSources{ 10407 From: []string{"from"}, 10408 }, 10409 }, 10410 }, 10411 }, 10412 }, 10413 }, 10414 Sender: &User{ 10415 Login: Ptr("l"), 10416 ID: Ptr(int64(1)), 10417 NodeID: Ptr("n"), 10418 URL: Ptr("u"), 10419 ReposURL: Ptr("r"), 10420 EventsURL: Ptr("e"), 10421 AvatarURL: Ptr("a"), 10422 }, 10423 } 10424 10425 want := `{ 10426 "action": "a", 10427 "enterprise": { 10428 "id": 1, 10429 "slug": "s", 10430 "name": "n", 10431 "node_id": "nid", 10432 "avatar_url": "au", 10433 "description": "d", 10434 "website_url": "wu", 10435 "html_url": "hu", 10436 "created_at": ` + referenceTimeStr + `, 10437 "updated_at": ` + referenceTimeStr + ` 10438 }, 10439 "installation": { 10440 "id": 1, 10441 "node_id": "nid", 10442 "app_id": 1, 10443 "app_slug": "as", 10444 "target_id": 1, 10445 "account": { 10446 "login": "l", 10447 "id": 1, 10448 "avatar_url": "a", 10449 "gravatar_id": "g", 10450 "name": "n", 10451 "company": "c", 10452 "blog": "b", 10453 "location": "l", 10454 "email": "e", 10455 "hireable": true, 10456 "bio": "b", 10457 "twitter_username": "t", 10458 "public_repos": 1, 10459 "followers": 1, 10460 "following": 1, 10461 "created_at": ` + referenceTimeStr + `, 10462 "suspended_at": ` + referenceTimeStr + `, 10463 "url": "u" 10464 }, 10465 "access_tokens_url": "atu", 10466 "repositories_url": "ru", 10467 "html_url": "hu", 10468 "target_type": "tt", 10469 "single_file_name": "sfn", 10470 "repository_selection": "rs", 10471 "events": [ 10472 "e" 10473 ], 10474 "single_file_paths": [ 10475 "s" 10476 ], 10477 "permissions": { 10478 "actions": "a", 10479 "administration": "ad", 10480 "checks": "c", 10481 "contents": "co", 10482 "content_references": "cr", 10483 "deployments": "d", 10484 "environments": "e", 10485 "issues": "i", 10486 "metadata": "md", 10487 "members": "m", 10488 "organization_administration": "oa", 10489 "organization_hooks": "oh", 10490 "organization_plan": "op", 10491 "organization_pre_receive_hooks": "opr", 10492 "organization_projects": "op", 10493 "organization_secrets": "os", 10494 "organization_self_hosted_runners": "osh", 10495 "organization_user_blocking": "oub", 10496 "packages": "pkg", 10497 "pages": "pg", 10498 "pull_requests": "pr", 10499 "repository_hooks": "rh", 10500 "repository_projects": "rp", 10501 "repository_pre_receive_hooks": "rprh", 10502 "secrets": "s", 10503 "secret_scanning_alerts": "ssa", 10504 "security_events": "se", 10505 "single_file": "sf", 10506 "statuses": "s", 10507 "team_discussions": "td", 10508 "vulnerability_alerts": "va", 10509 "workflows": "w" 10510 }, 10511 "created_at": ` + referenceTimeStr + `, 10512 "updated_at": ` + referenceTimeStr + `, 10513 "has_multiple_single_files": false, 10514 "suspended_by": { 10515 "login": "l", 10516 "id": 1, 10517 "avatar_url": "a", 10518 "gravatar_id": "g", 10519 "name": "n", 10520 "company": "c", 10521 "blog": "b", 10522 "location": "l", 10523 "email": "e", 10524 "hireable": true, 10525 "bio": "b", 10526 "twitter_username": "t", 10527 "public_repos": 1, 10528 "followers": 1, 10529 "following": 1, 10530 "created_at": ` + referenceTimeStr + `, 10531 "suspended_at": ` + referenceTimeStr + `, 10532 "url": "u" 10533 }, 10534 "suspended_at": ` + referenceTimeStr + ` 10535 }, 10536 "organization": { 10537 "name": "n", 10538 "company": "c", 10539 "blog": "b", 10540 "location": "loc", 10541 "email": "e", 10542 "twitter_username": "tu", 10543 "description": "d", 10544 "billing_email": "be", 10545 "is_verified": true, 10546 "has_organization_projects": true, 10547 "has_repository_projects": true, 10548 "default_repository_permission": "drp", 10549 "members_can_create_repositories": true, 10550 "members_can_create_public_repositories": false, 10551 "members_can_create_private_repositories": true, 10552 "members_can_create_internal_repositories": true, 10553 "members_allowed_repository_creation_type": "marct", 10554 "members_can_create_pages": true, 10555 "members_can_create_public_pages": false, 10556 "members_can_create_private_pages": true 10557 }, 10558 "repository": { 10559 "id": 1, 10560 "name": "n", 10561 "url": "u" 10562 }, 10563 "repository_ruleset": { 10564 "id": 1, 10565 "name": "n", 10566 "target": "branch", 10567 "source_type": "Repository", 10568 "source": "s", 10569 "enforcement": "disabled", 10570 "bypass_actors": [ 10571 { 10572 "actor_id": 234, 10573 "actor_type": "Team", 10574 "bypass_mode": "Always" 10575 } 10576 ], 10577 "current_user_can_bypass": "always", 10578 "node_id": "n", 10579 "_links": { 10580 "self": { 10581 "href": "href" 10582 }, 10583 "html": { 10584 "href": "href" 10585 } 10586 }, 10587 "conditions": { 10588 "key": "value" 10589 }, 10590 "rules": [ 10591 { 10592 "creation": { 10593 "type": "creation" 10594 }, 10595 "update": { 10596 "type": "update", 10597 "parameters": { 10598 "update_allows_fetch_and_merge": true 10599 } 10600 }, 10601 "deletion": { 10602 "type": "deletion" 10603 }, 10604 "required_linear_history": { 10605 "type": "required_linear_history" 10606 }, 10607 "merge_queue": { 10608 "type": "merge_queue", 10609 "parameters": { 10610 "check_response_timeout_minutes": 35, 10611 "grouping_strategy": "HEADGREEN", 10612 "max_entries_to_build": 8, 10613 "max_entries_to_merge": 4, 10614 "merge_method": "SQUASH", 10615 "min_entries_to_merge": 2, 10616 "min_entries_to_merge_wait_minutes": 13 10617 } 10618 }, 10619 "required_deployments": { 10620 "type": "required_deployments", 10621 "parameters": { 10622 "required_deployment_environments": [ 10623 "test" 10624 ] 10625 } 10626 }, 10627 "required_signatures": { 10628 "type": "required_signatures" 10629 }, 10630 "pull_request": { 10631 "type": "pull_request", 10632 "parameters": { 10633 "dismiss_stale_reviews_on_push": true, 10634 "require_code_owner_review": true, 10635 "require_last_push_approval": true, 10636 "required_approving_review_count": 1, 10637 "required_review_thread_resolution": true 10638 } 10639 }, 10640 "required_status_checks": { 10641 "type": "required_status_checks", 10642 "parameters": { 10643 "required_status_checks": [ 10644 { 10645 "context": "test", 10646 "integration_id": 1 10647 } 10648 ], 10649 "strict_required_status_checks_policy": true 10650 } 10651 }, 10652 "non_fast_forward": { 10653 "type": "non_fast_forward" 10654 }, 10655 "commit_message_pattern": { 10656 "type": "commit_message_pattern", 10657 "parameters": { 10658 "name": "avoid test commits", 10659 "negate": true, 10660 "operator": "starts_with", 10661 "pattern": "[test]" 10662 } 10663 }, 10664 "commit_author_email_pattern": { 10665 "type": "commit_author_email_pattern", 10666 "parameters": { 10667 "operator": "contains", 10668 "pattern": "github" 10669 } 10670 }, 10671 "committer_email_pattern": { 10672 "type": "committer_email_pattern", 10673 "parameters": { 10674 "name": "avoid commit emails", 10675 "negate": true, 10676 "operator": "ends_with", 10677 "pattern": "abc" 10678 } 10679 }, 10680 "branch_name_pattern": { 10681 "type": "branch_name_pattern", 10682 "parameters": { 10683 "name": "avoid branch names", 10684 "negate": true, 10685 "operator": "regex", 10686 "pattern": "github$" 10687 } 10688 }, 10689 "tag_name_pattern": { 10690 "type": "tag_name_pattern", 10691 "parameters": { 10692 "name": "avoid tag names", 10693 "negate": true, 10694 "operator": "contains", 10695 "pattern": "github" 10696 } 10697 }, 10698 "file_path_restriction": { 10699 "type": "file_path_restriction", 10700 "parameters": { 10701 "restricted_file_paths": [ 10702 "/a/file" 10703 ] 10704 } 10705 }, 10706 "max_file_path_length": { 10707 "type": "max_file_path_length", 10708 "parameters": { 10709 "max_file_path_length": 255 10710 } 10711 }, 10712 "file_extension_restriction": { 10713 "type": "file_extension_restriction", 10714 "parameters": { 10715 "restricted_file_extensions": [ 10716 ".exe" 10717 ] 10718 } 10719 }, 10720 "max_file_size": { 10721 "type": "max_file_size", 10722 "parameters": { 10723 "max_file_size": 1024 10724 } 10725 }, 10726 "workflows": { 10727 "type": "workflows", 10728 "parameters": { 10729 "workflows": [ 10730 { 10731 "path": ".github/workflows/test.yml", 10732 "repository_id": 1 10733 } 10734 ] 10735 } 10736 }, 10737 "code_scanning": { 10738 "type": "code_scanning", 10739 "parameters": { 10740 "code_scanning_tools": [ 10741 { 10742 "alerts_threshold": "alert", 10743 "security_alerts_threshold": "security", 10744 "tool": "tool" 10745 } 10746 ] 10747 } 10748 } 10749 } 10750 ], 10751 "created_at": ` + referenceTimeStr + `, 10752 "updated_at": ` + referenceTimeStr + ` 10753 }, 10754 "changes": { 10755 "name": { 10756 "from": "f" 10757 }, 10758 "enforcement": { 10759 "from": "e" 10760 }, 10761 "conditions": { 10762 "added": [ 10763 { 10764 "ref_name": { 10765 "include": [ 10766 "refs/heads/main", 10767 "refs/heads/master" 10768 ], 10769 "exclude": [ 10770 "refs/heads/dev*" 10771 ] 10772 } 10773 } 10774 ], 10775 "deleted": [ 10776 { 10777 "ref_name": { 10778 "include": [ 10779 "refs/heads/main", 10780 "refs/heads/master" 10781 ], 10782 "exclude": [ 10783 "refs/heads/dev*" 10784 ] 10785 } 10786 } 10787 ], 10788 "updated": [ 10789 { 10790 "condition": { 10791 "ref_name": { 10792 "include": [ 10793 "refs/heads/main", 10794 "refs/heads/master" 10795 ], 10796 "exclude": [ 10797 "refs/heads/dev*" 10798 ] 10799 } 10800 }, 10801 "changes": { 10802 "condition_type": { 10803 "from": "c" 10804 }, 10805 "target": { 10806 "from": "t" 10807 }, 10808 "include": { 10809 "from": [ 10810 "from" 10811 ] 10812 }, 10813 "exclude": { 10814 "from": [ 10815 "to" 10816 ] 10817 } 10818 } 10819 } 10820 ] 10821 }, 10822 "rules": { 10823 "added": [ 10824 { 10825 "creation": { 10826 "type": "creation" 10827 }, 10828 "update": { 10829 "type": "update", 10830 "parameters": { 10831 "update_allows_fetch_and_merge": true 10832 } 10833 }, 10834 "deletion": { 10835 "type": "deletion" 10836 }, 10837 "required_linear_history": { 10838 "type": "required_linear_history" 10839 }, 10840 "merge_queue": { 10841 "type": "merge_queue", 10842 "parameters": { 10843 "check_response_timeout_minutes": 35, 10844 "grouping_strategy": "HEADGREEN", 10845 "max_entries_to_build": 8, 10846 "max_entries_to_merge": 4, 10847 "merge_method": "SQUASH", 10848 "min_entries_to_merge": 2, 10849 "min_entries_to_merge_wait_minutes": 13 10850 } 10851 }, 10852 "required_deployments": { 10853 "type": "required_deployments", 10854 "parameters": { 10855 "required_deployment_environments": [ 10856 "test" 10857 ] 10858 } 10859 }, 10860 "required_signatures": { 10861 "type": "required_signatures" 10862 }, 10863 "pull_request": { 10864 "type": "pull_request", 10865 "parameters": { 10866 "dismiss_stale_reviews_on_push": true, 10867 "require_code_owner_review": true, 10868 "require_last_push_approval": true, 10869 "required_approving_review_count": 1, 10870 "required_review_thread_resolution": true 10871 } 10872 }, 10873 "required_status_checks": { 10874 "type": "required_status_checks", 10875 "parameters": { 10876 "required_status_checks": [ 10877 { 10878 "context": "test", 10879 "integration_id": 1 10880 } 10881 ], 10882 "strict_required_status_checks_policy": true 10883 } 10884 }, 10885 "non_fast_forward": { 10886 "type": "non_fast_forward" 10887 }, 10888 "commit_message_pattern": { 10889 "type": "commit_message_pattern", 10890 "parameters": { 10891 "name": "avoid test commits", 10892 "negate": true, 10893 "operator": "starts_with", 10894 "pattern": "[test]" 10895 } 10896 }, 10897 "commit_author_email_pattern": { 10898 "type": "commit_author_email_pattern", 10899 "parameters": { 10900 "operator": "contains", 10901 "pattern": "github" 10902 } 10903 }, 10904 "committer_email_pattern": { 10905 "type": "committer_email_pattern", 10906 "parameters": { 10907 "name": "avoid commit emails", 10908 "negate": true, 10909 "operator": "ends_with", 10910 "pattern": "abc" 10911 } 10912 }, 10913 "branch_name_pattern": { 10914 "type": "branch_name_pattern", 10915 "parameters": { 10916 "name": "avoid branch names", 10917 "negate": true, 10918 "operator": "regex", 10919 "pattern": "github$" 10920 } 10921 }, 10922 "tag_name_pattern": { 10923 "type": "tag_name_pattern", 10924 "parameters": { 10925 "name": "avoid tag names", 10926 "negate": true, 10927 "operator": "contains", 10928 "pattern": "github" 10929 } 10930 }, 10931 "file_path_restriction": { 10932 "type": "file_path_restriction", 10933 "parameters": { 10934 "restricted_file_paths": [ 10935 "/a/file" 10936 ] 10937 } 10938 }, 10939 "max_file_path_length": { 10940 "type": "max_file_path_length", 10941 "parameters": { 10942 "max_file_path_length": 255 10943 } 10944 }, 10945 "file_extension_restriction": { 10946 "type": "file_extension_restriction", 10947 "parameters": { 10948 "restricted_file_extensions": [ 10949 ".exe" 10950 ] 10951 } 10952 }, 10953 "max_file_size": { 10954 "type": "max_file_size", 10955 "parameters": { 10956 "max_file_size": 1024 10957 } 10958 }, 10959 "workflows": { 10960 "type": "workflows", 10961 "parameters": { 10962 "workflows": [ 10963 { 10964 "path": ".github/workflows/test.yml", 10965 "repository_id": 1 10966 } 10967 ] 10968 } 10969 }, 10970 "code_scanning": { 10971 "type": "code_scanning", 10972 "parameters": { 10973 "code_scanning_tools": [ 10974 { 10975 "alerts_threshold": "alert", 10976 "security_alerts_threshold": "security", 10977 "tool": "tool" 10978 } 10979 ] 10980 } 10981 } 10982 } 10983 ], 10984 "deleted": [ 10985 { 10986 "creation": { 10987 "type": "creation" 10988 }, 10989 "update": { 10990 "type": "update", 10991 "parameters": { 10992 "update_allows_fetch_and_merge": true 10993 } 10994 }, 10995 "deletion": { 10996 "type": "deletion" 10997 }, 10998 "required_linear_history": { 10999 "type": "required_linear_history" 11000 }, 11001 "merge_queue": { 11002 "type": "merge_queue", 11003 "parameters": { 11004 "check_response_timeout_minutes": 35, 11005 "grouping_strategy": "HEADGREEN", 11006 "max_entries_to_build": 8, 11007 "max_entries_to_merge": 4, 11008 "merge_method": "SQUASH", 11009 "min_entries_to_merge": 2, 11010 "min_entries_to_merge_wait_minutes": 13 11011 } 11012 }, 11013 "required_deployments": { 11014 "type": "required_deployments", 11015 "parameters": { 11016 "required_deployment_environments": [ 11017 "test" 11018 ] 11019 } 11020 }, 11021 "required_signatures": { 11022 "type": "required_signatures" 11023 }, 11024 "pull_request": { 11025 "type": "pull_request", 11026 "parameters": { 11027 "dismiss_stale_reviews_on_push": true, 11028 "require_code_owner_review": true, 11029 "require_last_push_approval": true, 11030 "required_approving_review_count": 1, 11031 "required_review_thread_resolution": true 11032 } 11033 }, 11034 "required_status_checks": { 11035 "type": "required_status_checks", 11036 "parameters": { 11037 "required_status_checks": [ 11038 { 11039 "context": "test", 11040 "integration_id": 1 11041 } 11042 ], 11043 "strict_required_status_checks_policy": true 11044 } 11045 }, 11046 "non_fast_forward": { 11047 "type": "non_fast_forward" 11048 }, 11049 "commit_message_pattern": { 11050 "type": "commit_message_pattern", 11051 "parameters": { 11052 "name": "avoid test commits", 11053 "negate": true, 11054 "operator": "starts_with", 11055 "pattern": "[test]" 11056 } 11057 }, 11058 "commit_author_email_pattern": { 11059 "type": "commit_author_email_pattern", 11060 "parameters": { 11061 "operator": "contains", 11062 "pattern": "github" 11063 } 11064 }, 11065 "committer_email_pattern": { 11066 "type": "committer_email_pattern", 11067 "parameters": { 11068 "name": "avoid commit emails", 11069 "negate": true, 11070 "operator": "ends_with", 11071 "pattern": "abc" 11072 } 11073 }, 11074 "branch_name_pattern": { 11075 "type": "branch_name_pattern", 11076 "parameters": { 11077 "name": "avoid branch names", 11078 "negate": true, 11079 "operator": "regex", 11080 "pattern": "github$" 11081 } 11082 }, 11083 "tag_name_pattern": { 11084 "type": "tag_name_pattern", 11085 "parameters": { 11086 "name": "avoid tag names", 11087 "negate": true, 11088 "operator": "contains", 11089 "pattern": "github" 11090 } 11091 }, 11092 "file_path_restriction": { 11093 "type": "file_path_restriction", 11094 "parameters": { 11095 "restricted_file_paths": [ 11096 "/a/file" 11097 ] 11098 } 11099 }, 11100 "max_file_path_length": { 11101 "type": "max_file_path_length", 11102 "parameters": { 11103 "max_file_path_length": 255 11104 } 11105 }, 11106 "file_extension_restriction": { 11107 "type": "file_extension_restriction", 11108 "parameters": { 11109 "restricted_file_extensions": [ 11110 ".exe" 11111 ] 11112 } 11113 }, 11114 "max_file_size": { 11115 "type": "max_file_size", 11116 "parameters": { 11117 "max_file_size": 1024 11118 } 11119 }, 11120 "workflows": { 11121 "type": "workflows", 11122 "parameters": { 11123 "workflows": [ 11124 { 11125 "path": ".github/workflows/test.yml", 11126 "repository_id": 1 11127 } 11128 ] 11129 } 11130 }, 11131 "code_scanning": { 11132 "type": "code_scanning", 11133 "parameters": { 11134 "code_scanning_tools": [ 11135 { 11136 "alerts_threshold": "alert", 11137 "security_alerts_threshold": "security", 11138 "tool": "tool" 11139 } 11140 ] 11141 } 11142 } 11143 } 11144 ], 11145 "updated": [ 11146 { 11147 "rule": { 11148 "creation": { 11149 "type": "creation" 11150 }, 11151 "update": { 11152 "type": "update", 11153 "parameters": { 11154 "update_allows_fetch_and_merge": true 11155 } 11156 }, 11157 "deletion": { 11158 "type": "deletion" 11159 }, 11160 "required_linear_history": { 11161 "type": "required_linear_history" 11162 }, 11163 "merge_queue": { 11164 "type": "merge_queue", 11165 "parameters": { 11166 "check_response_timeout_minutes": 35, 11167 "grouping_strategy": "HEADGREEN", 11168 "max_entries_to_build": 8, 11169 "max_entries_to_merge": 4, 11170 "merge_method": "SQUASH", 11171 "min_entries_to_merge": 2, 11172 "min_entries_to_merge_wait_minutes": 13 11173 } 11174 }, 11175 "required_deployments": { 11176 "type": "required_deployments", 11177 "parameters": { 11178 "required_deployment_environments": [ 11179 "test" 11180 ] 11181 } 11182 }, 11183 "required_signatures": { 11184 "type": "required_signatures" 11185 }, 11186 "pull_request": { 11187 "type": "pull_request", 11188 "parameters": { 11189 "dismiss_stale_reviews_on_push": true, 11190 "require_code_owner_review": true, 11191 "require_last_push_approval": true, 11192 "required_approving_review_count": 1, 11193 "required_review_thread_resolution": true 11194 } 11195 }, 11196 "required_status_checks": { 11197 "type": "required_status_checks", 11198 "parameters": { 11199 "required_status_checks": [ 11200 { 11201 "context": "test", 11202 "integration_id": 1 11203 } 11204 ], 11205 "strict_required_status_checks_policy": true 11206 } 11207 }, 11208 "non_fast_forward": { 11209 "type": "non_fast_forward" 11210 }, 11211 "commit_message_pattern": { 11212 "type": "commit_message_pattern", 11213 "parameters": { 11214 "name": "avoid test commits", 11215 "negate": true, 11216 "operator": "starts_with", 11217 "pattern": "[test]" 11218 } 11219 }, 11220 "commit_author_email_pattern": { 11221 "type": "commit_author_email_pattern", 11222 "parameters": { 11223 "operator": "contains", 11224 "pattern": "github" 11225 } 11226 }, 11227 "committer_email_pattern": { 11228 "type": "committer_email_pattern", 11229 "parameters": { 11230 "name": "avoid commit emails", 11231 "negate": true, 11232 "operator": "ends_with", 11233 "pattern": "abc" 11234 } 11235 }, 11236 "branch_name_pattern": { 11237 "type": "branch_name_pattern", 11238 "parameters": { 11239 "name": "avoid branch names", 11240 "negate": true, 11241 "operator": "regex", 11242 "pattern": "github$" 11243 } 11244 }, 11245 "tag_name_pattern": { 11246 "type": "tag_name_pattern", 11247 "parameters": { 11248 "name": "avoid tag names", 11249 "negate": true, 11250 "operator": "contains", 11251 "pattern": "github" 11252 } 11253 }, 11254 "file_path_restriction": { 11255 "type": "file_path_restriction", 11256 "parameters": { 11257 "restricted_file_paths": [ 11258 "/a/file" 11259 ] 11260 } 11261 }, 11262 "max_file_path_length": { 11263 "type": "max_file_path_length", 11264 "parameters": { 11265 "max_file_path_length": 255 11266 } 11267 }, 11268 "file_extension_restriction": { 11269 "type": "file_extension_restriction", 11270 "parameters": { 11271 "restricted_file_extensions": [ 11272 ".exe" 11273 ] 11274 } 11275 }, 11276 "max_file_size": { 11277 "type": "max_file_size", 11278 "parameters": { 11279 "max_file_size": 1024 11280 } 11281 }, 11282 "workflows": { 11283 "type": "workflows", 11284 "parameters": { 11285 "workflows": [ 11286 { 11287 "path": ".github/workflows/test.yml", 11288 "repository_id": 1 11289 } 11290 ] 11291 } 11292 }, 11293 "code_scanning": { 11294 "type": "code_scanning", 11295 "parameters": { 11296 "code_scanning_tools": [ 11297 { 11298 "alerts_threshold": "alert", 11299 "security_alerts_threshold": "security", 11300 "tool": "tool" 11301 } 11302 ] 11303 } 11304 } 11305 }, 11306 "changes": { 11307 "configuration": { 11308 "from": [ 11309 "from" 11310 ] 11311 }, 11312 "rule_type": { 11313 "from": [ 11314 "from" 11315 ] 11316 }, 11317 "pattern": { 11318 "from": [ 11319 "from" 11320 ] 11321 } 11322 } 11323 } 11324 ] 11325 } 11326 }, 11327 "sender": { 11328 "login": "l", 11329 "id": 1, 11330 "node_id": "n", 11331 "avatar_url": "a", 11332 "url": "u", 11333 "events_url": "e", 11334 "repos_url": "r" 11335 } 11336 }` 11337 11338 testJSONMarshal(t, u, want) 11339 } 11340 11341 func TestContentReferenceEvent_Marshal(t *testing.T) { 11342 t.Parallel() 11343 testJSONMarshal(t, &ContentReferenceEvent{}, "{}") 11344 11345 u := &ContentReferenceEvent{ 11346 Action: Ptr("a"), 11347 ContentReference: &ContentReference{ 11348 ID: Ptr(int64(1)), 11349 NodeID: Ptr("nid"), 11350 Reference: Ptr("ref"), 11351 }, 11352 Repo: &Repository{ 11353 ID: Ptr(int64(1)), 11354 URL: Ptr("s"), 11355 Name: Ptr("n"), 11356 }, 11357 Sender: &User{ 11358 Login: Ptr("l"), 11359 ID: Ptr(int64(1)), 11360 NodeID: Ptr("n"), 11361 URL: Ptr("u"), 11362 ReposURL: Ptr("r"), 11363 EventsURL: Ptr("e"), 11364 AvatarURL: Ptr("a"), 11365 }, 11366 Installation: &Installation{ 11367 ID: Ptr(int64(1)), 11368 NodeID: Ptr("nid"), 11369 AppID: Ptr(int64(1)), 11370 AppSlug: Ptr("as"), 11371 TargetID: Ptr(int64(1)), 11372 Account: &User{ 11373 Login: Ptr("l"), 11374 ID: Ptr(int64(1)), 11375 URL: Ptr("u"), 11376 AvatarURL: Ptr("a"), 11377 GravatarID: Ptr("g"), 11378 Name: Ptr("n"), 11379 Company: Ptr("c"), 11380 Blog: Ptr("b"), 11381 Location: Ptr("l"), 11382 Email: Ptr("e"), 11383 Hireable: Ptr(true), 11384 Bio: Ptr("b"), 11385 TwitterUsername: Ptr("t"), 11386 PublicRepos: Ptr(1), 11387 Followers: Ptr(1), 11388 Following: Ptr(1), 11389 CreatedAt: &Timestamp{referenceTime}, 11390 SuspendedAt: &Timestamp{referenceTime}, 11391 }, 11392 AccessTokensURL: Ptr("atu"), 11393 RepositoriesURL: Ptr("ru"), 11394 HTMLURL: Ptr("hu"), 11395 TargetType: Ptr("tt"), 11396 SingleFileName: Ptr("sfn"), 11397 RepositorySelection: Ptr("rs"), 11398 Events: []string{"e"}, 11399 SingleFilePaths: []string{"s"}, 11400 Permissions: &InstallationPermissions{ 11401 Actions: Ptr("a"), 11402 Administration: Ptr("ad"), 11403 Checks: Ptr("c"), 11404 Contents: Ptr("co"), 11405 ContentReferences: Ptr("cr"), 11406 Deployments: Ptr("d"), 11407 Environments: Ptr("e"), 11408 Issues: Ptr("i"), 11409 Metadata: Ptr("md"), 11410 Members: Ptr("m"), 11411 OrganizationAdministration: Ptr("oa"), 11412 OrganizationHooks: Ptr("oh"), 11413 OrganizationPlan: Ptr("op"), 11414 OrganizationPreReceiveHooks: Ptr("opr"), 11415 OrganizationProjects: Ptr("op"), 11416 OrganizationSecrets: Ptr("os"), 11417 OrganizationSelfHostedRunners: Ptr("osh"), 11418 OrganizationUserBlocking: Ptr("oub"), 11419 Packages: Ptr("pkg"), 11420 Pages: Ptr("pg"), 11421 PullRequests: Ptr("pr"), 11422 RepositoryHooks: Ptr("rh"), 11423 RepositoryProjects: Ptr("rp"), 11424 RepositoryPreReceiveHooks: Ptr("rprh"), 11425 Secrets: Ptr("s"), 11426 SecretScanningAlerts: Ptr("ssa"), 11427 SecurityEvents: Ptr("se"), 11428 SingleFile: Ptr("sf"), 11429 Statuses: Ptr("s"), 11430 TeamDiscussions: Ptr("td"), 11431 VulnerabilityAlerts: Ptr("va"), 11432 Workflows: Ptr("w"), 11433 }, 11434 CreatedAt: &Timestamp{referenceTime}, 11435 UpdatedAt: &Timestamp{referenceTime}, 11436 HasMultipleSingleFiles: Ptr(false), 11437 SuspendedBy: &User{ 11438 Login: Ptr("l"), 11439 ID: Ptr(int64(1)), 11440 URL: Ptr("u"), 11441 AvatarURL: Ptr("a"), 11442 GravatarID: Ptr("g"), 11443 Name: Ptr("n"), 11444 Company: Ptr("c"), 11445 Blog: Ptr("b"), 11446 Location: Ptr("l"), 11447 Email: Ptr("e"), 11448 Hireable: Ptr(true), 11449 Bio: Ptr("b"), 11450 TwitterUsername: Ptr("t"), 11451 PublicRepos: Ptr(1), 11452 Followers: Ptr(1), 11453 Following: Ptr(1), 11454 CreatedAt: &Timestamp{referenceTime}, 11455 SuspendedAt: &Timestamp{referenceTime}, 11456 }, 11457 SuspendedAt: &Timestamp{referenceTime}, 11458 }, 11459 } 11460 11461 want := `{ 11462 "action": "a", 11463 "content_reference": { 11464 "id": 1, 11465 "node_id": "nid", 11466 "reference": "ref" 11467 }, 11468 "repository": { 11469 "id": 1, 11470 "name": "n", 11471 "url": "s" 11472 }, 11473 "sender": { 11474 "login": "l", 11475 "id": 1, 11476 "node_id": "n", 11477 "avatar_url": "a", 11478 "url": "u", 11479 "events_url": "e", 11480 "repos_url": "r" 11481 }, 11482 "installation": { 11483 "id": 1, 11484 "node_id": "nid", 11485 "app_id": 1, 11486 "app_slug": "as", 11487 "target_id": 1, 11488 "account": { 11489 "login": "l", 11490 "id": 1, 11491 "avatar_url": "a", 11492 "gravatar_id": "g", 11493 "name": "n", 11494 "company": "c", 11495 "blog": "b", 11496 "location": "l", 11497 "email": "e", 11498 "hireable": true, 11499 "bio": "b", 11500 "twitter_username": "t", 11501 "public_repos": 1, 11502 "followers": 1, 11503 "following": 1, 11504 "created_at": ` + referenceTimeStr + `, 11505 "suspended_at": ` + referenceTimeStr + `, 11506 "url": "u" 11507 }, 11508 "access_tokens_url": "atu", 11509 "repositories_url": "ru", 11510 "html_url": "hu", 11511 "target_type": "tt", 11512 "single_file_name": "sfn", 11513 "repository_selection": "rs", 11514 "events": [ 11515 "e" 11516 ], 11517 "single_file_paths": [ 11518 "s" 11519 ], 11520 "permissions": { 11521 "actions": "a", 11522 "administration": "ad", 11523 "checks": "c", 11524 "contents": "co", 11525 "content_references": "cr", 11526 "deployments": "d", 11527 "environments": "e", 11528 "issues": "i", 11529 "metadata": "md", 11530 "members": "m", 11531 "organization_administration": "oa", 11532 "organization_hooks": "oh", 11533 "organization_plan": "op", 11534 "organization_pre_receive_hooks": "opr", 11535 "organization_projects": "op", 11536 "organization_secrets": "os", 11537 "organization_self_hosted_runners": "osh", 11538 "organization_user_blocking": "oub", 11539 "packages": "pkg", 11540 "pages": "pg", 11541 "pull_requests": "pr", 11542 "repository_hooks": "rh", 11543 "repository_projects": "rp", 11544 "repository_pre_receive_hooks": "rprh", 11545 "secrets": "s", 11546 "secret_scanning_alerts": "ssa", 11547 "security_events": "se", 11548 "single_file": "sf", 11549 "statuses": "s", 11550 "team_discussions": "td", 11551 "vulnerability_alerts": "va", 11552 "workflows": "w" 11553 }, 11554 "created_at": ` + referenceTimeStr + `, 11555 "updated_at": ` + referenceTimeStr + `, 11556 "has_multiple_single_files": false, 11557 "suspended_by": { 11558 "login": "l", 11559 "id": 1, 11560 "avatar_url": "a", 11561 "gravatar_id": "g", 11562 "name": "n", 11563 "company": "c", 11564 "blog": "b", 11565 "location": "l", 11566 "email": "e", 11567 "hireable": true, 11568 "bio": "b", 11569 "twitter_username": "t", 11570 "public_repos": 1, 11571 "followers": 1, 11572 "following": 1, 11573 "created_at": ` + referenceTimeStr + `, 11574 "suspended_at": ` + referenceTimeStr + `, 11575 "url": "u" 11576 }, 11577 "suspended_at": ` + referenceTimeStr + ` 11578 } 11579 }` 11580 11581 testJSONMarshal(t, u, want) 11582 } 11583 11584 func TestMemberEvent_Marshal(t *testing.T) { 11585 t.Parallel() 11586 testJSONMarshal(t, &MemberEvent{}, "{}") 11587 11588 u := &MemberEvent{ 11589 Action: Ptr("a"), 11590 Member: &User{ 11591 Login: Ptr("l"), 11592 ID: Ptr(int64(1)), 11593 NodeID: Ptr("n"), 11594 URL: Ptr("u"), 11595 ReposURL: Ptr("r"), 11596 EventsURL: Ptr("e"), 11597 AvatarURL: Ptr("a"), 11598 }, 11599 Changes: &MemberChanges{ 11600 Permission: &MemberChangesPermission{ 11601 From: Ptr("f"), 11602 To: Ptr("t"), 11603 }, 11604 RoleName: &MemberChangesRoleName{ 11605 From: Ptr("f"), 11606 To: Ptr("t"), 11607 }, 11608 }, 11609 Repo: &Repository{ 11610 ID: Ptr(int64(1)), 11611 URL: Ptr("s"), 11612 Name: Ptr("n"), 11613 }, 11614 Sender: &User{ 11615 Login: Ptr("l"), 11616 ID: Ptr(int64(1)), 11617 NodeID: Ptr("n"), 11618 URL: Ptr("u"), 11619 ReposURL: Ptr("r"), 11620 EventsURL: Ptr("e"), 11621 AvatarURL: Ptr("a"), 11622 }, 11623 Installation: &Installation{ 11624 ID: Ptr(int64(1)), 11625 NodeID: Ptr("nid"), 11626 AppID: Ptr(int64(1)), 11627 AppSlug: Ptr("as"), 11628 TargetID: Ptr(int64(1)), 11629 Account: &User{ 11630 Login: Ptr("l"), 11631 ID: Ptr(int64(1)), 11632 URL: Ptr("u"), 11633 AvatarURL: Ptr("a"), 11634 GravatarID: Ptr("g"), 11635 Name: Ptr("n"), 11636 Company: Ptr("c"), 11637 Blog: Ptr("b"), 11638 Location: Ptr("l"), 11639 Email: Ptr("e"), 11640 Hireable: Ptr(true), 11641 Bio: Ptr("b"), 11642 TwitterUsername: Ptr("t"), 11643 PublicRepos: Ptr(1), 11644 Followers: Ptr(1), 11645 Following: Ptr(1), 11646 CreatedAt: &Timestamp{referenceTime}, 11647 SuspendedAt: &Timestamp{referenceTime}, 11648 }, 11649 AccessTokensURL: Ptr("atu"), 11650 RepositoriesURL: Ptr("ru"), 11651 HTMLURL: Ptr("hu"), 11652 TargetType: Ptr("tt"), 11653 SingleFileName: Ptr("sfn"), 11654 RepositorySelection: Ptr("rs"), 11655 Events: []string{"e"}, 11656 SingleFilePaths: []string{"s"}, 11657 Permissions: &InstallationPermissions{ 11658 Actions: Ptr("a"), 11659 Administration: Ptr("ad"), 11660 Checks: Ptr("c"), 11661 Contents: Ptr("co"), 11662 ContentReferences: Ptr("cr"), 11663 Deployments: Ptr("d"), 11664 Environments: Ptr("e"), 11665 Issues: Ptr("i"), 11666 Metadata: Ptr("md"), 11667 Members: Ptr("m"), 11668 OrganizationAdministration: Ptr("oa"), 11669 OrganizationHooks: Ptr("oh"), 11670 OrganizationPlan: Ptr("op"), 11671 OrganizationPreReceiveHooks: Ptr("opr"), 11672 OrganizationProjects: Ptr("op"), 11673 OrganizationSecrets: Ptr("os"), 11674 OrganizationSelfHostedRunners: Ptr("osh"), 11675 OrganizationUserBlocking: Ptr("oub"), 11676 Packages: Ptr("pkg"), 11677 Pages: Ptr("pg"), 11678 PullRequests: Ptr("pr"), 11679 RepositoryHooks: Ptr("rh"), 11680 RepositoryProjects: Ptr("rp"), 11681 RepositoryPreReceiveHooks: Ptr("rprh"), 11682 Secrets: Ptr("s"), 11683 SecretScanningAlerts: Ptr("ssa"), 11684 SecurityEvents: Ptr("se"), 11685 SingleFile: Ptr("sf"), 11686 Statuses: Ptr("s"), 11687 TeamDiscussions: Ptr("td"), 11688 VulnerabilityAlerts: Ptr("va"), 11689 Workflows: Ptr("w"), 11690 }, 11691 CreatedAt: &Timestamp{referenceTime}, 11692 UpdatedAt: &Timestamp{referenceTime}, 11693 HasMultipleSingleFiles: Ptr(false), 11694 SuspendedBy: &User{ 11695 Login: Ptr("l"), 11696 ID: Ptr(int64(1)), 11697 URL: Ptr("u"), 11698 AvatarURL: Ptr("a"), 11699 GravatarID: Ptr("g"), 11700 Name: Ptr("n"), 11701 Company: Ptr("c"), 11702 Blog: Ptr("b"), 11703 Location: Ptr("l"), 11704 Email: Ptr("e"), 11705 Hireable: Ptr(true), 11706 Bio: Ptr("b"), 11707 TwitterUsername: Ptr("t"), 11708 PublicRepos: Ptr(1), 11709 Followers: Ptr(1), 11710 Following: Ptr(1), 11711 CreatedAt: &Timestamp{referenceTime}, 11712 SuspendedAt: &Timestamp{referenceTime}, 11713 }, 11714 SuspendedAt: &Timestamp{referenceTime}, 11715 }, 11716 } 11717 11718 want := `{ 11719 "action": "a", 11720 "member": { 11721 "login": "l", 11722 "id": 1, 11723 "node_id": "n", 11724 "avatar_url": "a", 11725 "url": "u", 11726 "events_url": "e", 11727 "repos_url": "r" 11728 }, 11729 "changes": { 11730 "permission": { 11731 "from": "f", 11732 "to": "t" 11733 }, 11734 "role_name": { 11735 "from": "f", 11736 "to": "t" 11737 } 11738 }, 11739 "repository": { 11740 "id": 1, 11741 "name": "n", 11742 "url": "s" 11743 }, 11744 "sender": { 11745 "login": "l", 11746 "id": 1, 11747 "node_id": "n", 11748 "avatar_url": "a", 11749 "url": "u", 11750 "events_url": "e", 11751 "repos_url": "r" 11752 }, 11753 "installation": { 11754 "id": 1, 11755 "node_id": "nid", 11756 "app_id": 1, 11757 "app_slug": "as", 11758 "target_id": 1, 11759 "account": { 11760 "login": "l", 11761 "id": 1, 11762 "avatar_url": "a", 11763 "gravatar_id": "g", 11764 "name": "n", 11765 "company": "c", 11766 "blog": "b", 11767 "location": "l", 11768 "email": "e", 11769 "hireable": true, 11770 "bio": "b", 11771 "twitter_username": "t", 11772 "public_repos": 1, 11773 "followers": 1, 11774 "following": 1, 11775 "created_at": ` + referenceTimeStr + `, 11776 "suspended_at": ` + referenceTimeStr + `, 11777 "url": "u" 11778 }, 11779 "access_tokens_url": "atu", 11780 "repositories_url": "ru", 11781 "html_url": "hu", 11782 "target_type": "tt", 11783 "single_file_name": "sfn", 11784 "repository_selection": "rs", 11785 "events": [ 11786 "e" 11787 ], 11788 "single_file_paths": [ 11789 "s" 11790 ], 11791 "permissions": { 11792 "actions": "a", 11793 "administration": "ad", 11794 "checks": "c", 11795 "contents": "co", 11796 "content_references": "cr", 11797 "deployments": "d", 11798 "environments": "e", 11799 "issues": "i", 11800 "metadata": "md", 11801 "members": "m", 11802 "organization_administration": "oa", 11803 "organization_hooks": "oh", 11804 "organization_plan": "op", 11805 "organization_pre_receive_hooks": "opr", 11806 "organization_projects": "op", 11807 "organization_secrets": "os", 11808 "organization_self_hosted_runners": "osh", 11809 "organization_user_blocking": "oub", 11810 "packages": "pkg", 11811 "pages": "pg", 11812 "pull_requests": "pr", 11813 "repository_hooks": "rh", 11814 "repository_projects": "rp", 11815 "repository_pre_receive_hooks": "rprh", 11816 "secrets": "s", 11817 "secret_scanning_alerts": "ssa", 11818 "security_events": "se", 11819 "single_file": "sf", 11820 "statuses": "s", 11821 "team_discussions": "td", 11822 "vulnerability_alerts": "va", 11823 "workflows": "w" 11824 }, 11825 "created_at": ` + referenceTimeStr + `, 11826 "updated_at": ` + referenceTimeStr + `, 11827 "has_multiple_single_files": false, 11828 "suspended_by": { 11829 "login": "l", 11830 "id": 1, 11831 "avatar_url": "a", 11832 "gravatar_id": "g", 11833 "name": "n", 11834 "company": "c", 11835 "blog": "b", 11836 "location": "l", 11837 "email": "e", 11838 "hireable": true, 11839 "bio": "b", 11840 "twitter_username": "t", 11841 "public_repos": 1, 11842 "followers": 1, 11843 "following": 1, 11844 "created_at": ` + referenceTimeStr + `, 11845 "suspended_at": ` + referenceTimeStr + `, 11846 "url": "u" 11847 }, 11848 "suspended_at": ` + referenceTimeStr + ` 11849 } 11850 }` 11851 11852 testJSONMarshal(t, u, want) 11853 } 11854 11855 func TestMembershipEvent_Marshal(t *testing.T) { 11856 t.Parallel() 11857 testJSONMarshal(t, &MembershipEvent{}, "{}") 11858 11859 u := &MembershipEvent{ 11860 Action: Ptr("a"), 11861 Scope: Ptr("s"), 11862 Member: &User{ 11863 Login: Ptr("l"), 11864 ID: Ptr(int64(1)), 11865 NodeID: Ptr("n"), 11866 URL: Ptr("u"), 11867 ReposURL: Ptr("r"), 11868 EventsURL: Ptr("e"), 11869 AvatarURL: Ptr("a"), 11870 }, 11871 Team: &Team{ 11872 ID: Ptr(int64(1)), 11873 NodeID: Ptr("n"), 11874 Name: Ptr("n"), 11875 Description: Ptr("d"), 11876 URL: Ptr("u"), 11877 Slug: Ptr("s"), 11878 Permission: Ptr("p"), 11879 Privacy: Ptr("p"), 11880 MembersCount: Ptr(1), 11881 ReposCount: Ptr(1), 11882 MembersURL: Ptr("m"), 11883 RepositoriesURL: Ptr("r"), 11884 Organization: &Organization{ 11885 Login: Ptr("l"), 11886 ID: Ptr(int64(1)), 11887 NodeID: Ptr("n"), 11888 AvatarURL: Ptr("a"), 11889 HTMLURL: Ptr("h"), 11890 Name: Ptr("n"), 11891 Company: Ptr("c"), 11892 Blog: Ptr("b"), 11893 Location: Ptr("l"), 11894 Email: Ptr("e"), 11895 }, 11896 Parent: &Team{ 11897 ID: Ptr(int64(1)), 11898 NodeID: Ptr("n"), 11899 Name: Ptr("n"), 11900 Description: Ptr("d"), 11901 URL: Ptr("u"), 11902 Slug: Ptr("s"), 11903 Permission: Ptr("p"), 11904 Privacy: Ptr("p"), 11905 MembersCount: Ptr(1), 11906 ReposCount: Ptr(1), 11907 }, 11908 LDAPDN: Ptr("l"), 11909 }, 11910 Org: &Organization{ 11911 BillingEmail: Ptr("be"), 11912 Blog: Ptr("b"), 11913 Company: Ptr("c"), 11914 Email: Ptr("e"), 11915 TwitterUsername: Ptr("tu"), 11916 Location: Ptr("loc"), 11917 Name: Ptr("n"), 11918 Description: Ptr("d"), 11919 IsVerified: Ptr(true), 11920 HasOrganizationProjects: Ptr(true), 11921 HasRepositoryProjects: Ptr(true), 11922 DefaultRepoPermission: Ptr("drp"), 11923 MembersCanCreateRepos: Ptr(true), 11924 MembersCanCreateInternalRepos: Ptr(true), 11925 MembersCanCreatePrivateRepos: Ptr(true), 11926 MembersCanCreatePublicRepos: Ptr(false), 11927 MembersAllowedRepositoryCreationType: Ptr("marct"), 11928 MembersCanCreatePages: Ptr(true), 11929 MembersCanCreatePublicPages: Ptr(false), 11930 MembersCanCreatePrivatePages: Ptr(true), 11931 }, 11932 Sender: &User{ 11933 Login: Ptr("l"), 11934 ID: Ptr(int64(1)), 11935 NodeID: Ptr("n"), 11936 URL: Ptr("u"), 11937 ReposURL: Ptr("r"), 11938 EventsURL: Ptr("e"), 11939 AvatarURL: Ptr("a"), 11940 }, 11941 Installation: &Installation{ 11942 ID: Ptr(int64(1)), 11943 NodeID: Ptr("nid"), 11944 AppID: Ptr(int64(1)), 11945 AppSlug: Ptr("as"), 11946 TargetID: Ptr(int64(1)), 11947 Account: &User{ 11948 Login: Ptr("l"), 11949 ID: Ptr(int64(1)), 11950 URL: Ptr("u"), 11951 AvatarURL: Ptr("a"), 11952 GravatarID: Ptr("g"), 11953 Name: Ptr("n"), 11954 Company: Ptr("c"), 11955 Blog: Ptr("b"), 11956 Location: Ptr("l"), 11957 Email: Ptr("e"), 11958 Hireable: Ptr(true), 11959 Bio: Ptr("b"), 11960 TwitterUsername: Ptr("t"), 11961 PublicRepos: Ptr(1), 11962 Followers: Ptr(1), 11963 Following: Ptr(1), 11964 CreatedAt: &Timestamp{referenceTime}, 11965 SuspendedAt: &Timestamp{referenceTime}, 11966 }, 11967 AccessTokensURL: Ptr("atu"), 11968 RepositoriesURL: Ptr("ru"), 11969 HTMLURL: Ptr("hu"), 11970 TargetType: Ptr("tt"), 11971 SingleFileName: Ptr("sfn"), 11972 RepositorySelection: Ptr("rs"), 11973 Events: []string{"e"}, 11974 SingleFilePaths: []string{"s"}, 11975 Permissions: &InstallationPermissions{ 11976 Actions: Ptr("a"), 11977 Administration: Ptr("ad"), 11978 Checks: Ptr("c"), 11979 Contents: Ptr("co"), 11980 ContentReferences: Ptr("cr"), 11981 Deployments: Ptr("d"), 11982 Environments: Ptr("e"), 11983 Issues: Ptr("i"), 11984 Metadata: Ptr("md"), 11985 Members: Ptr("m"), 11986 OrganizationAdministration: Ptr("oa"), 11987 OrganizationHooks: Ptr("oh"), 11988 OrganizationPlan: Ptr("op"), 11989 OrganizationPreReceiveHooks: Ptr("opr"), 11990 OrganizationProjects: Ptr("op"), 11991 OrganizationSecrets: Ptr("os"), 11992 OrganizationSelfHostedRunners: Ptr("osh"), 11993 OrganizationUserBlocking: Ptr("oub"), 11994 Packages: Ptr("pkg"), 11995 Pages: Ptr("pg"), 11996 PullRequests: Ptr("pr"), 11997 RepositoryHooks: Ptr("rh"), 11998 RepositoryProjects: Ptr("rp"), 11999 RepositoryPreReceiveHooks: Ptr("rprh"), 12000 Secrets: Ptr("s"), 12001 SecretScanningAlerts: Ptr("ssa"), 12002 SecurityEvents: Ptr("se"), 12003 SingleFile: Ptr("sf"), 12004 Statuses: Ptr("s"), 12005 TeamDiscussions: Ptr("td"), 12006 VulnerabilityAlerts: Ptr("va"), 12007 Workflows: Ptr("w"), 12008 }, 12009 CreatedAt: &Timestamp{referenceTime}, 12010 UpdatedAt: &Timestamp{referenceTime}, 12011 HasMultipleSingleFiles: Ptr(false), 12012 SuspendedBy: &User{ 12013 Login: Ptr("l"), 12014 ID: Ptr(int64(1)), 12015 URL: Ptr("u"), 12016 AvatarURL: Ptr("a"), 12017 GravatarID: Ptr("g"), 12018 Name: Ptr("n"), 12019 Company: Ptr("c"), 12020 Blog: Ptr("b"), 12021 Location: Ptr("l"), 12022 Email: Ptr("e"), 12023 Hireable: Ptr(true), 12024 Bio: Ptr("b"), 12025 TwitterUsername: Ptr("t"), 12026 PublicRepos: Ptr(1), 12027 Followers: Ptr(1), 12028 Following: Ptr(1), 12029 CreatedAt: &Timestamp{referenceTime}, 12030 SuspendedAt: &Timestamp{referenceTime}, 12031 }, 12032 SuspendedAt: &Timestamp{referenceTime}, 12033 }, 12034 } 12035 12036 want := `{ 12037 "action": "a", 12038 "scope": "s", 12039 "member": { 12040 "login": "l", 12041 "id": 1, 12042 "node_id": "n", 12043 "avatar_url": "a", 12044 "url": "u", 12045 "events_url": "e", 12046 "repos_url": "r" 12047 }, 12048 "team": { 12049 "id": 1, 12050 "node_id": "n", 12051 "name": "n", 12052 "description": "d", 12053 "url": "u", 12054 "slug": "s", 12055 "permission": "p", 12056 "privacy": "p", 12057 "members_count": 1, 12058 "repos_count": 1, 12059 "organization": { 12060 "login": "l", 12061 "id": 1, 12062 "node_id": "n", 12063 "avatar_url": "a", 12064 "html_url": "h", 12065 "name": "n", 12066 "company": "c", 12067 "blog": "b", 12068 "location": "l", 12069 "email": "e" 12070 }, 12071 "members_url": "m", 12072 "repositories_url": "r", 12073 "parent": { 12074 "id": 1, 12075 "node_id": "n", 12076 "name": "n", 12077 "description": "d", 12078 "url": "u", 12079 "slug": "s", 12080 "permission": "p", 12081 "privacy": "p", 12082 "members_count": 1, 12083 "repos_count": 1 12084 }, 12085 "ldap_dn": "l" 12086 }, 12087 "organization": { 12088 "name": "n", 12089 "company": "c", 12090 "blog": "b", 12091 "location": "loc", 12092 "email": "e", 12093 "twitter_username": "tu", 12094 "description": "d", 12095 "billing_email": "be", 12096 "is_verified": true, 12097 "has_organization_projects": true, 12098 "has_repository_projects": true, 12099 "default_repository_permission": "drp", 12100 "members_can_create_repositories": true, 12101 "members_can_create_public_repositories": false, 12102 "members_can_create_private_repositories": true, 12103 "members_can_create_internal_repositories": true, 12104 "members_allowed_repository_creation_type": "marct", 12105 "members_can_create_pages": true, 12106 "members_can_create_public_pages": false, 12107 "members_can_create_private_pages": true 12108 }, 12109 "sender": { 12110 "login": "l", 12111 "id": 1, 12112 "node_id": "n", 12113 "avatar_url": "a", 12114 "url": "u", 12115 "events_url": "e", 12116 "repos_url": "r" 12117 }, 12118 "installation": { 12119 "id": 1, 12120 "node_id": "nid", 12121 "app_id": 1, 12122 "app_slug": "as", 12123 "target_id": 1, 12124 "account": { 12125 "login": "l", 12126 "id": 1, 12127 "avatar_url": "a", 12128 "gravatar_id": "g", 12129 "name": "n", 12130 "company": "c", 12131 "blog": "b", 12132 "location": "l", 12133 "email": "e", 12134 "hireable": true, 12135 "bio": "b", 12136 "twitter_username": "t", 12137 "public_repos": 1, 12138 "followers": 1, 12139 "following": 1, 12140 "created_at": ` + referenceTimeStr + `, 12141 "suspended_at": ` + referenceTimeStr + `, 12142 "url": "u" 12143 }, 12144 "access_tokens_url": "atu", 12145 "repositories_url": "ru", 12146 "html_url": "hu", 12147 "target_type": "tt", 12148 "single_file_name": "sfn", 12149 "repository_selection": "rs", 12150 "events": [ 12151 "e" 12152 ], 12153 "single_file_paths": [ 12154 "s" 12155 ], 12156 "permissions": { 12157 "actions": "a", 12158 "administration": "ad", 12159 "checks": "c", 12160 "contents": "co", 12161 "content_references": "cr", 12162 "deployments": "d", 12163 "environments": "e", 12164 "issues": "i", 12165 "metadata": "md", 12166 "members": "m", 12167 "organization_administration": "oa", 12168 "organization_hooks": "oh", 12169 "organization_plan": "op", 12170 "organization_pre_receive_hooks": "opr", 12171 "organization_projects": "op", 12172 "organization_secrets": "os", 12173 "organization_self_hosted_runners": "osh", 12174 "organization_user_blocking": "oub", 12175 "packages": "pkg", 12176 "pages": "pg", 12177 "pull_requests": "pr", 12178 "repository_hooks": "rh", 12179 "repository_projects": "rp", 12180 "repository_pre_receive_hooks": "rprh", 12181 "secrets": "s", 12182 "secret_scanning_alerts": "ssa", 12183 "security_events": "se", 12184 "single_file": "sf", 12185 "statuses": "s", 12186 "team_discussions": "td", 12187 "vulnerability_alerts": "va", 12188 "workflows": "w" 12189 }, 12190 "created_at": ` + referenceTimeStr + `, 12191 "updated_at": ` + referenceTimeStr + `, 12192 "has_multiple_single_files": false, 12193 "suspended_by": { 12194 "login": "l", 12195 "id": 1, 12196 "avatar_url": "a", 12197 "gravatar_id": "g", 12198 "name": "n", 12199 "company": "c", 12200 "blog": "b", 12201 "location": "l", 12202 "email": "e", 12203 "hireable": true, 12204 "bio": "b", 12205 "twitter_username": "t", 12206 "public_repos": 1, 12207 "followers": 1, 12208 "following": 1, 12209 "created_at": ` + referenceTimeStr + `, 12210 "suspended_at": ` + referenceTimeStr + `, 12211 "url": "u" 12212 }, 12213 "suspended_at": ` + referenceTimeStr + ` 12214 } 12215 }` 12216 12217 testJSONMarshal(t, u, want) 12218 } 12219 12220 func TestMergeGroupEvent_Marshal(t *testing.T) { 12221 t.Parallel() 12222 testJSONMarshal(t, &MergeGroupEvent{}, "{}") 12223 12224 u := &MergeGroupEvent{ 12225 Action: Ptr("a"), 12226 MergeGroup: &MergeGroup{ 12227 HeadSHA: Ptr("hs"), 12228 HeadRef: Ptr("hr"), 12229 BaseSHA: Ptr("bs"), 12230 BaseRef: Ptr("br"), 12231 HeadCommit: &Commit{NodeID: Ptr("nid")}, 12232 }, 12233 Repo: &Repository{ 12234 ID: Ptr(int64(1)), 12235 URL: Ptr("s"), 12236 Name: Ptr("n"), 12237 }, 12238 Org: &Organization{ 12239 BillingEmail: Ptr("be"), 12240 Blog: Ptr("b"), 12241 Company: Ptr("c"), 12242 Email: Ptr("e"), 12243 TwitterUsername: Ptr("tu"), 12244 Location: Ptr("loc"), 12245 Name: Ptr("n"), 12246 Description: Ptr("d"), 12247 IsVerified: Ptr(true), 12248 HasOrganizationProjects: Ptr(true), 12249 HasRepositoryProjects: Ptr(true), 12250 DefaultRepoPermission: Ptr("drp"), 12251 MembersCanCreateRepos: Ptr(true), 12252 MembersCanCreateInternalRepos: Ptr(true), 12253 MembersCanCreatePrivateRepos: Ptr(true), 12254 MembersCanCreatePublicRepos: Ptr(false), 12255 MembersAllowedRepositoryCreationType: Ptr("marct"), 12256 MembersCanCreatePages: Ptr(true), 12257 MembersCanCreatePublicPages: Ptr(false), 12258 MembersCanCreatePrivatePages: Ptr(true), 12259 }, 12260 Sender: &User{ 12261 Login: Ptr("l"), 12262 ID: Ptr(int64(1)), 12263 NodeID: Ptr("n"), 12264 URL: Ptr("u"), 12265 ReposURL: Ptr("r"), 12266 EventsURL: Ptr("e"), 12267 AvatarURL: Ptr("a"), 12268 }, 12269 Installation: &Installation{ 12270 ID: Ptr(int64(1)), 12271 NodeID: Ptr("nid"), 12272 AppID: Ptr(int64(1)), 12273 AppSlug: Ptr("as"), 12274 TargetID: Ptr(int64(1)), 12275 Account: &User{ 12276 Login: Ptr("l"), 12277 ID: Ptr(int64(1)), 12278 URL: Ptr("u"), 12279 AvatarURL: Ptr("a"), 12280 GravatarID: Ptr("g"), 12281 Name: Ptr("n"), 12282 Company: Ptr("c"), 12283 Blog: Ptr("b"), 12284 Location: Ptr("l"), 12285 Email: Ptr("e"), 12286 Hireable: Ptr(true), 12287 Bio: Ptr("b"), 12288 TwitterUsername: Ptr("t"), 12289 PublicRepos: Ptr(1), 12290 Followers: Ptr(1), 12291 Following: Ptr(1), 12292 CreatedAt: &Timestamp{referenceTime}, 12293 SuspendedAt: &Timestamp{referenceTime}, 12294 }, 12295 AccessTokensURL: Ptr("atu"), 12296 RepositoriesURL: Ptr("ru"), 12297 HTMLURL: Ptr("hu"), 12298 TargetType: Ptr("tt"), 12299 SingleFileName: Ptr("sfn"), 12300 RepositorySelection: Ptr("rs"), 12301 Events: []string{"e"}, 12302 SingleFilePaths: []string{"s"}, 12303 Permissions: &InstallationPermissions{ 12304 Actions: Ptr("a"), 12305 Administration: Ptr("ad"), 12306 Checks: Ptr("c"), 12307 Contents: Ptr("co"), 12308 ContentReferences: Ptr("cr"), 12309 Deployments: Ptr("d"), 12310 Environments: Ptr("e"), 12311 Issues: Ptr("i"), 12312 Metadata: Ptr("md"), 12313 Members: Ptr("m"), 12314 OrganizationAdministration: Ptr("oa"), 12315 OrganizationHooks: Ptr("oh"), 12316 OrganizationPlan: Ptr("op"), 12317 OrganizationPreReceiveHooks: Ptr("opr"), 12318 OrganizationProjects: Ptr("op"), 12319 OrganizationSecrets: Ptr("os"), 12320 OrganizationSelfHostedRunners: Ptr("osh"), 12321 OrganizationUserBlocking: Ptr("oub"), 12322 Packages: Ptr("pkg"), 12323 Pages: Ptr("pg"), 12324 PullRequests: Ptr("pr"), 12325 RepositoryHooks: Ptr("rh"), 12326 RepositoryProjects: Ptr("rp"), 12327 RepositoryPreReceiveHooks: Ptr("rprh"), 12328 Secrets: Ptr("s"), 12329 SecretScanningAlerts: Ptr("ssa"), 12330 SecurityEvents: Ptr("se"), 12331 SingleFile: Ptr("sf"), 12332 Statuses: Ptr("s"), 12333 TeamDiscussions: Ptr("td"), 12334 VulnerabilityAlerts: Ptr("va"), 12335 Workflows: Ptr("w"), 12336 }, 12337 CreatedAt: &Timestamp{referenceTime}, 12338 UpdatedAt: &Timestamp{referenceTime}, 12339 HasMultipleSingleFiles: Ptr(false), 12340 SuspendedBy: &User{ 12341 Login: Ptr("l"), 12342 ID: Ptr(int64(1)), 12343 URL: Ptr("u"), 12344 AvatarURL: Ptr("a"), 12345 GravatarID: Ptr("g"), 12346 Name: Ptr("n"), 12347 Company: Ptr("c"), 12348 Blog: Ptr("b"), 12349 Location: Ptr("l"), 12350 Email: Ptr("e"), 12351 Hireable: Ptr(true), 12352 Bio: Ptr("b"), 12353 TwitterUsername: Ptr("t"), 12354 PublicRepos: Ptr(1), 12355 Followers: Ptr(1), 12356 Following: Ptr(1), 12357 CreatedAt: &Timestamp{referenceTime}, 12358 SuspendedAt: &Timestamp{referenceTime}, 12359 }, 12360 SuspendedAt: &Timestamp{referenceTime}, 12361 }, 12362 } 12363 12364 want := `{ 12365 "action": "a", 12366 "merge_group": { 12367 "head_sha": "hs", 12368 "head_ref": "hr", 12369 "base_sha": "bs", 12370 "base_ref": "br", 12371 "head_commit": { 12372 "node_id": "nid" 12373 } 12374 }, 12375 "repository": { 12376 "id": 1, 12377 "name": "n", 12378 "url": "s" 12379 }, 12380 "organization": { 12381 "name": "n", 12382 "company": "c", 12383 "blog": "b", 12384 "location": "loc", 12385 "email": "e", 12386 "twitter_username": "tu", 12387 "description": "d", 12388 "billing_email": "be", 12389 "is_verified": true, 12390 "has_organization_projects": true, 12391 "has_repository_projects": true, 12392 "default_repository_permission": "drp", 12393 "members_can_create_repositories": true, 12394 "members_can_create_public_repositories": false, 12395 "members_can_create_private_repositories": true, 12396 "members_can_create_internal_repositories": true, 12397 "members_allowed_repository_creation_type": "marct", 12398 "members_can_create_pages": true, 12399 "members_can_create_public_pages": false, 12400 "members_can_create_private_pages": true 12401 }, 12402 "sender": { 12403 "login": "l", 12404 "id": 1, 12405 "node_id": "n", 12406 "avatar_url": "a", 12407 "url": "u", 12408 "events_url": "e", 12409 "repos_url": "r" 12410 }, 12411 "installation": { 12412 "id": 1, 12413 "node_id": "nid", 12414 "app_id": 1, 12415 "app_slug": "as", 12416 "target_id": 1, 12417 "account": { 12418 "login": "l", 12419 "id": 1, 12420 "avatar_url": "a", 12421 "gravatar_id": "g", 12422 "name": "n", 12423 "company": "c", 12424 "blog": "b", 12425 "location": "l", 12426 "email": "e", 12427 "hireable": true, 12428 "bio": "b", 12429 "twitter_username": "t", 12430 "public_repos": 1, 12431 "followers": 1, 12432 "following": 1, 12433 "created_at": ` + referenceTimeStr + `, 12434 "suspended_at": ` + referenceTimeStr + `, 12435 "url": "u" 12436 }, 12437 "access_tokens_url": "atu", 12438 "repositories_url": "ru", 12439 "html_url": "hu", 12440 "target_type": "tt", 12441 "single_file_name": "sfn", 12442 "repository_selection": "rs", 12443 "events": [ 12444 "e" 12445 ], 12446 "single_file_paths": [ 12447 "s" 12448 ], 12449 "permissions": { 12450 "actions": "a", 12451 "administration": "ad", 12452 "checks": "c", 12453 "contents": "co", 12454 "content_references": "cr", 12455 "deployments": "d", 12456 "environments": "e", 12457 "issues": "i", 12458 "metadata": "md", 12459 "members": "m", 12460 "organization_administration": "oa", 12461 "organization_hooks": "oh", 12462 "organization_plan": "op", 12463 "organization_pre_receive_hooks": "opr", 12464 "organization_projects": "op", 12465 "organization_secrets": "os", 12466 "organization_self_hosted_runners": "osh", 12467 "organization_user_blocking": "oub", 12468 "packages": "pkg", 12469 "pages": "pg", 12470 "pull_requests": "pr", 12471 "repository_hooks": "rh", 12472 "repository_projects": "rp", 12473 "repository_pre_receive_hooks": "rprh", 12474 "secrets": "s", 12475 "secret_scanning_alerts": "ssa", 12476 "security_events": "se", 12477 "single_file": "sf", 12478 "statuses": "s", 12479 "team_discussions": "td", 12480 "vulnerability_alerts": "va", 12481 "workflows": "w" 12482 }, 12483 "created_at": ` + referenceTimeStr + `, 12484 "updated_at": ` + referenceTimeStr + `, 12485 "has_multiple_single_files": false, 12486 "suspended_by": { 12487 "login": "l", 12488 "id": 1, 12489 "avatar_url": "a", 12490 "gravatar_id": "g", 12491 "name": "n", 12492 "company": "c", 12493 "blog": "b", 12494 "location": "l", 12495 "email": "e", 12496 "hireable": true, 12497 "bio": "b", 12498 "twitter_username": "t", 12499 "public_repos": 1, 12500 "followers": 1, 12501 "following": 1, 12502 "created_at": ` + referenceTimeStr + `, 12503 "suspended_at": ` + referenceTimeStr + `, 12504 "url": "u" 12505 }, 12506 "suspended_at": ` + referenceTimeStr + ` 12507 } 12508 }` 12509 12510 testJSONMarshal(t, u, want) 12511 } 12512 12513 func TestOrgBlockEvent_Marshal(t *testing.T) { 12514 t.Parallel() 12515 testJSONMarshal(t, &OrgBlockEvent{}, "{}") 12516 12517 u := &OrgBlockEvent{ 12518 Action: Ptr("a"), 12519 BlockedUser: &User{ 12520 Login: Ptr("l"), 12521 ID: Ptr(int64(1)), 12522 NodeID: Ptr("n"), 12523 URL: Ptr("u"), 12524 ReposURL: Ptr("r"), 12525 EventsURL: Ptr("e"), 12526 AvatarURL: Ptr("a"), 12527 }, 12528 Organization: &Organization{ 12529 BillingEmail: Ptr("be"), 12530 Blog: Ptr("b"), 12531 Company: Ptr("c"), 12532 Email: Ptr("e"), 12533 TwitterUsername: Ptr("tu"), 12534 Location: Ptr("loc"), 12535 Name: Ptr("n"), 12536 Description: Ptr("d"), 12537 IsVerified: Ptr(true), 12538 HasOrganizationProjects: Ptr(true), 12539 HasRepositoryProjects: Ptr(true), 12540 DefaultRepoPermission: Ptr("drp"), 12541 MembersCanCreateRepos: Ptr(true), 12542 MembersCanCreateInternalRepos: Ptr(true), 12543 MembersCanCreatePrivateRepos: Ptr(true), 12544 MembersCanCreatePublicRepos: Ptr(false), 12545 MembersAllowedRepositoryCreationType: Ptr("marct"), 12546 MembersCanCreatePages: Ptr(true), 12547 MembersCanCreatePublicPages: Ptr(false), 12548 MembersCanCreatePrivatePages: Ptr(true), 12549 }, 12550 Sender: &User{ 12551 Login: Ptr("l"), 12552 ID: Ptr(int64(1)), 12553 NodeID: Ptr("n"), 12554 URL: Ptr("u"), 12555 ReposURL: Ptr("r"), 12556 EventsURL: Ptr("e"), 12557 AvatarURL: Ptr("a"), 12558 }, 12559 Installation: &Installation{ 12560 ID: Ptr(int64(1)), 12561 NodeID: Ptr("nid"), 12562 AppID: Ptr(int64(1)), 12563 AppSlug: Ptr("as"), 12564 TargetID: Ptr(int64(1)), 12565 Account: &User{ 12566 Login: Ptr("l"), 12567 ID: Ptr(int64(1)), 12568 URL: Ptr("u"), 12569 AvatarURL: Ptr("a"), 12570 GravatarID: Ptr("g"), 12571 Name: Ptr("n"), 12572 Company: Ptr("c"), 12573 Blog: Ptr("b"), 12574 Location: Ptr("l"), 12575 Email: Ptr("e"), 12576 Hireable: Ptr(true), 12577 Bio: Ptr("b"), 12578 TwitterUsername: Ptr("t"), 12579 PublicRepos: Ptr(1), 12580 Followers: Ptr(1), 12581 Following: Ptr(1), 12582 CreatedAt: &Timestamp{referenceTime}, 12583 SuspendedAt: &Timestamp{referenceTime}, 12584 }, 12585 AccessTokensURL: Ptr("atu"), 12586 RepositoriesURL: Ptr("ru"), 12587 HTMLURL: Ptr("hu"), 12588 TargetType: Ptr("tt"), 12589 SingleFileName: Ptr("sfn"), 12590 RepositorySelection: Ptr("rs"), 12591 Events: []string{"e"}, 12592 SingleFilePaths: []string{"s"}, 12593 Permissions: &InstallationPermissions{ 12594 Actions: Ptr("a"), 12595 Administration: Ptr("ad"), 12596 Checks: Ptr("c"), 12597 Contents: Ptr("co"), 12598 ContentReferences: Ptr("cr"), 12599 Deployments: Ptr("d"), 12600 Environments: Ptr("e"), 12601 Issues: Ptr("i"), 12602 Metadata: Ptr("md"), 12603 Members: Ptr("m"), 12604 OrganizationAdministration: Ptr("oa"), 12605 OrganizationHooks: Ptr("oh"), 12606 OrganizationPlan: Ptr("op"), 12607 OrganizationPreReceiveHooks: Ptr("opr"), 12608 OrganizationProjects: Ptr("op"), 12609 OrganizationSecrets: Ptr("os"), 12610 OrganizationSelfHostedRunners: Ptr("osh"), 12611 OrganizationUserBlocking: Ptr("oub"), 12612 Packages: Ptr("pkg"), 12613 Pages: Ptr("pg"), 12614 PullRequests: Ptr("pr"), 12615 RepositoryHooks: Ptr("rh"), 12616 RepositoryProjects: Ptr("rp"), 12617 RepositoryPreReceiveHooks: Ptr("rprh"), 12618 Secrets: Ptr("s"), 12619 SecretScanningAlerts: Ptr("ssa"), 12620 SecurityEvents: Ptr("se"), 12621 SingleFile: Ptr("sf"), 12622 Statuses: Ptr("s"), 12623 TeamDiscussions: Ptr("td"), 12624 VulnerabilityAlerts: Ptr("va"), 12625 Workflows: Ptr("w"), 12626 }, 12627 CreatedAt: &Timestamp{referenceTime}, 12628 UpdatedAt: &Timestamp{referenceTime}, 12629 HasMultipleSingleFiles: Ptr(false), 12630 SuspendedBy: &User{ 12631 Login: Ptr("l"), 12632 ID: Ptr(int64(1)), 12633 URL: Ptr("u"), 12634 AvatarURL: Ptr("a"), 12635 GravatarID: Ptr("g"), 12636 Name: Ptr("n"), 12637 Company: Ptr("c"), 12638 Blog: Ptr("b"), 12639 Location: Ptr("l"), 12640 Email: Ptr("e"), 12641 Hireable: Ptr(true), 12642 Bio: Ptr("b"), 12643 TwitterUsername: Ptr("t"), 12644 PublicRepos: Ptr(1), 12645 Followers: Ptr(1), 12646 Following: Ptr(1), 12647 CreatedAt: &Timestamp{referenceTime}, 12648 SuspendedAt: &Timestamp{referenceTime}, 12649 }, 12650 SuspendedAt: &Timestamp{referenceTime}, 12651 }, 12652 } 12653 12654 want := `{ 12655 "action": "a", 12656 "blocked_user": { 12657 "login": "l", 12658 "id": 1, 12659 "node_id": "n", 12660 "avatar_url": "a", 12661 "url": "u", 12662 "events_url": "e", 12663 "repos_url": "r" 12664 }, 12665 "organization": { 12666 "name": "n", 12667 "company": "c", 12668 "blog": "b", 12669 "location": "loc", 12670 "email": "e", 12671 "twitter_username": "tu", 12672 "description": "d", 12673 "billing_email": "be", 12674 "is_verified": true, 12675 "has_organization_projects": true, 12676 "has_repository_projects": true, 12677 "default_repository_permission": "drp", 12678 "members_can_create_repositories": true, 12679 "members_can_create_public_repositories": false, 12680 "members_can_create_private_repositories": true, 12681 "members_can_create_internal_repositories": true, 12682 "members_allowed_repository_creation_type": "marct", 12683 "members_can_create_pages": true, 12684 "members_can_create_public_pages": false, 12685 "members_can_create_private_pages": true 12686 }, 12687 "sender": { 12688 "login": "l", 12689 "id": 1, 12690 "node_id": "n", 12691 "avatar_url": "a", 12692 "url": "u", 12693 "events_url": "e", 12694 "repos_url": "r" 12695 }, 12696 "installation": { 12697 "id": 1, 12698 "node_id": "nid", 12699 "app_id": 1, 12700 "app_slug": "as", 12701 "target_id": 1, 12702 "account": { 12703 "login": "l", 12704 "id": 1, 12705 "avatar_url": "a", 12706 "gravatar_id": "g", 12707 "name": "n", 12708 "company": "c", 12709 "blog": "b", 12710 "location": "l", 12711 "email": "e", 12712 "hireable": true, 12713 "bio": "b", 12714 "twitter_username": "t", 12715 "public_repos": 1, 12716 "followers": 1, 12717 "following": 1, 12718 "created_at": ` + referenceTimeStr + `, 12719 "suspended_at": ` + referenceTimeStr + `, 12720 "url": "u" 12721 }, 12722 "access_tokens_url": "atu", 12723 "repositories_url": "ru", 12724 "html_url": "hu", 12725 "target_type": "tt", 12726 "single_file_name": "sfn", 12727 "repository_selection": "rs", 12728 "events": [ 12729 "e" 12730 ], 12731 "single_file_paths": [ 12732 "s" 12733 ], 12734 "permissions": { 12735 "actions": "a", 12736 "administration": "ad", 12737 "checks": "c", 12738 "contents": "co", 12739 "content_references": "cr", 12740 "deployments": "d", 12741 "environments": "e", 12742 "issues": "i", 12743 "metadata": "md", 12744 "members": "m", 12745 "organization_administration": "oa", 12746 "organization_hooks": "oh", 12747 "organization_plan": "op", 12748 "organization_pre_receive_hooks": "opr", 12749 "organization_projects": "op", 12750 "organization_secrets": "os", 12751 "organization_self_hosted_runners": "osh", 12752 "organization_user_blocking": "oub", 12753 "packages": "pkg", 12754 "pages": "pg", 12755 "pull_requests": "pr", 12756 "repository_hooks": "rh", 12757 "repository_projects": "rp", 12758 "repository_pre_receive_hooks": "rprh", 12759 "secrets": "s", 12760 "secret_scanning_alerts": "ssa", 12761 "security_events": "se", 12762 "single_file": "sf", 12763 "statuses": "s", 12764 "team_discussions": "td", 12765 "vulnerability_alerts": "va", 12766 "workflows": "w" 12767 }, 12768 "created_at": ` + referenceTimeStr + `, 12769 "updated_at": ` + referenceTimeStr + `, 12770 "has_multiple_single_files": false, 12771 "suspended_by": { 12772 "login": "l", 12773 "id": 1, 12774 "avatar_url": "a", 12775 "gravatar_id": "g", 12776 "name": "n", 12777 "company": "c", 12778 "blog": "b", 12779 "location": "l", 12780 "email": "e", 12781 "hireable": true, 12782 "bio": "b", 12783 "twitter_username": "t", 12784 "public_repos": 1, 12785 "followers": 1, 12786 "following": 1, 12787 "created_at": ` + referenceTimeStr + `, 12788 "suspended_at": ` + referenceTimeStr + `, 12789 "url": "u" 12790 }, 12791 "suspended_at": ` + referenceTimeStr + ` 12792 } 12793 }` 12794 12795 testJSONMarshal(t, u, want) 12796 } 12797 12798 func TestGollumEvent_Marshal(t *testing.T) { 12799 t.Parallel() 12800 testJSONMarshal(t, &GollumEvent{}, "{}") 12801 12802 u := &GollumEvent{ 12803 Pages: []*Page{ 12804 { 12805 PageName: Ptr("pn"), 12806 Title: Ptr("t"), 12807 Summary: Ptr("s"), 12808 Action: Ptr("a"), 12809 SHA: Ptr("sha"), 12810 HTMLURL: Ptr("hu"), 12811 }, 12812 }, 12813 Repo: &Repository{ 12814 ID: Ptr(int64(1)), 12815 URL: Ptr("s"), 12816 Name: Ptr("n"), 12817 }, 12818 Sender: &User{ 12819 Login: Ptr("l"), 12820 ID: Ptr(int64(1)), 12821 NodeID: Ptr("n"), 12822 URL: Ptr("u"), 12823 ReposURL: Ptr("r"), 12824 EventsURL: Ptr("e"), 12825 AvatarURL: Ptr("a"), 12826 }, 12827 Installation: &Installation{ 12828 ID: Ptr(int64(1)), 12829 NodeID: Ptr("nid"), 12830 AppID: Ptr(int64(1)), 12831 AppSlug: Ptr("as"), 12832 TargetID: Ptr(int64(1)), 12833 Account: &User{ 12834 Login: Ptr("l"), 12835 ID: Ptr(int64(1)), 12836 URL: Ptr("u"), 12837 AvatarURL: Ptr("a"), 12838 GravatarID: Ptr("g"), 12839 Name: Ptr("n"), 12840 Company: Ptr("c"), 12841 Blog: Ptr("b"), 12842 Location: Ptr("l"), 12843 Email: Ptr("e"), 12844 Hireable: Ptr(true), 12845 Bio: Ptr("b"), 12846 TwitterUsername: Ptr("t"), 12847 PublicRepos: Ptr(1), 12848 Followers: Ptr(1), 12849 Following: Ptr(1), 12850 CreatedAt: &Timestamp{referenceTime}, 12851 SuspendedAt: &Timestamp{referenceTime}, 12852 }, 12853 AccessTokensURL: Ptr("atu"), 12854 RepositoriesURL: Ptr("ru"), 12855 HTMLURL: Ptr("hu"), 12856 TargetType: Ptr("tt"), 12857 SingleFileName: Ptr("sfn"), 12858 RepositorySelection: Ptr("rs"), 12859 Events: []string{"e"}, 12860 SingleFilePaths: []string{"s"}, 12861 Permissions: &InstallationPermissions{ 12862 Actions: Ptr("a"), 12863 Administration: Ptr("ad"), 12864 Checks: Ptr("c"), 12865 Contents: Ptr("co"), 12866 ContentReferences: Ptr("cr"), 12867 Deployments: Ptr("d"), 12868 Environments: Ptr("e"), 12869 Issues: Ptr("i"), 12870 Metadata: Ptr("md"), 12871 Members: Ptr("m"), 12872 OrganizationAdministration: Ptr("oa"), 12873 OrganizationHooks: Ptr("oh"), 12874 OrganizationPlan: Ptr("op"), 12875 OrganizationPreReceiveHooks: Ptr("opr"), 12876 OrganizationProjects: Ptr("op"), 12877 OrganizationSecrets: Ptr("os"), 12878 OrganizationSelfHostedRunners: Ptr("osh"), 12879 OrganizationUserBlocking: Ptr("oub"), 12880 Packages: Ptr("pkg"), 12881 Pages: Ptr("pg"), 12882 PullRequests: Ptr("pr"), 12883 RepositoryHooks: Ptr("rh"), 12884 RepositoryProjects: Ptr("rp"), 12885 RepositoryPreReceiveHooks: Ptr("rprh"), 12886 Secrets: Ptr("s"), 12887 SecretScanningAlerts: Ptr("ssa"), 12888 SecurityEvents: Ptr("se"), 12889 SingleFile: Ptr("sf"), 12890 Statuses: Ptr("s"), 12891 TeamDiscussions: Ptr("td"), 12892 VulnerabilityAlerts: Ptr("va"), 12893 Workflows: Ptr("w"), 12894 }, 12895 CreatedAt: &Timestamp{referenceTime}, 12896 UpdatedAt: &Timestamp{referenceTime}, 12897 HasMultipleSingleFiles: Ptr(false), 12898 SuspendedBy: &User{ 12899 Login: Ptr("l"), 12900 ID: Ptr(int64(1)), 12901 URL: Ptr("u"), 12902 AvatarURL: Ptr("a"), 12903 GravatarID: Ptr("g"), 12904 Name: Ptr("n"), 12905 Company: Ptr("c"), 12906 Blog: Ptr("b"), 12907 Location: Ptr("l"), 12908 Email: Ptr("e"), 12909 Hireable: Ptr(true), 12910 Bio: Ptr("b"), 12911 TwitterUsername: Ptr("t"), 12912 PublicRepos: Ptr(1), 12913 Followers: Ptr(1), 12914 Following: Ptr(1), 12915 CreatedAt: &Timestamp{referenceTime}, 12916 SuspendedAt: &Timestamp{referenceTime}, 12917 }, 12918 SuspendedAt: &Timestamp{referenceTime}, 12919 }, 12920 } 12921 12922 want := `{ 12923 "pages": [ 12924 { 12925 "page_name": "pn", 12926 "title": "t", 12927 "summary": "s", 12928 "action": "a", 12929 "sha": "sha", 12930 "html_url": "hu" 12931 } 12932 ], 12933 "repository": { 12934 "id": 1, 12935 "name": "n", 12936 "url": "s" 12937 }, 12938 "sender": { 12939 "login": "l", 12940 "id": 1, 12941 "node_id": "n", 12942 "avatar_url": "a", 12943 "url": "u", 12944 "events_url": "e", 12945 "repos_url": "r" 12946 }, 12947 "installation": { 12948 "id": 1, 12949 "node_id": "nid", 12950 "app_id": 1, 12951 "app_slug": "as", 12952 "target_id": 1, 12953 "account": { 12954 "login": "l", 12955 "id": 1, 12956 "avatar_url": "a", 12957 "gravatar_id": "g", 12958 "name": "n", 12959 "company": "c", 12960 "blog": "b", 12961 "location": "l", 12962 "email": "e", 12963 "hireable": true, 12964 "bio": "b", 12965 "twitter_username": "t", 12966 "public_repos": 1, 12967 "followers": 1, 12968 "following": 1, 12969 "created_at": ` + referenceTimeStr + `, 12970 "suspended_at": ` + referenceTimeStr + `, 12971 "url": "u" 12972 }, 12973 "access_tokens_url": "atu", 12974 "repositories_url": "ru", 12975 "html_url": "hu", 12976 "target_type": "tt", 12977 "single_file_name": "sfn", 12978 "repository_selection": "rs", 12979 "events": [ 12980 "e" 12981 ], 12982 "single_file_paths": [ 12983 "s" 12984 ], 12985 "permissions": { 12986 "actions": "a", 12987 "administration": "ad", 12988 "checks": "c", 12989 "contents": "co", 12990 "content_references": "cr", 12991 "deployments": "d", 12992 "environments": "e", 12993 "issues": "i", 12994 "metadata": "md", 12995 "members": "m", 12996 "organization_administration": "oa", 12997 "organization_hooks": "oh", 12998 "organization_plan": "op", 12999 "organization_pre_receive_hooks": "opr", 13000 "organization_projects": "op", 13001 "organization_secrets": "os", 13002 "organization_self_hosted_runners": "osh", 13003 "organization_user_blocking": "oub", 13004 "packages": "pkg", 13005 "pages": "pg", 13006 "pull_requests": "pr", 13007 "repository_hooks": "rh", 13008 "repository_projects": "rp", 13009 "repository_pre_receive_hooks": "rprh", 13010 "secrets": "s", 13011 "secret_scanning_alerts": "ssa", 13012 "security_events": "se", 13013 "single_file": "sf", 13014 "statuses": "s", 13015 "team_discussions": "td", 13016 "vulnerability_alerts": "va", 13017 "workflows": "w" 13018 }, 13019 "created_at": ` + referenceTimeStr + `, 13020 "updated_at": ` + referenceTimeStr + `, 13021 "has_multiple_single_files": false, 13022 "suspended_by": { 13023 "login": "l", 13024 "id": 1, 13025 "avatar_url": "a", 13026 "gravatar_id": "g", 13027 "name": "n", 13028 "company": "c", 13029 "blog": "b", 13030 "location": "l", 13031 "email": "e", 13032 "hireable": true, 13033 "bio": "b", 13034 "twitter_username": "t", 13035 "public_repos": 1, 13036 "followers": 1, 13037 "following": 1, 13038 "created_at": ` + referenceTimeStr + `, 13039 "suspended_at": ` + referenceTimeStr + `, 13040 "url": "u" 13041 }, 13042 "suspended_at": ` + referenceTimeStr + ` 13043 } 13044 }` 13045 13046 testJSONMarshal(t, u, want) 13047 } 13048 13049 func TestWorkflowRunEvent_Marshal(t *testing.T) { 13050 t.Parallel() 13051 testJSONMarshal(t, &WorkflowRunEvent{}, "{}") 13052 13053 u := &WorkflowRunEvent{ 13054 Action: Ptr("a"), 13055 Workflow: &Workflow{ 13056 ID: Ptr(int64(1)), 13057 NodeID: Ptr("nid"), 13058 Name: Ptr("n"), 13059 Path: Ptr("p"), 13060 State: Ptr("s"), 13061 CreatedAt: &Timestamp{referenceTime}, 13062 UpdatedAt: &Timestamp{referenceTime}, 13063 URL: Ptr("u"), 13064 HTMLURL: Ptr("h"), 13065 BadgeURL: Ptr("b"), 13066 }, 13067 WorkflowRun: &WorkflowRun{ 13068 ID: Ptr(int64(1)), 13069 Name: Ptr("n"), 13070 NodeID: Ptr("nid"), 13071 HeadBranch: Ptr("hb"), 13072 HeadSHA: Ptr("hs"), 13073 RunNumber: Ptr(1), 13074 RunAttempt: Ptr(1), 13075 Event: Ptr("e"), 13076 Status: Ptr("s"), 13077 Conclusion: Ptr("c"), 13078 WorkflowID: Ptr(int64(1)), 13079 URL: Ptr("u"), 13080 HTMLURL: Ptr("h"), 13081 PullRequests: []*PullRequest{ 13082 { 13083 URL: Ptr("u"), 13084 ID: Ptr(int64(1)), 13085 Number: Ptr(1), 13086 Head: &PullRequestBranch{ 13087 Ref: Ptr("r"), 13088 SHA: Ptr("s"), 13089 Repo: &Repository{ 13090 ID: Ptr(int64(1)), 13091 URL: Ptr("s"), 13092 Name: Ptr("n"), 13093 }, 13094 }, 13095 Base: &PullRequestBranch{ 13096 Ref: Ptr("r"), 13097 SHA: Ptr("s"), 13098 Repo: &Repository{ 13099 ID: Ptr(int64(1)), 13100 URL: Ptr("u"), 13101 Name: Ptr("n"), 13102 }, 13103 }, 13104 }, 13105 }, 13106 CreatedAt: &Timestamp{referenceTime}, 13107 UpdatedAt: &Timestamp{referenceTime}, 13108 RunStartedAt: &Timestamp{referenceTime}, 13109 JobsURL: Ptr("j"), 13110 LogsURL: Ptr("l"), 13111 CheckSuiteURL: Ptr("c"), 13112 ArtifactsURL: Ptr("a"), 13113 CancelURL: Ptr("c"), 13114 RerunURL: Ptr("r"), 13115 PreviousAttemptURL: Ptr("p"), 13116 HeadCommit: &HeadCommit{ 13117 Message: Ptr("m"), 13118 Author: &CommitAuthor{ 13119 Name: Ptr("n"), 13120 Email: Ptr("e"), 13121 Login: Ptr("l"), 13122 }, 13123 URL: Ptr("u"), 13124 Distinct: Ptr(false), 13125 SHA: Ptr("s"), 13126 ID: Ptr("i"), 13127 TreeID: Ptr("tid"), 13128 Timestamp: &Timestamp{referenceTime}, 13129 Committer: &CommitAuthor{ 13130 Name: Ptr("n"), 13131 Email: Ptr("e"), 13132 Login: Ptr("l"), 13133 }, 13134 }, 13135 WorkflowURL: Ptr("w"), 13136 Repository: &Repository{ 13137 ID: Ptr(int64(1)), 13138 URL: Ptr("u"), 13139 Name: Ptr("n"), 13140 }, 13141 HeadRepository: &Repository{ 13142 ID: Ptr(int64(1)), 13143 URL: Ptr("u"), 13144 Name: Ptr("n"), 13145 }, 13146 }, 13147 Org: &Organization{ 13148 BillingEmail: Ptr("be"), 13149 Blog: Ptr("b"), 13150 Company: Ptr("c"), 13151 Email: Ptr("e"), 13152 TwitterUsername: Ptr("tu"), 13153 Location: Ptr("loc"), 13154 Name: Ptr("n"), 13155 Description: Ptr("d"), 13156 IsVerified: Ptr(true), 13157 HasOrganizationProjects: Ptr(true), 13158 HasRepositoryProjects: Ptr(true), 13159 DefaultRepoPermission: Ptr("drp"), 13160 MembersCanCreateRepos: Ptr(true), 13161 MembersCanCreateInternalRepos: Ptr(true), 13162 MembersCanCreatePrivateRepos: Ptr(true), 13163 MembersCanCreatePublicRepos: Ptr(false), 13164 MembersAllowedRepositoryCreationType: Ptr("marct"), 13165 MembersCanCreatePages: Ptr(true), 13166 MembersCanCreatePublicPages: Ptr(false), 13167 MembersCanCreatePrivatePages: Ptr(true), 13168 }, 13169 Repo: &Repository{ 13170 ID: Ptr(int64(1)), 13171 URL: Ptr("s"), 13172 Name: Ptr("n"), 13173 }, 13174 Sender: &User{ 13175 Login: Ptr("l"), 13176 ID: Ptr(int64(1)), 13177 NodeID: Ptr("n"), 13178 URL: Ptr("u"), 13179 ReposURL: Ptr("r"), 13180 EventsURL: Ptr("e"), 13181 AvatarURL: Ptr("a"), 13182 }, 13183 } 13184 13185 want := `{ 13186 "action": "a", 13187 "workflow": { 13188 "id": 1, 13189 "node_id": "nid", 13190 "name": "n", 13191 "path": "p", 13192 "state": "s", 13193 "created_at": ` + referenceTimeStr + `, 13194 "updated_at": ` + referenceTimeStr + `, 13195 "url": "u", 13196 "html_url": "h", 13197 "badge_url": "b" 13198 }, 13199 "workflow_run": { 13200 "id": 1, 13201 "name": "n", 13202 "node_id": "nid", 13203 "head_branch": "hb", 13204 "head_sha": "hs", 13205 "run_number": 1, 13206 "run_attempt": 1, 13207 "event": "e", 13208 "status": "s", 13209 "conclusion": "c", 13210 "workflow_id": 1, 13211 "url": "u", 13212 "html_url": "h", 13213 "pull_requests": [ 13214 { 13215 "id": 1, 13216 "number": 1, 13217 "url": "u", 13218 "head": { 13219 "ref": "r", 13220 "sha": "s", 13221 "repo": { 13222 "id": 1, 13223 "name": "n", 13224 "url": "s" 13225 } 13226 }, 13227 "base": { 13228 "ref": "r", 13229 "sha": "s", 13230 "repo": { 13231 "id": 1, 13232 "name": "n", 13233 "url": "u" 13234 } 13235 } 13236 } 13237 ], 13238 "created_at": ` + referenceTimeStr + `, 13239 "updated_at": ` + referenceTimeStr + `, 13240 "run_started_at": ` + referenceTimeStr + `, 13241 "jobs_url": "j", 13242 "logs_url": "l", 13243 "check_suite_url": "c", 13244 "artifacts_url": "a", 13245 "cancel_url": "c", 13246 "rerun_url": "r", 13247 "previous_attempt_url": "p", 13248 "head_commit": { 13249 "message": "m", 13250 "author": { 13251 "name": "n", 13252 "email": "e", 13253 "username": "l" 13254 }, 13255 "url": "u", 13256 "distinct": false, 13257 "sha": "s", 13258 "id": "i", 13259 "tree_id": "tid", 13260 "timestamp": ` + referenceTimeStr + `, 13261 "committer": { 13262 "name": "n", 13263 "email": "e", 13264 "username": "l" 13265 } 13266 }, 13267 "workflow_url": "w", 13268 "repository": { 13269 "id": 1, 13270 "name": "n", 13271 "url": "u" 13272 }, 13273 "head_repository": { 13274 "id": 1, 13275 "name": "n", 13276 "url": "u" 13277 } 13278 }, 13279 "organization": { 13280 "name": "n", 13281 "company": "c", 13282 "blog": "b", 13283 "location": "loc", 13284 "email": "e", 13285 "twitter_username": "tu", 13286 "description": "d", 13287 "billing_email": "be", 13288 "is_verified": true, 13289 "has_organization_projects": true, 13290 "has_repository_projects": true, 13291 "default_repository_permission": "drp", 13292 "members_can_create_repositories": true, 13293 "members_can_create_public_repositories": false, 13294 "members_can_create_private_repositories": true, 13295 "members_can_create_internal_repositories": true, 13296 "members_allowed_repository_creation_type": "marct", 13297 "members_can_create_pages": true, 13298 "members_can_create_public_pages": false, 13299 "members_can_create_private_pages": true 13300 }, 13301 "repository": { 13302 "id": 1, 13303 "name": "n", 13304 "url": "s" 13305 }, 13306 "sender": { 13307 "login": "l", 13308 "id": 1, 13309 "node_id": "n", 13310 "avatar_url": "a", 13311 "url": "u", 13312 "events_url": "e", 13313 "repos_url": "r" 13314 } 13315 }` 13316 13317 testJSONMarshal(t, u, want) 13318 } 13319 13320 func TestWorkflowDispatchEvent_Marshal(t *testing.T) { 13321 t.Parallel() 13322 testJSONMarshal(t, &WorkflowDispatchEvent{}, "{}") 13323 13324 i := make(map[string]interface{}) 13325 i["key"] = "value" 13326 13327 jsonMsg, _ := json.Marshal(i) 13328 u := &WorkflowDispatchEvent{ 13329 Inputs: jsonMsg, 13330 Ref: Ptr("r"), 13331 Workflow: Ptr("w"), 13332 Repo: &Repository{ 13333 ID: Ptr(int64(1)), 13334 URL: Ptr("s"), 13335 Name: Ptr("n"), 13336 }, 13337 Org: &Organization{ 13338 BillingEmail: Ptr("be"), 13339 Blog: Ptr("b"), 13340 Company: Ptr("c"), 13341 Email: Ptr("e"), 13342 TwitterUsername: Ptr("tu"), 13343 Location: Ptr("loc"), 13344 Name: Ptr("n"), 13345 Description: Ptr("d"), 13346 IsVerified: Ptr(true), 13347 HasOrganizationProjects: Ptr(true), 13348 HasRepositoryProjects: Ptr(true), 13349 DefaultRepoPermission: Ptr("drp"), 13350 MembersCanCreateRepos: Ptr(true), 13351 MembersCanCreateInternalRepos: Ptr(true), 13352 MembersCanCreatePrivateRepos: Ptr(true), 13353 MembersCanCreatePublicRepos: Ptr(false), 13354 MembersAllowedRepositoryCreationType: Ptr("marct"), 13355 MembersCanCreatePages: Ptr(true), 13356 MembersCanCreatePublicPages: Ptr(false), 13357 MembersCanCreatePrivatePages: Ptr(true), 13358 }, 13359 Sender: &User{ 13360 Login: Ptr("l"), 13361 ID: Ptr(int64(1)), 13362 NodeID: Ptr("n"), 13363 URL: Ptr("u"), 13364 ReposURL: Ptr("r"), 13365 EventsURL: Ptr("e"), 13366 AvatarURL: Ptr("a"), 13367 }, 13368 } 13369 13370 want := `{ 13371 "inputs": { 13372 "key": "value" 13373 }, 13374 "ref": "r", 13375 "workflow": "w", 13376 "repository": { 13377 "id": 1, 13378 "name": "n", 13379 "url": "s" 13380 }, 13381 "organization": { 13382 "name": "n", 13383 "company": "c", 13384 "blog": "b", 13385 "location": "loc", 13386 "email": "e", 13387 "twitter_username": "tu", 13388 "description": "d", 13389 "billing_email": "be", 13390 "is_verified": true, 13391 "has_organization_projects": true, 13392 "has_repository_projects": true, 13393 "default_repository_permission": "drp", 13394 "members_can_create_repositories": true, 13395 "members_can_create_public_repositories": false, 13396 "members_can_create_private_repositories": true, 13397 "members_can_create_internal_repositories": true, 13398 "members_allowed_repository_creation_type": "marct", 13399 "members_can_create_pages": true, 13400 "members_can_create_public_pages": false, 13401 "members_can_create_private_pages": true 13402 }, 13403 "sender": { 13404 "login": "l", 13405 "id": 1, 13406 "node_id": "n", 13407 "avatar_url": "a", 13408 "url": "u", 13409 "events_url": "e", 13410 "repos_url": "r" 13411 } 13412 }` 13413 13414 testJSONMarshal(t, u, want) 13415 } 13416 13417 func TestWatchEvent_Marshal(t *testing.T) { 13418 t.Parallel() 13419 testJSONMarshal(t, &WatchEvent{}, "{}") 13420 13421 u := &WatchEvent{ 13422 Action: Ptr("a"), 13423 Repo: &Repository{ 13424 ID: Ptr(int64(1)), 13425 URL: Ptr("s"), 13426 Name: Ptr("n"), 13427 }, 13428 Sender: &User{ 13429 Login: Ptr("l"), 13430 ID: Ptr(int64(1)), 13431 NodeID: Ptr("n"), 13432 URL: Ptr("u"), 13433 ReposURL: Ptr("r"), 13434 EventsURL: Ptr("e"), 13435 AvatarURL: Ptr("a"), 13436 }, 13437 Installation: &Installation{ 13438 ID: Ptr(int64(1)), 13439 NodeID: Ptr("nid"), 13440 AppID: Ptr(int64(1)), 13441 AppSlug: Ptr("as"), 13442 TargetID: Ptr(int64(1)), 13443 Account: &User{ 13444 Login: Ptr("l"), 13445 ID: Ptr(int64(1)), 13446 URL: Ptr("u"), 13447 AvatarURL: Ptr("a"), 13448 GravatarID: Ptr("g"), 13449 Name: Ptr("n"), 13450 Company: Ptr("c"), 13451 Blog: Ptr("b"), 13452 Location: Ptr("l"), 13453 Email: Ptr("e"), 13454 Hireable: Ptr(true), 13455 Bio: Ptr("b"), 13456 TwitterUsername: Ptr("t"), 13457 PublicRepos: Ptr(1), 13458 Followers: Ptr(1), 13459 Following: Ptr(1), 13460 CreatedAt: &Timestamp{referenceTime}, 13461 SuspendedAt: &Timestamp{referenceTime}, 13462 }, 13463 AccessTokensURL: Ptr("atu"), 13464 RepositoriesURL: Ptr("ru"), 13465 HTMLURL: Ptr("hu"), 13466 TargetType: Ptr("tt"), 13467 SingleFileName: Ptr("sfn"), 13468 RepositorySelection: Ptr("rs"), 13469 Events: []string{"e"}, 13470 SingleFilePaths: []string{"s"}, 13471 Permissions: &InstallationPermissions{ 13472 Actions: Ptr("a"), 13473 Administration: Ptr("ad"), 13474 Checks: Ptr("c"), 13475 Contents: Ptr("co"), 13476 ContentReferences: Ptr("cr"), 13477 Deployments: Ptr("d"), 13478 Environments: Ptr("e"), 13479 Issues: Ptr("i"), 13480 Metadata: Ptr("md"), 13481 Members: Ptr("m"), 13482 OrganizationAdministration: Ptr("oa"), 13483 OrganizationHooks: Ptr("oh"), 13484 OrganizationPlan: Ptr("op"), 13485 OrganizationPreReceiveHooks: Ptr("opr"), 13486 OrganizationProjects: Ptr("op"), 13487 OrganizationSecrets: Ptr("os"), 13488 OrganizationSelfHostedRunners: Ptr("osh"), 13489 OrganizationUserBlocking: Ptr("oub"), 13490 Packages: Ptr("pkg"), 13491 Pages: Ptr("pg"), 13492 PullRequests: Ptr("pr"), 13493 RepositoryHooks: Ptr("rh"), 13494 RepositoryProjects: Ptr("rp"), 13495 RepositoryPreReceiveHooks: Ptr("rprh"), 13496 Secrets: Ptr("s"), 13497 SecretScanningAlerts: Ptr("ssa"), 13498 SecurityEvents: Ptr("se"), 13499 SingleFile: Ptr("sf"), 13500 Statuses: Ptr("s"), 13501 TeamDiscussions: Ptr("td"), 13502 VulnerabilityAlerts: Ptr("va"), 13503 Workflows: Ptr("w"), 13504 }, 13505 CreatedAt: &Timestamp{referenceTime}, 13506 UpdatedAt: &Timestamp{referenceTime}, 13507 HasMultipleSingleFiles: Ptr(false), 13508 SuspendedBy: &User{ 13509 Login: Ptr("l"), 13510 ID: Ptr(int64(1)), 13511 URL: Ptr("u"), 13512 AvatarURL: Ptr("a"), 13513 GravatarID: Ptr("g"), 13514 Name: Ptr("n"), 13515 Company: Ptr("c"), 13516 Blog: Ptr("b"), 13517 Location: Ptr("l"), 13518 Email: Ptr("e"), 13519 Hireable: Ptr(true), 13520 Bio: Ptr("b"), 13521 TwitterUsername: Ptr("t"), 13522 PublicRepos: Ptr(1), 13523 Followers: Ptr(1), 13524 Following: Ptr(1), 13525 CreatedAt: &Timestamp{referenceTime}, 13526 SuspendedAt: &Timestamp{referenceTime}, 13527 }, 13528 SuspendedAt: &Timestamp{referenceTime}, 13529 }, 13530 } 13531 13532 want := `{ 13533 "action": "a", 13534 "repository": { 13535 "id": 1, 13536 "name": "n", 13537 "url": "s" 13538 }, 13539 "sender": { 13540 "login": "l", 13541 "id": 1, 13542 "node_id": "n", 13543 "avatar_url": "a", 13544 "url": "u", 13545 "events_url": "e", 13546 "repos_url": "r" 13547 }, 13548 "installation": { 13549 "id": 1, 13550 "node_id": "nid", 13551 "app_id": 1, 13552 "app_slug": "as", 13553 "target_id": 1, 13554 "account": { 13555 "login": "l", 13556 "id": 1, 13557 "avatar_url": "a", 13558 "gravatar_id": "g", 13559 "name": "n", 13560 "company": "c", 13561 "blog": "b", 13562 "location": "l", 13563 "email": "e", 13564 "hireable": true, 13565 "bio": "b", 13566 "twitter_username": "t", 13567 "public_repos": 1, 13568 "followers": 1, 13569 "following": 1, 13570 "created_at": ` + referenceTimeStr + `, 13571 "suspended_at": ` + referenceTimeStr + `, 13572 "url": "u" 13573 }, 13574 "access_tokens_url": "atu", 13575 "repositories_url": "ru", 13576 "html_url": "hu", 13577 "target_type": "tt", 13578 "single_file_name": "sfn", 13579 "repository_selection": "rs", 13580 "events": [ 13581 "e" 13582 ], 13583 "single_file_paths": [ 13584 "s" 13585 ], 13586 "permissions": { 13587 "actions": "a", 13588 "administration": "ad", 13589 "checks": "c", 13590 "contents": "co", 13591 "content_references": "cr", 13592 "deployments": "d", 13593 "environments": "e", 13594 "issues": "i", 13595 "metadata": "md", 13596 "members": "m", 13597 "organization_administration": "oa", 13598 "organization_hooks": "oh", 13599 "organization_plan": "op", 13600 "organization_pre_receive_hooks": "opr", 13601 "organization_projects": "op", 13602 "organization_secrets": "os", 13603 "organization_self_hosted_runners": "osh", 13604 "organization_user_blocking": "oub", 13605 "packages": "pkg", 13606 "pages": "pg", 13607 "pull_requests": "pr", 13608 "repository_hooks": "rh", 13609 "repository_projects": "rp", 13610 "repository_pre_receive_hooks": "rprh", 13611 "secrets": "s", 13612 "secret_scanning_alerts": "ssa", 13613 "security_events": "se", 13614 "single_file": "sf", 13615 "statuses": "s", 13616 "team_discussions": "td", 13617 "vulnerability_alerts": "va", 13618 "workflows": "w" 13619 }, 13620 "created_at": ` + referenceTimeStr + `, 13621 "updated_at": ` + referenceTimeStr + `, 13622 "has_multiple_single_files": false, 13623 "suspended_by": { 13624 "login": "l", 13625 "id": 1, 13626 "avatar_url": "a", 13627 "gravatar_id": "g", 13628 "name": "n", 13629 "company": "c", 13630 "blog": "b", 13631 "location": "l", 13632 "email": "e", 13633 "hireable": true, 13634 "bio": "b", 13635 "twitter_username": "t", 13636 "public_repos": 1, 13637 "followers": 1, 13638 "following": 1, 13639 "created_at": ` + referenceTimeStr + `, 13640 "suspended_at": ` + referenceTimeStr + `, 13641 "url": "u" 13642 }, 13643 "suspended_at": ` + referenceTimeStr + ` 13644 } 13645 }` 13646 13647 testJSONMarshal(t, u, want) 13648 } 13649 13650 func TestUserEvent_Marshal(t *testing.T) { 13651 t.Parallel() 13652 testJSONMarshal(t, &UserEvent{}, "{}") 13653 13654 u := &UserEvent{ 13655 User: &User{ 13656 Login: Ptr("l"), 13657 ID: Ptr(int64(1)), 13658 NodeID: Ptr("n"), 13659 URL: Ptr("u"), 13660 ReposURL: Ptr("r"), 13661 EventsURL: Ptr("e"), 13662 AvatarURL: Ptr("a"), 13663 }, 13664 // The action performed. Possible values are: "created" or "deleted". 13665 Action: Ptr("a"), 13666 Enterprise: &Enterprise{ 13667 ID: Ptr(1), 13668 Slug: Ptr("s"), 13669 Name: Ptr("n"), 13670 NodeID: Ptr("nid"), 13671 AvatarURL: Ptr("au"), 13672 Description: Ptr("d"), 13673 WebsiteURL: Ptr("wu"), 13674 HTMLURL: Ptr("hu"), 13675 CreatedAt: &Timestamp{referenceTime}, 13676 UpdatedAt: &Timestamp{referenceTime}, 13677 }, 13678 Sender: &User{ 13679 Login: Ptr("l"), 13680 ID: Ptr(int64(1)), 13681 NodeID: Ptr("n"), 13682 URL: Ptr("u"), 13683 ReposURL: Ptr("r"), 13684 EventsURL: Ptr("e"), 13685 AvatarURL: Ptr("a"), 13686 }, 13687 } 13688 13689 want := `{ 13690 "user": { 13691 "login": "l", 13692 "id": 1, 13693 "node_id": "n", 13694 "avatar_url": "a", 13695 "url": "u", 13696 "events_url": "e", 13697 "repos_url": "r" 13698 }, 13699 "action": "a", 13700 "enterprise": { 13701 "id": 1, 13702 "slug": "s", 13703 "name": "n", 13704 "node_id": "nid", 13705 "avatar_url": "au", 13706 "description": "d", 13707 "website_url": "wu", 13708 "html_url": "hu", 13709 "created_at": ` + referenceTimeStr + `, 13710 "updated_at": ` + referenceTimeStr + ` 13711 }, 13712 "sender": { 13713 "login": "l", 13714 "id": 1, 13715 "node_id": "n", 13716 "avatar_url": "a", 13717 "url": "u", 13718 "events_url": "e", 13719 "repos_url": "r" 13720 } 13721 }` 13722 13723 testJSONMarshal(t, u, want) 13724 } 13725 13726 func TestCheckRunEvent_Marshal(t *testing.T) { 13727 t.Parallel() 13728 testJSONMarshal(t, &CheckRunEvent{}, "{}") 13729 13730 r := &CheckRunEvent{ 13731 CheckRun: &CheckRun{ 13732 ID: Ptr(int64(1)), 13733 NodeID: Ptr("n"), 13734 HeadSHA: Ptr("h"), 13735 ExternalID: Ptr("1"), 13736 URL: Ptr("u"), 13737 HTMLURL: Ptr("u"), 13738 DetailsURL: Ptr("u"), 13739 Status: Ptr("s"), 13740 Conclusion: Ptr("c"), 13741 StartedAt: &Timestamp{referenceTime}, 13742 CompletedAt: &Timestamp{referenceTime}, 13743 Output: &CheckRunOutput{ 13744 Annotations: []*CheckRunAnnotation{ 13745 { 13746 AnnotationLevel: Ptr("a"), 13747 EndLine: Ptr(1), 13748 Message: Ptr("m"), 13749 Path: Ptr("p"), 13750 RawDetails: Ptr("r"), 13751 StartLine: Ptr(1), 13752 Title: Ptr("t"), 13753 }, 13754 }, 13755 AnnotationsCount: Ptr(1), 13756 AnnotationsURL: Ptr("a"), 13757 Images: []*CheckRunImage{ 13758 { 13759 Alt: Ptr("a"), 13760 ImageURL: Ptr("i"), 13761 Caption: Ptr("c"), 13762 }, 13763 }, 13764 Title: Ptr("t"), 13765 Summary: Ptr("s"), 13766 Text: Ptr("t"), 13767 }, 13768 Name: Ptr("n"), 13769 CheckSuite: &CheckSuite{ 13770 ID: Ptr(int64(1)), 13771 }, 13772 App: &App{ 13773 ID: Ptr(int64(1)), 13774 NodeID: Ptr("n"), 13775 Owner: &User{ 13776 Login: Ptr("l"), 13777 ID: Ptr(int64(1)), 13778 NodeID: Ptr("n"), 13779 URL: Ptr("u"), 13780 ReposURL: Ptr("r"), 13781 EventsURL: Ptr("e"), 13782 AvatarURL: Ptr("a"), 13783 }, 13784 Name: Ptr("n"), 13785 Description: Ptr("d"), 13786 HTMLURL: Ptr("h"), 13787 ExternalURL: Ptr("u"), 13788 CreatedAt: &Timestamp{referenceTime}, 13789 UpdatedAt: &Timestamp{referenceTime}, 13790 }, 13791 PullRequests: []*PullRequest{ 13792 { 13793 URL: Ptr("u"), 13794 ID: Ptr(int64(1)), 13795 Number: Ptr(1), 13796 Head: &PullRequestBranch{ 13797 Ref: Ptr("r"), 13798 SHA: Ptr("s"), 13799 Repo: &Repository{ 13800 ID: Ptr(int64(1)), 13801 URL: Ptr("s"), 13802 Name: Ptr("n"), 13803 }, 13804 }, 13805 Base: &PullRequestBranch{ 13806 Ref: Ptr("r"), 13807 SHA: Ptr("s"), 13808 Repo: &Repository{ 13809 ID: Ptr(int64(1)), 13810 URL: Ptr("u"), 13811 Name: Ptr("n"), 13812 }, 13813 }, 13814 }, 13815 }, 13816 }, 13817 Action: Ptr("a"), 13818 Repo: &Repository{ 13819 ID: Ptr(int64(1)), 13820 URL: Ptr("s"), 13821 Name: Ptr("n"), 13822 }, 13823 Org: &Organization{ 13824 BillingEmail: Ptr("be"), 13825 Blog: Ptr("b"), 13826 Company: Ptr("c"), 13827 Email: Ptr("e"), 13828 TwitterUsername: Ptr("tu"), 13829 Location: Ptr("loc"), 13830 Name: Ptr("n"), 13831 Description: Ptr("d"), 13832 IsVerified: Ptr(true), 13833 HasOrganizationProjects: Ptr(true), 13834 HasRepositoryProjects: Ptr(true), 13835 DefaultRepoPermission: Ptr("drp"), 13836 MembersCanCreateRepos: Ptr(true), 13837 MembersCanCreateInternalRepos: Ptr(true), 13838 MembersCanCreatePrivateRepos: Ptr(true), 13839 MembersCanCreatePublicRepos: Ptr(false), 13840 MembersAllowedRepositoryCreationType: Ptr("marct"), 13841 MembersCanCreatePages: Ptr(true), 13842 MembersCanCreatePublicPages: Ptr(false), 13843 MembersCanCreatePrivatePages: Ptr(true), 13844 }, 13845 Sender: &User{ 13846 Login: Ptr("l"), 13847 ID: Ptr(int64(1)), 13848 NodeID: Ptr("n"), 13849 URL: Ptr("u"), 13850 ReposURL: Ptr("r"), 13851 EventsURL: Ptr("e"), 13852 AvatarURL: Ptr("a"), 13853 }, 13854 Installation: &Installation{ 13855 ID: Ptr(int64(1)), 13856 NodeID: Ptr("nid"), 13857 AppID: Ptr(int64(1)), 13858 AppSlug: Ptr("as"), 13859 TargetID: Ptr(int64(1)), 13860 Account: &User{ 13861 Login: Ptr("l"), 13862 ID: Ptr(int64(1)), 13863 URL: Ptr("u"), 13864 AvatarURL: Ptr("a"), 13865 GravatarID: Ptr("g"), 13866 Name: Ptr("n"), 13867 Company: Ptr("c"), 13868 Blog: Ptr("b"), 13869 Location: Ptr("l"), 13870 Email: Ptr("e"), 13871 Hireable: Ptr(true), 13872 Bio: Ptr("b"), 13873 TwitterUsername: Ptr("t"), 13874 PublicRepos: Ptr(1), 13875 Followers: Ptr(1), 13876 Following: Ptr(1), 13877 CreatedAt: &Timestamp{referenceTime}, 13878 SuspendedAt: &Timestamp{referenceTime}, 13879 }, 13880 AccessTokensURL: Ptr("atu"), 13881 RepositoriesURL: Ptr("ru"), 13882 HTMLURL: Ptr("hu"), 13883 TargetType: Ptr("tt"), 13884 SingleFileName: Ptr("sfn"), 13885 RepositorySelection: Ptr("rs"), 13886 Events: []string{"e"}, 13887 SingleFilePaths: []string{"s"}, 13888 Permissions: &InstallationPermissions{ 13889 Actions: Ptr("a"), 13890 Administration: Ptr("ad"), 13891 Checks: Ptr("c"), 13892 Contents: Ptr("co"), 13893 ContentReferences: Ptr("cr"), 13894 Deployments: Ptr("d"), 13895 Environments: Ptr("e"), 13896 Issues: Ptr("i"), 13897 Metadata: Ptr("md"), 13898 Members: Ptr("m"), 13899 OrganizationAdministration: Ptr("oa"), 13900 OrganizationHooks: Ptr("oh"), 13901 OrganizationPlan: Ptr("op"), 13902 OrganizationPreReceiveHooks: Ptr("opr"), 13903 OrganizationProjects: Ptr("op"), 13904 OrganizationSecrets: Ptr("os"), 13905 OrganizationSelfHostedRunners: Ptr("osh"), 13906 OrganizationUserBlocking: Ptr("oub"), 13907 Packages: Ptr("pkg"), 13908 Pages: Ptr("pg"), 13909 PullRequests: Ptr("pr"), 13910 RepositoryHooks: Ptr("rh"), 13911 RepositoryProjects: Ptr("rp"), 13912 RepositoryPreReceiveHooks: Ptr("rprh"), 13913 Secrets: Ptr("s"), 13914 SecretScanningAlerts: Ptr("ssa"), 13915 SecurityEvents: Ptr("se"), 13916 SingleFile: Ptr("sf"), 13917 Statuses: Ptr("s"), 13918 TeamDiscussions: Ptr("td"), 13919 VulnerabilityAlerts: Ptr("va"), 13920 Workflows: Ptr("w"), 13921 }, 13922 CreatedAt: &Timestamp{referenceTime}, 13923 UpdatedAt: &Timestamp{referenceTime}, 13924 HasMultipleSingleFiles: Ptr(false), 13925 SuspendedBy: &User{ 13926 Login: Ptr("l"), 13927 ID: Ptr(int64(1)), 13928 URL: Ptr("u"), 13929 AvatarURL: Ptr("a"), 13930 GravatarID: Ptr("g"), 13931 Name: Ptr("n"), 13932 Company: Ptr("c"), 13933 Blog: Ptr("b"), 13934 Location: Ptr("l"), 13935 Email: Ptr("e"), 13936 Hireable: Ptr(true), 13937 Bio: Ptr("b"), 13938 TwitterUsername: Ptr("t"), 13939 PublicRepos: Ptr(1), 13940 Followers: Ptr(1), 13941 Following: Ptr(1), 13942 CreatedAt: &Timestamp{referenceTime}, 13943 SuspendedAt: &Timestamp{referenceTime}, 13944 }, 13945 SuspendedAt: &Timestamp{referenceTime}, 13946 }, 13947 RequestedAction: &RequestedAction{ 13948 Identifier: "i", 13949 }, 13950 } 13951 13952 want := `{ 13953 "check_run": { 13954 "id": 1, 13955 "node_id": "n", 13956 "head_sha": "h", 13957 "external_id": "1", 13958 "url": "u", 13959 "html_url": "u", 13960 "details_url": "u", 13961 "status": "s", 13962 "conclusion": "c", 13963 "started_at": ` + referenceTimeStr + `, 13964 "completed_at": ` + referenceTimeStr + `, 13965 "output": { 13966 "title": "t", 13967 "summary": "s", 13968 "text": "t", 13969 "annotations_count": 1, 13970 "annotations_url": "a", 13971 "annotations": [ 13972 { 13973 "path": "p", 13974 "start_line": 1, 13975 "end_line": 1, 13976 "annotation_level": "a", 13977 "message": "m", 13978 "title": "t", 13979 "raw_details": "r" 13980 } 13981 ], 13982 "images": [ 13983 { 13984 "alt": "a", 13985 "image_url": "i", 13986 "caption": "c" 13987 } 13988 ] 13989 }, 13990 "name": "n", 13991 "check_suite": { 13992 "id": 1 13993 }, 13994 "app": { 13995 "id": 1, 13996 "node_id": "n", 13997 "owner": { 13998 "login": "l", 13999 "id": 1, 14000 "node_id": "n", 14001 "avatar_url": "a", 14002 "url": "u", 14003 "events_url": "e", 14004 "repos_url": "r" 14005 }, 14006 "name": "n", 14007 "description": "d", 14008 "external_url": "u", 14009 "html_url": "h", 14010 "created_at": ` + referenceTimeStr + `, 14011 "updated_at": ` + referenceTimeStr + ` 14012 }, 14013 "pull_requests": [ 14014 { 14015 "id": 1, 14016 "number": 1, 14017 "url": "u", 14018 "head": { 14019 "ref": "r", 14020 "sha": "s", 14021 "repo": { 14022 "id": 1, 14023 "name": "n", 14024 "url": "s" 14025 } 14026 }, 14027 "base": { 14028 "ref": "r", 14029 "sha": "s", 14030 "repo": { 14031 "id": 1, 14032 "name": "n", 14033 "url": "u" 14034 } 14035 } 14036 } 14037 ] 14038 }, 14039 "action": "a", 14040 "repository": { 14041 "id": 1, 14042 "name": "n", 14043 "url": "s" 14044 }, 14045 "organization": { 14046 "name": "n", 14047 "company": "c", 14048 "blog": "b", 14049 "location": "loc", 14050 "email": "e", 14051 "twitter_username": "tu", 14052 "description": "d", 14053 "billing_email": "be", 14054 "is_verified": true, 14055 "has_organization_projects": true, 14056 "has_repository_projects": true, 14057 "default_repository_permission": "drp", 14058 "members_can_create_repositories": true, 14059 "members_can_create_public_repositories": false, 14060 "members_can_create_private_repositories": true, 14061 "members_can_create_internal_repositories": true, 14062 "members_allowed_repository_creation_type": "marct", 14063 "members_can_create_pages": true, 14064 "members_can_create_public_pages": false, 14065 "members_can_create_private_pages": true 14066 }, 14067 "sender": { 14068 "login": "l", 14069 "id": 1, 14070 "node_id": "n", 14071 "avatar_url": "a", 14072 "url": "u", 14073 "events_url": "e", 14074 "repos_url": "r" 14075 }, 14076 "installation": { 14077 "id": 1, 14078 "node_id": "nid", 14079 "app_id": 1, 14080 "app_slug": "as", 14081 "target_id": 1, 14082 "account": { 14083 "login": "l", 14084 "id": 1, 14085 "avatar_url": "a", 14086 "gravatar_id": "g", 14087 "name": "n", 14088 "company": "c", 14089 "blog": "b", 14090 "location": "l", 14091 "email": "e", 14092 "hireable": true, 14093 "bio": "b", 14094 "twitter_username": "t", 14095 "public_repos": 1, 14096 "followers": 1, 14097 "following": 1, 14098 "created_at": ` + referenceTimeStr + `, 14099 "suspended_at": ` + referenceTimeStr + `, 14100 "url": "u" 14101 }, 14102 "access_tokens_url": "atu", 14103 "repositories_url": "ru", 14104 "html_url": "hu", 14105 "target_type": "tt", 14106 "single_file_name": "sfn", 14107 "repository_selection": "rs", 14108 "events": [ 14109 "e" 14110 ], 14111 "single_file_paths": [ 14112 "s" 14113 ], 14114 "permissions": { 14115 "actions": "a", 14116 "administration": "ad", 14117 "checks": "c", 14118 "contents": "co", 14119 "content_references": "cr", 14120 "deployments": "d", 14121 "environments": "e", 14122 "issues": "i", 14123 "metadata": "md", 14124 "members": "m", 14125 "organization_administration": "oa", 14126 "organization_hooks": "oh", 14127 "organization_plan": "op", 14128 "organization_pre_receive_hooks": "opr", 14129 "organization_projects": "op", 14130 "organization_secrets": "os", 14131 "organization_self_hosted_runners": "osh", 14132 "organization_user_blocking": "oub", 14133 "packages": "pkg", 14134 "pages": "pg", 14135 "pull_requests": "pr", 14136 "repository_hooks": "rh", 14137 "repository_projects": "rp", 14138 "repository_pre_receive_hooks": "rprh", 14139 "secrets": "s", 14140 "secret_scanning_alerts": "ssa", 14141 "security_events": "se", 14142 "single_file": "sf", 14143 "statuses": "s", 14144 "team_discussions": "td", 14145 "vulnerability_alerts": "va", 14146 "workflows": "w" 14147 }, 14148 "created_at": ` + referenceTimeStr + `, 14149 "updated_at": ` + referenceTimeStr + `, 14150 "has_multiple_single_files": false, 14151 "suspended_by": { 14152 "login": "l", 14153 "id": 1, 14154 "avatar_url": "a", 14155 "gravatar_id": "g", 14156 "name": "n", 14157 "company": "c", 14158 "blog": "b", 14159 "location": "l", 14160 "email": "e", 14161 "hireable": true, 14162 "bio": "b", 14163 "twitter_username": "t", 14164 "public_repos": 1, 14165 "followers": 1, 14166 "following": 1, 14167 "created_at": ` + referenceTimeStr + `, 14168 "suspended_at": ` + referenceTimeStr + `, 14169 "url": "u" 14170 }, 14171 "suspended_at": ` + referenceTimeStr + ` 14172 }, 14173 "requested_action": { 14174 "identifier": "i" 14175 } 14176 }` 14177 14178 testJSONMarshal(t, r, want) 14179 } 14180 14181 func TestCheckSuiteEvent_Marshal(t *testing.T) { 14182 t.Parallel() 14183 testJSONMarshal(t, &CheckSuiteEvent{}, "{}") 14184 14185 r := &CheckSuiteEvent{ 14186 CheckSuite: &CheckSuite{ 14187 ID: Ptr(int64(1)), 14188 NodeID: Ptr("n"), 14189 HeadBranch: Ptr("h"), 14190 HeadSHA: Ptr("h"), 14191 URL: Ptr("u"), 14192 BeforeSHA: Ptr("b"), 14193 AfterSHA: Ptr("a"), 14194 Status: Ptr("s"), 14195 Conclusion: Ptr("c"), 14196 App: &App{ 14197 ID: Ptr(int64(1)), 14198 NodeID: Ptr("n"), 14199 Owner: &User{ 14200 Login: Ptr("l"), 14201 ID: Ptr(int64(1)), 14202 NodeID: Ptr("n"), 14203 URL: Ptr("u"), 14204 ReposURL: Ptr("r"), 14205 EventsURL: Ptr("e"), 14206 AvatarURL: Ptr("a"), 14207 }, 14208 Name: Ptr("n"), 14209 Description: Ptr("d"), 14210 HTMLURL: Ptr("h"), 14211 ExternalURL: Ptr("u"), 14212 CreatedAt: &Timestamp{referenceTime}, 14213 UpdatedAt: &Timestamp{referenceTime}, 14214 }, 14215 Repository: &Repository{ 14216 ID: Ptr(int64(1)), 14217 }, 14218 PullRequests: []*PullRequest{ 14219 { 14220 URL: Ptr("u"), 14221 ID: Ptr(int64(1)), 14222 Number: Ptr(1), 14223 Head: &PullRequestBranch{ 14224 Ref: Ptr("r"), 14225 SHA: Ptr("s"), 14226 Repo: &Repository{ 14227 ID: Ptr(int64(1)), 14228 URL: Ptr("s"), 14229 Name: Ptr("n"), 14230 }, 14231 }, 14232 Base: &PullRequestBranch{ 14233 Ref: Ptr("r"), 14234 SHA: Ptr("s"), 14235 Repo: &Repository{ 14236 ID: Ptr(int64(1)), 14237 URL: Ptr("u"), 14238 Name: Ptr("n"), 14239 }, 14240 }, 14241 }, 14242 }, 14243 HeadCommit: &Commit{ 14244 SHA: Ptr("s"), 14245 }, 14246 }, 14247 Action: Ptr("a"), 14248 Repo: &Repository{ 14249 ID: Ptr(int64(1)), 14250 URL: Ptr("s"), 14251 Name: Ptr("n"), 14252 }, 14253 Org: &Organization{ 14254 BillingEmail: Ptr("be"), 14255 Blog: Ptr("b"), 14256 Company: Ptr("c"), 14257 Email: Ptr("e"), 14258 TwitterUsername: Ptr("tu"), 14259 Location: Ptr("loc"), 14260 Name: Ptr("n"), 14261 Description: Ptr("d"), 14262 IsVerified: Ptr(true), 14263 HasOrganizationProjects: Ptr(true), 14264 HasRepositoryProjects: Ptr(true), 14265 DefaultRepoPermission: Ptr("drp"), 14266 MembersCanCreateRepos: Ptr(true), 14267 MembersCanCreateInternalRepos: Ptr(true), 14268 MembersCanCreatePrivateRepos: Ptr(true), 14269 MembersCanCreatePublicRepos: Ptr(false), 14270 MembersAllowedRepositoryCreationType: Ptr("marct"), 14271 MembersCanCreatePages: Ptr(true), 14272 MembersCanCreatePublicPages: Ptr(false), 14273 MembersCanCreatePrivatePages: Ptr(true), 14274 }, 14275 Sender: &User{ 14276 Login: Ptr("l"), 14277 ID: Ptr(int64(1)), 14278 NodeID: Ptr("n"), 14279 URL: Ptr("u"), 14280 ReposURL: Ptr("r"), 14281 EventsURL: Ptr("e"), 14282 AvatarURL: Ptr("a"), 14283 }, 14284 Installation: &Installation{ 14285 ID: Ptr(int64(1)), 14286 NodeID: Ptr("nid"), 14287 AppID: Ptr(int64(1)), 14288 AppSlug: Ptr("as"), 14289 TargetID: Ptr(int64(1)), 14290 Account: &User{ 14291 Login: Ptr("l"), 14292 ID: Ptr(int64(1)), 14293 URL: Ptr("u"), 14294 AvatarURL: Ptr("a"), 14295 GravatarID: Ptr("g"), 14296 Name: Ptr("n"), 14297 Company: Ptr("c"), 14298 Blog: Ptr("b"), 14299 Location: Ptr("l"), 14300 Email: Ptr("e"), 14301 Hireable: Ptr(true), 14302 Bio: Ptr("b"), 14303 TwitterUsername: Ptr("t"), 14304 PublicRepos: Ptr(1), 14305 Followers: Ptr(1), 14306 Following: Ptr(1), 14307 CreatedAt: &Timestamp{referenceTime}, 14308 SuspendedAt: &Timestamp{referenceTime}, 14309 }, 14310 AccessTokensURL: Ptr("atu"), 14311 RepositoriesURL: Ptr("ru"), 14312 HTMLURL: Ptr("hu"), 14313 TargetType: Ptr("tt"), 14314 SingleFileName: Ptr("sfn"), 14315 RepositorySelection: Ptr("rs"), 14316 Events: []string{"e"}, 14317 SingleFilePaths: []string{"s"}, 14318 Permissions: &InstallationPermissions{ 14319 Actions: Ptr("a"), 14320 Administration: Ptr("ad"), 14321 Checks: Ptr("c"), 14322 Contents: Ptr("co"), 14323 ContentReferences: Ptr("cr"), 14324 Deployments: Ptr("d"), 14325 Environments: Ptr("e"), 14326 Issues: Ptr("i"), 14327 Metadata: Ptr("md"), 14328 Members: Ptr("m"), 14329 OrganizationAdministration: Ptr("oa"), 14330 OrganizationHooks: Ptr("oh"), 14331 OrganizationPlan: Ptr("op"), 14332 OrganizationPreReceiveHooks: Ptr("opr"), 14333 OrganizationProjects: Ptr("op"), 14334 OrganizationSecrets: Ptr("os"), 14335 OrganizationSelfHostedRunners: Ptr("osh"), 14336 OrganizationUserBlocking: Ptr("oub"), 14337 Packages: Ptr("pkg"), 14338 Pages: Ptr("pg"), 14339 PullRequests: Ptr("pr"), 14340 RepositoryHooks: Ptr("rh"), 14341 RepositoryProjects: Ptr("rp"), 14342 RepositoryPreReceiveHooks: Ptr("rprh"), 14343 Secrets: Ptr("s"), 14344 SecretScanningAlerts: Ptr("ssa"), 14345 SecurityEvents: Ptr("se"), 14346 SingleFile: Ptr("sf"), 14347 Statuses: Ptr("s"), 14348 TeamDiscussions: Ptr("td"), 14349 VulnerabilityAlerts: Ptr("va"), 14350 Workflows: Ptr("w"), 14351 }, 14352 CreatedAt: &Timestamp{referenceTime}, 14353 UpdatedAt: &Timestamp{referenceTime}, 14354 HasMultipleSingleFiles: Ptr(false), 14355 SuspendedBy: &User{ 14356 Login: Ptr("l"), 14357 ID: Ptr(int64(1)), 14358 URL: Ptr("u"), 14359 AvatarURL: Ptr("a"), 14360 GravatarID: Ptr("g"), 14361 Name: Ptr("n"), 14362 Company: Ptr("c"), 14363 Blog: Ptr("b"), 14364 Location: Ptr("l"), 14365 Email: Ptr("e"), 14366 Hireable: Ptr(true), 14367 Bio: Ptr("b"), 14368 TwitterUsername: Ptr("t"), 14369 PublicRepos: Ptr(1), 14370 Followers: Ptr(1), 14371 Following: Ptr(1), 14372 CreatedAt: &Timestamp{referenceTime}, 14373 SuspendedAt: &Timestamp{referenceTime}, 14374 }, 14375 SuspendedAt: &Timestamp{referenceTime}, 14376 }, 14377 } 14378 14379 want := `{ 14380 "check_suite": { 14381 "id": 1, 14382 "node_id": "n", 14383 "head_branch": "h", 14384 "head_sha": "h", 14385 "url": "u", 14386 "before": "b", 14387 "after": "a", 14388 "status": "s", 14389 "conclusion": "c", 14390 "app": { 14391 "id": 1, 14392 "node_id": "n", 14393 "owner": { 14394 "login": "l", 14395 "id": 1, 14396 "node_id": "n", 14397 "avatar_url": "a", 14398 "url": "u", 14399 "events_url": "e", 14400 "repos_url": "r" 14401 }, 14402 "name": "n", 14403 "description": "d", 14404 "external_url": "u", 14405 "html_url": "h", 14406 "created_at": ` + referenceTimeStr + `, 14407 "updated_at": ` + referenceTimeStr + ` 14408 }, 14409 "repository": { 14410 "id": 1 14411 }, 14412 "pull_requests": [ 14413 { 14414 "id": 1, 14415 "number": 1, 14416 "url": "u", 14417 "head": { 14418 "ref": "r", 14419 "sha": "s", 14420 "repo": { 14421 "id": 1, 14422 "name": "n", 14423 "url": "s" 14424 } 14425 }, 14426 "base": { 14427 "ref": "r", 14428 "sha": "s", 14429 "repo": { 14430 "id": 1, 14431 "name": "n", 14432 "url": "u" 14433 } 14434 } 14435 } 14436 ], 14437 "head_commit": { 14438 "sha": "s" 14439 } 14440 }, 14441 "action": "a", 14442 "repository": { 14443 "id": 1, 14444 "name": "n", 14445 "url": "s" 14446 }, 14447 "organization": { 14448 "name": "n", 14449 "company": "c", 14450 "blog": "b", 14451 "location": "loc", 14452 "email": "e", 14453 "twitter_username": "tu", 14454 "description": "d", 14455 "billing_email": "be", 14456 "is_verified": true, 14457 "has_organization_projects": true, 14458 "has_repository_projects": true, 14459 "default_repository_permission": "drp", 14460 "members_can_create_repositories": true, 14461 "members_can_create_public_repositories": false, 14462 "members_can_create_private_repositories": true, 14463 "members_can_create_internal_repositories": true, 14464 "members_allowed_repository_creation_type": "marct", 14465 "members_can_create_pages": true, 14466 "members_can_create_public_pages": false, 14467 "members_can_create_private_pages": true 14468 }, 14469 "sender": { 14470 "login": "l", 14471 "id": 1, 14472 "node_id": "n", 14473 "avatar_url": "a", 14474 "url": "u", 14475 "events_url": "e", 14476 "repos_url": "r" 14477 }, 14478 "installation": { 14479 "id": 1, 14480 "node_id": "nid", 14481 "app_id": 1, 14482 "app_slug": "as", 14483 "target_id": 1, 14484 "account": { 14485 "login": "l", 14486 "id": 1, 14487 "avatar_url": "a", 14488 "gravatar_id": "g", 14489 "name": "n", 14490 "company": "c", 14491 "blog": "b", 14492 "location": "l", 14493 "email": "e", 14494 "hireable": true, 14495 "bio": "b", 14496 "twitter_username": "t", 14497 "public_repos": 1, 14498 "followers": 1, 14499 "following": 1, 14500 "created_at": ` + referenceTimeStr + `, 14501 "suspended_at": ` + referenceTimeStr + `, 14502 "url": "u" 14503 }, 14504 "access_tokens_url": "atu", 14505 "repositories_url": "ru", 14506 "html_url": "hu", 14507 "target_type": "tt", 14508 "single_file_name": "sfn", 14509 "repository_selection": "rs", 14510 "events": [ 14511 "e" 14512 ], 14513 "single_file_paths": [ 14514 "s" 14515 ], 14516 "permissions": { 14517 "actions": "a", 14518 "administration": "ad", 14519 "checks": "c", 14520 "contents": "co", 14521 "content_references": "cr", 14522 "deployments": "d", 14523 "environments": "e", 14524 "issues": "i", 14525 "metadata": "md", 14526 "members": "m", 14527 "organization_administration": "oa", 14528 "organization_hooks": "oh", 14529 "organization_plan": "op", 14530 "organization_pre_receive_hooks": "opr", 14531 "organization_projects": "op", 14532 "organization_secrets": "os", 14533 "organization_self_hosted_runners": "osh", 14534 "organization_user_blocking": "oub", 14535 "packages": "pkg", 14536 "pages": "pg", 14537 "pull_requests": "pr", 14538 "repository_hooks": "rh", 14539 "repository_projects": "rp", 14540 "repository_pre_receive_hooks": "rprh", 14541 "secrets": "s", 14542 "secret_scanning_alerts": "ssa", 14543 "security_events": "se", 14544 "single_file": "sf", 14545 "statuses": "s", 14546 "team_discussions": "td", 14547 "vulnerability_alerts": "va", 14548 "workflows": "w" 14549 }, 14550 "created_at": ` + referenceTimeStr + `, 14551 "updated_at": ` + referenceTimeStr + `, 14552 "has_multiple_single_files": false, 14553 "suspended_by": { 14554 "login": "l", 14555 "id": 1, 14556 "avatar_url": "a", 14557 "gravatar_id": "g", 14558 "name": "n", 14559 "company": "c", 14560 "blog": "b", 14561 "location": "l", 14562 "email": "e", 14563 "hireable": true, 14564 "bio": "b", 14565 "twitter_username": "t", 14566 "public_repos": 1, 14567 "followers": 1, 14568 "following": 1, 14569 "created_at": ` + referenceTimeStr + `, 14570 "suspended_at": ` + referenceTimeStr + `, 14571 "url": "u" 14572 }, 14573 "suspended_at": ` + referenceTimeStr + ` 14574 } 14575 }` 14576 14577 testJSONMarshal(t, r, want) 14578 } 14579 14580 func TestDeployKeyEvent_Marshal(t *testing.T) { 14581 t.Parallel() 14582 testJSONMarshal(t, &DeployKeyEvent{}, "{}") 14583 14584 u := &DeployKeyEvent{ 14585 Action: Ptr("a"), 14586 Key: &Key{ 14587 ID: Ptr(int64(1)), 14588 Key: Ptr("k"), 14589 URL: Ptr("k"), 14590 Title: Ptr("k"), 14591 ReadOnly: Ptr(false), 14592 Verified: Ptr(false), 14593 CreatedAt: &Timestamp{referenceTime}, 14594 }, 14595 Repo: &Repository{ 14596 ID: Ptr(int64(1)), 14597 URL: Ptr("s"), 14598 Name: Ptr("n"), 14599 }, 14600 Organization: &Organization{ 14601 BillingEmail: Ptr("be"), 14602 Blog: Ptr("b"), 14603 Company: Ptr("c"), 14604 Email: Ptr("e"), 14605 TwitterUsername: Ptr("tu"), 14606 Location: Ptr("loc"), 14607 Name: Ptr("n"), 14608 Description: Ptr("d"), 14609 IsVerified: Ptr(true), 14610 HasOrganizationProjects: Ptr(true), 14611 HasRepositoryProjects: Ptr(true), 14612 DefaultRepoPermission: Ptr("drp"), 14613 MembersCanCreateRepos: Ptr(true), 14614 MembersCanCreateInternalRepos: Ptr(true), 14615 MembersCanCreatePrivateRepos: Ptr(true), 14616 MembersCanCreatePublicRepos: Ptr(false), 14617 MembersAllowedRepositoryCreationType: Ptr("marct"), 14618 MembersCanCreatePages: Ptr(true), 14619 MembersCanCreatePublicPages: Ptr(false), 14620 MembersCanCreatePrivatePages: Ptr(true), 14621 }, 14622 Sender: &User{ 14623 Login: Ptr("l"), 14624 ID: Ptr(int64(1)), 14625 NodeID: Ptr("n"), 14626 AvatarURL: Ptr("a"), 14627 URL: Ptr("u"), 14628 EventsURL: Ptr("e"), 14629 ReposURL: Ptr("r"), 14630 }, 14631 } 14632 14633 want := `{ 14634 "action": "a", 14635 "key": { 14636 "id": 1, 14637 "key": "k", 14638 "url": "k", 14639 "title": "k", 14640 "read_only": false, 14641 "verified": false, 14642 "created_at": ` + referenceTimeStr + ` 14643 }, 14644 "repository": { 14645 "id": 1, 14646 "name": "n", 14647 "url": "s" 14648 }, 14649 "organization": { 14650 "name": "n", 14651 "company": "c", 14652 "blog": "b", 14653 "location": "loc", 14654 "email": "e", 14655 "twitter_username": "tu", 14656 "description": "d", 14657 "billing_email": "be", 14658 "is_verified": true, 14659 "has_organization_projects": true, 14660 "has_repository_projects": true, 14661 "default_repository_permission": "drp", 14662 "members_can_create_repositories": true, 14663 "members_can_create_public_repositories": false, 14664 "members_can_create_private_repositories": true, 14665 "members_can_create_internal_repositories": true, 14666 "members_allowed_repository_creation_type": "marct", 14667 "members_can_create_pages": true, 14668 "members_can_create_public_pages": false, 14669 "members_can_create_private_pages": true 14670 }, 14671 "sender": { 14672 "login": "l", 14673 "id": 1, 14674 "node_id": "n", 14675 "avatar_url": "a", 14676 "url": "u", 14677 "events_url": "e", 14678 "repos_url": "r" 14679 } 14680 }` 14681 14682 testJSONMarshal(t, u, want) 14683 } 14684 14685 func TestMetaEvent_Marshal(t *testing.T) { 14686 t.Parallel() 14687 testJSONMarshal(t, &MetaEvent{}, "{}") 14688 14689 v := make(map[string]interface{}) 14690 v["a"] = "b" 14691 hookConfig := &HookConfig{ 14692 ContentType: Ptr("json"), 14693 } 14694 14695 u := &MetaEvent{ 14696 Action: Ptr("a"), 14697 HookID: Ptr(int64(1)), 14698 Hook: &Hook{ 14699 CreatedAt: &Timestamp{referenceTime}, 14700 UpdatedAt: &Timestamp{referenceTime}, 14701 URL: Ptr("u"), 14702 ID: Ptr(int64(1)), 14703 Type: Ptr("t"), 14704 Name: Ptr("n"), 14705 TestURL: Ptr("tu"), 14706 PingURL: Ptr("pu"), 14707 LastResponse: v, 14708 Config: hookConfig, 14709 Events: []string{"a"}, 14710 Active: Ptr(true), 14711 }, 14712 } 14713 14714 want := `{ 14715 "action": "a", 14716 "hook_id": 1, 14717 "hook": { 14718 "created_at": ` + referenceTimeStr + `, 14719 "updated_at": ` + referenceTimeStr + `, 14720 "url": "u", 14721 "id": 1, 14722 "type": "t", 14723 "name": "n", 14724 "test_url": "tu", 14725 "ping_url": "pu", 14726 "last_response": { 14727 "a": "b" 14728 }, 14729 "config": { 14730 "content_type": "json" 14731 }, 14732 "events": [ 14733 "a" 14734 ], 14735 "active": true 14736 } 14737 }` 14738 14739 testJSONMarshal(t, u, want) 14740 } 14741 14742 func TestRequestedAction_Marshal(t *testing.T) { 14743 t.Parallel() 14744 testJSONMarshal(t, &RequestedAction{}, "{}") 14745 14746 r := &RequestedAction{ 14747 Identifier: "i", 14748 } 14749 14750 want := `{ 14751 "identifier": "i" 14752 }` 14753 14754 testJSONMarshal(t, r, want) 14755 } 14756 14757 func TestCreateEvent_Marshal(t *testing.T) { 14758 t.Parallel() 14759 testJSONMarshal(t, &CreateEvent{}, "{}") 14760 14761 r := &CreateEvent{ 14762 Ref: Ptr("r"), 14763 RefType: Ptr("rt"), 14764 MasterBranch: Ptr("mb"), 14765 Description: Ptr("d"), 14766 PusherType: Ptr("pt"), 14767 Repo: &Repository{ 14768 ID: Ptr(int64(1)), 14769 URL: Ptr("s"), 14770 Name: Ptr("n"), 14771 }, 14772 Sender: &User{ 14773 Login: Ptr("l"), 14774 ID: Ptr(int64(1)), 14775 NodeID: Ptr("n"), 14776 URL: Ptr("u"), 14777 ReposURL: Ptr("r"), 14778 EventsURL: Ptr("e"), 14779 AvatarURL: Ptr("a"), 14780 }, 14781 Installation: &Installation{ 14782 ID: Ptr(int64(1)), 14783 NodeID: Ptr("nid"), 14784 AppID: Ptr(int64(1)), 14785 AppSlug: Ptr("as"), 14786 TargetID: Ptr(int64(1)), 14787 Account: &User{ 14788 Login: Ptr("l"), 14789 ID: Ptr(int64(1)), 14790 URL: Ptr("u"), 14791 AvatarURL: Ptr("a"), 14792 GravatarID: Ptr("g"), 14793 Name: Ptr("n"), 14794 Company: Ptr("c"), 14795 Blog: Ptr("b"), 14796 Location: Ptr("l"), 14797 Email: Ptr("e"), 14798 Hireable: Ptr(true), 14799 Bio: Ptr("b"), 14800 TwitterUsername: Ptr("t"), 14801 PublicRepos: Ptr(1), 14802 Followers: Ptr(1), 14803 Following: Ptr(1), 14804 CreatedAt: &Timestamp{referenceTime}, 14805 SuspendedAt: &Timestamp{referenceTime}, 14806 }, 14807 AccessTokensURL: Ptr("atu"), 14808 RepositoriesURL: Ptr("ru"), 14809 HTMLURL: Ptr("hu"), 14810 TargetType: Ptr("tt"), 14811 SingleFileName: Ptr("sfn"), 14812 RepositorySelection: Ptr("rs"), 14813 Events: []string{"e"}, 14814 SingleFilePaths: []string{"s"}, 14815 Permissions: &InstallationPermissions{ 14816 Actions: Ptr("a"), 14817 Administration: Ptr("ad"), 14818 Checks: Ptr("c"), 14819 Contents: Ptr("co"), 14820 ContentReferences: Ptr("cr"), 14821 Deployments: Ptr("d"), 14822 Environments: Ptr("e"), 14823 Issues: Ptr("i"), 14824 Metadata: Ptr("md"), 14825 Members: Ptr("m"), 14826 OrganizationAdministration: Ptr("oa"), 14827 OrganizationHooks: Ptr("oh"), 14828 OrganizationPlan: Ptr("op"), 14829 OrganizationPreReceiveHooks: Ptr("opr"), 14830 OrganizationProjects: Ptr("op"), 14831 OrganizationSecrets: Ptr("os"), 14832 OrganizationSelfHostedRunners: Ptr("osh"), 14833 OrganizationUserBlocking: Ptr("oub"), 14834 Packages: Ptr("pkg"), 14835 Pages: Ptr("pg"), 14836 PullRequests: Ptr("pr"), 14837 RepositoryHooks: Ptr("rh"), 14838 RepositoryProjects: Ptr("rp"), 14839 RepositoryPreReceiveHooks: Ptr("rprh"), 14840 Secrets: Ptr("s"), 14841 SecretScanningAlerts: Ptr("ssa"), 14842 SecurityEvents: Ptr("se"), 14843 SingleFile: Ptr("sf"), 14844 Statuses: Ptr("s"), 14845 TeamDiscussions: Ptr("td"), 14846 VulnerabilityAlerts: Ptr("va"), 14847 Workflows: Ptr("w"), 14848 }, 14849 CreatedAt: &Timestamp{referenceTime}, 14850 UpdatedAt: &Timestamp{referenceTime}, 14851 HasMultipleSingleFiles: Ptr(false), 14852 SuspendedBy: &User{ 14853 Login: Ptr("l"), 14854 ID: Ptr(int64(1)), 14855 URL: Ptr("u"), 14856 AvatarURL: Ptr("a"), 14857 GravatarID: Ptr("g"), 14858 Name: Ptr("n"), 14859 Company: Ptr("c"), 14860 Blog: Ptr("b"), 14861 Location: Ptr("l"), 14862 Email: Ptr("e"), 14863 Hireable: Ptr(true), 14864 Bio: Ptr("b"), 14865 TwitterUsername: Ptr("t"), 14866 PublicRepos: Ptr(1), 14867 Followers: Ptr(1), 14868 Following: Ptr(1), 14869 CreatedAt: &Timestamp{referenceTime}, 14870 SuspendedAt: &Timestamp{referenceTime}, 14871 }, 14872 SuspendedAt: &Timestamp{referenceTime}, 14873 }, 14874 } 14875 14876 want := `{ 14877 "ref": "r", 14878 "ref_type": "rt", 14879 "master_branch": "mb", 14880 "description": "d", 14881 "pusher_type": "pt", 14882 "repository": { 14883 "id": 1, 14884 "name": "n", 14885 "url": "s" 14886 }, 14887 "sender": { 14888 "login": "l", 14889 "id": 1, 14890 "node_id": "n", 14891 "avatar_url": "a", 14892 "url": "u", 14893 "events_url": "e", 14894 "repos_url": "r" 14895 }, 14896 "installation": { 14897 "id": 1, 14898 "node_id": "nid", 14899 "app_id": 1, 14900 "app_slug": "as", 14901 "target_id": 1, 14902 "account": { 14903 "login": "l", 14904 "id": 1, 14905 "avatar_url": "a", 14906 "gravatar_id": "g", 14907 "name": "n", 14908 "company": "c", 14909 "blog": "b", 14910 "location": "l", 14911 "email": "e", 14912 "hireable": true, 14913 "bio": "b", 14914 "twitter_username": "t", 14915 "public_repos": 1, 14916 "followers": 1, 14917 "following": 1, 14918 "created_at": ` + referenceTimeStr + `, 14919 "suspended_at": ` + referenceTimeStr + `, 14920 "url": "u" 14921 }, 14922 "access_tokens_url": "atu", 14923 "repositories_url": "ru", 14924 "html_url": "hu", 14925 "target_type": "tt", 14926 "single_file_name": "sfn", 14927 "repository_selection": "rs", 14928 "events": [ 14929 "e" 14930 ], 14931 "single_file_paths": [ 14932 "s" 14933 ], 14934 "permissions": { 14935 "actions": "a", 14936 "administration": "ad", 14937 "checks": "c", 14938 "contents": "co", 14939 "content_references": "cr", 14940 "deployments": "d", 14941 "environments": "e", 14942 "issues": "i", 14943 "metadata": "md", 14944 "members": "m", 14945 "organization_administration": "oa", 14946 "organization_hooks": "oh", 14947 "organization_plan": "op", 14948 "organization_pre_receive_hooks": "opr", 14949 "organization_projects": "op", 14950 "organization_secrets": "os", 14951 "organization_self_hosted_runners": "osh", 14952 "organization_user_blocking": "oub", 14953 "packages": "pkg", 14954 "pages": "pg", 14955 "pull_requests": "pr", 14956 "repository_hooks": "rh", 14957 "repository_projects": "rp", 14958 "repository_pre_receive_hooks": "rprh", 14959 "secrets": "s", 14960 "secret_scanning_alerts": "ssa", 14961 "security_events": "se", 14962 "single_file": "sf", 14963 "statuses": "s", 14964 "team_discussions": "td", 14965 "vulnerability_alerts": "va", 14966 "workflows": "w" 14967 }, 14968 "created_at": ` + referenceTimeStr + `, 14969 "updated_at": ` + referenceTimeStr + `, 14970 "has_multiple_single_files": false, 14971 "suspended_by": { 14972 "login": "l", 14973 "id": 1, 14974 "avatar_url": "a", 14975 "gravatar_id": "g", 14976 "name": "n", 14977 "company": "c", 14978 "blog": "b", 14979 "location": "l", 14980 "email": "e", 14981 "hireable": true, 14982 "bio": "b", 14983 "twitter_username": "t", 14984 "public_repos": 1, 14985 "followers": 1, 14986 "following": 1, 14987 "created_at": ` + referenceTimeStr + `, 14988 "suspended_at": ` + referenceTimeStr + `, 14989 "url": "u" 14990 }, 14991 "suspended_at": ` + referenceTimeStr + ` 14992 } 14993 }` 14994 14995 testJSONMarshal(t, r, want) 14996 } 14997 14998 func TestCustomPropertyEvent_Marshal(t *testing.T) { 14999 t.Parallel() 15000 testJSONMarshal(t, &CustomPropertyEvent{}, "{}") 15001 15002 r := &CustomPropertyEvent{ 15003 Action: Ptr("created"), 15004 Definition: &CustomProperty{ 15005 PropertyName: Ptr("name"), 15006 ValueType: "single_select", 15007 SourceType: Ptr("enterprise"), 15008 Required: Ptr(true), 15009 DefaultValue: Ptr("production"), 15010 Description: Ptr("Prod or dev environment"), 15011 AllowedValues: []string{"production", "development"}, 15012 ValuesEditableBy: Ptr("org_actors"), 15013 }, 15014 Sender: &User{ 15015 Login: Ptr("l"), 15016 ID: Ptr(int64(1)), 15017 NodeID: Ptr("n"), 15018 URL: Ptr("u"), 15019 ReposURL: Ptr("r"), 15020 EventsURL: Ptr("e"), 15021 AvatarURL: Ptr("a"), 15022 }, 15023 Installation: &Installation{ 15024 ID: Ptr(int64(1)), 15025 NodeID: Ptr("nid"), 15026 AppID: Ptr(int64(1)), 15027 AppSlug: Ptr("as"), 15028 TargetID: Ptr(int64(1)), 15029 Account: &User{ 15030 Login: Ptr("l"), 15031 ID: Ptr(int64(1)), 15032 URL: Ptr("u"), 15033 AvatarURL: Ptr("a"), 15034 GravatarID: Ptr("g"), 15035 Name: Ptr("n"), 15036 Company: Ptr("c"), 15037 Blog: Ptr("b"), 15038 Location: Ptr("l"), 15039 Email: Ptr("e"), 15040 Hireable: Ptr(true), 15041 Bio: Ptr("b"), 15042 TwitterUsername: Ptr("t"), 15043 PublicRepos: Ptr(1), 15044 Followers: Ptr(1), 15045 Following: Ptr(1), 15046 CreatedAt: &Timestamp{referenceTime}, 15047 SuspendedAt: &Timestamp{referenceTime}, 15048 }, 15049 AccessTokensURL: Ptr("atu"), 15050 RepositoriesURL: Ptr("ru"), 15051 HTMLURL: Ptr("hu"), 15052 TargetType: Ptr("tt"), 15053 SingleFileName: Ptr("sfn"), 15054 RepositorySelection: Ptr("rs"), 15055 Events: []string{"e"}, 15056 SingleFilePaths: []string{"s"}, 15057 Permissions: &InstallationPermissions{ 15058 Actions: Ptr("a"), 15059 Administration: Ptr("ad"), 15060 Checks: Ptr("c"), 15061 Contents: Ptr("co"), 15062 ContentReferences: Ptr("cr"), 15063 Deployments: Ptr("d"), 15064 Environments: Ptr("e"), 15065 Issues: Ptr("i"), 15066 Metadata: Ptr("md"), 15067 Members: Ptr("m"), 15068 OrganizationAdministration: Ptr("oa"), 15069 OrganizationHooks: Ptr("oh"), 15070 OrganizationPlan: Ptr("op"), 15071 OrganizationPreReceiveHooks: Ptr("opr"), 15072 OrganizationProjects: Ptr("op"), 15073 OrganizationSecrets: Ptr("os"), 15074 OrganizationSelfHostedRunners: Ptr("osh"), 15075 OrganizationUserBlocking: Ptr("oub"), 15076 Packages: Ptr("pkg"), 15077 Pages: Ptr("pg"), 15078 PullRequests: Ptr("pr"), 15079 RepositoryHooks: Ptr("rh"), 15080 RepositoryProjects: Ptr("rp"), 15081 RepositoryPreReceiveHooks: Ptr("rprh"), 15082 Secrets: Ptr("s"), 15083 SecretScanningAlerts: Ptr("ssa"), 15084 SecurityEvents: Ptr("se"), 15085 SingleFile: Ptr("sf"), 15086 Statuses: Ptr("s"), 15087 TeamDiscussions: Ptr("td"), 15088 VulnerabilityAlerts: Ptr("va"), 15089 Workflows: Ptr("w"), 15090 }, 15091 CreatedAt: &Timestamp{referenceTime}, 15092 UpdatedAt: &Timestamp{referenceTime}, 15093 HasMultipleSingleFiles: Ptr(false), 15094 SuspendedBy: &User{ 15095 Login: Ptr("l"), 15096 ID: Ptr(int64(1)), 15097 URL: Ptr("u"), 15098 AvatarURL: Ptr("a"), 15099 GravatarID: Ptr("g"), 15100 Name: Ptr("n"), 15101 Company: Ptr("c"), 15102 Blog: Ptr("b"), 15103 Location: Ptr("l"), 15104 Email: Ptr("e"), 15105 Hireable: Ptr(true), 15106 Bio: Ptr("b"), 15107 TwitterUsername: Ptr("t"), 15108 PublicRepos: Ptr(1), 15109 Followers: Ptr(1), 15110 Following: Ptr(1), 15111 CreatedAt: &Timestamp{referenceTime}, 15112 SuspendedAt: &Timestamp{referenceTime}, 15113 }, 15114 SuspendedAt: &Timestamp{referenceTime}, 15115 }, 15116 } 15117 15118 want := `{ 15119 "action": "created", 15120 "definition": { 15121 "property_name": "name", 15122 "source_type": "enterprise", 15123 "value_type": "single_select", 15124 "required": true, 15125 "default_value": "production", 15126 "description": "Prod or dev environment", 15127 "allowed_values": [ 15128 "production", 15129 "development" 15130 ], 15131 "values_editable_by": "org_actors" 15132 }, 15133 "repository": { 15134 "id": 1, 15135 "name": "n", 15136 "url": "s" 15137 }, 15138 "sender": { 15139 "login": "l", 15140 "id": 1, 15141 "node_id": "n", 15142 "avatar_url": "a", 15143 "url": "u", 15144 "events_url": "e", 15145 "repos_url": "r" 15146 }, 15147 "installation": { 15148 "id": 1, 15149 "node_id": "nid", 15150 "app_id": 1, 15151 "app_slug": "as", 15152 "target_id": 1, 15153 "account": { 15154 "login": "l", 15155 "id": 1, 15156 "avatar_url": "a", 15157 "gravatar_id": "g", 15158 "name": "n", 15159 "company": "c", 15160 "blog": "b", 15161 "location": "l", 15162 "email": "e", 15163 "hireable": true, 15164 "bio": "b", 15165 "twitter_username": "t", 15166 "public_repos": 1, 15167 "followers": 1, 15168 "following": 1, 15169 "created_at": ` + referenceTimeStr + `, 15170 "suspended_at": ` + referenceTimeStr + `, 15171 "url": "u" 15172 }, 15173 "access_tokens_url": "atu", 15174 "repositories_url": "ru", 15175 "html_url": "hu", 15176 "target_type": "tt", 15177 "single_file_name": "sfn", 15178 "repository_selection": "rs", 15179 "events": [ 15180 "e" 15181 ], 15182 "single_file_paths": [ 15183 "s" 15184 ], 15185 "permissions": { 15186 "actions": "a", 15187 "administration": "ad", 15188 "checks": "c", 15189 "contents": "co", 15190 "content_references": "cr", 15191 "deployments": "d", 15192 "environments": "e", 15193 "issues": "i", 15194 "metadata": "md", 15195 "members": "m", 15196 "organization_administration": "oa", 15197 "organization_hooks": "oh", 15198 "organization_plan": "op", 15199 "organization_pre_receive_hooks": "opr", 15200 "organization_projects": "op", 15201 "organization_secrets": "os", 15202 "organization_self_hosted_runners": "osh", 15203 "organization_user_blocking": "oub", 15204 "packages": "pkg", 15205 "pages": "pg", 15206 "pull_requests": "pr", 15207 "repository_hooks": "rh", 15208 "repository_projects": "rp", 15209 "repository_pre_receive_hooks": "rprh", 15210 "secrets": "s", 15211 "secret_scanning_alerts": "ssa", 15212 "security_events": "se", 15213 "single_file": "sf", 15214 "statuses": "s", 15215 "team_discussions": "td", 15216 "vulnerability_alerts": "va", 15217 "workflows": "w" 15218 }, 15219 "created_at": ` + referenceTimeStr + `, 15220 "updated_at": ` + referenceTimeStr + `, 15221 "has_multiple_single_files": false, 15222 "suspended_by": { 15223 "login": "l", 15224 "id": 1, 15225 "avatar_url": "a", 15226 "gravatar_id": "g", 15227 "name": "n", 15228 "company": "c", 15229 "blog": "b", 15230 "location": "l", 15231 "email": "e", 15232 "hireable": true, 15233 "bio": "b", 15234 "twitter_username": "t", 15235 "public_repos": 1, 15236 "followers": 1, 15237 "following": 1, 15238 "created_at": ` + referenceTimeStr + `, 15239 "suspended_at": ` + referenceTimeStr + `, 15240 "url": "u" 15241 }, 15242 "suspended_at": ` + referenceTimeStr + ` 15243 } 15244 }` 15245 15246 testJSONMarshal(t, r, want) 15247 } 15248 15249 func TestCustomPropertyValuesEvent_Marshal(t *testing.T) { 15250 t.Parallel() 15251 testJSONMarshal(t, &CustomPropertyValuesEvent{}, "{}") 15252 15253 r := &CustomPropertyValuesEvent{ 15254 Action: Ptr("updated"), 15255 NewPropertyValues: []*CustomPropertyValue{ 15256 { 15257 PropertyName: "environment", 15258 Value: "production", 15259 }, 15260 }, 15261 OldPropertyValues: []*CustomPropertyValue{ 15262 { 15263 PropertyName: "environment", 15264 Value: "staging", 15265 }, 15266 }, 15267 Sender: &User{ 15268 Login: Ptr("l"), 15269 ID: Ptr(int64(1)), 15270 NodeID: Ptr("n"), 15271 URL: Ptr("u"), 15272 ReposURL: Ptr("r"), 15273 EventsURL: Ptr("e"), 15274 AvatarURL: Ptr("a"), 15275 }, 15276 Installation: &Installation{ 15277 ID: Ptr(int64(1)), 15278 NodeID: Ptr("nid"), 15279 AppID: Ptr(int64(1)), 15280 AppSlug: Ptr("as"), 15281 TargetID: Ptr(int64(1)), 15282 Account: &User{ 15283 Login: Ptr("l"), 15284 ID: Ptr(int64(1)), 15285 URL: Ptr("u"), 15286 AvatarURL: Ptr("a"), 15287 GravatarID: Ptr("g"), 15288 Name: Ptr("n"), 15289 Company: Ptr("c"), 15290 Blog: Ptr("b"), 15291 Location: Ptr("l"), 15292 Email: Ptr("e"), 15293 Hireable: Ptr(true), 15294 Bio: Ptr("b"), 15295 TwitterUsername: Ptr("t"), 15296 PublicRepos: Ptr(1), 15297 Followers: Ptr(1), 15298 Following: Ptr(1), 15299 CreatedAt: &Timestamp{referenceTime}, 15300 SuspendedAt: &Timestamp{referenceTime}, 15301 }, 15302 AccessTokensURL: Ptr("atu"), 15303 RepositoriesURL: Ptr("ru"), 15304 HTMLURL: Ptr("hu"), 15305 TargetType: Ptr("tt"), 15306 SingleFileName: Ptr("sfn"), 15307 RepositorySelection: Ptr("rs"), 15308 Events: []string{"e"}, 15309 SingleFilePaths: []string{"s"}, 15310 Permissions: &InstallationPermissions{ 15311 Actions: Ptr("a"), 15312 Administration: Ptr("ad"), 15313 Checks: Ptr("c"), 15314 Contents: Ptr("co"), 15315 ContentReferences: Ptr("cr"), 15316 Deployments: Ptr("d"), 15317 Environments: Ptr("e"), 15318 Issues: Ptr("i"), 15319 Metadata: Ptr("md"), 15320 Members: Ptr("m"), 15321 OrganizationAdministration: Ptr("oa"), 15322 OrganizationHooks: Ptr("oh"), 15323 OrganizationPlan: Ptr("op"), 15324 OrganizationPreReceiveHooks: Ptr("opr"), 15325 OrganizationProjects: Ptr("op"), 15326 OrganizationSecrets: Ptr("os"), 15327 OrganizationSelfHostedRunners: Ptr("osh"), 15328 OrganizationUserBlocking: Ptr("oub"), 15329 Packages: Ptr("pkg"), 15330 Pages: Ptr("pg"), 15331 PullRequests: Ptr("pr"), 15332 RepositoryHooks: Ptr("rh"), 15333 RepositoryProjects: Ptr("rp"), 15334 RepositoryPreReceiveHooks: Ptr("rprh"), 15335 Secrets: Ptr("s"), 15336 SecretScanningAlerts: Ptr("ssa"), 15337 SecurityEvents: Ptr("se"), 15338 SingleFile: Ptr("sf"), 15339 Statuses: Ptr("s"), 15340 TeamDiscussions: Ptr("td"), 15341 VulnerabilityAlerts: Ptr("va"), 15342 Workflows: Ptr("w"), 15343 }, 15344 CreatedAt: &Timestamp{referenceTime}, 15345 UpdatedAt: &Timestamp{referenceTime}, 15346 HasMultipleSingleFiles: Ptr(false), 15347 SuspendedBy: &User{ 15348 Login: Ptr("l"), 15349 ID: Ptr(int64(1)), 15350 URL: Ptr("u"), 15351 AvatarURL: Ptr("a"), 15352 GravatarID: Ptr("g"), 15353 Name: Ptr("n"), 15354 Company: Ptr("c"), 15355 Blog: Ptr("b"), 15356 Location: Ptr("l"), 15357 Email: Ptr("e"), 15358 Hireable: Ptr(true), 15359 Bio: Ptr("b"), 15360 TwitterUsername: Ptr("t"), 15361 PublicRepos: Ptr(1), 15362 Followers: Ptr(1), 15363 Following: Ptr(1), 15364 CreatedAt: &Timestamp{referenceTime}, 15365 SuspendedAt: &Timestamp{referenceTime}, 15366 }, 15367 SuspendedAt: &Timestamp{referenceTime}, 15368 }, 15369 } 15370 15371 want := `{ 15372 "action": "updated", 15373 "new_property_values": [{ 15374 "property_name": "environment", 15375 "value": "production" 15376 }], 15377 "old_property_values": [{ 15378 "property_name": "environment", 15379 "value": "staging" 15380 }], 15381 "sender": { 15382 "login": "l", 15383 "id": 1, 15384 "node_id": "n", 15385 "avatar_url": "a", 15386 "url": "u", 15387 "events_url": "e", 15388 "repos_url": "r" 15389 }, 15390 "installation": { 15391 "id": 1, 15392 "node_id": "nid", 15393 "app_id": 1, 15394 "app_slug": "as", 15395 "target_id": 1, 15396 "account": { 15397 "login": "l", 15398 "id": 1, 15399 "avatar_url": "a", 15400 "gravatar_id": "g", 15401 "name": "n", 15402 "company": "c", 15403 "blog": "b", 15404 "location": "l", 15405 "email": "e", 15406 "hireable": true, 15407 "bio": "b", 15408 "twitter_username": "t", 15409 "public_repos": 1, 15410 "followers": 1, 15411 "following": 1, 15412 "created_at": ` + referenceTimeStr + `, 15413 "suspended_at": ` + referenceTimeStr + `, 15414 "url": "u" 15415 }, 15416 "access_tokens_url": "atu", 15417 "repositories_url": "ru", 15418 "html_url": "hu", 15419 "target_type": "tt", 15420 "single_file_name": "sfn", 15421 "repository_selection": "rs", 15422 "events": [ 15423 "e" 15424 ], 15425 "single_file_paths": [ 15426 "s" 15427 ], 15428 "permissions": { 15429 "actions": "a", 15430 "administration": "ad", 15431 "checks": "c", 15432 "contents": "co", 15433 "content_references": "cr", 15434 "deployments": "d", 15435 "environments": "e", 15436 "issues": "i", 15437 "metadata": "md", 15438 "members": "m", 15439 "organization_administration": "oa", 15440 "organization_hooks": "oh", 15441 "organization_plan": "op", 15442 "organization_pre_receive_hooks": "opr", 15443 "organization_projects": "op", 15444 "organization_secrets": "os", 15445 "organization_self_hosted_runners": "osh", 15446 "organization_user_blocking": "oub", 15447 "packages": "pkg", 15448 "pages": "pg", 15449 "pull_requests": "pr", 15450 "repository_hooks": "rh", 15451 "repository_projects": "rp", 15452 "repository_pre_receive_hooks": "rprh", 15453 "secrets": "s", 15454 "secret_scanning_alerts": "ssa", 15455 "security_events": "se", 15456 "single_file": "sf", 15457 "statuses": "s", 15458 "team_discussions": "td", 15459 "vulnerability_alerts": "va", 15460 "workflows": "w" 15461 }, 15462 "created_at": ` + referenceTimeStr + `, 15463 "updated_at": ` + referenceTimeStr + `, 15464 "has_multiple_single_files": false, 15465 "suspended_by": { 15466 "login": "l", 15467 "id": 1, 15468 "avatar_url": "a", 15469 "gravatar_id": "g", 15470 "name": "n", 15471 "company": "c", 15472 "blog": "b", 15473 "location": "l", 15474 "email": "e", 15475 "hireable": true, 15476 "bio": "b", 15477 "twitter_username": "t", 15478 "public_repos": 1, 15479 "followers": 1, 15480 "following": 1, 15481 "created_at": ` + referenceTimeStr + `, 15482 "suspended_at": ` + referenceTimeStr + `, 15483 "url": "u" 15484 }, 15485 "suspended_at": ` + referenceTimeStr + ` 15486 } 15487 }` 15488 15489 testJSONMarshal(t, r, want) 15490 } 15491 15492 func TestDeleteEvent_Marshal(t *testing.T) { 15493 t.Parallel() 15494 testJSONMarshal(t, &DeleteEvent{}, "{}") 15495 15496 r := &DeleteEvent{ 15497 Ref: Ptr("r"), 15498 RefType: Ptr("rt"), 15499 PusherType: Ptr("pt"), 15500 Repo: &Repository{ 15501 ID: Ptr(int64(1)), 15502 URL: Ptr("s"), 15503 Name: Ptr("n"), 15504 }, 15505 Sender: &User{ 15506 Login: Ptr("l"), 15507 ID: Ptr(int64(1)), 15508 NodeID: Ptr("n"), 15509 URL: Ptr("u"), 15510 ReposURL: Ptr("r"), 15511 EventsURL: Ptr("e"), 15512 AvatarURL: Ptr("a"), 15513 }, 15514 Installation: &Installation{ 15515 ID: Ptr(int64(1)), 15516 NodeID: Ptr("nid"), 15517 AppID: Ptr(int64(1)), 15518 AppSlug: Ptr("as"), 15519 TargetID: Ptr(int64(1)), 15520 Account: &User{ 15521 Login: Ptr("l"), 15522 ID: Ptr(int64(1)), 15523 URL: Ptr("u"), 15524 AvatarURL: Ptr("a"), 15525 GravatarID: Ptr("g"), 15526 Name: Ptr("n"), 15527 Company: Ptr("c"), 15528 Blog: Ptr("b"), 15529 Location: Ptr("l"), 15530 Email: Ptr("e"), 15531 Hireable: Ptr(true), 15532 Bio: Ptr("b"), 15533 TwitterUsername: Ptr("t"), 15534 PublicRepos: Ptr(1), 15535 Followers: Ptr(1), 15536 Following: Ptr(1), 15537 CreatedAt: &Timestamp{referenceTime}, 15538 SuspendedAt: &Timestamp{referenceTime}, 15539 }, 15540 AccessTokensURL: Ptr("atu"), 15541 RepositoriesURL: Ptr("ru"), 15542 HTMLURL: Ptr("hu"), 15543 TargetType: Ptr("tt"), 15544 SingleFileName: Ptr("sfn"), 15545 RepositorySelection: Ptr("rs"), 15546 Events: []string{"e"}, 15547 SingleFilePaths: []string{"s"}, 15548 Permissions: &InstallationPermissions{ 15549 Actions: Ptr("a"), 15550 Administration: Ptr("ad"), 15551 Checks: Ptr("c"), 15552 Contents: Ptr("co"), 15553 ContentReferences: Ptr("cr"), 15554 Deployments: Ptr("d"), 15555 Environments: Ptr("e"), 15556 Issues: Ptr("i"), 15557 Metadata: Ptr("md"), 15558 Members: Ptr("m"), 15559 OrganizationAdministration: Ptr("oa"), 15560 OrganizationHooks: Ptr("oh"), 15561 OrganizationPlan: Ptr("op"), 15562 OrganizationPreReceiveHooks: Ptr("opr"), 15563 OrganizationProjects: Ptr("op"), 15564 OrganizationSecrets: Ptr("os"), 15565 OrganizationSelfHostedRunners: Ptr("osh"), 15566 OrganizationUserBlocking: Ptr("oub"), 15567 Packages: Ptr("pkg"), 15568 Pages: Ptr("pg"), 15569 PullRequests: Ptr("pr"), 15570 RepositoryHooks: Ptr("rh"), 15571 RepositoryProjects: Ptr("rp"), 15572 RepositoryPreReceiveHooks: Ptr("rprh"), 15573 Secrets: Ptr("s"), 15574 SecretScanningAlerts: Ptr("ssa"), 15575 SecurityEvents: Ptr("se"), 15576 SingleFile: Ptr("sf"), 15577 Statuses: Ptr("s"), 15578 TeamDiscussions: Ptr("td"), 15579 VulnerabilityAlerts: Ptr("va"), 15580 Workflows: Ptr("w"), 15581 }, 15582 CreatedAt: &Timestamp{referenceTime}, 15583 UpdatedAt: &Timestamp{referenceTime}, 15584 HasMultipleSingleFiles: Ptr(false), 15585 SuspendedBy: &User{ 15586 Login: Ptr("l"), 15587 ID: Ptr(int64(1)), 15588 URL: Ptr("u"), 15589 AvatarURL: Ptr("a"), 15590 GravatarID: Ptr("g"), 15591 Name: Ptr("n"), 15592 Company: Ptr("c"), 15593 Blog: Ptr("b"), 15594 Location: Ptr("l"), 15595 Email: Ptr("e"), 15596 Hireable: Ptr(true), 15597 Bio: Ptr("b"), 15598 TwitterUsername: Ptr("t"), 15599 PublicRepos: Ptr(1), 15600 Followers: Ptr(1), 15601 Following: Ptr(1), 15602 CreatedAt: &Timestamp{referenceTime}, 15603 SuspendedAt: &Timestamp{referenceTime}, 15604 }, 15605 SuspendedAt: &Timestamp{referenceTime}, 15606 }, 15607 } 15608 15609 want := `{ 15610 "ref": "r", 15611 "ref_type": "rt", 15612 "pusher_type": "pt", 15613 "repository": { 15614 "id": 1, 15615 "name": "n", 15616 "url": "s" 15617 }, 15618 "sender": { 15619 "login": "l", 15620 "id": 1, 15621 "node_id": "n", 15622 "avatar_url": "a", 15623 "url": "u", 15624 "events_url": "e", 15625 "repos_url": "r" 15626 }, 15627 "installation": { 15628 "id": 1, 15629 "node_id": "nid", 15630 "app_id": 1, 15631 "app_slug": "as", 15632 "target_id": 1, 15633 "account": { 15634 "login": "l", 15635 "id": 1, 15636 "avatar_url": "a", 15637 "gravatar_id": "g", 15638 "name": "n", 15639 "company": "c", 15640 "blog": "b", 15641 "location": "l", 15642 "email": "e", 15643 "hireable": true, 15644 "bio": "b", 15645 "twitter_username": "t", 15646 "public_repos": 1, 15647 "followers": 1, 15648 "following": 1, 15649 "created_at": ` + referenceTimeStr + `, 15650 "suspended_at": ` + referenceTimeStr + `, 15651 "url": "u" 15652 }, 15653 "access_tokens_url": "atu", 15654 "repositories_url": "ru", 15655 "html_url": "hu", 15656 "target_type": "tt", 15657 "single_file_name": "sfn", 15658 "repository_selection": "rs", 15659 "events": [ 15660 "e" 15661 ], 15662 "single_file_paths": [ 15663 "s" 15664 ], 15665 "permissions": { 15666 "actions": "a", 15667 "administration": "ad", 15668 "checks": "c", 15669 "contents": "co", 15670 "content_references": "cr", 15671 "deployments": "d", 15672 "environments": "e", 15673 "issues": "i", 15674 "metadata": "md", 15675 "members": "m", 15676 "organization_administration": "oa", 15677 "organization_hooks": "oh", 15678 "organization_plan": "op", 15679 "organization_pre_receive_hooks": "opr", 15680 "organization_projects": "op", 15681 "organization_secrets": "os", 15682 "organization_self_hosted_runners": "osh", 15683 "organization_user_blocking": "oub", 15684 "packages": "pkg", 15685 "pages": "pg", 15686 "pull_requests": "pr", 15687 "repository_hooks": "rh", 15688 "repository_projects": "rp", 15689 "repository_pre_receive_hooks": "rprh", 15690 "secrets": "s", 15691 "secret_scanning_alerts": "ssa", 15692 "security_events": "se", 15693 "single_file": "sf", 15694 "statuses": "s", 15695 "team_discussions": "td", 15696 "vulnerability_alerts": "va", 15697 "workflows": "w" 15698 }, 15699 "created_at": ` + referenceTimeStr + `, 15700 "updated_at": ` + referenceTimeStr + `, 15701 "has_multiple_single_files": false, 15702 "suspended_by": { 15703 "login": "l", 15704 "id": 1, 15705 "avatar_url": "a", 15706 "gravatar_id": "g", 15707 "name": "n", 15708 "company": "c", 15709 "blog": "b", 15710 "location": "l", 15711 "email": "e", 15712 "hireable": true, 15713 "bio": "b", 15714 "twitter_username": "t", 15715 "public_repos": 1, 15716 "followers": 1, 15717 "following": 1, 15718 "created_at": ` + referenceTimeStr + `, 15719 "suspended_at": ` + referenceTimeStr + `, 15720 "url": "u" 15721 }, 15722 "suspended_at": ` + referenceTimeStr + ` 15723 } 15724 }` 15725 15726 testJSONMarshal(t, r, want) 15727 } 15728 15729 func TestDependabotAlertEvent_Marshal(t *testing.T) { 15730 t.Parallel() 15731 testJSONMarshal(t, &DependabotAlertEvent{}, "{}") 15732 15733 e := &DependabotAlertEvent{ 15734 Action: Ptr("a"), 15735 Alert: &DependabotAlert{ 15736 Number: Ptr(1), 15737 State: Ptr("s"), 15738 Dependency: &Dependency{ 15739 Package: &VulnerabilityPackage{ 15740 Ecosystem: Ptr("e"), 15741 Name: Ptr("n"), 15742 }, 15743 ManifestPath: Ptr("mp"), 15744 Scope: Ptr("s"), 15745 }, 15746 SecurityAdvisory: &DependabotSecurityAdvisory{ 15747 GHSAID: Ptr("ghsaid"), 15748 CVEID: Ptr("cveid"), 15749 Summary: Ptr("s"), 15750 Description: Ptr("d"), 15751 Vulnerabilities: []*AdvisoryVulnerability{ 15752 { 15753 Package: &VulnerabilityPackage{ 15754 Ecosystem: Ptr("e"), 15755 Name: Ptr("n"), 15756 }, 15757 Severity: Ptr("s"), 15758 }, 15759 }, 15760 Severity: Ptr("s"), 15761 CVSS: &AdvisoryCVSS{ 15762 Score: Ptr(1.0), 15763 VectorString: Ptr("vs"), 15764 }, 15765 CWEs: []*AdvisoryCWEs{ 15766 { 15767 CWEID: Ptr("cweid"), 15768 Name: Ptr("n"), 15769 }, 15770 }, 15771 Identifiers: []*AdvisoryIdentifier{ 15772 { 15773 Value: Ptr("v"), 15774 Type: Ptr("t"), 15775 }, 15776 }, 15777 References: []*AdvisoryReference{ 15778 { 15779 URL: Ptr("u"), 15780 }, 15781 }, 15782 PublishedAt: &Timestamp{referenceTime}, 15783 UpdatedAt: &Timestamp{referenceTime}, 15784 WithdrawnAt: &Timestamp{referenceTime}, 15785 }, 15786 SecurityVulnerability: &AdvisoryVulnerability{ 15787 Package: &VulnerabilityPackage{ 15788 Ecosystem: Ptr("e"), 15789 Name: Ptr("n"), 15790 }, 15791 Severity: Ptr("s"), 15792 VulnerableVersionRange: Ptr("vvr"), 15793 FirstPatchedVersion: &FirstPatchedVersion{ 15794 Identifier: Ptr("i"), 15795 }, 15796 }, 15797 URL: Ptr("u"), 15798 HTMLURL: Ptr("hu"), 15799 CreatedAt: &Timestamp{referenceTime}, 15800 UpdatedAt: &Timestamp{referenceTime}, 15801 DismissedAt: &Timestamp{referenceTime}, 15802 DismissedBy: &User{ 15803 Login: Ptr("l"), 15804 ID: Ptr(int64(1)), 15805 NodeID: Ptr("n"), 15806 URL: Ptr("u"), 15807 ReposURL: Ptr("r"), 15808 EventsURL: Ptr("e"), 15809 AvatarURL: Ptr("a"), 15810 }, 15811 DismissedReason: Ptr("dr"), 15812 DismissedComment: Ptr("dc"), 15813 FixedAt: &Timestamp{referenceTime}, 15814 AutoDismissedAt: &Timestamp{referenceTime}, 15815 }, 15816 Repo: &Repository{ 15817 ID: Ptr(int64(1)), 15818 URL: Ptr("s"), 15819 Name: Ptr("n"), 15820 }, 15821 Organization: &Organization{ 15822 BillingEmail: Ptr("be"), 15823 Blog: Ptr("b"), 15824 Company: Ptr("c"), 15825 Email: Ptr("e"), 15826 TwitterUsername: Ptr("tu"), 15827 Location: Ptr("loc"), 15828 Name: Ptr("n"), 15829 Description: Ptr("d"), 15830 IsVerified: Ptr(true), 15831 HasOrganizationProjects: Ptr(true), 15832 HasRepositoryProjects: Ptr(true), 15833 DefaultRepoPermission: Ptr("drp"), 15834 MembersCanCreateRepos: Ptr(true), 15835 MembersCanCreateInternalRepos: Ptr(true), 15836 MembersCanCreatePrivateRepos: Ptr(true), 15837 MembersCanCreatePublicRepos: Ptr(false), 15838 MembersAllowedRepositoryCreationType: Ptr("marct"), 15839 MembersCanCreatePages: Ptr(true), 15840 MembersCanCreatePublicPages: Ptr(false), 15841 MembersCanCreatePrivatePages: Ptr(true), 15842 }, 15843 Enterprise: &Enterprise{ 15844 ID: Ptr(1), 15845 Slug: Ptr("s"), 15846 Name: Ptr("n"), 15847 NodeID: Ptr("nid"), 15848 AvatarURL: Ptr("au"), 15849 Description: Ptr("d"), 15850 WebsiteURL: Ptr("wu"), 15851 HTMLURL: Ptr("hu"), 15852 CreatedAt: &Timestamp{referenceTime}, 15853 UpdatedAt: &Timestamp{referenceTime}, 15854 }, 15855 Sender: &User{ 15856 Login: Ptr("l"), 15857 ID: Ptr(int64(1)), 15858 NodeID: Ptr("n"), 15859 URL: Ptr("u"), 15860 ReposURL: Ptr("r"), 15861 EventsURL: Ptr("e"), 15862 AvatarURL: Ptr("a"), 15863 }, 15864 Installation: &Installation{ 15865 ID: Ptr(int64(1)), 15866 NodeID: Ptr("nid"), 15867 AppID: Ptr(int64(1)), 15868 AppSlug: Ptr("as"), 15869 TargetID: Ptr(int64(1)), 15870 Account: &User{ 15871 Login: Ptr("l"), 15872 ID: Ptr(int64(1)), 15873 URL: Ptr("u"), 15874 AvatarURL: Ptr("a"), 15875 GravatarID: Ptr("g"), 15876 Name: Ptr("n"), 15877 Company: Ptr("c"), 15878 Blog: Ptr("b"), 15879 Location: Ptr("l"), 15880 Email: Ptr("e"), 15881 Hireable: Ptr(true), 15882 Bio: Ptr("b"), 15883 TwitterUsername: Ptr("t"), 15884 PublicRepos: Ptr(1), 15885 Followers: Ptr(1), 15886 Following: Ptr(1), 15887 CreatedAt: &Timestamp{referenceTime}, 15888 SuspendedAt: &Timestamp{referenceTime}, 15889 }, 15890 AccessTokensURL: Ptr("atu"), 15891 RepositoriesURL: Ptr("ru"), 15892 HTMLURL: Ptr("hu"), 15893 TargetType: Ptr("tt"), 15894 SingleFileName: Ptr("sfn"), 15895 RepositorySelection: Ptr("rs"), 15896 Events: []string{"e"}, 15897 SingleFilePaths: []string{"s"}, 15898 Permissions: &InstallationPermissions{ 15899 Actions: Ptr("a"), 15900 Administration: Ptr("ad"), 15901 Checks: Ptr("c"), 15902 Contents: Ptr("co"), 15903 ContentReferences: Ptr("cr"), 15904 Deployments: Ptr("d"), 15905 Environments: Ptr("e"), 15906 Issues: Ptr("i"), 15907 Metadata: Ptr("md"), 15908 Members: Ptr("m"), 15909 OrganizationAdministration: Ptr("oa"), 15910 OrganizationHooks: Ptr("oh"), 15911 OrganizationPlan: Ptr("op"), 15912 OrganizationPreReceiveHooks: Ptr("opr"), 15913 OrganizationProjects: Ptr("op"), 15914 OrganizationSecrets: Ptr("os"), 15915 OrganizationSelfHostedRunners: Ptr("osh"), 15916 OrganizationUserBlocking: Ptr("oub"), 15917 Packages: Ptr("pkg"), 15918 Pages: Ptr("pg"), 15919 PullRequests: Ptr("pr"), 15920 RepositoryHooks: Ptr("rh"), 15921 RepositoryProjects: Ptr("rp"), 15922 RepositoryPreReceiveHooks: Ptr("rprh"), 15923 Secrets: Ptr("s"), 15924 SecretScanningAlerts: Ptr("ssa"), 15925 SecurityEvents: Ptr("se"), 15926 SingleFile: Ptr("sf"), 15927 Statuses: Ptr("s"), 15928 TeamDiscussions: Ptr("td"), 15929 VulnerabilityAlerts: Ptr("va"), 15930 Workflows: Ptr("w"), 15931 }, 15932 CreatedAt: &Timestamp{referenceTime}, 15933 UpdatedAt: &Timestamp{referenceTime}, 15934 HasMultipleSingleFiles: Ptr(false), 15935 SuspendedBy: &User{ 15936 Login: Ptr("l"), 15937 ID: Ptr(int64(1)), 15938 URL: Ptr("u"), 15939 AvatarURL: Ptr("a"), 15940 GravatarID: Ptr("g"), 15941 Name: Ptr("n"), 15942 Company: Ptr("c"), 15943 Blog: Ptr("b"), 15944 Location: Ptr("l"), 15945 Email: Ptr("e"), 15946 Hireable: Ptr(true), 15947 Bio: Ptr("b"), 15948 TwitterUsername: Ptr("t"), 15949 PublicRepos: Ptr(1), 15950 Followers: Ptr(1), 15951 Following: Ptr(1), 15952 CreatedAt: &Timestamp{referenceTime}, 15953 SuspendedAt: &Timestamp{referenceTime}, 15954 }, 15955 SuspendedAt: &Timestamp{referenceTime}, 15956 }, 15957 } 15958 want := `{ 15959 "action": "a", 15960 "alert": { 15961 "number": 1, 15962 "state": "s", 15963 "dependency": { 15964 "package": { 15965 "ecosystem": "e", 15966 "name": "n" 15967 }, 15968 "manifest_path": "mp", 15969 "scope": "s" 15970 }, 15971 "security_advisory": { 15972 "ghsa_id": "ghsaid", 15973 "cve_id": "cveid", 15974 "summary": "s", 15975 "description": "d", 15976 "vulnerabilities": [ 15977 { 15978 "package": { 15979 "ecosystem": "e", 15980 "name": "n" 15981 }, 15982 "severity": "s" 15983 } 15984 ], 15985 "severity": "s", 15986 "cvss": { 15987 "score": 1.0, 15988 "vector_string": "vs" 15989 }, 15990 "cwes": [ 15991 { 15992 "cwe_id": "cweid", 15993 "name": "n" 15994 } 15995 ], 15996 "identifiers": [ 15997 { 15998 "value": "v", 15999 "type": "t" 16000 } 16001 ], 16002 "references": [ 16003 { 16004 "url": "u" 16005 } 16006 ], 16007 "published_at": ` + referenceTimeStr + `, 16008 "updated_at": ` + referenceTimeStr + `, 16009 "withdrawn_at": ` + referenceTimeStr + ` 16010 }, 16011 "security_vulnerability": { 16012 "package": { 16013 "ecosystem": "e", 16014 "name": "n" 16015 }, 16016 "severity": "s", 16017 "vulnerable_version_range": "vvr", 16018 "first_patched_version": { 16019 "identifier": "i" 16020 } 16021 }, 16022 "url": "u", 16023 "html_url": "hu", 16024 "created_at": ` + referenceTimeStr + `, 16025 "updated_at": ` + referenceTimeStr + `, 16026 "dismissed_at": ` + referenceTimeStr + `, 16027 "dismissed_by": { 16028 "login": "l", 16029 "id": 1, 16030 "node_id": "n", 16031 "avatar_url": "a", 16032 "url": "u", 16033 "events_url": "e", 16034 "repos_url": "r" 16035 }, 16036 "dismissed_reason": "dr", 16037 "dismissed_comment": "dc", 16038 "fixed_at": ` + referenceTimeStr + `, 16039 "auto_dismissed_at": ` + referenceTimeStr + ` 16040 }, 16041 "repository": { 16042 "id": 1, 16043 "name": "n", 16044 "url": "s" 16045 }, 16046 "organization": { 16047 "name": "n", 16048 "company": "c", 16049 "blog": "b", 16050 "location": "loc", 16051 "email": "e", 16052 "twitter_username": "tu", 16053 "description": "d", 16054 "billing_email": "be", 16055 "is_verified": true, 16056 "has_organization_projects": true, 16057 "has_repository_projects": true, 16058 "default_repository_permission": "drp", 16059 "members_can_create_repositories": true, 16060 "members_can_create_public_repositories": false, 16061 "members_can_create_private_repositories": true, 16062 "members_can_create_internal_repositories": true, 16063 "members_allowed_repository_creation_type": "marct", 16064 "members_can_create_pages": true, 16065 "members_can_create_public_pages": false, 16066 "members_can_create_private_pages": true 16067 }, 16068 "enterprise": { 16069 "id": 1, 16070 "slug": "s", 16071 "name": "n", 16072 "node_id": "nid", 16073 "avatar_url": "au", 16074 "description": "d", 16075 "website_url": "wu", 16076 "html_url": "hu", 16077 "created_at": ` + referenceTimeStr + `, 16078 "updated_at": ` + referenceTimeStr + ` 16079 }, 16080 "sender": { 16081 "login": "l", 16082 "id": 1, 16083 "node_id": "n", 16084 "avatar_url": "a", 16085 "url": "u", 16086 "events_url": "e", 16087 "repos_url": "r" 16088 }, 16089 "installation": { 16090 "id": 1, 16091 "node_id": "nid", 16092 "app_id": 1, 16093 "app_slug": "as", 16094 "target_id": 1, 16095 "account": { 16096 "login": "l", 16097 "id": 1, 16098 "avatar_url": "a", 16099 "gravatar_id": "g", 16100 "name": "n", 16101 "company": "c", 16102 "blog": "b", 16103 "location": "l", 16104 "email": "e", 16105 "hireable": true, 16106 "bio": "b", 16107 "twitter_username": "t", 16108 "public_repos": 1, 16109 "followers": 1, 16110 "following": 1, 16111 "created_at": ` + referenceTimeStr + `, 16112 "suspended_at": ` + referenceTimeStr + `, 16113 "url": "u" 16114 }, 16115 "access_tokens_url": "atu", 16116 "repositories_url": "ru", 16117 "html_url": "hu", 16118 "target_type": "tt", 16119 "single_file_name": "sfn", 16120 "repository_selection": "rs", 16121 "events": [ 16122 "e" 16123 ], 16124 "single_file_paths": [ 16125 "s" 16126 ], 16127 "permissions": { 16128 "actions": "a", 16129 "administration": "ad", 16130 "checks": "c", 16131 "contents": "co", 16132 "content_references": "cr", 16133 "deployments": "d", 16134 "environments": "e", 16135 "issues": "i", 16136 "metadata": "md", 16137 "members": "m", 16138 "organization_administration": "oa", 16139 "organization_hooks": "oh", 16140 "organization_plan": "op", 16141 "organization_pre_receive_hooks": "opr", 16142 "organization_projects": "op", 16143 "organization_secrets": "os", 16144 "organization_self_hosted_runners": "osh", 16145 "organization_user_blocking": "oub", 16146 "packages": "pkg", 16147 "pages": "pg", 16148 "pull_requests": "pr", 16149 "repository_hooks": "rh", 16150 "repository_projects": "rp", 16151 "repository_pre_receive_hooks": "rprh", 16152 "secrets": "s", 16153 "secret_scanning_alerts": "ssa", 16154 "security_events": "se", 16155 "single_file": "sf", 16156 "statuses": "s", 16157 "team_discussions": "td", 16158 "vulnerability_alerts": "va", 16159 "workflows": "w" 16160 }, 16161 "created_at": ` + referenceTimeStr + `, 16162 "updated_at": ` + referenceTimeStr + `, 16163 "has_multiple_single_files": false, 16164 "suspended_by": { 16165 "login": "l", 16166 "id": 1, 16167 "avatar_url": "a", 16168 "gravatar_id": "g", 16169 "name": "n", 16170 "company": "c", 16171 "blog": "b", 16172 "location": "l", 16173 "email": "e", 16174 "hireable": true, 16175 "bio": "b", 16176 "twitter_username": "t", 16177 "public_repos": 1, 16178 "followers": 1, 16179 "following": 1, 16180 "created_at": ` + referenceTimeStr + `, 16181 "suspended_at": ` + referenceTimeStr + `, 16182 "url": "u" 16183 }, 16184 "suspended_at": ` + referenceTimeStr + ` 16185 } 16186 }` 16187 16188 testJSONMarshal(t, e, want) 16189 } 16190 16191 func TestForkEvent_Marshal(t *testing.T) { 16192 t.Parallel() 16193 testJSONMarshal(t, &ForkEvent{}, "{}") 16194 16195 u := &ForkEvent{ 16196 Forkee: &Repository{ 16197 ID: Ptr(int64(1)), 16198 URL: Ptr("s"), 16199 Name: Ptr("n"), 16200 }, 16201 Repo: &Repository{ 16202 ID: Ptr(int64(1)), 16203 URL: Ptr("s"), 16204 Name: Ptr("n"), 16205 }, 16206 Sender: &User{ 16207 Login: Ptr("l"), 16208 ID: Ptr(int64(1)), 16209 NodeID: Ptr("n"), 16210 URL: Ptr("u"), 16211 ReposURL: Ptr("r"), 16212 EventsURL: Ptr("e"), 16213 AvatarURL: Ptr("a"), 16214 }, 16215 Installation: &Installation{ 16216 ID: Ptr(int64(1)), 16217 NodeID: Ptr("nid"), 16218 AppID: Ptr(int64(1)), 16219 AppSlug: Ptr("as"), 16220 TargetID: Ptr(int64(1)), 16221 Account: &User{ 16222 Login: Ptr("l"), 16223 ID: Ptr(int64(1)), 16224 URL: Ptr("u"), 16225 AvatarURL: Ptr("a"), 16226 GravatarID: Ptr("g"), 16227 Name: Ptr("n"), 16228 Company: Ptr("c"), 16229 Blog: Ptr("b"), 16230 Location: Ptr("l"), 16231 Email: Ptr("e"), 16232 Hireable: Ptr(true), 16233 Bio: Ptr("b"), 16234 TwitterUsername: Ptr("t"), 16235 PublicRepos: Ptr(1), 16236 Followers: Ptr(1), 16237 Following: Ptr(1), 16238 CreatedAt: &Timestamp{referenceTime}, 16239 SuspendedAt: &Timestamp{referenceTime}, 16240 }, 16241 AccessTokensURL: Ptr("atu"), 16242 RepositoriesURL: Ptr("ru"), 16243 HTMLURL: Ptr("hu"), 16244 TargetType: Ptr("tt"), 16245 SingleFileName: Ptr("sfn"), 16246 RepositorySelection: Ptr("rs"), 16247 Events: []string{"e"}, 16248 SingleFilePaths: []string{"s"}, 16249 Permissions: &InstallationPermissions{ 16250 Actions: Ptr("a"), 16251 Administration: Ptr("ad"), 16252 Checks: Ptr("c"), 16253 Contents: Ptr("co"), 16254 ContentReferences: Ptr("cr"), 16255 Deployments: Ptr("d"), 16256 Environments: Ptr("e"), 16257 Issues: Ptr("i"), 16258 Metadata: Ptr("md"), 16259 Members: Ptr("m"), 16260 OrganizationAdministration: Ptr("oa"), 16261 OrganizationHooks: Ptr("oh"), 16262 OrganizationPlan: Ptr("op"), 16263 OrganizationPreReceiveHooks: Ptr("opr"), 16264 OrganizationProjects: Ptr("op"), 16265 OrganizationSecrets: Ptr("os"), 16266 OrganizationSelfHostedRunners: Ptr("osh"), 16267 OrganizationUserBlocking: Ptr("oub"), 16268 Packages: Ptr("pkg"), 16269 Pages: Ptr("pg"), 16270 PullRequests: Ptr("pr"), 16271 RepositoryHooks: Ptr("rh"), 16272 RepositoryProjects: Ptr("rp"), 16273 RepositoryPreReceiveHooks: Ptr("rprh"), 16274 Secrets: Ptr("s"), 16275 SecretScanningAlerts: Ptr("ssa"), 16276 SecurityEvents: Ptr("se"), 16277 SingleFile: Ptr("sf"), 16278 Statuses: Ptr("s"), 16279 TeamDiscussions: Ptr("td"), 16280 VulnerabilityAlerts: Ptr("va"), 16281 Workflows: Ptr("w"), 16282 }, 16283 CreatedAt: &Timestamp{referenceTime}, 16284 UpdatedAt: &Timestamp{referenceTime}, 16285 HasMultipleSingleFiles: Ptr(false), 16286 SuspendedBy: &User{ 16287 Login: Ptr("l"), 16288 ID: Ptr(int64(1)), 16289 URL: Ptr("u"), 16290 AvatarURL: Ptr("a"), 16291 GravatarID: Ptr("g"), 16292 Name: Ptr("n"), 16293 Company: Ptr("c"), 16294 Blog: Ptr("b"), 16295 Location: Ptr("l"), 16296 Email: Ptr("e"), 16297 Hireable: Ptr(true), 16298 Bio: Ptr("b"), 16299 TwitterUsername: Ptr("t"), 16300 PublicRepos: Ptr(1), 16301 Followers: Ptr(1), 16302 Following: Ptr(1), 16303 CreatedAt: &Timestamp{referenceTime}, 16304 SuspendedAt: &Timestamp{referenceTime}, 16305 }, 16306 SuspendedAt: &Timestamp{referenceTime}, 16307 }, 16308 } 16309 16310 want := `{ 16311 "forkee": { 16312 "id": 1, 16313 "name": "n", 16314 "url": "s" 16315 }, 16316 "repository": { 16317 "id": 1, 16318 "name": "n", 16319 "url": "s" 16320 }, 16321 "sender": { 16322 "login": "l", 16323 "id": 1, 16324 "node_id": "n", 16325 "avatar_url": "a", 16326 "url": "u", 16327 "events_url": "e", 16328 "repos_url": "r" 16329 }, 16330 "installation": { 16331 "id": 1, 16332 "node_id": "nid", 16333 "app_id": 1, 16334 "app_slug": "as", 16335 "target_id": 1, 16336 "account": { 16337 "login": "l", 16338 "id": 1, 16339 "avatar_url": "a", 16340 "gravatar_id": "g", 16341 "name": "n", 16342 "company": "c", 16343 "blog": "b", 16344 "location": "l", 16345 "email": "e", 16346 "hireable": true, 16347 "bio": "b", 16348 "twitter_username": "t", 16349 "public_repos": 1, 16350 "followers": 1, 16351 "following": 1, 16352 "created_at": ` + referenceTimeStr + `, 16353 "suspended_at": ` + referenceTimeStr + `, 16354 "url": "u" 16355 }, 16356 "access_tokens_url": "atu", 16357 "repositories_url": "ru", 16358 "html_url": "hu", 16359 "target_type": "tt", 16360 "single_file_name": "sfn", 16361 "repository_selection": "rs", 16362 "events": [ 16363 "e" 16364 ], 16365 "single_file_paths": [ 16366 "s" 16367 ], 16368 "permissions": { 16369 "actions": "a", 16370 "administration": "ad", 16371 "checks": "c", 16372 "contents": "co", 16373 "content_references": "cr", 16374 "deployments": "d", 16375 "environments": "e", 16376 "issues": "i", 16377 "metadata": "md", 16378 "members": "m", 16379 "organization_administration": "oa", 16380 "organization_hooks": "oh", 16381 "organization_plan": "op", 16382 "organization_pre_receive_hooks": "opr", 16383 "organization_projects": "op", 16384 "organization_secrets": "os", 16385 "organization_self_hosted_runners": "osh", 16386 "organization_user_blocking": "oub", 16387 "packages": "pkg", 16388 "pages": "pg", 16389 "pull_requests": "pr", 16390 "repository_hooks": "rh", 16391 "repository_projects": "rp", 16392 "repository_pre_receive_hooks": "rprh", 16393 "secrets": "s", 16394 "secret_scanning_alerts": "ssa", 16395 "security_events": "se", 16396 "single_file": "sf", 16397 "statuses": "s", 16398 "team_discussions": "td", 16399 "vulnerability_alerts": "va", 16400 "workflows": "w" 16401 }, 16402 "created_at": ` + referenceTimeStr + `, 16403 "updated_at": ` + referenceTimeStr + `, 16404 "has_multiple_single_files": false, 16405 "suspended_by": { 16406 "login": "l", 16407 "id": 1, 16408 "avatar_url": "a", 16409 "gravatar_id": "g", 16410 "name": "n", 16411 "company": "c", 16412 "blog": "b", 16413 "location": "l", 16414 "email": "e", 16415 "hireable": true, 16416 "bio": "b", 16417 "twitter_username": "t", 16418 "public_repos": 1, 16419 "followers": 1, 16420 "following": 1, 16421 "created_at": ` + referenceTimeStr + `, 16422 "suspended_at": ` + referenceTimeStr + `, 16423 "url": "u" 16424 }, 16425 "suspended_at": ` + referenceTimeStr + ` 16426 } 16427 }` 16428 16429 testJSONMarshal(t, u, want) 16430 } 16431 16432 func TestGitHubAppAuthorizationEvent_Marshal(t *testing.T) { 16433 t.Parallel() 16434 testJSONMarshal(t, &GitHubAppAuthorizationEvent{}, "{}") 16435 16436 u := &GitHubAppAuthorizationEvent{ 16437 Action: Ptr("a"), 16438 Sender: &User{ 16439 Login: Ptr("l"), 16440 ID: Ptr(int64(1)), 16441 NodeID: Ptr("n"), 16442 URL: Ptr("u"), 16443 ReposURL: Ptr("r"), 16444 EventsURL: Ptr("e"), 16445 AvatarURL: Ptr("a"), 16446 }, 16447 } 16448 16449 want := `{ 16450 "action": "a", 16451 "sender": { 16452 "login": "l", 16453 "id": 1, 16454 "node_id": "n", 16455 "avatar_url": "a", 16456 "url": "u", 16457 "events_url": "e", 16458 "repos_url": "r" 16459 } 16460 }` 16461 16462 testJSONMarshal(t, u, want) 16463 } 16464 16465 func TestInstallationEvent_Marshal(t *testing.T) { 16466 t.Parallel() 16467 testJSONMarshal(t, &InstallationEvent{}, "{}") 16468 16469 u := &InstallationEvent{ 16470 Action: Ptr("a"), 16471 Repositories: []*Repository{ 16472 { 16473 ID: Ptr(int64(1)), 16474 URL: Ptr("u"), 16475 Name: Ptr("n"), 16476 }, 16477 }, 16478 Sender: &User{ 16479 Login: Ptr("l"), 16480 ID: Ptr(int64(1)), 16481 NodeID: Ptr("n"), 16482 URL: Ptr("u"), 16483 ReposURL: Ptr("r"), 16484 EventsURL: Ptr("e"), 16485 AvatarURL: Ptr("a"), 16486 }, 16487 Installation: &Installation{ 16488 ID: Ptr(int64(1)), 16489 NodeID: Ptr("nid"), 16490 AppID: Ptr(int64(1)), 16491 AppSlug: Ptr("as"), 16492 TargetID: Ptr(int64(1)), 16493 Account: &User{ 16494 Login: Ptr("l"), 16495 ID: Ptr(int64(1)), 16496 URL: Ptr("u"), 16497 AvatarURL: Ptr("a"), 16498 GravatarID: Ptr("g"), 16499 Name: Ptr("n"), 16500 Company: Ptr("c"), 16501 Blog: Ptr("b"), 16502 Location: Ptr("l"), 16503 Email: Ptr("e"), 16504 Hireable: Ptr(true), 16505 Bio: Ptr("b"), 16506 TwitterUsername: Ptr("t"), 16507 PublicRepos: Ptr(1), 16508 Followers: Ptr(1), 16509 Following: Ptr(1), 16510 CreatedAt: &Timestamp{referenceTime}, 16511 SuspendedAt: &Timestamp{referenceTime}, 16512 }, 16513 AccessTokensURL: Ptr("atu"), 16514 RepositoriesURL: Ptr("ru"), 16515 HTMLURL: Ptr("hu"), 16516 TargetType: Ptr("tt"), 16517 SingleFileName: Ptr("sfn"), 16518 RepositorySelection: Ptr("rs"), 16519 Events: []string{"e"}, 16520 SingleFilePaths: []string{"s"}, 16521 Permissions: &InstallationPermissions{ 16522 Actions: Ptr("a"), 16523 Administration: Ptr("ad"), 16524 Checks: Ptr("c"), 16525 Contents: Ptr("co"), 16526 ContentReferences: Ptr("cr"), 16527 Deployments: Ptr("d"), 16528 Environments: Ptr("e"), 16529 Issues: Ptr("i"), 16530 Metadata: Ptr("md"), 16531 Members: Ptr("m"), 16532 OrganizationAdministration: Ptr("oa"), 16533 OrganizationHooks: Ptr("oh"), 16534 OrganizationPlan: Ptr("op"), 16535 OrganizationPreReceiveHooks: Ptr("opr"), 16536 OrganizationProjects: Ptr("op"), 16537 OrganizationSecrets: Ptr("os"), 16538 OrganizationSelfHostedRunners: Ptr("osh"), 16539 OrganizationUserBlocking: Ptr("oub"), 16540 Packages: Ptr("pkg"), 16541 Pages: Ptr("pg"), 16542 PullRequests: Ptr("pr"), 16543 RepositoryHooks: Ptr("rh"), 16544 RepositoryProjects: Ptr("rp"), 16545 RepositoryPreReceiveHooks: Ptr("rprh"), 16546 Secrets: Ptr("s"), 16547 SecretScanningAlerts: Ptr("ssa"), 16548 SecurityEvents: Ptr("se"), 16549 SingleFile: Ptr("sf"), 16550 Statuses: Ptr("s"), 16551 TeamDiscussions: Ptr("td"), 16552 VulnerabilityAlerts: Ptr("va"), 16553 Workflows: Ptr("w"), 16554 }, 16555 CreatedAt: &Timestamp{referenceTime}, 16556 UpdatedAt: &Timestamp{referenceTime}, 16557 HasMultipleSingleFiles: Ptr(false), 16558 SuspendedBy: &User{ 16559 Login: Ptr("l"), 16560 ID: Ptr(int64(1)), 16561 URL: Ptr("u"), 16562 AvatarURL: Ptr("a"), 16563 GravatarID: Ptr("g"), 16564 Name: Ptr("n"), 16565 Company: Ptr("c"), 16566 Blog: Ptr("b"), 16567 Location: Ptr("l"), 16568 Email: Ptr("e"), 16569 Hireable: Ptr(true), 16570 Bio: Ptr("b"), 16571 TwitterUsername: Ptr("t"), 16572 PublicRepos: Ptr(1), 16573 Followers: Ptr(1), 16574 Following: Ptr(1), 16575 CreatedAt: &Timestamp{referenceTime}, 16576 SuspendedAt: &Timestamp{referenceTime}, 16577 }, 16578 SuspendedAt: &Timestamp{referenceTime}, 16579 }, 16580 } 16581 16582 want := `{ 16583 "action": "a", 16584 "repositories": [ 16585 { 16586 "id":1, 16587 "name":"n", 16588 "url":"u" 16589 } 16590 ], 16591 "sender": { 16592 "login": "l", 16593 "id": 1, 16594 "node_id": "n", 16595 "avatar_url": "a", 16596 "url": "u", 16597 "events_url": "e", 16598 "repos_url": "r" 16599 }, 16600 "installation": { 16601 "id": 1, 16602 "node_id": "nid", 16603 "app_id": 1, 16604 "app_slug": "as", 16605 "target_id": 1, 16606 "account": { 16607 "login": "l", 16608 "id": 1, 16609 "avatar_url": "a", 16610 "gravatar_id": "g", 16611 "name": "n", 16612 "company": "c", 16613 "blog": "b", 16614 "location": "l", 16615 "email": "e", 16616 "hireable": true, 16617 "bio": "b", 16618 "twitter_username": "t", 16619 "public_repos": 1, 16620 "followers": 1, 16621 "following": 1, 16622 "created_at": ` + referenceTimeStr + `, 16623 "suspended_at": ` + referenceTimeStr + `, 16624 "url": "u" 16625 }, 16626 "access_tokens_url": "atu", 16627 "repositories_url": "ru", 16628 "html_url": "hu", 16629 "target_type": "tt", 16630 "single_file_name": "sfn", 16631 "repository_selection": "rs", 16632 "events": [ 16633 "e" 16634 ], 16635 "single_file_paths": [ 16636 "s" 16637 ], 16638 "permissions": { 16639 "actions": "a", 16640 "administration": "ad", 16641 "checks": "c", 16642 "contents": "co", 16643 "content_references": "cr", 16644 "deployments": "d", 16645 "environments": "e", 16646 "issues": "i", 16647 "metadata": "md", 16648 "members": "m", 16649 "organization_administration": "oa", 16650 "organization_hooks": "oh", 16651 "organization_plan": "op", 16652 "organization_pre_receive_hooks": "opr", 16653 "organization_projects": "op", 16654 "organization_secrets": "os", 16655 "organization_self_hosted_runners": "osh", 16656 "organization_user_blocking": "oub", 16657 "packages": "pkg", 16658 "pages": "pg", 16659 "pull_requests": "pr", 16660 "repository_hooks": "rh", 16661 "repository_projects": "rp", 16662 "repository_pre_receive_hooks": "rprh", 16663 "secrets": "s", 16664 "secret_scanning_alerts": "ssa", 16665 "security_events": "se", 16666 "single_file": "sf", 16667 "statuses": "s", 16668 "team_discussions": "td", 16669 "vulnerability_alerts": "va", 16670 "workflows": "w" 16671 }, 16672 "created_at": ` + referenceTimeStr + `, 16673 "updated_at": ` + referenceTimeStr + `, 16674 "has_multiple_single_files": false, 16675 "suspended_by": { 16676 "login": "l", 16677 "id": 1, 16678 "avatar_url": "a", 16679 "gravatar_id": "g", 16680 "name": "n", 16681 "company": "c", 16682 "blog": "b", 16683 "location": "l", 16684 "email": "e", 16685 "hireable": true, 16686 "bio": "b", 16687 "twitter_username": "t", 16688 "public_repos": 1, 16689 "followers": 1, 16690 "following": 1, 16691 "created_at": ` + referenceTimeStr + `, 16692 "suspended_at": ` + referenceTimeStr + `, 16693 "url": "u" 16694 }, 16695 "suspended_at": ` + referenceTimeStr + ` 16696 } 16697 }` 16698 16699 testJSONMarshal(t, u, want) 16700 } 16701 16702 func TestHeadCommit_Marshal(t *testing.T) { 16703 t.Parallel() 16704 testJSONMarshal(t, &HeadCommit{}, "{}") 16705 16706 u := &HeadCommit{ 16707 Message: Ptr("m"), 16708 Author: &CommitAuthor{ 16709 Date: &Timestamp{referenceTime}, 16710 Name: Ptr("n"), 16711 Email: Ptr("e"), 16712 Login: Ptr("u"), 16713 }, 16714 URL: Ptr("u"), 16715 Distinct: Ptr(true), 16716 SHA: Ptr("s"), 16717 ID: Ptr("id"), 16718 TreeID: Ptr("tid"), 16719 Timestamp: &Timestamp{referenceTime}, 16720 Committer: &CommitAuthor{ 16721 Date: &Timestamp{referenceTime}, 16722 Name: Ptr("n"), 16723 Email: Ptr("e"), 16724 Login: Ptr("u"), 16725 }, 16726 Added: []string{"a"}, 16727 Removed: []string{"r"}, 16728 Modified: []string{"m"}, 16729 } 16730 16731 want := `{ 16732 "message": "m", 16733 "author": { 16734 "date": ` + referenceTimeStr + `, 16735 "name": "n", 16736 "email": "e", 16737 "username": "u" 16738 }, 16739 "url": "u", 16740 "distinct": true, 16741 "sha": "s", 16742 "id": "id", 16743 "tree_id": "tid", 16744 "timestamp": ` + referenceTimeStr + `, 16745 "committer": { 16746 "date": ` + referenceTimeStr + `, 16747 "name": "n", 16748 "email": "e", 16749 "username": "u" 16750 }, 16751 "added": [ 16752 "a" 16753 ], 16754 "removed": [ 16755 "r" 16756 ], 16757 "modified": [ 16758 "m" 16759 ] 16760 }` 16761 16762 testJSONMarshal(t, u, want) 16763 } 16764 16765 func TestPushEventRepository_Marshal(t *testing.T) { 16766 t.Parallel() 16767 testJSONMarshal(t, &PushEventRepository{}, "{}") 16768 16769 u := &PushEventRepository{ 16770 ID: Ptr(int64(1)), 16771 NodeID: Ptr("nid"), 16772 Name: Ptr("n"), 16773 FullName: Ptr("fn"), 16774 Owner: &User{ 16775 Login: Ptr("l"), 16776 ID: Ptr(int64(1)), 16777 AvatarURL: Ptr("a"), 16778 GravatarID: Ptr("g"), 16779 Name: Ptr("n"), 16780 Company: Ptr("c"), 16781 Blog: Ptr("b"), 16782 Location: Ptr("l"), 16783 Email: Ptr("e"), 16784 Hireable: Ptr(true), 16785 PublicRepos: Ptr(1), 16786 Followers: Ptr(1), 16787 Following: Ptr(1), 16788 CreatedAt: &Timestamp{referenceTime}, 16789 URL: Ptr("u"), 16790 }, 16791 Private: Ptr(true), 16792 Description: Ptr("d"), 16793 Fork: Ptr(true), 16794 CreatedAt: &Timestamp{referenceTime}, 16795 PushedAt: &Timestamp{referenceTime}, 16796 UpdatedAt: &Timestamp{referenceTime}, 16797 Homepage: Ptr("h"), 16798 PullsURL: Ptr("p"), 16799 Size: Ptr(1), 16800 StargazersCount: Ptr(1), 16801 WatchersCount: Ptr(1), 16802 Language: Ptr("l"), 16803 HasIssues: Ptr(true), 16804 HasDownloads: Ptr(true), 16805 HasWiki: Ptr(true), 16806 HasPages: Ptr(true), 16807 ForksCount: Ptr(1), 16808 Archived: Ptr(true), 16809 Disabled: Ptr(true), 16810 OpenIssuesCount: Ptr(1), 16811 DefaultBranch: Ptr("d"), 16812 MasterBranch: Ptr("m"), 16813 Organization: Ptr("o"), 16814 URL: Ptr("u"), 16815 ArchiveURL: Ptr("a"), 16816 HTMLURL: Ptr("h"), 16817 StatusesURL: Ptr("s"), 16818 GitURL: Ptr("g"), 16819 SSHURL: Ptr("s"), 16820 CloneURL: Ptr("c"), 16821 SVNURL: Ptr("s"), 16822 Topics: []string{"octocat", "api"}, 16823 } 16824 16825 want := `{ 16826 "id": 1, 16827 "node_id": "nid", 16828 "name": "n", 16829 "full_name": "fn", 16830 "owner": { 16831 "login": "l", 16832 "id": 1, 16833 "avatar_url": "a", 16834 "gravatar_id": "g", 16835 "name": "n", 16836 "company": "c", 16837 "blog": "b", 16838 "location": "l", 16839 "email": "e", 16840 "hireable": true, 16841 "public_repos": 1, 16842 "followers": 1, 16843 "following": 1, 16844 "created_at": ` + referenceTimeStr + `, 16845 "url": "u" 16846 }, 16847 "private": true, 16848 "description": "d", 16849 "fork": true, 16850 "created_at": ` + referenceTimeStr + `, 16851 "pushed_at": ` + referenceTimeStr + `, 16852 "updated_at": ` + referenceTimeStr + `, 16853 "homepage": "h", 16854 "pulls_url": "p", 16855 "size": 1, 16856 "stargazers_count": 1, 16857 "watchers_count": 1, 16858 "language": "l", 16859 "has_issues": true, 16860 "has_downloads": true, 16861 "has_wiki": true, 16862 "has_pages": true, 16863 "forks_count": 1, 16864 "archived": true, 16865 "disabled": true, 16866 "open_issues_count": 1, 16867 "default_branch": "d", 16868 "master_branch": "m", 16869 "organization": "o", 16870 "url": "u", 16871 "archive_url": "a", 16872 "html_url": "h", 16873 "statuses_url": "s", 16874 "git_url": "g", 16875 "ssh_url": "s", 16876 "clone_url": "c", 16877 "svn_url": "s", 16878 "topics": ["octocat","api"] 16879 }` 16880 16881 testJSONMarshal(t, u, want) 16882 } 16883 16884 func TestPushEventRepoOwner_Marshal(t *testing.T) { 16885 t.Parallel() 16886 testJSONMarshal(t, &PushEventRepoOwner{}, "{}") 16887 16888 u := &PushEventRepoOwner{ 16889 Name: Ptr("n"), 16890 Email: Ptr("e"), 16891 } 16892 16893 want := `{ 16894 "name": "n", 16895 "email": "e" 16896 }` 16897 16898 testJSONMarshal(t, u, want) 16899 } 16900 16901 func TestProjectV2Event_Marshal(t *testing.T) { 16902 t.Parallel() 16903 testJSONMarshal(t, &ProjectV2Event{}, "{}") 16904 16905 u := &ProjectV2Event{ 16906 Action: Ptr("a"), 16907 ProjectsV2: &ProjectV2{ 16908 ID: Ptr(int64(1)), 16909 NodeID: Ptr("nid"), 16910 Owner: &User{ 16911 Login: Ptr("l"), 16912 ID: Ptr(int64(1)), 16913 NodeID: Ptr("n"), 16914 URL: Ptr("u"), 16915 ReposURL: Ptr("r"), 16916 EventsURL: Ptr("e"), 16917 AvatarURL: Ptr("a"), 16918 }, 16919 Creator: &User{ 16920 Login: Ptr("l"), 16921 ID: Ptr(int64(1)), 16922 NodeID: Ptr("n"), 16923 URL: Ptr("u"), 16924 ReposURL: Ptr("r"), 16925 EventsURL: Ptr("e"), 16926 AvatarURL: Ptr("a"), 16927 }, 16928 Title: Ptr("t"), 16929 Description: Ptr("d"), 16930 Public: Ptr(true), 16931 ClosedAt: &Timestamp{referenceTime}, 16932 CreatedAt: &Timestamp{referenceTime}, 16933 UpdatedAt: &Timestamp{referenceTime}, 16934 DeletedAt: &Timestamp{referenceTime}, 16935 Number: Ptr(1), 16936 ShortDescription: Ptr("sd"), 16937 DeletedBy: &User{ 16938 Login: Ptr("l"), 16939 ID: Ptr(int64(1)), 16940 NodeID: Ptr("n"), 16941 URL: Ptr("u"), 16942 ReposURL: Ptr("r"), 16943 EventsURL: Ptr("e"), 16944 AvatarURL: Ptr("a"), 16945 }, 16946 }, 16947 Org: &Organization{ 16948 BillingEmail: Ptr("be"), 16949 Blog: Ptr("b"), 16950 Company: Ptr("c"), 16951 Email: Ptr("e"), 16952 TwitterUsername: Ptr("tu"), 16953 Location: Ptr("loc"), 16954 Name: Ptr("n"), 16955 Description: Ptr("d"), 16956 IsVerified: Ptr(true), 16957 HasOrganizationProjects: Ptr(true), 16958 HasRepositoryProjects: Ptr(true), 16959 DefaultRepoPermission: Ptr("drp"), 16960 MembersCanCreateRepos: Ptr(true), 16961 MembersCanCreateInternalRepos: Ptr(true), 16962 MembersCanCreatePrivateRepos: Ptr(true), 16963 MembersCanCreatePublicRepos: Ptr(false), 16964 MembersAllowedRepositoryCreationType: Ptr("marct"), 16965 MembersCanCreatePages: Ptr(true), 16966 MembersCanCreatePublicPages: Ptr(false), 16967 MembersCanCreatePrivatePages: Ptr(true), 16968 }, 16969 Sender: &User{ 16970 Login: Ptr("l"), 16971 ID: Ptr(int64(1)), 16972 NodeID: Ptr("n"), 16973 URL: Ptr("u"), 16974 ReposURL: Ptr("r"), 16975 EventsURL: Ptr("e"), 16976 AvatarURL: Ptr("a"), 16977 }, 16978 Installation: &Installation{ 16979 ID: Ptr(int64(1)), 16980 NodeID: Ptr("nid"), 16981 AppID: Ptr(int64(1)), 16982 AppSlug: Ptr("as"), 16983 TargetID: Ptr(int64(1)), 16984 Account: &User{ 16985 Login: Ptr("l"), 16986 ID: Ptr(int64(1)), 16987 URL: Ptr("u"), 16988 AvatarURL: Ptr("a"), 16989 GravatarID: Ptr("g"), 16990 Name: Ptr("n"), 16991 Company: Ptr("c"), 16992 Blog: Ptr("b"), 16993 Location: Ptr("l"), 16994 Email: Ptr("e"), 16995 Hireable: Ptr(true), 16996 Bio: Ptr("b"), 16997 TwitterUsername: Ptr("t"), 16998 PublicRepos: Ptr(1), 16999 Followers: Ptr(1), 17000 Following: Ptr(1), 17001 CreatedAt: &Timestamp{referenceTime}, 17002 SuspendedAt: &Timestamp{referenceTime}, 17003 }, 17004 }, 17005 } 17006 17007 want := `{ 17008 "action": "a", 17009 "projects_v2": { 17010 "id": 1, 17011 "node_id": "nid", 17012 "owner": { 17013 "login": "l", 17014 "id": 1, 17015 "node_id": "n", 17016 "avatar_url": "a", 17017 "url": "u", 17018 "events_url": "e", 17019 "repos_url": "r" 17020 }, 17021 "creator": { 17022 "login": "l", 17023 "id": 1, 17024 "node_id": "n", 17025 "avatar_url": "a", 17026 "url": "u", 17027 "events_url": "e", 17028 "repos_url": "r" 17029 }, 17030 "title": "t", 17031 "description": "d", 17032 "public": true, 17033 "closed_at": ` + referenceTimeStr + `, 17034 "created_at": ` + referenceTimeStr + `, 17035 "updated_at": ` + referenceTimeStr + `, 17036 "deleted_at": ` + referenceTimeStr + `, 17037 "number": 1, 17038 "short_description": "sd", 17039 "deleted_by": { 17040 "login": "l", 17041 "id": 1, 17042 "node_id": "n", 17043 "avatar_url": "a", 17044 "url": "u", 17045 "events_url": "e", 17046 "repos_url": "r" 17047 } 17048 }, 17049 "organization": { 17050 "name": "n", 17051 "company": "c", 17052 "blog": "b", 17053 "location": "loc", 17054 "email": "e", 17055 "twitter_username": "tu", 17056 "description": "d", 17057 "billing_email": "be", 17058 "is_verified": true, 17059 "has_organization_projects": true, 17060 "has_repository_projects": true, 17061 "default_repository_permission": "drp", 17062 "members_can_create_repositories": true, 17063 "members_can_create_public_repositories": false, 17064 "members_can_create_private_repositories": true, 17065 "members_can_create_internal_repositories": true, 17066 "members_allowed_repository_creation_type": "marct", 17067 "members_can_create_pages": true, 17068 "members_can_create_public_pages": false, 17069 "members_can_create_private_pages": true 17070 }, 17071 "sender": { 17072 "login": "l", 17073 "id": 1, 17074 "node_id": "n", 17075 "avatar_url": "a", 17076 "url": "u", 17077 "events_url": "e", 17078 "repos_url": "r" 17079 }, 17080 "installation": { 17081 "id": 1, 17082 "node_id": "nid", 17083 "app_id": 1, 17084 "app_slug": "as", 17085 "target_id": 1, 17086 "account": { 17087 "login": "l", 17088 "id": 1, 17089 "avatar_url": "a", 17090 "gravatar_id": "g", 17091 "name": "n", 17092 "company": "c", 17093 "blog": "b", 17094 "location": "l", 17095 "email": "e", 17096 "hireable": true, 17097 "bio": "b", 17098 "twitter_username": "t", 17099 "public_repos": 1, 17100 "followers": 1, 17101 "following": 1, 17102 "created_at": ` + referenceTimeStr + `, 17103 "suspended_at": ` + referenceTimeStr + `, 17104 "url": "u" 17105 } 17106 } 17107 }` 17108 17109 testJSONMarshal(t, u, want) 17110 } 17111 17112 func TestProjectV2ItemEvent_Marshal(t *testing.T) { 17113 t.Parallel() 17114 testJSONMarshal(t, &ProjectV2ItemEvent{}, "{}") 17115 17116 u := &ProjectV2ItemEvent{ 17117 Action: Ptr("a"), 17118 Changes: &ProjectV2ItemChange{ 17119 ArchivedAt: &ArchivedAt{ 17120 From: &Timestamp{referenceTime}, 17121 To: &Timestamp{referenceTime}, 17122 }, 17123 }, 17124 ProjectV2Item: &ProjectV2Item{ 17125 ID: Ptr(int64(1)), 17126 NodeID: Ptr("nid"), 17127 ProjectNodeID: Ptr("pnid"), 17128 ContentNodeID: Ptr("cnid"), 17129 ContentType: Ptr("ct"), 17130 Creator: &User{ 17131 Login: Ptr("l"), 17132 ID: Ptr(int64(1)), 17133 NodeID: Ptr("n"), 17134 URL: Ptr("u"), 17135 ReposURL: Ptr("r"), 17136 EventsURL: Ptr("e"), 17137 AvatarURL: Ptr("a"), 17138 }, 17139 CreatedAt: &Timestamp{referenceTime}, 17140 UpdatedAt: &Timestamp{referenceTime}, 17141 ArchivedAt: &Timestamp{referenceTime}, 17142 }, 17143 Org: &Organization{ 17144 BillingEmail: Ptr("be"), 17145 Blog: Ptr("b"), 17146 Company: Ptr("c"), 17147 Email: Ptr("e"), 17148 TwitterUsername: Ptr("tu"), 17149 Location: Ptr("loc"), 17150 Name: Ptr("n"), 17151 Description: Ptr("d"), 17152 IsVerified: Ptr(true), 17153 HasOrganizationProjects: Ptr(true), 17154 HasRepositoryProjects: Ptr(true), 17155 DefaultRepoPermission: Ptr("drp"), 17156 MembersCanCreateRepos: Ptr(true), 17157 MembersCanCreateInternalRepos: Ptr(true), 17158 MembersCanCreatePrivateRepos: Ptr(true), 17159 MembersCanCreatePublicRepos: Ptr(false), 17160 MembersAllowedRepositoryCreationType: Ptr("marct"), 17161 MembersCanCreatePages: Ptr(true), 17162 MembersCanCreatePublicPages: Ptr(false), 17163 MembersCanCreatePrivatePages: Ptr(true), 17164 }, 17165 Sender: &User{ 17166 Login: Ptr("l"), 17167 ID: Ptr(int64(1)), 17168 NodeID: Ptr("n"), 17169 URL: Ptr("u"), 17170 ReposURL: Ptr("r"), 17171 EventsURL: Ptr("e"), 17172 AvatarURL: Ptr("a"), 17173 }, 17174 Installation: &Installation{ 17175 ID: Ptr(int64(1)), 17176 NodeID: Ptr("nid"), 17177 AppID: Ptr(int64(1)), 17178 AppSlug: Ptr("as"), 17179 TargetID: Ptr(int64(1)), 17180 Account: &User{ 17181 Login: Ptr("l"), 17182 ID: Ptr(int64(1)), 17183 URL: Ptr("u"), 17184 AvatarURL: Ptr("a"), 17185 GravatarID: Ptr("g"), 17186 Name: Ptr("n"), 17187 Company: Ptr("c"), 17188 Blog: Ptr("b"), 17189 Location: Ptr("l"), 17190 Email: Ptr("e"), 17191 Hireable: Ptr(true), 17192 Bio: Ptr("b"), 17193 TwitterUsername: Ptr("t"), 17194 PublicRepos: Ptr(1), 17195 Followers: Ptr(1), 17196 Following: Ptr(1), 17197 CreatedAt: &Timestamp{referenceTime}, 17198 SuspendedAt: &Timestamp{referenceTime}, 17199 }, 17200 }, 17201 } 17202 17203 want := `{ 17204 "action": "a", 17205 "changes": { 17206 "archived_at": { 17207 "from": ` + referenceTimeStr + `, 17208 "to": ` + referenceTimeStr + ` 17209 } 17210 }, 17211 "projects_v2_item": { 17212 "id": 1, 17213 "node_id": "nid", 17214 "project_node_id": "pnid", 17215 "content_node_id": "cnid", 17216 "content_type": "ct", 17217 "creator": { 17218 "login": "l", 17219 "id": 1, 17220 "node_id": "n", 17221 "avatar_url": "a", 17222 "url": "u", 17223 "events_url": "e", 17224 "repos_url": "r" 17225 }, 17226 "created_at": ` + referenceTimeStr + `, 17227 "updated_at": ` + referenceTimeStr + `, 17228 "archived_at": ` + referenceTimeStr + ` 17229 }, 17230 "organization": { 17231 "name": "n", 17232 "company": "c", 17233 "blog": "b", 17234 "location": "loc", 17235 "email": "e", 17236 "twitter_username": "tu", 17237 "description": "d", 17238 "billing_email": "be", 17239 "is_verified": true, 17240 "has_organization_projects": true, 17241 "has_repository_projects": true, 17242 "default_repository_permission": "drp", 17243 "members_can_create_repositories": true, 17244 "members_can_create_public_repositories": false, 17245 "members_can_create_private_repositories": true, 17246 "members_can_create_internal_repositories": true, 17247 "members_allowed_repository_creation_type": "marct", 17248 "members_can_create_pages": true, 17249 "members_can_create_public_pages": false, 17250 "members_can_create_private_pages": true 17251 }, 17252 "sender": { 17253 "login": "l", 17254 "id": 1, 17255 "node_id": "n", 17256 "avatar_url": "a", 17257 "url": "u", 17258 "events_url": "e", 17259 "repos_url": "r" 17260 }, 17261 "installation": { 17262 "id": 1, 17263 "node_id": "nid", 17264 "app_id": 1, 17265 "app_slug": "as", 17266 "target_id": 1, 17267 "account": { 17268 "login": "l", 17269 "id": 1, 17270 "avatar_url": "a", 17271 "gravatar_id": "g", 17272 "name": "n", 17273 "company": "c", 17274 "blog": "b", 17275 "location": "l", 17276 "email": "e", 17277 "hireable": true, 17278 "bio": "b", 17279 "twitter_username": "t", 17280 "public_repos": 1, 17281 "followers": 1, 17282 "following": 1, 17283 "created_at": ` + referenceTimeStr + `, 17284 "suspended_at": ` + referenceTimeStr + `, 17285 "url": "u" 17286 } 17287 } 17288 }` 17289 17290 testJSONMarshal(t, u, want) 17291 } 17292 17293 func TestPullRequestEvent_Marshal(t *testing.T) { 17294 t.Parallel() 17295 testJSONMarshal(t, &PullRequestEvent{}, "{}") 17296 17297 u := &PullRequestEvent{ 17298 Action: Ptr("a"), 17299 Assignee: &User{ 17300 Login: Ptr("l"), 17301 ID: Ptr(int64(1)), 17302 NodeID: Ptr("n"), 17303 URL: Ptr("u"), 17304 ReposURL: Ptr("r"), 17305 EventsURL: Ptr("e"), 17306 AvatarURL: Ptr("a"), 17307 }, 17308 Number: Ptr(1), 17309 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 17310 Changes: &EditChange{ 17311 Title: &EditTitle{ 17312 From: Ptr("TitleFrom"), 17313 }, 17314 Body: &EditBody{ 17315 From: Ptr("BodyFrom"), 17316 }, 17317 Base: &EditBase{ 17318 Ref: &EditRef{ 17319 From: Ptr("BaseRefFrom"), 17320 }, 17321 SHA: &EditSHA{ 17322 From: Ptr("BaseSHAFrom"), 17323 }, 17324 }, 17325 }, 17326 RequestedReviewer: &User{ 17327 Login: Ptr("l"), 17328 ID: Ptr(int64(1)), 17329 NodeID: Ptr("n"), 17330 URL: Ptr("u"), 17331 ReposURL: Ptr("r"), 17332 EventsURL: Ptr("e"), 17333 AvatarURL: Ptr("a"), 17334 }, 17335 RequestedTeam: &Team{ID: Ptr(int64(1))}, 17336 Label: &Label{ID: Ptr(int64(1))}, 17337 Before: Ptr("before"), 17338 After: Ptr("after"), 17339 Repo: &Repository{ 17340 ID: Ptr(int64(1)), 17341 URL: Ptr("s"), 17342 Name: Ptr("n"), 17343 }, 17344 PerformedViaGithubApp: &App{ 17345 ID: Ptr(int64(1)), 17346 NodeID: Ptr("n"), 17347 Slug: Ptr("s"), 17348 Name: Ptr("n"), 17349 Description: Ptr("d"), 17350 ExternalURL: Ptr("e"), 17351 HTMLURL: Ptr("h"), 17352 }, 17353 Organization: &Organization{ 17354 BillingEmail: Ptr("be"), 17355 Blog: Ptr("b"), 17356 Company: Ptr("c"), 17357 Email: Ptr("e"), 17358 TwitterUsername: Ptr("tu"), 17359 Location: Ptr("loc"), 17360 Name: Ptr("n"), 17361 Description: Ptr("d"), 17362 IsVerified: Ptr(true), 17363 HasOrganizationProjects: Ptr(true), 17364 HasRepositoryProjects: Ptr(true), 17365 DefaultRepoPermission: Ptr("drp"), 17366 MembersCanCreateRepos: Ptr(true), 17367 MembersCanCreateInternalRepos: Ptr(true), 17368 MembersCanCreatePrivateRepos: Ptr(true), 17369 MembersCanCreatePublicRepos: Ptr(false), 17370 MembersAllowedRepositoryCreationType: Ptr("marct"), 17371 MembersCanCreatePages: Ptr(true), 17372 MembersCanCreatePublicPages: Ptr(false), 17373 MembersCanCreatePrivatePages: Ptr(true), 17374 }, 17375 Sender: &User{ 17376 Login: Ptr("l"), 17377 ID: Ptr(int64(1)), 17378 NodeID: Ptr("n"), 17379 URL: Ptr("u"), 17380 ReposURL: Ptr("r"), 17381 EventsURL: Ptr("e"), 17382 AvatarURL: Ptr("a"), 17383 }, 17384 Installation: &Installation{ 17385 ID: Ptr(int64(1)), 17386 NodeID: Ptr("nid"), 17387 AppID: Ptr(int64(1)), 17388 AppSlug: Ptr("as"), 17389 TargetID: Ptr(int64(1)), 17390 Account: &User{ 17391 Login: Ptr("l"), 17392 ID: Ptr(int64(1)), 17393 URL: Ptr("u"), 17394 AvatarURL: Ptr("a"), 17395 GravatarID: Ptr("g"), 17396 Name: Ptr("n"), 17397 Company: Ptr("c"), 17398 Blog: Ptr("b"), 17399 Location: Ptr("l"), 17400 Email: Ptr("e"), 17401 Hireable: Ptr(true), 17402 Bio: Ptr("b"), 17403 TwitterUsername: Ptr("t"), 17404 PublicRepos: Ptr(1), 17405 Followers: Ptr(1), 17406 Following: Ptr(1), 17407 CreatedAt: &Timestamp{referenceTime}, 17408 SuspendedAt: &Timestamp{referenceTime}, 17409 }, 17410 AccessTokensURL: Ptr("atu"), 17411 RepositoriesURL: Ptr("ru"), 17412 HTMLURL: Ptr("hu"), 17413 TargetType: Ptr("tt"), 17414 SingleFileName: Ptr("sfn"), 17415 RepositorySelection: Ptr("rs"), 17416 Events: []string{"e"}, 17417 SingleFilePaths: []string{"s"}, 17418 Permissions: &InstallationPermissions{ 17419 Actions: Ptr("a"), 17420 Administration: Ptr("ad"), 17421 Checks: Ptr("c"), 17422 Contents: Ptr("co"), 17423 ContentReferences: Ptr("cr"), 17424 Deployments: Ptr("d"), 17425 Environments: Ptr("e"), 17426 Issues: Ptr("i"), 17427 Metadata: Ptr("md"), 17428 Members: Ptr("m"), 17429 OrganizationAdministration: Ptr("oa"), 17430 OrganizationHooks: Ptr("oh"), 17431 OrganizationPlan: Ptr("op"), 17432 OrganizationPreReceiveHooks: Ptr("opr"), 17433 OrganizationProjects: Ptr("op"), 17434 OrganizationSecrets: Ptr("os"), 17435 OrganizationSelfHostedRunners: Ptr("osh"), 17436 OrganizationUserBlocking: Ptr("oub"), 17437 Packages: Ptr("pkg"), 17438 Pages: Ptr("pg"), 17439 PullRequests: Ptr("pr"), 17440 RepositoryHooks: Ptr("rh"), 17441 RepositoryProjects: Ptr("rp"), 17442 RepositoryPreReceiveHooks: Ptr("rprh"), 17443 Secrets: Ptr("s"), 17444 SecretScanningAlerts: Ptr("ssa"), 17445 SecurityEvents: Ptr("se"), 17446 SingleFile: Ptr("sf"), 17447 Statuses: Ptr("s"), 17448 TeamDiscussions: Ptr("td"), 17449 VulnerabilityAlerts: Ptr("va"), 17450 Workflows: Ptr("w"), 17451 }, 17452 CreatedAt: &Timestamp{referenceTime}, 17453 UpdatedAt: &Timestamp{referenceTime}, 17454 HasMultipleSingleFiles: Ptr(false), 17455 SuspendedBy: &User{ 17456 Login: Ptr("l"), 17457 ID: Ptr(int64(1)), 17458 URL: Ptr("u"), 17459 AvatarURL: Ptr("a"), 17460 GravatarID: Ptr("g"), 17461 Name: Ptr("n"), 17462 Company: Ptr("c"), 17463 Blog: Ptr("b"), 17464 Location: Ptr("l"), 17465 Email: Ptr("e"), 17466 Hireable: Ptr(true), 17467 Bio: Ptr("b"), 17468 TwitterUsername: Ptr("t"), 17469 PublicRepos: Ptr(1), 17470 Followers: Ptr(1), 17471 Following: Ptr(1), 17472 CreatedAt: &Timestamp{referenceTime}, 17473 SuspendedAt: &Timestamp{referenceTime}, 17474 }, 17475 SuspendedAt: &Timestamp{referenceTime}, 17476 }, 17477 } 17478 17479 want := `{ 17480 "action": "a", 17481 "assignee": { 17482 "login": "l", 17483 "id": 1, 17484 "node_id": "n", 17485 "avatar_url": "a", 17486 "url": "u", 17487 "events_url": "e", 17488 "repos_url": "r" 17489 }, 17490 "number": 1, 17491 "pull_request": { 17492 "id": 1 17493 }, 17494 "changes": { 17495 "title": { 17496 "from": "TitleFrom" 17497 }, 17498 "body": { 17499 "from": "BodyFrom" 17500 }, 17501 "base": { 17502 "ref": { 17503 "from": "BaseRefFrom" 17504 }, 17505 "sha": { 17506 "from": "BaseSHAFrom" 17507 } 17508 } 17509 }, 17510 "requested_reviewer": { 17511 "login": "l", 17512 "id": 1, 17513 "node_id": "n", 17514 "avatar_url": "a", 17515 "url": "u", 17516 "events_url": "e", 17517 "repos_url": "r" 17518 }, 17519 "requested_team": { 17520 "id": 1 17521 }, 17522 "label": { 17523 "id": 1 17524 }, 17525 "before": "before", 17526 "after": "after", 17527 "repository": { 17528 "id": 1, 17529 "name": "n", 17530 "url": "s" 17531 }, 17532 "performed_via_github_app": { 17533 "id": 1, 17534 "node_id": "n", 17535 "slug": "s", 17536 "name": "n", 17537 "description": "d", 17538 "external_url": "e", 17539 "html_url": "h" 17540 }, 17541 "organization": { 17542 "name": "n", 17543 "company": "c", 17544 "blog": "b", 17545 "location": "loc", 17546 "email": "e", 17547 "twitter_username": "tu", 17548 "description": "d", 17549 "billing_email": "be", 17550 "is_verified": true, 17551 "has_organization_projects": true, 17552 "has_repository_projects": true, 17553 "default_repository_permission": "drp", 17554 "members_can_create_repositories": true, 17555 "members_can_create_public_repositories": false, 17556 "members_can_create_private_repositories": true, 17557 "members_can_create_internal_repositories": true, 17558 "members_allowed_repository_creation_type": "marct", 17559 "members_can_create_pages": true, 17560 "members_can_create_public_pages": false, 17561 "members_can_create_private_pages": true 17562 }, 17563 "sender": { 17564 "login": "l", 17565 "id": 1, 17566 "node_id": "n", 17567 "avatar_url": "a", 17568 "url": "u", 17569 "events_url": "e", 17570 "repos_url": "r" 17571 }, 17572 "installation": { 17573 "id": 1, 17574 "node_id": "nid", 17575 "app_id": 1, 17576 "app_slug": "as", 17577 "target_id": 1, 17578 "account": { 17579 "login": "l", 17580 "id": 1, 17581 "avatar_url": "a", 17582 "gravatar_id": "g", 17583 "name": "n", 17584 "company": "c", 17585 "blog": "b", 17586 "location": "l", 17587 "email": "e", 17588 "hireable": true, 17589 "bio": "b", 17590 "twitter_username": "t", 17591 "public_repos": 1, 17592 "followers": 1, 17593 "following": 1, 17594 "created_at": ` + referenceTimeStr + `, 17595 "suspended_at": ` + referenceTimeStr + `, 17596 "url": "u" 17597 }, 17598 "access_tokens_url": "atu", 17599 "repositories_url": "ru", 17600 "html_url": "hu", 17601 "target_type": "tt", 17602 "single_file_name": "sfn", 17603 "repository_selection": "rs", 17604 "events": [ 17605 "e" 17606 ], 17607 "single_file_paths": [ 17608 "s" 17609 ], 17610 "permissions": { 17611 "actions": "a", 17612 "administration": "ad", 17613 "checks": "c", 17614 "contents": "co", 17615 "content_references": "cr", 17616 "deployments": "d", 17617 "environments": "e", 17618 "issues": "i", 17619 "metadata": "md", 17620 "members": "m", 17621 "organization_administration": "oa", 17622 "organization_hooks": "oh", 17623 "organization_plan": "op", 17624 "organization_pre_receive_hooks": "opr", 17625 "organization_projects": "op", 17626 "organization_secrets": "os", 17627 "organization_self_hosted_runners": "osh", 17628 "organization_user_blocking": "oub", 17629 "packages": "pkg", 17630 "pages": "pg", 17631 "pull_requests": "pr", 17632 "repository_hooks": "rh", 17633 "repository_projects": "rp", 17634 "repository_pre_receive_hooks": "rprh", 17635 "secrets": "s", 17636 "secret_scanning_alerts": "ssa", 17637 "security_events": "se", 17638 "single_file": "sf", 17639 "statuses": "s", 17640 "team_discussions": "td", 17641 "vulnerability_alerts": "va", 17642 "workflows": "w" 17643 }, 17644 "created_at": ` + referenceTimeStr + `, 17645 "updated_at": ` + referenceTimeStr + `, 17646 "has_multiple_single_files": false, 17647 "suspended_by": { 17648 "login": "l", 17649 "id": 1, 17650 "avatar_url": "a", 17651 "gravatar_id": "g", 17652 "name": "n", 17653 "company": "c", 17654 "blog": "b", 17655 "location": "l", 17656 "email": "e", 17657 "hireable": true, 17658 "bio": "b", 17659 "twitter_username": "t", 17660 "public_repos": 1, 17661 "followers": 1, 17662 "following": 1, 17663 "created_at": ` + referenceTimeStr + `, 17664 "suspended_at": ` + referenceTimeStr + `, 17665 "url": "u" 17666 }, 17667 "suspended_at": ` + referenceTimeStr + ` 17668 } 17669 }` 17670 17671 testJSONMarshal(t, u, want) 17672 } 17673 17674 func TestPullRequestReviewCommentEvent_Marshal(t *testing.T) { 17675 t.Parallel() 17676 testJSONMarshal(t, &PullRequestReviewCommentEvent{}, "{}") 17677 17678 u := &PullRequestReviewCommentEvent{ 17679 Action: Ptr("a"), 17680 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 17681 Comment: &PullRequestComment{ID: Ptr(int64(1))}, 17682 Changes: &EditChange{ 17683 Title: &EditTitle{ 17684 From: Ptr("TitleFrom"), 17685 }, 17686 Body: &EditBody{ 17687 From: Ptr("BodyFrom"), 17688 }, 17689 Base: &EditBase{ 17690 Ref: &EditRef{ 17691 From: Ptr("BaseRefFrom"), 17692 }, 17693 SHA: &EditSHA{ 17694 From: Ptr("BaseSHAFrom"), 17695 }, 17696 }, 17697 }, 17698 Repo: &Repository{ 17699 ID: Ptr(int64(1)), 17700 URL: Ptr("s"), 17701 Name: Ptr("n"), 17702 }, 17703 Sender: &User{ 17704 Login: Ptr("l"), 17705 ID: Ptr(int64(1)), 17706 NodeID: Ptr("n"), 17707 URL: Ptr("u"), 17708 ReposURL: Ptr("r"), 17709 EventsURL: Ptr("e"), 17710 AvatarURL: Ptr("a"), 17711 }, 17712 Installation: &Installation{ 17713 ID: Ptr(int64(1)), 17714 NodeID: Ptr("nid"), 17715 AppID: Ptr(int64(1)), 17716 AppSlug: Ptr("as"), 17717 TargetID: Ptr(int64(1)), 17718 Account: &User{ 17719 Login: Ptr("l"), 17720 ID: Ptr(int64(1)), 17721 URL: Ptr("u"), 17722 AvatarURL: Ptr("a"), 17723 GravatarID: Ptr("g"), 17724 Name: Ptr("n"), 17725 Company: Ptr("c"), 17726 Blog: Ptr("b"), 17727 Location: Ptr("l"), 17728 Email: Ptr("e"), 17729 Hireable: Ptr(true), 17730 Bio: Ptr("b"), 17731 TwitterUsername: Ptr("t"), 17732 PublicRepos: Ptr(1), 17733 Followers: Ptr(1), 17734 Following: Ptr(1), 17735 CreatedAt: &Timestamp{referenceTime}, 17736 SuspendedAt: &Timestamp{referenceTime}, 17737 }, 17738 AccessTokensURL: Ptr("atu"), 17739 RepositoriesURL: Ptr("ru"), 17740 HTMLURL: Ptr("hu"), 17741 TargetType: Ptr("tt"), 17742 SingleFileName: Ptr("sfn"), 17743 RepositorySelection: Ptr("rs"), 17744 Events: []string{"e"}, 17745 SingleFilePaths: []string{"s"}, 17746 Permissions: &InstallationPermissions{ 17747 Actions: Ptr("a"), 17748 Administration: Ptr("ad"), 17749 Checks: Ptr("c"), 17750 Contents: Ptr("co"), 17751 ContentReferences: Ptr("cr"), 17752 Deployments: Ptr("d"), 17753 Environments: Ptr("e"), 17754 Issues: Ptr("i"), 17755 Metadata: Ptr("md"), 17756 Members: Ptr("m"), 17757 OrganizationAdministration: Ptr("oa"), 17758 OrganizationHooks: Ptr("oh"), 17759 OrganizationPlan: Ptr("op"), 17760 OrganizationPreReceiveHooks: Ptr("opr"), 17761 OrganizationProjects: Ptr("op"), 17762 OrganizationSecrets: Ptr("os"), 17763 OrganizationSelfHostedRunners: Ptr("osh"), 17764 OrganizationUserBlocking: Ptr("oub"), 17765 Packages: Ptr("pkg"), 17766 Pages: Ptr("pg"), 17767 PullRequests: Ptr("pr"), 17768 RepositoryHooks: Ptr("rh"), 17769 RepositoryProjects: Ptr("rp"), 17770 RepositoryPreReceiveHooks: Ptr("rprh"), 17771 Secrets: Ptr("s"), 17772 SecretScanningAlerts: Ptr("ssa"), 17773 SecurityEvents: Ptr("se"), 17774 SingleFile: Ptr("sf"), 17775 Statuses: Ptr("s"), 17776 TeamDiscussions: Ptr("td"), 17777 VulnerabilityAlerts: Ptr("va"), 17778 Workflows: Ptr("w"), 17779 }, 17780 CreatedAt: &Timestamp{referenceTime}, 17781 UpdatedAt: &Timestamp{referenceTime}, 17782 HasMultipleSingleFiles: Ptr(false), 17783 SuspendedBy: &User{ 17784 Login: Ptr("l"), 17785 ID: Ptr(int64(1)), 17786 URL: Ptr("u"), 17787 AvatarURL: Ptr("a"), 17788 GravatarID: Ptr("g"), 17789 Name: Ptr("n"), 17790 Company: Ptr("c"), 17791 Blog: Ptr("b"), 17792 Location: Ptr("l"), 17793 Email: Ptr("e"), 17794 Hireable: Ptr(true), 17795 Bio: Ptr("b"), 17796 TwitterUsername: Ptr("t"), 17797 PublicRepos: Ptr(1), 17798 Followers: Ptr(1), 17799 Following: Ptr(1), 17800 CreatedAt: &Timestamp{referenceTime}, 17801 SuspendedAt: &Timestamp{referenceTime}, 17802 }, 17803 SuspendedAt: &Timestamp{referenceTime}, 17804 }, 17805 } 17806 17807 want := `{ 17808 "action": "a", 17809 "pull_request": { 17810 "id": 1 17811 }, 17812 "comment": { 17813 "id": 1 17814 }, 17815 "changes": { 17816 "title": { 17817 "from": "TitleFrom" 17818 }, 17819 "body": { 17820 "from": "BodyFrom" 17821 }, 17822 "base": { 17823 "ref": { 17824 "from": "BaseRefFrom" 17825 }, 17826 "sha": { 17827 "from": "BaseSHAFrom" 17828 } 17829 } 17830 }, 17831 "repository": { 17832 "id": 1, 17833 "name": "n", 17834 "url": "s" 17835 }, 17836 "sender": { 17837 "login": "l", 17838 "id": 1, 17839 "node_id": "n", 17840 "avatar_url": "a", 17841 "url": "u", 17842 "events_url": "e", 17843 "repos_url": "r" 17844 }, 17845 "installation": { 17846 "id": 1, 17847 "node_id": "nid", 17848 "app_id": 1, 17849 "app_slug": "as", 17850 "target_id": 1, 17851 "account": { 17852 "login": "l", 17853 "id": 1, 17854 "avatar_url": "a", 17855 "gravatar_id": "g", 17856 "name": "n", 17857 "company": "c", 17858 "blog": "b", 17859 "location": "l", 17860 "email": "e", 17861 "hireable": true, 17862 "bio": "b", 17863 "twitter_username": "t", 17864 "public_repos": 1, 17865 "followers": 1, 17866 "following": 1, 17867 "created_at": ` + referenceTimeStr + `, 17868 "suspended_at": ` + referenceTimeStr + `, 17869 "url": "u" 17870 }, 17871 "access_tokens_url": "atu", 17872 "repositories_url": "ru", 17873 "html_url": "hu", 17874 "target_type": "tt", 17875 "single_file_name": "sfn", 17876 "repository_selection": "rs", 17877 "events": [ 17878 "e" 17879 ], 17880 "single_file_paths": [ 17881 "s" 17882 ], 17883 "permissions": { 17884 "actions": "a", 17885 "administration": "ad", 17886 "checks": "c", 17887 "contents": "co", 17888 "content_references": "cr", 17889 "deployments": "d", 17890 "environments": "e", 17891 "issues": "i", 17892 "metadata": "md", 17893 "members": "m", 17894 "organization_administration": "oa", 17895 "organization_hooks": "oh", 17896 "organization_plan": "op", 17897 "organization_pre_receive_hooks": "opr", 17898 "organization_projects": "op", 17899 "organization_secrets": "os", 17900 "organization_self_hosted_runners": "osh", 17901 "organization_user_blocking": "oub", 17902 "packages": "pkg", 17903 "pages": "pg", 17904 "pull_requests": "pr", 17905 "repository_hooks": "rh", 17906 "repository_projects": "rp", 17907 "repository_pre_receive_hooks": "rprh", 17908 "secrets": "s", 17909 "secret_scanning_alerts": "ssa", 17910 "security_events": "se", 17911 "single_file": "sf", 17912 "statuses": "s", 17913 "team_discussions": "td", 17914 "vulnerability_alerts": "va", 17915 "workflows": "w" 17916 }, 17917 "created_at": ` + referenceTimeStr + `, 17918 "updated_at": ` + referenceTimeStr + `, 17919 "has_multiple_single_files": false, 17920 "suspended_by": { 17921 "login": "l", 17922 "id": 1, 17923 "avatar_url": "a", 17924 "gravatar_id": "g", 17925 "name": "n", 17926 "company": "c", 17927 "blog": "b", 17928 "location": "l", 17929 "email": "e", 17930 "hireable": true, 17931 "bio": "b", 17932 "twitter_username": "t", 17933 "public_repos": 1, 17934 "followers": 1, 17935 "following": 1, 17936 "created_at": ` + referenceTimeStr + `, 17937 "suspended_at": ` + referenceTimeStr + `, 17938 "url": "u" 17939 }, 17940 "suspended_at": ` + referenceTimeStr + ` 17941 } 17942 }` 17943 17944 testJSONMarshal(t, u, want) 17945 } 17946 17947 func TestPullRequestReviewThreadEvent_Marshal(t *testing.T) { 17948 t.Parallel() 17949 testJSONMarshal(t, &PullRequestReviewThreadEvent{}, "{}") 17950 17951 u := &PullRequestReviewThreadEvent{ 17952 Action: Ptr("a"), 17953 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 17954 Thread: &PullRequestThread{ 17955 Comments: []*PullRequestComment{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}}, 17956 }, 17957 Repo: &Repository{ 17958 ID: Ptr(int64(1)), 17959 URL: Ptr("s"), 17960 Name: Ptr("n"), 17961 }, 17962 Sender: &User{ 17963 Login: Ptr("l"), 17964 ID: Ptr(int64(1)), 17965 NodeID: Ptr("n"), 17966 URL: Ptr("u"), 17967 ReposURL: Ptr("r"), 17968 EventsURL: Ptr("e"), 17969 AvatarURL: Ptr("a"), 17970 }, 17971 Installation: &Installation{ 17972 ID: Ptr(int64(1)), 17973 NodeID: Ptr("nid"), 17974 AppID: Ptr(int64(1)), 17975 AppSlug: Ptr("as"), 17976 TargetID: Ptr(int64(1)), 17977 Account: &User{ 17978 Login: Ptr("l"), 17979 ID: Ptr(int64(1)), 17980 URL: Ptr("u"), 17981 AvatarURL: Ptr("a"), 17982 GravatarID: Ptr("g"), 17983 Name: Ptr("n"), 17984 Company: Ptr("c"), 17985 Blog: Ptr("b"), 17986 Location: Ptr("l"), 17987 Email: Ptr("e"), 17988 Hireable: Ptr(true), 17989 Bio: Ptr("b"), 17990 TwitterUsername: Ptr("t"), 17991 PublicRepos: Ptr(1), 17992 Followers: Ptr(1), 17993 Following: Ptr(1), 17994 CreatedAt: &Timestamp{referenceTime}, 17995 SuspendedAt: &Timestamp{referenceTime}, 17996 }, 17997 AccessTokensURL: Ptr("atu"), 17998 RepositoriesURL: Ptr("ru"), 17999 HTMLURL: Ptr("hu"), 18000 TargetType: Ptr("tt"), 18001 SingleFileName: Ptr("sfn"), 18002 RepositorySelection: Ptr("rs"), 18003 Events: []string{"e"}, 18004 SingleFilePaths: []string{"s"}, 18005 Permissions: &InstallationPermissions{ 18006 Actions: Ptr("a"), 18007 Administration: Ptr("ad"), 18008 Checks: Ptr("c"), 18009 Contents: Ptr("co"), 18010 ContentReferences: Ptr("cr"), 18011 Deployments: Ptr("d"), 18012 Environments: Ptr("e"), 18013 Issues: Ptr("i"), 18014 Metadata: Ptr("md"), 18015 Members: Ptr("m"), 18016 OrganizationAdministration: Ptr("oa"), 18017 OrganizationHooks: Ptr("oh"), 18018 OrganizationPlan: Ptr("op"), 18019 OrganizationPreReceiveHooks: Ptr("opr"), 18020 OrganizationProjects: Ptr("op"), 18021 OrganizationSecrets: Ptr("os"), 18022 OrganizationSelfHostedRunners: Ptr("osh"), 18023 OrganizationUserBlocking: Ptr("oub"), 18024 Packages: Ptr("pkg"), 18025 Pages: Ptr("pg"), 18026 PullRequests: Ptr("pr"), 18027 RepositoryHooks: Ptr("rh"), 18028 RepositoryProjects: Ptr("rp"), 18029 RepositoryPreReceiveHooks: Ptr("rprh"), 18030 Secrets: Ptr("s"), 18031 SecretScanningAlerts: Ptr("ssa"), 18032 SecurityEvents: Ptr("se"), 18033 SingleFile: Ptr("sf"), 18034 Statuses: Ptr("s"), 18035 TeamDiscussions: Ptr("td"), 18036 VulnerabilityAlerts: Ptr("va"), 18037 Workflows: Ptr("w"), 18038 }, 18039 CreatedAt: &Timestamp{referenceTime}, 18040 UpdatedAt: &Timestamp{referenceTime}, 18041 HasMultipleSingleFiles: Ptr(false), 18042 SuspendedBy: &User{ 18043 Login: Ptr("l"), 18044 ID: Ptr(int64(1)), 18045 URL: Ptr("u"), 18046 AvatarURL: Ptr("a"), 18047 GravatarID: Ptr("g"), 18048 Name: Ptr("n"), 18049 Company: Ptr("c"), 18050 Blog: Ptr("b"), 18051 Location: Ptr("l"), 18052 Email: Ptr("e"), 18053 Hireable: Ptr(true), 18054 Bio: Ptr("b"), 18055 TwitterUsername: Ptr("t"), 18056 PublicRepos: Ptr(1), 18057 Followers: Ptr(1), 18058 Following: Ptr(1), 18059 CreatedAt: &Timestamp{referenceTime}, 18060 SuspendedAt: &Timestamp{referenceTime}, 18061 }, 18062 SuspendedAt: &Timestamp{referenceTime}, 18063 }, 18064 } 18065 18066 want := `{ 18067 "action": "a", 18068 "pull_request": { 18069 "id": 1 18070 }, 18071 "thread": { 18072 "comments": [ 18073 { 18074 "id": 1 18075 }, 18076 { 18077 "id": 2 18078 } 18079 ] 18080 }, 18081 "repository": { 18082 "id": 1, 18083 "name": "n", 18084 "url": "s" 18085 }, 18086 "sender": { 18087 "login": "l", 18088 "id": 1, 18089 "node_id": "n", 18090 "avatar_url": "a", 18091 "url": "u", 18092 "events_url": "e", 18093 "repos_url": "r" 18094 }, 18095 "installation": { 18096 "id": 1, 18097 "node_id": "nid", 18098 "app_id": 1, 18099 "app_slug": "as", 18100 "target_id": 1, 18101 "account": { 18102 "login": "l", 18103 "id": 1, 18104 "avatar_url": "a", 18105 "gravatar_id": "g", 18106 "name": "n", 18107 "company": "c", 18108 "blog": "b", 18109 "location": "l", 18110 "email": "e", 18111 "hireable": true, 18112 "bio": "b", 18113 "twitter_username": "t", 18114 "public_repos": 1, 18115 "followers": 1, 18116 "following": 1, 18117 "created_at": ` + referenceTimeStr + `, 18118 "suspended_at": ` + referenceTimeStr + `, 18119 "url": "u" 18120 }, 18121 "access_tokens_url": "atu", 18122 "repositories_url": "ru", 18123 "html_url": "hu", 18124 "target_type": "tt", 18125 "single_file_name": "sfn", 18126 "repository_selection": "rs", 18127 "events": [ 18128 "e" 18129 ], 18130 "single_file_paths": [ 18131 "s" 18132 ], 18133 "permissions": { 18134 "actions": "a", 18135 "administration": "ad", 18136 "checks": "c", 18137 "contents": "co", 18138 "content_references": "cr", 18139 "deployments": "d", 18140 "environments": "e", 18141 "issues": "i", 18142 "metadata": "md", 18143 "members": "m", 18144 "organization_administration": "oa", 18145 "organization_hooks": "oh", 18146 "organization_plan": "op", 18147 "organization_pre_receive_hooks": "opr", 18148 "organization_projects": "op", 18149 "organization_secrets": "os", 18150 "organization_self_hosted_runners": "osh", 18151 "organization_user_blocking": "oub", 18152 "packages": "pkg", 18153 "pages": "pg", 18154 "pull_requests": "pr", 18155 "repository_hooks": "rh", 18156 "repository_projects": "rp", 18157 "repository_pre_receive_hooks": "rprh", 18158 "secrets": "s", 18159 "secret_scanning_alerts": "ssa", 18160 "security_events": "se", 18161 "single_file": "sf", 18162 "statuses": "s", 18163 "team_discussions": "td", 18164 "vulnerability_alerts": "va", 18165 "workflows": "w" 18166 }, 18167 "created_at": ` + referenceTimeStr + `, 18168 "updated_at": ` + referenceTimeStr + `, 18169 "has_multiple_single_files": false, 18170 "suspended_by": { 18171 "login": "l", 18172 "id": 1, 18173 "avatar_url": "a", 18174 "gravatar_id": "g", 18175 "name": "n", 18176 "company": "c", 18177 "blog": "b", 18178 "location": "l", 18179 "email": "e", 18180 "hireable": true, 18181 "bio": "b", 18182 "twitter_username": "t", 18183 "public_repos": 1, 18184 "followers": 1, 18185 "following": 1, 18186 "created_at": ` + referenceTimeStr + `, 18187 "suspended_at": ` + referenceTimeStr + `, 18188 "url": "u" 18189 }, 18190 "suspended_at": ` + referenceTimeStr + ` 18191 } 18192 }` 18193 18194 testJSONMarshal(t, u, want) 18195 } 18196 18197 func TestPullRequestTargetEvent_Marshal(t *testing.T) { 18198 t.Parallel() 18199 testJSONMarshal(t, &PullRequestTargetEvent{}, "{}") 18200 18201 u := &PullRequestTargetEvent{ 18202 Action: Ptr("a"), 18203 Assignee: &User{ 18204 Login: Ptr("l"), 18205 ID: Ptr(int64(1)), 18206 NodeID: Ptr("n"), 18207 URL: Ptr("u"), 18208 ReposURL: Ptr("r"), 18209 EventsURL: Ptr("e"), 18210 AvatarURL: Ptr("a"), 18211 }, 18212 Number: Ptr(1), 18213 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 18214 Changes: &EditChange{ 18215 Title: &EditTitle{ 18216 From: Ptr("TitleFrom"), 18217 }, 18218 Body: &EditBody{ 18219 From: Ptr("BodyFrom"), 18220 }, 18221 Base: &EditBase{ 18222 Ref: &EditRef{ 18223 From: Ptr("BaseRefFrom"), 18224 }, 18225 SHA: &EditSHA{ 18226 From: Ptr("BaseSHAFrom"), 18227 }, 18228 }, 18229 }, 18230 RequestedReviewer: &User{ 18231 Login: Ptr("l"), 18232 ID: Ptr(int64(1)), 18233 NodeID: Ptr("n"), 18234 URL: Ptr("u"), 18235 ReposURL: Ptr("r"), 18236 EventsURL: Ptr("e"), 18237 AvatarURL: Ptr("a"), 18238 }, 18239 RequestedTeam: &Team{ID: Ptr(int64(1))}, 18240 Label: &Label{ID: Ptr(int64(1))}, 18241 Before: Ptr("before"), 18242 After: Ptr("after"), 18243 Repo: &Repository{ 18244 ID: Ptr(int64(1)), 18245 URL: Ptr("s"), 18246 Name: Ptr("n"), 18247 }, 18248 PerformedViaGithubApp: &App{ 18249 ID: Ptr(int64(1)), 18250 NodeID: Ptr("n"), 18251 Slug: Ptr("s"), 18252 Name: Ptr("n"), 18253 Description: Ptr("d"), 18254 ExternalURL: Ptr("e"), 18255 HTMLURL: Ptr("h"), 18256 }, 18257 Organization: &Organization{ 18258 BillingEmail: Ptr("be"), 18259 Blog: Ptr("b"), 18260 Company: Ptr("c"), 18261 Email: Ptr("e"), 18262 TwitterUsername: Ptr("tu"), 18263 Location: Ptr("loc"), 18264 Name: Ptr("n"), 18265 Description: Ptr("d"), 18266 IsVerified: Ptr(true), 18267 HasOrganizationProjects: Ptr(true), 18268 HasRepositoryProjects: Ptr(true), 18269 DefaultRepoPermission: Ptr("drp"), 18270 MembersCanCreateRepos: Ptr(true), 18271 MembersCanCreateInternalRepos: Ptr(true), 18272 MembersCanCreatePrivateRepos: Ptr(true), 18273 MembersCanCreatePublicRepos: Ptr(false), 18274 MembersAllowedRepositoryCreationType: Ptr("marct"), 18275 MembersCanCreatePages: Ptr(true), 18276 MembersCanCreatePublicPages: Ptr(false), 18277 MembersCanCreatePrivatePages: Ptr(true), 18278 }, 18279 Sender: &User{ 18280 Login: Ptr("l"), 18281 ID: Ptr(int64(1)), 18282 NodeID: Ptr("n"), 18283 URL: Ptr("u"), 18284 ReposURL: Ptr("r"), 18285 EventsURL: Ptr("e"), 18286 AvatarURL: Ptr("a"), 18287 }, 18288 Installation: &Installation{ 18289 ID: Ptr(int64(1)), 18290 NodeID: Ptr("nid"), 18291 AppID: Ptr(int64(1)), 18292 AppSlug: Ptr("as"), 18293 TargetID: Ptr(int64(1)), 18294 Account: &User{ 18295 Login: Ptr("l"), 18296 ID: Ptr(int64(1)), 18297 URL: Ptr("u"), 18298 AvatarURL: Ptr("a"), 18299 GravatarID: Ptr("g"), 18300 Name: Ptr("n"), 18301 Company: Ptr("c"), 18302 Blog: Ptr("b"), 18303 Location: Ptr("l"), 18304 Email: Ptr("e"), 18305 Hireable: Ptr(true), 18306 Bio: Ptr("b"), 18307 TwitterUsername: Ptr("t"), 18308 PublicRepos: Ptr(1), 18309 Followers: Ptr(1), 18310 Following: Ptr(1), 18311 CreatedAt: &Timestamp{referenceTime}, 18312 SuspendedAt: &Timestamp{referenceTime}, 18313 }, 18314 AccessTokensURL: Ptr("atu"), 18315 RepositoriesURL: Ptr("ru"), 18316 HTMLURL: Ptr("hu"), 18317 TargetType: Ptr("tt"), 18318 SingleFileName: Ptr("sfn"), 18319 RepositorySelection: Ptr("rs"), 18320 Events: []string{"e"}, 18321 SingleFilePaths: []string{"s"}, 18322 Permissions: &InstallationPermissions{ 18323 Actions: Ptr("a"), 18324 Administration: Ptr("ad"), 18325 Checks: Ptr("c"), 18326 Contents: Ptr("co"), 18327 ContentReferences: Ptr("cr"), 18328 Deployments: Ptr("d"), 18329 Environments: Ptr("e"), 18330 Issues: Ptr("i"), 18331 Metadata: Ptr("md"), 18332 Members: Ptr("m"), 18333 OrganizationAdministration: Ptr("oa"), 18334 OrganizationHooks: Ptr("oh"), 18335 OrganizationPlan: Ptr("op"), 18336 OrganizationPreReceiveHooks: Ptr("opr"), 18337 OrganizationProjects: Ptr("op"), 18338 OrganizationSecrets: Ptr("os"), 18339 OrganizationSelfHostedRunners: Ptr("osh"), 18340 OrganizationUserBlocking: Ptr("oub"), 18341 Packages: Ptr("pkg"), 18342 Pages: Ptr("pg"), 18343 PullRequests: Ptr("pr"), 18344 RepositoryHooks: Ptr("rh"), 18345 RepositoryProjects: Ptr("rp"), 18346 RepositoryPreReceiveHooks: Ptr("rprh"), 18347 Secrets: Ptr("s"), 18348 SecretScanningAlerts: Ptr("ssa"), 18349 SecurityEvents: Ptr("se"), 18350 SingleFile: Ptr("sf"), 18351 Statuses: Ptr("s"), 18352 TeamDiscussions: Ptr("td"), 18353 VulnerabilityAlerts: Ptr("va"), 18354 Workflows: Ptr("w"), 18355 }, 18356 CreatedAt: &Timestamp{referenceTime}, 18357 UpdatedAt: &Timestamp{referenceTime}, 18358 HasMultipleSingleFiles: Ptr(false), 18359 SuspendedBy: &User{ 18360 Login: Ptr("l"), 18361 ID: Ptr(int64(1)), 18362 URL: Ptr("u"), 18363 AvatarURL: Ptr("a"), 18364 GravatarID: Ptr("g"), 18365 Name: Ptr("n"), 18366 Company: Ptr("c"), 18367 Blog: Ptr("b"), 18368 Location: Ptr("l"), 18369 Email: Ptr("e"), 18370 Hireable: Ptr(true), 18371 Bio: Ptr("b"), 18372 TwitterUsername: Ptr("t"), 18373 PublicRepos: Ptr(1), 18374 Followers: Ptr(1), 18375 Following: Ptr(1), 18376 CreatedAt: &Timestamp{referenceTime}, 18377 SuspendedAt: &Timestamp{referenceTime}, 18378 }, 18379 SuspendedAt: &Timestamp{referenceTime}, 18380 }, 18381 } 18382 18383 want := `{ 18384 "action": "a", 18385 "assignee": { 18386 "login": "l", 18387 "id": 1, 18388 "node_id": "n", 18389 "avatar_url": "a", 18390 "url": "u", 18391 "events_url": "e", 18392 "repos_url": "r" 18393 }, 18394 "number": 1, 18395 "pull_request": { 18396 "id": 1 18397 }, 18398 "changes": { 18399 "title": { 18400 "from": "TitleFrom" 18401 }, 18402 "body": { 18403 "from": "BodyFrom" 18404 }, 18405 "base": { 18406 "ref": { 18407 "from": "BaseRefFrom" 18408 }, 18409 "sha": { 18410 "from": "BaseSHAFrom" 18411 } 18412 } 18413 }, 18414 "requested_reviewer": { 18415 "login": "l", 18416 "id": 1, 18417 "node_id": "n", 18418 "avatar_url": "a", 18419 "url": "u", 18420 "events_url": "e", 18421 "repos_url": "r" 18422 }, 18423 "requested_team": { 18424 "id": 1 18425 }, 18426 "label": { 18427 "id": 1 18428 }, 18429 "before": "before", 18430 "after": "after", 18431 "repository": { 18432 "id": 1, 18433 "name": "n", 18434 "url": "s" 18435 }, 18436 "performed_via_github_app": { 18437 "id": 1, 18438 "node_id": "n", 18439 "slug": "s", 18440 "name": "n", 18441 "description": "d", 18442 "external_url": "e", 18443 "html_url": "h" 18444 }, 18445 "organization": { 18446 "name": "n", 18447 "company": "c", 18448 "blog": "b", 18449 "location": "loc", 18450 "email": "e", 18451 "twitter_username": "tu", 18452 "description": "d", 18453 "billing_email": "be", 18454 "is_verified": true, 18455 "has_organization_projects": true, 18456 "has_repository_projects": true, 18457 "default_repository_permission": "drp", 18458 "members_can_create_repositories": true, 18459 "members_can_create_public_repositories": false, 18460 "members_can_create_private_repositories": true, 18461 "members_can_create_internal_repositories": true, 18462 "members_allowed_repository_creation_type": "marct", 18463 "members_can_create_pages": true, 18464 "members_can_create_public_pages": false, 18465 "members_can_create_private_pages": true 18466 }, 18467 "sender": { 18468 "login": "l", 18469 "id": 1, 18470 "node_id": "n", 18471 "avatar_url": "a", 18472 "url": "u", 18473 "events_url": "e", 18474 "repos_url": "r" 18475 }, 18476 "installation": { 18477 "id": 1, 18478 "node_id": "nid", 18479 "app_id": 1, 18480 "app_slug": "as", 18481 "target_id": 1, 18482 "account": { 18483 "login": "l", 18484 "id": 1, 18485 "avatar_url": "a", 18486 "gravatar_id": "g", 18487 "name": "n", 18488 "company": "c", 18489 "blog": "b", 18490 "location": "l", 18491 "email": "e", 18492 "hireable": true, 18493 "bio": "b", 18494 "twitter_username": "t", 18495 "public_repos": 1, 18496 "followers": 1, 18497 "following": 1, 18498 "created_at": ` + referenceTimeStr + `, 18499 "suspended_at": ` + referenceTimeStr + `, 18500 "url": "u" 18501 }, 18502 "access_tokens_url": "atu", 18503 "repositories_url": "ru", 18504 "html_url": "hu", 18505 "target_type": "tt", 18506 "single_file_name": "sfn", 18507 "repository_selection": "rs", 18508 "events": [ 18509 "e" 18510 ], 18511 "single_file_paths": [ 18512 "s" 18513 ], 18514 "permissions": { 18515 "actions": "a", 18516 "administration": "ad", 18517 "checks": "c", 18518 "contents": "co", 18519 "content_references": "cr", 18520 "deployments": "d", 18521 "environments": "e", 18522 "issues": "i", 18523 "metadata": "md", 18524 "members": "m", 18525 "organization_administration": "oa", 18526 "organization_hooks": "oh", 18527 "organization_plan": "op", 18528 "organization_pre_receive_hooks": "opr", 18529 "organization_projects": "op", 18530 "organization_secrets": "os", 18531 "organization_self_hosted_runners": "osh", 18532 "organization_user_blocking": "oub", 18533 "packages": "pkg", 18534 "pages": "pg", 18535 "pull_requests": "pr", 18536 "repository_hooks": "rh", 18537 "repository_projects": "rp", 18538 "repository_pre_receive_hooks": "rprh", 18539 "secrets": "s", 18540 "secret_scanning_alerts": "ssa", 18541 "security_events": "se", 18542 "single_file": "sf", 18543 "statuses": "s", 18544 "team_discussions": "td", 18545 "vulnerability_alerts": "va", 18546 "workflows": "w" 18547 }, 18548 "created_at": ` + referenceTimeStr + `, 18549 "updated_at": ` + referenceTimeStr + `, 18550 "has_multiple_single_files": false, 18551 "suspended_by": { 18552 "login": "l", 18553 "id": 1, 18554 "avatar_url": "a", 18555 "gravatar_id": "g", 18556 "name": "n", 18557 "company": "c", 18558 "blog": "b", 18559 "location": "l", 18560 "email": "e", 18561 "hireable": true, 18562 "bio": "b", 18563 "twitter_username": "t", 18564 "public_repos": 1, 18565 "followers": 1, 18566 "following": 1, 18567 "created_at": ` + referenceTimeStr + `, 18568 "suspended_at": ` + referenceTimeStr + `, 18569 "url": "u" 18570 }, 18571 "suspended_at": ` + referenceTimeStr + ` 18572 } 18573 }` 18574 18575 testJSONMarshal(t, u, want) 18576 } 18577 18578 func TestRepositoryVulnerabilityAlertEvent_Marshal(t *testing.T) { 18579 t.Parallel() 18580 testJSONMarshal(t, &RepositoryVulnerabilityAlertEvent{}, "{}") 18581 18582 u := &RepositoryVulnerabilityAlertEvent{ 18583 Action: Ptr("a"), 18584 Alert: &RepositoryVulnerabilityAlert{ 18585 ID: Ptr(int64(1)), 18586 AffectedRange: Ptr("ar"), 18587 AffectedPackageName: Ptr("apn"), 18588 ExternalReference: Ptr("er"), 18589 ExternalIdentifier: Ptr("ei"), 18590 FixedIn: Ptr("fi"), 18591 Dismisser: &User{ 18592 Login: Ptr("l"), 18593 ID: Ptr(int64(1)), 18594 NodeID: Ptr("n"), 18595 URL: Ptr("u"), 18596 ReposURL: Ptr("r"), 18597 EventsURL: Ptr("e"), 18598 AvatarURL: Ptr("a"), 18599 }, 18600 DismissReason: Ptr("dr"), 18601 DismissedAt: &Timestamp{referenceTime}, 18602 }, 18603 Repository: &Repository{ 18604 ID: Ptr(int64(1)), 18605 URL: Ptr("s"), 18606 Name: Ptr("n"), 18607 }, 18608 } 18609 18610 want := `{ 18611 "action": "a", 18612 "alert": { 18613 "id": 1, 18614 "affected_range": "ar", 18615 "affected_package_name": "apn", 18616 "external_reference": "er", 18617 "external_identifier": "ei", 18618 "fixed_in": "fi", 18619 "dismisser": { 18620 "login": "l", 18621 "id": 1, 18622 "node_id": "n", 18623 "avatar_url": "a", 18624 "url": "u", 18625 "events_url": "e", 18626 "repos_url": "r" 18627 }, 18628 "dismiss_reason": "dr", 18629 "dismissed_at": ` + referenceTimeStr + ` 18630 }, 18631 "repository": { 18632 "id": 1, 18633 "name": "n", 18634 "url": "s" 18635 } 18636 }` 18637 18638 testJSONMarshal(t, u, want) 18639 } 18640 18641 func TestSecretScanningAlertEvent_Marshal(t *testing.T) { 18642 t.Parallel() 18643 testJSONMarshal(t, &SecretScanningAlertEvent{}, "{}") 18644 18645 u := &SecretScanningAlertEvent{ 18646 Action: Ptr("a"), 18647 Alert: &SecretScanningAlert{ 18648 Number: Ptr(1), 18649 SecretType: Ptr("t"), 18650 Resolution: Ptr("r"), 18651 ResolvedBy: &User{ 18652 Login: Ptr("l"), 18653 ID: Ptr(int64(1)), 18654 NodeID: Ptr("n"), 18655 URL: Ptr("u"), 18656 ReposURL: Ptr("r"), 18657 EventsURL: Ptr("e"), 18658 AvatarURL: Ptr("a"), 18659 }, 18660 ResolvedAt: &Timestamp{referenceTime}, 18661 }, 18662 Repo: &Repository{ 18663 ID: Ptr(int64(1)), 18664 URL: Ptr("s"), 18665 Name: Ptr("n"), 18666 }, 18667 Organization: &Organization{ 18668 BillingEmail: Ptr("be"), 18669 Blog: Ptr("b"), 18670 Company: Ptr("c"), 18671 Email: Ptr("e"), 18672 TwitterUsername: Ptr("tu"), 18673 Location: Ptr("loc"), 18674 Name: Ptr("n"), 18675 Description: Ptr("d"), 18676 IsVerified: Ptr(true), 18677 HasOrganizationProjects: Ptr(true), 18678 HasRepositoryProjects: Ptr(true), 18679 DefaultRepoPermission: Ptr("drp"), 18680 MembersCanCreateRepos: Ptr(true), 18681 MembersCanCreateInternalRepos: Ptr(true), 18682 MembersCanCreatePrivateRepos: Ptr(true), 18683 MembersCanCreatePublicRepos: Ptr(false), 18684 MembersAllowedRepositoryCreationType: Ptr("marct"), 18685 MembersCanCreatePages: Ptr(true), 18686 MembersCanCreatePublicPages: Ptr(false), 18687 MembersCanCreatePrivatePages: Ptr(true), 18688 }, 18689 Enterprise: &Enterprise{ 18690 ID: Ptr(1), 18691 Slug: Ptr("s"), 18692 Name: Ptr("n"), 18693 NodeID: Ptr("nid"), 18694 AvatarURL: Ptr("au"), 18695 Description: Ptr("d"), 18696 WebsiteURL: Ptr("wu"), 18697 HTMLURL: Ptr("hu"), 18698 CreatedAt: &Timestamp{referenceTime}, 18699 UpdatedAt: &Timestamp{referenceTime}, 18700 }, 18701 Sender: &User{ 18702 Login: Ptr("l"), 18703 ID: Ptr(int64(1)), 18704 NodeID: Ptr("n"), 18705 URL: Ptr("u"), 18706 ReposURL: Ptr("r"), 18707 EventsURL: Ptr("e"), 18708 AvatarURL: Ptr("a"), 18709 }, 18710 Installation: &Installation{ 18711 ID: Ptr(int64(1)), 18712 NodeID: Ptr("nid"), 18713 AppID: Ptr(int64(1)), 18714 AppSlug: Ptr("as"), 18715 TargetID: Ptr(int64(1)), 18716 Account: &User{ 18717 Login: Ptr("l"), 18718 ID: Ptr(int64(1)), 18719 URL: Ptr("u"), 18720 AvatarURL: Ptr("a"), 18721 GravatarID: Ptr("g"), 18722 Name: Ptr("n"), 18723 Company: Ptr("c"), 18724 Blog: Ptr("b"), 18725 Location: Ptr("l"), 18726 Email: Ptr("e"), 18727 Hireable: Ptr(true), 18728 Bio: Ptr("b"), 18729 TwitterUsername: Ptr("t"), 18730 PublicRepos: Ptr(1), 18731 Followers: Ptr(1), 18732 Following: Ptr(1), 18733 CreatedAt: &Timestamp{referenceTime}, 18734 SuspendedAt: &Timestamp{referenceTime}, 18735 }, 18736 AccessTokensURL: Ptr("atu"), 18737 RepositoriesURL: Ptr("ru"), 18738 HTMLURL: Ptr("hu"), 18739 TargetType: Ptr("tt"), 18740 SingleFileName: Ptr("sfn"), 18741 RepositorySelection: Ptr("rs"), 18742 Events: []string{"e"}, 18743 SingleFilePaths: []string{"s"}, 18744 Permissions: &InstallationPermissions{ 18745 Actions: Ptr("a"), 18746 Administration: Ptr("ad"), 18747 Checks: Ptr("c"), 18748 Contents: Ptr("co"), 18749 ContentReferences: Ptr("cr"), 18750 Deployments: Ptr("d"), 18751 Environments: Ptr("e"), 18752 Issues: Ptr("i"), 18753 Metadata: Ptr("md"), 18754 Members: Ptr("m"), 18755 OrganizationAdministration: Ptr("oa"), 18756 OrganizationHooks: Ptr("oh"), 18757 OrganizationPlan: Ptr("op"), 18758 OrganizationPreReceiveHooks: Ptr("opr"), 18759 OrganizationProjects: Ptr("op"), 18760 OrganizationSecrets: Ptr("os"), 18761 OrganizationSelfHostedRunners: Ptr("osh"), 18762 OrganizationUserBlocking: Ptr("oub"), 18763 Packages: Ptr("pkg"), 18764 Pages: Ptr("pg"), 18765 PullRequests: Ptr("pr"), 18766 RepositoryHooks: Ptr("rh"), 18767 RepositoryProjects: Ptr("rp"), 18768 RepositoryPreReceiveHooks: Ptr("rprh"), 18769 Secrets: Ptr("s"), 18770 SecretScanningAlerts: Ptr("ssa"), 18771 SecurityEvents: Ptr("se"), 18772 SingleFile: Ptr("sf"), 18773 Statuses: Ptr("s"), 18774 TeamDiscussions: Ptr("td"), 18775 VulnerabilityAlerts: Ptr("va"), 18776 Workflows: Ptr("w"), 18777 }, 18778 CreatedAt: &Timestamp{referenceTime}, 18779 UpdatedAt: &Timestamp{referenceTime}, 18780 HasMultipleSingleFiles: Ptr(false), 18781 SuspendedBy: &User{ 18782 Login: Ptr("l"), 18783 ID: Ptr(int64(1)), 18784 URL: Ptr("u"), 18785 AvatarURL: Ptr("a"), 18786 GravatarID: Ptr("g"), 18787 Name: Ptr("n"), 18788 Company: Ptr("c"), 18789 Blog: Ptr("b"), 18790 Location: Ptr("l"), 18791 Email: Ptr("e"), 18792 Hireable: Ptr(true), 18793 Bio: Ptr("b"), 18794 TwitterUsername: Ptr("t"), 18795 PublicRepos: Ptr(1), 18796 Followers: Ptr(1), 18797 Following: Ptr(1), 18798 CreatedAt: &Timestamp{referenceTime}, 18799 SuspendedAt: &Timestamp{referenceTime}, 18800 }, 18801 SuspendedAt: &Timestamp{referenceTime}, 18802 }, 18803 } 18804 18805 want := `{ 18806 "action": "a", 18807 "alert": { 18808 "number": 1, 18809 "secret_type": "t", 18810 "resolution": "r", 18811 "resolved_by": { 18812 "login": "l", 18813 "id": 1, 18814 "node_id": "n", 18815 "avatar_url": "a", 18816 "url": "u", 18817 "events_url": "e", 18818 "repos_url": "r" 18819 }, 18820 "resolved_at": ` + referenceTimeStr + ` 18821 }, 18822 "repository": { 18823 "id": 1, 18824 "name": "n", 18825 "url": "s" 18826 }, 18827 "organization": { 18828 "name": "n", 18829 "company": "c", 18830 "blog": "b", 18831 "location": "loc", 18832 "email": "e", 18833 "twitter_username": "tu", 18834 "description": "d", 18835 "billing_email": "be", 18836 "is_verified": true, 18837 "has_organization_projects": true, 18838 "has_repository_projects": true, 18839 "default_repository_permission": "drp", 18840 "members_can_create_repositories": true, 18841 "members_can_create_public_repositories": false, 18842 "members_can_create_private_repositories": true, 18843 "members_can_create_internal_repositories": true, 18844 "members_allowed_repository_creation_type": "marct", 18845 "members_can_create_pages": true, 18846 "members_can_create_public_pages": false, 18847 "members_can_create_private_pages": true 18848 }, 18849 "enterprise": { 18850 "id": 1, 18851 "slug": "s", 18852 "name": "n", 18853 "node_id": "nid", 18854 "avatar_url": "au", 18855 "description": "d", 18856 "website_url": "wu", 18857 "html_url": "hu", 18858 "created_at": ` + referenceTimeStr + `, 18859 "updated_at": ` + referenceTimeStr + ` 18860 }, 18861 "sender": { 18862 "login": "l", 18863 "id": 1, 18864 "node_id": "n", 18865 "avatar_url": "a", 18866 "url": "u", 18867 "events_url": "e", 18868 "repos_url": "r" 18869 }, 18870 "installation": { 18871 "id": 1, 18872 "node_id": "nid", 18873 "app_id": 1, 18874 "app_slug": "as", 18875 "target_id": 1, 18876 "account": { 18877 "login": "l", 18878 "id": 1, 18879 "avatar_url": "a", 18880 "gravatar_id": "g", 18881 "name": "n", 18882 "company": "c", 18883 "blog": "b", 18884 "location": "l", 18885 "email": "e", 18886 "hireable": true, 18887 "bio": "b", 18888 "twitter_username": "t", 18889 "public_repos": 1, 18890 "followers": 1, 18891 "following": 1, 18892 "created_at": ` + referenceTimeStr + `, 18893 "suspended_at": ` + referenceTimeStr + `, 18894 "url": "u" 18895 }, 18896 "access_tokens_url": "atu", 18897 "repositories_url": "ru", 18898 "html_url": "hu", 18899 "target_type": "tt", 18900 "single_file_name": "sfn", 18901 "repository_selection": "rs", 18902 "events": [ 18903 "e" 18904 ], 18905 "single_file_paths": [ 18906 "s" 18907 ], 18908 "permissions": { 18909 "actions": "a", 18910 "administration": "ad", 18911 "checks": "c", 18912 "contents": "co", 18913 "content_references": "cr", 18914 "deployments": "d", 18915 "environments": "e", 18916 "issues": "i", 18917 "metadata": "md", 18918 "members": "m", 18919 "organization_administration": "oa", 18920 "organization_hooks": "oh", 18921 "organization_plan": "op", 18922 "organization_pre_receive_hooks": "opr", 18923 "organization_projects": "op", 18924 "organization_secrets": "os", 18925 "organization_self_hosted_runners": "osh", 18926 "organization_user_blocking": "oub", 18927 "packages": "pkg", 18928 "pages": "pg", 18929 "pull_requests": "pr", 18930 "repository_hooks": "rh", 18931 "repository_projects": "rp", 18932 "repository_pre_receive_hooks": "rprh", 18933 "secrets": "s", 18934 "secret_scanning_alerts": "ssa", 18935 "security_events": "se", 18936 "single_file": "sf", 18937 "statuses": "s", 18938 "team_discussions": "td", 18939 "vulnerability_alerts": "va", 18940 "workflows": "w" 18941 }, 18942 "created_at": ` + referenceTimeStr + `, 18943 "updated_at": ` + referenceTimeStr + `, 18944 "has_multiple_single_files": false, 18945 "suspended_by": { 18946 "login": "l", 18947 "id": 1, 18948 "avatar_url": "a", 18949 "gravatar_id": "g", 18950 "name": "n", 18951 "company": "c", 18952 "blog": "b", 18953 "location": "l", 18954 "email": "e", 18955 "hireable": true, 18956 "bio": "b", 18957 "twitter_username": "t", 18958 "public_repos": 1, 18959 "followers": 1, 18960 "following": 1, 18961 "created_at": ` + referenceTimeStr + `, 18962 "suspended_at": ` + referenceTimeStr + `, 18963 "url": "u" 18964 }, 18965 "suspended_at": ` + referenceTimeStr + ` 18966 } 18967 }` 18968 18969 testJSONMarshal(t, u, want) 18970 } 18971 18972 func TestSecretScanningAlertLocationEvent_Marshal(t *testing.T) { 18973 t.Parallel() 18974 testJSONMarshal(t, &SecretScanningAlertLocationEvent{}, "{}") 18975 u := &SecretScanningAlertLocationEvent{ 18976 Action: Ptr("created"), 18977 Alert: &SecretScanningAlert{ 18978 Number: Ptr(10), 18979 CreatedAt: &Timestamp{referenceTime}, 18980 UpdatedAt: &Timestamp{referenceTime}, 18981 URL: Ptr("a"), 18982 HTMLURL: Ptr("a"), 18983 SecretType: Ptr("mailchimp_api_key"), 18984 }, 18985 Location: &SecretScanningAlertLocation{ 18986 Type: Ptr("blob"), 18987 Details: &SecretScanningAlertLocationDetails{ 18988 Path: Ptr("path/to/file"), 18989 Startline: Ptr(10), 18990 EndLine: Ptr(20), 18991 StartColumn: Ptr(1), 18992 EndColumn: Ptr(2), 18993 BlobSHA: Ptr("d6e4c75c141dbacecc279b721b8bsomeSHA"), 18994 BlobURL: Ptr("a"), 18995 CommitSHA: Ptr("d6e4c75c141dbacecc279b721b8bsomeSHA"), 18996 CommitURL: Ptr("a"), 18997 }, 18998 }, 18999 Repo: &Repository{ 19000 ID: Ptr(int64(12345)), 19001 NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjM0NQ=="), 19002 Name: Ptr("example-repo"), 19003 }, 19004 Organization: &Organization{ 19005 Login: Ptr("example-org"), 19006 ID: Ptr(int64(67890)), 19007 }, 19008 Sender: &User{ 19009 Login: Ptr("example-user"), 19010 ID: Ptr(int64(1111)), 19011 }, 19012 Installation: &Installation{ 19013 ID: Ptr(int64(2222)), 19014 }, 19015 } 19016 19017 want := `{ 19018 "action": "created", 19019 "alert": { 19020 "number": 10, 19021 "created_at": ` + referenceTimeStr + `, 19022 "updated_at": ` + referenceTimeStr + `, 19023 "url": "a", 19024 "html_url": "a", 19025 "secret_type": "mailchimp_api_key" 19026 }, 19027 "location": { 19028 19029 "type": "blob", 19030 "details": { 19031 "path": "path/to/file", 19032 "start_line": 10, 19033 "end_line": 20, 19034 "start_column": 1, 19035 "end_column": 2, 19036 "blob_sha": "d6e4c75c141dbacecc279b721b8bsomeSHA", 19037 "blob_url": "a", 19038 "commit_sha": "d6e4c75c141dbacecc279b721b8bsomeSHA", 19039 "commit_url": "a" 19040 } 19041 }, 19042 "repository": { 19043 19044 "id": 12345, 19045 "node_id": "MDEwOlJlcG9zaXRvcnkxMjM0NQ==", 19046 "name": "example-repo" 19047 }, 19048 "organization": { 19049 "login": "example-org", 19050 "id": 67890 19051 }, 19052 "sender": { 19053 "login": "example-user", 19054 "id": 1111 19055 }, 19056 "installation": { 19057 "id": 2222 19058 } 19059 }` 19060 19061 testJSONMarshal(t, u, want) 19062 } 19063 19064 func TestSecurityAdvisoryEvent_Marshal(t *testing.T) { 19065 t.Parallel() 19066 testJSONMarshal(t, &SecurityAdvisoryEvent{}, "{}") 19067 u := &SecurityAdvisoryEvent{ 19068 Action: Ptr("published"), 19069 SecurityAdvisory: &SecurityAdvisory{ 19070 CVSS: &AdvisoryCVSS{ 19071 Score: Ptr(1.0), 19072 VectorString: Ptr("vs"), 19073 }, 19074 CWEs: []*AdvisoryCWEs{ 19075 { 19076 CWEID: Ptr("cweid"), 19077 Name: Ptr("n"), 19078 }, 19079 }, 19080 GHSAID: Ptr("GHSA-rf4j-j272-some"), 19081 Summary: Ptr("Siuuuuuuuuu"), 19082 Description: Ptr("desc"), 19083 Severity: Ptr("moderate"), 19084 Identifiers: []*AdvisoryIdentifier{ 19085 { 19086 Value: Ptr("GHSA-rf4j-j272-some"), 19087 Type: Ptr("GHSA"), 19088 }, 19089 }, 19090 References: []*AdvisoryReference{ 19091 { 19092 URL: Ptr("https://some-url"), 19093 }, 19094 }, 19095 PublishedAt: &Timestamp{referenceTime}, 19096 UpdatedAt: &Timestamp{referenceTime}, 19097 WithdrawnAt: nil, 19098 Vulnerabilities: []*AdvisoryVulnerability{ 19099 { 19100 Package: &VulnerabilityPackage{ 19101 Ecosystem: Ptr("ucl"), 19102 Name: Ptr("penaldo"), 19103 }, 19104 Severity: Ptr("moderate"), 19105 VulnerableVersionRange: Ptr(">= 2.0.0, < 2.0.2"), 19106 FirstPatchedVersion: &FirstPatchedVersion{ 19107 Identifier: Ptr("2.0.2"), 19108 }, 19109 }, 19110 }, 19111 }, 19112 Enterprise: &Enterprise{ 19113 ID: Ptr(1), 19114 Slug: Ptr("s"), 19115 Name: Ptr("n"), 19116 NodeID: Ptr("nid"), 19117 AvatarURL: Ptr("au"), 19118 Description: Ptr("d"), 19119 WebsiteURL: Ptr("wu"), 19120 HTMLURL: Ptr("hu"), 19121 CreatedAt: &Timestamp{referenceTime}, 19122 UpdatedAt: &Timestamp{referenceTime}, 19123 }, 19124 Installation: &Installation{ 19125 ID: Ptr(int64(1)), 19126 NodeID: Ptr("nid"), 19127 AppID: Ptr(int64(1)), 19128 AppSlug: Ptr("as"), 19129 TargetID: Ptr(int64(1)), 19130 Account: &User{ 19131 Login: Ptr("l"), 19132 ID: Ptr(int64(1)), 19133 URL: Ptr("u"), 19134 AvatarURL: Ptr("a"), 19135 GravatarID: Ptr("g"), 19136 Name: Ptr("n"), 19137 Company: Ptr("c"), 19138 Blog: Ptr("b"), 19139 Location: Ptr("l"), 19140 Email: Ptr("e"), 19141 Hireable: Ptr(true), 19142 Bio: Ptr("b"), 19143 TwitterUsername: Ptr("t"), 19144 PublicRepos: Ptr(1), 19145 Followers: Ptr(1), 19146 Following: Ptr(1), 19147 CreatedAt: &Timestamp{referenceTime}, 19148 SuspendedAt: &Timestamp{referenceTime}, 19149 }, 19150 AccessTokensURL: Ptr("atu"), 19151 RepositoriesURL: Ptr("ru"), 19152 HTMLURL: Ptr("hu"), 19153 TargetType: Ptr("tt"), 19154 SingleFileName: Ptr("sfn"), 19155 RepositorySelection: Ptr("rs"), 19156 Events: []string{"e"}, 19157 SingleFilePaths: []string{"s"}, 19158 Permissions: &InstallationPermissions{ 19159 Actions: Ptr("a"), 19160 Administration: Ptr("ad"), 19161 Checks: Ptr("c"), 19162 Contents: Ptr("co"), 19163 ContentReferences: Ptr("cr"), 19164 Deployments: Ptr("d"), 19165 Environments: Ptr("e"), 19166 Issues: Ptr("i"), 19167 Metadata: Ptr("md"), 19168 Members: Ptr("m"), 19169 OrganizationAdministration: Ptr("oa"), 19170 OrganizationHooks: Ptr("oh"), 19171 OrganizationPlan: Ptr("op"), 19172 OrganizationPreReceiveHooks: Ptr("opr"), 19173 OrganizationProjects: Ptr("op"), 19174 OrganizationSecrets: Ptr("os"), 19175 OrganizationSelfHostedRunners: Ptr("osh"), 19176 OrganizationUserBlocking: Ptr("oub"), 19177 Packages: Ptr("pkg"), 19178 Pages: Ptr("pg"), 19179 PullRequests: Ptr("pr"), 19180 RepositoryHooks: Ptr("rh"), 19181 RepositoryProjects: Ptr("rp"), 19182 RepositoryPreReceiveHooks: Ptr("rprh"), 19183 Secrets: Ptr("s"), 19184 SecretScanningAlerts: Ptr("ssa"), 19185 SecurityEvents: Ptr("se"), 19186 SingleFile: Ptr("sf"), 19187 Statuses: Ptr("s"), 19188 TeamDiscussions: Ptr("td"), 19189 VulnerabilityAlerts: Ptr("va"), 19190 Workflows: Ptr("w"), 19191 }, 19192 CreatedAt: &Timestamp{referenceTime}, 19193 UpdatedAt: &Timestamp{referenceTime}, 19194 HasMultipleSingleFiles: Ptr(false), 19195 SuspendedBy: &User{ 19196 Login: Ptr("l"), 19197 ID: Ptr(int64(1)), 19198 URL: Ptr("u"), 19199 AvatarURL: Ptr("a"), 19200 GravatarID: Ptr("g"), 19201 Name: Ptr("n"), 19202 Company: Ptr("c"), 19203 Blog: Ptr("b"), 19204 Location: Ptr("l"), 19205 Email: Ptr("e"), 19206 Hireable: Ptr(true), 19207 Bio: Ptr("b"), 19208 TwitterUsername: Ptr("t"), 19209 PublicRepos: Ptr(1), 19210 Followers: Ptr(1), 19211 Following: Ptr(1), 19212 CreatedAt: &Timestamp{referenceTime}, 19213 SuspendedAt: &Timestamp{referenceTime}, 19214 }, 19215 SuspendedAt: &Timestamp{referenceTime}, 19216 }, 19217 Organization: &Organization{ 19218 BillingEmail: Ptr("be"), 19219 Blog: Ptr("b"), 19220 Company: Ptr("c"), 19221 Email: Ptr("e"), 19222 TwitterUsername: Ptr("tu"), 19223 Location: Ptr("loc"), 19224 Name: Ptr("n"), 19225 Description: Ptr("d"), 19226 IsVerified: Ptr(true), 19227 HasOrganizationProjects: Ptr(true), 19228 HasRepositoryProjects: Ptr(true), 19229 DefaultRepoPermission: Ptr("drp"), 19230 MembersCanCreateRepos: Ptr(true), 19231 MembersCanCreateInternalRepos: Ptr(true), 19232 MembersCanCreatePrivateRepos: Ptr(true), 19233 MembersCanCreatePublicRepos: Ptr(false), 19234 MembersAllowedRepositoryCreationType: Ptr("marct"), 19235 MembersCanCreatePages: Ptr(true), 19236 MembersCanCreatePublicPages: Ptr(false), 19237 MembersCanCreatePrivatePages: Ptr(true), 19238 }, 19239 Repository: &Repository{ 19240 ID: Ptr(int64(1)), 19241 URL: Ptr("s"), 19242 Name: Ptr("n"), 19243 }, 19244 Sender: &User{ 19245 Login: Ptr("l"), 19246 ID: Ptr(int64(1)), 19247 NodeID: Ptr("n"), 19248 URL: Ptr("u"), 19249 ReposURL: Ptr("r"), 19250 EventsURL: Ptr("e"), 19251 AvatarURL: Ptr("a"), 19252 }, 19253 } 19254 19255 want := `{ 19256 "action": "published", 19257 "security_advisory": { 19258 "ghsa_id": "GHSA-rf4j-j272-some", 19259 "summary": "Siuuuuuuuuu", 19260 "cvss": { 19261 "score": 1.0, 19262 "vector_string": "vs" 19263 }, 19264 "cwes": [ 19265 { 19266 "cwe_id": "cweid", 19267 "name": "n" 19268 } 19269 ], 19270 "description": "desc", 19271 "severity": "moderate", 19272 "identifiers": [ 19273 { 19274 "value": "GHSA-rf4j-j272-some", 19275 "type": "GHSA" 19276 } 19277 ], 19278 "references": [ 19279 { 19280 "url": "https://some-url" 19281 } 19282 ], 19283 "published_at": ` + referenceTimeStr + `, 19284 "updated_at": ` + referenceTimeStr + `, 19285 "withdrawn_at": null, 19286 "vulnerabilities": [ 19287 { 19288 "package": { 19289 "ecosystem": "ucl", 19290 "name": "penaldo" 19291 }, 19292 "severity": "moderate", 19293 "vulnerable_version_range": ">= 2.0.0, < 2.0.2", 19294 "first_patched_version": { 19295 "identifier": "2.0.2" 19296 } 19297 } 19298 ] 19299 }, 19300 "enterprise": { 19301 "id": 1, 19302 "slug": "s", 19303 "name": "n", 19304 "node_id": "nid", 19305 "avatar_url": "au", 19306 "description": "d", 19307 "website_url": "wu", 19308 "html_url": "hu", 19309 "created_at": ` + referenceTimeStr + `, 19310 "updated_at": ` + referenceTimeStr + ` 19311 }, 19312 "installation": { 19313 "id": 1, 19314 "node_id": "nid", 19315 "app_id": 1, 19316 "app_slug": "as", 19317 "target_id": 1, 19318 "account": { 19319 "login": "l", 19320 "id": 1, 19321 "avatar_url": "a", 19322 "gravatar_id": "g", 19323 "name": "n", 19324 "company": "c", 19325 "blog": "b", 19326 "location": "l", 19327 "email": "e", 19328 "hireable": true, 19329 "bio": "b", 19330 "twitter_username": "t", 19331 "public_repos": 1, 19332 "followers": 1, 19333 "following": 1, 19334 "created_at": ` + referenceTimeStr + `, 19335 "suspended_at": ` + referenceTimeStr + `, 19336 "url": "u" 19337 }, 19338 "access_tokens_url": "atu", 19339 "repositories_url": "ru", 19340 "html_url": "hu", 19341 "target_type": "tt", 19342 "single_file_name": "sfn", 19343 "repository_selection": "rs", 19344 "events": [ 19345 "e" 19346 ], 19347 "single_file_paths": [ 19348 "s" 19349 ], 19350 "permissions": { 19351 "actions": "a", 19352 "administration": "ad", 19353 "checks": "c", 19354 "contents": "co", 19355 "content_references": "cr", 19356 "deployments": "d", 19357 "environments": "e", 19358 "issues": "i", 19359 "metadata": "md", 19360 "members": "m", 19361 "organization_administration": "oa", 19362 "organization_hooks": "oh", 19363 "organization_plan": "op", 19364 "organization_pre_receive_hooks": "opr", 19365 "organization_projects": "op", 19366 "organization_secrets": "os", 19367 "organization_self_hosted_runners": "osh", 19368 "organization_user_blocking": "oub", 19369 "packages": "pkg", 19370 "pages": "pg", 19371 "pull_requests": "pr", 19372 "repository_hooks": "rh", 19373 "repository_projects": "rp", 19374 "repository_pre_receive_hooks": "rprh", 19375 "secrets": "s", 19376 "secret_scanning_alerts": "ssa", 19377 "security_events": "se", 19378 "single_file": "sf", 19379 "statuses": "s", 19380 "team_discussions": "td", 19381 "vulnerability_alerts": "va", 19382 "workflows": "w" 19383 }, 19384 "created_at": ` + referenceTimeStr + `, 19385 "updated_at": ` + referenceTimeStr + `, 19386 "has_multiple_single_files": false, 19387 "suspended_by": { 19388 "login": "l", 19389 "id": 1, 19390 "avatar_url": "a", 19391 "gravatar_id": "g", 19392 "name": "n", 19393 "company": "c", 19394 "blog": "b", 19395 "location": "l", 19396 "email": "e", 19397 "hireable": true, 19398 "bio": "b", 19399 "twitter_username": "t", 19400 "public_repos": 1, 19401 "followers": 1, 19402 "following": 1, 19403 "created_at": ` + referenceTimeStr + `, 19404 "suspended_at": ` + referenceTimeStr + `, 19405 "url": "u" 19406 }, 19407 "suspended_at": ` + referenceTimeStr + ` 19408 }, 19409 "organization": { 19410 "name": "n", 19411 "company": "c", 19412 "blog": "b", 19413 "location": "loc", 19414 "email": "e", 19415 "twitter_username": "tu", 19416 "description": "d", 19417 "billing_email": "be", 19418 "is_verified": true, 19419 "has_organization_projects": true, 19420 "has_repository_projects": true, 19421 "default_repository_permission": "drp", 19422 "members_can_create_repositories": true, 19423 "members_can_create_public_repositories": false, 19424 "members_can_create_private_repositories": true, 19425 "members_can_create_internal_repositories": true, 19426 "members_allowed_repository_creation_type": "marct", 19427 "members_can_create_pages": true, 19428 "members_can_create_public_pages": false, 19429 "members_can_create_private_pages": true 19430 }, 19431 "repository": { 19432 "id": 1, 19433 "url": "s", 19434 "name": "n" 19435 }, 19436 "sender": { 19437 "login": "l", 19438 "id": 1, 19439 "node_id": "n", 19440 "avatar_url": "a", 19441 "url": "u", 19442 "events_url": "e", 19443 "repos_url": "r" 19444 } 19445 }` 19446 19447 testJSONMarshal(t, u, want) 19448 } 19449 19450 func TestSecurityAndAnalysisEvent_Marshal(t *testing.T) { 19451 t.Parallel() 19452 testJSONMarshal(t, &SecurityAndAnalysisEvent{}, "{}") 19453 19454 u := &SecurityAndAnalysisEvent{ 19455 Changes: &SecurityAndAnalysisChange{ 19456 From: &SecurityAndAnalysisChangeFrom{ 19457 SecurityAndAnalysis: &SecurityAndAnalysis{ 19458 AdvancedSecurity: &AdvancedSecurity{ 19459 Status: Ptr("enabled"), 19460 }, 19461 SecretScanning: &SecretScanning{ 19462 Status: Ptr("enabled"), 19463 }, 19464 SecretScanningPushProtection: &SecretScanningPushProtection{ 19465 Status: Ptr("enabled"), 19466 }, 19467 DependabotSecurityUpdates: &DependabotSecurityUpdates{ 19468 Status: Ptr("enabled"), 19469 }, 19470 }, 19471 }, 19472 }, 19473 Enterprise: &Enterprise{ 19474 ID: Ptr(1), 19475 Slug: Ptr("s"), 19476 Name: Ptr("n"), 19477 NodeID: Ptr("nid"), 19478 AvatarURL: Ptr("au"), 19479 Description: Ptr("d"), 19480 WebsiteURL: Ptr("wu"), 19481 HTMLURL: Ptr("hu"), 19482 CreatedAt: &Timestamp{referenceTime}, 19483 UpdatedAt: &Timestamp{referenceTime}, 19484 }, 19485 Installation: &Installation{ 19486 ID: Ptr(int64(1)), 19487 NodeID: Ptr("nid"), 19488 AppID: Ptr(int64(1)), 19489 AppSlug: Ptr("as"), 19490 TargetID: Ptr(int64(1)), 19491 Account: &User{ 19492 Login: Ptr("l"), 19493 ID: Ptr(int64(1)), 19494 URL: Ptr("u"), 19495 AvatarURL: Ptr("a"), 19496 GravatarID: Ptr("g"), 19497 Name: Ptr("n"), 19498 Company: Ptr("c"), 19499 Blog: Ptr("b"), 19500 Location: Ptr("l"), 19501 Email: Ptr("e"), 19502 Hireable: Ptr(true), 19503 Bio: Ptr("b"), 19504 TwitterUsername: Ptr("t"), 19505 PublicRepos: Ptr(1), 19506 Followers: Ptr(1), 19507 Following: Ptr(1), 19508 CreatedAt: &Timestamp{referenceTime}, 19509 SuspendedAt: &Timestamp{referenceTime}, 19510 }, 19511 AccessTokensURL: Ptr("atu"), 19512 RepositoriesURL: Ptr("ru"), 19513 HTMLURL: Ptr("hu"), 19514 TargetType: Ptr("tt"), 19515 SingleFileName: Ptr("sfn"), 19516 RepositorySelection: Ptr("rs"), 19517 Events: []string{"e"}, 19518 SingleFilePaths: []string{"s"}, 19519 Permissions: &InstallationPermissions{ 19520 Actions: Ptr("a"), 19521 Administration: Ptr("ad"), 19522 Checks: Ptr("c"), 19523 Contents: Ptr("co"), 19524 ContentReferences: Ptr("cr"), 19525 Deployments: Ptr("d"), 19526 Environments: Ptr("e"), 19527 Issues: Ptr("i"), 19528 Metadata: Ptr("md"), 19529 Members: Ptr("m"), 19530 OrganizationAdministration: Ptr("oa"), 19531 OrganizationHooks: Ptr("oh"), 19532 OrganizationPlan: Ptr("op"), 19533 OrganizationPreReceiveHooks: Ptr("opr"), 19534 OrganizationProjects: Ptr("op"), 19535 OrganizationSecrets: Ptr("os"), 19536 OrganizationSelfHostedRunners: Ptr("osh"), 19537 OrganizationUserBlocking: Ptr("oub"), 19538 Packages: Ptr("pkg"), 19539 Pages: Ptr("pg"), 19540 PullRequests: Ptr("pr"), 19541 RepositoryHooks: Ptr("rh"), 19542 RepositoryProjects: Ptr("rp"), 19543 RepositoryPreReceiveHooks: Ptr("rprh"), 19544 Secrets: Ptr("s"), 19545 SecretScanningAlerts: Ptr("ssa"), 19546 SecurityEvents: Ptr("se"), 19547 SingleFile: Ptr("sf"), 19548 Statuses: Ptr("s"), 19549 TeamDiscussions: Ptr("td"), 19550 VulnerabilityAlerts: Ptr("va"), 19551 Workflows: Ptr("w"), 19552 }, 19553 CreatedAt: &Timestamp{referenceTime}, 19554 UpdatedAt: &Timestamp{referenceTime}, 19555 HasMultipleSingleFiles: Ptr(false), 19556 SuspendedBy: &User{ 19557 Login: Ptr("l"), 19558 ID: Ptr(int64(1)), 19559 URL: Ptr("u"), 19560 AvatarURL: Ptr("a"), 19561 GravatarID: Ptr("g"), 19562 Name: Ptr("n"), 19563 Company: Ptr("c"), 19564 Blog: Ptr("b"), 19565 Location: Ptr("l"), 19566 Email: Ptr("e"), 19567 Hireable: Ptr(true), 19568 Bio: Ptr("b"), 19569 TwitterUsername: Ptr("t"), 19570 PublicRepos: Ptr(1), 19571 Followers: Ptr(1), 19572 Following: Ptr(1), 19573 CreatedAt: &Timestamp{referenceTime}, 19574 SuspendedAt: &Timestamp{referenceTime}, 19575 }, 19576 SuspendedAt: &Timestamp{referenceTime}, 19577 }, 19578 Organization: &Organization{ 19579 BillingEmail: Ptr("be"), 19580 Blog: Ptr("b"), 19581 Company: Ptr("c"), 19582 Email: Ptr("e"), 19583 TwitterUsername: Ptr("tu"), 19584 Location: Ptr("loc"), 19585 Name: Ptr("n"), 19586 Description: Ptr("d"), 19587 IsVerified: Ptr(true), 19588 HasOrganizationProjects: Ptr(true), 19589 HasRepositoryProjects: Ptr(true), 19590 DefaultRepoPermission: Ptr("drp"), 19591 MembersCanCreateRepos: Ptr(true), 19592 MembersCanCreateInternalRepos: Ptr(true), 19593 MembersCanCreatePrivateRepos: Ptr(true), 19594 MembersCanCreatePublicRepos: Ptr(false), 19595 MembersAllowedRepositoryCreationType: Ptr("marct"), 19596 MembersCanCreatePages: Ptr(true), 19597 MembersCanCreatePublicPages: Ptr(false), 19598 MembersCanCreatePrivatePages: Ptr(true), 19599 }, 19600 Repository: &Repository{ 19601 ID: Ptr(int64(1)), 19602 URL: Ptr("s"), 19603 Name: Ptr("n"), 19604 }, 19605 Sender: &User{ 19606 Login: Ptr("l"), 19607 ID: Ptr(int64(1)), 19608 NodeID: Ptr("n"), 19609 URL: Ptr("u"), 19610 ReposURL: Ptr("r"), 19611 EventsURL: Ptr("e"), 19612 AvatarURL: Ptr("a"), 19613 }, 19614 } 19615 19616 want := `{ 19617 "changes": { 19618 "from": { 19619 "security_and_analysis": { 19620 "advanced_security": { 19621 "status": "enabled" 19622 }, 19623 "secret_scanning": { 19624 "status": "enabled" 19625 }, 19626 "secret_scanning_push_protection": { 19627 "status": "enabled" 19628 }, 19629 "dependabot_security_updates": { 19630 "status": "enabled" 19631 } 19632 } 19633 } 19634 }, 19635 "enterprise": { 19636 "id": 1, 19637 "slug": "s", 19638 "name": "n", 19639 "node_id": "nid", 19640 "avatar_url": "au", 19641 "description": "d", 19642 "website_url": "wu", 19643 "html_url": "hu", 19644 "created_at": ` + referenceTimeStr + `, 19645 "updated_at": ` + referenceTimeStr + ` 19646 }, 19647 "installation": { 19648 "id": 1, 19649 "node_id": "nid", 19650 "app_id": 1, 19651 "app_slug": "as", 19652 "target_id": 1, 19653 "account": { 19654 "login": "l", 19655 "id": 1, 19656 "avatar_url": "a", 19657 "gravatar_id": "g", 19658 "name": "n", 19659 "company": "c", 19660 "blog": "b", 19661 "location": "l", 19662 "email": "e", 19663 "hireable": true, 19664 "bio": "b", 19665 "twitter_username": "t", 19666 "public_repos": 1, 19667 "followers": 1, 19668 "following": 1, 19669 "created_at": ` + referenceTimeStr + `, 19670 "suspended_at": ` + referenceTimeStr + `, 19671 "url": "u" 19672 }, 19673 "access_tokens_url": "atu", 19674 "repositories_url": "ru", 19675 "html_url": "hu", 19676 "target_type": "tt", 19677 "single_file_name": "sfn", 19678 "repository_selection": "rs", 19679 "events": [ 19680 "e" 19681 ], 19682 "single_file_paths": [ 19683 "s" 19684 ], 19685 "permissions": { 19686 "actions": "a", 19687 "administration": "ad", 19688 "checks": "c", 19689 "contents": "co", 19690 "content_references": "cr", 19691 "deployments": "d", 19692 "environments": "e", 19693 "issues": "i", 19694 "metadata": "md", 19695 "members": "m", 19696 "organization_administration": "oa", 19697 "organization_hooks": "oh", 19698 "organization_plan": "op", 19699 "organization_pre_receive_hooks": "opr", 19700 "organization_projects": "op", 19701 "organization_secrets": "os", 19702 "organization_self_hosted_runners": "osh", 19703 "organization_user_blocking": "oub", 19704 "packages": "pkg", 19705 "pages": "pg", 19706 "pull_requests": "pr", 19707 "repository_hooks": "rh", 19708 "repository_projects": "rp", 19709 "repository_pre_receive_hooks": "rprh", 19710 "secrets": "s", 19711 "secret_scanning_alerts": "ssa", 19712 "security_events": "se", 19713 "single_file": "sf", 19714 "statuses": "s", 19715 "team_discussions": "td", 19716 "vulnerability_alerts": "va", 19717 "workflows": "w" 19718 }, 19719 "created_at": ` + referenceTimeStr + `, 19720 "updated_at": ` + referenceTimeStr + `, 19721 "has_multiple_single_files": false, 19722 "suspended_by": { 19723 "login": "l", 19724 "id": 1, 19725 "avatar_url": "a", 19726 "gravatar_id": "g", 19727 "name": "n", 19728 "company": "c", 19729 "blog": "b", 19730 "location": "l", 19731 "email": "e", 19732 "hireable": true, 19733 "bio": "b", 19734 "twitter_username": "t", 19735 "public_repos": 1, 19736 "followers": 1, 19737 "following": 1, 19738 "created_at": ` + referenceTimeStr + `, 19739 "suspended_at": ` + referenceTimeStr + `, 19740 "url": "u" 19741 }, 19742 "suspended_at": ` + referenceTimeStr + ` 19743 }, 19744 "organization": { 19745 "name": "n", 19746 "company": "c", 19747 "blog": "b", 19748 "location": "loc", 19749 "email": "e", 19750 "twitter_username": "tu", 19751 "description": "d", 19752 "billing_email": "be", 19753 "is_verified": true, 19754 "has_organization_projects": true, 19755 "has_repository_projects": true, 19756 "default_repository_permission": "drp", 19757 "members_can_create_repositories": true, 19758 "members_can_create_public_repositories": false, 19759 "members_can_create_private_repositories": true, 19760 "members_can_create_internal_repositories": true, 19761 "members_allowed_repository_creation_type": "marct", 19762 "members_can_create_pages": true, 19763 "members_can_create_public_pages": false, 19764 "members_can_create_private_pages": true 19765 }, 19766 "repository": { 19767 "id": 1, 19768 "url": "s", 19769 "name": "n" 19770 }, 19771 "sender": { 19772 "login": "l", 19773 "id": 1, 19774 "node_id": "n", 19775 "avatar_url": "a", 19776 "url": "u", 19777 "events_url": "e", 19778 "repos_url": "r" 19779 }, 19780 "target_type": "running" 19781 }` 19782 19783 testJSONMarshal(t, u, want) 19784 } 19785 19786 func TestCodeScanningAlertEvent_Marshal(t *testing.T) { 19787 t.Parallel() 19788 testJSONMarshal(t, &CodeScanningAlertEvent{}, "{}") 19789 19790 u := &CodeScanningAlertEvent{ 19791 Action: Ptr("reopened"), 19792 Alert: &Alert{ 19793 Number: Ptr(10), 19794 Rule: &Rule{ 19795 ID: Ptr("Style/FrozenStringLiteralComment"), 19796 Severity: Ptr("note"), 19797 Description: Ptr("desc"), 19798 FullDescription: Ptr("full desc"), 19799 Tags: []string{"style"}, 19800 Help: Ptr("help"), 19801 }, 19802 Tool: &Tool{ 19803 Name: Ptr("Rubocop"), 19804 Version: nil, 19805 }, 19806 CreatedAt: &Timestamp{referenceTime}, 19807 UpdatedAt: &Timestamp{referenceTime}, 19808 FixedAt: nil, 19809 State: Ptr("open"), 19810 URL: Ptr("a"), 19811 HTMLURL: Ptr("a"), 19812 Instances: []*MostRecentInstance{ 19813 { 19814 Ref: Ptr("refs/heads/main"), 19815 AnalysisKey: Ptr(".github/workflows/workflow.yml:upload"), 19816 Environment: Ptr("{}"), 19817 State: Ptr("open"), 19818 }, 19819 }, 19820 DismissedBy: nil, 19821 DismissedAt: nil, 19822 DismissedReason: nil, 19823 }, 19824 Ref: Ptr("refs/heads/main"), 19825 CommitOID: Ptr("d6e4c75c141dbacecc279b721b8bsomeSHA"), 19826 Repo: &Repository{ 19827 ID: Ptr(int64(1234234535)), 19828 NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxODY4NT=="), 19829 Owner: &User{ 19830 Login: Ptr("Codertocat"), 19831 ID: Ptr(int64(21031067)), 19832 NodeID: Ptr("MDQ6VXNlcjIxMDMxMDY3"), 19833 AvatarURL: Ptr("a"), 19834 GravatarID: Ptr(""), 19835 URL: Ptr("a"), 19836 HTMLURL: Ptr("a"), 19837 Type: Ptr("User"), 19838 SiteAdmin: Ptr(false), 19839 FollowersURL: Ptr("a"), 19840 FollowingURL: Ptr("a"), 19841 EventsURL: Ptr("a"), 19842 GistsURL: Ptr("a"), 19843 OrganizationsURL: Ptr("a"), 19844 ReceivedEventsURL: Ptr("a"), 19845 ReposURL: Ptr("a"), 19846 StarredURL: Ptr("a"), 19847 SubscriptionsURL: Ptr("a"), 19848 }, 19849 HTMLURL: Ptr("a"), 19850 Name: Ptr("Hello-World"), 19851 FullName: Ptr("Codertocat/Hello-World"), 19852 Description: nil, 19853 Fork: Ptr(false), 19854 Homepage: nil, 19855 DefaultBranch: Ptr("main"), 19856 CreatedAt: &Timestamp{referenceTime}, 19857 PushedAt: &Timestamp{referenceTime}, 19858 UpdatedAt: &Timestamp{referenceTime}, 19859 CloneURL: Ptr("a"), 19860 GitURL: Ptr("a"), 19861 MirrorURL: nil, 19862 SSHURL: Ptr("a"), 19863 SVNURL: Ptr("a"), 19864 Language: nil, 19865 ForksCount: Ptr(0), 19866 OpenIssuesCount: Ptr(2), 19867 OpenIssues: Ptr(2), 19868 StargazersCount: Ptr(0), 19869 WatchersCount: Ptr(0), 19870 Watchers: Ptr(0), 19871 Size: Ptr(0), 19872 Archived: Ptr(false), 19873 Disabled: Ptr(false), 19874 License: nil, 19875 Private: Ptr(false), 19876 HasIssues: Ptr(true), 19877 HasWiki: Ptr(true), 19878 HasPages: Ptr(true), 19879 HasProjects: Ptr(true), 19880 HasDownloads: Ptr(true), 19881 URL: Ptr("a"), 19882 ArchiveURL: Ptr("a"), 19883 AssigneesURL: Ptr("a"), 19884 BlobsURL: Ptr("a"), 19885 BranchesURL: Ptr("a"), 19886 CollaboratorsURL: Ptr("a"), 19887 CommentsURL: Ptr("a"), 19888 CommitsURL: Ptr("a"), 19889 CompareURL: Ptr("a"), 19890 ContentsURL: Ptr("a"), 19891 ContributorsURL: Ptr("a"), 19892 DeploymentsURL: Ptr("a"), 19893 DownloadsURL: Ptr("a"), 19894 EventsURL: Ptr("a"), 19895 ForksURL: Ptr("a"), 19896 GitCommitsURL: Ptr("a"), 19897 GitRefsURL: Ptr("a"), 19898 GitTagsURL: Ptr("a"), 19899 HooksURL: Ptr("a"), 19900 IssueCommentURL: Ptr("a"), 19901 IssueEventsURL: Ptr("a"), 19902 IssuesURL: Ptr("a"), 19903 KeysURL: Ptr("a"), 19904 LabelsURL: Ptr("a"), 19905 LanguagesURL: Ptr("a"), 19906 MergesURL: Ptr("a"), 19907 MilestonesURL: Ptr("a"), 19908 NotificationsURL: Ptr("a"), 19909 PullsURL: Ptr("a"), 19910 ReleasesURL: Ptr("a"), 19911 StargazersURL: Ptr("a"), 19912 StatusesURL: Ptr("a"), 19913 SubscribersURL: Ptr("a"), 19914 SubscriptionURL: Ptr("a"), 19915 TagsURL: Ptr("a"), 19916 TreesURL: Ptr("a"), 19917 TeamsURL: Ptr("a"), 19918 }, 19919 Org: &Organization{ 19920 Login: Ptr("Octocoders"), 19921 ID: Ptr(int64(6)), 19922 NodeID: Ptr("MDEyOk9yZ2FuaXphdGlvbjY="), 19923 AvatarURL: Ptr("a"), 19924 Description: Ptr(""), 19925 URL: Ptr("a"), 19926 EventsURL: Ptr("a"), 19927 HooksURL: Ptr("a"), 19928 IssuesURL: Ptr("a"), 19929 MembersURL: Ptr("a"), 19930 PublicMembersURL: Ptr("a"), 19931 ReposURL: Ptr("a"), 19932 }, 19933 Sender: &User{ 19934 Login: Ptr("github"), 19935 ID: Ptr(int64(9919)), 19936 NodeID: Ptr("MDEyOk9yZ2FuaXphdGlvbjk5MTk="), 19937 AvatarURL: Ptr("a"), 19938 HTMLURL: Ptr("a"), 19939 GravatarID: Ptr(""), 19940 Type: Ptr("Organization"), 19941 SiteAdmin: Ptr(false), 19942 URL: Ptr("a"), 19943 EventsURL: Ptr("a"), 19944 FollowingURL: Ptr("a"), 19945 FollowersURL: Ptr("a"), 19946 GistsURL: Ptr("a"), 19947 OrganizationsURL: Ptr("a"), 19948 ReceivedEventsURL: Ptr("a"), 19949 ReposURL: Ptr("a"), 19950 StarredURL: Ptr("a"), 19951 SubscriptionsURL: Ptr("a"), 19952 }, 19953 } 19954 19955 want := `{ 19956 "action": "reopened", 19957 "alert": { 19958 "number": 10, 19959 "created_at": ` + referenceTimeStr + `, 19960 "updated_at": ` + referenceTimeStr + `, 19961 "url": "a", 19962 "html_url": "a", 19963 "instances": [ 19964 { 19965 "ref": "refs/heads/main", 19966 "analysis_key": ".github/workflows/workflow.yml:upload", 19967 "environment": "{}", 19968 "state": "open" 19969 } 19970 ], 19971 "state": "open", 19972 "fixed_at": null, 19973 "dismissed_by": null, 19974 "dismissed_at": null, 19975 "dismissed_reason": null, 19976 "rule": { 19977 "id": "Style/FrozenStringLiteralComment", 19978 "severity": "note", 19979 "description": "desc", 19980 "full_description": "full desc", 19981 "tags": [ 19982 "style" 19983 ], 19984 "help": "help" 19985 }, 19986 "tool": { 19987 "name": "Rubocop", 19988 "version": null 19989 } 19990 }, 19991 "ref": "refs/heads/main", 19992 "commit_oid": "d6e4c75c141dbacecc279b721b8bsomeSHA", 19993 "repository": { 19994 "id": 1234234535, 19995 "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NT==", 19996 "name": "Hello-World", 19997 "full_name": "Codertocat/Hello-World", 19998 "private": false, 19999 "owner": { 20000 "login": "Codertocat", 20001 "id": 21031067, 20002 "node_id": "MDQ6VXNlcjIxMDMxMDY3", 20003 "avatar_url": "a", 20004 "gravatar_id": "", 20005 "url": "a", 20006 "html_url": "a", 20007 "followers_url": "a", 20008 "following_url": "a", 20009 "gists_url": "a", 20010 "starred_url": "a", 20011 "subscriptions_url": "a", 20012 "organizations_url": "a", 20013 "repos_url": "a", 20014 "events_url": "a", 20015 "received_events_url": "a", 20016 "type": "User", 20017 "site_admin": false 20018 }, 20019 "html_url": "a", 20020 "description": null, 20021 "fork": false, 20022 "url": "a", 20023 "forks_url": "a", 20024 "keys_url": "a", 20025 "collaborators_url": "a", 20026 "teams_url": "a", 20027 "hooks_url": "a", 20028 "issue_events_url": "a", 20029 "events_url": "a", 20030 "assignees_url": "a", 20031 "branches_url": "a", 20032 "tags_url": "a", 20033 "blobs_url": "a", 20034 "git_tags_url": "a", 20035 "git_refs_url": "a", 20036 "trees_url": "a", 20037 "statuses_url": "a", 20038 "languages_url": "a", 20039 "stargazers_url": "a", 20040 "contributors_url": "a", 20041 "subscribers_url": "a", 20042 "subscription_url": "a", 20043 "commits_url": "a", 20044 "git_commits_url": "a", 20045 "comments_url": "a", 20046 "issue_comment_url": "a", 20047 "contents_url": "a", 20048 "compare_url": "a", 20049 "merges_url": "a", 20050 "archive_url": "a", 20051 "downloads_url": "a", 20052 "issues_url": "a", 20053 "pulls_url": "a", 20054 "milestones_url": "a", 20055 "notifications_url": "a", 20056 "labels_url": "a", 20057 "releases_url": "a", 20058 "deployments_url": "a", 20059 "created_at": ` + referenceTimeStr + `, 20060 "updated_at": ` + referenceTimeStr + `, 20061 "pushed_at": ` + referenceTimeStr + `, 20062 "git_url": "a", 20063 "ssh_url": "a", 20064 "clone_url": "a", 20065 "svn_url": "a", 20066 "homepage": null, 20067 "size": 0, 20068 "stargazers_count": 0, 20069 "watchers_count": 0, 20070 "language": null, 20071 "has_issues": true, 20072 "has_projects": true, 20073 "has_downloads": true, 20074 "has_wiki": true, 20075 "has_pages": true, 20076 "forks_count": 0, 20077 "mirror_url": null, 20078 "archived": false, 20079 "disabled": false, 20080 "open_issues_count": 2, 20081 "license": null, 20082 "forks": 0, 20083 "open_issues": 2, 20084 "watchers": 0, 20085 "default_branch": "main" 20086 }, 20087 "organization": { 20088 "login": "Octocoders", 20089 "id": 6, 20090 "node_id": "MDEyOk9yZ2FuaXphdGlvbjY=", 20091 "url": "a", 20092 "repos_url": "a", 20093 "events_url": "a", 20094 "hooks_url": "a", 20095 "issues_url": "a", 20096 "members_url": "a", 20097 "public_members_url": "a", 20098 "avatar_url": "a", 20099 "description": "" 20100 }, 20101 "sender": { 20102 "login": "github", 20103 "id": 9919, 20104 "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", 20105 "avatar_url": "a", 20106 "gravatar_id": "", 20107 "url": "a", 20108 "html_url": "a", 20109 "followers_url": "a", 20110 "following_url": "a", 20111 "gists_url": "a", 20112 "starred_url": "a", 20113 "subscriptions_url": "a", 20114 "organizations_url": "a", 20115 "repos_url": "a", 20116 "events_url": "a", 20117 "received_events_url": "a", 20118 "type": "Organization", 20119 "site_admin": false 20120 } 20121 }` 20122 20123 testJSONMarshal(t, u, want) 20124 } 20125 20126 func TestSponsorshipEvent_Marshal(t *testing.T) { 20127 t.Parallel() 20128 testJSONMarshal(t, &SponsorshipEvent{}, "{}") 20129 20130 u := &SponsorshipEvent{ 20131 Action: Ptr("created"), 20132 EffectiveDate: Ptr("2023-01-01T00:00:00Z"), 20133 Changes: &SponsorshipChanges{ 20134 Tier: &SponsorshipTier{ 20135 From: Ptr("basic"), 20136 }, 20137 PrivacyLevel: Ptr("public"), 20138 }, 20139 Repository: &Repository{ 20140 ID: Ptr(int64(12345)), 20141 NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjM0NQ=="), 20142 Name: Ptr("example-repo"), 20143 }, 20144 Organization: &Organization{ 20145 Login: Ptr("example-org"), 20146 ID: Ptr(int64(67890)), 20147 }, 20148 Sender: &User{ 20149 Login: Ptr("example-user"), 20150 ID: Ptr(int64(1111)), 20151 }, 20152 Installation: &Installation{ 20153 ID: Ptr(int64(2222)), 20154 }, 20155 } 20156 20157 want := `{ 20158 "action": "created", 20159 "effective_date": "2023-01-01T00:00:00Z", 20160 "changes": { 20161 "tier": { 20162 "from": "basic" 20163 }, 20164 "privacy_level": "public" 20165 }, 20166 "repository": { 20167 "id": 12345, 20168 "node_id": "MDEwOlJlcG9zaXRvcnkxMjM0NQ==", 20169 "name": "example-repo" 20170 }, 20171 "organization": { 20172 "login": "example-org", 20173 "id": 67890 20174 }, 20175 "sender": { 20176 "login": "example-user", 20177 "id": 1111 20178 }, 20179 "installation": { 20180 "id": 2222 20181 } 20182 }` 20183 20184 testJSONMarshal(t, u, want) 20185 } 20186 20187 func TestSponsorshipChanges_Marshal(t *testing.T) { 20188 t.Parallel() 20189 testJSONMarshal(t, &SponsorshipChanges{}, "{}") 20190 20191 u := &SponsorshipChanges{ 20192 Tier: &SponsorshipTier{ 20193 From: Ptr("premium"), 20194 }, 20195 PrivacyLevel: Ptr("private"), 20196 } 20197 20198 want := `{ 20199 "tier": { 20200 "from": "premium" 20201 }, 20202 "privacy_level": "private" 20203 }` 20204 20205 testJSONMarshal(t, u, want) 20206 } 20207 20208 func TestSponsorshipTier_Marshal(t *testing.T) { 20209 t.Parallel() 20210 testJSONMarshal(t, &SponsorshipTier{}, "{}") 20211 20212 u := &SponsorshipTier{ 20213 From: Ptr("gold"), 20214 } 20215 20216 want := `{ 20217 "from": "gold" 20218 }` 20219 20220 testJSONMarshal(t, u, want) 20221 }