github.com/google/go-github/v69@v69.2.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]interface{}) 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]interface{}) 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]interface{}) 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]interface{}) 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 TestRepositoryDispatchEvent_Marshal(t *testing.T) { 8644 t.Parallel() 8645 testJSONMarshal(t, &RepositoryDispatchEvent{}, "{}") 8646 8647 l := make(map[string]interface{}) 8648 l["key"] = "value" 8649 8650 jsonMsg, _ := json.Marshal(&l) 8651 8652 u := &RepositoryDispatchEvent{ 8653 Action: Ptr("a"), 8654 Branch: Ptr("b"), 8655 ClientPayload: jsonMsg, 8656 Repo: &Repository{ 8657 ID: Ptr(int64(1)), 8658 URL: Ptr("s"), 8659 Name: Ptr("n"), 8660 }, 8661 Org: &Organization{ 8662 BillingEmail: Ptr("be"), 8663 Blog: Ptr("b"), 8664 Company: Ptr("c"), 8665 Email: Ptr("e"), 8666 TwitterUsername: Ptr("tu"), 8667 Location: Ptr("loc"), 8668 Name: Ptr("n"), 8669 Description: Ptr("d"), 8670 IsVerified: Ptr(true), 8671 HasOrganizationProjects: Ptr(true), 8672 HasRepositoryProjects: Ptr(true), 8673 DefaultRepoPermission: Ptr("drp"), 8674 MembersCanCreateRepos: Ptr(true), 8675 MembersCanCreateInternalRepos: Ptr(true), 8676 MembersCanCreatePrivateRepos: Ptr(true), 8677 MembersCanCreatePublicRepos: Ptr(false), 8678 MembersAllowedRepositoryCreationType: Ptr("marct"), 8679 MembersCanCreatePages: Ptr(true), 8680 MembersCanCreatePublicPages: Ptr(false), 8681 MembersCanCreatePrivatePages: Ptr(true), 8682 }, 8683 Sender: &User{ 8684 Login: Ptr("l"), 8685 ID: Ptr(int64(1)), 8686 NodeID: Ptr("n"), 8687 URL: Ptr("u"), 8688 ReposURL: Ptr("r"), 8689 EventsURL: Ptr("e"), 8690 AvatarURL: Ptr("a"), 8691 }, 8692 Installation: &Installation{ 8693 ID: Ptr(int64(1)), 8694 NodeID: Ptr("nid"), 8695 AppID: Ptr(int64(1)), 8696 AppSlug: Ptr("as"), 8697 TargetID: Ptr(int64(1)), 8698 Account: &User{ 8699 Login: Ptr("l"), 8700 ID: Ptr(int64(1)), 8701 URL: Ptr("u"), 8702 AvatarURL: Ptr("a"), 8703 GravatarID: Ptr("g"), 8704 Name: Ptr("n"), 8705 Company: Ptr("c"), 8706 Blog: Ptr("b"), 8707 Location: Ptr("l"), 8708 Email: Ptr("e"), 8709 Hireable: Ptr(true), 8710 Bio: Ptr("b"), 8711 TwitterUsername: Ptr("t"), 8712 PublicRepos: Ptr(1), 8713 Followers: Ptr(1), 8714 Following: Ptr(1), 8715 CreatedAt: &Timestamp{referenceTime}, 8716 SuspendedAt: &Timestamp{referenceTime}, 8717 }, 8718 AccessTokensURL: Ptr("atu"), 8719 RepositoriesURL: Ptr("ru"), 8720 HTMLURL: Ptr("hu"), 8721 TargetType: Ptr("tt"), 8722 SingleFileName: Ptr("sfn"), 8723 RepositorySelection: Ptr("rs"), 8724 Events: []string{"e"}, 8725 SingleFilePaths: []string{"s"}, 8726 Permissions: &InstallationPermissions{ 8727 Actions: Ptr("a"), 8728 Administration: Ptr("ad"), 8729 Checks: Ptr("c"), 8730 Contents: Ptr("co"), 8731 ContentReferences: Ptr("cr"), 8732 Deployments: Ptr("d"), 8733 Environments: Ptr("e"), 8734 Issues: Ptr("i"), 8735 Metadata: Ptr("md"), 8736 Members: Ptr("m"), 8737 OrganizationAdministration: Ptr("oa"), 8738 OrganizationHooks: Ptr("oh"), 8739 OrganizationPlan: Ptr("op"), 8740 OrganizationPreReceiveHooks: Ptr("opr"), 8741 OrganizationProjects: Ptr("op"), 8742 OrganizationSecrets: Ptr("os"), 8743 OrganizationSelfHostedRunners: Ptr("osh"), 8744 OrganizationUserBlocking: Ptr("oub"), 8745 Packages: Ptr("pkg"), 8746 Pages: Ptr("pg"), 8747 PullRequests: Ptr("pr"), 8748 RepositoryHooks: Ptr("rh"), 8749 RepositoryProjects: Ptr("rp"), 8750 RepositoryPreReceiveHooks: Ptr("rprh"), 8751 Secrets: Ptr("s"), 8752 SecretScanningAlerts: Ptr("ssa"), 8753 SecurityEvents: Ptr("se"), 8754 SingleFile: Ptr("sf"), 8755 Statuses: Ptr("s"), 8756 TeamDiscussions: Ptr("td"), 8757 VulnerabilityAlerts: Ptr("va"), 8758 Workflows: Ptr("w"), 8759 }, 8760 CreatedAt: &Timestamp{referenceTime}, 8761 UpdatedAt: &Timestamp{referenceTime}, 8762 HasMultipleSingleFiles: Ptr(false), 8763 SuspendedBy: &User{ 8764 Login: Ptr("l"), 8765 ID: Ptr(int64(1)), 8766 URL: Ptr("u"), 8767 AvatarURL: Ptr("a"), 8768 GravatarID: Ptr("g"), 8769 Name: Ptr("n"), 8770 Company: Ptr("c"), 8771 Blog: Ptr("b"), 8772 Location: Ptr("l"), 8773 Email: Ptr("e"), 8774 Hireable: Ptr(true), 8775 Bio: Ptr("b"), 8776 TwitterUsername: Ptr("t"), 8777 PublicRepos: Ptr(1), 8778 Followers: Ptr(1), 8779 Following: Ptr(1), 8780 CreatedAt: &Timestamp{referenceTime}, 8781 SuspendedAt: &Timestamp{referenceTime}, 8782 }, 8783 SuspendedAt: &Timestamp{referenceTime}, 8784 }, 8785 } 8786 8787 want := `{ 8788 "action": "a", 8789 "branch": "b", 8790 "client_payload": { 8791 "key": "value" 8792 }, 8793 "repository": { 8794 "id": 1, 8795 "name": "n", 8796 "url": "s" 8797 }, 8798 "organization": { 8799 "name": "n", 8800 "company": "c", 8801 "blog": "b", 8802 "location": "loc", 8803 "email": "e", 8804 "twitter_username": "tu", 8805 "description": "d", 8806 "billing_email": "be", 8807 "is_verified": true, 8808 "has_organization_projects": true, 8809 "has_repository_projects": true, 8810 "default_repository_permission": "drp", 8811 "members_can_create_repositories": true, 8812 "members_can_create_public_repositories": false, 8813 "members_can_create_private_repositories": true, 8814 "members_can_create_internal_repositories": true, 8815 "members_allowed_repository_creation_type": "marct", 8816 "members_can_create_pages": true, 8817 "members_can_create_public_pages": false, 8818 "members_can_create_private_pages": true 8819 }, 8820 "sender": { 8821 "login": "l", 8822 "id": 1, 8823 "node_id": "n", 8824 "avatar_url": "a", 8825 "url": "u", 8826 "events_url": "e", 8827 "repos_url": "r" 8828 }, 8829 "installation": { 8830 "id": 1, 8831 "node_id": "nid", 8832 "app_id": 1, 8833 "app_slug": "as", 8834 "target_id": 1, 8835 "account": { 8836 "login": "l", 8837 "id": 1, 8838 "avatar_url": "a", 8839 "gravatar_id": "g", 8840 "name": "n", 8841 "company": "c", 8842 "blog": "b", 8843 "location": "l", 8844 "email": "e", 8845 "hireable": true, 8846 "bio": "b", 8847 "twitter_username": "t", 8848 "public_repos": 1, 8849 "followers": 1, 8850 "following": 1, 8851 "created_at": ` + referenceTimeStr + `, 8852 "suspended_at": ` + referenceTimeStr + `, 8853 "url": "u" 8854 }, 8855 "access_tokens_url": "atu", 8856 "repositories_url": "ru", 8857 "html_url": "hu", 8858 "target_type": "tt", 8859 "single_file_name": "sfn", 8860 "repository_selection": "rs", 8861 "events": [ 8862 "e" 8863 ], 8864 "single_file_paths": [ 8865 "s" 8866 ], 8867 "permissions": { 8868 "actions": "a", 8869 "administration": "ad", 8870 "checks": "c", 8871 "contents": "co", 8872 "content_references": "cr", 8873 "deployments": "d", 8874 "environments": "e", 8875 "issues": "i", 8876 "metadata": "md", 8877 "members": "m", 8878 "organization_administration": "oa", 8879 "organization_hooks": "oh", 8880 "organization_plan": "op", 8881 "organization_pre_receive_hooks": "opr", 8882 "organization_projects": "op", 8883 "organization_secrets": "os", 8884 "organization_self_hosted_runners": "osh", 8885 "organization_user_blocking": "oub", 8886 "packages": "pkg", 8887 "pages": "pg", 8888 "pull_requests": "pr", 8889 "repository_hooks": "rh", 8890 "repository_projects": "rp", 8891 "repository_pre_receive_hooks": "rprh", 8892 "secrets": "s", 8893 "secret_scanning_alerts": "ssa", 8894 "security_events": "se", 8895 "single_file": "sf", 8896 "statuses": "s", 8897 "team_discussions": "td", 8898 "vulnerability_alerts": "va", 8899 "workflows": "w" 8900 }, 8901 "created_at": ` + referenceTimeStr + `, 8902 "updated_at": ` + referenceTimeStr + `, 8903 "has_multiple_single_files": false, 8904 "suspended_by": { 8905 "login": "l", 8906 "id": 1, 8907 "avatar_url": "a", 8908 "gravatar_id": "g", 8909 "name": "n", 8910 "company": "c", 8911 "blog": "b", 8912 "location": "l", 8913 "email": "e", 8914 "hireable": true, 8915 "bio": "b", 8916 "twitter_username": "t", 8917 "public_repos": 1, 8918 "followers": 1, 8919 "following": 1, 8920 "created_at": ` + referenceTimeStr + `, 8921 "suspended_at": ` + referenceTimeStr + `, 8922 "url": "u" 8923 }, 8924 "suspended_at": ` + referenceTimeStr + ` 8925 } 8926 }` 8927 8928 testJSONMarshal(t, u, want) 8929 } 8930 8931 func TestRepositoryImportEvent_Marshal(t *testing.T) { 8932 t.Parallel() 8933 testJSONMarshal(t, &RepositoryImportEvent{}, "{}") 8934 8935 u := &RepositoryImportEvent{ 8936 Status: Ptr("success"), 8937 Repo: &Repository{ 8938 ID: Ptr(int64(1)), 8939 URL: Ptr("s"), 8940 Name: Ptr("n"), 8941 }, 8942 Org: &Organization{ 8943 BillingEmail: Ptr("be"), 8944 Blog: Ptr("b"), 8945 Company: Ptr("c"), 8946 Email: Ptr("e"), 8947 TwitterUsername: Ptr("tu"), 8948 Location: Ptr("loc"), 8949 Name: Ptr("n"), 8950 Description: Ptr("d"), 8951 IsVerified: Ptr(true), 8952 HasOrganizationProjects: Ptr(true), 8953 HasRepositoryProjects: Ptr(true), 8954 DefaultRepoPermission: Ptr("drp"), 8955 MembersCanCreateRepos: Ptr(true), 8956 MembersCanCreateInternalRepos: Ptr(true), 8957 MembersCanCreatePrivateRepos: Ptr(true), 8958 MembersCanCreatePublicRepos: Ptr(false), 8959 MembersAllowedRepositoryCreationType: Ptr("marct"), 8960 MembersCanCreatePages: Ptr(true), 8961 MembersCanCreatePublicPages: Ptr(false), 8962 MembersCanCreatePrivatePages: Ptr(true), 8963 }, 8964 Sender: &User{ 8965 Login: Ptr("l"), 8966 ID: Ptr(int64(1)), 8967 NodeID: Ptr("n"), 8968 URL: Ptr("u"), 8969 ReposURL: Ptr("r"), 8970 EventsURL: Ptr("e"), 8971 AvatarURL: Ptr("a"), 8972 }, 8973 } 8974 8975 want := `{ 8976 "status": "success", 8977 "repository": { 8978 "id": 1, 8979 "name": "n", 8980 "url": "s" 8981 }, 8982 "organization": { 8983 "name": "n", 8984 "company": "c", 8985 "blog": "b", 8986 "location": "loc", 8987 "email": "e", 8988 "twitter_username": "tu", 8989 "description": "d", 8990 "billing_email": "be", 8991 "is_verified": true, 8992 "has_organization_projects": true, 8993 "has_repository_projects": true, 8994 "default_repository_permission": "drp", 8995 "members_can_create_repositories": true, 8996 "members_can_create_public_repositories": false, 8997 "members_can_create_private_repositories": true, 8998 "members_can_create_internal_repositories": true, 8999 "members_allowed_repository_creation_type": "marct", 9000 "members_can_create_pages": true, 9001 "members_can_create_public_pages": false, 9002 "members_can_create_private_pages": true 9003 }, 9004 "sender": { 9005 "login": "l", 9006 "id": 1, 9007 "node_id": "n", 9008 "avatar_url": "a", 9009 "url": "u", 9010 "events_url": "e", 9011 "repos_url": "r" 9012 } 9013 }` 9014 9015 testJSONMarshal(t, u, want) 9016 } 9017 9018 func TestRepositoryEvent_Marshal(t *testing.T) { 9019 t.Parallel() 9020 testJSONMarshal(t, &RepositoryEvent{}, "{}") 9021 9022 u := &RepositoryEvent{ 9023 Action: Ptr("a"), 9024 Repo: &Repository{ 9025 ID: Ptr(int64(1)), 9026 URL: Ptr("s"), 9027 Name: Ptr("n"), 9028 }, 9029 Org: &Organization{ 9030 BillingEmail: Ptr("be"), 9031 Blog: Ptr("b"), 9032 Company: Ptr("c"), 9033 Email: Ptr("e"), 9034 TwitterUsername: Ptr("tu"), 9035 Location: Ptr("loc"), 9036 Name: Ptr("n"), 9037 Description: Ptr("d"), 9038 IsVerified: Ptr(true), 9039 HasOrganizationProjects: Ptr(true), 9040 HasRepositoryProjects: Ptr(true), 9041 DefaultRepoPermission: Ptr("drp"), 9042 MembersCanCreateRepos: Ptr(true), 9043 MembersCanCreateInternalRepos: Ptr(true), 9044 MembersCanCreatePrivateRepos: Ptr(true), 9045 MembersCanCreatePublicRepos: Ptr(false), 9046 MembersAllowedRepositoryCreationType: Ptr("marct"), 9047 MembersCanCreatePages: Ptr(true), 9048 MembersCanCreatePublicPages: Ptr(false), 9049 MembersCanCreatePrivatePages: Ptr(true), 9050 }, 9051 Sender: &User{ 9052 Login: Ptr("l"), 9053 ID: Ptr(int64(1)), 9054 NodeID: Ptr("n"), 9055 URL: Ptr("u"), 9056 ReposURL: Ptr("r"), 9057 EventsURL: Ptr("e"), 9058 AvatarURL: Ptr("a"), 9059 }, 9060 Installation: &Installation{ 9061 ID: Ptr(int64(1)), 9062 NodeID: Ptr("nid"), 9063 AppID: Ptr(int64(1)), 9064 AppSlug: Ptr("as"), 9065 TargetID: Ptr(int64(1)), 9066 Account: &User{ 9067 Login: Ptr("l"), 9068 ID: Ptr(int64(1)), 9069 URL: Ptr("u"), 9070 AvatarURL: Ptr("a"), 9071 GravatarID: Ptr("g"), 9072 Name: Ptr("n"), 9073 Company: Ptr("c"), 9074 Blog: Ptr("b"), 9075 Location: Ptr("l"), 9076 Email: Ptr("e"), 9077 Hireable: Ptr(true), 9078 Bio: Ptr("b"), 9079 TwitterUsername: Ptr("t"), 9080 PublicRepos: Ptr(1), 9081 Followers: Ptr(1), 9082 Following: Ptr(1), 9083 CreatedAt: &Timestamp{referenceTime}, 9084 SuspendedAt: &Timestamp{referenceTime}, 9085 }, 9086 AccessTokensURL: Ptr("atu"), 9087 RepositoriesURL: Ptr("ru"), 9088 HTMLURL: Ptr("hu"), 9089 TargetType: Ptr("tt"), 9090 SingleFileName: Ptr("sfn"), 9091 RepositorySelection: Ptr("rs"), 9092 Events: []string{"e"}, 9093 SingleFilePaths: []string{"s"}, 9094 Permissions: &InstallationPermissions{ 9095 Actions: Ptr("a"), 9096 Administration: Ptr("ad"), 9097 Checks: Ptr("c"), 9098 Contents: Ptr("co"), 9099 ContentReferences: Ptr("cr"), 9100 Deployments: Ptr("d"), 9101 Environments: Ptr("e"), 9102 Issues: Ptr("i"), 9103 Metadata: Ptr("md"), 9104 Members: Ptr("m"), 9105 OrganizationAdministration: Ptr("oa"), 9106 OrganizationHooks: Ptr("oh"), 9107 OrganizationPlan: Ptr("op"), 9108 OrganizationPreReceiveHooks: Ptr("opr"), 9109 OrganizationProjects: Ptr("op"), 9110 OrganizationSecrets: Ptr("os"), 9111 OrganizationSelfHostedRunners: Ptr("osh"), 9112 OrganizationUserBlocking: Ptr("oub"), 9113 Packages: Ptr("pkg"), 9114 Pages: Ptr("pg"), 9115 PullRequests: Ptr("pr"), 9116 RepositoryHooks: Ptr("rh"), 9117 RepositoryProjects: Ptr("rp"), 9118 RepositoryPreReceiveHooks: Ptr("rprh"), 9119 Secrets: Ptr("s"), 9120 SecretScanningAlerts: Ptr("ssa"), 9121 SecurityEvents: Ptr("se"), 9122 SingleFile: Ptr("sf"), 9123 Statuses: Ptr("s"), 9124 TeamDiscussions: Ptr("td"), 9125 VulnerabilityAlerts: Ptr("va"), 9126 Workflows: Ptr("w"), 9127 }, 9128 CreatedAt: &Timestamp{referenceTime}, 9129 UpdatedAt: &Timestamp{referenceTime}, 9130 HasMultipleSingleFiles: Ptr(false), 9131 SuspendedBy: &User{ 9132 Login: Ptr("l"), 9133 ID: Ptr(int64(1)), 9134 URL: Ptr("u"), 9135 AvatarURL: Ptr("a"), 9136 GravatarID: Ptr("g"), 9137 Name: Ptr("n"), 9138 Company: Ptr("c"), 9139 Blog: Ptr("b"), 9140 Location: Ptr("l"), 9141 Email: Ptr("e"), 9142 Hireable: Ptr(true), 9143 Bio: Ptr("b"), 9144 TwitterUsername: Ptr("t"), 9145 PublicRepos: Ptr(1), 9146 Followers: Ptr(1), 9147 Following: Ptr(1), 9148 CreatedAt: &Timestamp{referenceTime}, 9149 SuspendedAt: &Timestamp{referenceTime}, 9150 }, 9151 SuspendedAt: &Timestamp{referenceTime}, 9152 }, 9153 } 9154 9155 want := `{ 9156 "action": "a", 9157 "repository": { 9158 "id": 1, 9159 "name": "n", 9160 "url": "s" 9161 }, 9162 "organization": { 9163 "name": "n", 9164 "company": "c", 9165 "blog": "b", 9166 "location": "loc", 9167 "email": "e", 9168 "twitter_username": "tu", 9169 "description": "d", 9170 "billing_email": "be", 9171 "is_verified": true, 9172 "has_organization_projects": true, 9173 "has_repository_projects": true, 9174 "default_repository_permission": "drp", 9175 "members_can_create_repositories": true, 9176 "members_can_create_public_repositories": false, 9177 "members_can_create_private_repositories": true, 9178 "members_can_create_internal_repositories": true, 9179 "members_allowed_repository_creation_type": "marct", 9180 "members_can_create_pages": true, 9181 "members_can_create_public_pages": false, 9182 "members_can_create_private_pages": true 9183 }, 9184 "sender": { 9185 "login": "l", 9186 "id": 1, 9187 "node_id": "n", 9188 "avatar_url": "a", 9189 "url": "u", 9190 "events_url": "e", 9191 "repos_url": "r" 9192 }, 9193 "installation": { 9194 "id": 1, 9195 "node_id": "nid", 9196 "app_id": 1, 9197 "app_slug": "as", 9198 "target_id": 1, 9199 "account": { 9200 "login": "l", 9201 "id": 1, 9202 "avatar_url": "a", 9203 "gravatar_id": "g", 9204 "name": "n", 9205 "company": "c", 9206 "blog": "b", 9207 "location": "l", 9208 "email": "e", 9209 "hireable": true, 9210 "bio": "b", 9211 "twitter_username": "t", 9212 "public_repos": 1, 9213 "followers": 1, 9214 "following": 1, 9215 "created_at": ` + referenceTimeStr + `, 9216 "suspended_at": ` + referenceTimeStr + `, 9217 "url": "u" 9218 }, 9219 "access_tokens_url": "atu", 9220 "repositories_url": "ru", 9221 "html_url": "hu", 9222 "target_type": "tt", 9223 "single_file_name": "sfn", 9224 "repository_selection": "rs", 9225 "events": [ 9226 "e" 9227 ], 9228 "single_file_paths": [ 9229 "s" 9230 ], 9231 "permissions": { 9232 "actions": "a", 9233 "administration": "ad", 9234 "checks": "c", 9235 "contents": "co", 9236 "content_references": "cr", 9237 "deployments": "d", 9238 "environments": "e", 9239 "issues": "i", 9240 "metadata": "md", 9241 "members": "m", 9242 "organization_administration": "oa", 9243 "organization_hooks": "oh", 9244 "organization_plan": "op", 9245 "organization_pre_receive_hooks": "opr", 9246 "organization_projects": "op", 9247 "organization_secrets": "os", 9248 "organization_self_hosted_runners": "osh", 9249 "organization_user_blocking": "oub", 9250 "packages": "pkg", 9251 "pages": "pg", 9252 "pull_requests": "pr", 9253 "repository_hooks": "rh", 9254 "repository_projects": "rp", 9255 "repository_pre_receive_hooks": "rprh", 9256 "secrets": "s", 9257 "secret_scanning_alerts": "ssa", 9258 "security_events": "se", 9259 "single_file": "sf", 9260 "statuses": "s", 9261 "team_discussions": "td", 9262 "vulnerability_alerts": "va", 9263 "workflows": "w" 9264 }, 9265 "created_at": ` + referenceTimeStr + `, 9266 "updated_at": ` + referenceTimeStr + `, 9267 "has_multiple_single_files": false, 9268 "suspended_by": { 9269 "login": "l", 9270 "id": 1, 9271 "avatar_url": "a", 9272 "gravatar_id": "g", 9273 "name": "n", 9274 "company": "c", 9275 "blog": "b", 9276 "location": "l", 9277 "email": "e", 9278 "hireable": true, 9279 "bio": "b", 9280 "twitter_username": "t", 9281 "public_repos": 1, 9282 "followers": 1, 9283 "following": 1, 9284 "created_at": ` + referenceTimeStr + `, 9285 "suspended_at": ` + referenceTimeStr + `, 9286 "url": "u" 9287 }, 9288 "suspended_at": ` + referenceTimeStr + ` 9289 } 9290 }` 9291 9292 testJSONMarshal(t, u, want) 9293 } 9294 9295 func TestReleaseEvent_Marshal(t *testing.T) { 9296 t.Parallel() 9297 testJSONMarshal(t, &ReleaseEvent{}, "{}") 9298 9299 u := &ReleaseEvent{ 9300 Action: Ptr("a"), 9301 Release: &RepositoryRelease{ 9302 Name: Ptr("n"), 9303 DiscussionCategoryName: Ptr("dcn"), 9304 ID: Ptr(int64(2)), 9305 CreatedAt: &Timestamp{referenceTime}, 9306 PublishedAt: &Timestamp{referenceTime}, 9307 URL: Ptr("url"), 9308 HTMLURL: Ptr("htmlurl"), 9309 AssetsURL: Ptr("assetsurl"), 9310 Assets: []*ReleaseAsset{{ID: Ptr(int64(1))}}, 9311 UploadURL: Ptr("uploadurl"), 9312 ZipballURL: Ptr("zipballurl"), 9313 TarballURL: Ptr("tarballurl"), 9314 Author: &User{Name: Ptr("octocat")}, 9315 NodeID: Ptr("nid"), 9316 }, 9317 Repo: &Repository{ 9318 ID: Ptr(int64(1)), 9319 URL: Ptr("s"), 9320 Name: Ptr("n"), 9321 }, 9322 Sender: &User{ 9323 Login: Ptr("l"), 9324 ID: Ptr(int64(1)), 9325 NodeID: Ptr("n"), 9326 URL: Ptr("u"), 9327 ReposURL: Ptr("r"), 9328 EventsURL: Ptr("e"), 9329 AvatarURL: Ptr("a"), 9330 }, 9331 Installation: &Installation{ 9332 ID: Ptr(int64(1)), 9333 NodeID: Ptr("nid"), 9334 AppID: Ptr(int64(1)), 9335 AppSlug: Ptr("as"), 9336 TargetID: Ptr(int64(1)), 9337 Account: &User{ 9338 Login: Ptr("l"), 9339 ID: Ptr(int64(1)), 9340 URL: Ptr("u"), 9341 AvatarURL: Ptr("a"), 9342 GravatarID: Ptr("g"), 9343 Name: Ptr("n"), 9344 Company: Ptr("c"), 9345 Blog: Ptr("b"), 9346 Location: Ptr("l"), 9347 Email: Ptr("e"), 9348 Hireable: Ptr(true), 9349 Bio: Ptr("b"), 9350 TwitterUsername: Ptr("t"), 9351 PublicRepos: Ptr(1), 9352 Followers: Ptr(1), 9353 Following: Ptr(1), 9354 CreatedAt: &Timestamp{referenceTime}, 9355 SuspendedAt: &Timestamp{referenceTime}, 9356 }, 9357 AccessTokensURL: Ptr("atu"), 9358 RepositoriesURL: Ptr("ru"), 9359 HTMLURL: Ptr("hu"), 9360 TargetType: Ptr("tt"), 9361 SingleFileName: Ptr("sfn"), 9362 RepositorySelection: Ptr("rs"), 9363 Events: []string{"e"}, 9364 SingleFilePaths: []string{"s"}, 9365 Permissions: &InstallationPermissions{ 9366 Actions: Ptr("a"), 9367 Administration: Ptr("ad"), 9368 Checks: Ptr("c"), 9369 Contents: Ptr("co"), 9370 ContentReferences: Ptr("cr"), 9371 Deployments: Ptr("d"), 9372 Environments: Ptr("e"), 9373 Issues: Ptr("i"), 9374 Metadata: Ptr("md"), 9375 Members: Ptr("m"), 9376 OrganizationAdministration: Ptr("oa"), 9377 OrganizationHooks: Ptr("oh"), 9378 OrganizationPlan: Ptr("op"), 9379 OrganizationPreReceiveHooks: Ptr("opr"), 9380 OrganizationProjects: Ptr("op"), 9381 OrganizationSecrets: Ptr("os"), 9382 OrganizationSelfHostedRunners: Ptr("osh"), 9383 OrganizationUserBlocking: Ptr("oub"), 9384 Packages: Ptr("pkg"), 9385 Pages: Ptr("pg"), 9386 PullRequests: Ptr("pr"), 9387 RepositoryHooks: Ptr("rh"), 9388 RepositoryProjects: Ptr("rp"), 9389 RepositoryPreReceiveHooks: Ptr("rprh"), 9390 Secrets: Ptr("s"), 9391 SecretScanningAlerts: Ptr("ssa"), 9392 SecurityEvents: Ptr("se"), 9393 SingleFile: Ptr("sf"), 9394 Statuses: Ptr("s"), 9395 TeamDiscussions: Ptr("td"), 9396 VulnerabilityAlerts: Ptr("va"), 9397 Workflows: Ptr("w"), 9398 }, 9399 CreatedAt: &Timestamp{referenceTime}, 9400 UpdatedAt: &Timestamp{referenceTime}, 9401 HasMultipleSingleFiles: Ptr(false), 9402 SuspendedBy: &User{ 9403 Login: Ptr("l"), 9404 ID: Ptr(int64(1)), 9405 URL: Ptr("u"), 9406 AvatarURL: Ptr("a"), 9407 GravatarID: Ptr("g"), 9408 Name: Ptr("n"), 9409 Company: Ptr("c"), 9410 Blog: Ptr("b"), 9411 Location: Ptr("l"), 9412 Email: Ptr("e"), 9413 Hireable: Ptr(true), 9414 Bio: Ptr("b"), 9415 TwitterUsername: Ptr("t"), 9416 PublicRepos: Ptr(1), 9417 Followers: Ptr(1), 9418 Following: Ptr(1), 9419 CreatedAt: &Timestamp{referenceTime}, 9420 SuspendedAt: &Timestamp{referenceTime}, 9421 }, 9422 SuspendedAt: &Timestamp{referenceTime}, 9423 }, 9424 } 9425 9426 want := `{ 9427 "action": "a", 9428 "release": { 9429 "name": "n", 9430 "discussion_category_name": "dcn", 9431 "id": 2, 9432 "created_at": ` + referenceTimeStr + `, 9433 "published_at": ` + referenceTimeStr + `, 9434 "url": "url", 9435 "html_url": "htmlurl", 9436 "assets_url": "assetsurl", 9437 "assets": [ 9438 { 9439 "id": 1 9440 } 9441 ], 9442 "upload_url": "uploadurl", 9443 "zipball_url": "zipballurl", 9444 "tarball_url": "tarballurl", 9445 "author": { 9446 "name": "octocat" 9447 }, 9448 "node_id": "nid" 9449 }, 9450 "repository": { 9451 "id": 1, 9452 "name": "n", 9453 "url": "s" 9454 }, 9455 "sender": { 9456 "login": "l", 9457 "id": 1, 9458 "node_id": "n", 9459 "avatar_url": "a", 9460 "url": "u", 9461 "events_url": "e", 9462 "repos_url": "r" 9463 }, 9464 "installation": { 9465 "id": 1, 9466 "node_id": "nid", 9467 "app_id": 1, 9468 "app_slug": "as", 9469 "target_id": 1, 9470 "account": { 9471 "login": "l", 9472 "id": 1, 9473 "avatar_url": "a", 9474 "gravatar_id": "g", 9475 "name": "n", 9476 "company": "c", 9477 "blog": "b", 9478 "location": "l", 9479 "email": "e", 9480 "hireable": true, 9481 "bio": "b", 9482 "twitter_username": "t", 9483 "public_repos": 1, 9484 "followers": 1, 9485 "following": 1, 9486 "created_at": ` + referenceTimeStr + `, 9487 "suspended_at": ` + referenceTimeStr + `, 9488 "url": "u" 9489 }, 9490 "access_tokens_url": "atu", 9491 "repositories_url": "ru", 9492 "html_url": "hu", 9493 "target_type": "tt", 9494 "single_file_name": "sfn", 9495 "repository_selection": "rs", 9496 "events": [ 9497 "e" 9498 ], 9499 "single_file_paths": [ 9500 "s" 9501 ], 9502 "permissions": { 9503 "actions": "a", 9504 "administration": "ad", 9505 "checks": "c", 9506 "contents": "co", 9507 "content_references": "cr", 9508 "deployments": "d", 9509 "environments": "e", 9510 "issues": "i", 9511 "metadata": "md", 9512 "members": "m", 9513 "organization_administration": "oa", 9514 "organization_hooks": "oh", 9515 "organization_plan": "op", 9516 "organization_pre_receive_hooks": "opr", 9517 "organization_projects": "op", 9518 "organization_secrets": "os", 9519 "organization_self_hosted_runners": "osh", 9520 "organization_user_blocking": "oub", 9521 "packages": "pkg", 9522 "pages": "pg", 9523 "pull_requests": "pr", 9524 "repository_hooks": "rh", 9525 "repository_projects": "rp", 9526 "repository_pre_receive_hooks": "rprh", 9527 "secrets": "s", 9528 "secret_scanning_alerts": "ssa", 9529 "security_events": "se", 9530 "single_file": "sf", 9531 "statuses": "s", 9532 "team_discussions": "td", 9533 "vulnerability_alerts": "va", 9534 "workflows": "w" 9535 }, 9536 "created_at": ` + referenceTimeStr + `, 9537 "updated_at": ` + referenceTimeStr + `, 9538 "has_multiple_single_files": false, 9539 "suspended_by": { 9540 "login": "l", 9541 "id": 1, 9542 "avatar_url": "a", 9543 "gravatar_id": "g", 9544 "name": "n", 9545 "company": "c", 9546 "blog": "b", 9547 "location": "l", 9548 "email": "e", 9549 "hireable": true, 9550 "bio": "b", 9551 "twitter_username": "t", 9552 "public_repos": 1, 9553 "followers": 1, 9554 "following": 1, 9555 "created_at": ` + referenceTimeStr + `, 9556 "suspended_at": ` + referenceTimeStr + `, 9557 "url": "u" 9558 }, 9559 "suspended_at": ` + referenceTimeStr + ` 9560 } 9561 }` 9562 9563 testJSONMarshal(t, u, want) 9564 } 9565 9566 func TestRepositoryRulesetEvent_Unmarshal(t *testing.T) { 9567 t.Parallel() 9568 9569 enterprise := &Enterprise{ 9570 ID: Ptr(1), 9571 NodeID: Ptr("n"), 9572 Slug: Ptr("e"), 9573 Name: Ptr("e"), 9574 } 9575 9576 installation := &Installation{ 9577 ID: Ptr(int64(1)), 9578 NodeID: Ptr("n"), 9579 AppID: Ptr(int64(1)), 9580 AppSlug: Ptr("a"), 9581 } 9582 9583 organization := &Organization{ 9584 ID: Ptr(int64(1)), 9585 NodeID: Ptr("n"), 9586 Name: Ptr("o"), 9587 } 9588 9589 repository := &Repository{ 9590 ID: Ptr(int64(1)), 9591 NodeID: Ptr("n"), 9592 Name: Ptr("r"), 9593 FullName: Ptr("o/r"), 9594 } 9595 9596 sender := &User{ 9597 ID: Ptr(int64(1)), 9598 NodeID: Ptr("n"), 9599 Login: Ptr("l"), 9600 } 9601 9602 tests := []struct { 9603 name string 9604 json string 9605 event *RepositoryRulesetEvent 9606 }{ 9607 {"empty", `{}`, &RepositoryRulesetEvent{}}, 9608 { 9609 "created", 9610 fmt.Sprintf( 9611 `{"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"}}`, 9612 referenceTimeStr, 9613 ), 9614 &RepositoryRulesetEvent{ 9615 Action: Ptr("created"), 9616 RepositoryRuleset: &RepositoryRuleset{ 9617 ID: Ptr(int64(1)), 9618 Name: "r", 9619 Target: Ptr(RulesetTargetBranch), 9620 SourceType: Ptr(RulesetSourceTypeRepository), 9621 Source: "o/r", 9622 Enforcement: RulesetEnforcementActive, 9623 Conditions: &RepositoryRulesetConditions{ 9624 RefName: &RepositoryRulesetRefConditionParameters{ 9625 Include: []string{"~ALL"}, 9626 Exclude: []string{}, 9627 }, 9628 }, 9629 Rules: &RepositoryRulesetRules{ 9630 Creation: &EmptyRuleParameters{}, 9631 Update: &UpdateRuleParameters{}, 9632 Deletion: &EmptyRuleParameters{}, 9633 RequiredLinearHistory: &EmptyRuleParameters{}, 9634 PullRequest: &PullRequestRuleParameters{ 9635 AllowedMergeMethods: []MergeMethod{ 9636 MergeMethodSquash, 9637 MergeMethodRebase, 9638 MergeMethodMerge, 9639 }, 9640 DismissStaleReviewsOnPush: false, 9641 RequireCodeOwnerReview: false, 9642 RequireLastPushApproval: false, 9643 RequiredApprovingReviewCount: 2, 9644 RequiredReviewThreadResolution: false, 9645 }, 9646 CodeScanning: &CodeScanningRuleParameters{ 9647 CodeScanningTools: []*RuleCodeScanningTool{ 9648 { 9649 AlertsThreshold: CodeScanningAlertsThresholdErrors, 9650 SecurityAlertsThreshold: CodeScanningSecurityAlertsThresholdHighOrHigher, 9651 Tool: "CodeQL", 9652 }, 9653 }, 9654 }, 9655 }, 9656 NodeID: Ptr("n"), 9657 CreatedAt: &Timestamp{referenceTime}, 9658 UpdatedAt: &Timestamp{referenceTime}, 9659 Links: &RepositoryRulesetLinks{ 9660 Self: &RepositoryRulesetLink{HRef: Ptr("a")}, 9661 HTML: &RepositoryRulesetLink{HRef: Ptr("a")}, 9662 }, 9663 }, 9664 Repository: repository, 9665 Organization: organization, 9666 Enterprise: enterprise, 9667 Installation: installation, 9668 Sender: sender, 9669 }, 9670 }, 9671 { 9672 "edited", 9673 fmt.Sprintf( 9674 `{"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"}}`, 9675 referenceTimeStr, 9676 ), 9677 &RepositoryRulesetEvent{ 9678 Action: Ptr("edited"), 9679 RepositoryRuleset: &RepositoryRuleset{ 9680 ID: Ptr(int64(1)), 9681 Name: "r", 9682 Target: Ptr(RulesetTargetBranch), 9683 SourceType: Ptr(RulesetSourceTypeRepository), 9684 Source: "o/r", 9685 Enforcement: RulesetEnforcementActive, 9686 Conditions: &RepositoryRulesetConditions{ 9687 RefName: &RepositoryRulesetRefConditionParameters{ 9688 Include: []string{"~DEFAULT_BRANCH", "refs/heads/dev-*"}, 9689 Exclude: []string{}, 9690 }, 9691 }, 9692 Rules: &RepositoryRulesetRules{ 9693 Creation: &EmptyRuleParameters{}, 9694 Update: &UpdateRuleParameters{}, 9695 Deletion: &EmptyRuleParameters{}, 9696 RequiredSignatures: &EmptyRuleParameters{}, 9697 PullRequest: &PullRequestRuleParameters{ 9698 AllowedMergeMethods: []MergeMethod{ 9699 MergeMethodSquash, 9700 MergeMethodRebase, 9701 }, 9702 DismissStaleReviewsOnPush: false, 9703 RequireCodeOwnerReview: false, 9704 RequireLastPushApproval: false, 9705 RequiredApprovingReviewCount: 2, 9706 RequiredReviewThreadResolution: false, 9707 }, 9708 CodeScanning: &CodeScanningRuleParameters{ 9709 CodeScanningTools: []*RuleCodeScanningTool{ 9710 { 9711 AlertsThreshold: CodeScanningAlertsThresholdErrors, 9712 SecurityAlertsThreshold: CodeScanningSecurityAlertsThresholdMediumOrHigher, 9713 Tool: "CodeQL", 9714 }, 9715 }, 9716 }, 9717 }, 9718 NodeID: Ptr("n"), 9719 CreatedAt: &Timestamp{referenceTime}, 9720 UpdatedAt: &Timestamp{referenceTime}, 9721 Links: &RepositoryRulesetLinks{ 9722 Self: &RepositoryRulesetLink{HRef: Ptr("a")}, 9723 HTML: &RepositoryRulesetLink{HRef: Ptr("a")}, 9724 }, 9725 }, 9726 Changes: &RepositoryRulesetChanges{ 9727 Conditions: &RepositoryRulesetChangedConditions{ 9728 Updated: []*RepositoryRulesetUpdatedConditions{ 9729 { 9730 Condition: &RepositoryRulesetConditions{ 9731 RefName: &RepositoryRulesetRefConditionParameters{ 9732 Include: []string{"~DEFAULT_BRANCH", "refs/heads/dev-*"}, 9733 Exclude: []string{}, 9734 }, 9735 }, 9736 Changes: &RepositoryRulesetUpdatedCondition{ 9737 Include: &RepositoryRulesetChangeSources{ 9738 From: []string{"~ALL"}, 9739 }, 9740 }, 9741 }, 9742 }, 9743 Deleted: []*RepositoryRulesetConditions{}, 9744 }, 9745 Rules: &RepositoryRulesetChangedRules{ 9746 Added: []*RepositoryRule{{Type: RulesetRuleTypeRequiredSignatures}}, 9747 Updated: []*RepositoryRulesetUpdatedRules{ 9748 { 9749 Rule: &RepositoryRule{ 9750 Type: RulesetRuleTypePullRequest, 9751 Parameters: &PullRequestRuleParameters{ 9752 AllowedMergeMethods: []MergeMethod{ 9753 MergeMethodSquash, 9754 MergeMethodRebase, 9755 }, 9756 DismissStaleReviewsOnPush: false, 9757 RequireCodeOwnerReview: false, 9758 RequireLastPushApproval: false, 9759 RequiredApprovingReviewCount: 2, 9760 RequiredReviewThreadResolution: false, 9761 }, 9762 }, 9763 Changes: &RepositoryRulesetChangedRule{ 9764 Configuration: &RepositoryRulesetChangeSource{ 9765 From: Ptr( 9766 `{\"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}`, 9767 ), 9768 }, 9769 }, 9770 }, 9771 { 9772 Rule: &RepositoryRule{ 9773 Type: RulesetRuleTypeCodeScanning, 9774 Parameters: &CodeScanningRuleParameters{ 9775 CodeScanningTools: []*RuleCodeScanningTool{ 9776 { 9777 AlertsThreshold: CodeScanningAlertsThresholdErrors, 9778 SecurityAlertsThreshold: CodeScanningSecurityAlertsThresholdMediumOrHigher, 9779 Tool: "CodeQL", 9780 }, 9781 }, 9782 }, 9783 }, 9784 Changes: &RepositoryRulesetChangedRule{ 9785 Configuration: &RepositoryRulesetChangeSource{ 9786 From: Ptr( 9787 `{\"code_scanning_tools\":[{\"tool\":\"CodeQL\",\"alerts_threshold\":\"errors\",\"security_alerts_threshold\":\"high_or_higher\"}]}`, 9788 ), 9789 }, 9790 }, 9791 }, 9792 }, 9793 Deleted: []*RepositoryRule{{Type: RulesetRuleTypeRequiredLinearHistory}}, 9794 }, 9795 }, 9796 Repository: repository, 9797 Organization: organization, 9798 Enterprise: enterprise, 9799 Installation: installation, 9800 Sender: sender, 9801 }, 9802 }, 9803 { 9804 "deleted", 9805 fmt.Sprintf( 9806 `{"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"}}`, 9807 referenceTimeStr, 9808 ), 9809 &RepositoryRulesetEvent{ 9810 Action: Ptr("deleted"), 9811 RepositoryRuleset: &RepositoryRuleset{ 9812 ID: Ptr(int64(1)), 9813 Name: "r", 9814 Target: Ptr(RulesetTargetBranch), 9815 SourceType: Ptr(RulesetSourceTypeRepository), 9816 Source: "o/r", 9817 Enforcement: RulesetEnforcementActive, 9818 Conditions: &RepositoryRulesetConditions{ 9819 RefName: &RepositoryRulesetRefConditionParameters{ 9820 Include: []string{"~DEFAULT_BRANCH", "refs/heads/dev-*"}, 9821 Exclude: []string{}, 9822 }, 9823 }, 9824 Rules: &RepositoryRulesetRules{ 9825 Creation: &EmptyRuleParameters{}, 9826 Update: &UpdateRuleParameters{}, 9827 Deletion: &EmptyRuleParameters{}, 9828 RequiredLinearHistory: &EmptyRuleParameters{}, 9829 }, 9830 NodeID: Ptr("n"), 9831 CreatedAt: &Timestamp{referenceTime}, 9832 UpdatedAt: &Timestamp{referenceTime}, 9833 Links: &RepositoryRulesetLinks{ 9834 Self: &RepositoryRulesetLink{HRef: Ptr("a")}, 9835 HTML: &RepositoryRulesetLink{HRef: Ptr("a")}, 9836 }, 9837 }, 9838 Repository: repository, 9839 Organization: organization, 9840 Enterprise: enterprise, 9841 Installation: installation, 9842 Sender: sender, 9843 }, 9844 }, 9845 } 9846 9847 for _, test := range tests { 9848 t.Run(test.name, func(t *testing.T) { 9849 t.Parallel() 9850 9851 got := &RepositoryRulesetEvent{} 9852 err := json.Unmarshal([]byte(test.json), got) 9853 if err != nil { 9854 t.Errorf("Unable to unmarshal JSON %v: %v", test.json, err) 9855 } 9856 9857 if diff := cmp.Diff(test.event, got); diff != "" { 9858 t.Errorf("json.Unmarshal returned:\n%#v\nwant:\n%#v\ndiff:\n%v", got, test.event, diff) 9859 } 9860 }) 9861 } 9862 } 9863 9864 func TestContentReferenceEvent_Marshal(t *testing.T) { 9865 t.Parallel() 9866 testJSONMarshal(t, &ContentReferenceEvent{}, "{}") 9867 9868 u := &ContentReferenceEvent{ 9869 Action: Ptr("a"), 9870 ContentReference: &ContentReference{ 9871 ID: Ptr(int64(1)), 9872 NodeID: Ptr("nid"), 9873 Reference: Ptr("ref"), 9874 }, 9875 Repo: &Repository{ 9876 ID: Ptr(int64(1)), 9877 URL: Ptr("s"), 9878 Name: Ptr("n"), 9879 }, 9880 Sender: &User{ 9881 Login: Ptr("l"), 9882 ID: Ptr(int64(1)), 9883 NodeID: Ptr("n"), 9884 URL: Ptr("u"), 9885 ReposURL: Ptr("r"), 9886 EventsURL: Ptr("e"), 9887 AvatarURL: Ptr("a"), 9888 }, 9889 Installation: &Installation{ 9890 ID: Ptr(int64(1)), 9891 NodeID: Ptr("nid"), 9892 AppID: Ptr(int64(1)), 9893 AppSlug: Ptr("as"), 9894 TargetID: Ptr(int64(1)), 9895 Account: &User{ 9896 Login: Ptr("l"), 9897 ID: Ptr(int64(1)), 9898 URL: Ptr("u"), 9899 AvatarURL: Ptr("a"), 9900 GravatarID: Ptr("g"), 9901 Name: Ptr("n"), 9902 Company: Ptr("c"), 9903 Blog: Ptr("b"), 9904 Location: Ptr("l"), 9905 Email: Ptr("e"), 9906 Hireable: Ptr(true), 9907 Bio: Ptr("b"), 9908 TwitterUsername: Ptr("t"), 9909 PublicRepos: Ptr(1), 9910 Followers: Ptr(1), 9911 Following: Ptr(1), 9912 CreatedAt: &Timestamp{referenceTime}, 9913 SuspendedAt: &Timestamp{referenceTime}, 9914 }, 9915 AccessTokensURL: Ptr("atu"), 9916 RepositoriesURL: Ptr("ru"), 9917 HTMLURL: Ptr("hu"), 9918 TargetType: Ptr("tt"), 9919 SingleFileName: Ptr("sfn"), 9920 RepositorySelection: Ptr("rs"), 9921 Events: []string{"e"}, 9922 SingleFilePaths: []string{"s"}, 9923 Permissions: &InstallationPermissions{ 9924 Actions: Ptr("a"), 9925 Administration: Ptr("ad"), 9926 Checks: Ptr("c"), 9927 Contents: Ptr("co"), 9928 ContentReferences: Ptr("cr"), 9929 Deployments: Ptr("d"), 9930 Environments: Ptr("e"), 9931 Issues: Ptr("i"), 9932 Metadata: Ptr("md"), 9933 Members: Ptr("m"), 9934 OrganizationAdministration: Ptr("oa"), 9935 OrganizationHooks: Ptr("oh"), 9936 OrganizationPlan: Ptr("op"), 9937 OrganizationPreReceiveHooks: Ptr("opr"), 9938 OrganizationProjects: Ptr("op"), 9939 OrganizationSecrets: Ptr("os"), 9940 OrganizationSelfHostedRunners: Ptr("osh"), 9941 OrganizationUserBlocking: Ptr("oub"), 9942 Packages: Ptr("pkg"), 9943 Pages: Ptr("pg"), 9944 PullRequests: Ptr("pr"), 9945 RepositoryHooks: Ptr("rh"), 9946 RepositoryProjects: Ptr("rp"), 9947 RepositoryPreReceiveHooks: Ptr("rprh"), 9948 Secrets: Ptr("s"), 9949 SecretScanningAlerts: Ptr("ssa"), 9950 SecurityEvents: Ptr("se"), 9951 SingleFile: Ptr("sf"), 9952 Statuses: Ptr("s"), 9953 TeamDiscussions: Ptr("td"), 9954 VulnerabilityAlerts: Ptr("va"), 9955 Workflows: Ptr("w"), 9956 }, 9957 CreatedAt: &Timestamp{referenceTime}, 9958 UpdatedAt: &Timestamp{referenceTime}, 9959 HasMultipleSingleFiles: Ptr(false), 9960 SuspendedBy: &User{ 9961 Login: Ptr("l"), 9962 ID: Ptr(int64(1)), 9963 URL: Ptr("u"), 9964 AvatarURL: Ptr("a"), 9965 GravatarID: Ptr("g"), 9966 Name: Ptr("n"), 9967 Company: Ptr("c"), 9968 Blog: Ptr("b"), 9969 Location: Ptr("l"), 9970 Email: Ptr("e"), 9971 Hireable: Ptr(true), 9972 Bio: Ptr("b"), 9973 TwitterUsername: Ptr("t"), 9974 PublicRepos: Ptr(1), 9975 Followers: Ptr(1), 9976 Following: Ptr(1), 9977 CreatedAt: &Timestamp{referenceTime}, 9978 SuspendedAt: &Timestamp{referenceTime}, 9979 }, 9980 SuspendedAt: &Timestamp{referenceTime}, 9981 }, 9982 } 9983 9984 want := `{ 9985 "action": "a", 9986 "content_reference": { 9987 "id": 1, 9988 "node_id": "nid", 9989 "reference": "ref" 9990 }, 9991 "repository": { 9992 "id": 1, 9993 "name": "n", 9994 "url": "s" 9995 }, 9996 "sender": { 9997 "login": "l", 9998 "id": 1, 9999 "node_id": "n", 10000 "avatar_url": "a", 10001 "url": "u", 10002 "events_url": "e", 10003 "repos_url": "r" 10004 }, 10005 "installation": { 10006 "id": 1, 10007 "node_id": "nid", 10008 "app_id": 1, 10009 "app_slug": "as", 10010 "target_id": 1, 10011 "account": { 10012 "login": "l", 10013 "id": 1, 10014 "avatar_url": "a", 10015 "gravatar_id": "g", 10016 "name": "n", 10017 "company": "c", 10018 "blog": "b", 10019 "location": "l", 10020 "email": "e", 10021 "hireable": true, 10022 "bio": "b", 10023 "twitter_username": "t", 10024 "public_repos": 1, 10025 "followers": 1, 10026 "following": 1, 10027 "created_at": ` + referenceTimeStr + `, 10028 "suspended_at": ` + referenceTimeStr + `, 10029 "url": "u" 10030 }, 10031 "access_tokens_url": "atu", 10032 "repositories_url": "ru", 10033 "html_url": "hu", 10034 "target_type": "tt", 10035 "single_file_name": "sfn", 10036 "repository_selection": "rs", 10037 "events": [ 10038 "e" 10039 ], 10040 "single_file_paths": [ 10041 "s" 10042 ], 10043 "permissions": { 10044 "actions": "a", 10045 "administration": "ad", 10046 "checks": "c", 10047 "contents": "co", 10048 "content_references": "cr", 10049 "deployments": "d", 10050 "environments": "e", 10051 "issues": "i", 10052 "metadata": "md", 10053 "members": "m", 10054 "organization_administration": "oa", 10055 "organization_hooks": "oh", 10056 "organization_plan": "op", 10057 "organization_pre_receive_hooks": "opr", 10058 "organization_projects": "op", 10059 "organization_secrets": "os", 10060 "organization_self_hosted_runners": "osh", 10061 "organization_user_blocking": "oub", 10062 "packages": "pkg", 10063 "pages": "pg", 10064 "pull_requests": "pr", 10065 "repository_hooks": "rh", 10066 "repository_projects": "rp", 10067 "repository_pre_receive_hooks": "rprh", 10068 "secrets": "s", 10069 "secret_scanning_alerts": "ssa", 10070 "security_events": "se", 10071 "single_file": "sf", 10072 "statuses": "s", 10073 "team_discussions": "td", 10074 "vulnerability_alerts": "va", 10075 "workflows": "w" 10076 }, 10077 "created_at": ` + referenceTimeStr + `, 10078 "updated_at": ` + referenceTimeStr + `, 10079 "has_multiple_single_files": false, 10080 "suspended_by": { 10081 "login": "l", 10082 "id": 1, 10083 "avatar_url": "a", 10084 "gravatar_id": "g", 10085 "name": "n", 10086 "company": "c", 10087 "blog": "b", 10088 "location": "l", 10089 "email": "e", 10090 "hireable": true, 10091 "bio": "b", 10092 "twitter_username": "t", 10093 "public_repos": 1, 10094 "followers": 1, 10095 "following": 1, 10096 "created_at": ` + referenceTimeStr + `, 10097 "suspended_at": ` + referenceTimeStr + `, 10098 "url": "u" 10099 }, 10100 "suspended_at": ` + referenceTimeStr + ` 10101 } 10102 }` 10103 10104 testJSONMarshal(t, u, want) 10105 } 10106 10107 func TestMemberEvent_Marshal(t *testing.T) { 10108 t.Parallel() 10109 testJSONMarshal(t, &MemberEvent{}, "{}") 10110 10111 u := &MemberEvent{ 10112 Action: Ptr("a"), 10113 Member: &User{ 10114 Login: Ptr("l"), 10115 ID: Ptr(int64(1)), 10116 NodeID: Ptr("n"), 10117 URL: Ptr("u"), 10118 ReposURL: Ptr("r"), 10119 EventsURL: Ptr("e"), 10120 AvatarURL: Ptr("a"), 10121 }, 10122 Changes: &MemberChanges{ 10123 Permission: &MemberChangesPermission{ 10124 From: Ptr("f"), 10125 To: Ptr("t"), 10126 }, 10127 RoleName: &MemberChangesRoleName{ 10128 From: Ptr("f"), 10129 To: Ptr("t"), 10130 }, 10131 }, 10132 Repo: &Repository{ 10133 ID: Ptr(int64(1)), 10134 URL: Ptr("s"), 10135 Name: Ptr("n"), 10136 }, 10137 Sender: &User{ 10138 Login: Ptr("l"), 10139 ID: Ptr(int64(1)), 10140 NodeID: Ptr("n"), 10141 URL: Ptr("u"), 10142 ReposURL: Ptr("r"), 10143 EventsURL: Ptr("e"), 10144 AvatarURL: Ptr("a"), 10145 }, 10146 Installation: &Installation{ 10147 ID: Ptr(int64(1)), 10148 NodeID: Ptr("nid"), 10149 AppID: Ptr(int64(1)), 10150 AppSlug: Ptr("as"), 10151 TargetID: Ptr(int64(1)), 10152 Account: &User{ 10153 Login: Ptr("l"), 10154 ID: Ptr(int64(1)), 10155 URL: Ptr("u"), 10156 AvatarURL: Ptr("a"), 10157 GravatarID: Ptr("g"), 10158 Name: Ptr("n"), 10159 Company: Ptr("c"), 10160 Blog: Ptr("b"), 10161 Location: Ptr("l"), 10162 Email: Ptr("e"), 10163 Hireable: Ptr(true), 10164 Bio: Ptr("b"), 10165 TwitterUsername: Ptr("t"), 10166 PublicRepos: Ptr(1), 10167 Followers: Ptr(1), 10168 Following: Ptr(1), 10169 CreatedAt: &Timestamp{referenceTime}, 10170 SuspendedAt: &Timestamp{referenceTime}, 10171 }, 10172 AccessTokensURL: Ptr("atu"), 10173 RepositoriesURL: Ptr("ru"), 10174 HTMLURL: Ptr("hu"), 10175 TargetType: Ptr("tt"), 10176 SingleFileName: Ptr("sfn"), 10177 RepositorySelection: Ptr("rs"), 10178 Events: []string{"e"}, 10179 SingleFilePaths: []string{"s"}, 10180 Permissions: &InstallationPermissions{ 10181 Actions: Ptr("a"), 10182 Administration: Ptr("ad"), 10183 Checks: Ptr("c"), 10184 Contents: Ptr("co"), 10185 ContentReferences: Ptr("cr"), 10186 Deployments: Ptr("d"), 10187 Environments: Ptr("e"), 10188 Issues: Ptr("i"), 10189 Metadata: Ptr("md"), 10190 Members: Ptr("m"), 10191 OrganizationAdministration: Ptr("oa"), 10192 OrganizationHooks: Ptr("oh"), 10193 OrganizationPlan: Ptr("op"), 10194 OrganizationPreReceiveHooks: Ptr("opr"), 10195 OrganizationProjects: Ptr("op"), 10196 OrganizationSecrets: Ptr("os"), 10197 OrganizationSelfHostedRunners: Ptr("osh"), 10198 OrganizationUserBlocking: Ptr("oub"), 10199 Packages: Ptr("pkg"), 10200 Pages: Ptr("pg"), 10201 PullRequests: Ptr("pr"), 10202 RepositoryHooks: Ptr("rh"), 10203 RepositoryProjects: Ptr("rp"), 10204 RepositoryPreReceiveHooks: Ptr("rprh"), 10205 Secrets: Ptr("s"), 10206 SecretScanningAlerts: Ptr("ssa"), 10207 SecurityEvents: Ptr("se"), 10208 SingleFile: Ptr("sf"), 10209 Statuses: Ptr("s"), 10210 TeamDiscussions: Ptr("td"), 10211 VulnerabilityAlerts: Ptr("va"), 10212 Workflows: Ptr("w"), 10213 }, 10214 CreatedAt: &Timestamp{referenceTime}, 10215 UpdatedAt: &Timestamp{referenceTime}, 10216 HasMultipleSingleFiles: Ptr(false), 10217 SuspendedBy: &User{ 10218 Login: Ptr("l"), 10219 ID: Ptr(int64(1)), 10220 URL: Ptr("u"), 10221 AvatarURL: Ptr("a"), 10222 GravatarID: Ptr("g"), 10223 Name: Ptr("n"), 10224 Company: Ptr("c"), 10225 Blog: Ptr("b"), 10226 Location: Ptr("l"), 10227 Email: Ptr("e"), 10228 Hireable: Ptr(true), 10229 Bio: Ptr("b"), 10230 TwitterUsername: Ptr("t"), 10231 PublicRepos: Ptr(1), 10232 Followers: Ptr(1), 10233 Following: Ptr(1), 10234 CreatedAt: &Timestamp{referenceTime}, 10235 SuspendedAt: &Timestamp{referenceTime}, 10236 }, 10237 SuspendedAt: &Timestamp{referenceTime}, 10238 }, 10239 } 10240 10241 want := `{ 10242 "action": "a", 10243 "member": { 10244 "login": "l", 10245 "id": 1, 10246 "node_id": "n", 10247 "avatar_url": "a", 10248 "url": "u", 10249 "events_url": "e", 10250 "repos_url": "r" 10251 }, 10252 "changes": { 10253 "permission": { 10254 "from": "f", 10255 "to": "t" 10256 }, 10257 "role_name": { 10258 "from": "f", 10259 "to": "t" 10260 } 10261 }, 10262 "repository": { 10263 "id": 1, 10264 "name": "n", 10265 "url": "s" 10266 }, 10267 "sender": { 10268 "login": "l", 10269 "id": 1, 10270 "node_id": "n", 10271 "avatar_url": "a", 10272 "url": "u", 10273 "events_url": "e", 10274 "repos_url": "r" 10275 }, 10276 "installation": { 10277 "id": 1, 10278 "node_id": "nid", 10279 "app_id": 1, 10280 "app_slug": "as", 10281 "target_id": 1, 10282 "account": { 10283 "login": "l", 10284 "id": 1, 10285 "avatar_url": "a", 10286 "gravatar_id": "g", 10287 "name": "n", 10288 "company": "c", 10289 "blog": "b", 10290 "location": "l", 10291 "email": "e", 10292 "hireable": true, 10293 "bio": "b", 10294 "twitter_username": "t", 10295 "public_repos": 1, 10296 "followers": 1, 10297 "following": 1, 10298 "created_at": ` + referenceTimeStr + `, 10299 "suspended_at": ` + referenceTimeStr + `, 10300 "url": "u" 10301 }, 10302 "access_tokens_url": "atu", 10303 "repositories_url": "ru", 10304 "html_url": "hu", 10305 "target_type": "tt", 10306 "single_file_name": "sfn", 10307 "repository_selection": "rs", 10308 "events": [ 10309 "e" 10310 ], 10311 "single_file_paths": [ 10312 "s" 10313 ], 10314 "permissions": { 10315 "actions": "a", 10316 "administration": "ad", 10317 "checks": "c", 10318 "contents": "co", 10319 "content_references": "cr", 10320 "deployments": "d", 10321 "environments": "e", 10322 "issues": "i", 10323 "metadata": "md", 10324 "members": "m", 10325 "organization_administration": "oa", 10326 "organization_hooks": "oh", 10327 "organization_plan": "op", 10328 "organization_pre_receive_hooks": "opr", 10329 "organization_projects": "op", 10330 "organization_secrets": "os", 10331 "organization_self_hosted_runners": "osh", 10332 "organization_user_blocking": "oub", 10333 "packages": "pkg", 10334 "pages": "pg", 10335 "pull_requests": "pr", 10336 "repository_hooks": "rh", 10337 "repository_projects": "rp", 10338 "repository_pre_receive_hooks": "rprh", 10339 "secrets": "s", 10340 "secret_scanning_alerts": "ssa", 10341 "security_events": "se", 10342 "single_file": "sf", 10343 "statuses": "s", 10344 "team_discussions": "td", 10345 "vulnerability_alerts": "va", 10346 "workflows": "w" 10347 }, 10348 "created_at": ` + referenceTimeStr + `, 10349 "updated_at": ` + referenceTimeStr + `, 10350 "has_multiple_single_files": false, 10351 "suspended_by": { 10352 "login": "l", 10353 "id": 1, 10354 "avatar_url": "a", 10355 "gravatar_id": "g", 10356 "name": "n", 10357 "company": "c", 10358 "blog": "b", 10359 "location": "l", 10360 "email": "e", 10361 "hireable": true, 10362 "bio": "b", 10363 "twitter_username": "t", 10364 "public_repos": 1, 10365 "followers": 1, 10366 "following": 1, 10367 "created_at": ` + referenceTimeStr + `, 10368 "suspended_at": ` + referenceTimeStr + `, 10369 "url": "u" 10370 }, 10371 "suspended_at": ` + referenceTimeStr + ` 10372 } 10373 }` 10374 10375 testJSONMarshal(t, u, want) 10376 } 10377 10378 func TestMembershipEvent_Marshal(t *testing.T) { 10379 t.Parallel() 10380 testJSONMarshal(t, &MembershipEvent{}, "{}") 10381 10382 u := &MembershipEvent{ 10383 Action: Ptr("a"), 10384 Scope: Ptr("s"), 10385 Member: &User{ 10386 Login: Ptr("l"), 10387 ID: Ptr(int64(1)), 10388 NodeID: Ptr("n"), 10389 URL: Ptr("u"), 10390 ReposURL: Ptr("r"), 10391 EventsURL: Ptr("e"), 10392 AvatarURL: Ptr("a"), 10393 }, 10394 Team: &Team{ 10395 ID: Ptr(int64(1)), 10396 NodeID: Ptr("n"), 10397 Name: Ptr("n"), 10398 Description: Ptr("d"), 10399 URL: Ptr("u"), 10400 Slug: Ptr("s"), 10401 Permission: Ptr("p"), 10402 Privacy: Ptr("p"), 10403 MembersCount: Ptr(1), 10404 ReposCount: Ptr(1), 10405 MembersURL: Ptr("m"), 10406 RepositoriesURL: Ptr("r"), 10407 Organization: &Organization{ 10408 Login: Ptr("l"), 10409 ID: Ptr(int64(1)), 10410 NodeID: Ptr("n"), 10411 AvatarURL: Ptr("a"), 10412 HTMLURL: Ptr("h"), 10413 Name: Ptr("n"), 10414 Company: Ptr("c"), 10415 Blog: Ptr("b"), 10416 Location: Ptr("l"), 10417 Email: Ptr("e"), 10418 }, 10419 Parent: &Team{ 10420 ID: Ptr(int64(1)), 10421 NodeID: Ptr("n"), 10422 Name: Ptr("n"), 10423 Description: Ptr("d"), 10424 URL: Ptr("u"), 10425 Slug: Ptr("s"), 10426 Permission: Ptr("p"), 10427 Privacy: Ptr("p"), 10428 MembersCount: Ptr(1), 10429 ReposCount: Ptr(1), 10430 }, 10431 LDAPDN: Ptr("l"), 10432 }, 10433 Org: &Organization{ 10434 BillingEmail: Ptr("be"), 10435 Blog: Ptr("b"), 10436 Company: Ptr("c"), 10437 Email: Ptr("e"), 10438 TwitterUsername: Ptr("tu"), 10439 Location: Ptr("loc"), 10440 Name: Ptr("n"), 10441 Description: Ptr("d"), 10442 IsVerified: Ptr(true), 10443 HasOrganizationProjects: Ptr(true), 10444 HasRepositoryProjects: Ptr(true), 10445 DefaultRepoPermission: Ptr("drp"), 10446 MembersCanCreateRepos: Ptr(true), 10447 MembersCanCreateInternalRepos: Ptr(true), 10448 MembersCanCreatePrivateRepos: Ptr(true), 10449 MembersCanCreatePublicRepos: Ptr(false), 10450 MembersAllowedRepositoryCreationType: Ptr("marct"), 10451 MembersCanCreatePages: Ptr(true), 10452 MembersCanCreatePublicPages: Ptr(false), 10453 MembersCanCreatePrivatePages: Ptr(true), 10454 }, 10455 Sender: &User{ 10456 Login: Ptr("l"), 10457 ID: Ptr(int64(1)), 10458 NodeID: Ptr("n"), 10459 URL: Ptr("u"), 10460 ReposURL: Ptr("r"), 10461 EventsURL: Ptr("e"), 10462 AvatarURL: Ptr("a"), 10463 }, 10464 Installation: &Installation{ 10465 ID: Ptr(int64(1)), 10466 NodeID: Ptr("nid"), 10467 AppID: Ptr(int64(1)), 10468 AppSlug: Ptr("as"), 10469 TargetID: Ptr(int64(1)), 10470 Account: &User{ 10471 Login: Ptr("l"), 10472 ID: Ptr(int64(1)), 10473 URL: Ptr("u"), 10474 AvatarURL: Ptr("a"), 10475 GravatarID: Ptr("g"), 10476 Name: Ptr("n"), 10477 Company: Ptr("c"), 10478 Blog: Ptr("b"), 10479 Location: Ptr("l"), 10480 Email: Ptr("e"), 10481 Hireable: Ptr(true), 10482 Bio: Ptr("b"), 10483 TwitterUsername: Ptr("t"), 10484 PublicRepos: Ptr(1), 10485 Followers: Ptr(1), 10486 Following: Ptr(1), 10487 CreatedAt: &Timestamp{referenceTime}, 10488 SuspendedAt: &Timestamp{referenceTime}, 10489 }, 10490 AccessTokensURL: Ptr("atu"), 10491 RepositoriesURL: Ptr("ru"), 10492 HTMLURL: Ptr("hu"), 10493 TargetType: Ptr("tt"), 10494 SingleFileName: Ptr("sfn"), 10495 RepositorySelection: Ptr("rs"), 10496 Events: []string{"e"}, 10497 SingleFilePaths: []string{"s"}, 10498 Permissions: &InstallationPermissions{ 10499 Actions: Ptr("a"), 10500 Administration: Ptr("ad"), 10501 Checks: Ptr("c"), 10502 Contents: Ptr("co"), 10503 ContentReferences: Ptr("cr"), 10504 Deployments: Ptr("d"), 10505 Environments: Ptr("e"), 10506 Issues: Ptr("i"), 10507 Metadata: Ptr("md"), 10508 Members: Ptr("m"), 10509 OrganizationAdministration: Ptr("oa"), 10510 OrganizationHooks: Ptr("oh"), 10511 OrganizationPlan: Ptr("op"), 10512 OrganizationPreReceiveHooks: Ptr("opr"), 10513 OrganizationProjects: Ptr("op"), 10514 OrganizationSecrets: Ptr("os"), 10515 OrganizationSelfHostedRunners: Ptr("osh"), 10516 OrganizationUserBlocking: Ptr("oub"), 10517 Packages: Ptr("pkg"), 10518 Pages: Ptr("pg"), 10519 PullRequests: Ptr("pr"), 10520 RepositoryHooks: Ptr("rh"), 10521 RepositoryProjects: Ptr("rp"), 10522 RepositoryPreReceiveHooks: Ptr("rprh"), 10523 Secrets: Ptr("s"), 10524 SecretScanningAlerts: Ptr("ssa"), 10525 SecurityEvents: Ptr("se"), 10526 SingleFile: Ptr("sf"), 10527 Statuses: Ptr("s"), 10528 TeamDiscussions: Ptr("td"), 10529 VulnerabilityAlerts: Ptr("va"), 10530 Workflows: Ptr("w"), 10531 }, 10532 CreatedAt: &Timestamp{referenceTime}, 10533 UpdatedAt: &Timestamp{referenceTime}, 10534 HasMultipleSingleFiles: Ptr(false), 10535 SuspendedBy: &User{ 10536 Login: Ptr("l"), 10537 ID: Ptr(int64(1)), 10538 URL: Ptr("u"), 10539 AvatarURL: Ptr("a"), 10540 GravatarID: Ptr("g"), 10541 Name: Ptr("n"), 10542 Company: Ptr("c"), 10543 Blog: Ptr("b"), 10544 Location: Ptr("l"), 10545 Email: Ptr("e"), 10546 Hireable: Ptr(true), 10547 Bio: Ptr("b"), 10548 TwitterUsername: Ptr("t"), 10549 PublicRepos: Ptr(1), 10550 Followers: Ptr(1), 10551 Following: Ptr(1), 10552 CreatedAt: &Timestamp{referenceTime}, 10553 SuspendedAt: &Timestamp{referenceTime}, 10554 }, 10555 SuspendedAt: &Timestamp{referenceTime}, 10556 }, 10557 } 10558 10559 want := `{ 10560 "action": "a", 10561 "scope": "s", 10562 "member": { 10563 "login": "l", 10564 "id": 1, 10565 "node_id": "n", 10566 "avatar_url": "a", 10567 "url": "u", 10568 "events_url": "e", 10569 "repos_url": "r" 10570 }, 10571 "team": { 10572 "id": 1, 10573 "node_id": "n", 10574 "name": "n", 10575 "description": "d", 10576 "url": "u", 10577 "slug": "s", 10578 "permission": "p", 10579 "privacy": "p", 10580 "members_count": 1, 10581 "repos_count": 1, 10582 "organization": { 10583 "login": "l", 10584 "id": 1, 10585 "node_id": "n", 10586 "avatar_url": "a", 10587 "html_url": "h", 10588 "name": "n", 10589 "company": "c", 10590 "blog": "b", 10591 "location": "l", 10592 "email": "e" 10593 }, 10594 "members_url": "m", 10595 "repositories_url": "r", 10596 "parent": { 10597 "id": 1, 10598 "node_id": "n", 10599 "name": "n", 10600 "description": "d", 10601 "url": "u", 10602 "slug": "s", 10603 "permission": "p", 10604 "privacy": "p", 10605 "members_count": 1, 10606 "repos_count": 1 10607 }, 10608 "ldap_dn": "l" 10609 }, 10610 "organization": { 10611 "name": "n", 10612 "company": "c", 10613 "blog": "b", 10614 "location": "loc", 10615 "email": "e", 10616 "twitter_username": "tu", 10617 "description": "d", 10618 "billing_email": "be", 10619 "is_verified": true, 10620 "has_organization_projects": true, 10621 "has_repository_projects": true, 10622 "default_repository_permission": "drp", 10623 "members_can_create_repositories": true, 10624 "members_can_create_public_repositories": false, 10625 "members_can_create_private_repositories": true, 10626 "members_can_create_internal_repositories": true, 10627 "members_allowed_repository_creation_type": "marct", 10628 "members_can_create_pages": true, 10629 "members_can_create_public_pages": false, 10630 "members_can_create_private_pages": true 10631 }, 10632 "sender": { 10633 "login": "l", 10634 "id": 1, 10635 "node_id": "n", 10636 "avatar_url": "a", 10637 "url": "u", 10638 "events_url": "e", 10639 "repos_url": "r" 10640 }, 10641 "installation": { 10642 "id": 1, 10643 "node_id": "nid", 10644 "app_id": 1, 10645 "app_slug": "as", 10646 "target_id": 1, 10647 "account": { 10648 "login": "l", 10649 "id": 1, 10650 "avatar_url": "a", 10651 "gravatar_id": "g", 10652 "name": "n", 10653 "company": "c", 10654 "blog": "b", 10655 "location": "l", 10656 "email": "e", 10657 "hireable": true, 10658 "bio": "b", 10659 "twitter_username": "t", 10660 "public_repos": 1, 10661 "followers": 1, 10662 "following": 1, 10663 "created_at": ` + referenceTimeStr + `, 10664 "suspended_at": ` + referenceTimeStr + `, 10665 "url": "u" 10666 }, 10667 "access_tokens_url": "atu", 10668 "repositories_url": "ru", 10669 "html_url": "hu", 10670 "target_type": "tt", 10671 "single_file_name": "sfn", 10672 "repository_selection": "rs", 10673 "events": [ 10674 "e" 10675 ], 10676 "single_file_paths": [ 10677 "s" 10678 ], 10679 "permissions": { 10680 "actions": "a", 10681 "administration": "ad", 10682 "checks": "c", 10683 "contents": "co", 10684 "content_references": "cr", 10685 "deployments": "d", 10686 "environments": "e", 10687 "issues": "i", 10688 "metadata": "md", 10689 "members": "m", 10690 "organization_administration": "oa", 10691 "organization_hooks": "oh", 10692 "organization_plan": "op", 10693 "organization_pre_receive_hooks": "opr", 10694 "organization_projects": "op", 10695 "organization_secrets": "os", 10696 "organization_self_hosted_runners": "osh", 10697 "organization_user_blocking": "oub", 10698 "packages": "pkg", 10699 "pages": "pg", 10700 "pull_requests": "pr", 10701 "repository_hooks": "rh", 10702 "repository_projects": "rp", 10703 "repository_pre_receive_hooks": "rprh", 10704 "secrets": "s", 10705 "secret_scanning_alerts": "ssa", 10706 "security_events": "se", 10707 "single_file": "sf", 10708 "statuses": "s", 10709 "team_discussions": "td", 10710 "vulnerability_alerts": "va", 10711 "workflows": "w" 10712 }, 10713 "created_at": ` + referenceTimeStr + `, 10714 "updated_at": ` + referenceTimeStr + `, 10715 "has_multiple_single_files": false, 10716 "suspended_by": { 10717 "login": "l", 10718 "id": 1, 10719 "avatar_url": "a", 10720 "gravatar_id": "g", 10721 "name": "n", 10722 "company": "c", 10723 "blog": "b", 10724 "location": "l", 10725 "email": "e", 10726 "hireable": true, 10727 "bio": "b", 10728 "twitter_username": "t", 10729 "public_repos": 1, 10730 "followers": 1, 10731 "following": 1, 10732 "created_at": ` + referenceTimeStr + `, 10733 "suspended_at": ` + referenceTimeStr + `, 10734 "url": "u" 10735 }, 10736 "suspended_at": ` + referenceTimeStr + ` 10737 } 10738 }` 10739 10740 testJSONMarshal(t, u, want) 10741 } 10742 10743 func TestMergeGroupEvent_Marshal(t *testing.T) { 10744 t.Parallel() 10745 testJSONMarshal(t, &MergeGroupEvent{}, "{}") 10746 10747 u := &MergeGroupEvent{ 10748 Action: Ptr("a"), 10749 MergeGroup: &MergeGroup{ 10750 HeadSHA: Ptr("hs"), 10751 HeadRef: Ptr("hr"), 10752 BaseSHA: Ptr("bs"), 10753 BaseRef: Ptr("br"), 10754 HeadCommit: &Commit{NodeID: Ptr("nid")}, 10755 }, 10756 Repo: &Repository{ 10757 ID: Ptr(int64(1)), 10758 URL: Ptr("s"), 10759 Name: Ptr("n"), 10760 }, 10761 Org: &Organization{ 10762 BillingEmail: Ptr("be"), 10763 Blog: Ptr("b"), 10764 Company: Ptr("c"), 10765 Email: Ptr("e"), 10766 TwitterUsername: Ptr("tu"), 10767 Location: Ptr("loc"), 10768 Name: Ptr("n"), 10769 Description: Ptr("d"), 10770 IsVerified: Ptr(true), 10771 HasOrganizationProjects: Ptr(true), 10772 HasRepositoryProjects: Ptr(true), 10773 DefaultRepoPermission: Ptr("drp"), 10774 MembersCanCreateRepos: Ptr(true), 10775 MembersCanCreateInternalRepos: Ptr(true), 10776 MembersCanCreatePrivateRepos: Ptr(true), 10777 MembersCanCreatePublicRepos: Ptr(false), 10778 MembersAllowedRepositoryCreationType: Ptr("marct"), 10779 MembersCanCreatePages: Ptr(true), 10780 MembersCanCreatePublicPages: Ptr(false), 10781 MembersCanCreatePrivatePages: Ptr(true), 10782 }, 10783 Sender: &User{ 10784 Login: Ptr("l"), 10785 ID: Ptr(int64(1)), 10786 NodeID: Ptr("n"), 10787 URL: Ptr("u"), 10788 ReposURL: Ptr("r"), 10789 EventsURL: Ptr("e"), 10790 AvatarURL: Ptr("a"), 10791 }, 10792 Installation: &Installation{ 10793 ID: Ptr(int64(1)), 10794 NodeID: Ptr("nid"), 10795 AppID: Ptr(int64(1)), 10796 AppSlug: Ptr("as"), 10797 TargetID: Ptr(int64(1)), 10798 Account: &User{ 10799 Login: Ptr("l"), 10800 ID: Ptr(int64(1)), 10801 URL: Ptr("u"), 10802 AvatarURL: Ptr("a"), 10803 GravatarID: Ptr("g"), 10804 Name: Ptr("n"), 10805 Company: Ptr("c"), 10806 Blog: Ptr("b"), 10807 Location: Ptr("l"), 10808 Email: Ptr("e"), 10809 Hireable: Ptr(true), 10810 Bio: Ptr("b"), 10811 TwitterUsername: Ptr("t"), 10812 PublicRepos: Ptr(1), 10813 Followers: Ptr(1), 10814 Following: Ptr(1), 10815 CreatedAt: &Timestamp{referenceTime}, 10816 SuspendedAt: &Timestamp{referenceTime}, 10817 }, 10818 AccessTokensURL: Ptr("atu"), 10819 RepositoriesURL: Ptr("ru"), 10820 HTMLURL: Ptr("hu"), 10821 TargetType: Ptr("tt"), 10822 SingleFileName: Ptr("sfn"), 10823 RepositorySelection: Ptr("rs"), 10824 Events: []string{"e"}, 10825 SingleFilePaths: []string{"s"}, 10826 Permissions: &InstallationPermissions{ 10827 Actions: Ptr("a"), 10828 Administration: Ptr("ad"), 10829 Checks: Ptr("c"), 10830 Contents: Ptr("co"), 10831 ContentReferences: Ptr("cr"), 10832 Deployments: Ptr("d"), 10833 Environments: Ptr("e"), 10834 Issues: Ptr("i"), 10835 Metadata: Ptr("md"), 10836 Members: Ptr("m"), 10837 OrganizationAdministration: Ptr("oa"), 10838 OrganizationHooks: Ptr("oh"), 10839 OrganizationPlan: Ptr("op"), 10840 OrganizationPreReceiveHooks: Ptr("opr"), 10841 OrganizationProjects: Ptr("op"), 10842 OrganizationSecrets: Ptr("os"), 10843 OrganizationSelfHostedRunners: Ptr("osh"), 10844 OrganizationUserBlocking: Ptr("oub"), 10845 Packages: Ptr("pkg"), 10846 Pages: Ptr("pg"), 10847 PullRequests: Ptr("pr"), 10848 RepositoryHooks: Ptr("rh"), 10849 RepositoryProjects: Ptr("rp"), 10850 RepositoryPreReceiveHooks: Ptr("rprh"), 10851 Secrets: Ptr("s"), 10852 SecretScanningAlerts: Ptr("ssa"), 10853 SecurityEvents: Ptr("se"), 10854 SingleFile: Ptr("sf"), 10855 Statuses: Ptr("s"), 10856 TeamDiscussions: Ptr("td"), 10857 VulnerabilityAlerts: Ptr("va"), 10858 Workflows: Ptr("w"), 10859 }, 10860 CreatedAt: &Timestamp{referenceTime}, 10861 UpdatedAt: &Timestamp{referenceTime}, 10862 HasMultipleSingleFiles: Ptr(false), 10863 SuspendedBy: &User{ 10864 Login: Ptr("l"), 10865 ID: Ptr(int64(1)), 10866 URL: Ptr("u"), 10867 AvatarURL: Ptr("a"), 10868 GravatarID: Ptr("g"), 10869 Name: Ptr("n"), 10870 Company: Ptr("c"), 10871 Blog: Ptr("b"), 10872 Location: Ptr("l"), 10873 Email: Ptr("e"), 10874 Hireable: Ptr(true), 10875 Bio: Ptr("b"), 10876 TwitterUsername: Ptr("t"), 10877 PublicRepos: Ptr(1), 10878 Followers: Ptr(1), 10879 Following: Ptr(1), 10880 CreatedAt: &Timestamp{referenceTime}, 10881 SuspendedAt: &Timestamp{referenceTime}, 10882 }, 10883 SuspendedAt: &Timestamp{referenceTime}, 10884 }, 10885 } 10886 10887 want := `{ 10888 "action": "a", 10889 "merge_group": { 10890 "head_sha": "hs", 10891 "head_ref": "hr", 10892 "base_sha": "bs", 10893 "base_ref": "br", 10894 "head_commit": { 10895 "node_id": "nid" 10896 } 10897 }, 10898 "repository": { 10899 "id": 1, 10900 "name": "n", 10901 "url": "s" 10902 }, 10903 "organization": { 10904 "name": "n", 10905 "company": "c", 10906 "blog": "b", 10907 "location": "loc", 10908 "email": "e", 10909 "twitter_username": "tu", 10910 "description": "d", 10911 "billing_email": "be", 10912 "is_verified": true, 10913 "has_organization_projects": true, 10914 "has_repository_projects": true, 10915 "default_repository_permission": "drp", 10916 "members_can_create_repositories": true, 10917 "members_can_create_public_repositories": false, 10918 "members_can_create_private_repositories": true, 10919 "members_can_create_internal_repositories": true, 10920 "members_allowed_repository_creation_type": "marct", 10921 "members_can_create_pages": true, 10922 "members_can_create_public_pages": false, 10923 "members_can_create_private_pages": true 10924 }, 10925 "sender": { 10926 "login": "l", 10927 "id": 1, 10928 "node_id": "n", 10929 "avatar_url": "a", 10930 "url": "u", 10931 "events_url": "e", 10932 "repos_url": "r" 10933 }, 10934 "installation": { 10935 "id": 1, 10936 "node_id": "nid", 10937 "app_id": 1, 10938 "app_slug": "as", 10939 "target_id": 1, 10940 "account": { 10941 "login": "l", 10942 "id": 1, 10943 "avatar_url": "a", 10944 "gravatar_id": "g", 10945 "name": "n", 10946 "company": "c", 10947 "blog": "b", 10948 "location": "l", 10949 "email": "e", 10950 "hireable": true, 10951 "bio": "b", 10952 "twitter_username": "t", 10953 "public_repos": 1, 10954 "followers": 1, 10955 "following": 1, 10956 "created_at": ` + referenceTimeStr + `, 10957 "suspended_at": ` + referenceTimeStr + `, 10958 "url": "u" 10959 }, 10960 "access_tokens_url": "atu", 10961 "repositories_url": "ru", 10962 "html_url": "hu", 10963 "target_type": "tt", 10964 "single_file_name": "sfn", 10965 "repository_selection": "rs", 10966 "events": [ 10967 "e" 10968 ], 10969 "single_file_paths": [ 10970 "s" 10971 ], 10972 "permissions": { 10973 "actions": "a", 10974 "administration": "ad", 10975 "checks": "c", 10976 "contents": "co", 10977 "content_references": "cr", 10978 "deployments": "d", 10979 "environments": "e", 10980 "issues": "i", 10981 "metadata": "md", 10982 "members": "m", 10983 "organization_administration": "oa", 10984 "organization_hooks": "oh", 10985 "organization_plan": "op", 10986 "organization_pre_receive_hooks": "opr", 10987 "organization_projects": "op", 10988 "organization_secrets": "os", 10989 "organization_self_hosted_runners": "osh", 10990 "organization_user_blocking": "oub", 10991 "packages": "pkg", 10992 "pages": "pg", 10993 "pull_requests": "pr", 10994 "repository_hooks": "rh", 10995 "repository_projects": "rp", 10996 "repository_pre_receive_hooks": "rprh", 10997 "secrets": "s", 10998 "secret_scanning_alerts": "ssa", 10999 "security_events": "se", 11000 "single_file": "sf", 11001 "statuses": "s", 11002 "team_discussions": "td", 11003 "vulnerability_alerts": "va", 11004 "workflows": "w" 11005 }, 11006 "created_at": ` + referenceTimeStr + `, 11007 "updated_at": ` + referenceTimeStr + `, 11008 "has_multiple_single_files": false, 11009 "suspended_by": { 11010 "login": "l", 11011 "id": 1, 11012 "avatar_url": "a", 11013 "gravatar_id": "g", 11014 "name": "n", 11015 "company": "c", 11016 "blog": "b", 11017 "location": "l", 11018 "email": "e", 11019 "hireable": true, 11020 "bio": "b", 11021 "twitter_username": "t", 11022 "public_repos": 1, 11023 "followers": 1, 11024 "following": 1, 11025 "created_at": ` + referenceTimeStr + `, 11026 "suspended_at": ` + referenceTimeStr + `, 11027 "url": "u" 11028 }, 11029 "suspended_at": ` + referenceTimeStr + ` 11030 } 11031 }` 11032 11033 testJSONMarshal(t, u, want) 11034 } 11035 11036 func TestOrgBlockEvent_Marshal(t *testing.T) { 11037 t.Parallel() 11038 testJSONMarshal(t, &OrgBlockEvent{}, "{}") 11039 11040 u := &OrgBlockEvent{ 11041 Action: Ptr("a"), 11042 BlockedUser: &User{ 11043 Login: Ptr("l"), 11044 ID: Ptr(int64(1)), 11045 NodeID: Ptr("n"), 11046 URL: Ptr("u"), 11047 ReposURL: Ptr("r"), 11048 EventsURL: Ptr("e"), 11049 AvatarURL: Ptr("a"), 11050 }, 11051 Organization: &Organization{ 11052 BillingEmail: Ptr("be"), 11053 Blog: Ptr("b"), 11054 Company: Ptr("c"), 11055 Email: Ptr("e"), 11056 TwitterUsername: Ptr("tu"), 11057 Location: Ptr("loc"), 11058 Name: Ptr("n"), 11059 Description: Ptr("d"), 11060 IsVerified: Ptr(true), 11061 HasOrganizationProjects: Ptr(true), 11062 HasRepositoryProjects: Ptr(true), 11063 DefaultRepoPermission: Ptr("drp"), 11064 MembersCanCreateRepos: Ptr(true), 11065 MembersCanCreateInternalRepos: Ptr(true), 11066 MembersCanCreatePrivateRepos: Ptr(true), 11067 MembersCanCreatePublicRepos: Ptr(false), 11068 MembersAllowedRepositoryCreationType: Ptr("marct"), 11069 MembersCanCreatePages: Ptr(true), 11070 MembersCanCreatePublicPages: Ptr(false), 11071 MembersCanCreatePrivatePages: Ptr(true), 11072 }, 11073 Sender: &User{ 11074 Login: Ptr("l"), 11075 ID: Ptr(int64(1)), 11076 NodeID: Ptr("n"), 11077 URL: Ptr("u"), 11078 ReposURL: Ptr("r"), 11079 EventsURL: Ptr("e"), 11080 AvatarURL: Ptr("a"), 11081 }, 11082 Installation: &Installation{ 11083 ID: Ptr(int64(1)), 11084 NodeID: Ptr("nid"), 11085 AppID: Ptr(int64(1)), 11086 AppSlug: Ptr("as"), 11087 TargetID: Ptr(int64(1)), 11088 Account: &User{ 11089 Login: Ptr("l"), 11090 ID: Ptr(int64(1)), 11091 URL: Ptr("u"), 11092 AvatarURL: Ptr("a"), 11093 GravatarID: Ptr("g"), 11094 Name: Ptr("n"), 11095 Company: Ptr("c"), 11096 Blog: Ptr("b"), 11097 Location: Ptr("l"), 11098 Email: Ptr("e"), 11099 Hireable: Ptr(true), 11100 Bio: Ptr("b"), 11101 TwitterUsername: Ptr("t"), 11102 PublicRepos: Ptr(1), 11103 Followers: Ptr(1), 11104 Following: Ptr(1), 11105 CreatedAt: &Timestamp{referenceTime}, 11106 SuspendedAt: &Timestamp{referenceTime}, 11107 }, 11108 AccessTokensURL: Ptr("atu"), 11109 RepositoriesURL: Ptr("ru"), 11110 HTMLURL: Ptr("hu"), 11111 TargetType: Ptr("tt"), 11112 SingleFileName: Ptr("sfn"), 11113 RepositorySelection: Ptr("rs"), 11114 Events: []string{"e"}, 11115 SingleFilePaths: []string{"s"}, 11116 Permissions: &InstallationPermissions{ 11117 Actions: Ptr("a"), 11118 Administration: Ptr("ad"), 11119 Checks: Ptr("c"), 11120 Contents: Ptr("co"), 11121 ContentReferences: Ptr("cr"), 11122 Deployments: Ptr("d"), 11123 Environments: Ptr("e"), 11124 Issues: Ptr("i"), 11125 Metadata: Ptr("md"), 11126 Members: Ptr("m"), 11127 OrganizationAdministration: Ptr("oa"), 11128 OrganizationHooks: Ptr("oh"), 11129 OrganizationPlan: Ptr("op"), 11130 OrganizationPreReceiveHooks: Ptr("opr"), 11131 OrganizationProjects: Ptr("op"), 11132 OrganizationSecrets: Ptr("os"), 11133 OrganizationSelfHostedRunners: Ptr("osh"), 11134 OrganizationUserBlocking: Ptr("oub"), 11135 Packages: Ptr("pkg"), 11136 Pages: Ptr("pg"), 11137 PullRequests: Ptr("pr"), 11138 RepositoryHooks: Ptr("rh"), 11139 RepositoryProjects: Ptr("rp"), 11140 RepositoryPreReceiveHooks: Ptr("rprh"), 11141 Secrets: Ptr("s"), 11142 SecretScanningAlerts: Ptr("ssa"), 11143 SecurityEvents: Ptr("se"), 11144 SingleFile: Ptr("sf"), 11145 Statuses: Ptr("s"), 11146 TeamDiscussions: Ptr("td"), 11147 VulnerabilityAlerts: Ptr("va"), 11148 Workflows: Ptr("w"), 11149 }, 11150 CreatedAt: &Timestamp{referenceTime}, 11151 UpdatedAt: &Timestamp{referenceTime}, 11152 HasMultipleSingleFiles: Ptr(false), 11153 SuspendedBy: &User{ 11154 Login: Ptr("l"), 11155 ID: Ptr(int64(1)), 11156 URL: Ptr("u"), 11157 AvatarURL: Ptr("a"), 11158 GravatarID: Ptr("g"), 11159 Name: Ptr("n"), 11160 Company: Ptr("c"), 11161 Blog: Ptr("b"), 11162 Location: Ptr("l"), 11163 Email: Ptr("e"), 11164 Hireable: Ptr(true), 11165 Bio: Ptr("b"), 11166 TwitterUsername: Ptr("t"), 11167 PublicRepos: Ptr(1), 11168 Followers: Ptr(1), 11169 Following: Ptr(1), 11170 CreatedAt: &Timestamp{referenceTime}, 11171 SuspendedAt: &Timestamp{referenceTime}, 11172 }, 11173 SuspendedAt: &Timestamp{referenceTime}, 11174 }, 11175 } 11176 11177 want := `{ 11178 "action": "a", 11179 "blocked_user": { 11180 "login": "l", 11181 "id": 1, 11182 "node_id": "n", 11183 "avatar_url": "a", 11184 "url": "u", 11185 "events_url": "e", 11186 "repos_url": "r" 11187 }, 11188 "organization": { 11189 "name": "n", 11190 "company": "c", 11191 "blog": "b", 11192 "location": "loc", 11193 "email": "e", 11194 "twitter_username": "tu", 11195 "description": "d", 11196 "billing_email": "be", 11197 "is_verified": true, 11198 "has_organization_projects": true, 11199 "has_repository_projects": true, 11200 "default_repository_permission": "drp", 11201 "members_can_create_repositories": true, 11202 "members_can_create_public_repositories": false, 11203 "members_can_create_private_repositories": true, 11204 "members_can_create_internal_repositories": true, 11205 "members_allowed_repository_creation_type": "marct", 11206 "members_can_create_pages": true, 11207 "members_can_create_public_pages": false, 11208 "members_can_create_private_pages": true 11209 }, 11210 "sender": { 11211 "login": "l", 11212 "id": 1, 11213 "node_id": "n", 11214 "avatar_url": "a", 11215 "url": "u", 11216 "events_url": "e", 11217 "repos_url": "r" 11218 }, 11219 "installation": { 11220 "id": 1, 11221 "node_id": "nid", 11222 "app_id": 1, 11223 "app_slug": "as", 11224 "target_id": 1, 11225 "account": { 11226 "login": "l", 11227 "id": 1, 11228 "avatar_url": "a", 11229 "gravatar_id": "g", 11230 "name": "n", 11231 "company": "c", 11232 "blog": "b", 11233 "location": "l", 11234 "email": "e", 11235 "hireable": true, 11236 "bio": "b", 11237 "twitter_username": "t", 11238 "public_repos": 1, 11239 "followers": 1, 11240 "following": 1, 11241 "created_at": ` + referenceTimeStr + `, 11242 "suspended_at": ` + referenceTimeStr + `, 11243 "url": "u" 11244 }, 11245 "access_tokens_url": "atu", 11246 "repositories_url": "ru", 11247 "html_url": "hu", 11248 "target_type": "tt", 11249 "single_file_name": "sfn", 11250 "repository_selection": "rs", 11251 "events": [ 11252 "e" 11253 ], 11254 "single_file_paths": [ 11255 "s" 11256 ], 11257 "permissions": { 11258 "actions": "a", 11259 "administration": "ad", 11260 "checks": "c", 11261 "contents": "co", 11262 "content_references": "cr", 11263 "deployments": "d", 11264 "environments": "e", 11265 "issues": "i", 11266 "metadata": "md", 11267 "members": "m", 11268 "organization_administration": "oa", 11269 "organization_hooks": "oh", 11270 "organization_plan": "op", 11271 "organization_pre_receive_hooks": "opr", 11272 "organization_projects": "op", 11273 "organization_secrets": "os", 11274 "organization_self_hosted_runners": "osh", 11275 "organization_user_blocking": "oub", 11276 "packages": "pkg", 11277 "pages": "pg", 11278 "pull_requests": "pr", 11279 "repository_hooks": "rh", 11280 "repository_projects": "rp", 11281 "repository_pre_receive_hooks": "rprh", 11282 "secrets": "s", 11283 "secret_scanning_alerts": "ssa", 11284 "security_events": "se", 11285 "single_file": "sf", 11286 "statuses": "s", 11287 "team_discussions": "td", 11288 "vulnerability_alerts": "va", 11289 "workflows": "w" 11290 }, 11291 "created_at": ` + referenceTimeStr + `, 11292 "updated_at": ` + referenceTimeStr + `, 11293 "has_multiple_single_files": false, 11294 "suspended_by": { 11295 "login": "l", 11296 "id": 1, 11297 "avatar_url": "a", 11298 "gravatar_id": "g", 11299 "name": "n", 11300 "company": "c", 11301 "blog": "b", 11302 "location": "l", 11303 "email": "e", 11304 "hireable": true, 11305 "bio": "b", 11306 "twitter_username": "t", 11307 "public_repos": 1, 11308 "followers": 1, 11309 "following": 1, 11310 "created_at": ` + referenceTimeStr + `, 11311 "suspended_at": ` + referenceTimeStr + `, 11312 "url": "u" 11313 }, 11314 "suspended_at": ` + referenceTimeStr + ` 11315 } 11316 }` 11317 11318 testJSONMarshal(t, u, want) 11319 } 11320 11321 func TestGollumEvent_Marshal(t *testing.T) { 11322 t.Parallel() 11323 testJSONMarshal(t, &GollumEvent{}, "{}") 11324 11325 u := &GollumEvent{ 11326 Pages: []*Page{ 11327 { 11328 PageName: Ptr("pn"), 11329 Title: Ptr("t"), 11330 Summary: Ptr("s"), 11331 Action: Ptr("a"), 11332 SHA: Ptr("sha"), 11333 HTMLURL: Ptr("hu"), 11334 }, 11335 }, 11336 Repo: &Repository{ 11337 ID: Ptr(int64(1)), 11338 URL: Ptr("s"), 11339 Name: Ptr("n"), 11340 }, 11341 Sender: &User{ 11342 Login: Ptr("l"), 11343 ID: Ptr(int64(1)), 11344 NodeID: Ptr("n"), 11345 URL: Ptr("u"), 11346 ReposURL: Ptr("r"), 11347 EventsURL: Ptr("e"), 11348 AvatarURL: Ptr("a"), 11349 }, 11350 Installation: &Installation{ 11351 ID: Ptr(int64(1)), 11352 NodeID: Ptr("nid"), 11353 AppID: Ptr(int64(1)), 11354 AppSlug: Ptr("as"), 11355 TargetID: Ptr(int64(1)), 11356 Account: &User{ 11357 Login: Ptr("l"), 11358 ID: Ptr(int64(1)), 11359 URL: Ptr("u"), 11360 AvatarURL: Ptr("a"), 11361 GravatarID: Ptr("g"), 11362 Name: Ptr("n"), 11363 Company: Ptr("c"), 11364 Blog: Ptr("b"), 11365 Location: Ptr("l"), 11366 Email: Ptr("e"), 11367 Hireable: Ptr(true), 11368 Bio: Ptr("b"), 11369 TwitterUsername: Ptr("t"), 11370 PublicRepos: Ptr(1), 11371 Followers: Ptr(1), 11372 Following: Ptr(1), 11373 CreatedAt: &Timestamp{referenceTime}, 11374 SuspendedAt: &Timestamp{referenceTime}, 11375 }, 11376 AccessTokensURL: Ptr("atu"), 11377 RepositoriesURL: Ptr("ru"), 11378 HTMLURL: Ptr("hu"), 11379 TargetType: Ptr("tt"), 11380 SingleFileName: Ptr("sfn"), 11381 RepositorySelection: Ptr("rs"), 11382 Events: []string{"e"}, 11383 SingleFilePaths: []string{"s"}, 11384 Permissions: &InstallationPermissions{ 11385 Actions: Ptr("a"), 11386 Administration: Ptr("ad"), 11387 Checks: Ptr("c"), 11388 Contents: Ptr("co"), 11389 ContentReferences: Ptr("cr"), 11390 Deployments: Ptr("d"), 11391 Environments: Ptr("e"), 11392 Issues: Ptr("i"), 11393 Metadata: Ptr("md"), 11394 Members: Ptr("m"), 11395 OrganizationAdministration: Ptr("oa"), 11396 OrganizationHooks: Ptr("oh"), 11397 OrganizationPlan: Ptr("op"), 11398 OrganizationPreReceiveHooks: Ptr("opr"), 11399 OrganizationProjects: Ptr("op"), 11400 OrganizationSecrets: Ptr("os"), 11401 OrganizationSelfHostedRunners: Ptr("osh"), 11402 OrganizationUserBlocking: Ptr("oub"), 11403 Packages: Ptr("pkg"), 11404 Pages: Ptr("pg"), 11405 PullRequests: Ptr("pr"), 11406 RepositoryHooks: Ptr("rh"), 11407 RepositoryProjects: Ptr("rp"), 11408 RepositoryPreReceiveHooks: Ptr("rprh"), 11409 Secrets: Ptr("s"), 11410 SecretScanningAlerts: Ptr("ssa"), 11411 SecurityEvents: Ptr("se"), 11412 SingleFile: Ptr("sf"), 11413 Statuses: Ptr("s"), 11414 TeamDiscussions: Ptr("td"), 11415 VulnerabilityAlerts: Ptr("va"), 11416 Workflows: Ptr("w"), 11417 }, 11418 CreatedAt: &Timestamp{referenceTime}, 11419 UpdatedAt: &Timestamp{referenceTime}, 11420 HasMultipleSingleFiles: Ptr(false), 11421 SuspendedBy: &User{ 11422 Login: Ptr("l"), 11423 ID: Ptr(int64(1)), 11424 URL: Ptr("u"), 11425 AvatarURL: Ptr("a"), 11426 GravatarID: Ptr("g"), 11427 Name: Ptr("n"), 11428 Company: Ptr("c"), 11429 Blog: Ptr("b"), 11430 Location: Ptr("l"), 11431 Email: Ptr("e"), 11432 Hireable: Ptr(true), 11433 Bio: Ptr("b"), 11434 TwitterUsername: Ptr("t"), 11435 PublicRepos: Ptr(1), 11436 Followers: Ptr(1), 11437 Following: Ptr(1), 11438 CreatedAt: &Timestamp{referenceTime}, 11439 SuspendedAt: &Timestamp{referenceTime}, 11440 }, 11441 SuspendedAt: &Timestamp{referenceTime}, 11442 }, 11443 } 11444 11445 want := `{ 11446 "pages": [ 11447 { 11448 "page_name": "pn", 11449 "title": "t", 11450 "summary": "s", 11451 "action": "a", 11452 "sha": "sha", 11453 "html_url": "hu" 11454 } 11455 ], 11456 "repository": { 11457 "id": 1, 11458 "name": "n", 11459 "url": "s" 11460 }, 11461 "sender": { 11462 "login": "l", 11463 "id": 1, 11464 "node_id": "n", 11465 "avatar_url": "a", 11466 "url": "u", 11467 "events_url": "e", 11468 "repos_url": "r" 11469 }, 11470 "installation": { 11471 "id": 1, 11472 "node_id": "nid", 11473 "app_id": 1, 11474 "app_slug": "as", 11475 "target_id": 1, 11476 "account": { 11477 "login": "l", 11478 "id": 1, 11479 "avatar_url": "a", 11480 "gravatar_id": "g", 11481 "name": "n", 11482 "company": "c", 11483 "blog": "b", 11484 "location": "l", 11485 "email": "e", 11486 "hireable": true, 11487 "bio": "b", 11488 "twitter_username": "t", 11489 "public_repos": 1, 11490 "followers": 1, 11491 "following": 1, 11492 "created_at": ` + referenceTimeStr + `, 11493 "suspended_at": ` + referenceTimeStr + `, 11494 "url": "u" 11495 }, 11496 "access_tokens_url": "atu", 11497 "repositories_url": "ru", 11498 "html_url": "hu", 11499 "target_type": "tt", 11500 "single_file_name": "sfn", 11501 "repository_selection": "rs", 11502 "events": [ 11503 "e" 11504 ], 11505 "single_file_paths": [ 11506 "s" 11507 ], 11508 "permissions": { 11509 "actions": "a", 11510 "administration": "ad", 11511 "checks": "c", 11512 "contents": "co", 11513 "content_references": "cr", 11514 "deployments": "d", 11515 "environments": "e", 11516 "issues": "i", 11517 "metadata": "md", 11518 "members": "m", 11519 "organization_administration": "oa", 11520 "organization_hooks": "oh", 11521 "organization_plan": "op", 11522 "organization_pre_receive_hooks": "opr", 11523 "organization_projects": "op", 11524 "organization_secrets": "os", 11525 "organization_self_hosted_runners": "osh", 11526 "organization_user_blocking": "oub", 11527 "packages": "pkg", 11528 "pages": "pg", 11529 "pull_requests": "pr", 11530 "repository_hooks": "rh", 11531 "repository_projects": "rp", 11532 "repository_pre_receive_hooks": "rprh", 11533 "secrets": "s", 11534 "secret_scanning_alerts": "ssa", 11535 "security_events": "se", 11536 "single_file": "sf", 11537 "statuses": "s", 11538 "team_discussions": "td", 11539 "vulnerability_alerts": "va", 11540 "workflows": "w" 11541 }, 11542 "created_at": ` + referenceTimeStr + `, 11543 "updated_at": ` + referenceTimeStr + `, 11544 "has_multiple_single_files": false, 11545 "suspended_by": { 11546 "login": "l", 11547 "id": 1, 11548 "avatar_url": "a", 11549 "gravatar_id": "g", 11550 "name": "n", 11551 "company": "c", 11552 "blog": "b", 11553 "location": "l", 11554 "email": "e", 11555 "hireable": true, 11556 "bio": "b", 11557 "twitter_username": "t", 11558 "public_repos": 1, 11559 "followers": 1, 11560 "following": 1, 11561 "created_at": ` + referenceTimeStr + `, 11562 "suspended_at": ` + referenceTimeStr + `, 11563 "url": "u" 11564 }, 11565 "suspended_at": ` + referenceTimeStr + ` 11566 } 11567 }` 11568 11569 testJSONMarshal(t, u, want) 11570 } 11571 11572 func TestWorkflowRunEvent_Marshal(t *testing.T) { 11573 t.Parallel() 11574 testJSONMarshal(t, &WorkflowRunEvent{}, "{}") 11575 11576 u := &WorkflowRunEvent{ 11577 Action: Ptr("a"), 11578 Workflow: &Workflow{ 11579 ID: Ptr(int64(1)), 11580 NodeID: Ptr("nid"), 11581 Name: Ptr("n"), 11582 Path: Ptr("p"), 11583 State: Ptr("s"), 11584 CreatedAt: &Timestamp{referenceTime}, 11585 UpdatedAt: &Timestamp{referenceTime}, 11586 URL: Ptr("u"), 11587 HTMLURL: Ptr("h"), 11588 BadgeURL: Ptr("b"), 11589 }, 11590 WorkflowRun: &WorkflowRun{ 11591 ID: Ptr(int64(1)), 11592 Name: Ptr("n"), 11593 NodeID: Ptr("nid"), 11594 HeadBranch: Ptr("hb"), 11595 HeadSHA: Ptr("hs"), 11596 RunNumber: Ptr(1), 11597 RunAttempt: Ptr(1), 11598 Event: Ptr("e"), 11599 Status: Ptr("s"), 11600 Conclusion: Ptr("c"), 11601 WorkflowID: Ptr(int64(1)), 11602 URL: Ptr("u"), 11603 HTMLURL: Ptr("h"), 11604 PullRequests: []*PullRequest{ 11605 { 11606 URL: Ptr("u"), 11607 ID: Ptr(int64(1)), 11608 Number: Ptr(1), 11609 Head: &PullRequestBranch{ 11610 Ref: Ptr("r"), 11611 SHA: Ptr("s"), 11612 Repo: &Repository{ 11613 ID: Ptr(int64(1)), 11614 URL: Ptr("s"), 11615 Name: Ptr("n"), 11616 }, 11617 }, 11618 Base: &PullRequestBranch{ 11619 Ref: Ptr("r"), 11620 SHA: Ptr("s"), 11621 Repo: &Repository{ 11622 ID: Ptr(int64(1)), 11623 URL: Ptr("u"), 11624 Name: Ptr("n"), 11625 }, 11626 }, 11627 }, 11628 }, 11629 CreatedAt: &Timestamp{referenceTime}, 11630 UpdatedAt: &Timestamp{referenceTime}, 11631 RunStartedAt: &Timestamp{referenceTime}, 11632 JobsURL: Ptr("j"), 11633 LogsURL: Ptr("l"), 11634 CheckSuiteURL: Ptr("c"), 11635 ArtifactsURL: Ptr("a"), 11636 CancelURL: Ptr("c"), 11637 RerunURL: Ptr("r"), 11638 PreviousAttemptURL: Ptr("p"), 11639 HeadCommit: &HeadCommit{ 11640 Message: Ptr("m"), 11641 Author: &CommitAuthor{ 11642 Name: Ptr("n"), 11643 Email: Ptr("e"), 11644 Login: Ptr("l"), 11645 }, 11646 URL: Ptr("u"), 11647 Distinct: Ptr(false), 11648 SHA: Ptr("s"), 11649 ID: Ptr("i"), 11650 TreeID: Ptr("tid"), 11651 Timestamp: &Timestamp{referenceTime}, 11652 Committer: &CommitAuthor{ 11653 Name: Ptr("n"), 11654 Email: Ptr("e"), 11655 Login: Ptr("l"), 11656 }, 11657 }, 11658 WorkflowURL: Ptr("w"), 11659 Repository: &Repository{ 11660 ID: Ptr(int64(1)), 11661 URL: Ptr("u"), 11662 Name: Ptr("n"), 11663 }, 11664 HeadRepository: &Repository{ 11665 ID: Ptr(int64(1)), 11666 URL: Ptr("u"), 11667 Name: Ptr("n"), 11668 }, 11669 }, 11670 Org: &Organization{ 11671 BillingEmail: Ptr("be"), 11672 Blog: Ptr("b"), 11673 Company: Ptr("c"), 11674 Email: Ptr("e"), 11675 TwitterUsername: Ptr("tu"), 11676 Location: Ptr("loc"), 11677 Name: Ptr("n"), 11678 Description: Ptr("d"), 11679 IsVerified: Ptr(true), 11680 HasOrganizationProjects: Ptr(true), 11681 HasRepositoryProjects: Ptr(true), 11682 DefaultRepoPermission: Ptr("drp"), 11683 MembersCanCreateRepos: Ptr(true), 11684 MembersCanCreateInternalRepos: Ptr(true), 11685 MembersCanCreatePrivateRepos: Ptr(true), 11686 MembersCanCreatePublicRepos: Ptr(false), 11687 MembersAllowedRepositoryCreationType: Ptr("marct"), 11688 MembersCanCreatePages: Ptr(true), 11689 MembersCanCreatePublicPages: Ptr(false), 11690 MembersCanCreatePrivatePages: Ptr(true), 11691 }, 11692 Repo: &Repository{ 11693 ID: Ptr(int64(1)), 11694 URL: Ptr("s"), 11695 Name: Ptr("n"), 11696 }, 11697 Sender: &User{ 11698 Login: Ptr("l"), 11699 ID: Ptr(int64(1)), 11700 NodeID: Ptr("n"), 11701 URL: Ptr("u"), 11702 ReposURL: Ptr("r"), 11703 EventsURL: Ptr("e"), 11704 AvatarURL: Ptr("a"), 11705 }, 11706 } 11707 11708 want := `{ 11709 "action": "a", 11710 "workflow": { 11711 "id": 1, 11712 "node_id": "nid", 11713 "name": "n", 11714 "path": "p", 11715 "state": "s", 11716 "created_at": ` + referenceTimeStr + `, 11717 "updated_at": ` + referenceTimeStr + `, 11718 "url": "u", 11719 "html_url": "h", 11720 "badge_url": "b" 11721 }, 11722 "workflow_run": { 11723 "id": 1, 11724 "name": "n", 11725 "node_id": "nid", 11726 "head_branch": "hb", 11727 "head_sha": "hs", 11728 "run_number": 1, 11729 "run_attempt": 1, 11730 "event": "e", 11731 "status": "s", 11732 "conclusion": "c", 11733 "workflow_id": 1, 11734 "url": "u", 11735 "html_url": "h", 11736 "pull_requests": [ 11737 { 11738 "id": 1, 11739 "number": 1, 11740 "url": "u", 11741 "head": { 11742 "ref": "r", 11743 "sha": "s", 11744 "repo": { 11745 "id": 1, 11746 "name": "n", 11747 "url": "s" 11748 } 11749 }, 11750 "base": { 11751 "ref": "r", 11752 "sha": "s", 11753 "repo": { 11754 "id": 1, 11755 "name": "n", 11756 "url": "u" 11757 } 11758 } 11759 } 11760 ], 11761 "created_at": ` + referenceTimeStr + `, 11762 "updated_at": ` + referenceTimeStr + `, 11763 "run_started_at": ` + referenceTimeStr + `, 11764 "jobs_url": "j", 11765 "logs_url": "l", 11766 "check_suite_url": "c", 11767 "artifacts_url": "a", 11768 "cancel_url": "c", 11769 "rerun_url": "r", 11770 "previous_attempt_url": "p", 11771 "head_commit": { 11772 "message": "m", 11773 "author": { 11774 "name": "n", 11775 "email": "e", 11776 "username": "l" 11777 }, 11778 "url": "u", 11779 "distinct": false, 11780 "sha": "s", 11781 "id": "i", 11782 "tree_id": "tid", 11783 "timestamp": ` + referenceTimeStr + `, 11784 "committer": { 11785 "name": "n", 11786 "email": "e", 11787 "username": "l" 11788 } 11789 }, 11790 "workflow_url": "w", 11791 "repository": { 11792 "id": 1, 11793 "name": "n", 11794 "url": "u" 11795 }, 11796 "head_repository": { 11797 "id": 1, 11798 "name": "n", 11799 "url": "u" 11800 } 11801 }, 11802 "organization": { 11803 "name": "n", 11804 "company": "c", 11805 "blog": "b", 11806 "location": "loc", 11807 "email": "e", 11808 "twitter_username": "tu", 11809 "description": "d", 11810 "billing_email": "be", 11811 "is_verified": true, 11812 "has_organization_projects": true, 11813 "has_repository_projects": true, 11814 "default_repository_permission": "drp", 11815 "members_can_create_repositories": true, 11816 "members_can_create_public_repositories": false, 11817 "members_can_create_private_repositories": true, 11818 "members_can_create_internal_repositories": true, 11819 "members_allowed_repository_creation_type": "marct", 11820 "members_can_create_pages": true, 11821 "members_can_create_public_pages": false, 11822 "members_can_create_private_pages": true 11823 }, 11824 "repository": { 11825 "id": 1, 11826 "name": "n", 11827 "url": "s" 11828 }, 11829 "sender": { 11830 "login": "l", 11831 "id": 1, 11832 "node_id": "n", 11833 "avatar_url": "a", 11834 "url": "u", 11835 "events_url": "e", 11836 "repos_url": "r" 11837 } 11838 }` 11839 11840 testJSONMarshal(t, u, want) 11841 } 11842 11843 func TestWorkflowDispatchEvent_Marshal(t *testing.T) { 11844 t.Parallel() 11845 testJSONMarshal(t, &WorkflowDispatchEvent{}, "{}") 11846 11847 i := make(map[string]interface{}) 11848 i["key"] = "value" 11849 11850 jsonMsg, _ := json.Marshal(i) 11851 u := &WorkflowDispatchEvent{ 11852 Inputs: jsonMsg, 11853 Ref: Ptr("r"), 11854 Workflow: Ptr("w"), 11855 Repo: &Repository{ 11856 ID: Ptr(int64(1)), 11857 URL: Ptr("s"), 11858 Name: Ptr("n"), 11859 }, 11860 Org: &Organization{ 11861 BillingEmail: Ptr("be"), 11862 Blog: Ptr("b"), 11863 Company: Ptr("c"), 11864 Email: Ptr("e"), 11865 TwitterUsername: Ptr("tu"), 11866 Location: Ptr("loc"), 11867 Name: Ptr("n"), 11868 Description: Ptr("d"), 11869 IsVerified: Ptr(true), 11870 HasOrganizationProjects: Ptr(true), 11871 HasRepositoryProjects: Ptr(true), 11872 DefaultRepoPermission: Ptr("drp"), 11873 MembersCanCreateRepos: Ptr(true), 11874 MembersCanCreateInternalRepos: Ptr(true), 11875 MembersCanCreatePrivateRepos: Ptr(true), 11876 MembersCanCreatePublicRepos: Ptr(false), 11877 MembersAllowedRepositoryCreationType: Ptr("marct"), 11878 MembersCanCreatePages: Ptr(true), 11879 MembersCanCreatePublicPages: Ptr(false), 11880 MembersCanCreatePrivatePages: Ptr(true), 11881 }, 11882 Sender: &User{ 11883 Login: Ptr("l"), 11884 ID: Ptr(int64(1)), 11885 NodeID: Ptr("n"), 11886 URL: Ptr("u"), 11887 ReposURL: Ptr("r"), 11888 EventsURL: Ptr("e"), 11889 AvatarURL: Ptr("a"), 11890 }, 11891 } 11892 11893 want := `{ 11894 "inputs": { 11895 "key": "value" 11896 }, 11897 "ref": "r", 11898 "workflow": "w", 11899 "repository": { 11900 "id": 1, 11901 "name": "n", 11902 "url": "s" 11903 }, 11904 "organization": { 11905 "name": "n", 11906 "company": "c", 11907 "blog": "b", 11908 "location": "loc", 11909 "email": "e", 11910 "twitter_username": "tu", 11911 "description": "d", 11912 "billing_email": "be", 11913 "is_verified": true, 11914 "has_organization_projects": true, 11915 "has_repository_projects": true, 11916 "default_repository_permission": "drp", 11917 "members_can_create_repositories": true, 11918 "members_can_create_public_repositories": false, 11919 "members_can_create_private_repositories": true, 11920 "members_can_create_internal_repositories": true, 11921 "members_allowed_repository_creation_type": "marct", 11922 "members_can_create_pages": true, 11923 "members_can_create_public_pages": false, 11924 "members_can_create_private_pages": true 11925 }, 11926 "sender": { 11927 "login": "l", 11928 "id": 1, 11929 "node_id": "n", 11930 "avatar_url": "a", 11931 "url": "u", 11932 "events_url": "e", 11933 "repos_url": "r" 11934 } 11935 }` 11936 11937 testJSONMarshal(t, u, want) 11938 } 11939 11940 func TestWatchEvent_Marshal(t *testing.T) { 11941 t.Parallel() 11942 testJSONMarshal(t, &WatchEvent{}, "{}") 11943 11944 u := &WatchEvent{ 11945 Action: Ptr("a"), 11946 Repo: &Repository{ 11947 ID: Ptr(int64(1)), 11948 URL: Ptr("s"), 11949 Name: Ptr("n"), 11950 }, 11951 Sender: &User{ 11952 Login: Ptr("l"), 11953 ID: Ptr(int64(1)), 11954 NodeID: Ptr("n"), 11955 URL: Ptr("u"), 11956 ReposURL: Ptr("r"), 11957 EventsURL: Ptr("e"), 11958 AvatarURL: Ptr("a"), 11959 }, 11960 Installation: &Installation{ 11961 ID: Ptr(int64(1)), 11962 NodeID: Ptr("nid"), 11963 AppID: Ptr(int64(1)), 11964 AppSlug: Ptr("as"), 11965 TargetID: Ptr(int64(1)), 11966 Account: &User{ 11967 Login: Ptr("l"), 11968 ID: Ptr(int64(1)), 11969 URL: Ptr("u"), 11970 AvatarURL: Ptr("a"), 11971 GravatarID: Ptr("g"), 11972 Name: Ptr("n"), 11973 Company: Ptr("c"), 11974 Blog: Ptr("b"), 11975 Location: Ptr("l"), 11976 Email: Ptr("e"), 11977 Hireable: Ptr(true), 11978 Bio: Ptr("b"), 11979 TwitterUsername: Ptr("t"), 11980 PublicRepos: Ptr(1), 11981 Followers: Ptr(1), 11982 Following: Ptr(1), 11983 CreatedAt: &Timestamp{referenceTime}, 11984 SuspendedAt: &Timestamp{referenceTime}, 11985 }, 11986 AccessTokensURL: Ptr("atu"), 11987 RepositoriesURL: Ptr("ru"), 11988 HTMLURL: Ptr("hu"), 11989 TargetType: Ptr("tt"), 11990 SingleFileName: Ptr("sfn"), 11991 RepositorySelection: Ptr("rs"), 11992 Events: []string{"e"}, 11993 SingleFilePaths: []string{"s"}, 11994 Permissions: &InstallationPermissions{ 11995 Actions: Ptr("a"), 11996 Administration: Ptr("ad"), 11997 Checks: Ptr("c"), 11998 Contents: Ptr("co"), 11999 ContentReferences: Ptr("cr"), 12000 Deployments: Ptr("d"), 12001 Environments: Ptr("e"), 12002 Issues: Ptr("i"), 12003 Metadata: Ptr("md"), 12004 Members: Ptr("m"), 12005 OrganizationAdministration: Ptr("oa"), 12006 OrganizationHooks: Ptr("oh"), 12007 OrganizationPlan: Ptr("op"), 12008 OrganizationPreReceiveHooks: Ptr("opr"), 12009 OrganizationProjects: Ptr("op"), 12010 OrganizationSecrets: Ptr("os"), 12011 OrganizationSelfHostedRunners: Ptr("osh"), 12012 OrganizationUserBlocking: Ptr("oub"), 12013 Packages: Ptr("pkg"), 12014 Pages: Ptr("pg"), 12015 PullRequests: Ptr("pr"), 12016 RepositoryHooks: Ptr("rh"), 12017 RepositoryProjects: Ptr("rp"), 12018 RepositoryPreReceiveHooks: Ptr("rprh"), 12019 Secrets: Ptr("s"), 12020 SecretScanningAlerts: Ptr("ssa"), 12021 SecurityEvents: Ptr("se"), 12022 SingleFile: Ptr("sf"), 12023 Statuses: Ptr("s"), 12024 TeamDiscussions: Ptr("td"), 12025 VulnerabilityAlerts: Ptr("va"), 12026 Workflows: Ptr("w"), 12027 }, 12028 CreatedAt: &Timestamp{referenceTime}, 12029 UpdatedAt: &Timestamp{referenceTime}, 12030 HasMultipleSingleFiles: Ptr(false), 12031 SuspendedBy: &User{ 12032 Login: Ptr("l"), 12033 ID: Ptr(int64(1)), 12034 URL: Ptr("u"), 12035 AvatarURL: Ptr("a"), 12036 GravatarID: Ptr("g"), 12037 Name: Ptr("n"), 12038 Company: Ptr("c"), 12039 Blog: Ptr("b"), 12040 Location: Ptr("l"), 12041 Email: Ptr("e"), 12042 Hireable: Ptr(true), 12043 Bio: Ptr("b"), 12044 TwitterUsername: Ptr("t"), 12045 PublicRepos: Ptr(1), 12046 Followers: Ptr(1), 12047 Following: Ptr(1), 12048 CreatedAt: &Timestamp{referenceTime}, 12049 SuspendedAt: &Timestamp{referenceTime}, 12050 }, 12051 SuspendedAt: &Timestamp{referenceTime}, 12052 }, 12053 } 12054 12055 want := `{ 12056 "action": "a", 12057 "repository": { 12058 "id": 1, 12059 "name": "n", 12060 "url": "s" 12061 }, 12062 "sender": { 12063 "login": "l", 12064 "id": 1, 12065 "node_id": "n", 12066 "avatar_url": "a", 12067 "url": "u", 12068 "events_url": "e", 12069 "repos_url": "r" 12070 }, 12071 "installation": { 12072 "id": 1, 12073 "node_id": "nid", 12074 "app_id": 1, 12075 "app_slug": "as", 12076 "target_id": 1, 12077 "account": { 12078 "login": "l", 12079 "id": 1, 12080 "avatar_url": "a", 12081 "gravatar_id": "g", 12082 "name": "n", 12083 "company": "c", 12084 "blog": "b", 12085 "location": "l", 12086 "email": "e", 12087 "hireable": true, 12088 "bio": "b", 12089 "twitter_username": "t", 12090 "public_repos": 1, 12091 "followers": 1, 12092 "following": 1, 12093 "created_at": ` + referenceTimeStr + `, 12094 "suspended_at": ` + referenceTimeStr + `, 12095 "url": "u" 12096 }, 12097 "access_tokens_url": "atu", 12098 "repositories_url": "ru", 12099 "html_url": "hu", 12100 "target_type": "tt", 12101 "single_file_name": "sfn", 12102 "repository_selection": "rs", 12103 "events": [ 12104 "e" 12105 ], 12106 "single_file_paths": [ 12107 "s" 12108 ], 12109 "permissions": { 12110 "actions": "a", 12111 "administration": "ad", 12112 "checks": "c", 12113 "contents": "co", 12114 "content_references": "cr", 12115 "deployments": "d", 12116 "environments": "e", 12117 "issues": "i", 12118 "metadata": "md", 12119 "members": "m", 12120 "organization_administration": "oa", 12121 "organization_hooks": "oh", 12122 "organization_plan": "op", 12123 "organization_pre_receive_hooks": "opr", 12124 "organization_projects": "op", 12125 "organization_secrets": "os", 12126 "organization_self_hosted_runners": "osh", 12127 "organization_user_blocking": "oub", 12128 "packages": "pkg", 12129 "pages": "pg", 12130 "pull_requests": "pr", 12131 "repository_hooks": "rh", 12132 "repository_projects": "rp", 12133 "repository_pre_receive_hooks": "rprh", 12134 "secrets": "s", 12135 "secret_scanning_alerts": "ssa", 12136 "security_events": "se", 12137 "single_file": "sf", 12138 "statuses": "s", 12139 "team_discussions": "td", 12140 "vulnerability_alerts": "va", 12141 "workflows": "w" 12142 }, 12143 "created_at": ` + referenceTimeStr + `, 12144 "updated_at": ` + referenceTimeStr + `, 12145 "has_multiple_single_files": false, 12146 "suspended_by": { 12147 "login": "l", 12148 "id": 1, 12149 "avatar_url": "a", 12150 "gravatar_id": "g", 12151 "name": "n", 12152 "company": "c", 12153 "blog": "b", 12154 "location": "l", 12155 "email": "e", 12156 "hireable": true, 12157 "bio": "b", 12158 "twitter_username": "t", 12159 "public_repos": 1, 12160 "followers": 1, 12161 "following": 1, 12162 "created_at": ` + referenceTimeStr + `, 12163 "suspended_at": ` + referenceTimeStr + `, 12164 "url": "u" 12165 }, 12166 "suspended_at": ` + referenceTimeStr + ` 12167 } 12168 }` 12169 12170 testJSONMarshal(t, u, want) 12171 } 12172 12173 func TestUserEvent_Marshal(t *testing.T) { 12174 t.Parallel() 12175 testJSONMarshal(t, &UserEvent{}, "{}") 12176 12177 u := &UserEvent{ 12178 User: &User{ 12179 Login: Ptr("l"), 12180 ID: Ptr(int64(1)), 12181 NodeID: Ptr("n"), 12182 URL: Ptr("u"), 12183 ReposURL: Ptr("r"), 12184 EventsURL: Ptr("e"), 12185 AvatarURL: Ptr("a"), 12186 }, 12187 // The action performed. Possible values are: "created" or "deleted". 12188 Action: Ptr("a"), 12189 Enterprise: &Enterprise{ 12190 ID: Ptr(1), 12191 Slug: Ptr("s"), 12192 Name: Ptr("n"), 12193 NodeID: Ptr("nid"), 12194 AvatarURL: Ptr("au"), 12195 Description: Ptr("d"), 12196 WebsiteURL: Ptr("wu"), 12197 HTMLURL: Ptr("hu"), 12198 CreatedAt: &Timestamp{referenceTime}, 12199 UpdatedAt: &Timestamp{referenceTime}, 12200 }, 12201 Sender: &User{ 12202 Login: Ptr("l"), 12203 ID: Ptr(int64(1)), 12204 NodeID: Ptr("n"), 12205 URL: Ptr("u"), 12206 ReposURL: Ptr("r"), 12207 EventsURL: Ptr("e"), 12208 AvatarURL: Ptr("a"), 12209 }, 12210 } 12211 12212 want := `{ 12213 "user": { 12214 "login": "l", 12215 "id": 1, 12216 "node_id": "n", 12217 "avatar_url": "a", 12218 "url": "u", 12219 "events_url": "e", 12220 "repos_url": "r" 12221 }, 12222 "action": "a", 12223 "enterprise": { 12224 "id": 1, 12225 "slug": "s", 12226 "name": "n", 12227 "node_id": "nid", 12228 "avatar_url": "au", 12229 "description": "d", 12230 "website_url": "wu", 12231 "html_url": "hu", 12232 "created_at": ` + referenceTimeStr + `, 12233 "updated_at": ` + referenceTimeStr + ` 12234 }, 12235 "sender": { 12236 "login": "l", 12237 "id": 1, 12238 "node_id": "n", 12239 "avatar_url": "a", 12240 "url": "u", 12241 "events_url": "e", 12242 "repos_url": "r" 12243 } 12244 }` 12245 12246 testJSONMarshal(t, u, want) 12247 } 12248 12249 func TestCheckRunEvent_Marshal(t *testing.T) { 12250 t.Parallel() 12251 testJSONMarshal(t, &CheckRunEvent{}, "{}") 12252 12253 r := &CheckRunEvent{ 12254 CheckRun: &CheckRun{ 12255 ID: Ptr(int64(1)), 12256 NodeID: Ptr("n"), 12257 HeadSHA: Ptr("h"), 12258 ExternalID: Ptr("1"), 12259 URL: Ptr("u"), 12260 HTMLURL: Ptr("u"), 12261 DetailsURL: Ptr("u"), 12262 Status: Ptr("s"), 12263 Conclusion: Ptr("c"), 12264 StartedAt: &Timestamp{referenceTime}, 12265 CompletedAt: &Timestamp{referenceTime}, 12266 Output: &CheckRunOutput{ 12267 Annotations: []*CheckRunAnnotation{ 12268 { 12269 AnnotationLevel: Ptr("a"), 12270 EndLine: Ptr(1), 12271 Message: Ptr("m"), 12272 Path: Ptr("p"), 12273 RawDetails: Ptr("r"), 12274 StartLine: Ptr(1), 12275 Title: Ptr("t"), 12276 }, 12277 }, 12278 AnnotationsCount: Ptr(1), 12279 AnnotationsURL: Ptr("a"), 12280 Images: []*CheckRunImage{ 12281 { 12282 Alt: Ptr("a"), 12283 ImageURL: Ptr("i"), 12284 Caption: Ptr("c"), 12285 }, 12286 }, 12287 Title: Ptr("t"), 12288 Summary: Ptr("s"), 12289 Text: Ptr("t"), 12290 }, 12291 Name: Ptr("n"), 12292 CheckSuite: &CheckSuite{ 12293 ID: Ptr(int64(1)), 12294 }, 12295 App: &App{ 12296 ID: Ptr(int64(1)), 12297 NodeID: Ptr("n"), 12298 Owner: &User{ 12299 Login: Ptr("l"), 12300 ID: Ptr(int64(1)), 12301 NodeID: Ptr("n"), 12302 URL: Ptr("u"), 12303 ReposURL: Ptr("r"), 12304 EventsURL: Ptr("e"), 12305 AvatarURL: Ptr("a"), 12306 }, 12307 Name: Ptr("n"), 12308 Description: Ptr("d"), 12309 HTMLURL: Ptr("h"), 12310 ExternalURL: Ptr("u"), 12311 CreatedAt: &Timestamp{referenceTime}, 12312 UpdatedAt: &Timestamp{referenceTime}, 12313 }, 12314 PullRequests: []*PullRequest{ 12315 { 12316 URL: Ptr("u"), 12317 ID: Ptr(int64(1)), 12318 Number: Ptr(1), 12319 Head: &PullRequestBranch{ 12320 Ref: Ptr("r"), 12321 SHA: Ptr("s"), 12322 Repo: &Repository{ 12323 ID: Ptr(int64(1)), 12324 URL: Ptr("s"), 12325 Name: Ptr("n"), 12326 }, 12327 }, 12328 Base: &PullRequestBranch{ 12329 Ref: Ptr("r"), 12330 SHA: Ptr("s"), 12331 Repo: &Repository{ 12332 ID: Ptr(int64(1)), 12333 URL: Ptr("u"), 12334 Name: Ptr("n"), 12335 }, 12336 }, 12337 }, 12338 }, 12339 }, 12340 Action: Ptr("a"), 12341 Repo: &Repository{ 12342 ID: Ptr(int64(1)), 12343 URL: Ptr("s"), 12344 Name: Ptr("n"), 12345 }, 12346 Org: &Organization{ 12347 BillingEmail: Ptr("be"), 12348 Blog: Ptr("b"), 12349 Company: Ptr("c"), 12350 Email: Ptr("e"), 12351 TwitterUsername: Ptr("tu"), 12352 Location: Ptr("loc"), 12353 Name: Ptr("n"), 12354 Description: Ptr("d"), 12355 IsVerified: Ptr(true), 12356 HasOrganizationProjects: Ptr(true), 12357 HasRepositoryProjects: Ptr(true), 12358 DefaultRepoPermission: Ptr("drp"), 12359 MembersCanCreateRepos: Ptr(true), 12360 MembersCanCreateInternalRepos: Ptr(true), 12361 MembersCanCreatePrivateRepos: Ptr(true), 12362 MembersCanCreatePublicRepos: Ptr(false), 12363 MembersAllowedRepositoryCreationType: Ptr("marct"), 12364 MembersCanCreatePages: Ptr(true), 12365 MembersCanCreatePublicPages: Ptr(false), 12366 MembersCanCreatePrivatePages: Ptr(true), 12367 }, 12368 Sender: &User{ 12369 Login: Ptr("l"), 12370 ID: Ptr(int64(1)), 12371 NodeID: Ptr("n"), 12372 URL: Ptr("u"), 12373 ReposURL: Ptr("r"), 12374 EventsURL: Ptr("e"), 12375 AvatarURL: Ptr("a"), 12376 }, 12377 Installation: &Installation{ 12378 ID: Ptr(int64(1)), 12379 NodeID: Ptr("nid"), 12380 AppID: Ptr(int64(1)), 12381 AppSlug: Ptr("as"), 12382 TargetID: Ptr(int64(1)), 12383 Account: &User{ 12384 Login: Ptr("l"), 12385 ID: Ptr(int64(1)), 12386 URL: Ptr("u"), 12387 AvatarURL: Ptr("a"), 12388 GravatarID: Ptr("g"), 12389 Name: Ptr("n"), 12390 Company: Ptr("c"), 12391 Blog: Ptr("b"), 12392 Location: Ptr("l"), 12393 Email: Ptr("e"), 12394 Hireable: Ptr(true), 12395 Bio: Ptr("b"), 12396 TwitterUsername: Ptr("t"), 12397 PublicRepos: Ptr(1), 12398 Followers: Ptr(1), 12399 Following: Ptr(1), 12400 CreatedAt: &Timestamp{referenceTime}, 12401 SuspendedAt: &Timestamp{referenceTime}, 12402 }, 12403 AccessTokensURL: Ptr("atu"), 12404 RepositoriesURL: Ptr("ru"), 12405 HTMLURL: Ptr("hu"), 12406 TargetType: Ptr("tt"), 12407 SingleFileName: Ptr("sfn"), 12408 RepositorySelection: Ptr("rs"), 12409 Events: []string{"e"}, 12410 SingleFilePaths: []string{"s"}, 12411 Permissions: &InstallationPermissions{ 12412 Actions: Ptr("a"), 12413 Administration: Ptr("ad"), 12414 Checks: Ptr("c"), 12415 Contents: Ptr("co"), 12416 ContentReferences: Ptr("cr"), 12417 Deployments: Ptr("d"), 12418 Environments: Ptr("e"), 12419 Issues: Ptr("i"), 12420 Metadata: Ptr("md"), 12421 Members: Ptr("m"), 12422 OrganizationAdministration: Ptr("oa"), 12423 OrganizationHooks: Ptr("oh"), 12424 OrganizationPlan: Ptr("op"), 12425 OrganizationPreReceiveHooks: Ptr("opr"), 12426 OrganizationProjects: Ptr("op"), 12427 OrganizationSecrets: Ptr("os"), 12428 OrganizationSelfHostedRunners: Ptr("osh"), 12429 OrganizationUserBlocking: Ptr("oub"), 12430 Packages: Ptr("pkg"), 12431 Pages: Ptr("pg"), 12432 PullRequests: Ptr("pr"), 12433 RepositoryHooks: Ptr("rh"), 12434 RepositoryProjects: Ptr("rp"), 12435 RepositoryPreReceiveHooks: Ptr("rprh"), 12436 Secrets: Ptr("s"), 12437 SecretScanningAlerts: Ptr("ssa"), 12438 SecurityEvents: Ptr("se"), 12439 SingleFile: Ptr("sf"), 12440 Statuses: Ptr("s"), 12441 TeamDiscussions: Ptr("td"), 12442 VulnerabilityAlerts: Ptr("va"), 12443 Workflows: Ptr("w"), 12444 }, 12445 CreatedAt: &Timestamp{referenceTime}, 12446 UpdatedAt: &Timestamp{referenceTime}, 12447 HasMultipleSingleFiles: Ptr(false), 12448 SuspendedBy: &User{ 12449 Login: Ptr("l"), 12450 ID: Ptr(int64(1)), 12451 URL: Ptr("u"), 12452 AvatarURL: Ptr("a"), 12453 GravatarID: Ptr("g"), 12454 Name: Ptr("n"), 12455 Company: Ptr("c"), 12456 Blog: Ptr("b"), 12457 Location: Ptr("l"), 12458 Email: Ptr("e"), 12459 Hireable: Ptr(true), 12460 Bio: Ptr("b"), 12461 TwitterUsername: Ptr("t"), 12462 PublicRepos: Ptr(1), 12463 Followers: Ptr(1), 12464 Following: Ptr(1), 12465 CreatedAt: &Timestamp{referenceTime}, 12466 SuspendedAt: &Timestamp{referenceTime}, 12467 }, 12468 SuspendedAt: &Timestamp{referenceTime}, 12469 }, 12470 RequestedAction: &RequestedAction{ 12471 Identifier: "i", 12472 }, 12473 } 12474 12475 want := `{ 12476 "check_run": { 12477 "id": 1, 12478 "node_id": "n", 12479 "head_sha": "h", 12480 "external_id": "1", 12481 "url": "u", 12482 "html_url": "u", 12483 "details_url": "u", 12484 "status": "s", 12485 "conclusion": "c", 12486 "started_at": ` + referenceTimeStr + `, 12487 "completed_at": ` + referenceTimeStr + `, 12488 "output": { 12489 "title": "t", 12490 "summary": "s", 12491 "text": "t", 12492 "annotations_count": 1, 12493 "annotations_url": "a", 12494 "annotations": [ 12495 { 12496 "path": "p", 12497 "start_line": 1, 12498 "end_line": 1, 12499 "annotation_level": "a", 12500 "message": "m", 12501 "title": "t", 12502 "raw_details": "r" 12503 } 12504 ], 12505 "images": [ 12506 { 12507 "alt": "a", 12508 "image_url": "i", 12509 "caption": "c" 12510 } 12511 ] 12512 }, 12513 "name": "n", 12514 "check_suite": { 12515 "id": 1 12516 }, 12517 "app": { 12518 "id": 1, 12519 "node_id": "n", 12520 "owner": { 12521 "login": "l", 12522 "id": 1, 12523 "node_id": "n", 12524 "avatar_url": "a", 12525 "url": "u", 12526 "events_url": "e", 12527 "repos_url": "r" 12528 }, 12529 "name": "n", 12530 "description": "d", 12531 "external_url": "u", 12532 "html_url": "h", 12533 "created_at": ` + referenceTimeStr + `, 12534 "updated_at": ` + referenceTimeStr + ` 12535 }, 12536 "pull_requests": [ 12537 { 12538 "id": 1, 12539 "number": 1, 12540 "url": "u", 12541 "head": { 12542 "ref": "r", 12543 "sha": "s", 12544 "repo": { 12545 "id": 1, 12546 "name": "n", 12547 "url": "s" 12548 } 12549 }, 12550 "base": { 12551 "ref": "r", 12552 "sha": "s", 12553 "repo": { 12554 "id": 1, 12555 "name": "n", 12556 "url": "u" 12557 } 12558 } 12559 } 12560 ] 12561 }, 12562 "action": "a", 12563 "repository": { 12564 "id": 1, 12565 "name": "n", 12566 "url": "s" 12567 }, 12568 "organization": { 12569 "name": "n", 12570 "company": "c", 12571 "blog": "b", 12572 "location": "loc", 12573 "email": "e", 12574 "twitter_username": "tu", 12575 "description": "d", 12576 "billing_email": "be", 12577 "is_verified": true, 12578 "has_organization_projects": true, 12579 "has_repository_projects": true, 12580 "default_repository_permission": "drp", 12581 "members_can_create_repositories": true, 12582 "members_can_create_public_repositories": false, 12583 "members_can_create_private_repositories": true, 12584 "members_can_create_internal_repositories": true, 12585 "members_allowed_repository_creation_type": "marct", 12586 "members_can_create_pages": true, 12587 "members_can_create_public_pages": false, 12588 "members_can_create_private_pages": true 12589 }, 12590 "sender": { 12591 "login": "l", 12592 "id": 1, 12593 "node_id": "n", 12594 "avatar_url": "a", 12595 "url": "u", 12596 "events_url": "e", 12597 "repos_url": "r" 12598 }, 12599 "installation": { 12600 "id": 1, 12601 "node_id": "nid", 12602 "app_id": 1, 12603 "app_slug": "as", 12604 "target_id": 1, 12605 "account": { 12606 "login": "l", 12607 "id": 1, 12608 "avatar_url": "a", 12609 "gravatar_id": "g", 12610 "name": "n", 12611 "company": "c", 12612 "blog": "b", 12613 "location": "l", 12614 "email": "e", 12615 "hireable": true, 12616 "bio": "b", 12617 "twitter_username": "t", 12618 "public_repos": 1, 12619 "followers": 1, 12620 "following": 1, 12621 "created_at": ` + referenceTimeStr + `, 12622 "suspended_at": ` + referenceTimeStr + `, 12623 "url": "u" 12624 }, 12625 "access_tokens_url": "atu", 12626 "repositories_url": "ru", 12627 "html_url": "hu", 12628 "target_type": "tt", 12629 "single_file_name": "sfn", 12630 "repository_selection": "rs", 12631 "events": [ 12632 "e" 12633 ], 12634 "single_file_paths": [ 12635 "s" 12636 ], 12637 "permissions": { 12638 "actions": "a", 12639 "administration": "ad", 12640 "checks": "c", 12641 "contents": "co", 12642 "content_references": "cr", 12643 "deployments": "d", 12644 "environments": "e", 12645 "issues": "i", 12646 "metadata": "md", 12647 "members": "m", 12648 "organization_administration": "oa", 12649 "organization_hooks": "oh", 12650 "organization_plan": "op", 12651 "organization_pre_receive_hooks": "opr", 12652 "organization_projects": "op", 12653 "organization_secrets": "os", 12654 "organization_self_hosted_runners": "osh", 12655 "organization_user_blocking": "oub", 12656 "packages": "pkg", 12657 "pages": "pg", 12658 "pull_requests": "pr", 12659 "repository_hooks": "rh", 12660 "repository_projects": "rp", 12661 "repository_pre_receive_hooks": "rprh", 12662 "secrets": "s", 12663 "secret_scanning_alerts": "ssa", 12664 "security_events": "se", 12665 "single_file": "sf", 12666 "statuses": "s", 12667 "team_discussions": "td", 12668 "vulnerability_alerts": "va", 12669 "workflows": "w" 12670 }, 12671 "created_at": ` + referenceTimeStr + `, 12672 "updated_at": ` + referenceTimeStr + `, 12673 "has_multiple_single_files": false, 12674 "suspended_by": { 12675 "login": "l", 12676 "id": 1, 12677 "avatar_url": "a", 12678 "gravatar_id": "g", 12679 "name": "n", 12680 "company": "c", 12681 "blog": "b", 12682 "location": "l", 12683 "email": "e", 12684 "hireable": true, 12685 "bio": "b", 12686 "twitter_username": "t", 12687 "public_repos": 1, 12688 "followers": 1, 12689 "following": 1, 12690 "created_at": ` + referenceTimeStr + `, 12691 "suspended_at": ` + referenceTimeStr + `, 12692 "url": "u" 12693 }, 12694 "suspended_at": ` + referenceTimeStr + ` 12695 }, 12696 "requested_action": { 12697 "identifier": "i" 12698 } 12699 }` 12700 12701 testJSONMarshal(t, r, want) 12702 } 12703 12704 func TestCheckSuiteEvent_Marshal(t *testing.T) { 12705 t.Parallel() 12706 testJSONMarshal(t, &CheckSuiteEvent{}, "{}") 12707 12708 r := &CheckSuiteEvent{ 12709 CheckSuite: &CheckSuite{ 12710 ID: Ptr(int64(1)), 12711 NodeID: Ptr("n"), 12712 HeadBranch: Ptr("h"), 12713 HeadSHA: Ptr("h"), 12714 URL: Ptr("u"), 12715 BeforeSHA: Ptr("b"), 12716 AfterSHA: Ptr("a"), 12717 Status: Ptr("s"), 12718 Conclusion: Ptr("c"), 12719 App: &App{ 12720 ID: Ptr(int64(1)), 12721 NodeID: Ptr("n"), 12722 Owner: &User{ 12723 Login: Ptr("l"), 12724 ID: Ptr(int64(1)), 12725 NodeID: Ptr("n"), 12726 URL: Ptr("u"), 12727 ReposURL: Ptr("r"), 12728 EventsURL: Ptr("e"), 12729 AvatarURL: Ptr("a"), 12730 }, 12731 Name: Ptr("n"), 12732 Description: Ptr("d"), 12733 HTMLURL: Ptr("h"), 12734 ExternalURL: Ptr("u"), 12735 CreatedAt: &Timestamp{referenceTime}, 12736 UpdatedAt: &Timestamp{referenceTime}, 12737 }, 12738 Repository: &Repository{ 12739 ID: Ptr(int64(1)), 12740 }, 12741 PullRequests: []*PullRequest{ 12742 { 12743 URL: Ptr("u"), 12744 ID: Ptr(int64(1)), 12745 Number: Ptr(1), 12746 Head: &PullRequestBranch{ 12747 Ref: Ptr("r"), 12748 SHA: Ptr("s"), 12749 Repo: &Repository{ 12750 ID: Ptr(int64(1)), 12751 URL: Ptr("s"), 12752 Name: Ptr("n"), 12753 }, 12754 }, 12755 Base: &PullRequestBranch{ 12756 Ref: Ptr("r"), 12757 SHA: Ptr("s"), 12758 Repo: &Repository{ 12759 ID: Ptr(int64(1)), 12760 URL: Ptr("u"), 12761 Name: Ptr("n"), 12762 }, 12763 }, 12764 }, 12765 }, 12766 HeadCommit: &Commit{ 12767 SHA: Ptr("s"), 12768 }, 12769 }, 12770 Action: Ptr("a"), 12771 Repo: &Repository{ 12772 ID: Ptr(int64(1)), 12773 URL: Ptr("s"), 12774 Name: Ptr("n"), 12775 }, 12776 Org: &Organization{ 12777 BillingEmail: Ptr("be"), 12778 Blog: Ptr("b"), 12779 Company: Ptr("c"), 12780 Email: Ptr("e"), 12781 TwitterUsername: Ptr("tu"), 12782 Location: Ptr("loc"), 12783 Name: Ptr("n"), 12784 Description: Ptr("d"), 12785 IsVerified: Ptr(true), 12786 HasOrganizationProjects: Ptr(true), 12787 HasRepositoryProjects: Ptr(true), 12788 DefaultRepoPermission: Ptr("drp"), 12789 MembersCanCreateRepos: Ptr(true), 12790 MembersCanCreateInternalRepos: Ptr(true), 12791 MembersCanCreatePrivateRepos: Ptr(true), 12792 MembersCanCreatePublicRepos: Ptr(false), 12793 MembersAllowedRepositoryCreationType: Ptr("marct"), 12794 MembersCanCreatePages: Ptr(true), 12795 MembersCanCreatePublicPages: Ptr(false), 12796 MembersCanCreatePrivatePages: Ptr(true), 12797 }, 12798 Sender: &User{ 12799 Login: Ptr("l"), 12800 ID: Ptr(int64(1)), 12801 NodeID: Ptr("n"), 12802 URL: Ptr("u"), 12803 ReposURL: Ptr("r"), 12804 EventsURL: Ptr("e"), 12805 AvatarURL: Ptr("a"), 12806 }, 12807 Installation: &Installation{ 12808 ID: Ptr(int64(1)), 12809 NodeID: Ptr("nid"), 12810 AppID: Ptr(int64(1)), 12811 AppSlug: Ptr("as"), 12812 TargetID: Ptr(int64(1)), 12813 Account: &User{ 12814 Login: Ptr("l"), 12815 ID: Ptr(int64(1)), 12816 URL: Ptr("u"), 12817 AvatarURL: Ptr("a"), 12818 GravatarID: Ptr("g"), 12819 Name: Ptr("n"), 12820 Company: Ptr("c"), 12821 Blog: Ptr("b"), 12822 Location: Ptr("l"), 12823 Email: Ptr("e"), 12824 Hireable: Ptr(true), 12825 Bio: Ptr("b"), 12826 TwitterUsername: Ptr("t"), 12827 PublicRepos: Ptr(1), 12828 Followers: Ptr(1), 12829 Following: Ptr(1), 12830 CreatedAt: &Timestamp{referenceTime}, 12831 SuspendedAt: &Timestamp{referenceTime}, 12832 }, 12833 AccessTokensURL: Ptr("atu"), 12834 RepositoriesURL: Ptr("ru"), 12835 HTMLURL: Ptr("hu"), 12836 TargetType: Ptr("tt"), 12837 SingleFileName: Ptr("sfn"), 12838 RepositorySelection: Ptr("rs"), 12839 Events: []string{"e"}, 12840 SingleFilePaths: []string{"s"}, 12841 Permissions: &InstallationPermissions{ 12842 Actions: Ptr("a"), 12843 Administration: Ptr("ad"), 12844 Checks: Ptr("c"), 12845 Contents: Ptr("co"), 12846 ContentReferences: Ptr("cr"), 12847 Deployments: Ptr("d"), 12848 Environments: Ptr("e"), 12849 Issues: Ptr("i"), 12850 Metadata: Ptr("md"), 12851 Members: Ptr("m"), 12852 OrganizationAdministration: Ptr("oa"), 12853 OrganizationHooks: Ptr("oh"), 12854 OrganizationPlan: Ptr("op"), 12855 OrganizationPreReceiveHooks: Ptr("opr"), 12856 OrganizationProjects: Ptr("op"), 12857 OrganizationSecrets: Ptr("os"), 12858 OrganizationSelfHostedRunners: Ptr("osh"), 12859 OrganizationUserBlocking: Ptr("oub"), 12860 Packages: Ptr("pkg"), 12861 Pages: Ptr("pg"), 12862 PullRequests: Ptr("pr"), 12863 RepositoryHooks: Ptr("rh"), 12864 RepositoryProjects: Ptr("rp"), 12865 RepositoryPreReceiveHooks: Ptr("rprh"), 12866 Secrets: Ptr("s"), 12867 SecretScanningAlerts: Ptr("ssa"), 12868 SecurityEvents: Ptr("se"), 12869 SingleFile: Ptr("sf"), 12870 Statuses: Ptr("s"), 12871 TeamDiscussions: Ptr("td"), 12872 VulnerabilityAlerts: Ptr("va"), 12873 Workflows: Ptr("w"), 12874 }, 12875 CreatedAt: &Timestamp{referenceTime}, 12876 UpdatedAt: &Timestamp{referenceTime}, 12877 HasMultipleSingleFiles: Ptr(false), 12878 SuspendedBy: &User{ 12879 Login: Ptr("l"), 12880 ID: Ptr(int64(1)), 12881 URL: Ptr("u"), 12882 AvatarURL: Ptr("a"), 12883 GravatarID: Ptr("g"), 12884 Name: Ptr("n"), 12885 Company: Ptr("c"), 12886 Blog: Ptr("b"), 12887 Location: Ptr("l"), 12888 Email: Ptr("e"), 12889 Hireable: Ptr(true), 12890 Bio: Ptr("b"), 12891 TwitterUsername: Ptr("t"), 12892 PublicRepos: Ptr(1), 12893 Followers: Ptr(1), 12894 Following: Ptr(1), 12895 CreatedAt: &Timestamp{referenceTime}, 12896 SuspendedAt: &Timestamp{referenceTime}, 12897 }, 12898 SuspendedAt: &Timestamp{referenceTime}, 12899 }, 12900 } 12901 12902 want := `{ 12903 "check_suite": { 12904 "id": 1, 12905 "node_id": "n", 12906 "head_branch": "h", 12907 "head_sha": "h", 12908 "url": "u", 12909 "before": "b", 12910 "after": "a", 12911 "status": "s", 12912 "conclusion": "c", 12913 "app": { 12914 "id": 1, 12915 "node_id": "n", 12916 "owner": { 12917 "login": "l", 12918 "id": 1, 12919 "node_id": "n", 12920 "avatar_url": "a", 12921 "url": "u", 12922 "events_url": "e", 12923 "repos_url": "r" 12924 }, 12925 "name": "n", 12926 "description": "d", 12927 "external_url": "u", 12928 "html_url": "h", 12929 "created_at": ` + referenceTimeStr + `, 12930 "updated_at": ` + referenceTimeStr + ` 12931 }, 12932 "repository": { 12933 "id": 1 12934 }, 12935 "pull_requests": [ 12936 { 12937 "id": 1, 12938 "number": 1, 12939 "url": "u", 12940 "head": { 12941 "ref": "r", 12942 "sha": "s", 12943 "repo": { 12944 "id": 1, 12945 "name": "n", 12946 "url": "s" 12947 } 12948 }, 12949 "base": { 12950 "ref": "r", 12951 "sha": "s", 12952 "repo": { 12953 "id": 1, 12954 "name": "n", 12955 "url": "u" 12956 } 12957 } 12958 } 12959 ], 12960 "head_commit": { 12961 "sha": "s" 12962 } 12963 }, 12964 "action": "a", 12965 "repository": { 12966 "id": 1, 12967 "name": "n", 12968 "url": "s" 12969 }, 12970 "organization": { 12971 "name": "n", 12972 "company": "c", 12973 "blog": "b", 12974 "location": "loc", 12975 "email": "e", 12976 "twitter_username": "tu", 12977 "description": "d", 12978 "billing_email": "be", 12979 "is_verified": true, 12980 "has_organization_projects": true, 12981 "has_repository_projects": true, 12982 "default_repository_permission": "drp", 12983 "members_can_create_repositories": true, 12984 "members_can_create_public_repositories": false, 12985 "members_can_create_private_repositories": true, 12986 "members_can_create_internal_repositories": true, 12987 "members_allowed_repository_creation_type": "marct", 12988 "members_can_create_pages": true, 12989 "members_can_create_public_pages": false, 12990 "members_can_create_private_pages": true 12991 }, 12992 "sender": { 12993 "login": "l", 12994 "id": 1, 12995 "node_id": "n", 12996 "avatar_url": "a", 12997 "url": "u", 12998 "events_url": "e", 12999 "repos_url": "r" 13000 }, 13001 "installation": { 13002 "id": 1, 13003 "node_id": "nid", 13004 "app_id": 1, 13005 "app_slug": "as", 13006 "target_id": 1, 13007 "account": { 13008 "login": "l", 13009 "id": 1, 13010 "avatar_url": "a", 13011 "gravatar_id": "g", 13012 "name": "n", 13013 "company": "c", 13014 "blog": "b", 13015 "location": "l", 13016 "email": "e", 13017 "hireable": true, 13018 "bio": "b", 13019 "twitter_username": "t", 13020 "public_repos": 1, 13021 "followers": 1, 13022 "following": 1, 13023 "created_at": ` + referenceTimeStr + `, 13024 "suspended_at": ` + referenceTimeStr + `, 13025 "url": "u" 13026 }, 13027 "access_tokens_url": "atu", 13028 "repositories_url": "ru", 13029 "html_url": "hu", 13030 "target_type": "tt", 13031 "single_file_name": "sfn", 13032 "repository_selection": "rs", 13033 "events": [ 13034 "e" 13035 ], 13036 "single_file_paths": [ 13037 "s" 13038 ], 13039 "permissions": { 13040 "actions": "a", 13041 "administration": "ad", 13042 "checks": "c", 13043 "contents": "co", 13044 "content_references": "cr", 13045 "deployments": "d", 13046 "environments": "e", 13047 "issues": "i", 13048 "metadata": "md", 13049 "members": "m", 13050 "organization_administration": "oa", 13051 "organization_hooks": "oh", 13052 "organization_plan": "op", 13053 "organization_pre_receive_hooks": "opr", 13054 "organization_projects": "op", 13055 "organization_secrets": "os", 13056 "organization_self_hosted_runners": "osh", 13057 "organization_user_blocking": "oub", 13058 "packages": "pkg", 13059 "pages": "pg", 13060 "pull_requests": "pr", 13061 "repository_hooks": "rh", 13062 "repository_projects": "rp", 13063 "repository_pre_receive_hooks": "rprh", 13064 "secrets": "s", 13065 "secret_scanning_alerts": "ssa", 13066 "security_events": "se", 13067 "single_file": "sf", 13068 "statuses": "s", 13069 "team_discussions": "td", 13070 "vulnerability_alerts": "va", 13071 "workflows": "w" 13072 }, 13073 "created_at": ` + referenceTimeStr + `, 13074 "updated_at": ` + referenceTimeStr + `, 13075 "has_multiple_single_files": false, 13076 "suspended_by": { 13077 "login": "l", 13078 "id": 1, 13079 "avatar_url": "a", 13080 "gravatar_id": "g", 13081 "name": "n", 13082 "company": "c", 13083 "blog": "b", 13084 "location": "l", 13085 "email": "e", 13086 "hireable": true, 13087 "bio": "b", 13088 "twitter_username": "t", 13089 "public_repos": 1, 13090 "followers": 1, 13091 "following": 1, 13092 "created_at": ` + referenceTimeStr + `, 13093 "suspended_at": ` + referenceTimeStr + `, 13094 "url": "u" 13095 }, 13096 "suspended_at": ` + referenceTimeStr + ` 13097 } 13098 }` 13099 13100 testJSONMarshal(t, r, want) 13101 } 13102 13103 func TestDeployKeyEvent_Marshal(t *testing.T) { 13104 t.Parallel() 13105 testJSONMarshal(t, &DeployKeyEvent{}, "{}") 13106 13107 u := &DeployKeyEvent{ 13108 Action: Ptr("a"), 13109 Key: &Key{ 13110 ID: Ptr(int64(1)), 13111 Key: Ptr("k"), 13112 URL: Ptr("k"), 13113 Title: Ptr("k"), 13114 ReadOnly: Ptr(false), 13115 Verified: Ptr(false), 13116 CreatedAt: &Timestamp{referenceTime}, 13117 }, 13118 Repo: &Repository{ 13119 ID: Ptr(int64(1)), 13120 URL: Ptr("s"), 13121 Name: Ptr("n"), 13122 }, 13123 Organization: &Organization{ 13124 BillingEmail: Ptr("be"), 13125 Blog: Ptr("b"), 13126 Company: Ptr("c"), 13127 Email: Ptr("e"), 13128 TwitterUsername: Ptr("tu"), 13129 Location: Ptr("loc"), 13130 Name: Ptr("n"), 13131 Description: Ptr("d"), 13132 IsVerified: Ptr(true), 13133 HasOrganizationProjects: Ptr(true), 13134 HasRepositoryProjects: Ptr(true), 13135 DefaultRepoPermission: Ptr("drp"), 13136 MembersCanCreateRepos: Ptr(true), 13137 MembersCanCreateInternalRepos: Ptr(true), 13138 MembersCanCreatePrivateRepos: Ptr(true), 13139 MembersCanCreatePublicRepos: Ptr(false), 13140 MembersAllowedRepositoryCreationType: Ptr("marct"), 13141 MembersCanCreatePages: Ptr(true), 13142 MembersCanCreatePublicPages: Ptr(false), 13143 MembersCanCreatePrivatePages: Ptr(true), 13144 }, 13145 Sender: &User{ 13146 Login: Ptr("l"), 13147 ID: Ptr(int64(1)), 13148 NodeID: Ptr("n"), 13149 AvatarURL: Ptr("a"), 13150 URL: Ptr("u"), 13151 EventsURL: Ptr("e"), 13152 ReposURL: Ptr("r"), 13153 }, 13154 } 13155 13156 want := `{ 13157 "action": "a", 13158 "key": { 13159 "id": 1, 13160 "key": "k", 13161 "url": "k", 13162 "title": "k", 13163 "read_only": false, 13164 "verified": false, 13165 "created_at": ` + referenceTimeStr + ` 13166 }, 13167 "repository": { 13168 "id": 1, 13169 "name": "n", 13170 "url": "s" 13171 }, 13172 "organization": { 13173 "name": "n", 13174 "company": "c", 13175 "blog": "b", 13176 "location": "loc", 13177 "email": "e", 13178 "twitter_username": "tu", 13179 "description": "d", 13180 "billing_email": "be", 13181 "is_verified": true, 13182 "has_organization_projects": true, 13183 "has_repository_projects": true, 13184 "default_repository_permission": "drp", 13185 "members_can_create_repositories": true, 13186 "members_can_create_public_repositories": false, 13187 "members_can_create_private_repositories": true, 13188 "members_can_create_internal_repositories": true, 13189 "members_allowed_repository_creation_type": "marct", 13190 "members_can_create_pages": true, 13191 "members_can_create_public_pages": false, 13192 "members_can_create_private_pages": true 13193 }, 13194 "sender": { 13195 "login": "l", 13196 "id": 1, 13197 "node_id": "n", 13198 "avatar_url": "a", 13199 "url": "u", 13200 "events_url": "e", 13201 "repos_url": "r" 13202 } 13203 }` 13204 13205 testJSONMarshal(t, u, want) 13206 } 13207 13208 func TestMetaEvent_Marshal(t *testing.T) { 13209 t.Parallel() 13210 testJSONMarshal(t, &MetaEvent{}, "{}") 13211 13212 v := make(map[string]interface{}) 13213 v["a"] = "b" 13214 hookConfig := &HookConfig{ 13215 ContentType: Ptr("json"), 13216 } 13217 13218 u := &MetaEvent{ 13219 Action: Ptr("a"), 13220 HookID: Ptr(int64(1)), 13221 Hook: &Hook{ 13222 CreatedAt: &Timestamp{referenceTime}, 13223 UpdatedAt: &Timestamp{referenceTime}, 13224 URL: Ptr("u"), 13225 ID: Ptr(int64(1)), 13226 Type: Ptr("t"), 13227 Name: Ptr("n"), 13228 TestURL: Ptr("tu"), 13229 PingURL: Ptr("pu"), 13230 LastResponse: v, 13231 Config: hookConfig, 13232 Events: []string{"a"}, 13233 Active: Ptr(true), 13234 }, 13235 } 13236 13237 want := `{ 13238 "action": "a", 13239 "hook_id": 1, 13240 "hook": { 13241 "created_at": ` + referenceTimeStr + `, 13242 "updated_at": ` + referenceTimeStr + `, 13243 "url": "u", 13244 "id": 1, 13245 "type": "t", 13246 "name": "n", 13247 "test_url": "tu", 13248 "ping_url": "pu", 13249 "last_response": { 13250 "a": "b" 13251 }, 13252 "config": { 13253 "content_type": "json" 13254 }, 13255 "events": [ 13256 "a" 13257 ], 13258 "active": true 13259 } 13260 }` 13261 13262 testJSONMarshal(t, u, want) 13263 } 13264 13265 func TestRequestedAction_Marshal(t *testing.T) { 13266 t.Parallel() 13267 testJSONMarshal(t, &RequestedAction{}, "{}") 13268 13269 r := &RequestedAction{ 13270 Identifier: "i", 13271 } 13272 13273 want := `{ 13274 "identifier": "i" 13275 }` 13276 13277 testJSONMarshal(t, r, want) 13278 } 13279 13280 func TestCreateEvent_Marshal(t *testing.T) { 13281 t.Parallel() 13282 testJSONMarshal(t, &CreateEvent{}, "{}") 13283 13284 r := &CreateEvent{ 13285 Ref: Ptr("r"), 13286 RefType: Ptr("rt"), 13287 MasterBranch: Ptr("mb"), 13288 Description: Ptr("d"), 13289 PusherType: Ptr("pt"), 13290 Repo: &Repository{ 13291 ID: Ptr(int64(1)), 13292 URL: Ptr("s"), 13293 Name: Ptr("n"), 13294 }, 13295 Sender: &User{ 13296 Login: Ptr("l"), 13297 ID: Ptr(int64(1)), 13298 NodeID: Ptr("n"), 13299 URL: Ptr("u"), 13300 ReposURL: Ptr("r"), 13301 EventsURL: Ptr("e"), 13302 AvatarURL: Ptr("a"), 13303 }, 13304 Installation: &Installation{ 13305 ID: Ptr(int64(1)), 13306 NodeID: Ptr("nid"), 13307 AppID: Ptr(int64(1)), 13308 AppSlug: Ptr("as"), 13309 TargetID: Ptr(int64(1)), 13310 Account: &User{ 13311 Login: Ptr("l"), 13312 ID: Ptr(int64(1)), 13313 URL: Ptr("u"), 13314 AvatarURL: Ptr("a"), 13315 GravatarID: Ptr("g"), 13316 Name: Ptr("n"), 13317 Company: Ptr("c"), 13318 Blog: Ptr("b"), 13319 Location: Ptr("l"), 13320 Email: Ptr("e"), 13321 Hireable: Ptr(true), 13322 Bio: Ptr("b"), 13323 TwitterUsername: Ptr("t"), 13324 PublicRepos: Ptr(1), 13325 Followers: Ptr(1), 13326 Following: Ptr(1), 13327 CreatedAt: &Timestamp{referenceTime}, 13328 SuspendedAt: &Timestamp{referenceTime}, 13329 }, 13330 AccessTokensURL: Ptr("atu"), 13331 RepositoriesURL: Ptr("ru"), 13332 HTMLURL: Ptr("hu"), 13333 TargetType: Ptr("tt"), 13334 SingleFileName: Ptr("sfn"), 13335 RepositorySelection: Ptr("rs"), 13336 Events: []string{"e"}, 13337 SingleFilePaths: []string{"s"}, 13338 Permissions: &InstallationPermissions{ 13339 Actions: Ptr("a"), 13340 Administration: Ptr("ad"), 13341 Checks: Ptr("c"), 13342 Contents: Ptr("co"), 13343 ContentReferences: Ptr("cr"), 13344 Deployments: Ptr("d"), 13345 Environments: Ptr("e"), 13346 Issues: Ptr("i"), 13347 Metadata: Ptr("md"), 13348 Members: Ptr("m"), 13349 OrganizationAdministration: Ptr("oa"), 13350 OrganizationHooks: Ptr("oh"), 13351 OrganizationPlan: Ptr("op"), 13352 OrganizationPreReceiveHooks: Ptr("opr"), 13353 OrganizationProjects: Ptr("op"), 13354 OrganizationSecrets: Ptr("os"), 13355 OrganizationSelfHostedRunners: Ptr("osh"), 13356 OrganizationUserBlocking: Ptr("oub"), 13357 Packages: Ptr("pkg"), 13358 Pages: Ptr("pg"), 13359 PullRequests: Ptr("pr"), 13360 RepositoryHooks: Ptr("rh"), 13361 RepositoryProjects: Ptr("rp"), 13362 RepositoryPreReceiveHooks: Ptr("rprh"), 13363 Secrets: Ptr("s"), 13364 SecretScanningAlerts: Ptr("ssa"), 13365 SecurityEvents: Ptr("se"), 13366 SingleFile: Ptr("sf"), 13367 Statuses: Ptr("s"), 13368 TeamDiscussions: Ptr("td"), 13369 VulnerabilityAlerts: Ptr("va"), 13370 Workflows: Ptr("w"), 13371 }, 13372 CreatedAt: &Timestamp{referenceTime}, 13373 UpdatedAt: &Timestamp{referenceTime}, 13374 HasMultipleSingleFiles: Ptr(false), 13375 SuspendedBy: &User{ 13376 Login: Ptr("l"), 13377 ID: Ptr(int64(1)), 13378 URL: Ptr("u"), 13379 AvatarURL: Ptr("a"), 13380 GravatarID: Ptr("g"), 13381 Name: Ptr("n"), 13382 Company: Ptr("c"), 13383 Blog: Ptr("b"), 13384 Location: Ptr("l"), 13385 Email: Ptr("e"), 13386 Hireable: Ptr(true), 13387 Bio: Ptr("b"), 13388 TwitterUsername: Ptr("t"), 13389 PublicRepos: Ptr(1), 13390 Followers: Ptr(1), 13391 Following: Ptr(1), 13392 CreatedAt: &Timestamp{referenceTime}, 13393 SuspendedAt: &Timestamp{referenceTime}, 13394 }, 13395 SuspendedAt: &Timestamp{referenceTime}, 13396 }, 13397 } 13398 13399 want := `{ 13400 "ref": "r", 13401 "ref_type": "rt", 13402 "master_branch": "mb", 13403 "description": "d", 13404 "pusher_type": "pt", 13405 "repository": { 13406 "id": 1, 13407 "name": "n", 13408 "url": "s" 13409 }, 13410 "sender": { 13411 "login": "l", 13412 "id": 1, 13413 "node_id": "n", 13414 "avatar_url": "a", 13415 "url": "u", 13416 "events_url": "e", 13417 "repos_url": "r" 13418 }, 13419 "installation": { 13420 "id": 1, 13421 "node_id": "nid", 13422 "app_id": 1, 13423 "app_slug": "as", 13424 "target_id": 1, 13425 "account": { 13426 "login": "l", 13427 "id": 1, 13428 "avatar_url": "a", 13429 "gravatar_id": "g", 13430 "name": "n", 13431 "company": "c", 13432 "blog": "b", 13433 "location": "l", 13434 "email": "e", 13435 "hireable": true, 13436 "bio": "b", 13437 "twitter_username": "t", 13438 "public_repos": 1, 13439 "followers": 1, 13440 "following": 1, 13441 "created_at": ` + referenceTimeStr + `, 13442 "suspended_at": ` + referenceTimeStr + `, 13443 "url": "u" 13444 }, 13445 "access_tokens_url": "atu", 13446 "repositories_url": "ru", 13447 "html_url": "hu", 13448 "target_type": "tt", 13449 "single_file_name": "sfn", 13450 "repository_selection": "rs", 13451 "events": [ 13452 "e" 13453 ], 13454 "single_file_paths": [ 13455 "s" 13456 ], 13457 "permissions": { 13458 "actions": "a", 13459 "administration": "ad", 13460 "checks": "c", 13461 "contents": "co", 13462 "content_references": "cr", 13463 "deployments": "d", 13464 "environments": "e", 13465 "issues": "i", 13466 "metadata": "md", 13467 "members": "m", 13468 "organization_administration": "oa", 13469 "organization_hooks": "oh", 13470 "organization_plan": "op", 13471 "organization_pre_receive_hooks": "opr", 13472 "organization_projects": "op", 13473 "organization_secrets": "os", 13474 "organization_self_hosted_runners": "osh", 13475 "organization_user_blocking": "oub", 13476 "packages": "pkg", 13477 "pages": "pg", 13478 "pull_requests": "pr", 13479 "repository_hooks": "rh", 13480 "repository_projects": "rp", 13481 "repository_pre_receive_hooks": "rprh", 13482 "secrets": "s", 13483 "secret_scanning_alerts": "ssa", 13484 "security_events": "se", 13485 "single_file": "sf", 13486 "statuses": "s", 13487 "team_discussions": "td", 13488 "vulnerability_alerts": "va", 13489 "workflows": "w" 13490 }, 13491 "created_at": ` + referenceTimeStr + `, 13492 "updated_at": ` + referenceTimeStr + `, 13493 "has_multiple_single_files": false, 13494 "suspended_by": { 13495 "login": "l", 13496 "id": 1, 13497 "avatar_url": "a", 13498 "gravatar_id": "g", 13499 "name": "n", 13500 "company": "c", 13501 "blog": "b", 13502 "location": "l", 13503 "email": "e", 13504 "hireable": true, 13505 "bio": "b", 13506 "twitter_username": "t", 13507 "public_repos": 1, 13508 "followers": 1, 13509 "following": 1, 13510 "created_at": ` + referenceTimeStr + `, 13511 "suspended_at": ` + referenceTimeStr + `, 13512 "url": "u" 13513 }, 13514 "suspended_at": ` + referenceTimeStr + ` 13515 } 13516 }` 13517 13518 testJSONMarshal(t, r, want) 13519 } 13520 13521 func TestCustomPropertyEvent_Marshal(t *testing.T) { 13522 t.Parallel() 13523 testJSONMarshal(t, &CustomPropertyEvent{}, "{}") 13524 13525 r := &CustomPropertyEvent{ 13526 Action: Ptr("created"), 13527 Definition: &CustomProperty{ 13528 PropertyName: Ptr("name"), 13529 ValueType: "single_select", 13530 SourceType: Ptr("enterprise"), 13531 Required: Ptr(true), 13532 DefaultValue: Ptr("production"), 13533 Description: Ptr("Prod or dev environment"), 13534 AllowedValues: []string{"production", "development"}, 13535 ValuesEditableBy: Ptr("org_actors"), 13536 }, 13537 Sender: &User{ 13538 Login: Ptr("l"), 13539 ID: Ptr(int64(1)), 13540 NodeID: Ptr("n"), 13541 URL: Ptr("u"), 13542 ReposURL: Ptr("r"), 13543 EventsURL: Ptr("e"), 13544 AvatarURL: Ptr("a"), 13545 }, 13546 Installation: &Installation{ 13547 ID: Ptr(int64(1)), 13548 NodeID: Ptr("nid"), 13549 AppID: Ptr(int64(1)), 13550 AppSlug: Ptr("as"), 13551 TargetID: Ptr(int64(1)), 13552 Account: &User{ 13553 Login: Ptr("l"), 13554 ID: Ptr(int64(1)), 13555 URL: Ptr("u"), 13556 AvatarURL: Ptr("a"), 13557 GravatarID: Ptr("g"), 13558 Name: Ptr("n"), 13559 Company: Ptr("c"), 13560 Blog: Ptr("b"), 13561 Location: Ptr("l"), 13562 Email: Ptr("e"), 13563 Hireable: Ptr(true), 13564 Bio: Ptr("b"), 13565 TwitterUsername: Ptr("t"), 13566 PublicRepos: Ptr(1), 13567 Followers: Ptr(1), 13568 Following: Ptr(1), 13569 CreatedAt: &Timestamp{referenceTime}, 13570 SuspendedAt: &Timestamp{referenceTime}, 13571 }, 13572 AccessTokensURL: Ptr("atu"), 13573 RepositoriesURL: Ptr("ru"), 13574 HTMLURL: Ptr("hu"), 13575 TargetType: Ptr("tt"), 13576 SingleFileName: Ptr("sfn"), 13577 RepositorySelection: Ptr("rs"), 13578 Events: []string{"e"}, 13579 SingleFilePaths: []string{"s"}, 13580 Permissions: &InstallationPermissions{ 13581 Actions: Ptr("a"), 13582 Administration: Ptr("ad"), 13583 Checks: Ptr("c"), 13584 Contents: Ptr("co"), 13585 ContentReferences: Ptr("cr"), 13586 Deployments: Ptr("d"), 13587 Environments: Ptr("e"), 13588 Issues: Ptr("i"), 13589 Metadata: Ptr("md"), 13590 Members: Ptr("m"), 13591 OrganizationAdministration: Ptr("oa"), 13592 OrganizationHooks: Ptr("oh"), 13593 OrganizationPlan: Ptr("op"), 13594 OrganizationPreReceiveHooks: Ptr("opr"), 13595 OrganizationProjects: Ptr("op"), 13596 OrganizationSecrets: Ptr("os"), 13597 OrganizationSelfHostedRunners: Ptr("osh"), 13598 OrganizationUserBlocking: Ptr("oub"), 13599 Packages: Ptr("pkg"), 13600 Pages: Ptr("pg"), 13601 PullRequests: Ptr("pr"), 13602 RepositoryHooks: Ptr("rh"), 13603 RepositoryProjects: Ptr("rp"), 13604 RepositoryPreReceiveHooks: Ptr("rprh"), 13605 Secrets: Ptr("s"), 13606 SecretScanningAlerts: Ptr("ssa"), 13607 SecurityEvents: Ptr("se"), 13608 SingleFile: Ptr("sf"), 13609 Statuses: Ptr("s"), 13610 TeamDiscussions: Ptr("td"), 13611 VulnerabilityAlerts: Ptr("va"), 13612 Workflows: Ptr("w"), 13613 }, 13614 CreatedAt: &Timestamp{referenceTime}, 13615 UpdatedAt: &Timestamp{referenceTime}, 13616 HasMultipleSingleFiles: Ptr(false), 13617 SuspendedBy: &User{ 13618 Login: Ptr("l"), 13619 ID: Ptr(int64(1)), 13620 URL: Ptr("u"), 13621 AvatarURL: Ptr("a"), 13622 GravatarID: Ptr("g"), 13623 Name: Ptr("n"), 13624 Company: Ptr("c"), 13625 Blog: Ptr("b"), 13626 Location: Ptr("l"), 13627 Email: Ptr("e"), 13628 Hireable: Ptr(true), 13629 Bio: Ptr("b"), 13630 TwitterUsername: Ptr("t"), 13631 PublicRepos: Ptr(1), 13632 Followers: Ptr(1), 13633 Following: Ptr(1), 13634 CreatedAt: &Timestamp{referenceTime}, 13635 SuspendedAt: &Timestamp{referenceTime}, 13636 }, 13637 SuspendedAt: &Timestamp{referenceTime}, 13638 }, 13639 } 13640 13641 want := `{ 13642 "action": "created", 13643 "definition": { 13644 "property_name": "name", 13645 "source_type": "enterprise", 13646 "value_type": "single_select", 13647 "required": true, 13648 "default_value": "production", 13649 "description": "Prod or dev environment", 13650 "allowed_values": [ 13651 "production", 13652 "development" 13653 ], 13654 "values_editable_by": "org_actors" 13655 }, 13656 "repository": { 13657 "id": 1, 13658 "name": "n", 13659 "url": "s" 13660 }, 13661 "sender": { 13662 "login": "l", 13663 "id": 1, 13664 "node_id": "n", 13665 "avatar_url": "a", 13666 "url": "u", 13667 "events_url": "e", 13668 "repos_url": "r" 13669 }, 13670 "installation": { 13671 "id": 1, 13672 "node_id": "nid", 13673 "app_id": 1, 13674 "app_slug": "as", 13675 "target_id": 1, 13676 "account": { 13677 "login": "l", 13678 "id": 1, 13679 "avatar_url": "a", 13680 "gravatar_id": "g", 13681 "name": "n", 13682 "company": "c", 13683 "blog": "b", 13684 "location": "l", 13685 "email": "e", 13686 "hireable": true, 13687 "bio": "b", 13688 "twitter_username": "t", 13689 "public_repos": 1, 13690 "followers": 1, 13691 "following": 1, 13692 "created_at": ` + referenceTimeStr + `, 13693 "suspended_at": ` + referenceTimeStr + `, 13694 "url": "u" 13695 }, 13696 "access_tokens_url": "atu", 13697 "repositories_url": "ru", 13698 "html_url": "hu", 13699 "target_type": "tt", 13700 "single_file_name": "sfn", 13701 "repository_selection": "rs", 13702 "events": [ 13703 "e" 13704 ], 13705 "single_file_paths": [ 13706 "s" 13707 ], 13708 "permissions": { 13709 "actions": "a", 13710 "administration": "ad", 13711 "checks": "c", 13712 "contents": "co", 13713 "content_references": "cr", 13714 "deployments": "d", 13715 "environments": "e", 13716 "issues": "i", 13717 "metadata": "md", 13718 "members": "m", 13719 "organization_administration": "oa", 13720 "organization_hooks": "oh", 13721 "organization_plan": "op", 13722 "organization_pre_receive_hooks": "opr", 13723 "organization_projects": "op", 13724 "organization_secrets": "os", 13725 "organization_self_hosted_runners": "osh", 13726 "organization_user_blocking": "oub", 13727 "packages": "pkg", 13728 "pages": "pg", 13729 "pull_requests": "pr", 13730 "repository_hooks": "rh", 13731 "repository_projects": "rp", 13732 "repository_pre_receive_hooks": "rprh", 13733 "secrets": "s", 13734 "secret_scanning_alerts": "ssa", 13735 "security_events": "se", 13736 "single_file": "sf", 13737 "statuses": "s", 13738 "team_discussions": "td", 13739 "vulnerability_alerts": "va", 13740 "workflows": "w" 13741 }, 13742 "created_at": ` + referenceTimeStr + `, 13743 "updated_at": ` + referenceTimeStr + `, 13744 "has_multiple_single_files": false, 13745 "suspended_by": { 13746 "login": "l", 13747 "id": 1, 13748 "avatar_url": "a", 13749 "gravatar_id": "g", 13750 "name": "n", 13751 "company": "c", 13752 "blog": "b", 13753 "location": "l", 13754 "email": "e", 13755 "hireable": true, 13756 "bio": "b", 13757 "twitter_username": "t", 13758 "public_repos": 1, 13759 "followers": 1, 13760 "following": 1, 13761 "created_at": ` + referenceTimeStr + `, 13762 "suspended_at": ` + referenceTimeStr + `, 13763 "url": "u" 13764 }, 13765 "suspended_at": ` + referenceTimeStr + ` 13766 } 13767 }` 13768 13769 testJSONMarshal(t, r, want) 13770 } 13771 13772 func TestCustomPropertyValuesEvent_Marshal(t *testing.T) { 13773 t.Parallel() 13774 testJSONMarshal(t, &CustomPropertyValuesEvent{}, "{}") 13775 13776 r := &CustomPropertyValuesEvent{ 13777 Action: Ptr("updated"), 13778 NewPropertyValues: []*CustomPropertyValue{ 13779 { 13780 PropertyName: "environment", 13781 Value: "production", 13782 }, 13783 }, 13784 OldPropertyValues: []*CustomPropertyValue{ 13785 { 13786 PropertyName: "environment", 13787 Value: "staging", 13788 }, 13789 }, 13790 Sender: &User{ 13791 Login: Ptr("l"), 13792 ID: Ptr(int64(1)), 13793 NodeID: Ptr("n"), 13794 URL: Ptr("u"), 13795 ReposURL: Ptr("r"), 13796 EventsURL: Ptr("e"), 13797 AvatarURL: Ptr("a"), 13798 }, 13799 Installation: &Installation{ 13800 ID: Ptr(int64(1)), 13801 NodeID: Ptr("nid"), 13802 AppID: Ptr(int64(1)), 13803 AppSlug: Ptr("as"), 13804 TargetID: Ptr(int64(1)), 13805 Account: &User{ 13806 Login: Ptr("l"), 13807 ID: Ptr(int64(1)), 13808 URL: Ptr("u"), 13809 AvatarURL: Ptr("a"), 13810 GravatarID: Ptr("g"), 13811 Name: Ptr("n"), 13812 Company: Ptr("c"), 13813 Blog: Ptr("b"), 13814 Location: Ptr("l"), 13815 Email: Ptr("e"), 13816 Hireable: Ptr(true), 13817 Bio: Ptr("b"), 13818 TwitterUsername: Ptr("t"), 13819 PublicRepos: Ptr(1), 13820 Followers: Ptr(1), 13821 Following: Ptr(1), 13822 CreatedAt: &Timestamp{referenceTime}, 13823 SuspendedAt: &Timestamp{referenceTime}, 13824 }, 13825 AccessTokensURL: Ptr("atu"), 13826 RepositoriesURL: Ptr("ru"), 13827 HTMLURL: Ptr("hu"), 13828 TargetType: Ptr("tt"), 13829 SingleFileName: Ptr("sfn"), 13830 RepositorySelection: Ptr("rs"), 13831 Events: []string{"e"}, 13832 SingleFilePaths: []string{"s"}, 13833 Permissions: &InstallationPermissions{ 13834 Actions: Ptr("a"), 13835 Administration: Ptr("ad"), 13836 Checks: Ptr("c"), 13837 Contents: Ptr("co"), 13838 ContentReferences: Ptr("cr"), 13839 Deployments: Ptr("d"), 13840 Environments: Ptr("e"), 13841 Issues: Ptr("i"), 13842 Metadata: Ptr("md"), 13843 Members: Ptr("m"), 13844 OrganizationAdministration: Ptr("oa"), 13845 OrganizationHooks: Ptr("oh"), 13846 OrganizationPlan: Ptr("op"), 13847 OrganizationPreReceiveHooks: Ptr("opr"), 13848 OrganizationProjects: Ptr("op"), 13849 OrganizationSecrets: Ptr("os"), 13850 OrganizationSelfHostedRunners: Ptr("osh"), 13851 OrganizationUserBlocking: Ptr("oub"), 13852 Packages: Ptr("pkg"), 13853 Pages: Ptr("pg"), 13854 PullRequests: Ptr("pr"), 13855 RepositoryHooks: Ptr("rh"), 13856 RepositoryProjects: Ptr("rp"), 13857 RepositoryPreReceiveHooks: Ptr("rprh"), 13858 Secrets: Ptr("s"), 13859 SecretScanningAlerts: Ptr("ssa"), 13860 SecurityEvents: Ptr("se"), 13861 SingleFile: Ptr("sf"), 13862 Statuses: Ptr("s"), 13863 TeamDiscussions: Ptr("td"), 13864 VulnerabilityAlerts: Ptr("va"), 13865 Workflows: Ptr("w"), 13866 }, 13867 CreatedAt: &Timestamp{referenceTime}, 13868 UpdatedAt: &Timestamp{referenceTime}, 13869 HasMultipleSingleFiles: Ptr(false), 13870 SuspendedBy: &User{ 13871 Login: Ptr("l"), 13872 ID: Ptr(int64(1)), 13873 URL: Ptr("u"), 13874 AvatarURL: Ptr("a"), 13875 GravatarID: Ptr("g"), 13876 Name: Ptr("n"), 13877 Company: Ptr("c"), 13878 Blog: Ptr("b"), 13879 Location: Ptr("l"), 13880 Email: Ptr("e"), 13881 Hireable: Ptr(true), 13882 Bio: Ptr("b"), 13883 TwitterUsername: Ptr("t"), 13884 PublicRepos: Ptr(1), 13885 Followers: Ptr(1), 13886 Following: Ptr(1), 13887 CreatedAt: &Timestamp{referenceTime}, 13888 SuspendedAt: &Timestamp{referenceTime}, 13889 }, 13890 SuspendedAt: &Timestamp{referenceTime}, 13891 }, 13892 } 13893 13894 want := `{ 13895 "action": "updated", 13896 "new_property_values": [{ 13897 "property_name": "environment", 13898 "value": "production" 13899 }], 13900 "old_property_values": [{ 13901 "property_name": "environment", 13902 "value": "staging" 13903 }], 13904 "sender": { 13905 "login": "l", 13906 "id": 1, 13907 "node_id": "n", 13908 "avatar_url": "a", 13909 "url": "u", 13910 "events_url": "e", 13911 "repos_url": "r" 13912 }, 13913 "installation": { 13914 "id": 1, 13915 "node_id": "nid", 13916 "app_id": 1, 13917 "app_slug": "as", 13918 "target_id": 1, 13919 "account": { 13920 "login": "l", 13921 "id": 1, 13922 "avatar_url": "a", 13923 "gravatar_id": "g", 13924 "name": "n", 13925 "company": "c", 13926 "blog": "b", 13927 "location": "l", 13928 "email": "e", 13929 "hireable": true, 13930 "bio": "b", 13931 "twitter_username": "t", 13932 "public_repos": 1, 13933 "followers": 1, 13934 "following": 1, 13935 "created_at": ` + referenceTimeStr + `, 13936 "suspended_at": ` + referenceTimeStr + `, 13937 "url": "u" 13938 }, 13939 "access_tokens_url": "atu", 13940 "repositories_url": "ru", 13941 "html_url": "hu", 13942 "target_type": "tt", 13943 "single_file_name": "sfn", 13944 "repository_selection": "rs", 13945 "events": [ 13946 "e" 13947 ], 13948 "single_file_paths": [ 13949 "s" 13950 ], 13951 "permissions": { 13952 "actions": "a", 13953 "administration": "ad", 13954 "checks": "c", 13955 "contents": "co", 13956 "content_references": "cr", 13957 "deployments": "d", 13958 "environments": "e", 13959 "issues": "i", 13960 "metadata": "md", 13961 "members": "m", 13962 "organization_administration": "oa", 13963 "organization_hooks": "oh", 13964 "organization_plan": "op", 13965 "organization_pre_receive_hooks": "opr", 13966 "organization_projects": "op", 13967 "organization_secrets": "os", 13968 "organization_self_hosted_runners": "osh", 13969 "organization_user_blocking": "oub", 13970 "packages": "pkg", 13971 "pages": "pg", 13972 "pull_requests": "pr", 13973 "repository_hooks": "rh", 13974 "repository_projects": "rp", 13975 "repository_pre_receive_hooks": "rprh", 13976 "secrets": "s", 13977 "secret_scanning_alerts": "ssa", 13978 "security_events": "se", 13979 "single_file": "sf", 13980 "statuses": "s", 13981 "team_discussions": "td", 13982 "vulnerability_alerts": "va", 13983 "workflows": "w" 13984 }, 13985 "created_at": ` + referenceTimeStr + `, 13986 "updated_at": ` + referenceTimeStr + `, 13987 "has_multiple_single_files": false, 13988 "suspended_by": { 13989 "login": "l", 13990 "id": 1, 13991 "avatar_url": "a", 13992 "gravatar_id": "g", 13993 "name": "n", 13994 "company": "c", 13995 "blog": "b", 13996 "location": "l", 13997 "email": "e", 13998 "hireable": true, 13999 "bio": "b", 14000 "twitter_username": "t", 14001 "public_repos": 1, 14002 "followers": 1, 14003 "following": 1, 14004 "created_at": ` + referenceTimeStr + `, 14005 "suspended_at": ` + referenceTimeStr + `, 14006 "url": "u" 14007 }, 14008 "suspended_at": ` + referenceTimeStr + ` 14009 } 14010 }` 14011 14012 testJSONMarshal(t, r, want) 14013 } 14014 14015 func TestDeleteEvent_Marshal(t *testing.T) { 14016 t.Parallel() 14017 testJSONMarshal(t, &DeleteEvent{}, "{}") 14018 14019 r := &DeleteEvent{ 14020 Ref: Ptr("r"), 14021 RefType: Ptr("rt"), 14022 PusherType: Ptr("pt"), 14023 Repo: &Repository{ 14024 ID: Ptr(int64(1)), 14025 URL: Ptr("s"), 14026 Name: Ptr("n"), 14027 }, 14028 Sender: &User{ 14029 Login: Ptr("l"), 14030 ID: Ptr(int64(1)), 14031 NodeID: Ptr("n"), 14032 URL: Ptr("u"), 14033 ReposURL: Ptr("r"), 14034 EventsURL: Ptr("e"), 14035 AvatarURL: Ptr("a"), 14036 }, 14037 Installation: &Installation{ 14038 ID: Ptr(int64(1)), 14039 NodeID: Ptr("nid"), 14040 AppID: Ptr(int64(1)), 14041 AppSlug: Ptr("as"), 14042 TargetID: Ptr(int64(1)), 14043 Account: &User{ 14044 Login: Ptr("l"), 14045 ID: Ptr(int64(1)), 14046 URL: Ptr("u"), 14047 AvatarURL: Ptr("a"), 14048 GravatarID: Ptr("g"), 14049 Name: Ptr("n"), 14050 Company: Ptr("c"), 14051 Blog: Ptr("b"), 14052 Location: Ptr("l"), 14053 Email: Ptr("e"), 14054 Hireable: Ptr(true), 14055 Bio: Ptr("b"), 14056 TwitterUsername: Ptr("t"), 14057 PublicRepos: Ptr(1), 14058 Followers: Ptr(1), 14059 Following: Ptr(1), 14060 CreatedAt: &Timestamp{referenceTime}, 14061 SuspendedAt: &Timestamp{referenceTime}, 14062 }, 14063 AccessTokensURL: Ptr("atu"), 14064 RepositoriesURL: Ptr("ru"), 14065 HTMLURL: Ptr("hu"), 14066 TargetType: Ptr("tt"), 14067 SingleFileName: Ptr("sfn"), 14068 RepositorySelection: Ptr("rs"), 14069 Events: []string{"e"}, 14070 SingleFilePaths: []string{"s"}, 14071 Permissions: &InstallationPermissions{ 14072 Actions: Ptr("a"), 14073 Administration: Ptr("ad"), 14074 Checks: Ptr("c"), 14075 Contents: Ptr("co"), 14076 ContentReferences: Ptr("cr"), 14077 Deployments: Ptr("d"), 14078 Environments: Ptr("e"), 14079 Issues: Ptr("i"), 14080 Metadata: Ptr("md"), 14081 Members: Ptr("m"), 14082 OrganizationAdministration: Ptr("oa"), 14083 OrganizationHooks: Ptr("oh"), 14084 OrganizationPlan: Ptr("op"), 14085 OrganizationPreReceiveHooks: Ptr("opr"), 14086 OrganizationProjects: Ptr("op"), 14087 OrganizationSecrets: Ptr("os"), 14088 OrganizationSelfHostedRunners: Ptr("osh"), 14089 OrganizationUserBlocking: Ptr("oub"), 14090 Packages: Ptr("pkg"), 14091 Pages: Ptr("pg"), 14092 PullRequests: Ptr("pr"), 14093 RepositoryHooks: Ptr("rh"), 14094 RepositoryProjects: Ptr("rp"), 14095 RepositoryPreReceiveHooks: Ptr("rprh"), 14096 Secrets: Ptr("s"), 14097 SecretScanningAlerts: Ptr("ssa"), 14098 SecurityEvents: Ptr("se"), 14099 SingleFile: Ptr("sf"), 14100 Statuses: Ptr("s"), 14101 TeamDiscussions: Ptr("td"), 14102 VulnerabilityAlerts: Ptr("va"), 14103 Workflows: Ptr("w"), 14104 }, 14105 CreatedAt: &Timestamp{referenceTime}, 14106 UpdatedAt: &Timestamp{referenceTime}, 14107 HasMultipleSingleFiles: Ptr(false), 14108 SuspendedBy: &User{ 14109 Login: Ptr("l"), 14110 ID: Ptr(int64(1)), 14111 URL: Ptr("u"), 14112 AvatarURL: Ptr("a"), 14113 GravatarID: Ptr("g"), 14114 Name: Ptr("n"), 14115 Company: Ptr("c"), 14116 Blog: Ptr("b"), 14117 Location: Ptr("l"), 14118 Email: Ptr("e"), 14119 Hireable: Ptr(true), 14120 Bio: Ptr("b"), 14121 TwitterUsername: Ptr("t"), 14122 PublicRepos: Ptr(1), 14123 Followers: Ptr(1), 14124 Following: Ptr(1), 14125 CreatedAt: &Timestamp{referenceTime}, 14126 SuspendedAt: &Timestamp{referenceTime}, 14127 }, 14128 SuspendedAt: &Timestamp{referenceTime}, 14129 }, 14130 } 14131 14132 want := `{ 14133 "ref": "r", 14134 "ref_type": "rt", 14135 "pusher_type": "pt", 14136 "repository": { 14137 "id": 1, 14138 "name": "n", 14139 "url": "s" 14140 }, 14141 "sender": { 14142 "login": "l", 14143 "id": 1, 14144 "node_id": "n", 14145 "avatar_url": "a", 14146 "url": "u", 14147 "events_url": "e", 14148 "repos_url": "r" 14149 }, 14150 "installation": { 14151 "id": 1, 14152 "node_id": "nid", 14153 "app_id": 1, 14154 "app_slug": "as", 14155 "target_id": 1, 14156 "account": { 14157 "login": "l", 14158 "id": 1, 14159 "avatar_url": "a", 14160 "gravatar_id": "g", 14161 "name": "n", 14162 "company": "c", 14163 "blog": "b", 14164 "location": "l", 14165 "email": "e", 14166 "hireable": true, 14167 "bio": "b", 14168 "twitter_username": "t", 14169 "public_repos": 1, 14170 "followers": 1, 14171 "following": 1, 14172 "created_at": ` + referenceTimeStr + `, 14173 "suspended_at": ` + referenceTimeStr + `, 14174 "url": "u" 14175 }, 14176 "access_tokens_url": "atu", 14177 "repositories_url": "ru", 14178 "html_url": "hu", 14179 "target_type": "tt", 14180 "single_file_name": "sfn", 14181 "repository_selection": "rs", 14182 "events": [ 14183 "e" 14184 ], 14185 "single_file_paths": [ 14186 "s" 14187 ], 14188 "permissions": { 14189 "actions": "a", 14190 "administration": "ad", 14191 "checks": "c", 14192 "contents": "co", 14193 "content_references": "cr", 14194 "deployments": "d", 14195 "environments": "e", 14196 "issues": "i", 14197 "metadata": "md", 14198 "members": "m", 14199 "organization_administration": "oa", 14200 "organization_hooks": "oh", 14201 "organization_plan": "op", 14202 "organization_pre_receive_hooks": "opr", 14203 "organization_projects": "op", 14204 "organization_secrets": "os", 14205 "organization_self_hosted_runners": "osh", 14206 "organization_user_blocking": "oub", 14207 "packages": "pkg", 14208 "pages": "pg", 14209 "pull_requests": "pr", 14210 "repository_hooks": "rh", 14211 "repository_projects": "rp", 14212 "repository_pre_receive_hooks": "rprh", 14213 "secrets": "s", 14214 "secret_scanning_alerts": "ssa", 14215 "security_events": "se", 14216 "single_file": "sf", 14217 "statuses": "s", 14218 "team_discussions": "td", 14219 "vulnerability_alerts": "va", 14220 "workflows": "w" 14221 }, 14222 "created_at": ` + referenceTimeStr + `, 14223 "updated_at": ` + referenceTimeStr + `, 14224 "has_multiple_single_files": false, 14225 "suspended_by": { 14226 "login": "l", 14227 "id": 1, 14228 "avatar_url": "a", 14229 "gravatar_id": "g", 14230 "name": "n", 14231 "company": "c", 14232 "blog": "b", 14233 "location": "l", 14234 "email": "e", 14235 "hireable": true, 14236 "bio": "b", 14237 "twitter_username": "t", 14238 "public_repos": 1, 14239 "followers": 1, 14240 "following": 1, 14241 "created_at": ` + referenceTimeStr + `, 14242 "suspended_at": ` + referenceTimeStr + `, 14243 "url": "u" 14244 }, 14245 "suspended_at": ` + referenceTimeStr + ` 14246 } 14247 }` 14248 14249 testJSONMarshal(t, r, want) 14250 } 14251 14252 func TestDependabotAlertEvent_Marshal(t *testing.T) { 14253 t.Parallel() 14254 testJSONMarshal(t, &DependabotAlertEvent{}, "{}") 14255 14256 e := &DependabotAlertEvent{ 14257 Action: Ptr("a"), 14258 Alert: &DependabotAlert{ 14259 Number: Ptr(1), 14260 State: Ptr("s"), 14261 Dependency: &Dependency{ 14262 Package: &VulnerabilityPackage{ 14263 Ecosystem: Ptr("e"), 14264 Name: Ptr("n"), 14265 }, 14266 ManifestPath: Ptr("mp"), 14267 Scope: Ptr("s"), 14268 }, 14269 SecurityAdvisory: &DependabotSecurityAdvisory{ 14270 GHSAID: Ptr("ghsaid"), 14271 CVEID: Ptr("cveid"), 14272 Summary: Ptr("s"), 14273 Description: Ptr("d"), 14274 Vulnerabilities: []*AdvisoryVulnerability{ 14275 { 14276 Package: &VulnerabilityPackage{ 14277 Ecosystem: Ptr("e"), 14278 Name: Ptr("n"), 14279 }, 14280 Severity: Ptr("s"), 14281 }, 14282 }, 14283 Severity: Ptr("s"), 14284 CVSS: &AdvisoryCVSS{ 14285 Score: Ptr(1.0), 14286 VectorString: Ptr("vs"), 14287 }, 14288 CWEs: []*AdvisoryCWEs{ 14289 { 14290 CWEID: Ptr("cweid"), 14291 Name: Ptr("n"), 14292 }, 14293 }, 14294 Identifiers: []*AdvisoryIdentifier{ 14295 { 14296 Value: Ptr("v"), 14297 Type: Ptr("t"), 14298 }, 14299 }, 14300 References: []*AdvisoryReference{ 14301 { 14302 URL: Ptr("u"), 14303 }, 14304 }, 14305 PublishedAt: &Timestamp{referenceTime}, 14306 UpdatedAt: &Timestamp{referenceTime}, 14307 WithdrawnAt: &Timestamp{referenceTime}, 14308 }, 14309 SecurityVulnerability: &AdvisoryVulnerability{ 14310 Package: &VulnerabilityPackage{ 14311 Ecosystem: Ptr("e"), 14312 Name: Ptr("n"), 14313 }, 14314 Severity: Ptr("s"), 14315 VulnerableVersionRange: Ptr("vvr"), 14316 FirstPatchedVersion: &FirstPatchedVersion{ 14317 Identifier: Ptr("i"), 14318 }, 14319 }, 14320 URL: Ptr("u"), 14321 HTMLURL: Ptr("hu"), 14322 CreatedAt: &Timestamp{referenceTime}, 14323 UpdatedAt: &Timestamp{referenceTime}, 14324 DismissedAt: &Timestamp{referenceTime}, 14325 DismissedBy: &User{ 14326 Login: Ptr("l"), 14327 ID: Ptr(int64(1)), 14328 NodeID: Ptr("n"), 14329 URL: Ptr("u"), 14330 ReposURL: Ptr("r"), 14331 EventsURL: Ptr("e"), 14332 AvatarURL: Ptr("a"), 14333 }, 14334 DismissedReason: Ptr("dr"), 14335 DismissedComment: Ptr("dc"), 14336 FixedAt: &Timestamp{referenceTime}, 14337 AutoDismissedAt: &Timestamp{referenceTime}, 14338 }, 14339 Repo: &Repository{ 14340 ID: Ptr(int64(1)), 14341 URL: Ptr("s"), 14342 Name: Ptr("n"), 14343 }, 14344 Organization: &Organization{ 14345 BillingEmail: Ptr("be"), 14346 Blog: Ptr("b"), 14347 Company: Ptr("c"), 14348 Email: Ptr("e"), 14349 TwitterUsername: Ptr("tu"), 14350 Location: Ptr("loc"), 14351 Name: Ptr("n"), 14352 Description: Ptr("d"), 14353 IsVerified: Ptr(true), 14354 HasOrganizationProjects: Ptr(true), 14355 HasRepositoryProjects: Ptr(true), 14356 DefaultRepoPermission: Ptr("drp"), 14357 MembersCanCreateRepos: Ptr(true), 14358 MembersCanCreateInternalRepos: Ptr(true), 14359 MembersCanCreatePrivateRepos: Ptr(true), 14360 MembersCanCreatePublicRepos: Ptr(false), 14361 MembersAllowedRepositoryCreationType: Ptr("marct"), 14362 MembersCanCreatePages: Ptr(true), 14363 MembersCanCreatePublicPages: Ptr(false), 14364 MembersCanCreatePrivatePages: Ptr(true), 14365 }, 14366 Enterprise: &Enterprise{ 14367 ID: Ptr(1), 14368 Slug: Ptr("s"), 14369 Name: Ptr("n"), 14370 NodeID: Ptr("nid"), 14371 AvatarURL: Ptr("au"), 14372 Description: Ptr("d"), 14373 WebsiteURL: Ptr("wu"), 14374 HTMLURL: Ptr("hu"), 14375 CreatedAt: &Timestamp{referenceTime}, 14376 UpdatedAt: &Timestamp{referenceTime}, 14377 }, 14378 Sender: &User{ 14379 Login: Ptr("l"), 14380 ID: Ptr(int64(1)), 14381 NodeID: Ptr("n"), 14382 URL: Ptr("u"), 14383 ReposURL: Ptr("r"), 14384 EventsURL: Ptr("e"), 14385 AvatarURL: Ptr("a"), 14386 }, 14387 Installation: &Installation{ 14388 ID: Ptr(int64(1)), 14389 NodeID: Ptr("nid"), 14390 AppID: Ptr(int64(1)), 14391 AppSlug: Ptr("as"), 14392 TargetID: Ptr(int64(1)), 14393 Account: &User{ 14394 Login: Ptr("l"), 14395 ID: Ptr(int64(1)), 14396 URL: Ptr("u"), 14397 AvatarURL: Ptr("a"), 14398 GravatarID: Ptr("g"), 14399 Name: Ptr("n"), 14400 Company: Ptr("c"), 14401 Blog: Ptr("b"), 14402 Location: Ptr("l"), 14403 Email: Ptr("e"), 14404 Hireable: Ptr(true), 14405 Bio: Ptr("b"), 14406 TwitterUsername: Ptr("t"), 14407 PublicRepos: Ptr(1), 14408 Followers: Ptr(1), 14409 Following: Ptr(1), 14410 CreatedAt: &Timestamp{referenceTime}, 14411 SuspendedAt: &Timestamp{referenceTime}, 14412 }, 14413 AccessTokensURL: Ptr("atu"), 14414 RepositoriesURL: Ptr("ru"), 14415 HTMLURL: Ptr("hu"), 14416 TargetType: Ptr("tt"), 14417 SingleFileName: Ptr("sfn"), 14418 RepositorySelection: Ptr("rs"), 14419 Events: []string{"e"}, 14420 SingleFilePaths: []string{"s"}, 14421 Permissions: &InstallationPermissions{ 14422 Actions: Ptr("a"), 14423 Administration: Ptr("ad"), 14424 Checks: Ptr("c"), 14425 Contents: Ptr("co"), 14426 ContentReferences: Ptr("cr"), 14427 Deployments: Ptr("d"), 14428 Environments: Ptr("e"), 14429 Issues: Ptr("i"), 14430 Metadata: Ptr("md"), 14431 Members: Ptr("m"), 14432 OrganizationAdministration: Ptr("oa"), 14433 OrganizationHooks: Ptr("oh"), 14434 OrganizationPlan: Ptr("op"), 14435 OrganizationPreReceiveHooks: Ptr("opr"), 14436 OrganizationProjects: Ptr("op"), 14437 OrganizationSecrets: Ptr("os"), 14438 OrganizationSelfHostedRunners: Ptr("osh"), 14439 OrganizationUserBlocking: Ptr("oub"), 14440 Packages: Ptr("pkg"), 14441 Pages: Ptr("pg"), 14442 PullRequests: Ptr("pr"), 14443 RepositoryHooks: Ptr("rh"), 14444 RepositoryProjects: Ptr("rp"), 14445 RepositoryPreReceiveHooks: Ptr("rprh"), 14446 Secrets: Ptr("s"), 14447 SecretScanningAlerts: Ptr("ssa"), 14448 SecurityEvents: Ptr("se"), 14449 SingleFile: Ptr("sf"), 14450 Statuses: Ptr("s"), 14451 TeamDiscussions: Ptr("td"), 14452 VulnerabilityAlerts: Ptr("va"), 14453 Workflows: Ptr("w"), 14454 }, 14455 CreatedAt: &Timestamp{referenceTime}, 14456 UpdatedAt: &Timestamp{referenceTime}, 14457 HasMultipleSingleFiles: Ptr(false), 14458 SuspendedBy: &User{ 14459 Login: Ptr("l"), 14460 ID: Ptr(int64(1)), 14461 URL: Ptr("u"), 14462 AvatarURL: Ptr("a"), 14463 GravatarID: Ptr("g"), 14464 Name: Ptr("n"), 14465 Company: Ptr("c"), 14466 Blog: Ptr("b"), 14467 Location: Ptr("l"), 14468 Email: Ptr("e"), 14469 Hireable: Ptr(true), 14470 Bio: Ptr("b"), 14471 TwitterUsername: Ptr("t"), 14472 PublicRepos: Ptr(1), 14473 Followers: Ptr(1), 14474 Following: Ptr(1), 14475 CreatedAt: &Timestamp{referenceTime}, 14476 SuspendedAt: &Timestamp{referenceTime}, 14477 }, 14478 SuspendedAt: &Timestamp{referenceTime}, 14479 }, 14480 } 14481 want := `{ 14482 "action": "a", 14483 "alert": { 14484 "number": 1, 14485 "state": "s", 14486 "dependency": { 14487 "package": { 14488 "ecosystem": "e", 14489 "name": "n" 14490 }, 14491 "manifest_path": "mp", 14492 "scope": "s" 14493 }, 14494 "security_advisory": { 14495 "ghsa_id": "ghsaid", 14496 "cve_id": "cveid", 14497 "summary": "s", 14498 "description": "d", 14499 "vulnerabilities": [ 14500 { 14501 "package": { 14502 "ecosystem": "e", 14503 "name": "n" 14504 }, 14505 "severity": "s" 14506 } 14507 ], 14508 "severity": "s", 14509 "cvss": { 14510 "score": 1.0, 14511 "vector_string": "vs" 14512 }, 14513 "cwes": [ 14514 { 14515 "cwe_id": "cweid", 14516 "name": "n" 14517 } 14518 ], 14519 "identifiers": [ 14520 { 14521 "value": "v", 14522 "type": "t" 14523 } 14524 ], 14525 "references": [ 14526 { 14527 "url": "u" 14528 } 14529 ], 14530 "published_at": ` + referenceTimeStr + `, 14531 "updated_at": ` + referenceTimeStr + `, 14532 "withdrawn_at": ` + referenceTimeStr + ` 14533 }, 14534 "security_vulnerability": { 14535 "package": { 14536 "ecosystem": "e", 14537 "name": "n" 14538 }, 14539 "severity": "s", 14540 "vulnerable_version_range": "vvr", 14541 "first_patched_version": { 14542 "identifier": "i" 14543 } 14544 }, 14545 "url": "u", 14546 "html_url": "hu", 14547 "created_at": ` + referenceTimeStr + `, 14548 "updated_at": ` + referenceTimeStr + `, 14549 "dismissed_at": ` + referenceTimeStr + `, 14550 "dismissed_by": { 14551 "login": "l", 14552 "id": 1, 14553 "node_id": "n", 14554 "avatar_url": "a", 14555 "url": "u", 14556 "events_url": "e", 14557 "repos_url": "r" 14558 }, 14559 "dismissed_reason": "dr", 14560 "dismissed_comment": "dc", 14561 "fixed_at": ` + referenceTimeStr + `, 14562 "auto_dismissed_at": ` + referenceTimeStr + ` 14563 }, 14564 "repository": { 14565 "id": 1, 14566 "name": "n", 14567 "url": "s" 14568 }, 14569 "organization": { 14570 "name": "n", 14571 "company": "c", 14572 "blog": "b", 14573 "location": "loc", 14574 "email": "e", 14575 "twitter_username": "tu", 14576 "description": "d", 14577 "billing_email": "be", 14578 "is_verified": true, 14579 "has_organization_projects": true, 14580 "has_repository_projects": true, 14581 "default_repository_permission": "drp", 14582 "members_can_create_repositories": true, 14583 "members_can_create_public_repositories": false, 14584 "members_can_create_private_repositories": true, 14585 "members_can_create_internal_repositories": true, 14586 "members_allowed_repository_creation_type": "marct", 14587 "members_can_create_pages": true, 14588 "members_can_create_public_pages": false, 14589 "members_can_create_private_pages": true 14590 }, 14591 "enterprise": { 14592 "id": 1, 14593 "slug": "s", 14594 "name": "n", 14595 "node_id": "nid", 14596 "avatar_url": "au", 14597 "description": "d", 14598 "website_url": "wu", 14599 "html_url": "hu", 14600 "created_at": ` + referenceTimeStr + `, 14601 "updated_at": ` + referenceTimeStr + ` 14602 }, 14603 "sender": { 14604 "login": "l", 14605 "id": 1, 14606 "node_id": "n", 14607 "avatar_url": "a", 14608 "url": "u", 14609 "events_url": "e", 14610 "repos_url": "r" 14611 }, 14612 "installation": { 14613 "id": 1, 14614 "node_id": "nid", 14615 "app_id": 1, 14616 "app_slug": "as", 14617 "target_id": 1, 14618 "account": { 14619 "login": "l", 14620 "id": 1, 14621 "avatar_url": "a", 14622 "gravatar_id": "g", 14623 "name": "n", 14624 "company": "c", 14625 "blog": "b", 14626 "location": "l", 14627 "email": "e", 14628 "hireable": true, 14629 "bio": "b", 14630 "twitter_username": "t", 14631 "public_repos": 1, 14632 "followers": 1, 14633 "following": 1, 14634 "created_at": ` + referenceTimeStr + `, 14635 "suspended_at": ` + referenceTimeStr + `, 14636 "url": "u" 14637 }, 14638 "access_tokens_url": "atu", 14639 "repositories_url": "ru", 14640 "html_url": "hu", 14641 "target_type": "tt", 14642 "single_file_name": "sfn", 14643 "repository_selection": "rs", 14644 "events": [ 14645 "e" 14646 ], 14647 "single_file_paths": [ 14648 "s" 14649 ], 14650 "permissions": { 14651 "actions": "a", 14652 "administration": "ad", 14653 "checks": "c", 14654 "contents": "co", 14655 "content_references": "cr", 14656 "deployments": "d", 14657 "environments": "e", 14658 "issues": "i", 14659 "metadata": "md", 14660 "members": "m", 14661 "organization_administration": "oa", 14662 "organization_hooks": "oh", 14663 "organization_plan": "op", 14664 "organization_pre_receive_hooks": "opr", 14665 "organization_projects": "op", 14666 "organization_secrets": "os", 14667 "organization_self_hosted_runners": "osh", 14668 "organization_user_blocking": "oub", 14669 "packages": "pkg", 14670 "pages": "pg", 14671 "pull_requests": "pr", 14672 "repository_hooks": "rh", 14673 "repository_projects": "rp", 14674 "repository_pre_receive_hooks": "rprh", 14675 "secrets": "s", 14676 "secret_scanning_alerts": "ssa", 14677 "security_events": "se", 14678 "single_file": "sf", 14679 "statuses": "s", 14680 "team_discussions": "td", 14681 "vulnerability_alerts": "va", 14682 "workflows": "w" 14683 }, 14684 "created_at": ` + referenceTimeStr + `, 14685 "updated_at": ` + referenceTimeStr + `, 14686 "has_multiple_single_files": false, 14687 "suspended_by": { 14688 "login": "l", 14689 "id": 1, 14690 "avatar_url": "a", 14691 "gravatar_id": "g", 14692 "name": "n", 14693 "company": "c", 14694 "blog": "b", 14695 "location": "l", 14696 "email": "e", 14697 "hireable": true, 14698 "bio": "b", 14699 "twitter_username": "t", 14700 "public_repos": 1, 14701 "followers": 1, 14702 "following": 1, 14703 "created_at": ` + referenceTimeStr + `, 14704 "suspended_at": ` + referenceTimeStr + `, 14705 "url": "u" 14706 }, 14707 "suspended_at": ` + referenceTimeStr + ` 14708 } 14709 }` 14710 14711 testJSONMarshal(t, e, want) 14712 } 14713 14714 func TestForkEvent_Marshal(t *testing.T) { 14715 t.Parallel() 14716 testJSONMarshal(t, &ForkEvent{}, "{}") 14717 14718 u := &ForkEvent{ 14719 Forkee: &Repository{ 14720 ID: Ptr(int64(1)), 14721 URL: Ptr("s"), 14722 Name: Ptr("n"), 14723 }, 14724 Repo: &Repository{ 14725 ID: Ptr(int64(1)), 14726 URL: Ptr("s"), 14727 Name: Ptr("n"), 14728 }, 14729 Sender: &User{ 14730 Login: Ptr("l"), 14731 ID: Ptr(int64(1)), 14732 NodeID: Ptr("n"), 14733 URL: Ptr("u"), 14734 ReposURL: Ptr("r"), 14735 EventsURL: Ptr("e"), 14736 AvatarURL: Ptr("a"), 14737 }, 14738 Installation: &Installation{ 14739 ID: Ptr(int64(1)), 14740 NodeID: Ptr("nid"), 14741 AppID: Ptr(int64(1)), 14742 AppSlug: Ptr("as"), 14743 TargetID: Ptr(int64(1)), 14744 Account: &User{ 14745 Login: Ptr("l"), 14746 ID: Ptr(int64(1)), 14747 URL: Ptr("u"), 14748 AvatarURL: Ptr("a"), 14749 GravatarID: Ptr("g"), 14750 Name: Ptr("n"), 14751 Company: Ptr("c"), 14752 Blog: Ptr("b"), 14753 Location: Ptr("l"), 14754 Email: Ptr("e"), 14755 Hireable: Ptr(true), 14756 Bio: Ptr("b"), 14757 TwitterUsername: Ptr("t"), 14758 PublicRepos: Ptr(1), 14759 Followers: Ptr(1), 14760 Following: Ptr(1), 14761 CreatedAt: &Timestamp{referenceTime}, 14762 SuspendedAt: &Timestamp{referenceTime}, 14763 }, 14764 AccessTokensURL: Ptr("atu"), 14765 RepositoriesURL: Ptr("ru"), 14766 HTMLURL: Ptr("hu"), 14767 TargetType: Ptr("tt"), 14768 SingleFileName: Ptr("sfn"), 14769 RepositorySelection: Ptr("rs"), 14770 Events: []string{"e"}, 14771 SingleFilePaths: []string{"s"}, 14772 Permissions: &InstallationPermissions{ 14773 Actions: Ptr("a"), 14774 Administration: Ptr("ad"), 14775 Checks: Ptr("c"), 14776 Contents: Ptr("co"), 14777 ContentReferences: Ptr("cr"), 14778 Deployments: Ptr("d"), 14779 Environments: Ptr("e"), 14780 Issues: Ptr("i"), 14781 Metadata: Ptr("md"), 14782 Members: Ptr("m"), 14783 OrganizationAdministration: Ptr("oa"), 14784 OrganizationHooks: Ptr("oh"), 14785 OrganizationPlan: Ptr("op"), 14786 OrganizationPreReceiveHooks: Ptr("opr"), 14787 OrganizationProjects: Ptr("op"), 14788 OrganizationSecrets: Ptr("os"), 14789 OrganizationSelfHostedRunners: Ptr("osh"), 14790 OrganizationUserBlocking: Ptr("oub"), 14791 Packages: Ptr("pkg"), 14792 Pages: Ptr("pg"), 14793 PullRequests: Ptr("pr"), 14794 RepositoryHooks: Ptr("rh"), 14795 RepositoryProjects: Ptr("rp"), 14796 RepositoryPreReceiveHooks: Ptr("rprh"), 14797 Secrets: Ptr("s"), 14798 SecretScanningAlerts: Ptr("ssa"), 14799 SecurityEvents: Ptr("se"), 14800 SingleFile: Ptr("sf"), 14801 Statuses: Ptr("s"), 14802 TeamDiscussions: Ptr("td"), 14803 VulnerabilityAlerts: Ptr("va"), 14804 Workflows: Ptr("w"), 14805 }, 14806 CreatedAt: &Timestamp{referenceTime}, 14807 UpdatedAt: &Timestamp{referenceTime}, 14808 HasMultipleSingleFiles: Ptr(false), 14809 SuspendedBy: &User{ 14810 Login: Ptr("l"), 14811 ID: Ptr(int64(1)), 14812 URL: Ptr("u"), 14813 AvatarURL: Ptr("a"), 14814 GravatarID: Ptr("g"), 14815 Name: Ptr("n"), 14816 Company: Ptr("c"), 14817 Blog: Ptr("b"), 14818 Location: Ptr("l"), 14819 Email: Ptr("e"), 14820 Hireable: Ptr(true), 14821 Bio: Ptr("b"), 14822 TwitterUsername: Ptr("t"), 14823 PublicRepos: Ptr(1), 14824 Followers: Ptr(1), 14825 Following: Ptr(1), 14826 CreatedAt: &Timestamp{referenceTime}, 14827 SuspendedAt: &Timestamp{referenceTime}, 14828 }, 14829 SuspendedAt: &Timestamp{referenceTime}, 14830 }, 14831 } 14832 14833 want := `{ 14834 "forkee": { 14835 "id": 1, 14836 "name": "n", 14837 "url": "s" 14838 }, 14839 "repository": { 14840 "id": 1, 14841 "name": "n", 14842 "url": "s" 14843 }, 14844 "sender": { 14845 "login": "l", 14846 "id": 1, 14847 "node_id": "n", 14848 "avatar_url": "a", 14849 "url": "u", 14850 "events_url": "e", 14851 "repos_url": "r" 14852 }, 14853 "installation": { 14854 "id": 1, 14855 "node_id": "nid", 14856 "app_id": 1, 14857 "app_slug": "as", 14858 "target_id": 1, 14859 "account": { 14860 "login": "l", 14861 "id": 1, 14862 "avatar_url": "a", 14863 "gravatar_id": "g", 14864 "name": "n", 14865 "company": "c", 14866 "blog": "b", 14867 "location": "l", 14868 "email": "e", 14869 "hireable": true, 14870 "bio": "b", 14871 "twitter_username": "t", 14872 "public_repos": 1, 14873 "followers": 1, 14874 "following": 1, 14875 "created_at": ` + referenceTimeStr + `, 14876 "suspended_at": ` + referenceTimeStr + `, 14877 "url": "u" 14878 }, 14879 "access_tokens_url": "atu", 14880 "repositories_url": "ru", 14881 "html_url": "hu", 14882 "target_type": "tt", 14883 "single_file_name": "sfn", 14884 "repository_selection": "rs", 14885 "events": [ 14886 "e" 14887 ], 14888 "single_file_paths": [ 14889 "s" 14890 ], 14891 "permissions": { 14892 "actions": "a", 14893 "administration": "ad", 14894 "checks": "c", 14895 "contents": "co", 14896 "content_references": "cr", 14897 "deployments": "d", 14898 "environments": "e", 14899 "issues": "i", 14900 "metadata": "md", 14901 "members": "m", 14902 "organization_administration": "oa", 14903 "organization_hooks": "oh", 14904 "organization_plan": "op", 14905 "organization_pre_receive_hooks": "opr", 14906 "organization_projects": "op", 14907 "organization_secrets": "os", 14908 "organization_self_hosted_runners": "osh", 14909 "organization_user_blocking": "oub", 14910 "packages": "pkg", 14911 "pages": "pg", 14912 "pull_requests": "pr", 14913 "repository_hooks": "rh", 14914 "repository_projects": "rp", 14915 "repository_pre_receive_hooks": "rprh", 14916 "secrets": "s", 14917 "secret_scanning_alerts": "ssa", 14918 "security_events": "se", 14919 "single_file": "sf", 14920 "statuses": "s", 14921 "team_discussions": "td", 14922 "vulnerability_alerts": "va", 14923 "workflows": "w" 14924 }, 14925 "created_at": ` + referenceTimeStr + `, 14926 "updated_at": ` + referenceTimeStr + `, 14927 "has_multiple_single_files": false, 14928 "suspended_by": { 14929 "login": "l", 14930 "id": 1, 14931 "avatar_url": "a", 14932 "gravatar_id": "g", 14933 "name": "n", 14934 "company": "c", 14935 "blog": "b", 14936 "location": "l", 14937 "email": "e", 14938 "hireable": true, 14939 "bio": "b", 14940 "twitter_username": "t", 14941 "public_repos": 1, 14942 "followers": 1, 14943 "following": 1, 14944 "created_at": ` + referenceTimeStr + `, 14945 "suspended_at": ` + referenceTimeStr + `, 14946 "url": "u" 14947 }, 14948 "suspended_at": ` + referenceTimeStr + ` 14949 } 14950 }` 14951 14952 testJSONMarshal(t, u, want) 14953 } 14954 14955 func TestGitHubAppAuthorizationEvent_Marshal(t *testing.T) { 14956 t.Parallel() 14957 testJSONMarshal(t, &GitHubAppAuthorizationEvent{}, "{}") 14958 14959 u := &GitHubAppAuthorizationEvent{ 14960 Action: Ptr("a"), 14961 Sender: &User{ 14962 Login: Ptr("l"), 14963 ID: Ptr(int64(1)), 14964 NodeID: Ptr("n"), 14965 URL: Ptr("u"), 14966 ReposURL: Ptr("r"), 14967 EventsURL: Ptr("e"), 14968 AvatarURL: Ptr("a"), 14969 }, 14970 } 14971 14972 want := `{ 14973 "action": "a", 14974 "sender": { 14975 "login": "l", 14976 "id": 1, 14977 "node_id": "n", 14978 "avatar_url": "a", 14979 "url": "u", 14980 "events_url": "e", 14981 "repos_url": "r" 14982 } 14983 }` 14984 14985 testJSONMarshal(t, u, want) 14986 } 14987 14988 func TestInstallationEvent_Marshal(t *testing.T) { 14989 t.Parallel() 14990 testJSONMarshal(t, &InstallationEvent{}, "{}") 14991 14992 u := &InstallationEvent{ 14993 Action: Ptr("a"), 14994 Repositories: []*Repository{ 14995 { 14996 ID: Ptr(int64(1)), 14997 URL: Ptr("u"), 14998 Name: Ptr("n"), 14999 }, 15000 }, 15001 Sender: &User{ 15002 Login: Ptr("l"), 15003 ID: Ptr(int64(1)), 15004 NodeID: Ptr("n"), 15005 URL: Ptr("u"), 15006 ReposURL: Ptr("r"), 15007 EventsURL: Ptr("e"), 15008 AvatarURL: Ptr("a"), 15009 }, 15010 Installation: &Installation{ 15011 ID: Ptr(int64(1)), 15012 NodeID: Ptr("nid"), 15013 AppID: Ptr(int64(1)), 15014 AppSlug: Ptr("as"), 15015 TargetID: Ptr(int64(1)), 15016 Account: &User{ 15017 Login: Ptr("l"), 15018 ID: Ptr(int64(1)), 15019 URL: Ptr("u"), 15020 AvatarURL: Ptr("a"), 15021 GravatarID: Ptr("g"), 15022 Name: Ptr("n"), 15023 Company: Ptr("c"), 15024 Blog: Ptr("b"), 15025 Location: Ptr("l"), 15026 Email: Ptr("e"), 15027 Hireable: Ptr(true), 15028 Bio: Ptr("b"), 15029 TwitterUsername: Ptr("t"), 15030 PublicRepos: Ptr(1), 15031 Followers: Ptr(1), 15032 Following: Ptr(1), 15033 CreatedAt: &Timestamp{referenceTime}, 15034 SuspendedAt: &Timestamp{referenceTime}, 15035 }, 15036 AccessTokensURL: Ptr("atu"), 15037 RepositoriesURL: Ptr("ru"), 15038 HTMLURL: Ptr("hu"), 15039 TargetType: Ptr("tt"), 15040 SingleFileName: Ptr("sfn"), 15041 RepositorySelection: Ptr("rs"), 15042 Events: []string{"e"}, 15043 SingleFilePaths: []string{"s"}, 15044 Permissions: &InstallationPermissions{ 15045 Actions: Ptr("a"), 15046 Administration: Ptr("ad"), 15047 Checks: Ptr("c"), 15048 Contents: Ptr("co"), 15049 ContentReferences: Ptr("cr"), 15050 Deployments: Ptr("d"), 15051 Environments: Ptr("e"), 15052 Issues: Ptr("i"), 15053 Metadata: Ptr("md"), 15054 Members: Ptr("m"), 15055 OrganizationAdministration: Ptr("oa"), 15056 OrganizationHooks: Ptr("oh"), 15057 OrganizationPlan: Ptr("op"), 15058 OrganizationPreReceiveHooks: Ptr("opr"), 15059 OrganizationProjects: Ptr("op"), 15060 OrganizationSecrets: Ptr("os"), 15061 OrganizationSelfHostedRunners: Ptr("osh"), 15062 OrganizationUserBlocking: Ptr("oub"), 15063 Packages: Ptr("pkg"), 15064 Pages: Ptr("pg"), 15065 PullRequests: Ptr("pr"), 15066 RepositoryHooks: Ptr("rh"), 15067 RepositoryProjects: Ptr("rp"), 15068 RepositoryPreReceiveHooks: Ptr("rprh"), 15069 Secrets: Ptr("s"), 15070 SecretScanningAlerts: Ptr("ssa"), 15071 SecurityEvents: Ptr("se"), 15072 SingleFile: Ptr("sf"), 15073 Statuses: Ptr("s"), 15074 TeamDiscussions: Ptr("td"), 15075 VulnerabilityAlerts: Ptr("va"), 15076 Workflows: Ptr("w"), 15077 }, 15078 CreatedAt: &Timestamp{referenceTime}, 15079 UpdatedAt: &Timestamp{referenceTime}, 15080 HasMultipleSingleFiles: Ptr(false), 15081 SuspendedBy: &User{ 15082 Login: Ptr("l"), 15083 ID: Ptr(int64(1)), 15084 URL: Ptr("u"), 15085 AvatarURL: Ptr("a"), 15086 GravatarID: Ptr("g"), 15087 Name: Ptr("n"), 15088 Company: Ptr("c"), 15089 Blog: Ptr("b"), 15090 Location: Ptr("l"), 15091 Email: Ptr("e"), 15092 Hireable: Ptr(true), 15093 Bio: Ptr("b"), 15094 TwitterUsername: Ptr("t"), 15095 PublicRepos: Ptr(1), 15096 Followers: Ptr(1), 15097 Following: Ptr(1), 15098 CreatedAt: &Timestamp{referenceTime}, 15099 SuspendedAt: &Timestamp{referenceTime}, 15100 }, 15101 SuspendedAt: &Timestamp{referenceTime}, 15102 }, 15103 } 15104 15105 want := `{ 15106 "action": "a", 15107 "repositories": [ 15108 { 15109 "id":1, 15110 "name":"n", 15111 "url":"u" 15112 } 15113 ], 15114 "sender": { 15115 "login": "l", 15116 "id": 1, 15117 "node_id": "n", 15118 "avatar_url": "a", 15119 "url": "u", 15120 "events_url": "e", 15121 "repos_url": "r" 15122 }, 15123 "installation": { 15124 "id": 1, 15125 "node_id": "nid", 15126 "app_id": 1, 15127 "app_slug": "as", 15128 "target_id": 1, 15129 "account": { 15130 "login": "l", 15131 "id": 1, 15132 "avatar_url": "a", 15133 "gravatar_id": "g", 15134 "name": "n", 15135 "company": "c", 15136 "blog": "b", 15137 "location": "l", 15138 "email": "e", 15139 "hireable": true, 15140 "bio": "b", 15141 "twitter_username": "t", 15142 "public_repos": 1, 15143 "followers": 1, 15144 "following": 1, 15145 "created_at": ` + referenceTimeStr + `, 15146 "suspended_at": ` + referenceTimeStr + `, 15147 "url": "u" 15148 }, 15149 "access_tokens_url": "atu", 15150 "repositories_url": "ru", 15151 "html_url": "hu", 15152 "target_type": "tt", 15153 "single_file_name": "sfn", 15154 "repository_selection": "rs", 15155 "events": [ 15156 "e" 15157 ], 15158 "single_file_paths": [ 15159 "s" 15160 ], 15161 "permissions": { 15162 "actions": "a", 15163 "administration": "ad", 15164 "checks": "c", 15165 "contents": "co", 15166 "content_references": "cr", 15167 "deployments": "d", 15168 "environments": "e", 15169 "issues": "i", 15170 "metadata": "md", 15171 "members": "m", 15172 "organization_administration": "oa", 15173 "organization_hooks": "oh", 15174 "organization_plan": "op", 15175 "organization_pre_receive_hooks": "opr", 15176 "organization_projects": "op", 15177 "organization_secrets": "os", 15178 "organization_self_hosted_runners": "osh", 15179 "organization_user_blocking": "oub", 15180 "packages": "pkg", 15181 "pages": "pg", 15182 "pull_requests": "pr", 15183 "repository_hooks": "rh", 15184 "repository_projects": "rp", 15185 "repository_pre_receive_hooks": "rprh", 15186 "secrets": "s", 15187 "secret_scanning_alerts": "ssa", 15188 "security_events": "se", 15189 "single_file": "sf", 15190 "statuses": "s", 15191 "team_discussions": "td", 15192 "vulnerability_alerts": "va", 15193 "workflows": "w" 15194 }, 15195 "created_at": ` + referenceTimeStr + `, 15196 "updated_at": ` + referenceTimeStr + `, 15197 "has_multiple_single_files": false, 15198 "suspended_by": { 15199 "login": "l", 15200 "id": 1, 15201 "avatar_url": "a", 15202 "gravatar_id": "g", 15203 "name": "n", 15204 "company": "c", 15205 "blog": "b", 15206 "location": "l", 15207 "email": "e", 15208 "hireable": true, 15209 "bio": "b", 15210 "twitter_username": "t", 15211 "public_repos": 1, 15212 "followers": 1, 15213 "following": 1, 15214 "created_at": ` + referenceTimeStr + `, 15215 "suspended_at": ` + referenceTimeStr + `, 15216 "url": "u" 15217 }, 15218 "suspended_at": ` + referenceTimeStr + ` 15219 } 15220 }` 15221 15222 testJSONMarshal(t, u, want) 15223 } 15224 15225 func TestHeadCommit_Marshal(t *testing.T) { 15226 t.Parallel() 15227 testJSONMarshal(t, &HeadCommit{}, "{}") 15228 15229 u := &HeadCommit{ 15230 Message: Ptr("m"), 15231 Author: &CommitAuthor{ 15232 Date: &Timestamp{referenceTime}, 15233 Name: Ptr("n"), 15234 Email: Ptr("e"), 15235 Login: Ptr("u"), 15236 }, 15237 URL: Ptr("u"), 15238 Distinct: Ptr(true), 15239 SHA: Ptr("s"), 15240 ID: Ptr("id"), 15241 TreeID: Ptr("tid"), 15242 Timestamp: &Timestamp{referenceTime}, 15243 Committer: &CommitAuthor{ 15244 Date: &Timestamp{referenceTime}, 15245 Name: Ptr("n"), 15246 Email: Ptr("e"), 15247 Login: Ptr("u"), 15248 }, 15249 Added: []string{"a"}, 15250 Removed: []string{"r"}, 15251 Modified: []string{"m"}, 15252 } 15253 15254 want := `{ 15255 "message": "m", 15256 "author": { 15257 "date": ` + referenceTimeStr + `, 15258 "name": "n", 15259 "email": "e", 15260 "username": "u" 15261 }, 15262 "url": "u", 15263 "distinct": true, 15264 "sha": "s", 15265 "id": "id", 15266 "tree_id": "tid", 15267 "timestamp": ` + referenceTimeStr + `, 15268 "committer": { 15269 "date": ` + referenceTimeStr + `, 15270 "name": "n", 15271 "email": "e", 15272 "username": "u" 15273 }, 15274 "added": [ 15275 "a" 15276 ], 15277 "removed": [ 15278 "r" 15279 ], 15280 "modified": [ 15281 "m" 15282 ] 15283 }` 15284 15285 testJSONMarshal(t, u, want) 15286 } 15287 15288 func TestPushEventRepository_Marshal(t *testing.T) { 15289 t.Parallel() 15290 testJSONMarshal(t, &PushEventRepository{}, "{}") 15291 15292 u := &PushEventRepository{ 15293 ID: Ptr(int64(1)), 15294 NodeID: Ptr("nid"), 15295 Name: Ptr("n"), 15296 FullName: Ptr("fn"), 15297 Owner: &User{ 15298 Login: Ptr("l"), 15299 ID: Ptr(int64(1)), 15300 AvatarURL: Ptr("a"), 15301 GravatarID: Ptr("g"), 15302 Name: Ptr("n"), 15303 Company: Ptr("c"), 15304 Blog: Ptr("b"), 15305 Location: Ptr("l"), 15306 Email: Ptr("e"), 15307 Hireable: Ptr(true), 15308 PublicRepos: Ptr(1), 15309 Followers: Ptr(1), 15310 Following: Ptr(1), 15311 CreatedAt: &Timestamp{referenceTime}, 15312 URL: Ptr("u"), 15313 }, 15314 Private: Ptr(true), 15315 Description: Ptr("d"), 15316 Fork: Ptr(true), 15317 CreatedAt: &Timestamp{referenceTime}, 15318 PushedAt: &Timestamp{referenceTime}, 15319 UpdatedAt: &Timestamp{referenceTime}, 15320 Homepage: Ptr("h"), 15321 PullsURL: Ptr("p"), 15322 Size: Ptr(1), 15323 StargazersCount: Ptr(1), 15324 WatchersCount: Ptr(1), 15325 Language: Ptr("l"), 15326 HasIssues: Ptr(true), 15327 HasDownloads: Ptr(true), 15328 HasWiki: Ptr(true), 15329 HasPages: Ptr(true), 15330 ForksCount: Ptr(1), 15331 Archived: Ptr(true), 15332 Disabled: Ptr(true), 15333 OpenIssuesCount: Ptr(1), 15334 DefaultBranch: Ptr("d"), 15335 MasterBranch: Ptr("m"), 15336 Organization: Ptr("o"), 15337 URL: Ptr("u"), 15338 ArchiveURL: Ptr("a"), 15339 HTMLURL: Ptr("h"), 15340 StatusesURL: Ptr("s"), 15341 GitURL: Ptr("g"), 15342 SSHURL: Ptr("s"), 15343 CloneURL: Ptr("c"), 15344 SVNURL: Ptr("s"), 15345 Topics: []string{"octocat", "api"}, 15346 } 15347 15348 want := `{ 15349 "id": 1, 15350 "node_id": "nid", 15351 "name": "n", 15352 "full_name": "fn", 15353 "owner": { 15354 "login": "l", 15355 "id": 1, 15356 "avatar_url": "a", 15357 "gravatar_id": "g", 15358 "name": "n", 15359 "company": "c", 15360 "blog": "b", 15361 "location": "l", 15362 "email": "e", 15363 "hireable": true, 15364 "public_repos": 1, 15365 "followers": 1, 15366 "following": 1, 15367 "created_at": ` + referenceTimeStr + `, 15368 "url": "u" 15369 }, 15370 "private": true, 15371 "description": "d", 15372 "fork": true, 15373 "created_at": ` + referenceTimeStr + `, 15374 "pushed_at": ` + referenceTimeStr + `, 15375 "updated_at": ` + referenceTimeStr + `, 15376 "homepage": "h", 15377 "pulls_url": "p", 15378 "size": 1, 15379 "stargazers_count": 1, 15380 "watchers_count": 1, 15381 "language": "l", 15382 "has_issues": true, 15383 "has_downloads": true, 15384 "has_wiki": true, 15385 "has_pages": true, 15386 "forks_count": 1, 15387 "archived": true, 15388 "disabled": true, 15389 "open_issues_count": 1, 15390 "default_branch": "d", 15391 "master_branch": "m", 15392 "organization": "o", 15393 "url": "u", 15394 "archive_url": "a", 15395 "html_url": "h", 15396 "statuses_url": "s", 15397 "git_url": "g", 15398 "ssh_url": "s", 15399 "clone_url": "c", 15400 "svn_url": "s", 15401 "topics": ["octocat","api"] 15402 }` 15403 15404 testJSONMarshal(t, u, want) 15405 } 15406 15407 func TestPushEventRepoOwner_Marshal(t *testing.T) { 15408 t.Parallel() 15409 testJSONMarshal(t, &PushEventRepoOwner{}, "{}") 15410 15411 u := &PushEventRepoOwner{ 15412 Name: Ptr("n"), 15413 Email: Ptr("e"), 15414 } 15415 15416 want := `{ 15417 "name": "n", 15418 "email": "e" 15419 }` 15420 15421 testJSONMarshal(t, u, want) 15422 } 15423 15424 func TestProjectV2Event_Marshal(t *testing.T) { 15425 t.Parallel() 15426 testJSONMarshal(t, &ProjectV2Event{}, "{}") 15427 15428 u := &ProjectV2Event{ 15429 Action: Ptr("a"), 15430 ProjectsV2: &ProjectV2{ 15431 ID: Ptr(int64(1)), 15432 NodeID: Ptr("nid"), 15433 Owner: &User{ 15434 Login: Ptr("l"), 15435 ID: Ptr(int64(1)), 15436 NodeID: Ptr("n"), 15437 URL: Ptr("u"), 15438 ReposURL: Ptr("r"), 15439 EventsURL: Ptr("e"), 15440 AvatarURL: Ptr("a"), 15441 }, 15442 Creator: &User{ 15443 Login: Ptr("l"), 15444 ID: Ptr(int64(1)), 15445 NodeID: Ptr("n"), 15446 URL: Ptr("u"), 15447 ReposURL: Ptr("r"), 15448 EventsURL: Ptr("e"), 15449 AvatarURL: Ptr("a"), 15450 }, 15451 Title: Ptr("t"), 15452 Description: Ptr("d"), 15453 Public: Ptr(true), 15454 ClosedAt: &Timestamp{referenceTime}, 15455 CreatedAt: &Timestamp{referenceTime}, 15456 UpdatedAt: &Timestamp{referenceTime}, 15457 DeletedAt: &Timestamp{referenceTime}, 15458 Number: Ptr(1), 15459 ShortDescription: Ptr("sd"), 15460 DeletedBy: &User{ 15461 Login: Ptr("l"), 15462 ID: Ptr(int64(1)), 15463 NodeID: Ptr("n"), 15464 URL: Ptr("u"), 15465 ReposURL: Ptr("r"), 15466 EventsURL: Ptr("e"), 15467 AvatarURL: Ptr("a"), 15468 }, 15469 }, 15470 Org: &Organization{ 15471 BillingEmail: Ptr("be"), 15472 Blog: Ptr("b"), 15473 Company: Ptr("c"), 15474 Email: Ptr("e"), 15475 TwitterUsername: Ptr("tu"), 15476 Location: Ptr("loc"), 15477 Name: Ptr("n"), 15478 Description: Ptr("d"), 15479 IsVerified: Ptr(true), 15480 HasOrganizationProjects: Ptr(true), 15481 HasRepositoryProjects: Ptr(true), 15482 DefaultRepoPermission: Ptr("drp"), 15483 MembersCanCreateRepos: Ptr(true), 15484 MembersCanCreateInternalRepos: Ptr(true), 15485 MembersCanCreatePrivateRepos: Ptr(true), 15486 MembersCanCreatePublicRepos: Ptr(false), 15487 MembersAllowedRepositoryCreationType: Ptr("marct"), 15488 MembersCanCreatePages: Ptr(true), 15489 MembersCanCreatePublicPages: Ptr(false), 15490 MembersCanCreatePrivatePages: Ptr(true), 15491 }, 15492 Sender: &User{ 15493 Login: Ptr("l"), 15494 ID: Ptr(int64(1)), 15495 NodeID: Ptr("n"), 15496 URL: Ptr("u"), 15497 ReposURL: Ptr("r"), 15498 EventsURL: Ptr("e"), 15499 AvatarURL: Ptr("a"), 15500 }, 15501 Installation: &Installation{ 15502 ID: Ptr(int64(1)), 15503 NodeID: Ptr("nid"), 15504 AppID: Ptr(int64(1)), 15505 AppSlug: Ptr("as"), 15506 TargetID: Ptr(int64(1)), 15507 Account: &User{ 15508 Login: Ptr("l"), 15509 ID: Ptr(int64(1)), 15510 URL: Ptr("u"), 15511 AvatarURL: Ptr("a"), 15512 GravatarID: Ptr("g"), 15513 Name: Ptr("n"), 15514 Company: Ptr("c"), 15515 Blog: Ptr("b"), 15516 Location: Ptr("l"), 15517 Email: Ptr("e"), 15518 Hireable: Ptr(true), 15519 Bio: Ptr("b"), 15520 TwitterUsername: Ptr("t"), 15521 PublicRepos: Ptr(1), 15522 Followers: Ptr(1), 15523 Following: Ptr(1), 15524 CreatedAt: &Timestamp{referenceTime}, 15525 SuspendedAt: &Timestamp{referenceTime}, 15526 }, 15527 }, 15528 } 15529 15530 want := `{ 15531 "action": "a", 15532 "projects_v2": { 15533 "id": 1, 15534 "node_id": "nid", 15535 "owner": { 15536 "login": "l", 15537 "id": 1, 15538 "node_id": "n", 15539 "avatar_url": "a", 15540 "url": "u", 15541 "events_url": "e", 15542 "repos_url": "r" 15543 }, 15544 "creator": { 15545 "login": "l", 15546 "id": 1, 15547 "node_id": "n", 15548 "avatar_url": "a", 15549 "url": "u", 15550 "events_url": "e", 15551 "repos_url": "r" 15552 }, 15553 "title": "t", 15554 "description": "d", 15555 "public": true, 15556 "closed_at": ` + referenceTimeStr + `, 15557 "created_at": ` + referenceTimeStr + `, 15558 "updated_at": ` + referenceTimeStr + `, 15559 "deleted_at": ` + referenceTimeStr + `, 15560 "number": 1, 15561 "short_description": "sd", 15562 "deleted_by": { 15563 "login": "l", 15564 "id": 1, 15565 "node_id": "n", 15566 "avatar_url": "a", 15567 "url": "u", 15568 "events_url": "e", 15569 "repos_url": "r" 15570 } 15571 }, 15572 "organization": { 15573 "name": "n", 15574 "company": "c", 15575 "blog": "b", 15576 "location": "loc", 15577 "email": "e", 15578 "twitter_username": "tu", 15579 "description": "d", 15580 "billing_email": "be", 15581 "is_verified": true, 15582 "has_organization_projects": true, 15583 "has_repository_projects": true, 15584 "default_repository_permission": "drp", 15585 "members_can_create_repositories": true, 15586 "members_can_create_public_repositories": false, 15587 "members_can_create_private_repositories": true, 15588 "members_can_create_internal_repositories": true, 15589 "members_allowed_repository_creation_type": "marct", 15590 "members_can_create_pages": true, 15591 "members_can_create_public_pages": false, 15592 "members_can_create_private_pages": true 15593 }, 15594 "sender": { 15595 "login": "l", 15596 "id": 1, 15597 "node_id": "n", 15598 "avatar_url": "a", 15599 "url": "u", 15600 "events_url": "e", 15601 "repos_url": "r" 15602 }, 15603 "installation": { 15604 "id": 1, 15605 "node_id": "nid", 15606 "app_id": 1, 15607 "app_slug": "as", 15608 "target_id": 1, 15609 "account": { 15610 "login": "l", 15611 "id": 1, 15612 "avatar_url": "a", 15613 "gravatar_id": "g", 15614 "name": "n", 15615 "company": "c", 15616 "blog": "b", 15617 "location": "l", 15618 "email": "e", 15619 "hireable": true, 15620 "bio": "b", 15621 "twitter_username": "t", 15622 "public_repos": 1, 15623 "followers": 1, 15624 "following": 1, 15625 "created_at": ` + referenceTimeStr + `, 15626 "suspended_at": ` + referenceTimeStr + `, 15627 "url": "u" 15628 } 15629 } 15630 }` 15631 15632 testJSONMarshal(t, u, want) 15633 } 15634 15635 func TestProjectV2ItemEvent_Marshal(t *testing.T) { 15636 t.Parallel() 15637 testJSONMarshal(t, &ProjectV2ItemEvent{}, "{}") 15638 15639 u := &ProjectV2ItemEvent{ 15640 Action: Ptr("a"), 15641 Changes: &ProjectV2ItemChange{ 15642 ArchivedAt: &ArchivedAt{ 15643 From: &Timestamp{referenceTime}, 15644 To: &Timestamp{referenceTime}, 15645 }, 15646 }, 15647 ProjectV2Item: &ProjectV2Item{ 15648 ID: Ptr(int64(1)), 15649 NodeID: Ptr("nid"), 15650 ProjectNodeID: Ptr("pnid"), 15651 ContentNodeID: Ptr("cnid"), 15652 ContentType: Ptr("ct"), 15653 Creator: &User{ 15654 Login: Ptr("l"), 15655 ID: Ptr(int64(1)), 15656 NodeID: Ptr("n"), 15657 URL: Ptr("u"), 15658 ReposURL: Ptr("r"), 15659 EventsURL: Ptr("e"), 15660 AvatarURL: Ptr("a"), 15661 }, 15662 CreatedAt: &Timestamp{referenceTime}, 15663 UpdatedAt: &Timestamp{referenceTime}, 15664 ArchivedAt: &Timestamp{referenceTime}, 15665 }, 15666 Org: &Organization{ 15667 BillingEmail: Ptr("be"), 15668 Blog: Ptr("b"), 15669 Company: Ptr("c"), 15670 Email: Ptr("e"), 15671 TwitterUsername: Ptr("tu"), 15672 Location: Ptr("loc"), 15673 Name: Ptr("n"), 15674 Description: Ptr("d"), 15675 IsVerified: Ptr(true), 15676 HasOrganizationProjects: Ptr(true), 15677 HasRepositoryProjects: Ptr(true), 15678 DefaultRepoPermission: Ptr("drp"), 15679 MembersCanCreateRepos: Ptr(true), 15680 MembersCanCreateInternalRepos: Ptr(true), 15681 MembersCanCreatePrivateRepos: Ptr(true), 15682 MembersCanCreatePublicRepos: Ptr(false), 15683 MembersAllowedRepositoryCreationType: Ptr("marct"), 15684 MembersCanCreatePages: Ptr(true), 15685 MembersCanCreatePublicPages: Ptr(false), 15686 MembersCanCreatePrivatePages: Ptr(true), 15687 }, 15688 Sender: &User{ 15689 Login: Ptr("l"), 15690 ID: Ptr(int64(1)), 15691 NodeID: Ptr("n"), 15692 URL: Ptr("u"), 15693 ReposURL: Ptr("r"), 15694 EventsURL: Ptr("e"), 15695 AvatarURL: Ptr("a"), 15696 }, 15697 Installation: &Installation{ 15698 ID: Ptr(int64(1)), 15699 NodeID: Ptr("nid"), 15700 AppID: Ptr(int64(1)), 15701 AppSlug: Ptr("as"), 15702 TargetID: Ptr(int64(1)), 15703 Account: &User{ 15704 Login: Ptr("l"), 15705 ID: Ptr(int64(1)), 15706 URL: Ptr("u"), 15707 AvatarURL: Ptr("a"), 15708 GravatarID: Ptr("g"), 15709 Name: Ptr("n"), 15710 Company: Ptr("c"), 15711 Blog: Ptr("b"), 15712 Location: Ptr("l"), 15713 Email: Ptr("e"), 15714 Hireable: Ptr(true), 15715 Bio: Ptr("b"), 15716 TwitterUsername: Ptr("t"), 15717 PublicRepos: Ptr(1), 15718 Followers: Ptr(1), 15719 Following: Ptr(1), 15720 CreatedAt: &Timestamp{referenceTime}, 15721 SuspendedAt: &Timestamp{referenceTime}, 15722 }, 15723 }, 15724 } 15725 15726 want := `{ 15727 "action": "a", 15728 "changes": { 15729 "archived_at": { 15730 "from": ` + referenceTimeStr + `, 15731 "to": ` + referenceTimeStr + ` 15732 } 15733 }, 15734 "projects_v2_item": { 15735 "id": 1, 15736 "node_id": "nid", 15737 "project_node_id": "pnid", 15738 "content_node_id": "cnid", 15739 "content_type": "ct", 15740 "creator": { 15741 "login": "l", 15742 "id": 1, 15743 "node_id": "n", 15744 "avatar_url": "a", 15745 "url": "u", 15746 "events_url": "e", 15747 "repos_url": "r" 15748 }, 15749 "created_at": ` + referenceTimeStr + `, 15750 "updated_at": ` + referenceTimeStr + `, 15751 "archived_at": ` + referenceTimeStr + ` 15752 }, 15753 "organization": { 15754 "name": "n", 15755 "company": "c", 15756 "blog": "b", 15757 "location": "loc", 15758 "email": "e", 15759 "twitter_username": "tu", 15760 "description": "d", 15761 "billing_email": "be", 15762 "is_verified": true, 15763 "has_organization_projects": true, 15764 "has_repository_projects": true, 15765 "default_repository_permission": "drp", 15766 "members_can_create_repositories": true, 15767 "members_can_create_public_repositories": false, 15768 "members_can_create_private_repositories": true, 15769 "members_can_create_internal_repositories": true, 15770 "members_allowed_repository_creation_type": "marct", 15771 "members_can_create_pages": true, 15772 "members_can_create_public_pages": false, 15773 "members_can_create_private_pages": true 15774 }, 15775 "sender": { 15776 "login": "l", 15777 "id": 1, 15778 "node_id": "n", 15779 "avatar_url": "a", 15780 "url": "u", 15781 "events_url": "e", 15782 "repos_url": "r" 15783 }, 15784 "installation": { 15785 "id": 1, 15786 "node_id": "nid", 15787 "app_id": 1, 15788 "app_slug": "as", 15789 "target_id": 1, 15790 "account": { 15791 "login": "l", 15792 "id": 1, 15793 "avatar_url": "a", 15794 "gravatar_id": "g", 15795 "name": "n", 15796 "company": "c", 15797 "blog": "b", 15798 "location": "l", 15799 "email": "e", 15800 "hireable": true, 15801 "bio": "b", 15802 "twitter_username": "t", 15803 "public_repos": 1, 15804 "followers": 1, 15805 "following": 1, 15806 "created_at": ` + referenceTimeStr + `, 15807 "suspended_at": ` + referenceTimeStr + `, 15808 "url": "u" 15809 } 15810 } 15811 }` 15812 15813 testJSONMarshal(t, u, want) 15814 } 15815 15816 func TestPullRequestEvent_Marshal(t *testing.T) { 15817 t.Parallel() 15818 testJSONMarshal(t, &PullRequestEvent{}, "{}") 15819 15820 u := &PullRequestEvent{ 15821 Action: Ptr("a"), 15822 Assignee: &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 Number: Ptr(1), 15832 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 15833 Changes: &EditChange{ 15834 Title: &EditTitle{ 15835 From: Ptr("TitleFrom"), 15836 }, 15837 Body: &EditBody{ 15838 From: Ptr("BodyFrom"), 15839 }, 15840 Base: &EditBase{ 15841 Ref: &EditRef{ 15842 From: Ptr("BaseRefFrom"), 15843 }, 15844 SHA: &EditSHA{ 15845 From: Ptr("BaseSHAFrom"), 15846 }, 15847 }, 15848 }, 15849 RequestedReviewer: &User{ 15850 Login: Ptr("l"), 15851 ID: Ptr(int64(1)), 15852 NodeID: Ptr("n"), 15853 URL: Ptr("u"), 15854 ReposURL: Ptr("r"), 15855 EventsURL: Ptr("e"), 15856 AvatarURL: Ptr("a"), 15857 }, 15858 RequestedTeam: &Team{ID: Ptr(int64(1))}, 15859 Label: &Label{ID: Ptr(int64(1))}, 15860 Before: Ptr("before"), 15861 After: Ptr("after"), 15862 Repo: &Repository{ 15863 ID: Ptr(int64(1)), 15864 URL: Ptr("s"), 15865 Name: Ptr("n"), 15866 }, 15867 PerformedViaGithubApp: &App{ 15868 ID: Ptr(int64(1)), 15869 NodeID: Ptr("n"), 15870 Slug: Ptr("s"), 15871 Name: Ptr("n"), 15872 Description: Ptr("d"), 15873 ExternalURL: Ptr("e"), 15874 HTMLURL: Ptr("h"), 15875 }, 15876 Organization: &Organization{ 15877 BillingEmail: Ptr("be"), 15878 Blog: Ptr("b"), 15879 Company: Ptr("c"), 15880 Email: Ptr("e"), 15881 TwitterUsername: Ptr("tu"), 15882 Location: Ptr("loc"), 15883 Name: Ptr("n"), 15884 Description: Ptr("d"), 15885 IsVerified: Ptr(true), 15886 HasOrganizationProjects: Ptr(true), 15887 HasRepositoryProjects: Ptr(true), 15888 DefaultRepoPermission: Ptr("drp"), 15889 MembersCanCreateRepos: Ptr(true), 15890 MembersCanCreateInternalRepos: Ptr(true), 15891 MembersCanCreatePrivateRepos: Ptr(true), 15892 MembersCanCreatePublicRepos: Ptr(false), 15893 MembersAllowedRepositoryCreationType: Ptr("marct"), 15894 MembersCanCreatePages: Ptr(true), 15895 MembersCanCreatePublicPages: Ptr(false), 15896 MembersCanCreatePrivatePages: Ptr(true), 15897 }, 15898 Sender: &User{ 15899 Login: Ptr("l"), 15900 ID: Ptr(int64(1)), 15901 NodeID: Ptr("n"), 15902 URL: Ptr("u"), 15903 ReposURL: Ptr("r"), 15904 EventsURL: Ptr("e"), 15905 AvatarURL: Ptr("a"), 15906 }, 15907 Installation: &Installation{ 15908 ID: Ptr(int64(1)), 15909 NodeID: Ptr("nid"), 15910 AppID: Ptr(int64(1)), 15911 AppSlug: Ptr("as"), 15912 TargetID: Ptr(int64(1)), 15913 Account: &User{ 15914 Login: Ptr("l"), 15915 ID: Ptr(int64(1)), 15916 URL: Ptr("u"), 15917 AvatarURL: Ptr("a"), 15918 GravatarID: Ptr("g"), 15919 Name: Ptr("n"), 15920 Company: Ptr("c"), 15921 Blog: Ptr("b"), 15922 Location: Ptr("l"), 15923 Email: Ptr("e"), 15924 Hireable: Ptr(true), 15925 Bio: Ptr("b"), 15926 TwitterUsername: Ptr("t"), 15927 PublicRepos: Ptr(1), 15928 Followers: Ptr(1), 15929 Following: Ptr(1), 15930 CreatedAt: &Timestamp{referenceTime}, 15931 SuspendedAt: &Timestamp{referenceTime}, 15932 }, 15933 AccessTokensURL: Ptr("atu"), 15934 RepositoriesURL: Ptr("ru"), 15935 HTMLURL: Ptr("hu"), 15936 TargetType: Ptr("tt"), 15937 SingleFileName: Ptr("sfn"), 15938 RepositorySelection: Ptr("rs"), 15939 Events: []string{"e"}, 15940 SingleFilePaths: []string{"s"}, 15941 Permissions: &InstallationPermissions{ 15942 Actions: Ptr("a"), 15943 Administration: Ptr("ad"), 15944 Checks: Ptr("c"), 15945 Contents: Ptr("co"), 15946 ContentReferences: Ptr("cr"), 15947 Deployments: Ptr("d"), 15948 Environments: Ptr("e"), 15949 Issues: Ptr("i"), 15950 Metadata: Ptr("md"), 15951 Members: Ptr("m"), 15952 OrganizationAdministration: Ptr("oa"), 15953 OrganizationHooks: Ptr("oh"), 15954 OrganizationPlan: Ptr("op"), 15955 OrganizationPreReceiveHooks: Ptr("opr"), 15956 OrganizationProjects: Ptr("op"), 15957 OrganizationSecrets: Ptr("os"), 15958 OrganizationSelfHostedRunners: Ptr("osh"), 15959 OrganizationUserBlocking: Ptr("oub"), 15960 Packages: Ptr("pkg"), 15961 Pages: Ptr("pg"), 15962 PullRequests: Ptr("pr"), 15963 RepositoryHooks: Ptr("rh"), 15964 RepositoryProjects: Ptr("rp"), 15965 RepositoryPreReceiveHooks: Ptr("rprh"), 15966 Secrets: Ptr("s"), 15967 SecretScanningAlerts: Ptr("ssa"), 15968 SecurityEvents: Ptr("se"), 15969 SingleFile: Ptr("sf"), 15970 Statuses: Ptr("s"), 15971 TeamDiscussions: Ptr("td"), 15972 VulnerabilityAlerts: Ptr("va"), 15973 Workflows: Ptr("w"), 15974 }, 15975 CreatedAt: &Timestamp{referenceTime}, 15976 UpdatedAt: &Timestamp{referenceTime}, 15977 HasMultipleSingleFiles: Ptr(false), 15978 SuspendedBy: &User{ 15979 Login: Ptr("l"), 15980 ID: Ptr(int64(1)), 15981 URL: Ptr("u"), 15982 AvatarURL: Ptr("a"), 15983 GravatarID: Ptr("g"), 15984 Name: Ptr("n"), 15985 Company: Ptr("c"), 15986 Blog: Ptr("b"), 15987 Location: Ptr("l"), 15988 Email: Ptr("e"), 15989 Hireable: Ptr(true), 15990 Bio: Ptr("b"), 15991 TwitterUsername: Ptr("t"), 15992 PublicRepos: Ptr(1), 15993 Followers: Ptr(1), 15994 Following: Ptr(1), 15995 CreatedAt: &Timestamp{referenceTime}, 15996 SuspendedAt: &Timestamp{referenceTime}, 15997 }, 15998 SuspendedAt: &Timestamp{referenceTime}, 15999 }, 16000 } 16001 16002 want := `{ 16003 "action": "a", 16004 "assignee": { 16005 "login": "l", 16006 "id": 1, 16007 "node_id": "n", 16008 "avatar_url": "a", 16009 "url": "u", 16010 "events_url": "e", 16011 "repos_url": "r" 16012 }, 16013 "number": 1, 16014 "pull_request": { 16015 "id": 1 16016 }, 16017 "changes": { 16018 "title": { 16019 "from": "TitleFrom" 16020 }, 16021 "body": { 16022 "from": "BodyFrom" 16023 }, 16024 "base": { 16025 "ref": { 16026 "from": "BaseRefFrom" 16027 }, 16028 "sha": { 16029 "from": "BaseSHAFrom" 16030 } 16031 } 16032 }, 16033 "requested_reviewer": { 16034 "login": "l", 16035 "id": 1, 16036 "node_id": "n", 16037 "avatar_url": "a", 16038 "url": "u", 16039 "events_url": "e", 16040 "repos_url": "r" 16041 }, 16042 "requested_team": { 16043 "id": 1 16044 }, 16045 "label": { 16046 "id": 1 16047 }, 16048 "before": "before", 16049 "after": "after", 16050 "repository": { 16051 "id": 1, 16052 "name": "n", 16053 "url": "s" 16054 }, 16055 "performed_via_github_app": { 16056 "id": 1, 16057 "node_id": "n", 16058 "slug": "s", 16059 "name": "n", 16060 "description": "d", 16061 "external_url": "e", 16062 "html_url": "h" 16063 }, 16064 "organization": { 16065 "name": "n", 16066 "company": "c", 16067 "blog": "b", 16068 "location": "loc", 16069 "email": "e", 16070 "twitter_username": "tu", 16071 "description": "d", 16072 "billing_email": "be", 16073 "is_verified": true, 16074 "has_organization_projects": true, 16075 "has_repository_projects": true, 16076 "default_repository_permission": "drp", 16077 "members_can_create_repositories": true, 16078 "members_can_create_public_repositories": false, 16079 "members_can_create_private_repositories": true, 16080 "members_can_create_internal_repositories": true, 16081 "members_allowed_repository_creation_type": "marct", 16082 "members_can_create_pages": true, 16083 "members_can_create_public_pages": false, 16084 "members_can_create_private_pages": true 16085 }, 16086 "sender": { 16087 "login": "l", 16088 "id": 1, 16089 "node_id": "n", 16090 "avatar_url": "a", 16091 "url": "u", 16092 "events_url": "e", 16093 "repos_url": "r" 16094 }, 16095 "installation": { 16096 "id": 1, 16097 "node_id": "nid", 16098 "app_id": 1, 16099 "app_slug": "as", 16100 "target_id": 1, 16101 "account": { 16102 "login": "l", 16103 "id": 1, 16104 "avatar_url": "a", 16105 "gravatar_id": "g", 16106 "name": "n", 16107 "company": "c", 16108 "blog": "b", 16109 "location": "l", 16110 "email": "e", 16111 "hireable": true, 16112 "bio": "b", 16113 "twitter_username": "t", 16114 "public_repos": 1, 16115 "followers": 1, 16116 "following": 1, 16117 "created_at": ` + referenceTimeStr + `, 16118 "suspended_at": ` + referenceTimeStr + `, 16119 "url": "u" 16120 }, 16121 "access_tokens_url": "atu", 16122 "repositories_url": "ru", 16123 "html_url": "hu", 16124 "target_type": "tt", 16125 "single_file_name": "sfn", 16126 "repository_selection": "rs", 16127 "events": [ 16128 "e" 16129 ], 16130 "single_file_paths": [ 16131 "s" 16132 ], 16133 "permissions": { 16134 "actions": "a", 16135 "administration": "ad", 16136 "checks": "c", 16137 "contents": "co", 16138 "content_references": "cr", 16139 "deployments": "d", 16140 "environments": "e", 16141 "issues": "i", 16142 "metadata": "md", 16143 "members": "m", 16144 "organization_administration": "oa", 16145 "organization_hooks": "oh", 16146 "organization_plan": "op", 16147 "organization_pre_receive_hooks": "opr", 16148 "organization_projects": "op", 16149 "organization_secrets": "os", 16150 "organization_self_hosted_runners": "osh", 16151 "organization_user_blocking": "oub", 16152 "packages": "pkg", 16153 "pages": "pg", 16154 "pull_requests": "pr", 16155 "repository_hooks": "rh", 16156 "repository_projects": "rp", 16157 "repository_pre_receive_hooks": "rprh", 16158 "secrets": "s", 16159 "secret_scanning_alerts": "ssa", 16160 "security_events": "se", 16161 "single_file": "sf", 16162 "statuses": "s", 16163 "team_discussions": "td", 16164 "vulnerability_alerts": "va", 16165 "workflows": "w" 16166 }, 16167 "created_at": ` + referenceTimeStr + `, 16168 "updated_at": ` + referenceTimeStr + `, 16169 "has_multiple_single_files": false, 16170 "suspended_by": { 16171 "login": "l", 16172 "id": 1, 16173 "avatar_url": "a", 16174 "gravatar_id": "g", 16175 "name": "n", 16176 "company": "c", 16177 "blog": "b", 16178 "location": "l", 16179 "email": "e", 16180 "hireable": true, 16181 "bio": "b", 16182 "twitter_username": "t", 16183 "public_repos": 1, 16184 "followers": 1, 16185 "following": 1, 16186 "created_at": ` + referenceTimeStr + `, 16187 "suspended_at": ` + referenceTimeStr + `, 16188 "url": "u" 16189 }, 16190 "suspended_at": ` + referenceTimeStr + ` 16191 } 16192 }` 16193 16194 testJSONMarshal(t, u, want) 16195 } 16196 16197 func TestPullRequestReviewCommentEvent_Marshal(t *testing.T) { 16198 t.Parallel() 16199 testJSONMarshal(t, &PullRequestReviewCommentEvent{}, "{}") 16200 16201 u := &PullRequestReviewCommentEvent{ 16202 Action: Ptr("a"), 16203 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 16204 Comment: &PullRequestComment{ID: Ptr(int64(1))}, 16205 Changes: &EditChange{ 16206 Title: &EditTitle{ 16207 From: Ptr("TitleFrom"), 16208 }, 16209 Body: &EditBody{ 16210 From: Ptr("BodyFrom"), 16211 }, 16212 Base: &EditBase{ 16213 Ref: &EditRef{ 16214 From: Ptr("BaseRefFrom"), 16215 }, 16216 SHA: &EditSHA{ 16217 From: Ptr("BaseSHAFrom"), 16218 }, 16219 }, 16220 }, 16221 Repo: &Repository{ 16222 ID: Ptr(int64(1)), 16223 URL: Ptr("s"), 16224 Name: Ptr("n"), 16225 }, 16226 Sender: &User{ 16227 Login: Ptr("l"), 16228 ID: Ptr(int64(1)), 16229 NodeID: Ptr("n"), 16230 URL: Ptr("u"), 16231 ReposURL: Ptr("r"), 16232 EventsURL: Ptr("e"), 16233 AvatarURL: Ptr("a"), 16234 }, 16235 Installation: &Installation{ 16236 ID: Ptr(int64(1)), 16237 NodeID: Ptr("nid"), 16238 AppID: Ptr(int64(1)), 16239 AppSlug: Ptr("as"), 16240 TargetID: Ptr(int64(1)), 16241 Account: &User{ 16242 Login: Ptr("l"), 16243 ID: Ptr(int64(1)), 16244 URL: Ptr("u"), 16245 AvatarURL: Ptr("a"), 16246 GravatarID: Ptr("g"), 16247 Name: Ptr("n"), 16248 Company: Ptr("c"), 16249 Blog: Ptr("b"), 16250 Location: Ptr("l"), 16251 Email: Ptr("e"), 16252 Hireable: Ptr(true), 16253 Bio: Ptr("b"), 16254 TwitterUsername: Ptr("t"), 16255 PublicRepos: Ptr(1), 16256 Followers: Ptr(1), 16257 Following: Ptr(1), 16258 CreatedAt: &Timestamp{referenceTime}, 16259 SuspendedAt: &Timestamp{referenceTime}, 16260 }, 16261 AccessTokensURL: Ptr("atu"), 16262 RepositoriesURL: Ptr("ru"), 16263 HTMLURL: Ptr("hu"), 16264 TargetType: Ptr("tt"), 16265 SingleFileName: Ptr("sfn"), 16266 RepositorySelection: Ptr("rs"), 16267 Events: []string{"e"}, 16268 SingleFilePaths: []string{"s"}, 16269 Permissions: &InstallationPermissions{ 16270 Actions: Ptr("a"), 16271 Administration: Ptr("ad"), 16272 Checks: Ptr("c"), 16273 Contents: Ptr("co"), 16274 ContentReferences: Ptr("cr"), 16275 Deployments: Ptr("d"), 16276 Environments: Ptr("e"), 16277 Issues: Ptr("i"), 16278 Metadata: Ptr("md"), 16279 Members: Ptr("m"), 16280 OrganizationAdministration: Ptr("oa"), 16281 OrganizationHooks: Ptr("oh"), 16282 OrganizationPlan: Ptr("op"), 16283 OrganizationPreReceiveHooks: Ptr("opr"), 16284 OrganizationProjects: Ptr("op"), 16285 OrganizationSecrets: Ptr("os"), 16286 OrganizationSelfHostedRunners: Ptr("osh"), 16287 OrganizationUserBlocking: Ptr("oub"), 16288 Packages: Ptr("pkg"), 16289 Pages: Ptr("pg"), 16290 PullRequests: Ptr("pr"), 16291 RepositoryHooks: Ptr("rh"), 16292 RepositoryProjects: Ptr("rp"), 16293 RepositoryPreReceiveHooks: Ptr("rprh"), 16294 Secrets: Ptr("s"), 16295 SecretScanningAlerts: Ptr("ssa"), 16296 SecurityEvents: Ptr("se"), 16297 SingleFile: Ptr("sf"), 16298 Statuses: Ptr("s"), 16299 TeamDiscussions: Ptr("td"), 16300 VulnerabilityAlerts: Ptr("va"), 16301 Workflows: Ptr("w"), 16302 }, 16303 CreatedAt: &Timestamp{referenceTime}, 16304 UpdatedAt: &Timestamp{referenceTime}, 16305 HasMultipleSingleFiles: Ptr(false), 16306 SuspendedBy: &User{ 16307 Login: Ptr("l"), 16308 ID: Ptr(int64(1)), 16309 URL: Ptr("u"), 16310 AvatarURL: Ptr("a"), 16311 GravatarID: Ptr("g"), 16312 Name: Ptr("n"), 16313 Company: Ptr("c"), 16314 Blog: Ptr("b"), 16315 Location: Ptr("l"), 16316 Email: Ptr("e"), 16317 Hireable: Ptr(true), 16318 Bio: Ptr("b"), 16319 TwitterUsername: Ptr("t"), 16320 PublicRepos: Ptr(1), 16321 Followers: Ptr(1), 16322 Following: Ptr(1), 16323 CreatedAt: &Timestamp{referenceTime}, 16324 SuspendedAt: &Timestamp{referenceTime}, 16325 }, 16326 SuspendedAt: &Timestamp{referenceTime}, 16327 }, 16328 } 16329 16330 want := `{ 16331 "action": "a", 16332 "pull_request": { 16333 "id": 1 16334 }, 16335 "comment": { 16336 "id": 1 16337 }, 16338 "changes": { 16339 "title": { 16340 "from": "TitleFrom" 16341 }, 16342 "body": { 16343 "from": "BodyFrom" 16344 }, 16345 "base": { 16346 "ref": { 16347 "from": "BaseRefFrom" 16348 }, 16349 "sha": { 16350 "from": "BaseSHAFrom" 16351 } 16352 } 16353 }, 16354 "repository": { 16355 "id": 1, 16356 "name": "n", 16357 "url": "s" 16358 }, 16359 "sender": { 16360 "login": "l", 16361 "id": 1, 16362 "node_id": "n", 16363 "avatar_url": "a", 16364 "url": "u", 16365 "events_url": "e", 16366 "repos_url": "r" 16367 }, 16368 "installation": { 16369 "id": 1, 16370 "node_id": "nid", 16371 "app_id": 1, 16372 "app_slug": "as", 16373 "target_id": 1, 16374 "account": { 16375 "login": "l", 16376 "id": 1, 16377 "avatar_url": "a", 16378 "gravatar_id": "g", 16379 "name": "n", 16380 "company": "c", 16381 "blog": "b", 16382 "location": "l", 16383 "email": "e", 16384 "hireable": true, 16385 "bio": "b", 16386 "twitter_username": "t", 16387 "public_repos": 1, 16388 "followers": 1, 16389 "following": 1, 16390 "created_at": ` + referenceTimeStr + `, 16391 "suspended_at": ` + referenceTimeStr + `, 16392 "url": "u" 16393 }, 16394 "access_tokens_url": "atu", 16395 "repositories_url": "ru", 16396 "html_url": "hu", 16397 "target_type": "tt", 16398 "single_file_name": "sfn", 16399 "repository_selection": "rs", 16400 "events": [ 16401 "e" 16402 ], 16403 "single_file_paths": [ 16404 "s" 16405 ], 16406 "permissions": { 16407 "actions": "a", 16408 "administration": "ad", 16409 "checks": "c", 16410 "contents": "co", 16411 "content_references": "cr", 16412 "deployments": "d", 16413 "environments": "e", 16414 "issues": "i", 16415 "metadata": "md", 16416 "members": "m", 16417 "organization_administration": "oa", 16418 "organization_hooks": "oh", 16419 "organization_plan": "op", 16420 "organization_pre_receive_hooks": "opr", 16421 "organization_projects": "op", 16422 "organization_secrets": "os", 16423 "organization_self_hosted_runners": "osh", 16424 "organization_user_blocking": "oub", 16425 "packages": "pkg", 16426 "pages": "pg", 16427 "pull_requests": "pr", 16428 "repository_hooks": "rh", 16429 "repository_projects": "rp", 16430 "repository_pre_receive_hooks": "rprh", 16431 "secrets": "s", 16432 "secret_scanning_alerts": "ssa", 16433 "security_events": "se", 16434 "single_file": "sf", 16435 "statuses": "s", 16436 "team_discussions": "td", 16437 "vulnerability_alerts": "va", 16438 "workflows": "w" 16439 }, 16440 "created_at": ` + referenceTimeStr + `, 16441 "updated_at": ` + referenceTimeStr + `, 16442 "has_multiple_single_files": false, 16443 "suspended_by": { 16444 "login": "l", 16445 "id": 1, 16446 "avatar_url": "a", 16447 "gravatar_id": "g", 16448 "name": "n", 16449 "company": "c", 16450 "blog": "b", 16451 "location": "l", 16452 "email": "e", 16453 "hireable": true, 16454 "bio": "b", 16455 "twitter_username": "t", 16456 "public_repos": 1, 16457 "followers": 1, 16458 "following": 1, 16459 "created_at": ` + referenceTimeStr + `, 16460 "suspended_at": ` + referenceTimeStr + `, 16461 "url": "u" 16462 }, 16463 "suspended_at": ` + referenceTimeStr + ` 16464 } 16465 }` 16466 16467 testJSONMarshal(t, u, want) 16468 } 16469 16470 func TestPullRequestReviewThreadEvent_Marshal(t *testing.T) { 16471 t.Parallel() 16472 testJSONMarshal(t, &PullRequestReviewThreadEvent{}, "{}") 16473 16474 u := &PullRequestReviewThreadEvent{ 16475 Action: Ptr("a"), 16476 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 16477 Thread: &PullRequestThread{ 16478 Comments: []*PullRequestComment{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}}, 16479 }, 16480 Repo: &Repository{ 16481 ID: Ptr(int64(1)), 16482 URL: Ptr("s"), 16483 Name: Ptr("n"), 16484 }, 16485 Sender: &User{ 16486 Login: Ptr("l"), 16487 ID: Ptr(int64(1)), 16488 NodeID: Ptr("n"), 16489 URL: Ptr("u"), 16490 ReposURL: Ptr("r"), 16491 EventsURL: Ptr("e"), 16492 AvatarURL: Ptr("a"), 16493 }, 16494 Installation: &Installation{ 16495 ID: Ptr(int64(1)), 16496 NodeID: Ptr("nid"), 16497 AppID: Ptr(int64(1)), 16498 AppSlug: Ptr("as"), 16499 TargetID: Ptr(int64(1)), 16500 Account: &User{ 16501 Login: Ptr("l"), 16502 ID: Ptr(int64(1)), 16503 URL: Ptr("u"), 16504 AvatarURL: Ptr("a"), 16505 GravatarID: Ptr("g"), 16506 Name: Ptr("n"), 16507 Company: Ptr("c"), 16508 Blog: Ptr("b"), 16509 Location: Ptr("l"), 16510 Email: Ptr("e"), 16511 Hireable: Ptr(true), 16512 Bio: Ptr("b"), 16513 TwitterUsername: Ptr("t"), 16514 PublicRepos: Ptr(1), 16515 Followers: Ptr(1), 16516 Following: Ptr(1), 16517 CreatedAt: &Timestamp{referenceTime}, 16518 SuspendedAt: &Timestamp{referenceTime}, 16519 }, 16520 AccessTokensURL: Ptr("atu"), 16521 RepositoriesURL: Ptr("ru"), 16522 HTMLURL: Ptr("hu"), 16523 TargetType: Ptr("tt"), 16524 SingleFileName: Ptr("sfn"), 16525 RepositorySelection: Ptr("rs"), 16526 Events: []string{"e"}, 16527 SingleFilePaths: []string{"s"}, 16528 Permissions: &InstallationPermissions{ 16529 Actions: Ptr("a"), 16530 Administration: Ptr("ad"), 16531 Checks: Ptr("c"), 16532 Contents: Ptr("co"), 16533 ContentReferences: Ptr("cr"), 16534 Deployments: Ptr("d"), 16535 Environments: Ptr("e"), 16536 Issues: Ptr("i"), 16537 Metadata: Ptr("md"), 16538 Members: Ptr("m"), 16539 OrganizationAdministration: Ptr("oa"), 16540 OrganizationHooks: Ptr("oh"), 16541 OrganizationPlan: Ptr("op"), 16542 OrganizationPreReceiveHooks: Ptr("opr"), 16543 OrganizationProjects: Ptr("op"), 16544 OrganizationSecrets: Ptr("os"), 16545 OrganizationSelfHostedRunners: Ptr("osh"), 16546 OrganizationUserBlocking: Ptr("oub"), 16547 Packages: Ptr("pkg"), 16548 Pages: Ptr("pg"), 16549 PullRequests: Ptr("pr"), 16550 RepositoryHooks: Ptr("rh"), 16551 RepositoryProjects: Ptr("rp"), 16552 RepositoryPreReceiveHooks: Ptr("rprh"), 16553 Secrets: Ptr("s"), 16554 SecretScanningAlerts: Ptr("ssa"), 16555 SecurityEvents: Ptr("se"), 16556 SingleFile: Ptr("sf"), 16557 Statuses: Ptr("s"), 16558 TeamDiscussions: Ptr("td"), 16559 VulnerabilityAlerts: Ptr("va"), 16560 Workflows: Ptr("w"), 16561 }, 16562 CreatedAt: &Timestamp{referenceTime}, 16563 UpdatedAt: &Timestamp{referenceTime}, 16564 HasMultipleSingleFiles: Ptr(false), 16565 SuspendedBy: &User{ 16566 Login: Ptr("l"), 16567 ID: Ptr(int64(1)), 16568 URL: Ptr("u"), 16569 AvatarURL: Ptr("a"), 16570 GravatarID: Ptr("g"), 16571 Name: Ptr("n"), 16572 Company: Ptr("c"), 16573 Blog: Ptr("b"), 16574 Location: Ptr("l"), 16575 Email: Ptr("e"), 16576 Hireable: Ptr(true), 16577 Bio: Ptr("b"), 16578 TwitterUsername: Ptr("t"), 16579 PublicRepos: Ptr(1), 16580 Followers: Ptr(1), 16581 Following: Ptr(1), 16582 CreatedAt: &Timestamp{referenceTime}, 16583 SuspendedAt: &Timestamp{referenceTime}, 16584 }, 16585 SuspendedAt: &Timestamp{referenceTime}, 16586 }, 16587 } 16588 16589 want := `{ 16590 "action": "a", 16591 "pull_request": { 16592 "id": 1 16593 }, 16594 "thread": { 16595 "comments": [ 16596 { 16597 "id": 1 16598 }, 16599 { 16600 "id": 2 16601 } 16602 ] 16603 }, 16604 "repository": { 16605 "id": 1, 16606 "name": "n", 16607 "url": "s" 16608 }, 16609 "sender": { 16610 "login": "l", 16611 "id": 1, 16612 "node_id": "n", 16613 "avatar_url": "a", 16614 "url": "u", 16615 "events_url": "e", 16616 "repos_url": "r" 16617 }, 16618 "installation": { 16619 "id": 1, 16620 "node_id": "nid", 16621 "app_id": 1, 16622 "app_slug": "as", 16623 "target_id": 1, 16624 "account": { 16625 "login": "l", 16626 "id": 1, 16627 "avatar_url": "a", 16628 "gravatar_id": "g", 16629 "name": "n", 16630 "company": "c", 16631 "blog": "b", 16632 "location": "l", 16633 "email": "e", 16634 "hireable": true, 16635 "bio": "b", 16636 "twitter_username": "t", 16637 "public_repos": 1, 16638 "followers": 1, 16639 "following": 1, 16640 "created_at": ` + referenceTimeStr + `, 16641 "suspended_at": ` + referenceTimeStr + `, 16642 "url": "u" 16643 }, 16644 "access_tokens_url": "atu", 16645 "repositories_url": "ru", 16646 "html_url": "hu", 16647 "target_type": "tt", 16648 "single_file_name": "sfn", 16649 "repository_selection": "rs", 16650 "events": [ 16651 "e" 16652 ], 16653 "single_file_paths": [ 16654 "s" 16655 ], 16656 "permissions": { 16657 "actions": "a", 16658 "administration": "ad", 16659 "checks": "c", 16660 "contents": "co", 16661 "content_references": "cr", 16662 "deployments": "d", 16663 "environments": "e", 16664 "issues": "i", 16665 "metadata": "md", 16666 "members": "m", 16667 "organization_administration": "oa", 16668 "organization_hooks": "oh", 16669 "organization_plan": "op", 16670 "organization_pre_receive_hooks": "opr", 16671 "organization_projects": "op", 16672 "organization_secrets": "os", 16673 "organization_self_hosted_runners": "osh", 16674 "organization_user_blocking": "oub", 16675 "packages": "pkg", 16676 "pages": "pg", 16677 "pull_requests": "pr", 16678 "repository_hooks": "rh", 16679 "repository_projects": "rp", 16680 "repository_pre_receive_hooks": "rprh", 16681 "secrets": "s", 16682 "secret_scanning_alerts": "ssa", 16683 "security_events": "se", 16684 "single_file": "sf", 16685 "statuses": "s", 16686 "team_discussions": "td", 16687 "vulnerability_alerts": "va", 16688 "workflows": "w" 16689 }, 16690 "created_at": ` + referenceTimeStr + `, 16691 "updated_at": ` + referenceTimeStr + `, 16692 "has_multiple_single_files": false, 16693 "suspended_by": { 16694 "login": "l", 16695 "id": 1, 16696 "avatar_url": "a", 16697 "gravatar_id": "g", 16698 "name": "n", 16699 "company": "c", 16700 "blog": "b", 16701 "location": "l", 16702 "email": "e", 16703 "hireable": true, 16704 "bio": "b", 16705 "twitter_username": "t", 16706 "public_repos": 1, 16707 "followers": 1, 16708 "following": 1, 16709 "created_at": ` + referenceTimeStr + `, 16710 "suspended_at": ` + referenceTimeStr + `, 16711 "url": "u" 16712 }, 16713 "suspended_at": ` + referenceTimeStr + ` 16714 } 16715 }` 16716 16717 testJSONMarshal(t, u, want) 16718 } 16719 16720 func TestPullRequestTargetEvent_Marshal(t *testing.T) { 16721 t.Parallel() 16722 testJSONMarshal(t, &PullRequestTargetEvent{}, "{}") 16723 16724 u := &PullRequestTargetEvent{ 16725 Action: Ptr("a"), 16726 Assignee: &User{ 16727 Login: Ptr("l"), 16728 ID: Ptr(int64(1)), 16729 NodeID: Ptr("n"), 16730 URL: Ptr("u"), 16731 ReposURL: Ptr("r"), 16732 EventsURL: Ptr("e"), 16733 AvatarURL: Ptr("a"), 16734 }, 16735 Number: Ptr(1), 16736 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 16737 Changes: &EditChange{ 16738 Title: &EditTitle{ 16739 From: Ptr("TitleFrom"), 16740 }, 16741 Body: &EditBody{ 16742 From: Ptr("BodyFrom"), 16743 }, 16744 Base: &EditBase{ 16745 Ref: &EditRef{ 16746 From: Ptr("BaseRefFrom"), 16747 }, 16748 SHA: &EditSHA{ 16749 From: Ptr("BaseSHAFrom"), 16750 }, 16751 }, 16752 }, 16753 RequestedReviewer: &User{ 16754 Login: Ptr("l"), 16755 ID: Ptr(int64(1)), 16756 NodeID: Ptr("n"), 16757 URL: Ptr("u"), 16758 ReposURL: Ptr("r"), 16759 EventsURL: Ptr("e"), 16760 AvatarURL: Ptr("a"), 16761 }, 16762 RequestedTeam: &Team{ID: Ptr(int64(1))}, 16763 Label: &Label{ID: Ptr(int64(1))}, 16764 Before: Ptr("before"), 16765 After: Ptr("after"), 16766 Repo: &Repository{ 16767 ID: Ptr(int64(1)), 16768 URL: Ptr("s"), 16769 Name: Ptr("n"), 16770 }, 16771 PerformedViaGithubApp: &App{ 16772 ID: Ptr(int64(1)), 16773 NodeID: Ptr("n"), 16774 Slug: Ptr("s"), 16775 Name: Ptr("n"), 16776 Description: Ptr("d"), 16777 ExternalURL: Ptr("e"), 16778 HTMLURL: Ptr("h"), 16779 }, 16780 Organization: &Organization{ 16781 BillingEmail: Ptr("be"), 16782 Blog: Ptr("b"), 16783 Company: Ptr("c"), 16784 Email: Ptr("e"), 16785 TwitterUsername: Ptr("tu"), 16786 Location: Ptr("loc"), 16787 Name: Ptr("n"), 16788 Description: Ptr("d"), 16789 IsVerified: Ptr(true), 16790 HasOrganizationProjects: Ptr(true), 16791 HasRepositoryProjects: Ptr(true), 16792 DefaultRepoPermission: Ptr("drp"), 16793 MembersCanCreateRepos: Ptr(true), 16794 MembersCanCreateInternalRepos: Ptr(true), 16795 MembersCanCreatePrivateRepos: Ptr(true), 16796 MembersCanCreatePublicRepos: Ptr(false), 16797 MembersAllowedRepositoryCreationType: Ptr("marct"), 16798 MembersCanCreatePages: Ptr(true), 16799 MembersCanCreatePublicPages: Ptr(false), 16800 MembersCanCreatePrivatePages: Ptr(true), 16801 }, 16802 Sender: &User{ 16803 Login: Ptr("l"), 16804 ID: Ptr(int64(1)), 16805 NodeID: Ptr("n"), 16806 URL: Ptr("u"), 16807 ReposURL: Ptr("r"), 16808 EventsURL: Ptr("e"), 16809 AvatarURL: Ptr("a"), 16810 }, 16811 Installation: &Installation{ 16812 ID: Ptr(int64(1)), 16813 NodeID: Ptr("nid"), 16814 AppID: Ptr(int64(1)), 16815 AppSlug: Ptr("as"), 16816 TargetID: Ptr(int64(1)), 16817 Account: &User{ 16818 Login: Ptr("l"), 16819 ID: Ptr(int64(1)), 16820 URL: Ptr("u"), 16821 AvatarURL: Ptr("a"), 16822 GravatarID: Ptr("g"), 16823 Name: Ptr("n"), 16824 Company: Ptr("c"), 16825 Blog: Ptr("b"), 16826 Location: Ptr("l"), 16827 Email: Ptr("e"), 16828 Hireable: Ptr(true), 16829 Bio: Ptr("b"), 16830 TwitterUsername: Ptr("t"), 16831 PublicRepos: Ptr(1), 16832 Followers: Ptr(1), 16833 Following: Ptr(1), 16834 CreatedAt: &Timestamp{referenceTime}, 16835 SuspendedAt: &Timestamp{referenceTime}, 16836 }, 16837 AccessTokensURL: Ptr("atu"), 16838 RepositoriesURL: Ptr("ru"), 16839 HTMLURL: Ptr("hu"), 16840 TargetType: Ptr("tt"), 16841 SingleFileName: Ptr("sfn"), 16842 RepositorySelection: Ptr("rs"), 16843 Events: []string{"e"}, 16844 SingleFilePaths: []string{"s"}, 16845 Permissions: &InstallationPermissions{ 16846 Actions: Ptr("a"), 16847 Administration: Ptr("ad"), 16848 Checks: Ptr("c"), 16849 Contents: Ptr("co"), 16850 ContentReferences: Ptr("cr"), 16851 Deployments: Ptr("d"), 16852 Environments: Ptr("e"), 16853 Issues: Ptr("i"), 16854 Metadata: Ptr("md"), 16855 Members: Ptr("m"), 16856 OrganizationAdministration: Ptr("oa"), 16857 OrganizationHooks: Ptr("oh"), 16858 OrganizationPlan: Ptr("op"), 16859 OrganizationPreReceiveHooks: Ptr("opr"), 16860 OrganizationProjects: Ptr("op"), 16861 OrganizationSecrets: Ptr("os"), 16862 OrganizationSelfHostedRunners: Ptr("osh"), 16863 OrganizationUserBlocking: Ptr("oub"), 16864 Packages: Ptr("pkg"), 16865 Pages: Ptr("pg"), 16866 PullRequests: Ptr("pr"), 16867 RepositoryHooks: Ptr("rh"), 16868 RepositoryProjects: Ptr("rp"), 16869 RepositoryPreReceiveHooks: Ptr("rprh"), 16870 Secrets: Ptr("s"), 16871 SecretScanningAlerts: Ptr("ssa"), 16872 SecurityEvents: Ptr("se"), 16873 SingleFile: Ptr("sf"), 16874 Statuses: Ptr("s"), 16875 TeamDiscussions: Ptr("td"), 16876 VulnerabilityAlerts: Ptr("va"), 16877 Workflows: Ptr("w"), 16878 }, 16879 CreatedAt: &Timestamp{referenceTime}, 16880 UpdatedAt: &Timestamp{referenceTime}, 16881 HasMultipleSingleFiles: Ptr(false), 16882 SuspendedBy: &User{ 16883 Login: Ptr("l"), 16884 ID: Ptr(int64(1)), 16885 URL: Ptr("u"), 16886 AvatarURL: Ptr("a"), 16887 GravatarID: Ptr("g"), 16888 Name: Ptr("n"), 16889 Company: Ptr("c"), 16890 Blog: Ptr("b"), 16891 Location: Ptr("l"), 16892 Email: Ptr("e"), 16893 Hireable: Ptr(true), 16894 Bio: Ptr("b"), 16895 TwitterUsername: Ptr("t"), 16896 PublicRepos: Ptr(1), 16897 Followers: Ptr(1), 16898 Following: Ptr(1), 16899 CreatedAt: &Timestamp{referenceTime}, 16900 SuspendedAt: &Timestamp{referenceTime}, 16901 }, 16902 SuspendedAt: &Timestamp{referenceTime}, 16903 }, 16904 } 16905 16906 want := `{ 16907 "action": "a", 16908 "assignee": { 16909 "login": "l", 16910 "id": 1, 16911 "node_id": "n", 16912 "avatar_url": "a", 16913 "url": "u", 16914 "events_url": "e", 16915 "repos_url": "r" 16916 }, 16917 "number": 1, 16918 "pull_request": { 16919 "id": 1 16920 }, 16921 "changes": { 16922 "title": { 16923 "from": "TitleFrom" 16924 }, 16925 "body": { 16926 "from": "BodyFrom" 16927 }, 16928 "base": { 16929 "ref": { 16930 "from": "BaseRefFrom" 16931 }, 16932 "sha": { 16933 "from": "BaseSHAFrom" 16934 } 16935 } 16936 }, 16937 "requested_reviewer": { 16938 "login": "l", 16939 "id": 1, 16940 "node_id": "n", 16941 "avatar_url": "a", 16942 "url": "u", 16943 "events_url": "e", 16944 "repos_url": "r" 16945 }, 16946 "requested_team": { 16947 "id": 1 16948 }, 16949 "label": { 16950 "id": 1 16951 }, 16952 "before": "before", 16953 "after": "after", 16954 "repository": { 16955 "id": 1, 16956 "name": "n", 16957 "url": "s" 16958 }, 16959 "performed_via_github_app": { 16960 "id": 1, 16961 "node_id": "n", 16962 "slug": "s", 16963 "name": "n", 16964 "description": "d", 16965 "external_url": "e", 16966 "html_url": "h" 16967 }, 16968 "organization": { 16969 "name": "n", 16970 "company": "c", 16971 "blog": "b", 16972 "location": "loc", 16973 "email": "e", 16974 "twitter_username": "tu", 16975 "description": "d", 16976 "billing_email": "be", 16977 "is_verified": true, 16978 "has_organization_projects": true, 16979 "has_repository_projects": true, 16980 "default_repository_permission": "drp", 16981 "members_can_create_repositories": true, 16982 "members_can_create_public_repositories": false, 16983 "members_can_create_private_repositories": true, 16984 "members_can_create_internal_repositories": true, 16985 "members_allowed_repository_creation_type": "marct", 16986 "members_can_create_pages": true, 16987 "members_can_create_public_pages": false, 16988 "members_can_create_private_pages": true 16989 }, 16990 "sender": { 16991 "login": "l", 16992 "id": 1, 16993 "node_id": "n", 16994 "avatar_url": "a", 16995 "url": "u", 16996 "events_url": "e", 16997 "repos_url": "r" 16998 }, 16999 "installation": { 17000 "id": 1, 17001 "node_id": "nid", 17002 "app_id": 1, 17003 "app_slug": "as", 17004 "target_id": 1, 17005 "account": { 17006 "login": "l", 17007 "id": 1, 17008 "avatar_url": "a", 17009 "gravatar_id": "g", 17010 "name": "n", 17011 "company": "c", 17012 "blog": "b", 17013 "location": "l", 17014 "email": "e", 17015 "hireable": true, 17016 "bio": "b", 17017 "twitter_username": "t", 17018 "public_repos": 1, 17019 "followers": 1, 17020 "following": 1, 17021 "created_at": ` + referenceTimeStr + `, 17022 "suspended_at": ` + referenceTimeStr + `, 17023 "url": "u" 17024 }, 17025 "access_tokens_url": "atu", 17026 "repositories_url": "ru", 17027 "html_url": "hu", 17028 "target_type": "tt", 17029 "single_file_name": "sfn", 17030 "repository_selection": "rs", 17031 "events": [ 17032 "e" 17033 ], 17034 "single_file_paths": [ 17035 "s" 17036 ], 17037 "permissions": { 17038 "actions": "a", 17039 "administration": "ad", 17040 "checks": "c", 17041 "contents": "co", 17042 "content_references": "cr", 17043 "deployments": "d", 17044 "environments": "e", 17045 "issues": "i", 17046 "metadata": "md", 17047 "members": "m", 17048 "organization_administration": "oa", 17049 "organization_hooks": "oh", 17050 "organization_plan": "op", 17051 "organization_pre_receive_hooks": "opr", 17052 "organization_projects": "op", 17053 "organization_secrets": "os", 17054 "organization_self_hosted_runners": "osh", 17055 "organization_user_blocking": "oub", 17056 "packages": "pkg", 17057 "pages": "pg", 17058 "pull_requests": "pr", 17059 "repository_hooks": "rh", 17060 "repository_projects": "rp", 17061 "repository_pre_receive_hooks": "rprh", 17062 "secrets": "s", 17063 "secret_scanning_alerts": "ssa", 17064 "security_events": "se", 17065 "single_file": "sf", 17066 "statuses": "s", 17067 "team_discussions": "td", 17068 "vulnerability_alerts": "va", 17069 "workflows": "w" 17070 }, 17071 "created_at": ` + referenceTimeStr + `, 17072 "updated_at": ` + referenceTimeStr + `, 17073 "has_multiple_single_files": false, 17074 "suspended_by": { 17075 "login": "l", 17076 "id": 1, 17077 "avatar_url": "a", 17078 "gravatar_id": "g", 17079 "name": "n", 17080 "company": "c", 17081 "blog": "b", 17082 "location": "l", 17083 "email": "e", 17084 "hireable": true, 17085 "bio": "b", 17086 "twitter_username": "t", 17087 "public_repos": 1, 17088 "followers": 1, 17089 "following": 1, 17090 "created_at": ` + referenceTimeStr + `, 17091 "suspended_at": ` + referenceTimeStr + `, 17092 "url": "u" 17093 }, 17094 "suspended_at": ` + referenceTimeStr + ` 17095 } 17096 }` 17097 17098 testJSONMarshal(t, u, want) 17099 } 17100 17101 func TestRepositoryVulnerabilityAlertEvent_Marshal(t *testing.T) { 17102 t.Parallel() 17103 testJSONMarshal(t, &RepositoryVulnerabilityAlertEvent{}, "{}") 17104 17105 u := &RepositoryVulnerabilityAlertEvent{ 17106 Action: Ptr("a"), 17107 Alert: &RepositoryVulnerabilityAlert{ 17108 ID: Ptr(int64(1)), 17109 AffectedRange: Ptr("ar"), 17110 AffectedPackageName: Ptr("apn"), 17111 ExternalReference: Ptr("er"), 17112 ExternalIdentifier: Ptr("ei"), 17113 FixedIn: Ptr("fi"), 17114 Dismisser: &User{ 17115 Login: Ptr("l"), 17116 ID: Ptr(int64(1)), 17117 NodeID: Ptr("n"), 17118 URL: Ptr("u"), 17119 ReposURL: Ptr("r"), 17120 EventsURL: Ptr("e"), 17121 AvatarURL: Ptr("a"), 17122 }, 17123 DismissReason: Ptr("dr"), 17124 DismissedAt: &Timestamp{referenceTime}, 17125 }, 17126 Repository: &Repository{ 17127 ID: Ptr(int64(1)), 17128 URL: Ptr("s"), 17129 Name: Ptr("n"), 17130 }, 17131 } 17132 17133 want := `{ 17134 "action": "a", 17135 "alert": { 17136 "id": 1, 17137 "affected_range": "ar", 17138 "affected_package_name": "apn", 17139 "external_reference": "er", 17140 "external_identifier": "ei", 17141 "fixed_in": "fi", 17142 "dismisser": { 17143 "login": "l", 17144 "id": 1, 17145 "node_id": "n", 17146 "avatar_url": "a", 17147 "url": "u", 17148 "events_url": "e", 17149 "repos_url": "r" 17150 }, 17151 "dismiss_reason": "dr", 17152 "dismissed_at": ` + referenceTimeStr + ` 17153 }, 17154 "repository": { 17155 "id": 1, 17156 "name": "n", 17157 "url": "s" 17158 } 17159 }` 17160 17161 testJSONMarshal(t, u, want) 17162 } 17163 17164 func TestSecretScanningAlertEvent_Marshal(t *testing.T) { 17165 t.Parallel() 17166 testJSONMarshal(t, &SecretScanningAlertEvent{}, "{}") 17167 17168 u := &SecretScanningAlertEvent{ 17169 Action: Ptr("a"), 17170 Alert: &SecretScanningAlert{ 17171 Number: Ptr(1), 17172 SecretType: Ptr("t"), 17173 Resolution: Ptr("r"), 17174 ResolvedBy: &User{ 17175 Login: Ptr("l"), 17176 ID: Ptr(int64(1)), 17177 NodeID: Ptr("n"), 17178 URL: Ptr("u"), 17179 ReposURL: Ptr("r"), 17180 EventsURL: Ptr("e"), 17181 AvatarURL: Ptr("a"), 17182 }, 17183 ResolvedAt: &Timestamp{referenceTime}, 17184 }, 17185 Repo: &Repository{ 17186 ID: Ptr(int64(1)), 17187 URL: Ptr("s"), 17188 Name: Ptr("n"), 17189 }, 17190 Organization: &Organization{ 17191 BillingEmail: Ptr("be"), 17192 Blog: Ptr("b"), 17193 Company: Ptr("c"), 17194 Email: Ptr("e"), 17195 TwitterUsername: Ptr("tu"), 17196 Location: Ptr("loc"), 17197 Name: Ptr("n"), 17198 Description: Ptr("d"), 17199 IsVerified: Ptr(true), 17200 HasOrganizationProjects: Ptr(true), 17201 HasRepositoryProjects: Ptr(true), 17202 DefaultRepoPermission: Ptr("drp"), 17203 MembersCanCreateRepos: Ptr(true), 17204 MembersCanCreateInternalRepos: Ptr(true), 17205 MembersCanCreatePrivateRepos: Ptr(true), 17206 MembersCanCreatePublicRepos: Ptr(false), 17207 MembersAllowedRepositoryCreationType: Ptr("marct"), 17208 MembersCanCreatePages: Ptr(true), 17209 MembersCanCreatePublicPages: Ptr(false), 17210 MembersCanCreatePrivatePages: Ptr(true), 17211 }, 17212 Enterprise: &Enterprise{ 17213 ID: Ptr(1), 17214 Slug: Ptr("s"), 17215 Name: Ptr("n"), 17216 NodeID: Ptr("nid"), 17217 AvatarURL: Ptr("au"), 17218 Description: Ptr("d"), 17219 WebsiteURL: Ptr("wu"), 17220 HTMLURL: Ptr("hu"), 17221 CreatedAt: &Timestamp{referenceTime}, 17222 UpdatedAt: &Timestamp{referenceTime}, 17223 }, 17224 Sender: &User{ 17225 Login: Ptr("l"), 17226 ID: Ptr(int64(1)), 17227 NodeID: Ptr("n"), 17228 URL: Ptr("u"), 17229 ReposURL: Ptr("r"), 17230 EventsURL: Ptr("e"), 17231 AvatarURL: Ptr("a"), 17232 }, 17233 Installation: &Installation{ 17234 ID: Ptr(int64(1)), 17235 NodeID: Ptr("nid"), 17236 AppID: Ptr(int64(1)), 17237 AppSlug: Ptr("as"), 17238 TargetID: Ptr(int64(1)), 17239 Account: &User{ 17240 Login: Ptr("l"), 17241 ID: Ptr(int64(1)), 17242 URL: Ptr("u"), 17243 AvatarURL: Ptr("a"), 17244 GravatarID: Ptr("g"), 17245 Name: Ptr("n"), 17246 Company: Ptr("c"), 17247 Blog: Ptr("b"), 17248 Location: Ptr("l"), 17249 Email: Ptr("e"), 17250 Hireable: Ptr(true), 17251 Bio: Ptr("b"), 17252 TwitterUsername: Ptr("t"), 17253 PublicRepos: Ptr(1), 17254 Followers: Ptr(1), 17255 Following: Ptr(1), 17256 CreatedAt: &Timestamp{referenceTime}, 17257 SuspendedAt: &Timestamp{referenceTime}, 17258 }, 17259 AccessTokensURL: Ptr("atu"), 17260 RepositoriesURL: Ptr("ru"), 17261 HTMLURL: Ptr("hu"), 17262 TargetType: Ptr("tt"), 17263 SingleFileName: Ptr("sfn"), 17264 RepositorySelection: Ptr("rs"), 17265 Events: []string{"e"}, 17266 SingleFilePaths: []string{"s"}, 17267 Permissions: &InstallationPermissions{ 17268 Actions: Ptr("a"), 17269 Administration: Ptr("ad"), 17270 Checks: Ptr("c"), 17271 Contents: Ptr("co"), 17272 ContentReferences: Ptr("cr"), 17273 Deployments: Ptr("d"), 17274 Environments: Ptr("e"), 17275 Issues: Ptr("i"), 17276 Metadata: Ptr("md"), 17277 Members: Ptr("m"), 17278 OrganizationAdministration: Ptr("oa"), 17279 OrganizationHooks: Ptr("oh"), 17280 OrganizationPlan: Ptr("op"), 17281 OrganizationPreReceiveHooks: Ptr("opr"), 17282 OrganizationProjects: Ptr("op"), 17283 OrganizationSecrets: Ptr("os"), 17284 OrganizationSelfHostedRunners: Ptr("osh"), 17285 OrganizationUserBlocking: Ptr("oub"), 17286 Packages: Ptr("pkg"), 17287 Pages: Ptr("pg"), 17288 PullRequests: Ptr("pr"), 17289 RepositoryHooks: Ptr("rh"), 17290 RepositoryProjects: Ptr("rp"), 17291 RepositoryPreReceiveHooks: Ptr("rprh"), 17292 Secrets: Ptr("s"), 17293 SecretScanningAlerts: Ptr("ssa"), 17294 SecurityEvents: Ptr("se"), 17295 SingleFile: Ptr("sf"), 17296 Statuses: Ptr("s"), 17297 TeamDiscussions: Ptr("td"), 17298 VulnerabilityAlerts: Ptr("va"), 17299 Workflows: Ptr("w"), 17300 }, 17301 CreatedAt: &Timestamp{referenceTime}, 17302 UpdatedAt: &Timestamp{referenceTime}, 17303 HasMultipleSingleFiles: Ptr(false), 17304 SuspendedBy: &User{ 17305 Login: Ptr("l"), 17306 ID: Ptr(int64(1)), 17307 URL: Ptr("u"), 17308 AvatarURL: Ptr("a"), 17309 GravatarID: Ptr("g"), 17310 Name: Ptr("n"), 17311 Company: Ptr("c"), 17312 Blog: Ptr("b"), 17313 Location: Ptr("l"), 17314 Email: Ptr("e"), 17315 Hireable: Ptr(true), 17316 Bio: Ptr("b"), 17317 TwitterUsername: Ptr("t"), 17318 PublicRepos: Ptr(1), 17319 Followers: Ptr(1), 17320 Following: Ptr(1), 17321 CreatedAt: &Timestamp{referenceTime}, 17322 SuspendedAt: &Timestamp{referenceTime}, 17323 }, 17324 SuspendedAt: &Timestamp{referenceTime}, 17325 }, 17326 } 17327 17328 want := `{ 17329 "action": "a", 17330 "alert": { 17331 "number": 1, 17332 "secret_type": "t", 17333 "resolution": "r", 17334 "resolved_by": { 17335 "login": "l", 17336 "id": 1, 17337 "node_id": "n", 17338 "avatar_url": "a", 17339 "url": "u", 17340 "events_url": "e", 17341 "repos_url": "r" 17342 }, 17343 "resolved_at": ` + referenceTimeStr + ` 17344 }, 17345 "repository": { 17346 "id": 1, 17347 "name": "n", 17348 "url": "s" 17349 }, 17350 "organization": { 17351 "name": "n", 17352 "company": "c", 17353 "blog": "b", 17354 "location": "loc", 17355 "email": "e", 17356 "twitter_username": "tu", 17357 "description": "d", 17358 "billing_email": "be", 17359 "is_verified": true, 17360 "has_organization_projects": true, 17361 "has_repository_projects": true, 17362 "default_repository_permission": "drp", 17363 "members_can_create_repositories": true, 17364 "members_can_create_public_repositories": false, 17365 "members_can_create_private_repositories": true, 17366 "members_can_create_internal_repositories": true, 17367 "members_allowed_repository_creation_type": "marct", 17368 "members_can_create_pages": true, 17369 "members_can_create_public_pages": false, 17370 "members_can_create_private_pages": true 17371 }, 17372 "enterprise": { 17373 "id": 1, 17374 "slug": "s", 17375 "name": "n", 17376 "node_id": "nid", 17377 "avatar_url": "au", 17378 "description": "d", 17379 "website_url": "wu", 17380 "html_url": "hu", 17381 "created_at": ` + referenceTimeStr + `, 17382 "updated_at": ` + referenceTimeStr + ` 17383 }, 17384 "sender": { 17385 "login": "l", 17386 "id": 1, 17387 "node_id": "n", 17388 "avatar_url": "a", 17389 "url": "u", 17390 "events_url": "e", 17391 "repos_url": "r" 17392 }, 17393 "installation": { 17394 "id": 1, 17395 "node_id": "nid", 17396 "app_id": 1, 17397 "app_slug": "as", 17398 "target_id": 1, 17399 "account": { 17400 "login": "l", 17401 "id": 1, 17402 "avatar_url": "a", 17403 "gravatar_id": "g", 17404 "name": "n", 17405 "company": "c", 17406 "blog": "b", 17407 "location": "l", 17408 "email": "e", 17409 "hireable": true, 17410 "bio": "b", 17411 "twitter_username": "t", 17412 "public_repos": 1, 17413 "followers": 1, 17414 "following": 1, 17415 "created_at": ` + referenceTimeStr + `, 17416 "suspended_at": ` + referenceTimeStr + `, 17417 "url": "u" 17418 }, 17419 "access_tokens_url": "atu", 17420 "repositories_url": "ru", 17421 "html_url": "hu", 17422 "target_type": "tt", 17423 "single_file_name": "sfn", 17424 "repository_selection": "rs", 17425 "events": [ 17426 "e" 17427 ], 17428 "single_file_paths": [ 17429 "s" 17430 ], 17431 "permissions": { 17432 "actions": "a", 17433 "administration": "ad", 17434 "checks": "c", 17435 "contents": "co", 17436 "content_references": "cr", 17437 "deployments": "d", 17438 "environments": "e", 17439 "issues": "i", 17440 "metadata": "md", 17441 "members": "m", 17442 "organization_administration": "oa", 17443 "organization_hooks": "oh", 17444 "organization_plan": "op", 17445 "organization_pre_receive_hooks": "opr", 17446 "organization_projects": "op", 17447 "organization_secrets": "os", 17448 "organization_self_hosted_runners": "osh", 17449 "organization_user_blocking": "oub", 17450 "packages": "pkg", 17451 "pages": "pg", 17452 "pull_requests": "pr", 17453 "repository_hooks": "rh", 17454 "repository_projects": "rp", 17455 "repository_pre_receive_hooks": "rprh", 17456 "secrets": "s", 17457 "secret_scanning_alerts": "ssa", 17458 "security_events": "se", 17459 "single_file": "sf", 17460 "statuses": "s", 17461 "team_discussions": "td", 17462 "vulnerability_alerts": "va", 17463 "workflows": "w" 17464 }, 17465 "created_at": ` + referenceTimeStr + `, 17466 "updated_at": ` + referenceTimeStr + `, 17467 "has_multiple_single_files": false, 17468 "suspended_by": { 17469 "login": "l", 17470 "id": 1, 17471 "avatar_url": "a", 17472 "gravatar_id": "g", 17473 "name": "n", 17474 "company": "c", 17475 "blog": "b", 17476 "location": "l", 17477 "email": "e", 17478 "hireable": true, 17479 "bio": "b", 17480 "twitter_username": "t", 17481 "public_repos": 1, 17482 "followers": 1, 17483 "following": 1, 17484 "created_at": ` + referenceTimeStr + `, 17485 "suspended_at": ` + referenceTimeStr + `, 17486 "url": "u" 17487 }, 17488 "suspended_at": ` + referenceTimeStr + ` 17489 } 17490 }` 17491 17492 testJSONMarshal(t, u, want) 17493 } 17494 17495 func TestSecretScanningAlertLocationEvent_Marshal(t *testing.T) { 17496 t.Parallel() 17497 testJSONMarshal(t, &SecretScanningAlertLocationEvent{}, "{}") 17498 u := &SecretScanningAlertLocationEvent{ 17499 Action: Ptr("created"), 17500 Alert: &SecretScanningAlert{ 17501 Number: Ptr(10), 17502 CreatedAt: &Timestamp{referenceTime}, 17503 UpdatedAt: &Timestamp{referenceTime}, 17504 URL: Ptr("a"), 17505 HTMLURL: Ptr("a"), 17506 SecretType: Ptr("mailchimp_api_key"), 17507 }, 17508 Location: &SecretScanningAlertLocation{ 17509 Type: Ptr("blob"), 17510 Details: &SecretScanningAlertLocationDetails{ 17511 Path: Ptr("path/to/file"), 17512 Startline: Ptr(10), 17513 EndLine: Ptr(20), 17514 StartColumn: Ptr(1), 17515 EndColumn: Ptr(2), 17516 BlobSHA: Ptr("d6e4c75c141dbacecc279b721b8bsomeSHA"), 17517 BlobURL: Ptr("a"), 17518 CommitSHA: Ptr("d6e4c75c141dbacecc279b721b8bsomeSHA"), 17519 CommitURL: Ptr("a"), 17520 }, 17521 }, 17522 Repo: &Repository{ 17523 ID: Ptr(int64(12345)), 17524 NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjM0NQ=="), 17525 Name: Ptr("example-repo"), 17526 }, 17527 Organization: &Organization{ 17528 Login: Ptr("example-org"), 17529 ID: Ptr(int64(67890)), 17530 }, 17531 Sender: &User{ 17532 Login: Ptr("example-user"), 17533 ID: Ptr(int64(1111)), 17534 }, 17535 Installation: &Installation{ 17536 ID: Ptr(int64(2222)), 17537 }, 17538 } 17539 17540 want := `{ 17541 "action": "created", 17542 "alert": { 17543 "number": 10, 17544 "created_at": ` + referenceTimeStr + `, 17545 "updated_at": ` + referenceTimeStr + `, 17546 "url": "a", 17547 "html_url": "a", 17548 "secret_type": "mailchimp_api_key" 17549 }, 17550 "location": { 17551 17552 "type": "blob", 17553 "details": { 17554 "path": "path/to/file", 17555 "start_line": 10, 17556 "end_line": 20, 17557 "start_column": 1, 17558 "end_column": 2, 17559 "blob_sha": "d6e4c75c141dbacecc279b721b8bsomeSHA", 17560 "blob_url": "a", 17561 "commit_sha": "d6e4c75c141dbacecc279b721b8bsomeSHA", 17562 "commit_url": "a" 17563 } 17564 }, 17565 "repository": { 17566 17567 "id": 12345, 17568 "node_id": "MDEwOlJlcG9zaXRvcnkxMjM0NQ==", 17569 "name": "example-repo" 17570 }, 17571 "organization": { 17572 "login": "example-org", 17573 "id": 67890 17574 }, 17575 "sender": { 17576 "login": "example-user", 17577 "id": 1111 17578 }, 17579 "installation": { 17580 "id": 2222 17581 } 17582 }` 17583 17584 testJSONMarshal(t, u, want) 17585 } 17586 17587 func TestSecurityAdvisoryEvent_Marshal(t *testing.T) { 17588 t.Parallel() 17589 testJSONMarshal(t, &SecurityAdvisoryEvent{}, "{}") 17590 u := &SecurityAdvisoryEvent{ 17591 Action: Ptr("published"), 17592 SecurityAdvisory: &SecurityAdvisory{ 17593 CVSS: &AdvisoryCVSS{ 17594 Score: Ptr(1.0), 17595 VectorString: Ptr("vs"), 17596 }, 17597 CWEs: []*AdvisoryCWEs{ 17598 { 17599 CWEID: Ptr("cweid"), 17600 Name: Ptr("n"), 17601 }, 17602 }, 17603 GHSAID: Ptr("GHSA-rf4j-j272-some"), 17604 Summary: Ptr("Siuuuuuuuuu"), 17605 Description: Ptr("desc"), 17606 Severity: Ptr("moderate"), 17607 Identifiers: []*AdvisoryIdentifier{ 17608 { 17609 Value: Ptr("GHSA-rf4j-j272-some"), 17610 Type: Ptr("GHSA"), 17611 }, 17612 }, 17613 References: []*AdvisoryReference{ 17614 { 17615 URL: Ptr("https://some-url"), 17616 }, 17617 }, 17618 PublishedAt: &Timestamp{referenceTime}, 17619 UpdatedAt: &Timestamp{referenceTime}, 17620 WithdrawnAt: nil, 17621 Vulnerabilities: []*AdvisoryVulnerability{ 17622 { 17623 Package: &VulnerabilityPackage{ 17624 Ecosystem: Ptr("ucl"), 17625 Name: Ptr("penaldo"), 17626 }, 17627 Severity: Ptr("moderate"), 17628 VulnerableVersionRange: Ptr(">= 2.0.0, < 2.0.2"), 17629 FirstPatchedVersion: &FirstPatchedVersion{ 17630 Identifier: Ptr("2.0.2"), 17631 }, 17632 }, 17633 }, 17634 }, 17635 Enterprise: &Enterprise{ 17636 ID: Ptr(1), 17637 Slug: Ptr("s"), 17638 Name: Ptr("n"), 17639 NodeID: Ptr("nid"), 17640 AvatarURL: Ptr("au"), 17641 Description: Ptr("d"), 17642 WebsiteURL: Ptr("wu"), 17643 HTMLURL: Ptr("hu"), 17644 CreatedAt: &Timestamp{referenceTime}, 17645 UpdatedAt: &Timestamp{referenceTime}, 17646 }, 17647 Installation: &Installation{ 17648 ID: Ptr(int64(1)), 17649 NodeID: Ptr("nid"), 17650 AppID: Ptr(int64(1)), 17651 AppSlug: Ptr("as"), 17652 TargetID: Ptr(int64(1)), 17653 Account: &User{ 17654 Login: Ptr("l"), 17655 ID: Ptr(int64(1)), 17656 URL: Ptr("u"), 17657 AvatarURL: Ptr("a"), 17658 GravatarID: Ptr("g"), 17659 Name: Ptr("n"), 17660 Company: Ptr("c"), 17661 Blog: Ptr("b"), 17662 Location: Ptr("l"), 17663 Email: Ptr("e"), 17664 Hireable: Ptr(true), 17665 Bio: Ptr("b"), 17666 TwitterUsername: Ptr("t"), 17667 PublicRepos: Ptr(1), 17668 Followers: Ptr(1), 17669 Following: Ptr(1), 17670 CreatedAt: &Timestamp{referenceTime}, 17671 SuspendedAt: &Timestamp{referenceTime}, 17672 }, 17673 AccessTokensURL: Ptr("atu"), 17674 RepositoriesURL: Ptr("ru"), 17675 HTMLURL: Ptr("hu"), 17676 TargetType: Ptr("tt"), 17677 SingleFileName: Ptr("sfn"), 17678 RepositorySelection: Ptr("rs"), 17679 Events: []string{"e"}, 17680 SingleFilePaths: []string{"s"}, 17681 Permissions: &InstallationPermissions{ 17682 Actions: Ptr("a"), 17683 Administration: Ptr("ad"), 17684 Checks: Ptr("c"), 17685 Contents: Ptr("co"), 17686 ContentReferences: Ptr("cr"), 17687 Deployments: Ptr("d"), 17688 Environments: Ptr("e"), 17689 Issues: Ptr("i"), 17690 Metadata: Ptr("md"), 17691 Members: Ptr("m"), 17692 OrganizationAdministration: Ptr("oa"), 17693 OrganizationHooks: Ptr("oh"), 17694 OrganizationPlan: Ptr("op"), 17695 OrganizationPreReceiveHooks: Ptr("opr"), 17696 OrganizationProjects: Ptr("op"), 17697 OrganizationSecrets: Ptr("os"), 17698 OrganizationSelfHostedRunners: Ptr("osh"), 17699 OrganizationUserBlocking: Ptr("oub"), 17700 Packages: Ptr("pkg"), 17701 Pages: Ptr("pg"), 17702 PullRequests: Ptr("pr"), 17703 RepositoryHooks: Ptr("rh"), 17704 RepositoryProjects: Ptr("rp"), 17705 RepositoryPreReceiveHooks: Ptr("rprh"), 17706 Secrets: Ptr("s"), 17707 SecretScanningAlerts: Ptr("ssa"), 17708 SecurityEvents: Ptr("se"), 17709 SingleFile: Ptr("sf"), 17710 Statuses: Ptr("s"), 17711 TeamDiscussions: Ptr("td"), 17712 VulnerabilityAlerts: Ptr("va"), 17713 Workflows: Ptr("w"), 17714 }, 17715 CreatedAt: &Timestamp{referenceTime}, 17716 UpdatedAt: &Timestamp{referenceTime}, 17717 HasMultipleSingleFiles: Ptr(false), 17718 SuspendedBy: &User{ 17719 Login: Ptr("l"), 17720 ID: Ptr(int64(1)), 17721 URL: Ptr("u"), 17722 AvatarURL: Ptr("a"), 17723 GravatarID: Ptr("g"), 17724 Name: Ptr("n"), 17725 Company: Ptr("c"), 17726 Blog: Ptr("b"), 17727 Location: Ptr("l"), 17728 Email: Ptr("e"), 17729 Hireable: Ptr(true), 17730 Bio: Ptr("b"), 17731 TwitterUsername: Ptr("t"), 17732 PublicRepos: Ptr(1), 17733 Followers: Ptr(1), 17734 Following: Ptr(1), 17735 CreatedAt: &Timestamp{referenceTime}, 17736 SuspendedAt: &Timestamp{referenceTime}, 17737 }, 17738 SuspendedAt: &Timestamp{referenceTime}, 17739 }, 17740 Organization: &Organization{ 17741 BillingEmail: Ptr("be"), 17742 Blog: Ptr("b"), 17743 Company: Ptr("c"), 17744 Email: Ptr("e"), 17745 TwitterUsername: Ptr("tu"), 17746 Location: Ptr("loc"), 17747 Name: Ptr("n"), 17748 Description: Ptr("d"), 17749 IsVerified: Ptr(true), 17750 HasOrganizationProjects: Ptr(true), 17751 HasRepositoryProjects: Ptr(true), 17752 DefaultRepoPermission: Ptr("drp"), 17753 MembersCanCreateRepos: Ptr(true), 17754 MembersCanCreateInternalRepos: Ptr(true), 17755 MembersCanCreatePrivateRepos: Ptr(true), 17756 MembersCanCreatePublicRepos: Ptr(false), 17757 MembersAllowedRepositoryCreationType: Ptr("marct"), 17758 MembersCanCreatePages: Ptr(true), 17759 MembersCanCreatePublicPages: Ptr(false), 17760 MembersCanCreatePrivatePages: Ptr(true), 17761 }, 17762 Repository: &Repository{ 17763 ID: Ptr(int64(1)), 17764 URL: Ptr("s"), 17765 Name: Ptr("n"), 17766 }, 17767 Sender: &User{ 17768 Login: Ptr("l"), 17769 ID: Ptr(int64(1)), 17770 NodeID: Ptr("n"), 17771 URL: Ptr("u"), 17772 ReposURL: Ptr("r"), 17773 EventsURL: Ptr("e"), 17774 AvatarURL: Ptr("a"), 17775 }, 17776 } 17777 17778 want := `{ 17779 "action": "published", 17780 "security_advisory": { 17781 "ghsa_id": "GHSA-rf4j-j272-some", 17782 "summary": "Siuuuuuuuuu", 17783 "cvss": { 17784 "score": 1.0, 17785 "vector_string": "vs" 17786 }, 17787 "cwes": [ 17788 { 17789 "cwe_id": "cweid", 17790 "name": "n" 17791 } 17792 ], 17793 "description": "desc", 17794 "severity": "moderate", 17795 "identifiers": [ 17796 { 17797 "value": "GHSA-rf4j-j272-some", 17798 "type": "GHSA" 17799 } 17800 ], 17801 "references": [ 17802 { 17803 "url": "https://some-url" 17804 } 17805 ], 17806 "published_at": ` + referenceTimeStr + `, 17807 "updated_at": ` + referenceTimeStr + `, 17808 "withdrawn_at": null, 17809 "vulnerabilities": [ 17810 { 17811 "package": { 17812 "ecosystem": "ucl", 17813 "name": "penaldo" 17814 }, 17815 "severity": "moderate", 17816 "vulnerable_version_range": ">= 2.0.0, < 2.0.2", 17817 "first_patched_version": { 17818 "identifier": "2.0.2" 17819 } 17820 } 17821 ] 17822 }, 17823 "enterprise": { 17824 "id": 1, 17825 "slug": "s", 17826 "name": "n", 17827 "node_id": "nid", 17828 "avatar_url": "au", 17829 "description": "d", 17830 "website_url": "wu", 17831 "html_url": "hu", 17832 "created_at": ` + referenceTimeStr + `, 17833 "updated_at": ` + referenceTimeStr + ` 17834 }, 17835 "installation": { 17836 "id": 1, 17837 "node_id": "nid", 17838 "app_id": 1, 17839 "app_slug": "as", 17840 "target_id": 1, 17841 "account": { 17842 "login": "l", 17843 "id": 1, 17844 "avatar_url": "a", 17845 "gravatar_id": "g", 17846 "name": "n", 17847 "company": "c", 17848 "blog": "b", 17849 "location": "l", 17850 "email": "e", 17851 "hireable": true, 17852 "bio": "b", 17853 "twitter_username": "t", 17854 "public_repos": 1, 17855 "followers": 1, 17856 "following": 1, 17857 "created_at": ` + referenceTimeStr + `, 17858 "suspended_at": ` + referenceTimeStr + `, 17859 "url": "u" 17860 }, 17861 "access_tokens_url": "atu", 17862 "repositories_url": "ru", 17863 "html_url": "hu", 17864 "target_type": "tt", 17865 "single_file_name": "sfn", 17866 "repository_selection": "rs", 17867 "events": [ 17868 "e" 17869 ], 17870 "single_file_paths": [ 17871 "s" 17872 ], 17873 "permissions": { 17874 "actions": "a", 17875 "administration": "ad", 17876 "checks": "c", 17877 "contents": "co", 17878 "content_references": "cr", 17879 "deployments": "d", 17880 "environments": "e", 17881 "issues": "i", 17882 "metadata": "md", 17883 "members": "m", 17884 "organization_administration": "oa", 17885 "organization_hooks": "oh", 17886 "organization_plan": "op", 17887 "organization_pre_receive_hooks": "opr", 17888 "organization_projects": "op", 17889 "organization_secrets": "os", 17890 "organization_self_hosted_runners": "osh", 17891 "organization_user_blocking": "oub", 17892 "packages": "pkg", 17893 "pages": "pg", 17894 "pull_requests": "pr", 17895 "repository_hooks": "rh", 17896 "repository_projects": "rp", 17897 "repository_pre_receive_hooks": "rprh", 17898 "secrets": "s", 17899 "secret_scanning_alerts": "ssa", 17900 "security_events": "se", 17901 "single_file": "sf", 17902 "statuses": "s", 17903 "team_discussions": "td", 17904 "vulnerability_alerts": "va", 17905 "workflows": "w" 17906 }, 17907 "created_at": ` + referenceTimeStr + `, 17908 "updated_at": ` + referenceTimeStr + `, 17909 "has_multiple_single_files": false, 17910 "suspended_by": { 17911 "login": "l", 17912 "id": 1, 17913 "avatar_url": "a", 17914 "gravatar_id": "g", 17915 "name": "n", 17916 "company": "c", 17917 "blog": "b", 17918 "location": "l", 17919 "email": "e", 17920 "hireable": true, 17921 "bio": "b", 17922 "twitter_username": "t", 17923 "public_repos": 1, 17924 "followers": 1, 17925 "following": 1, 17926 "created_at": ` + referenceTimeStr + `, 17927 "suspended_at": ` + referenceTimeStr + `, 17928 "url": "u" 17929 }, 17930 "suspended_at": ` + referenceTimeStr + ` 17931 }, 17932 "organization": { 17933 "name": "n", 17934 "company": "c", 17935 "blog": "b", 17936 "location": "loc", 17937 "email": "e", 17938 "twitter_username": "tu", 17939 "description": "d", 17940 "billing_email": "be", 17941 "is_verified": true, 17942 "has_organization_projects": true, 17943 "has_repository_projects": true, 17944 "default_repository_permission": "drp", 17945 "members_can_create_repositories": true, 17946 "members_can_create_public_repositories": false, 17947 "members_can_create_private_repositories": true, 17948 "members_can_create_internal_repositories": true, 17949 "members_allowed_repository_creation_type": "marct", 17950 "members_can_create_pages": true, 17951 "members_can_create_public_pages": false, 17952 "members_can_create_private_pages": true 17953 }, 17954 "repository": { 17955 "id": 1, 17956 "url": "s", 17957 "name": "n" 17958 }, 17959 "sender": { 17960 "login": "l", 17961 "id": 1, 17962 "node_id": "n", 17963 "avatar_url": "a", 17964 "url": "u", 17965 "events_url": "e", 17966 "repos_url": "r" 17967 } 17968 }` 17969 17970 testJSONMarshal(t, u, want) 17971 } 17972 17973 func TestSecurityAndAnalysisEvent_Marshal(t *testing.T) { 17974 t.Parallel() 17975 testJSONMarshal(t, &SecurityAndAnalysisEvent{}, "{}") 17976 17977 u := &SecurityAndAnalysisEvent{ 17978 Changes: &SecurityAndAnalysisChange{ 17979 From: &SecurityAndAnalysisChangeFrom{ 17980 SecurityAndAnalysis: &SecurityAndAnalysis{ 17981 AdvancedSecurity: &AdvancedSecurity{ 17982 Status: Ptr("enabled"), 17983 }, 17984 SecretScanning: &SecretScanning{ 17985 Status: Ptr("enabled"), 17986 }, 17987 SecretScanningPushProtection: &SecretScanningPushProtection{ 17988 Status: Ptr("enabled"), 17989 }, 17990 DependabotSecurityUpdates: &DependabotSecurityUpdates{ 17991 Status: Ptr("enabled"), 17992 }, 17993 }, 17994 }, 17995 }, 17996 Enterprise: &Enterprise{ 17997 ID: Ptr(1), 17998 Slug: Ptr("s"), 17999 Name: Ptr("n"), 18000 NodeID: Ptr("nid"), 18001 AvatarURL: Ptr("au"), 18002 Description: Ptr("d"), 18003 WebsiteURL: Ptr("wu"), 18004 HTMLURL: Ptr("hu"), 18005 CreatedAt: &Timestamp{referenceTime}, 18006 UpdatedAt: &Timestamp{referenceTime}, 18007 }, 18008 Installation: &Installation{ 18009 ID: Ptr(int64(1)), 18010 NodeID: Ptr("nid"), 18011 AppID: Ptr(int64(1)), 18012 AppSlug: Ptr("as"), 18013 TargetID: Ptr(int64(1)), 18014 Account: &User{ 18015 Login: Ptr("l"), 18016 ID: Ptr(int64(1)), 18017 URL: Ptr("u"), 18018 AvatarURL: Ptr("a"), 18019 GravatarID: Ptr("g"), 18020 Name: Ptr("n"), 18021 Company: Ptr("c"), 18022 Blog: Ptr("b"), 18023 Location: Ptr("l"), 18024 Email: Ptr("e"), 18025 Hireable: Ptr(true), 18026 Bio: Ptr("b"), 18027 TwitterUsername: Ptr("t"), 18028 PublicRepos: Ptr(1), 18029 Followers: Ptr(1), 18030 Following: Ptr(1), 18031 CreatedAt: &Timestamp{referenceTime}, 18032 SuspendedAt: &Timestamp{referenceTime}, 18033 }, 18034 AccessTokensURL: Ptr("atu"), 18035 RepositoriesURL: Ptr("ru"), 18036 HTMLURL: Ptr("hu"), 18037 TargetType: Ptr("tt"), 18038 SingleFileName: Ptr("sfn"), 18039 RepositorySelection: Ptr("rs"), 18040 Events: []string{"e"}, 18041 SingleFilePaths: []string{"s"}, 18042 Permissions: &InstallationPermissions{ 18043 Actions: Ptr("a"), 18044 Administration: Ptr("ad"), 18045 Checks: Ptr("c"), 18046 Contents: Ptr("co"), 18047 ContentReferences: Ptr("cr"), 18048 Deployments: Ptr("d"), 18049 Environments: Ptr("e"), 18050 Issues: Ptr("i"), 18051 Metadata: Ptr("md"), 18052 Members: Ptr("m"), 18053 OrganizationAdministration: Ptr("oa"), 18054 OrganizationHooks: Ptr("oh"), 18055 OrganizationPlan: Ptr("op"), 18056 OrganizationPreReceiveHooks: Ptr("opr"), 18057 OrganizationProjects: Ptr("op"), 18058 OrganizationSecrets: Ptr("os"), 18059 OrganizationSelfHostedRunners: Ptr("osh"), 18060 OrganizationUserBlocking: Ptr("oub"), 18061 Packages: Ptr("pkg"), 18062 Pages: Ptr("pg"), 18063 PullRequests: Ptr("pr"), 18064 RepositoryHooks: Ptr("rh"), 18065 RepositoryProjects: Ptr("rp"), 18066 RepositoryPreReceiveHooks: Ptr("rprh"), 18067 Secrets: Ptr("s"), 18068 SecretScanningAlerts: Ptr("ssa"), 18069 SecurityEvents: Ptr("se"), 18070 SingleFile: Ptr("sf"), 18071 Statuses: Ptr("s"), 18072 TeamDiscussions: Ptr("td"), 18073 VulnerabilityAlerts: Ptr("va"), 18074 Workflows: Ptr("w"), 18075 }, 18076 CreatedAt: &Timestamp{referenceTime}, 18077 UpdatedAt: &Timestamp{referenceTime}, 18078 HasMultipleSingleFiles: Ptr(false), 18079 SuspendedBy: &User{ 18080 Login: Ptr("l"), 18081 ID: Ptr(int64(1)), 18082 URL: Ptr("u"), 18083 AvatarURL: Ptr("a"), 18084 GravatarID: Ptr("g"), 18085 Name: Ptr("n"), 18086 Company: Ptr("c"), 18087 Blog: Ptr("b"), 18088 Location: Ptr("l"), 18089 Email: Ptr("e"), 18090 Hireable: Ptr(true), 18091 Bio: Ptr("b"), 18092 TwitterUsername: Ptr("t"), 18093 PublicRepos: Ptr(1), 18094 Followers: Ptr(1), 18095 Following: Ptr(1), 18096 CreatedAt: &Timestamp{referenceTime}, 18097 SuspendedAt: &Timestamp{referenceTime}, 18098 }, 18099 SuspendedAt: &Timestamp{referenceTime}, 18100 }, 18101 Organization: &Organization{ 18102 BillingEmail: Ptr("be"), 18103 Blog: Ptr("b"), 18104 Company: Ptr("c"), 18105 Email: Ptr("e"), 18106 TwitterUsername: Ptr("tu"), 18107 Location: Ptr("loc"), 18108 Name: Ptr("n"), 18109 Description: Ptr("d"), 18110 IsVerified: Ptr(true), 18111 HasOrganizationProjects: Ptr(true), 18112 HasRepositoryProjects: Ptr(true), 18113 DefaultRepoPermission: Ptr("drp"), 18114 MembersCanCreateRepos: Ptr(true), 18115 MembersCanCreateInternalRepos: Ptr(true), 18116 MembersCanCreatePrivateRepos: Ptr(true), 18117 MembersCanCreatePublicRepos: Ptr(false), 18118 MembersAllowedRepositoryCreationType: Ptr("marct"), 18119 MembersCanCreatePages: Ptr(true), 18120 MembersCanCreatePublicPages: Ptr(false), 18121 MembersCanCreatePrivatePages: Ptr(true), 18122 }, 18123 Repository: &Repository{ 18124 ID: Ptr(int64(1)), 18125 URL: Ptr("s"), 18126 Name: Ptr("n"), 18127 }, 18128 Sender: &User{ 18129 Login: Ptr("l"), 18130 ID: Ptr(int64(1)), 18131 NodeID: Ptr("n"), 18132 URL: Ptr("u"), 18133 ReposURL: Ptr("r"), 18134 EventsURL: Ptr("e"), 18135 AvatarURL: Ptr("a"), 18136 }, 18137 } 18138 18139 want := `{ 18140 "changes": { 18141 "from": { 18142 "security_and_analysis": { 18143 "advanced_security": { 18144 "status": "enabled" 18145 }, 18146 "secret_scanning": { 18147 "status": "enabled" 18148 }, 18149 "secret_scanning_push_protection": { 18150 "status": "enabled" 18151 }, 18152 "dependabot_security_updates": { 18153 "status": "enabled" 18154 } 18155 } 18156 } 18157 }, 18158 "enterprise": { 18159 "id": 1, 18160 "slug": "s", 18161 "name": "n", 18162 "node_id": "nid", 18163 "avatar_url": "au", 18164 "description": "d", 18165 "website_url": "wu", 18166 "html_url": "hu", 18167 "created_at": ` + referenceTimeStr + `, 18168 "updated_at": ` + referenceTimeStr + ` 18169 }, 18170 "installation": { 18171 "id": 1, 18172 "node_id": "nid", 18173 "app_id": 1, 18174 "app_slug": "as", 18175 "target_id": 1, 18176 "account": { 18177 "login": "l", 18178 "id": 1, 18179 "avatar_url": "a", 18180 "gravatar_id": "g", 18181 "name": "n", 18182 "company": "c", 18183 "blog": "b", 18184 "location": "l", 18185 "email": "e", 18186 "hireable": true, 18187 "bio": "b", 18188 "twitter_username": "t", 18189 "public_repos": 1, 18190 "followers": 1, 18191 "following": 1, 18192 "created_at": ` + referenceTimeStr + `, 18193 "suspended_at": ` + referenceTimeStr + `, 18194 "url": "u" 18195 }, 18196 "access_tokens_url": "atu", 18197 "repositories_url": "ru", 18198 "html_url": "hu", 18199 "target_type": "tt", 18200 "single_file_name": "sfn", 18201 "repository_selection": "rs", 18202 "events": [ 18203 "e" 18204 ], 18205 "single_file_paths": [ 18206 "s" 18207 ], 18208 "permissions": { 18209 "actions": "a", 18210 "administration": "ad", 18211 "checks": "c", 18212 "contents": "co", 18213 "content_references": "cr", 18214 "deployments": "d", 18215 "environments": "e", 18216 "issues": "i", 18217 "metadata": "md", 18218 "members": "m", 18219 "organization_administration": "oa", 18220 "organization_hooks": "oh", 18221 "organization_plan": "op", 18222 "organization_pre_receive_hooks": "opr", 18223 "organization_projects": "op", 18224 "organization_secrets": "os", 18225 "organization_self_hosted_runners": "osh", 18226 "organization_user_blocking": "oub", 18227 "packages": "pkg", 18228 "pages": "pg", 18229 "pull_requests": "pr", 18230 "repository_hooks": "rh", 18231 "repository_projects": "rp", 18232 "repository_pre_receive_hooks": "rprh", 18233 "secrets": "s", 18234 "secret_scanning_alerts": "ssa", 18235 "security_events": "se", 18236 "single_file": "sf", 18237 "statuses": "s", 18238 "team_discussions": "td", 18239 "vulnerability_alerts": "va", 18240 "workflows": "w" 18241 }, 18242 "created_at": ` + referenceTimeStr + `, 18243 "updated_at": ` + referenceTimeStr + `, 18244 "has_multiple_single_files": false, 18245 "suspended_by": { 18246 "login": "l", 18247 "id": 1, 18248 "avatar_url": "a", 18249 "gravatar_id": "g", 18250 "name": "n", 18251 "company": "c", 18252 "blog": "b", 18253 "location": "l", 18254 "email": "e", 18255 "hireable": true, 18256 "bio": "b", 18257 "twitter_username": "t", 18258 "public_repos": 1, 18259 "followers": 1, 18260 "following": 1, 18261 "created_at": ` + referenceTimeStr + `, 18262 "suspended_at": ` + referenceTimeStr + `, 18263 "url": "u" 18264 }, 18265 "suspended_at": ` + referenceTimeStr + ` 18266 }, 18267 "organization": { 18268 "name": "n", 18269 "company": "c", 18270 "blog": "b", 18271 "location": "loc", 18272 "email": "e", 18273 "twitter_username": "tu", 18274 "description": "d", 18275 "billing_email": "be", 18276 "is_verified": true, 18277 "has_organization_projects": true, 18278 "has_repository_projects": true, 18279 "default_repository_permission": "drp", 18280 "members_can_create_repositories": true, 18281 "members_can_create_public_repositories": false, 18282 "members_can_create_private_repositories": true, 18283 "members_can_create_internal_repositories": true, 18284 "members_allowed_repository_creation_type": "marct", 18285 "members_can_create_pages": true, 18286 "members_can_create_public_pages": false, 18287 "members_can_create_private_pages": true 18288 }, 18289 "repository": { 18290 "id": 1, 18291 "url": "s", 18292 "name": "n" 18293 }, 18294 "sender": { 18295 "login": "l", 18296 "id": 1, 18297 "node_id": "n", 18298 "avatar_url": "a", 18299 "url": "u", 18300 "events_url": "e", 18301 "repos_url": "r" 18302 }, 18303 "target_type": "running" 18304 }` 18305 18306 testJSONMarshal(t, u, want) 18307 } 18308 18309 func TestCodeScanningAlertEvent_Marshal(t *testing.T) { 18310 t.Parallel() 18311 testJSONMarshal(t, &CodeScanningAlertEvent{}, "{}") 18312 18313 u := &CodeScanningAlertEvent{ 18314 Action: Ptr("reopened"), 18315 Alert: &Alert{ 18316 Number: Ptr(10), 18317 Rule: &Rule{ 18318 ID: Ptr("Style/FrozenStringLiteralComment"), 18319 Severity: Ptr("note"), 18320 Description: Ptr("desc"), 18321 FullDescription: Ptr("full desc"), 18322 Tags: []string{"style"}, 18323 Help: Ptr("help"), 18324 }, 18325 Tool: &Tool{ 18326 Name: Ptr("Rubocop"), 18327 Version: nil, 18328 }, 18329 CreatedAt: &Timestamp{referenceTime}, 18330 UpdatedAt: &Timestamp{referenceTime}, 18331 FixedAt: nil, 18332 State: Ptr("open"), 18333 URL: Ptr("a"), 18334 HTMLURL: Ptr("a"), 18335 Instances: []*MostRecentInstance{ 18336 { 18337 Ref: Ptr("refs/heads/main"), 18338 AnalysisKey: Ptr(".github/workflows/workflow.yml:upload"), 18339 Environment: Ptr("{}"), 18340 State: Ptr("open"), 18341 }, 18342 }, 18343 DismissedBy: nil, 18344 DismissedAt: nil, 18345 DismissedReason: nil, 18346 }, 18347 Ref: Ptr("refs/heads/main"), 18348 CommitOID: Ptr("d6e4c75c141dbacecc279b721b8bsomeSHA"), 18349 Repo: &Repository{ 18350 ID: Ptr(int64(1234234535)), 18351 NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxODY4NT=="), 18352 Owner: &User{ 18353 Login: Ptr("Codertocat"), 18354 ID: Ptr(int64(21031067)), 18355 NodeID: Ptr("MDQ6VXNlcjIxMDMxMDY3"), 18356 AvatarURL: Ptr("a"), 18357 GravatarID: Ptr(""), 18358 URL: Ptr("a"), 18359 HTMLURL: Ptr("a"), 18360 Type: Ptr("User"), 18361 SiteAdmin: Ptr(false), 18362 FollowersURL: Ptr("a"), 18363 FollowingURL: Ptr("a"), 18364 EventsURL: Ptr("a"), 18365 GistsURL: Ptr("a"), 18366 OrganizationsURL: Ptr("a"), 18367 ReceivedEventsURL: Ptr("a"), 18368 ReposURL: Ptr("a"), 18369 StarredURL: Ptr("a"), 18370 SubscriptionsURL: Ptr("a"), 18371 }, 18372 HTMLURL: Ptr("a"), 18373 Name: Ptr("Hello-World"), 18374 FullName: Ptr("Codertocat/Hello-World"), 18375 Description: nil, 18376 Fork: Ptr(false), 18377 Homepage: nil, 18378 DefaultBranch: Ptr("main"), 18379 CreatedAt: &Timestamp{referenceTime}, 18380 PushedAt: &Timestamp{referenceTime}, 18381 UpdatedAt: &Timestamp{referenceTime}, 18382 CloneURL: Ptr("a"), 18383 GitURL: Ptr("a"), 18384 MirrorURL: nil, 18385 SSHURL: Ptr("a"), 18386 SVNURL: Ptr("a"), 18387 Language: nil, 18388 ForksCount: Ptr(0), 18389 OpenIssuesCount: Ptr(2), 18390 OpenIssues: Ptr(2), 18391 StargazersCount: Ptr(0), 18392 WatchersCount: Ptr(0), 18393 Watchers: Ptr(0), 18394 Size: Ptr(0), 18395 Archived: Ptr(false), 18396 Disabled: Ptr(false), 18397 License: nil, 18398 Private: Ptr(false), 18399 HasIssues: Ptr(true), 18400 HasWiki: Ptr(true), 18401 HasPages: Ptr(true), 18402 HasProjects: Ptr(true), 18403 HasDownloads: Ptr(true), 18404 URL: Ptr("a"), 18405 ArchiveURL: Ptr("a"), 18406 AssigneesURL: Ptr("a"), 18407 BlobsURL: Ptr("a"), 18408 BranchesURL: Ptr("a"), 18409 CollaboratorsURL: Ptr("a"), 18410 CommentsURL: Ptr("a"), 18411 CommitsURL: Ptr("a"), 18412 CompareURL: Ptr("a"), 18413 ContentsURL: Ptr("a"), 18414 ContributorsURL: Ptr("a"), 18415 DeploymentsURL: Ptr("a"), 18416 DownloadsURL: Ptr("a"), 18417 EventsURL: Ptr("a"), 18418 ForksURL: Ptr("a"), 18419 GitCommitsURL: Ptr("a"), 18420 GitRefsURL: Ptr("a"), 18421 GitTagsURL: Ptr("a"), 18422 HooksURL: Ptr("a"), 18423 IssueCommentURL: Ptr("a"), 18424 IssueEventsURL: Ptr("a"), 18425 IssuesURL: Ptr("a"), 18426 KeysURL: Ptr("a"), 18427 LabelsURL: Ptr("a"), 18428 LanguagesURL: Ptr("a"), 18429 MergesURL: Ptr("a"), 18430 MilestonesURL: Ptr("a"), 18431 NotificationsURL: Ptr("a"), 18432 PullsURL: Ptr("a"), 18433 ReleasesURL: Ptr("a"), 18434 StargazersURL: Ptr("a"), 18435 StatusesURL: Ptr("a"), 18436 SubscribersURL: Ptr("a"), 18437 SubscriptionURL: Ptr("a"), 18438 TagsURL: Ptr("a"), 18439 TreesURL: Ptr("a"), 18440 TeamsURL: Ptr("a"), 18441 }, 18442 Org: &Organization{ 18443 Login: Ptr("Octocoders"), 18444 ID: Ptr(int64(6)), 18445 NodeID: Ptr("MDEyOk9yZ2FuaXphdGlvbjY="), 18446 AvatarURL: Ptr("a"), 18447 Description: Ptr(""), 18448 URL: Ptr("a"), 18449 EventsURL: Ptr("a"), 18450 HooksURL: Ptr("a"), 18451 IssuesURL: Ptr("a"), 18452 MembersURL: Ptr("a"), 18453 PublicMembersURL: Ptr("a"), 18454 ReposURL: Ptr("a"), 18455 }, 18456 Sender: &User{ 18457 Login: Ptr("github"), 18458 ID: Ptr(int64(9919)), 18459 NodeID: Ptr("MDEyOk9yZ2FuaXphdGlvbjk5MTk="), 18460 AvatarURL: Ptr("a"), 18461 HTMLURL: Ptr("a"), 18462 GravatarID: Ptr(""), 18463 Type: Ptr("Organization"), 18464 SiteAdmin: Ptr(false), 18465 URL: Ptr("a"), 18466 EventsURL: Ptr("a"), 18467 FollowingURL: Ptr("a"), 18468 FollowersURL: Ptr("a"), 18469 GistsURL: Ptr("a"), 18470 OrganizationsURL: Ptr("a"), 18471 ReceivedEventsURL: Ptr("a"), 18472 ReposURL: Ptr("a"), 18473 StarredURL: Ptr("a"), 18474 SubscriptionsURL: Ptr("a"), 18475 }, 18476 } 18477 18478 want := `{ 18479 "action": "reopened", 18480 "alert": { 18481 "number": 10, 18482 "created_at": ` + referenceTimeStr + `, 18483 "updated_at": ` + referenceTimeStr + `, 18484 "url": "a", 18485 "html_url": "a", 18486 "instances": [ 18487 { 18488 "ref": "refs/heads/main", 18489 "analysis_key": ".github/workflows/workflow.yml:upload", 18490 "environment": "{}", 18491 "state": "open" 18492 } 18493 ], 18494 "state": "open", 18495 "fixed_at": null, 18496 "dismissed_by": null, 18497 "dismissed_at": null, 18498 "dismissed_reason": null, 18499 "rule": { 18500 "id": "Style/FrozenStringLiteralComment", 18501 "severity": "note", 18502 "description": "desc", 18503 "full_description": "full desc", 18504 "tags": [ 18505 "style" 18506 ], 18507 "help": "help" 18508 }, 18509 "tool": { 18510 "name": "Rubocop", 18511 "version": null 18512 } 18513 }, 18514 "ref": "refs/heads/main", 18515 "commit_oid": "d6e4c75c141dbacecc279b721b8bsomeSHA", 18516 "repository": { 18517 "id": 1234234535, 18518 "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NT==", 18519 "name": "Hello-World", 18520 "full_name": "Codertocat/Hello-World", 18521 "private": false, 18522 "owner": { 18523 "login": "Codertocat", 18524 "id": 21031067, 18525 "node_id": "MDQ6VXNlcjIxMDMxMDY3", 18526 "avatar_url": "a", 18527 "gravatar_id": "", 18528 "url": "a", 18529 "html_url": "a", 18530 "followers_url": "a", 18531 "following_url": "a", 18532 "gists_url": "a", 18533 "starred_url": "a", 18534 "subscriptions_url": "a", 18535 "organizations_url": "a", 18536 "repos_url": "a", 18537 "events_url": "a", 18538 "received_events_url": "a", 18539 "type": "User", 18540 "site_admin": false 18541 }, 18542 "html_url": "a", 18543 "description": null, 18544 "fork": false, 18545 "url": "a", 18546 "forks_url": "a", 18547 "keys_url": "a", 18548 "collaborators_url": "a", 18549 "teams_url": "a", 18550 "hooks_url": "a", 18551 "issue_events_url": "a", 18552 "events_url": "a", 18553 "assignees_url": "a", 18554 "branches_url": "a", 18555 "tags_url": "a", 18556 "blobs_url": "a", 18557 "git_tags_url": "a", 18558 "git_refs_url": "a", 18559 "trees_url": "a", 18560 "statuses_url": "a", 18561 "languages_url": "a", 18562 "stargazers_url": "a", 18563 "contributors_url": "a", 18564 "subscribers_url": "a", 18565 "subscription_url": "a", 18566 "commits_url": "a", 18567 "git_commits_url": "a", 18568 "comments_url": "a", 18569 "issue_comment_url": "a", 18570 "contents_url": "a", 18571 "compare_url": "a", 18572 "merges_url": "a", 18573 "archive_url": "a", 18574 "downloads_url": "a", 18575 "issues_url": "a", 18576 "pulls_url": "a", 18577 "milestones_url": "a", 18578 "notifications_url": "a", 18579 "labels_url": "a", 18580 "releases_url": "a", 18581 "deployments_url": "a", 18582 "created_at": ` + referenceTimeStr + `, 18583 "updated_at": ` + referenceTimeStr + `, 18584 "pushed_at": ` + referenceTimeStr + `, 18585 "git_url": "a", 18586 "ssh_url": "a", 18587 "clone_url": "a", 18588 "svn_url": "a", 18589 "homepage": null, 18590 "size": 0, 18591 "stargazers_count": 0, 18592 "watchers_count": 0, 18593 "language": null, 18594 "has_issues": true, 18595 "has_projects": true, 18596 "has_downloads": true, 18597 "has_wiki": true, 18598 "has_pages": true, 18599 "forks_count": 0, 18600 "mirror_url": null, 18601 "archived": false, 18602 "disabled": false, 18603 "open_issues_count": 2, 18604 "license": null, 18605 "forks": 0, 18606 "open_issues": 2, 18607 "watchers": 0, 18608 "default_branch": "main" 18609 }, 18610 "organization": { 18611 "login": "Octocoders", 18612 "id": 6, 18613 "node_id": "MDEyOk9yZ2FuaXphdGlvbjY=", 18614 "url": "a", 18615 "repos_url": "a", 18616 "events_url": "a", 18617 "hooks_url": "a", 18618 "issues_url": "a", 18619 "members_url": "a", 18620 "public_members_url": "a", 18621 "avatar_url": "a", 18622 "description": "" 18623 }, 18624 "sender": { 18625 "login": "github", 18626 "id": 9919, 18627 "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", 18628 "avatar_url": "a", 18629 "gravatar_id": "", 18630 "url": "a", 18631 "html_url": "a", 18632 "followers_url": "a", 18633 "following_url": "a", 18634 "gists_url": "a", 18635 "starred_url": "a", 18636 "subscriptions_url": "a", 18637 "organizations_url": "a", 18638 "repos_url": "a", 18639 "events_url": "a", 18640 "received_events_url": "a", 18641 "type": "Organization", 18642 "site_admin": false 18643 } 18644 }` 18645 18646 testJSONMarshal(t, u, want) 18647 } 18648 18649 func TestSponsorshipEvent_Marshal(t *testing.T) { 18650 t.Parallel() 18651 testJSONMarshal(t, &SponsorshipEvent{}, "{}") 18652 18653 u := &SponsorshipEvent{ 18654 Action: Ptr("created"), 18655 EffectiveDate: Ptr("2023-01-01T00:00:00Z"), 18656 Changes: &SponsorshipChanges{ 18657 Tier: &SponsorshipTier{ 18658 From: Ptr("basic"), 18659 }, 18660 PrivacyLevel: Ptr("public"), 18661 }, 18662 Repository: &Repository{ 18663 ID: Ptr(int64(12345)), 18664 NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjM0NQ=="), 18665 Name: Ptr("example-repo"), 18666 }, 18667 Organization: &Organization{ 18668 Login: Ptr("example-org"), 18669 ID: Ptr(int64(67890)), 18670 }, 18671 Sender: &User{ 18672 Login: Ptr("example-user"), 18673 ID: Ptr(int64(1111)), 18674 }, 18675 Installation: &Installation{ 18676 ID: Ptr(int64(2222)), 18677 }, 18678 } 18679 18680 want := `{ 18681 "action": "created", 18682 "effective_date": "2023-01-01T00:00:00Z", 18683 "changes": { 18684 "tier": { 18685 "from": "basic" 18686 }, 18687 "privacy_level": "public" 18688 }, 18689 "repository": { 18690 "id": 12345, 18691 "node_id": "MDEwOlJlcG9zaXRvcnkxMjM0NQ==", 18692 "name": "example-repo" 18693 }, 18694 "organization": { 18695 "login": "example-org", 18696 "id": 67890 18697 }, 18698 "sender": { 18699 "login": "example-user", 18700 "id": 1111 18701 }, 18702 "installation": { 18703 "id": 2222 18704 } 18705 }` 18706 18707 testJSONMarshal(t, u, want) 18708 } 18709 18710 func TestSponsorshipChanges_Marshal(t *testing.T) { 18711 t.Parallel() 18712 testJSONMarshal(t, &SponsorshipChanges{}, "{}") 18713 18714 u := &SponsorshipChanges{ 18715 Tier: &SponsorshipTier{ 18716 From: Ptr("premium"), 18717 }, 18718 PrivacyLevel: Ptr("private"), 18719 } 18720 18721 want := `{ 18722 "tier": { 18723 "from": "premium" 18724 }, 18725 "privacy_level": "private" 18726 }` 18727 18728 testJSONMarshal(t, u, want) 18729 } 18730 18731 func TestSponsorshipTier_Marshal(t *testing.T) { 18732 t.Parallel() 18733 testJSONMarshal(t, &SponsorshipTier{}, "{}") 18734 18735 u := &SponsorshipTier{ 18736 From: Ptr("gold"), 18737 } 18738 18739 want := `{ 18740 "from": "gold" 18741 }` 18742 18743 testJSONMarshal(t, u, want) 18744 }