github.com/google/go-github/v74@v74.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 "fmt" 11 "testing" 12 13 "github.com/google/go-cmp/cmp" 14 ) 15 16 func TestEditChange_Marshal_TitleChange(t *testing.T) { 17 t.Parallel() 18 testJSONMarshal(t, &EditChange{}, "{}") 19 20 u := &EditChange{ 21 Title: &EditTitle{ 22 From: Ptr("TitleFrom"), 23 }, 24 Body: nil, 25 Base: nil, 26 } 27 28 want := `{ 29 "title": { 30 "from": "TitleFrom" 31 } 32 }` 33 34 testJSONMarshal(t, u, want) 35 } 36 37 func TestEditChange_Marshal_BodyChange(t *testing.T) { 38 t.Parallel() 39 testJSONMarshal(t, &EditChange{}, "{}") 40 41 u := &EditChange{ 42 Title: nil, 43 Body: &EditBody{ 44 From: Ptr("BodyFrom"), 45 }, 46 Base: nil, 47 } 48 49 want := `{ 50 "body": { 51 "from": "BodyFrom" 52 } 53 }` 54 55 testJSONMarshal(t, u, want) 56 } 57 58 func TestEditChange_Marshal_BaseChange(t *testing.T) { 59 t.Parallel() 60 testJSONMarshal(t, &EditChange{}, "{}") 61 62 base := EditBase{ 63 Ref: &EditRef{ 64 From: Ptr("BaseRefFrom"), 65 }, 66 SHA: &EditSHA{ 67 From: Ptr("BaseSHAFrom"), 68 }, 69 } 70 71 u := &EditChange{ 72 Title: nil, 73 Body: nil, 74 Base: &base, 75 } 76 77 want := `{ 78 "base": { 79 "ref": { 80 "from": "BaseRefFrom" 81 }, 82 "sha": { 83 "from": "BaseSHAFrom" 84 } 85 } 86 }` 87 88 testJSONMarshal(t, u, want) 89 } 90 91 func TestEditChange_Marshal_Repo(t *testing.T) { 92 t.Parallel() 93 testJSONMarshal(t, &EditChange{}, "{}") 94 95 u := &EditChange{ 96 Repo: &EditRepo{ 97 Name: &RepoName{ 98 From: Ptr("old-repo-name"), 99 }, 100 }, 101 Topics: &EditTopics{ 102 From: []string{"topic1", "topic2"}, 103 }, 104 } 105 106 want := `{ 107 "repository": { 108 "name": { 109 "from": "old-repo-name" 110 } 111 }, 112 "topics": { 113 "from": [ 114 "topic1", 115 "topic2" 116 ] 117 } 118 }` 119 120 testJSONMarshal(t, u, want) 121 } 122 123 func TestEditChange_Marshal_TransferFromUser(t *testing.T) { 124 t.Parallel() 125 testJSONMarshal(t, &EditChange{}, "{}") 126 127 u := &EditChange{ 128 Owner: &EditOwner{ 129 OwnerInfo: &OwnerInfo{ 130 User: &User{ 131 Login: Ptr("l"), 132 ID: Ptr(int64(1)), 133 NodeID: Ptr("n"), 134 URL: Ptr("u"), 135 ReposURL: Ptr("r"), 136 EventsURL: Ptr("e"), 137 AvatarURL: Ptr("a"), 138 }, 139 }, 140 }, 141 } 142 143 want := `{ 144 "owner": { 145 "from": { 146 "user": { 147 "login": "l", 148 "id": 1, 149 "node_id": "n", 150 "avatar_url": "a", 151 "url": "u", 152 "repos_url": "r", 153 "events_url": "e" 154 } 155 } 156 } 157 }` 158 159 testJSONMarshal(t, u, want) 160 } 161 162 func TestEditChange_Marshal_TransferFromOrg(t *testing.T) { 163 t.Parallel() 164 testJSONMarshal(t, &EditChange{}, "{}") 165 166 u := &EditChange{ 167 Owner: &EditOwner{ 168 OwnerInfo: &OwnerInfo{ 169 Org: &User{ 170 Login: Ptr("l"), 171 ID: Ptr(int64(1)), 172 NodeID: Ptr("n"), 173 URL: Ptr("u"), 174 ReposURL: Ptr("r"), 175 EventsURL: Ptr("e"), 176 AvatarURL: Ptr("a"), 177 }, 178 }, 179 }, 180 } 181 182 want := `{ 183 "owner": { 184 "from": { 185 "organization": { 186 "login": "l", 187 "id": 1, 188 "node_id": "n", 189 "avatar_url": "a", 190 "url": "u", 191 "repos_url": "r", 192 "events_url": "e" 193 } 194 } 195 } 196 }` 197 198 testJSONMarshal(t, u, want) 199 } 200 201 func TestProjectChange_Marshal_NameChange(t *testing.T) { 202 t.Parallel() 203 testJSONMarshal(t, &ProjectChange{}, "{}") 204 205 u := &ProjectChange{ 206 Name: &ProjectName{From: Ptr("NameFrom")}, 207 Body: nil, 208 } 209 210 want := `{ 211 "name": { 212 "from": "NameFrom" 213 } 214 }` 215 216 testJSONMarshal(t, u, want) 217 } 218 219 func TestProjectChange_Marshal_BodyChange(t *testing.T) { 220 t.Parallel() 221 testJSONMarshal(t, &ProjectChange{}, "{}") 222 223 u := &ProjectChange{ 224 Name: nil, 225 Body: &ProjectBody{From: Ptr("BodyFrom")}, 226 } 227 228 want := `{ 229 "body": { 230 "from": "BodyFrom" 231 } 232 }` 233 234 testJSONMarshal(t, u, want) 235 } 236 237 func TestProjectCardChange_Marshal_NoteChange(t *testing.T) { 238 t.Parallel() 239 testJSONMarshal(t, &ProjectCardChange{}, "{}") 240 241 u := &ProjectCardChange{ 242 Note: &ProjectCardNote{From: Ptr("NoteFrom")}, 243 } 244 245 want := `{ 246 "note": { 247 "from": "NoteFrom" 248 } 249 }` 250 251 testJSONMarshal(t, u, want) 252 } 253 254 func TestProjectColumnChange_Marshal_NameChange(t *testing.T) { 255 t.Parallel() 256 testJSONMarshal(t, &ProjectColumnChange{}, "{}") 257 258 u := &ProjectColumnChange{ 259 Name: &ProjectColumnName{From: Ptr("NameFrom")}, 260 } 261 262 want := `{ 263 "name": { 264 "from": "NameFrom" 265 } 266 }` 267 268 testJSONMarshal(t, u, want) 269 } 270 271 func TestBranchProtectionConfigurationEvent_Marshal(t *testing.T) { 272 t.Parallel() 273 testJSONMarshal(t, &BranchProtectionConfigurationEvent{}, "{}") 274 u := &BranchProtectionConfigurationEvent{ 275 Action: Ptr("enabled"), 276 Repo: &Repository{ 277 ID: Ptr(int64(12345)), 278 NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjM0NQ=="), 279 Name: Ptr("example-repo"), 280 }, 281 Org: &Organization{ 282 Login: Ptr("example-org"), 283 ID: Ptr(int64(67890)), 284 }, 285 Sender: &User{ 286 Login: Ptr("example-user"), 287 ID: Ptr(int64(1111)), 288 }, 289 Installation: &Installation{ 290 ID: Ptr(int64(2222)), 291 }, 292 Enterprise: &Enterprise{ 293 ID: Ptr(3333), 294 Slug: Ptr("example-enterprise"), 295 Name: Ptr("Example Enterprise"), 296 }, 297 } 298 299 want := `{ 300 "action": "enabled", 301 "repository": { 302 "id": 12345, 303 "node_id": "MDEwOlJlcG9zaXRvcnkxMjM0NQ==", 304 "name": "example-repo" 305 }, 306 "organization": { 307 "login": "example-org", 308 "id": 67890 309 }, 310 "sender": { 311 "login": "example-user", 312 "id": 1111 313 }, 314 "installation": { 315 "id": 2222 316 }, 317 "enterprise": { 318 "id": 3333, 319 "slug": "example-enterprise", 320 "name": "Example Enterprise" 321 } 322 }` 323 testJSONMarshal(t, u, want) 324 } 325 326 func TestTeamAddEvent_Marshal(t *testing.T) { 327 t.Parallel() 328 testJSONMarshal(t, &TeamAddEvent{}, "{}") 329 330 u := &TeamAddEvent{ 331 Team: &Team{ 332 ID: Ptr(int64(1)), 333 NodeID: Ptr("n"), 334 Name: Ptr("n"), 335 Description: Ptr("d"), 336 URL: Ptr("u"), 337 Slug: Ptr("s"), 338 Permission: Ptr("p"), 339 Privacy: Ptr("p"), 340 MembersCount: Ptr(1), 341 ReposCount: Ptr(1), 342 MembersURL: Ptr("m"), 343 RepositoriesURL: Ptr("r"), 344 Organization: &Organization{ 345 Login: Ptr("l"), 346 ID: Ptr(int64(1)), 347 NodeID: Ptr("n"), 348 AvatarURL: Ptr("a"), 349 HTMLURL: Ptr("h"), 350 Name: Ptr("n"), 351 Company: Ptr("c"), 352 Blog: Ptr("b"), 353 Location: Ptr("l"), 354 Email: Ptr("e"), 355 }, 356 Parent: &Team{ 357 ID: Ptr(int64(1)), 358 NodeID: Ptr("n"), 359 Name: Ptr("n"), 360 Description: Ptr("d"), 361 URL: Ptr("u"), 362 Slug: Ptr("s"), 363 Permission: Ptr("p"), 364 Privacy: Ptr("p"), 365 MembersCount: Ptr(1), 366 ReposCount: Ptr(1), 367 }, 368 LDAPDN: Ptr("l"), 369 }, 370 Repo: &Repository{ 371 ID: Ptr(int64(1)), 372 URL: Ptr("s"), 373 Name: Ptr("n"), 374 }, 375 Org: &Organization{ 376 BillingEmail: Ptr("be"), 377 Blog: Ptr("b"), 378 Company: Ptr("c"), 379 Email: Ptr("e"), 380 TwitterUsername: Ptr("tu"), 381 Location: Ptr("loc"), 382 Name: Ptr("n"), 383 Description: Ptr("d"), 384 IsVerified: Ptr(true), 385 HasOrganizationProjects: Ptr(true), 386 HasRepositoryProjects: Ptr(true), 387 DefaultRepoPermission: Ptr("drp"), 388 MembersCanCreateRepos: Ptr(true), 389 MembersCanCreateInternalRepos: Ptr(true), 390 MembersCanCreatePrivateRepos: Ptr(true), 391 MembersCanCreatePublicRepos: Ptr(false), 392 MembersAllowedRepositoryCreationType: Ptr("marct"), 393 MembersCanCreatePages: Ptr(true), 394 MembersCanCreatePublicPages: Ptr(false), 395 MembersCanCreatePrivatePages: Ptr(true), 396 }, 397 Sender: &User{ 398 Login: Ptr("l"), 399 ID: Ptr(int64(1)), 400 NodeID: Ptr("n"), 401 URL: Ptr("u"), 402 ReposURL: Ptr("r"), 403 EventsURL: Ptr("e"), 404 AvatarURL: Ptr("a"), 405 }, 406 Installation: &Installation{ 407 ID: Ptr(int64(1)), 408 NodeID: Ptr("nid"), 409 AppID: Ptr(int64(1)), 410 AppSlug: Ptr("as"), 411 TargetID: Ptr(int64(1)), 412 Account: &User{ 413 Login: Ptr("l"), 414 ID: Ptr(int64(1)), 415 URL: Ptr("u"), 416 AvatarURL: Ptr("a"), 417 GravatarID: Ptr("g"), 418 Name: Ptr("n"), 419 Company: Ptr("c"), 420 Blog: Ptr("b"), 421 Location: Ptr("l"), 422 Email: Ptr("e"), 423 Hireable: Ptr(true), 424 Bio: Ptr("b"), 425 TwitterUsername: Ptr("t"), 426 PublicRepos: Ptr(1), 427 Followers: Ptr(1), 428 Following: Ptr(1), 429 CreatedAt: &Timestamp{referenceTime}, 430 SuspendedAt: &Timestamp{referenceTime}, 431 }, 432 AccessTokensURL: Ptr("atu"), 433 RepositoriesURL: Ptr("ru"), 434 HTMLURL: Ptr("hu"), 435 TargetType: Ptr("tt"), 436 SingleFileName: Ptr("sfn"), 437 RepositorySelection: Ptr("rs"), 438 Events: []string{"e"}, 439 SingleFilePaths: []string{"s"}, 440 Permissions: &InstallationPermissions{ 441 Actions: Ptr("a"), 442 Administration: Ptr("ad"), 443 Checks: Ptr("c"), 444 Contents: Ptr("co"), 445 ContentReferences: Ptr("cr"), 446 Deployments: Ptr("d"), 447 Environments: Ptr("e"), 448 Issues: Ptr("i"), 449 Metadata: Ptr("md"), 450 Members: Ptr("m"), 451 OrganizationAdministration: Ptr("oa"), 452 OrganizationHooks: Ptr("oh"), 453 OrganizationPlan: Ptr("op"), 454 OrganizationPreReceiveHooks: Ptr("opr"), 455 OrganizationProjects: Ptr("op"), 456 OrganizationSecrets: Ptr("os"), 457 OrganizationSelfHostedRunners: Ptr("osh"), 458 OrganizationUserBlocking: Ptr("oub"), 459 Packages: Ptr("pkg"), 460 Pages: Ptr("pg"), 461 PullRequests: Ptr("pr"), 462 RepositoryHooks: Ptr("rh"), 463 RepositoryProjects: Ptr("rp"), 464 RepositoryPreReceiveHooks: Ptr("rprh"), 465 Secrets: Ptr("s"), 466 SecretScanningAlerts: Ptr("ssa"), 467 SecurityEvents: Ptr("se"), 468 SingleFile: Ptr("sf"), 469 Statuses: Ptr("s"), 470 TeamDiscussions: Ptr("td"), 471 VulnerabilityAlerts: Ptr("va"), 472 Workflows: Ptr("w"), 473 }, 474 CreatedAt: &Timestamp{referenceTime}, 475 UpdatedAt: &Timestamp{referenceTime}, 476 HasMultipleSingleFiles: Ptr(false), 477 SuspendedBy: &User{ 478 Login: Ptr("l"), 479 ID: Ptr(int64(1)), 480 URL: Ptr("u"), 481 AvatarURL: Ptr("a"), 482 GravatarID: Ptr("g"), 483 Name: Ptr("n"), 484 Company: Ptr("c"), 485 Blog: Ptr("b"), 486 Location: Ptr("l"), 487 Email: Ptr("e"), 488 Hireable: Ptr(true), 489 Bio: Ptr("b"), 490 TwitterUsername: Ptr("t"), 491 PublicRepos: Ptr(1), 492 Followers: Ptr(1), 493 Following: Ptr(1), 494 CreatedAt: &Timestamp{referenceTime}, 495 SuspendedAt: &Timestamp{referenceTime}, 496 }, 497 SuspendedAt: &Timestamp{referenceTime}, 498 }, 499 } 500 501 want := `{ 502 "team": { 503 "id": 1, 504 "node_id": "n", 505 "name": "n", 506 "description": "d", 507 "url": "u", 508 "slug": "s", 509 "permission": "p", 510 "privacy": "p", 511 "members_count": 1, 512 "repos_count": 1, 513 "organization": { 514 "login": "l", 515 "id": 1, 516 "node_id": "n", 517 "avatar_url": "a", 518 "html_url": "h", 519 "name": "n", 520 "company": "c", 521 "blog": "b", 522 "location": "l", 523 "email": "e" 524 }, 525 "members_url": "m", 526 "repositories_url": "r", 527 "parent": { 528 "id": 1, 529 "node_id": "n", 530 "name": "n", 531 "description": "d", 532 "url": "u", 533 "slug": "s", 534 "permission": "p", 535 "privacy": "p", 536 "members_count": 1, 537 "repos_count": 1 538 }, 539 "ldap_dn": "l" 540 }, 541 "repository": { 542 "id": 1, 543 "name": "n", 544 "url": "s" 545 }, 546 "organization": { 547 "name": "n", 548 "company": "c", 549 "blog": "b", 550 "location": "loc", 551 "email": "e", 552 "twitter_username": "tu", 553 "description": "d", 554 "billing_email": "be", 555 "is_verified": true, 556 "has_organization_projects": true, 557 "has_repository_projects": true, 558 "default_repository_permission": "drp", 559 "members_can_create_repositories": true, 560 "members_can_create_public_repositories": false, 561 "members_can_create_private_repositories": true, 562 "members_can_create_internal_repositories": true, 563 "members_allowed_repository_creation_type": "marct", 564 "members_can_create_pages": true, 565 "members_can_create_public_pages": false, 566 "members_can_create_private_pages": true 567 }, 568 "sender": { 569 "login": "l", 570 "id": 1, 571 "node_id": "n", 572 "avatar_url": "a", 573 "url": "u", 574 "events_url": "e", 575 "repos_url": "r" 576 }, 577 "installation": { 578 "id": 1, 579 "node_id": "nid", 580 "app_id": 1, 581 "app_slug": "as", 582 "target_id": 1, 583 "account": { 584 "login": "l", 585 "id": 1, 586 "avatar_url": "a", 587 "gravatar_id": "g", 588 "name": "n", 589 "company": "c", 590 "blog": "b", 591 "location": "l", 592 "email": "e", 593 "hireable": true, 594 "bio": "b", 595 "twitter_username": "t", 596 "public_repos": 1, 597 "followers": 1, 598 "following": 1, 599 "created_at": ` + referenceTimeStr + `, 600 "suspended_at": ` + referenceTimeStr + `, 601 "url": "u" 602 }, 603 "access_tokens_url": "atu", 604 "repositories_url": "ru", 605 "html_url": "hu", 606 "target_type": "tt", 607 "single_file_name": "sfn", 608 "repository_selection": "rs", 609 "events": [ 610 "e" 611 ], 612 "single_file_paths": [ 613 "s" 614 ], 615 "permissions": { 616 "actions": "a", 617 "administration": "ad", 618 "checks": "c", 619 "contents": "co", 620 "content_references": "cr", 621 "deployments": "d", 622 "environments": "e", 623 "issues": "i", 624 "metadata": "md", 625 "members": "m", 626 "organization_administration": "oa", 627 "organization_hooks": "oh", 628 "organization_plan": "op", 629 "organization_pre_receive_hooks": "opr", 630 "organization_projects": "op", 631 "organization_secrets": "os", 632 "organization_self_hosted_runners": "osh", 633 "organization_user_blocking": "oub", 634 "packages": "pkg", 635 "pages": "pg", 636 "pull_requests": "pr", 637 "repository_hooks": "rh", 638 "repository_projects": "rp", 639 "repository_pre_receive_hooks": "rprh", 640 "secrets": "s", 641 "secret_scanning_alerts": "ssa", 642 "security_events": "se", 643 "single_file": "sf", 644 "statuses": "s", 645 "team_discussions": "td", 646 "vulnerability_alerts": "va", 647 "workflows": "w" 648 }, 649 "created_at": ` + referenceTimeStr + `, 650 "updated_at": ` + referenceTimeStr + `, 651 "has_multiple_single_files": false, 652 "suspended_by": { 653 "login": "l", 654 "id": 1, 655 "avatar_url": "a", 656 "gravatar_id": "g", 657 "name": "n", 658 "company": "c", 659 "blog": "b", 660 "location": "l", 661 "email": "e", 662 "hireable": true, 663 "bio": "b", 664 "twitter_username": "t", 665 "public_repos": 1, 666 "followers": 1, 667 "following": 1, 668 "created_at": ` + referenceTimeStr + `, 669 "suspended_at": ` + referenceTimeStr + `, 670 "url": "u" 671 }, 672 "suspended_at": ` + referenceTimeStr + ` 673 } 674 }` 675 676 testJSONMarshal(t, u, want) 677 } 678 679 func TestStarEvent_Marshal(t *testing.T) { 680 t.Parallel() 681 testJSONMarshal(t, &StarEvent{}, "{}") 682 683 u := &StarEvent{ 684 Action: Ptr("a"), 685 StarredAt: &Timestamp{referenceTime}, 686 Org: &Organization{ 687 BillingEmail: Ptr("be"), 688 Blog: Ptr("b"), 689 Company: Ptr("c"), 690 Email: Ptr("e"), 691 TwitterUsername: Ptr("tu"), 692 Location: Ptr("loc"), 693 Name: Ptr("n"), 694 Description: Ptr("d"), 695 IsVerified: Ptr(true), 696 HasOrganizationProjects: Ptr(true), 697 HasRepositoryProjects: Ptr(true), 698 DefaultRepoPermission: Ptr("drp"), 699 MembersCanCreateRepos: Ptr(true), 700 MembersCanCreateInternalRepos: Ptr(true), 701 MembersCanCreatePrivateRepos: Ptr(true), 702 MembersCanCreatePublicRepos: Ptr(false), 703 MembersAllowedRepositoryCreationType: Ptr("marct"), 704 MembersCanCreatePages: Ptr(true), 705 MembersCanCreatePublicPages: Ptr(false), 706 MembersCanCreatePrivatePages: Ptr(true), 707 }, 708 Repo: &Repository{ 709 ID: Ptr(int64(1)), 710 URL: Ptr("s"), 711 Name: Ptr("n"), 712 }, 713 Sender: &User{ 714 Login: Ptr("l"), 715 ID: Ptr(int64(1)), 716 NodeID: Ptr("n"), 717 URL: Ptr("u"), 718 ReposURL: Ptr("r"), 719 EventsURL: Ptr("e"), 720 AvatarURL: Ptr("a"), 721 }, 722 } 723 724 want := `{ 725 "action": "a", 726 "starred_at": ` + referenceTimeStr + `, 727 "organization": { 728 "name": "n", 729 "company": "c", 730 "blog": "b", 731 "location": "loc", 732 "email": "e", 733 "twitter_username": "tu", 734 "description": "d", 735 "billing_email": "be", 736 "is_verified": true, 737 "has_organization_projects": true, 738 "has_repository_projects": true, 739 "default_repository_permission": "drp", 740 "members_can_create_repositories": true, 741 "members_can_create_public_repositories": false, 742 "members_can_create_private_repositories": true, 743 "members_can_create_internal_repositories": true, 744 "members_allowed_repository_creation_type": "marct", 745 "members_can_create_pages": true, 746 "members_can_create_public_pages": false, 747 "members_can_create_private_pages": true 748 }, 749 "repository": { 750 "id": 1, 751 "name": "n", 752 "url": "s" 753 }, 754 "sender": { 755 "login": "l", 756 "id": 1, 757 "node_id": "n", 758 "avatar_url": "a", 759 "url": "u", 760 "events_url": "e", 761 "repos_url": "r" 762 } 763 }` 764 765 testJSONMarshal(t, u, want) 766 } 767 768 func TestTeamEvent_Marshal(t *testing.T) { 769 t.Parallel() 770 testJSONMarshal(t, &TeamEvent{}, "{}") 771 772 u := &TeamEvent{ 773 Action: Ptr("a"), 774 Team: &Team{ 775 ID: Ptr(int64(1)), 776 NodeID: Ptr("n"), 777 Name: Ptr("n"), 778 Description: Ptr("d"), 779 URL: Ptr("u"), 780 Slug: Ptr("s"), 781 Permission: Ptr("p"), 782 Privacy: Ptr("p"), 783 MembersCount: Ptr(1), 784 ReposCount: Ptr(1), 785 MembersURL: Ptr("m"), 786 RepositoriesURL: Ptr("r"), 787 Organization: &Organization{ 788 Login: Ptr("l"), 789 ID: Ptr(int64(1)), 790 NodeID: Ptr("n"), 791 AvatarURL: Ptr("a"), 792 HTMLURL: Ptr("h"), 793 Name: Ptr("n"), 794 Company: Ptr("c"), 795 Blog: Ptr("b"), 796 Location: Ptr("l"), 797 Email: Ptr("e"), 798 }, 799 Parent: &Team{ 800 ID: Ptr(int64(1)), 801 NodeID: Ptr("n"), 802 Name: Ptr("n"), 803 Description: Ptr("d"), 804 URL: Ptr("u"), 805 Slug: Ptr("s"), 806 Permission: Ptr("p"), 807 Privacy: Ptr("p"), 808 MembersCount: Ptr(1), 809 ReposCount: Ptr(1), 810 }, 811 LDAPDN: Ptr("l"), 812 }, 813 Changes: &TeamChange{ 814 Description: &TeamDescription{ 815 From: Ptr("from"), 816 }, 817 Name: &TeamName{ 818 From: Ptr("from"), 819 }, 820 Privacy: &TeamPrivacy{ 821 From: Ptr("from"), 822 }, 823 Repository: &TeamRepository{ 824 Permissions: &TeamPermissions{ 825 From: &TeamPermissionsFrom{ 826 Admin: Ptr(true), 827 Pull: Ptr(true), 828 Push: Ptr(true), 829 }, 830 }, 831 }, 832 }, 833 Repo: &Repository{ 834 ID: Ptr(int64(1)), 835 URL: Ptr("s"), 836 Name: Ptr("n"), 837 }, 838 Org: &Organization{ 839 BillingEmail: Ptr("be"), 840 Blog: Ptr("b"), 841 Company: Ptr("c"), 842 Email: Ptr("e"), 843 TwitterUsername: Ptr("tu"), 844 Location: Ptr("loc"), 845 Name: Ptr("n"), 846 Description: Ptr("d"), 847 IsVerified: Ptr(true), 848 HasOrganizationProjects: Ptr(true), 849 HasRepositoryProjects: Ptr(true), 850 DefaultRepoPermission: Ptr("drp"), 851 MembersCanCreateRepos: Ptr(true), 852 MembersCanCreateInternalRepos: Ptr(true), 853 MembersCanCreatePrivateRepos: Ptr(true), 854 MembersCanCreatePublicRepos: Ptr(false), 855 MembersAllowedRepositoryCreationType: Ptr("marct"), 856 MembersCanCreatePages: Ptr(true), 857 MembersCanCreatePublicPages: Ptr(false), 858 MembersCanCreatePrivatePages: Ptr(true), 859 }, 860 Sender: &User{ 861 Login: Ptr("l"), 862 ID: Ptr(int64(1)), 863 NodeID: Ptr("n"), 864 URL: Ptr("u"), 865 ReposURL: Ptr("r"), 866 EventsURL: Ptr("e"), 867 AvatarURL: Ptr("a"), 868 }, 869 Installation: &Installation{ 870 ID: Ptr(int64(1)), 871 NodeID: Ptr("nid"), 872 AppID: Ptr(int64(1)), 873 AppSlug: Ptr("as"), 874 TargetID: Ptr(int64(1)), 875 Account: &User{ 876 Login: Ptr("l"), 877 ID: Ptr(int64(1)), 878 URL: Ptr("u"), 879 AvatarURL: Ptr("a"), 880 GravatarID: Ptr("g"), 881 Name: Ptr("n"), 882 Company: Ptr("c"), 883 Blog: Ptr("b"), 884 Location: Ptr("l"), 885 Email: Ptr("e"), 886 Hireable: Ptr(true), 887 Bio: Ptr("b"), 888 TwitterUsername: Ptr("t"), 889 PublicRepos: Ptr(1), 890 Followers: Ptr(1), 891 Following: Ptr(1), 892 CreatedAt: &Timestamp{referenceTime}, 893 SuspendedAt: &Timestamp{referenceTime}, 894 }, 895 AccessTokensURL: Ptr("atu"), 896 RepositoriesURL: Ptr("ru"), 897 HTMLURL: Ptr("hu"), 898 TargetType: Ptr("tt"), 899 SingleFileName: Ptr("sfn"), 900 RepositorySelection: Ptr("rs"), 901 Events: []string{"e"}, 902 SingleFilePaths: []string{"s"}, 903 Permissions: &InstallationPermissions{ 904 Actions: Ptr("a"), 905 Administration: Ptr("ad"), 906 Checks: Ptr("c"), 907 Contents: Ptr("co"), 908 ContentReferences: Ptr("cr"), 909 Deployments: Ptr("d"), 910 Environments: Ptr("e"), 911 Issues: Ptr("i"), 912 Metadata: Ptr("md"), 913 Members: Ptr("m"), 914 OrganizationAdministration: Ptr("oa"), 915 OrganizationHooks: Ptr("oh"), 916 OrganizationPlan: Ptr("op"), 917 OrganizationPreReceiveHooks: Ptr("opr"), 918 OrganizationProjects: Ptr("op"), 919 OrganizationSecrets: Ptr("os"), 920 OrganizationSelfHostedRunners: Ptr("osh"), 921 OrganizationUserBlocking: Ptr("oub"), 922 Packages: Ptr("pkg"), 923 Pages: Ptr("pg"), 924 PullRequests: Ptr("pr"), 925 RepositoryHooks: Ptr("rh"), 926 RepositoryProjects: Ptr("rp"), 927 RepositoryPreReceiveHooks: Ptr("rprh"), 928 Secrets: Ptr("s"), 929 SecretScanningAlerts: Ptr("ssa"), 930 SecurityEvents: Ptr("se"), 931 SingleFile: Ptr("sf"), 932 Statuses: Ptr("s"), 933 TeamDiscussions: Ptr("td"), 934 VulnerabilityAlerts: Ptr("va"), 935 Workflows: Ptr("w"), 936 }, 937 CreatedAt: &Timestamp{referenceTime}, 938 UpdatedAt: &Timestamp{referenceTime}, 939 HasMultipleSingleFiles: Ptr(false), 940 SuspendedBy: &User{ 941 Login: Ptr("l"), 942 ID: Ptr(int64(1)), 943 URL: Ptr("u"), 944 AvatarURL: Ptr("a"), 945 GravatarID: Ptr("g"), 946 Name: Ptr("n"), 947 Company: Ptr("c"), 948 Blog: Ptr("b"), 949 Location: Ptr("l"), 950 Email: Ptr("e"), 951 Hireable: Ptr(true), 952 Bio: Ptr("b"), 953 TwitterUsername: Ptr("t"), 954 PublicRepos: Ptr(1), 955 Followers: Ptr(1), 956 Following: Ptr(1), 957 CreatedAt: &Timestamp{referenceTime}, 958 SuspendedAt: &Timestamp{referenceTime}, 959 }, 960 SuspendedAt: &Timestamp{referenceTime}, 961 }, 962 } 963 964 want := `{ 965 "action": "a", 966 "team": { 967 "id": 1, 968 "node_id": "n", 969 "name": "n", 970 "description": "d", 971 "url": "u", 972 "slug": "s", 973 "permission": "p", 974 "privacy": "p", 975 "members_count": 1, 976 "repos_count": 1, 977 "organization": { 978 "login": "l", 979 "id": 1, 980 "node_id": "n", 981 "avatar_url": "a", 982 "html_url": "h", 983 "name": "n", 984 "company": "c", 985 "blog": "b", 986 "location": "l", 987 "email": "e" 988 }, 989 "members_url": "m", 990 "repositories_url": "r", 991 "parent": { 992 "id": 1, 993 "node_id": "n", 994 "name": "n", 995 "description": "d", 996 "url": "u", 997 "slug": "s", 998 "permission": "p", 999 "privacy": "p", 1000 "members_count": 1, 1001 "repos_count": 1 1002 }, 1003 "ldap_dn": "l" 1004 }, 1005 "changes": { 1006 "description": { 1007 "from": "from" 1008 }, 1009 "name": { 1010 "from": "from" 1011 }, 1012 "privacy": { 1013 "from": "from" 1014 }, 1015 "repository": { 1016 "permissions": { 1017 "from": { 1018 "admin": true, 1019 "pull": true, 1020 "push": true 1021 } 1022 } 1023 } 1024 }, 1025 "repository": { 1026 "id": 1, 1027 "name": "n", 1028 "url": "s" 1029 }, 1030 "organization": { 1031 "name": "n", 1032 "company": "c", 1033 "blog": "b", 1034 "location": "loc", 1035 "email": "e", 1036 "twitter_username": "tu", 1037 "description": "d", 1038 "billing_email": "be", 1039 "is_verified": true, 1040 "has_organization_projects": true, 1041 "has_repository_projects": true, 1042 "default_repository_permission": "drp", 1043 "members_can_create_repositories": true, 1044 "members_can_create_public_repositories": false, 1045 "members_can_create_private_repositories": true, 1046 "members_can_create_internal_repositories": true, 1047 "members_allowed_repository_creation_type": "marct", 1048 "members_can_create_pages": true, 1049 "members_can_create_public_pages": false, 1050 "members_can_create_private_pages": true 1051 }, 1052 "sender": { 1053 "login": "l", 1054 "id": 1, 1055 "node_id": "n", 1056 "avatar_url": "a", 1057 "url": "u", 1058 "events_url": "e", 1059 "repos_url": "r" 1060 }, 1061 "installation": { 1062 "id": 1, 1063 "node_id": "nid", 1064 "app_id": 1, 1065 "app_slug": "as", 1066 "target_id": 1, 1067 "account": { 1068 "login": "l", 1069 "id": 1, 1070 "avatar_url": "a", 1071 "gravatar_id": "g", 1072 "name": "n", 1073 "company": "c", 1074 "blog": "b", 1075 "location": "l", 1076 "email": "e", 1077 "hireable": true, 1078 "bio": "b", 1079 "twitter_username": "t", 1080 "public_repos": 1, 1081 "followers": 1, 1082 "following": 1, 1083 "created_at": ` + referenceTimeStr + `, 1084 "suspended_at": ` + referenceTimeStr + `, 1085 "url": "u" 1086 }, 1087 "access_tokens_url": "atu", 1088 "repositories_url": "ru", 1089 "html_url": "hu", 1090 "target_type": "tt", 1091 "single_file_name": "sfn", 1092 "repository_selection": "rs", 1093 "events": [ 1094 "e" 1095 ], 1096 "single_file_paths": [ 1097 "s" 1098 ], 1099 "permissions": { 1100 "actions": "a", 1101 "administration": "ad", 1102 "checks": "c", 1103 "contents": "co", 1104 "content_references": "cr", 1105 "deployments": "d", 1106 "environments": "e", 1107 "issues": "i", 1108 "metadata": "md", 1109 "members": "m", 1110 "organization_administration": "oa", 1111 "organization_hooks": "oh", 1112 "organization_plan": "op", 1113 "organization_pre_receive_hooks": "opr", 1114 "organization_projects": "op", 1115 "organization_secrets": "os", 1116 "organization_self_hosted_runners": "osh", 1117 "organization_user_blocking": "oub", 1118 "packages": "pkg", 1119 "pages": "pg", 1120 "pull_requests": "pr", 1121 "repository_hooks": "rh", 1122 "repository_projects": "rp", 1123 "repository_pre_receive_hooks": "rprh", 1124 "secrets": "s", 1125 "secret_scanning_alerts": "ssa", 1126 "security_events": "se", 1127 "single_file": "sf", 1128 "statuses": "s", 1129 "team_discussions": "td", 1130 "vulnerability_alerts": "va", 1131 "workflows": "w" 1132 }, 1133 "created_at": ` + referenceTimeStr + `, 1134 "updated_at": ` + referenceTimeStr + `, 1135 "has_multiple_single_files": false, 1136 "suspended_by": { 1137 "login": "l", 1138 "id": 1, 1139 "avatar_url": "a", 1140 "gravatar_id": "g", 1141 "name": "n", 1142 "company": "c", 1143 "blog": "b", 1144 "location": "l", 1145 "email": "e", 1146 "hireable": true, 1147 "bio": "b", 1148 "twitter_username": "t", 1149 "public_repos": 1, 1150 "followers": 1, 1151 "following": 1, 1152 "created_at": ` + referenceTimeStr + `, 1153 "suspended_at": ` + referenceTimeStr + `, 1154 "url": "u" 1155 }, 1156 "suspended_at": ` + referenceTimeStr + ` 1157 } 1158 }` 1159 1160 testJSONMarshal(t, u, want) 1161 } 1162 1163 func TestInstallationRepositoriesEvent_Marshal(t *testing.T) { 1164 t.Parallel() 1165 testJSONMarshal(t, &InstallationRepositoriesEvent{}, "{}") 1166 1167 u := &InstallationRepositoriesEvent{ 1168 Action: Ptr("a"), 1169 RepositoriesAdded: []*Repository{ 1170 { 1171 ID: Ptr(int64(1)), 1172 URL: Ptr("s"), 1173 Name: Ptr("n"), 1174 }, 1175 }, 1176 RepositoriesRemoved: []*Repository{ 1177 { 1178 ID: Ptr(int64(1)), 1179 URL: Ptr("s"), 1180 Name: Ptr("n"), 1181 }, 1182 }, 1183 RepositorySelection: Ptr("rs"), 1184 Sender: &User{ 1185 Login: Ptr("l"), 1186 ID: Ptr(int64(1)), 1187 NodeID: Ptr("n"), 1188 URL: Ptr("u"), 1189 ReposURL: Ptr("r"), 1190 EventsURL: Ptr("e"), 1191 AvatarURL: Ptr("a"), 1192 }, 1193 Installation: &Installation{ 1194 ID: Ptr(int64(1)), 1195 NodeID: Ptr("nid"), 1196 AppID: Ptr(int64(1)), 1197 AppSlug: Ptr("as"), 1198 TargetID: Ptr(int64(1)), 1199 Account: &User{ 1200 Login: Ptr("l"), 1201 ID: Ptr(int64(1)), 1202 URL: Ptr("u"), 1203 AvatarURL: Ptr("a"), 1204 GravatarID: Ptr("g"), 1205 Name: Ptr("n"), 1206 Company: Ptr("c"), 1207 Blog: Ptr("b"), 1208 Location: Ptr("l"), 1209 Email: Ptr("e"), 1210 Hireable: Ptr(true), 1211 Bio: Ptr("b"), 1212 TwitterUsername: Ptr("t"), 1213 PublicRepos: Ptr(1), 1214 Followers: Ptr(1), 1215 Following: Ptr(1), 1216 CreatedAt: &Timestamp{referenceTime}, 1217 SuspendedAt: &Timestamp{referenceTime}, 1218 }, 1219 AccessTokensURL: Ptr("atu"), 1220 RepositoriesURL: Ptr("ru"), 1221 HTMLURL: Ptr("hu"), 1222 TargetType: Ptr("tt"), 1223 SingleFileName: Ptr("sfn"), 1224 RepositorySelection: Ptr("rs"), 1225 Events: []string{"e"}, 1226 SingleFilePaths: []string{"s"}, 1227 Permissions: &InstallationPermissions{ 1228 Actions: Ptr("a"), 1229 Administration: Ptr("ad"), 1230 Checks: Ptr("c"), 1231 Contents: Ptr("co"), 1232 ContentReferences: Ptr("cr"), 1233 Deployments: Ptr("d"), 1234 Environments: Ptr("e"), 1235 Issues: Ptr("i"), 1236 Metadata: Ptr("md"), 1237 Members: Ptr("m"), 1238 OrganizationAdministration: Ptr("oa"), 1239 OrganizationHooks: Ptr("oh"), 1240 OrganizationPlan: Ptr("op"), 1241 OrganizationPreReceiveHooks: Ptr("opr"), 1242 OrganizationProjects: Ptr("op"), 1243 OrganizationSecrets: Ptr("os"), 1244 OrganizationSelfHostedRunners: Ptr("osh"), 1245 OrganizationUserBlocking: Ptr("oub"), 1246 Packages: Ptr("pkg"), 1247 Pages: Ptr("pg"), 1248 PullRequests: Ptr("pr"), 1249 RepositoryHooks: Ptr("rh"), 1250 RepositoryProjects: Ptr("rp"), 1251 RepositoryPreReceiveHooks: Ptr("rprh"), 1252 Secrets: Ptr("s"), 1253 SecretScanningAlerts: Ptr("ssa"), 1254 SecurityEvents: Ptr("se"), 1255 SingleFile: Ptr("sf"), 1256 Statuses: Ptr("s"), 1257 TeamDiscussions: Ptr("td"), 1258 VulnerabilityAlerts: Ptr("va"), 1259 Workflows: Ptr("w"), 1260 }, 1261 CreatedAt: &Timestamp{referenceTime}, 1262 UpdatedAt: &Timestamp{referenceTime}, 1263 HasMultipleSingleFiles: Ptr(false), 1264 SuspendedBy: &User{ 1265 Login: Ptr("l"), 1266 ID: Ptr(int64(1)), 1267 URL: Ptr("u"), 1268 AvatarURL: Ptr("a"), 1269 GravatarID: Ptr("g"), 1270 Name: Ptr("n"), 1271 Company: Ptr("c"), 1272 Blog: Ptr("b"), 1273 Location: Ptr("l"), 1274 Email: Ptr("e"), 1275 Hireable: Ptr(true), 1276 Bio: Ptr("b"), 1277 TwitterUsername: Ptr("t"), 1278 PublicRepos: Ptr(1), 1279 Followers: Ptr(1), 1280 Following: Ptr(1), 1281 CreatedAt: &Timestamp{referenceTime}, 1282 SuspendedAt: &Timestamp{referenceTime}, 1283 }, 1284 SuspendedAt: &Timestamp{referenceTime}, 1285 }, 1286 } 1287 1288 want := `{ 1289 "action": "a", 1290 "repositories_added": [ 1291 { 1292 "id": 1, 1293 "name": "n", 1294 "url": "s" 1295 } 1296 ], 1297 "repositories_removed": [ 1298 { 1299 "id": 1, 1300 "name": "n", 1301 "url": "s" 1302 } 1303 ], 1304 "repository_selection": "rs", 1305 "sender": { 1306 "login": "l", 1307 "id": 1, 1308 "node_id": "n", 1309 "avatar_url": "a", 1310 "url": "u", 1311 "events_url": "e", 1312 "repos_url": "r" 1313 }, 1314 "installation": { 1315 "id": 1, 1316 "node_id": "nid", 1317 "app_id": 1, 1318 "app_slug": "as", 1319 "target_id": 1, 1320 "account": { 1321 "login": "l", 1322 "id": 1, 1323 "avatar_url": "a", 1324 "gravatar_id": "g", 1325 "name": "n", 1326 "company": "c", 1327 "blog": "b", 1328 "location": "l", 1329 "email": "e", 1330 "hireable": true, 1331 "bio": "b", 1332 "twitter_username": "t", 1333 "public_repos": 1, 1334 "followers": 1, 1335 "following": 1, 1336 "created_at": ` + referenceTimeStr + `, 1337 "suspended_at": ` + referenceTimeStr + `, 1338 "url": "u" 1339 }, 1340 "access_tokens_url": "atu", 1341 "repositories_url": "ru", 1342 "html_url": "hu", 1343 "target_type": "tt", 1344 "single_file_name": "sfn", 1345 "repository_selection": "rs", 1346 "events": [ 1347 "e" 1348 ], 1349 "single_file_paths": [ 1350 "s" 1351 ], 1352 "permissions": { 1353 "actions": "a", 1354 "administration": "ad", 1355 "checks": "c", 1356 "contents": "co", 1357 "content_references": "cr", 1358 "deployments": "d", 1359 "environments": "e", 1360 "issues": "i", 1361 "metadata": "md", 1362 "members": "m", 1363 "organization_administration": "oa", 1364 "organization_hooks": "oh", 1365 "organization_plan": "op", 1366 "organization_pre_receive_hooks": "opr", 1367 "organization_projects": "op", 1368 "organization_secrets": "os", 1369 "organization_self_hosted_runners": "osh", 1370 "organization_user_blocking": "oub", 1371 "packages": "pkg", 1372 "pages": "pg", 1373 "pull_requests": "pr", 1374 "repository_hooks": "rh", 1375 "repository_projects": "rp", 1376 "repository_pre_receive_hooks": "rprh", 1377 "secrets": "s", 1378 "secret_scanning_alerts": "ssa", 1379 "security_events": "se", 1380 "single_file": "sf", 1381 "statuses": "s", 1382 "team_discussions": "td", 1383 "vulnerability_alerts": "va", 1384 "workflows": "w" 1385 }, 1386 "created_at": ` + referenceTimeStr + `, 1387 "updated_at": ` + referenceTimeStr + `, 1388 "has_multiple_single_files": false, 1389 "suspended_by": { 1390 "login": "l", 1391 "id": 1, 1392 "avatar_url": "a", 1393 "gravatar_id": "g", 1394 "name": "n", 1395 "company": "c", 1396 "blog": "b", 1397 "location": "l", 1398 "email": "e", 1399 "hireable": true, 1400 "bio": "b", 1401 "twitter_username": "t", 1402 "public_repos": 1, 1403 "followers": 1, 1404 "following": 1, 1405 "created_at": ` + referenceTimeStr + `, 1406 "suspended_at": ` + referenceTimeStr + `, 1407 "url": "u" 1408 }, 1409 "suspended_at": ` + referenceTimeStr + ` 1410 } 1411 }` 1412 1413 testJSONMarshal(t, u, want) 1414 } 1415 1416 func TestInstallationTargetEvent_Marshal(t *testing.T) { 1417 t.Parallel() 1418 testJSONMarshal(t, &InstallationTargetEvent{}, "{}") 1419 1420 u := &InstallationTargetEvent{ 1421 Account: &User{ 1422 Login: Ptr("u"), 1423 ID: Ptr(int64(1)), 1424 NodeID: Ptr("n"), 1425 URL: Ptr("u"), 1426 ReposURL: Ptr("r"), 1427 EventsURL: Ptr("e"), 1428 AvatarURL: Ptr("l"), 1429 }, 1430 Action: Ptr("a"), 1431 Changes: &InstallationChanges{ 1432 Login: &InstallationLoginChange{ 1433 From: Ptr("p"), 1434 }, 1435 Slug: &InstallationSlugChange{ 1436 From: Ptr("j"), 1437 }, 1438 }, 1439 Enterprise: &Enterprise{ 1440 ID: Ptr(1), 1441 Slug: Ptr("s"), 1442 Name: Ptr("n"), 1443 NodeID: Ptr("nid"), 1444 AvatarURL: Ptr("au"), 1445 Description: Ptr("d"), 1446 WebsiteURL: Ptr("wu"), 1447 HTMLURL: Ptr("hu"), 1448 CreatedAt: &Timestamp{referenceTime}, 1449 UpdatedAt: &Timestamp{referenceTime}, 1450 }, 1451 Installation: &Installation{ 1452 ID: Ptr(int64(1)), 1453 NodeID: Ptr("nid"), 1454 AppID: Ptr(int64(1)), 1455 AppSlug: Ptr("as"), 1456 TargetID: Ptr(int64(1)), 1457 Account: &User{ 1458 Login: Ptr("l"), 1459 ID: Ptr(int64(1)), 1460 URL: Ptr("u"), 1461 AvatarURL: Ptr("a"), 1462 GravatarID: Ptr("g"), 1463 Name: Ptr("n"), 1464 Company: Ptr("c"), 1465 Blog: Ptr("b"), 1466 Location: Ptr("l"), 1467 Email: Ptr("e"), 1468 Hireable: Ptr(true), 1469 Bio: Ptr("b"), 1470 TwitterUsername: Ptr("t"), 1471 PublicRepos: Ptr(1), 1472 Followers: Ptr(1), 1473 Following: Ptr(1), 1474 CreatedAt: &Timestamp{referenceTime}, 1475 SuspendedAt: &Timestamp{referenceTime}, 1476 }, 1477 AccessTokensURL: Ptr("atu"), 1478 RepositoriesURL: Ptr("ru"), 1479 HTMLURL: Ptr("hu"), 1480 TargetType: Ptr("tt"), 1481 SingleFileName: Ptr("sfn"), 1482 RepositorySelection: Ptr("rs"), 1483 Events: []string{"e"}, 1484 SingleFilePaths: []string{"s"}, 1485 Permissions: &InstallationPermissions{ 1486 Actions: Ptr("a"), 1487 Administration: Ptr("ad"), 1488 Checks: Ptr("c"), 1489 Contents: Ptr("co"), 1490 ContentReferences: Ptr("cr"), 1491 Deployments: Ptr("d"), 1492 Environments: Ptr("e"), 1493 Issues: Ptr("i"), 1494 Metadata: Ptr("md"), 1495 Members: Ptr("m"), 1496 OrganizationAdministration: Ptr("oa"), 1497 OrganizationHooks: Ptr("oh"), 1498 OrganizationPlan: Ptr("op"), 1499 OrganizationPreReceiveHooks: Ptr("opr"), 1500 OrganizationProjects: Ptr("op"), 1501 OrganizationSecrets: Ptr("os"), 1502 OrganizationSelfHostedRunners: Ptr("osh"), 1503 OrganizationUserBlocking: Ptr("oub"), 1504 Packages: Ptr("pkg"), 1505 Pages: Ptr("pg"), 1506 PullRequests: Ptr("pr"), 1507 RepositoryHooks: Ptr("rh"), 1508 RepositoryProjects: Ptr("rp"), 1509 RepositoryPreReceiveHooks: Ptr("rprh"), 1510 Secrets: Ptr("s"), 1511 SecretScanningAlerts: Ptr("ssa"), 1512 SecurityEvents: Ptr("se"), 1513 SingleFile: Ptr("sf"), 1514 Statuses: Ptr("s"), 1515 TeamDiscussions: Ptr("td"), 1516 VulnerabilityAlerts: Ptr("va"), 1517 Workflows: Ptr("w"), 1518 }, 1519 CreatedAt: &Timestamp{referenceTime}, 1520 UpdatedAt: &Timestamp{referenceTime}, 1521 HasMultipleSingleFiles: Ptr(false), 1522 SuspendedBy: &User{ 1523 Login: Ptr("l"), 1524 ID: Ptr(int64(1)), 1525 URL: Ptr("u"), 1526 AvatarURL: Ptr("a"), 1527 GravatarID: Ptr("g"), 1528 Name: Ptr("n"), 1529 Company: Ptr("c"), 1530 Blog: Ptr("b"), 1531 Location: Ptr("l"), 1532 Email: Ptr("e"), 1533 Hireable: Ptr(true), 1534 Bio: Ptr("b"), 1535 TwitterUsername: Ptr("t"), 1536 PublicRepos: Ptr(1), 1537 Followers: Ptr(1), 1538 Following: Ptr(1), 1539 CreatedAt: &Timestamp{referenceTime}, 1540 SuspendedAt: &Timestamp{referenceTime}, 1541 }, 1542 SuspendedAt: &Timestamp{referenceTime}, 1543 }, 1544 Organization: &Organization{ 1545 BillingEmail: Ptr("be"), 1546 Blog: Ptr("b"), 1547 Company: Ptr("c"), 1548 Email: Ptr("e"), 1549 TwitterUsername: Ptr("tu"), 1550 Location: Ptr("loc"), 1551 Name: Ptr("n"), 1552 Description: Ptr("d"), 1553 IsVerified: Ptr(true), 1554 HasOrganizationProjects: Ptr(true), 1555 HasRepositoryProjects: Ptr(true), 1556 DefaultRepoPermission: Ptr("drp"), 1557 MembersCanCreateRepos: Ptr(true), 1558 MembersCanCreateInternalRepos: Ptr(true), 1559 MembersCanCreatePrivateRepos: Ptr(true), 1560 MembersCanCreatePublicRepos: Ptr(false), 1561 MembersAllowedRepositoryCreationType: Ptr("marct"), 1562 MembersCanCreatePages: Ptr(true), 1563 MembersCanCreatePublicPages: Ptr(false), 1564 MembersCanCreatePrivatePages: Ptr(true), 1565 }, 1566 Repository: &Repository{ 1567 ID: Ptr(int64(1)), 1568 URL: Ptr("s"), 1569 Name: Ptr("n"), 1570 }, 1571 Sender: &User{ 1572 Login: Ptr("l"), 1573 ID: Ptr(int64(1)), 1574 NodeID: Ptr("n"), 1575 URL: Ptr("u"), 1576 ReposURL: Ptr("r"), 1577 EventsURL: Ptr("e"), 1578 AvatarURL: Ptr("a"), 1579 }, 1580 TargetType: Ptr("running"), 1581 } 1582 1583 want := `{ 1584 "account": { 1585 "login": "u", 1586 "id": 1, 1587 "node_id": "n", 1588 "avatar_url": "l", 1589 "url": "u", 1590 "events_url": "e", 1591 "repos_url": "r" 1592 }, 1593 "action": "a", 1594 "changes": { 1595 "login": { 1596 "from": "p" 1597 }, 1598 "slug": { 1599 "from": "j" 1600 } 1601 }, 1602 "enterprise": { 1603 "id": 1, 1604 "slug": "s", 1605 "name": "n", 1606 "node_id": "nid", 1607 "avatar_url": "au", 1608 "description": "d", 1609 "website_url": "wu", 1610 "html_url": "hu", 1611 "created_at": ` + referenceTimeStr + `, 1612 "updated_at": ` + referenceTimeStr + ` 1613 }, 1614 "installation": { 1615 "id": 1, 1616 "node_id": "nid", 1617 "app_id": 1, 1618 "app_slug": "as", 1619 "target_id": 1, 1620 "account": { 1621 "login": "l", 1622 "id": 1, 1623 "avatar_url": "a", 1624 "gravatar_id": "g", 1625 "name": "n", 1626 "company": "c", 1627 "blog": "b", 1628 "location": "l", 1629 "email": "e", 1630 "hireable": true, 1631 "bio": "b", 1632 "twitter_username": "t", 1633 "public_repos": 1, 1634 "followers": 1, 1635 "following": 1, 1636 "created_at": ` + referenceTimeStr + `, 1637 "suspended_at": ` + referenceTimeStr + `, 1638 "url": "u" 1639 }, 1640 "access_tokens_url": "atu", 1641 "repositories_url": "ru", 1642 "html_url": "hu", 1643 "target_type": "tt", 1644 "single_file_name": "sfn", 1645 "repository_selection": "rs", 1646 "events": [ 1647 "e" 1648 ], 1649 "single_file_paths": [ 1650 "s" 1651 ], 1652 "permissions": { 1653 "actions": "a", 1654 "administration": "ad", 1655 "checks": "c", 1656 "contents": "co", 1657 "content_references": "cr", 1658 "deployments": "d", 1659 "environments": "e", 1660 "issues": "i", 1661 "metadata": "md", 1662 "members": "m", 1663 "organization_administration": "oa", 1664 "organization_hooks": "oh", 1665 "organization_plan": "op", 1666 "organization_pre_receive_hooks": "opr", 1667 "organization_projects": "op", 1668 "organization_secrets": "os", 1669 "organization_self_hosted_runners": "osh", 1670 "organization_user_blocking": "oub", 1671 "packages": "pkg", 1672 "pages": "pg", 1673 "pull_requests": "pr", 1674 "repository_hooks": "rh", 1675 "repository_projects": "rp", 1676 "repository_pre_receive_hooks": "rprh", 1677 "secrets": "s", 1678 "secret_scanning_alerts": "ssa", 1679 "security_events": "se", 1680 "single_file": "sf", 1681 "statuses": "s", 1682 "team_discussions": "td", 1683 "vulnerability_alerts": "va", 1684 "workflows": "w" 1685 }, 1686 "created_at": ` + referenceTimeStr + `, 1687 "updated_at": ` + referenceTimeStr + `, 1688 "has_multiple_single_files": false, 1689 "suspended_by": { 1690 "login": "l", 1691 "id": 1, 1692 "avatar_url": "a", 1693 "gravatar_id": "g", 1694 "name": "n", 1695 "company": "c", 1696 "blog": "b", 1697 "location": "l", 1698 "email": "e", 1699 "hireable": true, 1700 "bio": "b", 1701 "twitter_username": "t", 1702 "public_repos": 1, 1703 "followers": 1, 1704 "following": 1, 1705 "created_at": ` + referenceTimeStr + `, 1706 "suspended_at": ` + referenceTimeStr + `, 1707 "url": "u" 1708 }, 1709 "suspended_at": ` + referenceTimeStr + ` 1710 }, 1711 "organization": { 1712 "name": "n", 1713 "company": "c", 1714 "blog": "b", 1715 "location": "loc", 1716 "email": "e", 1717 "twitter_username": "tu", 1718 "description": "d", 1719 "billing_email": "be", 1720 "is_verified": true, 1721 "has_organization_projects": true, 1722 "has_repository_projects": true, 1723 "default_repository_permission": "drp", 1724 "members_can_create_repositories": true, 1725 "members_can_create_public_repositories": false, 1726 "members_can_create_private_repositories": true, 1727 "members_can_create_internal_repositories": true, 1728 "members_allowed_repository_creation_type": "marct", 1729 "members_can_create_pages": true, 1730 "members_can_create_public_pages": false, 1731 "members_can_create_private_pages": true 1732 }, 1733 "repository": { 1734 "id": 1, 1735 "url": "s", 1736 "name": "n" 1737 }, 1738 "sender": { 1739 "login": "l", 1740 "id": 1, 1741 "node_id": "n", 1742 "avatar_url": "a", 1743 "url": "u", 1744 "events_url": "e", 1745 "repos_url": "r" 1746 }, 1747 "target_type": "running" 1748 }` 1749 1750 testJSONMarshal(t, u, want) 1751 } 1752 1753 func TestEditTitle_Marshal(t *testing.T) { 1754 t.Parallel() 1755 testJSONMarshal(t, &EditTitle{}, "{}") 1756 1757 u := &EditTitle{ 1758 From: Ptr("EditTitleFrom"), 1759 } 1760 1761 want := `{ 1762 "from": "EditTitleFrom" 1763 }` 1764 1765 testJSONMarshal(t, u, want) 1766 } 1767 1768 func TestEditBody_Marshal(t *testing.T) { 1769 t.Parallel() 1770 testJSONMarshal(t, &EditBody{}, "{}") 1771 1772 u := &EditBody{ 1773 From: Ptr("EditBodyFrom"), 1774 } 1775 1776 want := `{ 1777 "from": "EditBodyFrom" 1778 }` 1779 1780 testJSONMarshal(t, u, want) 1781 } 1782 1783 func TestEditBase_Marshal(t *testing.T) { 1784 t.Parallel() 1785 testJSONMarshal(t, &EditBase{}, "{}") 1786 1787 u := &EditBase{ 1788 Ref: &EditRef{ 1789 From: Ptr("EditRefFrom"), 1790 }, 1791 SHA: &EditSHA{ 1792 From: Ptr("EditSHAFrom"), 1793 }, 1794 } 1795 1796 want := `{ 1797 "ref": { 1798 "from": "EditRefFrom" 1799 }, 1800 "sha": { 1801 "from": "EditSHAFrom" 1802 } 1803 }` 1804 1805 testJSONMarshal(t, u, want) 1806 } 1807 1808 func TestEditRef_Marshal(t *testing.T) { 1809 t.Parallel() 1810 testJSONMarshal(t, &EditRef{}, "{}") 1811 1812 u := &EditRef{ 1813 From: Ptr("EditRefFrom"), 1814 } 1815 1816 want := `{ 1817 "from": "EditRefFrom" 1818 }` 1819 1820 testJSONMarshal(t, u, want) 1821 } 1822 1823 func TestEditSHA_Marshal(t *testing.T) { 1824 t.Parallel() 1825 testJSONMarshal(t, &EditSHA{}, "{}") 1826 1827 u := &EditSHA{ 1828 From: Ptr("EditSHAFrom"), 1829 } 1830 1831 want := `{ 1832 "from": "EditSHAFrom" 1833 }` 1834 1835 testJSONMarshal(t, u, want) 1836 } 1837 1838 func TestProjectName_Marshal(t *testing.T) { 1839 t.Parallel() 1840 testJSONMarshal(t, &ProjectName{}, "{}") 1841 1842 u := &ProjectName{ 1843 From: Ptr("ProjectNameFrom"), 1844 } 1845 1846 want := `{ 1847 "from": "ProjectNameFrom" 1848 }` 1849 1850 testJSONMarshal(t, u, want) 1851 } 1852 1853 func TestProjectBody_Marshal(t *testing.T) { 1854 t.Parallel() 1855 testJSONMarshal(t, &ProjectBody{}, "{}") 1856 1857 u := &ProjectBody{ 1858 From: Ptr("ProjectBodyFrom"), 1859 } 1860 1861 want := `{ 1862 "from": "ProjectBodyFrom" 1863 }` 1864 1865 testJSONMarshal(t, u, want) 1866 } 1867 1868 func TestProjectCardNote_Marshal(t *testing.T) { 1869 t.Parallel() 1870 testJSONMarshal(t, &ProjectCardNote{}, "{}") 1871 1872 u := &ProjectCardNote{ 1873 From: Ptr("ProjectCardNoteFrom"), 1874 } 1875 1876 want := `{ 1877 "from": "ProjectCardNoteFrom" 1878 }` 1879 1880 testJSONMarshal(t, u, want) 1881 } 1882 1883 func TestProjectColumnName_Marshal(t *testing.T) { 1884 t.Parallel() 1885 testJSONMarshal(t, &ProjectColumnName{}, "{}") 1886 1887 u := &ProjectColumnName{ 1888 From: Ptr("ProjectColumnNameFrom"), 1889 } 1890 1891 want := `{ 1892 "from": "ProjectColumnNameFrom" 1893 }` 1894 1895 testJSONMarshal(t, u, want) 1896 } 1897 1898 func TestTeamDescription_Marshal(t *testing.T) { 1899 t.Parallel() 1900 testJSONMarshal(t, &TeamDescription{}, "{}") 1901 1902 u := &TeamDescription{ 1903 From: Ptr("TeamDescriptionFrom"), 1904 } 1905 1906 want := `{ 1907 "from": "TeamDescriptionFrom" 1908 }` 1909 1910 testJSONMarshal(t, u, want) 1911 } 1912 1913 func TestTeamName_Marshal(t *testing.T) { 1914 t.Parallel() 1915 testJSONMarshal(t, &TeamName{}, "{}") 1916 1917 u := &TeamName{ 1918 From: Ptr("TeamNameFrom"), 1919 } 1920 1921 want := `{ 1922 "from": "TeamNameFrom" 1923 }` 1924 1925 testJSONMarshal(t, u, want) 1926 } 1927 1928 func TestTeamPrivacy_Marshal(t *testing.T) { 1929 t.Parallel() 1930 testJSONMarshal(t, &TeamPrivacy{}, "{}") 1931 1932 u := &TeamPrivacy{ 1933 From: Ptr("TeamPrivacyFrom"), 1934 } 1935 1936 want := `{ 1937 "from": "TeamPrivacyFrom" 1938 }` 1939 1940 testJSONMarshal(t, u, want) 1941 } 1942 1943 func TestTeamRepository_Marshal(t *testing.T) { 1944 t.Parallel() 1945 testJSONMarshal(t, &TeamRepository{}, "{}") 1946 1947 u := &TeamRepository{ 1948 Permissions: &TeamPermissions{ 1949 From: &TeamPermissionsFrom{ 1950 Admin: Ptr(true), 1951 Pull: Ptr(true), 1952 Push: Ptr(true), 1953 }, 1954 }, 1955 } 1956 1957 want := `{ 1958 "permissions": { 1959 "from": { 1960 "admin": true, 1961 "pull": true, 1962 "push": true 1963 } 1964 } 1965 }` 1966 1967 testJSONMarshal(t, u, want) 1968 } 1969 1970 func TestTeamPermissions_Marshal(t *testing.T) { 1971 t.Parallel() 1972 testJSONMarshal(t, &TeamPermissions{}, "{}") 1973 1974 u := &TeamPermissions{ 1975 From: &TeamPermissionsFrom{ 1976 Admin: Ptr(true), 1977 Pull: Ptr(true), 1978 Push: Ptr(true), 1979 }, 1980 } 1981 1982 want := `{ 1983 "from": { 1984 "admin": true, 1985 "pull": true, 1986 "push": true 1987 } 1988 }` 1989 1990 testJSONMarshal(t, u, want) 1991 } 1992 1993 func TestTeamPermissionsFrom_Marshal(t *testing.T) { 1994 t.Parallel() 1995 testJSONMarshal(t, &TeamPermissionsFrom{}, "{}") 1996 1997 u := &TeamPermissionsFrom{ 1998 Admin: Ptr(true), 1999 Pull: Ptr(true), 2000 Push: Ptr(true), 2001 } 2002 2003 want := `{ 2004 "admin": true, 2005 "pull": true, 2006 "push": true 2007 }` 2008 2009 testJSONMarshal(t, u, want) 2010 } 2011 2012 func TestRepositoryVulnerabilityAlert_Marshal(t *testing.T) { 2013 t.Parallel() 2014 testJSONMarshal(t, &RepositoryVulnerabilityAlert{}, "{}") 2015 2016 u := &RepositoryVulnerabilityAlert{ 2017 ID: Ptr(int64(1)), 2018 AffectedRange: Ptr("ar"), 2019 AffectedPackageName: Ptr("apn"), 2020 ExternalReference: Ptr("er"), 2021 ExternalIdentifier: Ptr("ei"), 2022 FixedIn: Ptr("fi"), 2023 Dismisser: &User{ 2024 Login: Ptr("l"), 2025 ID: Ptr(int64(1)), 2026 NodeID: Ptr("n"), 2027 URL: Ptr("u"), 2028 ReposURL: Ptr("r"), 2029 EventsURL: Ptr("e"), 2030 AvatarURL: Ptr("a"), 2031 }, 2032 DismissReason: Ptr("dr"), 2033 DismissedAt: &Timestamp{referenceTime}, 2034 } 2035 2036 want := `{ 2037 "id": 1, 2038 "affected_range": "ar", 2039 "affected_package_name": "apn", 2040 "external_reference": "er", 2041 "external_identifier": "ei", 2042 "fixed_in": "fi", 2043 "dismisser": { 2044 "login": "l", 2045 "id": 1, 2046 "node_id": "n", 2047 "avatar_url": "a", 2048 "url": "u", 2049 "events_url": "e", 2050 "repos_url": "r" 2051 }, 2052 "dismiss_reason": "dr", 2053 "dismissed_at": ` + referenceTimeStr + ` 2054 }` 2055 2056 testJSONMarshal(t, u, want) 2057 } 2058 2059 func TestPage_Marshal(t *testing.T) { 2060 t.Parallel() 2061 testJSONMarshal(t, &Page{}, "{}") 2062 2063 u := &Page{ 2064 PageName: Ptr("p"), 2065 Title: Ptr("t"), 2066 Summary: Ptr("s"), 2067 Action: Ptr("a"), 2068 SHA: Ptr("s"), 2069 HTMLURL: Ptr("h"), 2070 } 2071 2072 want := `{ 2073 "page_name": "p", 2074 "title": "t", 2075 "summary": "s", 2076 "action": "a", 2077 "sha": "s", 2078 "html_url": "h" 2079 }` 2080 2081 testJSONMarshal(t, u, want) 2082 } 2083 2084 func TestTeamChange_Marshal(t *testing.T) { 2085 t.Parallel() 2086 testJSONMarshal(t, &TeamChange{}, "{}") 2087 2088 u := &TeamChange{ 2089 Description: &TeamDescription{ 2090 From: Ptr("DescriptionFrom"), 2091 }, 2092 Name: &TeamName{ 2093 From: Ptr("NameFrom"), 2094 }, 2095 Privacy: &TeamPrivacy{ 2096 From: Ptr("PrivacyFrom"), 2097 }, 2098 Repository: &TeamRepository{ 2099 Permissions: &TeamPermissions{ 2100 From: &TeamPermissionsFrom{ 2101 Admin: Ptr(false), 2102 Pull: Ptr(false), 2103 Push: Ptr(false), 2104 }, 2105 }, 2106 }, 2107 } 2108 2109 want := `{ 2110 "description": { 2111 "from": "DescriptionFrom" 2112 }, 2113 "name": { 2114 "from": "NameFrom" 2115 }, 2116 "privacy": { 2117 "from": "PrivacyFrom" 2118 }, 2119 "repository": { 2120 "permissions": { 2121 "from": { 2122 "admin": false, 2123 "pull": false, 2124 "push": false 2125 } 2126 } 2127 } 2128 }` 2129 2130 testJSONMarshal(t, u, want) 2131 } 2132 2133 func TestIssueCommentEvent_Marshal(t *testing.T) { 2134 t.Parallel() 2135 testJSONMarshal(t, &IssueCommentEvent{}, "{}") 2136 2137 u := &IssueCommentEvent{ 2138 Action: Ptr("a"), 2139 Issue: &Issue{ID: Ptr(int64(1))}, 2140 Comment: &IssueComment{ID: Ptr(int64(1))}, 2141 Changes: &EditChange{ 2142 Title: &EditTitle{ 2143 From: Ptr("TitleFrom"), 2144 }, 2145 Body: &EditBody{ 2146 From: Ptr("BodyFrom"), 2147 }, 2148 Base: &EditBase{ 2149 Ref: &EditRef{ 2150 From: Ptr("BaseRefFrom"), 2151 }, 2152 SHA: &EditSHA{ 2153 From: Ptr("BaseSHAFrom"), 2154 }, 2155 }, 2156 }, 2157 Repo: &Repository{ 2158 ID: Ptr(int64(1)), 2159 URL: Ptr("s"), 2160 Name: Ptr("n"), 2161 }, 2162 Sender: &User{ 2163 Login: Ptr("l"), 2164 ID: Ptr(int64(1)), 2165 NodeID: Ptr("n"), 2166 URL: Ptr("u"), 2167 ReposURL: Ptr("r"), 2168 EventsURL: Ptr("e"), 2169 AvatarURL: Ptr("a"), 2170 }, 2171 Installation: &Installation{ 2172 ID: Ptr(int64(1)), 2173 NodeID: Ptr("nid"), 2174 AppID: Ptr(int64(1)), 2175 AppSlug: Ptr("as"), 2176 TargetID: Ptr(int64(1)), 2177 Account: &User{ 2178 Login: Ptr("l"), 2179 ID: Ptr(int64(1)), 2180 URL: Ptr("u"), 2181 AvatarURL: Ptr("a"), 2182 GravatarID: Ptr("g"), 2183 Name: Ptr("n"), 2184 Company: Ptr("c"), 2185 Blog: Ptr("b"), 2186 Location: Ptr("l"), 2187 Email: Ptr("e"), 2188 Hireable: Ptr(true), 2189 Bio: Ptr("b"), 2190 TwitterUsername: Ptr("t"), 2191 PublicRepos: Ptr(1), 2192 Followers: Ptr(1), 2193 Following: Ptr(1), 2194 CreatedAt: &Timestamp{referenceTime}, 2195 SuspendedAt: &Timestamp{referenceTime}, 2196 }, 2197 AccessTokensURL: Ptr("atu"), 2198 RepositoriesURL: Ptr("ru"), 2199 HTMLURL: Ptr("hu"), 2200 TargetType: Ptr("tt"), 2201 SingleFileName: Ptr("sfn"), 2202 RepositorySelection: Ptr("rs"), 2203 Events: []string{"e"}, 2204 SingleFilePaths: []string{"s"}, 2205 Permissions: &InstallationPermissions{ 2206 Actions: Ptr("a"), 2207 Administration: Ptr("ad"), 2208 Checks: Ptr("c"), 2209 Contents: Ptr("co"), 2210 ContentReferences: Ptr("cr"), 2211 Deployments: Ptr("d"), 2212 Environments: Ptr("e"), 2213 Issues: Ptr("i"), 2214 Metadata: Ptr("md"), 2215 Members: Ptr("m"), 2216 OrganizationAdministration: Ptr("oa"), 2217 OrganizationHooks: Ptr("oh"), 2218 OrganizationPlan: Ptr("op"), 2219 OrganizationPreReceiveHooks: Ptr("opr"), 2220 OrganizationProjects: Ptr("op"), 2221 OrganizationSecrets: Ptr("os"), 2222 OrganizationSelfHostedRunners: Ptr("osh"), 2223 OrganizationUserBlocking: Ptr("oub"), 2224 Packages: Ptr("pkg"), 2225 Pages: Ptr("pg"), 2226 PullRequests: Ptr("pr"), 2227 RepositoryHooks: Ptr("rh"), 2228 RepositoryProjects: Ptr("rp"), 2229 RepositoryPreReceiveHooks: Ptr("rprh"), 2230 Secrets: Ptr("s"), 2231 SecretScanningAlerts: Ptr("ssa"), 2232 SecurityEvents: Ptr("se"), 2233 SingleFile: Ptr("sf"), 2234 Statuses: Ptr("s"), 2235 TeamDiscussions: Ptr("td"), 2236 VulnerabilityAlerts: Ptr("va"), 2237 Workflows: Ptr("w"), 2238 }, 2239 CreatedAt: &Timestamp{referenceTime}, 2240 UpdatedAt: &Timestamp{referenceTime}, 2241 HasMultipleSingleFiles: Ptr(false), 2242 SuspendedBy: &User{ 2243 Login: Ptr("l"), 2244 ID: Ptr(int64(1)), 2245 URL: Ptr("u"), 2246 AvatarURL: Ptr("a"), 2247 GravatarID: Ptr("g"), 2248 Name: Ptr("n"), 2249 Company: Ptr("c"), 2250 Blog: Ptr("b"), 2251 Location: Ptr("l"), 2252 Email: Ptr("e"), 2253 Hireable: Ptr(true), 2254 Bio: Ptr("b"), 2255 TwitterUsername: Ptr("t"), 2256 PublicRepos: Ptr(1), 2257 Followers: Ptr(1), 2258 Following: Ptr(1), 2259 CreatedAt: &Timestamp{referenceTime}, 2260 SuspendedAt: &Timestamp{referenceTime}, 2261 }, 2262 SuspendedAt: &Timestamp{referenceTime}, 2263 }, 2264 Organization: &Organization{ 2265 BillingEmail: Ptr("be"), 2266 Blog: Ptr("b"), 2267 Company: Ptr("c"), 2268 Email: Ptr("e"), 2269 TwitterUsername: Ptr("tu"), 2270 Location: Ptr("loc"), 2271 Name: Ptr("n"), 2272 Description: Ptr("d"), 2273 IsVerified: Ptr(true), 2274 HasOrganizationProjects: Ptr(true), 2275 HasRepositoryProjects: Ptr(true), 2276 DefaultRepoPermission: Ptr("drp"), 2277 MembersCanCreateRepos: Ptr(true), 2278 MembersCanCreateInternalRepos: Ptr(true), 2279 MembersCanCreatePrivateRepos: Ptr(true), 2280 MembersCanCreatePublicRepos: Ptr(false), 2281 MembersAllowedRepositoryCreationType: Ptr("marct"), 2282 MembersCanCreatePages: Ptr(true), 2283 MembersCanCreatePublicPages: Ptr(false), 2284 MembersCanCreatePrivatePages: Ptr(true), 2285 }, 2286 } 2287 2288 want := `{ 2289 "action": "a", 2290 "issue": { 2291 "id": 1 2292 }, 2293 "comment": { 2294 "id": 1 2295 }, 2296 "changes": { 2297 "title": { 2298 "from": "TitleFrom" 2299 }, 2300 "body": { 2301 "from": "BodyFrom" 2302 }, 2303 "base": { 2304 "ref": { 2305 "from": "BaseRefFrom" 2306 }, 2307 "sha": { 2308 "from": "BaseSHAFrom" 2309 } 2310 } 2311 }, 2312 "repository": { 2313 "id": 1, 2314 "name": "n", 2315 "url": "s" 2316 }, 2317 "sender": { 2318 "login": "l", 2319 "id": 1, 2320 "node_id": "n", 2321 "avatar_url": "a", 2322 "url": "u", 2323 "events_url": "e", 2324 "repos_url": "r" 2325 }, 2326 "installation": { 2327 "id": 1, 2328 "node_id": "nid", 2329 "app_id": 1, 2330 "app_slug": "as", 2331 "target_id": 1, 2332 "account": { 2333 "login": "l", 2334 "id": 1, 2335 "avatar_url": "a", 2336 "gravatar_id": "g", 2337 "name": "n", 2338 "company": "c", 2339 "blog": "b", 2340 "location": "l", 2341 "email": "e", 2342 "hireable": true, 2343 "bio": "b", 2344 "twitter_username": "t", 2345 "public_repos": 1, 2346 "followers": 1, 2347 "following": 1, 2348 "created_at": ` + referenceTimeStr + `, 2349 "suspended_at": ` + referenceTimeStr + `, 2350 "url": "u" 2351 }, 2352 "access_tokens_url": "atu", 2353 "repositories_url": "ru", 2354 "html_url": "hu", 2355 "target_type": "tt", 2356 "single_file_name": "sfn", 2357 "repository_selection": "rs", 2358 "events": [ 2359 "e" 2360 ], 2361 "single_file_paths": [ 2362 "s" 2363 ], 2364 "permissions": { 2365 "actions": "a", 2366 "administration": "ad", 2367 "checks": "c", 2368 "contents": "co", 2369 "content_references": "cr", 2370 "deployments": "d", 2371 "environments": "e", 2372 "issues": "i", 2373 "metadata": "md", 2374 "members": "m", 2375 "organization_administration": "oa", 2376 "organization_hooks": "oh", 2377 "organization_plan": "op", 2378 "organization_pre_receive_hooks": "opr", 2379 "organization_projects": "op", 2380 "organization_secrets": "os", 2381 "organization_self_hosted_runners": "osh", 2382 "organization_user_blocking": "oub", 2383 "packages": "pkg", 2384 "pages": "pg", 2385 "pull_requests": "pr", 2386 "repository_hooks": "rh", 2387 "repository_projects": "rp", 2388 "repository_pre_receive_hooks": "rprh", 2389 "secrets": "s", 2390 "secret_scanning_alerts": "ssa", 2391 "security_events": "se", 2392 "single_file": "sf", 2393 "statuses": "s", 2394 "team_discussions": "td", 2395 "vulnerability_alerts": "va", 2396 "workflows": "w" 2397 }, 2398 "created_at": ` + referenceTimeStr + `, 2399 "updated_at": ` + referenceTimeStr + `, 2400 "has_multiple_single_files": false, 2401 "suspended_by": { 2402 "login": "l", 2403 "id": 1, 2404 "avatar_url": "a", 2405 "gravatar_id": "g", 2406 "name": "n", 2407 "company": "c", 2408 "blog": "b", 2409 "location": "l", 2410 "email": "e", 2411 "hireable": true, 2412 "bio": "b", 2413 "twitter_username": "t", 2414 "public_repos": 1, 2415 "followers": 1, 2416 "following": 1, 2417 "created_at": ` + referenceTimeStr + `, 2418 "suspended_at": ` + referenceTimeStr + `, 2419 "url": "u" 2420 }, 2421 "suspended_at": ` + referenceTimeStr + ` 2422 }, 2423 "organization": { 2424 "name": "n", 2425 "company": "c", 2426 "blog": "b", 2427 "location": "loc", 2428 "email": "e", 2429 "twitter_username": "tu", 2430 "description": "d", 2431 "billing_email": "be", 2432 "is_verified": true, 2433 "has_organization_projects": true, 2434 "has_repository_projects": true, 2435 "default_repository_permission": "drp", 2436 "members_can_create_repositories": true, 2437 "members_can_create_public_repositories": false, 2438 "members_can_create_private_repositories": true, 2439 "members_can_create_internal_repositories": true, 2440 "members_allowed_repository_creation_type": "marct", 2441 "members_can_create_pages": true, 2442 "members_can_create_public_pages": false, 2443 "members_can_create_private_pages": true 2444 } 2445 }` 2446 2447 testJSONMarshal(t, u, want) 2448 } 2449 2450 func TestIssuesEvent_Marshal(t *testing.T) { 2451 t.Parallel() 2452 testJSONMarshal(t, &IssuesEvent{}, "{}") 2453 2454 u := &IssuesEvent{ 2455 Action: Ptr("a"), 2456 Issue: &Issue{ID: Ptr(int64(1))}, 2457 Assignee: &User{ 2458 Login: Ptr("l"), 2459 ID: Ptr(int64(1)), 2460 NodeID: Ptr("n"), 2461 URL: Ptr("u"), 2462 ReposURL: Ptr("r"), 2463 EventsURL: Ptr("e"), 2464 AvatarURL: Ptr("a"), 2465 }, 2466 Label: &Label{ID: Ptr(int64(1))}, 2467 Changes: &EditChange{ 2468 Title: &EditTitle{ 2469 From: Ptr("TitleFrom"), 2470 }, 2471 Body: &EditBody{ 2472 From: Ptr("BodyFrom"), 2473 }, 2474 Base: &EditBase{ 2475 Ref: &EditRef{ 2476 From: Ptr("BaseRefFrom"), 2477 }, 2478 SHA: &EditSHA{ 2479 From: Ptr("BaseSHAFrom"), 2480 }, 2481 }, 2482 }, 2483 Repo: &Repository{ 2484 ID: Ptr(int64(1)), 2485 URL: Ptr("s"), 2486 Name: Ptr("n"), 2487 }, 2488 Sender: &User{ 2489 Login: Ptr("l"), 2490 ID: Ptr(int64(1)), 2491 NodeID: Ptr("n"), 2492 URL: Ptr("u"), 2493 ReposURL: Ptr("r"), 2494 EventsURL: Ptr("e"), 2495 AvatarURL: Ptr("a"), 2496 }, 2497 Installation: &Installation{ 2498 ID: Ptr(int64(1)), 2499 NodeID: Ptr("nid"), 2500 AppID: Ptr(int64(1)), 2501 AppSlug: Ptr("as"), 2502 TargetID: Ptr(int64(1)), 2503 Account: &User{ 2504 Login: Ptr("l"), 2505 ID: Ptr(int64(1)), 2506 URL: Ptr("u"), 2507 AvatarURL: Ptr("a"), 2508 GravatarID: Ptr("g"), 2509 Name: Ptr("n"), 2510 Company: Ptr("c"), 2511 Blog: Ptr("b"), 2512 Location: Ptr("l"), 2513 Email: Ptr("e"), 2514 Hireable: Ptr(true), 2515 Bio: Ptr("b"), 2516 TwitterUsername: Ptr("t"), 2517 PublicRepos: Ptr(1), 2518 Followers: Ptr(1), 2519 Following: Ptr(1), 2520 CreatedAt: &Timestamp{referenceTime}, 2521 SuspendedAt: &Timestamp{referenceTime}, 2522 }, 2523 AccessTokensURL: Ptr("atu"), 2524 RepositoriesURL: Ptr("ru"), 2525 HTMLURL: Ptr("hu"), 2526 TargetType: Ptr("tt"), 2527 SingleFileName: Ptr("sfn"), 2528 RepositorySelection: Ptr("rs"), 2529 Events: []string{"e"}, 2530 SingleFilePaths: []string{"s"}, 2531 Permissions: &InstallationPermissions{ 2532 Actions: Ptr("a"), 2533 Administration: Ptr("ad"), 2534 Checks: Ptr("c"), 2535 Contents: Ptr("co"), 2536 ContentReferences: Ptr("cr"), 2537 Deployments: Ptr("d"), 2538 Environments: Ptr("e"), 2539 Issues: Ptr("i"), 2540 Metadata: Ptr("md"), 2541 Members: Ptr("m"), 2542 OrganizationAdministration: Ptr("oa"), 2543 OrganizationHooks: Ptr("oh"), 2544 OrganizationPlan: Ptr("op"), 2545 OrganizationPreReceiveHooks: Ptr("opr"), 2546 OrganizationProjects: Ptr("op"), 2547 OrganizationSecrets: Ptr("os"), 2548 OrganizationSelfHostedRunners: Ptr("osh"), 2549 OrganizationUserBlocking: Ptr("oub"), 2550 Packages: Ptr("pkg"), 2551 Pages: Ptr("pg"), 2552 PullRequests: Ptr("pr"), 2553 RepositoryHooks: Ptr("rh"), 2554 RepositoryProjects: Ptr("rp"), 2555 RepositoryPreReceiveHooks: Ptr("rprh"), 2556 Secrets: Ptr("s"), 2557 SecretScanningAlerts: Ptr("ssa"), 2558 SecurityEvents: Ptr("se"), 2559 SingleFile: Ptr("sf"), 2560 Statuses: Ptr("s"), 2561 TeamDiscussions: Ptr("td"), 2562 VulnerabilityAlerts: Ptr("va"), 2563 Workflows: Ptr("w"), 2564 }, 2565 CreatedAt: &Timestamp{referenceTime}, 2566 UpdatedAt: &Timestamp{referenceTime}, 2567 HasMultipleSingleFiles: Ptr(false), 2568 SuspendedBy: &User{ 2569 Login: Ptr("l"), 2570 ID: Ptr(int64(1)), 2571 URL: Ptr("u"), 2572 AvatarURL: Ptr("a"), 2573 GravatarID: Ptr("g"), 2574 Name: Ptr("n"), 2575 Company: Ptr("c"), 2576 Blog: Ptr("b"), 2577 Location: Ptr("l"), 2578 Email: Ptr("e"), 2579 Hireable: Ptr(true), 2580 Bio: Ptr("b"), 2581 TwitterUsername: Ptr("t"), 2582 PublicRepos: Ptr(1), 2583 Followers: Ptr(1), 2584 Following: Ptr(1), 2585 CreatedAt: &Timestamp{referenceTime}, 2586 SuspendedAt: &Timestamp{referenceTime}, 2587 }, 2588 SuspendedAt: &Timestamp{referenceTime}, 2589 }, 2590 } 2591 2592 want := `{ 2593 "action": "a", 2594 "issue": { 2595 "id": 1 2596 }, 2597 "assignee": { 2598 "login": "l", 2599 "id": 1, 2600 "node_id": "n", 2601 "avatar_url": "a", 2602 "url": "u", 2603 "events_url": "e", 2604 "repos_url": "r" 2605 }, 2606 "label": { 2607 "id": 1 2608 }, 2609 "changes": { 2610 "title": { 2611 "from": "TitleFrom" 2612 }, 2613 "body": { 2614 "from": "BodyFrom" 2615 }, 2616 "base": { 2617 "ref": { 2618 "from": "BaseRefFrom" 2619 }, 2620 "sha": { 2621 "from": "BaseSHAFrom" 2622 } 2623 } 2624 }, 2625 "repository": { 2626 "id": 1, 2627 "name": "n", 2628 "url": "s" 2629 }, 2630 "sender": { 2631 "login": "l", 2632 "id": 1, 2633 "node_id": "n", 2634 "avatar_url": "a", 2635 "url": "u", 2636 "events_url": "e", 2637 "repos_url": "r" 2638 }, 2639 "installation": { 2640 "id": 1, 2641 "node_id": "nid", 2642 "app_id": 1, 2643 "app_slug": "as", 2644 "target_id": 1, 2645 "account": { 2646 "login": "l", 2647 "id": 1, 2648 "avatar_url": "a", 2649 "gravatar_id": "g", 2650 "name": "n", 2651 "company": "c", 2652 "blog": "b", 2653 "location": "l", 2654 "email": "e", 2655 "hireable": true, 2656 "bio": "b", 2657 "twitter_username": "t", 2658 "public_repos": 1, 2659 "followers": 1, 2660 "following": 1, 2661 "created_at": ` + referenceTimeStr + `, 2662 "suspended_at": ` + referenceTimeStr + `, 2663 "url": "u" 2664 }, 2665 "access_tokens_url": "atu", 2666 "repositories_url": "ru", 2667 "html_url": "hu", 2668 "target_type": "tt", 2669 "single_file_name": "sfn", 2670 "repository_selection": "rs", 2671 "events": [ 2672 "e" 2673 ], 2674 "single_file_paths": [ 2675 "s" 2676 ], 2677 "permissions": { 2678 "actions": "a", 2679 "administration": "ad", 2680 "checks": "c", 2681 "contents": "co", 2682 "content_references": "cr", 2683 "deployments": "d", 2684 "environments": "e", 2685 "issues": "i", 2686 "metadata": "md", 2687 "members": "m", 2688 "organization_administration": "oa", 2689 "organization_hooks": "oh", 2690 "organization_plan": "op", 2691 "organization_pre_receive_hooks": "opr", 2692 "organization_projects": "op", 2693 "organization_secrets": "os", 2694 "organization_self_hosted_runners": "osh", 2695 "organization_user_blocking": "oub", 2696 "packages": "pkg", 2697 "pages": "pg", 2698 "pull_requests": "pr", 2699 "repository_hooks": "rh", 2700 "repository_projects": "rp", 2701 "repository_pre_receive_hooks": "rprh", 2702 "secrets": "s", 2703 "secret_scanning_alerts": "ssa", 2704 "security_events": "se", 2705 "single_file": "sf", 2706 "statuses": "s", 2707 "team_discussions": "td", 2708 "vulnerability_alerts": "va", 2709 "workflows": "w" 2710 }, 2711 "created_at": ` + referenceTimeStr + `, 2712 "updated_at": ` + referenceTimeStr + `, 2713 "has_multiple_single_files": false, 2714 "suspended_by": { 2715 "login": "l", 2716 "id": 1, 2717 "avatar_url": "a", 2718 "gravatar_id": "g", 2719 "name": "n", 2720 "company": "c", 2721 "blog": "b", 2722 "location": "l", 2723 "email": "e", 2724 "hireable": true, 2725 "bio": "b", 2726 "twitter_username": "t", 2727 "public_repos": 1, 2728 "followers": 1, 2729 "following": 1, 2730 "created_at": ` + referenceTimeStr + `, 2731 "suspended_at": ` + referenceTimeStr + `, 2732 "url": "u" 2733 }, 2734 "suspended_at": ` + referenceTimeStr + ` 2735 } 2736 }` 2737 2738 testJSONMarshal(t, u, want) 2739 } 2740 2741 func TestLabelEvent_Marshal(t *testing.T) { 2742 t.Parallel() 2743 testJSONMarshal(t, &LabelEvent{}, "{}") 2744 2745 u := &LabelEvent{ 2746 Action: Ptr("a"), 2747 Label: &Label{ID: Ptr(int64(1))}, 2748 Changes: &EditChange{ 2749 Title: &EditTitle{ 2750 From: Ptr("TitleFrom"), 2751 }, 2752 Body: &EditBody{ 2753 From: Ptr("BodyFrom"), 2754 }, 2755 Base: &EditBase{ 2756 Ref: &EditRef{ 2757 From: Ptr("BaseRefFrom"), 2758 }, 2759 SHA: &EditSHA{ 2760 From: Ptr("BaseSHAFrom"), 2761 }, 2762 }, 2763 }, 2764 Repo: &Repository{ 2765 ID: Ptr(int64(1)), 2766 URL: Ptr("s"), 2767 Name: Ptr("n"), 2768 }, 2769 Org: &Organization{ 2770 BillingEmail: Ptr("be"), 2771 Blog: Ptr("b"), 2772 Company: Ptr("c"), 2773 Email: Ptr("e"), 2774 TwitterUsername: Ptr("tu"), 2775 Location: Ptr("loc"), 2776 Name: Ptr("n"), 2777 Description: Ptr("d"), 2778 IsVerified: Ptr(true), 2779 HasOrganizationProjects: Ptr(true), 2780 HasRepositoryProjects: Ptr(true), 2781 DefaultRepoPermission: Ptr("drp"), 2782 MembersCanCreateRepos: Ptr(true), 2783 MembersCanCreateInternalRepos: Ptr(true), 2784 MembersCanCreatePrivateRepos: Ptr(true), 2785 MembersCanCreatePublicRepos: Ptr(false), 2786 MembersAllowedRepositoryCreationType: Ptr("marct"), 2787 MembersCanCreatePages: Ptr(true), 2788 MembersCanCreatePublicPages: Ptr(false), 2789 MembersCanCreatePrivatePages: Ptr(true), 2790 }, 2791 Installation: &Installation{ 2792 ID: Ptr(int64(1)), 2793 NodeID: Ptr("nid"), 2794 AppID: Ptr(int64(1)), 2795 AppSlug: Ptr("as"), 2796 TargetID: Ptr(int64(1)), 2797 Account: &User{ 2798 Login: Ptr("l"), 2799 ID: Ptr(int64(1)), 2800 URL: Ptr("u"), 2801 AvatarURL: Ptr("a"), 2802 GravatarID: Ptr("g"), 2803 Name: Ptr("n"), 2804 Company: Ptr("c"), 2805 Blog: Ptr("b"), 2806 Location: Ptr("l"), 2807 Email: Ptr("e"), 2808 Hireable: Ptr(true), 2809 Bio: Ptr("b"), 2810 TwitterUsername: Ptr("t"), 2811 PublicRepos: Ptr(1), 2812 Followers: Ptr(1), 2813 Following: Ptr(1), 2814 CreatedAt: &Timestamp{referenceTime}, 2815 SuspendedAt: &Timestamp{referenceTime}, 2816 }, 2817 AccessTokensURL: Ptr("atu"), 2818 RepositoriesURL: Ptr("ru"), 2819 HTMLURL: Ptr("hu"), 2820 TargetType: Ptr("tt"), 2821 SingleFileName: Ptr("sfn"), 2822 RepositorySelection: Ptr("rs"), 2823 Events: []string{"e"}, 2824 SingleFilePaths: []string{"s"}, 2825 Permissions: &InstallationPermissions{ 2826 Actions: Ptr("a"), 2827 Administration: Ptr("ad"), 2828 Checks: Ptr("c"), 2829 Contents: Ptr("co"), 2830 ContentReferences: Ptr("cr"), 2831 Deployments: Ptr("d"), 2832 Environments: Ptr("e"), 2833 Issues: Ptr("i"), 2834 Metadata: Ptr("md"), 2835 Members: Ptr("m"), 2836 OrganizationAdministration: Ptr("oa"), 2837 OrganizationHooks: Ptr("oh"), 2838 OrganizationPlan: Ptr("op"), 2839 OrganizationPreReceiveHooks: Ptr("opr"), 2840 OrganizationProjects: Ptr("op"), 2841 OrganizationSecrets: Ptr("os"), 2842 OrganizationSelfHostedRunners: Ptr("osh"), 2843 OrganizationUserBlocking: Ptr("oub"), 2844 Packages: Ptr("pkg"), 2845 Pages: Ptr("pg"), 2846 PullRequests: Ptr("pr"), 2847 RepositoryHooks: Ptr("rh"), 2848 RepositoryProjects: Ptr("rp"), 2849 RepositoryPreReceiveHooks: Ptr("rprh"), 2850 Secrets: Ptr("s"), 2851 SecretScanningAlerts: Ptr("ssa"), 2852 SecurityEvents: Ptr("se"), 2853 SingleFile: Ptr("sf"), 2854 Statuses: Ptr("s"), 2855 TeamDiscussions: Ptr("td"), 2856 VulnerabilityAlerts: Ptr("va"), 2857 Workflows: Ptr("w"), 2858 }, 2859 CreatedAt: &Timestamp{referenceTime}, 2860 UpdatedAt: &Timestamp{referenceTime}, 2861 HasMultipleSingleFiles: Ptr(false), 2862 SuspendedBy: &User{ 2863 Login: Ptr("l"), 2864 ID: Ptr(int64(1)), 2865 URL: Ptr("u"), 2866 AvatarURL: Ptr("a"), 2867 GravatarID: Ptr("g"), 2868 Name: Ptr("n"), 2869 Company: Ptr("c"), 2870 Blog: Ptr("b"), 2871 Location: Ptr("l"), 2872 Email: Ptr("e"), 2873 Hireable: Ptr(true), 2874 Bio: Ptr("b"), 2875 TwitterUsername: Ptr("t"), 2876 PublicRepos: Ptr(1), 2877 Followers: Ptr(1), 2878 Following: Ptr(1), 2879 CreatedAt: &Timestamp{referenceTime}, 2880 SuspendedAt: &Timestamp{referenceTime}, 2881 }, 2882 SuspendedAt: &Timestamp{referenceTime}, 2883 }, 2884 } 2885 2886 want := `{ 2887 "action": "a", 2888 "label": { 2889 "id": 1 2890 }, 2891 "changes": { 2892 "title": { 2893 "from": "TitleFrom" 2894 }, 2895 "body": { 2896 "from": "BodyFrom" 2897 }, 2898 "base": { 2899 "ref": { 2900 "from": "BaseRefFrom" 2901 }, 2902 "sha": { 2903 "from": "BaseSHAFrom" 2904 } 2905 } 2906 }, 2907 "repository": { 2908 "id": 1, 2909 "name": "n", 2910 "url": "s" 2911 }, 2912 "organization": { 2913 "name": "n", 2914 "company": "c", 2915 "blog": "b", 2916 "location": "loc", 2917 "email": "e", 2918 "twitter_username": "tu", 2919 "description": "d", 2920 "billing_email": "be", 2921 "is_verified": true, 2922 "has_organization_projects": true, 2923 "has_repository_projects": true, 2924 "default_repository_permission": "drp", 2925 "members_can_create_repositories": true, 2926 "members_can_create_public_repositories": false, 2927 "members_can_create_private_repositories": true, 2928 "members_can_create_internal_repositories": true, 2929 "members_allowed_repository_creation_type": "marct", 2930 "members_can_create_pages": true, 2931 "members_can_create_public_pages": false, 2932 "members_can_create_private_pages": true 2933 }, 2934 "installation": { 2935 "id": 1, 2936 "node_id": "nid", 2937 "app_id": 1, 2938 "app_slug": "as", 2939 "target_id": 1, 2940 "account": { 2941 "login": "l", 2942 "id": 1, 2943 "avatar_url": "a", 2944 "gravatar_id": "g", 2945 "name": "n", 2946 "company": "c", 2947 "blog": "b", 2948 "location": "l", 2949 "email": "e", 2950 "hireable": true, 2951 "bio": "b", 2952 "twitter_username": "t", 2953 "public_repos": 1, 2954 "followers": 1, 2955 "following": 1, 2956 "created_at": ` + referenceTimeStr + `, 2957 "suspended_at": ` + referenceTimeStr + `, 2958 "url": "u" 2959 }, 2960 "access_tokens_url": "atu", 2961 "repositories_url": "ru", 2962 "html_url": "hu", 2963 "target_type": "tt", 2964 "single_file_name": "sfn", 2965 "repository_selection": "rs", 2966 "events": [ 2967 "e" 2968 ], 2969 "single_file_paths": [ 2970 "s" 2971 ], 2972 "permissions": { 2973 "actions": "a", 2974 "administration": "ad", 2975 "checks": "c", 2976 "contents": "co", 2977 "content_references": "cr", 2978 "deployments": "d", 2979 "environments": "e", 2980 "issues": "i", 2981 "metadata": "md", 2982 "members": "m", 2983 "organization_administration": "oa", 2984 "organization_hooks": "oh", 2985 "organization_plan": "op", 2986 "organization_pre_receive_hooks": "opr", 2987 "organization_projects": "op", 2988 "organization_secrets": "os", 2989 "organization_self_hosted_runners": "osh", 2990 "organization_user_blocking": "oub", 2991 "packages": "pkg", 2992 "pages": "pg", 2993 "pull_requests": "pr", 2994 "repository_hooks": "rh", 2995 "repository_projects": "rp", 2996 "repository_pre_receive_hooks": "rprh", 2997 "secrets": "s", 2998 "secret_scanning_alerts": "ssa", 2999 "security_events": "se", 3000 "single_file": "sf", 3001 "statuses": "s", 3002 "team_discussions": "td", 3003 "vulnerability_alerts": "va", 3004 "workflows": "w" 3005 }, 3006 "created_at": ` + referenceTimeStr + `, 3007 "updated_at": ` + referenceTimeStr + `, 3008 "has_multiple_single_files": false, 3009 "suspended_by": { 3010 "login": "l", 3011 "id": 1, 3012 "avatar_url": "a", 3013 "gravatar_id": "g", 3014 "name": "n", 3015 "company": "c", 3016 "blog": "b", 3017 "location": "l", 3018 "email": "e", 3019 "hireable": true, 3020 "bio": "b", 3021 "twitter_username": "t", 3022 "public_repos": 1, 3023 "followers": 1, 3024 "following": 1, 3025 "created_at": ` + referenceTimeStr + `, 3026 "suspended_at": ` + referenceTimeStr + `, 3027 "url": "u" 3028 }, 3029 "suspended_at": ` + referenceTimeStr + ` 3030 } 3031 }` 3032 3033 testJSONMarshal(t, u, want) 3034 } 3035 3036 func TestMilestoneEvent_Marshal(t *testing.T) { 3037 t.Parallel() 3038 testJSONMarshal(t, &MilestoneEvent{}, "{}") 3039 3040 u := &MilestoneEvent{ 3041 Action: Ptr("a"), 3042 Milestone: &Milestone{ID: Ptr(int64(1))}, 3043 Changes: &EditChange{ 3044 Title: &EditTitle{ 3045 From: Ptr("TitleFrom"), 3046 }, 3047 Body: &EditBody{ 3048 From: Ptr("BodyFrom"), 3049 }, 3050 Base: &EditBase{ 3051 Ref: &EditRef{ 3052 From: Ptr("BaseRefFrom"), 3053 }, 3054 SHA: &EditSHA{ 3055 From: Ptr("BaseSHAFrom"), 3056 }, 3057 }, 3058 }, 3059 Repo: &Repository{ 3060 ID: Ptr(int64(1)), 3061 URL: Ptr("s"), 3062 Name: Ptr("n"), 3063 }, 3064 Sender: &User{ 3065 Login: Ptr("l"), 3066 ID: Ptr(int64(1)), 3067 NodeID: Ptr("n"), 3068 URL: Ptr("u"), 3069 ReposURL: Ptr("r"), 3070 EventsURL: Ptr("e"), 3071 AvatarURL: Ptr("a"), 3072 }, 3073 Org: &Organization{ 3074 BillingEmail: Ptr("be"), 3075 Blog: Ptr("b"), 3076 Company: Ptr("c"), 3077 Email: Ptr("e"), 3078 TwitterUsername: Ptr("tu"), 3079 Location: Ptr("loc"), 3080 Name: Ptr("n"), 3081 Description: Ptr("d"), 3082 IsVerified: Ptr(true), 3083 HasOrganizationProjects: Ptr(true), 3084 HasRepositoryProjects: Ptr(true), 3085 DefaultRepoPermission: Ptr("drp"), 3086 MembersCanCreateRepos: Ptr(true), 3087 MembersCanCreateInternalRepos: Ptr(true), 3088 MembersCanCreatePrivateRepos: Ptr(true), 3089 MembersCanCreatePublicRepos: Ptr(false), 3090 MembersAllowedRepositoryCreationType: Ptr("marct"), 3091 MembersCanCreatePages: Ptr(true), 3092 MembersCanCreatePublicPages: Ptr(false), 3093 MembersCanCreatePrivatePages: Ptr(true), 3094 }, 3095 Installation: &Installation{ 3096 ID: Ptr(int64(1)), 3097 NodeID: Ptr("nid"), 3098 AppID: Ptr(int64(1)), 3099 AppSlug: Ptr("as"), 3100 TargetID: Ptr(int64(1)), 3101 Account: &User{ 3102 Login: Ptr("l"), 3103 ID: Ptr(int64(1)), 3104 URL: Ptr("u"), 3105 AvatarURL: Ptr("a"), 3106 GravatarID: Ptr("g"), 3107 Name: Ptr("n"), 3108 Company: Ptr("c"), 3109 Blog: Ptr("b"), 3110 Location: Ptr("l"), 3111 Email: Ptr("e"), 3112 Hireable: Ptr(true), 3113 Bio: Ptr("b"), 3114 TwitterUsername: Ptr("t"), 3115 PublicRepos: Ptr(1), 3116 Followers: Ptr(1), 3117 Following: Ptr(1), 3118 CreatedAt: &Timestamp{referenceTime}, 3119 SuspendedAt: &Timestamp{referenceTime}, 3120 }, 3121 AccessTokensURL: Ptr("atu"), 3122 RepositoriesURL: Ptr("ru"), 3123 HTMLURL: Ptr("hu"), 3124 TargetType: Ptr("tt"), 3125 SingleFileName: Ptr("sfn"), 3126 RepositorySelection: Ptr("rs"), 3127 Events: []string{"e"}, 3128 SingleFilePaths: []string{"s"}, 3129 Permissions: &InstallationPermissions{ 3130 Actions: Ptr("a"), 3131 Administration: Ptr("ad"), 3132 Checks: Ptr("c"), 3133 Contents: Ptr("co"), 3134 ContentReferences: Ptr("cr"), 3135 Deployments: Ptr("d"), 3136 Environments: Ptr("e"), 3137 Issues: Ptr("i"), 3138 Metadata: Ptr("md"), 3139 Members: Ptr("m"), 3140 OrganizationAdministration: Ptr("oa"), 3141 OrganizationHooks: Ptr("oh"), 3142 OrganizationPlan: Ptr("op"), 3143 OrganizationPreReceiveHooks: Ptr("opr"), 3144 OrganizationProjects: Ptr("op"), 3145 OrganizationSecrets: Ptr("os"), 3146 OrganizationSelfHostedRunners: Ptr("osh"), 3147 OrganizationUserBlocking: Ptr("oub"), 3148 Packages: Ptr("pkg"), 3149 Pages: Ptr("pg"), 3150 PullRequests: Ptr("pr"), 3151 RepositoryHooks: Ptr("rh"), 3152 RepositoryProjects: Ptr("rp"), 3153 RepositoryPreReceiveHooks: Ptr("rprh"), 3154 Secrets: Ptr("s"), 3155 SecretScanningAlerts: Ptr("ssa"), 3156 SecurityEvents: Ptr("se"), 3157 SingleFile: Ptr("sf"), 3158 Statuses: Ptr("s"), 3159 TeamDiscussions: Ptr("td"), 3160 VulnerabilityAlerts: Ptr("va"), 3161 Workflows: Ptr("w"), 3162 }, 3163 CreatedAt: &Timestamp{referenceTime}, 3164 UpdatedAt: &Timestamp{referenceTime}, 3165 HasMultipleSingleFiles: Ptr(false), 3166 SuspendedBy: &User{ 3167 Login: Ptr("l"), 3168 ID: Ptr(int64(1)), 3169 URL: Ptr("u"), 3170 AvatarURL: Ptr("a"), 3171 GravatarID: Ptr("g"), 3172 Name: Ptr("n"), 3173 Company: Ptr("c"), 3174 Blog: Ptr("b"), 3175 Location: Ptr("l"), 3176 Email: Ptr("e"), 3177 Hireable: Ptr(true), 3178 Bio: Ptr("b"), 3179 TwitterUsername: Ptr("t"), 3180 PublicRepos: Ptr(1), 3181 Followers: Ptr(1), 3182 Following: Ptr(1), 3183 CreatedAt: &Timestamp{referenceTime}, 3184 SuspendedAt: &Timestamp{referenceTime}, 3185 }, 3186 SuspendedAt: &Timestamp{referenceTime}, 3187 }, 3188 } 3189 3190 want := `{ 3191 "action": "a", 3192 "milestone": { 3193 "id": 1 3194 }, 3195 "changes": { 3196 "title": { 3197 "from": "TitleFrom" 3198 }, 3199 "body": { 3200 "from": "BodyFrom" 3201 }, 3202 "base": { 3203 "ref": { 3204 "from": "BaseRefFrom" 3205 }, 3206 "sha": { 3207 "from": "BaseSHAFrom" 3208 } 3209 } 3210 }, 3211 "repository": { 3212 "id": 1, 3213 "name": "n", 3214 "url": "s" 3215 }, 3216 "sender": { 3217 "login": "l", 3218 "id": 1, 3219 "node_id": "n", 3220 "avatar_url": "a", 3221 "url": "u", 3222 "events_url": "e", 3223 "repos_url": "r" 3224 }, 3225 "organization": { 3226 "name": "n", 3227 "company": "c", 3228 "blog": "b", 3229 "location": "loc", 3230 "email": "e", 3231 "twitter_username": "tu", 3232 "description": "d", 3233 "billing_email": "be", 3234 "is_verified": true, 3235 "has_organization_projects": true, 3236 "has_repository_projects": true, 3237 "default_repository_permission": "drp", 3238 "members_can_create_repositories": true, 3239 "members_can_create_public_repositories": false, 3240 "members_can_create_private_repositories": true, 3241 "members_can_create_internal_repositories": true, 3242 "members_allowed_repository_creation_type": "marct", 3243 "members_can_create_pages": true, 3244 "members_can_create_public_pages": false, 3245 "members_can_create_private_pages": true 3246 }, 3247 "installation": { 3248 "id": 1, 3249 "node_id": "nid", 3250 "app_id": 1, 3251 "app_slug": "as", 3252 "target_id": 1, 3253 "account": { 3254 "login": "l", 3255 "id": 1, 3256 "avatar_url": "a", 3257 "gravatar_id": "g", 3258 "name": "n", 3259 "company": "c", 3260 "blog": "b", 3261 "location": "l", 3262 "email": "e", 3263 "hireable": true, 3264 "bio": "b", 3265 "twitter_username": "t", 3266 "public_repos": 1, 3267 "followers": 1, 3268 "following": 1, 3269 "created_at": ` + referenceTimeStr + `, 3270 "suspended_at": ` + referenceTimeStr + `, 3271 "url": "u" 3272 }, 3273 "access_tokens_url": "atu", 3274 "repositories_url": "ru", 3275 "html_url": "hu", 3276 "target_type": "tt", 3277 "single_file_name": "sfn", 3278 "repository_selection": "rs", 3279 "events": [ 3280 "e" 3281 ], 3282 "single_file_paths": [ 3283 "s" 3284 ], 3285 "permissions": { 3286 "actions": "a", 3287 "administration": "ad", 3288 "checks": "c", 3289 "contents": "co", 3290 "content_references": "cr", 3291 "deployments": "d", 3292 "environments": "e", 3293 "issues": "i", 3294 "metadata": "md", 3295 "members": "m", 3296 "organization_administration": "oa", 3297 "organization_hooks": "oh", 3298 "organization_plan": "op", 3299 "organization_pre_receive_hooks": "opr", 3300 "organization_projects": "op", 3301 "organization_secrets": "os", 3302 "organization_self_hosted_runners": "osh", 3303 "organization_user_blocking": "oub", 3304 "packages": "pkg", 3305 "pages": "pg", 3306 "pull_requests": "pr", 3307 "repository_hooks": "rh", 3308 "repository_projects": "rp", 3309 "repository_pre_receive_hooks": "rprh", 3310 "secrets": "s", 3311 "secret_scanning_alerts": "ssa", 3312 "security_events": "se", 3313 "single_file": "sf", 3314 "statuses": "s", 3315 "team_discussions": "td", 3316 "vulnerability_alerts": "va", 3317 "workflows": "w" 3318 }, 3319 "created_at": ` + referenceTimeStr + `, 3320 "updated_at": ` + referenceTimeStr + `, 3321 "has_multiple_single_files": false, 3322 "suspended_by": { 3323 "login": "l", 3324 "id": 1, 3325 "avatar_url": "a", 3326 "gravatar_id": "g", 3327 "name": "n", 3328 "company": "c", 3329 "blog": "b", 3330 "location": "l", 3331 "email": "e", 3332 "hireable": true, 3333 "bio": "b", 3334 "twitter_username": "t", 3335 "public_repos": 1, 3336 "followers": 1, 3337 "following": 1, 3338 "created_at": ` + referenceTimeStr + `, 3339 "suspended_at": ` + referenceTimeStr + `, 3340 "url": "u" 3341 }, 3342 "suspended_at": ` + referenceTimeStr + ` 3343 } 3344 }` 3345 3346 testJSONMarshal(t, u, want) 3347 } 3348 3349 func TestPublicEvent_Marshal(t *testing.T) { 3350 t.Parallel() 3351 testJSONMarshal(t, &PublicEvent{}, "{}") 3352 3353 u := &PublicEvent{ 3354 Repo: &Repository{ 3355 ID: Ptr(int64(1)), 3356 URL: Ptr("s"), 3357 Name: Ptr("n"), 3358 }, 3359 Sender: &User{ 3360 Login: Ptr("l"), 3361 ID: Ptr(int64(1)), 3362 NodeID: Ptr("n"), 3363 URL: Ptr("u"), 3364 ReposURL: Ptr("r"), 3365 EventsURL: Ptr("e"), 3366 AvatarURL: Ptr("a"), 3367 }, 3368 Installation: &Installation{ 3369 ID: Ptr(int64(1)), 3370 NodeID: Ptr("nid"), 3371 AppID: Ptr(int64(1)), 3372 AppSlug: Ptr("as"), 3373 TargetID: Ptr(int64(1)), 3374 Account: &User{ 3375 Login: Ptr("l"), 3376 ID: Ptr(int64(1)), 3377 URL: Ptr("u"), 3378 AvatarURL: Ptr("a"), 3379 GravatarID: Ptr("g"), 3380 Name: Ptr("n"), 3381 Company: Ptr("c"), 3382 Blog: Ptr("b"), 3383 Location: Ptr("l"), 3384 Email: Ptr("e"), 3385 Hireable: Ptr(true), 3386 Bio: Ptr("b"), 3387 TwitterUsername: Ptr("t"), 3388 PublicRepos: Ptr(1), 3389 Followers: Ptr(1), 3390 Following: Ptr(1), 3391 CreatedAt: &Timestamp{referenceTime}, 3392 SuspendedAt: &Timestamp{referenceTime}, 3393 }, 3394 AccessTokensURL: Ptr("atu"), 3395 RepositoriesURL: Ptr("ru"), 3396 HTMLURL: Ptr("hu"), 3397 TargetType: Ptr("tt"), 3398 SingleFileName: Ptr("sfn"), 3399 RepositorySelection: Ptr("rs"), 3400 Events: []string{"e"}, 3401 SingleFilePaths: []string{"s"}, 3402 Permissions: &InstallationPermissions{ 3403 Actions: Ptr("a"), 3404 Administration: Ptr("ad"), 3405 Checks: Ptr("c"), 3406 Contents: Ptr("co"), 3407 ContentReferences: Ptr("cr"), 3408 Deployments: Ptr("d"), 3409 Environments: Ptr("e"), 3410 Issues: Ptr("i"), 3411 Metadata: Ptr("md"), 3412 Members: Ptr("m"), 3413 OrganizationAdministration: Ptr("oa"), 3414 OrganizationHooks: Ptr("oh"), 3415 OrganizationPlan: Ptr("op"), 3416 OrganizationPreReceiveHooks: Ptr("opr"), 3417 OrganizationProjects: Ptr("op"), 3418 OrganizationSecrets: Ptr("os"), 3419 OrganizationSelfHostedRunners: Ptr("osh"), 3420 OrganizationUserBlocking: Ptr("oub"), 3421 Packages: Ptr("pkg"), 3422 Pages: Ptr("pg"), 3423 PullRequests: Ptr("pr"), 3424 RepositoryHooks: Ptr("rh"), 3425 RepositoryProjects: Ptr("rp"), 3426 RepositoryPreReceiveHooks: Ptr("rprh"), 3427 Secrets: Ptr("s"), 3428 SecretScanningAlerts: Ptr("ssa"), 3429 SecurityEvents: Ptr("se"), 3430 SingleFile: Ptr("sf"), 3431 Statuses: Ptr("s"), 3432 TeamDiscussions: Ptr("td"), 3433 VulnerabilityAlerts: Ptr("va"), 3434 Workflows: Ptr("w"), 3435 }, 3436 CreatedAt: &Timestamp{referenceTime}, 3437 UpdatedAt: &Timestamp{referenceTime}, 3438 HasMultipleSingleFiles: Ptr(false), 3439 SuspendedBy: &User{ 3440 Login: Ptr("l"), 3441 ID: Ptr(int64(1)), 3442 URL: Ptr("u"), 3443 AvatarURL: Ptr("a"), 3444 GravatarID: Ptr("g"), 3445 Name: Ptr("n"), 3446 Company: Ptr("c"), 3447 Blog: Ptr("b"), 3448 Location: Ptr("l"), 3449 Email: Ptr("e"), 3450 Hireable: Ptr(true), 3451 Bio: Ptr("b"), 3452 TwitterUsername: Ptr("t"), 3453 PublicRepos: Ptr(1), 3454 Followers: Ptr(1), 3455 Following: Ptr(1), 3456 CreatedAt: &Timestamp{referenceTime}, 3457 SuspendedAt: &Timestamp{referenceTime}, 3458 }, 3459 SuspendedAt: &Timestamp{referenceTime}, 3460 }, 3461 } 3462 3463 want := `{ 3464 "repository": { 3465 "id": 1, 3466 "name": "n", 3467 "url": "s" 3468 }, 3469 "sender": { 3470 "login": "l", 3471 "id": 1, 3472 "node_id": "n", 3473 "avatar_url": "a", 3474 "url": "u", 3475 "events_url": "e", 3476 "repos_url": "r" 3477 }, 3478 "installation": { 3479 "id": 1, 3480 "node_id": "nid", 3481 "app_id": 1, 3482 "app_slug": "as", 3483 "target_id": 1, 3484 "account": { 3485 "login": "l", 3486 "id": 1, 3487 "avatar_url": "a", 3488 "gravatar_id": "g", 3489 "name": "n", 3490 "company": "c", 3491 "blog": "b", 3492 "location": "l", 3493 "email": "e", 3494 "hireable": true, 3495 "bio": "b", 3496 "twitter_username": "t", 3497 "public_repos": 1, 3498 "followers": 1, 3499 "following": 1, 3500 "created_at": ` + referenceTimeStr + `, 3501 "suspended_at": ` + referenceTimeStr + `, 3502 "url": "u" 3503 }, 3504 "access_tokens_url": "atu", 3505 "repositories_url": "ru", 3506 "html_url": "hu", 3507 "target_type": "tt", 3508 "single_file_name": "sfn", 3509 "repository_selection": "rs", 3510 "events": [ 3511 "e" 3512 ], 3513 "single_file_paths": [ 3514 "s" 3515 ], 3516 "permissions": { 3517 "actions": "a", 3518 "administration": "ad", 3519 "checks": "c", 3520 "contents": "co", 3521 "content_references": "cr", 3522 "deployments": "d", 3523 "environments": "e", 3524 "issues": "i", 3525 "metadata": "md", 3526 "members": "m", 3527 "organization_administration": "oa", 3528 "organization_hooks": "oh", 3529 "organization_plan": "op", 3530 "organization_pre_receive_hooks": "opr", 3531 "organization_projects": "op", 3532 "organization_secrets": "os", 3533 "organization_self_hosted_runners": "osh", 3534 "organization_user_blocking": "oub", 3535 "packages": "pkg", 3536 "pages": "pg", 3537 "pull_requests": "pr", 3538 "repository_hooks": "rh", 3539 "repository_projects": "rp", 3540 "repository_pre_receive_hooks": "rprh", 3541 "secrets": "s", 3542 "secret_scanning_alerts": "ssa", 3543 "security_events": "se", 3544 "single_file": "sf", 3545 "statuses": "s", 3546 "team_discussions": "td", 3547 "vulnerability_alerts": "va", 3548 "workflows": "w" 3549 }, 3550 "created_at": ` + referenceTimeStr + `, 3551 "updated_at": ` + referenceTimeStr + `, 3552 "has_multiple_single_files": false, 3553 "suspended_by": { 3554 "login": "l", 3555 "id": 1, 3556 "avatar_url": "a", 3557 "gravatar_id": "g", 3558 "name": "n", 3559 "company": "c", 3560 "blog": "b", 3561 "location": "l", 3562 "email": "e", 3563 "hireable": true, 3564 "bio": "b", 3565 "twitter_username": "t", 3566 "public_repos": 1, 3567 "followers": 1, 3568 "following": 1, 3569 "created_at": ` + referenceTimeStr + `, 3570 "suspended_at": ` + referenceTimeStr + `, 3571 "url": "u" 3572 }, 3573 "suspended_at": ` + referenceTimeStr + ` 3574 } 3575 }` 3576 3577 testJSONMarshal(t, u, want) 3578 } 3579 3580 func TestPullRequestReviewEvent_Marshal(t *testing.T) { 3581 t.Parallel() 3582 testJSONMarshal(t, &PullRequestReviewEvent{}, "{}") 3583 3584 u := &PullRequestReviewEvent{ 3585 Action: Ptr("a"), 3586 Review: &PullRequestReview{ID: Ptr(int64(1))}, 3587 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 3588 Repo: &Repository{ 3589 ID: Ptr(int64(1)), 3590 URL: Ptr("s"), 3591 Name: Ptr("n"), 3592 }, 3593 Sender: &User{ 3594 Login: Ptr("l"), 3595 ID: Ptr(int64(1)), 3596 NodeID: Ptr("n"), 3597 URL: Ptr("u"), 3598 ReposURL: Ptr("r"), 3599 EventsURL: Ptr("e"), 3600 AvatarURL: Ptr("a"), 3601 }, 3602 Installation: &Installation{ 3603 ID: Ptr(int64(1)), 3604 NodeID: Ptr("nid"), 3605 AppID: Ptr(int64(1)), 3606 AppSlug: Ptr("as"), 3607 TargetID: Ptr(int64(1)), 3608 Account: &User{ 3609 Login: Ptr("l"), 3610 ID: Ptr(int64(1)), 3611 URL: Ptr("u"), 3612 AvatarURL: Ptr("a"), 3613 GravatarID: Ptr("g"), 3614 Name: Ptr("n"), 3615 Company: Ptr("c"), 3616 Blog: Ptr("b"), 3617 Location: Ptr("l"), 3618 Email: Ptr("e"), 3619 Hireable: Ptr(true), 3620 Bio: Ptr("b"), 3621 TwitterUsername: Ptr("t"), 3622 PublicRepos: Ptr(1), 3623 Followers: Ptr(1), 3624 Following: Ptr(1), 3625 CreatedAt: &Timestamp{referenceTime}, 3626 SuspendedAt: &Timestamp{referenceTime}, 3627 }, 3628 AccessTokensURL: Ptr("atu"), 3629 RepositoriesURL: Ptr("ru"), 3630 HTMLURL: Ptr("hu"), 3631 TargetType: Ptr("tt"), 3632 SingleFileName: Ptr("sfn"), 3633 RepositorySelection: Ptr("rs"), 3634 Events: []string{"e"}, 3635 SingleFilePaths: []string{"s"}, 3636 Permissions: &InstallationPermissions{ 3637 Actions: Ptr("a"), 3638 Administration: Ptr("ad"), 3639 Checks: Ptr("c"), 3640 Contents: Ptr("co"), 3641 ContentReferences: Ptr("cr"), 3642 Deployments: Ptr("d"), 3643 Environments: Ptr("e"), 3644 Issues: Ptr("i"), 3645 Metadata: Ptr("md"), 3646 Members: Ptr("m"), 3647 OrganizationAdministration: Ptr("oa"), 3648 OrganizationHooks: Ptr("oh"), 3649 OrganizationPlan: Ptr("op"), 3650 OrganizationPreReceiveHooks: Ptr("opr"), 3651 OrganizationProjects: Ptr("op"), 3652 OrganizationSecrets: Ptr("os"), 3653 OrganizationSelfHostedRunners: Ptr("osh"), 3654 OrganizationUserBlocking: Ptr("oub"), 3655 Packages: Ptr("pkg"), 3656 Pages: Ptr("pg"), 3657 PullRequests: Ptr("pr"), 3658 RepositoryHooks: Ptr("rh"), 3659 RepositoryProjects: Ptr("rp"), 3660 RepositoryPreReceiveHooks: Ptr("rprh"), 3661 Secrets: Ptr("s"), 3662 SecretScanningAlerts: Ptr("ssa"), 3663 SecurityEvents: Ptr("se"), 3664 SingleFile: Ptr("sf"), 3665 Statuses: Ptr("s"), 3666 TeamDiscussions: Ptr("td"), 3667 VulnerabilityAlerts: Ptr("va"), 3668 Workflows: Ptr("w"), 3669 }, 3670 CreatedAt: &Timestamp{referenceTime}, 3671 UpdatedAt: &Timestamp{referenceTime}, 3672 HasMultipleSingleFiles: Ptr(false), 3673 SuspendedBy: &User{ 3674 Login: Ptr("l"), 3675 ID: Ptr(int64(1)), 3676 URL: Ptr("u"), 3677 AvatarURL: Ptr("a"), 3678 GravatarID: Ptr("g"), 3679 Name: Ptr("n"), 3680 Company: Ptr("c"), 3681 Blog: Ptr("b"), 3682 Location: Ptr("l"), 3683 Email: Ptr("e"), 3684 Hireable: Ptr(true), 3685 Bio: Ptr("b"), 3686 TwitterUsername: Ptr("t"), 3687 PublicRepos: Ptr(1), 3688 Followers: Ptr(1), 3689 Following: Ptr(1), 3690 CreatedAt: &Timestamp{referenceTime}, 3691 SuspendedAt: &Timestamp{referenceTime}, 3692 }, 3693 SuspendedAt: &Timestamp{referenceTime}, 3694 }, 3695 Organization: &Organization{ 3696 BillingEmail: Ptr("be"), 3697 Blog: Ptr("b"), 3698 Company: Ptr("c"), 3699 Email: Ptr("e"), 3700 TwitterUsername: Ptr("tu"), 3701 Location: Ptr("loc"), 3702 Name: Ptr("n"), 3703 Description: Ptr("d"), 3704 IsVerified: Ptr(true), 3705 HasOrganizationProjects: Ptr(true), 3706 HasRepositoryProjects: Ptr(true), 3707 DefaultRepoPermission: Ptr("drp"), 3708 MembersCanCreateRepos: Ptr(true), 3709 MembersCanCreateInternalRepos: Ptr(true), 3710 MembersCanCreatePrivateRepos: Ptr(true), 3711 MembersCanCreatePublicRepos: Ptr(false), 3712 MembersAllowedRepositoryCreationType: Ptr("marct"), 3713 MembersCanCreatePages: Ptr(true), 3714 MembersCanCreatePublicPages: Ptr(false), 3715 MembersCanCreatePrivatePages: Ptr(true), 3716 }, 3717 } 3718 3719 want := `{ 3720 "action": "a", 3721 "review": { 3722 "id": 1 3723 }, 3724 "pull_request": { 3725 "id": 1 3726 }, 3727 "repository": { 3728 "id": 1, 3729 "name": "n", 3730 "url": "s" 3731 }, 3732 "sender": { 3733 "login": "l", 3734 "id": 1, 3735 "node_id": "n", 3736 "avatar_url": "a", 3737 "url": "u", 3738 "events_url": "e", 3739 "repos_url": "r" 3740 }, 3741 "installation": { 3742 "id": 1, 3743 "node_id": "nid", 3744 "app_id": 1, 3745 "app_slug": "as", 3746 "target_id": 1, 3747 "account": { 3748 "login": "l", 3749 "id": 1, 3750 "avatar_url": "a", 3751 "gravatar_id": "g", 3752 "name": "n", 3753 "company": "c", 3754 "blog": "b", 3755 "location": "l", 3756 "email": "e", 3757 "hireable": true, 3758 "bio": "b", 3759 "twitter_username": "t", 3760 "public_repos": 1, 3761 "followers": 1, 3762 "following": 1, 3763 "created_at": ` + referenceTimeStr + `, 3764 "suspended_at": ` + referenceTimeStr + `, 3765 "url": "u" 3766 }, 3767 "access_tokens_url": "atu", 3768 "repositories_url": "ru", 3769 "html_url": "hu", 3770 "target_type": "tt", 3771 "single_file_name": "sfn", 3772 "repository_selection": "rs", 3773 "events": [ 3774 "e" 3775 ], 3776 "single_file_paths": [ 3777 "s" 3778 ], 3779 "permissions": { 3780 "actions": "a", 3781 "administration": "ad", 3782 "checks": "c", 3783 "contents": "co", 3784 "content_references": "cr", 3785 "deployments": "d", 3786 "environments": "e", 3787 "issues": "i", 3788 "metadata": "md", 3789 "members": "m", 3790 "organization_administration": "oa", 3791 "organization_hooks": "oh", 3792 "organization_plan": "op", 3793 "organization_pre_receive_hooks": "opr", 3794 "organization_projects": "op", 3795 "organization_secrets": "os", 3796 "organization_self_hosted_runners": "osh", 3797 "organization_user_blocking": "oub", 3798 "packages": "pkg", 3799 "pages": "pg", 3800 "pull_requests": "pr", 3801 "repository_hooks": "rh", 3802 "repository_projects": "rp", 3803 "repository_pre_receive_hooks": "rprh", 3804 "secrets": "s", 3805 "secret_scanning_alerts": "ssa", 3806 "security_events": "se", 3807 "single_file": "sf", 3808 "statuses": "s", 3809 "team_discussions": "td", 3810 "vulnerability_alerts": "va", 3811 "workflows": "w" 3812 }, 3813 "created_at": ` + referenceTimeStr + `, 3814 "updated_at": ` + referenceTimeStr + `, 3815 "has_multiple_single_files": false, 3816 "suspended_by": { 3817 "login": "l", 3818 "id": 1, 3819 "avatar_url": "a", 3820 "gravatar_id": "g", 3821 "name": "n", 3822 "company": "c", 3823 "blog": "b", 3824 "location": "l", 3825 "email": "e", 3826 "hireable": true, 3827 "bio": "b", 3828 "twitter_username": "t", 3829 "public_repos": 1, 3830 "followers": 1, 3831 "following": 1, 3832 "created_at": ` + referenceTimeStr + `, 3833 "suspended_at": ` + referenceTimeStr + `, 3834 "url": "u" 3835 }, 3836 "suspended_at": ` + referenceTimeStr + ` 3837 }, 3838 "organization": { 3839 "name": "n", 3840 "company": "c", 3841 "blog": "b", 3842 "location": "loc", 3843 "email": "e", 3844 "twitter_username": "tu", 3845 "description": "d", 3846 "billing_email": "be", 3847 "is_verified": true, 3848 "has_organization_projects": true, 3849 "has_repository_projects": true, 3850 "default_repository_permission": "drp", 3851 "members_can_create_repositories": true, 3852 "members_can_create_public_repositories": false, 3853 "members_can_create_private_repositories": true, 3854 "members_can_create_internal_repositories": true, 3855 "members_allowed_repository_creation_type": "marct", 3856 "members_can_create_pages": true, 3857 "members_can_create_public_pages": false, 3858 "members_can_create_private_pages": true 3859 } 3860 }` 3861 3862 testJSONMarshal(t, u, want) 3863 } 3864 3865 func TestPushEvent_Marshal(t *testing.T) { 3866 t.Parallel() 3867 testJSONMarshal(t, &PushEvent{}, "{}") 3868 3869 u := &PushEvent{ 3870 PushID: Ptr(int64(1)), 3871 Head: Ptr("h"), 3872 Ref: Ptr("ref"), 3873 Size: Ptr(1), 3874 Commits: []*HeadCommit{ 3875 {ID: Ptr("id")}, 3876 }, 3877 Before: Ptr("b"), 3878 DistinctSize: Ptr(1), 3879 After: Ptr("a"), 3880 Created: Ptr(true), 3881 Deleted: Ptr(true), 3882 Forced: Ptr(true), 3883 BaseRef: Ptr("a"), 3884 Compare: Ptr("a"), 3885 Repo: &PushEventRepository{ID: Ptr(int64(1))}, 3886 HeadCommit: &HeadCommit{ID: Ptr("id")}, 3887 Pusher: &CommitAuthor{ 3888 Login: Ptr("l"), 3889 Date: &Timestamp{referenceTime}, 3890 Name: Ptr("n"), 3891 Email: Ptr("e"), 3892 }, 3893 Sender: &User{ 3894 Login: Ptr("l"), 3895 ID: Ptr(int64(1)), 3896 NodeID: Ptr("n"), 3897 URL: Ptr("u"), 3898 ReposURL: Ptr("r"), 3899 EventsURL: Ptr("e"), 3900 AvatarURL: Ptr("a"), 3901 }, 3902 Installation: &Installation{ 3903 ID: Ptr(int64(1)), 3904 NodeID: Ptr("nid"), 3905 AppID: Ptr(int64(1)), 3906 AppSlug: Ptr("as"), 3907 TargetID: Ptr(int64(1)), 3908 Account: &User{ 3909 Login: Ptr("l"), 3910 ID: Ptr(int64(1)), 3911 URL: Ptr("u"), 3912 AvatarURL: Ptr("a"), 3913 GravatarID: Ptr("g"), 3914 Name: Ptr("n"), 3915 Company: Ptr("c"), 3916 Blog: Ptr("b"), 3917 Location: Ptr("l"), 3918 Email: Ptr("e"), 3919 Hireable: Ptr(true), 3920 Bio: Ptr("b"), 3921 TwitterUsername: Ptr("t"), 3922 PublicRepos: Ptr(1), 3923 Followers: Ptr(1), 3924 Following: Ptr(1), 3925 CreatedAt: &Timestamp{referenceTime}, 3926 SuspendedAt: &Timestamp{referenceTime}, 3927 }, 3928 AccessTokensURL: Ptr("atu"), 3929 RepositoriesURL: Ptr("ru"), 3930 HTMLURL: Ptr("hu"), 3931 TargetType: Ptr("tt"), 3932 SingleFileName: Ptr("sfn"), 3933 RepositorySelection: Ptr("rs"), 3934 Events: []string{"e"}, 3935 SingleFilePaths: []string{"s"}, 3936 Permissions: &InstallationPermissions{ 3937 Actions: Ptr("a"), 3938 Administration: Ptr("ad"), 3939 Checks: Ptr("c"), 3940 Contents: Ptr("co"), 3941 ContentReferences: Ptr("cr"), 3942 Deployments: Ptr("d"), 3943 Environments: Ptr("e"), 3944 Issues: Ptr("i"), 3945 Metadata: Ptr("md"), 3946 Members: Ptr("m"), 3947 OrganizationAdministration: Ptr("oa"), 3948 OrganizationHooks: Ptr("oh"), 3949 OrganizationPlan: Ptr("op"), 3950 OrganizationPreReceiveHooks: Ptr("opr"), 3951 OrganizationProjects: Ptr("op"), 3952 OrganizationSecrets: Ptr("os"), 3953 OrganizationSelfHostedRunners: Ptr("osh"), 3954 OrganizationUserBlocking: Ptr("oub"), 3955 Packages: Ptr("pkg"), 3956 Pages: Ptr("pg"), 3957 PullRequests: Ptr("pr"), 3958 RepositoryHooks: Ptr("rh"), 3959 RepositoryProjects: Ptr("rp"), 3960 RepositoryPreReceiveHooks: Ptr("rprh"), 3961 Secrets: Ptr("s"), 3962 SecretScanningAlerts: Ptr("ssa"), 3963 SecurityEvents: Ptr("se"), 3964 SingleFile: Ptr("sf"), 3965 Statuses: Ptr("s"), 3966 TeamDiscussions: Ptr("td"), 3967 VulnerabilityAlerts: Ptr("va"), 3968 Workflows: Ptr("w"), 3969 }, 3970 CreatedAt: &Timestamp{referenceTime}, 3971 UpdatedAt: &Timestamp{referenceTime}, 3972 HasMultipleSingleFiles: Ptr(false), 3973 SuspendedBy: &User{ 3974 Login: Ptr("l"), 3975 ID: Ptr(int64(1)), 3976 URL: Ptr("u"), 3977 AvatarURL: Ptr("a"), 3978 GravatarID: Ptr("g"), 3979 Name: Ptr("n"), 3980 Company: Ptr("c"), 3981 Blog: Ptr("b"), 3982 Location: Ptr("l"), 3983 Email: Ptr("e"), 3984 Hireable: Ptr(true), 3985 Bio: Ptr("b"), 3986 TwitterUsername: Ptr("t"), 3987 PublicRepos: Ptr(1), 3988 Followers: Ptr(1), 3989 Following: Ptr(1), 3990 CreatedAt: &Timestamp{referenceTime}, 3991 SuspendedAt: &Timestamp{referenceTime}, 3992 }, 3993 SuspendedAt: &Timestamp{referenceTime}, 3994 }, 3995 Organization: &Organization{ 3996 BillingEmail: Ptr("be"), 3997 Blog: Ptr("b"), 3998 Company: Ptr("c"), 3999 Email: Ptr("e"), 4000 TwitterUsername: Ptr("tu"), 4001 Location: Ptr("loc"), 4002 Name: Ptr("n"), 4003 Description: Ptr("d"), 4004 IsVerified: Ptr(true), 4005 HasOrganizationProjects: Ptr(true), 4006 HasRepositoryProjects: Ptr(true), 4007 DefaultRepoPermission: Ptr("drp"), 4008 MembersCanCreateRepos: Ptr(true), 4009 MembersCanCreateInternalRepos: Ptr(true), 4010 MembersCanCreatePrivateRepos: Ptr(true), 4011 MembersCanCreatePublicRepos: Ptr(false), 4012 MembersAllowedRepositoryCreationType: Ptr("marct"), 4013 MembersCanCreatePages: Ptr(true), 4014 MembersCanCreatePublicPages: Ptr(false), 4015 MembersCanCreatePrivatePages: Ptr(true), 4016 }, 4017 } 4018 4019 want := `{ 4020 "push_id": 1, 4021 "head": "h", 4022 "ref": "ref", 4023 "size": 1, 4024 "commits": [ 4025 { 4026 "id": "id" 4027 } 4028 ], 4029 "before": "b", 4030 "distinct_size": 1, 4031 "after": "a", 4032 "created": true, 4033 "deleted": true, 4034 "forced": true, 4035 "base_ref": "a", 4036 "compare": "a", 4037 "repository": { 4038 "id": 1 4039 }, 4040 "head_commit": { 4041 "id": "id" 4042 }, 4043 "pusher": { 4044 "date": ` + referenceTimeStr + `, 4045 "name": "n", 4046 "email": "e", 4047 "username": "l" 4048 }, 4049 "sender": { 4050 "login": "l", 4051 "id": 1, 4052 "node_id": "n", 4053 "avatar_url": "a", 4054 "url": "u", 4055 "events_url": "e", 4056 "repos_url": "r" 4057 }, 4058 "installation": { 4059 "id": 1, 4060 "node_id": "nid", 4061 "app_id": 1, 4062 "app_slug": "as", 4063 "target_id": 1, 4064 "account": { 4065 "login": "l", 4066 "id": 1, 4067 "avatar_url": "a", 4068 "gravatar_id": "g", 4069 "name": "n", 4070 "company": "c", 4071 "blog": "b", 4072 "location": "l", 4073 "email": "e", 4074 "hireable": true, 4075 "bio": "b", 4076 "twitter_username": "t", 4077 "public_repos": 1, 4078 "followers": 1, 4079 "following": 1, 4080 "created_at": ` + referenceTimeStr + `, 4081 "suspended_at": ` + referenceTimeStr + `, 4082 "url": "u" 4083 }, 4084 "access_tokens_url": "atu", 4085 "repositories_url": "ru", 4086 "html_url": "hu", 4087 "target_type": "tt", 4088 "single_file_name": "sfn", 4089 "repository_selection": "rs", 4090 "events": [ 4091 "e" 4092 ], 4093 "single_file_paths": [ 4094 "s" 4095 ], 4096 "permissions": { 4097 "actions": "a", 4098 "administration": "ad", 4099 "checks": "c", 4100 "contents": "co", 4101 "content_references": "cr", 4102 "deployments": "d", 4103 "environments": "e", 4104 "issues": "i", 4105 "metadata": "md", 4106 "members": "m", 4107 "organization_administration": "oa", 4108 "organization_hooks": "oh", 4109 "organization_plan": "op", 4110 "organization_pre_receive_hooks": "opr", 4111 "organization_projects": "op", 4112 "organization_secrets": "os", 4113 "organization_self_hosted_runners": "osh", 4114 "organization_user_blocking": "oub", 4115 "packages": "pkg", 4116 "pages": "pg", 4117 "pull_requests": "pr", 4118 "repository_hooks": "rh", 4119 "repository_projects": "rp", 4120 "repository_pre_receive_hooks": "rprh", 4121 "secrets": "s", 4122 "secret_scanning_alerts": "ssa", 4123 "security_events": "se", 4124 "single_file": "sf", 4125 "statuses": "s", 4126 "team_discussions": "td", 4127 "vulnerability_alerts": "va", 4128 "workflows": "w" 4129 }, 4130 "created_at": ` + referenceTimeStr + `, 4131 "updated_at": ` + referenceTimeStr + `, 4132 "has_multiple_single_files": false, 4133 "suspended_by": { 4134 "login": "l", 4135 "id": 1, 4136 "avatar_url": "a", 4137 "gravatar_id": "g", 4138 "name": "n", 4139 "company": "c", 4140 "blog": "b", 4141 "location": "l", 4142 "email": "e", 4143 "hireable": true, 4144 "bio": "b", 4145 "twitter_username": "t", 4146 "public_repos": 1, 4147 "followers": 1, 4148 "following": 1, 4149 "created_at": ` + referenceTimeStr + `, 4150 "suspended_at": ` + referenceTimeStr + `, 4151 "url": "u" 4152 }, 4153 "suspended_at": ` + referenceTimeStr + ` 4154 }, 4155 "organization": { 4156 "name": "n", 4157 "company": "c", 4158 "blog": "b", 4159 "location": "loc", 4160 "email": "e", 4161 "twitter_username": "tu", 4162 "description": "d", 4163 "billing_email": "be", 4164 "is_verified": true, 4165 "has_organization_projects": true, 4166 "has_repository_projects": true, 4167 "default_repository_permission": "drp", 4168 "members_can_create_repositories": true, 4169 "members_can_create_public_repositories": false, 4170 "members_can_create_private_repositories": true, 4171 "members_can_create_internal_repositories": true, 4172 "members_allowed_repository_creation_type": "marct", 4173 "members_can_create_pages": true, 4174 "members_can_create_public_pages": false, 4175 "members_can_create_private_pages": true 4176 } 4177 }` 4178 4179 testJSONMarshal(t, u, want) 4180 } 4181 4182 func TestStatusEvent_Marshal(t *testing.T) { 4183 t.Parallel() 4184 testJSONMarshal(t, &StatusEvent{}, "{}") 4185 4186 u := &StatusEvent{ 4187 SHA: Ptr("sha"), 4188 State: Ptr("s"), 4189 Description: Ptr("d"), 4190 TargetURL: Ptr("turl"), 4191 Branches: []*Branch{ 4192 { 4193 Name: Ptr("n"), 4194 Commit: &RepositoryCommit{NodeID: Ptr("nid")}, 4195 Protected: Ptr(false), 4196 }, 4197 }, 4198 ID: Ptr(int64(1)), 4199 Name: Ptr("n"), 4200 Context: Ptr("c"), 4201 Commit: &RepositoryCommit{NodeID: Ptr("nid")}, 4202 CreatedAt: &Timestamp{referenceTime}, 4203 UpdatedAt: &Timestamp{referenceTime}, 4204 Sender: &User{ 4205 Login: Ptr("l"), 4206 ID: Ptr(int64(1)), 4207 NodeID: Ptr("n"), 4208 URL: Ptr("u"), 4209 ReposURL: Ptr("r"), 4210 EventsURL: Ptr("e"), 4211 AvatarURL: Ptr("a"), 4212 }, 4213 Installation: &Installation{ 4214 ID: Ptr(int64(1)), 4215 NodeID: Ptr("nid"), 4216 AppID: Ptr(int64(1)), 4217 AppSlug: Ptr("as"), 4218 TargetID: Ptr(int64(1)), 4219 Account: &User{ 4220 Login: Ptr("l"), 4221 ID: Ptr(int64(1)), 4222 URL: Ptr("u"), 4223 AvatarURL: Ptr("a"), 4224 GravatarID: Ptr("g"), 4225 Name: Ptr("n"), 4226 Company: Ptr("c"), 4227 Blog: Ptr("b"), 4228 Location: Ptr("l"), 4229 Email: Ptr("e"), 4230 Hireable: Ptr(true), 4231 Bio: Ptr("b"), 4232 TwitterUsername: Ptr("t"), 4233 PublicRepos: Ptr(1), 4234 Followers: Ptr(1), 4235 Following: Ptr(1), 4236 CreatedAt: &Timestamp{referenceTime}, 4237 SuspendedAt: &Timestamp{referenceTime}, 4238 }, 4239 AccessTokensURL: Ptr("atu"), 4240 RepositoriesURL: Ptr("ru"), 4241 HTMLURL: Ptr("hu"), 4242 TargetType: Ptr("tt"), 4243 SingleFileName: Ptr("sfn"), 4244 RepositorySelection: Ptr("rs"), 4245 Events: []string{"e"}, 4246 SingleFilePaths: []string{"s"}, 4247 Permissions: &InstallationPermissions{ 4248 Actions: Ptr("a"), 4249 Administration: Ptr("ad"), 4250 Checks: Ptr("c"), 4251 Contents: Ptr("co"), 4252 ContentReferences: Ptr("cr"), 4253 Deployments: Ptr("d"), 4254 Environments: Ptr("e"), 4255 Issues: Ptr("i"), 4256 Metadata: Ptr("md"), 4257 Members: Ptr("m"), 4258 OrganizationAdministration: Ptr("oa"), 4259 OrganizationHooks: Ptr("oh"), 4260 OrganizationPlan: Ptr("op"), 4261 OrganizationPreReceiveHooks: Ptr("opr"), 4262 OrganizationProjects: Ptr("op"), 4263 OrganizationSecrets: Ptr("os"), 4264 OrganizationSelfHostedRunners: Ptr("osh"), 4265 OrganizationUserBlocking: Ptr("oub"), 4266 Packages: Ptr("pkg"), 4267 Pages: Ptr("pg"), 4268 PullRequests: Ptr("pr"), 4269 RepositoryHooks: Ptr("rh"), 4270 RepositoryProjects: Ptr("rp"), 4271 RepositoryPreReceiveHooks: Ptr("rprh"), 4272 Secrets: Ptr("s"), 4273 SecretScanningAlerts: Ptr("ssa"), 4274 SecurityEvents: Ptr("se"), 4275 SingleFile: Ptr("sf"), 4276 Statuses: Ptr("s"), 4277 TeamDiscussions: Ptr("td"), 4278 VulnerabilityAlerts: Ptr("va"), 4279 Workflows: Ptr("w"), 4280 }, 4281 CreatedAt: &Timestamp{referenceTime}, 4282 UpdatedAt: &Timestamp{referenceTime}, 4283 HasMultipleSingleFiles: Ptr(false), 4284 SuspendedBy: &User{ 4285 Login: Ptr("l"), 4286 ID: Ptr(int64(1)), 4287 URL: Ptr("u"), 4288 AvatarURL: Ptr("a"), 4289 GravatarID: Ptr("g"), 4290 Name: Ptr("n"), 4291 Company: Ptr("c"), 4292 Blog: Ptr("b"), 4293 Location: Ptr("l"), 4294 Email: Ptr("e"), 4295 Hireable: Ptr(true), 4296 Bio: Ptr("b"), 4297 TwitterUsername: Ptr("t"), 4298 PublicRepos: Ptr(1), 4299 Followers: Ptr(1), 4300 Following: Ptr(1), 4301 CreatedAt: &Timestamp{referenceTime}, 4302 SuspendedAt: &Timestamp{referenceTime}, 4303 }, 4304 SuspendedAt: &Timestamp{referenceTime}, 4305 }, 4306 } 4307 4308 want := `{ 4309 "sha": "sha", 4310 "state": "s", 4311 "description": "d", 4312 "target_url": "turl", 4313 "branches": [ 4314 { 4315 "name": "n", 4316 "commit": { 4317 "node_id": "nid" 4318 }, 4319 "protected": false 4320 } 4321 ], 4322 "id": 1, 4323 "name": "n", 4324 "context": "c", 4325 "commit": { 4326 "node_id": "nid" 4327 }, 4328 "created_at": ` + referenceTimeStr + `, 4329 "updated_at": ` + referenceTimeStr + `, 4330 "sender": { 4331 "login": "l", 4332 "id": 1, 4333 "node_id": "n", 4334 "avatar_url": "a", 4335 "url": "u", 4336 "events_url": "e", 4337 "repos_url": "r" 4338 }, 4339 "installation": { 4340 "id": 1, 4341 "node_id": "nid", 4342 "app_id": 1, 4343 "app_slug": "as", 4344 "target_id": 1, 4345 "account": { 4346 "login": "l", 4347 "id": 1, 4348 "avatar_url": "a", 4349 "gravatar_id": "g", 4350 "name": "n", 4351 "company": "c", 4352 "blog": "b", 4353 "location": "l", 4354 "email": "e", 4355 "hireable": true, 4356 "bio": "b", 4357 "twitter_username": "t", 4358 "public_repos": 1, 4359 "followers": 1, 4360 "following": 1, 4361 "created_at": ` + referenceTimeStr + `, 4362 "suspended_at": ` + referenceTimeStr + `, 4363 "url": "u" 4364 }, 4365 "access_tokens_url": "atu", 4366 "repositories_url": "ru", 4367 "html_url": "hu", 4368 "target_type": "tt", 4369 "single_file_name": "sfn", 4370 "repository_selection": "rs", 4371 "events": [ 4372 "e" 4373 ], 4374 "single_file_paths": [ 4375 "s" 4376 ], 4377 "permissions": { 4378 "actions": "a", 4379 "administration": "ad", 4380 "checks": "c", 4381 "contents": "co", 4382 "content_references": "cr", 4383 "deployments": "d", 4384 "environments": "e", 4385 "issues": "i", 4386 "metadata": "md", 4387 "members": "m", 4388 "organization_administration": "oa", 4389 "organization_hooks": "oh", 4390 "organization_plan": "op", 4391 "organization_pre_receive_hooks": "opr", 4392 "organization_projects": "op", 4393 "organization_secrets": "os", 4394 "organization_self_hosted_runners": "osh", 4395 "organization_user_blocking": "oub", 4396 "packages": "pkg", 4397 "pages": "pg", 4398 "pull_requests": "pr", 4399 "repository_hooks": "rh", 4400 "repository_projects": "rp", 4401 "repository_pre_receive_hooks": "rprh", 4402 "secrets": "s", 4403 "secret_scanning_alerts": "ssa", 4404 "security_events": "se", 4405 "single_file": "sf", 4406 "statuses": "s", 4407 "team_discussions": "td", 4408 "vulnerability_alerts": "va", 4409 "workflows": "w" 4410 }, 4411 "created_at": ` + referenceTimeStr + `, 4412 "updated_at": ` + referenceTimeStr + `, 4413 "has_multiple_single_files": false, 4414 "suspended_by": { 4415 "login": "l", 4416 "id": 1, 4417 "avatar_url": "a", 4418 "gravatar_id": "g", 4419 "name": "n", 4420 "company": "c", 4421 "blog": "b", 4422 "location": "l", 4423 "email": "e", 4424 "hireable": true, 4425 "bio": "b", 4426 "twitter_username": "t", 4427 "public_repos": 1, 4428 "followers": 1, 4429 "following": 1, 4430 "created_at": ` + referenceTimeStr + `, 4431 "suspended_at": ` + referenceTimeStr + `, 4432 "url": "u" 4433 }, 4434 "suspended_at": ` + referenceTimeStr + ` 4435 } 4436 }` 4437 4438 testJSONMarshal(t, u, want) 4439 } 4440 4441 func TestMarketplacePurchaseEvent_Marshal(t *testing.T) { 4442 t.Parallel() 4443 testJSONMarshal(t, &MarketplacePurchaseEvent{}, "{}") 4444 4445 u := &MarketplacePurchaseEvent{ 4446 Action: Ptr("a"), 4447 EffectiveDate: &Timestamp{referenceTime}, 4448 MarketplacePurchase: &MarketplacePurchase{ 4449 BillingCycle: Ptr("bc"), 4450 NextBillingDate: &Timestamp{referenceTime}, 4451 UnitCount: Ptr(1), 4452 Plan: &MarketplacePlan{ 4453 URL: Ptr("u"), 4454 AccountsURL: Ptr("au"), 4455 ID: Ptr(int64(1)), 4456 Number: Ptr(1), 4457 Name: Ptr("n"), 4458 Description: Ptr("d"), 4459 MonthlyPriceInCents: Ptr(1), 4460 YearlyPriceInCents: Ptr(1), 4461 PriceModel: Ptr("pm"), 4462 UnitName: Ptr("un"), 4463 Bullets: &[]string{"b"}, 4464 State: Ptr("s"), 4465 HasFreeTrial: Ptr(false), 4466 }, 4467 OnFreeTrial: Ptr(false), 4468 FreeTrialEndsOn: &Timestamp{referenceTime}, 4469 UpdatedAt: &Timestamp{referenceTime}, 4470 }, 4471 PreviousMarketplacePurchase: &MarketplacePurchase{ 4472 BillingCycle: Ptr("bc"), 4473 NextBillingDate: &Timestamp{referenceTime}, 4474 UnitCount: Ptr(1), 4475 Plan: &MarketplacePlan{ 4476 URL: Ptr("u"), 4477 AccountsURL: Ptr("au"), 4478 ID: Ptr(int64(1)), 4479 Number: Ptr(1), 4480 Name: Ptr("n"), 4481 Description: Ptr("d"), 4482 MonthlyPriceInCents: Ptr(1), 4483 YearlyPriceInCents: Ptr(1), 4484 PriceModel: Ptr("pm"), 4485 UnitName: Ptr("un"), 4486 Bullets: &[]string{"b"}, 4487 State: Ptr("s"), 4488 HasFreeTrial: Ptr(false), 4489 }, 4490 OnFreeTrial: Ptr(false), 4491 FreeTrialEndsOn: &Timestamp{referenceTime}, 4492 UpdatedAt: &Timestamp{referenceTime}, 4493 }, 4494 Sender: &User{ 4495 Login: Ptr("l"), 4496 ID: Ptr(int64(1)), 4497 NodeID: Ptr("n"), 4498 URL: Ptr("u"), 4499 ReposURL: Ptr("r"), 4500 EventsURL: Ptr("e"), 4501 AvatarURL: Ptr("a"), 4502 }, 4503 Installation: &Installation{ 4504 ID: Ptr(int64(1)), 4505 NodeID: Ptr("nid"), 4506 AppID: Ptr(int64(1)), 4507 AppSlug: Ptr("as"), 4508 TargetID: Ptr(int64(1)), 4509 Account: &User{ 4510 Login: Ptr("l"), 4511 ID: Ptr(int64(1)), 4512 URL: Ptr("u"), 4513 AvatarURL: Ptr("a"), 4514 GravatarID: Ptr("g"), 4515 Name: Ptr("n"), 4516 Company: Ptr("c"), 4517 Blog: Ptr("b"), 4518 Location: Ptr("l"), 4519 Email: Ptr("e"), 4520 Hireable: Ptr(true), 4521 Bio: Ptr("b"), 4522 TwitterUsername: Ptr("t"), 4523 PublicRepos: Ptr(1), 4524 Followers: Ptr(1), 4525 Following: Ptr(1), 4526 CreatedAt: &Timestamp{referenceTime}, 4527 SuspendedAt: &Timestamp{referenceTime}, 4528 }, 4529 AccessTokensURL: Ptr("atu"), 4530 RepositoriesURL: Ptr("ru"), 4531 HTMLURL: Ptr("hu"), 4532 TargetType: Ptr("tt"), 4533 SingleFileName: Ptr("sfn"), 4534 RepositorySelection: Ptr("rs"), 4535 Events: []string{"e"}, 4536 SingleFilePaths: []string{"s"}, 4537 Permissions: &InstallationPermissions{ 4538 Actions: Ptr("a"), 4539 Administration: Ptr("ad"), 4540 Checks: Ptr("c"), 4541 Contents: Ptr("co"), 4542 ContentReferences: Ptr("cr"), 4543 Deployments: Ptr("d"), 4544 Environments: Ptr("e"), 4545 Issues: Ptr("i"), 4546 Metadata: Ptr("md"), 4547 Members: Ptr("m"), 4548 OrganizationAdministration: Ptr("oa"), 4549 OrganizationHooks: Ptr("oh"), 4550 OrganizationPlan: Ptr("op"), 4551 OrganizationPreReceiveHooks: Ptr("opr"), 4552 OrganizationProjects: Ptr("op"), 4553 OrganizationSecrets: Ptr("os"), 4554 OrganizationSelfHostedRunners: Ptr("osh"), 4555 OrganizationUserBlocking: Ptr("oub"), 4556 Packages: Ptr("pkg"), 4557 Pages: Ptr("pg"), 4558 PullRequests: Ptr("pr"), 4559 RepositoryHooks: Ptr("rh"), 4560 RepositoryProjects: Ptr("rp"), 4561 RepositoryPreReceiveHooks: Ptr("rprh"), 4562 Secrets: Ptr("s"), 4563 SecretScanningAlerts: Ptr("ssa"), 4564 SecurityEvents: Ptr("se"), 4565 SingleFile: Ptr("sf"), 4566 Statuses: Ptr("s"), 4567 TeamDiscussions: Ptr("td"), 4568 VulnerabilityAlerts: Ptr("va"), 4569 Workflows: Ptr("w"), 4570 }, 4571 CreatedAt: &Timestamp{referenceTime}, 4572 UpdatedAt: &Timestamp{referenceTime}, 4573 HasMultipleSingleFiles: Ptr(false), 4574 SuspendedBy: &User{ 4575 Login: Ptr("l"), 4576 ID: Ptr(int64(1)), 4577 URL: Ptr("u"), 4578 AvatarURL: Ptr("a"), 4579 GravatarID: Ptr("g"), 4580 Name: Ptr("n"), 4581 Company: Ptr("c"), 4582 Blog: Ptr("b"), 4583 Location: Ptr("l"), 4584 Email: Ptr("e"), 4585 Hireable: Ptr(true), 4586 Bio: Ptr("b"), 4587 TwitterUsername: Ptr("t"), 4588 PublicRepos: Ptr(1), 4589 Followers: Ptr(1), 4590 Following: Ptr(1), 4591 CreatedAt: &Timestamp{referenceTime}, 4592 SuspendedAt: &Timestamp{referenceTime}, 4593 }, 4594 SuspendedAt: &Timestamp{referenceTime}, 4595 }, 4596 } 4597 4598 want := `{ 4599 "action": "a", 4600 "effective_date": ` + referenceTimeStr + `, 4601 "marketplace_purchase": { 4602 "billing_cycle": "bc", 4603 "next_billing_date": ` + referenceTimeStr + `, 4604 "unit_count": 1, 4605 "plan": { 4606 "url": "u", 4607 "accounts_url": "au", 4608 "id": 1, 4609 "number": 1, 4610 "name": "n", 4611 "description": "d", 4612 "monthly_price_in_cents": 1, 4613 "yearly_price_in_cents": 1, 4614 "price_model": "pm", 4615 "unit_name": "un", 4616 "bullets": [ 4617 "b" 4618 ], 4619 "state": "s", 4620 "has_free_trial": false 4621 }, 4622 "on_free_trial": false, 4623 "free_trial_ends_on": ` + referenceTimeStr + `, 4624 "updated_at": ` + referenceTimeStr + ` 4625 }, 4626 "previous_marketplace_purchase": { 4627 "billing_cycle": "bc", 4628 "next_billing_date": ` + referenceTimeStr + `, 4629 "unit_count": 1, 4630 "plan": { 4631 "url": "u", 4632 "accounts_url": "au", 4633 "id": 1, 4634 "number": 1, 4635 "name": "n", 4636 "description": "d", 4637 "monthly_price_in_cents": 1, 4638 "yearly_price_in_cents": 1, 4639 "price_model": "pm", 4640 "unit_name": "un", 4641 "bullets": [ 4642 "b" 4643 ], 4644 "state": "s", 4645 "has_free_trial": false 4646 }, 4647 "on_free_trial": false, 4648 "free_trial_ends_on": ` + referenceTimeStr + `, 4649 "updated_at": ` + referenceTimeStr + ` 4650 }, 4651 "sender": { 4652 "login": "l", 4653 "id": 1, 4654 "node_id": "n", 4655 "avatar_url": "a", 4656 "url": "u", 4657 "events_url": "e", 4658 "repos_url": "r" 4659 }, 4660 "installation": { 4661 "id": 1, 4662 "node_id": "nid", 4663 "app_id": 1, 4664 "app_slug": "as", 4665 "target_id": 1, 4666 "account": { 4667 "login": "l", 4668 "id": 1, 4669 "avatar_url": "a", 4670 "gravatar_id": "g", 4671 "name": "n", 4672 "company": "c", 4673 "blog": "b", 4674 "location": "l", 4675 "email": "e", 4676 "hireable": true, 4677 "bio": "b", 4678 "twitter_username": "t", 4679 "public_repos": 1, 4680 "followers": 1, 4681 "following": 1, 4682 "created_at": ` + referenceTimeStr + `, 4683 "suspended_at": ` + referenceTimeStr + `, 4684 "url": "u" 4685 }, 4686 "access_tokens_url": "atu", 4687 "repositories_url": "ru", 4688 "html_url": "hu", 4689 "target_type": "tt", 4690 "single_file_name": "sfn", 4691 "repository_selection": "rs", 4692 "events": [ 4693 "e" 4694 ], 4695 "single_file_paths": [ 4696 "s" 4697 ], 4698 "permissions": { 4699 "actions": "a", 4700 "administration": "ad", 4701 "checks": "c", 4702 "contents": "co", 4703 "content_references": "cr", 4704 "deployments": "d", 4705 "environments": "e", 4706 "issues": "i", 4707 "metadata": "md", 4708 "members": "m", 4709 "organization_administration": "oa", 4710 "organization_hooks": "oh", 4711 "organization_plan": "op", 4712 "organization_pre_receive_hooks": "opr", 4713 "organization_projects": "op", 4714 "organization_secrets": "os", 4715 "organization_self_hosted_runners": "osh", 4716 "organization_user_blocking": "oub", 4717 "packages": "pkg", 4718 "pages": "pg", 4719 "pull_requests": "pr", 4720 "repository_hooks": "rh", 4721 "repository_projects": "rp", 4722 "repository_pre_receive_hooks": "rprh", 4723 "secrets": "s", 4724 "secret_scanning_alerts": "ssa", 4725 "security_events": "se", 4726 "single_file": "sf", 4727 "statuses": "s", 4728 "team_discussions": "td", 4729 "vulnerability_alerts": "va", 4730 "workflows": "w" 4731 }, 4732 "created_at": ` + referenceTimeStr + `, 4733 "updated_at": ` + referenceTimeStr + `, 4734 "has_multiple_single_files": false, 4735 "suspended_by": { 4736 "login": "l", 4737 "id": 1, 4738 "avatar_url": "a", 4739 "gravatar_id": "g", 4740 "name": "n", 4741 "company": "c", 4742 "blog": "b", 4743 "location": "l", 4744 "email": "e", 4745 "hireable": true, 4746 "bio": "b", 4747 "twitter_username": "t", 4748 "public_repos": 1, 4749 "followers": 1, 4750 "following": 1, 4751 "created_at": ` + referenceTimeStr + `, 4752 "suspended_at": ` + referenceTimeStr + `, 4753 "url": "u" 4754 }, 4755 "suspended_at": ` + referenceTimeStr + ` 4756 } 4757 }` 4758 4759 testJSONMarshal(t, u, want) 4760 } 4761 4762 func TestOrganizationEvent_Marshal(t *testing.T) { 4763 t.Parallel() 4764 testJSONMarshal(t, &OrganizationEvent{}, "{}") 4765 4766 u := &OrganizationEvent{ 4767 Action: Ptr("a"), 4768 Invitation: &Invitation{ID: Ptr(int64(1))}, 4769 Membership: &Membership{ 4770 URL: Ptr("url"), 4771 State: Ptr("s"), 4772 Role: Ptr("r"), 4773 OrganizationURL: Ptr("ou"), 4774 Organization: &Organization{ 4775 BillingEmail: Ptr("be"), 4776 Blog: Ptr("b"), 4777 Company: Ptr("c"), 4778 Email: Ptr("e"), 4779 TwitterUsername: Ptr("tu"), 4780 Location: Ptr("loc"), 4781 Name: Ptr("n"), 4782 Description: Ptr("d"), 4783 IsVerified: Ptr(true), 4784 HasOrganizationProjects: Ptr(true), 4785 HasRepositoryProjects: Ptr(true), 4786 DefaultRepoPermission: Ptr("drp"), 4787 MembersCanCreateRepos: Ptr(true), 4788 MembersCanCreateInternalRepos: Ptr(true), 4789 MembersCanCreatePrivateRepos: Ptr(true), 4790 MembersCanCreatePublicRepos: Ptr(false), 4791 MembersAllowedRepositoryCreationType: Ptr("marct"), 4792 MembersCanCreatePages: Ptr(true), 4793 MembersCanCreatePublicPages: Ptr(false), 4794 MembersCanCreatePrivatePages: Ptr(true), 4795 }, 4796 User: &User{ 4797 Login: Ptr("l"), 4798 ID: Ptr(int64(1)), 4799 NodeID: Ptr("n"), 4800 URL: Ptr("u"), 4801 ReposURL: Ptr("r"), 4802 EventsURL: Ptr("e"), 4803 AvatarURL: Ptr("a"), 4804 }, 4805 }, 4806 Organization: &Organization{ 4807 BillingEmail: Ptr("be"), 4808 Blog: Ptr("b"), 4809 Company: Ptr("c"), 4810 Email: Ptr("e"), 4811 TwitterUsername: Ptr("tu"), 4812 Location: Ptr("loc"), 4813 Name: Ptr("n"), 4814 Description: Ptr("d"), 4815 IsVerified: Ptr(true), 4816 HasOrganizationProjects: Ptr(true), 4817 HasRepositoryProjects: Ptr(true), 4818 DefaultRepoPermission: Ptr("drp"), 4819 MembersCanCreateRepos: Ptr(true), 4820 MembersCanCreateInternalRepos: Ptr(true), 4821 MembersCanCreatePrivateRepos: Ptr(true), 4822 MembersCanCreatePublicRepos: Ptr(false), 4823 MembersAllowedRepositoryCreationType: Ptr("marct"), 4824 MembersCanCreatePages: Ptr(true), 4825 MembersCanCreatePublicPages: Ptr(false), 4826 MembersCanCreatePrivatePages: Ptr(true), 4827 }, 4828 Sender: &User{ 4829 Login: Ptr("l"), 4830 ID: Ptr(int64(1)), 4831 NodeID: Ptr("n"), 4832 URL: Ptr("u"), 4833 ReposURL: Ptr("r"), 4834 EventsURL: Ptr("e"), 4835 AvatarURL: Ptr("a"), 4836 }, 4837 Installation: &Installation{ 4838 ID: Ptr(int64(1)), 4839 NodeID: Ptr("nid"), 4840 AppID: Ptr(int64(1)), 4841 AppSlug: Ptr("as"), 4842 TargetID: Ptr(int64(1)), 4843 Account: &User{ 4844 Login: Ptr("l"), 4845 ID: Ptr(int64(1)), 4846 URL: Ptr("u"), 4847 AvatarURL: Ptr("a"), 4848 GravatarID: Ptr("g"), 4849 Name: Ptr("n"), 4850 Company: Ptr("c"), 4851 Blog: Ptr("b"), 4852 Location: Ptr("l"), 4853 Email: Ptr("e"), 4854 Hireable: Ptr(true), 4855 Bio: Ptr("b"), 4856 TwitterUsername: Ptr("t"), 4857 PublicRepos: Ptr(1), 4858 Followers: Ptr(1), 4859 Following: Ptr(1), 4860 CreatedAt: &Timestamp{referenceTime}, 4861 SuspendedAt: &Timestamp{referenceTime}, 4862 }, 4863 AccessTokensURL: Ptr("atu"), 4864 RepositoriesURL: Ptr("ru"), 4865 HTMLURL: Ptr("hu"), 4866 TargetType: Ptr("tt"), 4867 SingleFileName: Ptr("sfn"), 4868 RepositorySelection: Ptr("rs"), 4869 Events: []string{"e"}, 4870 SingleFilePaths: []string{"s"}, 4871 Permissions: &InstallationPermissions{ 4872 Actions: Ptr("a"), 4873 Administration: Ptr("ad"), 4874 Checks: Ptr("c"), 4875 Contents: Ptr("co"), 4876 ContentReferences: Ptr("cr"), 4877 Deployments: Ptr("d"), 4878 Environments: Ptr("e"), 4879 Issues: Ptr("i"), 4880 Metadata: Ptr("md"), 4881 Members: Ptr("m"), 4882 OrganizationAdministration: Ptr("oa"), 4883 OrganizationHooks: Ptr("oh"), 4884 OrganizationPlan: Ptr("op"), 4885 OrganizationPreReceiveHooks: Ptr("opr"), 4886 OrganizationProjects: Ptr("op"), 4887 OrganizationSecrets: Ptr("os"), 4888 OrganizationSelfHostedRunners: Ptr("osh"), 4889 OrganizationUserBlocking: Ptr("oub"), 4890 Packages: Ptr("pkg"), 4891 Pages: Ptr("pg"), 4892 PullRequests: Ptr("pr"), 4893 RepositoryHooks: Ptr("rh"), 4894 RepositoryProjects: Ptr("rp"), 4895 RepositoryPreReceiveHooks: Ptr("rprh"), 4896 Secrets: Ptr("s"), 4897 SecretScanningAlerts: Ptr("ssa"), 4898 SecurityEvents: Ptr("se"), 4899 SingleFile: Ptr("sf"), 4900 Statuses: Ptr("s"), 4901 TeamDiscussions: Ptr("td"), 4902 VulnerabilityAlerts: Ptr("va"), 4903 Workflows: Ptr("w"), 4904 }, 4905 CreatedAt: &Timestamp{referenceTime}, 4906 UpdatedAt: &Timestamp{referenceTime}, 4907 HasMultipleSingleFiles: Ptr(false), 4908 SuspendedBy: &User{ 4909 Login: Ptr("l"), 4910 ID: Ptr(int64(1)), 4911 URL: Ptr("u"), 4912 AvatarURL: Ptr("a"), 4913 GravatarID: Ptr("g"), 4914 Name: Ptr("n"), 4915 Company: Ptr("c"), 4916 Blog: Ptr("b"), 4917 Location: Ptr("l"), 4918 Email: Ptr("e"), 4919 Hireable: Ptr(true), 4920 Bio: Ptr("b"), 4921 TwitterUsername: Ptr("t"), 4922 PublicRepos: Ptr(1), 4923 Followers: Ptr(1), 4924 Following: Ptr(1), 4925 CreatedAt: &Timestamp{referenceTime}, 4926 SuspendedAt: &Timestamp{referenceTime}, 4927 }, 4928 SuspendedAt: &Timestamp{referenceTime}, 4929 }, 4930 } 4931 4932 want := `{ 4933 "action": "a", 4934 "invitation": { 4935 "id": 1 4936 }, 4937 "membership": { 4938 "url": "url", 4939 "state": "s", 4940 "role": "r", 4941 "organization_url": "ou", 4942 "organization": { 4943 "name": "n", 4944 "company": "c", 4945 "blog": "b", 4946 "location": "loc", 4947 "email": "e", 4948 "twitter_username": "tu", 4949 "description": "d", 4950 "billing_email": "be", 4951 "is_verified": true, 4952 "has_organization_projects": true, 4953 "has_repository_projects": true, 4954 "default_repository_permission": "drp", 4955 "members_can_create_repositories": true, 4956 "members_can_create_public_repositories": false, 4957 "members_can_create_private_repositories": true, 4958 "members_can_create_internal_repositories": true, 4959 "members_allowed_repository_creation_type": "marct", 4960 "members_can_create_pages": true, 4961 "members_can_create_public_pages": false, 4962 "members_can_create_private_pages": true 4963 }, 4964 "user": { 4965 "login": "l", 4966 "id": 1, 4967 "node_id": "n", 4968 "avatar_url": "a", 4969 "url": "u", 4970 "events_url": "e", 4971 "repos_url": "r" 4972 } 4973 }, 4974 "organization": { 4975 "name": "n", 4976 "company": "c", 4977 "blog": "b", 4978 "location": "loc", 4979 "email": "e", 4980 "twitter_username": "tu", 4981 "description": "d", 4982 "billing_email": "be", 4983 "is_verified": true, 4984 "has_organization_projects": true, 4985 "has_repository_projects": true, 4986 "default_repository_permission": "drp", 4987 "members_can_create_repositories": true, 4988 "members_can_create_public_repositories": false, 4989 "members_can_create_private_repositories": true, 4990 "members_can_create_internal_repositories": true, 4991 "members_allowed_repository_creation_type": "marct", 4992 "members_can_create_pages": true, 4993 "members_can_create_public_pages": false, 4994 "members_can_create_private_pages": true 4995 }, 4996 "sender": { 4997 "login": "l", 4998 "id": 1, 4999 "node_id": "n", 5000 "avatar_url": "a", 5001 "url": "u", 5002 "events_url": "e", 5003 "repos_url": "r" 5004 }, 5005 "installation": { 5006 "id": 1, 5007 "node_id": "nid", 5008 "app_id": 1, 5009 "app_slug": "as", 5010 "target_id": 1, 5011 "account": { 5012 "login": "l", 5013 "id": 1, 5014 "avatar_url": "a", 5015 "gravatar_id": "g", 5016 "name": "n", 5017 "company": "c", 5018 "blog": "b", 5019 "location": "l", 5020 "email": "e", 5021 "hireable": true, 5022 "bio": "b", 5023 "twitter_username": "t", 5024 "public_repos": 1, 5025 "followers": 1, 5026 "following": 1, 5027 "created_at": ` + referenceTimeStr + `, 5028 "suspended_at": ` + referenceTimeStr + `, 5029 "url": "u" 5030 }, 5031 "access_tokens_url": "atu", 5032 "repositories_url": "ru", 5033 "html_url": "hu", 5034 "target_type": "tt", 5035 "single_file_name": "sfn", 5036 "repository_selection": "rs", 5037 "events": [ 5038 "e" 5039 ], 5040 "single_file_paths": [ 5041 "s" 5042 ], 5043 "permissions": { 5044 "actions": "a", 5045 "administration": "ad", 5046 "checks": "c", 5047 "contents": "co", 5048 "content_references": "cr", 5049 "deployments": "d", 5050 "environments": "e", 5051 "issues": "i", 5052 "metadata": "md", 5053 "members": "m", 5054 "organization_administration": "oa", 5055 "organization_hooks": "oh", 5056 "organization_plan": "op", 5057 "organization_pre_receive_hooks": "opr", 5058 "organization_projects": "op", 5059 "organization_secrets": "os", 5060 "organization_self_hosted_runners": "osh", 5061 "organization_user_blocking": "oub", 5062 "packages": "pkg", 5063 "pages": "pg", 5064 "pull_requests": "pr", 5065 "repository_hooks": "rh", 5066 "repository_projects": "rp", 5067 "repository_pre_receive_hooks": "rprh", 5068 "secrets": "s", 5069 "secret_scanning_alerts": "ssa", 5070 "security_events": "se", 5071 "single_file": "sf", 5072 "statuses": "s", 5073 "team_discussions": "td", 5074 "vulnerability_alerts": "va", 5075 "workflows": "w" 5076 }, 5077 "created_at": ` + referenceTimeStr + `, 5078 "updated_at": ` + referenceTimeStr + `, 5079 "has_multiple_single_files": false, 5080 "suspended_by": { 5081 "login": "l", 5082 "id": 1, 5083 "avatar_url": "a", 5084 "gravatar_id": "g", 5085 "name": "n", 5086 "company": "c", 5087 "blog": "b", 5088 "location": "l", 5089 "email": "e", 5090 "hireable": true, 5091 "bio": "b", 5092 "twitter_username": "t", 5093 "public_repos": 1, 5094 "followers": 1, 5095 "following": 1, 5096 "created_at": ` + referenceTimeStr + `, 5097 "suspended_at": ` + referenceTimeStr + `, 5098 "url": "u" 5099 }, 5100 "suspended_at": ` + referenceTimeStr + ` 5101 } 5102 }` 5103 5104 testJSONMarshal(t, u, want) 5105 } 5106 5107 func TestPageBuildEvent_Marshal(t *testing.T) { 5108 t.Parallel() 5109 testJSONMarshal(t, &PageBuildEvent{}, "{}") 5110 5111 u := &PageBuildEvent{ 5112 Build: &PagesBuild{URL: Ptr("url")}, 5113 ID: Ptr(int64(1)), 5114 Repo: &Repository{ 5115 ID: Ptr(int64(1)), 5116 URL: Ptr("s"), 5117 Name: Ptr("n"), 5118 }, 5119 Sender: &User{ 5120 Login: Ptr("l"), 5121 ID: Ptr(int64(1)), 5122 NodeID: Ptr("n"), 5123 URL: Ptr("u"), 5124 ReposURL: Ptr("r"), 5125 EventsURL: Ptr("e"), 5126 AvatarURL: Ptr("a"), 5127 }, 5128 Installation: &Installation{ 5129 ID: Ptr(int64(1)), 5130 NodeID: Ptr("nid"), 5131 AppID: Ptr(int64(1)), 5132 AppSlug: Ptr("as"), 5133 TargetID: Ptr(int64(1)), 5134 Account: &User{ 5135 Login: Ptr("l"), 5136 ID: Ptr(int64(1)), 5137 URL: Ptr("u"), 5138 AvatarURL: Ptr("a"), 5139 GravatarID: Ptr("g"), 5140 Name: Ptr("n"), 5141 Company: Ptr("c"), 5142 Blog: Ptr("b"), 5143 Location: Ptr("l"), 5144 Email: Ptr("e"), 5145 Hireable: Ptr(true), 5146 Bio: Ptr("b"), 5147 TwitterUsername: Ptr("t"), 5148 PublicRepos: Ptr(1), 5149 Followers: Ptr(1), 5150 Following: Ptr(1), 5151 CreatedAt: &Timestamp{referenceTime}, 5152 SuspendedAt: &Timestamp{referenceTime}, 5153 }, 5154 AccessTokensURL: Ptr("atu"), 5155 RepositoriesURL: Ptr("ru"), 5156 HTMLURL: Ptr("hu"), 5157 TargetType: Ptr("tt"), 5158 SingleFileName: Ptr("sfn"), 5159 RepositorySelection: Ptr("rs"), 5160 Events: []string{"e"}, 5161 SingleFilePaths: []string{"s"}, 5162 Permissions: &InstallationPermissions{ 5163 Actions: Ptr("a"), 5164 Administration: Ptr("ad"), 5165 Checks: Ptr("c"), 5166 Contents: Ptr("co"), 5167 ContentReferences: Ptr("cr"), 5168 Deployments: Ptr("d"), 5169 Environments: Ptr("e"), 5170 Issues: Ptr("i"), 5171 Metadata: Ptr("md"), 5172 Members: Ptr("m"), 5173 OrganizationAdministration: Ptr("oa"), 5174 OrganizationHooks: Ptr("oh"), 5175 OrganizationPlan: Ptr("op"), 5176 OrganizationPreReceiveHooks: Ptr("opr"), 5177 OrganizationProjects: Ptr("op"), 5178 OrganizationSecrets: Ptr("os"), 5179 OrganizationSelfHostedRunners: Ptr("osh"), 5180 OrganizationUserBlocking: Ptr("oub"), 5181 Packages: Ptr("pkg"), 5182 Pages: Ptr("pg"), 5183 PullRequests: Ptr("pr"), 5184 RepositoryHooks: Ptr("rh"), 5185 RepositoryProjects: Ptr("rp"), 5186 RepositoryPreReceiveHooks: Ptr("rprh"), 5187 Secrets: Ptr("s"), 5188 SecretScanningAlerts: Ptr("ssa"), 5189 SecurityEvents: Ptr("se"), 5190 SingleFile: Ptr("sf"), 5191 Statuses: Ptr("s"), 5192 TeamDiscussions: Ptr("td"), 5193 VulnerabilityAlerts: Ptr("va"), 5194 Workflows: Ptr("w"), 5195 }, 5196 CreatedAt: &Timestamp{referenceTime}, 5197 UpdatedAt: &Timestamp{referenceTime}, 5198 HasMultipleSingleFiles: Ptr(false), 5199 SuspendedBy: &User{ 5200 Login: Ptr("l"), 5201 ID: Ptr(int64(1)), 5202 URL: Ptr("u"), 5203 AvatarURL: Ptr("a"), 5204 GravatarID: Ptr("g"), 5205 Name: Ptr("n"), 5206 Company: Ptr("c"), 5207 Blog: Ptr("b"), 5208 Location: Ptr("l"), 5209 Email: Ptr("e"), 5210 Hireable: Ptr(true), 5211 Bio: Ptr("b"), 5212 TwitterUsername: Ptr("t"), 5213 PublicRepos: Ptr(1), 5214 Followers: Ptr(1), 5215 Following: Ptr(1), 5216 CreatedAt: &Timestamp{referenceTime}, 5217 SuspendedAt: &Timestamp{referenceTime}, 5218 }, 5219 SuspendedAt: &Timestamp{referenceTime}, 5220 }, 5221 } 5222 5223 want := `{ 5224 "build": { 5225 "url": "url" 5226 }, 5227 "id": 1, 5228 "repository": { 5229 "id": 1, 5230 "name": "n", 5231 "url": "s" 5232 }, 5233 "sender": { 5234 "login": "l", 5235 "id": 1, 5236 "node_id": "n", 5237 "avatar_url": "a", 5238 "url": "u", 5239 "events_url": "e", 5240 "repos_url": "r" 5241 }, 5242 "installation": { 5243 "id": 1, 5244 "node_id": "nid", 5245 "app_id": 1, 5246 "app_slug": "as", 5247 "target_id": 1, 5248 "account": { 5249 "login": "l", 5250 "id": 1, 5251 "avatar_url": "a", 5252 "gravatar_id": "g", 5253 "name": "n", 5254 "company": "c", 5255 "blog": "b", 5256 "location": "l", 5257 "email": "e", 5258 "hireable": true, 5259 "bio": "b", 5260 "twitter_username": "t", 5261 "public_repos": 1, 5262 "followers": 1, 5263 "following": 1, 5264 "created_at": ` + referenceTimeStr + `, 5265 "suspended_at": ` + referenceTimeStr + `, 5266 "url": "u" 5267 }, 5268 "access_tokens_url": "atu", 5269 "repositories_url": "ru", 5270 "html_url": "hu", 5271 "target_type": "tt", 5272 "single_file_name": "sfn", 5273 "repository_selection": "rs", 5274 "events": [ 5275 "e" 5276 ], 5277 "single_file_paths": [ 5278 "s" 5279 ], 5280 "permissions": { 5281 "actions": "a", 5282 "administration": "ad", 5283 "checks": "c", 5284 "contents": "co", 5285 "content_references": "cr", 5286 "deployments": "d", 5287 "environments": "e", 5288 "issues": "i", 5289 "metadata": "md", 5290 "members": "m", 5291 "organization_administration": "oa", 5292 "organization_hooks": "oh", 5293 "organization_plan": "op", 5294 "organization_pre_receive_hooks": "opr", 5295 "organization_projects": "op", 5296 "organization_secrets": "os", 5297 "organization_self_hosted_runners": "osh", 5298 "organization_user_blocking": "oub", 5299 "packages": "pkg", 5300 "pages": "pg", 5301 "pull_requests": "pr", 5302 "repository_hooks": "rh", 5303 "repository_projects": "rp", 5304 "repository_pre_receive_hooks": "rprh", 5305 "secrets": "s", 5306 "secret_scanning_alerts": "ssa", 5307 "security_events": "se", 5308 "single_file": "sf", 5309 "statuses": "s", 5310 "team_discussions": "td", 5311 "vulnerability_alerts": "va", 5312 "workflows": "w" 5313 }, 5314 "created_at": ` + referenceTimeStr + `, 5315 "updated_at": ` + referenceTimeStr + `, 5316 "has_multiple_single_files": false, 5317 "suspended_by": { 5318 "login": "l", 5319 "id": 1, 5320 "avatar_url": "a", 5321 "gravatar_id": "g", 5322 "name": "n", 5323 "company": "c", 5324 "blog": "b", 5325 "location": "l", 5326 "email": "e", 5327 "hireable": true, 5328 "bio": "b", 5329 "twitter_username": "t", 5330 "public_repos": 1, 5331 "followers": 1, 5332 "following": 1, 5333 "created_at": ` + referenceTimeStr + `, 5334 "suspended_at": ` + referenceTimeStr + `, 5335 "url": "u" 5336 }, 5337 "suspended_at": ` + referenceTimeStr + ` 5338 } 5339 }` 5340 5341 testJSONMarshal(t, u, want) 5342 } 5343 5344 func TestCommitCommentEvent_Marshal(t *testing.T) { 5345 t.Parallel() 5346 testJSONMarshal(t, &CommitCommentEvent{}, "{}") 5347 5348 u := &CommitCommentEvent{ 5349 Comment: &RepositoryComment{ 5350 HTMLURL: Ptr("hurl"), 5351 URL: Ptr("url"), 5352 ID: Ptr(int64(1)), 5353 NodeID: Ptr("nid"), 5354 CommitID: Ptr("cid"), 5355 User: &User{ 5356 Login: Ptr("l"), 5357 ID: Ptr(int64(1)), 5358 NodeID: Ptr("n"), 5359 URL: Ptr("u"), 5360 ReposURL: Ptr("r"), 5361 EventsURL: Ptr("e"), 5362 AvatarURL: Ptr("a"), 5363 }, 5364 Reactions: &Reactions{ 5365 TotalCount: Ptr(1), 5366 PlusOne: Ptr(1), 5367 MinusOne: Ptr(1), 5368 Laugh: Ptr(1), 5369 Confused: Ptr(1), 5370 Heart: Ptr(1), 5371 Hooray: Ptr(1), 5372 Rocket: Ptr(1), 5373 Eyes: Ptr(1), 5374 URL: Ptr("url"), 5375 }, 5376 CreatedAt: &Timestamp{referenceTime}, 5377 UpdatedAt: &Timestamp{referenceTime}, 5378 Body: Ptr("b"), 5379 Path: Ptr("path"), 5380 Position: Ptr(1), 5381 }, 5382 Action: Ptr("a"), 5383 Repo: &Repository{ 5384 ID: Ptr(int64(1)), 5385 URL: Ptr("s"), 5386 Name: Ptr("n"), 5387 }, 5388 Sender: &User{ 5389 Login: Ptr("l"), 5390 ID: Ptr(int64(1)), 5391 NodeID: Ptr("n"), 5392 URL: Ptr("u"), 5393 ReposURL: Ptr("r"), 5394 EventsURL: Ptr("e"), 5395 AvatarURL: Ptr("a"), 5396 }, 5397 Installation: &Installation{ 5398 ID: Ptr(int64(1)), 5399 NodeID: Ptr("nid"), 5400 AppID: Ptr(int64(1)), 5401 AppSlug: Ptr("as"), 5402 TargetID: Ptr(int64(1)), 5403 Account: &User{ 5404 Login: Ptr("l"), 5405 ID: Ptr(int64(1)), 5406 URL: Ptr("u"), 5407 AvatarURL: Ptr("a"), 5408 GravatarID: Ptr("g"), 5409 Name: Ptr("n"), 5410 Company: Ptr("c"), 5411 Blog: Ptr("b"), 5412 Location: Ptr("l"), 5413 Email: Ptr("e"), 5414 Hireable: Ptr(true), 5415 Bio: Ptr("b"), 5416 TwitterUsername: Ptr("t"), 5417 PublicRepos: Ptr(1), 5418 Followers: Ptr(1), 5419 Following: Ptr(1), 5420 CreatedAt: &Timestamp{referenceTime}, 5421 SuspendedAt: &Timestamp{referenceTime}, 5422 }, 5423 AccessTokensURL: Ptr("atu"), 5424 RepositoriesURL: Ptr("ru"), 5425 HTMLURL: Ptr("hu"), 5426 TargetType: Ptr("tt"), 5427 SingleFileName: Ptr("sfn"), 5428 RepositorySelection: Ptr("rs"), 5429 Events: []string{"e"}, 5430 SingleFilePaths: []string{"s"}, 5431 Permissions: &InstallationPermissions{ 5432 Actions: Ptr("a"), 5433 Administration: Ptr("ad"), 5434 Checks: Ptr("c"), 5435 Contents: Ptr("co"), 5436 ContentReferences: Ptr("cr"), 5437 Deployments: Ptr("d"), 5438 Environments: Ptr("e"), 5439 Issues: Ptr("i"), 5440 Metadata: Ptr("md"), 5441 Members: Ptr("m"), 5442 OrganizationAdministration: Ptr("oa"), 5443 OrganizationHooks: Ptr("oh"), 5444 OrganizationPlan: Ptr("op"), 5445 OrganizationPreReceiveHooks: Ptr("opr"), 5446 OrganizationProjects: Ptr("op"), 5447 OrganizationSecrets: Ptr("os"), 5448 OrganizationSelfHostedRunners: Ptr("osh"), 5449 OrganizationUserBlocking: Ptr("oub"), 5450 Packages: Ptr("pkg"), 5451 Pages: Ptr("pg"), 5452 PullRequests: Ptr("pr"), 5453 RepositoryHooks: Ptr("rh"), 5454 RepositoryProjects: Ptr("rp"), 5455 RepositoryPreReceiveHooks: Ptr("rprh"), 5456 Secrets: Ptr("s"), 5457 SecretScanningAlerts: Ptr("ssa"), 5458 SecurityEvents: Ptr("se"), 5459 SingleFile: Ptr("sf"), 5460 Statuses: Ptr("s"), 5461 TeamDiscussions: Ptr("td"), 5462 VulnerabilityAlerts: Ptr("va"), 5463 Workflows: Ptr("w"), 5464 }, 5465 CreatedAt: &Timestamp{referenceTime}, 5466 UpdatedAt: &Timestamp{referenceTime}, 5467 HasMultipleSingleFiles: Ptr(false), 5468 SuspendedBy: &User{ 5469 Login: Ptr("l"), 5470 ID: Ptr(int64(1)), 5471 URL: Ptr("u"), 5472 AvatarURL: Ptr("a"), 5473 GravatarID: Ptr("g"), 5474 Name: Ptr("n"), 5475 Company: Ptr("c"), 5476 Blog: Ptr("b"), 5477 Location: Ptr("l"), 5478 Email: Ptr("e"), 5479 Hireable: Ptr(true), 5480 Bio: Ptr("b"), 5481 TwitterUsername: Ptr("t"), 5482 PublicRepos: Ptr(1), 5483 Followers: Ptr(1), 5484 Following: Ptr(1), 5485 CreatedAt: &Timestamp{referenceTime}, 5486 SuspendedAt: &Timestamp{referenceTime}, 5487 }, 5488 SuspendedAt: &Timestamp{referenceTime}, 5489 }, 5490 } 5491 5492 want := `{ 5493 "comment": { 5494 "html_url": "hurl", 5495 "url": "url", 5496 "id": 1, 5497 "node_id": "nid", 5498 "commit_id": "cid", 5499 "user": { 5500 "login": "l", 5501 "id": 1, 5502 "node_id": "n", 5503 "avatar_url": "a", 5504 "url": "u", 5505 "events_url": "e", 5506 "repos_url": "r" 5507 }, 5508 "reactions": { 5509 "total_count": 1, 5510 "+1": 1, 5511 "-1": 1, 5512 "laugh": 1, 5513 "confused": 1, 5514 "heart": 1, 5515 "hooray": 1, 5516 "rocket": 1, 5517 "eyes": 1, 5518 "url": "url" 5519 }, 5520 "created_at": ` + referenceTimeStr + `, 5521 "updated_at": ` + referenceTimeStr + `, 5522 "body": "b", 5523 "path": "path", 5524 "position": 1 5525 }, 5526 "action": "a", 5527 "repository": { 5528 "id": 1, 5529 "name": "n", 5530 "url": "s" 5531 }, 5532 "sender": { 5533 "login": "l", 5534 "id": 1, 5535 "node_id": "n", 5536 "avatar_url": "a", 5537 "url": "u", 5538 "events_url": "e", 5539 "repos_url": "r" 5540 }, 5541 "installation": { 5542 "id": 1, 5543 "node_id": "nid", 5544 "app_id": 1, 5545 "app_slug": "as", 5546 "target_id": 1, 5547 "account": { 5548 "login": "l", 5549 "id": 1, 5550 "avatar_url": "a", 5551 "gravatar_id": "g", 5552 "name": "n", 5553 "company": "c", 5554 "blog": "b", 5555 "location": "l", 5556 "email": "e", 5557 "hireable": true, 5558 "bio": "b", 5559 "twitter_username": "t", 5560 "public_repos": 1, 5561 "followers": 1, 5562 "following": 1, 5563 "created_at": ` + referenceTimeStr + `, 5564 "suspended_at": ` + referenceTimeStr + `, 5565 "url": "u" 5566 }, 5567 "access_tokens_url": "atu", 5568 "repositories_url": "ru", 5569 "html_url": "hu", 5570 "target_type": "tt", 5571 "single_file_name": "sfn", 5572 "repository_selection": "rs", 5573 "events": [ 5574 "e" 5575 ], 5576 "single_file_paths": [ 5577 "s" 5578 ], 5579 "permissions": { 5580 "actions": "a", 5581 "administration": "ad", 5582 "checks": "c", 5583 "contents": "co", 5584 "content_references": "cr", 5585 "deployments": "d", 5586 "environments": "e", 5587 "issues": "i", 5588 "metadata": "md", 5589 "members": "m", 5590 "organization_administration": "oa", 5591 "organization_hooks": "oh", 5592 "organization_plan": "op", 5593 "organization_pre_receive_hooks": "opr", 5594 "organization_projects": "op", 5595 "organization_secrets": "os", 5596 "organization_self_hosted_runners": "osh", 5597 "organization_user_blocking": "oub", 5598 "packages": "pkg", 5599 "pages": "pg", 5600 "pull_requests": "pr", 5601 "repository_hooks": "rh", 5602 "repository_projects": "rp", 5603 "repository_pre_receive_hooks": "rprh", 5604 "secrets": "s", 5605 "secret_scanning_alerts": "ssa", 5606 "security_events": "se", 5607 "single_file": "sf", 5608 "statuses": "s", 5609 "team_discussions": "td", 5610 "vulnerability_alerts": "va", 5611 "workflows": "w" 5612 }, 5613 "created_at": ` + referenceTimeStr + `, 5614 "updated_at": ` + referenceTimeStr + `, 5615 "has_multiple_single_files": false, 5616 "suspended_by": { 5617 "login": "l", 5618 "id": 1, 5619 "avatar_url": "a", 5620 "gravatar_id": "g", 5621 "name": "n", 5622 "company": "c", 5623 "blog": "b", 5624 "location": "l", 5625 "email": "e", 5626 "hireable": true, 5627 "bio": "b", 5628 "twitter_username": "t", 5629 "public_repos": 1, 5630 "followers": 1, 5631 "following": 1, 5632 "created_at": ` + referenceTimeStr + `, 5633 "suspended_at": ` + referenceTimeStr + `, 5634 "url": "u" 5635 }, 5636 "suspended_at": ` + referenceTimeStr + ` 5637 } 5638 }` 5639 5640 testJSONMarshal(t, u, want) 5641 } 5642 5643 func TestDeploymentEvent_Marshal(t *testing.T) { 5644 t.Parallel() 5645 testJSONMarshal(t, &DeploymentEvent{}, "{}") 5646 5647 l := make(map[string]any) 5648 l["key"] = "value" 5649 5650 jsonMsg, _ := json.Marshal(&l) 5651 5652 u := &DeploymentEvent{ 5653 Deployment: &Deployment{ 5654 URL: Ptr("url"), 5655 ID: Ptr(int64(1)), 5656 SHA: Ptr("sha"), 5657 Ref: Ptr("ref"), 5658 Task: Ptr("t"), 5659 Payload: jsonMsg, 5660 Environment: Ptr("e"), 5661 Description: Ptr("d"), 5662 Creator: &User{ 5663 Login: Ptr("l"), 5664 ID: Ptr(int64(1)), 5665 NodeID: Ptr("n"), 5666 URL: Ptr("u"), 5667 ReposURL: Ptr("r"), 5668 EventsURL: Ptr("e"), 5669 AvatarURL: Ptr("a"), 5670 }, 5671 CreatedAt: &Timestamp{referenceTime}, 5672 UpdatedAt: &Timestamp{referenceTime}, 5673 StatusesURL: Ptr("surl"), 5674 RepositoryURL: Ptr("rurl"), 5675 NodeID: Ptr("nid"), 5676 }, 5677 Repo: &Repository{ 5678 ID: Ptr(int64(1)), 5679 URL: Ptr("s"), 5680 Name: Ptr("n"), 5681 }, 5682 Sender: &User{ 5683 Login: Ptr("l"), 5684 ID: Ptr(int64(1)), 5685 NodeID: Ptr("n"), 5686 URL: Ptr("u"), 5687 ReposURL: Ptr("r"), 5688 EventsURL: Ptr("e"), 5689 AvatarURL: Ptr("a"), 5690 }, 5691 Installation: &Installation{ 5692 ID: Ptr(int64(1)), 5693 NodeID: Ptr("nid"), 5694 AppID: Ptr(int64(1)), 5695 AppSlug: Ptr("as"), 5696 TargetID: Ptr(int64(1)), 5697 Account: &User{ 5698 Login: Ptr("l"), 5699 ID: Ptr(int64(1)), 5700 URL: Ptr("u"), 5701 AvatarURL: Ptr("a"), 5702 GravatarID: Ptr("g"), 5703 Name: Ptr("n"), 5704 Company: Ptr("c"), 5705 Blog: Ptr("b"), 5706 Location: Ptr("l"), 5707 Email: Ptr("e"), 5708 Hireable: Ptr(true), 5709 Bio: Ptr("b"), 5710 TwitterUsername: Ptr("t"), 5711 PublicRepos: Ptr(1), 5712 Followers: Ptr(1), 5713 Following: Ptr(1), 5714 CreatedAt: &Timestamp{referenceTime}, 5715 SuspendedAt: &Timestamp{referenceTime}, 5716 }, 5717 AccessTokensURL: Ptr("atu"), 5718 RepositoriesURL: Ptr("ru"), 5719 HTMLURL: Ptr("hu"), 5720 TargetType: Ptr("tt"), 5721 SingleFileName: Ptr("sfn"), 5722 RepositorySelection: Ptr("rs"), 5723 Events: []string{"e"}, 5724 SingleFilePaths: []string{"s"}, 5725 Permissions: &InstallationPermissions{ 5726 Actions: Ptr("a"), 5727 Administration: Ptr("ad"), 5728 Checks: Ptr("c"), 5729 Contents: Ptr("co"), 5730 ContentReferences: Ptr("cr"), 5731 Deployments: Ptr("d"), 5732 Environments: Ptr("e"), 5733 Issues: Ptr("i"), 5734 Metadata: Ptr("md"), 5735 Members: Ptr("m"), 5736 OrganizationAdministration: Ptr("oa"), 5737 OrganizationHooks: Ptr("oh"), 5738 OrganizationPlan: Ptr("op"), 5739 OrganizationPreReceiveHooks: Ptr("opr"), 5740 OrganizationProjects: Ptr("op"), 5741 OrganizationSecrets: Ptr("os"), 5742 OrganizationSelfHostedRunners: Ptr("osh"), 5743 OrganizationUserBlocking: Ptr("oub"), 5744 Packages: Ptr("pkg"), 5745 Pages: Ptr("pg"), 5746 PullRequests: Ptr("pr"), 5747 RepositoryHooks: Ptr("rh"), 5748 RepositoryProjects: Ptr("rp"), 5749 RepositoryPreReceiveHooks: Ptr("rprh"), 5750 Secrets: Ptr("s"), 5751 SecretScanningAlerts: Ptr("ssa"), 5752 SecurityEvents: Ptr("se"), 5753 SingleFile: Ptr("sf"), 5754 Statuses: Ptr("s"), 5755 TeamDiscussions: Ptr("td"), 5756 VulnerabilityAlerts: Ptr("va"), 5757 Workflows: Ptr("w"), 5758 }, 5759 CreatedAt: &Timestamp{referenceTime}, 5760 UpdatedAt: &Timestamp{referenceTime}, 5761 HasMultipleSingleFiles: Ptr(false), 5762 SuspendedBy: &User{ 5763 Login: Ptr("l"), 5764 ID: Ptr(int64(1)), 5765 URL: Ptr("u"), 5766 AvatarURL: Ptr("a"), 5767 GravatarID: Ptr("g"), 5768 Name: Ptr("n"), 5769 Company: Ptr("c"), 5770 Blog: Ptr("b"), 5771 Location: Ptr("l"), 5772 Email: Ptr("e"), 5773 Hireable: Ptr(true), 5774 Bio: Ptr("b"), 5775 TwitterUsername: Ptr("t"), 5776 PublicRepos: Ptr(1), 5777 Followers: Ptr(1), 5778 Following: Ptr(1), 5779 CreatedAt: &Timestamp{referenceTime}, 5780 SuspendedAt: &Timestamp{referenceTime}, 5781 }, 5782 SuspendedAt: &Timestamp{referenceTime}, 5783 }, 5784 Workflow: &Workflow{ 5785 ID: Ptr(int64(1)), 5786 NodeID: Ptr("nid"), 5787 Name: Ptr("n"), 5788 Path: Ptr("p"), 5789 State: Ptr("s"), 5790 CreatedAt: &Timestamp{referenceTime}, 5791 UpdatedAt: &Timestamp{referenceTime}, 5792 URL: Ptr("u"), 5793 HTMLURL: Ptr("h"), 5794 BadgeURL: Ptr("b"), 5795 }, 5796 WorkflowRun: &WorkflowRun{ 5797 ID: Ptr(int64(1)), 5798 Name: Ptr("n"), 5799 NodeID: Ptr("nid"), 5800 HeadBranch: Ptr("hb"), 5801 HeadSHA: Ptr("hs"), 5802 RunNumber: Ptr(1), 5803 RunAttempt: Ptr(1), 5804 Event: Ptr("e"), 5805 Status: Ptr("s"), 5806 Conclusion: Ptr("c"), 5807 WorkflowID: Ptr(int64(1)), 5808 URL: Ptr("u"), 5809 HTMLURL: Ptr("h"), 5810 PullRequests: []*PullRequest{ 5811 { 5812 URL: Ptr("u"), 5813 ID: Ptr(int64(1)), 5814 Number: Ptr(1), 5815 Head: &PullRequestBranch{ 5816 Ref: Ptr("r"), 5817 SHA: Ptr("s"), 5818 Repo: &Repository{ 5819 ID: Ptr(int64(1)), 5820 URL: Ptr("s"), 5821 Name: Ptr("n"), 5822 }, 5823 }, 5824 Base: &PullRequestBranch{ 5825 Ref: Ptr("r"), 5826 SHA: Ptr("s"), 5827 Repo: &Repository{ 5828 ID: Ptr(int64(1)), 5829 URL: Ptr("u"), 5830 Name: Ptr("n"), 5831 }, 5832 }, 5833 }, 5834 }, 5835 CreatedAt: &Timestamp{referenceTime}, 5836 UpdatedAt: &Timestamp{referenceTime}, 5837 RunStartedAt: &Timestamp{referenceTime}, 5838 JobsURL: Ptr("j"), 5839 LogsURL: Ptr("l"), 5840 CheckSuiteURL: Ptr("c"), 5841 ArtifactsURL: Ptr("a"), 5842 CancelURL: Ptr("c"), 5843 RerunURL: Ptr("r"), 5844 PreviousAttemptURL: Ptr("p"), 5845 HeadCommit: &HeadCommit{ 5846 Message: Ptr("m"), 5847 Author: &CommitAuthor{ 5848 Name: Ptr("n"), 5849 Email: Ptr("e"), 5850 Login: Ptr("l"), 5851 }, 5852 URL: Ptr("u"), 5853 Distinct: Ptr(false), 5854 SHA: Ptr("s"), 5855 ID: Ptr("i"), 5856 TreeID: Ptr("tid"), 5857 Timestamp: &Timestamp{referenceTime}, 5858 Committer: &CommitAuthor{ 5859 Name: Ptr("n"), 5860 Email: Ptr("e"), 5861 Login: Ptr("l"), 5862 }, 5863 }, 5864 WorkflowURL: Ptr("w"), 5865 Repository: &Repository{ 5866 ID: Ptr(int64(1)), 5867 URL: Ptr("u"), 5868 Name: Ptr("n"), 5869 }, 5870 HeadRepository: &Repository{ 5871 ID: Ptr(int64(1)), 5872 URL: Ptr("u"), 5873 Name: Ptr("n"), 5874 }, 5875 }, 5876 } 5877 5878 want := `{ 5879 "deployment": { 5880 "url": "url", 5881 "id": 1, 5882 "sha": "sha", 5883 "ref": "ref", 5884 "task": "t", 5885 "payload": { 5886 "key": "value" 5887 }, 5888 "environment": "e", 5889 "description": "d", 5890 "creator": { 5891 "login": "l", 5892 "id": 1, 5893 "node_id": "n", 5894 "avatar_url": "a", 5895 "url": "u", 5896 "events_url": "e", 5897 "repos_url": "r" 5898 }, 5899 "created_at": ` + referenceTimeStr + `, 5900 "updated_at": ` + referenceTimeStr + `, 5901 "statuses_url": "surl", 5902 "repository_url": "rurl", 5903 "node_id": "nid" 5904 }, 5905 "repository": { 5906 "id": 1, 5907 "name": "n", 5908 "url": "s" 5909 }, 5910 "sender": { 5911 "login": "l", 5912 "id": 1, 5913 "node_id": "n", 5914 "avatar_url": "a", 5915 "url": "u", 5916 "events_url": "e", 5917 "repos_url": "r" 5918 }, 5919 "installation": { 5920 "id": 1, 5921 "node_id": "nid", 5922 "app_id": 1, 5923 "app_slug": "as", 5924 "target_id": 1, 5925 "account": { 5926 "login": "l", 5927 "id": 1, 5928 "avatar_url": "a", 5929 "gravatar_id": "g", 5930 "name": "n", 5931 "company": "c", 5932 "blog": "b", 5933 "location": "l", 5934 "email": "e", 5935 "hireable": true, 5936 "bio": "b", 5937 "twitter_username": "t", 5938 "public_repos": 1, 5939 "followers": 1, 5940 "following": 1, 5941 "created_at": ` + referenceTimeStr + `, 5942 "suspended_at": ` + referenceTimeStr + `, 5943 "url": "u" 5944 }, 5945 "access_tokens_url": "atu", 5946 "repositories_url": "ru", 5947 "html_url": "hu", 5948 "target_type": "tt", 5949 "single_file_name": "sfn", 5950 "repository_selection": "rs", 5951 "events": [ 5952 "e" 5953 ], 5954 "single_file_paths": [ 5955 "s" 5956 ], 5957 "permissions": { 5958 "actions": "a", 5959 "administration": "ad", 5960 "checks": "c", 5961 "contents": "co", 5962 "content_references": "cr", 5963 "deployments": "d", 5964 "environments": "e", 5965 "issues": "i", 5966 "metadata": "md", 5967 "members": "m", 5968 "organization_administration": "oa", 5969 "organization_hooks": "oh", 5970 "organization_plan": "op", 5971 "organization_pre_receive_hooks": "opr", 5972 "organization_projects": "op", 5973 "organization_secrets": "os", 5974 "organization_self_hosted_runners": "osh", 5975 "organization_user_blocking": "oub", 5976 "packages": "pkg", 5977 "pages": "pg", 5978 "pull_requests": "pr", 5979 "repository_hooks": "rh", 5980 "repository_projects": "rp", 5981 "repository_pre_receive_hooks": "rprh", 5982 "secrets": "s", 5983 "secret_scanning_alerts": "ssa", 5984 "security_events": "se", 5985 "single_file": "sf", 5986 "statuses": "s", 5987 "team_discussions": "td", 5988 "vulnerability_alerts": "va", 5989 "workflows": "w" 5990 }, 5991 "created_at": ` + referenceTimeStr + `, 5992 "updated_at": ` + referenceTimeStr + `, 5993 "has_multiple_single_files": false, 5994 "suspended_by": { 5995 "login": "l", 5996 "id": 1, 5997 "avatar_url": "a", 5998 "gravatar_id": "g", 5999 "name": "n", 6000 "company": "c", 6001 "blog": "b", 6002 "location": "l", 6003 "email": "e", 6004 "hireable": true, 6005 "bio": "b", 6006 "twitter_username": "t", 6007 "public_repos": 1, 6008 "followers": 1, 6009 "following": 1, 6010 "created_at": ` + referenceTimeStr + `, 6011 "suspended_at": ` + referenceTimeStr + `, 6012 "url": "u" 6013 }, 6014 "suspended_at": ` + referenceTimeStr + ` 6015 }, 6016 "workflow": { 6017 "id": 1, 6018 "node_id": "nid", 6019 "name": "n", 6020 "path": "p", 6021 "state": "s", 6022 "created_at": ` + referenceTimeStr + `, 6023 "updated_at": ` + referenceTimeStr + `, 6024 "url": "u", 6025 "html_url": "h", 6026 "badge_url": "b" 6027 }, 6028 "workflow_run": { 6029 "id": 1, 6030 "name": "n", 6031 "node_id": "nid", 6032 "head_branch": "hb", 6033 "head_sha": "hs", 6034 "run_number": 1, 6035 "run_attempt": 1, 6036 "event": "e", 6037 "status": "s", 6038 "conclusion": "c", 6039 "workflow_id": 1, 6040 "url": "u", 6041 "html_url": "h", 6042 "pull_requests": [ 6043 { 6044 "id": 1, 6045 "number": 1, 6046 "url": "u", 6047 "head": { 6048 "ref": "r", 6049 "sha": "s", 6050 "repo": { 6051 "id": 1, 6052 "name": "n", 6053 "url": "s" 6054 } 6055 }, 6056 "base": { 6057 "ref": "r", 6058 "sha": "s", 6059 "repo": { 6060 "id": 1, 6061 "name": "n", 6062 "url": "u" 6063 } 6064 } 6065 } 6066 ], 6067 "created_at": ` + referenceTimeStr + `, 6068 "updated_at": ` + referenceTimeStr + `, 6069 "run_started_at": ` + referenceTimeStr + `, 6070 "jobs_url": "j", 6071 "logs_url": "l", 6072 "check_suite_url": "c", 6073 "artifacts_url": "a", 6074 "cancel_url": "c", 6075 "rerun_url": "r", 6076 "previous_attempt_url": "p", 6077 "head_commit": { 6078 "message": "m", 6079 "author": { 6080 "name": "n", 6081 "email": "e", 6082 "username": "l" 6083 }, 6084 "url": "u", 6085 "distinct": false, 6086 "sha": "s", 6087 "id": "i", 6088 "tree_id": "tid", 6089 "timestamp": ` + referenceTimeStr + `, 6090 "committer": { 6091 "name": "n", 6092 "email": "e", 6093 "username": "l" 6094 } 6095 }, 6096 "workflow_url": "w", 6097 "repository": { 6098 "id": 1, 6099 "name": "n", 6100 "url": "u" 6101 }, 6102 "head_repository": { 6103 "id": 1, 6104 "name": "n", 6105 "url": "u" 6106 } 6107 } 6108 }` 6109 6110 testJSONMarshal(t, u, want) 6111 } 6112 6113 func TestDeploymentProtectionRuleEvent_Marshal(t *testing.T) { 6114 t.Parallel() 6115 testJSONMarshal(t, &DeploymentProtectionRuleEvent{}, "{}") 6116 6117 l := make(map[string]any) 6118 l["key"] = "value" 6119 6120 jsonMsg, _ := json.Marshal(&l) 6121 6122 u := &DeploymentProtectionRuleEvent{ 6123 Action: Ptr("a"), 6124 Environment: Ptr("e"), 6125 DeploymentCallbackURL: Ptr("b"), 6126 Deployment: &Deployment{ 6127 URL: Ptr("url"), 6128 ID: Ptr(int64(1)), 6129 SHA: Ptr("sha"), 6130 Ref: Ptr("ref"), 6131 Task: Ptr("t"), 6132 Payload: jsonMsg, 6133 Environment: Ptr("e"), 6134 Description: Ptr("d"), 6135 Creator: &User{ 6136 Login: Ptr("l"), 6137 ID: Ptr(int64(1)), 6138 NodeID: Ptr("n"), 6139 URL: Ptr("u"), 6140 ReposURL: Ptr("r"), 6141 EventsURL: Ptr("e"), 6142 AvatarURL: Ptr("a"), 6143 }, 6144 CreatedAt: &Timestamp{referenceTime}, 6145 UpdatedAt: &Timestamp{referenceTime}, 6146 StatusesURL: Ptr("surl"), 6147 RepositoryURL: Ptr("rurl"), 6148 NodeID: Ptr("nid"), 6149 }, 6150 Repo: &Repository{ 6151 ID: Ptr(int64(1)), 6152 URL: Ptr("s"), 6153 Name: Ptr("n"), 6154 }, 6155 Organization: &Organization{ 6156 BillingEmail: Ptr("be"), 6157 Blog: Ptr("b"), 6158 Company: Ptr("c"), 6159 Email: Ptr("e"), 6160 TwitterUsername: Ptr("tu"), 6161 Location: Ptr("loc"), 6162 Name: Ptr("n"), 6163 Description: Ptr("d"), 6164 IsVerified: Ptr(true), 6165 HasOrganizationProjects: Ptr(true), 6166 HasRepositoryProjects: Ptr(true), 6167 DefaultRepoPermission: Ptr("drp"), 6168 MembersCanCreateRepos: Ptr(true), 6169 MembersCanCreateInternalRepos: Ptr(true), 6170 MembersCanCreatePrivateRepos: Ptr(true), 6171 MembersCanCreatePublicRepos: Ptr(false), 6172 MembersAllowedRepositoryCreationType: Ptr("marct"), 6173 MembersCanCreatePages: Ptr(true), 6174 MembersCanCreatePublicPages: Ptr(false), 6175 MembersCanCreatePrivatePages: Ptr(true), 6176 }, 6177 PullRequests: []*PullRequest{ 6178 { 6179 URL: Ptr("u"), 6180 ID: Ptr(int64(1)), 6181 Number: Ptr(1), 6182 Head: &PullRequestBranch{ 6183 Ref: Ptr("r"), 6184 SHA: Ptr("s"), 6185 Repo: &Repository{ 6186 ID: Ptr(int64(1)), 6187 URL: Ptr("s"), 6188 Name: Ptr("n"), 6189 }, 6190 }, 6191 Base: &PullRequestBranch{ 6192 Ref: Ptr("r"), 6193 SHA: Ptr("s"), 6194 Repo: &Repository{ 6195 ID: Ptr(int64(1)), 6196 URL: Ptr("u"), 6197 Name: Ptr("n"), 6198 }, 6199 }, 6200 }, 6201 }, 6202 Sender: &User{ 6203 Login: Ptr("l"), 6204 ID: Ptr(int64(1)), 6205 NodeID: Ptr("n"), 6206 URL: Ptr("u"), 6207 ReposURL: Ptr("r"), 6208 EventsURL: Ptr("e"), 6209 AvatarURL: Ptr("a"), 6210 }, 6211 Installation: &Installation{ 6212 ID: Ptr(int64(1)), 6213 NodeID: Ptr("nid"), 6214 AppID: Ptr(int64(1)), 6215 AppSlug: Ptr("as"), 6216 TargetID: Ptr(int64(1)), 6217 Account: &User{ 6218 Login: Ptr("l"), 6219 ID: Ptr(int64(1)), 6220 URL: Ptr("u"), 6221 AvatarURL: Ptr("a"), 6222 GravatarID: Ptr("g"), 6223 Name: Ptr("n"), 6224 Company: Ptr("c"), 6225 Blog: Ptr("b"), 6226 Location: Ptr("l"), 6227 Email: Ptr("e"), 6228 Hireable: Ptr(true), 6229 Bio: Ptr("b"), 6230 TwitterUsername: Ptr("t"), 6231 PublicRepos: Ptr(1), 6232 Followers: Ptr(1), 6233 Following: Ptr(1), 6234 CreatedAt: &Timestamp{referenceTime}, 6235 SuspendedAt: &Timestamp{referenceTime}, 6236 }, 6237 AccessTokensURL: Ptr("atu"), 6238 RepositoriesURL: Ptr("ru"), 6239 HTMLURL: Ptr("hu"), 6240 TargetType: Ptr("tt"), 6241 SingleFileName: Ptr("sfn"), 6242 RepositorySelection: Ptr("rs"), 6243 Events: []string{"e"}, 6244 SingleFilePaths: []string{"s"}, 6245 Permissions: &InstallationPermissions{ 6246 Actions: Ptr("a"), 6247 Administration: Ptr("ad"), 6248 Checks: Ptr("c"), 6249 Contents: Ptr("co"), 6250 ContentReferences: Ptr("cr"), 6251 Deployments: Ptr("d"), 6252 Environments: Ptr("e"), 6253 Issues: Ptr("i"), 6254 Metadata: Ptr("md"), 6255 Members: Ptr("m"), 6256 OrganizationAdministration: Ptr("oa"), 6257 OrganizationHooks: Ptr("oh"), 6258 OrganizationPlan: Ptr("op"), 6259 OrganizationPreReceiveHooks: Ptr("opr"), 6260 OrganizationProjects: Ptr("op"), 6261 OrganizationSecrets: Ptr("os"), 6262 OrganizationSelfHostedRunners: Ptr("osh"), 6263 OrganizationUserBlocking: Ptr("oub"), 6264 Packages: Ptr("pkg"), 6265 Pages: Ptr("pg"), 6266 PullRequests: Ptr("pr"), 6267 RepositoryHooks: Ptr("rh"), 6268 RepositoryProjects: Ptr("rp"), 6269 RepositoryPreReceiveHooks: Ptr("rprh"), 6270 Secrets: Ptr("s"), 6271 SecretScanningAlerts: Ptr("ssa"), 6272 SecurityEvents: Ptr("se"), 6273 SingleFile: Ptr("sf"), 6274 Statuses: Ptr("s"), 6275 TeamDiscussions: Ptr("td"), 6276 VulnerabilityAlerts: Ptr("va"), 6277 Workflows: Ptr("w"), 6278 }, 6279 CreatedAt: &Timestamp{referenceTime}, 6280 UpdatedAt: &Timestamp{referenceTime}, 6281 HasMultipleSingleFiles: Ptr(false), 6282 SuspendedBy: &User{ 6283 Login: Ptr("l"), 6284 ID: Ptr(int64(1)), 6285 URL: Ptr("u"), 6286 AvatarURL: Ptr("a"), 6287 GravatarID: Ptr("g"), 6288 Name: Ptr("n"), 6289 Company: Ptr("c"), 6290 Blog: Ptr("b"), 6291 Location: Ptr("l"), 6292 Email: Ptr("e"), 6293 Hireable: Ptr(true), 6294 Bio: Ptr("b"), 6295 TwitterUsername: Ptr("t"), 6296 PublicRepos: Ptr(1), 6297 Followers: Ptr(1), 6298 Following: Ptr(1), 6299 CreatedAt: &Timestamp{referenceTime}, 6300 SuspendedAt: &Timestamp{referenceTime}, 6301 }, 6302 SuspendedAt: &Timestamp{referenceTime}, 6303 }, 6304 } 6305 6306 want := `{ 6307 "action": "a", 6308 "environment": "e", 6309 "deployment_callback_url": "b", 6310 "deployment": { 6311 "url": "url", 6312 "id": 1, 6313 "sha": "sha", 6314 "ref": "ref", 6315 "task": "t", 6316 "payload": { 6317 "key": "value" 6318 }, 6319 "environment": "e", 6320 "description": "d", 6321 "creator": { 6322 "login": "l", 6323 "id": 1, 6324 "node_id": "n", 6325 "avatar_url": "a", 6326 "url": "u", 6327 "events_url": "e", 6328 "repos_url": "r" 6329 }, 6330 "created_at": ` + referenceTimeStr + `, 6331 "updated_at": ` + referenceTimeStr + `, 6332 "statuses_url": "surl", 6333 "repository_url": "rurl", 6334 "node_id": "nid" 6335 }, 6336 "repository": { 6337 "id": 1, 6338 "name": "n", 6339 "url": "s" 6340 }, 6341 "organization": { 6342 "name": "n", 6343 "company": "c", 6344 "blog": "b", 6345 "location": "loc", 6346 "email": "e", 6347 "twitter_username": "tu", 6348 "description": "d", 6349 "billing_email": "be", 6350 "is_verified": true, 6351 "has_organization_projects": true, 6352 "has_repository_projects": true, 6353 "default_repository_permission": "drp", 6354 "members_can_create_repositories": true, 6355 "members_can_create_public_repositories": false, 6356 "members_can_create_private_repositories": true, 6357 "members_can_create_internal_repositories": true, 6358 "members_allowed_repository_creation_type": "marct", 6359 "members_can_create_pages": true, 6360 "members_can_create_public_pages": false, 6361 "members_can_create_private_pages": true 6362 }, 6363 "pull_requests": [ 6364 { 6365 "id": 1, 6366 "number": 1, 6367 "url": "u", 6368 "head": { 6369 "ref": "r", 6370 "sha": "s", 6371 "repo": { 6372 "id": 1, 6373 "name": "n", 6374 "url": "s" 6375 } 6376 }, 6377 "base": { 6378 "ref": "r", 6379 "sha": "s", 6380 "repo": { 6381 "id": 1, 6382 "name": "n", 6383 "url": "u" 6384 } 6385 } 6386 } 6387 ], 6388 "sender": { 6389 "login": "l", 6390 "id": 1, 6391 "node_id": "n", 6392 "avatar_url": "a", 6393 "url": "u", 6394 "events_url": "e", 6395 "repos_url": "r" 6396 }, 6397 "installation": { 6398 "id": 1, 6399 "node_id": "nid", 6400 "app_id": 1, 6401 "app_slug": "as", 6402 "target_id": 1, 6403 "account": { 6404 "login": "l", 6405 "id": 1, 6406 "avatar_url": "a", 6407 "gravatar_id": "g", 6408 "name": "n", 6409 "company": "c", 6410 "blog": "b", 6411 "location": "l", 6412 "email": "e", 6413 "hireable": true, 6414 "bio": "b", 6415 "twitter_username": "t", 6416 "public_repos": 1, 6417 "followers": 1, 6418 "following": 1, 6419 "created_at": ` + referenceTimeStr + `, 6420 "suspended_at": ` + referenceTimeStr + `, 6421 "url": "u" 6422 }, 6423 "access_tokens_url": "atu", 6424 "repositories_url": "ru", 6425 "html_url": "hu", 6426 "target_type": "tt", 6427 "single_file_name": "sfn", 6428 "repository_selection": "rs", 6429 "events": [ 6430 "e" 6431 ], 6432 "single_file_paths": [ 6433 "s" 6434 ], 6435 "permissions": { 6436 "actions": "a", 6437 "administration": "ad", 6438 "checks": "c", 6439 "contents": "co", 6440 "content_references": "cr", 6441 "deployments": "d", 6442 "environments": "e", 6443 "issues": "i", 6444 "metadata": "md", 6445 "members": "m", 6446 "organization_administration": "oa", 6447 "organization_hooks": "oh", 6448 "organization_plan": "op", 6449 "organization_pre_receive_hooks": "opr", 6450 "organization_projects": "op", 6451 "organization_secrets": "os", 6452 "organization_self_hosted_runners": "osh", 6453 "organization_user_blocking": "oub", 6454 "packages": "pkg", 6455 "pages": "pg", 6456 "pull_requests": "pr", 6457 "repository_hooks": "rh", 6458 "repository_projects": "rp", 6459 "repository_pre_receive_hooks": "rprh", 6460 "secrets": "s", 6461 "secret_scanning_alerts": "ssa", 6462 "security_events": "se", 6463 "single_file": "sf", 6464 "statuses": "s", 6465 "team_discussions": "td", 6466 "vulnerability_alerts": "va", 6467 "workflows": "w" 6468 }, 6469 "created_at": ` + referenceTimeStr + `, 6470 "updated_at": ` + referenceTimeStr + `, 6471 "has_multiple_single_files": false, 6472 "suspended_by": { 6473 "login": "l", 6474 "id": 1, 6475 "avatar_url": "a", 6476 "gravatar_id": "g", 6477 "name": "n", 6478 "company": "c", 6479 "blog": "b", 6480 "location": "l", 6481 "email": "e", 6482 "hireable": true, 6483 "bio": "b", 6484 "twitter_username": "t", 6485 "public_repos": 1, 6486 "followers": 1, 6487 "following": 1, 6488 "created_at": ` + referenceTimeStr + `, 6489 "suspended_at": ` + referenceTimeStr + `, 6490 "url": "u" 6491 }, 6492 "suspended_at": ` + referenceTimeStr + ` 6493 } 6494 }` 6495 6496 testJSONMarshal(t, u, want) 6497 } 6498 6499 func TestDeploymentReviewEvent_Marshal(t *testing.T) { 6500 t.Parallel() 6501 testJSONMarshal(t, &DeploymentReviewEvent{}, "{}") 6502 6503 u := &DeploymentReviewEvent{ 6504 Action: Ptr("a"), 6505 Environment: Ptr("e"), 6506 Requester: &User{ 6507 AvatarURL: Ptr("a"), 6508 Email: Ptr("e"), 6509 EventsURL: Ptr("e"), 6510 FollowersURL: Ptr("f"), 6511 FollowingURL: Ptr("f"), 6512 GistsURL: Ptr("g"), 6513 GravatarID: Ptr("g"), 6514 HTMLURL: Ptr("h"), 6515 ID: Ptr(int64(1)), 6516 Login: Ptr("l"), 6517 Name: Ptr("n"), 6518 NodeID: Ptr("n"), 6519 OrganizationsURL: Ptr("o"), 6520 ReceivedEventsURL: Ptr("r"), 6521 ReposURL: Ptr("r"), 6522 SiteAdmin: Ptr(false), 6523 StarredURL: Ptr("s"), 6524 SubscriptionsURL: Ptr("s"), 6525 Type: Ptr("User"), 6526 URL: Ptr("u"), 6527 }, 6528 Reviewers: []*RequiredReviewer{ 6529 { 6530 Type: Ptr("User"), 6531 Reviewer: &User{ 6532 AvatarURL: Ptr("a"), 6533 Email: Ptr("e"), 6534 EventsURL: Ptr("e"), 6535 FollowersURL: Ptr("f"), 6536 FollowingURL: Ptr("f"), 6537 GistsURL: Ptr("g"), 6538 GravatarID: Ptr("g"), 6539 HTMLURL: Ptr("h"), 6540 ID: Ptr(int64(1)), 6541 Login: Ptr("l"), 6542 Name: Ptr("n"), 6543 NodeID: Ptr("n"), 6544 OrganizationsURL: Ptr("o"), 6545 ReceivedEventsURL: Ptr("r"), 6546 ReposURL: Ptr("r"), 6547 SiteAdmin: Ptr(false), 6548 StarredURL: Ptr("s"), 6549 SubscriptionsURL: Ptr("s"), 6550 Type: Ptr("User"), 6551 URL: Ptr("u"), 6552 }, 6553 }, 6554 { 6555 Type: Ptr("Team"), 6556 Reviewer: &Team{ 6557 ID: Ptr(int64(1)), 6558 Name: Ptr("n"), 6559 Slug: Ptr("s"), 6560 }, 6561 }, 6562 }, 6563 Enterprise: &Enterprise{ 6564 ID: Ptr(1), 6565 Slug: Ptr("s"), 6566 Name: Ptr("n"), 6567 NodeID: Ptr("nid"), 6568 AvatarURL: Ptr("au"), 6569 Description: Ptr("d"), 6570 WebsiteURL: Ptr("wu"), 6571 HTMLURL: Ptr("hu"), 6572 CreatedAt: &Timestamp{referenceTime}, 6573 UpdatedAt: &Timestamp{referenceTime}, 6574 }, 6575 Installation: &Installation{ 6576 ID: Ptr(int64(1)), 6577 NodeID: Ptr("nid"), 6578 AppID: Ptr(int64(1)), 6579 AppSlug: Ptr("as"), 6580 TargetID: Ptr(int64(1)), 6581 Account: &User{ 6582 Login: Ptr("l"), 6583 ID: Ptr(int64(1)), 6584 URL: Ptr("u"), 6585 AvatarURL: Ptr("a"), 6586 GravatarID: Ptr("g"), 6587 Name: Ptr("n"), 6588 Company: Ptr("c"), 6589 Blog: Ptr("b"), 6590 Location: Ptr("l"), 6591 Email: Ptr("e"), 6592 Hireable: Ptr(true), 6593 Bio: Ptr("b"), 6594 TwitterUsername: Ptr("t"), 6595 PublicRepos: Ptr(1), 6596 Followers: Ptr(1), 6597 Following: Ptr(1), 6598 CreatedAt: &Timestamp{referenceTime}, 6599 SuspendedAt: &Timestamp{referenceTime}, 6600 }, 6601 AccessTokensURL: Ptr("atu"), 6602 RepositoriesURL: Ptr("ru"), 6603 HTMLURL: Ptr("hu"), 6604 TargetType: Ptr("tt"), 6605 SingleFileName: Ptr("sfn"), 6606 RepositorySelection: Ptr("rs"), 6607 Events: []string{"e"}, 6608 SingleFilePaths: []string{"s"}, 6609 Permissions: &InstallationPermissions{ 6610 Actions: Ptr("a"), 6611 Administration: Ptr("ad"), 6612 Checks: Ptr("c"), 6613 Contents: Ptr("co"), 6614 ContentReferences: Ptr("cr"), 6615 Deployments: Ptr("d"), 6616 Environments: Ptr("e"), 6617 Issues: Ptr("i"), 6618 Metadata: Ptr("md"), 6619 Members: Ptr("m"), 6620 OrganizationAdministration: Ptr("oa"), 6621 OrganizationHooks: Ptr("oh"), 6622 OrganizationPlan: Ptr("op"), 6623 OrganizationPreReceiveHooks: Ptr("opr"), 6624 OrganizationProjects: Ptr("op"), 6625 OrganizationSecrets: Ptr("os"), 6626 OrganizationSelfHostedRunners: Ptr("osh"), 6627 OrganizationUserBlocking: Ptr("oub"), 6628 Packages: Ptr("pkg"), 6629 Pages: Ptr("pg"), 6630 PullRequests: Ptr("pr"), 6631 RepositoryHooks: Ptr("rh"), 6632 RepositoryProjects: Ptr("rp"), 6633 RepositoryPreReceiveHooks: Ptr("rprh"), 6634 Secrets: Ptr("s"), 6635 SecretScanningAlerts: Ptr("ssa"), 6636 SecurityEvents: Ptr("se"), 6637 SingleFile: Ptr("sf"), 6638 Statuses: Ptr("s"), 6639 TeamDiscussions: Ptr("td"), 6640 VulnerabilityAlerts: Ptr("va"), 6641 Workflows: Ptr("w"), 6642 }, 6643 CreatedAt: &Timestamp{referenceTime}, 6644 UpdatedAt: &Timestamp{referenceTime}, 6645 HasMultipleSingleFiles: Ptr(false), 6646 SuspendedBy: &User{ 6647 Login: Ptr("l"), 6648 ID: Ptr(int64(1)), 6649 URL: Ptr("u"), 6650 AvatarURL: Ptr("a"), 6651 GravatarID: Ptr("g"), 6652 Name: Ptr("n"), 6653 Company: Ptr("c"), 6654 Blog: Ptr("b"), 6655 Location: Ptr("l"), 6656 Email: Ptr("e"), 6657 Hireable: Ptr(true), 6658 Bio: Ptr("b"), 6659 TwitterUsername: Ptr("t"), 6660 PublicRepos: Ptr(1), 6661 Followers: Ptr(1), 6662 Following: Ptr(1), 6663 CreatedAt: &Timestamp{referenceTime}, 6664 SuspendedAt: &Timestamp{referenceTime}, 6665 }, 6666 SuspendedAt: &Timestamp{referenceTime}, 6667 }, 6668 Organization: &Organization{ 6669 BillingEmail: Ptr("be"), 6670 Blog: Ptr("b"), 6671 Company: Ptr("c"), 6672 Email: Ptr("e"), 6673 TwitterUsername: Ptr("tu"), 6674 Location: Ptr("loc"), 6675 Name: Ptr("n"), 6676 Description: Ptr("d"), 6677 IsVerified: Ptr(true), 6678 HasOrganizationProjects: Ptr(true), 6679 HasRepositoryProjects: Ptr(true), 6680 DefaultRepoPermission: Ptr("drp"), 6681 MembersCanCreateRepos: Ptr(true), 6682 MembersCanCreateInternalRepos: Ptr(true), 6683 MembersCanCreatePrivateRepos: Ptr(true), 6684 MembersCanCreatePublicRepos: Ptr(false), 6685 MembersAllowedRepositoryCreationType: Ptr("marct"), 6686 MembersCanCreatePages: Ptr(true), 6687 MembersCanCreatePublicPages: Ptr(false), 6688 MembersCanCreatePrivatePages: Ptr(true), 6689 }, 6690 Repo: &Repository{ 6691 ID: Ptr(int64(1)), 6692 URL: Ptr("s"), 6693 Name: Ptr("n"), 6694 }, 6695 Sender: &User{ 6696 Login: Ptr("l"), 6697 ID: Ptr(int64(1)), 6698 NodeID: Ptr("n"), 6699 URL: Ptr("u"), 6700 ReposURL: Ptr("r"), 6701 EventsURL: Ptr("e"), 6702 AvatarURL: Ptr("a"), 6703 }, 6704 Since: Ptr("s"), 6705 WorkflowJobRun: &WorkflowJobRun{ 6706 ID: Ptr(int64(1)), 6707 Conclusion: Ptr("c"), 6708 Environment: Ptr("e"), 6709 HTMLURL: Ptr("h"), 6710 Name: Ptr("n"), 6711 Status: Ptr("s"), 6712 CreatedAt: &Timestamp{referenceTime}, 6713 UpdatedAt: &Timestamp{referenceTime}, 6714 }, 6715 WorkflowRun: &WorkflowRun{ 6716 ID: Ptr(int64(1)), 6717 Name: Ptr("n"), 6718 NodeID: Ptr("nid"), 6719 HeadBranch: Ptr("hb"), 6720 HeadSHA: Ptr("hs"), 6721 RunNumber: Ptr(1), 6722 RunAttempt: Ptr(1), 6723 Event: Ptr("e"), 6724 Status: Ptr("s"), 6725 Conclusion: Ptr("c"), 6726 WorkflowID: Ptr(int64(1)), 6727 URL: Ptr("u"), 6728 HTMLURL: Ptr("h"), 6729 PullRequests: []*PullRequest{ 6730 { 6731 URL: Ptr("u"), 6732 ID: Ptr(int64(1)), 6733 Number: Ptr(1), 6734 Head: &PullRequestBranch{ 6735 Ref: Ptr("r"), 6736 SHA: Ptr("s"), 6737 Repo: &Repository{ 6738 ID: Ptr(int64(1)), 6739 URL: Ptr("s"), 6740 Name: Ptr("n"), 6741 }, 6742 }, 6743 Base: &PullRequestBranch{ 6744 Ref: Ptr("r"), 6745 SHA: Ptr("s"), 6746 Repo: &Repository{ 6747 ID: Ptr(int64(1)), 6748 URL: Ptr("u"), 6749 Name: Ptr("n"), 6750 }, 6751 }, 6752 }, 6753 }, 6754 CreatedAt: &Timestamp{referenceTime}, 6755 UpdatedAt: &Timestamp{referenceTime}, 6756 RunStartedAt: &Timestamp{referenceTime}, 6757 JobsURL: Ptr("j"), 6758 LogsURL: Ptr("l"), 6759 CheckSuiteURL: Ptr("c"), 6760 ArtifactsURL: Ptr("a"), 6761 CancelURL: Ptr("c"), 6762 RerunURL: Ptr("r"), 6763 PreviousAttemptURL: Ptr("p"), 6764 HeadCommit: &HeadCommit{ 6765 Message: Ptr("m"), 6766 Author: &CommitAuthor{ 6767 Name: Ptr("n"), 6768 Email: Ptr("e"), 6769 Login: Ptr("l"), 6770 }, 6771 URL: Ptr("u"), 6772 Distinct: Ptr(false), 6773 SHA: Ptr("s"), 6774 ID: Ptr("i"), 6775 TreeID: Ptr("tid"), 6776 Timestamp: &Timestamp{referenceTime}, 6777 Committer: &CommitAuthor{ 6778 Name: Ptr("n"), 6779 Email: Ptr("e"), 6780 Login: Ptr("l"), 6781 }, 6782 }, 6783 WorkflowURL: Ptr("w"), 6784 Repository: &Repository{ 6785 ID: Ptr(int64(1)), 6786 URL: Ptr("u"), 6787 Name: Ptr("n"), 6788 }, 6789 HeadRepository: &Repository{ 6790 ID: Ptr(int64(1)), 6791 URL: Ptr("u"), 6792 Name: Ptr("n"), 6793 }, 6794 }, 6795 } 6796 6797 want := `{ 6798 "action": "a", 6799 "requester": { 6800 "login": "l", 6801 "id": 1, 6802 "node_id": "n", 6803 "avatar_url": "a", 6804 "url": "u", 6805 "html_url": "h", 6806 "followers_url": "f", 6807 "following_url": "f", 6808 "gists_url": "g", 6809 "starred_url": "s", 6810 "subscriptions_url": "s", 6811 "organizations_url": "o", 6812 "repos_url": "r", 6813 "events_url": "e", 6814 "received_events_url": "r", 6815 "type": "User", 6816 "site_admin": false, 6817 "name": "n", 6818 "email": "e", 6819 "gravatar_id": "g" 6820 }, 6821 "reviewers": [ 6822 { 6823 "type": "User", 6824 "reviewer": { 6825 "login": "l", 6826 "id": 1, 6827 "node_id": "n", 6828 "avatar_url": "a", 6829 "url": "u", 6830 "html_url": "h", 6831 "followers_url": "f", 6832 "following_url": "f", 6833 "gists_url": "g", 6834 "starred_url": "s", 6835 "subscriptions_url": "s", 6836 "organizations_url": "o", 6837 "repos_url": "r", 6838 "events_url": "e", 6839 "received_events_url": "r", 6840 "type": "User", 6841 "site_admin": false, 6842 "name": "n", 6843 "email": "e", 6844 "gravatar_id": "g" 6845 } 6846 }, 6847 { 6848 "type": "Team", 6849 "reviewer": { 6850 "id": 1, 6851 "name": "n", 6852 "slug": "s" 6853 } 6854 } 6855 ], 6856 "repository": { 6857 "id": 1, 6858 "name": "n", 6859 "url": "s" 6860 }, 6861 "organization": { 6862 "name": "n", 6863 "company": "c", 6864 "blog": "b", 6865 "location": "loc", 6866 "email": "e", 6867 "twitter_username": "tu", 6868 "description": "d", 6869 "billing_email": "be", 6870 "is_verified": true, 6871 "has_organization_projects": true, 6872 "has_repository_projects": true, 6873 "default_repository_permission": "drp", 6874 "members_can_create_repositories": true, 6875 "members_can_create_public_repositories": false, 6876 "members_can_create_private_repositories": true, 6877 "members_can_create_internal_repositories": true, 6878 "members_allowed_repository_creation_type": "marct", 6879 "members_can_create_pages": true, 6880 "members_can_create_public_pages": false, 6881 "members_can_create_private_pages": true 6882 }, 6883 "environment": "e", 6884 "enterprise": { 6885 "id": 1, 6886 "slug": "s", 6887 "name": "n", 6888 "node_id": "nid", 6889 "avatar_url": "au", 6890 "description": "d", 6891 "website_url": "wu", 6892 "html_url": "hu", 6893 "created_at": ` + referenceTimeStr + `, 6894 "updated_at": ` + referenceTimeStr + ` 6895 }, 6896 "sender": { 6897 "login": "l", 6898 "id": 1, 6899 "node_id": "n", 6900 "avatar_url": "a", 6901 "url": "u", 6902 "events_url": "e", 6903 "repos_url": "r" 6904 }, 6905 "installation": { 6906 "id": 1, 6907 "node_id": "nid", 6908 "app_id": 1, 6909 "app_slug": "as", 6910 "target_id": 1, 6911 "account": { 6912 "login": "l", 6913 "id": 1, 6914 "avatar_url": "a", 6915 "gravatar_id": "g", 6916 "name": "n", 6917 "company": "c", 6918 "blog": "b", 6919 "location": "l", 6920 "email": "e", 6921 "hireable": true, 6922 "bio": "b", 6923 "twitter_username": "t", 6924 "public_repos": 1, 6925 "followers": 1, 6926 "following": 1, 6927 "created_at": ` + referenceTimeStr + `, 6928 "suspended_at": ` + referenceTimeStr + `, 6929 "url": "u" 6930 }, 6931 "access_tokens_url": "atu", 6932 "repositories_url": "ru", 6933 "html_url": "hu", 6934 "target_type": "tt", 6935 "single_file_name": "sfn", 6936 "repository_selection": "rs", 6937 "events": [ 6938 "e" 6939 ], 6940 "single_file_paths": [ 6941 "s" 6942 ], 6943 "permissions": { 6944 "actions": "a", 6945 "administration": "ad", 6946 "checks": "c", 6947 "contents": "co", 6948 "content_references": "cr", 6949 "deployments": "d", 6950 "environments": "e", 6951 "issues": "i", 6952 "metadata": "md", 6953 "members": "m", 6954 "organization_administration": "oa", 6955 "organization_hooks": "oh", 6956 "organization_plan": "op", 6957 "organization_pre_receive_hooks": "opr", 6958 "organization_projects": "op", 6959 "organization_secrets": "os", 6960 "organization_self_hosted_runners": "osh", 6961 "organization_user_blocking": "oub", 6962 "packages": "pkg", 6963 "pages": "pg", 6964 "pull_requests": "pr", 6965 "repository_hooks": "rh", 6966 "repository_projects": "rp", 6967 "repository_pre_receive_hooks": "rprh", 6968 "secrets": "s", 6969 "secret_scanning_alerts": "ssa", 6970 "security_events": "se", 6971 "single_file": "sf", 6972 "statuses": "s", 6973 "team_discussions": "td", 6974 "vulnerability_alerts": "va", 6975 "workflows": "w" 6976 }, 6977 "created_at": ` + referenceTimeStr + `, 6978 "updated_at": ` + referenceTimeStr + `, 6979 "has_multiple_single_files": false, 6980 "suspended_by": { 6981 "login": "l", 6982 "id": 1, 6983 "avatar_url": "a", 6984 "gravatar_id": "g", 6985 "name": "n", 6986 "company": "c", 6987 "blog": "b", 6988 "location": "l", 6989 "email": "e", 6990 "hireable": true, 6991 "bio": "b", 6992 "twitter_username": "t", 6993 "public_repos": 1, 6994 "followers": 1, 6995 "following": 1, 6996 "created_at": ` + referenceTimeStr + `, 6997 "suspended_at": ` + referenceTimeStr + `, 6998 "url": "u" 6999 }, 7000 "suspended_at": ` + referenceTimeStr + ` 7001 }, 7002 "since": "s", 7003 "workflow_job_run": { 7004 "conclusion": "c", 7005 "created_at": "2006-01-02T15:04:05Z", 7006 "environment": "e", 7007 "html_url": "h", 7008 "id": 1, 7009 "name": "n", 7010 "status": "s", 7011 "updated_at": "2006-01-02T15:04:05Z" 7012 }, 7013 "workflow_run": { 7014 "id": 1, 7015 "name": "n", 7016 "node_id": "nid", 7017 "head_branch": "hb", 7018 "head_sha": "hs", 7019 "run_number": 1, 7020 "run_attempt": 1, 7021 "event": "e", 7022 "status": "s", 7023 "conclusion": "c", 7024 "workflow_id": 1, 7025 "url": "u", 7026 "html_url": "h", 7027 "pull_requests": [ 7028 { 7029 "id": 1, 7030 "number": 1, 7031 "url": "u", 7032 "head": { 7033 "ref": "r", 7034 "sha": "s", 7035 "repo": { 7036 "id": 1, 7037 "name": "n", 7038 "url": "s" 7039 } 7040 }, 7041 "base": { 7042 "ref": "r", 7043 "sha": "s", 7044 "repo": { 7045 "id": 1, 7046 "name": "n", 7047 "url": "u" 7048 } 7049 } 7050 } 7051 ], 7052 "created_at": ` + referenceTimeStr + `, 7053 "updated_at": ` + referenceTimeStr + `, 7054 "run_started_at": ` + referenceTimeStr + `, 7055 "jobs_url": "j", 7056 "logs_url": "l", 7057 "check_suite_url": "c", 7058 "artifacts_url": "a", 7059 "cancel_url": "c", 7060 "rerun_url": "r", 7061 "previous_attempt_url": "p", 7062 "head_commit": { 7063 "message": "m", 7064 "author": { 7065 "name": "n", 7066 "email": "e", 7067 "username": "l" 7068 }, 7069 "url": "u", 7070 "distinct": false, 7071 "sha": "s", 7072 "id": "i", 7073 "tree_id": "tid", 7074 "timestamp": ` + referenceTimeStr + `, 7075 "committer": { 7076 "name": "n", 7077 "email": "e", 7078 "username": "l" 7079 } 7080 }, 7081 "workflow_url": "w", 7082 "repository": { 7083 "id": 1, 7084 "name": "n", 7085 "url": "u" 7086 }, 7087 "head_repository": { 7088 "id": 1, 7089 "name": "n", 7090 "url": "u" 7091 } 7092 } 7093 }` 7094 7095 testJSONMarshal(t, u, want) 7096 } 7097 7098 func TestDeploymentStatusEvent_Marshal(t *testing.T) { 7099 t.Parallel() 7100 testJSONMarshal(t, &DeploymentStatusEvent{}, "{}") 7101 7102 l := make(map[string]any) 7103 l["key"] = "value" 7104 7105 jsonMsg, _ := json.Marshal(&l) 7106 7107 u := &DeploymentStatusEvent{ 7108 Deployment: &Deployment{ 7109 URL: Ptr("url"), 7110 ID: Ptr(int64(1)), 7111 SHA: Ptr("sha"), 7112 Ref: Ptr("ref"), 7113 Task: Ptr("t"), 7114 Payload: jsonMsg, 7115 Environment: Ptr("e"), 7116 Description: Ptr("d"), 7117 Creator: &User{ 7118 Login: Ptr("l"), 7119 ID: Ptr(int64(1)), 7120 NodeID: Ptr("n"), 7121 URL: Ptr("u"), 7122 ReposURL: Ptr("r"), 7123 EventsURL: Ptr("e"), 7124 AvatarURL: Ptr("a"), 7125 }, 7126 CreatedAt: &Timestamp{referenceTime}, 7127 UpdatedAt: &Timestamp{referenceTime}, 7128 StatusesURL: Ptr("surl"), 7129 RepositoryURL: Ptr("rurl"), 7130 NodeID: Ptr("nid"), 7131 }, 7132 DeploymentStatus: &DeploymentStatus{ 7133 ID: Ptr(int64(1)), 7134 State: Ptr("s"), 7135 Creator: &User{ 7136 Login: Ptr("l"), 7137 ID: Ptr(int64(1)), 7138 NodeID: Ptr("n"), 7139 URL: Ptr("u"), 7140 ReposURL: Ptr("r"), 7141 EventsURL: Ptr("e"), 7142 AvatarURL: Ptr("a"), 7143 }, 7144 Description: Ptr("s"), 7145 Environment: Ptr("s"), 7146 NodeID: Ptr("s"), 7147 CreatedAt: &Timestamp{referenceTime}, 7148 UpdatedAt: &Timestamp{referenceTime}, 7149 TargetURL: Ptr("s"), 7150 DeploymentURL: Ptr("s"), 7151 RepositoryURL: Ptr("s"), 7152 EnvironmentURL: Ptr("s"), 7153 LogURL: Ptr("s"), 7154 URL: Ptr("s"), 7155 }, 7156 Repo: &Repository{ 7157 ID: Ptr(int64(1)), 7158 URL: Ptr("s"), 7159 Name: Ptr("n"), 7160 }, 7161 Sender: &User{ 7162 Login: Ptr("l"), 7163 ID: Ptr(int64(1)), 7164 NodeID: Ptr("n"), 7165 URL: Ptr("u"), 7166 ReposURL: Ptr("r"), 7167 EventsURL: Ptr("e"), 7168 AvatarURL: Ptr("a"), 7169 }, 7170 Installation: &Installation{ 7171 ID: Ptr(int64(1)), 7172 NodeID: Ptr("nid"), 7173 AppID: Ptr(int64(1)), 7174 AppSlug: Ptr("as"), 7175 TargetID: Ptr(int64(1)), 7176 Account: &User{ 7177 Login: Ptr("l"), 7178 ID: Ptr(int64(1)), 7179 URL: Ptr("u"), 7180 AvatarURL: Ptr("a"), 7181 GravatarID: Ptr("g"), 7182 Name: Ptr("n"), 7183 Company: Ptr("c"), 7184 Blog: Ptr("b"), 7185 Location: Ptr("l"), 7186 Email: Ptr("e"), 7187 Hireable: Ptr(true), 7188 Bio: Ptr("b"), 7189 TwitterUsername: Ptr("t"), 7190 PublicRepos: Ptr(1), 7191 Followers: Ptr(1), 7192 Following: Ptr(1), 7193 CreatedAt: &Timestamp{referenceTime}, 7194 SuspendedAt: &Timestamp{referenceTime}, 7195 }, 7196 AccessTokensURL: Ptr("atu"), 7197 RepositoriesURL: Ptr("ru"), 7198 HTMLURL: Ptr("hu"), 7199 TargetType: Ptr("tt"), 7200 SingleFileName: Ptr("sfn"), 7201 RepositorySelection: Ptr("rs"), 7202 Events: []string{"e"}, 7203 SingleFilePaths: []string{"s"}, 7204 Permissions: &InstallationPermissions{ 7205 Actions: Ptr("a"), 7206 Administration: Ptr("ad"), 7207 Checks: Ptr("c"), 7208 Contents: Ptr("co"), 7209 ContentReferences: Ptr("cr"), 7210 Deployments: Ptr("d"), 7211 Environments: Ptr("e"), 7212 Issues: Ptr("i"), 7213 Metadata: Ptr("md"), 7214 Members: Ptr("m"), 7215 OrganizationAdministration: Ptr("oa"), 7216 OrganizationHooks: Ptr("oh"), 7217 OrganizationPlan: Ptr("op"), 7218 OrganizationPreReceiveHooks: Ptr("opr"), 7219 OrganizationProjects: Ptr("op"), 7220 OrganizationSecrets: Ptr("os"), 7221 OrganizationSelfHostedRunners: Ptr("osh"), 7222 OrganizationUserBlocking: Ptr("oub"), 7223 Packages: Ptr("pkg"), 7224 Pages: Ptr("pg"), 7225 PullRequests: Ptr("pr"), 7226 RepositoryHooks: Ptr("rh"), 7227 RepositoryProjects: Ptr("rp"), 7228 RepositoryPreReceiveHooks: Ptr("rprh"), 7229 Secrets: Ptr("s"), 7230 SecretScanningAlerts: Ptr("ssa"), 7231 SecurityEvents: Ptr("se"), 7232 SingleFile: Ptr("sf"), 7233 Statuses: Ptr("s"), 7234 TeamDiscussions: Ptr("td"), 7235 VulnerabilityAlerts: Ptr("va"), 7236 Workflows: Ptr("w"), 7237 }, 7238 CreatedAt: &Timestamp{referenceTime}, 7239 UpdatedAt: &Timestamp{referenceTime}, 7240 HasMultipleSingleFiles: Ptr(false), 7241 SuspendedBy: &User{ 7242 Login: Ptr("l"), 7243 ID: Ptr(int64(1)), 7244 URL: Ptr("u"), 7245 AvatarURL: Ptr("a"), 7246 GravatarID: Ptr("g"), 7247 Name: Ptr("n"), 7248 Company: Ptr("c"), 7249 Blog: Ptr("b"), 7250 Location: Ptr("l"), 7251 Email: Ptr("e"), 7252 Hireable: Ptr(true), 7253 Bio: Ptr("b"), 7254 TwitterUsername: Ptr("t"), 7255 PublicRepos: Ptr(1), 7256 Followers: Ptr(1), 7257 Following: Ptr(1), 7258 CreatedAt: &Timestamp{referenceTime}, 7259 SuspendedAt: &Timestamp{referenceTime}, 7260 }, 7261 SuspendedAt: &Timestamp{referenceTime}, 7262 }, 7263 } 7264 7265 want := `{ 7266 "deployment": { 7267 "url": "url", 7268 "id": 1, 7269 "sha": "sha", 7270 "ref": "ref", 7271 "task": "t", 7272 "payload": { 7273 "key": "value" 7274 }, 7275 "environment": "e", 7276 "description": "d", 7277 "creator": { 7278 "login": "l", 7279 "id": 1, 7280 "node_id": "n", 7281 "avatar_url": "a", 7282 "url": "u", 7283 "events_url": "e", 7284 "repos_url": "r" 7285 }, 7286 "created_at": ` + referenceTimeStr + `, 7287 "updated_at": ` + referenceTimeStr + `, 7288 "statuses_url": "surl", 7289 "repository_url": "rurl", 7290 "node_id": "nid" 7291 }, 7292 "deployment_status": { 7293 "id": 1, 7294 "state": "s", 7295 "creator": { 7296 "login": "l", 7297 "id": 1, 7298 "node_id": "n", 7299 "avatar_url": "a", 7300 "url": "u", 7301 "events_url": "e", 7302 "repos_url": "r" 7303 }, 7304 "description": "s", 7305 "environment": "s", 7306 "node_id": "s", 7307 "created_at": ` + referenceTimeStr + `, 7308 "updated_at": ` + referenceTimeStr + `, 7309 "target_url": "s", 7310 "deployment_url": "s", 7311 "repository_url": "s", 7312 "environment_url": "s", 7313 "log_url": "s", 7314 "url": "s" 7315 }, 7316 "repository": { 7317 "id": 1, 7318 "name": "n", 7319 "url": "s" 7320 }, 7321 "sender": { 7322 "login": "l", 7323 "id": 1, 7324 "node_id": "n", 7325 "avatar_url": "a", 7326 "url": "u", 7327 "events_url": "e", 7328 "repos_url": "r" 7329 }, 7330 "installation": { 7331 "id": 1, 7332 "node_id": "nid", 7333 "app_id": 1, 7334 "app_slug": "as", 7335 "target_id": 1, 7336 "account": { 7337 "login": "l", 7338 "id": 1, 7339 "avatar_url": "a", 7340 "gravatar_id": "g", 7341 "name": "n", 7342 "company": "c", 7343 "blog": "b", 7344 "location": "l", 7345 "email": "e", 7346 "hireable": true, 7347 "bio": "b", 7348 "twitter_username": "t", 7349 "public_repos": 1, 7350 "followers": 1, 7351 "following": 1, 7352 "created_at": ` + referenceTimeStr + `, 7353 "suspended_at": ` + referenceTimeStr + `, 7354 "url": "u" 7355 }, 7356 "access_tokens_url": "atu", 7357 "repositories_url": "ru", 7358 "html_url": "hu", 7359 "target_type": "tt", 7360 "single_file_name": "sfn", 7361 "repository_selection": "rs", 7362 "events": [ 7363 "e" 7364 ], 7365 "single_file_paths": [ 7366 "s" 7367 ], 7368 "permissions": { 7369 "actions": "a", 7370 "administration": "ad", 7371 "checks": "c", 7372 "contents": "co", 7373 "content_references": "cr", 7374 "deployments": "d", 7375 "environments": "e", 7376 "issues": "i", 7377 "metadata": "md", 7378 "members": "m", 7379 "organization_administration": "oa", 7380 "organization_hooks": "oh", 7381 "organization_plan": "op", 7382 "organization_pre_receive_hooks": "opr", 7383 "organization_projects": "op", 7384 "organization_secrets": "os", 7385 "organization_self_hosted_runners": "osh", 7386 "organization_user_blocking": "oub", 7387 "packages": "pkg", 7388 "pages": "pg", 7389 "pull_requests": "pr", 7390 "repository_hooks": "rh", 7391 "repository_projects": "rp", 7392 "repository_pre_receive_hooks": "rprh", 7393 "secrets": "s", 7394 "secret_scanning_alerts": "ssa", 7395 "security_events": "se", 7396 "single_file": "sf", 7397 "statuses": "s", 7398 "team_discussions": "td", 7399 "vulnerability_alerts": "va", 7400 "workflows": "w" 7401 }, 7402 "created_at": ` + referenceTimeStr + `, 7403 "updated_at": ` + referenceTimeStr + `, 7404 "has_multiple_single_files": false, 7405 "suspended_by": { 7406 "login": "l", 7407 "id": 1, 7408 "avatar_url": "a", 7409 "gravatar_id": "g", 7410 "name": "n", 7411 "company": "c", 7412 "blog": "b", 7413 "location": "l", 7414 "email": "e", 7415 "hireable": true, 7416 "bio": "b", 7417 "twitter_username": "t", 7418 "public_repos": 1, 7419 "followers": 1, 7420 "following": 1, 7421 "created_at": ` + referenceTimeStr + `, 7422 "suspended_at": ` + referenceTimeStr + `, 7423 "url": "u" 7424 }, 7425 "suspended_at": ` + referenceTimeStr + ` 7426 } 7427 }` 7428 7429 testJSONMarshal(t, u, want) 7430 } 7431 7432 func TestDiscussionCommentEvent_Marshal(t *testing.T) { 7433 t.Parallel() 7434 testJSONMarshal(t, &DiscussionCommentEvent{}, "{}") 7435 7436 u := &DiscussionCommentEvent{ 7437 Comment: &CommentDiscussion{ 7438 AuthorAssociation: Ptr("aa"), 7439 Body: Ptr("bo"), 7440 ChildCommentCount: Ptr(1), 7441 CreatedAt: &Timestamp{referenceTime}, 7442 DiscussionID: Ptr(int64(1)), 7443 HTMLURL: Ptr("hurl"), 7444 ID: Ptr(int64(1)), 7445 NodeID: Ptr("nid"), 7446 ParentID: Ptr(int64(1)), 7447 Reactions: &Reactions{ 7448 TotalCount: Ptr(1), 7449 PlusOne: Ptr(1), 7450 MinusOne: Ptr(1), 7451 Laugh: Ptr(1), 7452 Confused: Ptr(1), 7453 Heart: Ptr(1), 7454 Hooray: Ptr(1), 7455 Rocket: Ptr(1), 7456 Eyes: Ptr(1), 7457 URL: Ptr("url"), 7458 }, 7459 RepositoryURL: Ptr("rurl"), 7460 UpdatedAt: &Timestamp{referenceTime}, 7461 User: &User{ 7462 Login: Ptr("l"), 7463 ID: Ptr(int64(1)), 7464 NodeID: Ptr("n"), 7465 URL: Ptr("u"), 7466 ReposURL: Ptr("r"), 7467 EventsURL: Ptr("e"), 7468 AvatarURL: Ptr("a"), 7469 }, 7470 }, 7471 Discussion: &Discussion{ 7472 RepositoryURL: Ptr("rurl"), 7473 DiscussionCategory: &DiscussionCategory{ 7474 ID: Ptr(int64(1)), 7475 NodeID: Ptr("nid"), 7476 RepositoryID: Ptr(int64(1)), 7477 Emoji: Ptr("emoji"), 7478 Name: Ptr("name"), 7479 Description: Ptr("description"), 7480 CreatedAt: &Timestamp{referenceTime}, 7481 UpdatedAt: &Timestamp{referenceTime}, 7482 Slug: Ptr("slug"), 7483 IsAnswerable: Ptr(false), 7484 }, 7485 HTMLURL: Ptr("hurl"), 7486 ID: Ptr(int64(1)), 7487 NodeID: Ptr("nurl"), 7488 Number: Ptr(1), 7489 Title: Ptr("title"), 7490 User: &User{ 7491 Login: Ptr("l"), 7492 ID: Ptr(int64(1)), 7493 NodeID: Ptr("n"), 7494 URL: Ptr("u"), 7495 ReposURL: Ptr("r"), 7496 EventsURL: Ptr("e"), 7497 AvatarURL: Ptr("a"), 7498 }, 7499 State: Ptr("st"), 7500 Locked: Ptr(false), 7501 Comments: Ptr(1), 7502 CreatedAt: &Timestamp{referenceTime}, 7503 UpdatedAt: &Timestamp{referenceTime}, 7504 AuthorAssociation: Ptr("aa"), 7505 Body: Ptr("bo"), 7506 }, 7507 Repo: &Repository{ 7508 ID: Ptr(int64(1)), 7509 URL: Ptr("s"), 7510 Name: Ptr("n"), 7511 }, 7512 Org: &Organization{ 7513 BillingEmail: Ptr("be"), 7514 Blog: Ptr("b"), 7515 Company: Ptr("c"), 7516 Email: Ptr("e"), 7517 TwitterUsername: Ptr("tu"), 7518 Location: Ptr("loc"), 7519 Name: Ptr("n"), 7520 Description: Ptr("d"), 7521 IsVerified: Ptr(true), 7522 HasOrganizationProjects: Ptr(true), 7523 HasRepositoryProjects: Ptr(true), 7524 DefaultRepoPermission: Ptr("drp"), 7525 MembersCanCreateRepos: Ptr(true), 7526 MembersCanCreateInternalRepos: Ptr(true), 7527 MembersCanCreatePrivateRepos: Ptr(true), 7528 MembersCanCreatePublicRepos: Ptr(false), 7529 MembersAllowedRepositoryCreationType: Ptr("marct"), 7530 MembersCanCreatePages: Ptr(true), 7531 MembersCanCreatePublicPages: Ptr(false), 7532 MembersCanCreatePrivatePages: Ptr(true), 7533 }, 7534 Sender: &User{ 7535 Login: Ptr("l"), 7536 ID: Ptr(int64(1)), 7537 NodeID: Ptr("n"), 7538 URL: Ptr("u"), 7539 ReposURL: Ptr("r"), 7540 EventsURL: Ptr("e"), 7541 AvatarURL: Ptr("a"), 7542 }, 7543 Installation: &Installation{ 7544 ID: Ptr(int64(1)), 7545 NodeID: Ptr("nid"), 7546 AppID: Ptr(int64(1)), 7547 AppSlug: Ptr("as"), 7548 TargetID: Ptr(int64(1)), 7549 Account: &User{ 7550 Login: Ptr("l"), 7551 ID: Ptr(int64(1)), 7552 URL: Ptr("u"), 7553 AvatarURL: Ptr("a"), 7554 GravatarID: Ptr("g"), 7555 Name: Ptr("n"), 7556 Company: Ptr("c"), 7557 Blog: Ptr("b"), 7558 Location: Ptr("l"), 7559 Email: Ptr("e"), 7560 Hireable: Ptr(true), 7561 Bio: Ptr("b"), 7562 TwitterUsername: Ptr("t"), 7563 PublicRepos: Ptr(1), 7564 Followers: Ptr(1), 7565 Following: Ptr(1), 7566 CreatedAt: &Timestamp{referenceTime}, 7567 SuspendedAt: &Timestamp{referenceTime}, 7568 }, 7569 AccessTokensURL: Ptr("atu"), 7570 RepositoriesURL: Ptr("ru"), 7571 HTMLURL: Ptr("hu"), 7572 TargetType: Ptr("tt"), 7573 SingleFileName: Ptr("sfn"), 7574 RepositorySelection: Ptr("rs"), 7575 Events: []string{"e"}, 7576 SingleFilePaths: []string{"s"}, 7577 Permissions: &InstallationPermissions{ 7578 Actions: Ptr("a"), 7579 Administration: Ptr("ad"), 7580 Checks: Ptr("c"), 7581 Contents: Ptr("co"), 7582 ContentReferences: Ptr("cr"), 7583 Deployments: Ptr("d"), 7584 Environments: Ptr("e"), 7585 Issues: Ptr("i"), 7586 Metadata: Ptr("md"), 7587 Members: Ptr("m"), 7588 OrganizationAdministration: Ptr("oa"), 7589 OrganizationHooks: Ptr("oh"), 7590 OrganizationPlan: Ptr("op"), 7591 OrganizationPreReceiveHooks: Ptr("opr"), 7592 OrganizationProjects: Ptr("op"), 7593 OrganizationSecrets: Ptr("os"), 7594 OrganizationSelfHostedRunners: Ptr("osh"), 7595 OrganizationUserBlocking: Ptr("oub"), 7596 Packages: Ptr("pkg"), 7597 Pages: Ptr("pg"), 7598 PullRequests: Ptr("pr"), 7599 RepositoryHooks: Ptr("rh"), 7600 RepositoryProjects: Ptr("rp"), 7601 RepositoryPreReceiveHooks: Ptr("rprh"), 7602 Secrets: Ptr("s"), 7603 SecretScanningAlerts: Ptr("ssa"), 7604 SecurityEvents: Ptr("se"), 7605 SingleFile: Ptr("sf"), 7606 Statuses: Ptr("s"), 7607 TeamDiscussions: Ptr("td"), 7608 VulnerabilityAlerts: Ptr("va"), 7609 Workflows: Ptr("w"), 7610 }, 7611 CreatedAt: &Timestamp{referenceTime}, 7612 UpdatedAt: &Timestamp{referenceTime}, 7613 HasMultipleSingleFiles: Ptr(false), 7614 SuspendedBy: &User{ 7615 Login: Ptr("l"), 7616 ID: Ptr(int64(1)), 7617 URL: Ptr("u"), 7618 AvatarURL: Ptr("a"), 7619 GravatarID: Ptr("g"), 7620 Name: Ptr("n"), 7621 Company: Ptr("c"), 7622 Blog: Ptr("b"), 7623 Location: Ptr("l"), 7624 Email: Ptr("e"), 7625 Hireable: Ptr(true), 7626 Bio: Ptr("b"), 7627 TwitterUsername: Ptr("t"), 7628 PublicRepos: Ptr(1), 7629 Followers: Ptr(1), 7630 Following: Ptr(1), 7631 CreatedAt: &Timestamp{referenceTime}, 7632 SuspendedAt: &Timestamp{referenceTime}, 7633 }, 7634 SuspendedAt: &Timestamp{referenceTime}, 7635 }, 7636 } 7637 7638 want := `{ 7639 "comment": { 7640 "author_association": "aa", 7641 "body": "bo", 7642 "child_comment_count": 1, 7643 "created_at": ` + referenceTimeStr + `, 7644 "discussion_id": 1, 7645 "html_url": "hurl", 7646 "id": 1, 7647 "node_id": "nid", 7648 "parent_id": 1, 7649 "reactions": { 7650 "total_count": 1, 7651 "+1": 1, 7652 "-1": 1, 7653 "laugh": 1, 7654 "confused": 1, 7655 "heart": 1, 7656 "hooray": 1, 7657 "rocket": 1, 7658 "eyes": 1, 7659 "url": "url" 7660 }, 7661 "repository_url": "rurl", 7662 "updated_at": ` + referenceTimeStr + `, 7663 "user": { 7664 "login": "l", 7665 "id": 1, 7666 "node_id": "n", 7667 "avatar_url": "a", 7668 "url": "u", 7669 "events_url": "e", 7670 "repos_url": "r" 7671 } 7672 }, 7673 "discussion": { 7674 "repository_url": "rurl", 7675 "category": { 7676 "id": 1, 7677 "node_id": "nid", 7678 "repository_id": 1, 7679 "emoji": "emoji", 7680 "name": "name", 7681 "description": "description", 7682 "created_at": ` + referenceTimeStr + `, 7683 "updated_at": ` + referenceTimeStr + `, 7684 "slug": "slug", 7685 "is_answerable": false 7686 }, 7687 "html_url": "hurl", 7688 "id": 1, 7689 "node_id": "nurl", 7690 "number": 1, 7691 "title": "title", 7692 "user": { 7693 "login": "l", 7694 "id": 1, 7695 "node_id": "n", 7696 "avatar_url": "a", 7697 "url": "u", 7698 "events_url": "e", 7699 "repos_url": "r" 7700 }, 7701 "state": "st", 7702 "locked": false, 7703 "comments": 1, 7704 "created_at": ` + referenceTimeStr + `, 7705 "updated_at": ` + referenceTimeStr + `, 7706 "author_association": "aa", 7707 "body": "bo" 7708 }, 7709 "repository": { 7710 "id": 1, 7711 "name": "n", 7712 "url": "s" 7713 }, 7714 "organization": { 7715 "name": "n", 7716 "company": "c", 7717 "blog": "b", 7718 "location": "loc", 7719 "email": "e", 7720 "twitter_username": "tu", 7721 "description": "d", 7722 "billing_email": "be", 7723 "is_verified": true, 7724 "has_organization_projects": true, 7725 "has_repository_projects": true, 7726 "default_repository_permission": "drp", 7727 "members_can_create_repositories": true, 7728 "members_can_create_public_repositories": false, 7729 "members_can_create_private_repositories": true, 7730 "members_can_create_internal_repositories": true, 7731 "members_allowed_repository_creation_type": "marct", 7732 "members_can_create_pages": true, 7733 "members_can_create_public_pages": false, 7734 "members_can_create_private_pages": true 7735 }, 7736 "sender": { 7737 "login": "l", 7738 "id": 1, 7739 "node_id": "n", 7740 "avatar_url": "a", 7741 "url": "u", 7742 "events_url": "e", 7743 "repos_url": "r" 7744 }, 7745 "installation": { 7746 "id": 1, 7747 "node_id": "nid", 7748 "app_id": 1, 7749 "app_slug": "as", 7750 "target_id": 1, 7751 "account": { 7752 "login": "l", 7753 "id": 1, 7754 "avatar_url": "a", 7755 "gravatar_id": "g", 7756 "name": "n", 7757 "company": "c", 7758 "blog": "b", 7759 "location": "l", 7760 "email": "e", 7761 "hireable": true, 7762 "bio": "b", 7763 "twitter_username": "t", 7764 "public_repos": 1, 7765 "followers": 1, 7766 "following": 1, 7767 "created_at": ` + referenceTimeStr + `, 7768 "suspended_at": ` + referenceTimeStr + `, 7769 "url": "u" 7770 }, 7771 "access_tokens_url": "atu", 7772 "repositories_url": "ru", 7773 "html_url": "hu", 7774 "target_type": "tt", 7775 "single_file_name": "sfn", 7776 "repository_selection": "rs", 7777 "events": [ 7778 "e" 7779 ], 7780 "single_file_paths": [ 7781 "s" 7782 ], 7783 "permissions": { 7784 "actions": "a", 7785 "administration": "ad", 7786 "checks": "c", 7787 "contents": "co", 7788 "content_references": "cr", 7789 "deployments": "d", 7790 "environments": "e", 7791 "issues": "i", 7792 "metadata": "md", 7793 "members": "m", 7794 "organization_administration": "oa", 7795 "organization_hooks": "oh", 7796 "organization_plan": "op", 7797 "organization_pre_receive_hooks": "opr", 7798 "organization_projects": "op", 7799 "organization_secrets": "os", 7800 "organization_self_hosted_runners": "osh", 7801 "organization_user_blocking": "oub", 7802 "packages": "pkg", 7803 "pages": "pg", 7804 "pull_requests": "pr", 7805 "repository_hooks": "rh", 7806 "repository_projects": "rp", 7807 "repository_pre_receive_hooks": "rprh", 7808 "secrets": "s", 7809 "secret_scanning_alerts": "ssa", 7810 "security_events": "se", 7811 "single_file": "sf", 7812 "statuses": "s", 7813 "team_discussions": "td", 7814 "vulnerability_alerts": "va", 7815 "workflows": "w" 7816 }, 7817 "created_at": ` + referenceTimeStr + `, 7818 "updated_at": ` + referenceTimeStr + `, 7819 "has_multiple_single_files": false, 7820 "suspended_by": { 7821 "login": "l", 7822 "id": 1, 7823 "avatar_url": "a", 7824 "gravatar_id": "g", 7825 "name": "n", 7826 "company": "c", 7827 "blog": "b", 7828 "location": "l", 7829 "email": "e", 7830 "hireable": true, 7831 "bio": "b", 7832 "twitter_username": "t", 7833 "public_repos": 1, 7834 "followers": 1, 7835 "following": 1, 7836 "created_at": ` + referenceTimeStr + `, 7837 "suspended_at": ` + referenceTimeStr + `, 7838 "url": "u" 7839 }, 7840 "suspended_at": ` + referenceTimeStr + ` 7841 } 7842 }` 7843 7844 testJSONMarshal(t, u, want) 7845 } 7846 7847 func TestDiscussionEvent_Marshal(t *testing.T) { 7848 t.Parallel() 7849 testJSONMarshal(t, &DiscussionEvent{}, "{}") 7850 7851 u := &DiscussionEvent{ 7852 Discussion: &Discussion{ 7853 RepositoryURL: Ptr("rurl"), 7854 DiscussionCategory: &DiscussionCategory{ 7855 ID: Ptr(int64(1)), 7856 NodeID: Ptr("nid"), 7857 RepositoryID: Ptr(int64(1)), 7858 Emoji: Ptr("emoji"), 7859 Name: Ptr("name"), 7860 Description: Ptr("description"), 7861 CreatedAt: &Timestamp{referenceTime}, 7862 UpdatedAt: &Timestamp{referenceTime}, 7863 Slug: Ptr("slug"), 7864 IsAnswerable: Ptr(false), 7865 }, 7866 HTMLURL: Ptr("hurl"), 7867 ID: Ptr(int64(1)), 7868 NodeID: Ptr("nurl"), 7869 Number: Ptr(1), 7870 Title: Ptr("title"), 7871 User: &User{ 7872 Login: Ptr("l"), 7873 ID: Ptr(int64(1)), 7874 NodeID: Ptr("n"), 7875 URL: Ptr("u"), 7876 ReposURL: Ptr("r"), 7877 EventsURL: Ptr("e"), 7878 AvatarURL: Ptr("a"), 7879 }, 7880 State: Ptr("st"), 7881 Locked: Ptr(false), 7882 Comments: Ptr(1), 7883 CreatedAt: &Timestamp{referenceTime}, 7884 UpdatedAt: &Timestamp{referenceTime}, 7885 AuthorAssociation: Ptr("aa"), 7886 Body: Ptr("bo"), 7887 }, 7888 Repo: &Repository{ 7889 ID: Ptr(int64(1)), 7890 URL: Ptr("s"), 7891 Name: Ptr("n"), 7892 }, 7893 Org: &Organization{ 7894 BillingEmail: Ptr("be"), 7895 Blog: Ptr("b"), 7896 Company: Ptr("c"), 7897 Email: Ptr("e"), 7898 TwitterUsername: Ptr("tu"), 7899 Location: Ptr("loc"), 7900 Name: Ptr("n"), 7901 Description: Ptr("d"), 7902 IsVerified: Ptr(true), 7903 HasOrganizationProjects: Ptr(true), 7904 HasRepositoryProjects: Ptr(true), 7905 DefaultRepoPermission: Ptr("drp"), 7906 MembersCanCreateRepos: Ptr(true), 7907 MembersCanCreateInternalRepos: Ptr(true), 7908 MembersCanCreatePrivateRepos: Ptr(true), 7909 MembersCanCreatePublicRepos: Ptr(false), 7910 MembersAllowedRepositoryCreationType: Ptr("marct"), 7911 MembersCanCreatePages: Ptr(true), 7912 MembersCanCreatePublicPages: Ptr(false), 7913 MembersCanCreatePrivatePages: Ptr(true), 7914 }, 7915 Sender: &User{ 7916 Login: Ptr("l"), 7917 ID: Ptr(int64(1)), 7918 NodeID: Ptr("n"), 7919 URL: Ptr("u"), 7920 ReposURL: Ptr("r"), 7921 EventsURL: Ptr("e"), 7922 AvatarURL: Ptr("a"), 7923 }, 7924 Installation: &Installation{ 7925 ID: Ptr(int64(1)), 7926 NodeID: Ptr("nid"), 7927 AppID: Ptr(int64(1)), 7928 AppSlug: Ptr("as"), 7929 TargetID: Ptr(int64(1)), 7930 Account: &User{ 7931 Login: Ptr("l"), 7932 ID: Ptr(int64(1)), 7933 URL: Ptr("u"), 7934 AvatarURL: Ptr("a"), 7935 GravatarID: Ptr("g"), 7936 Name: Ptr("n"), 7937 Company: Ptr("c"), 7938 Blog: Ptr("b"), 7939 Location: Ptr("l"), 7940 Email: Ptr("e"), 7941 Hireable: Ptr(true), 7942 Bio: Ptr("b"), 7943 TwitterUsername: Ptr("t"), 7944 PublicRepos: Ptr(1), 7945 Followers: Ptr(1), 7946 Following: Ptr(1), 7947 CreatedAt: &Timestamp{referenceTime}, 7948 SuspendedAt: &Timestamp{referenceTime}, 7949 }, 7950 AccessTokensURL: Ptr("atu"), 7951 RepositoriesURL: Ptr("ru"), 7952 HTMLURL: Ptr("hu"), 7953 TargetType: Ptr("tt"), 7954 SingleFileName: Ptr("sfn"), 7955 RepositorySelection: Ptr("rs"), 7956 Events: []string{"e"}, 7957 SingleFilePaths: []string{"s"}, 7958 Permissions: &InstallationPermissions{ 7959 Actions: Ptr("a"), 7960 Administration: Ptr("ad"), 7961 Checks: Ptr("c"), 7962 Contents: Ptr("co"), 7963 ContentReferences: Ptr("cr"), 7964 Deployments: Ptr("d"), 7965 Environments: Ptr("e"), 7966 Issues: Ptr("i"), 7967 Metadata: Ptr("md"), 7968 Members: Ptr("m"), 7969 OrganizationAdministration: Ptr("oa"), 7970 OrganizationHooks: Ptr("oh"), 7971 OrganizationPlan: Ptr("op"), 7972 OrganizationPreReceiveHooks: Ptr("opr"), 7973 OrganizationProjects: Ptr("op"), 7974 OrganizationSecrets: Ptr("os"), 7975 OrganizationSelfHostedRunners: Ptr("osh"), 7976 OrganizationUserBlocking: Ptr("oub"), 7977 Packages: Ptr("pkg"), 7978 Pages: Ptr("pg"), 7979 PullRequests: Ptr("pr"), 7980 RepositoryHooks: Ptr("rh"), 7981 RepositoryProjects: Ptr("rp"), 7982 RepositoryPreReceiveHooks: Ptr("rprh"), 7983 Secrets: Ptr("s"), 7984 SecretScanningAlerts: Ptr("ssa"), 7985 SecurityEvents: Ptr("se"), 7986 SingleFile: Ptr("sf"), 7987 Statuses: Ptr("s"), 7988 TeamDiscussions: Ptr("td"), 7989 VulnerabilityAlerts: Ptr("va"), 7990 Workflows: Ptr("w"), 7991 }, 7992 CreatedAt: &Timestamp{referenceTime}, 7993 UpdatedAt: &Timestamp{referenceTime}, 7994 HasMultipleSingleFiles: Ptr(false), 7995 SuspendedBy: &User{ 7996 Login: Ptr("l"), 7997 ID: Ptr(int64(1)), 7998 URL: Ptr("u"), 7999 AvatarURL: Ptr("a"), 8000 GravatarID: Ptr("g"), 8001 Name: Ptr("n"), 8002 Company: Ptr("c"), 8003 Blog: Ptr("b"), 8004 Location: Ptr("l"), 8005 Email: Ptr("e"), 8006 Hireable: Ptr(true), 8007 Bio: Ptr("b"), 8008 TwitterUsername: Ptr("t"), 8009 PublicRepos: Ptr(1), 8010 Followers: Ptr(1), 8011 Following: Ptr(1), 8012 CreatedAt: &Timestamp{referenceTime}, 8013 SuspendedAt: &Timestamp{referenceTime}, 8014 }, 8015 SuspendedAt: &Timestamp{referenceTime}, 8016 }, 8017 } 8018 8019 want := `{ 8020 "discussion": { 8021 "repository_url": "rurl", 8022 "category": { 8023 "id": 1, 8024 "node_id": "nid", 8025 "repository_id": 1, 8026 "emoji": "emoji", 8027 "name": "name", 8028 "description": "description", 8029 "created_at": ` + referenceTimeStr + `, 8030 "updated_at": ` + referenceTimeStr + `, 8031 "slug": "slug", 8032 "is_answerable": false 8033 }, 8034 "html_url": "hurl", 8035 "id": 1, 8036 "node_id": "nurl", 8037 "number": 1, 8038 "title": "title", 8039 "user": { 8040 "login": "l", 8041 "id": 1, 8042 "node_id": "n", 8043 "avatar_url": "a", 8044 "url": "u", 8045 "events_url": "e", 8046 "repos_url": "r" 8047 }, 8048 "state": "st", 8049 "locked": false, 8050 "comments": 1, 8051 "created_at": ` + referenceTimeStr + `, 8052 "updated_at": ` + referenceTimeStr + `, 8053 "author_association": "aa", 8054 "body": "bo" 8055 }, 8056 "repository": { 8057 "id": 1, 8058 "name": "n", 8059 "url": "s" 8060 }, 8061 "organization": { 8062 "name": "n", 8063 "company": "c", 8064 "blog": "b", 8065 "location": "loc", 8066 "email": "e", 8067 "twitter_username": "tu", 8068 "description": "d", 8069 "billing_email": "be", 8070 "is_verified": true, 8071 "has_organization_projects": true, 8072 "has_repository_projects": true, 8073 "default_repository_permission": "drp", 8074 "members_can_create_repositories": true, 8075 "members_can_create_public_repositories": false, 8076 "members_can_create_private_repositories": true, 8077 "members_can_create_internal_repositories": true, 8078 "members_allowed_repository_creation_type": "marct", 8079 "members_can_create_pages": true, 8080 "members_can_create_public_pages": false, 8081 "members_can_create_private_pages": true 8082 }, 8083 "sender": { 8084 "login": "l", 8085 "id": 1, 8086 "node_id": "n", 8087 "avatar_url": "a", 8088 "url": "u", 8089 "events_url": "e", 8090 "repos_url": "r" 8091 }, 8092 "installation": { 8093 "id": 1, 8094 "node_id": "nid", 8095 "app_id": 1, 8096 "app_slug": "as", 8097 "target_id": 1, 8098 "account": { 8099 "login": "l", 8100 "id": 1, 8101 "avatar_url": "a", 8102 "gravatar_id": "g", 8103 "name": "n", 8104 "company": "c", 8105 "blog": "b", 8106 "location": "l", 8107 "email": "e", 8108 "hireable": true, 8109 "bio": "b", 8110 "twitter_username": "t", 8111 "public_repos": 1, 8112 "followers": 1, 8113 "following": 1, 8114 "created_at": ` + referenceTimeStr + `, 8115 "suspended_at": ` + referenceTimeStr + `, 8116 "url": "u" 8117 }, 8118 "access_tokens_url": "atu", 8119 "repositories_url": "ru", 8120 "html_url": "hu", 8121 "target_type": "tt", 8122 "single_file_name": "sfn", 8123 "repository_selection": "rs", 8124 "events": [ 8125 "e" 8126 ], 8127 "single_file_paths": [ 8128 "s" 8129 ], 8130 "permissions": { 8131 "actions": "a", 8132 "administration": "ad", 8133 "checks": "c", 8134 "contents": "co", 8135 "content_references": "cr", 8136 "deployments": "d", 8137 "environments": "e", 8138 "issues": "i", 8139 "metadata": "md", 8140 "members": "m", 8141 "organization_administration": "oa", 8142 "organization_hooks": "oh", 8143 "organization_plan": "op", 8144 "organization_pre_receive_hooks": "opr", 8145 "organization_projects": "op", 8146 "organization_secrets": "os", 8147 "organization_self_hosted_runners": "osh", 8148 "organization_user_blocking": "oub", 8149 "packages": "pkg", 8150 "pages": "pg", 8151 "pull_requests": "pr", 8152 "repository_hooks": "rh", 8153 "repository_projects": "rp", 8154 "repository_pre_receive_hooks": "rprh", 8155 "secrets": "s", 8156 "secret_scanning_alerts": "ssa", 8157 "security_events": "se", 8158 "single_file": "sf", 8159 "statuses": "s", 8160 "team_discussions": "td", 8161 "vulnerability_alerts": "va", 8162 "workflows": "w" 8163 }, 8164 "created_at": ` + referenceTimeStr + `, 8165 "updated_at": ` + referenceTimeStr + `, 8166 "has_multiple_single_files": false, 8167 "suspended_by": { 8168 "login": "l", 8169 "id": 1, 8170 "avatar_url": "a", 8171 "gravatar_id": "g", 8172 "name": "n", 8173 "company": "c", 8174 "blog": "b", 8175 "location": "l", 8176 "email": "e", 8177 "hireable": true, 8178 "bio": "b", 8179 "twitter_username": "t", 8180 "public_repos": 1, 8181 "followers": 1, 8182 "following": 1, 8183 "created_at": ` + referenceTimeStr + `, 8184 "suspended_at": ` + referenceTimeStr + `, 8185 "url": "u" 8186 }, 8187 "suspended_at": ` + referenceTimeStr + ` 8188 } 8189 }` 8190 8191 testJSONMarshal(t, u, want) 8192 } 8193 8194 func TestPackageEvent_Marshal(t *testing.T) { 8195 t.Parallel() 8196 testJSONMarshal(t, &PackageEvent{}, "{}") 8197 8198 u := &PackageEvent{ 8199 Action: Ptr("a"), 8200 Package: &Package{ 8201 ID: Ptr(int64(1)), 8202 Name: Ptr("n"), 8203 PackageType: Ptr("pt"), 8204 HTMLURL: Ptr("hurl"), 8205 CreatedAt: &Timestamp{referenceTime}, 8206 UpdatedAt: &Timestamp{referenceTime}, 8207 Owner: &User{ 8208 Login: Ptr("l"), 8209 ID: Ptr(int64(1)), 8210 NodeID: Ptr("n"), 8211 URL: Ptr("u"), 8212 ReposURL: Ptr("r"), 8213 EventsURL: Ptr("e"), 8214 AvatarURL: Ptr("a"), 8215 }, 8216 PackageVersion: &PackageVersion{ID: Ptr(int64(1))}, 8217 Registry: &PackageRegistry{Name: Ptr("n")}, 8218 }, 8219 Repo: &Repository{ 8220 ID: Ptr(int64(1)), 8221 URL: Ptr("s"), 8222 Name: Ptr("n"), 8223 }, 8224 Org: &Organization{ 8225 BillingEmail: Ptr("be"), 8226 Blog: Ptr("b"), 8227 Company: Ptr("c"), 8228 Email: Ptr("e"), 8229 TwitterUsername: Ptr("tu"), 8230 Location: Ptr("loc"), 8231 Name: Ptr("n"), 8232 Description: Ptr("d"), 8233 IsVerified: Ptr(true), 8234 HasOrganizationProjects: Ptr(true), 8235 HasRepositoryProjects: Ptr(true), 8236 DefaultRepoPermission: Ptr("drp"), 8237 MembersCanCreateRepos: Ptr(true), 8238 MembersCanCreateInternalRepos: Ptr(true), 8239 MembersCanCreatePrivateRepos: Ptr(true), 8240 MembersCanCreatePublicRepos: Ptr(false), 8241 MembersAllowedRepositoryCreationType: Ptr("marct"), 8242 MembersCanCreatePages: Ptr(true), 8243 MembersCanCreatePublicPages: Ptr(false), 8244 MembersCanCreatePrivatePages: Ptr(true), 8245 }, 8246 Sender: &User{ 8247 Login: Ptr("l"), 8248 ID: Ptr(int64(1)), 8249 NodeID: Ptr("n"), 8250 URL: Ptr("u"), 8251 ReposURL: Ptr("r"), 8252 EventsURL: Ptr("e"), 8253 AvatarURL: Ptr("a"), 8254 }, 8255 } 8256 8257 want := `{ 8258 "action": "a", 8259 "package": { 8260 "id": 1, 8261 "name": "n", 8262 "package_type": "pt", 8263 "html_url": "hurl", 8264 "created_at": ` + referenceTimeStr + `, 8265 "updated_at": ` + referenceTimeStr + `, 8266 "owner": { 8267 "login": "l", 8268 "id": 1, 8269 "node_id": "n", 8270 "avatar_url": "a", 8271 "url": "u", 8272 "events_url": "e", 8273 "repos_url": "r" 8274 }, 8275 "package_version": { 8276 "id": 1 8277 }, 8278 "registry": { 8279 "name": "n" 8280 } 8281 }, 8282 "repository": { 8283 "id": 1, 8284 "name": "n", 8285 "url": "s" 8286 }, 8287 "organization": { 8288 "name": "n", 8289 "company": "c", 8290 "blog": "b", 8291 "location": "loc", 8292 "email": "e", 8293 "twitter_username": "tu", 8294 "description": "d", 8295 "billing_email": "be", 8296 "is_verified": true, 8297 "has_organization_projects": true, 8298 "has_repository_projects": true, 8299 "default_repository_permission": "drp", 8300 "members_can_create_repositories": true, 8301 "members_can_create_public_repositories": false, 8302 "members_can_create_private_repositories": true, 8303 "members_can_create_internal_repositories": true, 8304 "members_allowed_repository_creation_type": "marct", 8305 "members_can_create_pages": true, 8306 "members_can_create_public_pages": false, 8307 "members_can_create_private_pages": true 8308 }, 8309 "sender": { 8310 "login": "l", 8311 "id": 1, 8312 "node_id": "n", 8313 "avatar_url": "a", 8314 "url": "u", 8315 "events_url": "e", 8316 "repos_url": "r" 8317 } 8318 }` 8319 8320 testJSONMarshal(t, u, want) 8321 } 8322 8323 func TestPersonalAccessTokenRequestEvent_Marshal(t *testing.T) { 8324 t.Parallel() 8325 testJSONMarshal(t, &PersonalAccessTokenRequestEvent{}, "{}") 8326 8327 event := &PersonalAccessTokenRequestEvent{ 8328 Action: Ptr("a"), 8329 PersonalAccessTokenRequest: &PersonalAccessTokenRequest{ 8330 ID: Ptr(int64(1)), 8331 Owner: &User{Login: Ptr("l")}, 8332 PermissionsAdded: &PersonalAccessTokenPermissions{ 8333 Org: map[string]string{"organization_events": "read"}, 8334 Repo: map[string]string{"security_events": "write"}, 8335 }, 8336 CreatedAt: &Timestamp{referenceTime}, 8337 TokenExpired: Ptr(false), 8338 TokenExpiresAt: &Timestamp{referenceTime}, 8339 TokenLastUsedAt: &Timestamp{referenceTime}, 8340 RepositoryCount: Ptr(int64(1)), 8341 RepositorySelection: Ptr("rs"), 8342 Repositories: []*Repository{ 8343 { 8344 Name: Ptr("n"), 8345 }, 8346 }, 8347 }, 8348 Org: &Organization{Name: Ptr("n")}, 8349 Sender: &User{ 8350 Login: Ptr("l"), 8351 }, 8352 Installation: &Installation{ 8353 ID: Ptr(int64(1)), 8354 }, 8355 } 8356 8357 want := `{ 8358 "action": "a", 8359 "personal_access_token_request": { 8360 "id": 1, 8361 "owner": { 8362 "login": "l" 8363 }, 8364 "permissions_added": { 8365 "organization": { 8366 "organization_events": "read" 8367 }, 8368 "repository": { 8369 "security_events": "write" 8370 } 8371 }, 8372 "created_at": ` + referenceTimeStr + `, 8373 "token_expired": false, 8374 "token_expires_at": ` + referenceTimeStr + `, 8375 "token_last_used_at": ` + referenceTimeStr + `, 8376 "repository_count": 1, 8377 "repository_selection": "rs", 8378 "repositories": [ 8379 { 8380 "name": "n" 8381 } 8382 ] 8383 }, 8384 "organization": { 8385 "name": "n" 8386 }, 8387 "sender": { 8388 "login": "l" 8389 }, 8390 "installation": { 8391 "id": 1 8392 } 8393 }` 8394 8395 testJSONMarshal(t, event, want) 8396 } 8397 8398 func TestPingEvent_Marshal(t *testing.T) { 8399 t.Parallel() 8400 testJSONMarshal(t, &PingEvent{}, "{}") 8401 8402 l := make(map[string]any) 8403 l["key"] = "value" 8404 hookConfig := new(HookConfig) 8405 8406 u := &PingEvent{ 8407 Zen: Ptr("z"), 8408 HookID: Ptr(int64(1)), 8409 Hook: &Hook{ 8410 CreatedAt: &Timestamp{referenceTime}, 8411 UpdatedAt: &Timestamp{referenceTime}, 8412 URL: Ptr("url"), 8413 ID: Ptr(int64(1)), 8414 Type: Ptr("t"), 8415 Name: Ptr("n"), 8416 TestURL: Ptr("tu"), 8417 PingURL: Ptr("pu"), 8418 LastResponse: l, 8419 Config: hookConfig, 8420 Events: []string{"a"}, 8421 Active: Ptr(true), 8422 }, 8423 Installation: &Installation{ 8424 ID: Ptr(int64(1)), 8425 NodeID: Ptr("nid"), 8426 AppID: Ptr(int64(1)), 8427 AppSlug: Ptr("as"), 8428 TargetID: Ptr(int64(1)), 8429 Account: &User{ 8430 Login: Ptr("l"), 8431 ID: Ptr(int64(1)), 8432 URL: Ptr("u"), 8433 AvatarURL: Ptr("a"), 8434 GravatarID: Ptr("g"), 8435 Name: Ptr("n"), 8436 Company: Ptr("c"), 8437 Blog: Ptr("b"), 8438 Location: Ptr("l"), 8439 Email: Ptr("e"), 8440 Hireable: Ptr(true), 8441 Bio: Ptr("b"), 8442 TwitterUsername: Ptr("t"), 8443 PublicRepos: Ptr(1), 8444 Followers: Ptr(1), 8445 Following: Ptr(1), 8446 CreatedAt: &Timestamp{referenceTime}, 8447 SuspendedAt: &Timestamp{referenceTime}, 8448 }, 8449 AccessTokensURL: Ptr("atu"), 8450 RepositoriesURL: Ptr("ru"), 8451 HTMLURL: Ptr("hu"), 8452 TargetType: Ptr("tt"), 8453 SingleFileName: Ptr("sfn"), 8454 RepositorySelection: Ptr("rs"), 8455 Events: []string{"e"}, 8456 SingleFilePaths: []string{"s"}, 8457 Permissions: &InstallationPermissions{ 8458 Actions: Ptr("a"), 8459 Administration: Ptr("ad"), 8460 Checks: Ptr("c"), 8461 Contents: Ptr("co"), 8462 ContentReferences: Ptr("cr"), 8463 Deployments: Ptr("d"), 8464 Environments: Ptr("e"), 8465 Issues: Ptr("i"), 8466 Metadata: Ptr("md"), 8467 Members: Ptr("m"), 8468 OrganizationAdministration: Ptr("oa"), 8469 OrganizationHooks: Ptr("oh"), 8470 OrganizationPlan: Ptr("op"), 8471 OrganizationPreReceiveHooks: Ptr("opr"), 8472 OrganizationProjects: Ptr("op"), 8473 OrganizationSecrets: Ptr("os"), 8474 OrganizationSelfHostedRunners: Ptr("osh"), 8475 OrganizationUserBlocking: Ptr("oub"), 8476 Packages: Ptr("pkg"), 8477 Pages: Ptr("pg"), 8478 PullRequests: Ptr("pr"), 8479 RepositoryHooks: Ptr("rh"), 8480 RepositoryProjects: Ptr("rp"), 8481 RepositoryPreReceiveHooks: Ptr("rprh"), 8482 Secrets: Ptr("s"), 8483 SecretScanningAlerts: Ptr("ssa"), 8484 SecurityEvents: Ptr("se"), 8485 SingleFile: Ptr("sf"), 8486 Statuses: Ptr("s"), 8487 TeamDiscussions: Ptr("td"), 8488 VulnerabilityAlerts: Ptr("va"), 8489 Workflows: Ptr("w"), 8490 }, 8491 CreatedAt: &Timestamp{referenceTime}, 8492 UpdatedAt: &Timestamp{referenceTime}, 8493 HasMultipleSingleFiles: Ptr(false), 8494 SuspendedBy: &User{ 8495 Login: Ptr("l"), 8496 ID: Ptr(int64(1)), 8497 URL: Ptr("u"), 8498 AvatarURL: Ptr("a"), 8499 GravatarID: Ptr("g"), 8500 Name: Ptr("n"), 8501 Company: Ptr("c"), 8502 Blog: Ptr("b"), 8503 Location: Ptr("l"), 8504 Email: Ptr("e"), 8505 Hireable: Ptr(true), 8506 Bio: Ptr("b"), 8507 TwitterUsername: Ptr("t"), 8508 PublicRepos: Ptr(1), 8509 Followers: Ptr(1), 8510 Following: Ptr(1), 8511 CreatedAt: &Timestamp{referenceTime}, 8512 SuspendedAt: &Timestamp{referenceTime}, 8513 }, 8514 SuspendedAt: &Timestamp{referenceTime}, 8515 }, 8516 } 8517 8518 want := `{ 8519 "zen": "z", 8520 "hook_id": 1, 8521 "hook": { 8522 "created_at": ` + referenceTimeStr + `, 8523 "updated_at": ` + referenceTimeStr + `, 8524 "url": "url", 8525 "id": 1, 8526 "type": "t", 8527 "name": "n", 8528 "test_url": "tu", 8529 "ping_url": "pu", 8530 "last_response": { 8531 "key": "value" 8532 }, 8533 "config": { 8534 "key": "value" 8535 }, 8536 "events": [ 8537 "a" 8538 ], 8539 "active": true 8540 }, 8541 "installation": { 8542 "id": 1, 8543 "node_id": "nid", 8544 "app_id": 1, 8545 "app_slug": "as", 8546 "target_id": 1, 8547 "account": { 8548 "login": "l", 8549 "id": 1, 8550 "avatar_url": "a", 8551 "gravatar_id": "g", 8552 "name": "n", 8553 "company": "c", 8554 "blog": "b", 8555 "location": "l", 8556 "email": "e", 8557 "hireable": true, 8558 "bio": "b", 8559 "twitter_username": "t", 8560 "public_repos": 1, 8561 "followers": 1, 8562 "following": 1, 8563 "created_at": ` + referenceTimeStr + `, 8564 "suspended_at": ` + referenceTimeStr + `, 8565 "url": "u" 8566 }, 8567 "access_tokens_url": "atu", 8568 "repositories_url": "ru", 8569 "html_url": "hu", 8570 "target_type": "tt", 8571 "single_file_name": "sfn", 8572 "repository_selection": "rs", 8573 "events": [ 8574 "e" 8575 ], 8576 "single_file_paths": [ 8577 "s" 8578 ], 8579 "permissions": { 8580 "actions": "a", 8581 "administration": "ad", 8582 "checks": "c", 8583 "contents": "co", 8584 "content_references": "cr", 8585 "deployments": "d", 8586 "environments": "e", 8587 "issues": "i", 8588 "metadata": "md", 8589 "members": "m", 8590 "organization_administration": "oa", 8591 "organization_hooks": "oh", 8592 "organization_plan": "op", 8593 "organization_pre_receive_hooks": "opr", 8594 "organization_projects": "op", 8595 "organization_secrets": "os", 8596 "organization_self_hosted_runners": "osh", 8597 "organization_user_blocking": "oub", 8598 "packages": "pkg", 8599 "pages": "pg", 8600 "pull_requests": "pr", 8601 "repository_hooks": "rh", 8602 "repository_projects": "rp", 8603 "repository_pre_receive_hooks": "rprh", 8604 "secrets": "s", 8605 "secret_scanning_alerts": "ssa", 8606 "security_events": "se", 8607 "single_file": "sf", 8608 "statuses": "s", 8609 "team_discussions": "td", 8610 "vulnerability_alerts": "va", 8611 "workflows": "w" 8612 }, 8613 "created_at": ` + referenceTimeStr + `, 8614 "updated_at": ` + referenceTimeStr + `, 8615 "has_multiple_single_files": false, 8616 "suspended_by": { 8617 "login": "l", 8618 "id": 1, 8619 "avatar_url": "a", 8620 "gravatar_id": "g", 8621 "name": "n", 8622 "company": "c", 8623 "blog": "b", 8624 "location": "l", 8625 "email": "e", 8626 "hireable": true, 8627 "bio": "b", 8628 "twitter_username": "t", 8629 "public_repos": 1, 8630 "followers": 1, 8631 "following": 1, 8632 "created_at": ` + referenceTimeStr + `, 8633 "suspended_at": ` + referenceTimeStr + `, 8634 "url": "u" 8635 }, 8636 "suspended_at": ` + referenceTimeStr + ` 8637 } 8638 }` 8639 8640 testJSONMarshal(t, u, want) 8641 } 8642 8643 func TestRegistryPackageEvent_Marshal(t *testing.T) { 8644 t.Parallel() 8645 testJSONMarshal(t, &RegistryPackageEvent{}, "{}") 8646 8647 u := &RegistryPackageEvent{ 8648 Action: Ptr("a"), 8649 RegistryPackage: &Package{ 8650 ID: Ptr(int64(1)), 8651 Name: Ptr("n"), 8652 PackageType: Ptr("pt"), 8653 HTMLURL: Ptr("hurl"), 8654 CreatedAt: &Timestamp{referenceTime}, 8655 UpdatedAt: &Timestamp{referenceTime}, 8656 Owner: &User{ 8657 Login: Ptr("l"), 8658 ID: Ptr(int64(1)), 8659 NodeID: Ptr("n"), 8660 URL: Ptr("u"), 8661 ReposURL: Ptr("r"), 8662 EventsURL: Ptr("e"), 8663 AvatarURL: Ptr("a"), 8664 }, 8665 PackageVersion: &PackageVersion{ID: Ptr(int64(1))}, 8666 Registry: &PackageRegistry{Name: Ptr("n")}, 8667 }, 8668 Repository: &Repository{ 8669 ID: Ptr(int64(1)), 8670 URL: Ptr("s"), 8671 Name: Ptr("n"), 8672 }, 8673 Organization: &Organization{ 8674 BillingEmail: Ptr("be"), 8675 Blog: Ptr("b"), 8676 Company: Ptr("c"), 8677 Email: Ptr("e"), 8678 TwitterUsername: Ptr("tu"), 8679 Location: Ptr("loc"), 8680 Name: Ptr("n"), 8681 Description: Ptr("d"), 8682 IsVerified: Ptr(true), 8683 HasOrganizationProjects: Ptr(true), 8684 HasRepositoryProjects: Ptr(true), 8685 DefaultRepoPermission: Ptr("drp"), 8686 MembersCanCreateRepos: Ptr(true), 8687 MembersCanCreateInternalRepos: Ptr(true), 8688 MembersCanCreatePrivateRepos: Ptr(true), 8689 MembersCanCreatePublicRepos: Ptr(false), 8690 MembersAllowedRepositoryCreationType: Ptr("marct"), 8691 MembersCanCreatePages: Ptr(true), 8692 MembersCanCreatePublicPages: Ptr(false), 8693 MembersCanCreatePrivatePages: Ptr(true), 8694 }, 8695 Sender: &User{ 8696 Login: Ptr("l"), 8697 ID: Ptr(int64(1)), 8698 NodeID: Ptr("n"), 8699 URL: Ptr("u"), 8700 ReposURL: Ptr("r"), 8701 EventsURL: Ptr("e"), 8702 AvatarURL: Ptr("a"), 8703 }, 8704 } 8705 8706 want := `{ 8707 "action": "a", 8708 "registry_package": { 8709 "id": 1, 8710 "name": "n", 8711 "package_type": "pt", 8712 "html_url": "hurl", 8713 "created_at": ` + referenceTimeStr + `, 8714 "updated_at": ` + referenceTimeStr + `, 8715 "owner": { 8716 "login": "l", 8717 "id": 1, 8718 "node_id": "n", 8719 "avatar_url": "a", 8720 "url": "u", 8721 "events_url": "e", 8722 "repos_url": "r" 8723 }, 8724 "package_version": { 8725 "id": 1 8726 }, 8727 "registry": { 8728 "name": "n" 8729 } 8730 }, 8731 "repository": { 8732 "id": 1, 8733 "name": "n", 8734 "url": "s" 8735 }, 8736 "organization": { 8737 "name": "n", 8738 "company": "c", 8739 "blog": "b", 8740 "location": "loc", 8741 "email": "e", 8742 "twitter_username": "tu", 8743 "description": "d", 8744 "billing_email": "be", 8745 "is_verified": true, 8746 "has_organization_projects": true, 8747 "has_repository_projects": true, 8748 "default_repository_permission": "drp", 8749 "members_can_create_repositories": true, 8750 "members_can_create_public_repositories": false, 8751 "members_can_create_private_repositories": true, 8752 "members_can_create_internal_repositories": true, 8753 "members_allowed_repository_creation_type": "marct", 8754 "members_can_create_pages": true, 8755 "members_can_create_public_pages": false, 8756 "members_can_create_private_pages": true 8757 }, 8758 "sender": { 8759 "login": "l", 8760 "id": 1, 8761 "node_id": "n", 8762 "avatar_url": "a", 8763 "url": "u", 8764 "events_url": "e", 8765 "repos_url": "r" 8766 } 8767 }` 8768 8769 testJSONMarshal(t, u, want) 8770 } 8771 8772 func TestRepositoryDispatchEvent_Marshal(t *testing.T) { 8773 t.Parallel() 8774 testJSONMarshal(t, &RepositoryDispatchEvent{}, "{}") 8775 8776 l := make(map[string]any) 8777 l["key"] = "value" 8778 8779 jsonMsg, _ := json.Marshal(&l) 8780 8781 u := &RepositoryDispatchEvent{ 8782 Action: Ptr("a"), 8783 Branch: Ptr("b"), 8784 ClientPayload: jsonMsg, 8785 Repo: &Repository{ 8786 ID: Ptr(int64(1)), 8787 URL: Ptr("s"), 8788 Name: Ptr("n"), 8789 }, 8790 Org: &Organization{ 8791 BillingEmail: Ptr("be"), 8792 Blog: Ptr("b"), 8793 Company: Ptr("c"), 8794 Email: Ptr("e"), 8795 TwitterUsername: Ptr("tu"), 8796 Location: Ptr("loc"), 8797 Name: Ptr("n"), 8798 Description: Ptr("d"), 8799 IsVerified: Ptr(true), 8800 HasOrganizationProjects: Ptr(true), 8801 HasRepositoryProjects: Ptr(true), 8802 DefaultRepoPermission: Ptr("drp"), 8803 MembersCanCreateRepos: Ptr(true), 8804 MembersCanCreateInternalRepos: Ptr(true), 8805 MembersCanCreatePrivateRepos: Ptr(true), 8806 MembersCanCreatePublicRepos: Ptr(false), 8807 MembersAllowedRepositoryCreationType: Ptr("marct"), 8808 MembersCanCreatePages: Ptr(true), 8809 MembersCanCreatePublicPages: Ptr(false), 8810 MembersCanCreatePrivatePages: Ptr(true), 8811 }, 8812 Sender: &User{ 8813 Login: Ptr("l"), 8814 ID: Ptr(int64(1)), 8815 NodeID: Ptr("n"), 8816 URL: Ptr("u"), 8817 ReposURL: Ptr("r"), 8818 EventsURL: Ptr("e"), 8819 AvatarURL: Ptr("a"), 8820 }, 8821 Installation: &Installation{ 8822 ID: Ptr(int64(1)), 8823 NodeID: Ptr("nid"), 8824 AppID: Ptr(int64(1)), 8825 AppSlug: Ptr("as"), 8826 TargetID: Ptr(int64(1)), 8827 Account: &User{ 8828 Login: Ptr("l"), 8829 ID: Ptr(int64(1)), 8830 URL: Ptr("u"), 8831 AvatarURL: Ptr("a"), 8832 GravatarID: Ptr("g"), 8833 Name: Ptr("n"), 8834 Company: Ptr("c"), 8835 Blog: Ptr("b"), 8836 Location: Ptr("l"), 8837 Email: Ptr("e"), 8838 Hireable: Ptr(true), 8839 Bio: Ptr("b"), 8840 TwitterUsername: Ptr("t"), 8841 PublicRepos: Ptr(1), 8842 Followers: Ptr(1), 8843 Following: Ptr(1), 8844 CreatedAt: &Timestamp{referenceTime}, 8845 SuspendedAt: &Timestamp{referenceTime}, 8846 }, 8847 AccessTokensURL: Ptr("atu"), 8848 RepositoriesURL: Ptr("ru"), 8849 HTMLURL: Ptr("hu"), 8850 TargetType: Ptr("tt"), 8851 SingleFileName: Ptr("sfn"), 8852 RepositorySelection: Ptr("rs"), 8853 Events: []string{"e"}, 8854 SingleFilePaths: []string{"s"}, 8855 Permissions: &InstallationPermissions{ 8856 Actions: Ptr("a"), 8857 Administration: Ptr("ad"), 8858 Checks: Ptr("c"), 8859 Contents: Ptr("co"), 8860 ContentReferences: Ptr("cr"), 8861 Deployments: Ptr("d"), 8862 Environments: Ptr("e"), 8863 Issues: Ptr("i"), 8864 Metadata: Ptr("md"), 8865 Members: Ptr("m"), 8866 OrganizationAdministration: Ptr("oa"), 8867 OrganizationHooks: Ptr("oh"), 8868 OrganizationPlan: Ptr("op"), 8869 OrganizationPreReceiveHooks: Ptr("opr"), 8870 OrganizationProjects: Ptr("op"), 8871 OrganizationSecrets: Ptr("os"), 8872 OrganizationSelfHostedRunners: Ptr("osh"), 8873 OrganizationUserBlocking: Ptr("oub"), 8874 Packages: Ptr("pkg"), 8875 Pages: Ptr("pg"), 8876 PullRequests: Ptr("pr"), 8877 RepositoryHooks: Ptr("rh"), 8878 RepositoryProjects: Ptr("rp"), 8879 RepositoryPreReceiveHooks: Ptr("rprh"), 8880 Secrets: Ptr("s"), 8881 SecretScanningAlerts: Ptr("ssa"), 8882 SecurityEvents: Ptr("se"), 8883 SingleFile: Ptr("sf"), 8884 Statuses: Ptr("s"), 8885 TeamDiscussions: Ptr("td"), 8886 VulnerabilityAlerts: Ptr("va"), 8887 Workflows: Ptr("w"), 8888 }, 8889 CreatedAt: &Timestamp{referenceTime}, 8890 UpdatedAt: &Timestamp{referenceTime}, 8891 HasMultipleSingleFiles: Ptr(false), 8892 SuspendedBy: &User{ 8893 Login: Ptr("l"), 8894 ID: Ptr(int64(1)), 8895 URL: Ptr("u"), 8896 AvatarURL: Ptr("a"), 8897 GravatarID: Ptr("g"), 8898 Name: Ptr("n"), 8899 Company: Ptr("c"), 8900 Blog: Ptr("b"), 8901 Location: Ptr("l"), 8902 Email: Ptr("e"), 8903 Hireable: Ptr(true), 8904 Bio: Ptr("b"), 8905 TwitterUsername: Ptr("t"), 8906 PublicRepos: Ptr(1), 8907 Followers: Ptr(1), 8908 Following: Ptr(1), 8909 CreatedAt: &Timestamp{referenceTime}, 8910 SuspendedAt: &Timestamp{referenceTime}, 8911 }, 8912 SuspendedAt: &Timestamp{referenceTime}, 8913 }, 8914 } 8915 8916 want := `{ 8917 "action": "a", 8918 "branch": "b", 8919 "client_payload": { 8920 "key": "value" 8921 }, 8922 "repository": { 8923 "id": 1, 8924 "name": "n", 8925 "url": "s" 8926 }, 8927 "organization": { 8928 "name": "n", 8929 "company": "c", 8930 "blog": "b", 8931 "location": "loc", 8932 "email": "e", 8933 "twitter_username": "tu", 8934 "description": "d", 8935 "billing_email": "be", 8936 "is_verified": true, 8937 "has_organization_projects": true, 8938 "has_repository_projects": true, 8939 "default_repository_permission": "drp", 8940 "members_can_create_repositories": true, 8941 "members_can_create_public_repositories": false, 8942 "members_can_create_private_repositories": true, 8943 "members_can_create_internal_repositories": true, 8944 "members_allowed_repository_creation_type": "marct", 8945 "members_can_create_pages": true, 8946 "members_can_create_public_pages": false, 8947 "members_can_create_private_pages": true 8948 }, 8949 "sender": { 8950 "login": "l", 8951 "id": 1, 8952 "node_id": "n", 8953 "avatar_url": "a", 8954 "url": "u", 8955 "events_url": "e", 8956 "repos_url": "r" 8957 }, 8958 "installation": { 8959 "id": 1, 8960 "node_id": "nid", 8961 "app_id": 1, 8962 "app_slug": "as", 8963 "target_id": 1, 8964 "account": { 8965 "login": "l", 8966 "id": 1, 8967 "avatar_url": "a", 8968 "gravatar_id": "g", 8969 "name": "n", 8970 "company": "c", 8971 "blog": "b", 8972 "location": "l", 8973 "email": "e", 8974 "hireable": true, 8975 "bio": "b", 8976 "twitter_username": "t", 8977 "public_repos": 1, 8978 "followers": 1, 8979 "following": 1, 8980 "created_at": ` + referenceTimeStr + `, 8981 "suspended_at": ` + referenceTimeStr + `, 8982 "url": "u" 8983 }, 8984 "access_tokens_url": "atu", 8985 "repositories_url": "ru", 8986 "html_url": "hu", 8987 "target_type": "tt", 8988 "single_file_name": "sfn", 8989 "repository_selection": "rs", 8990 "events": [ 8991 "e" 8992 ], 8993 "single_file_paths": [ 8994 "s" 8995 ], 8996 "permissions": { 8997 "actions": "a", 8998 "administration": "ad", 8999 "checks": "c", 9000 "contents": "co", 9001 "content_references": "cr", 9002 "deployments": "d", 9003 "environments": "e", 9004 "issues": "i", 9005 "metadata": "md", 9006 "members": "m", 9007 "organization_administration": "oa", 9008 "organization_hooks": "oh", 9009 "organization_plan": "op", 9010 "organization_pre_receive_hooks": "opr", 9011 "organization_projects": "op", 9012 "organization_secrets": "os", 9013 "organization_self_hosted_runners": "osh", 9014 "organization_user_blocking": "oub", 9015 "packages": "pkg", 9016 "pages": "pg", 9017 "pull_requests": "pr", 9018 "repository_hooks": "rh", 9019 "repository_projects": "rp", 9020 "repository_pre_receive_hooks": "rprh", 9021 "secrets": "s", 9022 "secret_scanning_alerts": "ssa", 9023 "security_events": "se", 9024 "single_file": "sf", 9025 "statuses": "s", 9026 "team_discussions": "td", 9027 "vulnerability_alerts": "va", 9028 "workflows": "w" 9029 }, 9030 "created_at": ` + referenceTimeStr + `, 9031 "updated_at": ` + referenceTimeStr + `, 9032 "has_multiple_single_files": false, 9033 "suspended_by": { 9034 "login": "l", 9035 "id": 1, 9036 "avatar_url": "a", 9037 "gravatar_id": "g", 9038 "name": "n", 9039 "company": "c", 9040 "blog": "b", 9041 "location": "l", 9042 "email": "e", 9043 "hireable": true, 9044 "bio": "b", 9045 "twitter_username": "t", 9046 "public_repos": 1, 9047 "followers": 1, 9048 "following": 1, 9049 "created_at": ` + referenceTimeStr + `, 9050 "suspended_at": ` + referenceTimeStr + `, 9051 "url": "u" 9052 }, 9053 "suspended_at": ` + referenceTimeStr + ` 9054 } 9055 }` 9056 9057 testJSONMarshal(t, u, want) 9058 } 9059 9060 func TestRepositoryImportEvent_Marshal(t *testing.T) { 9061 t.Parallel() 9062 testJSONMarshal(t, &RepositoryImportEvent{}, "{}") 9063 9064 u := &RepositoryImportEvent{ 9065 Status: Ptr("success"), 9066 Repo: &Repository{ 9067 ID: Ptr(int64(1)), 9068 URL: Ptr("s"), 9069 Name: Ptr("n"), 9070 }, 9071 Org: &Organization{ 9072 BillingEmail: Ptr("be"), 9073 Blog: Ptr("b"), 9074 Company: Ptr("c"), 9075 Email: Ptr("e"), 9076 TwitterUsername: Ptr("tu"), 9077 Location: Ptr("loc"), 9078 Name: Ptr("n"), 9079 Description: Ptr("d"), 9080 IsVerified: Ptr(true), 9081 HasOrganizationProjects: Ptr(true), 9082 HasRepositoryProjects: Ptr(true), 9083 DefaultRepoPermission: Ptr("drp"), 9084 MembersCanCreateRepos: Ptr(true), 9085 MembersCanCreateInternalRepos: Ptr(true), 9086 MembersCanCreatePrivateRepos: Ptr(true), 9087 MembersCanCreatePublicRepos: Ptr(false), 9088 MembersAllowedRepositoryCreationType: Ptr("marct"), 9089 MembersCanCreatePages: Ptr(true), 9090 MembersCanCreatePublicPages: Ptr(false), 9091 MembersCanCreatePrivatePages: Ptr(true), 9092 }, 9093 Sender: &User{ 9094 Login: Ptr("l"), 9095 ID: Ptr(int64(1)), 9096 NodeID: Ptr("n"), 9097 URL: Ptr("u"), 9098 ReposURL: Ptr("r"), 9099 EventsURL: Ptr("e"), 9100 AvatarURL: Ptr("a"), 9101 }, 9102 } 9103 9104 want := `{ 9105 "status": "success", 9106 "repository": { 9107 "id": 1, 9108 "name": "n", 9109 "url": "s" 9110 }, 9111 "organization": { 9112 "name": "n", 9113 "company": "c", 9114 "blog": "b", 9115 "location": "loc", 9116 "email": "e", 9117 "twitter_username": "tu", 9118 "description": "d", 9119 "billing_email": "be", 9120 "is_verified": true, 9121 "has_organization_projects": true, 9122 "has_repository_projects": true, 9123 "default_repository_permission": "drp", 9124 "members_can_create_repositories": true, 9125 "members_can_create_public_repositories": false, 9126 "members_can_create_private_repositories": true, 9127 "members_can_create_internal_repositories": true, 9128 "members_allowed_repository_creation_type": "marct", 9129 "members_can_create_pages": true, 9130 "members_can_create_public_pages": false, 9131 "members_can_create_private_pages": true 9132 }, 9133 "sender": { 9134 "login": "l", 9135 "id": 1, 9136 "node_id": "n", 9137 "avatar_url": "a", 9138 "url": "u", 9139 "events_url": "e", 9140 "repos_url": "r" 9141 } 9142 }` 9143 9144 testJSONMarshal(t, u, want) 9145 } 9146 9147 func TestRepositoryEvent_Marshal(t *testing.T) { 9148 t.Parallel() 9149 testJSONMarshal(t, &RepositoryEvent{}, "{}") 9150 9151 u := &RepositoryEvent{ 9152 Action: Ptr("a"), 9153 Repo: &Repository{ 9154 ID: Ptr(int64(1)), 9155 URL: Ptr("s"), 9156 Name: Ptr("n"), 9157 }, 9158 Org: &Organization{ 9159 BillingEmail: Ptr("be"), 9160 Blog: Ptr("b"), 9161 Company: Ptr("c"), 9162 Email: Ptr("e"), 9163 TwitterUsername: Ptr("tu"), 9164 Location: Ptr("loc"), 9165 Name: Ptr("n"), 9166 Description: Ptr("d"), 9167 IsVerified: Ptr(true), 9168 HasOrganizationProjects: Ptr(true), 9169 HasRepositoryProjects: Ptr(true), 9170 DefaultRepoPermission: Ptr("drp"), 9171 MembersCanCreateRepos: Ptr(true), 9172 MembersCanCreateInternalRepos: Ptr(true), 9173 MembersCanCreatePrivateRepos: Ptr(true), 9174 MembersCanCreatePublicRepos: Ptr(false), 9175 MembersAllowedRepositoryCreationType: Ptr("marct"), 9176 MembersCanCreatePages: Ptr(true), 9177 MembersCanCreatePublicPages: Ptr(false), 9178 MembersCanCreatePrivatePages: Ptr(true), 9179 }, 9180 Sender: &User{ 9181 Login: Ptr("l"), 9182 ID: Ptr(int64(1)), 9183 NodeID: Ptr("n"), 9184 URL: Ptr("u"), 9185 ReposURL: Ptr("r"), 9186 EventsURL: Ptr("e"), 9187 AvatarURL: Ptr("a"), 9188 }, 9189 Installation: &Installation{ 9190 ID: Ptr(int64(1)), 9191 NodeID: Ptr("nid"), 9192 AppID: Ptr(int64(1)), 9193 AppSlug: Ptr("as"), 9194 TargetID: Ptr(int64(1)), 9195 Account: &User{ 9196 Login: Ptr("l"), 9197 ID: Ptr(int64(1)), 9198 URL: Ptr("u"), 9199 AvatarURL: Ptr("a"), 9200 GravatarID: Ptr("g"), 9201 Name: Ptr("n"), 9202 Company: Ptr("c"), 9203 Blog: Ptr("b"), 9204 Location: Ptr("l"), 9205 Email: Ptr("e"), 9206 Hireable: Ptr(true), 9207 Bio: Ptr("b"), 9208 TwitterUsername: Ptr("t"), 9209 PublicRepos: Ptr(1), 9210 Followers: Ptr(1), 9211 Following: Ptr(1), 9212 CreatedAt: &Timestamp{referenceTime}, 9213 SuspendedAt: &Timestamp{referenceTime}, 9214 }, 9215 AccessTokensURL: Ptr("atu"), 9216 RepositoriesURL: Ptr("ru"), 9217 HTMLURL: Ptr("hu"), 9218 TargetType: Ptr("tt"), 9219 SingleFileName: Ptr("sfn"), 9220 RepositorySelection: Ptr("rs"), 9221 Events: []string{"e"}, 9222 SingleFilePaths: []string{"s"}, 9223 Permissions: &InstallationPermissions{ 9224 Actions: Ptr("a"), 9225 Administration: Ptr("ad"), 9226 Checks: Ptr("c"), 9227 Contents: Ptr("co"), 9228 ContentReferences: Ptr("cr"), 9229 Deployments: Ptr("d"), 9230 Environments: Ptr("e"), 9231 Issues: Ptr("i"), 9232 Metadata: Ptr("md"), 9233 Members: Ptr("m"), 9234 OrganizationAdministration: Ptr("oa"), 9235 OrganizationHooks: Ptr("oh"), 9236 OrganizationPlan: Ptr("op"), 9237 OrganizationPreReceiveHooks: Ptr("opr"), 9238 OrganizationProjects: Ptr("op"), 9239 OrganizationSecrets: Ptr("os"), 9240 OrganizationSelfHostedRunners: Ptr("osh"), 9241 OrganizationUserBlocking: Ptr("oub"), 9242 Packages: Ptr("pkg"), 9243 Pages: Ptr("pg"), 9244 PullRequests: Ptr("pr"), 9245 RepositoryHooks: Ptr("rh"), 9246 RepositoryProjects: Ptr("rp"), 9247 RepositoryPreReceiveHooks: Ptr("rprh"), 9248 Secrets: Ptr("s"), 9249 SecretScanningAlerts: Ptr("ssa"), 9250 SecurityEvents: Ptr("se"), 9251 SingleFile: Ptr("sf"), 9252 Statuses: Ptr("s"), 9253 TeamDiscussions: Ptr("td"), 9254 VulnerabilityAlerts: Ptr("va"), 9255 Workflows: Ptr("w"), 9256 }, 9257 CreatedAt: &Timestamp{referenceTime}, 9258 UpdatedAt: &Timestamp{referenceTime}, 9259 HasMultipleSingleFiles: Ptr(false), 9260 SuspendedBy: &User{ 9261 Login: Ptr("l"), 9262 ID: Ptr(int64(1)), 9263 URL: Ptr("u"), 9264 AvatarURL: Ptr("a"), 9265 GravatarID: Ptr("g"), 9266 Name: Ptr("n"), 9267 Company: Ptr("c"), 9268 Blog: Ptr("b"), 9269 Location: Ptr("l"), 9270 Email: Ptr("e"), 9271 Hireable: Ptr(true), 9272 Bio: Ptr("b"), 9273 TwitterUsername: Ptr("t"), 9274 PublicRepos: Ptr(1), 9275 Followers: Ptr(1), 9276 Following: Ptr(1), 9277 CreatedAt: &Timestamp{referenceTime}, 9278 SuspendedAt: &Timestamp{referenceTime}, 9279 }, 9280 SuspendedAt: &Timestamp{referenceTime}, 9281 }, 9282 } 9283 9284 want := `{ 9285 "action": "a", 9286 "repository": { 9287 "id": 1, 9288 "name": "n", 9289 "url": "s" 9290 }, 9291 "organization": { 9292 "name": "n", 9293 "company": "c", 9294 "blog": "b", 9295 "location": "loc", 9296 "email": "e", 9297 "twitter_username": "tu", 9298 "description": "d", 9299 "billing_email": "be", 9300 "is_verified": true, 9301 "has_organization_projects": true, 9302 "has_repository_projects": true, 9303 "default_repository_permission": "drp", 9304 "members_can_create_repositories": true, 9305 "members_can_create_public_repositories": false, 9306 "members_can_create_private_repositories": true, 9307 "members_can_create_internal_repositories": true, 9308 "members_allowed_repository_creation_type": "marct", 9309 "members_can_create_pages": true, 9310 "members_can_create_public_pages": false, 9311 "members_can_create_private_pages": true 9312 }, 9313 "sender": { 9314 "login": "l", 9315 "id": 1, 9316 "node_id": "n", 9317 "avatar_url": "a", 9318 "url": "u", 9319 "events_url": "e", 9320 "repos_url": "r" 9321 }, 9322 "installation": { 9323 "id": 1, 9324 "node_id": "nid", 9325 "app_id": 1, 9326 "app_slug": "as", 9327 "target_id": 1, 9328 "account": { 9329 "login": "l", 9330 "id": 1, 9331 "avatar_url": "a", 9332 "gravatar_id": "g", 9333 "name": "n", 9334 "company": "c", 9335 "blog": "b", 9336 "location": "l", 9337 "email": "e", 9338 "hireable": true, 9339 "bio": "b", 9340 "twitter_username": "t", 9341 "public_repos": 1, 9342 "followers": 1, 9343 "following": 1, 9344 "created_at": ` + referenceTimeStr + `, 9345 "suspended_at": ` + referenceTimeStr + `, 9346 "url": "u" 9347 }, 9348 "access_tokens_url": "atu", 9349 "repositories_url": "ru", 9350 "html_url": "hu", 9351 "target_type": "tt", 9352 "single_file_name": "sfn", 9353 "repository_selection": "rs", 9354 "events": [ 9355 "e" 9356 ], 9357 "single_file_paths": [ 9358 "s" 9359 ], 9360 "permissions": { 9361 "actions": "a", 9362 "administration": "ad", 9363 "checks": "c", 9364 "contents": "co", 9365 "content_references": "cr", 9366 "deployments": "d", 9367 "environments": "e", 9368 "issues": "i", 9369 "metadata": "md", 9370 "members": "m", 9371 "organization_administration": "oa", 9372 "organization_hooks": "oh", 9373 "organization_plan": "op", 9374 "organization_pre_receive_hooks": "opr", 9375 "organization_projects": "op", 9376 "organization_secrets": "os", 9377 "organization_self_hosted_runners": "osh", 9378 "organization_user_blocking": "oub", 9379 "packages": "pkg", 9380 "pages": "pg", 9381 "pull_requests": "pr", 9382 "repository_hooks": "rh", 9383 "repository_projects": "rp", 9384 "repository_pre_receive_hooks": "rprh", 9385 "secrets": "s", 9386 "secret_scanning_alerts": "ssa", 9387 "security_events": "se", 9388 "single_file": "sf", 9389 "statuses": "s", 9390 "team_discussions": "td", 9391 "vulnerability_alerts": "va", 9392 "workflows": "w" 9393 }, 9394 "created_at": ` + referenceTimeStr + `, 9395 "updated_at": ` + referenceTimeStr + `, 9396 "has_multiple_single_files": false, 9397 "suspended_by": { 9398 "login": "l", 9399 "id": 1, 9400 "avatar_url": "a", 9401 "gravatar_id": "g", 9402 "name": "n", 9403 "company": "c", 9404 "blog": "b", 9405 "location": "l", 9406 "email": "e", 9407 "hireable": true, 9408 "bio": "b", 9409 "twitter_username": "t", 9410 "public_repos": 1, 9411 "followers": 1, 9412 "following": 1, 9413 "created_at": ` + referenceTimeStr + `, 9414 "suspended_at": ` + referenceTimeStr + `, 9415 "url": "u" 9416 }, 9417 "suspended_at": ` + referenceTimeStr + ` 9418 } 9419 }` 9420 9421 testJSONMarshal(t, u, want) 9422 } 9423 9424 func TestReleaseEvent_Marshal(t *testing.T) { 9425 t.Parallel() 9426 testJSONMarshal(t, &ReleaseEvent{}, "{}") 9427 9428 u := &ReleaseEvent{ 9429 Action: Ptr("a"), 9430 Release: &RepositoryRelease{ 9431 Name: Ptr("n"), 9432 DiscussionCategoryName: Ptr("dcn"), 9433 ID: Ptr(int64(2)), 9434 CreatedAt: &Timestamp{referenceTime}, 9435 PublishedAt: &Timestamp{referenceTime}, 9436 URL: Ptr("url"), 9437 HTMLURL: Ptr("htmlurl"), 9438 AssetsURL: Ptr("assetsurl"), 9439 Assets: []*ReleaseAsset{{ID: Ptr(int64(1))}}, 9440 UploadURL: Ptr("uploadurl"), 9441 ZipballURL: Ptr("zipballurl"), 9442 TarballURL: Ptr("tarballurl"), 9443 Author: &User{Name: Ptr("octocat")}, 9444 NodeID: Ptr("nid"), 9445 }, 9446 Repo: &Repository{ 9447 ID: Ptr(int64(1)), 9448 URL: Ptr("s"), 9449 Name: Ptr("n"), 9450 }, 9451 Sender: &User{ 9452 Login: Ptr("l"), 9453 ID: Ptr(int64(1)), 9454 NodeID: Ptr("n"), 9455 URL: Ptr("u"), 9456 ReposURL: Ptr("r"), 9457 EventsURL: Ptr("e"), 9458 AvatarURL: Ptr("a"), 9459 }, 9460 Installation: &Installation{ 9461 ID: Ptr(int64(1)), 9462 NodeID: Ptr("nid"), 9463 AppID: Ptr(int64(1)), 9464 AppSlug: Ptr("as"), 9465 TargetID: Ptr(int64(1)), 9466 Account: &User{ 9467 Login: Ptr("l"), 9468 ID: Ptr(int64(1)), 9469 URL: Ptr("u"), 9470 AvatarURL: Ptr("a"), 9471 GravatarID: Ptr("g"), 9472 Name: Ptr("n"), 9473 Company: Ptr("c"), 9474 Blog: Ptr("b"), 9475 Location: Ptr("l"), 9476 Email: Ptr("e"), 9477 Hireable: Ptr(true), 9478 Bio: Ptr("b"), 9479 TwitterUsername: Ptr("t"), 9480 PublicRepos: Ptr(1), 9481 Followers: Ptr(1), 9482 Following: Ptr(1), 9483 CreatedAt: &Timestamp{referenceTime}, 9484 SuspendedAt: &Timestamp{referenceTime}, 9485 }, 9486 AccessTokensURL: Ptr("atu"), 9487 RepositoriesURL: Ptr("ru"), 9488 HTMLURL: Ptr("hu"), 9489 TargetType: Ptr("tt"), 9490 SingleFileName: Ptr("sfn"), 9491 RepositorySelection: Ptr("rs"), 9492 Events: []string{"e"}, 9493 SingleFilePaths: []string{"s"}, 9494 Permissions: &InstallationPermissions{ 9495 Actions: Ptr("a"), 9496 Administration: Ptr("ad"), 9497 Checks: Ptr("c"), 9498 Contents: Ptr("co"), 9499 ContentReferences: Ptr("cr"), 9500 Deployments: Ptr("d"), 9501 Environments: Ptr("e"), 9502 Issues: Ptr("i"), 9503 Metadata: Ptr("md"), 9504 Members: Ptr("m"), 9505 OrganizationAdministration: Ptr("oa"), 9506 OrganizationHooks: Ptr("oh"), 9507 OrganizationPlan: Ptr("op"), 9508 OrganizationPreReceiveHooks: Ptr("opr"), 9509 OrganizationProjects: Ptr("op"), 9510 OrganizationSecrets: Ptr("os"), 9511 OrganizationSelfHostedRunners: Ptr("osh"), 9512 OrganizationUserBlocking: Ptr("oub"), 9513 Packages: Ptr("pkg"), 9514 Pages: Ptr("pg"), 9515 PullRequests: Ptr("pr"), 9516 RepositoryHooks: Ptr("rh"), 9517 RepositoryProjects: Ptr("rp"), 9518 RepositoryPreReceiveHooks: Ptr("rprh"), 9519 Secrets: Ptr("s"), 9520 SecretScanningAlerts: Ptr("ssa"), 9521 SecurityEvents: Ptr("se"), 9522 SingleFile: Ptr("sf"), 9523 Statuses: Ptr("s"), 9524 TeamDiscussions: Ptr("td"), 9525 VulnerabilityAlerts: Ptr("va"), 9526 Workflows: Ptr("w"), 9527 }, 9528 CreatedAt: &Timestamp{referenceTime}, 9529 UpdatedAt: &Timestamp{referenceTime}, 9530 HasMultipleSingleFiles: Ptr(false), 9531 SuspendedBy: &User{ 9532 Login: Ptr("l"), 9533 ID: Ptr(int64(1)), 9534 URL: Ptr("u"), 9535 AvatarURL: Ptr("a"), 9536 GravatarID: Ptr("g"), 9537 Name: Ptr("n"), 9538 Company: Ptr("c"), 9539 Blog: Ptr("b"), 9540 Location: Ptr("l"), 9541 Email: Ptr("e"), 9542 Hireable: Ptr(true), 9543 Bio: Ptr("b"), 9544 TwitterUsername: Ptr("t"), 9545 PublicRepos: Ptr(1), 9546 Followers: Ptr(1), 9547 Following: Ptr(1), 9548 CreatedAt: &Timestamp{referenceTime}, 9549 SuspendedAt: &Timestamp{referenceTime}, 9550 }, 9551 SuspendedAt: &Timestamp{referenceTime}, 9552 }, 9553 } 9554 9555 want := `{ 9556 "action": "a", 9557 "release": { 9558 "name": "n", 9559 "discussion_category_name": "dcn", 9560 "id": 2, 9561 "created_at": ` + referenceTimeStr + `, 9562 "published_at": ` + referenceTimeStr + `, 9563 "url": "url", 9564 "html_url": "htmlurl", 9565 "assets_url": "assetsurl", 9566 "assets": [ 9567 { 9568 "id": 1 9569 } 9570 ], 9571 "upload_url": "uploadurl", 9572 "zipball_url": "zipballurl", 9573 "tarball_url": "tarballurl", 9574 "author": { 9575 "name": "octocat" 9576 }, 9577 "node_id": "nid" 9578 }, 9579 "repository": { 9580 "id": 1, 9581 "name": "n", 9582 "url": "s" 9583 }, 9584 "sender": { 9585 "login": "l", 9586 "id": 1, 9587 "node_id": "n", 9588 "avatar_url": "a", 9589 "url": "u", 9590 "events_url": "e", 9591 "repos_url": "r" 9592 }, 9593 "installation": { 9594 "id": 1, 9595 "node_id": "nid", 9596 "app_id": 1, 9597 "app_slug": "as", 9598 "target_id": 1, 9599 "account": { 9600 "login": "l", 9601 "id": 1, 9602 "avatar_url": "a", 9603 "gravatar_id": "g", 9604 "name": "n", 9605 "company": "c", 9606 "blog": "b", 9607 "location": "l", 9608 "email": "e", 9609 "hireable": true, 9610 "bio": "b", 9611 "twitter_username": "t", 9612 "public_repos": 1, 9613 "followers": 1, 9614 "following": 1, 9615 "created_at": ` + referenceTimeStr + `, 9616 "suspended_at": ` + referenceTimeStr + `, 9617 "url": "u" 9618 }, 9619 "access_tokens_url": "atu", 9620 "repositories_url": "ru", 9621 "html_url": "hu", 9622 "target_type": "tt", 9623 "single_file_name": "sfn", 9624 "repository_selection": "rs", 9625 "events": [ 9626 "e" 9627 ], 9628 "single_file_paths": [ 9629 "s" 9630 ], 9631 "permissions": { 9632 "actions": "a", 9633 "administration": "ad", 9634 "checks": "c", 9635 "contents": "co", 9636 "content_references": "cr", 9637 "deployments": "d", 9638 "environments": "e", 9639 "issues": "i", 9640 "metadata": "md", 9641 "members": "m", 9642 "organization_administration": "oa", 9643 "organization_hooks": "oh", 9644 "organization_plan": "op", 9645 "organization_pre_receive_hooks": "opr", 9646 "organization_projects": "op", 9647 "organization_secrets": "os", 9648 "organization_self_hosted_runners": "osh", 9649 "organization_user_blocking": "oub", 9650 "packages": "pkg", 9651 "pages": "pg", 9652 "pull_requests": "pr", 9653 "repository_hooks": "rh", 9654 "repository_projects": "rp", 9655 "repository_pre_receive_hooks": "rprh", 9656 "secrets": "s", 9657 "secret_scanning_alerts": "ssa", 9658 "security_events": "se", 9659 "single_file": "sf", 9660 "statuses": "s", 9661 "team_discussions": "td", 9662 "vulnerability_alerts": "va", 9663 "workflows": "w" 9664 }, 9665 "created_at": ` + referenceTimeStr + `, 9666 "updated_at": ` + referenceTimeStr + `, 9667 "has_multiple_single_files": false, 9668 "suspended_by": { 9669 "login": "l", 9670 "id": 1, 9671 "avatar_url": "a", 9672 "gravatar_id": "g", 9673 "name": "n", 9674 "company": "c", 9675 "blog": "b", 9676 "location": "l", 9677 "email": "e", 9678 "hireable": true, 9679 "bio": "b", 9680 "twitter_username": "t", 9681 "public_repos": 1, 9682 "followers": 1, 9683 "following": 1, 9684 "created_at": ` + referenceTimeStr + `, 9685 "suspended_at": ` + referenceTimeStr + `, 9686 "url": "u" 9687 }, 9688 "suspended_at": ` + referenceTimeStr + ` 9689 } 9690 }` 9691 9692 testJSONMarshal(t, u, want) 9693 } 9694 9695 func TestRepositoryRulesetEvent_Unmarshal(t *testing.T) { 9696 t.Parallel() 9697 9698 enterprise := &Enterprise{ 9699 ID: Ptr(1), 9700 NodeID: Ptr("n"), 9701 Slug: Ptr("e"), 9702 Name: Ptr("e"), 9703 } 9704 9705 installation := &Installation{ 9706 ID: Ptr(int64(1)), 9707 NodeID: Ptr("n"), 9708 AppID: Ptr(int64(1)), 9709 AppSlug: Ptr("a"), 9710 } 9711 9712 organization := &Organization{ 9713 ID: Ptr(int64(1)), 9714 NodeID: Ptr("n"), 9715 Name: Ptr("o"), 9716 } 9717 9718 repository := &Repository{ 9719 ID: Ptr(int64(1)), 9720 NodeID: Ptr("n"), 9721 Name: Ptr("r"), 9722 FullName: Ptr("o/r"), 9723 } 9724 9725 sender := &User{ 9726 ID: Ptr(int64(1)), 9727 NodeID: Ptr("n"), 9728 Login: Ptr("l"), 9729 } 9730 9731 tests := []struct { 9732 name string 9733 json string 9734 event *RepositoryRulesetEvent 9735 }{ 9736 {"empty", `{}`, &RepositoryRulesetEvent{}}, 9737 { 9738 "created", 9739 fmt.Sprintf( 9740 `{"action":"created","repository_ruleset":{"id":1,"name":"r","target":"branch","source_type":"Repository","source":"o/r","enforcement":"active","conditions":{"ref_name":{"exclude":[],"include":["~ALL"]}},"rules":[{"type":"deletion"},{"type":"creation"},{"type":"update"},{"type":"required_linear_history"},{"type":"pull_request","parameters":{"required_approving_review_count":2,"dismiss_stale_reviews_on_push":false,"require_code_owner_review":false,"require_last_push_approval":false,"required_review_thread_resolution":false,"automatic_copilot_code_review_enabled":false,"allowed_merge_methods":["squash","rebase","merge"]}},{"type":"code_scanning","parameters":{"code_scanning_tools":[{"tool":"CodeQL","security_alerts_threshold":"high_or_higher","alerts_threshold":"errors"}]}}],"node_id":"n","created_at":%[1]s,"updated_at":%[1]s,"_links":{"self":{"href":"a"},"html":{"href":"a"}}},"repository":{"id":1,"node_id":"n","name":"r","full_name":"o/r"},"organization":{"id":1,"node_id":"n","name":"o"},"enterprise":{"id":1,"node_id":"n","slug":"e","name":"e"},"installation":{"id":1,"node_id":"n","app_id":1,"app_slug":"a"},"sender":{"id":1,"node_id":"n","login":"l"}}`, 9741 referenceTimeStr, 9742 ), 9743 &RepositoryRulesetEvent{ 9744 Action: Ptr("created"), 9745 RepositoryRuleset: &RepositoryRuleset{ 9746 ID: Ptr(int64(1)), 9747 Name: "r", 9748 Target: Ptr(RulesetTargetBranch), 9749 SourceType: Ptr(RulesetSourceTypeRepository), 9750 Source: "o/r", 9751 Enforcement: RulesetEnforcementActive, 9752 Conditions: &RepositoryRulesetConditions{ 9753 RefName: &RepositoryRulesetRefConditionParameters{ 9754 Include: []string{"~ALL"}, 9755 Exclude: []string{}, 9756 }, 9757 }, 9758 Rules: &RepositoryRulesetRules{ 9759 Creation: &EmptyRuleParameters{}, 9760 Update: &UpdateRuleParameters{}, 9761 Deletion: &EmptyRuleParameters{}, 9762 RequiredLinearHistory: &EmptyRuleParameters{}, 9763 PullRequest: &PullRequestRuleParameters{ 9764 AllowedMergeMethods: []PullRequestMergeMethod{ 9765 PullRequestMergeMethodSquash, 9766 PullRequestMergeMethodRebase, 9767 PullRequestMergeMethodMerge, 9768 }, 9769 AutomaticCopilotCodeReviewEnabled: Ptr(false), 9770 DismissStaleReviewsOnPush: false, 9771 RequireCodeOwnerReview: false, 9772 RequireLastPushApproval: false, 9773 RequiredApprovingReviewCount: 2, 9774 RequiredReviewThreadResolution: false, 9775 }, 9776 CodeScanning: &CodeScanningRuleParameters{ 9777 CodeScanningTools: []*RuleCodeScanningTool{ 9778 { 9779 AlertsThreshold: CodeScanningAlertsThresholdErrors, 9780 SecurityAlertsThreshold: CodeScanningSecurityAlertsThresholdHighOrHigher, 9781 Tool: "CodeQL", 9782 }, 9783 }, 9784 }, 9785 }, 9786 NodeID: Ptr("n"), 9787 CreatedAt: &Timestamp{referenceTime}, 9788 UpdatedAt: &Timestamp{referenceTime}, 9789 Links: &RepositoryRulesetLinks{ 9790 Self: &RepositoryRulesetLink{HRef: Ptr("a")}, 9791 HTML: &RepositoryRulesetLink{HRef: Ptr("a")}, 9792 }, 9793 }, 9794 Repository: repository, 9795 Organization: organization, 9796 Enterprise: enterprise, 9797 Installation: installation, 9798 Sender: sender, 9799 }, 9800 }, 9801 { 9802 "edited", 9803 fmt.Sprintf( 9804 `{"action":"edited","repository_ruleset":{"id":1,"name":"r","target":"branch","source_type":"Repository","source":"o/r","enforcement":"active","conditions":{"ref_name":{"exclude":[],"include":["~DEFAULT_BRANCH","refs/heads/dev-*"]}},"rules":[{"type":"deletion"},{"type":"creation"},{"type":"update"},{"type": "required_signatures"},{"type":"pull_request","parameters":{"required_approving_review_count":2,"dismiss_stale_reviews_on_push":false,"require_code_owner_review":false,"require_last_push_approval":false,"required_review_thread_resolution":false,"automatic_copilot_code_review_enabled":false,"allowed_merge_methods":["squash","rebase"]}},{"type":"code_scanning","parameters":{"code_scanning_tools":[{"tool":"CodeQL","security_alerts_threshold":"medium_or_higher","alerts_threshold":"errors"}]}}],"node_id":"n","created_at":%[1]s,"updated_at":%[1]s,"_links":{"self":{"href":"a"},"html":{"href":"a"}}},"changes":{"rules":{"added":[{"type": "required_signatures"}],"updated":[{"rule":{"type":"pull_request","parameters":{"required_approving_review_count":2,"dismiss_stale_reviews_on_push":false,"require_code_owner_review":false,"require_last_push_approval":false,"required_review_thread_resolution":false,"automatic_copilot_code_review_enabled":false,"allowed_merge_methods":["squash","rebase"]}},"changes":{"configuration":{"from":"{\\\"required_reviewers\\\":[],\\\"allowed_merge_methods\\\":[\\\"squash\\\",\\\"rebase\\\",\\\"merge\\\"],\\\"require_code_owner_review\\\":false,\\\"require_last_push_approval\\\":false,\\\"dismiss_stale_reviews_on_push\\\":false,\\\"required_approving_review_count\\\":2,\\\"authorized_dismissal_actors_only\\\":false,\\\"required_review_thread_resolution\\\":false,\\\"ignore_approvals_from_contributors\\\":false,\\\"automatic_copilot_code_review_enabled\\\":false}"}}},{"rule":{"type":"code_scanning","parameters":{"code_scanning_tools":[{"tool":"CodeQL","security_alerts_threshold":"medium_or_higher","alerts_threshold":"errors"}]}},"changes":{"configuration":{"from":"{\\\"code_scanning_tools\\\":[{\\\"tool\\\":\\\"CodeQL\\\",\\\"alerts_threshold\\\":\\\"errors\\\",\\\"security_alerts_threshold\\\":\\\"high_or_higher\\\"}]}"}}}],"deleted":[{"type":"required_linear_history"}]},"conditions":{"updated":[{"condition":{"ref_name":{"exclude":[],"include":["~DEFAULT_BRANCH","refs/heads/dev-*"]}},"changes":{"include":{"from":["~ALL"]}}}],"deleted":[]}},"repository":{"id":1,"node_id":"n","name":"r","full_name":"o/r"},"organization":{"id":1,"node_id":"n","name":"o"},"enterprise":{"id":1,"node_id":"n","slug":"e","name":"e"},"installation":{"id":1,"node_id":"n","app_id":1,"app_slug":"a"},"sender":{"id":1,"node_id":"n","login":"l"}}`, 9805 referenceTimeStr, 9806 ), 9807 &RepositoryRulesetEvent{ 9808 Action: Ptr("edited"), 9809 RepositoryRuleset: &RepositoryRuleset{ 9810 ID: Ptr(int64(1)), 9811 Name: "r", 9812 Target: Ptr(RulesetTargetBranch), 9813 SourceType: Ptr(RulesetSourceTypeRepository), 9814 Source: "o/r", 9815 Enforcement: RulesetEnforcementActive, 9816 Conditions: &RepositoryRulesetConditions{ 9817 RefName: &RepositoryRulesetRefConditionParameters{ 9818 Include: []string{"~DEFAULT_BRANCH", "refs/heads/dev-*"}, 9819 Exclude: []string{}, 9820 }, 9821 }, 9822 Rules: &RepositoryRulesetRules{ 9823 Creation: &EmptyRuleParameters{}, 9824 Update: &UpdateRuleParameters{}, 9825 Deletion: &EmptyRuleParameters{}, 9826 RequiredSignatures: &EmptyRuleParameters{}, 9827 PullRequest: &PullRequestRuleParameters{ 9828 AllowedMergeMethods: []PullRequestMergeMethod{ 9829 PullRequestMergeMethodSquash, 9830 PullRequestMergeMethodRebase, 9831 }, 9832 AutomaticCopilotCodeReviewEnabled: Ptr(false), 9833 DismissStaleReviewsOnPush: false, 9834 RequireCodeOwnerReview: false, 9835 RequireLastPushApproval: false, 9836 RequiredApprovingReviewCount: 2, 9837 RequiredReviewThreadResolution: false, 9838 }, 9839 CodeScanning: &CodeScanningRuleParameters{ 9840 CodeScanningTools: []*RuleCodeScanningTool{ 9841 { 9842 AlertsThreshold: CodeScanningAlertsThresholdErrors, 9843 SecurityAlertsThreshold: CodeScanningSecurityAlertsThresholdMediumOrHigher, 9844 Tool: "CodeQL", 9845 }, 9846 }, 9847 }, 9848 }, 9849 NodeID: Ptr("n"), 9850 CreatedAt: &Timestamp{referenceTime}, 9851 UpdatedAt: &Timestamp{referenceTime}, 9852 Links: &RepositoryRulesetLinks{ 9853 Self: &RepositoryRulesetLink{HRef: Ptr("a")}, 9854 HTML: &RepositoryRulesetLink{HRef: Ptr("a")}, 9855 }, 9856 }, 9857 Changes: &RepositoryRulesetChanges{ 9858 Conditions: &RepositoryRulesetChangedConditions{ 9859 Updated: []*RepositoryRulesetUpdatedConditions{ 9860 { 9861 Condition: &RepositoryRulesetConditions{ 9862 RefName: &RepositoryRulesetRefConditionParameters{ 9863 Include: []string{"~DEFAULT_BRANCH", "refs/heads/dev-*"}, 9864 Exclude: []string{}, 9865 }, 9866 }, 9867 Changes: &RepositoryRulesetUpdatedCondition{ 9868 Include: &RepositoryRulesetChangeSources{ 9869 From: []string{"~ALL"}, 9870 }, 9871 }, 9872 }, 9873 }, 9874 Deleted: []*RepositoryRulesetConditions{}, 9875 }, 9876 Rules: &RepositoryRulesetChangedRules{ 9877 Added: []*RepositoryRule{{Type: RulesetRuleTypeRequiredSignatures}}, 9878 Updated: []*RepositoryRulesetUpdatedRules{ 9879 { 9880 Rule: &RepositoryRule{ 9881 Type: RulesetRuleTypePullRequest, 9882 Parameters: &PullRequestRuleParameters{ 9883 AllowedMergeMethods: []PullRequestMergeMethod{ 9884 PullRequestMergeMethodSquash, 9885 PullRequestMergeMethodRebase, 9886 }, 9887 AutomaticCopilotCodeReviewEnabled: Ptr(false), 9888 DismissStaleReviewsOnPush: false, 9889 RequireCodeOwnerReview: false, 9890 RequireLastPushApproval: false, 9891 RequiredApprovingReviewCount: 2, 9892 RequiredReviewThreadResolution: false, 9893 }, 9894 }, 9895 Changes: &RepositoryRulesetChangedRule{ 9896 Configuration: &RepositoryRulesetChangeSource{ 9897 From: Ptr( 9898 `{\"required_reviewers\":[],\"allowed_merge_methods\":[\"squash\",\"rebase\",\"merge\"],\"require_code_owner_review\":false,\"require_last_push_approval\":false,\"dismiss_stale_reviews_on_push\":false,\"required_approving_review_count\":2,\"authorized_dismissal_actors_only\":false,\"required_review_thread_resolution\":false,\"ignore_approvals_from_contributors\":false,\"automatic_copilot_code_review_enabled\":false}`, 9899 ), 9900 }, 9901 }, 9902 }, 9903 { 9904 Rule: &RepositoryRule{ 9905 Type: RulesetRuleTypeCodeScanning, 9906 Parameters: &CodeScanningRuleParameters{ 9907 CodeScanningTools: []*RuleCodeScanningTool{ 9908 { 9909 AlertsThreshold: CodeScanningAlertsThresholdErrors, 9910 SecurityAlertsThreshold: CodeScanningSecurityAlertsThresholdMediumOrHigher, 9911 Tool: "CodeQL", 9912 }, 9913 }, 9914 }, 9915 }, 9916 Changes: &RepositoryRulesetChangedRule{ 9917 Configuration: &RepositoryRulesetChangeSource{ 9918 From: Ptr( 9919 `{\"code_scanning_tools\":[{\"tool\":\"CodeQL\",\"alerts_threshold\":\"errors\",\"security_alerts_threshold\":\"high_or_higher\"}]}`, 9920 ), 9921 }, 9922 }, 9923 }, 9924 }, 9925 Deleted: []*RepositoryRule{{Type: RulesetRuleTypeRequiredLinearHistory}}, 9926 }, 9927 }, 9928 Repository: repository, 9929 Organization: organization, 9930 Enterprise: enterprise, 9931 Installation: installation, 9932 Sender: sender, 9933 }, 9934 }, 9935 { 9936 "deleted", 9937 fmt.Sprintf( 9938 `{"action":"deleted","repository_ruleset":{"id":1,"name":"r","target":"branch","source_type":"Repository","source":"o/r","enforcement":"active","conditions":{"ref_name":{"exclude":[],"include":["~DEFAULT_BRANCH","refs/heads/dev-*"]}},"rules":[{"type":"deletion"},{"type":"creation"},{"type":"update"},{"type":"required_linear_history"}],"node_id":"n","created_at":%[1]s,"updated_at":%[1]s,"_links":{"self":{"href":"a"},"html":{"href":"a"}}},"repository":{"id":1,"node_id":"n","name":"r","full_name":"o/r"},"organization":{"id":1,"node_id":"n","name":"o"},"enterprise":{"id":1,"node_id":"n","slug":"e","name":"e"},"installation":{"id":1,"node_id":"n","app_id":1,"app_slug":"a"},"sender":{"id":1,"node_id":"n","login":"l"}}`, 9939 referenceTimeStr, 9940 ), 9941 &RepositoryRulesetEvent{ 9942 Action: Ptr("deleted"), 9943 RepositoryRuleset: &RepositoryRuleset{ 9944 ID: Ptr(int64(1)), 9945 Name: "r", 9946 Target: Ptr(RulesetTargetBranch), 9947 SourceType: Ptr(RulesetSourceTypeRepository), 9948 Source: "o/r", 9949 Enforcement: RulesetEnforcementActive, 9950 Conditions: &RepositoryRulesetConditions{ 9951 RefName: &RepositoryRulesetRefConditionParameters{ 9952 Include: []string{"~DEFAULT_BRANCH", "refs/heads/dev-*"}, 9953 Exclude: []string{}, 9954 }, 9955 }, 9956 Rules: &RepositoryRulesetRules{ 9957 Creation: &EmptyRuleParameters{}, 9958 Update: &UpdateRuleParameters{}, 9959 Deletion: &EmptyRuleParameters{}, 9960 RequiredLinearHistory: &EmptyRuleParameters{}, 9961 }, 9962 NodeID: Ptr("n"), 9963 CreatedAt: &Timestamp{referenceTime}, 9964 UpdatedAt: &Timestamp{referenceTime}, 9965 Links: &RepositoryRulesetLinks{ 9966 Self: &RepositoryRulesetLink{HRef: Ptr("a")}, 9967 HTML: &RepositoryRulesetLink{HRef: Ptr("a")}, 9968 }, 9969 }, 9970 Repository: repository, 9971 Organization: organization, 9972 Enterprise: enterprise, 9973 Installation: installation, 9974 Sender: sender, 9975 }, 9976 }, 9977 } 9978 9979 for _, test := range tests { 9980 t.Run(test.name, func(t *testing.T) { 9981 t.Parallel() 9982 9983 got := &RepositoryRulesetEvent{} 9984 err := json.Unmarshal([]byte(test.json), got) 9985 if err != nil { 9986 t.Errorf("Unable to unmarshal JSON %v: %v", test.json, err) 9987 } 9988 9989 if diff := cmp.Diff(test.event, got); diff != "" { 9990 t.Errorf("json.Unmarshal returned:\n%#v\nwant:\n%#v\ndiff:\n%v", got, test.event, diff) 9991 } 9992 }) 9993 } 9994 } 9995 9996 func TestContentReferenceEvent_Marshal(t *testing.T) { 9997 t.Parallel() 9998 testJSONMarshal(t, &ContentReferenceEvent{}, "{}") 9999 10000 u := &ContentReferenceEvent{ 10001 Action: Ptr("a"), 10002 ContentReference: &ContentReference{ 10003 ID: Ptr(int64(1)), 10004 NodeID: Ptr("nid"), 10005 Reference: Ptr("ref"), 10006 }, 10007 Repo: &Repository{ 10008 ID: Ptr(int64(1)), 10009 URL: Ptr("s"), 10010 Name: Ptr("n"), 10011 }, 10012 Sender: &User{ 10013 Login: Ptr("l"), 10014 ID: Ptr(int64(1)), 10015 NodeID: Ptr("n"), 10016 URL: Ptr("u"), 10017 ReposURL: Ptr("r"), 10018 EventsURL: Ptr("e"), 10019 AvatarURL: Ptr("a"), 10020 }, 10021 Installation: &Installation{ 10022 ID: Ptr(int64(1)), 10023 NodeID: Ptr("nid"), 10024 AppID: Ptr(int64(1)), 10025 AppSlug: Ptr("as"), 10026 TargetID: Ptr(int64(1)), 10027 Account: &User{ 10028 Login: Ptr("l"), 10029 ID: Ptr(int64(1)), 10030 URL: Ptr("u"), 10031 AvatarURL: Ptr("a"), 10032 GravatarID: Ptr("g"), 10033 Name: Ptr("n"), 10034 Company: Ptr("c"), 10035 Blog: Ptr("b"), 10036 Location: Ptr("l"), 10037 Email: Ptr("e"), 10038 Hireable: Ptr(true), 10039 Bio: Ptr("b"), 10040 TwitterUsername: Ptr("t"), 10041 PublicRepos: Ptr(1), 10042 Followers: Ptr(1), 10043 Following: Ptr(1), 10044 CreatedAt: &Timestamp{referenceTime}, 10045 SuspendedAt: &Timestamp{referenceTime}, 10046 }, 10047 AccessTokensURL: Ptr("atu"), 10048 RepositoriesURL: Ptr("ru"), 10049 HTMLURL: Ptr("hu"), 10050 TargetType: Ptr("tt"), 10051 SingleFileName: Ptr("sfn"), 10052 RepositorySelection: Ptr("rs"), 10053 Events: []string{"e"}, 10054 SingleFilePaths: []string{"s"}, 10055 Permissions: &InstallationPermissions{ 10056 Actions: Ptr("a"), 10057 Administration: Ptr("ad"), 10058 Checks: Ptr("c"), 10059 Contents: Ptr("co"), 10060 ContentReferences: Ptr("cr"), 10061 Deployments: Ptr("d"), 10062 Environments: Ptr("e"), 10063 Issues: Ptr("i"), 10064 Metadata: Ptr("md"), 10065 Members: Ptr("m"), 10066 OrganizationAdministration: Ptr("oa"), 10067 OrganizationHooks: Ptr("oh"), 10068 OrganizationPlan: Ptr("op"), 10069 OrganizationPreReceiveHooks: Ptr("opr"), 10070 OrganizationProjects: Ptr("op"), 10071 OrganizationSecrets: Ptr("os"), 10072 OrganizationSelfHostedRunners: Ptr("osh"), 10073 OrganizationUserBlocking: Ptr("oub"), 10074 Packages: Ptr("pkg"), 10075 Pages: Ptr("pg"), 10076 PullRequests: Ptr("pr"), 10077 RepositoryHooks: Ptr("rh"), 10078 RepositoryProjects: Ptr("rp"), 10079 RepositoryPreReceiveHooks: Ptr("rprh"), 10080 Secrets: Ptr("s"), 10081 SecretScanningAlerts: Ptr("ssa"), 10082 SecurityEvents: Ptr("se"), 10083 SingleFile: Ptr("sf"), 10084 Statuses: Ptr("s"), 10085 TeamDiscussions: Ptr("td"), 10086 VulnerabilityAlerts: Ptr("va"), 10087 Workflows: Ptr("w"), 10088 }, 10089 CreatedAt: &Timestamp{referenceTime}, 10090 UpdatedAt: &Timestamp{referenceTime}, 10091 HasMultipleSingleFiles: Ptr(false), 10092 SuspendedBy: &User{ 10093 Login: Ptr("l"), 10094 ID: Ptr(int64(1)), 10095 URL: Ptr("u"), 10096 AvatarURL: Ptr("a"), 10097 GravatarID: Ptr("g"), 10098 Name: Ptr("n"), 10099 Company: Ptr("c"), 10100 Blog: Ptr("b"), 10101 Location: Ptr("l"), 10102 Email: Ptr("e"), 10103 Hireable: Ptr(true), 10104 Bio: Ptr("b"), 10105 TwitterUsername: Ptr("t"), 10106 PublicRepos: Ptr(1), 10107 Followers: Ptr(1), 10108 Following: Ptr(1), 10109 CreatedAt: &Timestamp{referenceTime}, 10110 SuspendedAt: &Timestamp{referenceTime}, 10111 }, 10112 SuspendedAt: &Timestamp{referenceTime}, 10113 }, 10114 } 10115 10116 want := `{ 10117 "action": "a", 10118 "content_reference": { 10119 "id": 1, 10120 "node_id": "nid", 10121 "reference": "ref" 10122 }, 10123 "repository": { 10124 "id": 1, 10125 "name": "n", 10126 "url": "s" 10127 }, 10128 "sender": { 10129 "login": "l", 10130 "id": 1, 10131 "node_id": "n", 10132 "avatar_url": "a", 10133 "url": "u", 10134 "events_url": "e", 10135 "repos_url": "r" 10136 }, 10137 "installation": { 10138 "id": 1, 10139 "node_id": "nid", 10140 "app_id": 1, 10141 "app_slug": "as", 10142 "target_id": 1, 10143 "account": { 10144 "login": "l", 10145 "id": 1, 10146 "avatar_url": "a", 10147 "gravatar_id": "g", 10148 "name": "n", 10149 "company": "c", 10150 "blog": "b", 10151 "location": "l", 10152 "email": "e", 10153 "hireable": true, 10154 "bio": "b", 10155 "twitter_username": "t", 10156 "public_repos": 1, 10157 "followers": 1, 10158 "following": 1, 10159 "created_at": ` + referenceTimeStr + `, 10160 "suspended_at": ` + referenceTimeStr + `, 10161 "url": "u" 10162 }, 10163 "access_tokens_url": "atu", 10164 "repositories_url": "ru", 10165 "html_url": "hu", 10166 "target_type": "tt", 10167 "single_file_name": "sfn", 10168 "repository_selection": "rs", 10169 "events": [ 10170 "e" 10171 ], 10172 "single_file_paths": [ 10173 "s" 10174 ], 10175 "permissions": { 10176 "actions": "a", 10177 "administration": "ad", 10178 "checks": "c", 10179 "contents": "co", 10180 "content_references": "cr", 10181 "deployments": "d", 10182 "environments": "e", 10183 "issues": "i", 10184 "metadata": "md", 10185 "members": "m", 10186 "organization_administration": "oa", 10187 "organization_hooks": "oh", 10188 "organization_plan": "op", 10189 "organization_pre_receive_hooks": "opr", 10190 "organization_projects": "op", 10191 "organization_secrets": "os", 10192 "organization_self_hosted_runners": "osh", 10193 "organization_user_blocking": "oub", 10194 "packages": "pkg", 10195 "pages": "pg", 10196 "pull_requests": "pr", 10197 "repository_hooks": "rh", 10198 "repository_projects": "rp", 10199 "repository_pre_receive_hooks": "rprh", 10200 "secrets": "s", 10201 "secret_scanning_alerts": "ssa", 10202 "security_events": "se", 10203 "single_file": "sf", 10204 "statuses": "s", 10205 "team_discussions": "td", 10206 "vulnerability_alerts": "va", 10207 "workflows": "w" 10208 }, 10209 "created_at": ` + referenceTimeStr + `, 10210 "updated_at": ` + referenceTimeStr + `, 10211 "has_multiple_single_files": false, 10212 "suspended_by": { 10213 "login": "l", 10214 "id": 1, 10215 "avatar_url": "a", 10216 "gravatar_id": "g", 10217 "name": "n", 10218 "company": "c", 10219 "blog": "b", 10220 "location": "l", 10221 "email": "e", 10222 "hireable": true, 10223 "bio": "b", 10224 "twitter_username": "t", 10225 "public_repos": 1, 10226 "followers": 1, 10227 "following": 1, 10228 "created_at": ` + referenceTimeStr + `, 10229 "suspended_at": ` + referenceTimeStr + `, 10230 "url": "u" 10231 }, 10232 "suspended_at": ` + referenceTimeStr + ` 10233 } 10234 }` 10235 10236 testJSONMarshal(t, u, want) 10237 } 10238 10239 func TestMemberEvent_Marshal(t *testing.T) { 10240 t.Parallel() 10241 testJSONMarshal(t, &MemberEvent{}, "{}") 10242 10243 u := &MemberEvent{ 10244 Action: Ptr("a"), 10245 Member: &User{ 10246 Login: Ptr("l"), 10247 ID: Ptr(int64(1)), 10248 NodeID: Ptr("n"), 10249 URL: Ptr("u"), 10250 ReposURL: Ptr("r"), 10251 EventsURL: Ptr("e"), 10252 AvatarURL: Ptr("a"), 10253 }, 10254 Changes: &MemberChanges{ 10255 Permission: &MemberChangesPermission{ 10256 From: Ptr("f"), 10257 To: Ptr("t"), 10258 }, 10259 RoleName: &MemberChangesRoleName{ 10260 From: Ptr("f"), 10261 To: Ptr("t"), 10262 }, 10263 }, 10264 Repo: &Repository{ 10265 ID: Ptr(int64(1)), 10266 URL: Ptr("s"), 10267 Name: Ptr("n"), 10268 }, 10269 Sender: &User{ 10270 Login: Ptr("l"), 10271 ID: Ptr(int64(1)), 10272 NodeID: Ptr("n"), 10273 URL: Ptr("u"), 10274 ReposURL: Ptr("r"), 10275 EventsURL: Ptr("e"), 10276 AvatarURL: Ptr("a"), 10277 }, 10278 Installation: &Installation{ 10279 ID: Ptr(int64(1)), 10280 NodeID: Ptr("nid"), 10281 AppID: Ptr(int64(1)), 10282 AppSlug: Ptr("as"), 10283 TargetID: Ptr(int64(1)), 10284 Account: &User{ 10285 Login: Ptr("l"), 10286 ID: Ptr(int64(1)), 10287 URL: Ptr("u"), 10288 AvatarURL: Ptr("a"), 10289 GravatarID: Ptr("g"), 10290 Name: Ptr("n"), 10291 Company: Ptr("c"), 10292 Blog: Ptr("b"), 10293 Location: Ptr("l"), 10294 Email: Ptr("e"), 10295 Hireable: Ptr(true), 10296 Bio: Ptr("b"), 10297 TwitterUsername: Ptr("t"), 10298 PublicRepos: Ptr(1), 10299 Followers: Ptr(1), 10300 Following: Ptr(1), 10301 CreatedAt: &Timestamp{referenceTime}, 10302 SuspendedAt: &Timestamp{referenceTime}, 10303 }, 10304 AccessTokensURL: Ptr("atu"), 10305 RepositoriesURL: Ptr("ru"), 10306 HTMLURL: Ptr("hu"), 10307 TargetType: Ptr("tt"), 10308 SingleFileName: Ptr("sfn"), 10309 RepositorySelection: Ptr("rs"), 10310 Events: []string{"e"}, 10311 SingleFilePaths: []string{"s"}, 10312 Permissions: &InstallationPermissions{ 10313 Actions: Ptr("a"), 10314 Administration: Ptr("ad"), 10315 Checks: Ptr("c"), 10316 Contents: Ptr("co"), 10317 ContentReferences: Ptr("cr"), 10318 Deployments: Ptr("d"), 10319 Environments: Ptr("e"), 10320 Issues: Ptr("i"), 10321 Metadata: Ptr("md"), 10322 Members: Ptr("m"), 10323 OrganizationAdministration: Ptr("oa"), 10324 OrganizationHooks: Ptr("oh"), 10325 OrganizationPlan: Ptr("op"), 10326 OrganizationPreReceiveHooks: Ptr("opr"), 10327 OrganizationProjects: Ptr("op"), 10328 OrganizationSecrets: Ptr("os"), 10329 OrganizationSelfHostedRunners: Ptr("osh"), 10330 OrganizationUserBlocking: Ptr("oub"), 10331 Packages: Ptr("pkg"), 10332 Pages: Ptr("pg"), 10333 PullRequests: Ptr("pr"), 10334 RepositoryHooks: Ptr("rh"), 10335 RepositoryProjects: Ptr("rp"), 10336 RepositoryPreReceiveHooks: Ptr("rprh"), 10337 Secrets: Ptr("s"), 10338 SecretScanningAlerts: Ptr("ssa"), 10339 SecurityEvents: Ptr("se"), 10340 SingleFile: Ptr("sf"), 10341 Statuses: Ptr("s"), 10342 TeamDiscussions: Ptr("td"), 10343 VulnerabilityAlerts: Ptr("va"), 10344 Workflows: Ptr("w"), 10345 }, 10346 CreatedAt: &Timestamp{referenceTime}, 10347 UpdatedAt: &Timestamp{referenceTime}, 10348 HasMultipleSingleFiles: Ptr(false), 10349 SuspendedBy: &User{ 10350 Login: Ptr("l"), 10351 ID: Ptr(int64(1)), 10352 URL: Ptr("u"), 10353 AvatarURL: Ptr("a"), 10354 GravatarID: Ptr("g"), 10355 Name: Ptr("n"), 10356 Company: Ptr("c"), 10357 Blog: Ptr("b"), 10358 Location: Ptr("l"), 10359 Email: Ptr("e"), 10360 Hireable: Ptr(true), 10361 Bio: Ptr("b"), 10362 TwitterUsername: Ptr("t"), 10363 PublicRepos: Ptr(1), 10364 Followers: Ptr(1), 10365 Following: Ptr(1), 10366 CreatedAt: &Timestamp{referenceTime}, 10367 SuspendedAt: &Timestamp{referenceTime}, 10368 }, 10369 SuspendedAt: &Timestamp{referenceTime}, 10370 }, 10371 } 10372 10373 want := `{ 10374 "action": "a", 10375 "member": { 10376 "login": "l", 10377 "id": 1, 10378 "node_id": "n", 10379 "avatar_url": "a", 10380 "url": "u", 10381 "events_url": "e", 10382 "repos_url": "r" 10383 }, 10384 "changes": { 10385 "permission": { 10386 "from": "f", 10387 "to": "t" 10388 }, 10389 "role_name": { 10390 "from": "f", 10391 "to": "t" 10392 } 10393 }, 10394 "repository": { 10395 "id": 1, 10396 "name": "n", 10397 "url": "s" 10398 }, 10399 "sender": { 10400 "login": "l", 10401 "id": 1, 10402 "node_id": "n", 10403 "avatar_url": "a", 10404 "url": "u", 10405 "events_url": "e", 10406 "repos_url": "r" 10407 }, 10408 "installation": { 10409 "id": 1, 10410 "node_id": "nid", 10411 "app_id": 1, 10412 "app_slug": "as", 10413 "target_id": 1, 10414 "account": { 10415 "login": "l", 10416 "id": 1, 10417 "avatar_url": "a", 10418 "gravatar_id": "g", 10419 "name": "n", 10420 "company": "c", 10421 "blog": "b", 10422 "location": "l", 10423 "email": "e", 10424 "hireable": true, 10425 "bio": "b", 10426 "twitter_username": "t", 10427 "public_repos": 1, 10428 "followers": 1, 10429 "following": 1, 10430 "created_at": ` + referenceTimeStr + `, 10431 "suspended_at": ` + referenceTimeStr + `, 10432 "url": "u" 10433 }, 10434 "access_tokens_url": "atu", 10435 "repositories_url": "ru", 10436 "html_url": "hu", 10437 "target_type": "tt", 10438 "single_file_name": "sfn", 10439 "repository_selection": "rs", 10440 "events": [ 10441 "e" 10442 ], 10443 "single_file_paths": [ 10444 "s" 10445 ], 10446 "permissions": { 10447 "actions": "a", 10448 "administration": "ad", 10449 "checks": "c", 10450 "contents": "co", 10451 "content_references": "cr", 10452 "deployments": "d", 10453 "environments": "e", 10454 "issues": "i", 10455 "metadata": "md", 10456 "members": "m", 10457 "organization_administration": "oa", 10458 "organization_hooks": "oh", 10459 "organization_plan": "op", 10460 "organization_pre_receive_hooks": "opr", 10461 "organization_projects": "op", 10462 "organization_secrets": "os", 10463 "organization_self_hosted_runners": "osh", 10464 "organization_user_blocking": "oub", 10465 "packages": "pkg", 10466 "pages": "pg", 10467 "pull_requests": "pr", 10468 "repository_hooks": "rh", 10469 "repository_projects": "rp", 10470 "repository_pre_receive_hooks": "rprh", 10471 "secrets": "s", 10472 "secret_scanning_alerts": "ssa", 10473 "security_events": "se", 10474 "single_file": "sf", 10475 "statuses": "s", 10476 "team_discussions": "td", 10477 "vulnerability_alerts": "va", 10478 "workflows": "w" 10479 }, 10480 "created_at": ` + referenceTimeStr + `, 10481 "updated_at": ` + referenceTimeStr + `, 10482 "has_multiple_single_files": false, 10483 "suspended_by": { 10484 "login": "l", 10485 "id": 1, 10486 "avatar_url": "a", 10487 "gravatar_id": "g", 10488 "name": "n", 10489 "company": "c", 10490 "blog": "b", 10491 "location": "l", 10492 "email": "e", 10493 "hireable": true, 10494 "bio": "b", 10495 "twitter_username": "t", 10496 "public_repos": 1, 10497 "followers": 1, 10498 "following": 1, 10499 "created_at": ` + referenceTimeStr + `, 10500 "suspended_at": ` + referenceTimeStr + `, 10501 "url": "u" 10502 }, 10503 "suspended_at": ` + referenceTimeStr + ` 10504 } 10505 }` 10506 10507 testJSONMarshal(t, u, want) 10508 } 10509 10510 func TestMembershipEvent_Marshal(t *testing.T) { 10511 t.Parallel() 10512 testJSONMarshal(t, &MembershipEvent{}, "{}") 10513 10514 u := &MembershipEvent{ 10515 Action: Ptr("a"), 10516 Scope: Ptr("s"), 10517 Member: &User{ 10518 Login: Ptr("l"), 10519 ID: Ptr(int64(1)), 10520 NodeID: Ptr("n"), 10521 URL: Ptr("u"), 10522 ReposURL: Ptr("r"), 10523 EventsURL: Ptr("e"), 10524 AvatarURL: Ptr("a"), 10525 }, 10526 Team: &Team{ 10527 ID: Ptr(int64(1)), 10528 NodeID: Ptr("n"), 10529 Name: Ptr("n"), 10530 Description: Ptr("d"), 10531 URL: Ptr("u"), 10532 Slug: Ptr("s"), 10533 Permission: Ptr("p"), 10534 Privacy: Ptr("p"), 10535 MembersCount: Ptr(1), 10536 ReposCount: Ptr(1), 10537 MembersURL: Ptr("m"), 10538 RepositoriesURL: Ptr("r"), 10539 Organization: &Organization{ 10540 Login: Ptr("l"), 10541 ID: Ptr(int64(1)), 10542 NodeID: Ptr("n"), 10543 AvatarURL: Ptr("a"), 10544 HTMLURL: Ptr("h"), 10545 Name: Ptr("n"), 10546 Company: Ptr("c"), 10547 Blog: Ptr("b"), 10548 Location: Ptr("l"), 10549 Email: Ptr("e"), 10550 }, 10551 Parent: &Team{ 10552 ID: Ptr(int64(1)), 10553 NodeID: Ptr("n"), 10554 Name: Ptr("n"), 10555 Description: Ptr("d"), 10556 URL: Ptr("u"), 10557 Slug: Ptr("s"), 10558 Permission: Ptr("p"), 10559 Privacy: Ptr("p"), 10560 MembersCount: Ptr(1), 10561 ReposCount: Ptr(1), 10562 }, 10563 LDAPDN: Ptr("l"), 10564 }, 10565 Org: &Organization{ 10566 BillingEmail: Ptr("be"), 10567 Blog: Ptr("b"), 10568 Company: Ptr("c"), 10569 Email: Ptr("e"), 10570 TwitterUsername: Ptr("tu"), 10571 Location: Ptr("loc"), 10572 Name: Ptr("n"), 10573 Description: Ptr("d"), 10574 IsVerified: Ptr(true), 10575 HasOrganizationProjects: Ptr(true), 10576 HasRepositoryProjects: Ptr(true), 10577 DefaultRepoPermission: Ptr("drp"), 10578 MembersCanCreateRepos: Ptr(true), 10579 MembersCanCreateInternalRepos: Ptr(true), 10580 MembersCanCreatePrivateRepos: Ptr(true), 10581 MembersCanCreatePublicRepos: Ptr(false), 10582 MembersAllowedRepositoryCreationType: Ptr("marct"), 10583 MembersCanCreatePages: Ptr(true), 10584 MembersCanCreatePublicPages: Ptr(false), 10585 MembersCanCreatePrivatePages: Ptr(true), 10586 }, 10587 Sender: &User{ 10588 Login: Ptr("l"), 10589 ID: Ptr(int64(1)), 10590 NodeID: Ptr("n"), 10591 URL: Ptr("u"), 10592 ReposURL: Ptr("r"), 10593 EventsURL: Ptr("e"), 10594 AvatarURL: Ptr("a"), 10595 }, 10596 Installation: &Installation{ 10597 ID: Ptr(int64(1)), 10598 NodeID: Ptr("nid"), 10599 AppID: Ptr(int64(1)), 10600 AppSlug: Ptr("as"), 10601 TargetID: Ptr(int64(1)), 10602 Account: &User{ 10603 Login: Ptr("l"), 10604 ID: Ptr(int64(1)), 10605 URL: Ptr("u"), 10606 AvatarURL: Ptr("a"), 10607 GravatarID: Ptr("g"), 10608 Name: Ptr("n"), 10609 Company: Ptr("c"), 10610 Blog: Ptr("b"), 10611 Location: Ptr("l"), 10612 Email: Ptr("e"), 10613 Hireable: Ptr(true), 10614 Bio: Ptr("b"), 10615 TwitterUsername: Ptr("t"), 10616 PublicRepos: Ptr(1), 10617 Followers: Ptr(1), 10618 Following: Ptr(1), 10619 CreatedAt: &Timestamp{referenceTime}, 10620 SuspendedAt: &Timestamp{referenceTime}, 10621 }, 10622 AccessTokensURL: Ptr("atu"), 10623 RepositoriesURL: Ptr("ru"), 10624 HTMLURL: Ptr("hu"), 10625 TargetType: Ptr("tt"), 10626 SingleFileName: Ptr("sfn"), 10627 RepositorySelection: Ptr("rs"), 10628 Events: []string{"e"}, 10629 SingleFilePaths: []string{"s"}, 10630 Permissions: &InstallationPermissions{ 10631 Actions: Ptr("a"), 10632 Administration: Ptr("ad"), 10633 Checks: Ptr("c"), 10634 Contents: Ptr("co"), 10635 ContentReferences: Ptr("cr"), 10636 Deployments: Ptr("d"), 10637 Environments: Ptr("e"), 10638 Issues: Ptr("i"), 10639 Metadata: Ptr("md"), 10640 Members: Ptr("m"), 10641 OrganizationAdministration: Ptr("oa"), 10642 OrganizationHooks: Ptr("oh"), 10643 OrganizationPlan: Ptr("op"), 10644 OrganizationPreReceiveHooks: Ptr("opr"), 10645 OrganizationProjects: Ptr("op"), 10646 OrganizationSecrets: Ptr("os"), 10647 OrganizationSelfHostedRunners: Ptr("osh"), 10648 OrganizationUserBlocking: Ptr("oub"), 10649 Packages: Ptr("pkg"), 10650 Pages: Ptr("pg"), 10651 PullRequests: Ptr("pr"), 10652 RepositoryHooks: Ptr("rh"), 10653 RepositoryProjects: Ptr("rp"), 10654 RepositoryPreReceiveHooks: Ptr("rprh"), 10655 Secrets: Ptr("s"), 10656 SecretScanningAlerts: Ptr("ssa"), 10657 SecurityEvents: Ptr("se"), 10658 SingleFile: Ptr("sf"), 10659 Statuses: Ptr("s"), 10660 TeamDiscussions: Ptr("td"), 10661 VulnerabilityAlerts: Ptr("va"), 10662 Workflows: Ptr("w"), 10663 }, 10664 CreatedAt: &Timestamp{referenceTime}, 10665 UpdatedAt: &Timestamp{referenceTime}, 10666 HasMultipleSingleFiles: Ptr(false), 10667 SuspendedBy: &User{ 10668 Login: Ptr("l"), 10669 ID: Ptr(int64(1)), 10670 URL: Ptr("u"), 10671 AvatarURL: Ptr("a"), 10672 GravatarID: Ptr("g"), 10673 Name: Ptr("n"), 10674 Company: Ptr("c"), 10675 Blog: Ptr("b"), 10676 Location: Ptr("l"), 10677 Email: Ptr("e"), 10678 Hireable: Ptr(true), 10679 Bio: Ptr("b"), 10680 TwitterUsername: Ptr("t"), 10681 PublicRepos: Ptr(1), 10682 Followers: Ptr(1), 10683 Following: Ptr(1), 10684 CreatedAt: &Timestamp{referenceTime}, 10685 SuspendedAt: &Timestamp{referenceTime}, 10686 }, 10687 SuspendedAt: &Timestamp{referenceTime}, 10688 }, 10689 } 10690 10691 want := `{ 10692 "action": "a", 10693 "scope": "s", 10694 "member": { 10695 "login": "l", 10696 "id": 1, 10697 "node_id": "n", 10698 "avatar_url": "a", 10699 "url": "u", 10700 "events_url": "e", 10701 "repos_url": "r" 10702 }, 10703 "team": { 10704 "id": 1, 10705 "node_id": "n", 10706 "name": "n", 10707 "description": "d", 10708 "url": "u", 10709 "slug": "s", 10710 "permission": "p", 10711 "privacy": "p", 10712 "members_count": 1, 10713 "repos_count": 1, 10714 "organization": { 10715 "login": "l", 10716 "id": 1, 10717 "node_id": "n", 10718 "avatar_url": "a", 10719 "html_url": "h", 10720 "name": "n", 10721 "company": "c", 10722 "blog": "b", 10723 "location": "l", 10724 "email": "e" 10725 }, 10726 "members_url": "m", 10727 "repositories_url": "r", 10728 "parent": { 10729 "id": 1, 10730 "node_id": "n", 10731 "name": "n", 10732 "description": "d", 10733 "url": "u", 10734 "slug": "s", 10735 "permission": "p", 10736 "privacy": "p", 10737 "members_count": 1, 10738 "repos_count": 1 10739 }, 10740 "ldap_dn": "l" 10741 }, 10742 "organization": { 10743 "name": "n", 10744 "company": "c", 10745 "blog": "b", 10746 "location": "loc", 10747 "email": "e", 10748 "twitter_username": "tu", 10749 "description": "d", 10750 "billing_email": "be", 10751 "is_verified": true, 10752 "has_organization_projects": true, 10753 "has_repository_projects": true, 10754 "default_repository_permission": "drp", 10755 "members_can_create_repositories": true, 10756 "members_can_create_public_repositories": false, 10757 "members_can_create_private_repositories": true, 10758 "members_can_create_internal_repositories": true, 10759 "members_allowed_repository_creation_type": "marct", 10760 "members_can_create_pages": true, 10761 "members_can_create_public_pages": false, 10762 "members_can_create_private_pages": true 10763 }, 10764 "sender": { 10765 "login": "l", 10766 "id": 1, 10767 "node_id": "n", 10768 "avatar_url": "a", 10769 "url": "u", 10770 "events_url": "e", 10771 "repos_url": "r" 10772 }, 10773 "installation": { 10774 "id": 1, 10775 "node_id": "nid", 10776 "app_id": 1, 10777 "app_slug": "as", 10778 "target_id": 1, 10779 "account": { 10780 "login": "l", 10781 "id": 1, 10782 "avatar_url": "a", 10783 "gravatar_id": "g", 10784 "name": "n", 10785 "company": "c", 10786 "blog": "b", 10787 "location": "l", 10788 "email": "e", 10789 "hireable": true, 10790 "bio": "b", 10791 "twitter_username": "t", 10792 "public_repos": 1, 10793 "followers": 1, 10794 "following": 1, 10795 "created_at": ` + referenceTimeStr + `, 10796 "suspended_at": ` + referenceTimeStr + `, 10797 "url": "u" 10798 }, 10799 "access_tokens_url": "atu", 10800 "repositories_url": "ru", 10801 "html_url": "hu", 10802 "target_type": "tt", 10803 "single_file_name": "sfn", 10804 "repository_selection": "rs", 10805 "events": [ 10806 "e" 10807 ], 10808 "single_file_paths": [ 10809 "s" 10810 ], 10811 "permissions": { 10812 "actions": "a", 10813 "administration": "ad", 10814 "checks": "c", 10815 "contents": "co", 10816 "content_references": "cr", 10817 "deployments": "d", 10818 "environments": "e", 10819 "issues": "i", 10820 "metadata": "md", 10821 "members": "m", 10822 "organization_administration": "oa", 10823 "organization_hooks": "oh", 10824 "organization_plan": "op", 10825 "organization_pre_receive_hooks": "opr", 10826 "organization_projects": "op", 10827 "organization_secrets": "os", 10828 "organization_self_hosted_runners": "osh", 10829 "organization_user_blocking": "oub", 10830 "packages": "pkg", 10831 "pages": "pg", 10832 "pull_requests": "pr", 10833 "repository_hooks": "rh", 10834 "repository_projects": "rp", 10835 "repository_pre_receive_hooks": "rprh", 10836 "secrets": "s", 10837 "secret_scanning_alerts": "ssa", 10838 "security_events": "se", 10839 "single_file": "sf", 10840 "statuses": "s", 10841 "team_discussions": "td", 10842 "vulnerability_alerts": "va", 10843 "workflows": "w" 10844 }, 10845 "created_at": ` + referenceTimeStr + `, 10846 "updated_at": ` + referenceTimeStr + `, 10847 "has_multiple_single_files": false, 10848 "suspended_by": { 10849 "login": "l", 10850 "id": 1, 10851 "avatar_url": "a", 10852 "gravatar_id": "g", 10853 "name": "n", 10854 "company": "c", 10855 "blog": "b", 10856 "location": "l", 10857 "email": "e", 10858 "hireable": true, 10859 "bio": "b", 10860 "twitter_username": "t", 10861 "public_repos": 1, 10862 "followers": 1, 10863 "following": 1, 10864 "created_at": ` + referenceTimeStr + `, 10865 "suspended_at": ` + referenceTimeStr + `, 10866 "url": "u" 10867 }, 10868 "suspended_at": ` + referenceTimeStr + ` 10869 } 10870 }` 10871 10872 testJSONMarshal(t, u, want) 10873 } 10874 10875 func TestMergeGroupEvent_Marshal(t *testing.T) { 10876 t.Parallel() 10877 testJSONMarshal(t, &MergeGroupEvent{}, "{}") 10878 10879 u := &MergeGroupEvent{ 10880 Action: Ptr("a"), 10881 Reason: Ptr("r"), 10882 MergeGroup: &MergeGroup{ 10883 HeadSHA: Ptr("hs"), 10884 HeadRef: Ptr("hr"), 10885 BaseSHA: Ptr("bs"), 10886 BaseRef: Ptr("br"), 10887 HeadCommit: &Commit{NodeID: Ptr("nid")}, 10888 }, 10889 Repo: &Repository{ 10890 ID: Ptr(int64(1)), 10891 URL: Ptr("s"), 10892 Name: Ptr("n"), 10893 }, 10894 Org: &Organization{ 10895 BillingEmail: Ptr("be"), 10896 Blog: Ptr("b"), 10897 Company: Ptr("c"), 10898 Email: Ptr("e"), 10899 TwitterUsername: Ptr("tu"), 10900 Location: Ptr("loc"), 10901 Name: Ptr("n"), 10902 Description: Ptr("d"), 10903 IsVerified: Ptr(true), 10904 HasOrganizationProjects: Ptr(true), 10905 HasRepositoryProjects: Ptr(true), 10906 DefaultRepoPermission: Ptr("drp"), 10907 MembersCanCreateRepos: Ptr(true), 10908 MembersCanCreateInternalRepos: Ptr(true), 10909 MembersCanCreatePrivateRepos: Ptr(true), 10910 MembersCanCreatePublicRepos: Ptr(false), 10911 MembersAllowedRepositoryCreationType: Ptr("marct"), 10912 MembersCanCreatePages: Ptr(true), 10913 MembersCanCreatePublicPages: Ptr(false), 10914 MembersCanCreatePrivatePages: Ptr(true), 10915 }, 10916 Sender: &User{ 10917 Login: Ptr("l"), 10918 ID: Ptr(int64(1)), 10919 NodeID: Ptr("n"), 10920 URL: Ptr("u"), 10921 ReposURL: Ptr("r"), 10922 EventsURL: Ptr("e"), 10923 AvatarURL: Ptr("a"), 10924 }, 10925 Installation: &Installation{ 10926 ID: Ptr(int64(1)), 10927 NodeID: Ptr("nid"), 10928 AppID: Ptr(int64(1)), 10929 AppSlug: Ptr("as"), 10930 TargetID: Ptr(int64(1)), 10931 Account: &User{ 10932 Login: Ptr("l"), 10933 ID: Ptr(int64(1)), 10934 URL: Ptr("u"), 10935 AvatarURL: Ptr("a"), 10936 GravatarID: Ptr("g"), 10937 Name: Ptr("n"), 10938 Company: Ptr("c"), 10939 Blog: Ptr("b"), 10940 Location: Ptr("l"), 10941 Email: Ptr("e"), 10942 Hireable: Ptr(true), 10943 Bio: Ptr("b"), 10944 TwitterUsername: Ptr("t"), 10945 PublicRepos: Ptr(1), 10946 Followers: Ptr(1), 10947 Following: Ptr(1), 10948 CreatedAt: &Timestamp{referenceTime}, 10949 SuspendedAt: &Timestamp{referenceTime}, 10950 }, 10951 AccessTokensURL: Ptr("atu"), 10952 RepositoriesURL: Ptr("ru"), 10953 HTMLURL: Ptr("hu"), 10954 TargetType: Ptr("tt"), 10955 SingleFileName: Ptr("sfn"), 10956 RepositorySelection: Ptr("rs"), 10957 Events: []string{"e"}, 10958 SingleFilePaths: []string{"s"}, 10959 Permissions: &InstallationPermissions{ 10960 Actions: Ptr("a"), 10961 Administration: Ptr("ad"), 10962 Checks: Ptr("c"), 10963 Contents: Ptr("co"), 10964 ContentReferences: Ptr("cr"), 10965 Deployments: Ptr("d"), 10966 Environments: Ptr("e"), 10967 Issues: Ptr("i"), 10968 Metadata: Ptr("md"), 10969 Members: Ptr("m"), 10970 OrganizationAdministration: Ptr("oa"), 10971 OrganizationHooks: Ptr("oh"), 10972 OrganizationPlan: Ptr("op"), 10973 OrganizationPreReceiveHooks: Ptr("opr"), 10974 OrganizationProjects: Ptr("op"), 10975 OrganizationSecrets: Ptr("os"), 10976 OrganizationSelfHostedRunners: Ptr("osh"), 10977 OrganizationUserBlocking: Ptr("oub"), 10978 Packages: Ptr("pkg"), 10979 Pages: Ptr("pg"), 10980 PullRequests: Ptr("pr"), 10981 RepositoryHooks: Ptr("rh"), 10982 RepositoryProjects: Ptr("rp"), 10983 RepositoryPreReceiveHooks: Ptr("rprh"), 10984 Secrets: Ptr("s"), 10985 SecretScanningAlerts: Ptr("ssa"), 10986 SecurityEvents: Ptr("se"), 10987 SingleFile: Ptr("sf"), 10988 Statuses: Ptr("s"), 10989 TeamDiscussions: Ptr("td"), 10990 VulnerabilityAlerts: Ptr("va"), 10991 Workflows: Ptr("w"), 10992 }, 10993 CreatedAt: &Timestamp{referenceTime}, 10994 UpdatedAt: &Timestamp{referenceTime}, 10995 HasMultipleSingleFiles: Ptr(false), 10996 SuspendedBy: &User{ 10997 Login: Ptr("l"), 10998 ID: Ptr(int64(1)), 10999 URL: Ptr("u"), 11000 AvatarURL: Ptr("a"), 11001 GravatarID: Ptr("g"), 11002 Name: Ptr("n"), 11003 Company: Ptr("c"), 11004 Blog: Ptr("b"), 11005 Location: Ptr("l"), 11006 Email: Ptr("e"), 11007 Hireable: Ptr(true), 11008 Bio: Ptr("b"), 11009 TwitterUsername: Ptr("t"), 11010 PublicRepos: Ptr(1), 11011 Followers: Ptr(1), 11012 Following: Ptr(1), 11013 CreatedAt: &Timestamp{referenceTime}, 11014 SuspendedAt: &Timestamp{referenceTime}, 11015 }, 11016 SuspendedAt: &Timestamp{referenceTime}, 11017 }, 11018 } 11019 11020 want := `{ 11021 "action": "a", 11022 "reason": "r", 11023 "merge_group": { 11024 "head_sha": "hs", 11025 "head_ref": "hr", 11026 "base_sha": "bs", 11027 "base_ref": "br", 11028 "head_commit": { 11029 "node_id": "nid" 11030 } 11031 }, 11032 "repository": { 11033 "id": 1, 11034 "name": "n", 11035 "url": "s" 11036 }, 11037 "organization": { 11038 "name": "n", 11039 "company": "c", 11040 "blog": "b", 11041 "location": "loc", 11042 "email": "e", 11043 "twitter_username": "tu", 11044 "description": "d", 11045 "billing_email": "be", 11046 "is_verified": true, 11047 "has_organization_projects": true, 11048 "has_repository_projects": true, 11049 "default_repository_permission": "drp", 11050 "members_can_create_repositories": true, 11051 "members_can_create_public_repositories": false, 11052 "members_can_create_private_repositories": true, 11053 "members_can_create_internal_repositories": true, 11054 "members_allowed_repository_creation_type": "marct", 11055 "members_can_create_pages": true, 11056 "members_can_create_public_pages": false, 11057 "members_can_create_private_pages": true 11058 }, 11059 "sender": { 11060 "login": "l", 11061 "id": 1, 11062 "node_id": "n", 11063 "avatar_url": "a", 11064 "url": "u", 11065 "events_url": "e", 11066 "repos_url": "r" 11067 }, 11068 "installation": { 11069 "id": 1, 11070 "node_id": "nid", 11071 "app_id": 1, 11072 "app_slug": "as", 11073 "target_id": 1, 11074 "account": { 11075 "login": "l", 11076 "id": 1, 11077 "avatar_url": "a", 11078 "gravatar_id": "g", 11079 "name": "n", 11080 "company": "c", 11081 "blog": "b", 11082 "location": "l", 11083 "email": "e", 11084 "hireable": true, 11085 "bio": "b", 11086 "twitter_username": "t", 11087 "public_repos": 1, 11088 "followers": 1, 11089 "following": 1, 11090 "created_at": ` + referenceTimeStr + `, 11091 "suspended_at": ` + referenceTimeStr + `, 11092 "url": "u" 11093 }, 11094 "access_tokens_url": "atu", 11095 "repositories_url": "ru", 11096 "html_url": "hu", 11097 "target_type": "tt", 11098 "single_file_name": "sfn", 11099 "repository_selection": "rs", 11100 "events": [ 11101 "e" 11102 ], 11103 "single_file_paths": [ 11104 "s" 11105 ], 11106 "permissions": { 11107 "actions": "a", 11108 "administration": "ad", 11109 "checks": "c", 11110 "contents": "co", 11111 "content_references": "cr", 11112 "deployments": "d", 11113 "environments": "e", 11114 "issues": "i", 11115 "metadata": "md", 11116 "members": "m", 11117 "organization_administration": "oa", 11118 "organization_hooks": "oh", 11119 "organization_plan": "op", 11120 "organization_pre_receive_hooks": "opr", 11121 "organization_projects": "op", 11122 "organization_secrets": "os", 11123 "organization_self_hosted_runners": "osh", 11124 "organization_user_blocking": "oub", 11125 "packages": "pkg", 11126 "pages": "pg", 11127 "pull_requests": "pr", 11128 "repository_hooks": "rh", 11129 "repository_projects": "rp", 11130 "repository_pre_receive_hooks": "rprh", 11131 "secrets": "s", 11132 "secret_scanning_alerts": "ssa", 11133 "security_events": "se", 11134 "single_file": "sf", 11135 "statuses": "s", 11136 "team_discussions": "td", 11137 "vulnerability_alerts": "va", 11138 "workflows": "w" 11139 }, 11140 "created_at": ` + referenceTimeStr + `, 11141 "updated_at": ` + referenceTimeStr + `, 11142 "has_multiple_single_files": false, 11143 "suspended_by": { 11144 "login": "l", 11145 "id": 1, 11146 "avatar_url": "a", 11147 "gravatar_id": "g", 11148 "name": "n", 11149 "company": "c", 11150 "blog": "b", 11151 "location": "l", 11152 "email": "e", 11153 "hireable": true, 11154 "bio": "b", 11155 "twitter_username": "t", 11156 "public_repos": 1, 11157 "followers": 1, 11158 "following": 1, 11159 "created_at": ` + referenceTimeStr + `, 11160 "suspended_at": ` + referenceTimeStr + `, 11161 "url": "u" 11162 }, 11163 "suspended_at": ` + referenceTimeStr + ` 11164 } 11165 }` 11166 11167 testJSONMarshal(t, u, want) 11168 } 11169 11170 func TestOrgBlockEvent_Marshal(t *testing.T) { 11171 t.Parallel() 11172 testJSONMarshal(t, &OrgBlockEvent{}, "{}") 11173 11174 u := &OrgBlockEvent{ 11175 Action: Ptr("a"), 11176 BlockedUser: &User{ 11177 Login: Ptr("l"), 11178 ID: Ptr(int64(1)), 11179 NodeID: Ptr("n"), 11180 URL: Ptr("u"), 11181 ReposURL: Ptr("r"), 11182 EventsURL: Ptr("e"), 11183 AvatarURL: Ptr("a"), 11184 }, 11185 Organization: &Organization{ 11186 BillingEmail: Ptr("be"), 11187 Blog: Ptr("b"), 11188 Company: Ptr("c"), 11189 Email: Ptr("e"), 11190 TwitterUsername: Ptr("tu"), 11191 Location: Ptr("loc"), 11192 Name: Ptr("n"), 11193 Description: Ptr("d"), 11194 IsVerified: Ptr(true), 11195 HasOrganizationProjects: Ptr(true), 11196 HasRepositoryProjects: Ptr(true), 11197 DefaultRepoPermission: Ptr("drp"), 11198 MembersCanCreateRepos: Ptr(true), 11199 MembersCanCreateInternalRepos: Ptr(true), 11200 MembersCanCreatePrivateRepos: Ptr(true), 11201 MembersCanCreatePublicRepos: Ptr(false), 11202 MembersAllowedRepositoryCreationType: Ptr("marct"), 11203 MembersCanCreatePages: Ptr(true), 11204 MembersCanCreatePublicPages: Ptr(false), 11205 MembersCanCreatePrivatePages: Ptr(true), 11206 }, 11207 Sender: &User{ 11208 Login: Ptr("l"), 11209 ID: Ptr(int64(1)), 11210 NodeID: Ptr("n"), 11211 URL: Ptr("u"), 11212 ReposURL: Ptr("r"), 11213 EventsURL: Ptr("e"), 11214 AvatarURL: Ptr("a"), 11215 }, 11216 Installation: &Installation{ 11217 ID: Ptr(int64(1)), 11218 NodeID: Ptr("nid"), 11219 AppID: Ptr(int64(1)), 11220 AppSlug: Ptr("as"), 11221 TargetID: Ptr(int64(1)), 11222 Account: &User{ 11223 Login: Ptr("l"), 11224 ID: Ptr(int64(1)), 11225 URL: Ptr("u"), 11226 AvatarURL: Ptr("a"), 11227 GravatarID: Ptr("g"), 11228 Name: Ptr("n"), 11229 Company: Ptr("c"), 11230 Blog: Ptr("b"), 11231 Location: Ptr("l"), 11232 Email: Ptr("e"), 11233 Hireable: Ptr(true), 11234 Bio: Ptr("b"), 11235 TwitterUsername: Ptr("t"), 11236 PublicRepos: Ptr(1), 11237 Followers: Ptr(1), 11238 Following: Ptr(1), 11239 CreatedAt: &Timestamp{referenceTime}, 11240 SuspendedAt: &Timestamp{referenceTime}, 11241 }, 11242 AccessTokensURL: Ptr("atu"), 11243 RepositoriesURL: Ptr("ru"), 11244 HTMLURL: Ptr("hu"), 11245 TargetType: Ptr("tt"), 11246 SingleFileName: Ptr("sfn"), 11247 RepositorySelection: Ptr("rs"), 11248 Events: []string{"e"}, 11249 SingleFilePaths: []string{"s"}, 11250 Permissions: &InstallationPermissions{ 11251 Actions: Ptr("a"), 11252 Administration: Ptr("ad"), 11253 Checks: Ptr("c"), 11254 Contents: Ptr("co"), 11255 ContentReferences: Ptr("cr"), 11256 Deployments: Ptr("d"), 11257 Environments: Ptr("e"), 11258 Issues: Ptr("i"), 11259 Metadata: Ptr("md"), 11260 Members: Ptr("m"), 11261 OrganizationAdministration: Ptr("oa"), 11262 OrganizationHooks: Ptr("oh"), 11263 OrganizationPlan: Ptr("op"), 11264 OrganizationPreReceiveHooks: Ptr("opr"), 11265 OrganizationProjects: Ptr("op"), 11266 OrganizationSecrets: Ptr("os"), 11267 OrganizationSelfHostedRunners: Ptr("osh"), 11268 OrganizationUserBlocking: Ptr("oub"), 11269 Packages: Ptr("pkg"), 11270 Pages: Ptr("pg"), 11271 PullRequests: Ptr("pr"), 11272 RepositoryHooks: Ptr("rh"), 11273 RepositoryProjects: Ptr("rp"), 11274 RepositoryPreReceiveHooks: Ptr("rprh"), 11275 Secrets: Ptr("s"), 11276 SecretScanningAlerts: Ptr("ssa"), 11277 SecurityEvents: Ptr("se"), 11278 SingleFile: Ptr("sf"), 11279 Statuses: Ptr("s"), 11280 TeamDiscussions: Ptr("td"), 11281 VulnerabilityAlerts: Ptr("va"), 11282 Workflows: Ptr("w"), 11283 }, 11284 CreatedAt: &Timestamp{referenceTime}, 11285 UpdatedAt: &Timestamp{referenceTime}, 11286 HasMultipleSingleFiles: Ptr(false), 11287 SuspendedBy: &User{ 11288 Login: Ptr("l"), 11289 ID: Ptr(int64(1)), 11290 URL: Ptr("u"), 11291 AvatarURL: Ptr("a"), 11292 GravatarID: Ptr("g"), 11293 Name: Ptr("n"), 11294 Company: Ptr("c"), 11295 Blog: Ptr("b"), 11296 Location: Ptr("l"), 11297 Email: Ptr("e"), 11298 Hireable: Ptr(true), 11299 Bio: Ptr("b"), 11300 TwitterUsername: Ptr("t"), 11301 PublicRepos: Ptr(1), 11302 Followers: Ptr(1), 11303 Following: Ptr(1), 11304 CreatedAt: &Timestamp{referenceTime}, 11305 SuspendedAt: &Timestamp{referenceTime}, 11306 }, 11307 SuspendedAt: &Timestamp{referenceTime}, 11308 }, 11309 } 11310 11311 want := `{ 11312 "action": "a", 11313 "blocked_user": { 11314 "login": "l", 11315 "id": 1, 11316 "node_id": "n", 11317 "avatar_url": "a", 11318 "url": "u", 11319 "events_url": "e", 11320 "repos_url": "r" 11321 }, 11322 "organization": { 11323 "name": "n", 11324 "company": "c", 11325 "blog": "b", 11326 "location": "loc", 11327 "email": "e", 11328 "twitter_username": "tu", 11329 "description": "d", 11330 "billing_email": "be", 11331 "is_verified": true, 11332 "has_organization_projects": true, 11333 "has_repository_projects": true, 11334 "default_repository_permission": "drp", 11335 "members_can_create_repositories": true, 11336 "members_can_create_public_repositories": false, 11337 "members_can_create_private_repositories": true, 11338 "members_can_create_internal_repositories": true, 11339 "members_allowed_repository_creation_type": "marct", 11340 "members_can_create_pages": true, 11341 "members_can_create_public_pages": false, 11342 "members_can_create_private_pages": true 11343 }, 11344 "sender": { 11345 "login": "l", 11346 "id": 1, 11347 "node_id": "n", 11348 "avatar_url": "a", 11349 "url": "u", 11350 "events_url": "e", 11351 "repos_url": "r" 11352 }, 11353 "installation": { 11354 "id": 1, 11355 "node_id": "nid", 11356 "app_id": 1, 11357 "app_slug": "as", 11358 "target_id": 1, 11359 "account": { 11360 "login": "l", 11361 "id": 1, 11362 "avatar_url": "a", 11363 "gravatar_id": "g", 11364 "name": "n", 11365 "company": "c", 11366 "blog": "b", 11367 "location": "l", 11368 "email": "e", 11369 "hireable": true, 11370 "bio": "b", 11371 "twitter_username": "t", 11372 "public_repos": 1, 11373 "followers": 1, 11374 "following": 1, 11375 "created_at": ` + referenceTimeStr + `, 11376 "suspended_at": ` + referenceTimeStr + `, 11377 "url": "u" 11378 }, 11379 "access_tokens_url": "atu", 11380 "repositories_url": "ru", 11381 "html_url": "hu", 11382 "target_type": "tt", 11383 "single_file_name": "sfn", 11384 "repository_selection": "rs", 11385 "events": [ 11386 "e" 11387 ], 11388 "single_file_paths": [ 11389 "s" 11390 ], 11391 "permissions": { 11392 "actions": "a", 11393 "administration": "ad", 11394 "checks": "c", 11395 "contents": "co", 11396 "content_references": "cr", 11397 "deployments": "d", 11398 "environments": "e", 11399 "issues": "i", 11400 "metadata": "md", 11401 "members": "m", 11402 "organization_administration": "oa", 11403 "organization_hooks": "oh", 11404 "organization_plan": "op", 11405 "organization_pre_receive_hooks": "opr", 11406 "organization_projects": "op", 11407 "organization_secrets": "os", 11408 "organization_self_hosted_runners": "osh", 11409 "organization_user_blocking": "oub", 11410 "packages": "pkg", 11411 "pages": "pg", 11412 "pull_requests": "pr", 11413 "repository_hooks": "rh", 11414 "repository_projects": "rp", 11415 "repository_pre_receive_hooks": "rprh", 11416 "secrets": "s", 11417 "secret_scanning_alerts": "ssa", 11418 "security_events": "se", 11419 "single_file": "sf", 11420 "statuses": "s", 11421 "team_discussions": "td", 11422 "vulnerability_alerts": "va", 11423 "workflows": "w" 11424 }, 11425 "created_at": ` + referenceTimeStr + `, 11426 "updated_at": ` + referenceTimeStr + `, 11427 "has_multiple_single_files": false, 11428 "suspended_by": { 11429 "login": "l", 11430 "id": 1, 11431 "avatar_url": "a", 11432 "gravatar_id": "g", 11433 "name": "n", 11434 "company": "c", 11435 "blog": "b", 11436 "location": "l", 11437 "email": "e", 11438 "hireable": true, 11439 "bio": "b", 11440 "twitter_username": "t", 11441 "public_repos": 1, 11442 "followers": 1, 11443 "following": 1, 11444 "created_at": ` + referenceTimeStr + `, 11445 "suspended_at": ` + referenceTimeStr + `, 11446 "url": "u" 11447 }, 11448 "suspended_at": ` + referenceTimeStr + ` 11449 } 11450 }` 11451 11452 testJSONMarshal(t, u, want) 11453 } 11454 11455 func TestGollumEvent_Marshal(t *testing.T) { 11456 t.Parallel() 11457 testJSONMarshal(t, &GollumEvent{}, "{}") 11458 11459 u := &GollumEvent{ 11460 Pages: []*Page{ 11461 { 11462 PageName: Ptr("pn"), 11463 Title: Ptr("t"), 11464 Summary: Ptr("s"), 11465 Action: Ptr("a"), 11466 SHA: Ptr("sha"), 11467 HTMLURL: Ptr("hu"), 11468 }, 11469 }, 11470 Repo: &Repository{ 11471 ID: Ptr(int64(1)), 11472 URL: Ptr("s"), 11473 Name: Ptr("n"), 11474 }, 11475 Sender: &User{ 11476 Login: Ptr("l"), 11477 ID: Ptr(int64(1)), 11478 NodeID: Ptr("n"), 11479 URL: Ptr("u"), 11480 ReposURL: Ptr("r"), 11481 EventsURL: Ptr("e"), 11482 AvatarURL: Ptr("a"), 11483 }, 11484 Installation: &Installation{ 11485 ID: Ptr(int64(1)), 11486 NodeID: Ptr("nid"), 11487 AppID: Ptr(int64(1)), 11488 AppSlug: Ptr("as"), 11489 TargetID: Ptr(int64(1)), 11490 Account: &User{ 11491 Login: Ptr("l"), 11492 ID: Ptr(int64(1)), 11493 URL: Ptr("u"), 11494 AvatarURL: Ptr("a"), 11495 GravatarID: Ptr("g"), 11496 Name: Ptr("n"), 11497 Company: Ptr("c"), 11498 Blog: Ptr("b"), 11499 Location: Ptr("l"), 11500 Email: Ptr("e"), 11501 Hireable: Ptr(true), 11502 Bio: Ptr("b"), 11503 TwitterUsername: Ptr("t"), 11504 PublicRepos: Ptr(1), 11505 Followers: Ptr(1), 11506 Following: Ptr(1), 11507 CreatedAt: &Timestamp{referenceTime}, 11508 SuspendedAt: &Timestamp{referenceTime}, 11509 }, 11510 AccessTokensURL: Ptr("atu"), 11511 RepositoriesURL: Ptr("ru"), 11512 HTMLURL: Ptr("hu"), 11513 TargetType: Ptr("tt"), 11514 SingleFileName: Ptr("sfn"), 11515 RepositorySelection: Ptr("rs"), 11516 Events: []string{"e"}, 11517 SingleFilePaths: []string{"s"}, 11518 Permissions: &InstallationPermissions{ 11519 Actions: Ptr("a"), 11520 Administration: Ptr("ad"), 11521 Checks: Ptr("c"), 11522 Contents: Ptr("co"), 11523 ContentReferences: Ptr("cr"), 11524 Deployments: Ptr("d"), 11525 Environments: Ptr("e"), 11526 Issues: Ptr("i"), 11527 Metadata: Ptr("md"), 11528 Members: Ptr("m"), 11529 OrganizationAdministration: Ptr("oa"), 11530 OrganizationHooks: Ptr("oh"), 11531 OrganizationPlan: Ptr("op"), 11532 OrganizationPreReceiveHooks: Ptr("opr"), 11533 OrganizationProjects: Ptr("op"), 11534 OrganizationSecrets: Ptr("os"), 11535 OrganizationSelfHostedRunners: Ptr("osh"), 11536 OrganizationUserBlocking: Ptr("oub"), 11537 Packages: Ptr("pkg"), 11538 Pages: Ptr("pg"), 11539 PullRequests: Ptr("pr"), 11540 RepositoryHooks: Ptr("rh"), 11541 RepositoryProjects: Ptr("rp"), 11542 RepositoryPreReceiveHooks: Ptr("rprh"), 11543 Secrets: Ptr("s"), 11544 SecretScanningAlerts: Ptr("ssa"), 11545 SecurityEvents: Ptr("se"), 11546 SingleFile: Ptr("sf"), 11547 Statuses: Ptr("s"), 11548 TeamDiscussions: Ptr("td"), 11549 VulnerabilityAlerts: Ptr("va"), 11550 Workflows: Ptr("w"), 11551 }, 11552 CreatedAt: &Timestamp{referenceTime}, 11553 UpdatedAt: &Timestamp{referenceTime}, 11554 HasMultipleSingleFiles: Ptr(false), 11555 SuspendedBy: &User{ 11556 Login: Ptr("l"), 11557 ID: Ptr(int64(1)), 11558 URL: Ptr("u"), 11559 AvatarURL: Ptr("a"), 11560 GravatarID: Ptr("g"), 11561 Name: Ptr("n"), 11562 Company: Ptr("c"), 11563 Blog: Ptr("b"), 11564 Location: Ptr("l"), 11565 Email: Ptr("e"), 11566 Hireable: Ptr(true), 11567 Bio: Ptr("b"), 11568 TwitterUsername: Ptr("t"), 11569 PublicRepos: Ptr(1), 11570 Followers: Ptr(1), 11571 Following: Ptr(1), 11572 CreatedAt: &Timestamp{referenceTime}, 11573 SuspendedAt: &Timestamp{referenceTime}, 11574 }, 11575 SuspendedAt: &Timestamp{referenceTime}, 11576 }, 11577 } 11578 11579 want := `{ 11580 "pages": [ 11581 { 11582 "page_name": "pn", 11583 "title": "t", 11584 "summary": "s", 11585 "action": "a", 11586 "sha": "sha", 11587 "html_url": "hu" 11588 } 11589 ], 11590 "repository": { 11591 "id": 1, 11592 "name": "n", 11593 "url": "s" 11594 }, 11595 "sender": { 11596 "login": "l", 11597 "id": 1, 11598 "node_id": "n", 11599 "avatar_url": "a", 11600 "url": "u", 11601 "events_url": "e", 11602 "repos_url": "r" 11603 }, 11604 "installation": { 11605 "id": 1, 11606 "node_id": "nid", 11607 "app_id": 1, 11608 "app_slug": "as", 11609 "target_id": 1, 11610 "account": { 11611 "login": "l", 11612 "id": 1, 11613 "avatar_url": "a", 11614 "gravatar_id": "g", 11615 "name": "n", 11616 "company": "c", 11617 "blog": "b", 11618 "location": "l", 11619 "email": "e", 11620 "hireable": true, 11621 "bio": "b", 11622 "twitter_username": "t", 11623 "public_repos": 1, 11624 "followers": 1, 11625 "following": 1, 11626 "created_at": ` + referenceTimeStr + `, 11627 "suspended_at": ` + referenceTimeStr + `, 11628 "url": "u" 11629 }, 11630 "access_tokens_url": "atu", 11631 "repositories_url": "ru", 11632 "html_url": "hu", 11633 "target_type": "tt", 11634 "single_file_name": "sfn", 11635 "repository_selection": "rs", 11636 "events": [ 11637 "e" 11638 ], 11639 "single_file_paths": [ 11640 "s" 11641 ], 11642 "permissions": { 11643 "actions": "a", 11644 "administration": "ad", 11645 "checks": "c", 11646 "contents": "co", 11647 "content_references": "cr", 11648 "deployments": "d", 11649 "environments": "e", 11650 "issues": "i", 11651 "metadata": "md", 11652 "members": "m", 11653 "organization_administration": "oa", 11654 "organization_hooks": "oh", 11655 "organization_plan": "op", 11656 "organization_pre_receive_hooks": "opr", 11657 "organization_projects": "op", 11658 "organization_secrets": "os", 11659 "organization_self_hosted_runners": "osh", 11660 "organization_user_blocking": "oub", 11661 "packages": "pkg", 11662 "pages": "pg", 11663 "pull_requests": "pr", 11664 "repository_hooks": "rh", 11665 "repository_projects": "rp", 11666 "repository_pre_receive_hooks": "rprh", 11667 "secrets": "s", 11668 "secret_scanning_alerts": "ssa", 11669 "security_events": "se", 11670 "single_file": "sf", 11671 "statuses": "s", 11672 "team_discussions": "td", 11673 "vulnerability_alerts": "va", 11674 "workflows": "w" 11675 }, 11676 "created_at": ` + referenceTimeStr + `, 11677 "updated_at": ` + referenceTimeStr + `, 11678 "has_multiple_single_files": false, 11679 "suspended_by": { 11680 "login": "l", 11681 "id": 1, 11682 "avatar_url": "a", 11683 "gravatar_id": "g", 11684 "name": "n", 11685 "company": "c", 11686 "blog": "b", 11687 "location": "l", 11688 "email": "e", 11689 "hireable": true, 11690 "bio": "b", 11691 "twitter_username": "t", 11692 "public_repos": 1, 11693 "followers": 1, 11694 "following": 1, 11695 "created_at": ` + referenceTimeStr + `, 11696 "suspended_at": ` + referenceTimeStr + `, 11697 "url": "u" 11698 }, 11699 "suspended_at": ` + referenceTimeStr + ` 11700 } 11701 }` 11702 11703 testJSONMarshal(t, u, want) 11704 } 11705 11706 func TestWorkflowRunEvent_Marshal(t *testing.T) { 11707 t.Parallel() 11708 testJSONMarshal(t, &WorkflowRunEvent{}, "{}") 11709 11710 u := &WorkflowRunEvent{ 11711 Action: Ptr("a"), 11712 Workflow: &Workflow{ 11713 ID: Ptr(int64(1)), 11714 NodeID: Ptr("nid"), 11715 Name: Ptr("n"), 11716 Path: Ptr("p"), 11717 State: Ptr("s"), 11718 CreatedAt: &Timestamp{referenceTime}, 11719 UpdatedAt: &Timestamp{referenceTime}, 11720 URL: Ptr("u"), 11721 HTMLURL: Ptr("h"), 11722 BadgeURL: Ptr("b"), 11723 }, 11724 WorkflowRun: &WorkflowRun{ 11725 ID: Ptr(int64(1)), 11726 Name: Ptr("n"), 11727 NodeID: Ptr("nid"), 11728 HeadBranch: Ptr("hb"), 11729 HeadSHA: Ptr("hs"), 11730 RunNumber: Ptr(1), 11731 RunAttempt: Ptr(1), 11732 Event: Ptr("e"), 11733 Status: Ptr("s"), 11734 Conclusion: Ptr("c"), 11735 WorkflowID: Ptr(int64(1)), 11736 URL: Ptr("u"), 11737 HTMLURL: Ptr("h"), 11738 PullRequests: []*PullRequest{ 11739 { 11740 URL: Ptr("u"), 11741 ID: Ptr(int64(1)), 11742 Number: Ptr(1), 11743 Head: &PullRequestBranch{ 11744 Ref: Ptr("r"), 11745 SHA: Ptr("s"), 11746 Repo: &Repository{ 11747 ID: Ptr(int64(1)), 11748 URL: Ptr("s"), 11749 Name: Ptr("n"), 11750 }, 11751 }, 11752 Base: &PullRequestBranch{ 11753 Ref: Ptr("r"), 11754 SHA: Ptr("s"), 11755 Repo: &Repository{ 11756 ID: Ptr(int64(1)), 11757 URL: Ptr("u"), 11758 Name: Ptr("n"), 11759 }, 11760 }, 11761 }, 11762 }, 11763 CreatedAt: &Timestamp{referenceTime}, 11764 UpdatedAt: &Timestamp{referenceTime}, 11765 RunStartedAt: &Timestamp{referenceTime}, 11766 JobsURL: Ptr("j"), 11767 LogsURL: Ptr("l"), 11768 CheckSuiteURL: Ptr("c"), 11769 ArtifactsURL: Ptr("a"), 11770 CancelURL: Ptr("c"), 11771 RerunURL: Ptr("r"), 11772 PreviousAttemptURL: Ptr("p"), 11773 HeadCommit: &HeadCommit{ 11774 Message: Ptr("m"), 11775 Author: &CommitAuthor{ 11776 Name: Ptr("n"), 11777 Email: Ptr("e"), 11778 Login: Ptr("l"), 11779 }, 11780 URL: Ptr("u"), 11781 Distinct: Ptr(false), 11782 SHA: Ptr("s"), 11783 ID: Ptr("i"), 11784 TreeID: Ptr("tid"), 11785 Timestamp: &Timestamp{referenceTime}, 11786 Committer: &CommitAuthor{ 11787 Name: Ptr("n"), 11788 Email: Ptr("e"), 11789 Login: Ptr("l"), 11790 }, 11791 }, 11792 WorkflowURL: Ptr("w"), 11793 Repository: &Repository{ 11794 ID: Ptr(int64(1)), 11795 URL: Ptr("u"), 11796 Name: Ptr("n"), 11797 }, 11798 HeadRepository: &Repository{ 11799 ID: Ptr(int64(1)), 11800 URL: Ptr("u"), 11801 Name: Ptr("n"), 11802 }, 11803 }, 11804 Org: &Organization{ 11805 BillingEmail: Ptr("be"), 11806 Blog: Ptr("b"), 11807 Company: Ptr("c"), 11808 Email: Ptr("e"), 11809 TwitterUsername: Ptr("tu"), 11810 Location: Ptr("loc"), 11811 Name: Ptr("n"), 11812 Description: Ptr("d"), 11813 IsVerified: Ptr(true), 11814 HasOrganizationProjects: Ptr(true), 11815 HasRepositoryProjects: Ptr(true), 11816 DefaultRepoPermission: Ptr("drp"), 11817 MembersCanCreateRepos: Ptr(true), 11818 MembersCanCreateInternalRepos: Ptr(true), 11819 MembersCanCreatePrivateRepos: Ptr(true), 11820 MembersCanCreatePublicRepos: Ptr(false), 11821 MembersAllowedRepositoryCreationType: Ptr("marct"), 11822 MembersCanCreatePages: Ptr(true), 11823 MembersCanCreatePublicPages: Ptr(false), 11824 MembersCanCreatePrivatePages: Ptr(true), 11825 }, 11826 Repo: &Repository{ 11827 ID: Ptr(int64(1)), 11828 URL: Ptr("s"), 11829 Name: Ptr("n"), 11830 }, 11831 Sender: &User{ 11832 Login: Ptr("l"), 11833 ID: Ptr(int64(1)), 11834 NodeID: Ptr("n"), 11835 URL: Ptr("u"), 11836 ReposURL: Ptr("r"), 11837 EventsURL: Ptr("e"), 11838 AvatarURL: Ptr("a"), 11839 }, 11840 } 11841 11842 want := `{ 11843 "action": "a", 11844 "workflow": { 11845 "id": 1, 11846 "node_id": "nid", 11847 "name": "n", 11848 "path": "p", 11849 "state": "s", 11850 "created_at": ` + referenceTimeStr + `, 11851 "updated_at": ` + referenceTimeStr + `, 11852 "url": "u", 11853 "html_url": "h", 11854 "badge_url": "b" 11855 }, 11856 "workflow_run": { 11857 "id": 1, 11858 "name": "n", 11859 "node_id": "nid", 11860 "head_branch": "hb", 11861 "head_sha": "hs", 11862 "run_number": 1, 11863 "run_attempt": 1, 11864 "event": "e", 11865 "status": "s", 11866 "conclusion": "c", 11867 "workflow_id": 1, 11868 "url": "u", 11869 "html_url": "h", 11870 "pull_requests": [ 11871 { 11872 "id": 1, 11873 "number": 1, 11874 "url": "u", 11875 "head": { 11876 "ref": "r", 11877 "sha": "s", 11878 "repo": { 11879 "id": 1, 11880 "name": "n", 11881 "url": "s" 11882 } 11883 }, 11884 "base": { 11885 "ref": "r", 11886 "sha": "s", 11887 "repo": { 11888 "id": 1, 11889 "name": "n", 11890 "url": "u" 11891 } 11892 } 11893 } 11894 ], 11895 "created_at": ` + referenceTimeStr + `, 11896 "updated_at": ` + referenceTimeStr + `, 11897 "run_started_at": ` + referenceTimeStr + `, 11898 "jobs_url": "j", 11899 "logs_url": "l", 11900 "check_suite_url": "c", 11901 "artifacts_url": "a", 11902 "cancel_url": "c", 11903 "rerun_url": "r", 11904 "previous_attempt_url": "p", 11905 "head_commit": { 11906 "message": "m", 11907 "author": { 11908 "name": "n", 11909 "email": "e", 11910 "username": "l" 11911 }, 11912 "url": "u", 11913 "distinct": false, 11914 "sha": "s", 11915 "id": "i", 11916 "tree_id": "tid", 11917 "timestamp": ` + referenceTimeStr + `, 11918 "committer": { 11919 "name": "n", 11920 "email": "e", 11921 "username": "l" 11922 } 11923 }, 11924 "workflow_url": "w", 11925 "repository": { 11926 "id": 1, 11927 "name": "n", 11928 "url": "u" 11929 }, 11930 "head_repository": { 11931 "id": 1, 11932 "name": "n", 11933 "url": "u" 11934 } 11935 }, 11936 "organization": { 11937 "name": "n", 11938 "company": "c", 11939 "blog": "b", 11940 "location": "loc", 11941 "email": "e", 11942 "twitter_username": "tu", 11943 "description": "d", 11944 "billing_email": "be", 11945 "is_verified": true, 11946 "has_organization_projects": true, 11947 "has_repository_projects": true, 11948 "default_repository_permission": "drp", 11949 "members_can_create_repositories": true, 11950 "members_can_create_public_repositories": false, 11951 "members_can_create_private_repositories": true, 11952 "members_can_create_internal_repositories": true, 11953 "members_allowed_repository_creation_type": "marct", 11954 "members_can_create_pages": true, 11955 "members_can_create_public_pages": false, 11956 "members_can_create_private_pages": true 11957 }, 11958 "repository": { 11959 "id": 1, 11960 "name": "n", 11961 "url": "s" 11962 }, 11963 "sender": { 11964 "login": "l", 11965 "id": 1, 11966 "node_id": "n", 11967 "avatar_url": "a", 11968 "url": "u", 11969 "events_url": "e", 11970 "repos_url": "r" 11971 } 11972 }` 11973 11974 testJSONMarshal(t, u, want) 11975 } 11976 11977 func TestWorkflowDispatchEvent_Marshal(t *testing.T) { 11978 t.Parallel() 11979 testJSONMarshal(t, &WorkflowDispatchEvent{}, "{}") 11980 11981 i := make(map[string]any) 11982 i["key"] = "value" 11983 11984 jsonMsg, _ := json.Marshal(i) 11985 u := &WorkflowDispatchEvent{ 11986 Inputs: jsonMsg, 11987 Ref: Ptr("r"), 11988 Workflow: Ptr("w"), 11989 Repo: &Repository{ 11990 ID: Ptr(int64(1)), 11991 URL: Ptr("s"), 11992 Name: Ptr("n"), 11993 }, 11994 Org: &Organization{ 11995 BillingEmail: Ptr("be"), 11996 Blog: Ptr("b"), 11997 Company: Ptr("c"), 11998 Email: Ptr("e"), 11999 TwitterUsername: Ptr("tu"), 12000 Location: Ptr("loc"), 12001 Name: Ptr("n"), 12002 Description: Ptr("d"), 12003 IsVerified: Ptr(true), 12004 HasOrganizationProjects: Ptr(true), 12005 HasRepositoryProjects: Ptr(true), 12006 DefaultRepoPermission: Ptr("drp"), 12007 MembersCanCreateRepos: Ptr(true), 12008 MembersCanCreateInternalRepos: Ptr(true), 12009 MembersCanCreatePrivateRepos: Ptr(true), 12010 MembersCanCreatePublicRepos: Ptr(false), 12011 MembersAllowedRepositoryCreationType: Ptr("marct"), 12012 MembersCanCreatePages: Ptr(true), 12013 MembersCanCreatePublicPages: Ptr(false), 12014 MembersCanCreatePrivatePages: Ptr(true), 12015 }, 12016 Sender: &User{ 12017 Login: Ptr("l"), 12018 ID: Ptr(int64(1)), 12019 NodeID: Ptr("n"), 12020 URL: Ptr("u"), 12021 ReposURL: Ptr("r"), 12022 EventsURL: Ptr("e"), 12023 AvatarURL: Ptr("a"), 12024 }, 12025 } 12026 12027 want := `{ 12028 "inputs": { 12029 "key": "value" 12030 }, 12031 "ref": "r", 12032 "workflow": "w", 12033 "repository": { 12034 "id": 1, 12035 "name": "n", 12036 "url": "s" 12037 }, 12038 "organization": { 12039 "name": "n", 12040 "company": "c", 12041 "blog": "b", 12042 "location": "loc", 12043 "email": "e", 12044 "twitter_username": "tu", 12045 "description": "d", 12046 "billing_email": "be", 12047 "is_verified": true, 12048 "has_organization_projects": true, 12049 "has_repository_projects": true, 12050 "default_repository_permission": "drp", 12051 "members_can_create_repositories": true, 12052 "members_can_create_public_repositories": false, 12053 "members_can_create_private_repositories": true, 12054 "members_can_create_internal_repositories": true, 12055 "members_allowed_repository_creation_type": "marct", 12056 "members_can_create_pages": true, 12057 "members_can_create_public_pages": false, 12058 "members_can_create_private_pages": true 12059 }, 12060 "sender": { 12061 "login": "l", 12062 "id": 1, 12063 "node_id": "n", 12064 "avatar_url": "a", 12065 "url": "u", 12066 "events_url": "e", 12067 "repos_url": "r" 12068 } 12069 }` 12070 12071 testJSONMarshal(t, u, want) 12072 } 12073 12074 func TestWatchEvent_Marshal(t *testing.T) { 12075 t.Parallel() 12076 testJSONMarshal(t, &WatchEvent{}, "{}") 12077 12078 u := &WatchEvent{ 12079 Action: Ptr("a"), 12080 Repo: &Repository{ 12081 ID: Ptr(int64(1)), 12082 URL: Ptr("s"), 12083 Name: Ptr("n"), 12084 }, 12085 Sender: &User{ 12086 Login: Ptr("l"), 12087 ID: Ptr(int64(1)), 12088 NodeID: Ptr("n"), 12089 URL: Ptr("u"), 12090 ReposURL: Ptr("r"), 12091 EventsURL: Ptr("e"), 12092 AvatarURL: Ptr("a"), 12093 }, 12094 Installation: &Installation{ 12095 ID: Ptr(int64(1)), 12096 NodeID: Ptr("nid"), 12097 AppID: Ptr(int64(1)), 12098 AppSlug: Ptr("as"), 12099 TargetID: Ptr(int64(1)), 12100 Account: &User{ 12101 Login: Ptr("l"), 12102 ID: Ptr(int64(1)), 12103 URL: Ptr("u"), 12104 AvatarURL: Ptr("a"), 12105 GravatarID: Ptr("g"), 12106 Name: Ptr("n"), 12107 Company: Ptr("c"), 12108 Blog: Ptr("b"), 12109 Location: Ptr("l"), 12110 Email: Ptr("e"), 12111 Hireable: Ptr(true), 12112 Bio: Ptr("b"), 12113 TwitterUsername: Ptr("t"), 12114 PublicRepos: Ptr(1), 12115 Followers: Ptr(1), 12116 Following: Ptr(1), 12117 CreatedAt: &Timestamp{referenceTime}, 12118 SuspendedAt: &Timestamp{referenceTime}, 12119 }, 12120 AccessTokensURL: Ptr("atu"), 12121 RepositoriesURL: Ptr("ru"), 12122 HTMLURL: Ptr("hu"), 12123 TargetType: Ptr("tt"), 12124 SingleFileName: Ptr("sfn"), 12125 RepositorySelection: Ptr("rs"), 12126 Events: []string{"e"}, 12127 SingleFilePaths: []string{"s"}, 12128 Permissions: &InstallationPermissions{ 12129 Actions: Ptr("a"), 12130 Administration: Ptr("ad"), 12131 Checks: Ptr("c"), 12132 Contents: Ptr("co"), 12133 ContentReferences: Ptr("cr"), 12134 Deployments: Ptr("d"), 12135 Environments: Ptr("e"), 12136 Issues: Ptr("i"), 12137 Metadata: Ptr("md"), 12138 Members: Ptr("m"), 12139 OrganizationAdministration: Ptr("oa"), 12140 OrganizationHooks: Ptr("oh"), 12141 OrganizationPlan: Ptr("op"), 12142 OrganizationPreReceiveHooks: Ptr("opr"), 12143 OrganizationProjects: Ptr("op"), 12144 OrganizationSecrets: Ptr("os"), 12145 OrganizationSelfHostedRunners: Ptr("osh"), 12146 OrganizationUserBlocking: Ptr("oub"), 12147 Packages: Ptr("pkg"), 12148 Pages: Ptr("pg"), 12149 PullRequests: Ptr("pr"), 12150 RepositoryHooks: Ptr("rh"), 12151 RepositoryProjects: Ptr("rp"), 12152 RepositoryPreReceiveHooks: Ptr("rprh"), 12153 Secrets: Ptr("s"), 12154 SecretScanningAlerts: Ptr("ssa"), 12155 SecurityEvents: Ptr("se"), 12156 SingleFile: Ptr("sf"), 12157 Statuses: Ptr("s"), 12158 TeamDiscussions: Ptr("td"), 12159 VulnerabilityAlerts: Ptr("va"), 12160 Workflows: Ptr("w"), 12161 }, 12162 CreatedAt: &Timestamp{referenceTime}, 12163 UpdatedAt: &Timestamp{referenceTime}, 12164 HasMultipleSingleFiles: Ptr(false), 12165 SuspendedBy: &User{ 12166 Login: Ptr("l"), 12167 ID: Ptr(int64(1)), 12168 URL: Ptr("u"), 12169 AvatarURL: Ptr("a"), 12170 GravatarID: Ptr("g"), 12171 Name: Ptr("n"), 12172 Company: Ptr("c"), 12173 Blog: Ptr("b"), 12174 Location: Ptr("l"), 12175 Email: Ptr("e"), 12176 Hireable: Ptr(true), 12177 Bio: Ptr("b"), 12178 TwitterUsername: Ptr("t"), 12179 PublicRepos: Ptr(1), 12180 Followers: Ptr(1), 12181 Following: Ptr(1), 12182 CreatedAt: &Timestamp{referenceTime}, 12183 SuspendedAt: &Timestamp{referenceTime}, 12184 }, 12185 SuspendedAt: &Timestamp{referenceTime}, 12186 }, 12187 } 12188 12189 want := `{ 12190 "action": "a", 12191 "repository": { 12192 "id": 1, 12193 "name": "n", 12194 "url": "s" 12195 }, 12196 "sender": { 12197 "login": "l", 12198 "id": 1, 12199 "node_id": "n", 12200 "avatar_url": "a", 12201 "url": "u", 12202 "events_url": "e", 12203 "repos_url": "r" 12204 }, 12205 "installation": { 12206 "id": 1, 12207 "node_id": "nid", 12208 "app_id": 1, 12209 "app_slug": "as", 12210 "target_id": 1, 12211 "account": { 12212 "login": "l", 12213 "id": 1, 12214 "avatar_url": "a", 12215 "gravatar_id": "g", 12216 "name": "n", 12217 "company": "c", 12218 "blog": "b", 12219 "location": "l", 12220 "email": "e", 12221 "hireable": true, 12222 "bio": "b", 12223 "twitter_username": "t", 12224 "public_repos": 1, 12225 "followers": 1, 12226 "following": 1, 12227 "created_at": ` + referenceTimeStr + `, 12228 "suspended_at": ` + referenceTimeStr + `, 12229 "url": "u" 12230 }, 12231 "access_tokens_url": "atu", 12232 "repositories_url": "ru", 12233 "html_url": "hu", 12234 "target_type": "tt", 12235 "single_file_name": "sfn", 12236 "repository_selection": "rs", 12237 "events": [ 12238 "e" 12239 ], 12240 "single_file_paths": [ 12241 "s" 12242 ], 12243 "permissions": { 12244 "actions": "a", 12245 "administration": "ad", 12246 "checks": "c", 12247 "contents": "co", 12248 "content_references": "cr", 12249 "deployments": "d", 12250 "environments": "e", 12251 "issues": "i", 12252 "metadata": "md", 12253 "members": "m", 12254 "organization_administration": "oa", 12255 "organization_hooks": "oh", 12256 "organization_plan": "op", 12257 "organization_pre_receive_hooks": "opr", 12258 "organization_projects": "op", 12259 "organization_secrets": "os", 12260 "organization_self_hosted_runners": "osh", 12261 "organization_user_blocking": "oub", 12262 "packages": "pkg", 12263 "pages": "pg", 12264 "pull_requests": "pr", 12265 "repository_hooks": "rh", 12266 "repository_projects": "rp", 12267 "repository_pre_receive_hooks": "rprh", 12268 "secrets": "s", 12269 "secret_scanning_alerts": "ssa", 12270 "security_events": "se", 12271 "single_file": "sf", 12272 "statuses": "s", 12273 "team_discussions": "td", 12274 "vulnerability_alerts": "va", 12275 "workflows": "w" 12276 }, 12277 "created_at": ` + referenceTimeStr + `, 12278 "updated_at": ` + referenceTimeStr + `, 12279 "has_multiple_single_files": false, 12280 "suspended_by": { 12281 "login": "l", 12282 "id": 1, 12283 "avatar_url": "a", 12284 "gravatar_id": "g", 12285 "name": "n", 12286 "company": "c", 12287 "blog": "b", 12288 "location": "l", 12289 "email": "e", 12290 "hireable": true, 12291 "bio": "b", 12292 "twitter_username": "t", 12293 "public_repos": 1, 12294 "followers": 1, 12295 "following": 1, 12296 "created_at": ` + referenceTimeStr + `, 12297 "suspended_at": ` + referenceTimeStr + `, 12298 "url": "u" 12299 }, 12300 "suspended_at": ` + referenceTimeStr + ` 12301 } 12302 }` 12303 12304 testJSONMarshal(t, u, want) 12305 } 12306 12307 func TestUserEvent_Marshal(t *testing.T) { 12308 t.Parallel() 12309 testJSONMarshal(t, &UserEvent{}, "{}") 12310 12311 u := &UserEvent{ 12312 User: &User{ 12313 Login: Ptr("l"), 12314 ID: Ptr(int64(1)), 12315 NodeID: Ptr("n"), 12316 URL: Ptr("u"), 12317 ReposURL: Ptr("r"), 12318 EventsURL: Ptr("e"), 12319 AvatarURL: Ptr("a"), 12320 }, 12321 // The action performed. Possible values are: "created" or "deleted". 12322 Action: Ptr("a"), 12323 Enterprise: &Enterprise{ 12324 ID: Ptr(1), 12325 Slug: Ptr("s"), 12326 Name: Ptr("n"), 12327 NodeID: Ptr("nid"), 12328 AvatarURL: Ptr("au"), 12329 Description: Ptr("d"), 12330 WebsiteURL: Ptr("wu"), 12331 HTMLURL: Ptr("hu"), 12332 CreatedAt: &Timestamp{referenceTime}, 12333 UpdatedAt: &Timestamp{referenceTime}, 12334 }, 12335 Sender: &User{ 12336 Login: Ptr("l"), 12337 ID: Ptr(int64(1)), 12338 NodeID: Ptr("n"), 12339 URL: Ptr("u"), 12340 ReposURL: Ptr("r"), 12341 EventsURL: Ptr("e"), 12342 AvatarURL: Ptr("a"), 12343 }, 12344 } 12345 12346 want := `{ 12347 "user": { 12348 "login": "l", 12349 "id": 1, 12350 "node_id": "n", 12351 "avatar_url": "a", 12352 "url": "u", 12353 "events_url": "e", 12354 "repos_url": "r" 12355 }, 12356 "action": "a", 12357 "enterprise": { 12358 "id": 1, 12359 "slug": "s", 12360 "name": "n", 12361 "node_id": "nid", 12362 "avatar_url": "au", 12363 "description": "d", 12364 "website_url": "wu", 12365 "html_url": "hu", 12366 "created_at": ` + referenceTimeStr + `, 12367 "updated_at": ` + referenceTimeStr + ` 12368 }, 12369 "sender": { 12370 "login": "l", 12371 "id": 1, 12372 "node_id": "n", 12373 "avatar_url": "a", 12374 "url": "u", 12375 "events_url": "e", 12376 "repos_url": "r" 12377 } 12378 }` 12379 12380 testJSONMarshal(t, u, want) 12381 } 12382 12383 func TestCheckRunEvent_Marshal(t *testing.T) { 12384 t.Parallel() 12385 testJSONMarshal(t, &CheckRunEvent{}, "{}") 12386 12387 r := &CheckRunEvent{ 12388 CheckRun: &CheckRun{ 12389 ID: Ptr(int64(1)), 12390 NodeID: Ptr("n"), 12391 HeadSHA: Ptr("h"), 12392 ExternalID: Ptr("1"), 12393 URL: Ptr("u"), 12394 HTMLURL: Ptr("u"), 12395 DetailsURL: Ptr("u"), 12396 Status: Ptr("s"), 12397 Conclusion: Ptr("c"), 12398 StartedAt: &Timestamp{referenceTime}, 12399 CompletedAt: &Timestamp{referenceTime}, 12400 Output: &CheckRunOutput{ 12401 Annotations: []*CheckRunAnnotation{ 12402 { 12403 AnnotationLevel: Ptr("a"), 12404 EndLine: Ptr(1), 12405 Message: Ptr("m"), 12406 Path: Ptr("p"), 12407 RawDetails: Ptr("r"), 12408 StartLine: Ptr(1), 12409 Title: Ptr("t"), 12410 }, 12411 }, 12412 AnnotationsCount: Ptr(1), 12413 AnnotationsURL: Ptr("a"), 12414 Images: []*CheckRunImage{ 12415 { 12416 Alt: Ptr("a"), 12417 ImageURL: Ptr("i"), 12418 Caption: Ptr("c"), 12419 }, 12420 }, 12421 Title: Ptr("t"), 12422 Summary: Ptr("s"), 12423 Text: Ptr("t"), 12424 }, 12425 Name: Ptr("n"), 12426 CheckSuite: &CheckSuite{ 12427 ID: Ptr(int64(1)), 12428 }, 12429 App: &App{ 12430 ID: Ptr(int64(1)), 12431 NodeID: Ptr("n"), 12432 Owner: &User{ 12433 Login: Ptr("l"), 12434 ID: Ptr(int64(1)), 12435 NodeID: Ptr("n"), 12436 URL: Ptr("u"), 12437 ReposURL: Ptr("r"), 12438 EventsURL: Ptr("e"), 12439 AvatarURL: Ptr("a"), 12440 }, 12441 Name: Ptr("n"), 12442 Description: Ptr("d"), 12443 HTMLURL: Ptr("h"), 12444 ExternalURL: Ptr("u"), 12445 CreatedAt: &Timestamp{referenceTime}, 12446 UpdatedAt: &Timestamp{referenceTime}, 12447 }, 12448 PullRequests: []*PullRequest{ 12449 { 12450 URL: Ptr("u"), 12451 ID: Ptr(int64(1)), 12452 Number: Ptr(1), 12453 Head: &PullRequestBranch{ 12454 Ref: Ptr("r"), 12455 SHA: Ptr("s"), 12456 Repo: &Repository{ 12457 ID: Ptr(int64(1)), 12458 URL: Ptr("s"), 12459 Name: Ptr("n"), 12460 }, 12461 }, 12462 Base: &PullRequestBranch{ 12463 Ref: Ptr("r"), 12464 SHA: Ptr("s"), 12465 Repo: &Repository{ 12466 ID: Ptr(int64(1)), 12467 URL: Ptr("u"), 12468 Name: Ptr("n"), 12469 }, 12470 }, 12471 }, 12472 }, 12473 }, 12474 Action: Ptr("a"), 12475 Repo: &Repository{ 12476 ID: Ptr(int64(1)), 12477 URL: Ptr("s"), 12478 Name: Ptr("n"), 12479 }, 12480 Org: &Organization{ 12481 BillingEmail: Ptr("be"), 12482 Blog: Ptr("b"), 12483 Company: Ptr("c"), 12484 Email: Ptr("e"), 12485 TwitterUsername: Ptr("tu"), 12486 Location: Ptr("loc"), 12487 Name: Ptr("n"), 12488 Description: Ptr("d"), 12489 IsVerified: Ptr(true), 12490 HasOrganizationProjects: Ptr(true), 12491 HasRepositoryProjects: Ptr(true), 12492 DefaultRepoPermission: Ptr("drp"), 12493 MembersCanCreateRepos: Ptr(true), 12494 MembersCanCreateInternalRepos: Ptr(true), 12495 MembersCanCreatePrivateRepos: Ptr(true), 12496 MembersCanCreatePublicRepos: Ptr(false), 12497 MembersAllowedRepositoryCreationType: Ptr("marct"), 12498 MembersCanCreatePages: Ptr(true), 12499 MembersCanCreatePublicPages: Ptr(false), 12500 MembersCanCreatePrivatePages: Ptr(true), 12501 }, 12502 Sender: &User{ 12503 Login: Ptr("l"), 12504 ID: Ptr(int64(1)), 12505 NodeID: Ptr("n"), 12506 URL: Ptr("u"), 12507 ReposURL: Ptr("r"), 12508 EventsURL: Ptr("e"), 12509 AvatarURL: Ptr("a"), 12510 }, 12511 Installation: &Installation{ 12512 ID: Ptr(int64(1)), 12513 NodeID: Ptr("nid"), 12514 AppID: Ptr(int64(1)), 12515 AppSlug: Ptr("as"), 12516 TargetID: Ptr(int64(1)), 12517 Account: &User{ 12518 Login: Ptr("l"), 12519 ID: Ptr(int64(1)), 12520 URL: Ptr("u"), 12521 AvatarURL: Ptr("a"), 12522 GravatarID: Ptr("g"), 12523 Name: Ptr("n"), 12524 Company: Ptr("c"), 12525 Blog: Ptr("b"), 12526 Location: Ptr("l"), 12527 Email: Ptr("e"), 12528 Hireable: Ptr(true), 12529 Bio: Ptr("b"), 12530 TwitterUsername: Ptr("t"), 12531 PublicRepos: Ptr(1), 12532 Followers: Ptr(1), 12533 Following: Ptr(1), 12534 CreatedAt: &Timestamp{referenceTime}, 12535 SuspendedAt: &Timestamp{referenceTime}, 12536 }, 12537 AccessTokensURL: Ptr("atu"), 12538 RepositoriesURL: Ptr("ru"), 12539 HTMLURL: Ptr("hu"), 12540 TargetType: Ptr("tt"), 12541 SingleFileName: Ptr("sfn"), 12542 RepositorySelection: Ptr("rs"), 12543 Events: []string{"e"}, 12544 SingleFilePaths: []string{"s"}, 12545 Permissions: &InstallationPermissions{ 12546 Actions: Ptr("a"), 12547 Administration: Ptr("ad"), 12548 Checks: Ptr("c"), 12549 Contents: Ptr("co"), 12550 ContentReferences: Ptr("cr"), 12551 Deployments: Ptr("d"), 12552 Environments: Ptr("e"), 12553 Issues: Ptr("i"), 12554 Metadata: Ptr("md"), 12555 Members: Ptr("m"), 12556 OrganizationAdministration: Ptr("oa"), 12557 OrganizationHooks: Ptr("oh"), 12558 OrganizationPlan: Ptr("op"), 12559 OrganizationPreReceiveHooks: Ptr("opr"), 12560 OrganizationProjects: Ptr("op"), 12561 OrganizationSecrets: Ptr("os"), 12562 OrganizationSelfHostedRunners: Ptr("osh"), 12563 OrganizationUserBlocking: Ptr("oub"), 12564 Packages: Ptr("pkg"), 12565 Pages: Ptr("pg"), 12566 PullRequests: Ptr("pr"), 12567 RepositoryHooks: Ptr("rh"), 12568 RepositoryProjects: Ptr("rp"), 12569 RepositoryPreReceiveHooks: Ptr("rprh"), 12570 Secrets: Ptr("s"), 12571 SecretScanningAlerts: Ptr("ssa"), 12572 SecurityEvents: Ptr("se"), 12573 SingleFile: Ptr("sf"), 12574 Statuses: Ptr("s"), 12575 TeamDiscussions: Ptr("td"), 12576 VulnerabilityAlerts: Ptr("va"), 12577 Workflows: Ptr("w"), 12578 }, 12579 CreatedAt: &Timestamp{referenceTime}, 12580 UpdatedAt: &Timestamp{referenceTime}, 12581 HasMultipleSingleFiles: Ptr(false), 12582 SuspendedBy: &User{ 12583 Login: Ptr("l"), 12584 ID: Ptr(int64(1)), 12585 URL: Ptr("u"), 12586 AvatarURL: Ptr("a"), 12587 GravatarID: Ptr("g"), 12588 Name: Ptr("n"), 12589 Company: Ptr("c"), 12590 Blog: Ptr("b"), 12591 Location: Ptr("l"), 12592 Email: Ptr("e"), 12593 Hireable: Ptr(true), 12594 Bio: Ptr("b"), 12595 TwitterUsername: Ptr("t"), 12596 PublicRepos: Ptr(1), 12597 Followers: Ptr(1), 12598 Following: Ptr(1), 12599 CreatedAt: &Timestamp{referenceTime}, 12600 SuspendedAt: &Timestamp{referenceTime}, 12601 }, 12602 SuspendedAt: &Timestamp{referenceTime}, 12603 }, 12604 RequestedAction: &RequestedAction{ 12605 Identifier: "i", 12606 }, 12607 } 12608 12609 want := `{ 12610 "check_run": { 12611 "id": 1, 12612 "node_id": "n", 12613 "head_sha": "h", 12614 "external_id": "1", 12615 "url": "u", 12616 "html_url": "u", 12617 "details_url": "u", 12618 "status": "s", 12619 "conclusion": "c", 12620 "started_at": ` + referenceTimeStr + `, 12621 "completed_at": ` + referenceTimeStr + `, 12622 "output": { 12623 "title": "t", 12624 "summary": "s", 12625 "text": "t", 12626 "annotations_count": 1, 12627 "annotations_url": "a", 12628 "annotations": [ 12629 { 12630 "path": "p", 12631 "start_line": 1, 12632 "end_line": 1, 12633 "annotation_level": "a", 12634 "message": "m", 12635 "title": "t", 12636 "raw_details": "r" 12637 } 12638 ], 12639 "images": [ 12640 { 12641 "alt": "a", 12642 "image_url": "i", 12643 "caption": "c" 12644 } 12645 ] 12646 }, 12647 "name": "n", 12648 "check_suite": { 12649 "id": 1 12650 }, 12651 "app": { 12652 "id": 1, 12653 "node_id": "n", 12654 "owner": { 12655 "login": "l", 12656 "id": 1, 12657 "node_id": "n", 12658 "avatar_url": "a", 12659 "url": "u", 12660 "events_url": "e", 12661 "repos_url": "r" 12662 }, 12663 "name": "n", 12664 "description": "d", 12665 "external_url": "u", 12666 "html_url": "h", 12667 "created_at": ` + referenceTimeStr + `, 12668 "updated_at": ` + referenceTimeStr + ` 12669 }, 12670 "pull_requests": [ 12671 { 12672 "id": 1, 12673 "number": 1, 12674 "url": "u", 12675 "head": { 12676 "ref": "r", 12677 "sha": "s", 12678 "repo": { 12679 "id": 1, 12680 "name": "n", 12681 "url": "s" 12682 } 12683 }, 12684 "base": { 12685 "ref": "r", 12686 "sha": "s", 12687 "repo": { 12688 "id": 1, 12689 "name": "n", 12690 "url": "u" 12691 } 12692 } 12693 } 12694 ] 12695 }, 12696 "action": "a", 12697 "repository": { 12698 "id": 1, 12699 "name": "n", 12700 "url": "s" 12701 }, 12702 "organization": { 12703 "name": "n", 12704 "company": "c", 12705 "blog": "b", 12706 "location": "loc", 12707 "email": "e", 12708 "twitter_username": "tu", 12709 "description": "d", 12710 "billing_email": "be", 12711 "is_verified": true, 12712 "has_organization_projects": true, 12713 "has_repository_projects": true, 12714 "default_repository_permission": "drp", 12715 "members_can_create_repositories": true, 12716 "members_can_create_public_repositories": false, 12717 "members_can_create_private_repositories": true, 12718 "members_can_create_internal_repositories": true, 12719 "members_allowed_repository_creation_type": "marct", 12720 "members_can_create_pages": true, 12721 "members_can_create_public_pages": false, 12722 "members_can_create_private_pages": true 12723 }, 12724 "sender": { 12725 "login": "l", 12726 "id": 1, 12727 "node_id": "n", 12728 "avatar_url": "a", 12729 "url": "u", 12730 "events_url": "e", 12731 "repos_url": "r" 12732 }, 12733 "installation": { 12734 "id": 1, 12735 "node_id": "nid", 12736 "app_id": 1, 12737 "app_slug": "as", 12738 "target_id": 1, 12739 "account": { 12740 "login": "l", 12741 "id": 1, 12742 "avatar_url": "a", 12743 "gravatar_id": "g", 12744 "name": "n", 12745 "company": "c", 12746 "blog": "b", 12747 "location": "l", 12748 "email": "e", 12749 "hireable": true, 12750 "bio": "b", 12751 "twitter_username": "t", 12752 "public_repos": 1, 12753 "followers": 1, 12754 "following": 1, 12755 "created_at": ` + referenceTimeStr + `, 12756 "suspended_at": ` + referenceTimeStr + `, 12757 "url": "u" 12758 }, 12759 "access_tokens_url": "atu", 12760 "repositories_url": "ru", 12761 "html_url": "hu", 12762 "target_type": "tt", 12763 "single_file_name": "sfn", 12764 "repository_selection": "rs", 12765 "events": [ 12766 "e" 12767 ], 12768 "single_file_paths": [ 12769 "s" 12770 ], 12771 "permissions": { 12772 "actions": "a", 12773 "administration": "ad", 12774 "checks": "c", 12775 "contents": "co", 12776 "content_references": "cr", 12777 "deployments": "d", 12778 "environments": "e", 12779 "issues": "i", 12780 "metadata": "md", 12781 "members": "m", 12782 "organization_administration": "oa", 12783 "organization_hooks": "oh", 12784 "organization_plan": "op", 12785 "organization_pre_receive_hooks": "opr", 12786 "organization_projects": "op", 12787 "organization_secrets": "os", 12788 "organization_self_hosted_runners": "osh", 12789 "organization_user_blocking": "oub", 12790 "packages": "pkg", 12791 "pages": "pg", 12792 "pull_requests": "pr", 12793 "repository_hooks": "rh", 12794 "repository_projects": "rp", 12795 "repository_pre_receive_hooks": "rprh", 12796 "secrets": "s", 12797 "secret_scanning_alerts": "ssa", 12798 "security_events": "se", 12799 "single_file": "sf", 12800 "statuses": "s", 12801 "team_discussions": "td", 12802 "vulnerability_alerts": "va", 12803 "workflows": "w" 12804 }, 12805 "created_at": ` + referenceTimeStr + `, 12806 "updated_at": ` + referenceTimeStr + `, 12807 "has_multiple_single_files": false, 12808 "suspended_by": { 12809 "login": "l", 12810 "id": 1, 12811 "avatar_url": "a", 12812 "gravatar_id": "g", 12813 "name": "n", 12814 "company": "c", 12815 "blog": "b", 12816 "location": "l", 12817 "email": "e", 12818 "hireable": true, 12819 "bio": "b", 12820 "twitter_username": "t", 12821 "public_repos": 1, 12822 "followers": 1, 12823 "following": 1, 12824 "created_at": ` + referenceTimeStr + `, 12825 "suspended_at": ` + referenceTimeStr + `, 12826 "url": "u" 12827 }, 12828 "suspended_at": ` + referenceTimeStr + ` 12829 }, 12830 "requested_action": { 12831 "identifier": "i" 12832 } 12833 }` 12834 12835 testJSONMarshal(t, r, want) 12836 } 12837 12838 func TestCheckSuiteEvent_Marshal(t *testing.T) { 12839 t.Parallel() 12840 testJSONMarshal(t, &CheckSuiteEvent{}, "{}") 12841 12842 r := &CheckSuiteEvent{ 12843 CheckSuite: &CheckSuite{ 12844 ID: Ptr(int64(1)), 12845 NodeID: Ptr("n"), 12846 HeadBranch: Ptr("h"), 12847 HeadSHA: Ptr("h"), 12848 URL: Ptr("u"), 12849 BeforeSHA: Ptr("b"), 12850 AfterSHA: Ptr("a"), 12851 Status: Ptr("s"), 12852 Conclusion: Ptr("c"), 12853 App: &App{ 12854 ID: Ptr(int64(1)), 12855 NodeID: Ptr("n"), 12856 Owner: &User{ 12857 Login: Ptr("l"), 12858 ID: Ptr(int64(1)), 12859 NodeID: Ptr("n"), 12860 URL: Ptr("u"), 12861 ReposURL: Ptr("r"), 12862 EventsURL: Ptr("e"), 12863 AvatarURL: Ptr("a"), 12864 }, 12865 Name: Ptr("n"), 12866 Description: Ptr("d"), 12867 HTMLURL: Ptr("h"), 12868 ExternalURL: Ptr("u"), 12869 CreatedAt: &Timestamp{referenceTime}, 12870 UpdatedAt: &Timestamp{referenceTime}, 12871 }, 12872 Repository: &Repository{ 12873 ID: Ptr(int64(1)), 12874 }, 12875 PullRequests: []*PullRequest{ 12876 { 12877 URL: Ptr("u"), 12878 ID: Ptr(int64(1)), 12879 Number: Ptr(1), 12880 Head: &PullRequestBranch{ 12881 Ref: Ptr("r"), 12882 SHA: Ptr("s"), 12883 Repo: &Repository{ 12884 ID: Ptr(int64(1)), 12885 URL: Ptr("s"), 12886 Name: Ptr("n"), 12887 }, 12888 }, 12889 Base: &PullRequestBranch{ 12890 Ref: Ptr("r"), 12891 SHA: Ptr("s"), 12892 Repo: &Repository{ 12893 ID: Ptr(int64(1)), 12894 URL: Ptr("u"), 12895 Name: Ptr("n"), 12896 }, 12897 }, 12898 }, 12899 }, 12900 HeadCommit: &Commit{ 12901 SHA: Ptr("s"), 12902 }, 12903 }, 12904 Action: Ptr("a"), 12905 Repo: &Repository{ 12906 ID: Ptr(int64(1)), 12907 URL: Ptr("s"), 12908 Name: Ptr("n"), 12909 }, 12910 Org: &Organization{ 12911 BillingEmail: Ptr("be"), 12912 Blog: Ptr("b"), 12913 Company: Ptr("c"), 12914 Email: Ptr("e"), 12915 TwitterUsername: Ptr("tu"), 12916 Location: Ptr("loc"), 12917 Name: Ptr("n"), 12918 Description: Ptr("d"), 12919 IsVerified: Ptr(true), 12920 HasOrganizationProjects: Ptr(true), 12921 HasRepositoryProjects: Ptr(true), 12922 DefaultRepoPermission: Ptr("drp"), 12923 MembersCanCreateRepos: Ptr(true), 12924 MembersCanCreateInternalRepos: Ptr(true), 12925 MembersCanCreatePrivateRepos: Ptr(true), 12926 MembersCanCreatePublicRepos: Ptr(false), 12927 MembersAllowedRepositoryCreationType: Ptr("marct"), 12928 MembersCanCreatePages: Ptr(true), 12929 MembersCanCreatePublicPages: Ptr(false), 12930 MembersCanCreatePrivatePages: Ptr(true), 12931 }, 12932 Sender: &User{ 12933 Login: Ptr("l"), 12934 ID: Ptr(int64(1)), 12935 NodeID: Ptr("n"), 12936 URL: Ptr("u"), 12937 ReposURL: Ptr("r"), 12938 EventsURL: Ptr("e"), 12939 AvatarURL: Ptr("a"), 12940 }, 12941 Installation: &Installation{ 12942 ID: Ptr(int64(1)), 12943 NodeID: Ptr("nid"), 12944 AppID: Ptr(int64(1)), 12945 AppSlug: Ptr("as"), 12946 TargetID: Ptr(int64(1)), 12947 Account: &User{ 12948 Login: Ptr("l"), 12949 ID: Ptr(int64(1)), 12950 URL: Ptr("u"), 12951 AvatarURL: Ptr("a"), 12952 GravatarID: Ptr("g"), 12953 Name: Ptr("n"), 12954 Company: Ptr("c"), 12955 Blog: Ptr("b"), 12956 Location: Ptr("l"), 12957 Email: Ptr("e"), 12958 Hireable: Ptr(true), 12959 Bio: Ptr("b"), 12960 TwitterUsername: Ptr("t"), 12961 PublicRepos: Ptr(1), 12962 Followers: Ptr(1), 12963 Following: Ptr(1), 12964 CreatedAt: &Timestamp{referenceTime}, 12965 SuspendedAt: &Timestamp{referenceTime}, 12966 }, 12967 AccessTokensURL: Ptr("atu"), 12968 RepositoriesURL: Ptr("ru"), 12969 HTMLURL: Ptr("hu"), 12970 TargetType: Ptr("tt"), 12971 SingleFileName: Ptr("sfn"), 12972 RepositorySelection: Ptr("rs"), 12973 Events: []string{"e"}, 12974 SingleFilePaths: []string{"s"}, 12975 Permissions: &InstallationPermissions{ 12976 Actions: Ptr("a"), 12977 Administration: Ptr("ad"), 12978 Checks: Ptr("c"), 12979 Contents: Ptr("co"), 12980 ContentReferences: Ptr("cr"), 12981 Deployments: Ptr("d"), 12982 Environments: Ptr("e"), 12983 Issues: Ptr("i"), 12984 Metadata: Ptr("md"), 12985 Members: Ptr("m"), 12986 OrganizationAdministration: Ptr("oa"), 12987 OrganizationHooks: Ptr("oh"), 12988 OrganizationPlan: Ptr("op"), 12989 OrganizationPreReceiveHooks: Ptr("opr"), 12990 OrganizationProjects: Ptr("op"), 12991 OrganizationSecrets: Ptr("os"), 12992 OrganizationSelfHostedRunners: Ptr("osh"), 12993 OrganizationUserBlocking: Ptr("oub"), 12994 Packages: Ptr("pkg"), 12995 Pages: Ptr("pg"), 12996 PullRequests: Ptr("pr"), 12997 RepositoryHooks: Ptr("rh"), 12998 RepositoryProjects: Ptr("rp"), 12999 RepositoryPreReceiveHooks: Ptr("rprh"), 13000 Secrets: Ptr("s"), 13001 SecretScanningAlerts: Ptr("ssa"), 13002 SecurityEvents: Ptr("se"), 13003 SingleFile: Ptr("sf"), 13004 Statuses: Ptr("s"), 13005 TeamDiscussions: Ptr("td"), 13006 VulnerabilityAlerts: Ptr("va"), 13007 Workflows: Ptr("w"), 13008 }, 13009 CreatedAt: &Timestamp{referenceTime}, 13010 UpdatedAt: &Timestamp{referenceTime}, 13011 HasMultipleSingleFiles: Ptr(false), 13012 SuspendedBy: &User{ 13013 Login: Ptr("l"), 13014 ID: Ptr(int64(1)), 13015 URL: Ptr("u"), 13016 AvatarURL: Ptr("a"), 13017 GravatarID: Ptr("g"), 13018 Name: Ptr("n"), 13019 Company: Ptr("c"), 13020 Blog: Ptr("b"), 13021 Location: Ptr("l"), 13022 Email: Ptr("e"), 13023 Hireable: Ptr(true), 13024 Bio: Ptr("b"), 13025 TwitterUsername: Ptr("t"), 13026 PublicRepos: Ptr(1), 13027 Followers: Ptr(1), 13028 Following: Ptr(1), 13029 CreatedAt: &Timestamp{referenceTime}, 13030 SuspendedAt: &Timestamp{referenceTime}, 13031 }, 13032 SuspendedAt: &Timestamp{referenceTime}, 13033 }, 13034 } 13035 13036 want := `{ 13037 "check_suite": { 13038 "id": 1, 13039 "node_id": "n", 13040 "head_branch": "h", 13041 "head_sha": "h", 13042 "url": "u", 13043 "before": "b", 13044 "after": "a", 13045 "status": "s", 13046 "conclusion": "c", 13047 "app": { 13048 "id": 1, 13049 "node_id": "n", 13050 "owner": { 13051 "login": "l", 13052 "id": 1, 13053 "node_id": "n", 13054 "avatar_url": "a", 13055 "url": "u", 13056 "events_url": "e", 13057 "repos_url": "r" 13058 }, 13059 "name": "n", 13060 "description": "d", 13061 "external_url": "u", 13062 "html_url": "h", 13063 "created_at": ` + referenceTimeStr + `, 13064 "updated_at": ` + referenceTimeStr + ` 13065 }, 13066 "repository": { 13067 "id": 1 13068 }, 13069 "pull_requests": [ 13070 { 13071 "id": 1, 13072 "number": 1, 13073 "url": "u", 13074 "head": { 13075 "ref": "r", 13076 "sha": "s", 13077 "repo": { 13078 "id": 1, 13079 "name": "n", 13080 "url": "s" 13081 } 13082 }, 13083 "base": { 13084 "ref": "r", 13085 "sha": "s", 13086 "repo": { 13087 "id": 1, 13088 "name": "n", 13089 "url": "u" 13090 } 13091 } 13092 } 13093 ], 13094 "head_commit": { 13095 "sha": "s" 13096 } 13097 }, 13098 "action": "a", 13099 "repository": { 13100 "id": 1, 13101 "name": "n", 13102 "url": "s" 13103 }, 13104 "organization": { 13105 "name": "n", 13106 "company": "c", 13107 "blog": "b", 13108 "location": "loc", 13109 "email": "e", 13110 "twitter_username": "tu", 13111 "description": "d", 13112 "billing_email": "be", 13113 "is_verified": true, 13114 "has_organization_projects": true, 13115 "has_repository_projects": true, 13116 "default_repository_permission": "drp", 13117 "members_can_create_repositories": true, 13118 "members_can_create_public_repositories": false, 13119 "members_can_create_private_repositories": true, 13120 "members_can_create_internal_repositories": true, 13121 "members_allowed_repository_creation_type": "marct", 13122 "members_can_create_pages": true, 13123 "members_can_create_public_pages": false, 13124 "members_can_create_private_pages": true 13125 }, 13126 "sender": { 13127 "login": "l", 13128 "id": 1, 13129 "node_id": "n", 13130 "avatar_url": "a", 13131 "url": "u", 13132 "events_url": "e", 13133 "repos_url": "r" 13134 }, 13135 "installation": { 13136 "id": 1, 13137 "node_id": "nid", 13138 "app_id": 1, 13139 "app_slug": "as", 13140 "target_id": 1, 13141 "account": { 13142 "login": "l", 13143 "id": 1, 13144 "avatar_url": "a", 13145 "gravatar_id": "g", 13146 "name": "n", 13147 "company": "c", 13148 "blog": "b", 13149 "location": "l", 13150 "email": "e", 13151 "hireable": true, 13152 "bio": "b", 13153 "twitter_username": "t", 13154 "public_repos": 1, 13155 "followers": 1, 13156 "following": 1, 13157 "created_at": ` + referenceTimeStr + `, 13158 "suspended_at": ` + referenceTimeStr + `, 13159 "url": "u" 13160 }, 13161 "access_tokens_url": "atu", 13162 "repositories_url": "ru", 13163 "html_url": "hu", 13164 "target_type": "tt", 13165 "single_file_name": "sfn", 13166 "repository_selection": "rs", 13167 "events": [ 13168 "e" 13169 ], 13170 "single_file_paths": [ 13171 "s" 13172 ], 13173 "permissions": { 13174 "actions": "a", 13175 "administration": "ad", 13176 "checks": "c", 13177 "contents": "co", 13178 "content_references": "cr", 13179 "deployments": "d", 13180 "environments": "e", 13181 "issues": "i", 13182 "metadata": "md", 13183 "members": "m", 13184 "organization_administration": "oa", 13185 "organization_hooks": "oh", 13186 "organization_plan": "op", 13187 "organization_pre_receive_hooks": "opr", 13188 "organization_projects": "op", 13189 "organization_secrets": "os", 13190 "organization_self_hosted_runners": "osh", 13191 "organization_user_blocking": "oub", 13192 "packages": "pkg", 13193 "pages": "pg", 13194 "pull_requests": "pr", 13195 "repository_hooks": "rh", 13196 "repository_projects": "rp", 13197 "repository_pre_receive_hooks": "rprh", 13198 "secrets": "s", 13199 "secret_scanning_alerts": "ssa", 13200 "security_events": "se", 13201 "single_file": "sf", 13202 "statuses": "s", 13203 "team_discussions": "td", 13204 "vulnerability_alerts": "va", 13205 "workflows": "w" 13206 }, 13207 "created_at": ` + referenceTimeStr + `, 13208 "updated_at": ` + referenceTimeStr + `, 13209 "has_multiple_single_files": false, 13210 "suspended_by": { 13211 "login": "l", 13212 "id": 1, 13213 "avatar_url": "a", 13214 "gravatar_id": "g", 13215 "name": "n", 13216 "company": "c", 13217 "blog": "b", 13218 "location": "l", 13219 "email": "e", 13220 "hireable": true, 13221 "bio": "b", 13222 "twitter_username": "t", 13223 "public_repos": 1, 13224 "followers": 1, 13225 "following": 1, 13226 "created_at": ` + referenceTimeStr + `, 13227 "suspended_at": ` + referenceTimeStr + `, 13228 "url": "u" 13229 }, 13230 "suspended_at": ` + referenceTimeStr + ` 13231 } 13232 }` 13233 13234 testJSONMarshal(t, r, want) 13235 } 13236 13237 func TestDeployKeyEvent_Marshal(t *testing.T) { 13238 t.Parallel() 13239 testJSONMarshal(t, &DeployKeyEvent{}, "{}") 13240 13241 u := &DeployKeyEvent{ 13242 Action: Ptr("a"), 13243 Key: &Key{ 13244 ID: Ptr(int64(1)), 13245 Key: Ptr("k"), 13246 URL: Ptr("k"), 13247 Title: Ptr("k"), 13248 ReadOnly: Ptr(false), 13249 Verified: Ptr(false), 13250 CreatedAt: &Timestamp{referenceTime}, 13251 }, 13252 Repo: &Repository{ 13253 ID: Ptr(int64(1)), 13254 URL: Ptr("s"), 13255 Name: Ptr("n"), 13256 }, 13257 Organization: &Organization{ 13258 BillingEmail: Ptr("be"), 13259 Blog: Ptr("b"), 13260 Company: Ptr("c"), 13261 Email: Ptr("e"), 13262 TwitterUsername: Ptr("tu"), 13263 Location: Ptr("loc"), 13264 Name: Ptr("n"), 13265 Description: Ptr("d"), 13266 IsVerified: Ptr(true), 13267 HasOrganizationProjects: Ptr(true), 13268 HasRepositoryProjects: Ptr(true), 13269 DefaultRepoPermission: Ptr("drp"), 13270 MembersCanCreateRepos: Ptr(true), 13271 MembersCanCreateInternalRepos: Ptr(true), 13272 MembersCanCreatePrivateRepos: Ptr(true), 13273 MembersCanCreatePublicRepos: Ptr(false), 13274 MembersAllowedRepositoryCreationType: Ptr("marct"), 13275 MembersCanCreatePages: Ptr(true), 13276 MembersCanCreatePublicPages: Ptr(false), 13277 MembersCanCreatePrivatePages: Ptr(true), 13278 }, 13279 Sender: &User{ 13280 Login: Ptr("l"), 13281 ID: Ptr(int64(1)), 13282 NodeID: Ptr("n"), 13283 AvatarURL: Ptr("a"), 13284 URL: Ptr("u"), 13285 EventsURL: Ptr("e"), 13286 ReposURL: Ptr("r"), 13287 }, 13288 } 13289 13290 want := `{ 13291 "action": "a", 13292 "key": { 13293 "id": 1, 13294 "key": "k", 13295 "url": "k", 13296 "title": "k", 13297 "read_only": false, 13298 "verified": false, 13299 "created_at": ` + referenceTimeStr + ` 13300 }, 13301 "repository": { 13302 "id": 1, 13303 "name": "n", 13304 "url": "s" 13305 }, 13306 "organization": { 13307 "name": "n", 13308 "company": "c", 13309 "blog": "b", 13310 "location": "loc", 13311 "email": "e", 13312 "twitter_username": "tu", 13313 "description": "d", 13314 "billing_email": "be", 13315 "is_verified": true, 13316 "has_organization_projects": true, 13317 "has_repository_projects": true, 13318 "default_repository_permission": "drp", 13319 "members_can_create_repositories": true, 13320 "members_can_create_public_repositories": false, 13321 "members_can_create_private_repositories": true, 13322 "members_can_create_internal_repositories": true, 13323 "members_allowed_repository_creation_type": "marct", 13324 "members_can_create_pages": true, 13325 "members_can_create_public_pages": false, 13326 "members_can_create_private_pages": true 13327 }, 13328 "sender": { 13329 "login": "l", 13330 "id": 1, 13331 "node_id": "n", 13332 "avatar_url": "a", 13333 "url": "u", 13334 "events_url": "e", 13335 "repos_url": "r" 13336 } 13337 }` 13338 13339 testJSONMarshal(t, u, want) 13340 } 13341 13342 func TestMetaEvent_Marshal(t *testing.T) { 13343 t.Parallel() 13344 testJSONMarshal(t, &MetaEvent{}, "{}") 13345 13346 v := make(map[string]any) 13347 v["a"] = "b" 13348 hookConfig := &HookConfig{ 13349 ContentType: Ptr("json"), 13350 } 13351 13352 u := &MetaEvent{ 13353 Action: Ptr("a"), 13354 HookID: Ptr(int64(1)), 13355 Hook: &Hook{ 13356 CreatedAt: &Timestamp{referenceTime}, 13357 UpdatedAt: &Timestamp{referenceTime}, 13358 URL: Ptr("u"), 13359 ID: Ptr(int64(1)), 13360 Type: Ptr("t"), 13361 Name: Ptr("n"), 13362 TestURL: Ptr("tu"), 13363 PingURL: Ptr("pu"), 13364 LastResponse: v, 13365 Config: hookConfig, 13366 Events: []string{"a"}, 13367 Active: Ptr(true), 13368 }, 13369 } 13370 13371 want := `{ 13372 "action": "a", 13373 "hook_id": 1, 13374 "hook": { 13375 "created_at": ` + referenceTimeStr + `, 13376 "updated_at": ` + referenceTimeStr + `, 13377 "url": "u", 13378 "id": 1, 13379 "type": "t", 13380 "name": "n", 13381 "test_url": "tu", 13382 "ping_url": "pu", 13383 "last_response": { 13384 "a": "b" 13385 }, 13386 "config": { 13387 "content_type": "json" 13388 }, 13389 "events": [ 13390 "a" 13391 ], 13392 "active": true 13393 } 13394 }` 13395 13396 testJSONMarshal(t, u, want) 13397 } 13398 13399 func TestRequestedAction_Marshal(t *testing.T) { 13400 t.Parallel() 13401 testJSONMarshal(t, &RequestedAction{}, "{}") 13402 13403 r := &RequestedAction{ 13404 Identifier: "i", 13405 } 13406 13407 want := `{ 13408 "identifier": "i" 13409 }` 13410 13411 testJSONMarshal(t, r, want) 13412 } 13413 13414 func TestCreateEvent_Marshal(t *testing.T) { 13415 t.Parallel() 13416 testJSONMarshal(t, &CreateEvent{}, "{}") 13417 13418 r := &CreateEvent{ 13419 Ref: Ptr("r"), 13420 RefType: Ptr("rt"), 13421 MasterBranch: Ptr("mb"), 13422 Description: Ptr("d"), 13423 PusherType: Ptr("pt"), 13424 Repo: &Repository{ 13425 ID: Ptr(int64(1)), 13426 URL: Ptr("s"), 13427 Name: Ptr("n"), 13428 }, 13429 Sender: &User{ 13430 Login: Ptr("l"), 13431 ID: Ptr(int64(1)), 13432 NodeID: Ptr("n"), 13433 URL: Ptr("u"), 13434 ReposURL: Ptr("r"), 13435 EventsURL: Ptr("e"), 13436 AvatarURL: Ptr("a"), 13437 }, 13438 Installation: &Installation{ 13439 ID: Ptr(int64(1)), 13440 NodeID: Ptr("nid"), 13441 AppID: Ptr(int64(1)), 13442 AppSlug: Ptr("as"), 13443 TargetID: Ptr(int64(1)), 13444 Account: &User{ 13445 Login: Ptr("l"), 13446 ID: Ptr(int64(1)), 13447 URL: Ptr("u"), 13448 AvatarURL: Ptr("a"), 13449 GravatarID: Ptr("g"), 13450 Name: Ptr("n"), 13451 Company: Ptr("c"), 13452 Blog: Ptr("b"), 13453 Location: Ptr("l"), 13454 Email: Ptr("e"), 13455 Hireable: Ptr(true), 13456 Bio: Ptr("b"), 13457 TwitterUsername: Ptr("t"), 13458 PublicRepos: Ptr(1), 13459 Followers: Ptr(1), 13460 Following: Ptr(1), 13461 CreatedAt: &Timestamp{referenceTime}, 13462 SuspendedAt: &Timestamp{referenceTime}, 13463 }, 13464 AccessTokensURL: Ptr("atu"), 13465 RepositoriesURL: Ptr("ru"), 13466 HTMLURL: Ptr("hu"), 13467 TargetType: Ptr("tt"), 13468 SingleFileName: Ptr("sfn"), 13469 RepositorySelection: Ptr("rs"), 13470 Events: []string{"e"}, 13471 SingleFilePaths: []string{"s"}, 13472 Permissions: &InstallationPermissions{ 13473 Actions: Ptr("a"), 13474 Administration: Ptr("ad"), 13475 Checks: Ptr("c"), 13476 Contents: Ptr("co"), 13477 ContentReferences: Ptr("cr"), 13478 Deployments: Ptr("d"), 13479 Environments: Ptr("e"), 13480 Issues: Ptr("i"), 13481 Metadata: Ptr("md"), 13482 Members: Ptr("m"), 13483 OrganizationAdministration: Ptr("oa"), 13484 OrganizationHooks: Ptr("oh"), 13485 OrganizationPlan: Ptr("op"), 13486 OrganizationPreReceiveHooks: Ptr("opr"), 13487 OrganizationProjects: Ptr("op"), 13488 OrganizationSecrets: Ptr("os"), 13489 OrganizationSelfHostedRunners: Ptr("osh"), 13490 OrganizationUserBlocking: Ptr("oub"), 13491 Packages: Ptr("pkg"), 13492 Pages: Ptr("pg"), 13493 PullRequests: Ptr("pr"), 13494 RepositoryHooks: Ptr("rh"), 13495 RepositoryProjects: Ptr("rp"), 13496 RepositoryPreReceiveHooks: Ptr("rprh"), 13497 Secrets: Ptr("s"), 13498 SecretScanningAlerts: Ptr("ssa"), 13499 SecurityEvents: Ptr("se"), 13500 SingleFile: Ptr("sf"), 13501 Statuses: Ptr("s"), 13502 TeamDiscussions: Ptr("td"), 13503 VulnerabilityAlerts: Ptr("va"), 13504 Workflows: Ptr("w"), 13505 }, 13506 CreatedAt: &Timestamp{referenceTime}, 13507 UpdatedAt: &Timestamp{referenceTime}, 13508 HasMultipleSingleFiles: Ptr(false), 13509 SuspendedBy: &User{ 13510 Login: Ptr("l"), 13511 ID: Ptr(int64(1)), 13512 URL: Ptr("u"), 13513 AvatarURL: Ptr("a"), 13514 GravatarID: Ptr("g"), 13515 Name: Ptr("n"), 13516 Company: Ptr("c"), 13517 Blog: Ptr("b"), 13518 Location: Ptr("l"), 13519 Email: Ptr("e"), 13520 Hireable: Ptr(true), 13521 Bio: Ptr("b"), 13522 TwitterUsername: Ptr("t"), 13523 PublicRepos: Ptr(1), 13524 Followers: Ptr(1), 13525 Following: Ptr(1), 13526 CreatedAt: &Timestamp{referenceTime}, 13527 SuspendedAt: &Timestamp{referenceTime}, 13528 }, 13529 SuspendedAt: &Timestamp{referenceTime}, 13530 }, 13531 } 13532 13533 want := `{ 13534 "ref": "r", 13535 "ref_type": "rt", 13536 "master_branch": "mb", 13537 "description": "d", 13538 "pusher_type": "pt", 13539 "repository": { 13540 "id": 1, 13541 "name": "n", 13542 "url": "s" 13543 }, 13544 "sender": { 13545 "login": "l", 13546 "id": 1, 13547 "node_id": "n", 13548 "avatar_url": "a", 13549 "url": "u", 13550 "events_url": "e", 13551 "repos_url": "r" 13552 }, 13553 "installation": { 13554 "id": 1, 13555 "node_id": "nid", 13556 "app_id": 1, 13557 "app_slug": "as", 13558 "target_id": 1, 13559 "account": { 13560 "login": "l", 13561 "id": 1, 13562 "avatar_url": "a", 13563 "gravatar_id": "g", 13564 "name": "n", 13565 "company": "c", 13566 "blog": "b", 13567 "location": "l", 13568 "email": "e", 13569 "hireable": true, 13570 "bio": "b", 13571 "twitter_username": "t", 13572 "public_repos": 1, 13573 "followers": 1, 13574 "following": 1, 13575 "created_at": ` + referenceTimeStr + `, 13576 "suspended_at": ` + referenceTimeStr + `, 13577 "url": "u" 13578 }, 13579 "access_tokens_url": "atu", 13580 "repositories_url": "ru", 13581 "html_url": "hu", 13582 "target_type": "tt", 13583 "single_file_name": "sfn", 13584 "repository_selection": "rs", 13585 "events": [ 13586 "e" 13587 ], 13588 "single_file_paths": [ 13589 "s" 13590 ], 13591 "permissions": { 13592 "actions": "a", 13593 "administration": "ad", 13594 "checks": "c", 13595 "contents": "co", 13596 "content_references": "cr", 13597 "deployments": "d", 13598 "environments": "e", 13599 "issues": "i", 13600 "metadata": "md", 13601 "members": "m", 13602 "organization_administration": "oa", 13603 "organization_hooks": "oh", 13604 "organization_plan": "op", 13605 "organization_pre_receive_hooks": "opr", 13606 "organization_projects": "op", 13607 "organization_secrets": "os", 13608 "organization_self_hosted_runners": "osh", 13609 "organization_user_blocking": "oub", 13610 "packages": "pkg", 13611 "pages": "pg", 13612 "pull_requests": "pr", 13613 "repository_hooks": "rh", 13614 "repository_projects": "rp", 13615 "repository_pre_receive_hooks": "rprh", 13616 "secrets": "s", 13617 "secret_scanning_alerts": "ssa", 13618 "security_events": "se", 13619 "single_file": "sf", 13620 "statuses": "s", 13621 "team_discussions": "td", 13622 "vulnerability_alerts": "va", 13623 "workflows": "w" 13624 }, 13625 "created_at": ` + referenceTimeStr + `, 13626 "updated_at": ` + referenceTimeStr + `, 13627 "has_multiple_single_files": false, 13628 "suspended_by": { 13629 "login": "l", 13630 "id": 1, 13631 "avatar_url": "a", 13632 "gravatar_id": "g", 13633 "name": "n", 13634 "company": "c", 13635 "blog": "b", 13636 "location": "l", 13637 "email": "e", 13638 "hireable": true, 13639 "bio": "b", 13640 "twitter_username": "t", 13641 "public_repos": 1, 13642 "followers": 1, 13643 "following": 1, 13644 "created_at": ` + referenceTimeStr + `, 13645 "suspended_at": ` + referenceTimeStr + `, 13646 "url": "u" 13647 }, 13648 "suspended_at": ` + referenceTimeStr + ` 13649 } 13650 }` 13651 13652 testJSONMarshal(t, r, want) 13653 } 13654 13655 func TestCustomPropertyEvent_Marshal(t *testing.T) { 13656 t.Parallel() 13657 testJSONMarshal(t, &CustomPropertyEvent{}, "{}") 13658 13659 r := &CustomPropertyEvent{ 13660 Action: Ptr("created"), 13661 Definition: &CustomProperty{ 13662 PropertyName: Ptr("name"), 13663 ValueType: "single_select", 13664 SourceType: Ptr("enterprise"), 13665 Required: Ptr(true), 13666 DefaultValue: Ptr("production"), 13667 Description: Ptr("Prod or dev environment"), 13668 AllowedValues: []string{"production", "development"}, 13669 ValuesEditableBy: Ptr("org_actors"), 13670 }, 13671 Sender: &User{ 13672 Login: Ptr("l"), 13673 ID: Ptr(int64(1)), 13674 NodeID: Ptr("n"), 13675 URL: Ptr("u"), 13676 ReposURL: Ptr("r"), 13677 EventsURL: Ptr("e"), 13678 AvatarURL: Ptr("a"), 13679 }, 13680 Installation: &Installation{ 13681 ID: Ptr(int64(1)), 13682 NodeID: Ptr("nid"), 13683 AppID: Ptr(int64(1)), 13684 AppSlug: Ptr("as"), 13685 TargetID: Ptr(int64(1)), 13686 Account: &User{ 13687 Login: Ptr("l"), 13688 ID: Ptr(int64(1)), 13689 URL: Ptr("u"), 13690 AvatarURL: Ptr("a"), 13691 GravatarID: Ptr("g"), 13692 Name: Ptr("n"), 13693 Company: Ptr("c"), 13694 Blog: Ptr("b"), 13695 Location: Ptr("l"), 13696 Email: Ptr("e"), 13697 Hireable: Ptr(true), 13698 Bio: Ptr("b"), 13699 TwitterUsername: Ptr("t"), 13700 PublicRepos: Ptr(1), 13701 Followers: Ptr(1), 13702 Following: Ptr(1), 13703 CreatedAt: &Timestamp{referenceTime}, 13704 SuspendedAt: &Timestamp{referenceTime}, 13705 }, 13706 AccessTokensURL: Ptr("atu"), 13707 RepositoriesURL: Ptr("ru"), 13708 HTMLURL: Ptr("hu"), 13709 TargetType: Ptr("tt"), 13710 SingleFileName: Ptr("sfn"), 13711 RepositorySelection: Ptr("rs"), 13712 Events: []string{"e"}, 13713 SingleFilePaths: []string{"s"}, 13714 Permissions: &InstallationPermissions{ 13715 Actions: Ptr("a"), 13716 Administration: Ptr("ad"), 13717 Checks: Ptr("c"), 13718 Contents: Ptr("co"), 13719 ContentReferences: Ptr("cr"), 13720 Deployments: Ptr("d"), 13721 Environments: Ptr("e"), 13722 Issues: Ptr("i"), 13723 Metadata: Ptr("md"), 13724 Members: Ptr("m"), 13725 OrganizationAdministration: Ptr("oa"), 13726 OrganizationHooks: Ptr("oh"), 13727 OrganizationPlan: Ptr("op"), 13728 OrganizationPreReceiveHooks: Ptr("opr"), 13729 OrganizationProjects: Ptr("op"), 13730 OrganizationSecrets: Ptr("os"), 13731 OrganizationSelfHostedRunners: Ptr("osh"), 13732 OrganizationUserBlocking: Ptr("oub"), 13733 Packages: Ptr("pkg"), 13734 Pages: Ptr("pg"), 13735 PullRequests: Ptr("pr"), 13736 RepositoryHooks: Ptr("rh"), 13737 RepositoryProjects: Ptr("rp"), 13738 RepositoryPreReceiveHooks: Ptr("rprh"), 13739 Secrets: Ptr("s"), 13740 SecretScanningAlerts: Ptr("ssa"), 13741 SecurityEvents: Ptr("se"), 13742 SingleFile: Ptr("sf"), 13743 Statuses: Ptr("s"), 13744 TeamDiscussions: Ptr("td"), 13745 VulnerabilityAlerts: Ptr("va"), 13746 Workflows: Ptr("w"), 13747 }, 13748 CreatedAt: &Timestamp{referenceTime}, 13749 UpdatedAt: &Timestamp{referenceTime}, 13750 HasMultipleSingleFiles: Ptr(false), 13751 SuspendedBy: &User{ 13752 Login: Ptr("l"), 13753 ID: Ptr(int64(1)), 13754 URL: Ptr("u"), 13755 AvatarURL: Ptr("a"), 13756 GravatarID: Ptr("g"), 13757 Name: Ptr("n"), 13758 Company: Ptr("c"), 13759 Blog: Ptr("b"), 13760 Location: Ptr("l"), 13761 Email: Ptr("e"), 13762 Hireable: Ptr(true), 13763 Bio: Ptr("b"), 13764 TwitterUsername: Ptr("t"), 13765 PublicRepos: Ptr(1), 13766 Followers: Ptr(1), 13767 Following: Ptr(1), 13768 CreatedAt: &Timestamp{referenceTime}, 13769 SuspendedAt: &Timestamp{referenceTime}, 13770 }, 13771 SuspendedAt: &Timestamp{referenceTime}, 13772 }, 13773 } 13774 13775 want := `{ 13776 "action": "created", 13777 "definition": { 13778 "property_name": "name", 13779 "source_type": "enterprise", 13780 "value_type": "single_select", 13781 "required": true, 13782 "default_value": "production", 13783 "description": "Prod or dev environment", 13784 "allowed_values": [ 13785 "production", 13786 "development" 13787 ], 13788 "values_editable_by": "org_actors" 13789 }, 13790 "repository": { 13791 "id": 1, 13792 "name": "n", 13793 "url": "s" 13794 }, 13795 "sender": { 13796 "login": "l", 13797 "id": 1, 13798 "node_id": "n", 13799 "avatar_url": "a", 13800 "url": "u", 13801 "events_url": "e", 13802 "repos_url": "r" 13803 }, 13804 "installation": { 13805 "id": 1, 13806 "node_id": "nid", 13807 "app_id": 1, 13808 "app_slug": "as", 13809 "target_id": 1, 13810 "account": { 13811 "login": "l", 13812 "id": 1, 13813 "avatar_url": "a", 13814 "gravatar_id": "g", 13815 "name": "n", 13816 "company": "c", 13817 "blog": "b", 13818 "location": "l", 13819 "email": "e", 13820 "hireable": true, 13821 "bio": "b", 13822 "twitter_username": "t", 13823 "public_repos": 1, 13824 "followers": 1, 13825 "following": 1, 13826 "created_at": ` + referenceTimeStr + `, 13827 "suspended_at": ` + referenceTimeStr + `, 13828 "url": "u" 13829 }, 13830 "access_tokens_url": "atu", 13831 "repositories_url": "ru", 13832 "html_url": "hu", 13833 "target_type": "tt", 13834 "single_file_name": "sfn", 13835 "repository_selection": "rs", 13836 "events": [ 13837 "e" 13838 ], 13839 "single_file_paths": [ 13840 "s" 13841 ], 13842 "permissions": { 13843 "actions": "a", 13844 "administration": "ad", 13845 "checks": "c", 13846 "contents": "co", 13847 "content_references": "cr", 13848 "deployments": "d", 13849 "environments": "e", 13850 "issues": "i", 13851 "metadata": "md", 13852 "members": "m", 13853 "organization_administration": "oa", 13854 "organization_hooks": "oh", 13855 "organization_plan": "op", 13856 "organization_pre_receive_hooks": "opr", 13857 "organization_projects": "op", 13858 "organization_secrets": "os", 13859 "organization_self_hosted_runners": "osh", 13860 "organization_user_blocking": "oub", 13861 "packages": "pkg", 13862 "pages": "pg", 13863 "pull_requests": "pr", 13864 "repository_hooks": "rh", 13865 "repository_projects": "rp", 13866 "repository_pre_receive_hooks": "rprh", 13867 "secrets": "s", 13868 "secret_scanning_alerts": "ssa", 13869 "security_events": "se", 13870 "single_file": "sf", 13871 "statuses": "s", 13872 "team_discussions": "td", 13873 "vulnerability_alerts": "va", 13874 "workflows": "w" 13875 }, 13876 "created_at": ` + referenceTimeStr + `, 13877 "updated_at": ` + referenceTimeStr + `, 13878 "has_multiple_single_files": false, 13879 "suspended_by": { 13880 "login": "l", 13881 "id": 1, 13882 "avatar_url": "a", 13883 "gravatar_id": "g", 13884 "name": "n", 13885 "company": "c", 13886 "blog": "b", 13887 "location": "l", 13888 "email": "e", 13889 "hireable": true, 13890 "bio": "b", 13891 "twitter_username": "t", 13892 "public_repos": 1, 13893 "followers": 1, 13894 "following": 1, 13895 "created_at": ` + referenceTimeStr + `, 13896 "suspended_at": ` + referenceTimeStr + `, 13897 "url": "u" 13898 }, 13899 "suspended_at": ` + referenceTimeStr + ` 13900 } 13901 }` 13902 13903 testJSONMarshal(t, r, want) 13904 } 13905 13906 func TestCustomPropertyValuesEvent_Marshal(t *testing.T) { 13907 t.Parallel() 13908 testJSONMarshal(t, &CustomPropertyValuesEvent{}, "{}") 13909 13910 r := &CustomPropertyValuesEvent{ 13911 Action: Ptr("updated"), 13912 NewPropertyValues: []*CustomPropertyValue{ 13913 { 13914 PropertyName: "environment", 13915 Value: "production", 13916 }, 13917 }, 13918 OldPropertyValues: []*CustomPropertyValue{ 13919 { 13920 PropertyName: "environment", 13921 Value: "staging", 13922 }, 13923 }, 13924 Sender: &User{ 13925 Login: Ptr("l"), 13926 ID: Ptr(int64(1)), 13927 NodeID: Ptr("n"), 13928 URL: Ptr("u"), 13929 ReposURL: Ptr("r"), 13930 EventsURL: Ptr("e"), 13931 AvatarURL: Ptr("a"), 13932 }, 13933 Installation: &Installation{ 13934 ID: Ptr(int64(1)), 13935 NodeID: Ptr("nid"), 13936 AppID: Ptr(int64(1)), 13937 AppSlug: Ptr("as"), 13938 TargetID: Ptr(int64(1)), 13939 Account: &User{ 13940 Login: Ptr("l"), 13941 ID: Ptr(int64(1)), 13942 URL: Ptr("u"), 13943 AvatarURL: Ptr("a"), 13944 GravatarID: Ptr("g"), 13945 Name: Ptr("n"), 13946 Company: Ptr("c"), 13947 Blog: Ptr("b"), 13948 Location: Ptr("l"), 13949 Email: Ptr("e"), 13950 Hireable: Ptr(true), 13951 Bio: Ptr("b"), 13952 TwitterUsername: Ptr("t"), 13953 PublicRepos: Ptr(1), 13954 Followers: Ptr(1), 13955 Following: Ptr(1), 13956 CreatedAt: &Timestamp{referenceTime}, 13957 SuspendedAt: &Timestamp{referenceTime}, 13958 }, 13959 AccessTokensURL: Ptr("atu"), 13960 RepositoriesURL: Ptr("ru"), 13961 HTMLURL: Ptr("hu"), 13962 TargetType: Ptr("tt"), 13963 SingleFileName: Ptr("sfn"), 13964 RepositorySelection: Ptr("rs"), 13965 Events: []string{"e"}, 13966 SingleFilePaths: []string{"s"}, 13967 Permissions: &InstallationPermissions{ 13968 Actions: Ptr("a"), 13969 Administration: Ptr("ad"), 13970 Checks: Ptr("c"), 13971 Contents: Ptr("co"), 13972 ContentReferences: Ptr("cr"), 13973 Deployments: Ptr("d"), 13974 Environments: Ptr("e"), 13975 Issues: Ptr("i"), 13976 Metadata: Ptr("md"), 13977 Members: Ptr("m"), 13978 OrganizationAdministration: Ptr("oa"), 13979 OrganizationHooks: Ptr("oh"), 13980 OrganizationPlan: Ptr("op"), 13981 OrganizationPreReceiveHooks: Ptr("opr"), 13982 OrganizationProjects: Ptr("op"), 13983 OrganizationSecrets: Ptr("os"), 13984 OrganizationSelfHostedRunners: Ptr("osh"), 13985 OrganizationUserBlocking: Ptr("oub"), 13986 Packages: Ptr("pkg"), 13987 Pages: Ptr("pg"), 13988 PullRequests: Ptr("pr"), 13989 RepositoryHooks: Ptr("rh"), 13990 RepositoryProjects: Ptr("rp"), 13991 RepositoryPreReceiveHooks: Ptr("rprh"), 13992 Secrets: Ptr("s"), 13993 SecretScanningAlerts: Ptr("ssa"), 13994 SecurityEvents: Ptr("se"), 13995 SingleFile: Ptr("sf"), 13996 Statuses: Ptr("s"), 13997 TeamDiscussions: Ptr("td"), 13998 VulnerabilityAlerts: Ptr("va"), 13999 Workflows: Ptr("w"), 14000 }, 14001 CreatedAt: &Timestamp{referenceTime}, 14002 UpdatedAt: &Timestamp{referenceTime}, 14003 HasMultipleSingleFiles: Ptr(false), 14004 SuspendedBy: &User{ 14005 Login: Ptr("l"), 14006 ID: Ptr(int64(1)), 14007 URL: Ptr("u"), 14008 AvatarURL: Ptr("a"), 14009 GravatarID: Ptr("g"), 14010 Name: Ptr("n"), 14011 Company: Ptr("c"), 14012 Blog: Ptr("b"), 14013 Location: Ptr("l"), 14014 Email: Ptr("e"), 14015 Hireable: Ptr(true), 14016 Bio: Ptr("b"), 14017 TwitterUsername: Ptr("t"), 14018 PublicRepos: Ptr(1), 14019 Followers: Ptr(1), 14020 Following: Ptr(1), 14021 CreatedAt: &Timestamp{referenceTime}, 14022 SuspendedAt: &Timestamp{referenceTime}, 14023 }, 14024 SuspendedAt: &Timestamp{referenceTime}, 14025 }, 14026 } 14027 14028 want := `{ 14029 "action": "updated", 14030 "new_property_values": [{ 14031 "property_name": "environment", 14032 "value": "production" 14033 }], 14034 "old_property_values": [{ 14035 "property_name": "environment", 14036 "value": "staging" 14037 }], 14038 "sender": { 14039 "login": "l", 14040 "id": 1, 14041 "node_id": "n", 14042 "avatar_url": "a", 14043 "url": "u", 14044 "events_url": "e", 14045 "repos_url": "r" 14046 }, 14047 "installation": { 14048 "id": 1, 14049 "node_id": "nid", 14050 "app_id": 1, 14051 "app_slug": "as", 14052 "target_id": 1, 14053 "account": { 14054 "login": "l", 14055 "id": 1, 14056 "avatar_url": "a", 14057 "gravatar_id": "g", 14058 "name": "n", 14059 "company": "c", 14060 "blog": "b", 14061 "location": "l", 14062 "email": "e", 14063 "hireable": true, 14064 "bio": "b", 14065 "twitter_username": "t", 14066 "public_repos": 1, 14067 "followers": 1, 14068 "following": 1, 14069 "created_at": ` + referenceTimeStr + `, 14070 "suspended_at": ` + referenceTimeStr + `, 14071 "url": "u" 14072 }, 14073 "access_tokens_url": "atu", 14074 "repositories_url": "ru", 14075 "html_url": "hu", 14076 "target_type": "tt", 14077 "single_file_name": "sfn", 14078 "repository_selection": "rs", 14079 "events": [ 14080 "e" 14081 ], 14082 "single_file_paths": [ 14083 "s" 14084 ], 14085 "permissions": { 14086 "actions": "a", 14087 "administration": "ad", 14088 "checks": "c", 14089 "contents": "co", 14090 "content_references": "cr", 14091 "deployments": "d", 14092 "environments": "e", 14093 "issues": "i", 14094 "metadata": "md", 14095 "members": "m", 14096 "organization_administration": "oa", 14097 "organization_hooks": "oh", 14098 "organization_plan": "op", 14099 "organization_pre_receive_hooks": "opr", 14100 "organization_projects": "op", 14101 "organization_secrets": "os", 14102 "organization_self_hosted_runners": "osh", 14103 "organization_user_blocking": "oub", 14104 "packages": "pkg", 14105 "pages": "pg", 14106 "pull_requests": "pr", 14107 "repository_hooks": "rh", 14108 "repository_projects": "rp", 14109 "repository_pre_receive_hooks": "rprh", 14110 "secrets": "s", 14111 "secret_scanning_alerts": "ssa", 14112 "security_events": "se", 14113 "single_file": "sf", 14114 "statuses": "s", 14115 "team_discussions": "td", 14116 "vulnerability_alerts": "va", 14117 "workflows": "w" 14118 }, 14119 "created_at": ` + referenceTimeStr + `, 14120 "updated_at": ` + referenceTimeStr + `, 14121 "has_multiple_single_files": false, 14122 "suspended_by": { 14123 "login": "l", 14124 "id": 1, 14125 "avatar_url": "a", 14126 "gravatar_id": "g", 14127 "name": "n", 14128 "company": "c", 14129 "blog": "b", 14130 "location": "l", 14131 "email": "e", 14132 "hireable": true, 14133 "bio": "b", 14134 "twitter_username": "t", 14135 "public_repos": 1, 14136 "followers": 1, 14137 "following": 1, 14138 "created_at": ` + referenceTimeStr + `, 14139 "suspended_at": ` + referenceTimeStr + `, 14140 "url": "u" 14141 }, 14142 "suspended_at": ` + referenceTimeStr + ` 14143 } 14144 }` 14145 14146 testJSONMarshal(t, r, want) 14147 } 14148 14149 func TestDeleteEvent_Marshal(t *testing.T) { 14150 t.Parallel() 14151 testJSONMarshal(t, &DeleteEvent{}, "{}") 14152 14153 r := &DeleteEvent{ 14154 Ref: Ptr("r"), 14155 RefType: Ptr("rt"), 14156 PusherType: Ptr("pt"), 14157 Repo: &Repository{ 14158 ID: Ptr(int64(1)), 14159 URL: Ptr("s"), 14160 Name: Ptr("n"), 14161 }, 14162 Sender: &User{ 14163 Login: Ptr("l"), 14164 ID: Ptr(int64(1)), 14165 NodeID: Ptr("n"), 14166 URL: Ptr("u"), 14167 ReposURL: Ptr("r"), 14168 EventsURL: Ptr("e"), 14169 AvatarURL: Ptr("a"), 14170 }, 14171 Installation: &Installation{ 14172 ID: Ptr(int64(1)), 14173 NodeID: Ptr("nid"), 14174 AppID: Ptr(int64(1)), 14175 AppSlug: Ptr("as"), 14176 TargetID: Ptr(int64(1)), 14177 Account: &User{ 14178 Login: Ptr("l"), 14179 ID: Ptr(int64(1)), 14180 URL: Ptr("u"), 14181 AvatarURL: Ptr("a"), 14182 GravatarID: Ptr("g"), 14183 Name: Ptr("n"), 14184 Company: Ptr("c"), 14185 Blog: Ptr("b"), 14186 Location: Ptr("l"), 14187 Email: Ptr("e"), 14188 Hireable: Ptr(true), 14189 Bio: Ptr("b"), 14190 TwitterUsername: Ptr("t"), 14191 PublicRepos: Ptr(1), 14192 Followers: Ptr(1), 14193 Following: Ptr(1), 14194 CreatedAt: &Timestamp{referenceTime}, 14195 SuspendedAt: &Timestamp{referenceTime}, 14196 }, 14197 AccessTokensURL: Ptr("atu"), 14198 RepositoriesURL: Ptr("ru"), 14199 HTMLURL: Ptr("hu"), 14200 TargetType: Ptr("tt"), 14201 SingleFileName: Ptr("sfn"), 14202 RepositorySelection: Ptr("rs"), 14203 Events: []string{"e"}, 14204 SingleFilePaths: []string{"s"}, 14205 Permissions: &InstallationPermissions{ 14206 Actions: Ptr("a"), 14207 Administration: Ptr("ad"), 14208 Checks: Ptr("c"), 14209 Contents: Ptr("co"), 14210 ContentReferences: Ptr("cr"), 14211 Deployments: Ptr("d"), 14212 Environments: Ptr("e"), 14213 Issues: Ptr("i"), 14214 Metadata: Ptr("md"), 14215 Members: Ptr("m"), 14216 OrganizationAdministration: Ptr("oa"), 14217 OrganizationHooks: Ptr("oh"), 14218 OrganizationPlan: Ptr("op"), 14219 OrganizationPreReceiveHooks: Ptr("opr"), 14220 OrganizationProjects: Ptr("op"), 14221 OrganizationSecrets: Ptr("os"), 14222 OrganizationSelfHostedRunners: Ptr("osh"), 14223 OrganizationUserBlocking: Ptr("oub"), 14224 Packages: Ptr("pkg"), 14225 Pages: Ptr("pg"), 14226 PullRequests: Ptr("pr"), 14227 RepositoryHooks: Ptr("rh"), 14228 RepositoryProjects: Ptr("rp"), 14229 RepositoryPreReceiveHooks: Ptr("rprh"), 14230 Secrets: Ptr("s"), 14231 SecretScanningAlerts: Ptr("ssa"), 14232 SecurityEvents: Ptr("se"), 14233 SingleFile: Ptr("sf"), 14234 Statuses: Ptr("s"), 14235 TeamDiscussions: Ptr("td"), 14236 VulnerabilityAlerts: Ptr("va"), 14237 Workflows: Ptr("w"), 14238 }, 14239 CreatedAt: &Timestamp{referenceTime}, 14240 UpdatedAt: &Timestamp{referenceTime}, 14241 HasMultipleSingleFiles: Ptr(false), 14242 SuspendedBy: &User{ 14243 Login: Ptr("l"), 14244 ID: Ptr(int64(1)), 14245 URL: Ptr("u"), 14246 AvatarURL: Ptr("a"), 14247 GravatarID: Ptr("g"), 14248 Name: Ptr("n"), 14249 Company: Ptr("c"), 14250 Blog: Ptr("b"), 14251 Location: Ptr("l"), 14252 Email: Ptr("e"), 14253 Hireable: Ptr(true), 14254 Bio: Ptr("b"), 14255 TwitterUsername: Ptr("t"), 14256 PublicRepos: Ptr(1), 14257 Followers: Ptr(1), 14258 Following: Ptr(1), 14259 CreatedAt: &Timestamp{referenceTime}, 14260 SuspendedAt: &Timestamp{referenceTime}, 14261 }, 14262 SuspendedAt: &Timestamp{referenceTime}, 14263 }, 14264 } 14265 14266 want := `{ 14267 "ref": "r", 14268 "ref_type": "rt", 14269 "pusher_type": "pt", 14270 "repository": { 14271 "id": 1, 14272 "name": "n", 14273 "url": "s" 14274 }, 14275 "sender": { 14276 "login": "l", 14277 "id": 1, 14278 "node_id": "n", 14279 "avatar_url": "a", 14280 "url": "u", 14281 "events_url": "e", 14282 "repos_url": "r" 14283 }, 14284 "installation": { 14285 "id": 1, 14286 "node_id": "nid", 14287 "app_id": 1, 14288 "app_slug": "as", 14289 "target_id": 1, 14290 "account": { 14291 "login": "l", 14292 "id": 1, 14293 "avatar_url": "a", 14294 "gravatar_id": "g", 14295 "name": "n", 14296 "company": "c", 14297 "blog": "b", 14298 "location": "l", 14299 "email": "e", 14300 "hireable": true, 14301 "bio": "b", 14302 "twitter_username": "t", 14303 "public_repos": 1, 14304 "followers": 1, 14305 "following": 1, 14306 "created_at": ` + referenceTimeStr + `, 14307 "suspended_at": ` + referenceTimeStr + `, 14308 "url": "u" 14309 }, 14310 "access_tokens_url": "atu", 14311 "repositories_url": "ru", 14312 "html_url": "hu", 14313 "target_type": "tt", 14314 "single_file_name": "sfn", 14315 "repository_selection": "rs", 14316 "events": [ 14317 "e" 14318 ], 14319 "single_file_paths": [ 14320 "s" 14321 ], 14322 "permissions": { 14323 "actions": "a", 14324 "administration": "ad", 14325 "checks": "c", 14326 "contents": "co", 14327 "content_references": "cr", 14328 "deployments": "d", 14329 "environments": "e", 14330 "issues": "i", 14331 "metadata": "md", 14332 "members": "m", 14333 "organization_administration": "oa", 14334 "organization_hooks": "oh", 14335 "organization_plan": "op", 14336 "organization_pre_receive_hooks": "opr", 14337 "organization_projects": "op", 14338 "organization_secrets": "os", 14339 "organization_self_hosted_runners": "osh", 14340 "organization_user_blocking": "oub", 14341 "packages": "pkg", 14342 "pages": "pg", 14343 "pull_requests": "pr", 14344 "repository_hooks": "rh", 14345 "repository_projects": "rp", 14346 "repository_pre_receive_hooks": "rprh", 14347 "secrets": "s", 14348 "secret_scanning_alerts": "ssa", 14349 "security_events": "se", 14350 "single_file": "sf", 14351 "statuses": "s", 14352 "team_discussions": "td", 14353 "vulnerability_alerts": "va", 14354 "workflows": "w" 14355 }, 14356 "created_at": ` + referenceTimeStr + `, 14357 "updated_at": ` + referenceTimeStr + `, 14358 "has_multiple_single_files": false, 14359 "suspended_by": { 14360 "login": "l", 14361 "id": 1, 14362 "avatar_url": "a", 14363 "gravatar_id": "g", 14364 "name": "n", 14365 "company": "c", 14366 "blog": "b", 14367 "location": "l", 14368 "email": "e", 14369 "hireable": true, 14370 "bio": "b", 14371 "twitter_username": "t", 14372 "public_repos": 1, 14373 "followers": 1, 14374 "following": 1, 14375 "created_at": ` + referenceTimeStr + `, 14376 "suspended_at": ` + referenceTimeStr + `, 14377 "url": "u" 14378 }, 14379 "suspended_at": ` + referenceTimeStr + ` 14380 } 14381 }` 14382 14383 testJSONMarshal(t, r, want) 14384 } 14385 14386 func TestDependabotAlertEvent_Marshal(t *testing.T) { 14387 t.Parallel() 14388 testJSONMarshal(t, &DependabotAlertEvent{}, "{}") 14389 14390 e := &DependabotAlertEvent{ 14391 Action: Ptr("a"), 14392 Alert: &DependabotAlert{ 14393 Number: Ptr(1), 14394 State: Ptr("s"), 14395 Dependency: &Dependency{ 14396 Package: &VulnerabilityPackage{ 14397 Ecosystem: Ptr("e"), 14398 Name: Ptr("n"), 14399 }, 14400 ManifestPath: Ptr("mp"), 14401 Scope: Ptr("s"), 14402 }, 14403 SecurityAdvisory: &DependabotSecurityAdvisory{ 14404 GHSAID: Ptr("ghsaid"), 14405 CVEID: Ptr("cveid"), 14406 Summary: Ptr("s"), 14407 Description: Ptr("d"), 14408 Vulnerabilities: []*AdvisoryVulnerability{ 14409 { 14410 Package: &VulnerabilityPackage{ 14411 Ecosystem: Ptr("e"), 14412 Name: Ptr("n"), 14413 }, 14414 Severity: Ptr("s"), 14415 }, 14416 }, 14417 Severity: Ptr("s"), 14418 CVSS: &AdvisoryCVSS{ 14419 Score: Ptr(1.0), 14420 VectorString: Ptr("vs"), 14421 }, 14422 CWEs: []*AdvisoryCWEs{ 14423 { 14424 CWEID: Ptr("cweid"), 14425 Name: Ptr("n"), 14426 }, 14427 }, 14428 Identifiers: []*AdvisoryIdentifier{ 14429 { 14430 Value: Ptr("v"), 14431 Type: Ptr("t"), 14432 }, 14433 }, 14434 References: []*AdvisoryReference{ 14435 { 14436 URL: Ptr("u"), 14437 }, 14438 }, 14439 PublishedAt: &Timestamp{referenceTime}, 14440 UpdatedAt: &Timestamp{referenceTime}, 14441 WithdrawnAt: &Timestamp{referenceTime}, 14442 }, 14443 SecurityVulnerability: &AdvisoryVulnerability{ 14444 Package: &VulnerabilityPackage{ 14445 Ecosystem: Ptr("e"), 14446 Name: Ptr("n"), 14447 }, 14448 Severity: Ptr("s"), 14449 VulnerableVersionRange: Ptr("vvr"), 14450 FirstPatchedVersion: &FirstPatchedVersion{ 14451 Identifier: Ptr("i"), 14452 }, 14453 }, 14454 URL: Ptr("u"), 14455 HTMLURL: Ptr("hu"), 14456 CreatedAt: &Timestamp{referenceTime}, 14457 UpdatedAt: &Timestamp{referenceTime}, 14458 DismissedAt: &Timestamp{referenceTime}, 14459 DismissedBy: &User{ 14460 Login: Ptr("l"), 14461 ID: Ptr(int64(1)), 14462 NodeID: Ptr("n"), 14463 URL: Ptr("u"), 14464 ReposURL: Ptr("r"), 14465 EventsURL: Ptr("e"), 14466 AvatarURL: Ptr("a"), 14467 }, 14468 DismissedReason: Ptr("dr"), 14469 DismissedComment: Ptr("dc"), 14470 FixedAt: &Timestamp{referenceTime}, 14471 AutoDismissedAt: &Timestamp{referenceTime}, 14472 }, 14473 Repo: &Repository{ 14474 ID: Ptr(int64(1)), 14475 URL: Ptr("s"), 14476 Name: Ptr("n"), 14477 }, 14478 Organization: &Organization{ 14479 BillingEmail: Ptr("be"), 14480 Blog: Ptr("b"), 14481 Company: Ptr("c"), 14482 Email: Ptr("e"), 14483 TwitterUsername: Ptr("tu"), 14484 Location: Ptr("loc"), 14485 Name: Ptr("n"), 14486 Description: Ptr("d"), 14487 IsVerified: Ptr(true), 14488 HasOrganizationProjects: Ptr(true), 14489 HasRepositoryProjects: Ptr(true), 14490 DefaultRepoPermission: Ptr("drp"), 14491 MembersCanCreateRepos: Ptr(true), 14492 MembersCanCreateInternalRepos: Ptr(true), 14493 MembersCanCreatePrivateRepos: Ptr(true), 14494 MembersCanCreatePublicRepos: Ptr(false), 14495 MembersAllowedRepositoryCreationType: Ptr("marct"), 14496 MembersCanCreatePages: Ptr(true), 14497 MembersCanCreatePublicPages: Ptr(false), 14498 MembersCanCreatePrivatePages: Ptr(true), 14499 }, 14500 Enterprise: &Enterprise{ 14501 ID: Ptr(1), 14502 Slug: Ptr("s"), 14503 Name: Ptr("n"), 14504 NodeID: Ptr("nid"), 14505 AvatarURL: Ptr("au"), 14506 Description: Ptr("d"), 14507 WebsiteURL: Ptr("wu"), 14508 HTMLURL: Ptr("hu"), 14509 CreatedAt: &Timestamp{referenceTime}, 14510 UpdatedAt: &Timestamp{referenceTime}, 14511 }, 14512 Sender: &User{ 14513 Login: Ptr("l"), 14514 ID: Ptr(int64(1)), 14515 NodeID: Ptr("n"), 14516 URL: Ptr("u"), 14517 ReposURL: Ptr("r"), 14518 EventsURL: Ptr("e"), 14519 AvatarURL: Ptr("a"), 14520 }, 14521 Installation: &Installation{ 14522 ID: Ptr(int64(1)), 14523 NodeID: Ptr("nid"), 14524 AppID: Ptr(int64(1)), 14525 AppSlug: Ptr("as"), 14526 TargetID: Ptr(int64(1)), 14527 Account: &User{ 14528 Login: Ptr("l"), 14529 ID: Ptr(int64(1)), 14530 URL: Ptr("u"), 14531 AvatarURL: Ptr("a"), 14532 GravatarID: Ptr("g"), 14533 Name: Ptr("n"), 14534 Company: Ptr("c"), 14535 Blog: Ptr("b"), 14536 Location: Ptr("l"), 14537 Email: Ptr("e"), 14538 Hireable: Ptr(true), 14539 Bio: Ptr("b"), 14540 TwitterUsername: Ptr("t"), 14541 PublicRepos: Ptr(1), 14542 Followers: Ptr(1), 14543 Following: Ptr(1), 14544 CreatedAt: &Timestamp{referenceTime}, 14545 SuspendedAt: &Timestamp{referenceTime}, 14546 }, 14547 AccessTokensURL: Ptr("atu"), 14548 RepositoriesURL: Ptr("ru"), 14549 HTMLURL: Ptr("hu"), 14550 TargetType: Ptr("tt"), 14551 SingleFileName: Ptr("sfn"), 14552 RepositorySelection: Ptr("rs"), 14553 Events: []string{"e"}, 14554 SingleFilePaths: []string{"s"}, 14555 Permissions: &InstallationPermissions{ 14556 Actions: Ptr("a"), 14557 Administration: Ptr("ad"), 14558 Checks: Ptr("c"), 14559 Contents: Ptr("co"), 14560 ContentReferences: Ptr("cr"), 14561 Deployments: Ptr("d"), 14562 Environments: Ptr("e"), 14563 Issues: Ptr("i"), 14564 Metadata: Ptr("md"), 14565 Members: Ptr("m"), 14566 OrganizationAdministration: Ptr("oa"), 14567 OrganizationHooks: Ptr("oh"), 14568 OrganizationPlan: Ptr("op"), 14569 OrganizationPreReceiveHooks: Ptr("opr"), 14570 OrganizationProjects: Ptr("op"), 14571 OrganizationSecrets: Ptr("os"), 14572 OrganizationSelfHostedRunners: Ptr("osh"), 14573 OrganizationUserBlocking: Ptr("oub"), 14574 Packages: Ptr("pkg"), 14575 Pages: Ptr("pg"), 14576 PullRequests: Ptr("pr"), 14577 RepositoryHooks: Ptr("rh"), 14578 RepositoryProjects: Ptr("rp"), 14579 RepositoryPreReceiveHooks: Ptr("rprh"), 14580 Secrets: Ptr("s"), 14581 SecretScanningAlerts: Ptr("ssa"), 14582 SecurityEvents: Ptr("se"), 14583 SingleFile: Ptr("sf"), 14584 Statuses: Ptr("s"), 14585 TeamDiscussions: Ptr("td"), 14586 VulnerabilityAlerts: Ptr("va"), 14587 Workflows: Ptr("w"), 14588 }, 14589 CreatedAt: &Timestamp{referenceTime}, 14590 UpdatedAt: &Timestamp{referenceTime}, 14591 HasMultipleSingleFiles: Ptr(false), 14592 SuspendedBy: &User{ 14593 Login: Ptr("l"), 14594 ID: Ptr(int64(1)), 14595 URL: Ptr("u"), 14596 AvatarURL: Ptr("a"), 14597 GravatarID: Ptr("g"), 14598 Name: Ptr("n"), 14599 Company: Ptr("c"), 14600 Blog: Ptr("b"), 14601 Location: Ptr("l"), 14602 Email: Ptr("e"), 14603 Hireable: Ptr(true), 14604 Bio: Ptr("b"), 14605 TwitterUsername: Ptr("t"), 14606 PublicRepos: Ptr(1), 14607 Followers: Ptr(1), 14608 Following: Ptr(1), 14609 CreatedAt: &Timestamp{referenceTime}, 14610 SuspendedAt: &Timestamp{referenceTime}, 14611 }, 14612 SuspendedAt: &Timestamp{referenceTime}, 14613 }, 14614 } 14615 want := `{ 14616 "action": "a", 14617 "alert": { 14618 "number": 1, 14619 "state": "s", 14620 "dependency": { 14621 "package": { 14622 "ecosystem": "e", 14623 "name": "n" 14624 }, 14625 "manifest_path": "mp", 14626 "scope": "s" 14627 }, 14628 "security_advisory": { 14629 "ghsa_id": "ghsaid", 14630 "cve_id": "cveid", 14631 "summary": "s", 14632 "description": "d", 14633 "vulnerabilities": [ 14634 { 14635 "package": { 14636 "ecosystem": "e", 14637 "name": "n" 14638 }, 14639 "severity": "s" 14640 } 14641 ], 14642 "severity": "s", 14643 "cvss": { 14644 "score": 1.0, 14645 "vector_string": "vs" 14646 }, 14647 "cwes": [ 14648 { 14649 "cwe_id": "cweid", 14650 "name": "n" 14651 } 14652 ], 14653 "identifiers": [ 14654 { 14655 "value": "v", 14656 "type": "t" 14657 } 14658 ], 14659 "references": [ 14660 { 14661 "url": "u" 14662 } 14663 ], 14664 "published_at": ` + referenceTimeStr + `, 14665 "updated_at": ` + referenceTimeStr + `, 14666 "withdrawn_at": ` + referenceTimeStr + ` 14667 }, 14668 "security_vulnerability": { 14669 "package": { 14670 "ecosystem": "e", 14671 "name": "n" 14672 }, 14673 "severity": "s", 14674 "vulnerable_version_range": "vvr", 14675 "first_patched_version": { 14676 "identifier": "i" 14677 } 14678 }, 14679 "url": "u", 14680 "html_url": "hu", 14681 "created_at": ` + referenceTimeStr + `, 14682 "updated_at": ` + referenceTimeStr + `, 14683 "dismissed_at": ` + referenceTimeStr + `, 14684 "dismissed_by": { 14685 "login": "l", 14686 "id": 1, 14687 "node_id": "n", 14688 "avatar_url": "a", 14689 "url": "u", 14690 "events_url": "e", 14691 "repos_url": "r" 14692 }, 14693 "dismissed_reason": "dr", 14694 "dismissed_comment": "dc", 14695 "fixed_at": ` + referenceTimeStr + `, 14696 "auto_dismissed_at": ` + referenceTimeStr + ` 14697 }, 14698 "repository": { 14699 "id": 1, 14700 "name": "n", 14701 "url": "s" 14702 }, 14703 "organization": { 14704 "name": "n", 14705 "company": "c", 14706 "blog": "b", 14707 "location": "loc", 14708 "email": "e", 14709 "twitter_username": "tu", 14710 "description": "d", 14711 "billing_email": "be", 14712 "is_verified": true, 14713 "has_organization_projects": true, 14714 "has_repository_projects": true, 14715 "default_repository_permission": "drp", 14716 "members_can_create_repositories": true, 14717 "members_can_create_public_repositories": false, 14718 "members_can_create_private_repositories": true, 14719 "members_can_create_internal_repositories": true, 14720 "members_allowed_repository_creation_type": "marct", 14721 "members_can_create_pages": true, 14722 "members_can_create_public_pages": false, 14723 "members_can_create_private_pages": true 14724 }, 14725 "enterprise": { 14726 "id": 1, 14727 "slug": "s", 14728 "name": "n", 14729 "node_id": "nid", 14730 "avatar_url": "au", 14731 "description": "d", 14732 "website_url": "wu", 14733 "html_url": "hu", 14734 "created_at": ` + referenceTimeStr + `, 14735 "updated_at": ` + referenceTimeStr + ` 14736 }, 14737 "sender": { 14738 "login": "l", 14739 "id": 1, 14740 "node_id": "n", 14741 "avatar_url": "a", 14742 "url": "u", 14743 "events_url": "e", 14744 "repos_url": "r" 14745 }, 14746 "installation": { 14747 "id": 1, 14748 "node_id": "nid", 14749 "app_id": 1, 14750 "app_slug": "as", 14751 "target_id": 1, 14752 "account": { 14753 "login": "l", 14754 "id": 1, 14755 "avatar_url": "a", 14756 "gravatar_id": "g", 14757 "name": "n", 14758 "company": "c", 14759 "blog": "b", 14760 "location": "l", 14761 "email": "e", 14762 "hireable": true, 14763 "bio": "b", 14764 "twitter_username": "t", 14765 "public_repos": 1, 14766 "followers": 1, 14767 "following": 1, 14768 "created_at": ` + referenceTimeStr + `, 14769 "suspended_at": ` + referenceTimeStr + `, 14770 "url": "u" 14771 }, 14772 "access_tokens_url": "atu", 14773 "repositories_url": "ru", 14774 "html_url": "hu", 14775 "target_type": "tt", 14776 "single_file_name": "sfn", 14777 "repository_selection": "rs", 14778 "events": [ 14779 "e" 14780 ], 14781 "single_file_paths": [ 14782 "s" 14783 ], 14784 "permissions": { 14785 "actions": "a", 14786 "administration": "ad", 14787 "checks": "c", 14788 "contents": "co", 14789 "content_references": "cr", 14790 "deployments": "d", 14791 "environments": "e", 14792 "issues": "i", 14793 "metadata": "md", 14794 "members": "m", 14795 "organization_administration": "oa", 14796 "organization_hooks": "oh", 14797 "organization_plan": "op", 14798 "organization_pre_receive_hooks": "opr", 14799 "organization_projects": "op", 14800 "organization_secrets": "os", 14801 "organization_self_hosted_runners": "osh", 14802 "organization_user_blocking": "oub", 14803 "packages": "pkg", 14804 "pages": "pg", 14805 "pull_requests": "pr", 14806 "repository_hooks": "rh", 14807 "repository_projects": "rp", 14808 "repository_pre_receive_hooks": "rprh", 14809 "secrets": "s", 14810 "secret_scanning_alerts": "ssa", 14811 "security_events": "se", 14812 "single_file": "sf", 14813 "statuses": "s", 14814 "team_discussions": "td", 14815 "vulnerability_alerts": "va", 14816 "workflows": "w" 14817 }, 14818 "created_at": ` + referenceTimeStr + `, 14819 "updated_at": ` + referenceTimeStr + `, 14820 "has_multiple_single_files": false, 14821 "suspended_by": { 14822 "login": "l", 14823 "id": 1, 14824 "avatar_url": "a", 14825 "gravatar_id": "g", 14826 "name": "n", 14827 "company": "c", 14828 "blog": "b", 14829 "location": "l", 14830 "email": "e", 14831 "hireable": true, 14832 "bio": "b", 14833 "twitter_username": "t", 14834 "public_repos": 1, 14835 "followers": 1, 14836 "following": 1, 14837 "created_at": ` + referenceTimeStr + `, 14838 "suspended_at": ` + referenceTimeStr + `, 14839 "url": "u" 14840 }, 14841 "suspended_at": ` + referenceTimeStr + ` 14842 } 14843 }` 14844 14845 testJSONMarshal(t, e, want) 14846 } 14847 14848 func TestForkEvent_Marshal(t *testing.T) { 14849 t.Parallel() 14850 testJSONMarshal(t, &ForkEvent{}, "{}") 14851 14852 u := &ForkEvent{ 14853 Forkee: &Repository{ 14854 ID: Ptr(int64(1)), 14855 URL: Ptr("s"), 14856 Name: Ptr("n"), 14857 }, 14858 Repo: &Repository{ 14859 ID: Ptr(int64(1)), 14860 URL: Ptr("s"), 14861 Name: Ptr("n"), 14862 }, 14863 Sender: &User{ 14864 Login: Ptr("l"), 14865 ID: Ptr(int64(1)), 14866 NodeID: Ptr("n"), 14867 URL: Ptr("u"), 14868 ReposURL: Ptr("r"), 14869 EventsURL: Ptr("e"), 14870 AvatarURL: Ptr("a"), 14871 }, 14872 Installation: &Installation{ 14873 ID: Ptr(int64(1)), 14874 NodeID: Ptr("nid"), 14875 AppID: Ptr(int64(1)), 14876 AppSlug: Ptr("as"), 14877 TargetID: Ptr(int64(1)), 14878 Account: &User{ 14879 Login: Ptr("l"), 14880 ID: Ptr(int64(1)), 14881 URL: Ptr("u"), 14882 AvatarURL: Ptr("a"), 14883 GravatarID: Ptr("g"), 14884 Name: Ptr("n"), 14885 Company: Ptr("c"), 14886 Blog: Ptr("b"), 14887 Location: Ptr("l"), 14888 Email: Ptr("e"), 14889 Hireable: Ptr(true), 14890 Bio: Ptr("b"), 14891 TwitterUsername: Ptr("t"), 14892 PublicRepos: Ptr(1), 14893 Followers: Ptr(1), 14894 Following: Ptr(1), 14895 CreatedAt: &Timestamp{referenceTime}, 14896 SuspendedAt: &Timestamp{referenceTime}, 14897 }, 14898 AccessTokensURL: Ptr("atu"), 14899 RepositoriesURL: Ptr("ru"), 14900 HTMLURL: Ptr("hu"), 14901 TargetType: Ptr("tt"), 14902 SingleFileName: Ptr("sfn"), 14903 RepositorySelection: Ptr("rs"), 14904 Events: []string{"e"}, 14905 SingleFilePaths: []string{"s"}, 14906 Permissions: &InstallationPermissions{ 14907 Actions: Ptr("a"), 14908 Administration: Ptr("ad"), 14909 Checks: Ptr("c"), 14910 Contents: Ptr("co"), 14911 ContentReferences: Ptr("cr"), 14912 Deployments: Ptr("d"), 14913 Environments: Ptr("e"), 14914 Issues: Ptr("i"), 14915 Metadata: Ptr("md"), 14916 Members: Ptr("m"), 14917 OrganizationAdministration: Ptr("oa"), 14918 OrganizationHooks: Ptr("oh"), 14919 OrganizationPlan: Ptr("op"), 14920 OrganizationPreReceiveHooks: Ptr("opr"), 14921 OrganizationProjects: Ptr("op"), 14922 OrganizationSecrets: Ptr("os"), 14923 OrganizationSelfHostedRunners: Ptr("osh"), 14924 OrganizationUserBlocking: Ptr("oub"), 14925 Packages: Ptr("pkg"), 14926 Pages: Ptr("pg"), 14927 PullRequests: Ptr("pr"), 14928 RepositoryHooks: Ptr("rh"), 14929 RepositoryProjects: Ptr("rp"), 14930 RepositoryPreReceiveHooks: Ptr("rprh"), 14931 Secrets: Ptr("s"), 14932 SecretScanningAlerts: Ptr("ssa"), 14933 SecurityEvents: Ptr("se"), 14934 SingleFile: Ptr("sf"), 14935 Statuses: Ptr("s"), 14936 TeamDiscussions: Ptr("td"), 14937 VulnerabilityAlerts: Ptr("va"), 14938 Workflows: Ptr("w"), 14939 }, 14940 CreatedAt: &Timestamp{referenceTime}, 14941 UpdatedAt: &Timestamp{referenceTime}, 14942 HasMultipleSingleFiles: Ptr(false), 14943 SuspendedBy: &User{ 14944 Login: Ptr("l"), 14945 ID: Ptr(int64(1)), 14946 URL: Ptr("u"), 14947 AvatarURL: Ptr("a"), 14948 GravatarID: Ptr("g"), 14949 Name: Ptr("n"), 14950 Company: Ptr("c"), 14951 Blog: Ptr("b"), 14952 Location: Ptr("l"), 14953 Email: Ptr("e"), 14954 Hireable: Ptr(true), 14955 Bio: Ptr("b"), 14956 TwitterUsername: Ptr("t"), 14957 PublicRepos: Ptr(1), 14958 Followers: Ptr(1), 14959 Following: Ptr(1), 14960 CreatedAt: &Timestamp{referenceTime}, 14961 SuspendedAt: &Timestamp{referenceTime}, 14962 }, 14963 SuspendedAt: &Timestamp{referenceTime}, 14964 }, 14965 } 14966 14967 want := `{ 14968 "forkee": { 14969 "id": 1, 14970 "name": "n", 14971 "url": "s" 14972 }, 14973 "repository": { 14974 "id": 1, 14975 "name": "n", 14976 "url": "s" 14977 }, 14978 "sender": { 14979 "login": "l", 14980 "id": 1, 14981 "node_id": "n", 14982 "avatar_url": "a", 14983 "url": "u", 14984 "events_url": "e", 14985 "repos_url": "r" 14986 }, 14987 "installation": { 14988 "id": 1, 14989 "node_id": "nid", 14990 "app_id": 1, 14991 "app_slug": "as", 14992 "target_id": 1, 14993 "account": { 14994 "login": "l", 14995 "id": 1, 14996 "avatar_url": "a", 14997 "gravatar_id": "g", 14998 "name": "n", 14999 "company": "c", 15000 "blog": "b", 15001 "location": "l", 15002 "email": "e", 15003 "hireable": true, 15004 "bio": "b", 15005 "twitter_username": "t", 15006 "public_repos": 1, 15007 "followers": 1, 15008 "following": 1, 15009 "created_at": ` + referenceTimeStr + `, 15010 "suspended_at": ` + referenceTimeStr + `, 15011 "url": "u" 15012 }, 15013 "access_tokens_url": "atu", 15014 "repositories_url": "ru", 15015 "html_url": "hu", 15016 "target_type": "tt", 15017 "single_file_name": "sfn", 15018 "repository_selection": "rs", 15019 "events": [ 15020 "e" 15021 ], 15022 "single_file_paths": [ 15023 "s" 15024 ], 15025 "permissions": { 15026 "actions": "a", 15027 "administration": "ad", 15028 "checks": "c", 15029 "contents": "co", 15030 "content_references": "cr", 15031 "deployments": "d", 15032 "environments": "e", 15033 "issues": "i", 15034 "metadata": "md", 15035 "members": "m", 15036 "organization_administration": "oa", 15037 "organization_hooks": "oh", 15038 "organization_plan": "op", 15039 "organization_pre_receive_hooks": "opr", 15040 "organization_projects": "op", 15041 "organization_secrets": "os", 15042 "organization_self_hosted_runners": "osh", 15043 "organization_user_blocking": "oub", 15044 "packages": "pkg", 15045 "pages": "pg", 15046 "pull_requests": "pr", 15047 "repository_hooks": "rh", 15048 "repository_projects": "rp", 15049 "repository_pre_receive_hooks": "rprh", 15050 "secrets": "s", 15051 "secret_scanning_alerts": "ssa", 15052 "security_events": "se", 15053 "single_file": "sf", 15054 "statuses": "s", 15055 "team_discussions": "td", 15056 "vulnerability_alerts": "va", 15057 "workflows": "w" 15058 }, 15059 "created_at": ` + referenceTimeStr + `, 15060 "updated_at": ` + referenceTimeStr + `, 15061 "has_multiple_single_files": false, 15062 "suspended_by": { 15063 "login": "l", 15064 "id": 1, 15065 "avatar_url": "a", 15066 "gravatar_id": "g", 15067 "name": "n", 15068 "company": "c", 15069 "blog": "b", 15070 "location": "l", 15071 "email": "e", 15072 "hireable": true, 15073 "bio": "b", 15074 "twitter_username": "t", 15075 "public_repos": 1, 15076 "followers": 1, 15077 "following": 1, 15078 "created_at": ` + referenceTimeStr + `, 15079 "suspended_at": ` + referenceTimeStr + `, 15080 "url": "u" 15081 }, 15082 "suspended_at": ` + referenceTimeStr + ` 15083 } 15084 }` 15085 15086 testJSONMarshal(t, u, want) 15087 } 15088 15089 func TestGitHubAppAuthorizationEvent_Marshal(t *testing.T) { 15090 t.Parallel() 15091 testJSONMarshal(t, &GitHubAppAuthorizationEvent{}, "{}") 15092 15093 u := &GitHubAppAuthorizationEvent{ 15094 Action: Ptr("a"), 15095 Sender: &User{ 15096 Login: Ptr("l"), 15097 ID: Ptr(int64(1)), 15098 NodeID: Ptr("n"), 15099 URL: Ptr("u"), 15100 ReposURL: Ptr("r"), 15101 EventsURL: Ptr("e"), 15102 AvatarURL: Ptr("a"), 15103 }, 15104 } 15105 15106 want := `{ 15107 "action": "a", 15108 "sender": { 15109 "login": "l", 15110 "id": 1, 15111 "node_id": "n", 15112 "avatar_url": "a", 15113 "url": "u", 15114 "events_url": "e", 15115 "repos_url": "r" 15116 } 15117 }` 15118 15119 testJSONMarshal(t, u, want) 15120 } 15121 15122 func TestInstallationEvent_Marshal(t *testing.T) { 15123 t.Parallel() 15124 testJSONMarshal(t, &InstallationEvent{}, "{}") 15125 15126 u := &InstallationEvent{ 15127 Action: Ptr("a"), 15128 Repositories: []*Repository{ 15129 { 15130 ID: Ptr(int64(1)), 15131 URL: Ptr("u"), 15132 Name: Ptr("n"), 15133 }, 15134 }, 15135 Sender: &User{ 15136 Login: Ptr("l"), 15137 ID: Ptr(int64(1)), 15138 NodeID: Ptr("n"), 15139 URL: Ptr("u"), 15140 ReposURL: Ptr("r"), 15141 EventsURL: Ptr("e"), 15142 AvatarURL: Ptr("a"), 15143 }, 15144 Installation: &Installation{ 15145 ID: Ptr(int64(1)), 15146 NodeID: Ptr("nid"), 15147 AppID: Ptr(int64(1)), 15148 AppSlug: Ptr("as"), 15149 TargetID: Ptr(int64(1)), 15150 Account: &User{ 15151 Login: Ptr("l"), 15152 ID: Ptr(int64(1)), 15153 URL: Ptr("u"), 15154 AvatarURL: Ptr("a"), 15155 GravatarID: Ptr("g"), 15156 Name: Ptr("n"), 15157 Company: Ptr("c"), 15158 Blog: Ptr("b"), 15159 Location: Ptr("l"), 15160 Email: Ptr("e"), 15161 Hireable: Ptr(true), 15162 Bio: Ptr("b"), 15163 TwitterUsername: Ptr("t"), 15164 PublicRepos: Ptr(1), 15165 Followers: Ptr(1), 15166 Following: Ptr(1), 15167 CreatedAt: &Timestamp{referenceTime}, 15168 SuspendedAt: &Timestamp{referenceTime}, 15169 }, 15170 AccessTokensURL: Ptr("atu"), 15171 RepositoriesURL: Ptr("ru"), 15172 HTMLURL: Ptr("hu"), 15173 TargetType: Ptr("tt"), 15174 SingleFileName: Ptr("sfn"), 15175 RepositorySelection: Ptr("rs"), 15176 Events: []string{"e"}, 15177 SingleFilePaths: []string{"s"}, 15178 Permissions: &InstallationPermissions{ 15179 Actions: Ptr("a"), 15180 Administration: Ptr("ad"), 15181 Checks: Ptr("c"), 15182 Contents: Ptr("co"), 15183 ContentReferences: Ptr("cr"), 15184 Deployments: Ptr("d"), 15185 Environments: Ptr("e"), 15186 Issues: Ptr("i"), 15187 Metadata: Ptr("md"), 15188 Members: Ptr("m"), 15189 OrganizationAdministration: Ptr("oa"), 15190 OrganizationHooks: Ptr("oh"), 15191 OrganizationPlan: Ptr("op"), 15192 OrganizationPreReceiveHooks: Ptr("opr"), 15193 OrganizationProjects: Ptr("op"), 15194 OrganizationSecrets: Ptr("os"), 15195 OrganizationSelfHostedRunners: Ptr("osh"), 15196 OrganizationUserBlocking: Ptr("oub"), 15197 Packages: Ptr("pkg"), 15198 Pages: Ptr("pg"), 15199 PullRequests: Ptr("pr"), 15200 RepositoryHooks: Ptr("rh"), 15201 RepositoryProjects: Ptr("rp"), 15202 RepositoryPreReceiveHooks: Ptr("rprh"), 15203 Secrets: Ptr("s"), 15204 SecretScanningAlerts: Ptr("ssa"), 15205 SecurityEvents: Ptr("se"), 15206 SingleFile: Ptr("sf"), 15207 Statuses: Ptr("s"), 15208 TeamDiscussions: Ptr("td"), 15209 VulnerabilityAlerts: Ptr("va"), 15210 Workflows: Ptr("w"), 15211 }, 15212 CreatedAt: &Timestamp{referenceTime}, 15213 UpdatedAt: &Timestamp{referenceTime}, 15214 HasMultipleSingleFiles: Ptr(false), 15215 SuspendedBy: &User{ 15216 Login: Ptr("l"), 15217 ID: Ptr(int64(1)), 15218 URL: Ptr("u"), 15219 AvatarURL: Ptr("a"), 15220 GravatarID: Ptr("g"), 15221 Name: Ptr("n"), 15222 Company: Ptr("c"), 15223 Blog: Ptr("b"), 15224 Location: Ptr("l"), 15225 Email: Ptr("e"), 15226 Hireable: Ptr(true), 15227 Bio: Ptr("b"), 15228 TwitterUsername: Ptr("t"), 15229 PublicRepos: Ptr(1), 15230 Followers: Ptr(1), 15231 Following: Ptr(1), 15232 CreatedAt: &Timestamp{referenceTime}, 15233 SuspendedAt: &Timestamp{referenceTime}, 15234 }, 15235 SuspendedAt: &Timestamp{referenceTime}, 15236 }, 15237 } 15238 15239 want := `{ 15240 "action": "a", 15241 "repositories": [ 15242 { 15243 "id":1, 15244 "name":"n", 15245 "url":"u" 15246 } 15247 ], 15248 "sender": { 15249 "login": "l", 15250 "id": 1, 15251 "node_id": "n", 15252 "avatar_url": "a", 15253 "url": "u", 15254 "events_url": "e", 15255 "repos_url": "r" 15256 }, 15257 "installation": { 15258 "id": 1, 15259 "node_id": "nid", 15260 "app_id": 1, 15261 "app_slug": "as", 15262 "target_id": 1, 15263 "account": { 15264 "login": "l", 15265 "id": 1, 15266 "avatar_url": "a", 15267 "gravatar_id": "g", 15268 "name": "n", 15269 "company": "c", 15270 "blog": "b", 15271 "location": "l", 15272 "email": "e", 15273 "hireable": true, 15274 "bio": "b", 15275 "twitter_username": "t", 15276 "public_repos": 1, 15277 "followers": 1, 15278 "following": 1, 15279 "created_at": ` + referenceTimeStr + `, 15280 "suspended_at": ` + referenceTimeStr + `, 15281 "url": "u" 15282 }, 15283 "access_tokens_url": "atu", 15284 "repositories_url": "ru", 15285 "html_url": "hu", 15286 "target_type": "tt", 15287 "single_file_name": "sfn", 15288 "repository_selection": "rs", 15289 "events": [ 15290 "e" 15291 ], 15292 "single_file_paths": [ 15293 "s" 15294 ], 15295 "permissions": { 15296 "actions": "a", 15297 "administration": "ad", 15298 "checks": "c", 15299 "contents": "co", 15300 "content_references": "cr", 15301 "deployments": "d", 15302 "environments": "e", 15303 "issues": "i", 15304 "metadata": "md", 15305 "members": "m", 15306 "organization_administration": "oa", 15307 "organization_hooks": "oh", 15308 "organization_plan": "op", 15309 "organization_pre_receive_hooks": "opr", 15310 "organization_projects": "op", 15311 "organization_secrets": "os", 15312 "organization_self_hosted_runners": "osh", 15313 "organization_user_blocking": "oub", 15314 "packages": "pkg", 15315 "pages": "pg", 15316 "pull_requests": "pr", 15317 "repository_hooks": "rh", 15318 "repository_projects": "rp", 15319 "repository_pre_receive_hooks": "rprh", 15320 "secrets": "s", 15321 "secret_scanning_alerts": "ssa", 15322 "security_events": "se", 15323 "single_file": "sf", 15324 "statuses": "s", 15325 "team_discussions": "td", 15326 "vulnerability_alerts": "va", 15327 "workflows": "w" 15328 }, 15329 "created_at": ` + referenceTimeStr + `, 15330 "updated_at": ` + referenceTimeStr + `, 15331 "has_multiple_single_files": false, 15332 "suspended_by": { 15333 "login": "l", 15334 "id": 1, 15335 "avatar_url": "a", 15336 "gravatar_id": "g", 15337 "name": "n", 15338 "company": "c", 15339 "blog": "b", 15340 "location": "l", 15341 "email": "e", 15342 "hireable": true, 15343 "bio": "b", 15344 "twitter_username": "t", 15345 "public_repos": 1, 15346 "followers": 1, 15347 "following": 1, 15348 "created_at": ` + referenceTimeStr + `, 15349 "suspended_at": ` + referenceTimeStr + `, 15350 "url": "u" 15351 }, 15352 "suspended_at": ` + referenceTimeStr + ` 15353 } 15354 }` 15355 15356 testJSONMarshal(t, u, want) 15357 } 15358 15359 func TestHeadCommit_Marshal(t *testing.T) { 15360 t.Parallel() 15361 testJSONMarshal(t, &HeadCommit{}, "{}") 15362 15363 u := &HeadCommit{ 15364 Message: Ptr("m"), 15365 Author: &CommitAuthor{ 15366 Date: &Timestamp{referenceTime}, 15367 Name: Ptr("n"), 15368 Email: Ptr("e"), 15369 Login: Ptr("u"), 15370 }, 15371 URL: Ptr("u"), 15372 Distinct: Ptr(true), 15373 SHA: Ptr("s"), 15374 ID: Ptr("id"), 15375 TreeID: Ptr("tid"), 15376 Timestamp: &Timestamp{referenceTime}, 15377 Committer: &CommitAuthor{ 15378 Date: &Timestamp{referenceTime}, 15379 Name: Ptr("n"), 15380 Email: Ptr("e"), 15381 Login: Ptr("u"), 15382 }, 15383 Added: []string{"a"}, 15384 Removed: []string{"r"}, 15385 Modified: []string{"m"}, 15386 } 15387 15388 want := `{ 15389 "message": "m", 15390 "author": { 15391 "date": ` + referenceTimeStr + `, 15392 "name": "n", 15393 "email": "e", 15394 "username": "u" 15395 }, 15396 "url": "u", 15397 "distinct": true, 15398 "sha": "s", 15399 "id": "id", 15400 "tree_id": "tid", 15401 "timestamp": ` + referenceTimeStr + `, 15402 "committer": { 15403 "date": ` + referenceTimeStr + `, 15404 "name": "n", 15405 "email": "e", 15406 "username": "u" 15407 }, 15408 "added": [ 15409 "a" 15410 ], 15411 "removed": [ 15412 "r" 15413 ], 15414 "modified": [ 15415 "m" 15416 ] 15417 }` 15418 15419 testJSONMarshal(t, u, want) 15420 } 15421 15422 func TestPushEventRepository_Marshal(t *testing.T) { 15423 t.Parallel() 15424 testJSONMarshal(t, &PushEventRepository{}, "{}") 15425 15426 u := &PushEventRepository{ 15427 ID: Ptr(int64(1)), 15428 NodeID: Ptr("nid"), 15429 Name: Ptr("n"), 15430 FullName: Ptr("fn"), 15431 Owner: &User{ 15432 Login: Ptr("l"), 15433 ID: Ptr(int64(1)), 15434 AvatarURL: Ptr("a"), 15435 GravatarID: Ptr("g"), 15436 Name: Ptr("n"), 15437 Company: Ptr("c"), 15438 Blog: Ptr("b"), 15439 Location: Ptr("l"), 15440 Email: Ptr("e"), 15441 Hireable: Ptr(true), 15442 PublicRepos: Ptr(1), 15443 Followers: Ptr(1), 15444 Following: Ptr(1), 15445 CreatedAt: &Timestamp{referenceTime}, 15446 URL: Ptr("u"), 15447 }, 15448 Private: Ptr(true), 15449 Description: Ptr("d"), 15450 Fork: Ptr(true), 15451 CreatedAt: &Timestamp{referenceTime}, 15452 PushedAt: &Timestamp{referenceTime}, 15453 UpdatedAt: &Timestamp{referenceTime}, 15454 Homepage: Ptr("h"), 15455 PullsURL: Ptr("p"), 15456 Size: Ptr(1), 15457 StargazersCount: Ptr(1), 15458 WatchersCount: Ptr(1), 15459 Language: Ptr("l"), 15460 HasIssues: Ptr(true), 15461 HasDownloads: Ptr(true), 15462 HasWiki: Ptr(true), 15463 HasPages: Ptr(true), 15464 ForksCount: Ptr(1), 15465 Archived: Ptr(true), 15466 Disabled: Ptr(true), 15467 OpenIssuesCount: Ptr(1), 15468 DefaultBranch: Ptr("d"), 15469 MasterBranch: Ptr("m"), 15470 Organization: Ptr("o"), 15471 URL: Ptr("u"), 15472 ArchiveURL: Ptr("a"), 15473 HTMLURL: Ptr("h"), 15474 StatusesURL: Ptr("s"), 15475 GitURL: Ptr("g"), 15476 SSHURL: Ptr("s"), 15477 CloneURL: Ptr("c"), 15478 SVNURL: Ptr("s"), 15479 Topics: []string{"octocat", "api"}, 15480 } 15481 15482 want := `{ 15483 "id": 1, 15484 "node_id": "nid", 15485 "name": "n", 15486 "full_name": "fn", 15487 "owner": { 15488 "login": "l", 15489 "id": 1, 15490 "avatar_url": "a", 15491 "gravatar_id": "g", 15492 "name": "n", 15493 "company": "c", 15494 "blog": "b", 15495 "location": "l", 15496 "email": "e", 15497 "hireable": true, 15498 "public_repos": 1, 15499 "followers": 1, 15500 "following": 1, 15501 "created_at": ` + referenceTimeStr + `, 15502 "url": "u" 15503 }, 15504 "private": true, 15505 "description": "d", 15506 "fork": true, 15507 "created_at": ` + referenceTimeStr + `, 15508 "pushed_at": ` + referenceTimeStr + `, 15509 "updated_at": ` + referenceTimeStr + `, 15510 "homepage": "h", 15511 "pulls_url": "p", 15512 "size": 1, 15513 "stargazers_count": 1, 15514 "watchers_count": 1, 15515 "language": "l", 15516 "has_issues": true, 15517 "has_downloads": true, 15518 "has_wiki": true, 15519 "has_pages": true, 15520 "forks_count": 1, 15521 "archived": true, 15522 "disabled": true, 15523 "open_issues_count": 1, 15524 "default_branch": "d", 15525 "master_branch": "m", 15526 "organization": "o", 15527 "url": "u", 15528 "archive_url": "a", 15529 "html_url": "h", 15530 "statuses_url": "s", 15531 "git_url": "g", 15532 "ssh_url": "s", 15533 "clone_url": "c", 15534 "svn_url": "s", 15535 "topics": ["octocat","api"] 15536 }` 15537 15538 testJSONMarshal(t, u, want) 15539 } 15540 15541 func TestPushEventRepoOwner_Marshal(t *testing.T) { 15542 t.Parallel() 15543 testJSONMarshal(t, &PushEventRepoOwner{}, "{}") 15544 15545 u := &PushEventRepoOwner{ 15546 Name: Ptr("n"), 15547 Email: Ptr("e"), 15548 } 15549 15550 want := `{ 15551 "name": "n", 15552 "email": "e" 15553 }` 15554 15555 testJSONMarshal(t, u, want) 15556 } 15557 15558 func TestProjectV2Event_Marshal(t *testing.T) { 15559 t.Parallel() 15560 testJSONMarshal(t, &ProjectV2Event{}, "{}") 15561 15562 u := &ProjectV2Event{ 15563 Action: Ptr("a"), 15564 ProjectsV2: &ProjectV2{ 15565 ID: Ptr(int64(1)), 15566 NodeID: Ptr("nid"), 15567 Owner: &User{ 15568 Login: Ptr("l"), 15569 ID: Ptr(int64(1)), 15570 NodeID: Ptr("n"), 15571 URL: Ptr("u"), 15572 ReposURL: Ptr("r"), 15573 EventsURL: Ptr("e"), 15574 AvatarURL: Ptr("a"), 15575 }, 15576 Creator: &User{ 15577 Login: Ptr("l"), 15578 ID: Ptr(int64(1)), 15579 NodeID: Ptr("n"), 15580 URL: Ptr("u"), 15581 ReposURL: Ptr("r"), 15582 EventsURL: Ptr("e"), 15583 AvatarURL: Ptr("a"), 15584 }, 15585 Title: Ptr("t"), 15586 Description: Ptr("d"), 15587 Public: Ptr(true), 15588 ClosedAt: &Timestamp{referenceTime}, 15589 CreatedAt: &Timestamp{referenceTime}, 15590 UpdatedAt: &Timestamp{referenceTime}, 15591 DeletedAt: &Timestamp{referenceTime}, 15592 Number: Ptr(1), 15593 ShortDescription: Ptr("sd"), 15594 DeletedBy: &User{ 15595 Login: Ptr("l"), 15596 ID: Ptr(int64(1)), 15597 NodeID: Ptr("n"), 15598 URL: Ptr("u"), 15599 ReposURL: Ptr("r"), 15600 EventsURL: Ptr("e"), 15601 AvatarURL: Ptr("a"), 15602 }, 15603 }, 15604 Org: &Organization{ 15605 BillingEmail: Ptr("be"), 15606 Blog: Ptr("b"), 15607 Company: Ptr("c"), 15608 Email: Ptr("e"), 15609 TwitterUsername: Ptr("tu"), 15610 Location: Ptr("loc"), 15611 Name: Ptr("n"), 15612 Description: Ptr("d"), 15613 IsVerified: Ptr(true), 15614 HasOrganizationProjects: Ptr(true), 15615 HasRepositoryProjects: Ptr(true), 15616 DefaultRepoPermission: Ptr("drp"), 15617 MembersCanCreateRepos: Ptr(true), 15618 MembersCanCreateInternalRepos: Ptr(true), 15619 MembersCanCreatePrivateRepos: Ptr(true), 15620 MembersCanCreatePublicRepos: Ptr(false), 15621 MembersAllowedRepositoryCreationType: Ptr("marct"), 15622 MembersCanCreatePages: Ptr(true), 15623 MembersCanCreatePublicPages: Ptr(false), 15624 MembersCanCreatePrivatePages: Ptr(true), 15625 }, 15626 Sender: &User{ 15627 Login: Ptr("l"), 15628 ID: Ptr(int64(1)), 15629 NodeID: Ptr("n"), 15630 URL: Ptr("u"), 15631 ReposURL: Ptr("r"), 15632 EventsURL: Ptr("e"), 15633 AvatarURL: Ptr("a"), 15634 }, 15635 Installation: &Installation{ 15636 ID: Ptr(int64(1)), 15637 NodeID: Ptr("nid"), 15638 AppID: Ptr(int64(1)), 15639 AppSlug: Ptr("as"), 15640 TargetID: Ptr(int64(1)), 15641 Account: &User{ 15642 Login: Ptr("l"), 15643 ID: Ptr(int64(1)), 15644 URL: Ptr("u"), 15645 AvatarURL: Ptr("a"), 15646 GravatarID: Ptr("g"), 15647 Name: Ptr("n"), 15648 Company: Ptr("c"), 15649 Blog: Ptr("b"), 15650 Location: Ptr("l"), 15651 Email: Ptr("e"), 15652 Hireable: Ptr(true), 15653 Bio: Ptr("b"), 15654 TwitterUsername: Ptr("t"), 15655 PublicRepos: Ptr(1), 15656 Followers: Ptr(1), 15657 Following: Ptr(1), 15658 CreatedAt: &Timestamp{referenceTime}, 15659 SuspendedAt: &Timestamp{referenceTime}, 15660 }, 15661 }, 15662 } 15663 15664 want := `{ 15665 "action": "a", 15666 "projects_v2": { 15667 "id": 1, 15668 "node_id": "nid", 15669 "owner": { 15670 "login": "l", 15671 "id": 1, 15672 "node_id": "n", 15673 "avatar_url": "a", 15674 "url": "u", 15675 "events_url": "e", 15676 "repos_url": "r" 15677 }, 15678 "creator": { 15679 "login": "l", 15680 "id": 1, 15681 "node_id": "n", 15682 "avatar_url": "a", 15683 "url": "u", 15684 "events_url": "e", 15685 "repos_url": "r" 15686 }, 15687 "title": "t", 15688 "description": "d", 15689 "public": true, 15690 "closed_at": ` + referenceTimeStr + `, 15691 "created_at": ` + referenceTimeStr + `, 15692 "updated_at": ` + referenceTimeStr + `, 15693 "deleted_at": ` + referenceTimeStr + `, 15694 "number": 1, 15695 "short_description": "sd", 15696 "deleted_by": { 15697 "login": "l", 15698 "id": 1, 15699 "node_id": "n", 15700 "avatar_url": "a", 15701 "url": "u", 15702 "events_url": "e", 15703 "repos_url": "r" 15704 } 15705 }, 15706 "organization": { 15707 "name": "n", 15708 "company": "c", 15709 "blog": "b", 15710 "location": "loc", 15711 "email": "e", 15712 "twitter_username": "tu", 15713 "description": "d", 15714 "billing_email": "be", 15715 "is_verified": true, 15716 "has_organization_projects": true, 15717 "has_repository_projects": true, 15718 "default_repository_permission": "drp", 15719 "members_can_create_repositories": true, 15720 "members_can_create_public_repositories": false, 15721 "members_can_create_private_repositories": true, 15722 "members_can_create_internal_repositories": true, 15723 "members_allowed_repository_creation_type": "marct", 15724 "members_can_create_pages": true, 15725 "members_can_create_public_pages": false, 15726 "members_can_create_private_pages": true 15727 }, 15728 "sender": { 15729 "login": "l", 15730 "id": 1, 15731 "node_id": "n", 15732 "avatar_url": "a", 15733 "url": "u", 15734 "events_url": "e", 15735 "repos_url": "r" 15736 }, 15737 "installation": { 15738 "id": 1, 15739 "node_id": "nid", 15740 "app_id": 1, 15741 "app_slug": "as", 15742 "target_id": 1, 15743 "account": { 15744 "login": "l", 15745 "id": 1, 15746 "avatar_url": "a", 15747 "gravatar_id": "g", 15748 "name": "n", 15749 "company": "c", 15750 "blog": "b", 15751 "location": "l", 15752 "email": "e", 15753 "hireable": true, 15754 "bio": "b", 15755 "twitter_username": "t", 15756 "public_repos": 1, 15757 "followers": 1, 15758 "following": 1, 15759 "created_at": ` + referenceTimeStr + `, 15760 "suspended_at": ` + referenceTimeStr + `, 15761 "url": "u" 15762 } 15763 } 15764 }` 15765 15766 testJSONMarshal(t, u, want) 15767 } 15768 15769 func TestProjectV2ItemEvent_Marshal(t *testing.T) { 15770 t.Parallel() 15771 testJSONMarshal(t, &ProjectV2ItemEvent{}, "{}") 15772 15773 u := &ProjectV2ItemEvent{ 15774 Action: Ptr("a"), 15775 Changes: &ProjectV2ItemChange{ 15776 ArchivedAt: &ArchivedAt{ 15777 From: &Timestamp{referenceTime}, 15778 To: &Timestamp{referenceTime}, 15779 }, 15780 }, 15781 ProjectV2Item: &ProjectV2Item{ 15782 ID: Ptr(int64(1)), 15783 NodeID: Ptr("nid"), 15784 ProjectNodeID: Ptr("pnid"), 15785 ContentNodeID: Ptr("cnid"), 15786 ContentType: Ptr("ct"), 15787 Creator: &User{ 15788 Login: Ptr("l"), 15789 ID: Ptr(int64(1)), 15790 NodeID: Ptr("n"), 15791 URL: Ptr("u"), 15792 ReposURL: Ptr("r"), 15793 EventsURL: Ptr("e"), 15794 AvatarURL: Ptr("a"), 15795 }, 15796 CreatedAt: &Timestamp{referenceTime}, 15797 UpdatedAt: &Timestamp{referenceTime}, 15798 ArchivedAt: &Timestamp{referenceTime}, 15799 }, 15800 Org: &Organization{ 15801 BillingEmail: Ptr("be"), 15802 Blog: Ptr("b"), 15803 Company: Ptr("c"), 15804 Email: Ptr("e"), 15805 TwitterUsername: Ptr("tu"), 15806 Location: Ptr("loc"), 15807 Name: Ptr("n"), 15808 Description: Ptr("d"), 15809 IsVerified: Ptr(true), 15810 HasOrganizationProjects: Ptr(true), 15811 HasRepositoryProjects: Ptr(true), 15812 DefaultRepoPermission: Ptr("drp"), 15813 MembersCanCreateRepos: Ptr(true), 15814 MembersCanCreateInternalRepos: Ptr(true), 15815 MembersCanCreatePrivateRepos: Ptr(true), 15816 MembersCanCreatePublicRepos: Ptr(false), 15817 MembersAllowedRepositoryCreationType: Ptr("marct"), 15818 MembersCanCreatePages: Ptr(true), 15819 MembersCanCreatePublicPages: Ptr(false), 15820 MembersCanCreatePrivatePages: Ptr(true), 15821 }, 15822 Sender: &User{ 15823 Login: Ptr("l"), 15824 ID: Ptr(int64(1)), 15825 NodeID: Ptr("n"), 15826 URL: Ptr("u"), 15827 ReposURL: Ptr("r"), 15828 EventsURL: Ptr("e"), 15829 AvatarURL: Ptr("a"), 15830 }, 15831 Installation: &Installation{ 15832 ID: Ptr(int64(1)), 15833 NodeID: Ptr("nid"), 15834 AppID: Ptr(int64(1)), 15835 AppSlug: Ptr("as"), 15836 TargetID: Ptr(int64(1)), 15837 Account: &User{ 15838 Login: Ptr("l"), 15839 ID: Ptr(int64(1)), 15840 URL: Ptr("u"), 15841 AvatarURL: Ptr("a"), 15842 GravatarID: Ptr("g"), 15843 Name: Ptr("n"), 15844 Company: Ptr("c"), 15845 Blog: Ptr("b"), 15846 Location: Ptr("l"), 15847 Email: Ptr("e"), 15848 Hireable: Ptr(true), 15849 Bio: Ptr("b"), 15850 TwitterUsername: Ptr("t"), 15851 PublicRepos: Ptr(1), 15852 Followers: Ptr(1), 15853 Following: Ptr(1), 15854 CreatedAt: &Timestamp{referenceTime}, 15855 SuspendedAt: &Timestamp{referenceTime}, 15856 }, 15857 }, 15858 } 15859 15860 want := `{ 15861 "action": "a", 15862 "changes": { 15863 "archived_at": { 15864 "from": ` + referenceTimeStr + `, 15865 "to": ` + referenceTimeStr + ` 15866 } 15867 }, 15868 "projects_v2_item": { 15869 "id": 1, 15870 "node_id": "nid", 15871 "project_node_id": "pnid", 15872 "content_node_id": "cnid", 15873 "content_type": "ct", 15874 "creator": { 15875 "login": "l", 15876 "id": 1, 15877 "node_id": "n", 15878 "avatar_url": "a", 15879 "url": "u", 15880 "events_url": "e", 15881 "repos_url": "r" 15882 }, 15883 "created_at": ` + referenceTimeStr + `, 15884 "updated_at": ` + referenceTimeStr + `, 15885 "archived_at": ` + referenceTimeStr + ` 15886 }, 15887 "organization": { 15888 "name": "n", 15889 "company": "c", 15890 "blog": "b", 15891 "location": "loc", 15892 "email": "e", 15893 "twitter_username": "tu", 15894 "description": "d", 15895 "billing_email": "be", 15896 "is_verified": true, 15897 "has_organization_projects": true, 15898 "has_repository_projects": true, 15899 "default_repository_permission": "drp", 15900 "members_can_create_repositories": true, 15901 "members_can_create_public_repositories": false, 15902 "members_can_create_private_repositories": true, 15903 "members_can_create_internal_repositories": true, 15904 "members_allowed_repository_creation_type": "marct", 15905 "members_can_create_pages": true, 15906 "members_can_create_public_pages": false, 15907 "members_can_create_private_pages": true 15908 }, 15909 "sender": { 15910 "login": "l", 15911 "id": 1, 15912 "node_id": "n", 15913 "avatar_url": "a", 15914 "url": "u", 15915 "events_url": "e", 15916 "repos_url": "r" 15917 }, 15918 "installation": { 15919 "id": 1, 15920 "node_id": "nid", 15921 "app_id": 1, 15922 "app_slug": "as", 15923 "target_id": 1, 15924 "account": { 15925 "login": "l", 15926 "id": 1, 15927 "avatar_url": "a", 15928 "gravatar_id": "g", 15929 "name": "n", 15930 "company": "c", 15931 "blog": "b", 15932 "location": "l", 15933 "email": "e", 15934 "hireable": true, 15935 "bio": "b", 15936 "twitter_username": "t", 15937 "public_repos": 1, 15938 "followers": 1, 15939 "following": 1, 15940 "created_at": ` + referenceTimeStr + `, 15941 "suspended_at": ` + referenceTimeStr + `, 15942 "url": "u" 15943 } 15944 } 15945 }` 15946 15947 testJSONMarshal(t, u, want) 15948 } 15949 15950 func TestPullRequestEvent_Marshal(t *testing.T) { 15951 t.Parallel() 15952 testJSONMarshal(t, &PullRequestEvent{}, "{}") 15953 15954 u := &PullRequestEvent{ 15955 Action: Ptr("a"), 15956 Assignee: &User{ 15957 Login: Ptr("l"), 15958 ID: Ptr(int64(1)), 15959 NodeID: Ptr("n"), 15960 URL: Ptr("u"), 15961 ReposURL: Ptr("r"), 15962 EventsURL: Ptr("e"), 15963 AvatarURL: Ptr("a"), 15964 }, 15965 Number: Ptr(1), 15966 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 15967 Changes: &EditChange{ 15968 Title: &EditTitle{ 15969 From: Ptr("TitleFrom"), 15970 }, 15971 Body: &EditBody{ 15972 From: Ptr("BodyFrom"), 15973 }, 15974 Base: &EditBase{ 15975 Ref: &EditRef{ 15976 From: Ptr("BaseRefFrom"), 15977 }, 15978 SHA: &EditSHA{ 15979 From: Ptr("BaseSHAFrom"), 15980 }, 15981 }, 15982 }, 15983 RequestedReviewer: &User{ 15984 Login: Ptr("l"), 15985 ID: Ptr(int64(1)), 15986 NodeID: Ptr("n"), 15987 URL: Ptr("u"), 15988 ReposURL: Ptr("r"), 15989 EventsURL: Ptr("e"), 15990 AvatarURL: Ptr("a"), 15991 }, 15992 RequestedTeam: &Team{ID: Ptr(int64(1))}, 15993 Label: &Label{ID: Ptr(int64(1))}, 15994 Before: Ptr("before"), 15995 After: Ptr("after"), 15996 Repo: &Repository{ 15997 ID: Ptr(int64(1)), 15998 URL: Ptr("s"), 15999 Name: Ptr("n"), 16000 }, 16001 PerformedViaGithubApp: &App{ 16002 ID: Ptr(int64(1)), 16003 NodeID: Ptr("n"), 16004 Slug: Ptr("s"), 16005 Name: Ptr("n"), 16006 Description: Ptr("d"), 16007 ExternalURL: Ptr("e"), 16008 HTMLURL: Ptr("h"), 16009 }, 16010 Organization: &Organization{ 16011 BillingEmail: Ptr("be"), 16012 Blog: Ptr("b"), 16013 Company: Ptr("c"), 16014 Email: Ptr("e"), 16015 TwitterUsername: Ptr("tu"), 16016 Location: Ptr("loc"), 16017 Name: Ptr("n"), 16018 Description: Ptr("d"), 16019 IsVerified: Ptr(true), 16020 HasOrganizationProjects: Ptr(true), 16021 HasRepositoryProjects: Ptr(true), 16022 DefaultRepoPermission: Ptr("drp"), 16023 MembersCanCreateRepos: Ptr(true), 16024 MembersCanCreateInternalRepos: Ptr(true), 16025 MembersCanCreatePrivateRepos: Ptr(true), 16026 MembersCanCreatePublicRepos: Ptr(false), 16027 MembersAllowedRepositoryCreationType: Ptr("marct"), 16028 MembersCanCreatePages: Ptr(true), 16029 MembersCanCreatePublicPages: Ptr(false), 16030 MembersCanCreatePrivatePages: Ptr(true), 16031 }, 16032 Sender: &User{ 16033 Login: Ptr("l"), 16034 ID: Ptr(int64(1)), 16035 NodeID: Ptr("n"), 16036 URL: Ptr("u"), 16037 ReposURL: Ptr("r"), 16038 EventsURL: Ptr("e"), 16039 AvatarURL: Ptr("a"), 16040 }, 16041 Installation: &Installation{ 16042 ID: Ptr(int64(1)), 16043 NodeID: Ptr("nid"), 16044 AppID: Ptr(int64(1)), 16045 AppSlug: Ptr("as"), 16046 TargetID: Ptr(int64(1)), 16047 Account: &User{ 16048 Login: Ptr("l"), 16049 ID: Ptr(int64(1)), 16050 URL: Ptr("u"), 16051 AvatarURL: Ptr("a"), 16052 GravatarID: Ptr("g"), 16053 Name: Ptr("n"), 16054 Company: Ptr("c"), 16055 Blog: Ptr("b"), 16056 Location: Ptr("l"), 16057 Email: Ptr("e"), 16058 Hireable: Ptr(true), 16059 Bio: Ptr("b"), 16060 TwitterUsername: Ptr("t"), 16061 PublicRepos: Ptr(1), 16062 Followers: Ptr(1), 16063 Following: Ptr(1), 16064 CreatedAt: &Timestamp{referenceTime}, 16065 SuspendedAt: &Timestamp{referenceTime}, 16066 }, 16067 AccessTokensURL: Ptr("atu"), 16068 RepositoriesURL: Ptr("ru"), 16069 HTMLURL: Ptr("hu"), 16070 TargetType: Ptr("tt"), 16071 SingleFileName: Ptr("sfn"), 16072 RepositorySelection: Ptr("rs"), 16073 Events: []string{"e"}, 16074 SingleFilePaths: []string{"s"}, 16075 Permissions: &InstallationPermissions{ 16076 Actions: Ptr("a"), 16077 Administration: Ptr("ad"), 16078 Checks: Ptr("c"), 16079 Contents: Ptr("co"), 16080 ContentReferences: Ptr("cr"), 16081 Deployments: Ptr("d"), 16082 Environments: Ptr("e"), 16083 Issues: Ptr("i"), 16084 Metadata: Ptr("md"), 16085 Members: Ptr("m"), 16086 OrganizationAdministration: Ptr("oa"), 16087 OrganizationHooks: Ptr("oh"), 16088 OrganizationPlan: Ptr("op"), 16089 OrganizationPreReceiveHooks: Ptr("opr"), 16090 OrganizationProjects: Ptr("op"), 16091 OrganizationSecrets: Ptr("os"), 16092 OrganizationSelfHostedRunners: Ptr("osh"), 16093 OrganizationUserBlocking: Ptr("oub"), 16094 Packages: Ptr("pkg"), 16095 Pages: Ptr("pg"), 16096 PullRequests: Ptr("pr"), 16097 RepositoryHooks: Ptr("rh"), 16098 RepositoryProjects: Ptr("rp"), 16099 RepositoryPreReceiveHooks: Ptr("rprh"), 16100 Secrets: Ptr("s"), 16101 SecretScanningAlerts: Ptr("ssa"), 16102 SecurityEvents: Ptr("se"), 16103 SingleFile: Ptr("sf"), 16104 Statuses: Ptr("s"), 16105 TeamDiscussions: Ptr("td"), 16106 VulnerabilityAlerts: Ptr("va"), 16107 Workflows: Ptr("w"), 16108 }, 16109 CreatedAt: &Timestamp{referenceTime}, 16110 UpdatedAt: &Timestamp{referenceTime}, 16111 HasMultipleSingleFiles: Ptr(false), 16112 SuspendedBy: &User{ 16113 Login: Ptr("l"), 16114 ID: Ptr(int64(1)), 16115 URL: Ptr("u"), 16116 AvatarURL: Ptr("a"), 16117 GravatarID: Ptr("g"), 16118 Name: Ptr("n"), 16119 Company: Ptr("c"), 16120 Blog: Ptr("b"), 16121 Location: Ptr("l"), 16122 Email: Ptr("e"), 16123 Hireable: Ptr(true), 16124 Bio: Ptr("b"), 16125 TwitterUsername: Ptr("t"), 16126 PublicRepos: Ptr(1), 16127 Followers: Ptr(1), 16128 Following: Ptr(1), 16129 CreatedAt: &Timestamp{referenceTime}, 16130 SuspendedAt: &Timestamp{referenceTime}, 16131 }, 16132 SuspendedAt: &Timestamp{referenceTime}, 16133 }, 16134 } 16135 16136 want := `{ 16137 "action": "a", 16138 "assignee": { 16139 "login": "l", 16140 "id": 1, 16141 "node_id": "n", 16142 "avatar_url": "a", 16143 "url": "u", 16144 "events_url": "e", 16145 "repos_url": "r" 16146 }, 16147 "number": 1, 16148 "pull_request": { 16149 "id": 1 16150 }, 16151 "changes": { 16152 "title": { 16153 "from": "TitleFrom" 16154 }, 16155 "body": { 16156 "from": "BodyFrom" 16157 }, 16158 "base": { 16159 "ref": { 16160 "from": "BaseRefFrom" 16161 }, 16162 "sha": { 16163 "from": "BaseSHAFrom" 16164 } 16165 } 16166 }, 16167 "requested_reviewer": { 16168 "login": "l", 16169 "id": 1, 16170 "node_id": "n", 16171 "avatar_url": "a", 16172 "url": "u", 16173 "events_url": "e", 16174 "repos_url": "r" 16175 }, 16176 "requested_team": { 16177 "id": 1 16178 }, 16179 "label": { 16180 "id": 1 16181 }, 16182 "before": "before", 16183 "after": "after", 16184 "repository": { 16185 "id": 1, 16186 "name": "n", 16187 "url": "s" 16188 }, 16189 "performed_via_github_app": { 16190 "id": 1, 16191 "node_id": "n", 16192 "slug": "s", 16193 "name": "n", 16194 "description": "d", 16195 "external_url": "e", 16196 "html_url": "h" 16197 }, 16198 "organization": { 16199 "name": "n", 16200 "company": "c", 16201 "blog": "b", 16202 "location": "loc", 16203 "email": "e", 16204 "twitter_username": "tu", 16205 "description": "d", 16206 "billing_email": "be", 16207 "is_verified": true, 16208 "has_organization_projects": true, 16209 "has_repository_projects": true, 16210 "default_repository_permission": "drp", 16211 "members_can_create_repositories": true, 16212 "members_can_create_public_repositories": false, 16213 "members_can_create_private_repositories": true, 16214 "members_can_create_internal_repositories": true, 16215 "members_allowed_repository_creation_type": "marct", 16216 "members_can_create_pages": true, 16217 "members_can_create_public_pages": false, 16218 "members_can_create_private_pages": true 16219 }, 16220 "sender": { 16221 "login": "l", 16222 "id": 1, 16223 "node_id": "n", 16224 "avatar_url": "a", 16225 "url": "u", 16226 "events_url": "e", 16227 "repos_url": "r" 16228 }, 16229 "installation": { 16230 "id": 1, 16231 "node_id": "nid", 16232 "app_id": 1, 16233 "app_slug": "as", 16234 "target_id": 1, 16235 "account": { 16236 "login": "l", 16237 "id": 1, 16238 "avatar_url": "a", 16239 "gravatar_id": "g", 16240 "name": "n", 16241 "company": "c", 16242 "blog": "b", 16243 "location": "l", 16244 "email": "e", 16245 "hireable": true, 16246 "bio": "b", 16247 "twitter_username": "t", 16248 "public_repos": 1, 16249 "followers": 1, 16250 "following": 1, 16251 "created_at": ` + referenceTimeStr + `, 16252 "suspended_at": ` + referenceTimeStr + `, 16253 "url": "u" 16254 }, 16255 "access_tokens_url": "atu", 16256 "repositories_url": "ru", 16257 "html_url": "hu", 16258 "target_type": "tt", 16259 "single_file_name": "sfn", 16260 "repository_selection": "rs", 16261 "events": [ 16262 "e" 16263 ], 16264 "single_file_paths": [ 16265 "s" 16266 ], 16267 "permissions": { 16268 "actions": "a", 16269 "administration": "ad", 16270 "checks": "c", 16271 "contents": "co", 16272 "content_references": "cr", 16273 "deployments": "d", 16274 "environments": "e", 16275 "issues": "i", 16276 "metadata": "md", 16277 "members": "m", 16278 "organization_administration": "oa", 16279 "organization_hooks": "oh", 16280 "organization_plan": "op", 16281 "organization_pre_receive_hooks": "opr", 16282 "organization_projects": "op", 16283 "organization_secrets": "os", 16284 "organization_self_hosted_runners": "osh", 16285 "organization_user_blocking": "oub", 16286 "packages": "pkg", 16287 "pages": "pg", 16288 "pull_requests": "pr", 16289 "repository_hooks": "rh", 16290 "repository_projects": "rp", 16291 "repository_pre_receive_hooks": "rprh", 16292 "secrets": "s", 16293 "secret_scanning_alerts": "ssa", 16294 "security_events": "se", 16295 "single_file": "sf", 16296 "statuses": "s", 16297 "team_discussions": "td", 16298 "vulnerability_alerts": "va", 16299 "workflows": "w" 16300 }, 16301 "created_at": ` + referenceTimeStr + `, 16302 "updated_at": ` + referenceTimeStr + `, 16303 "has_multiple_single_files": false, 16304 "suspended_by": { 16305 "login": "l", 16306 "id": 1, 16307 "avatar_url": "a", 16308 "gravatar_id": "g", 16309 "name": "n", 16310 "company": "c", 16311 "blog": "b", 16312 "location": "l", 16313 "email": "e", 16314 "hireable": true, 16315 "bio": "b", 16316 "twitter_username": "t", 16317 "public_repos": 1, 16318 "followers": 1, 16319 "following": 1, 16320 "created_at": ` + referenceTimeStr + `, 16321 "suspended_at": ` + referenceTimeStr + `, 16322 "url": "u" 16323 }, 16324 "suspended_at": ` + referenceTimeStr + ` 16325 } 16326 }` 16327 16328 testJSONMarshal(t, u, want) 16329 } 16330 16331 func TestPullRequestReviewCommentEvent_Marshal(t *testing.T) { 16332 t.Parallel() 16333 testJSONMarshal(t, &PullRequestReviewCommentEvent{}, "{}") 16334 16335 u := &PullRequestReviewCommentEvent{ 16336 Action: Ptr("a"), 16337 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 16338 Comment: &PullRequestComment{ID: Ptr(int64(1))}, 16339 Changes: &EditChange{ 16340 Title: &EditTitle{ 16341 From: Ptr("TitleFrom"), 16342 }, 16343 Body: &EditBody{ 16344 From: Ptr("BodyFrom"), 16345 }, 16346 Base: &EditBase{ 16347 Ref: &EditRef{ 16348 From: Ptr("BaseRefFrom"), 16349 }, 16350 SHA: &EditSHA{ 16351 From: Ptr("BaseSHAFrom"), 16352 }, 16353 }, 16354 }, 16355 Repo: &Repository{ 16356 ID: Ptr(int64(1)), 16357 URL: Ptr("s"), 16358 Name: Ptr("n"), 16359 }, 16360 Sender: &User{ 16361 Login: Ptr("l"), 16362 ID: Ptr(int64(1)), 16363 NodeID: Ptr("n"), 16364 URL: Ptr("u"), 16365 ReposURL: Ptr("r"), 16366 EventsURL: Ptr("e"), 16367 AvatarURL: Ptr("a"), 16368 }, 16369 Installation: &Installation{ 16370 ID: Ptr(int64(1)), 16371 NodeID: Ptr("nid"), 16372 AppID: Ptr(int64(1)), 16373 AppSlug: Ptr("as"), 16374 TargetID: Ptr(int64(1)), 16375 Account: &User{ 16376 Login: Ptr("l"), 16377 ID: Ptr(int64(1)), 16378 URL: Ptr("u"), 16379 AvatarURL: Ptr("a"), 16380 GravatarID: Ptr("g"), 16381 Name: Ptr("n"), 16382 Company: Ptr("c"), 16383 Blog: Ptr("b"), 16384 Location: Ptr("l"), 16385 Email: Ptr("e"), 16386 Hireable: Ptr(true), 16387 Bio: Ptr("b"), 16388 TwitterUsername: Ptr("t"), 16389 PublicRepos: Ptr(1), 16390 Followers: Ptr(1), 16391 Following: Ptr(1), 16392 CreatedAt: &Timestamp{referenceTime}, 16393 SuspendedAt: &Timestamp{referenceTime}, 16394 }, 16395 AccessTokensURL: Ptr("atu"), 16396 RepositoriesURL: Ptr("ru"), 16397 HTMLURL: Ptr("hu"), 16398 TargetType: Ptr("tt"), 16399 SingleFileName: Ptr("sfn"), 16400 RepositorySelection: Ptr("rs"), 16401 Events: []string{"e"}, 16402 SingleFilePaths: []string{"s"}, 16403 Permissions: &InstallationPermissions{ 16404 Actions: Ptr("a"), 16405 Administration: Ptr("ad"), 16406 Checks: Ptr("c"), 16407 Contents: Ptr("co"), 16408 ContentReferences: Ptr("cr"), 16409 Deployments: Ptr("d"), 16410 Environments: Ptr("e"), 16411 Issues: Ptr("i"), 16412 Metadata: Ptr("md"), 16413 Members: Ptr("m"), 16414 OrganizationAdministration: Ptr("oa"), 16415 OrganizationHooks: Ptr("oh"), 16416 OrganizationPlan: Ptr("op"), 16417 OrganizationPreReceiveHooks: Ptr("opr"), 16418 OrganizationProjects: Ptr("op"), 16419 OrganizationSecrets: Ptr("os"), 16420 OrganizationSelfHostedRunners: Ptr("osh"), 16421 OrganizationUserBlocking: Ptr("oub"), 16422 Packages: Ptr("pkg"), 16423 Pages: Ptr("pg"), 16424 PullRequests: Ptr("pr"), 16425 RepositoryHooks: Ptr("rh"), 16426 RepositoryProjects: Ptr("rp"), 16427 RepositoryPreReceiveHooks: Ptr("rprh"), 16428 Secrets: Ptr("s"), 16429 SecretScanningAlerts: Ptr("ssa"), 16430 SecurityEvents: Ptr("se"), 16431 SingleFile: Ptr("sf"), 16432 Statuses: Ptr("s"), 16433 TeamDiscussions: Ptr("td"), 16434 VulnerabilityAlerts: Ptr("va"), 16435 Workflows: Ptr("w"), 16436 }, 16437 CreatedAt: &Timestamp{referenceTime}, 16438 UpdatedAt: &Timestamp{referenceTime}, 16439 HasMultipleSingleFiles: Ptr(false), 16440 SuspendedBy: &User{ 16441 Login: Ptr("l"), 16442 ID: Ptr(int64(1)), 16443 URL: Ptr("u"), 16444 AvatarURL: Ptr("a"), 16445 GravatarID: Ptr("g"), 16446 Name: Ptr("n"), 16447 Company: Ptr("c"), 16448 Blog: Ptr("b"), 16449 Location: Ptr("l"), 16450 Email: Ptr("e"), 16451 Hireable: Ptr(true), 16452 Bio: Ptr("b"), 16453 TwitterUsername: Ptr("t"), 16454 PublicRepos: Ptr(1), 16455 Followers: Ptr(1), 16456 Following: Ptr(1), 16457 CreatedAt: &Timestamp{referenceTime}, 16458 SuspendedAt: &Timestamp{referenceTime}, 16459 }, 16460 SuspendedAt: &Timestamp{referenceTime}, 16461 }, 16462 } 16463 16464 want := `{ 16465 "action": "a", 16466 "pull_request": { 16467 "id": 1 16468 }, 16469 "comment": { 16470 "id": 1 16471 }, 16472 "changes": { 16473 "title": { 16474 "from": "TitleFrom" 16475 }, 16476 "body": { 16477 "from": "BodyFrom" 16478 }, 16479 "base": { 16480 "ref": { 16481 "from": "BaseRefFrom" 16482 }, 16483 "sha": { 16484 "from": "BaseSHAFrom" 16485 } 16486 } 16487 }, 16488 "repository": { 16489 "id": 1, 16490 "name": "n", 16491 "url": "s" 16492 }, 16493 "sender": { 16494 "login": "l", 16495 "id": 1, 16496 "node_id": "n", 16497 "avatar_url": "a", 16498 "url": "u", 16499 "events_url": "e", 16500 "repos_url": "r" 16501 }, 16502 "installation": { 16503 "id": 1, 16504 "node_id": "nid", 16505 "app_id": 1, 16506 "app_slug": "as", 16507 "target_id": 1, 16508 "account": { 16509 "login": "l", 16510 "id": 1, 16511 "avatar_url": "a", 16512 "gravatar_id": "g", 16513 "name": "n", 16514 "company": "c", 16515 "blog": "b", 16516 "location": "l", 16517 "email": "e", 16518 "hireable": true, 16519 "bio": "b", 16520 "twitter_username": "t", 16521 "public_repos": 1, 16522 "followers": 1, 16523 "following": 1, 16524 "created_at": ` + referenceTimeStr + `, 16525 "suspended_at": ` + referenceTimeStr + `, 16526 "url": "u" 16527 }, 16528 "access_tokens_url": "atu", 16529 "repositories_url": "ru", 16530 "html_url": "hu", 16531 "target_type": "tt", 16532 "single_file_name": "sfn", 16533 "repository_selection": "rs", 16534 "events": [ 16535 "e" 16536 ], 16537 "single_file_paths": [ 16538 "s" 16539 ], 16540 "permissions": { 16541 "actions": "a", 16542 "administration": "ad", 16543 "checks": "c", 16544 "contents": "co", 16545 "content_references": "cr", 16546 "deployments": "d", 16547 "environments": "e", 16548 "issues": "i", 16549 "metadata": "md", 16550 "members": "m", 16551 "organization_administration": "oa", 16552 "organization_hooks": "oh", 16553 "organization_plan": "op", 16554 "organization_pre_receive_hooks": "opr", 16555 "organization_projects": "op", 16556 "organization_secrets": "os", 16557 "organization_self_hosted_runners": "osh", 16558 "organization_user_blocking": "oub", 16559 "packages": "pkg", 16560 "pages": "pg", 16561 "pull_requests": "pr", 16562 "repository_hooks": "rh", 16563 "repository_projects": "rp", 16564 "repository_pre_receive_hooks": "rprh", 16565 "secrets": "s", 16566 "secret_scanning_alerts": "ssa", 16567 "security_events": "se", 16568 "single_file": "sf", 16569 "statuses": "s", 16570 "team_discussions": "td", 16571 "vulnerability_alerts": "va", 16572 "workflows": "w" 16573 }, 16574 "created_at": ` + referenceTimeStr + `, 16575 "updated_at": ` + referenceTimeStr + `, 16576 "has_multiple_single_files": false, 16577 "suspended_by": { 16578 "login": "l", 16579 "id": 1, 16580 "avatar_url": "a", 16581 "gravatar_id": "g", 16582 "name": "n", 16583 "company": "c", 16584 "blog": "b", 16585 "location": "l", 16586 "email": "e", 16587 "hireable": true, 16588 "bio": "b", 16589 "twitter_username": "t", 16590 "public_repos": 1, 16591 "followers": 1, 16592 "following": 1, 16593 "created_at": ` + referenceTimeStr + `, 16594 "suspended_at": ` + referenceTimeStr + `, 16595 "url": "u" 16596 }, 16597 "suspended_at": ` + referenceTimeStr + ` 16598 } 16599 }` 16600 16601 testJSONMarshal(t, u, want) 16602 } 16603 16604 func TestPullRequestReviewThreadEvent_Marshal(t *testing.T) { 16605 t.Parallel() 16606 testJSONMarshal(t, &PullRequestReviewThreadEvent{}, "{}") 16607 16608 u := &PullRequestReviewThreadEvent{ 16609 Action: Ptr("a"), 16610 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 16611 Thread: &PullRequestThread{ 16612 Comments: []*PullRequestComment{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}}, 16613 }, 16614 Repo: &Repository{ 16615 ID: Ptr(int64(1)), 16616 URL: Ptr("s"), 16617 Name: Ptr("n"), 16618 }, 16619 Sender: &User{ 16620 Login: Ptr("l"), 16621 ID: Ptr(int64(1)), 16622 NodeID: Ptr("n"), 16623 URL: Ptr("u"), 16624 ReposURL: Ptr("r"), 16625 EventsURL: Ptr("e"), 16626 AvatarURL: Ptr("a"), 16627 }, 16628 Installation: &Installation{ 16629 ID: Ptr(int64(1)), 16630 NodeID: Ptr("nid"), 16631 AppID: Ptr(int64(1)), 16632 AppSlug: Ptr("as"), 16633 TargetID: Ptr(int64(1)), 16634 Account: &User{ 16635 Login: Ptr("l"), 16636 ID: Ptr(int64(1)), 16637 URL: Ptr("u"), 16638 AvatarURL: Ptr("a"), 16639 GravatarID: Ptr("g"), 16640 Name: Ptr("n"), 16641 Company: Ptr("c"), 16642 Blog: Ptr("b"), 16643 Location: Ptr("l"), 16644 Email: Ptr("e"), 16645 Hireable: Ptr(true), 16646 Bio: Ptr("b"), 16647 TwitterUsername: Ptr("t"), 16648 PublicRepos: Ptr(1), 16649 Followers: Ptr(1), 16650 Following: Ptr(1), 16651 CreatedAt: &Timestamp{referenceTime}, 16652 SuspendedAt: &Timestamp{referenceTime}, 16653 }, 16654 AccessTokensURL: Ptr("atu"), 16655 RepositoriesURL: Ptr("ru"), 16656 HTMLURL: Ptr("hu"), 16657 TargetType: Ptr("tt"), 16658 SingleFileName: Ptr("sfn"), 16659 RepositorySelection: Ptr("rs"), 16660 Events: []string{"e"}, 16661 SingleFilePaths: []string{"s"}, 16662 Permissions: &InstallationPermissions{ 16663 Actions: Ptr("a"), 16664 Administration: Ptr("ad"), 16665 Checks: Ptr("c"), 16666 Contents: Ptr("co"), 16667 ContentReferences: Ptr("cr"), 16668 Deployments: Ptr("d"), 16669 Environments: Ptr("e"), 16670 Issues: Ptr("i"), 16671 Metadata: Ptr("md"), 16672 Members: Ptr("m"), 16673 OrganizationAdministration: Ptr("oa"), 16674 OrganizationHooks: Ptr("oh"), 16675 OrganizationPlan: Ptr("op"), 16676 OrganizationPreReceiveHooks: Ptr("opr"), 16677 OrganizationProjects: Ptr("op"), 16678 OrganizationSecrets: Ptr("os"), 16679 OrganizationSelfHostedRunners: Ptr("osh"), 16680 OrganizationUserBlocking: Ptr("oub"), 16681 Packages: Ptr("pkg"), 16682 Pages: Ptr("pg"), 16683 PullRequests: Ptr("pr"), 16684 RepositoryHooks: Ptr("rh"), 16685 RepositoryProjects: Ptr("rp"), 16686 RepositoryPreReceiveHooks: Ptr("rprh"), 16687 Secrets: Ptr("s"), 16688 SecretScanningAlerts: Ptr("ssa"), 16689 SecurityEvents: Ptr("se"), 16690 SingleFile: Ptr("sf"), 16691 Statuses: Ptr("s"), 16692 TeamDiscussions: Ptr("td"), 16693 VulnerabilityAlerts: Ptr("va"), 16694 Workflows: Ptr("w"), 16695 }, 16696 CreatedAt: &Timestamp{referenceTime}, 16697 UpdatedAt: &Timestamp{referenceTime}, 16698 HasMultipleSingleFiles: Ptr(false), 16699 SuspendedBy: &User{ 16700 Login: Ptr("l"), 16701 ID: Ptr(int64(1)), 16702 URL: Ptr("u"), 16703 AvatarURL: Ptr("a"), 16704 GravatarID: Ptr("g"), 16705 Name: Ptr("n"), 16706 Company: Ptr("c"), 16707 Blog: Ptr("b"), 16708 Location: Ptr("l"), 16709 Email: Ptr("e"), 16710 Hireable: Ptr(true), 16711 Bio: Ptr("b"), 16712 TwitterUsername: Ptr("t"), 16713 PublicRepos: Ptr(1), 16714 Followers: Ptr(1), 16715 Following: Ptr(1), 16716 CreatedAt: &Timestamp{referenceTime}, 16717 SuspendedAt: &Timestamp{referenceTime}, 16718 }, 16719 SuspendedAt: &Timestamp{referenceTime}, 16720 }, 16721 } 16722 16723 want := `{ 16724 "action": "a", 16725 "pull_request": { 16726 "id": 1 16727 }, 16728 "thread": { 16729 "comments": [ 16730 { 16731 "id": 1 16732 }, 16733 { 16734 "id": 2 16735 } 16736 ] 16737 }, 16738 "repository": { 16739 "id": 1, 16740 "name": "n", 16741 "url": "s" 16742 }, 16743 "sender": { 16744 "login": "l", 16745 "id": 1, 16746 "node_id": "n", 16747 "avatar_url": "a", 16748 "url": "u", 16749 "events_url": "e", 16750 "repos_url": "r" 16751 }, 16752 "installation": { 16753 "id": 1, 16754 "node_id": "nid", 16755 "app_id": 1, 16756 "app_slug": "as", 16757 "target_id": 1, 16758 "account": { 16759 "login": "l", 16760 "id": 1, 16761 "avatar_url": "a", 16762 "gravatar_id": "g", 16763 "name": "n", 16764 "company": "c", 16765 "blog": "b", 16766 "location": "l", 16767 "email": "e", 16768 "hireable": true, 16769 "bio": "b", 16770 "twitter_username": "t", 16771 "public_repos": 1, 16772 "followers": 1, 16773 "following": 1, 16774 "created_at": ` + referenceTimeStr + `, 16775 "suspended_at": ` + referenceTimeStr + `, 16776 "url": "u" 16777 }, 16778 "access_tokens_url": "atu", 16779 "repositories_url": "ru", 16780 "html_url": "hu", 16781 "target_type": "tt", 16782 "single_file_name": "sfn", 16783 "repository_selection": "rs", 16784 "events": [ 16785 "e" 16786 ], 16787 "single_file_paths": [ 16788 "s" 16789 ], 16790 "permissions": { 16791 "actions": "a", 16792 "administration": "ad", 16793 "checks": "c", 16794 "contents": "co", 16795 "content_references": "cr", 16796 "deployments": "d", 16797 "environments": "e", 16798 "issues": "i", 16799 "metadata": "md", 16800 "members": "m", 16801 "organization_administration": "oa", 16802 "organization_hooks": "oh", 16803 "organization_plan": "op", 16804 "organization_pre_receive_hooks": "opr", 16805 "organization_projects": "op", 16806 "organization_secrets": "os", 16807 "organization_self_hosted_runners": "osh", 16808 "organization_user_blocking": "oub", 16809 "packages": "pkg", 16810 "pages": "pg", 16811 "pull_requests": "pr", 16812 "repository_hooks": "rh", 16813 "repository_projects": "rp", 16814 "repository_pre_receive_hooks": "rprh", 16815 "secrets": "s", 16816 "secret_scanning_alerts": "ssa", 16817 "security_events": "se", 16818 "single_file": "sf", 16819 "statuses": "s", 16820 "team_discussions": "td", 16821 "vulnerability_alerts": "va", 16822 "workflows": "w" 16823 }, 16824 "created_at": ` + referenceTimeStr + `, 16825 "updated_at": ` + referenceTimeStr + `, 16826 "has_multiple_single_files": false, 16827 "suspended_by": { 16828 "login": "l", 16829 "id": 1, 16830 "avatar_url": "a", 16831 "gravatar_id": "g", 16832 "name": "n", 16833 "company": "c", 16834 "blog": "b", 16835 "location": "l", 16836 "email": "e", 16837 "hireable": true, 16838 "bio": "b", 16839 "twitter_username": "t", 16840 "public_repos": 1, 16841 "followers": 1, 16842 "following": 1, 16843 "created_at": ` + referenceTimeStr + `, 16844 "suspended_at": ` + referenceTimeStr + `, 16845 "url": "u" 16846 }, 16847 "suspended_at": ` + referenceTimeStr + ` 16848 } 16849 }` 16850 16851 testJSONMarshal(t, u, want) 16852 } 16853 16854 func TestPullRequestTargetEvent_Marshal(t *testing.T) { 16855 t.Parallel() 16856 testJSONMarshal(t, &PullRequestTargetEvent{}, "{}") 16857 16858 u := &PullRequestTargetEvent{ 16859 Action: Ptr("a"), 16860 Assignee: &User{ 16861 Login: Ptr("l"), 16862 ID: Ptr(int64(1)), 16863 NodeID: Ptr("n"), 16864 URL: Ptr("u"), 16865 ReposURL: Ptr("r"), 16866 EventsURL: Ptr("e"), 16867 AvatarURL: Ptr("a"), 16868 }, 16869 Number: Ptr(1), 16870 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 16871 Changes: &EditChange{ 16872 Title: &EditTitle{ 16873 From: Ptr("TitleFrom"), 16874 }, 16875 Body: &EditBody{ 16876 From: Ptr("BodyFrom"), 16877 }, 16878 Base: &EditBase{ 16879 Ref: &EditRef{ 16880 From: Ptr("BaseRefFrom"), 16881 }, 16882 SHA: &EditSHA{ 16883 From: Ptr("BaseSHAFrom"), 16884 }, 16885 }, 16886 }, 16887 RequestedReviewer: &User{ 16888 Login: Ptr("l"), 16889 ID: Ptr(int64(1)), 16890 NodeID: Ptr("n"), 16891 URL: Ptr("u"), 16892 ReposURL: Ptr("r"), 16893 EventsURL: Ptr("e"), 16894 AvatarURL: Ptr("a"), 16895 }, 16896 RequestedTeam: &Team{ID: Ptr(int64(1))}, 16897 Label: &Label{ID: Ptr(int64(1))}, 16898 Before: Ptr("before"), 16899 After: Ptr("after"), 16900 Repo: &Repository{ 16901 ID: Ptr(int64(1)), 16902 URL: Ptr("s"), 16903 Name: Ptr("n"), 16904 }, 16905 PerformedViaGithubApp: &App{ 16906 ID: Ptr(int64(1)), 16907 NodeID: Ptr("n"), 16908 Slug: Ptr("s"), 16909 Name: Ptr("n"), 16910 Description: Ptr("d"), 16911 ExternalURL: Ptr("e"), 16912 HTMLURL: Ptr("h"), 16913 }, 16914 Organization: &Organization{ 16915 BillingEmail: Ptr("be"), 16916 Blog: Ptr("b"), 16917 Company: Ptr("c"), 16918 Email: Ptr("e"), 16919 TwitterUsername: Ptr("tu"), 16920 Location: Ptr("loc"), 16921 Name: Ptr("n"), 16922 Description: Ptr("d"), 16923 IsVerified: Ptr(true), 16924 HasOrganizationProjects: Ptr(true), 16925 HasRepositoryProjects: Ptr(true), 16926 DefaultRepoPermission: Ptr("drp"), 16927 MembersCanCreateRepos: Ptr(true), 16928 MembersCanCreateInternalRepos: Ptr(true), 16929 MembersCanCreatePrivateRepos: Ptr(true), 16930 MembersCanCreatePublicRepos: Ptr(false), 16931 MembersAllowedRepositoryCreationType: Ptr("marct"), 16932 MembersCanCreatePages: Ptr(true), 16933 MembersCanCreatePublicPages: Ptr(false), 16934 MembersCanCreatePrivatePages: Ptr(true), 16935 }, 16936 Sender: &User{ 16937 Login: Ptr("l"), 16938 ID: Ptr(int64(1)), 16939 NodeID: Ptr("n"), 16940 URL: Ptr("u"), 16941 ReposURL: Ptr("r"), 16942 EventsURL: Ptr("e"), 16943 AvatarURL: Ptr("a"), 16944 }, 16945 Installation: &Installation{ 16946 ID: Ptr(int64(1)), 16947 NodeID: Ptr("nid"), 16948 AppID: Ptr(int64(1)), 16949 AppSlug: Ptr("as"), 16950 TargetID: Ptr(int64(1)), 16951 Account: &User{ 16952 Login: Ptr("l"), 16953 ID: Ptr(int64(1)), 16954 URL: Ptr("u"), 16955 AvatarURL: Ptr("a"), 16956 GravatarID: Ptr("g"), 16957 Name: Ptr("n"), 16958 Company: Ptr("c"), 16959 Blog: Ptr("b"), 16960 Location: Ptr("l"), 16961 Email: Ptr("e"), 16962 Hireable: Ptr(true), 16963 Bio: Ptr("b"), 16964 TwitterUsername: Ptr("t"), 16965 PublicRepos: Ptr(1), 16966 Followers: Ptr(1), 16967 Following: Ptr(1), 16968 CreatedAt: &Timestamp{referenceTime}, 16969 SuspendedAt: &Timestamp{referenceTime}, 16970 }, 16971 AccessTokensURL: Ptr("atu"), 16972 RepositoriesURL: Ptr("ru"), 16973 HTMLURL: Ptr("hu"), 16974 TargetType: Ptr("tt"), 16975 SingleFileName: Ptr("sfn"), 16976 RepositorySelection: Ptr("rs"), 16977 Events: []string{"e"}, 16978 SingleFilePaths: []string{"s"}, 16979 Permissions: &InstallationPermissions{ 16980 Actions: Ptr("a"), 16981 Administration: Ptr("ad"), 16982 Checks: Ptr("c"), 16983 Contents: Ptr("co"), 16984 ContentReferences: Ptr("cr"), 16985 Deployments: Ptr("d"), 16986 Environments: Ptr("e"), 16987 Issues: Ptr("i"), 16988 Metadata: Ptr("md"), 16989 Members: Ptr("m"), 16990 OrganizationAdministration: Ptr("oa"), 16991 OrganizationHooks: Ptr("oh"), 16992 OrganizationPlan: Ptr("op"), 16993 OrganizationPreReceiveHooks: Ptr("opr"), 16994 OrganizationProjects: Ptr("op"), 16995 OrganizationSecrets: Ptr("os"), 16996 OrganizationSelfHostedRunners: Ptr("osh"), 16997 OrganizationUserBlocking: Ptr("oub"), 16998 Packages: Ptr("pkg"), 16999 Pages: Ptr("pg"), 17000 PullRequests: Ptr("pr"), 17001 RepositoryHooks: Ptr("rh"), 17002 RepositoryProjects: Ptr("rp"), 17003 RepositoryPreReceiveHooks: Ptr("rprh"), 17004 Secrets: Ptr("s"), 17005 SecretScanningAlerts: Ptr("ssa"), 17006 SecurityEvents: Ptr("se"), 17007 SingleFile: Ptr("sf"), 17008 Statuses: Ptr("s"), 17009 TeamDiscussions: Ptr("td"), 17010 VulnerabilityAlerts: Ptr("va"), 17011 Workflows: Ptr("w"), 17012 }, 17013 CreatedAt: &Timestamp{referenceTime}, 17014 UpdatedAt: &Timestamp{referenceTime}, 17015 HasMultipleSingleFiles: Ptr(false), 17016 SuspendedBy: &User{ 17017 Login: Ptr("l"), 17018 ID: Ptr(int64(1)), 17019 URL: Ptr("u"), 17020 AvatarURL: Ptr("a"), 17021 GravatarID: Ptr("g"), 17022 Name: Ptr("n"), 17023 Company: Ptr("c"), 17024 Blog: Ptr("b"), 17025 Location: Ptr("l"), 17026 Email: Ptr("e"), 17027 Hireable: Ptr(true), 17028 Bio: Ptr("b"), 17029 TwitterUsername: Ptr("t"), 17030 PublicRepos: Ptr(1), 17031 Followers: Ptr(1), 17032 Following: Ptr(1), 17033 CreatedAt: &Timestamp{referenceTime}, 17034 SuspendedAt: &Timestamp{referenceTime}, 17035 }, 17036 SuspendedAt: &Timestamp{referenceTime}, 17037 }, 17038 } 17039 17040 want := `{ 17041 "action": "a", 17042 "assignee": { 17043 "login": "l", 17044 "id": 1, 17045 "node_id": "n", 17046 "avatar_url": "a", 17047 "url": "u", 17048 "events_url": "e", 17049 "repos_url": "r" 17050 }, 17051 "number": 1, 17052 "pull_request": { 17053 "id": 1 17054 }, 17055 "changes": { 17056 "title": { 17057 "from": "TitleFrom" 17058 }, 17059 "body": { 17060 "from": "BodyFrom" 17061 }, 17062 "base": { 17063 "ref": { 17064 "from": "BaseRefFrom" 17065 }, 17066 "sha": { 17067 "from": "BaseSHAFrom" 17068 } 17069 } 17070 }, 17071 "requested_reviewer": { 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 "requested_team": { 17081 "id": 1 17082 }, 17083 "label": { 17084 "id": 1 17085 }, 17086 "before": "before", 17087 "after": "after", 17088 "repository": { 17089 "id": 1, 17090 "name": "n", 17091 "url": "s" 17092 }, 17093 "performed_via_github_app": { 17094 "id": 1, 17095 "node_id": "n", 17096 "slug": "s", 17097 "name": "n", 17098 "description": "d", 17099 "external_url": "e", 17100 "html_url": "h" 17101 }, 17102 "organization": { 17103 "name": "n", 17104 "company": "c", 17105 "blog": "b", 17106 "location": "loc", 17107 "email": "e", 17108 "twitter_username": "tu", 17109 "description": "d", 17110 "billing_email": "be", 17111 "is_verified": true, 17112 "has_organization_projects": true, 17113 "has_repository_projects": true, 17114 "default_repository_permission": "drp", 17115 "members_can_create_repositories": true, 17116 "members_can_create_public_repositories": false, 17117 "members_can_create_private_repositories": true, 17118 "members_can_create_internal_repositories": true, 17119 "members_allowed_repository_creation_type": "marct", 17120 "members_can_create_pages": true, 17121 "members_can_create_public_pages": false, 17122 "members_can_create_private_pages": true 17123 }, 17124 "sender": { 17125 "login": "l", 17126 "id": 1, 17127 "node_id": "n", 17128 "avatar_url": "a", 17129 "url": "u", 17130 "events_url": "e", 17131 "repos_url": "r" 17132 }, 17133 "installation": { 17134 "id": 1, 17135 "node_id": "nid", 17136 "app_id": 1, 17137 "app_slug": "as", 17138 "target_id": 1, 17139 "account": { 17140 "login": "l", 17141 "id": 1, 17142 "avatar_url": "a", 17143 "gravatar_id": "g", 17144 "name": "n", 17145 "company": "c", 17146 "blog": "b", 17147 "location": "l", 17148 "email": "e", 17149 "hireable": true, 17150 "bio": "b", 17151 "twitter_username": "t", 17152 "public_repos": 1, 17153 "followers": 1, 17154 "following": 1, 17155 "created_at": ` + referenceTimeStr + `, 17156 "suspended_at": ` + referenceTimeStr + `, 17157 "url": "u" 17158 }, 17159 "access_tokens_url": "atu", 17160 "repositories_url": "ru", 17161 "html_url": "hu", 17162 "target_type": "tt", 17163 "single_file_name": "sfn", 17164 "repository_selection": "rs", 17165 "events": [ 17166 "e" 17167 ], 17168 "single_file_paths": [ 17169 "s" 17170 ], 17171 "permissions": { 17172 "actions": "a", 17173 "administration": "ad", 17174 "checks": "c", 17175 "contents": "co", 17176 "content_references": "cr", 17177 "deployments": "d", 17178 "environments": "e", 17179 "issues": "i", 17180 "metadata": "md", 17181 "members": "m", 17182 "organization_administration": "oa", 17183 "organization_hooks": "oh", 17184 "organization_plan": "op", 17185 "organization_pre_receive_hooks": "opr", 17186 "organization_projects": "op", 17187 "organization_secrets": "os", 17188 "organization_self_hosted_runners": "osh", 17189 "organization_user_blocking": "oub", 17190 "packages": "pkg", 17191 "pages": "pg", 17192 "pull_requests": "pr", 17193 "repository_hooks": "rh", 17194 "repository_projects": "rp", 17195 "repository_pre_receive_hooks": "rprh", 17196 "secrets": "s", 17197 "secret_scanning_alerts": "ssa", 17198 "security_events": "se", 17199 "single_file": "sf", 17200 "statuses": "s", 17201 "team_discussions": "td", 17202 "vulnerability_alerts": "va", 17203 "workflows": "w" 17204 }, 17205 "created_at": ` + referenceTimeStr + `, 17206 "updated_at": ` + referenceTimeStr + `, 17207 "has_multiple_single_files": false, 17208 "suspended_by": { 17209 "login": "l", 17210 "id": 1, 17211 "avatar_url": "a", 17212 "gravatar_id": "g", 17213 "name": "n", 17214 "company": "c", 17215 "blog": "b", 17216 "location": "l", 17217 "email": "e", 17218 "hireable": true, 17219 "bio": "b", 17220 "twitter_username": "t", 17221 "public_repos": 1, 17222 "followers": 1, 17223 "following": 1, 17224 "created_at": ` + referenceTimeStr + `, 17225 "suspended_at": ` + referenceTimeStr + `, 17226 "url": "u" 17227 }, 17228 "suspended_at": ` + referenceTimeStr + ` 17229 } 17230 }` 17231 17232 testJSONMarshal(t, u, want) 17233 } 17234 17235 func TestRepositoryVulnerabilityAlertEvent_Marshal(t *testing.T) { 17236 t.Parallel() 17237 testJSONMarshal(t, &RepositoryVulnerabilityAlertEvent{}, "{}") 17238 17239 u := &RepositoryVulnerabilityAlertEvent{ 17240 Action: Ptr("a"), 17241 Alert: &RepositoryVulnerabilityAlert{ 17242 ID: Ptr(int64(1)), 17243 AffectedRange: Ptr("ar"), 17244 AffectedPackageName: Ptr("apn"), 17245 ExternalReference: Ptr("er"), 17246 ExternalIdentifier: Ptr("ei"), 17247 FixedIn: Ptr("fi"), 17248 Dismisser: &User{ 17249 Login: Ptr("l"), 17250 ID: Ptr(int64(1)), 17251 NodeID: Ptr("n"), 17252 URL: Ptr("u"), 17253 ReposURL: Ptr("r"), 17254 EventsURL: Ptr("e"), 17255 AvatarURL: Ptr("a"), 17256 }, 17257 DismissReason: Ptr("dr"), 17258 DismissedAt: &Timestamp{referenceTime}, 17259 }, 17260 Repository: &Repository{ 17261 ID: Ptr(int64(1)), 17262 URL: Ptr("s"), 17263 Name: Ptr("n"), 17264 }, 17265 } 17266 17267 want := `{ 17268 "action": "a", 17269 "alert": { 17270 "id": 1, 17271 "affected_range": "ar", 17272 "affected_package_name": "apn", 17273 "external_reference": "er", 17274 "external_identifier": "ei", 17275 "fixed_in": "fi", 17276 "dismisser": { 17277 "login": "l", 17278 "id": 1, 17279 "node_id": "n", 17280 "avatar_url": "a", 17281 "url": "u", 17282 "events_url": "e", 17283 "repos_url": "r" 17284 }, 17285 "dismiss_reason": "dr", 17286 "dismissed_at": ` + referenceTimeStr + ` 17287 }, 17288 "repository": { 17289 "id": 1, 17290 "name": "n", 17291 "url": "s" 17292 } 17293 }` 17294 17295 testJSONMarshal(t, u, want) 17296 } 17297 17298 func TestSecretScanningAlertEvent_Marshal(t *testing.T) { 17299 t.Parallel() 17300 testJSONMarshal(t, &SecretScanningAlertEvent{}, "{}") 17301 17302 u := &SecretScanningAlertEvent{ 17303 Action: Ptr("a"), 17304 Alert: &SecretScanningAlert{ 17305 Number: Ptr(1), 17306 SecretType: Ptr("t"), 17307 Resolution: Ptr("r"), 17308 ResolvedBy: &User{ 17309 Login: Ptr("l"), 17310 ID: Ptr(int64(1)), 17311 NodeID: Ptr("n"), 17312 URL: Ptr("u"), 17313 ReposURL: Ptr("r"), 17314 EventsURL: Ptr("e"), 17315 AvatarURL: Ptr("a"), 17316 }, 17317 ResolvedAt: &Timestamp{referenceTime}, 17318 }, 17319 Repo: &Repository{ 17320 ID: Ptr(int64(1)), 17321 URL: Ptr("s"), 17322 Name: Ptr("n"), 17323 }, 17324 Organization: &Organization{ 17325 BillingEmail: Ptr("be"), 17326 Blog: Ptr("b"), 17327 Company: Ptr("c"), 17328 Email: Ptr("e"), 17329 TwitterUsername: Ptr("tu"), 17330 Location: Ptr("loc"), 17331 Name: Ptr("n"), 17332 Description: Ptr("d"), 17333 IsVerified: Ptr(true), 17334 HasOrganizationProjects: Ptr(true), 17335 HasRepositoryProjects: Ptr(true), 17336 DefaultRepoPermission: Ptr("drp"), 17337 MembersCanCreateRepos: Ptr(true), 17338 MembersCanCreateInternalRepos: Ptr(true), 17339 MembersCanCreatePrivateRepos: Ptr(true), 17340 MembersCanCreatePublicRepos: Ptr(false), 17341 MembersAllowedRepositoryCreationType: Ptr("marct"), 17342 MembersCanCreatePages: Ptr(true), 17343 MembersCanCreatePublicPages: Ptr(false), 17344 MembersCanCreatePrivatePages: Ptr(true), 17345 }, 17346 Enterprise: &Enterprise{ 17347 ID: Ptr(1), 17348 Slug: Ptr("s"), 17349 Name: Ptr("n"), 17350 NodeID: Ptr("nid"), 17351 AvatarURL: Ptr("au"), 17352 Description: Ptr("d"), 17353 WebsiteURL: Ptr("wu"), 17354 HTMLURL: Ptr("hu"), 17355 CreatedAt: &Timestamp{referenceTime}, 17356 UpdatedAt: &Timestamp{referenceTime}, 17357 }, 17358 Sender: &User{ 17359 Login: Ptr("l"), 17360 ID: Ptr(int64(1)), 17361 NodeID: Ptr("n"), 17362 URL: Ptr("u"), 17363 ReposURL: Ptr("r"), 17364 EventsURL: Ptr("e"), 17365 AvatarURL: Ptr("a"), 17366 }, 17367 Installation: &Installation{ 17368 ID: Ptr(int64(1)), 17369 NodeID: Ptr("nid"), 17370 AppID: Ptr(int64(1)), 17371 AppSlug: Ptr("as"), 17372 TargetID: Ptr(int64(1)), 17373 Account: &User{ 17374 Login: Ptr("l"), 17375 ID: Ptr(int64(1)), 17376 URL: Ptr("u"), 17377 AvatarURL: Ptr("a"), 17378 GravatarID: Ptr("g"), 17379 Name: Ptr("n"), 17380 Company: Ptr("c"), 17381 Blog: Ptr("b"), 17382 Location: Ptr("l"), 17383 Email: Ptr("e"), 17384 Hireable: Ptr(true), 17385 Bio: Ptr("b"), 17386 TwitterUsername: Ptr("t"), 17387 PublicRepos: Ptr(1), 17388 Followers: Ptr(1), 17389 Following: Ptr(1), 17390 CreatedAt: &Timestamp{referenceTime}, 17391 SuspendedAt: &Timestamp{referenceTime}, 17392 }, 17393 AccessTokensURL: Ptr("atu"), 17394 RepositoriesURL: Ptr("ru"), 17395 HTMLURL: Ptr("hu"), 17396 TargetType: Ptr("tt"), 17397 SingleFileName: Ptr("sfn"), 17398 RepositorySelection: Ptr("rs"), 17399 Events: []string{"e"}, 17400 SingleFilePaths: []string{"s"}, 17401 Permissions: &InstallationPermissions{ 17402 Actions: Ptr("a"), 17403 Administration: Ptr("ad"), 17404 Checks: Ptr("c"), 17405 Contents: Ptr("co"), 17406 ContentReferences: Ptr("cr"), 17407 Deployments: Ptr("d"), 17408 Environments: Ptr("e"), 17409 Issues: Ptr("i"), 17410 Metadata: Ptr("md"), 17411 Members: Ptr("m"), 17412 OrganizationAdministration: Ptr("oa"), 17413 OrganizationHooks: Ptr("oh"), 17414 OrganizationPlan: Ptr("op"), 17415 OrganizationPreReceiveHooks: Ptr("opr"), 17416 OrganizationProjects: Ptr("op"), 17417 OrganizationSecrets: Ptr("os"), 17418 OrganizationSelfHostedRunners: Ptr("osh"), 17419 OrganizationUserBlocking: Ptr("oub"), 17420 Packages: Ptr("pkg"), 17421 Pages: Ptr("pg"), 17422 PullRequests: Ptr("pr"), 17423 RepositoryHooks: Ptr("rh"), 17424 RepositoryProjects: Ptr("rp"), 17425 RepositoryPreReceiveHooks: Ptr("rprh"), 17426 Secrets: Ptr("s"), 17427 SecretScanningAlerts: Ptr("ssa"), 17428 SecurityEvents: Ptr("se"), 17429 SingleFile: Ptr("sf"), 17430 Statuses: Ptr("s"), 17431 TeamDiscussions: Ptr("td"), 17432 VulnerabilityAlerts: Ptr("va"), 17433 Workflows: Ptr("w"), 17434 }, 17435 CreatedAt: &Timestamp{referenceTime}, 17436 UpdatedAt: &Timestamp{referenceTime}, 17437 HasMultipleSingleFiles: Ptr(false), 17438 SuspendedBy: &User{ 17439 Login: Ptr("l"), 17440 ID: Ptr(int64(1)), 17441 URL: Ptr("u"), 17442 AvatarURL: Ptr("a"), 17443 GravatarID: Ptr("g"), 17444 Name: Ptr("n"), 17445 Company: Ptr("c"), 17446 Blog: Ptr("b"), 17447 Location: Ptr("l"), 17448 Email: Ptr("e"), 17449 Hireable: Ptr(true), 17450 Bio: Ptr("b"), 17451 TwitterUsername: Ptr("t"), 17452 PublicRepos: Ptr(1), 17453 Followers: Ptr(1), 17454 Following: Ptr(1), 17455 CreatedAt: &Timestamp{referenceTime}, 17456 SuspendedAt: &Timestamp{referenceTime}, 17457 }, 17458 SuspendedAt: &Timestamp{referenceTime}, 17459 }, 17460 } 17461 17462 want := `{ 17463 "action": "a", 17464 "alert": { 17465 "number": 1, 17466 "secret_type": "t", 17467 "resolution": "r", 17468 "resolved_by": { 17469 "login": "l", 17470 "id": 1, 17471 "node_id": "n", 17472 "avatar_url": "a", 17473 "url": "u", 17474 "events_url": "e", 17475 "repos_url": "r" 17476 }, 17477 "resolved_at": ` + referenceTimeStr + ` 17478 }, 17479 "repository": { 17480 "id": 1, 17481 "name": "n", 17482 "url": "s" 17483 }, 17484 "organization": { 17485 "name": "n", 17486 "company": "c", 17487 "blog": "b", 17488 "location": "loc", 17489 "email": "e", 17490 "twitter_username": "tu", 17491 "description": "d", 17492 "billing_email": "be", 17493 "is_verified": true, 17494 "has_organization_projects": true, 17495 "has_repository_projects": true, 17496 "default_repository_permission": "drp", 17497 "members_can_create_repositories": true, 17498 "members_can_create_public_repositories": false, 17499 "members_can_create_private_repositories": true, 17500 "members_can_create_internal_repositories": true, 17501 "members_allowed_repository_creation_type": "marct", 17502 "members_can_create_pages": true, 17503 "members_can_create_public_pages": false, 17504 "members_can_create_private_pages": true 17505 }, 17506 "enterprise": { 17507 "id": 1, 17508 "slug": "s", 17509 "name": "n", 17510 "node_id": "nid", 17511 "avatar_url": "au", 17512 "description": "d", 17513 "website_url": "wu", 17514 "html_url": "hu", 17515 "created_at": ` + referenceTimeStr + `, 17516 "updated_at": ` + referenceTimeStr + ` 17517 }, 17518 "sender": { 17519 "login": "l", 17520 "id": 1, 17521 "node_id": "n", 17522 "avatar_url": "a", 17523 "url": "u", 17524 "events_url": "e", 17525 "repos_url": "r" 17526 }, 17527 "installation": { 17528 "id": 1, 17529 "node_id": "nid", 17530 "app_id": 1, 17531 "app_slug": "as", 17532 "target_id": 1, 17533 "account": { 17534 "login": "l", 17535 "id": 1, 17536 "avatar_url": "a", 17537 "gravatar_id": "g", 17538 "name": "n", 17539 "company": "c", 17540 "blog": "b", 17541 "location": "l", 17542 "email": "e", 17543 "hireable": true, 17544 "bio": "b", 17545 "twitter_username": "t", 17546 "public_repos": 1, 17547 "followers": 1, 17548 "following": 1, 17549 "created_at": ` + referenceTimeStr + `, 17550 "suspended_at": ` + referenceTimeStr + `, 17551 "url": "u" 17552 }, 17553 "access_tokens_url": "atu", 17554 "repositories_url": "ru", 17555 "html_url": "hu", 17556 "target_type": "tt", 17557 "single_file_name": "sfn", 17558 "repository_selection": "rs", 17559 "events": [ 17560 "e" 17561 ], 17562 "single_file_paths": [ 17563 "s" 17564 ], 17565 "permissions": { 17566 "actions": "a", 17567 "administration": "ad", 17568 "checks": "c", 17569 "contents": "co", 17570 "content_references": "cr", 17571 "deployments": "d", 17572 "environments": "e", 17573 "issues": "i", 17574 "metadata": "md", 17575 "members": "m", 17576 "organization_administration": "oa", 17577 "organization_hooks": "oh", 17578 "organization_plan": "op", 17579 "organization_pre_receive_hooks": "opr", 17580 "organization_projects": "op", 17581 "organization_secrets": "os", 17582 "organization_self_hosted_runners": "osh", 17583 "organization_user_blocking": "oub", 17584 "packages": "pkg", 17585 "pages": "pg", 17586 "pull_requests": "pr", 17587 "repository_hooks": "rh", 17588 "repository_projects": "rp", 17589 "repository_pre_receive_hooks": "rprh", 17590 "secrets": "s", 17591 "secret_scanning_alerts": "ssa", 17592 "security_events": "se", 17593 "single_file": "sf", 17594 "statuses": "s", 17595 "team_discussions": "td", 17596 "vulnerability_alerts": "va", 17597 "workflows": "w" 17598 }, 17599 "created_at": ` + referenceTimeStr + `, 17600 "updated_at": ` + referenceTimeStr + `, 17601 "has_multiple_single_files": false, 17602 "suspended_by": { 17603 "login": "l", 17604 "id": 1, 17605 "avatar_url": "a", 17606 "gravatar_id": "g", 17607 "name": "n", 17608 "company": "c", 17609 "blog": "b", 17610 "location": "l", 17611 "email": "e", 17612 "hireable": true, 17613 "bio": "b", 17614 "twitter_username": "t", 17615 "public_repos": 1, 17616 "followers": 1, 17617 "following": 1, 17618 "created_at": ` + referenceTimeStr + `, 17619 "suspended_at": ` + referenceTimeStr + `, 17620 "url": "u" 17621 }, 17622 "suspended_at": ` + referenceTimeStr + ` 17623 } 17624 }` 17625 17626 testJSONMarshal(t, u, want) 17627 } 17628 17629 func TestSecretScanningAlertLocationEvent_Marshal(t *testing.T) { 17630 t.Parallel() 17631 testJSONMarshal(t, &SecretScanningAlertLocationEvent{}, "{}") 17632 u := &SecretScanningAlertLocationEvent{ 17633 Action: Ptr("created"), 17634 Alert: &SecretScanningAlert{ 17635 Number: Ptr(10), 17636 CreatedAt: &Timestamp{referenceTime}, 17637 UpdatedAt: &Timestamp{referenceTime}, 17638 URL: Ptr("a"), 17639 HTMLURL: Ptr("a"), 17640 SecretType: Ptr("mailchimp_api_key"), 17641 }, 17642 Location: &SecretScanningAlertLocation{ 17643 Type: Ptr("blob"), 17644 Details: &SecretScanningAlertLocationDetails{ 17645 Path: Ptr("path/to/file"), 17646 Startline: Ptr(10), 17647 EndLine: Ptr(20), 17648 StartColumn: Ptr(1), 17649 EndColumn: Ptr(2), 17650 BlobSHA: Ptr("d6e4c75c141dbacecc279b721b8bsomeSHA"), 17651 BlobURL: Ptr("a"), 17652 CommitSHA: Ptr("d6e4c75c141dbacecc279b721b8bsomeSHA"), 17653 CommitURL: Ptr("a"), 17654 }, 17655 }, 17656 Repo: &Repository{ 17657 ID: Ptr(int64(12345)), 17658 NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjM0NQ=="), 17659 Name: Ptr("example-repo"), 17660 }, 17661 Organization: &Organization{ 17662 Login: Ptr("example-org"), 17663 ID: Ptr(int64(67890)), 17664 }, 17665 Sender: &User{ 17666 Login: Ptr("example-user"), 17667 ID: Ptr(int64(1111)), 17668 }, 17669 Installation: &Installation{ 17670 ID: Ptr(int64(2222)), 17671 }, 17672 } 17673 17674 want := `{ 17675 "action": "created", 17676 "alert": { 17677 "number": 10, 17678 "created_at": ` + referenceTimeStr + `, 17679 "updated_at": ` + referenceTimeStr + `, 17680 "url": "a", 17681 "html_url": "a", 17682 "secret_type": "mailchimp_api_key" 17683 }, 17684 "location": { 17685 17686 "type": "blob", 17687 "details": { 17688 "path": "path/to/file", 17689 "start_line": 10, 17690 "end_line": 20, 17691 "start_column": 1, 17692 "end_column": 2, 17693 "blob_sha": "d6e4c75c141dbacecc279b721b8bsomeSHA", 17694 "blob_url": "a", 17695 "commit_sha": "d6e4c75c141dbacecc279b721b8bsomeSHA", 17696 "commit_url": "a" 17697 } 17698 }, 17699 "repository": { 17700 17701 "id": 12345, 17702 "node_id": "MDEwOlJlcG9zaXRvcnkxMjM0NQ==", 17703 "name": "example-repo" 17704 }, 17705 "organization": { 17706 "login": "example-org", 17707 "id": 67890 17708 }, 17709 "sender": { 17710 "login": "example-user", 17711 "id": 1111 17712 }, 17713 "installation": { 17714 "id": 2222 17715 } 17716 }` 17717 17718 testJSONMarshal(t, u, want) 17719 } 17720 17721 func TestSecurityAdvisoryEvent_Marshal(t *testing.T) { 17722 t.Parallel() 17723 testJSONMarshal(t, &SecurityAdvisoryEvent{}, "{}") 17724 u := &SecurityAdvisoryEvent{ 17725 Action: Ptr("published"), 17726 SecurityAdvisory: &SecurityAdvisory{ 17727 CVSS: &AdvisoryCVSS{ 17728 Score: Ptr(1.0), 17729 VectorString: Ptr("vs"), 17730 }, 17731 CWEs: []*AdvisoryCWEs{ 17732 { 17733 CWEID: Ptr("cweid"), 17734 Name: Ptr("n"), 17735 }, 17736 }, 17737 GHSAID: Ptr("GHSA-rf4j-j272-some"), 17738 Summary: Ptr("Siuuuuuuuuu"), 17739 Description: Ptr("desc"), 17740 Severity: Ptr("moderate"), 17741 Identifiers: []*AdvisoryIdentifier{ 17742 { 17743 Value: Ptr("GHSA-rf4j-j272-some"), 17744 Type: Ptr("GHSA"), 17745 }, 17746 }, 17747 References: []*AdvisoryReference{ 17748 { 17749 URL: Ptr("https://some-url"), 17750 }, 17751 }, 17752 PublishedAt: &Timestamp{referenceTime}, 17753 UpdatedAt: &Timestamp{referenceTime}, 17754 WithdrawnAt: nil, 17755 Vulnerabilities: []*AdvisoryVulnerability{ 17756 { 17757 Package: &VulnerabilityPackage{ 17758 Ecosystem: Ptr("ucl"), 17759 Name: Ptr("penaldo"), 17760 }, 17761 Severity: Ptr("moderate"), 17762 VulnerableVersionRange: Ptr(">= 2.0.0, < 2.0.2"), 17763 FirstPatchedVersion: &FirstPatchedVersion{ 17764 Identifier: Ptr("2.0.2"), 17765 }, 17766 }, 17767 }, 17768 }, 17769 Enterprise: &Enterprise{ 17770 ID: Ptr(1), 17771 Slug: Ptr("s"), 17772 Name: Ptr("n"), 17773 NodeID: Ptr("nid"), 17774 AvatarURL: Ptr("au"), 17775 Description: Ptr("d"), 17776 WebsiteURL: Ptr("wu"), 17777 HTMLURL: Ptr("hu"), 17778 CreatedAt: &Timestamp{referenceTime}, 17779 UpdatedAt: &Timestamp{referenceTime}, 17780 }, 17781 Installation: &Installation{ 17782 ID: Ptr(int64(1)), 17783 NodeID: Ptr("nid"), 17784 AppID: Ptr(int64(1)), 17785 AppSlug: Ptr("as"), 17786 TargetID: Ptr(int64(1)), 17787 Account: &User{ 17788 Login: Ptr("l"), 17789 ID: Ptr(int64(1)), 17790 URL: Ptr("u"), 17791 AvatarURL: Ptr("a"), 17792 GravatarID: Ptr("g"), 17793 Name: Ptr("n"), 17794 Company: Ptr("c"), 17795 Blog: Ptr("b"), 17796 Location: Ptr("l"), 17797 Email: Ptr("e"), 17798 Hireable: Ptr(true), 17799 Bio: Ptr("b"), 17800 TwitterUsername: Ptr("t"), 17801 PublicRepos: Ptr(1), 17802 Followers: Ptr(1), 17803 Following: Ptr(1), 17804 CreatedAt: &Timestamp{referenceTime}, 17805 SuspendedAt: &Timestamp{referenceTime}, 17806 }, 17807 AccessTokensURL: Ptr("atu"), 17808 RepositoriesURL: Ptr("ru"), 17809 HTMLURL: Ptr("hu"), 17810 TargetType: Ptr("tt"), 17811 SingleFileName: Ptr("sfn"), 17812 RepositorySelection: Ptr("rs"), 17813 Events: []string{"e"}, 17814 SingleFilePaths: []string{"s"}, 17815 Permissions: &InstallationPermissions{ 17816 Actions: Ptr("a"), 17817 Administration: Ptr("ad"), 17818 Checks: Ptr("c"), 17819 Contents: Ptr("co"), 17820 ContentReferences: Ptr("cr"), 17821 Deployments: Ptr("d"), 17822 Environments: Ptr("e"), 17823 Issues: Ptr("i"), 17824 Metadata: Ptr("md"), 17825 Members: Ptr("m"), 17826 OrganizationAdministration: Ptr("oa"), 17827 OrganizationHooks: Ptr("oh"), 17828 OrganizationPlan: Ptr("op"), 17829 OrganizationPreReceiveHooks: Ptr("opr"), 17830 OrganizationProjects: Ptr("op"), 17831 OrganizationSecrets: Ptr("os"), 17832 OrganizationSelfHostedRunners: Ptr("osh"), 17833 OrganizationUserBlocking: Ptr("oub"), 17834 Packages: Ptr("pkg"), 17835 Pages: Ptr("pg"), 17836 PullRequests: Ptr("pr"), 17837 RepositoryHooks: Ptr("rh"), 17838 RepositoryProjects: Ptr("rp"), 17839 RepositoryPreReceiveHooks: Ptr("rprh"), 17840 Secrets: Ptr("s"), 17841 SecretScanningAlerts: Ptr("ssa"), 17842 SecurityEvents: Ptr("se"), 17843 SingleFile: Ptr("sf"), 17844 Statuses: Ptr("s"), 17845 TeamDiscussions: Ptr("td"), 17846 VulnerabilityAlerts: Ptr("va"), 17847 Workflows: Ptr("w"), 17848 }, 17849 CreatedAt: &Timestamp{referenceTime}, 17850 UpdatedAt: &Timestamp{referenceTime}, 17851 HasMultipleSingleFiles: Ptr(false), 17852 SuspendedBy: &User{ 17853 Login: Ptr("l"), 17854 ID: Ptr(int64(1)), 17855 URL: Ptr("u"), 17856 AvatarURL: Ptr("a"), 17857 GravatarID: Ptr("g"), 17858 Name: Ptr("n"), 17859 Company: Ptr("c"), 17860 Blog: Ptr("b"), 17861 Location: Ptr("l"), 17862 Email: Ptr("e"), 17863 Hireable: Ptr(true), 17864 Bio: Ptr("b"), 17865 TwitterUsername: Ptr("t"), 17866 PublicRepos: Ptr(1), 17867 Followers: Ptr(1), 17868 Following: Ptr(1), 17869 CreatedAt: &Timestamp{referenceTime}, 17870 SuspendedAt: &Timestamp{referenceTime}, 17871 }, 17872 SuspendedAt: &Timestamp{referenceTime}, 17873 }, 17874 Organization: &Organization{ 17875 BillingEmail: Ptr("be"), 17876 Blog: Ptr("b"), 17877 Company: Ptr("c"), 17878 Email: Ptr("e"), 17879 TwitterUsername: Ptr("tu"), 17880 Location: Ptr("loc"), 17881 Name: Ptr("n"), 17882 Description: Ptr("d"), 17883 IsVerified: Ptr(true), 17884 HasOrganizationProjects: Ptr(true), 17885 HasRepositoryProjects: Ptr(true), 17886 DefaultRepoPermission: Ptr("drp"), 17887 MembersCanCreateRepos: Ptr(true), 17888 MembersCanCreateInternalRepos: Ptr(true), 17889 MembersCanCreatePrivateRepos: Ptr(true), 17890 MembersCanCreatePublicRepos: Ptr(false), 17891 MembersAllowedRepositoryCreationType: Ptr("marct"), 17892 MembersCanCreatePages: Ptr(true), 17893 MembersCanCreatePublicPages: Ptr(false), 17894 MembersCanCreatePrivatePages: Ptr(true), 17895 }, 17896 Repository: &Repository{ 17897 ID: Ptr(int64(1)), 17898 URL: Ptr("s"), 17899 Name: Ptr("n"), 17900 }, 17901 Sender: &User{ 17902 Login: Ptr("l"), 17903 ID: Ptr(int64(1)), 17904 NodeID: Ptr("n"), 17905 URL: Ptr("u"), 17906 ReposURL: Ptr("r"), 17907 EventsURL: Ptr("e"), 17908 AvatarURL: Ptr("a"), 17909 }, 17910 } 17911 17912 want := `{ 17913 "action": "published", 17914 "security_advisory": { 17915 "ghsa_id": "GHSA-rf4j-j272-some", 17916 "summary": "Siuuuuuuuuu", 17917 "cvss": { 17918 "score": 1.0, 17919 "vector_string": "vs" 17920 }, 17921 "cwes": [ 17922 { 17923 "cwe_id": "cweid", 17924 "name": "n" 17925 } 17926 ], 17927 "description": "desc", 17928 "severity": "moderate", 17929 "identifiers": [ 17930 { 17931 "value": "GHSA-rf4j-j272-some", 17932 "type": "GHSA" 17933 } 17934 ], 17935 "references": [ 17936 { 17937 "url": "https://some-url" 17938 } 17939 ], 17940 "published_at": ` + referenceTimeStr + `, 17941 "updated_at": ` + referenceTimeStr + `, 17942 "withdrawn_at": null, 17943 "vulnerabilities": [ 17944 { 17945 "package": { 17946 "ecosystem": "ucl", 17947 "name": "penaldo" 17948 }, 17949 "severity": "moderate", 17950 "vulnerable_version_range": ">= 2.0.0, < 2.0.2", 17951 "first_patched_version": { 17952 "identifier": "2.0.2" 17953 } 17954 } 17955 ] 17956 }, 17957 "enterprise": { 17958 "id": 1, 17959 "slug": "s", 17960 "name": "n", 17961 "node_id": "nid", 17962 "avatar_url": "au", 17963 "description": "d", 17964 "website_url": "wu", 17965 "html_url": "hu", 17966 "created_at": ` + referenceTimeStr + `, 17967 "updated_at": ` + referenceTimeStr + ` 17968 }, 17969 "installation": { 17970 "id": 1, 17971 "node_id": "nid", 17972 "app_id": 1, 17973 "app_slug": "as", 17974 "target_id": 1, 17975 "account": { 17976 "login": "l", 17977 "id": 1, 17978 "avatar_url": "a", 17979 "gravatar_id": "g", 17980 "name": "n", 17981 "company": "c", 17982 "blog": "b", 17983 "location": "l", 17984 "email": "e", 17985 "hireable": true, 17986 "bio": "b", 17987 "twitter_username": "t", 17988 "public_repos": 1, 17989 "followers": 1, 17990 "following": 1, 17991 "created_at": ` + referenceTimeStr + `, 17992 "suspended_at": ` + referenceTimeStr + `, 17993 "url": "u" 17994 }, 17995 "access_tokens_url": "atu", 17996 "repositories_url": "ru", 17997 "html_url": "hu", 17998 "target_type": "tt", 17999 "single_file_name": "sfn", 18000 "repository_selection": "rs", 18001 "events": [ 18002 "e" 18003 ], 18004 "single_file_paths": [ 18005 "s" 18006 ], 18007 "permissions": { 18008 "actions": "a", 18009 "administration": "ad", 18010 "checks": "c", 18011 "contents": "co", 18012 "content_references": "cr", 18013 "deployments": "d", 18014 "environments": "e", 18015 "issues": "i", 18016 "metadata": "md", 18017 "members": "m", 18018 "organization_administration": "oa", 18019 "organization_hooks": "oh", 18020 "organization_plan": "op", 18021 "organization_pre_receive_hooks": "opr", 18022 "organization_projects": "op", 18023 "organization_secrets": "os", 18024 "organization_self_hosted_runners": "osh", 18025 "organization_user_blocking": "oub", 18026 "packages": "pkg", 18027 "pages": "pg", 18028 "pull_requests": "pr", 18029 "repository_hooks": "rh", 18030 "repository_projects": "rp", 18031 "repository_pre_receive_hooks": "rprh", 18032 "secrets": "s", 18033 "secret_scanning_alerts": "ssa", 18034 "security_events": "se", 18035 "single_file": "sf", 18036 "statuses": "s", 18037 "team_discussions": "td", 18038 "vulnerability_alerts": "va", 18039 "workflows": "w" 18040 }, 18041 "created_at": ` + referenceTimeStr + `, 18042 "updated_at": ` + referenceTimeStr + `, 18043 "has_multiple_single_files": false, 18044 "suspended_by": { 18045 "login": "l", 18046 "id": 1, 18047 "avatar_url": "a", 18048 "gravatar_id": "g", 18049 "name": "n", 18050 "company": "c", 18051 "blog": "b", 18052 "location": "l", 18053 "email": "e", 18054 "hireable": true, 18055 "bio": "b", 18056 "twitter_username": "t", 18057 "public_repos": 1, 18058 "followers": 1, 18059 "following": 1, 18060 "created_at": ` + referenceTimeStr + `, 18061 "suspended_at": ` + referenceTimeStr + `, 18062 "url": "u" 18063 }, 18064 "suspended_at": ` + referenceTimeStr + ` 18065 }, 18066 "organization": { 18067 "name": "n", 18068 "company": "c", 18069 "blog": "b", 18070 "location": "loc", 18071 "email": "e", 18072 "twitter_username": "tu", 18073 "description": "d", 18074 "billing_email": "be", 18075 "is_verified": true, 18076 "has_organization_projects": true, 18077 "has_repository_projects": true, 18078 "default_repository_permission": "drp", 18079 "members_can_create_repositories": true, 18080 "members_can_create_public_repositories": false, 18081 "members_can_create_private_repositories": true, 18082 "members_can_create_internal_repositories": true, 18083 "members_allowed_repository_creation_type": "marct", 18084 "members_can_create_pages": true, 18085 "members_can_create_public_pages": false, 18086 "members_can_create_private_pages": true 18087 }, 18088 "repository": { 18089 "id": 1, 18090 "url": "s", 18091 "name": "n" 18092 }, 18093 "sender": { 18094 "login": "l", 18095 "id": 1, 18096 "node_id": "n", 18097 "avatar_url": "a", 18098 "url": "u", 18099 "events_url": "e", 18100 "repos_url": "r" 18101 } 18102 }` 18103 18104 testJSONMarshal(t, u, want) 18105 } 18106 18107 func TestSecurityAndAnalysisEvent_Marshal(t *testing.T) { 18108 t.Parallel() 18109 testJSONMarshal(t, &SecurityAndAnalysisEvent{}, "{}") 18110 18111 u := &SecurityAndAnalysisEvent{ 18112 Changes: &SecurityAndAnalysisChange{ 18113 From: &SecurityAndAnalysisChangeFrom{ 18114 SecurityAndAnalysis: &SecurityAndAnalysis{ 18115 AdvancedSecurity: &AdvancedSecurity{ 18116 Status: Ptr("enabled"), 18117 }, 18118 SecretScanning: &SecretScanning{ 18119 Status: Ptr("enabled"), 18120 }, 18121 SecretScanningPushProtection: &SecretScanningPushProtection{ 18122 Status: Ptr("enabled"), 18123 }, 18124 DependabotSecurityUpdates: &DependabotSecurityUpdates{ 18125 Status: Ptr("enabled"), 18126 }, 18127 }, 18128 }, 18129 }, 18130 Enterprise: &Enterprise{ 18131 ID: Ptr(1), 18132 Slug: Ptr("s"), 18133 Name: Ptr("n"), 18134 NodeID: Ptr("nid"), 18135 AvatarURL: Ptr("au"), 18136 Description: Ptr("d"), 18137 WebsiteURL: Ptr("wu"), 18138 HTMLURL: Ptr("hu"), 18139 CreatedAt: &Timestamp{referenceTime}, 18140 UpdatedAt: &Timestamp{referenceTime}, 18141 }, 18142 Installation: &Installation{ 18143 ID: Ptr(int64(1)), 18144 NodeID: Ptr("nid"), 18145 AppID: Ptr(int64(1)), 18146 AppSlug: Ptr("as"), 18147 TargetID: Ptr(int64(1)), 18148 Account: &User{ 18149 Login: Ptr("l"), 18150 ID: Ptr(int64(1)), 18151 URL: Ptr("u"), 18152 AvatarURL: Ptr("a"), 18153 GravatarID: Ptr("g"), 18154 Name: Ptr("n"), 18155 Company: Ptr("c"), 18156 Blog: Ptr("b"), 18157 Location: Ptr("l"), 18158 Email: Ptr("e"), 18159 Hireable: Ptr(true), 18160 Bio: Ptr("b"), 18161 TwitterUsername: Ptr("t"), 18162 PublicRepos: Ptr(1), 18163 Followers: Ptr(1), 18164 Following: Ptr(1), 18165 CreatedAt: &Timestamp{referenceTime}, 18166 SuspendedAt: &Timestamp{referenceTime}, 18167 }, 18168 AccessTokensURL: Ptr("atu"), 18169 RepositoriesURL: Ptr("ru"), 18170 HTMLURL: Ptr("hu"), 18171 TargetType: Ptr("tt"), 18172 SingleFileName: Ptr("sfn"), 18173 RepositorySelection: Ptr("rs"), 18174 Events: []string{"e"}, 18175 SingleFilePaths: []string{"s"}, 18176 Permissions: &InstallationPermissions{ 18177 Actions: Ptr("a"), 18178 Administration: Ptr("ad"), 18179 Checks: Ptr("c"), 18180 Contents: Ptr("co"), 18181 ContentReferences: Ptr("cr"), 18182 Deployments: Ptr("d"), 18183 Environments: Ptr("e"), 18184 Issues: Ptr("i"), 18185 Metadata: Ptr("md"), 18186 Members: Ptr("m"), 18187 OrganizationAdministration: Ptr("oa"), 18188 OrganizationHooks: Ptr("oh"), 18189 OrganizationPlan: Ptr("op"), 18190 OrganizationPreReceiveHooks: Ptr("opr"), 18191 OrganizationProjects: Ptr("op"), 18192 OrganizationSecrets: Ptr("os"), 18193 OrganizationSelfHostedRunners: Ptr("osh"), 18194 OrganizationUserBlocking: Ptr("oub"), 18195 Packages: Ptr("pkg"), 18196 Pages: Ptr("pg"), 18197 PullRequests: Ptr("pr"), 18198 RepositoryHooks: Ptr("rh"), 18199 RepositoryProjects: Ptr("rp"), 18200 RepositoryPreReceiveHooks: Ptr("rprh"), 18201 Secrets: Ptr("s"), 18202 SecretScanningAlerts: Ptr("ssa"), 18203 SecurityEvents: Ptr("se"), 18204 SingleFile: Ptr("sf"), 18205 Statuses: Ptr("s"), 18206 TeamDiscussions: Ptr("td"), 18207 VulnerabilityAlerts: Ptr("va"), 18208 Workflows: Ptr("w"), 18209 }, 18210 CreatedAt: &Timestamp{referenceTime}, 18211 UpdatedAt: &Timestamp{referenceTime}, 18212 HasMultipleSingleFiles: Ptr(false), 18213 SuspendedBy: &User{ 18214 Login: Ptr("l"), 18215 ID: Ptr(int64(1)), 18216 URL: Ptr("u"), 18217 AvatarURL: Ptr("a"), 18218 GravatarID: Ptr("g"), 18219 Name: Ptr("n"), 18220 Company: Ptr("c"), 18221 Blog: Ptr("b"), 18222 Location: Ptr("l"), 18223 Email: Ptr("e"), 18224 Hireable: Ptr(true), 18225 Bio: Ptr("b"), 18226 TwitterUsername: Ptr("t"), 18227 PublicRepos: Ptr(1), 18228 Followers: Ptr(1), 18229 Following: Ptr(1), 18230 CreatedAt: &Timestamp{referenceTime}, 18231 SuspendedAt: &Timestamp{referenceTime}, 18232 }, 18233 SuspendedAt: &Timestamp{referenceTime}, 18234 }, 18235 Organization: &Organization{ 18236 BillingEmail: Ptr("be"), 18237 Blog: Ptr("b"), 18238 Company: Ptr("c"), 18239 Email: Ptr("e"), 18240 TwitterUsername: Ptr("tu"), 18241 Location: Ptr("loc"), 18242 Name: Ptr("n"), 18243 Description: Ptr("d"), 18244 IsVerified: Ptr(true), 18245 HasOrganizationProjects: Ptr(true), 18246 HasRepositoryProjects: Ptr(true), 18247 DefaultRepoPermission: Ptr("drp"), 18248 MembersCanCreateRepos: Ptr(true), 18249 MembersCanCreateInternalRepos: Ptr(true), 18250 MembersCanCreatePrivateRepos: Ptr(true), 18251 MembersCanCreatePublicRepos: Ptr(false), 18252 MembersAllowedRepositoryCreationType: Ptr("marct"), 18253 MembersCanCreatePages: Ptr(true), 18254 MembersCanCreatePublicPages: Ptr(false), 18255 MembersCanCreatePrivatePages: Ptr(true), 18256 }, 18257 Repository: &Repository{ 18258 ID: Ptr(int64(1)), 18259 URL: Ptr("s"), 18260 Name: Ptr("n"), 18261 }, 18262 Sender: &User{ 18263 Login: Ptr("l"), 18264 ID: Ptr(int64(1)), 18265 NodeID: Ptr("n"), 18266 URL: Ptr("u"), 18267 ReposURL: Ptr("r"), 18268 EventsURL: Ptr("e"), 18269 AvatarURL: Ptr("a"), 18270 }, 18271 } 18272 18273 want := `{ 18274 "changes": { 18275 "from": { 18276 "security_and_analysis": { 18277 "advanced_security": { 18278 "status": "enabled" 18279 }, 18280 "secret_scanning": { 18281 "status": "enabled" 18282 }, 18283 "secret_scanning_push_protection": { 18284 "status": "enabled" 18285 }, 18286 "dependabot_security_updates": { 18287 "status": "enabled" 18288 } 18289 } 18290 } 18291 }, 18292 "enterprise": { 18293 "id": 1, 18294 "slug": "s", 18295 "name": "n", 18296 "node_id": "nid", 18297 "avatar_url": "au", 18298 "description": "d", 18299 "website_url": "wu", 18300 "html_url": "hu", 18301 "created_at": ` + referenceTimeStr + `, 18302 "updated_at": ` + referenceTimeStr + ` 18303 }, 18304 "installation": { 18305 "id": 1, 18306 "node_id": "nid", 18307 "app_id": 1, 18308 "app_slug": "as", 18309 "target_id": 1, 18310 "account": { 18311 "login": "l", 18312 "id": 1, 18313 "avatar_url": "a", 18314 "gravatar_id": "g", 18315 "name": "n", 18316 "company": "c", 18317 "blog": "b", 18318 "location": "l", 18319 "email": "e", 18320 "hireable": true, 18321 "bio": "b", 18322 "twitter_username": "t", 18323 "public_repos": 1, 18324 "followers": 1, 18325 "following": 1, 18326 "created_at": ` + referenceTimeStr + `, 18327 "suspended_at": ` + referenceTimeStr + `, 18328 "url": "u" 18329 }, 18330 "access_tokens_url": "atu", 18331 "repositories_url": "ru", 18332 "html_url": "hu", 18333 "target_type": "tt", 18334 "single_file_name": "sfn", 18335 "repository_selection": "rs", 18336 "events": [ 18337 "e" 18338 ], 18339 "single_file_paths": [ 18340 "s" 18341 ], 18342 "permissions": { 18343 "actions": "a", 18344 "administration": "ad", 18345 "checks": "c", 18346 "contents": "co", 18347 "content_references": "cr", 18348 "deployments": "d", 18349 "environments": "e", 18350 "issues": "i", 18351 "metadata": "md", 18352 "members": "m", 18353 "organization_administration": "oa", 18354 "organization_hooks": "oh", 18355 "organization_plan": "op", 18356 "organization_pre_receive_hooks": "opr", 18357 "organization_projects": "op", 18358 "organization_secrets": "os", 18359 "organization_self_hosted_runners": "osh", 18360 "organization_user_blocking": "oub", 18361 "packages": "pkg", 18362 "pages": "pg", 18363 "pull_requests": "pr", 18364 "repository_hooks": "rh", 18365 "repository_projects": "rp", 18366 "repository_pre_receive_hooks": "rprh", 18367 "secrets": "s", 18368 "secret_scanning_alerts": "ssa", 18369 "security_events": "se", 18370 "single_file": "sf", 18371 "statuses": "s", 18372 "team_discussions": "td", 18373 "vulnerability_alerts": "va", 18374 "workflows": "w" 18375 }, 18376 "created_at": ` + referenceTimeStr + `, 18377 "updated_at": ` + referenceTimeStr + `, 18378 "has_multiple_single_files": false, 18379 "suspended_by": { 18380 "login": "l", 18381 "id": 1, 18382 "avatar_url": "a", 18383 "gravatar_id": "g", 18384 "name": "n", 18385 "company": "c", 18386 "blog": "b", 18387 "location": "l", 18388 "email": "e", 18389 "hireable": true, 18390 "bio": "b", 18391 "twitter_username": "t", 18392 "public_repos": 1, 18393 "followers": 1, 18394 "following": 1, 18395 "created_at": ` + referenceTimeStr + `, 18396 "suspended_at": ` + referenceTimeStr + `, 18397 "url": "u" 18398 }, 18399 "suspended_at": ` + referenceTimeStr + ` 18400 }, 18401 "organization": { 18402 "name": "n", 18403 "company": "c", 18404 "blog": "b", 18405 "location": "loc", 18406 "email": "e", 18407 "twitter_username": "tu", 18408 "description": "d", 18409 "billing_email": "be", 18410 "is_verified": true, 18411 "has_organization_projects": true, 18412 "has_repository_projects": true, 18413 "default_repository_permission": "drp", 18414 "members_can_create_repositories": true, 18415 "members_can_create_public_repositories": false, 18416 "members_can_create_private_repositories": true, 18417 "members_can_create_internal_repositories": true, 18418 "members_allowed_repository_creation_type": "marct", 18419 "members_can_create_pages": true, 18420 "members_can_create_public_pages": false, 18421 "members_can_create_private_pages": true 18422 }, 18423 "repository": { 18424 "id": 1, 18425 "url": "s", 18426 "name": "n" 18427 }, 18428 "sender": { 18429 "login": "l", 18430 "id": 1, 18431 "node_id": "n", 18432 "avatar_url": "a", 18433 "url": "u", 18434 "events_url": "e", 18435 "repos_url": "r" 18436 }, 18437 "target_type": "running" 18438 }` 18439 18440 testJSONMarshal(t, u, want) 18441 } 18442 18443 func TestCodeScanningAlertEvent_Marshal(t *testing.T) { 18444 t.Parallel() 18445 testJSONMarshal(t, &CodeScanningAlertEvent{}, "{}") 18446 18447 u := &CodeScanningAlertEvent{ 18448 Action: Ptr("reopened"), 18449 Alert: &Alert{ 18450 Number: Ptr(10), 18451 Rule: &Rule{ 18452 ID: Ptr("Style/FrozenStringLiteralComment"), 18453 Severity: Ptr("note"), 18454 Description: Ptr("desc"), 18455 FullDescription: Ptr("full desc"), 18456 Tags: []string{"style"}, 18457 Help: Ptr("help"), 18458 }, 18459 Tool: &Tool{ 18460 Name: Ptr("Rubocop"), 18461 Version: nil, 18462 }, 18463 CreatedAt: &Timestamp{referenceTime}, 18464 UpdatedAt: &Timestamp{referenceTime}, 18465 FixedAt: nil, 18466 State: Ptr("open"), 18467 URL: Ptr("a"), 18468 HTMLURL: Ptr("a"), 18469 Instances: []*MostRecentInstance{ 18470 { 18471 Ref: Ptr("refs/heads/main"), 18472 AnalysisKey: Ptr(".github/workflows/workflow.yml:upload"), 18473 Environment: Ptr("{}"), 18474 State: Ptr("open"), 18475 }, 18476 }, 18477 DismissedBy: nil, 18478 DismissedAt: nil, 18479 DismissedReason: nil, 18480 }, 18481 Ref: Ptr("refs/heads/main"), 18482 CommitOID: Ptr("d6e4c75c141dbacecc279b721b8bsomeSHA"), 18483 Repo: &Repository{ 18484 ID: Ptr(int64(1234234535)), 18485 NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxODY4NT=="), 18486 Owner: &User{ 18487 Login: Ptr("Codertocat"), 18488 ID: Ptr(int64(21031067)), 18489 NodeID: Ptr("MDQ6VXNlcjIxMDMxMDY3"), 18490 AvatarURL: Ptr("a"), 18491 GravatarID: Ptr(""), 18492 URL: Ptr("a"), 18493 HTMLURL: Ptr("a"), 18494 Type: Ptr("User"), 18495 SiteAdmin: Ptr(false), 18496 FollowersURL: Ptr("a"), 18497 FollowingURL: Ptr("a"), 18498 EventsURL: Ptr("a"), 18499 GistsURL: Ptr("a"), 18500 OrganizationsURL: Ptr("a"), 18501 ReceivedEventsURL: Ptr("a"), 18502 ReposURL: Ptr("a"), 18503 StarredURL: Ptr("a"), 18504 SubscriptionsURL: Ptr("a"), 18505 }, 18506 HTMLURL: Ptr("a"), 18507 Name: Ptr("Hello-World"), 18508 FullName: Ptr("Codertocat/Hello-World"), 18509 Description: nil, 18510 Fork: Ptr(false), 18511 Homepage: nil, 18512 DefaultBranch: Ptr("main"), 18513 CreatedAt: &Timestamp{referenceTime}, 18514 PushedAt: &Timestamp{referenceTime}, 18515 UpdatedAt: &Timestamp{referenceTime}, 18516 CloneURL: Ptr("a"), 18517 GitURL: Ptr("a"), 18518 MirrorURL: nil, 18519 SSHURL: Ptr("a"), 18520 SVNURL: Ptr("a"), 18521 Language: nil, 18522 ForksCount: Ptr(0), 18523 OpenIssuesCount: Ptr(2), 18524 OpenIssues: Ptr(2), 18525 StargazersCount: Ptr(0), 18526 WatchersCount: Ptr(0), 18527 Watchers: Ptr(0), 18528 Size: Ptr(0), 18529 Archived: Ptr(false), 18530 Disabled: Ptr(false), 18531 License: nil, 18532 Private: Ptr(false), 18533 HasIssues: Ptr(true), 18534 HasWiki: Ptr(true), 18535 HasPages: Ptr(true), 18536 HasProjects: Ptr(true), 18537 HasDownloads: Ptr(true), 18538 URL: Ptr("a"), 18539 ArchiveURL: Ptr("a"), 18540 AssigneesURL: Ptr("a"), 18541 BlobsURL: Ptr("a"), 18542 BranchesURL: Ptr("a"), 18543 CollaboratorsURL: Ptr("a"), 18544 CommentsURL: Ptr("a"), 18545 CommitsURL: Ptr("a"), 18546 CompareURL: Ptr("a"), 18547 ContentsURL: Ptr("a"), 18548 ContributorsURL: Ptr("a"), 18549 DeploymentsURL: Ptr("a"), 18550 DownloadsURL: Ptr("a"), 18551 EventsURL: Ptr("a"), 18552 ForksURL: Ptr("a"), 18553 GitCommitsURL: Ptr("a"), 18554 GitRefsURL: Ptr("a"), 18555 GitTagsURL: Ptr("a"), 18556 HooksURL: Ptr("a"), 18557 IssueCommentURL: Ptr("a"), 18558 IssueEventsURL: Ptr("a"), 18559 IssuesURL: Ptr("a"), 18560 KeysURL: Ptr("a"), 18561 LabelsURL: Ptr("a"), 18562 LanguagesURL: Ptr("a"), 18563 MergesURL: Ptr("a"), 18564 MilestonesURL: Ptr("a"), 18565 NotificationsURL: Ptr("a"), 18566 PullsURL: Ptr("a"), 18567 ReleasesURL: Ptr("a"), 18568 StargazersURL: Ptr("a"), 18569 StatusesURL: Ptr("a"), 18570 SubscribersURL: Ptr("a"), 18571 SubscriptionURL: Ptr("a"), 18572 TagsURL: Ptr("a"), 18573 TreesURL: Ptr("a"), 18574 TeamsURL: Ptr("a"), 18575 }, 18576 Org: &Organization{ 18577 Login: Ptr("Octocoders"), 18578 ID: Ptr(int64(6)), 18579 NodeID: Ptr("MDEyOk9yZ2FuaXphdGlvbjY="), 18580 AvatarURL: Ptr("a"), 18581 Description: Ptr(""), 18582 URL: Ptr("a"), 18583 EventsURL: Ptr("a"), 18584 HooksURL: Ptr("a"), 18585 IssuesURL: Ptr("a"), 18586 MembersURL: Ptr("a"), 18587 PublicMembersURL: Ptr("a"), 18588 ReposURL: Ptr("a"), 18589 }, 18590 Sender: &User{ 18591 Login: Ptr("github"), 18592 ID: Ptr(int64(9919)), 18593 NodeID: Ptr("MDEyOk9yZ2FuaXphdGlvbjk5MTk="), 18594 AvatarURL: Ptr("a"), 18595 HTMLURL: Ptr("a"), 18596 GravatarID: Ptr(""), 18597 Type: Ptr("Organization"), 18598 SiteAdmin: Ptr(false), 18599 URL: Ptr("a"), 18600 EventsURL: Ptr("a"), 18601 FollowingURL: Ptr("a"), 18602 FollowersURL: Ptr("a"), 18603 GistsURL: Ptr("a"), 18604 OrganizationsURL: Ptr("a"), 18605 ReceivedEventsURL: Ptr("a"), 18606 ReposURL: Ptr("a"), 18607 StarredURL: Ptr("a"), 18608 SubscriptionsURL: Ptr("a"), 18609 }, 18610 } 18611 18612 want := `{ 18613 "action": "reopened", 18614 "alert": { 18615 "number": 10, 18616 "created_at": ` + referenceTimeStr + `, 18617 "updated_at": ` + referenceTimeStr + `, 18618 "url": "a", 18619 "html_url": "a", 18620 "instances": [ 18621 { 18622 "ref": "refs/heads/main", 18623 "analysis_key": ".github/workflows/workflow.yml:upload", 18624 "environment": "{}", 18625 "state": "open" 18626 } 18627 ], 18628 "state": "open", 18629 "fixed_at": null, 18630 "dismissed_by": null, 18631 "dismissed_at": null, 18632 "dismissed_reason": null, 18633 "rule": { 18634 "id": "Style/FrozenStringLiteralComment", 18635 "severity": "note", 18636 "description": "desc", 18637 "full_description": "full desc", 18638 "tags": [ 18639 "style" 18640 ], 18641 "help": "help" 18642 }, 18643 "tool": { 18644 "name": "Rubocop", 18645 "version": null 18646 } 18647 }, 18648 "ref": "refs/heads/main", 18649 "commit_oid": "d6e4c75c141dbacecc279b721b8bsomeSHA", 18650 "repository": { 18651 "id": 1234234535, 18652 "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NT==", 18653 "name": "Hello-World", 18654 "full_name": "Codertocat/Hello-World", 18655 "private": false, 18656 "owner": { 18657 "login": "Codertocat", 18658 "id": 21031067, 18659 "node_id": "MDQ6VXNlcjIxMDMxMDY3", 18660 "avatar_url": "a", 18661 "gravatar_id": "", 18662 "url": "a", 18663 "html_url": "a", 18664 "followers_url": "a", 18665 "following_url": "a", 18666 "gists_url": "a", 18667 "starred_url": "a", 18668 "subscriptions_url": "a", 18669 "organizations_url": "a", 18670 "repos_url": "a", 18671 "events_url": "a", 18672 "received_events_url": "a", 18673 "type": "User", 18674 "site_admin": false 18675 }, 18676 "html_url": "a", 18677 "description": null, 18678 "fork": false, 18679 "url": "a", 18680 "forks_url": "a", 18681 "keys_url": "a", 18682 "collaborators_url": "a", 18683 "teams_url": "a", 18684 "hooks_url": "a", 18685 "issue_events_url": "a", 18686 "events_url": "a", 18687 "assignees_url": "a", 18688 "branches_url": "a", 18689 "tags_url": "a", 18690 "blobs_url": "a", 18691 "git_tags_url": "a", 18692 "git_refs_url": "a", 18693 "trees_url": "a", 18694 "statuses_url": "a", 18695 "languages_url": "a", 18696 "stargazers_url": "a", 18697 "contributors_url": "a", 18698 "subscribers_url": "a", 18699 "subscription_url": "a", 18700 "commits_url": "a", 18701 "git_commits_url": "a", 18702 "comments_url": "a", 18703 "issue_comment_url": "a", 18704 "contents_url": "a", 18705 "compare_url": "a", 18706 "merges_url": "a", 18707 "archive_url": "a", 18708 "downloads_url": "a", 18709 "issues_url": "a", 18710 "pulls_url": "a", 18711 "milestones_url": "a", 18712 "notifications_url": "a", 18713 "labels_url": "a", 18714 "releases_url": "a", 18715 "deployments_url": "a", 18716 "created_at": ` + referenceTimeStr + `, 18717 "updated_at": ` + referenceTimeStr + `, 18718 "pushed_at": ` + referenceTimeStr + `, 18719 "git_url": "a", 18720 "ssh_url": "a", 18721 "clone_url": "a", 18722 "svn_url": "a", 18723 "homepage": null, 18724 "size": 0, 18725 "stargazers_count": 0, 18726 "watchers_count": 0, 18727 "language": null, 18728 "has_issues": true, 18729 "has_projects": true, 18730 "has_downloads": true, 18731 "has_wiki": true, 18732 "has_pages": true, 18733 "forks_count": 0, 18734 "mirror_url": null, 18735 "archived": false, 18736 "disabled": false, 18737 "open_issues_count": 2, 18738 "license": null, 18739 "forks": 0, 18740 "open_issues": 2, 18741 "watchers": 0, 18742 "default_branch": "main" 18743 }, 18744 "organization": { 18745 "login": "Octocoders", 18746 "id": 6, 18747 "node_id": "MDEyOk9yZ2FuaXphdGlvbjY=", 18748 "url": "a", 18749 "repos_url": "a", 18750 "events_url": "a", 18751 "hooks_url": "a", 18752 "issues_url": "a", 18753 "members_url": "a", 18754 "public_members_url": "a", 18755 "avatar_url": "a", 18756 "description": "" 18757 }, 18758 "sender": { 18759 "login": "github", 18760 "id": 9919, 18761 "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", 18762 "avatar_url": "a", 18763 "gravatar_id": "", 18764 "url": "a", 18765 "html_url": "a", 18766 "followers_url": "a", 18767 "following_url": "a", 18768 "gists_url": "a", 18769 "starred_url": "a", 18770 "subscriptions_url": "a", 18771 "organizations_url": "a", 18772 "repos_url": "a", 18773 "events_url": "a", 18774 "received_events_url": "a", 18775 "type": "Organization", 18776 "site_admin": false 18777 } 18778 }` 18779 18780 testJSONMarshal(t, u, want) 18781 } 18782 18783 func TestSponsorshipEvent_Marshal(t *testing.T) { 18784 t.Parallel() 18785 testJSONMarshal(t, &SponsorshipEvent{}, "{}") 18786 18787 u := &SponsorshipEvent{ 18788 Action: Ptr("created"), 18789 EffectiveDate: Ptr("2023-01-01T00:00:00Z"), 18790 Changes: &SponsorshipChanges{ 18791 Tier: &SponsorshipTier{ 18792 From: Ptr("basic"), 18793 }, 18794 PrivacyLevel: Ptr("public"), 18795 }, 18796 Repository: &Repository{ 18797 ID: Ptr(int64(12345)), 18798 NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjM0NQ=="), 18799 Name: Ptr("example-repo"), 18800 }, 18801 Organization: &Organization{ 18802 Login: Ptr("example-org"), 18803 ID: Ptr(int64(67890)), 18804 }, 18805 Sender: &User{ 18806 Login: Ptr("example-user"), 18807 ID: Ptr(int64(1111)), 18808 }, 18809 Installation: &Installation{ 18810 ID: Ptr(int64(2222)), 18811 }, 18812 } 18813 18814 want := `{ 18815 "action": "created", 18816 "effective_date": "2023-01-01T00:00:00Z", 18817 "changes": { 18818 "tier": { 18819 "from": "basic" 18820 }, 18821 "privacy_level": "public" 18822 }, 18823 "repository": { 18824 "id": 12345, 18825 "node_id": "MDEwOlJlcG9zaXRvcnkxMjM0NQ==", 18826 "name": "example-repo" 18827 }, 18828 "organization": { 18829 "login": "example-org", 18830 "id": 67890 18831 }, 18832 "sender": { 18833 "login": "example-user", 18834 "id": 1111 18835 }, 18836 "installation": { 18837 "id": 2222 18838 } 18839 }` 18840 18841 testJSONMarshal(t, u, want) 18842 } 18843 18844 func TestSponsorshipChanges_Marshal(t *testing.T) { 18845 t.Parallel() 18846 testJSONMarshal(t, &SponsorshipChanges{}, "{}") 18847 18848 u := &SponsorshipChanges{ 18849 Tier: &SponsorshipTier{ 18850 From: Ptr("premium"), 18851 }, 18852 PrivacyLevel: Ptr("private"), 18853 } 18854 18855 want := `{ 18856 "tier": { 18857 "from": "premium" 18858 }, 18859 "privacy_level": "private" 18860 }` 18861 18862 testJSONMarshal(t, u, want) 18863 } 18864 18865 func TestSponsorshipTier_Marshal(t *testing.T) { 18866 t.Parallel() 18867 testJSONMarshal(t, &SponsorshipTier{}, "{}") 18868 18869 u := &SponsorshipTier{ 18870 From: Ptr("gold"), 18871 } 18872 18873 want := `{ 18874 "from": "gold" 18875 }` 18876 18877 testJSONMarshal(t, u, want) 18878 }