github.com/google/go-github/v71@v71.0.0/github/event_types_test.go (about) 1 // Copyright 2020 The go-github AUTHORS. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 package github 7 8 import ( 9 "encoding/json" 10 "fmt" 11 "testing" 12 13 "github.com/google/go-cmp/cmp" 14 ) 15 16 func TestEditChange_Marshal_TitleChange(t *testing.T) { 17 t.Parallel() 18 testJSONMarshal(t, &EditChange{}, "{}") 19 20 u := &EditChange{ 21 Title: &EditTitle{ 22 From: Ptr("TitleFrom"), 23 }, 24 Body: nil, 25 Base: nil, 26 } 27 28 want := `{ 29 "title": { 30 "from": "TitleFrom" 31 } 32 }` 33 34 testJSONMarshal(t, u, want) 35 } 36 37 func TestEditChange_Marshal_BodyChange(t *testing.T) { 38 t.Parallel() 39 testJSONMarshal(t, &EditChange{}, "{}") 40 41 u := &EditChange{ 42 Title: nil, 43 Body: &EditBody{ 44 From: Ptr("BodyFrom"), 45 }, 46 Base: nil, 47 } 48 49 want := `{ 50 "body": { 51 "from": "BodyFrom" 52 } 53 }` 54 55 testJSONMarshal(t, u, want) 56 } 57 58 func TestEditChange_Marshal_BaseChange(t *testing.T) { 59 t.Parallel() 60 testJSONMarshal(t, &EditChange{}, "{}") 61 62 base := EditBase{ 63 Ref: &EditRef{ 64 From: Ptr("BaseRefFrom"), 65 }, 66 SHA: &EditSHA{ 67 From: Ptr("BaseSHAFrom"), 68 }, 69 } 70 71 u := &EditChange{ 72 Title: nil, 73 Body: nil, 74 Base: &base, 75 } 76 77 want := `{ 78 "base": { 79 "ref": { 80 "from": "BaseRefFrom" 81 }, 82 "sha": { 83 "from": "BaseSHAFrom" 84 } 85 } 86 }` 87 88 testJSONMarshal(t, u, want) 89 } 90 91 func TestEditChange_Marshal_Repo(t *testing.T) { 92 t.Parallel() 93 testJSONMarshal(t, &EditChange{}, "{}") 94 95 u := &EditChange{ 96 Repo: &EditRepo{ 97 Name: &RepoName{ 98 From: Ptr("old-repo-name"), 99 }, 100 }, 101 Topics: &EditTopics{ 102 From: []string{"topic1", "topic2"}, 103 }, 104 } 105 106 want := `{ 107 "repository": { 108 "name": { 109 "from": "old-repo-name" 110 } 111 }, 112 "topics": { 113 "from": [ 114 "topic1", 115 "topic2" 116 ] 117 } 118 }` 119 120 testJSONMarshal(t, u, want) 121 } 122 123 func TestEditChange_Marshal_TransferFromUser(t *testing.T) { 124 t.Parallel() 125 testJSONMarshal(t, &EditChange{}, "{}") 126 127 u := &EditChange{ 128 Owner: &EditOwner{ 129 OwnerInfo: &OwnerInfo{ 130 User: &User{ 131 Login: Ptr("l"), 132 ID: Ptr(int64(1)), 133 NodeID: Ptr("n"), 134 URL: Ptr("u"), 135 ReposURL: Ptr("r"), 136 EventsURL: Ptr("e"), 137 AvatarURL: Ptr("a"), 138 }, 139 }, 140 }, 141 } 142 143 want := `{ 144 "owner": { 145 "from": { 146 "user": { 147 "login": "l", 148 "id": 1, 149 "node_id": "n", 150 "avatar_url": "a", 151 "url": "u", 152 "repos_url": "r", 153 "events_url": "e" 154 } 155 } 156 } 157 }` 158 159 testJSONMarshal(t, u, want) 160 } 161 162 func TestEditChange_Marshal_TransferFromOrg(t *testing.T) { 163 t.Parallel() 164 testJSONMarshal(t, &EditChange{}, "{}") 165 166 u := &EditChange{ 167 Owner: &EditOwner{ 168 OwnerInfo: &OwnerInfo{ 169 Org: &User{ 170 Login: Ptr("l"), 171 ID: Ptr(int64(1)), 172 NodeID: Ptr("n"), 173 URL: Ptr("u"), 174 ReposURL: Ptr("r"), 175 EventsURL: Ptr("e"), 176 AvatarURL: Ptr("a"), 177 }, 178 }, 179 }, 180 } 181 182 want := `{ 183 "owner": { 184 "from": { 185 "organization": { 186 "login": "l", 187 "id": 1, 188 "node_id": "n", 189 "avatar_url": "a", 190 "url": "u", 191 "repos_url": "r", 192 "events_url": "e" 193 } 194 } 195 } 196 }` 197 198 testJSONMarshal(t, u, want) 199 } 200 201 func TestProjectChange_Marshal_NameChange(t *testing.T) { 202 t.Parallel() 203 testJSONMarshal(t, &ProjectChange{}, "{}") 204 205 u := &ProjectChange{ 206 Name: &ProjectName{From: Ptr("NameFrom")}, 207 Body: nil, 208 } 209 210 want := `{ 211 "name": { 212 "from": "NameFrom" 213 } 214 }` 215 216 testJSONMarshal(t, u, want) 217 } 218 219 func TestProjectChange_Marshal_BodyChange(t *testing.T) { 220 t.Parallel() 221 testJSONMarshal(t, &ProjectChange{}, "{}") 222 223 u := &ProjectChange{ 224 Name: nil, 225 Body: &ProjectBody{From: Ptr("BodyFrom")}, 226 } 227 228 want := `{ 229 "body": { 230 "from": "BodyFrom" 231 } 232 }` 233 234 testJSONMarshal(t, u, want) 235 } 236 237 func TestProjectCardChange_Marshal_NoteChange(t *testing.T) { 238 t.Parallel() 239 testJSONMarshal(t, &ProjectCardChange{}, "{}") 240 241 u := &ProjectCardChange{ 242 Note: &ProjectCardNote{From: Ptr("NoteFrom")}, 243 } 244 245 want := `{ 246 "note": { 247 "from": "NoteFrom" 248 } 249 }` 250 251 testJSONMarshal(t, u, want) 252 } 253 254 func TestProjectColumnChange_Marshal_NameChange(t *testing.T) { 255 t.Parallel() 256 testJSONMarshal(t, &ProjectColumnChange{}, "{}") 257 258 u := &ProjectColumnChange{ 259 Name: &ProjectColumnName{From: Ptr("NameFrom")}, 260 } 261 262 want := `{ 263 "name": { 264 "from": "NameFrom" 265 } 266 }` 267 268 testJSONMarshal(t, u, want) 269 } 270 271 func TestBranchProtectionConfigurationEvent_Marshal(t *testing.T) { 272 t.Parallel() 273 testJSONMarshal(t, &BranchProtectionConfigurationEvent{}, "{}") 274 u := &BranchProtectionConfigurationEvent{ 275 Action: Ptr("enabled"), 276 Repo: &Repository{ 277 ID: Ptr(int64(12345)), 278 NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjM0NQ=="), 279 Name: Ptr("example-repo"), 280 }, 281 Org: &Organization{ 282 Login: Ptr("example-org"), 283 ID: Ptr(int64(67890)), 284 }, 285 Sender: &User{ 286 Login: Ptr("example-user"), 287 ID: Ptr(int64(1111)), 288 }, 289 Installation: &Installation{ 290 ID: Ptr(int64(2222)), 291 }, 292 Enterprise: &Enterprise{ 293 ID: Ptr(3333), 294 Slug: Ptr("example-enterprise"), 295 Name: Ptr("Example Enterprise"), 296 }, 297 } 298 299 want := `{ 300 "action": "enabled", 301 "repository": { 302 "id": 12345, 303 "node_id": "MDEwOlJlcG9zaXRvcnkxMjM0NQ==", 304 "name": "example-repo" 305 }, 306 "organization": { 307 "login": "example-org", 308 "id": 67890 309 }, 310 "sender": { 311 "login": "example-user", 312 "id": 1111 313 }, 314 "installation": { 315 "id": 2222 316 }, 317 "enterprise": { 318 "id": 3333, 319 "slug": "example-enterprise", 320 "name": "Example Enterprise" 321 } 322 }` 323 testJSONMarshal(t, u, want) 324 } 325 326 func TestTeamAddEvent_Marshal(t *testing.T) { 327 t.Parallel() 328 testJSONMarshal(t, &TeamAddEvent{}, "{}") 329 330 u := &TeamAddEvent{ 331 Team: &Team{ 332 ID: Ptr(int64(1)), 333 NodeID: Ptr("n"), 334 Name: Ptr("n"), 335 Description: Ptr("d"), 336 URL: Ptr("u"), 337 Slug: Ptr("s"), 338 Permission: Ptr("p"), 339 Privacy: Ptr("p"), 340 MembersCount: Ptr(1), 341 ReposCount: Ptr(1), 342 MembersURL: Ptr("m"), 343 RepositoriesURL: Ptr("r"), 344 Organization: &Organization{ 345 Login: Ptr("l"), 346 ID: Ptr(int64(1)), 347 NodeID: Ptr("n"), 348 AvatarURL: Ptr("a"), 349 HTMLURL: Ptr("h"), 350 Name: Ptr("n"), 351 Company: Ptr("c"), 352 Blog: Ptr("b"), 353 Location: Ptr("l"), 354 Email: Ptr("e"), 355 }, 356 Parent: &Team{ 357 ID: Ptr(int64(1)), 358 NodeID: Ptr("n"), 359 Name: Ptr("n"), 360 Description: Ptr("d"), 361 URL: Ptr("u"), 362 Slug: Ptr("s"), 363 Permission: Ptr("p"), 364 Privacy: Ptr("p"), 365 MembersCount: Ptr(1), 366 ReposCount: Ptr(1), 367 }, 368 LDAPDN: Ptr("l"), 369 }, 370 Repo: &Repository{ 371 ID: Ptr(int64(1)), 372 URL: Ptr("s"), 373 Name: Ptr("n"), 374 }, 375 Org: &Organization{ 376 BillingEmail: Ptr("be"), 377 Blog: Ptr("b"), 378 Company: Ptr("c"), 379 Email: Ptr("e"), 380 TwitterUsername: Ptr("tu"), 381 Location: Ptr("loc"), 382 Name: Ptr("n"), 383 Description: Ptr("d"), 384 IsVerified: Ptr(true), 385 HasOrganizationProjects: Ptr(true), 386 HasRepositoryProjects: Ptr(true), 387 DefaultRepoPermission: Ptr("drp"), 388 MembersCanCreateRepos: Ptr(true), 389 MembersCanCreateInternalRepos: Ptr(true), 390 MembersCanCreatePrivateRepos: Ptr(true), 391 MembersCanCreatePublicRepos: Ptr(false), 392 MembersAllowedRepositoryCreationType: Ptr("marct"), 393 MembersCanCreatePages: Ptr(true), 394 MembersCanCreatePublicPages: Ptr(false), 395 MembersCanCreatePrivatePages: Ptr(true), 396 }, 397 Sender: &User{ 398 Login: Ptr("l"), 399 ID: Ptr(int64(1)), 400 NodeID: Ptr("n"), 401 URL: Ptr("u"), 402 ReposURL: Ptr("r"), 403 EventsURL: Ptr("e"), 404 AvatarURL: Ptr("a"), 405 }, 406 Installation: &Installation{ 407 ID: Ptr(int64(1)), 408 NodeID: Ptr("nid"), 409 AppID: Ptr(int64(1)), 410 AppSlug: Ptr("as"), 411 TargetID: Ptr(int64(1)), 412 Account: &User{ 413 Login: Ptr("l"), 414 ID: Ptr(int64(1)), 415 URL: Ptr("u"), 416 AvatarURL: Ptr("a"), 417 GravatarID: Ptr("g"), 418 Name: Ptr("n"), 419 Company: Ptr("c"), 420 Blog: Ptr("b"), 421 Location: Ptr("l"), 422 Email: Ptr("e"), 423 Hireable: Ptr(true), 424 Bio: Ptr("b"), 425 TwitterUsername: Ptr("t"), 426 PublicRepos: Ptr(1), 427 Followers: Ptr(1), 428 Following: Ptr(1), 429 CreatedAt: &Timestamp{referenceTime}, 430 SuspendedAt: &Timestamp{referenceTime}, 431 }, 432 AccessTokensURL: Ptr("atu"), 433 RepositoriesURL: Ptr("ru"), 434 HTMLURL: Ptr("hu"), 435 TargetType: Ptr("tt"), 436 SingleFileName: Ptr("sfn"), 437 RepositorySelection: Ptr("rs"), 438 Events: []string{"e"}, 439 SingleFilePaths: []string{"s"}, 440 Permissions: &InstallationPermissions{ 441 Actions: Ptr("a"), 442 Administration: Ptr("ad"), 443 Checks: Ptr("c"), 444 Contents: Ptr("co"), 445 ContentReferences: Ptr("cr"), 446 Deployments: Ptr("d"), 447 Environments: Ptr("e"), 448 Issues: Ptr("i"), 449 Metadata: Ptr("md"), 450 Members: Ptr("m"), 451 OrganizationAdministration: Ptr("oa"), 452 OrganizationHooks: Ptr("oh"), 453 OrganizationPlan: Ptr("op"), 454 OrganizationPreReceiveHooks: Ptr("opr"), 455 OrganizationProjects: Ptr("op"), 456 OrganizationSecrets: Ptr("os"), 457 OrganizationSelfHostedRunners: Ptr("osh"), 458 OrganizationUserBlocking: Ptr("oub"), 459 Packages: Ptr("pkg"), 460 Pages: Ptr("pg"), 461 PullRequests: Ptr("pr"), 462 RepositoryHooks: Ptr("rh"), 463 RepositoryProjects: Ptr("rp"), 464 RepositoryPreReceiveHooks: Ptr("rprh"), 465 Secrets: Ptr("s"), 466 SecretScanningAlerts: Ptr("ssa"), 467 SecurityEvents: Ptr("se"), 468 SingleFile: Ptr("sf"), 469 Statuses: Ptr("s"), 470 TeamDiscussions: Ptr("td"), 471 VulnerabilityAlerts: Ptr("va"), 472 Workflows: Ptr("w"), 473 }, 474 CreatedAt: &Timestamp{referenceTime}, 475 UpdatedAt: &Timestamp{referenceTime}, 476 HasMultipleSingleFiles: Ptr(false), 477 SuspendedBy: &User{ 478 Login: Ptr("l"), 479 ID: Ptr(int64(1)), 480 URL: Ptr("u"), 481 AvatarURL: Ptr("a"), 482 GravatarID: Ptr("g"), 483 Name: Ptr("n"), 484 Company: Ptr("c"), 485 Blog: Ptr("b"), 486 Location: Ptr("l"), 487 Email: Ptr("e"), 488 Hireable: Ptr(true), 489 Bio: Ptr("b"), 490 TwitterUsername: Ptr("t"), 491 PublicRepos: Ptr(1), 492 Followers: Ptr(1), 493 Following: Ptr(1), 494 CreatedAt: &Timestamp{referenceTime}, 495 SuspendedAt: &Timestamp{referenceTime}, 496 }, 497 SuspendedAt: &Timestamp{referenceTime}, 498 }, 499 } 500 501 want := `{ 502 "team": { 503 "id": 1, 504 "node_id": "n", 505 "name": "n", 506 "description": "d", 507 "url": "u", 508 "slug": "s", 509 "permission": "p", 510 "privacy": "p", 511 "members_count": 1, 512 "repos_count": 1, 513 "organization": { 514 "login": "l", 515 "id": 1, 516 "node_id": "n", 517 "avatar_url": "a", 518 "html_url": "h", 519 "name": "n", 520 "company": "c", 521 "blog": "b", 522 "location": "l", 523 "email": "e" 524 }, 525 "members_url": "m", 526 "repositories_url": "r", 527 "parent": { 528 "id": 1, 529 "node_id": "n", 530 "name": "n", 531 "description": "d", 532 "url": "u", 533 "slug": "s", 534 "permission": "p", 535 "privacy": "p", 536 "members_count": 1, 537 "repos_count": 1 538 }, 539 "ldap_dn": "l" 540 }, 541 "repository": { 542 "id": 1, 543 "name": "n", 544 "url": "s" 545 }, 546 "organization": { 547 "name": "n", 548 "company": "c", 549 "blog": "b", 550 "location": "loc", 551 "email": "e", 552 "twitter_username": "tu", 553 "description": "d", 554 "billing_email": "be", 555 "is_verified": true, 556 "has_organization_projects": true, 557 "has_repository_projects": true, 558 "default_repository_permission": "drp", 559 "members_can_create_repositories": true, 560 "members_can_create_public_repositories": false, 561 "members_can_create_private_repositories": true, 562 "members_can_create_internal_repositories": true, 563 "members_allowed_repository_creation_type": "marct", 564 "members_can_create_pages": true, 565 "members_can_create_public_pages": false, 566 "members_can_create_private_pages": true 567 }, 568 "sender": { 569 "login": "l", 570 "id": 1, 571 "node_id": "n", 572 "avatar_url": "a", 573 "url": "u", 574 "events_url": "e", 575 "repos_url": "r" 576 }, 577 "installation": { 578 "id": 1, 579 "node_id": "nid", 580 "app_id": 1, 581 "app_slug": "as", 582 "target_id": 1, 583 "account": { 584 "login": "l", 585 "id": 1, 586 "avatar_url": "a", 587 "gravatar_id": "g", 588 "name": "n", 589 "company": "c", 590 "blog": "b", 591 "location": "l", 592 "email": "e", 593 "hireable": true, 594 "bio": "b", 595 "twitter_username": "t", 596 "public_repos": 1, 597 "followers": 1, 598 "following": 1, 599 "created_at": ` + referenceTimeStr + `, 600 "suspended_at": ` + referenceTimeStr + `, 601 "url": "u" 602 }, 603 "access_tokens_url": "atu", 604 "repositories_url": "ru", 605 "html_url": "hu", 606 "target_type": "tt", 607 "single_file_name": "sfn", 608 "repository_selection": "rs", 609 "events": [ 610 "e" 611 ], 612 "single_file_paths": [ 613 "s" 614 ], 615 "permissions": { 616 "actions": "a", 617 "administration": "ad", 618 "checks": "c", 619 "contents": "co", 620 "content_references": "cr", 621 "deployments": "d", 622 "environments": "e", 623 "issues": "i", 624 "metadata": "md", 625 "members": "m", 626 "organization_administration": "oa", 627 "organization_hooks": "oh", 628 "organization_plan": "op", 629 "organization_pre_receive_hooks": "opr", 630 "organization_projects": "op", 631 "organization_secrets": "os", 632 "organization_self_hosted_runners": "osh", 633 "organization_user_blocking": "oub", 634 "packages": "pkg", 635 "pages": "pg", 636 "pull_requests": "pr", 637 "repository_hooks": "rh", 638 "repository_projects": "rp", 639 "repository_pre_receive_hooks": "rprh", 640 "secrets": "s", 641 "secret_scanning_alerts": "ssa", 642 "security_events": "se", 643 "single_file": "sf", 644 "statuses": "s", 645 "team_discussions": "td", 646 "vulnerability_alerts": "va", 647 "workflows": "w" 648 }, 649 "created_at": ` + referenceTimeStr + `, 650 "updated_at": ` + referenceTimeStr + `, 651 "has_multiple_single_files": false, 652 "suspended_by": { 653 "login": "l", 654 "id": 1, 655 "avatar_url": "a", 656 "gravatar_id": "g", 657 "name": "n", 658 "company": "c", 659 "blog": "b", 660 "location": "l", 661 "email": "e", 662 "hireable": true, 663 "bio": "b", 664 "twitter_username": "t", 665 "public_repos": 1, 666 "followers": 1, 667 "following": 1, 668 "created_at": ` + referenceTimeStr + `, 669 "suspended_at": ` + referenceTimeStr + `, 670 "url": "u" 671 }, 672 "suspended_at": ` + referenceTimeStr + ` 673 } 674 }` 675 676 testJSONMarshal(t, u, want) 677 } 678 679 func TestStarEvent_Marshal(t *testing.T) { 680 t.Parallel() 681 testJSONMarshal(t, &StarEvent{}, "{}") 682 683 u := &StarEvent{ 684 Action: Ptr("a"), 685 StarredAt: &Timestamp{referenceTime}, 686 Org: &Organization{ 687 BillingEmail: Ptr("be"), 688 Blog: Ptr("b"), 689 Company: Ptr("c"), 690 Email: Ptr("e"), 691 TwitterUsername: Ptr("tu"), 692 Location: Ptr("loc"), 693 Name: Ptr("n"), 694 Description: Ptr("d"), 695 IsVerified: Ptr(true), 696 HasOrganizationProjects: Ptr(true), 697 HasRepositoryProjects: Ptr(true), 698 DefaultRepoPermission: Ptr("drp"), 699 MembersCanCreateRepos: Ptr(true), 700 MembersCanCreateInternalRepos: Ptr(true), 701 MembersCanCreatePrivateRepos: Ptr(true), 702 MembersCanCreatePublicRepos: Ptr(false), 703 MembersAllowedRepositoryCreationType: Ptr("marct"), 704 MembersCanCreatePages: Ptr(true), 705 MembersCanCreatePublicPages: Ptr(false), 706 MembersCanCreatePrivatePages: Ptr(true), 707 }, 708 Repo: &Repository{ 709 ID: Ptr(int64(1)), 710 URL: Ptr("s"), 711 Name: Ptr("n"), 712 }, 713 Sender: &User{ 714 Login: Ptr("l"), 715 ID: Ptr(int64(1)), 716 NodeID: Ptr("n"), 717 URL: Ptr("u"), 718 ReposURL: Ptr("r"), 719 EventsURL: Ptr("e"), 720 AvatarURL: Ptr("a"), 721 }, 722 } 723 724 want := `{ 725 "action": "a", 726 "starred_at": ` + referenceTimeStr + `, 727 "organization": { 728 "name": "n", 729 "company": "c", 730 "blog": "b", 731 "location": "loc", 732 "email": "e", 733 "twitter_username": "tu", 734 "description": "d", 735 "billing_email": "be", 736 "is_verified": true, 737 "has_organization_projects": true, 738 "has_repository_projects": true, 739 "default_repository_permission": "drp", 740 "members_can_create_repositories": true, 741 "members_can_create_public_repositories": false, 742 "members_can_create_private_repositories": true, 743 "members_can_create_internal_repositories": true, 744 "members_allowed_repository_creation_type": "marct", 745 "members_can_create_pages": true, 746 "members_can_create_public_pages": false, 747 "members_can_create_private_pages": true 748 }, 749 "repository": { 750 "id": 1, 751 "name": "n", 752 "url": "s" 753 }, 754 "sender": { 755 "login": "l", 756 "id": 1, 757 "node_id": "n", 758 "avatar_url": "a", 759 "url": "u", 760 "events_url": "e", 761 "repos_url": "r" 762 } 763 }` 764 765 testJSONMarshal(t, u, want) 766 } 767 768 func TestTeamEvent_Marshal(t *testing.T) { 769 t.Parallel() 770 testJSONMarshal(t, &TeamEvent{}, "{}") 771 772 u := &TeamEvent{ 773 Action: Ptr("a"), 774 Team: &Team{ 775 ID: Ptr(int64(1)), 776 NodeID: Ptr("n"), 777 Name: Ptr("n"), 778 Description: Ptr("d"), 779 URL: Ptr("u"), 780 Slug: Ptr("s"), 781 Permission: Ptr("p"), 782 Privacy: Ptr("p"), 783 MembersCount: Ptr(1), 784 ReposCount: Ptr(1), 785 MembersURL: Ptr("m"), 786 RepositoriesURL: Ptr("r"), 787 Organization: &Organization{ 788 Login: Ptr("l"), 789 ID: Ptr(int64(1)), 790 NodeID: Ptr("n"), 791 AvatarURL: Ptr("a"), 792 HTMLURL: Ptr("h"), 793 Name: Ptr("n"), 794 Company: Ptr("c"), 795 Blog: Ptr("b"), 796 Location: Ptr("l"), 797 Email: Ptr("e"), 798 }, 799 Parent: &Team{ 800 ID: Ptr(int64(1)), 801 NodeID: Ptr("n"), 802 Name: Ptr("n"), 803 Description: Ptr("d"), 804 URL: Ptr("u"), 805 Slug: Ptr("s"), 806 Permission: Ptr("p"), 807 Privacy: Ptr("p"), 808 MembersCount: Ptr(1), 809 ReposCount: Ptr(1), 810 }, 811 LDAPDN: Ptr("l"), 812 }, 813 Changes: &TeamChange{ 814 Description: &TeamDescription{ 815 From: Ptr("from"), 816 }, 817 Name: &TeamName{ 818 From: Ptr("from"), 819 }, 820 Privacy: &TeamPrivacy{ 821 From: Ptr("from"), 822 }, 823 Repository: &TeamRepository{ 824 Permissions: &TeamPermissions{ 825 From: &TeamPermissionsFrom{ 826 Admin: Ptr(true), 827 Pull: Ptr(true), 828 Push: Ptr(true), 829 }, 830 }, 831 }, 832 }, 833 Repo: &Repository{ 834 ID: Ptr(int64(1)), 835 URL: Ptr("s"), 836 Name: Ptr("n"), 837 }, 838 Org: &Organization{ 839 BillingEmail: Ptr("be"), 840 Blog: Ptr("b"), 841 Company: Ptr("c"), 842 Email: Ptr("e"), 843 TwitterUsername: Ptr("tu"), 844 Location: Ptr("loc"), 845 Name: Ptr("n"), 846 Description: Ptr("d"), 847 IsVerified: Ptr(true), 848 HasOrganizationProjects: Ptr(true), 849 HasRepositoryProjects: Ptr(true), 850 DefaultRepoPermission: Ptr("drp"), 851 MembersCanCreateRepos: Ptr(true), 852 MembersCanCreateInternalRepos: Ptr(true), 853 MembersCanCreatePrivateRepos: Ptr(true), 854 MembersCanCreatePublicRepos: Ptr(false), 855 MembersAllowedRepositoryCreationType: Ptr("marct"), 856 MembersCanCreatePages: Ptr(true), 857 MembersCanCreatePublicPages: Ptr(false), 858 MembersCanCreatePrivatePages: Ptr(true), 859 }, 860 Sender: &User{ 861 Login: Ptr("l"), 862 ID: Ptr(int64(1)), 863 NodeID: Ptr("n"), 864 URL: Ptr("u"), 865 ReposURL: Ptr("r"), 866 EventsURL: Ptr("e"), 867 AvatarURL: Ptr("a"), 868 }, 869 Installation: &Installation{ 870 ID: Ptr(int64(1)), 871 NodeID: Ptr("nid"), 872 AppID: Ptr(int64(1)), 873 AppSlug: Ptr("as"), 874 TargetID: Ptr(int64(1)), 875 Account: &User{ 876 Login: Ptr("l"), 877 ID: Ptr(int64(1)), 878 URL: Ptr("u"), 879 AvatarURL: Ptr("a"), 880 GravatarID: Ptr("g"), 881 Name: Ptr("n"), 882 Company: Ptr("c"), 883 Blog: Ptr("b"), 884 Location: Ptr("l"), 885 Email: Ptr("e"), 886 Hireable: Ptr(true), 887 Bio: Ptr("b"), 888 TwitterUsername: Ptr("t"), 889 PublicRepos: Ptr(1), 890 Followers: Ptr(1), 891 Following: Ptr(1), 892 CreatedAt: &Timestamp{referenceTime}, 893 SuspendedAt: &Timestamp{referenceTime}, 894 }, 895 AccessTokensURL: Ptr("atu"), 896 RepositoriesURL: Ptr("ru"), 897 HTMLURL: Ptr("hu"), 898 TargetType: Ptr("tt"), 899 SingleFileName: Ptr("sfn"), 900 RepositorySelection: Ptr("rs"), 901 Events: []string{"e"}, 902 SingleFilePaths: []string{"s"}, 903 Permissions: &InstallationPermissions{ 904 Actions: Ptr("a"), 905 Administration: Ptr("ad"), 906 Checks: Ptr("c"), 907 Contents: Ptr("co"), 908 ContentReferences: Ptr("cr"), 909 Deployments: Ptr("d"), 910 Environments: Ptr("e"), 911 Issues: Ptr("i"), 912 Metadata: Ptr("md"), 913 Members: Ptr("m"), 914 OrganizationAdministration: Ptr("oa"), 915 OrganizationHooks: Ptr("oh"), 916 OrganizationPlan: Ptr("op"), 917 OrganizationPreReceiveHooks: Ptr("opr"), 918 OrganizationProjects: Ptr("op"), 919 OrganizationSecrets: Ptr("os"), 920 OrganizationSelfHostedRunners: Ptr("osh"), 921 OrganizationUserBlocking: Ptr("oub"), 922 Packages: Ptr("pkg"), 923 Pages: Ptr("pg"), 924 PullRequests: Ptr("pr"), 925 RepositoryHooks: Ptr("rh"), 926 RepositoryProjects: Ptr("rp"), 927 RepositoryPreReceiveHooks: Ptr("rprh"), 928 Secrets: Ptr("s"), 929 SecretScanningAlerts: Ptr("ssa"), 930 SecurityEvents: Ptr("se"), 931 SingleFile: Ptr("sf"), 932 Statuses: Ptr("s"), 933 TeamDiscussions: Ptr("td"), 934 VulnerabilityAlerts: Ptr("va"), 935 Workflows: Ptr("w"), 936 }, 937 CreatedAt: &Timestamp{referenceTime}, 938 UpdatedAt: &Timestamp{referenceTime}, 939 HasMultipleSingleFiles: Ptr(false), 940 SuspendedBy: &User{ 941 Login: Ptr("l"), 942 ID: Ptr(int64(1)), 943 URL: Ptr("u"), 944 AvatarURL: Ptr("a"), 945 GravatarID: Ptr("g"), 946 Name: Ptr("n"), 947 Company: Ptr("c"), 948 Blog: Ptr("b"), 949 Location: Ptr("l"), 950 Email: Ptr("e"), 951 Hireable: Ptr(true), 952 Bio: Ptr("b"), 953 TwitterUsername: Ptr("t"), 954 PublicRepos: Ptr(1), 955 Followers: Ptr(1), 956 Following: Ptr(1), 957 CreatedAt: &Timestamp{referenceTime}, 958 SuspendedAt: &Timestamp{referenceTime}, 959 }, 960 SuspendedAt: &Timestamp{referenceTime}, 961 }, 962 } 963 964 want := `{ 965 "action": "a", 966 "team": { 967 "id": 1, 968 "node_id": "n", 969 "name": "n", 970 "description": "d", 971 "url": "u", 972 "slug": "s", 973 "permission": "p", 974 "privacy": "p", 975 "members_count": 1, 976 "repos_count": 1, 977 "organization": { 978 "login": "l", 979 "id": 1, 980 "node_id": "n", 981 "avatar_url": "a", 982 "html_url": "h", 983 "name": "n", 984 "company": "c", 985 "blog": "b", 986 "location": "l", 987 "email": "e" 988 }, 989 "members_url": "m", 990 "repositories_url": "r", 991 "parent": { 992 "id": 1, 993 "node_id": "n", 994 "name": "n", 995 "description": "d", 996 "url": "u", 997 "slug": "s", 998 "permission": "p", 999 "privacy": "p", 1000 "members_count": 1, 1001 "repos_count": 1 1002 }, 1003 "ldap_dn": "l" 1004 }, 1005 "changes": { 1006 "description": { 1007 "from": "from" 1008 }, 1009 "name": { 1010 "from": "from" 1011 }, 1012 "privacy": { 1013 "from": "from" 1014 }, 1015 "repository": { 1016 "permissions": { 1017 "from": { 1018 "admin": true, 1019 "pull": true, 1020 "push": true 1021 } 1022 } 1023 } 1024 }, 1025 "repository": { 1026 "id": 1, 1027 "name": "n", 1028 "url": "s" 1029 }, 1030 "organization": { 1031 "name": "n", 1032 "company": "c", 1033 "blog": "b", 1034 "location": "loc", 1035 "email": "e", 1036 "twitter_username": "tu", 1037 "description": "d", 1038 "billing_email": "be", 1039 "is_verified": true, 1040 "has_organization_projects": true, 1041 "has_repository_projects": true, 1042 "default_repository_permission": "drp", 1043 "members_can_create_repositories": true, 1044 "members_can_create_public_repositories": false, 1045 "members_can_create_private_repositories": true, 1046 "members_can_create_internal_repositories": true, 1047 "members_allowed_repository_creation_type": "marct", 1048 "members_can_create_pages": true, 1049 "members_can_create_public_pages": false, 1050 "members_can_create_private_pages": true 1051 }, 1052 "sender": { 1053 "login": "l", 1054 "id": 1, 1055 "node_id": "n", 1056 "avatar_url": "a", 1057 "url": "u", 1058 "events_url": "e", 1059 "repos_url": "r" 1060 }, 1061 "installation": { 1062 "id": 1, 1063 "node_id": "nid", 1064 "app_id": 1, 1065 "app_slug": "as", 1066 "target_id": 1, 1067 "account": { 1068 "login": "l", 1069 "id": 1, 1070 "avatar_url": "a", 1071 "gravatar_id": "g", 1072 "name": "n", 1073 "company": "c", 1074 "blog": "b", 1075 "location": "l", 1076 "email": "e", 1077 "hireable": true, 1078 "bio": "b", 1079 "twitter_username": "t", 1080 "public_repos": 1, 1081 "followers": 1, 1082 "following": 1, 1083 "created_at": ` + referenceTimeStr + `, 1084 "suspended_at": ` + referenceTimeStr + `, 1085 "url": "u" 1086 }, 1087 "access_tokens_url": "atu", 1088 "repositories_url": "ru", 1089 "html_url": "hu", 1090 "target_type": "tt", 1091 "single_file_name": "sfn", 1092 "repository_selection": "rs", 1093 "events": [ 1094 "e" 1095 ], 1096 "single_file_paths": [ 1097 "s" 1098 ], 1099 "permissions": { 1100 "actions": "a", 1101 "administration": "ad", 1102 "checks": "c", 1103 "contents": "co", 1104 "content_references": "cr", 1105 "deployments": "d", 1106 "environments": "e", 1107 "issues": "i", 1108 "metadata": "md", 1109 "members": "m", 1110 "organization_administration": "oa", 1111 "organization_hooks": "oh", 1112 "organization_plan": "op", 1113 "organization_pre_receive_hooks": "opr", 1114 "organization_projects": "op", 1115 "organization_secrets": "os", 1116 "organization_self_hosted_runners": "osh", 1117 "organization_user_blocking": "oub", 1118 "packages": "pkg", 1119 "pages": "pg", 1120 "pull_requests": "pr", 1121 "repository_hooks": "rh", 1122 "repository_projects": "rp", 1123 "repository_pre_receive_hooks": "rprh", 1124 "secrets": "s", 1125 "secret_scanning_alerts": "ssa", 1126 "security_events": "se", 1127 "single_file": "sf", 1128 "statuses": "s", 1129 "team_discussions": "td", 1130 "vulnerability_alerts": "va", 1131 "workflows": "w" 1132 }, 1133 "created_at": ` + referenceTimeStr + `, 1134 "updated_at": ` + referenceTimeStr + `, 1135 "has_multiple_single_files": false, 1136 "suspended_by": { 1137 "login": "l", 1138 "id": 1, 1139 "avatar_url": "a", 1140 "gravatar_id": "g", 1141 "name": "n", 1142 "company": "c", 1143 "blog": "b", 1144 "location": "l", 1145 "email": "e", 1146 "hireable": true, 1147 "bio": "b", 1148 "twitter_username": "t", 1149 "public_repos": 1, 1150 "followers": 1, 1151 "following": 1, 1152 "created_at": ` + referenceTimeStr + `, 1153 "suspended_at": ` + referenceTimeStr + `, 1154 "url": "u" 1155 }, 1156 "suspended_at": ` + referenceTimeStr + ` 1157 } 1158 }` 1159 1160 testJSONMarshal(t, u, want) 1161 } 1162 1163 func TestInstallationRepositoriesEvent_Marshal(t *testing.T) { 1164 t.Parallel() 1165 testJSONMarshal(t, &InstallationRepositoriesEvent{}, "{}") 1166 1167 u := &InstallationRepositoriesEvent{ 1168 Action: Ptr("a"), 1169 RepositoriesAdded: []*Repository{ 1170 { 1171 ID: Ptr(int64(1)), 1172 URL: Ptr("s"), 1173 Name: Ptr("n"), 1174 }, 1175 }, 1176 RepositoriesRemoved: []*Repository{ 1177 { 1178 ID: Ptr(int64(1)), 1179 URL: Ptr("s"), 1180 Name: Ptr("n"), 1181 }, 1182 }, 1183 RepositorySelection: Ptr("rs"), 1184 Sender: &User{ 1185 Login: Ptr("l"), 1186 ID: Ptr(int64(1)), 1187 NodeID: Ptr("n"), 1188 URL: Ptr("u"), 1189 ReposURL: Ptr("r"), 1190 EventsURL: Ptr("e"), 1191 AvatarURL: Ptr("a"), 1192 }, 1193 Installation: &Installation{ 1194 ID: Ptr(int64(1)), 1195 NodeID: Ptr("nid"), 1196 AppID: Ptr(int64(1)), 1197 AppSlug: Ptr("as"), 1198 TargetID: Ptr(int64(1)), 1199 Account: &User{ 1200 Login: Ptr("l"), 1201 ID: Ptr(int64(1)), 1202 URL: Ptr("u"), 1203 AvatarURL: Ptr("a"), 1204 GravatarID: Ptr("g"), 1205 Name: Ptr("n"), 1206 Company: Ptr("c"), 1207 Blog: Ptr("b"), 1208 Location: Ptr("l"), 1209 Email: Ptr("e"), 1210 Hireable: Ptr(true), 1211 Bio: Ptr("b"), 1212 TwitterUsername: Ptr("t"), 1213 PublicRepos: Ptr(1), 1214 Followers: Ptr(1), 1215 Following: Ptr(1), 1216 CreatedAt: &Timestamp{referenceTime}, 1217 SuspendedAt: &Timestamp{referenceTime}, 1218 }, 1219 AccessTokensURL: Ptr("atu"), 1220 RepositoriesURL: Ptr("ru"), 1221 HTMLURL: Ptr("hu"), 1222 TargetType: Ptr("tt"), 1223 SingleFileName: Ptr("sfn"), 1224 RepositorySelection: Ptr("rs"), 1225 Events: []string{"e"}, 1226 SingleFilePaths: []string{"s"}, 1227 Permissions: &InstallationPermissions{ 1228 Actions: Ptr("a"), 1229 Administration: Ptr("ad"), 1230 Checks: Ptr("c"), 1231 Contents: Ptr("co"), 1232 ContentReferences: Ptr("cr"), 1233 Deployments: Ptr("d"), 1234 Environments: Ptr("e"), 1235 Issues: Ptr("i"), 1236 Metadata: Ptr("md"), 1237 Members: Ptr("m"), 1238 OrganizationAdministration: Ptr("oa"), 1239 OrganizationHooks: Ptr("oh"), 1240 OrganizationPlan: Ptr("op"), 1241 OrganizationPreReceiveHooks: Ptr("opr"), 1242 OrganizationProjects: Ptr("op"), 1243 OrganizationSecrets: Ptr("os"), 1244 OrganizationSelfHostedRunners: Ptr("osh"), 1245 OrganizationUserBlocking: Ptr("oub"), 1246 Packages: Ptr("pkg"), 1247 Pages: Ptr("pg"), 1248 PullRequests: Ptr("pr"), 1249 RepositoryHooks: Ptr("rh"), 1250 RepositoryProjects: Ptr("rp"), 1251 RepositoryPreReceiveHooks: Ptr("rprh"), 1252 Secrets: Ptr("s"), 1253 SecretScanningAlerts: Ptr("ssa"), 1254 SecurityEvents: Ptr("se"), 1255 SingleFile: Ptr("sf"), 1256 Statuses: Ptr("s"), 1257 TeamDiscussions: Ptr("td"), 1258 VulnerabilityAlerts: Ptr("va"), 1259 Workflows: Ptr("w"), 1260 }, 1261 CreatedAt: &Timestamp{referenceTime}, 1262 UpdatedAt: &Timestamp{referenceTime}, 1263 HasMultipleSingleFiles: Ptr(false), 1264 SuspendedBy: &User{ 1265 Login: Ptr("l"), 1266 ID: Ptr(int64(1)), 1267 URL: Ptr("u"), 1268 AvatarURL: Ptr("a"), 1269 GravatarID: Ptr("g"), 1270 Name: Ptr("n"), 1271 Company: Ptr("c"), 1272 Blog: Ptr("b"), 1273 Location: Ptr("l"), 1274 Email: Ptr("e"), 1275 Hireable: Ptr(true), 1276 Bio: Ptr("b"), 1277 TwitterUsername: Ptr("t"), 1278 PublicRepos: Ptr(1), 1279 Followers: Ptr(1), 1280 Following: Ptr(1), 1281 CreatedAt: &Timestamp{referenceTime}, 1282 SuspendedAt: &Timestamp{referenceTime}, 1283 }, 1284 SuspendedAt: &Timestamp{referenceTime}, 1285 }, 1286 } 1287 1288 want := `{ 1289 "action": "a", 1290 "repositories_added": [ 1291 { 1292 "id": 1, 1293 "name": "n", 1294 "url": "s" 1295 } 1296 ], 1297 "repositories_removed": [ 1298 { 1299 "id": 1, 1300 "name": "n", 1301 "url": "s" 1302 } 1303 ], 1304 "repository_selection": "rs", 1305 "sender": { 1306 "login": "l", 1307 "id": 1, 1308 "node_id": "n", 1309 "avatar_url": "a", 1310 "url": "u", 1311 "events_url": "e", 1312 "repos_url": "r" 1313 }, 1314 "installation": { 1315 "id": 1, 1316 "node_id": "nid", 1317 "app_id": 1, 1318 "app_slug": "as", 1319 "target_id": 1, 1320 "account": { 1321 "login": "l", 1322 "id": 1, 1323 "avatar_url": "a", 1324 "gravatar_id": "g", 1325 "name": "n", 1326 "company": "c", 1327 "blog": "b", 1328 "location": "l", 1329 "email": "e", 1330 "hireable": true, 1331 "bio": "b", 1332 "twitter_username": "t", 1333 "public_repos": 1, 1334 "followers": 1, 1335 "following": 1, 1336 "created_at": ` + referenceTimeStr + `, 1337 "suspended_at": ` + referenceTimeStr + `, 1338 "url": "u" 1339 }, 1340 "access_tokens_url": "atu", 1341 "repositories_url": "ru", 1342 "html_url": "hu", 1343 "target_type": "tt", 1344 "single_file_name": "sfn", 1345 "repository_selection": "rs", 1346 "events": [ 1347 "e" 1348 ], 1349 "single_file_paths": [ 1350 "s" 1351 ], 1352 "permissions": { 1353 "actions": "a", 1354 "administration": "ad", 1355 "checks": "c", 1356 "contents": "co", 1357 "content_references": "cr", 1358 "deployments": "d", 1359 "environments": "e", 1360 "issues": "i", 1361 "metadata": "md", 1362 "members": "m", 1363 "organization_administration": "oa", 1364 "organization_hooks": "oh", 1365 "organization_plan": "op", 1366 "organization_pre_receive_hooks": "opr", 1367 "organization_projects": "op", 1368 "organization_secrets": "os", 1369 "organization_self_hosted_runners": "osh", 1370 "organization_user_blocking": "oub", 1371 "packages": "pkg", 1372 "pages": "pg", 1373 "pull_requests": "pr", 1374 "repository_hooks": "rh", 1375 "repository_projects": "rp", 1376 "repository_pre_receive_hooks": "rprh", 1377 "secrets": "s", 1378 "secret_scanning_alerts": "ssa", 1379 "security_events": "se", 1380 "single_file": "sf", 1381 "statuses": "s", 1382 "team_discussions": "td", 1383 "vulnerability_alerts": "va", 1384 "workflows": "w" 1385 }, 1386 "created_at": ` + referenceTimeStr + `, 1387 "updated_at": ` + referenceTimeStr + `, 1388 "has_multiple_single_files": false, 1389 "suspended_by": { 1390 "login": "l", 1391 "id": 1, 1392 "avatar_url": "a", 1393 "gravatar_id": "g", 1394 "name": "n", 1395 "company": "c", 1396 "blog": "b", 1397 "location": "l", 1398 "email": "e", 1399 "hireable": true, 1400 "bio": "b", 1401 "twitter_username": "t", 1402 "public_repos": 1, 1403 "followers": 1, 1404 "following": 1, 1405 "created_at": ` + referenceTimeStr + `, 1406 "suspended_at": ` + referenceTimeStr + `, 1407 "url": "u" 1408 }, 1409 "suspended_at": ` + referenceTimeStr + ` 1410 } 1411 }` 1412 1413 testJSONMarshal(t, u, want) 1414 } 1415 1416 func TestInstallationTargetEvent_Marshal(t *testing.T) { 1417 t.Parallel() 1418 testJSONMarshal(t, &InstallationTargetEvent{}, "{}") 1419 1420 u := &InstallationTargetEvent{ 1421 Account: &User{ 1422 Login: Ptr("u"), 1423 ID: Ptr(int64(1)), 1424 NodeID: Ptr("n"), 1425 URL: Ptr("u"), 1426 ReposURL: Ptr("r"), 1427 EventsURL: Ptr("e"), 1428 AvatarURL: Ptr("l"), 1429 }, 1430 Action: Ptr("a"), 1431 Changes: &InstallationChanges{ 1432 Login: &InstallationLoginChange{ 1433 From: Ptr("p"), 1434 }, 1435 Slug: &InstallationSlugChange{ 1436 From: Ptr("j"), 1437 }, 1438 }, 1439 Enterprise: &Enterprise{ 1440 ID: Ptr(1), 1441 Slug: Ptr("s"), 1442 Name: Ptr("n"), 1443 NodeID: Ptr("nid"), 1444 AvatarURL: Ptr("au"), 1445 Description: Ptr("d"), 1446 WebsiteURL: Ptr("wu"), 1447 HTMLURL: Ptr("hu"), 1448 CreatedAt: &Timestamp{referenceTime}, 1449 UpdatedAt: &Timestamp{referenceTime}, 1450 }, 1451 Installation: &Installation{ 1452 ID: Ptr(int64(1)), 1453 NodeID: Ptr("nid"), 1454 AppID: Ptr(int64(1)), 1455 AppSlug: Ptr("as"), 1456 TargetID: Ptr(int64(1)), 1457 Account: &User{ 1458 Login: Ptr("l"), 1459 ID: Ptr(int64(1)), 1460 URL: Ptr("u"), 1461 AvatarURL: Ptr("a"), 1462 GravatarID: Ptr("g"), 1463 Name: Ptr("n"), 1464 Company: Ptr("c"), 1465 Blog: Ptr("b"), 1466 Location: Ptr("l"), 1467 Email: Ptr("e"), 1468 Hireable: Ptr(true), 1469 Bio: Ptr("b"), 1470 TwitterUsername: Ptr("t"), 1471 PublicRepos: Ptr(1), 1472 Followers: Ptr(1), 1473 Following: Ptr(1), 1474 CreatedAt: &Timestamp{referenceTime}, 1475 SuspendedAt: &Timestamp{referenceTime}, 1476 }, 1477 AccessTokensURL: Ptr("atu"), 1478 RepositoriesURL: Ptr("ru"), 1479 HTMLURL: Ptr("hu"), 1480 TargetType: Ptr("tt"), 1481 SingleFileName: Ptr("sfn"), 1482 RepositorySelection: Ptr("rs"), 1483 Events: []string{"e"}, 1484 SingleFilePaths: []string{"s"}, 1485 Permissions: &InstallationPermissions{ 1486 Actions: Ptr("a"), 1487 Administration: Ptr("ad"), 1488 Checks: Ptr("c"), 1489 Contents: Ptr("co"), 1490 ContentReferences: Ptr("cr"), 1491 Deployments: Ptr("d"), 1492 Environments: Ptr("e"), 1493 Issues: Ptr("i"), 1494 Metadata: Ptr("md"), 1495 Members: Ptr("m"), 1496 OrganizationAdministration: Ptr("oa"), 1497 OrganizationHooks: Ptr("oh"), 1498 OrganizationPlan: Ptr("op"), 1499 OrganizationPreReceiveHooks: Ptr("opr"), 1500 OrganizationProjects: Ptr("op"), 1501 OrganizationSecrets: Ptr("os"), 1502 OrganizationSelfHostedRunners: Ptr("osh"), 1503 OrganizationUserBlocking: Ptr("oub"), 1504 Packages: Ptr("pkg"), 1505 Pages: Ptr("pg"), 1506 PullRequests: Ptr("pr"), 1507 RepositoryHooks: Ptr("rh"), 1508 RepositoryProjects: Ptr("rp"), 1509 RepositoryPreReceiveHooks: Ptr("rprh"), 1510 Secrets: Ptr("s"), 1511 SecretScanningAlerts: Ptr("ssa"), 1512 SecurityEvents: Ptr("se"), 1513 SingleFile: Ptr("sf"), 1514 Statuses: Ptr("s"), 1515 TeamDiscussions: Ptr("td"), 1516 VulnerabilityAlerts: Ptr("va"), 1517 Workflows: Ptr("w"), 1518 }, 1519 CreatedAt: &Timestamp{referenceTime}, 1520 UpdatedAt: &Timestamp{referenceTime}, 1521 HasMultipleSingleFiles: Ptr(false), 1522 SuspendedBy: &User{ 1523 Login: Ptr("l"), 1524 ID: Ptr(int64(1)), 1525 URL: Ptr("u"), 1526 AvatarURL: Ptr("a"), 1527 GravatarID: Ptr("g"), 1528 Name: Ptr("n"), 1529 Company: Ptr("c"), 1530 Blog: Ptr("b"), 1531 Location: Ptr("l"), 1532 Email: Ptr("e"), 1533 Hireable: Ptr(true), 1534 Bio: Ptr("b"), 1535 TwitterUsername: Ptr("t"), 1536 PublicRepos: Ptr(1), 1537 Followers: Ptr(1), 1538 Following: Ptr(1), 1539 CreatedAt: &Timestamp{referenceTime}, 1540 SuspendedAt: &Timestamp{referenceTime}, 1541 }, 1542 SuspendedAt: &Timestamp{referenceTime}, 1543 }, 1544 Organization: &Organization{ 1545 BillingEmail: Ptr("be"), 1546 Blog: Ptr("b"), 1547 Company: Ptr("c"), 1548 Email: Ptr("e"), 1549 TwitterUsername: Ptr("tu"), 1550 Location: Ptr("loc"), 1551 Name: Ptr("n"), 1552 Description: Ptr("d"), 1553 IsVerified: Ptr(true), 1554 HasOrganizationProjects: Ptr(true), 1555 HasRepositoryProjects: Ptr(true), 1556 DefaultRepoPermission: Ptr("drp"), 1557 MembersCanCreateRepos: Ptr(true), 1558 MembersCanCreateInternalRepos: Ptr(true), 1559 MembersCanCreatePrivateRepos: Ptr(true), 1560 MembersCanCreatePublicRepos: Ptr(false), 1561 MembersAllowedRepositoryCreationType: Ptr("marct"), 1562 MembersCanCreatePages: Ptr(true), 1563 MembersCanCreatePublicPages: Ptr(false), 1564 MembersCanCreatePrivatePages: Ptr(true), 1565 }, 1566 Repository: &Repository{ 1567 ID: Ptr(int64(1)), 1568 URL: Ptr("s"), 1569 Name: Ptr("n"), 1570 }, 1571 Sender: &User{ 1572 Login: Ptr("l"), 1573 ID: Ptr(int64(1)), 1574 NodeID: Ptr("n"), 1575 URL: Ptr("u"), 1576 ReposURL: Ptr("r"), 1577 EventsURL: Ptr("e"), 1578 AvatarURL: Ptr("a"), 1579 }, 1580 TargetType: Ptr("running"), 1581 } 1582 1583 want := `{ 1584 "account": { 1585 "login": "u", 1586 "id": 1, 1587 "node_id": "n", 1588 "avatar_url": "l", 1589 "url": "u", 1590 "events_url": "e", 1591 "repos_url": "r" 1592 }, 1593 "action": "a", 1594 "changes": { 1595 "login": { 1596 "from": "p" 1597 }, 1598 "slug": { 1599 "from": "j" 1600 } 1601 }, 1602 "enterprise": { 1603 "id": 1, 1604 "slug": "s", 1605 "name": "n", 1606 "node_id": "nid", 1607 "avatar_url": "au", 1608 "description": "d", 1609 "website_url": "wu", 1610 "html_url": "hu", 1611 "created_at": ` + referenceTimeStr + `, 1612 "updated_at": ` + referenceTimeStr + ` 1613 }, 1614 "installation": { 1615 "id": 1, 1616 "node_id": "nid", 1617 "app_id": 1, 1618 "app_slug": "as", 1619 "target_id": 1, 1620 "account": { 1621 "login": "l", 1622 "id": 1, 1623 "avatar_url": "a", 1624 "gravatar_id": "g", 1625 "name": "n", 1626 "company": "c", 1627 "blog": "b", 1628 "location": "l", 1629 "email": "e", 1630 "hireable": true, 1631 "bio": "b", 1632 "twitter_username": "t", 1633 "public_repos": 1, 1634 "followers": 1, 1635 "following": 1, 1636 "created_at": ` + referenceTimeStr + `, 1637 "suspended_at": ` + referenceTimeStr + `, 1638 "url": "u" 1639 }, 1640 "access_tokens_url": "atu", 1641 "repositories_url": "ru", 1642 "html_url": "hu", 1643 "target_type": "tt", 1644 "single_file_name": "sfn", 1645 "repository_selection": "rs", 1646 "events": [ 1647 "e" 1648 ], 1649 "single_file_paths": [ 1650 "s" 1651 ], 1652 "permissions": { 1653 "actions": "a", 1654 "administration": "ad", 1655 "checks": "c", 1656 "contents": "co", 1657 "content_references": "cr", 1658 "deployments": "d", 1659 "environments": "e", 1660 "issues": "i", 1661 "metadata": "md", 1662 "members": "m", 1663 "organization_administration": "oa", 1664 "organization_hooks": "oh", 1665 "organization_plan": "op", 1666 "organization_pre_receive_hooks": "opr", 1667 "organization_projects": "op", 1668 "organization_secrets": "os", 1669 "organization_self_hosted_runners": "osh", 1670 "organization_user_blocking": "oub", 1671 "packages": "pkg", 1672 "pages": "pg", 1673 "pull_requests": "pr", 1674 "repository_hooks": "rh", 1675 "repository_projects": "rp", 1676 "repository_pre_receive_hooks": "rprh", 1677 "secrets": "s", 1678 "secret_scanning_alerts": "ssa", 1679 "security_events": "se", 1680 "single_file": "sf", 1681 "statuses": "s", 1682 "team_discussions": "td", 1683 "vulnerability_alerts": "va", 1684 "workflows": "w" 1685 }, 1686 "created_at": ` + referenceTimeStr + `, 1687 "updated_at": ` + referenceTimeStr + `, 1688 "has_multiple_single_files": false, 1689 "suspended_by": { 1690 "login": "l", 1691 "id": 1, 1692 "avatar_url": "a", 1693 "gravatar_id": "g", 1694 "name": "n", 1695 "company": "c", 1696 "blog": "b", 1697 "location": "l", 1698 "email": "e", 1699 "hireable": true, 1700 "bio": "b", 1701 "twitter_username": "t", 1702 "public_repos": 1, 1703 "followers": 1, 1704 "following": 1, 1705 "created_at": ` + referenceTimeStr + `, 1706 "suspended_at": ` + referenceTimeStr + `, 1707 "url": "u" 1708 }, 1709 "suspended_at": ` + referenceTimeStr + ` 1710 }, 1711 "organization": { 1712 "name": "n", 1713 "company": "c", 1714 "blog": "b", 1715 "location": "loc", 1716 "email": "e", 1717 "twitter_username": "tu", 1718 "description": "d", 1719 "billing_email": "be", 1720 "is_verified": true, 1721 "has_organization_projects": true, 1722 "has_repository_projects": true, 1723 "default_repository_permission": "drp", 1724 "members_can_create_repositories": true, 1725 "members_can_create_public_repositories": false, 1726 "members_can_create_private_repositories": true, 1727 "members_can_create_internal_repositories": true, 1728 "members_allowed_repository_creation_type": "marct", 1729 "members_can_create_pages": true, 1730 "members_can_create_public_pages": false, 1731 "members_can_create_private_pages": true 1732 }, 1733 "repository": { 1734 "id": 1, 1735 "url": "s", 1736 "name": "n" 1737 }, 1738 "sender": { 1739 "login": "l", 1740 "id": 1, 1741 "node_id": "n", 1742 "avatar_url": "a", 1743 "url": "u", 1744 "events_url": "e", 1745 "repos_url": "r" 1746 }, 1747 "target_type": "running" 1748 }` 1749 1750 testJSONMarshal(t, u, want) 1751 } 1752 1753 func TestEditTitle_Marshal(t *testing.T) { 1754 t.Parallel() 1755 testJSONMarshal(t, &EditTitle{}, "{}") 1756 1757 u := &EditTitle{ 1758 From: Ptr("EditTitleFrom"), 1759 } 1760 1761 want := `{ 1762 "from": "EditTitleFrom" 1763 }` 1764 1765 testJSONMarshal(t, u, want) 1766 } 1767 1768 func TestEditBody_Marshal(t *testing.T) { 1769 t.Parallel() 1770 testJSONMarshal(t, &EditBody{}, "{}") 1771 1772 u := &EditBody{ 1773 From: Ptr("EditBodyFrom"), 1774 } 1775 1776 want := `{ 1777 "from": "EditBodyFrom" 1778 }` 1779 1780 testJSONMarshal(t, u, want) 1781 } 1782 1783 func TestEditBase_Marshal(t *testing.T) { 1784 t.Parallel() 1785 testJSONMarshal(t, &EditBase{}, "{}") 1786 1787 u := &EditBase{ 1788 Ref: &EditRef{ 1789 From: Ptr("EditRefFrom"), 1790 }, 1791 SHA: &EditSHA{ 1792 From: Ptr("EditSHAFrom"), 1793 }, 1794 } 1795 1796 want := `{ 1797 "ref": { 1798 "from": "EditRefFrom" 1799 }, 1800 "sha": { 1801 "from": "EditSHAFrom" 1802 } 1803 }` 1804 1805 testJSONMarshal(t, u, want) 1806 } 1807 1808 func TestEditRef_Marshal(t *testing.T) { 1809 t.Parallel() 1810 testJSONMarshal(t, &EditRef{}, "{}") 1811 1812 u := &EditRef{ 1813 From: Ptr("EditRefFrom"), 1814 } 1815 1816 want := `{ 1817 "from": "EditRefFrom" 1818 }` 1819 1820 testJSONMarshal(t, u, want) 1821 } 1822 1823 func TestEditSHA_Marshal(t *testing.T) { 1824 t.Parallel() 1825 testJSONMarshal(t, &EditSHA{}, "{}") 1826 1827 u := &EditSHA{ 1828 From: Ptr("EditSHAFrom"), 1829 } 1830 1831 want := `{ 1832 "from": "EditSHAFrom" 1833 }` 1834 1835 testJSONMarshal(t, u, want) 1836 } 1837 1838 func TestProjectName_Marshal(t *testing.T) { 1839 t.Parallel() 1840 testJSONMarshal(t, &ProjectName{}, "{}") 1841 1842 u := &ProjectName{ 1843 From: Ptr("ProjectNameFrom"), 1844 } 1845 1846 want := `{ 1847 "from": "ProjectNameFrom" 1848 }` 1849 1850 testJSONMarshal(t, u, want) 1851 } 1852 1853 func TestProjectBody_Marshal(t *testing.T) { 1854 t.Parallel() 1855 testJSONMarshal(t, &ProjectBody{}, "{}") 1856 1857 u := &ProjectBody{ 1858 From: Ptr("ProjectBodyFrom"), 1859 } 1860 1861 want := `{ 1862 "from": "ProjectBodyFrom" 1863 }` 1864 1865 testJSONMarshal(t, u, want) 1866 } 1867 1868 func TestProjectCardNote_Marshal(t *testing.T) { 1869 t.Parallel() 1870 testJSONMarshal(t, &ProjectCardNote{}, "{}") 1871 1872 u := &ProjectCardNote{ 1873 From: Ptr("ProjectCardNoteFrom"), 1874 } 1875 1876 want := `{ 1877 "from": "ProjectCardNoteFrom" 1878 }` 1879 1880 testJSONMarshal(t, u, want) 1881 } 1882 1883 func TestProjectColumnName_Marshal(t *testing.T) { 1884 t.Parallel() 1885 testJSONMarshal(t, &ProjectColumnName{}, "{}") 1886 1887 u := &ProjectColumnName{ 1888 From: Ptr("ProjectColumnNameFrom"), 1889 } 1890 1891 want := `{ 1892 "from": "ProjectColumnNameFrom" 1893 }` 1894 1895 testJSONMarshal(t, u, want) 1896 } 1897 1898 func TestTeamDescription_Marshal(t *testing.T) { 1899 t.Parallel() 1900 testJSONMarshal(t, &TeamDescription{}, "{}") 1901 1902 u := &TeamDescription{ 1903 From: Ptr("TeamDescriptionFrom"), 1904 } 1905 1906 want := `{ 1907 "from": "TeamDescriptionFrom" 1908 }` 1909 1910 testJSONMarshal(t, u, want) 1911 } 1912 1913 func TestTeamName_Marshal(t *testing.T) { 1914 t.Parallel() 1915 testJSONMarshal(t, &TeamName{}, "{}") 1916 1917 u := &TeamName{ 1918 From: Ptr("TeamNameFrom"), 1919 } 1920 1921 want := `{ 1922 "from": "TeamNameFrom" 1923 }` 1924 1925 testJSONMarshal(t, u, want) 1926 } 1927 1928 func TestTeamPrivacy_Marshal(t *testing.T) { 1929 t.Parallel() 1930 testJSONMarshal(t, &TeamPrivacy{}, "{}") 1931 1932 u := &TeamPrivacy{ 1933 From: Ptr("TeamPrivacyFrom"), 1934 } 1935 1936 want := `{ 1937 "from": "TeamPrivacyFrom" 1938 }` 1939 1940 testJSONMarshal(t, u, want) 1941 } 1942 1943 func TestTeamRepository_Marshal(t *testing.T) { 1944 t.Parallel() 1945 testJSONMarshal(t, &TeamRepository{}, "{}") 1946 1947 u := &TeamRepository{ 1948 Permissions: &TeamPermissions{ 1949 From: &TeamPermissionsFrom{ 1950 Admin: Ptr(true), 1951 Pull: Ptr(true), 1952 Push: Ptr(true), 1953 }, 1954 }, 1955 } 1956 1957 want := `{ 1958 "permissions": { 1959 "from": { 1960 "admin": true, 1961 "pull": true, 1962 "push": true 1963 } 1964 } 1965 }` 1966 1967 testJSONMarshal(t, u, want) 1968 } 1969 1970 func TestTeamPermissions_Marshal(t *testing.T) { 1971 t.Parallel() 1972 testJSONMarshal(t, &TeamPermissions{}, "{}") 1973 1974 u := &TeamPermissions{ 1975 From: &TeamPermissionsFrom{ 1976 Admin: Ptr(true), 1977 Pull: Ptr(true), 1978 Push: Ptr(true), 1979 }, 1980 } 1981 1982 want := `{ 1983 "from": { 1984 "admin": true, 1985 "pull": true, 1986 "push": true 1987 } 1988 }` 1989 1990 testJSONMarshal(t, u, want) 1991 } 1992 1993 func TestTeamPermissionsFrom_Marshal(t *testing.T) { 1994 t.Parallel() 1995 testJSONMarshal(t, &TeamPermissionsFrom{}, "{}") 1996 1997 u := &TeamPermissionsFrom{ 1998 Admin: Ptr(true), 1999 Pull: Ptr(true), 2000 Push: Ptr(true), 2001 } 2002 2003 want := `{ 2004 "admin": true, 2005 "pull": true, 2006 "push": true 2007 }` 2008 2009 testJSONMarshal(t, u, want) 2010 } 2011 2012 func TestRepositoryVulnerabilityAlert_Marshal(t *testing.T) { 2013 t.Parallel() 2014 testJSONMarshal(t, &RepositoryVulnerabilityAlert{}, "{}") 2015 2016 u := &RepositoryVulnerabilityAlert{ 2017 ID: Ptr(int64(1)), 2018 AffectedRange: Ptr("ar"), 2019 AffectedPackageName: Ptr("apn"), 2020 ExternalReference: Ptr("er"), 2021 ExternalIdentifier: Ptr("ei"), 2022 FixedIn: Ptr("fi"), 2023 Dismisser: &User{ 2024 Login: Ptr("l"), 2025 ID: Ptr(int64(1)), 2026 NodeID: Ptr("n"), 2027 URL: Ptr("u"), 2028 ReposURL: Ptr("r"), 2029 EventsURL: Ptr("e"), 2030 AvatarURL: Ptr("a"), 2031 }, 2032 DismissReason: Ptr("dr"), 2033 DismissedAt: &Timestamp{referenceTime}, 2034 } 2035 2036 want := `{ 2037 "id": 1, 2038 "affected_range": "ar", 2039 "affected_package_name": "apn", 2040 "external_reference": "er", 2041 "external_identifier": "ei", 2042 "fixed_in": "fi", 2043 "dismisser": { 2044 "login": "l", 2045 "id": 1, 2046 "node_id": "n", 2047 "avatar_url": "a", 2048 "url": "u", 2049 "events_url": "e", 2050 "repos_url": "r" 2051 }, 2052 "dismiss_reason": "dr", 2053 "dismissed_at": ` + referenceTimeStr + ` 2054 }` 2055 2056 testJSONMarshal(t, u, want) 2057 } 2058 2059 func TestPage_Marshal(t *testing.T) { 2060 t.Parallel() 2061 testJSONMarshal(t, &Page{}, "{}") 2062 2063 u := &Page{ 2064 PageName: Ptr("p"), 2065 Title: Ptr("t"), 2066 Summary: Ptr("s"), 2067 Action: Ptr("a"), 2068 SHA: Ptr("s"), 2069 HTMLURL: Ptr("h"), 2070 } 2071 2072 want := `{ 2073 "page_name": "p", 2074 "title": "t", 2075 "summary": "s", 2076 "action": "a", 2077 "sha": "s", 2078 "html_url": "h" 2079 }` 2080 2081 testJSONMarshal(t, u, want) 2082 } 2083 2084 func TestTeamChange_Marshal(t *testing.T) { 2085 t.Parallel() 2086 testJSONMarshal(t, &TeamChange{}, "{}") 2087 2088 u := &TeamChange{ 2089 Description: &TeamDescription{ 2090 From: Ptr("DescriptionFrom"), 2091 }, 2092 Name: &TeamName{ 2093 From: Ptr("NameFrom"), 2094 }, 2095 Privacy: &TeamPrivacy{ 2096 From: Ptr("PrivacyFrom"), 2097 }, 2098 Repository: &TeamRepository{ 2099 Permissions: &TeamPermissions{ 2100 From: &TeamPermissionsFrom{ 2101 Admin: Ptr(false), 2102 Pull: Ptr(false), 2103 Push: Ptr(false), 2104 }, 2105 }, 2106 }, 2107 } 2108 2109 want := `{ 2110 "description": { 2111 "from": "DescriptionFrom" 2112 }, 2113 "name": { 2114 "from": "NameFrom" 2115 }, 2116 "privacy": { 2117 "from": "PrivacyFrom" 2118 }, 2119 "repository": { 2120 "permissions": { 2121 "from": { 2122 "admin": false, 2123 "pull": false, 2124 "push": false 2125 } 2126 } 2127 } 2128 }` 2129 2130 testJSONMarshal(t, u, want) 2131 } 2132 2133 func TestIssueCommentEvent_Marshal(t *testing.T) { 2134 t.Parallel() 2135 testJSONMarshal(t, &IssueCommentEvent{}, "{}") 2136 2137 u := &IssueCommentEvent{ 2138 Action: Ptr("a"), 2139 Issue: &Issue{ID: Ptr(int64(1))}, 2140 Comment: &IssueComment{ID: Ptr(int64(1))}, 2141 Changes: &EditChange{ 2142 Title: &EditTitle{ 2143 From: Ptr("TitleFrom"), 2144 }, 2145 Body: &EditBody{ 2146 From: Ptr("BodyFrom"), 2147 }, 2148 Base: &EditBase{ 2149 Ref: &EditRef{ 2150 From: Ptr("BaseRefFrom"), 2151 }, 2152 SHA: &EditSHA{ 2153 From: Ptr("BaseSHAFrom"), 2154 }, 2155 }, 2156 }, 2157 Repo: &Repository{ 2158 ID: Ptr(int64(1)), 2159 URL: Ptr("s"), 2160 Name: Ptr("n"), 2161 }, 2162 Sender: &User{ 2163 Login: Ptr("l"), 2164 ID: Ptr(int64(1)), 2165 NodeID: Ptr("n"), 2166 URL: Ptr("u"), 2167 ReposURL: Ptr("r"), 2168 EventsURL: Ptr("e"), 2169 AvatarURL: Ptr("a"), 2170 }, 2171 Installation: &Installation{ 2172 ID: Ptr(int64(1)), 2173 NodeID: Ptr("nid"), 2174 AppID: Ptr(int64(1)), 2175 AppSlug: Ptr("as"), 2176 TargetID: Ptr(int64(1)), 2177 Account: &User{ 2178 Login: Ptr("l"), 2179 ID: Ptr(int64(1)), 2180 URL: Ptr("u"), 2181 AvatarURL: Ptr("a"), 2182 GravatarID: Ptr("g"), 2183 Name: Ptr("n"), 2184 Company: Ptr("c"), 2185 Blog: Ptr("b"), 2186 Location: Ptr("l"), 2187 Email: Ptr("e"), 2188 Hireable: Ptr(true), 2189 Bio: Ptr("b"), 2190 TwitterUsername: Ptr("t"), 2191 PublicRepos: Ptr(1), 2192 Followers: Ptr(1), 2193 Following: Ptr(1), 2194 CreatedAt: &Timestamp{referenceTime}, 2195 SuspendedAt: &Timestamp{referenceTime}, 2196 }, 2197 AccessTokensURL: Ptr("atu"), 2198 RepositoriesURL: Ptr("ru"), 2199 HTMLURL: Ptr("hu"), 2200 TargetType: Ptr("tt"), 2201 SingleFileName: Ptr("sfn"), 2202 RepositorySelection: Ptr("rs"), 2203 Events: []string{"e"}, 2204 SingleFilePaths: []string{"s"}, 2205 Permissions: &InstallationPermissions{ 2206 Actions: Ptr("a"), 2207 Administration: Ptr("ad"), 2208 Checks: Ptr("c"), 2209 Contents: Ptr("co"), 2210 ContentReferences: Ptr("cr"), 2211 Deployments: Ptr("d"), 2212 Environments: Ptr("e"), 2213 Issues: Ptr("i"), 2214 Metadata: Ptr("md"), 2215 Members: Ptr("m"), 2216 OrganizationAdministration: Ptr("oa"), 2217 OrganizationHooks: Ptr("oh"), 2218 OrganizationPlan: Ptr("op"), 2219 OrganizationPreReceiveHooks: Ptr("opr"), 2220 OrganizationProjects: Ptr("op"), 2221 OrganizationSecrets: Ptr("os"), 2222 OrganizationSelfHostedRunners: Ptr("osh"), 2223 OrganizationUserBlocking: Ptr("oub"), 2224 Packages: Ptr("pkg"), 2225 Pages: Ptr("pg"), 2226 PullRequests: Ptr("pr"), 2227 RepositoryHooks: Ptr("rh"), 2228 RepositoryProjects: Ptr("rp"), 2229 RepositoryPreReceiveHooks: Ptr("rprh"), 2230 Secrets: Ptr("s"), 2231 SecretScanningAlerts: Ptr("ssa"), 2232 SecurityEvents: Ptr("se"), 2233 SingleFile: Ptr("sf"), 2234 Statuses: Ptr("s"), 2235 TeamDiscussions: Ptr("td"), 2236 VulnerabilityAlerts: Ptr("va"), 2237 Workflows: Ptr("w"), 2238 }, 2239 CreatedAt: &Timestamp{referenceTime}, 2240 UpdatedAt: &Timestamp{referenceTime}, 2241 HasMultipleSingleFiles: Ptr(false), 2242 SuspendedBy: &User{ 2243 Login: Ptr("l"), 2244 ID: Ptr(int64(1)), 2245 URL: Ptr("u"), 2246 AvatarURL: Ptr("a"), 2247 GravatarID: Ptr("g"), 2248 Name: Ptr("n"), 2249 Company: Ptr("c"), 2250 Blog: Ptr("b"), 2251 Location: Ptr("l"), 2252 Email: Ptr("e"), 2253 Hireable: Ptr(true), 2254 Bio: Ptr("b"), 2255 TwitterUsername: Ptr("t"), 2256 PublicRepos: Ptr(1), 2257 Followers: Ptr(1), 2258 Following: Ptr(1), 2259 CreatedAt: &Timestamp{referenceTime}, 2260 SuspendedAt: &Timestamp{referenceTime}, 2261 }, 2262 SuspendedAt: &Timestamp{referenceTime}, 2263 }, 2264 Organization: &Organization{ 2265 BillingEmail: Ptr("be"), 2266 Blog: Ptr("b"), 2267 Company: Ptr("c"), 2268 Email: Ptr("e"), 2269 TwitterUsername: Ptr("tu"), 2270 Location: Ptr("loc"), 2271 Name: Ptr("n"), 2272 Description: Ptr("d"), 2273 IsVerified: Ptr(true), 2274 HasOrganizationProjects: Ptr(true), 2275 HasRepositoryProjects: Ptr(true), 2276 DefaultRepoPermission: Ptr("drp"), 2277 MembersCanCreateRepos: Ptr(true), 2278 MembersCanCreateInternalRepos: Ptr(true), 2279 MembersCanCreatePrivateRepos: Ptr(true), 2280 MembersCanCreatePublicRepos: Ptr(false), 2281 MembersAllowedRepositoryCreationType: Ptr("marct"), 2282 MembersCanCreatePages: Ptr(true), 2283 MembersCanCreatePublicPages: Ptr(false), 2284 MembersCanCreatePrivatePages: Ptr(true), 2285 }, 2286 } 2287 2288 want := `{ 2289 "action": "a", 2290 "issue": { 2291 "id": 1 2292 }, 2293 "comment": { 2294 "id": 1 2295 }, 2296 "changes": { 2297 "title": { 2298 "from": "TitleFrom" 2299 }, 2300 "body": { 2301 "from": "BodyFrom" 2302 }, 2303 "base": { 2304 "ref": { 2305 "from": "BaseRefFrom" 2306 }, 2307 "sha": { 2308 "from": "BaseSHAFrom" 2309 } 2310 } 2311 }, 2312 "repository": { 2313 "id": 1, 2314 "name": "n", 2315 "url": "s" 2316 }, 2317 "sender": { 2318 "login": "l", 2319 "id": 1, 2320 "node_id": "n", 2321 "avatar_url": "a", 2322 "url": "u", 2323 "events_url": "e", 2324 "repos_url": "r" 2325 }, 2326 "installation": { 2327 "id": 1, 2328 "node_id": "nid", 2329 "app_id": 1, 2330 "app_slug": "as", 2331 "target_id": 1, 2332 "account": { 2333 "login": "l", 2334 "id": 1, 2335 "avatar_url": "a", 2336 "gravatar_id": "g", 2337 "name": "n", 2338 "company": "c", 2339 "blog": "b", 2340 "location": "l", 2341 "email": "e", 2342 "hireable": true, 2343 "bio": "b", 2344 "twitter_username": "t", 2345 "public_repos": 1, 2346 "followers": 1, 2347 "following": 1, 2348 "created_at": ` + referenceTimeStr + `, 2349 "suspended_at": ` + referenceTimeStr + `, 2350 "url": "u" 2351 }, 2352 "access_tokens_url": "atu", 2353 "repositories_url": "ru", 2354 "html_url": "hu", 2355 "target_type": "tt", 2356 "single_file_name": "sfn", 2357 "repository_selection": "rs", 2358 "events": [ 2359 "e" 2360 ], 2361 "single_file_paths": [ 2362 "s" 2363 ], 2364 "permissions": { 2365 "actions": "a", 2366 "administration": "ad", 2367 "checks": "c", 2368 "contents": "co", 2369 "content_references": "cr", 2370 "deployments": "d", 2371 "environments": "e", 2372 "issues": "i", 2373 "metadata": "md", 2374 "members": "m", 2375 "organization_administration": "oa", 2376 "organization_hooks": "oh", 2377 "organization_plan": "op", 2378 "organization_pre_receive_hooks": "opr", 2379 "organization_projects": "op", 2380 "organization_secrets": "os", 2381 "organization_self_hosted_runners": "osh", 2382 "organization_user_blocking": "oub", 2383 "packages": "pkg", 2384 "pages": "pg", 2385 "pull_requests": "pr", 2386 "repository_hooks": "rh", 2387 "repository_projects": "rp", 2388 "repository_pre_receive_hooks": "rprh", 2389 "secrets": "s", 2390 "secret_scanning_alerts": "ssa", 2391 "security_events": "se", 2392 "single_file": "sf", 2393 "statuses": "s", 2394 "team_discussions": "td", 2395 "vulnerability_alerts": "va", 2396 "workflows": "w" 2397 }, 2398 "created_at": ` + referenceTimeStr + `, 2399 "updated_at": ` + referenceTimeStr + `, 2400 "has_multiple_single_files": false, 2401 "suspended_by": { 2402 "login": "l", 2403 "id": 1, 2404 "avatar_url": "a", 2405 "gravatar_id": "g", 2406 "name": "n", 2407 "company": "c", 2408 "blog": "b", 2409 "location": "l", 2410 "email": "e", 2411 "hireable": true, 2412 "bio": "b", 2413 "twitter_username": "t", 2414 "public_repos": 1, 2415 "followers": 1, 2416 "following": 1, 2417 "created_at": ` + referenceTimeStr + `, 2418 "suspended_at": ` + referenceTimeStr + `, 2419 "url": "u" 2420 }, 2421 "suspended_at": ` + referenceTimeStr + ` 2422 }, 2423 "organization": { 2424 "name": "n", 2425 "company": "c", 2426 "blog": "b", 2427 "location": "loc", 2428 "email": "e", 2429 "twitter_username": "tu", 2430 "description": "d", 2431 "billing_email": "be", 2432 "is_verified": true, 2433 "has_organization_projects": true, 2434 "has_repository_projects": true, 2435 "default_repository_permission": "drp", 2436 "members_can_create_repositories": true, 2437 "members_can_create_public_repositories": false, 2438 "members_can_create_private_repositories": true, 2439 "members_can_create_internal_repositories": true, 2440 "members_allowed_repository_creation_type": "marct", 2441 "members_can_create_pages": true, 2442 "members_can_create_public_pages": false, 2443 "members_can_create_private_pages": true 2444 } 2445 }` 2446 2447 testJSONMarshal(t, u, want) 2448 } 2449 2450 func TestIssuesEvent_Marshal(t *testing.T) { 2451 t.Parallel() 2452 testJSONMarshal(t, &IssuesEvent{}, "{}") 2453 2454 u := &IssuesEvent{ 2455 Action: Ptr("a"), 2456 Issue: &Issue{ID: Ptr(int64(1))}, 2457 Assignee: &User{ 2458 Login: Ptr("l"), 2459 ID: Ptr(int64(1)), 2460 NodeID: Ptr("n"), 2461 URL: Ptr("u"), 2462 ReposURL: Ptr("r"), 2463 EventsURL: Ptr("e"), 2464 AvatarURL: Ptr("a"), 2465 }, 2466 Label: &Label{ID: Ptr(int64(1))}, 2467 Changes: &EditChange{ 2468 Title: &EditTitle{ 2469 From: Ptr("TitleFrom"), 2470 }, 2471 Body: &EditBody{ 2472 From: Ptr("BodyFrom"), 2473 }, 2474 Base: &EditBase{ 2475 Ref: &EditRef{ 2476 From: Ptr("BaseRefFrom"), 2477 }, 2478 SHA: &EditSHA{ 2479 From: Ptr("BaseSHAFrom"), 2480 }, 2481 }, 2482 }, 2483 Repo: &Repository{ 2484 ID: Ptr(int64(1)), 2485 URL: Ptr("s"), 2486 Name: Ptr("n"), 2487 }, 2488 Sender: &User{ 2489 Login: Ptr("l"), 2490 ID: Ptr(int64(1)), 2491 NodeID: Ptr("n"), 2492 URL: Ptr("u"), 2493 ReposURL: Ptr("r"), 2494 EventsURL: Ptr("e"), 2495 AvatarURL: Ptr("a"), 2496 }, 2497 Installation: &Installation{ 2498 ID: Ptr(int64(1)), 2499 NodeID: Ptr("nid"), 2500 AppID: Ptr(int64(1)), 2501 AppSlug: Ptr("as"), 2502 TargetID: Ptr(int64(1)), 2503 Account: &User{ 2504 Login: Ptr("l"), 2505 ID: Ptr(int64(1)), 2506 URL: Ptr("u"), 2507 AvatarURL: Ptr("a"), 2508 GravatarID: Ptr("g"), 2509 Name: Ptr("n"), 2510 Company: Ptr("c"), 2511 Blog: Ptr("b"), 2512 Location: Ptr("l"), 2513 Email: Ptr("e"), 2514 Hireable: Ptr(true), 2515 Bio: Ptr("b"), 2516 TwitterUsername: Ptr("t"), 2517 PublicRepos: Ptr(1), 2518 Followers: Ptr(1), 2519 Following: Ptr(1), 2520 CreatedAt: &Timestamp{referenceTime}, 2521 SuspendedAt: &Timestamp{referenceTime}, 2522 }, 2523 AccessTokensURL: Ptr("atu"), 2524 RepositoriesURL: Ptr("ru"), 2525 HTMLURL: Ptr("hu"), 2526 TargetType: Ptr("tt"), 2527 SingleFileName: Ptr("sfn"), 2528 RepositorySelection: Ptr("rs"), 2529 Events: []string{"e"}, 2530 SingleFilePaths: []string{"s"}, 2531 Permissions: &InstallationPermissions{ 2532 Actions: Ptr("a"), 2533 Administration: Ptr("ad"), 2534 Checks: Ptr("c"), 2535 Contents: Ptr("co"), 2536 ContentReferences: Ptr("cr"), 2537 Deployments: Ptr("d"), 2538 Environments: Ptr("e"), 2539 Issues: Ptr("i"), 2540 Metadata: Ptr("md"), 2541 Members: Ptr("m"), 2542 OrganizationAdministration: Ptr("oa"), 2543 OrganizationHooks: Ptr("oh"), 2544 OrganizationPlan: Ptr("op"), 2545 OrganizationPreReceiveHooks: Ptr("opr"), 2546 OrganizationProjects: Ptr("op"), 2547 OrganizationSecrets: Ptr("os"), 2548 OrganizationSelfHostedRunners: Ptr("osh"), 2549 OrganizationUserBlocking: Ptr("oub"), 2550 Packages: Ptr("pkg"), 2551 Pages: Ptr("pg"), 2552 PullRequests: Ptr("pr"), 2553 RepositoryHooks: Ptr("rh"), 2554 RepositoryProjects: Ptr("rp"), 2555 RepositoryPreReceiveHooks: Ptr("rprh"), 2556 Secrets: Ptr("s"), 2557 SecretScanningAlerts: Ptr("ssa"), 2558 SecurityEvents: Ptr("se"), 2559 SingleFile: Ptr("sf"), 2560 Statuses: Ptr("s"), 2561 TeamDiscussions: Ptr("td"), 2562 VulnerabilityAlerts: Ptr("va"), 2563 Workflows: Ptr("w"), 2564 }, 2565 CreatedAt: &Timestamp{referenceTime}, 2566 UpdatedAt: &Timestamp{referenceTime}, 2567 HasMultipleSingleFiles: Ptr(false), 2568 SuspendedBy: &User{ 2569 Login: Ptr("l"), 2570 ID: Ptr(int64(1)), 2571 URL: Ptr("u"), 2572 AvatarURL: Ptr("a"), 2573 GravatarID: Ptr("g"), 2574 Name: Ptr("n"), 2575 Company: Ptr("c"), 2576 Blog: Ptr("b"), 2577 Location: Ptr("l"), 2578 Email: Ptr("e"), 2579 Hireable: Ptr(true), 2580 Bio: Ptr("b"), 2581 TwitterUsername: Ptr("t"), 2582 PublicRepos: Ptr(1), 2583 Followers: Ptr(1), 2584 Following: Ptr(1), 2585 CreatedAt: &Timestamp{referenceTime}, 2586 SuspendedAt: &Timestamp{referenceTime}, 2587 }, 2588 SuspendedAt: &Timestamp{referenceTime}, 2589 }, 2590 } 2591 2592 want := `{ 2593 "action": "a", 2594 "issue": { 2595 "id": 1 2596 }, 2597 "assignee": { 2598 "login": "l", 2599 "id": 1, 2600 "node_id": "n", 2601 "avatar_url": "a", 2602 "url": "u", 2603 "events_url": "e", 2604 "repos_url": "r" 2605 }, 2606 "label": { 2607 "id": 1 2608 }, 2609 "changes": { 2610 "title": { 2611 "from": "TitleFrom" 2612 }, 2613 "body": { 2614 "from": "BodyFrom" 2615 }, 2616 "base": { 2617 "ref": { 2618 "from": "BaseRefFrom" 2619 }, 2620 "sha": { 2621 "from": "BaseSHAFrom" 2622 } 2623 } 2624 }, 2625 "repository": { 2626 "id": 1, 2627 "name": "n", 2628 "url": "s" 2629 }, 2630 "sender": { 2631 "login": "l", 2632 "id": 1, 2633 "node_id": "n", 2634 "avatar_url": "a", 2635 "url": "u", 2636 "events_url": "e", 2637 "repos_url": "r" 2638 }, 2639 "installation": { 2640 "id": 1, 2641 "node_id": "nid", 2642 "app_id": 1, 2643 "app_slug": "as", 2644 "target_id": 1, 2645 "account": { 2646 "login": "l", 2647 "id": 1, 2648 "avatar_url": "a", 2649 "gravatar_id": "g", 2650 "name": "n", 2651 "company": "c", 2652 "blog": "b", 2653 "location": "l", 2654 "email": "e", 2655 "hireable": true, 2656 "bio": "b", 2657 "twitter_username": "t", 2658 "public_repos": 1, 2659 "followers": 1, 2660 "following": 1, 2661 "created_at": ` + referenceTimeStr + `, 2662 "suspended_at": ` + referenceTimeStr + `, 2663 "url": "u" 2664 }, 2665 "access_tokens_url": "atu", 2666 "repositories_url": "ru", 2667 "html_url": "hu", 2668 "target_type": "tt", 2669 "single_file_name": "sfn", 2670 "repository_selection": "rs", 2671 "events": [ 2672 "e" 2673 ], 2674 "single_file_paths": [ 2675 "s" 2676 ], 2677 "permissions": { 2678 "actions": "a", 2679 "administration": "ad", 2680 "checks": "c", 2681 "contents": "co", 2682 "content_references": "cr", 2683 "deployments": "d", 2684 "environments": "e", 2685 "issues": "i", 2686 "metadata": "md", 2687 "members": "m", 2688 "organization_administration": "oa", 2689 "organization_hooks": "oh", 2690 "organization_plan": "op", 2691 "organization_pre_receive_hooks": "opr", 2692 "organization_projects": "op", 2693 "organization_secrets": "os", 2694 "organization_self_hosted_runners": "osh", 2695 "organization_user_blocking": "oub", 2696 "packages": "pkg", 2697 "pages": "pg", 2698 "pull_requests": "pr", 2699 "repository_hooks": "rh", 2700 "repository_projects": "rp", 2701 "repository_pre_receive_hooks": "rprh", 2702 "secrets": "s", 2703 "secret_scanning_alerts": "ssa", 2704 "security_events": "se", 2705 "single_file": "sf", 2706 "statuses": "s", 2707 "team_discussions": "td", 2708 "vulnerability_alerts": "va", 2709 "workflows": "w" 2710 }, 2711 "created_at": ` + referenceTimeStr + `, 2712 "updated_at": ` + referenceTimeStr + `, 2713 "has_multiple_single_files": false, 2714 "suspended_by": { 2715 "login": "l", 2716 "id": 1, 2717 "avatar_url": "a", 2718 "gravatar_id": "g", 2719 "name": "n", 2720 "company": "c", 2721 "blog": "b", 2722 "location": "l", 2723 "email": "e", 2724 "hireable": true, 2725 "bio": "b", 2726 "twitter_username": "t", 2727 "public_repos": 1, 2728 "followers": 1, 2729 "following": 1, 2730 "created_at": ` + referenceTimeStr + `, 2731 "suspended_at": ` + referenceTimeStr + `, 2732 "url": "u" 2733 }, 2734 "suspended_at": ` + referenceTimeStr + ` 2735 } 2736 }` 2737 2738 testJSONMarshal(t, u, want) 2739 } 2740 2741 func TestLabelEvent_Marshal(t *testing.T) { 2742 t.Parallel() 2743 testJSONMarshal(t, &LabelEvent{}, "{}") 2744 2745 u := &LabelEvent{ 2746 Action: Ptr("a"), 2747 Label: &Label{ID: Ptr(int64(1))}, 2748 Changes: &EditChange{ 2749 Title: &EditTitle{ 2750 From: Ptr("TitleFrom"), 2751 }, 2752 Body: &EditBody{ 2753 From: Ptr("BodyFrom"), 2754 }, 2755 Base: &EditBase{ 2756 Ref: &EditRef{ 2757 From: Ptr("BaseRefFrom"), 2758 }, 2759 SHA: &EditSHA{ 2760 From: Ptr("BaseSHAFrom"), 2761 }, 2762 }, 2763 }, 2764 Repo: &Repository{ 2765 ID: Ptr(int64(1)), 2766 URL: Ptr("s"), 2767 Name: Ptr("n"), 2768 }, 2769 Org: &Organization{ 2770 BillingEmail: Ptr("be"), 2771 Blog: Ptr("b"), 2772 Company: Ptr("c"), 2773 Email: Ptr("e"), 2774 TwitterUsername: Ptr("tu"), 2775 Location: Ptr("loc"), 2776 Name: Ptr("n"), 2777 Description: Ptr("d"), 2778 IsVerified: Ptr(true), 2779 HasOrganizationProjects: Ptr(true), 2780 HasRepositoryProjects: Ptr(true), 2781 DefaultRepoPermission: Ptr("drp"), 2782 MembersCanCreateRepos: Ptr(true), 2783 MembersCanCreateInternalRepos: Ptr(true), 2784 MembersCanCreatePrivateRepos: Ptr(true), 2785 MembersCanCreatePublicRepos: Ptr(false), 2786 MembersAllowedRepositoryCreationType: Ptr("marct"), 2787 MembersCanCreatePages: Ptr(true), 2788 MembersCanCreatePublicPages: Ptr(false), 2789 MembersCanCreatePrivatePages: Ptr(true), 2790 }, 2791 Installation: &Installation{ 2792 ID: Ptr(int64(1)), 2793 NodeID: Ptr("nid"), 2794 AppID: Ptr(int64(1)), 2795 AppSlug: Ptr("as"), 2796 TargetID: Ptr(int64(1)), 2797 Account: &User{ 2798 Login: Ptr("l"), 2799 ID: Ptr(int64(1)), 2800 URL: Ptr("u"), 2801 AvatarURL: Ptr("a"), 2802 GravatarID: Ptr("g"), 2803 Name: Ptr("n"), 2804 Company: Ptr("c"), 2805 Blog: Ptr("b"), 2806 Location: Ptr("l"), 2807 Email: Ptr("e"), 2808 Hireable: Ptr(true), 2809 Bio: Ptr("b"), 2810 TwitterUsername: Ptr("t"), 2811 PublicRepos: Ptr(1), 2812 Followers: Ptr(1), 2813 Following: Ptr(1), 2814 CreatedAt: &Timestamp{referenceTime}, 2815 SuspendedAt: &Timestamp{referenceTime}, 2816 }, 2817 AccessTokensURL: Ptr("atu"), 2818 RepositoriesURL: Ptr("ru"), 2819 HTMLURL: Ptr("hu"), 2820 TargetType: Ptr("tt"), 2821 SingleFileName: Ptr("sfn"), 2822 RepositorySelection: Ptr("rs"), 2823 Events: []string{"e"}, 2824 SingleFilePaths: []string{"s"}, 2825 Permissions: &InstallationPermissions{ 2826 Actions: Ptr("a"), 2827 Administration: Ptr("ad"), 2828 Checks: Ptr("c"), 2829 Contents: Ptr("co"), 2830 ContentReferences: Ptr("cr"), 2831 Deployments: Ptr("d"), 2832 Environments: Ptr("e"), 2833 Issues: Ptr("i"), 2834 Metadata: Ptr("md"), 2835 Members: Ptr("m"), 2836 OrganizationAdministration: Ptr("oa"), 2837 OrganizationHooks: Ptr("oh"), 2838 OrganizationPlan: Ptr("op"), 2839 OrganizationPreReceiveHooks: Ptr("opr"), 2840 OrganizationProjects: Ptr("op"), 2841 OrganizationSecrets: Ptr("os"), 2842 OrganizationSelfHostedRunners: Ptr("osh"), 2843 OrganizationUserBlocking: Ptr("oub"), 2844 Packages: Ptr("pkg"), 2845 Pages: Ptr("pg"), 2846 PullRequests: Ptr("pr"), 2847 RepositoryHooks: Ptr("rh"), 2848 RepositoryProjects: Ptr("rp"), 2849 RepositoryPreReceiveHooks: Ptr("rprh"), 2850 Secrets: Ptr("s"), 2851 SecretScanningAlerts: Ptr("ssa"), 2852 SecurityEvents: Ptr("se"), 2853 SingleFile: Ptr("sf"), 2854 Statuses: Ptr("s"), 2855 TeamDiscussions: Ptr("td"), 2856 VulnerabilityAlerts: Ptr("va"), 2857 Workflows: Ptr("w"), 2858 }, 2859 CreatedAt: &Timestamp{referenceTime}, 2860 UpdatedAt: &Timestamp{referenceTime}, 2861 HasMultipleSingleFiles: Ptr(false), 2862 SuspendedBy: &User{ 2863 Login: Ptr("l"), 2864 ID: Ptr(int64(1)), 2865 URL: Ptr("u"), 2866 AvatarURL: Ptr("a"), 2867 GravatarID: Ptr("g"), 2868 Name: Ptr("n"), 2869 Company: Ptr("c"), 2870 Blog: Ptr("b"), 2871 Location: Ptr("l"), 2872 Email: Ptr("e"), 2873 Hireable: Ptr(true), 2874 Bio: Ptr("b"), 2875 TwitterUsername: Ptr("t"), 2876 PublicRepos: Ptr(1), 2877 Followers: Ptr(1), 2878 Following: Ptr(1), 2879 CreatedAt: &Timestamp{referenceTime}, 2880 SuspendedAt: &Timestamp{referenceTime}, 2881 }, 2882 SuspendedAt: &Timestamp{referenceTime}, 2883 }, 2884 } 2885 2886 want := `{ 2887 "action": "a", 2888 "label": { 2889 "id": 1 2890 }, 2891 "changes": { 2892 "title": { 2893 "from": "TitleFrom" 2894 }, 2895 "body": { 2896 "from": "BodyFrom" 2897 }, 2898 "base": { 2899 "ref": { 2900 "from": "BaseRefFrom" 2901 }, 2902 "sha": { 2903 "from": "BaseSHAFrom" 2904 } 2905 } 2906 }, 2907 "repository": { 2908 "id": 1, 2909 "name": "n", 2910 "url": "s" 2911 }, 2912 "organization": { 2913 "name": "n", 2914 "company": "c", 2915 "blog": "b", 2916 "location": "loc", 2917 "email": "e", 2918 "twitter_username": "tu", 2919 "description": "d", 2920 "billing_email": "be", 2921 "is_verified": true, 2922 "has_organization_projects": true, 2923 "has_repository_projects": true, 2924 "default_repository_permission": "drp", 2925 "members_can_create_repositories": true, 2926 "members_can_create_public_repositories": false, 2927 "members_can_create_private_repositories": true, 2928 "members_can_create_internal_repositories": true, 2929 "members_allowed_repository_creation_type": "marct", 2930 "members_can_create_pages": true, 2931 "members_can_create_public_pages": false, 2932 "members_can_create_private_pages": true 2933 }, 2934 "installation": { 2935 "id": 1, 2936 "node_id": "nid", 2937 "app_id": 1, 2938 "app_slug": "as", 2939 "target_id": 1, 2940 "account": { 2941 "login": "l", 2942 "id": 1, 2943 "avatar_url": "a", 2944 "gravatar_id": "g", 2945 "name": "n", 2946 "company": "c", 2947 "blog": "b", 2948 "location": "l", 2949 "email": "e", 2950 "hireable": true, 2951 "bio": "b", 2952 "twitter_username": "t", 2953 "public_repos": 1, 2954 "followers": 1, 2955 "following": 1, 2956 "created_at": ` + referenceTimeStr + `, 2957 "suspended_at": ` + referenceTimeStr + `, 2958 "url": "u" 2959 }, 2960 "access_tokens_url": "atu", 2961 "repositories_url": "ru", 2962 "html_url": "hu", 2963 "target_type": "tt", 2964 "single_file_name": "sfn", 2965 "repository_selection": "rs", 2966 "events": [ 2967 "e" 2968 ], 2969 "single_file_paths": [ 2970 "s" 2971 ], 2972 "permissions": { 2973 "actions": "a", 2974 "administration": "ad", 2975 "checks": "c", 2976 "contents": "co", 2977 "content_references": "cr", 2978 "deployments": "d", 2979 "environments": "e", 2980 "issues": "i", 2981 "metadata": "md", 2982 "members": "m", 2983 "organization_administration": "oa", 2984 "organization_hooks": "oh", 2985 "organization_plan": "op", 2986 "organization_pre_receive_hooks": "opr", 2987 "organization_projects": "op", 2988 "organization_secrets": "os", 2989 "organization_self_hosted_runners": "osh", 2990 "organization_user_blocking": "oub", 2991 "packages": "pkg", 2992 "pages": "pg", 2993 "pull_requests": "pr", 2994 "repository_hooks": "rh", 2995 "repository_projects": "rp", 2996 "repository_pre_receive_hooks": "rprh", 2997 "secrets": "s", 2998 "secret_scanning_alerts": "ssa", 2999 "security_events": "se", 3000 "single_file": "sf", 3001 "statuses": "s", 3002 "team_discussions": "td", 3003 "vulnerability_alerts": "va", 3004 "workflows": "w" 3005 }, 3006 "created_at": ` + referenceTimeStr + `, 3007 "updated_at": ` + referenceTimeStr + `, 3008 "has_multiple_single_files": false, 3009 "suspended_by": { 3010 "login": "l", 3011 "id": 1, 3012 "avatar_url": "a", 3013 "gravatar_id": "g", 3014 "name": "n", 3015 "company": "c", 3016 "blog": "b", 3017 "location": "l", 3018 "email": "e", 3019 "hireable": true, 3020 "bio": "b", 3021 "twitter_username": "t", 3022 "public_repos": 1, 3023 "followers": 1, 3024 "following": 1, 3025 "created_at": ` + referenceTimeStr + `, 3026 "suspended_at": ` + referenceTimeStr + `, 3027 "url": "u" 3028 }, 3029 "suspended_at": ` + referenceTimeStr + ` 3030 } 3031 }` 3032 3033 testJSONMarshal(t, u, want) 3034 } 3035 3036 func TestMilestoneEvent_Marshal(t *testing.T) { 3037 t.Parallel() 3038 testJSONMarshal(t, &MilestoneEvent{}, "{}") 3039 3040 u := &MilestoneEvent{ 3041 Action: Ptr("a"), 3042 Milestone: &Milestone{ID: Ptr(int64(1))}, 3043 Changes: &EditChange{ 3044 Title: &EditTitle{ 3045 From: Ptr("TitleFrom"), 3046 }, 3047 Body: &EditBody{ 3048 From: Ptr("BodyFrom"), 3049 }, 3050 Base: &EditBase{ 3051 Ref: &EditRef{ 3052 From: Ptr("BaseRefFrom"), 3053 }, 3054 SHA: &EditSHA{ 3055 From: Ptr("BaseSHAFrom"), 3056 }, 3057 }, 3058 }, 3059 Repo: &Repository{ 3060 ID: Ptr(int64(1)), 3061 URL: Ptr("s"), 3062 Name: Ptr("n"), 3063 }, 3064 Sender: &User{ 3065 Login: Ptr("l"), 3066 ID: Ptr(int64(1)), 3067 NodeID: Ptr("n"), 3068 URL: Ptr("u"), 3069 ReposURL: Ptr("r"), 3070 EventsURL: Ptr("e"), 3071 AvatarURL: Ptr("a"), 3072 }, 3073 Org: &Organization{ 3074 BillingEmail: Ptr("be"), 3075 Blog: Ptr("b"), 3076 Company: Ptr("c"), 3077 Email: Ptr("e"), 3078 TwitterUsername: Ptr("tu"), 3079 Location: Ptr("loc"), 3080 Name: Ptr("n"), 3081 Description: Ptr("d"), 3082 IsVerified: Ptr(true), 3083 HasOrganizationProjects: Ptr(true), 3084 HasRepositoryProjects: Ptr(true), 3085 DefaultRepoPermission: Ptr("drp"), 3086 MembersCanCreateRepos: Ptr(true), 3087 MembersCanCreateInternalRepos: Ptr(true), 3088 MembersCanCreatePrivateRepos: Ptr(true), 3089 MembersCanCreatePublicRepos: Ptr(false), 3090 MembersAllowedRepositoryCreationType: Ptr("marct"), 3091 MembersCanCreatePages: Ptr(true), 3092 MembersCanCreatePublicPages: Ptr(false), 3093 MembersCanCreatePrivatePages: Ptr(true), 3094 }, 3095 Installation: &Installation{ 3096 ID: Ptr(int64(1)), 3097 NodeID: Ptr("nid"), 3098 AppID: Ptr(int64(1)), 3099 AppSlug: Ptr("as"), 3100 TargetID: Ptr(int64(1)), 3101 Account: &User{ 3102 Login: Ptr("l"), 3103 ID: Ptr(int64(1)), 3104 URL: Ptr("u"), 3105 AvatarURL: Ptr("a"), 3106 GravatarID: Ptr("g"), 3107 Name: Ptr("n"), 3108 Company: Ptr("c"), 3109 Blog: Ptr("b"), 3110 Location: Ptr("l"), 3111 Email: Ptr("e"), 3112 Hireable: Ptr(true), 3113 Bio: Ptr("b"), 3114 TwitterUsername: Ptr("t"), 3115 PublicRepos: Ptr(1), 3116 Followers: Ptr(1), 3117 Following: Ptr(1), 3118 CreatedAt: &Timestamp{referenceTime}, 3119 SuspendedAt: &Timestamp{referenceTime}, 3120 }, 3121 AccessTokensURL: Ptr("atu"), 3122 RepositoriesURL: Ptr("ru"), 3123 HTMLURL: Ptr("hu"), 3124 TargetType: Ptr("tt"), 3125 SingleFileName: Ptr("sfn"), 3126 RepositorySelection: Ptr("rs"), 3127 Events: []string{"e"}, 3128 SingleFilePaths: []string{"s"}, 3129 Permissions: &InstallationPermissions{ 3130 Actions: Ptr("a"), 3131 Administration: Ptr("ad"), 3132 Checks: Ptr("c"), 3133 Contents: Ptr("co"), 3134 ContentReferences: Ptr("cr"), 3135 Deployments: Ptr("d"), 3136 Environments: Ptr("e"), 3137 Issues: Ptr("i"), 3138 Metadata: Ptr("md"), 3139 Members: Ptr("m"), 3140 OrganizationAdministration: Ptr("oa"), 3141 OrganizationHooks: Ptr("oh"), 3142 OrganizationPlan: Ptr("op"), 3143 OrganizationPreReceiveHooks: Ptr("opr"), 3144 OrganizationProjects: Ptr("op"), 3145 OrganizationSecrets: Ptr("os"), 3146 OrganizationSelfHostedRunners: Ptr("osh"), 3147 OrganizationUserBlocking: Ptr("oub"), 3148 Packages: Ptr("pkg"), 3149 Pages: Ptr("pg"), 3150 PullRequests: Ptr("pr"), 3151 RepositoryHooks: Ptr("rh"), 3152 RepositoryProjects: Ptr("rp"), 3153 RepositoryPreReceiveHooks: Ptr("rprh"), 3154 Secrets: Ptr("s"), 3155 SecretScanningAlerts: Ptr("ssa"), 3156 SecurityEvents: Ptr("se"), 3157 SingleFile: Ptr("sf"), 3158 Statuses: Ptr("s"), 3159 TeamDiscussions: Ptr("td"), 3160 VulnerabilityAlerts: Ptr("va"), 3161 Workflows: Ptr("w"), 3162 }, 3163 CreatedAt: &Timestamp{referenceTime}, 3164 UpdatedAt: &Timestamp{referenceTime}, 3165 HasMultipleSingleFiles: Ptr(false), 3166 SuspendedBy: &User{ 3167 Login: Ptr("l"), 3168 ID: Ptr(int64(1)), 3169 URL: Ptr("u"), 3170 AvatarURL: Ptr("a"), 3171 GravatarID: Ptr("g"), 3172 Name: Ptr("n"), 3173 Company: Ptr("c"), 3174 Blog: Ptr("b"), 3175 Location: Ptr("l"), 3176 Email: Ptr("e"), 3177 Hireable: Ptr(true), 3178 Bio: Ptr("b"), 3179 TwitterUsername: Ptr("t"), 3180 PublicRepos: Ptr(1), 3181 Followers: Ptr(1), 3182 Following: Ptr(1), 3183 CreatedAt: &Timestamp{referenceTime}, 3184 SuspendedAt: &Timestamp{referenceTime}, 3185 }, 3186 SuspendedAt: &Timestamp{referenceTime}, 3187 }, 3188 } 3189 3190 want := `{ 3191 "action": "a", 3192 "milestone": { 3193 "id": 1 3194 }, 3195 "changes": { 3196 "title": { 3197 "from": "TitleFrom" 3198 }, 3199 "body": { 3200 "from": "BodyFrom" 3201 }, 3202 "base": { 3203 "ref": { 3204 "from": "BaseRefFrom" 3205 }, 3206 "sha": { 3207 "from": "BaseSHAFrom" 3208 } 3209 } 3210 }, 3211 "repository": { 3212 "id": 1, 3213 "name": "n", 3214 "url": "s" 3215 }, 3216 "sender": { 3217 "login": "l", 3218 "id": 1, 3219 "node_id": "n", 3220 "avatar_url": "a", 3221 "url": "u", 3222 "events_url": "e", 3223 "repos_url": "r" 3224 }, 3225 "organization": { 3226 "name": "n", 3227 "company": "c", 3228 "blog": "b", 3229 "location": "loc", 3230 "email": "e", 3231 "twitter_username": "tu", 3232 "description": "d", 3233 "billing_email": "be", 3234 "is_verified": true, 3235 "has_organization_projects": true, 3236 "has_repository_projects": true, 3237 "default_repository_permission": "drp", 3238 "members_can_create_repositories": true, 3239 "members_can_create_public_repositories": false, 3240 "members_can_create_private_repositories": true, 3241 "members_can_create_internal_repositories": true, 3242 "members_allowed_repository_creation_type": "marct", 3243 "members_can_create_pages": true, 3244 "members_can_create_public_pages": false, 3245 "members_can_create_private_pages": true 3246 }, 3247 "installation": { 3248 "id": 1, 3249 "node_id": "nid", 3250 "app_id": 1, 3251 "app_slug": "as", 3252 "target_id": 1, 3253 "account": { 3254 "login": "l", 3255 "id": 1, 3256 "avatar_url": "a", 3257 "gravatar_id": "g", 3258 "name": "n", 3259 "company": "c", 3260 "blog": "b", 3261 "location": "l", 3262 "email": "e", 3263 "hireable": true, 3264 "bio": "b", 3265 "twitter_username": "t", 3266 "public_repos": 1, 3267 "followers": 1, 3268 "following": 1, 3269 "created_at": ` + referenceTimeStr + `, 3270 "suspended_at": ` + referenceTimeStr + `, 3271 "url": "u" 3272 }, 3273 "access_tokens_url": "atu", 3274 "repositories_url": "ru", 3275 "html_url": "hu", 3276 "target_type": "tt", 3277 "single_file_name": "sfn", 3278 "repository_selection": "rs", 3279 "events": [ 3280 "e" 3281 ], 3282 "single_file_paths": [ 3283 "s" 3284 ], 3285 "permissions": { 3286 "actions": "a", 3287 "administration": "ad", 3288 "checks": "c", 3289 "contents": "co", 3290 "content_references": "cr", 3291 "deployments": "d", 3292 "environments": "e", 3293 "issues": "i", 3294 "metadata": "md", 3295 "members": "m", 3296 "organization_administration": "oa", 3297 "organization_hooks": "oh", 3298 "organization_plan": "op", 3299 "organization_pre_receive_hooks": "opr", 3300 "organization_projects": "op", 3301 "organization_secrets": "os", 3302 "organization_self_hosted_runners": "osh", 3303 "organization_user_blocking": "oub", 3304 "packages": "pkg", 3305 "pages": "pg", 3306 "pull_requests": "pr", 3307 "repository_hooks": "rh", 3308 "repository_projects": "rp", 3309 "repository_pre_receive_hooks": "rprh", 3310 "secrets": "s", 3311 "secret_scanning_alerts": "ssa", 3312 "security_events": "se", 3313 "single_file": "sf", 3314 "statuses": "s", 3315 "team_discussions": "td", 3316 "vulnerability_alerts": "va", 3317 "workflows": "w" 3318 }, 3319 "created_at": ` + referenceTimeStr + `, 3320 "updated_at": ` + referenceTimeStr + `, 3321 "has_multiple_single_files": false, 3322 "suspended_by": { 3323 "login": "l", 3324 "id": 1, 3325 "avatar_url": "a", 3326 "gravatar_id": "g", 3327 "name": "n", 3328 "company": "c", 3329 "blog": "b", 3330 "location": "l", 3331 "email": "e", 3332 "hireable": true, 3333 "bio": "b", 3334 "twitter_username": "t", 3335 "public_repos": 1, 3336 "followers": 1, 3337 "following": 1, 3338 "created_at": ` + referenceTimeStr + `, 3339 "suspended_at": ` + referenceTimeStr + `, 3340 "url": "u" 3341 }, 3342 "suspended_at": ` + referenceTimeStr + ` 3343 } 3344 }` 3345 3346 testJSONMarshal(t, u, want) 3347 } 3348 3349 func TestPublicEvent_Marshal(t *testing.T) { 3350 t.Parallel() 3351 testJSONMarshal(t, &PublicEvent{}, "{}") 3352 3353 u := &PublicEvent{ 3354 Repo: &Repository{ 3355 ID: Ptr(int64(1)), 3356 URL: Ptr("s"), 3357 Name: Ptr("n"), 3358 }, 3359 Sender: &User{ 3360 Login: Ptr("l"), 3361 ID: Ptr(int64(1)), 3362 NodeID: Ptr("n"), 3363 URL: Ptr("u"), 3364 ReposURL: Ptr("r"), 3365 EventsURL: Ptr("e"), 3366 AvatarURL: Ptr("a"), 3367 }, 3368 Installation: &Installation{ 3369 ID: Ptr(int64(1)), 3370 NodeID: Ptr("nid"), 3371 AppID: Ptr(int64(1)), 3372 AppSlug: Ptr("as"), 3373 TargetID: Ptr(int64(1)), 3374 Account: &User{ 3375 Login: Ptr("l"), 3376 ID: Ptr(int64(1)), 3377 URL: Ptr("u"), 3378 AvatarURL: Ptr("a"), 3379 GravatarID: Ptr("g"), 3380 Name: Ptr("n"), 3381 Company: Ptr("c"), 3382 Blog: Ptr("b"), 3383 Location: Ptr("l"), 3384 Email: Ptr("e"), 3385 Hireable: Ptr(true), 3386 Bio: Ptr("b"), 3387 TwitterUsername: Ptr("t"), 3388 PublicRepos: Ptr(1), 3389 Followers: Ptr(1), 3390 Following: Ptr(1), 3391 CreatedAt: &Timestamp{referenceTime}, 3392 SuspendedAt: &Timestamp{referenceTime}, 3393 }, 3394 AccessTokensURL: Ptr("atu"), 3395 RepositoriesURL: Ptr("ru"), 3396 HTMLURL: Ptr("hu"), 3397 TargetType: Ptr("tt"), 3398 SingleFileName: Ptr("sfn"), 3399 RepositorySelection: Ptr("rs"), 3400 Events: []string{"e"}, 3401 SingleFilePaths: []string{"s"}, 3402 Permissions: &InstallationPermissions{ 3403 Actions: Ptr("a"), 3404 Administration: Ptr("ad"), 3405 Checks: Ptr("c"), 3406 Contents: Ptr("co"), 3407 ContentReferences: Ptr("cr"), 3408 Deployments: Ptr("d"), 3409 Environments: Ptr("e"), 3410 Issues: Ptr("i"), 3411 Metadata: Ptr("md"), 3412 Members: Ptr("m"), 3413 OrganizationAdministration: Ptr("oa"), 3414 OrganizationHooks: Ptr("oh"), 3415 OrganizationPlan: Ptr("op"), 3416 OrganizationPreReceiveHooks: Ptr("opr"), 3417 OrganizationProjects: Ptr("op"), 3418 OrganizationSecrets: Ptr("os"), 3419 OrganizationSelfHostedRunners: Ptr("osh"), 3420 OrganizationUserBlocking: Ptr("oub"), 3421 Packages: Ptr("pkg"), 3422 Pages: Ptr("pg"), 3423 PullRequests: Ptr("pr"), 3424 RepositoryHooks: Ptr("rh"), 3425 RepositoryProjects: Ptr("rp"), 3426 RepositoryPreReceiveHooks: Ptr("rprh"), 3427 Secrets: Ptr("s"), 3428 SecretScanningAlerts: Ptr("ssa"), 3429 SecurityEvents: Ptr("se"), 3430 SingleFile: Ptr("sf"), 3431 Statuses: Ptr("s"), 3432 TeamDiscussions: Ptr("td"), 3433 VulnerabilityAlerts: Ptr("va"), 3434 Workflows: Ptr("w"), 3435 }, 3436 CreatedAt: &Timestamp{referenceTime}, 3437 UpdatedAt: &Timestamp{referenceTime}, 3438 HasMultipleSingleFiles: Ptr(false), 3439 SuspendedBy: &User{ 3440 Login: Ptr("l"), 3441 ID: Ptr(int64(1)), 3442 URL: Ptr("u"), 3443 AvatarURL: Ptr("a"), 3444 GravatarID: Ptr("g"), 3445 Name: Ptr("n"), 3446 Company: Ptr("c"), 3447 Blog: Ptr("b"), 3448 Location: Ptr("l"), 3449 Email: Ptr("e"), 3450 Hireable: Ptr(true), 3451 Bio: Ptr("b"), 3452 TwitterUsername: Ptr("t"), 3453 PublicRepos: Ptr(1), 3454 Followers: Ptr(1), 3455 Following: Ptr(1), 3456 CreatedAt: &Timestamp{referenceTime}, 3457 SuspendedAt: &Timestamp{referenceTime}, 3458 }, 3459 SuspendedAt: &Timestamp{referenceTime}, 3460 }, 3461 } 3462 3463 want := `{ 3464 "repository": { 3465 "id": 1, 3466 "name": "n", 3467 "url": "s" 3468 }, 3469 "sender": { 3470 "login": "l", 3471 "id": 1, 3472 "node_id": "n", 3473 "avatar_url": "a", 3474 "url": "u", 3475 "events_url": "e", 3476 "repos_url": "r" 3477 }, 3478 "installation": { 3479 "id": 1, 3480 "node_id": "nid", 3481 "app_id": 1, 3482 "app_slug": "as", 3483 "target_id": 1, 3484 "account": { 3485 "login": "l", 3486 "id": 1, 3487 "avatar_url": "a", 3488 "gravatar_id": "g", 3489 "name": "n", 3490 "company": "c", 3491 "blog": "b", 3492 "location": "l", 3493 "email": "e", 3494 "hireable": true, 3495 "bio": "b", 3496 "twitter_username": "t", 3497 "public_repos": 1, 3498 "followers": 1, 3499 "following": 1, 3500 "created_at": ` + referenceTimeStr + `, 3501 "suspended_at": ` + referenceTimeStr + `, 3502 "url": "u" 3503 }, 3504 "access_tokens_url": "atu", 3505 "repositories_url": "ru", 3506 "html_url": "hu", 3507 "target_type": "tt", 3508 "single_file_name": "sfn", 3509 "repository_selection": "rs", 3510 "events": [ 3511 "e" 3512 ], 3513 "single_file_paths": [ 3514 "s" 3515 ], 3516 "permissions": { 3517 "actions": "a", 3518 "administration": "ad", 3519 "checks": "c", 3520 "contents": "co", 3521 "content_references": "cr", 3522 "deployments": "d", 3523 "environments": "e", 3524 "issues": "i", 3525 "metadata": "md", 3526 "members": "m", 3527 "organization_administration": "oa", 3528 "organization_hooks": "oh", 3529 "organization_plan": "op", 3530 "organization_pre_receive_hooks": "opr", 3531 "organization_projects": "op", 3532 "organization_secrets": "os", 3533 "organization_self_hosted_runners": "osh", 3534 "organization_user_blocking": "oub", 3535 "packages": "pkg", 3536 "pages": "pg", 3537 "pull_requests": "pr", 3538 "repository_hooks": "rh", 3539 "repository_projects": "rp", 3540 "repository_pre_receive_hooks": "rprh", 3541 "secrets": "s", 3542 "secret_scanning_alerts": "ssa", 3543 "security_events": "se", 3544 "single_file": "sf", 3545 "statuses": "s", 3546 "team_discussions": "td", 3547 "vulnerability_alerts": "va", 3548 "workflows": "w" 3549 }, 3550 "created_at": ` + referenceTimeStr + `, 3551 "updated_at": ` + referenceTimeStr + `, 3552 "has_multiple_single_files": false, 3553 "suspended_by": { 3554 "login": "l", 3555 "id": 1, 3556 "avatar_url": "a", 3557 "gravatar_id": "g", 3558 "name": "n", 3559 "company": "c", 3560 "blog": "b", 3561 "location": "l", 3562 "email": "e", 3563 "hireable": true, 3564 "bio": "b", 3565 "twitter_username": "t", 3566 "public_repos": 1, 3567 "followers": 1, 3568 "following": 1, 3569 "created_at": ` + referenceTimeStr + `, 3570 "suspended_at": ` + referenceTimeStr + `, 3571 "url": "u" 3572 }, 3573 "suspended_at": ` + referenceTimeStr + ` 3574 } 3575 }` 3576 3577 testJSONMarshal(t, u, want) 3578 } 3579 3580 func TestPullRequestReviewEvent_Marshal(t *testing.T) { 3581 t.Parallel() 3582 testJSONMarshal(t, &PullRequestReviewEvent{}, "{}") 3583 3584 u := &PullRequestReviewEvent{ 3585 Action: Ptr("a"), 3586 Review: &PullRequestReview{ID: Ptr(int64(1))}, 3587 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 3588 Repo: &Repository{ 3589 ID: Ptr(int64(1)), 3590 URL: Ptr("s"), 3591 Name: Ptr("n"), 3592 }, 3593 Sender: &User{ 3594 Login: Ptr("l"), 3595 ID: Ptr(int64(1)), 3596 NodeID: Ptr("n"), 3597 URL: Ptr("u"), 3598 ReposURL: Ptr("r"), 3599 EventsURL: Ptr("e"), 3600 AvatarURL: Ptr("a"), 3601 }, 3602 Installation: &Installation{ 3603 ID: Ptr(int64(1)), 3604 NodeID: Ptr("nid"), 3605 AppID: Ptr(int64(1)), 3606 AppSlug: Ptr("as"), 3607 TargetID: Ptr(int64(1)), 3608 Account: &User{ 3609 Login: Ptr("l"), 3610 ID: Ptr(int64(1)), 3611 URL: Ptr("u"), 3612 AvatarURL: Ptr("a"), 3613 GravatarID: Ptr("g"), 3614 Name: Ptr("n"), 3615 Company: Ptr("c"), 3616 Blog: Ptr("b"), 3617 Location: Ptr("l"), 3618 Email: Ptr("e"), 3619 Hireable: Ptr(true), 3620 Bio: Ptr("b"), 3621 TwitterUsername: Ptr("t"), 3622 PublicRepos: Ptr(1), 3623 Followers: Ptr(1), 3624 Following: Ptr(1), 3625 CreatedAt: &Timestamp{referenceTime}, 3626 SuspendedAt: &Timestamp{referenceTime}, 3627 }, 3628 AccessTokensURL: Ptr("atu"), 3629 RepositoriesURL: Ptr("ru"), 3630 HTMLURL: Ptr("hu"), 3631 TargetType: Ptr("tt"), 3632 SingleFileName: Ptr("sfn"), 3633 RepositorySelection: Ptr("rs"), 3634 Events: []string{"e"}, 3635 SingleFilePaths: []string{"s"}, 3636 Permissions: &InstallationPermissions{ 3637 Actions: Ptr("a"), 3638 Administration: Ptr("ad"), 3639 Checks: Ptr("c"), 3640 Contents: Ptr("co"), 3641 ContentReferences: Ptr("cr"), 3642 Deployments: Ptr("d"), 3643 Environments: Ptr("e"), 3644 Issues: Ptr("i"), 3645 Metadata: Ptr("md"), 3646 Members: Ptr("m"), 3647 OrganizationAdministration: Ptr("oa"), 3648 OrganizationHooks: Ptr("oh"), 3649 OrganizationPlan: Ptr("op"), 3650 OrganizationPreReceiveHooks: Ptr("opr"), 3651 OrganizationProjects: Ptr("op"), 3652 OrganizationSecrets: Ptr("os"), 3653 OrganizationSelfHostedRunners: Ptr("osh"), 3654 OrganizationUserBlocking: Ptr("oub"), 3655 Packages: Ptr("pkg"), 3656 Pages: Ptr("pg"), 3657 PullRequests: Ptr("pr"), 3658 RepositoryHooks: Ptr("rh"), 3659 RepositoryProjects: Ptr("rp"), 3660 RepositoryPreReceiveHooks: Ptr("rprh"), 3661 Secrets: Ptr("s"), 3662 SecretScanningAlerts: Ptr("ssa"), 3663 SecurityEvents: Ptr("se"), 3664 SingleFile: Ptr("sf"), 3665 Statuses: Ptr("s"), 3666 TeamDiscussions: Ptr("td"), 3667 VulnerabilityAlerts: Ptr("va"), 3668 Workflows: Ptr("w"), 3669 }, 3670 CreatedAt: &Timestamp{referenceTime}, 3671 UpdatedAt: &Timestamp{referenceTime}, 3672 HasMultipleSingleFiles: Ptr(false), 3673 SuspendedBy: &User{ 3674 Login: Ptr("l"), 3675 ID: Ptr(int64(1)), 3676 URL: Ptr("u"), 3677 AvatarURL: Ptr("a"), 3678 GravatarID: Ptr("g"), 3679 Name: Ptr("n"), 3680 Company: Ptr("c"), 3681 Blog: Ptr("b"), 3682 Location: Ptr("l"), 3683 Email: Ptr("e"), 3684 Hireable: Ptr(true), 3685 Bio: Ptr("b"), 3686 TwitterUsername: Ptr("t"), 3687 PublicRepos: Ptr(1), 3688 Followers: Ptr(1), 3689 Following: Ptr(1), 3690 CreatedAt: &Timestamp{referenceTime}, 3691 SuspendedAt: &Timestamp{referenceTime}, 3692 }, 3693 SuspendedAt: &Timestamp{referenceTime}, 3694 }, 3695 Organization: &Organization{ 3696 BillingEmail: Ptr("be"), 3697 Blog: Ptr("b"), 3698 Company: Ptr("c"), 3699 Email: Ptr("e"), 3700 TwitterUsername: Ptr("tu"), 3701 Location: Ptr("loc"), 3702 Name: Ptr("n"), 3703 Description: Ptr("d"), 3704 IsVerified: Ptr(true), 3705 HasOrganizationProjects: Ptr(true), 3706 HasRepositoryProjects: Ptr(true), 3707 DefaultRepoPermission: Ptr("drp"), 3708 MembersCanCreateRepos: Ptr(true), 3709 MembersCanCreateInternalRepos: Ptr(true), 3710 MembersCanCreatePrivateRepos: Ptr(true), 3711 MembersCanCreatePublicRepos: Ptr(false), 3712 MembersAllowedRepositoryCreationType: Ptr("marct"), 3713 MembersCanCreatePages: Ptr(true), 3714 MembersCanCreatePublicPages: Ptr(false), 3715 MembersCanCreatePrivatePages: Ptr(true), 3716 }, 3717 } 3718 3719 want := `{ 3720 "action": "a", 3721 "review": { 3722 "id": 1 3723 }, 3724 "pull_request": { 3725 "id": 1 3726 }, 3727 "repository": { 3728 "id": 1, 3729 "name": "n", 3730 "url": "s" 3731 }, 3732 "sender": { 3733 "login": "l", 3734 "id": 1, 3735 "node_id": "n", 3736 "avatar_url": "a", 3737 "url": "u", 3738 "events_url": "e", 3739 "repos_url": "r" 3740 }, 3741 "installation": { 3742 "id": 1, 3743 "node_id": "nid", 3744 "app_id": 1, 3745 "app_slug": "as", 3746 "target_id": 1, 3747 "account": { 3748 "login": "l", 3749 "id": 1, 3750 "avatar_url": "a", 3751 "gravatar_id": "g", 3752 "name": "n", 3753 "company": "c", 3754 "blog": "b", 3755 "location": "l", 3756 "email": "e", 3757 "hireable": true, 3758 "bio": "b", 3759 "twitter_username": "t", 3760 "public_repos": 1, 3761 "followers": 1, 3762 "following": 1, 3763 "created_at": ` + referenceTimeStr + `, 3764 "suspended_at": ` + referenceTimeStr + `, 3765 "url": "u" 3766 }, 3767 "access_tokens_url": "atu", 3768 "repositories_url": "ru", 3769 "html_url": "hu", 3770 "target_type": "tt", 3771 "single_file_name": "sfn", 3772 "repository_selection": "rs", 3773 "events": [ 3774 "e" 3775 ], 3776 "single_file_paths": [ 3777 "s" 3778 ], 3779 "permissions": { 3780 "actions": "a", 3781 "administration": "ad", 3782 "checks": "c", 3783 "contents": "co", 3784 "content_references": "cr", 3785 "deployments": "d", 3786 "environments": "e", 3787 "issues": "i", 3788 "metadata": "md", 3789 "members": "m", 3790 "organization_administration": "oa", 3791 "organization_hooks": "oh", 3792 "organization_plan": "op", 3793 "organization_pre_receive_hooks": "opr", 3794 "organization_projects": "op", 3795 "organization_secrets": "os", 3796 "organization_self_hosted_runners": "osh", 3797 "organization_user_blocking": "oub", 3798 "packages": "pkg", 3799 "pages": "pg", 3800 "pull_requests": "pr", 3801 "repository_hooks": "rh", 3802 "repository_projects": "rp", 3803 "repository_pre_receive_hooks": "rprh", 3804 "secrets": "s", 3805 "secret_scanning_alerts": "ssa", 3806 "security_events": "se", 3807 "single_file": "sf", 3808 "statuses": "s", 3809 "team_discussions": "td", 3810 "vulnerability_alerts": "va", 3811 "workflows": "w" 3812 }, 3813 "created_at": ` + referenceTimeStr + `, 3814 "updated_at": ` + referenceTimeStr + `, 3815 "has_multiple_single_files": false, 3816 "suspended_by": { 3817 "login": "l", 3818 "id": 1, 3819 "avatar_url": "a", 3820 "gravatar_id": "g", 3821 "name": "n", 3822 "company": "c", 3823 "blog": "b", 3824 "location": "l", 3825 "email": "e", 3826 "hireable": true, 3827 "bio": "b", 3828 "twitter_username": "t", 3829 "public_repos": 1, 3830 "followers": 1, 3831 "following": 1, 3832 "created_at": ` + referenceTimeStr + `, 3833 "suspended_at": ` + referenceTimeStr + `, 3834 "url": "u" 3835 }, 3836 "suspended_at": ` + referenceTimeStr + ` 3837 }, 3838 "organization": { 3839 "name": "n", 3840 "company": "c", 3841 "blog": "b", 3842 "location": "loc", 3843 "email": "e", 3844 "twitter_username": "tu", 3845 "description": "d", 3846 "billing_email": "be", 3847 "is_verified": true, 3848 "has_organization_projects": true, 3849 "has_repository_projects": true, 3850 "default_repository_permission": "drp", 3851 "members_can_create_repositories": true, 3852 "members_can_create_public_repositories": false, 3853 "members_can_create_private_repositories": true, 3854 "members_can_create_internal_repositories": true, 3855 "members_allowed_repository_creation_type": "marct", 3856 "members_can_create_pages": true, 3857 "members_can_create_public_pages": false, 3858 "members_can_create_private_pages": true 3859 } 3860 }` 3861 3862 testJSONMarshal(t, u, want) 3863 } 3864 3865 func TestPushEvent_Marshal(t *testing.T) { 3866 t.Parallel() 3867 testJSONMarshal(t, &PushEvent{}, "{}") 3868 3869 u := &PushEvent{ 3870 PushID: Ptr(int64(1)), 3871 Head: Ptr("h"), 3872 Ref: Ptr("ref"), 3873 Size: Ptr(1), 3874 Commits: []*HeadCommit{ 3875 {ID: Ptr("id")}, 3876 }, 3877 Before: Ptr("b"), 3878 DistinctSize: Ptr(1), 3879 After: Ptr("a"), 3880 Created: Ptr(true), 3881 Deleted: Ptr(true), 3882 Forced: Ptr(true), 3883 BaseRef: Ptr("a"), 3884 Compare: Ptr("a"), 3885 Repo: &PushEventRepository{ID: Ptr(int64(1))}, 3886 HeadCommit: &HeadCommit{ID: Ptr("id")}, 3887 Pusher: &CommitAuthor{ 3888 Login: Ptr("l"), 3889 Date: &Timestamp{referenceTime}, 3890 Name: Ptr("n"), 3891 Email: Ptr("e"), 3892 }, 3893 Sender: &User{ 3894 Login: Ptr("l"), 3895 ID: Ptr(int64(1)), 3896 NodeID: Ptr("n"), 3897 URL: Ptr("u"), 3898 ReposURL: Ptr("r"), 3899 EventsURL: Ptr("e"), 3900 AvatarURL: Ptr("a"), 3901 }, 3902 Installation: &Installation{ 3903 ID: Ptr(int64(1)), 3904 NodeID: Ptr("nid"), 3905 AppID: Ptr(int64(1)), 3906 AppSlug: Ptr("as"), 3907 TargetID: Ptr(int64(1)), 3908 Account: &User{ 3909 Login: Ptr("l"), 3910 ID: Ptr(int64(1)), 3911 URL: Ptr("u"), 3912 AvatarURL: Ptr("a"), 3913 GravatarID: Ptr("g"), 3914 Name: Ptr("n"), 3915 Company: Ptr("c"), 3916 Blog: Ptr("b"), 3917 Location: Ptr("l"), 3918 Email: Ptr("e"), 3919 Hireable: Ptr(true), 3920 Bio: Ptr("b"), 3921 TwitterUsername: Ptr("t"), 3922 PublicRepos: Ptr(1), 3923 Followers: Ptr(1), 3924 Following: Ptr(1), 3925 CreatedAt: &Timestamp{referenceTime}, 3926 SuspendedAt: &Timestamp{referenceTime}, 3927 }, 3928 AccessTokensURL: Ptr("atu"), 3929 RepositoriesURL: Ptr("ru"), 3930 HTMLURL: Ptr("hu"), 3931 TargetType: Ptr("tt"), 3932 SingleFileName: Ptr("sfn"), 3933 RepositorySelection: Ptr("rs"), 3934 Events: []string{"e"}, 3935 SingleFilePaths: []string{"s"}, 3936 Permissions: &InstallationPermissions{ 3937 Actions: Ptr("a"), 3938 Administration: Ptr("ad"), 3939 Checks: Ptr("c"), 3940 Contents: Ptr("co"), 3941 ContentReferences: Ptr("cr"), 3942 Deployments: Ptr("d"), 3943 Environments: Ptr("e"), 3944 Issues: Ptr("i"), 3945 Metadata: Ptr("md"), 3946 Members: Ptr("m"), 3947 OrganizationAdministration: Ptr("oa"), 3948 OrganizationHooks: Ptr("oh"), 3949 OrganizationPlan: Ptr("op"), 3950 OrganizationPreReceiveHooks: Ptr("opr"), 3951 OrganizationProjects: Ptr("op"), 3952 OrganizationSecrets: Ptr("os"), 3953 OrganizationSelfHostedRunners: Ptr("osh"), 3954 OrganizationUserBlocking: Ptr("oub"), 3955 Packages: Ptr("pkg"), 3956 Pages: Ptr("pg"), 3957 PullRequests: Ptr("pr"), 3958 RepositoryHooks: Ptr("rh"), 3959 RepositoryProjects: Ptr("rp"), 3960 RepositoryPreReceiveHooks: Ptr("rprh"), 3961 Secrets: Ptr("s"), 3962 SecretScanningAlerts: Ptr("ssa"), 3963 SecurityEvents: Ptr("se"), 3964 SingleFile: Ptr("sf"), 3965 Statuses: Ptr("s"), 3966 TeamDiscussions: Ptr("td"), 3967 VulnerabilityAlerts: Ptr("va"), 3968 Workflows: Ptr("w"), 3969 }, 3970 CreatedAt: &Timestamp{referenceTime}, 3971 UpdatedAt: &Timestamp{referenceTime}, 3972 HasMultipleSingleFiles: Ptr(false), 3973 SuspendedBy: &User{ 3974 Login: Ptr("l"), 3975 ID: Ptr(int64(1)), 3976 URL: Ptr("u"), 3977 AvatarURL: Ptr("a"), 3978 GravatarID: Ptr("g"), 3979 Name: Ptr("n"), 3980 Company: Ptr("c"), 3981 Blog: Ptr("b"), 3982 Location: Ptr("l"), 3983 Email: Ptr("e"), 3984 Hireable: Ptr(true), 3985 Bio: Ptr("b"), 3986 TwitterUsername: Ptr("t"), 3987 PublicRepos: Ptr(1), 3988 Followers: Ptr(1), 3989 Following: Ptr(1), 3990 CreatedAt: &Timestamp{referenceTime}, 3991 SuspendedAt: &Timestamp{referenceTime}, 3992 }, 3993 SuspendedAt: &Timestamp{referenceTime}, 3994 }, 3995 Organization: &Organization{ 3996 BillingEmail: Ptr("be"), 3997 Blog: Ptr("b"), 3998 Company: Ptr("c"), 3999 Email: Ptr("e"), 4000 TwitterUsername: Ptr("tu"), 4001 Location: Ptr("loc"), 4002 Name: Ptr("n"), 4003 Description: Ptr("d"), 4004 IsVerified: Ptr(true), 4005 HasOrganizationProjects: Ptr(true), 4006 HasRepositoryProjects: Ptr(true), 4007 DefaultRepoPermission: Ptr("drp"), 4008 MembersCanCreateRepos: Ptr(true), 4009 MembersCanCreateInternalRepos: Ptr(true), 4010 MembersCanCreatePrivateRepos: Ptr(true), 4011 MembersCanCreatePublicRepos: Ptr(false), 4012 MembersAllowedRepositoryCreationType: Ptr("marct"), 4013 MembersCanCreatePages: Ptr(true), 4014 MembersCanCreatePublicPages: Ptr(false), 4015 MembersCanCreatePrivatePages: Ptr(true), 4016 }, 4017 } 4018 4019 want := `{ 4020 "push_id": 1, 4021 "head": "h", 4022 "ref": "ref", 4023 "size": 1, 4024 "commits": [ 4025 { 4026 "id": "id" 4027 } 4028 ], 4029 "before": "b", 4030 "distinct_size": 1, 4031 "after": "a", 4032 "created": true, 4033 "deleted": true, 4034 "forced": true, 4035 "base_ref": "a", 4036 "compare": "a", 4037 "repository": { 4038 "id": 1 4039 }, 4040 "head_commit": { 4041 "id": "id" 4042 }, 4043 "pusher": { 4044 "date": ` + referenceTimeStr + `, 4045 "name": "n", 4046 "email": "e", 4047 "username": "l" 4048 }, 4049 "sender": { 4050 "login": "l", 4051 "id": 1, 4052 "node_id": "n", 4053 "avatar_url": "a", 4054 "url": "u", 4055 "events_url": "e", 4056 "repos_url": "r" 4057 }, 4058 "installation": { 4059 "id": 1, 4060 "node_id": "nid", 4061 "app_id": 1, 4062 "app_slug": "as", 4063 "target_id": 1, 4064 "account": { 4065 "login": "l", 4066 "id": 1, 4067 "avatar_url": "a", 4068 "gravatar_id": "g", 4069 "name": "n", 4070 "company": "c", 4071 "blog": "b", 4072 "location": "l", 4073 "email": "e", 4074 "hireable": true, 4075 "bio": "b", 4076 "twitter_username": "t", 4077 "public_repos": 1, 4078 "followers": 1, 4079 "following": 1, 4080 "created_at": ` + referenceTimeStr + `, 4081 "suspended_at": ` + referenceTimeStr + `, 4082 "url": "u" 4083 }, 4084 "access_tokens_url": "atu", 4085 "repositories_url": "ru", 4086 "html_url": "hu", 4087 "target_type": "tt", 4088 "single_file_name": "sfn", 4089 "repository_selection": "rs", 4090 "events": [ 4091 "e" 4092 ], 4093 "single_file_paths": [ 4094 "s" 4095 ], 4096 "permissions": { 4097 "actions": "a", 4098 "administration": "ad", 4099 "checks": "c", 4100 "contents": "co", 4101 "content_references": "cr", 4102 "deployments": "d", 4103 "environments": "e", 4104 "issues": "i", 4105 "metadata": "md", 4106 "members": "m", 4107 "organization_administration": "oa", 4108 "organization_hooks": "oh", 4109 "organization_plan": "op", 4110 "organization_pre_receive_hooks": "opr", 4111 "organization_projects": "op", 4112 "organization_secrets": "os", 4113 "organization_self_hosted_runners": "osh", 4114 "organization_user_blocking": "oub", 4115 "packages": "pkg", 4116 "pages": "pg", 4117 "pull_requests": "pr", 4118 "repository_hooks": "rh", 4119 "repository_projects": "rp", 4120 "repository_pre_receive_hooks": "rprh", 4121 "secrets": "s", 4122 "secret_scanning_alerts": "ssa", 4123 "security_events": "se", 4124 "single_file": "sf", 4125 "statuses": "s", 4126 "team_discussions": "td", 4127 "vulnerability_alerts": "va", 4128 "workflows": "w" 4129 }, 4130 "created_at": ` + referenceTimeStr + `, 4131 "updated_at": ` + referenceTimeStr + `, 4132 "has_multiple_single_files": false, 4133 "suspended_by": { 4134 "login": "l", 4135 "id": 1, 4136 "avatar_url": "a", 4137 "gravatar_id": "g", 4138 "name": "n", 4139 "company": "c", 4140 "blog": "b", 4141 "location": "l", 4142 "email": "e", 4143 "hireable": true, 4144 "bio": "b", 4145 "twitter_username": "t", 4146 "public_repos": 1, 4147 "followers": 1, 4148 "following": 1, 4149 "created_at": ` + referenceTimeStr + `, 4150 "suspended_at": ` + referenceTimeStr + `, 4151 "url": "u" 4152 }, 4153 "suspended_at": ` + referenceTimeStr + ` 4154 }, 4155 "organization": { 4156 "name": "n", 4157 "company": "c", 4158 "blog": "b", 4159 "location": "loc", 4160 "email": "e", 4161 "twitter_username": "tu", 4162 "description": "d", 4163 "billing_email": "be", 4164 "is_verified": true, 4165 "has_organization_projects": true, 4166 "has_repository_projects": true, 4167 "default_repository_permission": "drp", 4168 "members_can_create_repositories": true, 4169 "members_can_create_public_repositories": false, 4170 "members_can_create_private_repositories": true, 4171 "members_can_create_internal_repositories": true, 4172 "members_allowed_repository_creation_type": "marct", 4173 "members_can_create_pages": true, 4174 "members_can_create_public_pages": false, 4175 "members_can_create_private_pages": true 4176 } 4177 }` 4178 4179 testJSONMarshal(t, u, want) 4180 } 4181 4182 func TestStatusEvent_Marshal(t *testing.T) { 4183 t.Parallel() 4184 testJSONMarshal(t, &StatusEvent{}, "{}") 4185 4186 u := &StatusEvent{ 4187 SHA: Ptr("sha"), 4188 State: Ptr("s"), 4189 Description: Ptr("d"), 4190 TargetURL: Ptr("turl"), 4191 Branches: []*Branch{ 4192 { 4193 Name: Ptr("n"), 4194 Commit: &RepositoryCommit{NodeID: Ptr("nid")}, 4195 Protected: Ptr(false), 4196 }, 4197 }, 4198 ID: Ptr(int64(1)), 4199 Name: Ptr("n"), 4200 Context: Ptr("c"), 4201 Commit: &RepositoryCommit{NodeID: Ptr("nid")}, 4202 CreatedAt: &Timestamp{referenceTime}, 4203 UpdatedAt: &Timestamp{referenceTime}, 4204 Sender: &User{ 4205 Login: Ptr("l"), 4206 ID: Ptr(int64(1)), 4207 NodeID: Ptr("n"), 4208 URL: Ptr("u"), 4209 ReposURL: Ptr("r"), 4210 EventsURL: Ptr("e"), 4211 AvatarURL: Ptr("a"), 4212 }, 4213 Installation: &Installation{ 4214 ID: Ptr(int64(1)), 4215 NodeID: Ptr("nid"), 4216 AppID: Ptr(int64(1)), 4217 AppSlug: Ptr("as"), 4218 TargetID: Ptr(int64(1)), 4219 Account: &User{ 4220 Login: Ptr("l"), 4221 ID: Ptr(int64(1)), 4222 URL: Ptr("u"), 4223 AvatarURL: Ptr("a"), 4224 GravatarID: Ptr("g"), 4225 Name: Ptr("n"), 4226 Company: Ptr("c"), 4227 Blog: Ptr("b"), 4228 Location: Ptr("l"), 4229 Email: Ptr("e"), 4230 Hireable: Ptr(true), 4231 Bio: Ptr("b"), 4232 TwitterUsername: Ptr("t"), 4233 PublicRepos: Ptr(1), 4234 Followers: Ptr(1), 4235 Following: Ptr(1), 4236 CreatedAt: &Timestamp{referenceTime}, 4237 SuspendedAt: &Timestamp{referenceTime}, 4238 }, 4239 AccessTokensURL: Ptr("atu"), 4240 RepositoriesURL: Ptr("ru"), 4241 HTMLURL: Ptr("hu"), 4242 TargetType: Ptr("tt"), 4243 SingleFileName: Ptr("sfn"), 4244 RepositorySelection: Ptr("rs"), 4245 Events: []string{"e"}, 4246 SingleFilePaths: []string{"s"}, 4247 Permissions: &InstallationPermissions{ 4248 Actions: Ptr("a"), 4249 Administration: Ptr("ad"), 4250 Checks: Ptr("c"), 4251 Contents: Ptr("co"), 4252 ContentReferences: Ptr("cr"), 4253 Deployments: Ptr("d"), 4254 Environments: Ptr("e"), 4255 Issues: Ptr("i"), 4256 Metadata: Ptr("md"), 4257 Members: Ptr("m"), 4258 OrganizationAdministration: Ptr("oa"), 4259 OrganizationHooks: Ptr("oh"), 4260 OrganizationPlan: Ptr("op"), 4261 OrganizationPreReceiveHooks: Ptr("opr"), 4262 OrganizationProjects: Ptr("op"), 4263 OrganizationSecrets: Ptr("os"), 4264 OrganizationSelfHostedRunners: Ptr("osh"), 4265 OrganizationUserBlocking: Ptr("oub"), 4266 Packages: Ptr("pkg"), 4267 Pages: Ptr("pg"), 4268 PullRequests: Ptr("pr"), 4269 RepositoryHooks: Ptr("rh"), 4270 RepositoryProjects: Ptr("rp"), 4271 RepositoryPreReceiveHooks: Ptr("rprh"), 4272 Secrets: Ptr("s"), 4273 SecretScanningAlerts: Ptr("ssa"), 4274 SecurityEvents: Ptr("se"), 4275 SingleFile: Ptr("sf"), 4276 Statuses: Ptr("s"), 4277 TeamDiscussions: Ptr("td"), 4278 VulnerabilityAlerts: Ptr("va"), 4279 Workflows: Ptr("w"), 4280 }, 4281 CreatedAt: &Timestamp{referenceTime}, 4282 UpdatedAt: &Timestamp{referenceTime}, 4283 HasMultipleSingleFiles: Ptr(false), 4284 SuspendedBy: &User{ 4285 Login: Ptr("l"), 4286 ID: Ptr(int64(1)), 4287 URL: Ptr("u"), 4288 AvatarURL: Ptr("a"), 4289 GravatarID: Ptr("g"), 4290 Name: Ptr("n"), 4291 Company: Ptr("c"), 4292 Blog: Ptr("b"), 4293 Location: Ptr("l"), 4294 Email: Ptr("e"), 4295 Hireable: Ptr(true), 4296 Bio: Ptr("b"), 4297 TwitterUsername: Ptr("t"), 4298 PublicRepos: Ptr(1), 4299 Followers: Ptr(1), 4300 Following: Ptr(1), 4301 CreatedAt: &Timestamp{referenceTime}, 4302 SuspendedAt: &Timestamp{referenceTime}, 4303 }, 4304 SuspendedAt: &Timestamp{referenceTime}, 4305 }, 4306 } 4307 4308 want := `{ 4309 "sha": "sha", 4310 "state": "s", 4311 "description": "d", 4312 "target_url": "turl", 4313 "branches": [ 4314 { 4315 "name": "n", 4316 "commit": { 4317 "node_id": "nid" 4318 }, 4319 "protected": false 4320 } 4321 ], 4322 "id": 1, 4323 "name": "n", 4324 "context": "c", 4325 "commit": { 4326 "node_id": "nid" 4327 }, 4328 "created_at": ` + referenceTimeStr + `, 4329 "updated_at": ` + referenceTimeStr + `, 4330 "sender": { 4331 "login": "l", 4332 "id": 1, 4333 "node_id": "n", 4334 "avatar_url": "a", 4335 "url": "u", 4336 "events_url": "e", 4337 "repos_url": "r" 4338 }, 4339 "installation": { 4340 "id": 1, 4341 "node_id": "nid", 4342 "app_id": 1, 4343 "app_slug": "as", 4344 "target_id": 1, 4345 "account": { 4346 "login": "l", 4347 "id": 1, 4348 "avatar_url": "a", 4349 "gravatar_id": "g", 4350 "name": "n", 4351 "company": "c", 4352 "blog": "b", 4353 "location": "l", 4354 "email": "e", 4355 "hireable": true, 4356 "bio": "b", 4357 "twitter_username": "t", 4358 "public_repos": 1, 4359 "followers": 1, 4360 "following": 1, 4361 "created_at": ` + referenceTimeStr + `, 4362 "suspended_at": ` + referenceTimeStr + `, 4363 "url": "u" 4364 }, 4365 "access_tokens_url": "atu", 4366 "repositories_url": "ru", 4367 "html_url": "hu", 4368 "target_type": "tt", 4369 "single_file_name": "sfn", 4370 "repository_selection": "rs", 4371 "events": [ 4372 "e" 4373 ], 4374 "single_file_paths": [ 4375 "s" 4376 ], 4377 "permissions": { 4378 "actions": "a", 4379 "administration": "ad", 4380 "checks": "c", 4381 "contents": "co", 4382 "content_references": "cr", 4383 "deployments": "d", 4384 "environments": "e", 4385 "issues": "i", 4386 "metadata": "md", 4387 "members": "m", 4388 "organization_administration": "oa", 4389 "organization_hooks": "oh", 4390 "organization_plan": "op", 4391 "organization_pre_receive_hooks": "opr", 4392 "organization_projects": "op", 4393 "organization_secrets": "os", 4394 "organization_self_hosted_runners": "osh", 4395 "organization_user_blocking": "oub", 4396 "packages": "pkg", 4397 "pages": "pg", 4398 "pull_requests": "pr", 4399 "repository_hooks": "rh", 4400 "repository_projects": "rp", 4401 "repository_pre_receive_hooks": "rprh", 4402 "secrets": "s", 4403 "secret_scanning_alerts": "ssa", 4404 "security_events": "se", 4405 "single_file": "sf", 4406 "statuses": "s", 4407 "team_discussions": "td", 4408 "vulnerability_alerts": "va", 4409 "workflows": "w" 4410 }, 4411 "created_at": ` + referenceTimeStr + `, 4412 "updated_at": ` + referenceTimeStr + `, 4413 "has_multiple_single_files": false, 4414 "suspended_by": { 4415 "login": "l", 4416 "id": 1, 4417 "avatar_url": "a", 4418 "gravatar_id": "g", 4419 "name": "n", 4420 "company": "c", 4421 "blog": "b", 4422 "location": "l", 4423 "email": "e", 4424 "hireable": true, 4425 "bio": "b", 4426 "twitter_username": "t", 4427 "public_repos": 1, 4428 "followers": 1, 4429 "following": 1, 4430 "created_at": ` + referenceTimeStr + `, 4431 "suspended_at": ` + referenceTimeStr + `, 4432 "url": "u" 4433 }, 4434 "suspended_at": ` + referenceTimeStr + ` 4435 } 4436 }` 4437 4438 testJSONMarshal(t, u, want) 4439 } 4440 4441 func TestMarketplacePurchaseEvent_Marshal(t *testing.T) { 4442 t.Parallel() 4443 testJSONMarshal(t, &MarketplacePurchaseEvent{}, "{}") 4444 4445 u := &MarketplacePurchaseEvent{ 4446 Action: Ptr("a"), 4447 EffectiveDate: &Timestamp{referenceTime}, 4448 MarketplacePurchase: &MarketplacePurchase{ 4449 BillingCycle: Ptr("bc"), 4450 NextBillingDate: &Timestamp{referenceTime}, 4451 UnitCount: Ptr(1), 4452 Plan: &MarketplacePlan{ 4453 URL: Ptr("u"), 4454 AccountsURL: Ptr("au"), 4455 ID: Ptr(int64(1)), 4456 Number: Ptr(1), 4457 Name: Ptr("n"), 4458 Description: Ptr("d"), 4459 MonthlyPriceInCents: Ptr(1), 4460 YearlyPriceInCents: Ptr(1), 4461 PriceModel: Ptr("pm"), 4462 UnitName: Ptr("un"), 4463 Bullets: &[]string{"b"}, 4464 State: Ptr("s"), 4465 HasFreeTrial: Ptr(false), 4466 }, 4467 OnFreeTrial: Ptr(false), 4468 FreeTrialEndsOn: &Timestamp{referenceTime}, 4469 UpdatedAt: &Timestamp{referenceTime}, 4470 }, 4471 PreviousMarketplacePurchase: &MarketplacePurchase{ 4472 BillingCycle: Ptr("bc"), 4473 NextBillingDate: &Timestamp{referenceTime}, 4474 UnitCount: Ptr(1), 4475 Plan: &MarketplacePlan{ 4476 URL: Ptr("u"), 4477 AccountsURL: Ptr("au"), 4478 ID: Ptr(int64(1)), 4479 Number: Ptr(1), 4480 Name: Ptr("n"), 4481 Description: Ptr("d"), 4482 MonthlyPriceInCents: Ptr(1), 4483 YearlyPriceInCents: Ptr(1), 4484 PriceModel: Ptr("pm"), 4485 UnitName: Ptr("un"), 4486 Bullets: &[]string{"b"}, 4487 State: Ptr("s"), 4488 HasFreeTrial: Ptr(false), 4489 }, 4490 OnFreeTrial: Ptr(false), 4491 FreeTrialEndsOn: &Timestamp{referenceTime}, 4492 UpdatedAt: &Timestamp{referenceTime}, 4493 }, 4494 Sender: &User{ 4495 Login: Ptr("l"), 4496 ID: Ptr(int64(1)), 4497 NodeID: Ptr("n"), 4498 URL: Ptr("u"), 4499 ReposURL: Ptr("r"), 4500 EventsURL: Ptr("e"), 4501 AvatarURL: Ptr("a"), 4502 }, 4503 Installation: &Installation{ 4504 ID: Ptr(int64(1)), 4505 NodeID: Ptr("nid"), 4506 AppID: Ptr(int64(1)), 4507 AppSlug: Ptr("as"), 4508 TargetID: Ptr(int64(1)), 4509 Account: &User{ 4510 Login: Ptr("l"), 4511 ID: Ptr(int64(1)), 4512 URL: Ptr("u"), 4513 AvatarURL: Ptr("a"), 4514 GravatarID: Ptr("g"), 4515 Name: Ptr("n"), 4516 Company: Ptr("c"), 4517 Blog: Ptr("b"), 4518 Location: Ptr("l"), 4519 Email: Ptr("e"), 4520 Hireable: Ptr(true), 4521 Bio: Ptr("b"), 4522 TwitterUsername: Ptr("t"), 4523 PublicRepos: Ptr(1), 4524 Followers: Ptr(1), 4525 Following: Ptr(1), 4526 CreatedAt: &Timestamp{referenceTime}, 4527 SuspendedAt: &Timestamp{referenceTime}, 4528 }, 4529 AccessTokensURL: Ptr("atu"), 4530 RepositoriesURL: Ptr("ru"), 4531 HTMLURL: Ptr("hu"), 4532 TargetType: Ptr("tt"), 4533 SingleFileName: Ptr("sfn"), 4534 RepositorySelection: Ptr("rs"), 4535 Events: []string{"e"}, 4536 SingleFilePaths: []string{"s"}, 4537 Permissions: &InstallationPermissions{ 4538 Actions: Ptr("a"), 4539 Administration: Ptr("ad"), 4540 Checks: Ptr("c"), 4541 Contents: Ptr("co"), 4542 ContentReferences: Ptr("cr"), 4543 Deployments: Ptr("d"), 4544 Environments: Ptr("e"), 4545 Issues: Ptr("i"), 4546 Metadata: Ptr("md"), 4547 Members: Ptr("m"), 4548 OrganizationAdministration: Ptr("oa"), 4549 OrganizationHooks: Ptr("oh"), 4550 OrganizationPlan: Ptr("op"), 4551 OrganizationPreReceiveHooks: Ptr("opr"), 4552 OrganizationProjects: Ptr("op"), 4553 OrganizationSecrets: Ptr("os"), 4554 OrganizationSelfHostedRunners: Ptr("osh"), 4555 OrganizationUserBlocking: Ptr("oub"), 4556 Packages: Ptr("pkg"), 4557 Pages: Ptr("pg"), 4558 PullRequests: Ptr("pr"), 4559 RepositoryHooks: Ptr("rh"), 4560 RepositoryProjects: Ptr("rp"), 4561 RepositoryPreReceiveHooks: Ptr("rprh"), 4562 Secrets: Ptr("s"), 4563 SecretScanningAlerts: Ptr("ssa"), 4564 SecurityEvents: Ptr("se"), 4565 SingleFile: Ptr("sf"), 4566 Statuses: Ptr("s"), 4567 TeamDiscussions: Ptr("td"), 4568 VulnerabilityAlerts: Ptr("va"), 4569 Workflows: Ptr("w"), 4570 }, 4571 CreatedAt: &Timestamp{referenceTime}, 4572 UpdatedAt: &Timestamp{referenceTime}, 4573 HasMultipleSingleFiles: Ptr(false), 4574 SuspendedBy: &User{ 4575 Login: Ptr("l"), 4576 ID: Ptr(int64(1)), 4577 URL: Ptr("u"), 4578 AvatarURL: Ptr("a"), 4579 GravatarID: Ptr("g"), 4580 Name: Ptr("n"), 4581 Company: Ptr("c"), 4582 Blog: Ptr("b"), 4583 Location: Ptr("l"), 4584 Email: Ptr("e"), 4585 Hireable: Ptr(true), 4586 Bio: Ptr("b"), 4587 TwitterUsername: Ptr("t"), 4588 PublicRepos: Ptr(1), 4589 Followers: Ptr(1), 4590 Following: Ptr(1), 4591 CreatedAt: &Timestamp{referenceTime}, 4592 SuspendedAt: &Timestamp{referenceTime}, 4593 }, 4594 SuspendedAt: &Timestamp{referenceTime}, 4595 }, 4596 } 4597 4598 want := `{ 4599 "action": "a", 4600 "effective_date": ` + referenceTimeStr + `, 4601 "marketplace_purchase": { 4602 "billing_cycle": "bc", 4603 "next_billing_date": ` + referenceTimeStr + `, 4604 "unit_count": 1, 4605 "plan": { 4606 "url": "u", 4607 "accounts_url": "au", 4608 "id": 1, 4609 "number": 1, 4610 "name": "n", 4611 "description": "d", 4612 "monthly_price_in_cents": 1, 4613 "yearly_price_in_cents": 1, 4614 "price_model": "pm", 4615 "unit_name": "un", 4616 "bullets": [ 4617 "b" 4618 ], 4619 "state": "s", 4620 "has_free_trial": false 4621 }, 4622 "on_free_trial": false, 4623 "free_trial_ends_on": ` + referenceTimeStr + `, 4624 "updated_at": ` + referenceTimeStr + ` 4625 }, 4626 "previous_marketplace_purchase": { 4627 "billing_cycle": "bc", 4628 "next_billing_date": ` + referenceTimeStr + `, 4629 "unit_count": 1, 4630 "plan": { 4631 "url": "u", 4632 "accounts_url": "au", 4633 "id": 1, 4634 "number": 1, 4635 "name": "n", 4636 "description": "d", 4637 "monthly_price_in_cents": 1, 4638 "yearly_price_in_cents": 1, 4639 "price_model": "pm", 4640 "unit_name": "un", 4641 "bullets": [ 4642 "b" 4643 ], 4644 "state": "s", 4645 "has_free_trial": false 4646 }, 4647 "on_free_trial": false, 4648 "free_trial_ends_on": ` + referenceTimeStr + `, 4649 "updated_at": ` + referenceTimeStr + ` 4650 }, 4651 "sender": { 4652 "login": "l", 4653 "id": 1, 4654 "node_id": "n", 4655 "avatar_url": "a", 4656 "url": "u", 4657 "events_url": "e", 4658 "repos_url": "r" 4659 }, 4660 "installation": { 4661 "id": 1, 4662 "node_id": "nid", 4663 "app_id": 1, 4664 "app_slug": "as", 4665 "target_id": 1, 4666 "account": { 4667 "login": "l", 4668 "id": 1, 4669 "avatar_url": "a", 4670 "gravatar_id": "g", 4671 "name": "n", 4672 "company": "c", 4673 "blog": "b", 4674 "location": "l", 4675 "email": "e", 4676 "hireable": true, 4677 "bio": "b", 4678 "twitter_username": "t", 4679 "public_repos": 1, 4680 "followers": 1, 4681 "following": 1, 4682 "created_at": ` + referenceTimeStr + `, 4683 "suspended_at": ` + referenceTimeStr + `, 4684 "url": "u" 4685 }, 4686 "access_tokens_url": "atu", 4687 "repositories_url": "ru", 4688 "html_url": "hu", 4689 "target_type": "tt", 4690 "single_file_name": "sfn", 4691 "repository_selection": "rs", 4692 "events": [ 4693 "e" 4694 ], 4695 "single_file_paths": [ 4696 "s" 4697 ], 4698 "permissions": { 4699 "actions": "a", 4700 "administration": "ad", 4701 "checks": "c", 4702 "contents": "co", 4703 "content_references": "cr", 4704 "deployments": "d", 4705 "environments": "e", 4706 "issues": "i", 4707 "metadata": "md", 4708 "members": "m", 4709 "organization_administration": "oa", 4710 "organization_hooks": "oh", 4711 "organization_plan": "op", 4712 "organization_pre_receive_hooks": "opr", 4713 "organization_projects": "op", 4714 "organization_secrets": "os", 4715 "organization_self_hosted_runners": "osh", 4716 "organization_user_blocking": "oub", 4717 "packages": "pkg", 4718 "pages": "pg", 4719 "pull_requests": "pr", 4720 "repository_hooks": "rh", 4721 "repository_projects": "rp", 4722 "repository_pre_receive_hooks": "rprh", 4723 "secrets": "s", 4724 "secret_scanning_alerts": "ssa", 4725 "security_events": "se", 4726 "single_file": "sf", 4727 "statuses": "s", 4728 "team_discussions": "td", 4729 "vulnerability_alerts": "va", 4730 "workflows": "w" 4731 }, 4732 "created_at": ` + referenceTimeStr + `, 4733 "updated_at": ` + referenceTimeStr + `, 4734 "has_multiple_single_files": false, 4735 "suspended_by": { 4736 "login": "l", 4737 "id": 1, 4738 "avatar_url": "a", 4739 "gravatar_id": "g", 4740 "name": "n", 4741 "company": "c", 4742 "blog": "b", 4743 "location": "l", 4744 "email": "e", 4745 "hireable": true, 4746 "bio": "b", 4747 "twitter_username": "t", 4748 "public_repos": 1, 4749 "followers": 1, 4750 "following": 1, 4751 "created_at": ` + referenceTimeStr + `, 4752 "suspended_at": ` + referenceTimeStr + `, 4753 "url": "u" 4754 }, 4755 "suspended_at": ` + referenceTimeStr + ` 4756 } 4757 }` 4758 4759 testJSONMarshal(t, u, want) 4760 } 4761 4762 func TestOrganizationEvent_Marshal(t *testing.T) { 4763 t.Parallel() 4764 testJSONMarshal(t, &OrganizationEvent{}, "{}") 4765 4766 u := &OrganizationEvent{ 4767 Action: Ptr("a"), 4768 Invitation: &Invitation{ID: Ptr(int64(1))}, 4769 Membership: &Membership{ 4770 URL: Ptr("url"), 4771 State: Ptr("s"), 4772 Role: Ptr("r"), 4773 OrganizationURL: Ptr("ou"), 4774 Organization: &Organization{ 4775 BillingEmail: Ptr("be"), 4776 Blog: Ptr("b"), 4777 Company: Ptr("c"), 4778 Email: Ptr("e"), 4779 TwitterUsername: Ptr("tu"), 4780 Location: Ptr("loc"), 4781 Name: Ptr("n"), 4782 Description: Ptr("d"), 4783 IsVerified: Ptr(true), 4784 HasOrganizationProjects: Ptr(true), 4785 HasRepositoryProjects: Ptr(true), 4786 DefaultRepoPermission: Ptr("drp"), 4787 MembersCanCreateRepos: Ptr(true), 4788 MembersCanCreateInternalRepos: Ptr(true), 4789 MembersCanCreatePrivateRepos: Ptr(true), 4790 MembersCanCreatePublicRepos: Ptr(false), 4791 MembersAllowedRepositoryCreationType: Ptr("marct"), 4792 MembersCanCreatePages: Ptr(true), 4793 MembersCanCreatePublicPages: Ptr(false), 4794 MembersCanCreatePrivatePages: Ptr(true), 4795 }, 4796 User: &User{ 4797 Login: Ptr("l"), 4798 ID: Ptr(int64(1)), 4799 NodeID: Ptr("n"), 4800 URL: Ptr("u"), 4801 ReposURL: Ptr("r"), 4802 EventsURL: Ptr("e"), 4803 AvatarURL: Ptr("a"), 4804 }, 4805 }, 4806 Organization: &Organization{ 4807 BillingEmail: Ptr("be"), 4808 Blog: Ptr("b"), 4809 Company: Ptr("c"), 4810 Email: Ptr("e"), 4811 TwitterUsername: Ptr("tu"), 4812 Location: Ptr("loc"), 4813 Name: Ptr("n"), 4814 Description: Ptr("d"), 4815 IsVerified: Ptr(true), 4816 HasOrganizationProjects: Ptr(true), 4817 HasRepositoryProjects: Ptr(true), 4818 DefaultRepoPermission: Ptr("drp"), 4819 MembersCanCreateRepos: Ptr(true), 4820 MembersCanCreateInternalRepos: Ptr(true), 4821 MembersCanCreatePrivateRepos: Ptr(true), 4822 MembersCanCreatePublicRepos: Ptr(false), 4823 MembersAllowedRepositoryCreationType: Ptr("marct"), 4824 MembersCanCreatePages: Ptr(true), 4825 MembersCanCreatePublicPages: Ptr(false), 4826 MembersCanCreatePrivatePages: Ptr(true), 4827 }, 4828 Sender: &User{ 4829 Login: Ptr("l"), 4830 ID: Ptr(int64(1)), 4831 NodeID: Ptr("n"), 4832 URL: Ptr("u"), 4833 ReposURL: Ptr("r"), 4834 EventsURL: Ptr("e"), 4835 AvatarURL: Ptr("a"), 4836 }, 4837 Installation: &Installation{ 4838 ID: Ptr(int64(1)), 4839 NodeID: Ptr("nid"), 4840 AppID: Ptr(int64(1)), 4841 AppSlug: Ptr("as"), 4842 TargetID: Ptr(int64(1)), 4843 Account: &User{ 4844 Login: Ptr("l"), 4845 ID: Ptr(int64(1)), 4846 URL: Ptr("u"), 4847 AvatarURL: Ptr("a"), 4848 GravatarID: Ptr("g"), 4849 Name: Ptr("n"), 4850 Company: Ptr("c"), 4851 Blog: Ptr("b"), 4852 Location: Ptr("l"), 4853 Email: Ptr("e"), 4854 Hireable: Ptr(true), 4855 Bio: Ptr("b"), 4856 TwitterUsername: Ptr("t"), 4857 PublicRepos: Ptr(1), 4858 Followers: Ptr(1), 4859 Following: Ptr(1), 4860 CreatedAt: &Timestamp{referenceTime}, 4861 SuspendedAt: &Timestamp{referenceTime}, 4862 }, 4863 AccessTokensURL: Ptr("atu"), 4864 RepositoriesURL: Ptr("ru"), 4865 HTMLURL: Ptr("hu"), 4866 TargetType: Ptr("tt"), 4867 SingleFileName: Ptr("sfn"), 4868 RepositorySelection: Ptr("rs"), 4869 Events: []string{"e"}, 4870 SingleFilePaths: []string{"s"}, 4871 Permissions: &InstallationPermissions{ 4872 Actions: Ptr("a"), 4873 Administration: Ptr("ad"), 4874 Checks: Ptr("c"), 4875 Contents: Ptr("co"), 4876 ContentReferences: Ptr("cr"), 4877 Deployments: Ptr("d"), 4878 Environments: Ptr("e"), 4879 Issues: Ptr("i"), 4880 Metadata: Ptr("md"), 4881 Members: Ptr("m"), 4882 OrganizationAdministration: Ptr("oa"), 4883 OrganizationHooks: Ptr("oh"), 4884 OrganizationPlan: Ptr("op"), 4885 OrganizationPreReceiveHooks: Ptr("opr"), 4886 OrganizationProjects: Ptr("op"), 4887 OrganizationSecrets: Ptr("os"), 4888 OrganizationSelfHostedRunners: Ptr("osh"), 4889 OrganizationUserBlocking: Ptr("oub"), 4890 Packages: Ptr("pkg"), 4891 Pages: Ptr("pg"), 4892 PullRequests: Ptr("pr"), 4893 RepositoryHooks: Ptr("rh"), 4894 RepositoryProjects: Ptr("rp"), 4895 RepositoryPreReceiveHooks: Ptr("rprh"), 4896 Secrets: Ptr("s"), 4897 SecretScanningAlerts: Ptr("ssa"), 4898 SecurityEvents: Ptr("se"), 4899 SingleFile: Ptr("sf"), 4900 Statuses: Ptr("s"), 4901 TeamDiscussions: Ptr("td"), 4902 VulnerabilityAlerts: Ptr("va"), 4903 Workflows: Ptr("w"), 4904 }, 4905 CreatedAt: &Timestamp{referenceTime}, 4906 UpdatedAt: &Timestamp{referenceTime}, 4907 HasMultipleSingleFiles: Ptr(false), 4908 SuspendedBy: &User{ 4909 Login: Ptr("l"), 4910 ID: Ptr(int64(1)), 4911 URL: Ptr("u"), 4912 AvatarURL: Ptr("a"), 4913 GravatarID: Ptr("g"), 4914 Name: Ptr("n"), 4915 Company: Ptr("c"), 4916 Blog: Ptr("b"), 4917 Location: Ptr("l"), 4918 Email: Ptr("e"), 4919 Hireable: Ptr(true), 4920 Bio: Ptr("b"), 4921 TwitterUsername: Ptr("t"), 4922 PublicRepos: Ptr(1), 4923 Followers: Ptr(1), 4924 Following: Ptr(1), 4925 CreatedAt: &Timestamp{referenceTime}, 4926 SuspendedAt: &Timestamp{referenceTime}, 4927 }, 4928 SuspendedAt: &Timestamp{referenceTime}, 4929 }, 4930 } 4931 4932 want := `{ 4933 "action": "a", 4934 "invitation": { 4935 "id": 1 4936 }, 4937 "membership": { 4938 "url": "url", 4939 "state": "s", 4940 "role": "r", 4941 "organization_url": "ou", 4942 "organization": { 4943 "name": "n", 4944 "company": "c", 4945 "blog": "b", 4946 "location": "loc", 4947 "email": "e", 4948 "twitter_username": "tu", 4949 "description": "d", 4950 "billing_email": "be", 4951 "is_verified": true, 4952 "has_organization_projects": true, 4953 "has_repository_projects": true, 4954 "default_repository_permission": "drp", 4955 "members_can_create_repositories": true, 4956 "members_can_create_public_repositories": false, 4957 "members_can_create_private_repositories": true, 4958 "members_can_create_internal_repositories": true, 4959 "members_allowed_repository_creation_type": "marct", 4960 "members_can_create_pages": true, 4961 "members_can_create_public_pages": false, 4962 "members_can_create_private_pages": true 4963 }, 4964 "user": { 4965 "login": "l", 4966 "id": 1, 4967 "node_id": "n", 4968 "avatar_url": "a", 4969 "url": "u", 4970 "events_url": "e", 4971 "repos_url": "r" 4972 } 4973 }, 4974 "organization": { 4975 "name": "n", 4976 "company": "c", 4977 "blog": "b", 4978 "location": "loc", 4979 "email": "e", 4980 "twitter_username": "tu", 4981 "description": "d", 4982 "billing_email": "be", 4983 "is_verified": true, 4984 "has_organization_projects": true, 4985 "has_repository_projects": true, 4986 "default_repository_permission": "drp", 4987 "members_can_create_repositories": true, 4988 "members_can_create_public_repositories": false, 4989 "members_can_create_private_repositories": true, 4990 "members_can_create_internal_repositories": true, 4991 "members_allowed_repository_creation_type": "marct", 4992 "members_can_create_pages": true, 4993 "members_can_create_public_pages": false, 4994 "members_can_create_private_pages": true 4995 }, 4996 "sender": { 4997 "login": "l", 4998 "id": 1, 4999 "node_id": "n", 5000 "avatar_url": "a", 5001 "url": "u", 5002 "events_url": "e", 5003 "repos_url": "r" 5004 }, 5005 "installation": { 5006 "id": 1, 5007 "node_id": "nid", 5008 "app_id": 1, 5009 "app_slug": "as", 5010 "target_id": 1, 5011 "account": { 5012 "login": "l", 5013 "id": 1, 5014 "avatar_url": "a", 5015 "gravatar_id": "g", 5016 "name": "n", 5017 "company": "c", 5018 "blog": "b", 5019 "location": "l", 5020 "email": "e", 5021 "hireable": true, 5022 "bio": "b", 5023 "twitter_username": "t", 5024 "public_repos": 1, 5025 "followers": 1, 5026 "following": 1, 5027 "created_at": ` + referenceTimeStr + `, 5028 "suspended_at": ` + referenceTimeStr + `, 5029 "url": "u" 5030 }, 5031 "access_tokens_url": "atu", 5032 "repositories_url": "ru", 5033 "html_url": "hu", 5034 "target_type": "tt", 5035 "single_file_name": "sfn", 5036 "repository_selection": "rs", 5037 "events": [ 5038 "e" 5039 ], 5040 "single_file_paths": [ 5041 "s" 5042 ], 5043 "permissions": { 5044 "actions": "a", 5045 "administration": "ad", 5046 "checks": "c", 5047 "contents": "co", 5048 "content_references": "cr", 5049 "deployments": "d", 5050 "environments": "e", 5051 "issues": "i", 5052 "metadata": "md", 5053 "members": "m", 5054 "organization_administration": "oa", 5055 "organization_hooks": "oh", 5056 "organization_plan": "op", 5057 "organization_pre_receive_hooks": "opr", 5058 "organization_projects": "op", 5059 "organization_secrets": "os", 5060 "organization_self_hosted_runners": "osh", 5061 "organization_user_blocking": "oub", 5062 "packages": "pkg", 5063 "pages": "pg", 5064 "pull_requests": "pr", 5065 "repository_hooks": "rh", 5066 "repository_projects": "rp", 5067 "repository_pre_receive_hooks": "rprh", 5068 "secrets": "s", 5069 "secret_scanning_alerts": "ssa", 5070 "security_events": "se", 5071 "single_file": "sf", 5072 "statuses": "s", 5073 "team_discussions": "td", 5074 "vulnerability_alerts": "va", 5075 "workflows": "w" 5076 }, 5077 "created_at": ` + referenceTimeStr + `, 5078 "updated_at": ` + referenceTimeStr + `, 5079 "has_multiple_single_files": false, 5080 "suspended_by": { 5081 "login": "l", 5082 "id": 1, 5083 "avatar_url": "a", 5084 "gravatar_id": "g", 5085 "name": "n", 5086 "company": "c", 5087 "blog": "b", 5088 "location": "l", 5089 "email": "e", 5090 "hireable": true, 5091 "bio": "b", 5092 "twitter_username": "t", 5093 "public_repos": 1, 5094 "followers": 1, 5095 "following": 1, 5096 "created_at": ` + referenceTimeStr + `, 5097 "suspended_at": ` + referenceTimeStr + `, 5098 "url": "u" 5099 }, 5100 "suspended_at": ` + referenceTimeStr + ` 5101 } 5102 }` 5103 5104 testJSONMarshal(t, u, want) 5105 } 5106 5107 func TestPageBuildEvent_Marshal(t *testing.T) { 5108 t.Parallel() 5109 testJSONMarshal(t, &PageBuildEvent{}, "{}") 5110 5111 u := &PageBuildEvent{ 5112 Build: &PagesBuild{URL: Ptr("url")}, 5113 ID: Ptr(int64(1)), 5114 Repo: &Repository{ 5115 ID: Ptr(int64(1)), 5116 URL: Ptr("s"), 5117 Name: Ptr("n"), 5118 }, 5119 Sender: &User{ 5120 Login: Ptr("l"), 5121 ID: Ptr(int64(1)), 5122 NodeID: Ptr("n"), 5123 URL: Ptr("u"), 5124 ReposURL: Ptr("r"), 5125 EventsURL: Ptr("e"), 5126 AvatarURL: Ptr("a"), 5127 }, 5128 Installation: &Installation{ 5129 ID: Ptr(int64(1)), 5130 NodeID: Ptr("nid"), 5131 AppID: Ptr(int64(1)), 5132 AppSlug: Ptr("as"), 5133 TargetID: Ptr(int64(1)), 5134 Account: &User{ 5135 Login: Ptr("l"), 5136 ID: Ptr(int64(1)), 5137 URL: Ptr("u"), 5138 AvatarURL: Ptr("a"), 5139 GravatarID: Ptr("g"), 5140 Name: Ptr("n"), 5141 Company: Ptr("c"), 5142 Blog: Ptr("b"), 5143 Location: Ptr("l"), 5144 Email: Ptr("e"), 5145 Hireable: Ptr(true), 5146 Bio: Ptr("b"), 5147 TwitterUsername: Ptr("t"), 5148 PublicRepos: Ptr(1), 5149 Followers: Ptr(1), 5150 Following: Ptr(1), 5151 CreatedAt: &Timestamp{referenceTime}, 5152 SuspendedAt: &Timestamp{referenceTime}, 5153 }, 5154 AccessTokensURL: Ptr("atu"), 5155 RepositoriesURL: Ptr("ru"), 5156 HTMLURL: Ptr("hu"), 5157 TargetType: Ptr("tt"), 5158 SingleFileName: Ptr("sfn"), 5159 RepositorySelection: Ptr("rs"), 5160 Events: []string{"e"}, 5161 SingleFilePaths: []string{"s"}, 5162 Permissions: &InstallationPermissions{ 5163 Actions: Ptr("a"), 5164 Administration: Ptr("ad"), 5165 Checks: Ptr("c"), 5166 Contents: Ptr("co"), 5167 ContentReferences: Ptr("cr"), 5168 Deployments: Ptr("d"), 5169 Environments: Ptr("e"), 5170 Issues: Ptr("i"), 5171 Metadata: Ptr("md"), 5172 Members: Ptr("m"), 5173 OrganizationAdministration: Ptr("oa"), 5174 OrganizationHooks: Ptr("oh"), 5175 OrganizationPlan: Ptr("op"), 5176 OrganizationPreReceiveHooks: Ptr("opr"), 5177 OrganizationProjects: Ptr("op"), 5178 OrganizationSecrets: Ptr("os"), 5179 OrganizationSelfHostedRunners: Ptr("osh"), 5180 OrganizationUserBlocking: Ptr("oub"), 5181 Packages: Ptr("pkg"), 5182 Pages: Ptr("pg"), 5183 PullRequests: Ptr("pr"), 5184 RepositoryHooks: Ptr("rh"), 5185 RepositoryProjects: Ptr("rp"), 5186 RepositoryPreReceiveHooks: Ptr("rprh"), 5187 Secrets: Ptr("s"), 5188 SecretScanningAlerts: Ptr("ssa"), 5189 SecurityEvents: Ptr("se"), 5190 SingleFile: Ptr("sf"), 5191 Statuses: Ptr("s"), 5192 TeamDiscussions: Ptr("td"), 5193 VulnerabilityAlerts: Ptr("va"), 5194 Workflows: Ptr("w"), 5195 }, 5196 CreatedAt: &Timestamp{referenceTime}, 5197 UpdatedAt: &Timestamp{referenceTime}, 5198 HasMultipleSingleFiles: Ptr(false), 5199 SuspendedBy: &User{ 5200 Login: Ptr("l"), 5201 ID: Ptr(int64(1)), 5202 URL: Ptr("u"), 5203 AvatarURL: Ptr("a"), 5204 GravatarID: Ptr("g"), 5205 Name: Ptr("n"), 5206 Company: Ptr("c"), 5207 Blog: Ptr("b"), 5208 Location: Ptr("l"), 5209 Email: Ptr("e"), 5210 Hireable: Ptr(true), 5211 Bio: Ptr("b"), 5212 TwitterUsername: Ptr("t"), 5213 PublicRepos: Ptr(1), 5214 Followers: Ptr(1), 5215 Following: Ptr(1), 5216 CreatedAt: &Timestamp{referenceTime}, 5217 SuspendedAt: &Timestamp{referenceTime}, 5218 }, 5219 SuspendedAt: &Timestamp{referenceTime}, 5220 }, 5221 } 5222 5223 want := `{ 5224 "build": { 5225 "url": "url" 5226 }, 5227 "id": 1, 5228 "repository": { 5229 "id": 1, 5230 "name": "n", 5231 "url": "s" 5232 }, 5233 "sender": { 5234 "login": "l", 5235 "id": 1, 5236 "node_id": "n", 5237 "avatar_url": "a", 5238 "url": "u", 5239 "events_url": "e", 5240 "repos_url": "r" 5241 }, 5242 "installation": { 5243 "id": 1, 5244 "node_id": "nid", 5245 "app_id": 1, 5246 "app_slug": "as", 5247 "target_id": 1, 5248 "account": { 5249 "login": "l", 5250 "id": 1, 5251 "avatar_url": "a", 5252 "gravatar_id": "g", 5253 "name": "n", 5254 "company": "c", 5255 "blog": "b", 5256 "location": "l", 5257 "email": "e", 5258 "hireable": true, 5259 "bio": "b", 5260 "twitter_username": "t", 5261 "public_repos": 1, 5262 "followers": 1, 5263 "following": 1, 5264 "created_at": ` + referenceTimeStr + `, 5265 "suspended_at": ` + referenceTimeStr + `, 5266 "url": "u" 5267 }, 5268 "access_tokens_url": "atu", 5269 "repositories_url": "ru", 5270 "html_url": "hu", 5271 "target_type": "tt", 5272 "single_file_name": "sfn", 5273 "repository_selection": "rs", 5274 "events": [ 5275 "e" 5276 ], 5277 "single_file_paths": [ 5278 "s" 5279 ], 5280 "permissions": { 5281 "actions": "a", 5282 "administration": "ad", 5283 "checks": "c", 5284 "contents": "co", 5285 "content_references": "cr", 5286 "deployments": "d", 5287 "environments": "e", 5288 "issues": "i", 5289 "metadata": "md", 5290 "members": "m", 5291 "organization_administration": "oa", 5292 "organization_hooks": "oh", 5293 "organization_plan": "op", 5294 "organization_pre_receive_hooks": "opr", 5295 "organization_projects": "op", 5296 "organization_secrets": "os", 5297 "organization_self_hosted_runners": "osh", 5298 "organization_user_blocking": "oub", 5299 "packages": "pkg", 5300 "pages": "pg", 5301 "pull_requests": "pr", 5302 "repository_hooks": "rh", 5303 "repository_projects": "rp", 5304 "repository_pre_receive_hooks": "rprh", 5305 "secrets": "s", 5306 "secret_scanning_alerts": "ssa", 5307 "security_events": "se", 5308 "single_file": "sf", 5309 "statuses": "s", 5310 "team_discussions": "td", 5311 "vulnerability_alerts": "va", 5312 "workflows": "w" 5313 }, 5314 "created_at": ` + referenceTimeStr + `, 5315 "updated_at": ` + referenceTimeStr + `, 5316 "has_multiple_single_files": false, 5317 "suspended_by": { 5318 "login": "l", 5319 "id": 1, 5320 "avatar_url": "a", 5321 "gravatar_id": "g", 5322 "name": "n", 5323 "company": "c", 5324 "blog": "b", 5325 "location": "l", 5326 "email": "e", 5327 "hireable": true, 5328 "bio": "b", 5329 "twitter_username": "t", 5330 "public_repos": 1, 5331 "followers": 1, 5332 "following": 1, 5333 "created_at": ` + referenceTimeStr + `, 5334 "suspended_at": ` + referenceTimeStr + `, 5335 "url": "u" 5336 }, 5337 "suspended_at": ` + referenceTimeStr + ` 5338 } 5339 }` 5340 5341 testJSONMarshal(t, u, want) 5342 } 5343 5344 func TestCommitCommentEvent_Marshal(t *testing.T) { 5345 t.Parallel() 5346 testJSONMarshal(t, &CommitCommentEvent{}, "{}") 5347 5348 u := &CommitCommentEvent{ 5349 Comment: &RepositoryComment{ 5350 HTMLURL: Ptr("hurl"), 5351 URL: Ptr("url"), 5352 ID: Ptr(int64(1)), 5353 NodeID: Ptr("nid"), 5354 CommitID: Ptr("cid"), 5355 User: &User{ 5356 Login: Ptr("l"), 5357 ID: Ptr(int64(1)), 5358 NodeID: Ptr("n"), 5359 URL: Ptr("u"), 5360 ReposURL: Ptr("r"), 5361 EventsURL: Ptr("e"), 5362 AvatarURL: Ptr("a"), 5363 }, 5364 Reactions: &Reactions{ 5365 TotalCount: Ptr(1), 5366 PlusOne: Ptr(1), 5367 MinusOne: Ptr(1), 5368 Laugh: Ptr(1), 5369 Confused: Ptr(1), 5370 Heart: Ptr(1), 5371 Hooray: Ptr(1), 5372 Rocket: Ptr(1), 5373 Eyes: Ptr(1), 5374 URL: Ptr("url"), 5375 }, 5376 CreatedAt: &Timestamp{referenceTime}, 5377 UpdatedAt: &Timestamp{referenceTime}, 5378 Body: Ptr("b"), 5379 Path: Ptr("path"), 5380 Position: Ptr(1), 5381 }, 5382 Action: Ptr("a"), 5383 Repo: &Repository{ 5384 ID: Ptr(int64(1)), 5385 URL: Ptr("s"), 5386 Name: Ptr("n"), 5387 }, 5388 Sender: &User{ 5389 Login: Ptr("l"), 5390 ID: Ptr(int64(1)), 5391 NodeID: Ptr("n"), 5392 URL: Ptr("u"), 5393 ReposURL: Ptr("r"), 5394 EventsURL: Ptr("e"), 5395 AvatarURL: Ptr("a"), 5396 }, 5397 Installation: &Installation{ 5398 ID: Ptr(int64(1)), 5399 NodeID: Ptr("nid"), 5400 AppID: Ptr(int64(1)), 5401 AppSlug: Ptr("as"), 5402 TargetID: Ptr(int64(1)), 5403 Account: &User{ 5404 Login: Ptr("l"), 5405 ID: Ptr(int64(1)), 5406 URL: Ptr("u"), 5407 AvatarURL: Ptr("a"), 5408 GravatarID: Ptr("g"), 5409 Name: Ptr("n"), 5410 Company: Ptr("c"), 5411 Blog: Ptr("b"), 5412 Location: Ptr("l"), 5413 Email: Ptr("e"), 5414 Hireable: Ptr(true), 5415 Bio: Ptr("b"), 5416 TwitterUsername: Ptr("t"), 5417 PublicRepos: Ptr(1), 5418 Followers: Ptr(1), 5419 Following: Ptr(1), 5420 CreatedAt: &Timestamp{referenceTime}, 5421 SuspendedAt: &Timestamp{referenceTime}, 5422 }, 5423 AccessTokensURL: Ptr("atu"), 5424 RepositoriesURL: Ptr("ru"), 5425 HTMLURL: Ptr("hu"), 5426 TargetType: Ptr("tt"), 5427 SingleFileName: Ptr("sfn"), 5428 RepositorySelection: Ptr("rs"), 5429 Events: []string{"e"}, 5430 SingleFilePaths: []string{"s"}, 5431 Permissions: &InstallationPermissions{ 5432 Actions: Ptr("a"), 5433 Administration: Ptr("ad"), 5434 Checks: Ptr("c"), 5435 Contents: Ptr("co"), 5436 ContentReferences: Ptr("cr"), 5437 Deployments: Ptr("d"), 5438 Environments: Ptr("e"), 5439 Issues: Ptr("i"), 5440 Metadata: Ptr("md"), 5441 Members: Ptr("m"), 5442 OrganizationAdministration: Ptr("oa"), 5443 OrganizationHooks: Ptr("oh"), 5444 OrganizationPlan: Ptr("op"), 5445 OrganizationPreReceiveHooks: Ptr("opr"), 5446 OrganizationProjects: Ptr("op"), 5447 OrganizationSecrets: Ptr("os"), 5448 OrganizationSelfHostedRunners: Ptr("osh"), 5449 OrganizationUserBlocking: Ptr("oub"), 5450 Packages: Ptr("pkg"), 5451 Pages: Ptr("pg"), 5452 PullRequests: Ptr("pr"), 5453 RepositoryHooks: Ptr("rh"), 5454 RepositoryProjects: Ptr("rp"), 5455 RepositoryPreReceiveHooks: Ptr("rprh"), 5456 Secrets: Ptr("s"), 5457 SecretScanningAlerts: Ptr("ssa"), 5458 SecurityEvents: Ptr("se"), 5459 SingleFile: Ptr("sf"), 5460 Statuses: Ptr("s"), 5461 TeamDiscussions: Ptr("td"), 5462 VulnerabilityAlerts: Ptr("va"), 5463 Workflows: Ptr("w"), 5464 }, 5465 CreatedAt: &Timestamp{referenceTime}, 5466 UpdatedAt: &Timestamp{referenceTime}, 5467 HasMultipleSingleFiles: Ptr(false), 5468 SuspendedBy: &User{ 5469 Login: Ptr("l"), 5470 ID: Ptr(int64(1)), 5471 URL: Ptr("u"), 5472 AvatarURL: Ptr("a"), 5473 GravatarID: Ptr("g"), 5474 Name: Ptr("n"), 5475 Company: Ptr("c"), 5476 Blog: Ptr("b"), 5477 Location: Ptr("l"), 5478 Email: Ptr("e"), 5479 Hireable: Ptr(true), 5480 Bio: Ptr("b"), 5481 TwitterUsername: Ptr("t"), 5482 PublicRepos: Ptr(1), 5483 Followers: Ptr(1), 5484 Following: Ptr(1), 5485 CreatedAt: &Timestamp{referenceTime}, 5486 SuspendedAt: &Timestamp{referenceTime}, 5487 }, 5488 SuspendedAt: &Timestamp{referenceTime}, 5489 }, 5490 } 5491 5492 want := `{ 5493 "comment": { 5494 "html_url": "hurl", 5495 "url": "url", 5496 "id": 1, 5497 "node_id": "nid", 5498 "commit_id": "cid", 5499 "user": { 5500 "login": "l", 5501 "id": 1, 5502 "node_id": "n", 5503 "avatar_url": "a", 5504 "url": "u", 5505 "events_url": "e", 5506 "repos_url": "r" 5507 }, 5508 "reactions": { 5509 "total_count": 1, 5510 "+1": 1, 5511 "-1": 1, 5512 "laugh": 1, 5513 "confused": 1, 5514 "heart": 1, 5515 "hooray": 1, 5516 "rocket": 1, 5517 "eyes": 1, 5518 "url": "url" 5519 }, 5520 "created_at": ` + referenceTimeStr + `, 5521 "updated_at": ` + referenceTimeStr + `, 5522 "body": "b", 5523 "path": "path", 5524 "position": 1 5525 }, 5526 "action": "a", 5527 "repository": { 5528 "id": 1, 5529 "name": "n", 5530 "url": "s" 5531 }, 5532 "sender": { 5533 "login": "l", 5534 "id": 1, 5535 "node_id": "n", 5536 "avatar_url": "a", 5537 "url": "u", 5538 "events_url": "e", 5539 "repos_url": "r" 5540 }, 5541 "installation": { 5542 "id": 1, 5543 "node_id": "nid", 5544 "app_id": 1, 5545 "app_slug": "as", 5546 "target_id": 1, 5547 "account": { 5548 "login": "l", 5549 "id": 1, 5550 "avatar_url": "a", 5551 "gravatar_id": "g", 5552 "name": "n", 5553 "company": "c", 5554 "blog": "b", 5555 "location": "l", 5556 "email": "e", 5557 "hireable": true, 5558 "bio": "b", 5559 "twitter_username": "t", 5560 "public_repos": 1, 5561 "followers": 1, 5562 "following": 1, 5563 "created_at": ` + referenceTimeStr + `, 5564 "suspended_at": ` + referenceTimeStr + `, 5565 "url": "u" 5566 }, 5567 "access_tokens_url": "atu", 5568 "repositories_url": "ru", 5569 "html_url": "hu", 5570 "target_type": "tt", 5571 "single_file_name": "sfn", 5572 "repository_selection": "rs", 5573 "events": [ 5574 "e" 5575 ], 5576 "single_file_paths": [ 5577 "s" 5578 ], 5579 "permissions": { 5580 "actions": "a", 5581 "administration": "ad", 5582 "checks": "c", 5583 "contents": "co", 5584 "content_references": "cr", 5585 "deployments": "d", 5586 "environments": "e", 5587 "issues": "i", 5588 "metadata": "md", 5589 "members": "m", 5590 "organization_administration": "oa", 5591 "organization_hooks": "oh", 5592 "organization_plan": "op", 5593 "organization_pre_receive_hooks": "opr", 5594 "organization_projects": "op", 5595 "organization_secrets": "os", 5596 "organization_self_hosted_runners": "osh", 5597 "organization_user_blocking": "oub", 5598 "packages": "pkg", 5599 "pages": "pg", 5600 "pull_requests": "pr", 5601 "repository_hooks": "rh", 5602 "repository_projects": "rp", 5603 "repository_pre_receive_hooks": "rprh", 5604 "secrets": "s", 5605 "secret_scanning_alerts": "ssa", 5606 "security_events": "se", 5607 "single_file": "sf", 5608 "statuses": "s", 5609 "team_discussions": "td", 5610 "vulnerability_alerts": "va", 5611 "workflows": "w" 5612 }, 5613 "created_at": ` + referenceTimeStr + `, 5614 "updated_at": ` + referenceTimeStr + `, 5615 "has_multiple_single_files": false, 5616 "suspended_by": { 5617 "login": "l", 5618 "id": 1, 5619 "avatar_url": "a", 5620 "gravatar_id": "g", 5621 "name": "n", 5622 "company": "c", 5623 "blog": "b", 5624 "location": "l", 5625 "email": "e", 5626 "hireable": true, 5627 "bio": "b", 5628 "twitter_username": "t", 5629 "public_repos": 1, 5630 "followers": 1, 5631 "following": 1, 5632 "created_at": ` + referenceTimeStr + `, 5633 "suspended_at": ` + referenceTimeStr + `, 5634 "url": "u" 5635 }, 5636 "suspended_at": ` + referenceTimeStr + ` 5637 } 5638 }` 5639 5640 testJSONMarshal(t, u, want) 5641 } 5642 5643 func TestDeploymentEvent_Marshal(t *testing.T) { 5644 t.Parallel() 5645 testJSONMarshal(t, &DeploymentEvent{}, "{}") 5646 5647 l := make(map[string]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 AutomaticCopilotCodeReviewEnabled: Ptr(false), 9641 DismissStaleReviewsOnPush: false, 9642 RequireCodeOwnerReview: false, 9643 RequireLastPushApproval: false, 9644 RequiredApprovingReviewCount: 2, 9645 RequiredReviewThreadResolution: false, 9646 }, 9647 CodeScanning: &CodeScanningRuleParameters{ 9648 CodeScanningTools: []*RuleCodeScanningTool{ 9649 { 9650 AlertsThreshold: CodeScanningAlertsThresholdErrors, 9651 SecurityAlertsThreshold: CodeScanningSecurityAlertsThresholdHighOrHigher, 9652 Tool: "CodeQL", 9653 }, 9654 }, 9655 }, 9656 }, 9657 NodeID: Ptr("n"), 9658 CreatedAt: &Timestamp{referenceTime}, 9659 UpdatedAt: &Timestamp{referenceTime}, 9660 Links: &RepositoryRulesetLinks{ 9661 Self: &RepositoryRulesetLink{HRef: Ptr("a")}, 9662 HTML: &RepositoryRulesetLink{HRef: Ptr("a")}, 9663 }, 9664 }, 9665 Repository: repository, 9666 Organization: organization, 9667 Enterprise: enterprise, 9668 Installation: installation, 9669 Sender: sender, 9670 }, 9671 }, 9672 { 9673 "edited", 9674 fmt.Sprintf( 9675 `{"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"}}`, 9676 referenceTimeStr, 9677 ), 9678 &RepositoryRulesetEvent{ 9679 Action: Ptr("edited"), 9680 RepositoryRuleset: &RepositoryRuleset{ 9681 ID: Ptr(int64(1)), 9682 Name: "r", 9683 Target: Ptr(RulesetTargetBranch), 9684 SourceType: Ptr(RulesetSourceTypeRepository), 9685 Source: "o/r", 9686 Enforcement: RulesetEnforcementActive, 9687 Conditions: &RepositoryRulesetConditions{ 9688 RefName: &RepositoryRulesetRefConditionParameters{ 9689 Include: []string{"~DEFAULT_BRANCH", "refs/heads/dev-*"}, 9690 Exclude: []string{}, 9691 }, 9692 }, 9693 Rules: &RepositoryRulesetRules{ 9694 Creation: &EmptyRuleParameters{}, 9695 Update: &UpdateRuleParameters{}, 9696 Deletion: &EmptyRuleParameters{}, 9697 RequiredSignatures: &EmptyRuleParameters{}, 9698 PullRequest: &PullRequestRuleParameters{ 9699 AllowedMergeMethods: []MergeMethod{ 9700 MergeMethodSquash, 9701 MergeMethodRebase, 9702 }, 9703 AutomaticCopilotCodeReviewEnabled: Ptr(false), 9704 DismissStaleReviewsOnPush: false, 9705 RequireCodeOwnerReview: false, 9706 RequireLastPushApproval: false, 9707 RequiredApprovingReviewCount: 2, 9708 RequiredReviewThreadResolution: false, 9709 }, 9710 CodeScanning: &CodeScanningRuleParameters{ 9711 CodeScanningTools: []*RuleCodeScanningTool{ 9712 { 9713 AlertsThreshold: CodeScanningAlertsThresholdErrors, 9714 SecurityAlertsThreshold: CodeScanningSecurityAlertsThresholdMediumOrHigher, 9715 Tool: "CodeQL", 9716 }, 9717 }, 9718 }, 9719 }, 9720 NodeID: Ptr("n"), 9721 CreatedAt: &Timestamp{referenceTime}, 9722 UpdatedAt: &Timestamp{referenceTime}, 9723 Links: &RepositoryRulesetLinks{ 9724 Self: &RepositoryRulesetLink{HRef: Ptr("a")}, 9725 HTML: &RepositoryRulesetLink{HRef: Ptr("a")}, 9726 }, 9727 }, 9728 Changes: &RepositoryRulesetChanges{ 9729 Conditions: &RepositoryRulesetChangedConditions{ 9730 Updated: []*RepositoryRulesetUpdatedConditions{ 9731 { 9732 Condition: &RepositoryRulesetConditions{ 9733 RefName: &RepositoryRulesetRefConditionParameters{ 9734 Include: []string{"~DEFAULT_BRANCH", "refs/heads/dev-*"}, 9735 Exclude: []string{}, 9736 }, 9737 }, 9738 Changes: &RepositoryRulesetUpdatedCondition{ 9739 Include: &RepositoryRulesetChangeSources{ 9740 From: []string{"~ALL"}, 9741 }, 9742 }, 9743 }, 9744 }, 9745 Deleted: []*RepositoryRulesetConditions{}, 9746 }, 9747 Rules: &RepositoryRulesetChangedRules{ 9748 Added: []*RepositoryRule{{Type: RulesetRuleTypeRequiredSignatures}}, 9749 Updated: []*RepositoryRulesetUpdatedRules{ 9750 { 9751 Rule: &RepositoryRule{ 9752 Type: RulesetRuleTypePullRequest, 9753 Parameters: &PullRequestRuleParameters{ 9754 AllowedMergeMethods: []MergeMethod{ 9755 MergeMethodSquash, 9756 MergeMethodRebase, 9757 }, 9758 AutomaticCopilotCodeReviewEnabled: Ptr(false), 9759 DismissStaleReviewsOnPush: false, 9760 RequireCodeOwnerReview: false, 9761 RequireLastPushApproval: false, 9762 RequiredApprovingReviewCount: 2, 9763 RequiredReviewThreadResolution: false, 9764 }, 9765 }, 9766 Changes: &RepositoryRulesetChangedRule{ 9767 Configuration: &RepositoryRulesetChangeSource{ 9768 From: Ptr( 9769 `{\"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}`, 9770 ), 9771 }, 9772 }, 9773 }, 9774 { 9775 Rule: &RepositoryRule{ 9776 Type: RulesetRuleTypeCodeScanning, 9777 Parameters: &CodeScanningRuleParameters{ 9778 CodeScanningTools: []*RuleCodeScanningTool{ 9779 { 9780 AlertsThreshold: CodeScanningAlertsThresholdErrors, 9781 SecurityAlertsThreshold: CodeScanningSecurityAlertsThresholdMediumOrHigher, 9782 Tool: "CodeQL", 9783 }, 9784 }, 9785 }, 9786 }, 9787 Changes: &RepositoryRulesetChangedRule{ 9788 Configuration: &RepositoryRulesetChangeSource{ 9789 From: Ptr( 9790 `{\"code_scanning_tools\":[{\"tool\":\"CodeQL\",\"alerts_threshold\":\"errors\",\"security_alerts_threshold\":\"high_or_higher\"}]}`, 9791 ), 9792 }, 9793 }, 9794 }, 9795 }, 9796 Deleted: []*RepositoryRule{{Type: RulesetRuleTypeRequiredLinearHistory}}, 9797 }, 9798 }, 9799 Repository: repository, 9800 Organization: organization, 9801 Enterprise: enterprise, 9802 Installation: installation, 9803 Sender: sender, 9804 }, 9805 }, 9806 { 9807 "deleted", 9808 fmt.Sprintf( 9809 `{"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"}}`, 9810 referenceTimeStr, 9811 ), 9812 &RepositoryRulesetEvent{ 9813 Action: Ptr("deleted"), 9814 RepositoryRuleset: &RepositoryRuleset{ 9815 ID: Ptr(int64(1)), 9816 Name: "r", 9817 Target: Ptr(RulesetTargetBranch), 9818 SourceType: Ptr(RulesetSourceTypeRepository), 9819 Source: "o/r", 9820 Enforcement: RulesetEnforcementActive, 9821 Conditions: &RepositoryRulesetConditions{ 9822 RefName: &RepositoryRulesetRefConditionParameters{ 9823 Include: []string{"~DEFAULT_BRANCH", "refs/heads/dev-*"}, 9824 Exclude: []string{}, 9825 }, 9826 }, 9827 Rules: &RepositoryRulesetRules{ 9828 Creation: &EmptyRuleParameters{}, 9829 Update: &UpdateRuleParameters{}, 9830 Deletion: &EmptyRuleParameters{}, 9831 RequiredLinearHistory: &EmptyRuleParameters{}, 9832 }, 9833 NodeID: Ptr("n"), 9834 CreatedAt: &Timestamp{referenceTime}, 9835 UpdatedAt: &Timestamp{referenceTime}, 9836 Links: &RepositoryRulesetLinks{ 9837 Self: &RepositoryRulesetLink{HRef: Ptr("a")}, 9838 HTML: &RepositoryRulesetLink{HRef: Ptr("a")}, 9839 }, 9840 }, 9841 Repository: repository, 9842 Organization: organization, 9843 Enterprise: enterprise, 9844 Installation: installation, 9845 Sender: sender, 9846 }, 9847 }, 9848 } 9849 9850 for _, test := range tests { 9851 t.Run(test.name, func(t *testing.T) { 9852 t.Parallel() 9853 9854 got := &RepositoryRulesetEvent{} 9855 err := json.Unmarshal([]byte(test.json), got) 9856 if err != nil { 9857 t.Errorf("Unable to unmarshal JSON %v: %v", test.json, err) 9858 } 9859 9860 if diff := cmp.Diff(test.event, got); diff != "" { 9861 t.Errorf("json.Unmarshal returned:\n%#v\nwant:\n%#v\ndiff:\n%v", got, test.event, diff) 9862 } 9863 }) 9864 } 9865 } 9866 9867 func TestContentReferenceEvent_Marshal(t *testing.T) { 9868 t.Parallel() 9869 testJSONMarshal(t, &ContentReferenceEvent{}, "{}") 9870 9871 u := &ContentReferenceEvent{ 9872 Action: Ptr("a"), 9873 ContentReference: &ContentReference{ 9874 ID: Ptr(int64(1)), 9875 NodeID: Ptr("nid"), 9876 Reference: Ptr("ref"), 9877 }, 9878 Repo: &Repository{ 9879 ID: Ptr(int64(1)), 9880 URL: Ptr("s"), 9881 Name: Ptr("n"), 9882 }, 9883 Sender: &User{ 9884 Login: Ptr("l"), 9885 ID: Ptr(int64(1)), 9886 NodeID: Ptr("n"), 9887 URL: Ptr("u"), 9888 ReposURL: Ptr("r"), 9889 EventsURL: Ptr("e"), 9890 AvatarURL: Ptr("a"), 9891 }, 9892 Installation: &Installation{ 9893 ID: Ptr(int64(1)), 9894 NodeID: Ptr("nid"), 9895 AppID: Ptr(int64(1)), 9896 AppSlug: Ptr("as"), 9897 TargetID: Ptr(int64(1)), 9898 Account: &User{ 9899 Login: Ptr("l"), 9900 ID: Ptr(int64(1)), 9901 URL: Ptr("u"), 9902 AvatarURL: Ptr("a"), 9903 GravatarID: Ptr("g"), 9904 Name: Ptr("n"), 9905 Company: Ptr("c"), 9906 Blog: Ptr("b"), 9907 Location: Ptr("l"), 9908 Email: Ptr("e"), 9909 Hireable: Ptr(true), 9910 Bio: Ptr("b"), 9911 TwitterUsername: Ptr("t"), 9912 PublicRepos: Ptr(1), 9913 Followers: Ptr(1), 9914 Following: Ptr(1), 9915 CreatedAt: &Timestamp{referenceTime}, 9916 SuspendedAt: &Timestamp{referenceTime}, 9917 }, 9918 AccessTokensURL: Ptr("atu"), 9919 RepositoriesURL: Ptr("ru"), 9920 HTMLURL: Ptr("hu"), 9921 TargetType: Ptr("tt"), 9922 SingleFileName: Ptr("sfn"), 9923 RepositorySelection: Ptr("rs"), 9924 Events: []string{"e"}, 9925 SingleFilePaths: []string{"s"}, 9926 Permissions: &InstallationPermissions{ 9927 Actions: Ptr("a"), 9928 Administration: Ptr("ad"), 9929 Checks: Ptr("c"), 9930 Contents: Ptr("co"), 9931 ContentReferences: Ptr("cr"), 9932 Deployments: Ptr("d"), 9933 Environments: Ptr("e"), 9934 Issues: Ptr("i"), 9935 Metadata: Ptr("md"), 9936 Members: Ptr("m"), 9937 OrganizationAdministration: Ptr("oa"), 9938 OrganizationHooks: Ptr("oh"), 9939 OrganizationPlan: Ptr("op"), 9940 OrganizationPreReceiveHooks: Ptr("opr"), 9941 OrganizationProjects: Ptr("op"), 9942 OrganizationSecrets: Ptr("os"), 9943 OrganizationSelfHostedRunners: Ptr("osh"), 9944 OrganizationUserBlocking: Ptr("oub"), 9945 Packages: Ptr("pkg"), 9946 Pages: Ptr("pg"), 9947 PullRequests: Ptr("pr"), 9948 RepositoryHooks: Ptr("rh"), 9949 RepositoryProjects: Ptr("rp"), 9950 RepositoryPreReceiveHooks: Ptr("rprh"), 9951 Secrets: Ptr("s"), 9952 SecretScanningAlerts: Ptr("ssa"), 9953 SecurityEvents: Ptr("se"), 9954 SingleFile: Ptr("sf"), 9955 Statuses: Ptr("s"), 9956 TeamDiscussions: Ptr("td"), 9957 VulnerabilityAlerts: Ptr("va"), 9958 Workflows: Ptr("w"), 9959 }, 9960 CreatedAt: &Timestamp{referenceTime}, 9961 UpdatedAt: &Timestamp{referenceTime}, 9962 HasMultipleSingleFiles: Ptr(false), 9963 SuspendedBy: &User{ 9964 Login: Ptr("l"), 9965 ID: Ptr(int64(1)), 9966 URL: Ptr("u"), 9967 AvatarURL: Ptr("a"), 9968 GravatarID: Ptr("g"), 9969 Name: Ptr("n"), 9970 Company: Ptr("c"), 9971 Blog: Ptr("b"), 9972 Location: Ptr("l"), 9973 Email: Ptr("e"), 9974 Hireable: Ptr(true), 9975 Bio: Ptr("b"), 9976 TwitterUsername: Ptr("t"), 9977 PublicRepos: Ptr(1), 9978 Followers: Ptr(1), 9979 Following: Ptr(1), 9980 CreatedAt: &Timestamp{referenceTime}, 9981 SuspendedAt: &Timestamp{referenceTime}, 9982 }, 9983 SuspendedAt: &Timestamp{referenceTime}, 9984 }, 9985 } 9986 9987 want := `{ 9988 "action": "a", 9989 "content_reference": { 9990 "id": 1, 9991 "node_id": "nid", 9992 "reference": "ref" 9993 }, 9994 "repository": { 9995 "id": 1, 9996 "name": "n", 9997 "url": "s" 9998 }, 9999 "sender": { 10000 "login": "l", 10001 "id": 1, 10002 "node_id": "n", 10003 "avatar_url": "a", 10004 "url": "u", 10005 "events_url": "e", 10006 "repos_url": "r" 10007 }, 10008 "installation": { 10009 "id": 1, 10010 "node_id": "nid", 10011 "app_id": 1, 10012 "app_slug": "as", 10013 "target_id": 1, 10014 "account": { 10015 "login": "l", 10016 "id": 1, 10017 "avatar_url": "a", 10018 "gravatar_id": "g", 10019 "name": "n", 10020 "company": "c", 10021 "blog": "b", 10022 "location": "l", 10023 "email": "e", 10024 "hireable": true, 10025 "bio": "b", 10026 "twitter_username": "t", 10027 "public_repos": 1, 10028 "followers": 1, 10029 "following": 1, 10030 "created_at": ` + referenceTimeStr + `, 10031 "suspended_at": ` + referenceTimeStr + `, 10032 "url": "u" 10033 }, 10034 "access_tokens_url": "atu", 10035 "repositories_url": "ru", 10036 "html_url": "hu", 10037 "target_type": "tt", 10038 "single_file_name": "sfn", 10039 "repository_selection": "rs", 10040 "events": [ 10041 "e" 10042 ], 10043 "single_file_paths": [ 10044 "s" 10045 ], 10046 "permissions": { 10047 "actions": "a", 10048 "administration": "ad", 10049 "checks": "c", 10050 "contents": "co", 10051 "content_references": "cr", 10052 "deployments": "d", 10053 "environments": "e", 10054 "issues": "i", 10055 "metadata": "md", 10056 "members": "m", 10057 "organization_administration": "oa", 10058 "organization_hooks": "oh", 10059 "organization_plan": "op", 10060 "organization_pre_receive_hooks": "opr", 10061 "organization_projects": "op", 10062 "organization_secrets": "os", 10063 "organization_self_hosted_runners": "osh", 10064 "organization_user_blocking": "oub", 10065 "packages": "pkg", 10066 "pages": "pg", 10067 "pull_requests": "pr", 10068 "repository_hooks": "rh", 10069 "repository_projects": "rp", 10070 "repository_pre_receive_hooks": "rprh", 10071 "secrets": "s", 10072 "secret_scanning_alerts": "ssa", 10073 "security_events": "se", 10074 "single_file": "sf", 10075 "statuses": "s", 10076 "team_discussions": "td", 10077 "vulnerability_alerts": "va", 10078 "workflows": "w" 10079 }, 10080 "created_at": ` + referenceTimeStr + `, 10081 "updated_at": ` + referenceTimeStr + `, 10082 "has_multiple_single_files": false, 10083 "suspended_by": { 10084 "login": "l", 10085 "id": 1, 10086 "avatar_url": "a", 10087 "gravatar_id": "g", 10088 "name": "n", 10089 "company": "c", 10090 "blog": "b", 10091 "location": "l", 10092 "email": "e", 10093 "hireable": true, 10094 "bio": "b", 10095 "twitter_username": "t", 10096 "public_repos": 1, 10097 "followers": 1, 10098 "following": 1, 10099 "created_at": ` + referenceTimeStr + `, 10100 "suspended_at": ` + referenceTimeStr + `, 10101 "url": "u" 10102 }, 10103 "suspended_at": ` + referenceTimeStr + ` 10104 } 10105 }` 10106 10107 testJSONMarshal(t, u, want) 10108 } 10109 10110 func TestMemberEvent_Marshal(t *testing.T) { 10111 t.Parallel() 10112 testJSONMarshal(t, &MemberEvent{}, "{}") 10113 10114 u := &MemberEvent{ 10115 Action: Ptr("a"), 10116 Member: &User{ 10117 Login: Ptr("l"), 10118 ID: Ptr(int64(1)), 10119 NodeID: Ptr("n"), 10120 URL: Ptr("u"), 10121 ReposURL: Ptr("r"), 10122 EventsURL: Ptr("e"), 10123 AvatarURL: Ptr("a"), 10124 }, 10125 Changes: &MemberChanges{ 10126 Permission: &MemberChangesPermission{ 10127 From: Ptr("f"), 10128 To: Ptr("t"), 10129 }, 10130 RoleName: &MemberChangesRoleName{ 10131 From: Ptr("f"), 10132 To: Ptr("t"), 10133 }, 10134 }, 10135 Repo: &Repository{ 10136 ID: Ptr(int64(1)), 10137 URL: Ptr("s"), 10138 Name: Ptr("n"), 10139 }, 10140 Sender: &User{ 10141 Login: Ptr("l"), 10142 ID: Ptr(int64(1)), 10143 NodeID: Ptr("n"), 10144 URL: Ptr("u"), 10145 ReposURL: Ptr("r"), 10146 EventsURL: Ptr("e"), 10147 AvatarURL: Ptr("a"), 10148 }, 10149 Installation: &Installation{ 10150 ID: Ptr(int64(1)), 10151 NodeID: Ptr("nid"), 10152 AppID: Ptr(int64(1)), 10153 AppSlug: Ptr("as"), 10154 TargetID: Ptr(int64(1)), 10155 Account: &User{ 10156 Login: Ptr("l"), 10157 ID: Ptr(int64(1)), 10158 URL: Ptr("u"), 10159 AvatarURL: Ptr("a"), 10160 GravatarID: Ptr("g"), 10161 Name: Ptr("n"), 10162 Company: Ptr("c"), 10163 Blog: Ptr("b"), 10164 Location: Ptr("l"), 10165 Email: Ptr("e"), 10166 Hireable: Ptr(true), 10167 Bio: Ptr("b"), 10168 TwitterUsername: Ptr("t"), 10169 PublicRepos: Ptr(1), 10170 Followers: Ptr(1), 10171 Following: Ptr(1), 10172 CreatedAt: &Timestamp{referenceTime}, 10173 SuspendedAt: &Timestamp{referenceTime}, 10174 }, 10175 AccessTokensURL: Ptr("atu"), 10176 RepositoriesURL: Ptr("ru"), 10177 HTMLURL: Ptr("hu"), 10178 TargetType: Ptr("tt"), 10179 SingleFileName: Ptr("sfn"), 10180 RepositorySelection: Ptr("rs"), 10181 Events: []string{"e"}, 10182 SingleFilePaths: []string{"s"}, 10183 Permissions: &InstallationPermissions{ 10184 Actions: Ptr("a"), 10185 Administration: Ptr("ad"), 10186 Checks: Ptr("c"), 10187 Contents: Ptr("co"), 10188 ContentReferences: Ptr("cr"), 10189 Deployments: Ptr("d"), 10190 Environments: Ptr("e"), 10191 Issues: Ptr("i"), 10192 Metadata: Ptr("md"), 10193 Members: Ptr("m"), 10194 OrganizationAdministration: Ptr("oa"), 10195 OrganizationHooks: Ptr("oh"), 10196 OrganizationPlan: Ptr("op"), 10197 OrganizationPreReceiveHooks: Ptr("opr"), 10198 OrganizationProjects: Ptr("op"), 10199 OrganizationSecrets: Ptr("os"), 10200 OrganizationSelfHostedRunners: Ptr("osh"), 10201 OrganizationUserBlocking: Ptr("oub"), 10202 Packages: Ptr("pkg"), 10203 Pages: Ptr("pg"), 10204 PullRequests: Ptr("pr"), 10205 RepositoryHooks: Ptr("rh"), 10206 RepositoryProjects: Ptr("rp"), 10207 RepositoryPreReceiveHooks: Ptr("rprh"), 10208 Secrets: Ptr("s"), 10209 SecretScanningAlerts: Ptr("ssa"), 10210 SecurityEvents: Ptr("se"), 10211 SingleFile: Ptr("sf"), 10212 Statuses: Ptr("s"), 10213 TeamDiscussions: Ptr("td"), 10214 VulnerabilityAlerts: Ptr("va"), 10215 Workflows: Ptr("w"), 10216 }, 10217 CreatedAt: &Timestamp{referenceTime}, 10218 UpdatedAt: &Timestamp{referenceTime}, 10219 HasMultipleSingleFiles: Ptr(false), 10220 SuspendedBy: &User{ 10221 Login: Ptr("l"), 10222 ID: Ptr(int64(1)), 10223 URL: Ptr("u"), 10224 AvatarURL: Ptr("a"), 10225 GravatarID: Ptr("g"), 10226 Name: Ptr("n"), 10227 Company: Ptr("c"), 10228 Blog: Ptr("b"), 10229 Location: Ptr("l"), 10230 Email: Ptr("e"), 10231 Hireable: Ptr(true), 10232 Bio: Ptr("b"), 10233 TwitterUsername: Ptr("t"), 10234 PublicRepos: Ptr(1), 10235 Followers: Ptr(1), 10236 Following: Ptr(1), 10237 CreatedAt: &Timestamp{referenceTime}, 10238 SuspendedAt: &Timestamp{referenceTime}, 10239 }, 10240 SuspendedAt: &Timestamp{referenceTime}, 10241 }, 10242 } 10243 10244 want := `{ 10245 "action": "a", 10246 "member": { 10247 "login": "l", 10248 "id": 1, 10249 "node_id": "n", 10250 "avatar_url": "a", 10251 "url": "u", 10252 "events_url": "e", 10253 "repos_url": "r" 10254 }, 10255 "changes": { 10256 "permission": { 10257 "from": "f", 10258 "to": "t" 10259 }, 10260 "role_name": { 10261 "from": "f", 10262 "to": "t" 10263 } 10264 }, 10265 "repository": { 10266 "id": 1, 10267 "name": "n", 10268 "url": "s" 10269 }, 10270 "sender": { 10271 "login": "l", 10272 "id": 1, 10273 "node_id": "n", 10274 "avatar_url": "a", 10275 "url": "u", 10276 "events_url": "e", 10277 "repos_url": "r" 10278 }, 10279 "installation": { 10280 "id": 1, 10281 "node_id": "nid", 10282 "app_id": 1, 10283 "app_slug": "as", 10284 "target_id": 1, 10285 "account": { 10286 "login": "l", 10287 "id": 1, 10288 "avatar_url": "a", 10289 "gravatar_id": "g", 10290 "name": "n", 10291 "company": "c", 10292 "blog": "b", 10293 "location": "l", 10294 "email": "e", 10295 "hireable": true, 10296 "bio": "b", 10297 "twitter_username": "t", 10298 "public_repos": 1, 10299 "followers": 1, 10300 "following": 1, 10301 "created_at": ` + referenceTimeStr + `, 10302 "suspended_at": ` + referenceTimeStr + `, 10303 "url": "u" 10304 }, 10305 "access_tokens_url": "atu", 10306 "repositories_url": "ru", 10307 "html_url": "hu", 10308 "target_type": "tt", 10309 "single_file_name": "sfn", 10310 "repository_selection": "rs", 10311 "events": [ 10312 "e" 10313 ], 10314 "single_file_paths": [ 10315 "s" 10316 ], 10317 "permissions": { 10318 "actions": "a", 10319 "administration": "ad", 10320 "checks": "c", 10321 "contents": "co", 10322 "content_references": "cr", 10323 "deployments": "d", 10324 "environments": "e", 10325 "issues": "i", 10326 "metadata": "md", 10327 "members": "m", 10328 "organization_administration": "oa", 10329 "organization_hooks": "oh", 10330 "organization_plan": "op", 10331 "organization_pre_receive_hooks": "opr", 10332 "organization_projects": "op", 10333 "organization_secrets": "os", 10334 "organization_self_hosted_runners": "osh", 10335 "organization_user_blocking": "oub", 10336 "packages": "pkg", 10337 "pages": "pg", 10338 "pull_requests": "pr", 10339 "repository_hooks": "rh", 10340 "repository_projects": "rp", 10341 "repository_pre_receive_hooks": "rprh", 10342 "secrets": "s", 10343 "secret_scanning_alerts": "ssa", 10344 "security_events": "se", 10345 "single_file": "sf", 10346 "statuses": "s", 10347 "team_discussions": "td", 10348 "vulnerability_alerts": "va", 10349 "workflows": "w" 10350 }, 10351 "created_at": ` + referenceTimeStr + `, 10352 "updated_at": ` + referenceTimeStr + `, 10353 "has_multiple_single_files": false, 10354 "suspended_by": { 10355 "login": "l", 10356 "id": 1, 10357 "avatar_url": "a", 10358 "gravatar_id": "g", 10359 "name": "n", 10360 "company": "c", 10361 "blog": "b", 10362 "location": "l", 10363 "email": "e", 10364 "hireable": true, 10365 "bio": "b", 10366 "twitter_username": "t", 10367 "public_repos": 1, 10368 "followers": 1, 10369 "following": 1, 10370 "created_at": ` + referenceTimeStr + `, 10371 "suspended_at": ` + referenceTimeStr + `, 10372 "url": "u" 10373 }, 10374 "suspended_at": ` + referenceTimeStr + ` 10375 } 10376 }` 10377 10378 testJSONMarshal(t, u, want) 10379 } 10380 10381 func TestMembershipEvent_Marshal(t *testing.T) { 10382 t.Parallel() 10383 testJSONMarshal(t, &MembershipEvent{}, "{}") 10384 10385 u := &MembershipEvent{ 10386 Action: Ptr("a"), 10387 Scope: Ptr("s"), 10388 Member: &User{ 10389 Login: Ptr("l"), 10390 ID: Ptr(int64(1)), 10391 NodeID: Ptr("n"), 10392 URL: Ptr("u"), 10393 ReposURL: Ptr("r"), 10394 EventsURL: Ptr("e"), 10395 AvatarURL: Ptr("a"), 10396 }, 10397 Team: &Team{ 10398 ID: Ptr(int64(1)), 10399 NodeID: Ptr("n"), 10400 Name: Ptr("n"), 10401 Description: Ptr("d"), 10402 URL: Ptr("u"), 10403 Slug: Ptr("s"), 10404 Permission: Ptr("p"), 10405 Privacy: Ptr("p"), 10406 MembersCount: Ptr(1), 10407 ReposCount: Ptr(1), 10408 MembersURL: Ptr("m"), 10409 RepositoriesURL: Ptr("r"), 10410 Organization: &Organization{ 10411 Login: Ptr("l"), 10412 ID: Ptr(int64(1)), 10413 NodeID: Ptr("n"), 10414 AvatarURL: Ptr("a"), 10415 HTMLURL: Ptr("h"), 10416 Name: Ptr("n"), 10417 Company: Ptr("c"), 10418 Blog: Ptr("b"), 10419 Location: Ptr("l"), 10420 Email: Ptr("e"), 10421 }, 10422 Parent: &Team{ 10423 ID: Ptr(int64(1)), 10424 NodeID: Ptr("n"), 10425 Name: Ptr("n"), 10426 Description: Ptr("d"), 10427 URL: Ptr("u"), 10428 Slug: Ptr("s"), 10429 Permission: Ptr("p"), 10430 Privacy: Ptr("p"), 10431 MembersCount: Ptr(1), 10432 ReposCount: Ptr(1), 10433 }, 10434 LDAPDN: Ptr("l"), 10435 }, 10436 Org: &Organization{ 10437 BillingEmail: Ptr("be"), 10438 Blog: Ptr("b"), 10439 Company: Ptr("c"), 10440 Email: Ptr("e"), 10441 TwitterUsername: Ptr("tu"), 10442 Location: Ptr("loc"), 10443 Name: Ptr("n"), 10444 Description: Ptr("d"), 10445 IsVerified: Ptr(true), 10446 HasOrganizationProjects: Ptr(true), 10447 HasRepositoryProjects: Ptr(true), 10448 DefaultRepoPermission: Ptr("drp"), 10449 MembersCanCreateRepos: Ptr(true), 10450 MembersCanCreateInternalRepos: Ptr(true), 10451 MembersCanCreatePrivateRepos: Ptr(true), 10452 MembersCanCreatePublicRepos: Ptr(false), 10453 MembersAllowedRepositoryCreationType: Ptr("marct"), 10454 MembersCanCreatePages: Ptr(true), 10455 MembersCanCreatePublicPages: Ptr(false), 10456 MembersCanCreatePrivatePages: Ptr(true), 10457 }, 10458 Sender: &User{ 10459 Login: Ptr("l"), 10460 ID: Ptr(int64(1)), 10461 NodeID: Ptr("n"), 10462 URL: Ptr("u"), 10463 ReposURL: Ptr("r"), 10464 EventsURL: Ptr("e"), 10465 AvatarURL: Ptr("a"), 10466 }, 10467 Installation: &Installation{ 10468 ID: Ptr(int64(1)), 10469 NodeID: Ptr("nid"), 10470 AppID: Ptr(int64(1)), 10471 AppSlug: Ptr("as"), 10472 TargetID: Ptr(int64(1)), 10473 Account: &User{ 10474 Login: Ptr("l"), 10475 ID: Ptr(int64(1)), 10476 URL: Ptr("u"), 10477 AvatarURL: Ptr("a"), 10478 GravatarID: Ptr("g"), 10479 Name: Ptr("n"), 10480 Company: Ptr("c"), 10481 Blog: Ptr("b"), 10482 Location: Ptr("l"), 10483 Email: Ptr("e"), 10484 Hireable: Ptr(true), 10485 Bio: Ptr("b"), 10486 TwitterUsername: Ptr("t"), 10487 PublicRepos: Ptr(1), 10488 Followers: Ptr(1), 10489 Following: Ptr(1), 10490 CreatedAt: &Timestamp{referenceTime}, 10491 SuspendedAt: &Timestamp{referenceTime}, 10492 }, 10493 AccessTokensURL: Ptr("atu"), 10494 RepositoriesURL: Ptr("ru"), 10495 HTMLURL: Ptr("hu"), 10496 TargetType: Ptr("tt"), 10497 SingleFileName: Ptr("sfn"), 10498 RepositorySelection: Ptr("rs"), 10499 Events: []string{"e"}, 10500 SingleFilePaths: []string{"s"}, 10501 Permissions: &InstallationPermissions{ 10502 Actions: Ptr("a"), 10503 Administration: Ptr("ad"), 10504 Checks: Ptr("c"), 10505 Contents: Ptr("co"), 10506 ContentReferences: Ptr("cr"), 10507 Deployments: Ptr("d"), 10508 Environments: Ptr("e"), 10509 Issues: Ptr("i"), 10510 Metadata: Ptr("md"), 10511 Members: Ptr("m"), 10512 OrganizationAdministration: Ptr("oa"), 10513 OrganizationHooks: Ptr("oh"), 10514 OrganizationPlan: Ptr("op"), 10515 OrganizationPreReceiveHooks: Ptr("opr"), 10516 OrganizationProjects: Ptr("op"), 10517 OrganizationSecrets: Ptr("os"), 10518 OrganizationSelfHostedRunners: Ptr("osh"), 10519 OrganizationUserBlocking: Ptr("oub"), 10520 Packages: Ptr("pkg"), 10521 Pages: Ptr("pg"), 10522 PullRequests: Ptr("pr"), 10523 RepositoryHooks: Ptr("rh"), 10524 RepositoryProjects: Ptr("rp"), 10525 RepositoryPreReceiveHooks: Ptr("rprh"), 10526 Secrets: Ptr("s"), 10527 SecretScanningAlerts: Ptr("ssa"), 10528 SecurityEvents: Ptr("se"), 10529 SingleFile: Ptr("sf"), 10530 Statuses: Ptr("s"), 10531 TeamDiscussions: Ptr("td"), 10532 VulnerabilityAlerts: Ptr("va"), 10533 Workflows: Ptr("w"), 10534 }, 10535 CreatedAt: &Timestamp{referenceTime}, 10536 UpdatedAt: &Timestamp{referenceTime}, 10537 HasMultipleSingleFiles: Ptr(false), 10538 SuspendedBy: &User{ 10539 Login: Ptr("l"), 10540 ID: Ptr(int64(1)), 10541 URL: Ptr("u"), 10542 AvatarURL: Ptr("a"), 10543 GravatarID: Ptr("g"), 10544 Name: Ptr("n"), 10545 Company: Ptr("c"), 10546 Blog: Ptr("b"), 10547 Location: Ptr("l"), 10548 Email: Ptr("e"), 10549 Hireable: Ptr(true), 10550 Bio: Ptr("b"), 10551 TwitterUsername: Ptr("t"), 10552 PublicRepos: Ptr(1), 10553 Followers: Ptr(1), 10554 Following: Ptr(1), 10555 CreatedAt: &Timestamp{referenceTime}, 10556 SuspendedAt: &Timestamp{referenceTime}, 10557 }, 10558 SuspendedAt: &Timestamp{referenceTime}, 10559 }, 10560 } 10561 10562 want := `{ 10563 "action": "a", 10564 "scope": "s", 10565 "member": { 10566 "login": "l", 10567 "id": 1, 10568 "node_id": "n", 10569 "avatar_url": "a", 10570 "url": "u", 10571 "events_url": "e", 10572 "repos_url": "r" 10573 }, 10574 "team": { 10575 "id": 1, 10576 "node_id": "n", 10577 "name": "n", 10578 "description": "d", 10579 "url": "u", 10580 "slug": "s", 10581 "permission": "p", 10582 "privacy": "p", 10583 "members_count": 1, 10584 "repos_count": 1, 10585 "organization": { 10586 "login": "l", 10587 "id": 1, 10588 "node_id": "n", 10589 "avatar_url": "a", 10590 "html_url": "h", 10591 "name": "n", 10592 "company": "c", 10593 "blog": "b", 10594 "location": "l", 10595 "email": "e" 10596 }, 10597 "members_url": "m", 10598 "repositories_url": "r", 10599 "parent": { 10600 "id": 1, 10601 "node_id": "n", 10602 "name": "n", 10603 "description": "d", 10604 "url": "u", 10605 "slug": "s", 10606 "permission": "p", 10607 "privacy": "p", 10608 "members_count": 1, 10609 "repos_count": 1 10610 }, 10611 "ldap_dn": "l" 10612 }, 10613 "organization": { 10614 "name": "n", 10615 "company": "c", 10616 "blog": "b", 10617 "location": "loc", 10618 "email": "e", 10619 "twitter_username": "tu", 10620 "description": "d", 10621 "billing_email": "be", 10622 "is_verified": true, 10623 "has_organization_projects": true, 10624 "has_repository_projects": true, 10625 "default_repository_permission": "drp", 10626 "members_can_create_repositories": true, 10627 "members_can_create_public_repositories": false, 10628 "members_can_create_private_repositories": true, 10629 "members_can_create_internal_repositories": true, 10630 "members_allowed_repository_creation_type": "marct", 10631 "members_can_create_pages": true, 10632 "members_can_create_public_pages": false, 10633 "members_can_create_private_pages": true 10634 }, 10635 "sender": { 10636 "login": "l", 10637 "id": 1, 10638 "node_id": "n", 10639 "avatar_url": "a", 10640 "url": "u", 10641 "events_url": "e", 10642 "repos_url": "r" 10643 }, 10644 "installation": { 10645 "id": 1, 10646 "node_id": "nid", 10647 "app_id": 1, 10648 "app_slug": "as", 10649 "target_id": 1, 10650 "account": { 10651 "login": "l", 10652 "id": 1, 10653 "avatar_url": "a", 10654 "gravatar_id": "g", 10655 "name": "n", 10656 "company": "c", 10657 "blog": "b", 10658 "location": "l", 10659 "email": "e", 10660 "hireable": true, 10661 "bio": "b", 10662 "twitter_username": "t", 10663 "public_repos": 1, 10664 "followers": 1, 10665 "following": 1, 10666 "created_at": ` + referenceTimeStr + `, 10667 "suspended_at": ` + referenceTimeStr + `, 10668 "url": "u" 10669 }, 10670 "access_tokens_url": "atu", 10671 "repositories_url": "ru", 10672 "html_url": "hu", 10673 "target_type": "tt", 10674 "single_file_name": "sfn", 10675 "repository_selection": "rs", 10676 "events": [ 10677 "e" 10678 ], 10679 "single_file_paths": [ 10680 "s" 10681 ], 10682 "permissions": { 10683 "actions": "a", 10684 "administration": "ad", 10685 "checks": "c", 10686 "contents": "co", 10687 "content_references": "cr", 10688 "deployments": "d", 10689 "environments": "e", 10690 "issues": "i", 10691 "metadata": "md", 10692 "members": "m", 10693 "organization_administration": "oa", 10694 "organization_hooks": "oh", 10695 "organization_plan": "op", 10696 "organization_pre_receive_hooks": "opr", 10697 "organization_projects": "op", 10698 "organization_secrets": "os", 10699 "organization_self_hosted_runners": "osh", 10700 "organization_user_blocking": "oub", 10701 "packages": "pkg", 10702 "pages": "pg", 10703 "pull_requests": "pr", 10704 "repository_hooks": "rh", 10705 "repository_projects": "rp", 10706 "repository_pre_receive_hooks": "rprh", 10707 "secrets": "s", 10708 "secret_scanning_alerts": "ssa", 10709 "security_events": "se", 10710 "single_file": "sf", 10711 "statuses": "s", 10712 "team_discussions": "td", 10713 "vulnerability_alerts": "va", 10714 "workflows": "w" 10715 }, 10716 "created_at": ` + referenceTimeStr + `, 10717 "updated_at": ` + referenceTimeStr + `, 10718 "has_multiple_single_files": false, 10719 "suspended_by": { 10720 "login": "l", 10721 "id": 1, 10722 "avatar_url": "a", 10723 "gravatar_id": "g", 10724 "name": "n", 10725 "company": "c", 10726 "blog": "b", 10727 "location": "l", 10728 "email": "e", 10729 "hireable": true, 10730 "bio": "b", 10731 "twitter_username": "t", 10732 "public_repos": 1, 10733 "followers": 1, 10734 "following": 1, 10735 "created_at": ` + referenceTimeStr + `, 10736 "suspended_at": ` + referenceTimeStr + `, 10737 "url": "u" 10738 }, 10739 "suspended_at": ` + referenceTimeStr + ` 10740 } 10741 }` 10742 10743 testJSONMarshal(t, u, want) 10744 } 10745 10746 func TestMergeGroupEvent_Marshal(t *testing.T) { 10747 t.Parallel() 10748 testJSONMarshal(t, &MergeGroupEvent{}, "{}") 10749 10750 u := &MergeGroupEvent{ 10751 Action: Ptr("a"), 10752 Reason: Ptr("r"), 10753 MergeGroup: &MergeGroup{ 10754 HeadSHA: Ptr("hs"), 10755 HeadRef: Ptr("hr"), 10756 BaseSHA: Ptr("bs"), 10757 BaseRef: Ptr("br"), 10758 HeadCommit: &Commit{NodeID: Ptr("nid")}, 10759 }, 10760 Repo: &Repository{ 10761 ID: Ptr(int64(1)), 10762 URL: Ptr("s"), 10763 Name: Ptr("n"), 10764 }, 10765 Org: &Organization{ 10766 BillingEmail: Ptr("be"), 10767 Blog: Ptr("b"), 10768 Company: Ptr("c"), 10769 Email: Ptr("e"), 10770 TwitterUsername: Ptr("tu"), 10771 Location: Ptr("loc"), 10772 Name: Ptr("n"), 10773 Description: Ptr("d"), 10774 IsVerified: Ptr(true), 10775 HasOrganizationProjects: Ptr(true), 10776 HasRepositoryProjects: Ptr(true), 10777 DefaultRepoPermission: Ptr("drp"), 10778 MembersCanCreateRepos: Ptr(true), 10779 MembersCanCreateInternalRepos: Ptr(true), 10780 MembersCanCreatePrivateRepos: Ptr(true), 10781 MembersCanCreatePublicRepos: Ptr(false), 10782 MembersAllowedRepositoryCreationType: Ptr("marct"), 10783 MembersCanCreatePages: Ptr(true), 10784 MembersCanCreatePublicPages: Ptr(false), 10785 MembersCanCreatePrivatePages: Ptr(true), 10786 }, 10787 Sender: &User{ 10788 Login: Ptr("l"), 10789 ID: Ptr(int64(1)), 10790 NodeID: Ptr("n"), 10791 URL: Ptr("u"), 10792 ReposURL: Ptr("r"), 10793 EventsURL: Ptr("e"), 10794 AvatarURL: Ptr("a"), 10795 }, 10796 Installation: &Installation{ 10797 ID: Ptr(int64(1)), 10798 NodeID: Ptr("nid"), 10799 AppID: Ptr(int64(1)), 10800 AppSlug: Ptr("as"), 10801 TargetID: Ptr(int64(1)), 10802 Account: &User{ 10803 Login: Ptr("l"), 10804 ID: Ptr(int64(1)), 10805 URL: Ptr("u"), 10806 AvatarURL: Ptr("a"), 10807 GravatarID: Ptr("g"), 10808 Name: Ptr("n"), 10809 Company: Ptr("c"), 10810 Blog: Ptr("b"), 10811 Location: Ptr("l"), 10812 Email: Ptr("e"), 10813 Hireable: Ptr(true), 10814 Bio: Ptr("b"), 10815 TwitterUsername: Ptr("t"), 10816 PublicRepos: Ptr(1), 10817 Followers: Ptr(1), 10818 Following: Ptr(1), 10819 CreatedAt: &Timestamp{referenceTime}, 10820 SuspendedAt: &Timestamp{referenceTime}, 10821 }, 10822 AccessTokensURL: Ptr("atu"), 10823 RepositoriesURL: Ptr("ru"), 10824 HTMLURL: Ptr("hu"), 10825 TargetType: Ptr("tt"), 10826 SingleFileName: Ptr("sfn"), 10827 RepositorySelection: Ptr("rs"), 10828 Events: []string{"e"}, 10829 SingleFilePaths: []string{"s"}, 10830 Permissions: &InstallationPermissions{ 10831 Actions: Ptr("a"), 10832 Administration: Ptr("ad"), 10833 Checks: Ptr("c"), 10834 Contents: Ptr("co"), 10835 ContentReferences: Ptr("cr"), 10836 Deployments: Ptr("d"), 10837 Environments: Ptr("e"), 10838 Issues: Ptr("i"), 10839 Metadata: Ptr("md"), 10840 Members: Ptr("m"), 10841 OrganizationAdministration: Ptr("oa"), 10842 OrganizationHooks: Ptr("oh"), 10843 OrganizationPlan: Ptr("op"), 10844 OrganizationPreReceiveHooks: Ptr("opr"), 10845 OrganizationProjects: Ptr("op"), 10846 OrganizationSecrets: Ptr("os"), 10847 OrganizationSelfHostedRunners: Ptr("osh"), 10848 OrganizationUserBlocking: Ptr("oub"), 10849 Packages: Ptr("pkg"), 10850 Pages: Ptr("pg"), 10851 PullRequests: Ptr("pr"), 10852 RepositoryHooks: Ptr("rh"), 10853 RepositoryProjects: Ptr("rp"), 10854 RepositoryPreReceiveHooks: Ptr("rprh"), 10855 Secrets: Ptr("s"), 10856 SecretScanningAlerts: Ptr("ssa"), 10857 SecurityEvents: Ptr("se"), 10858 SingleFile: Ptr("sf"), 10859 Statuses: Ptr("s"), 10860 TeamDiscussions: Ptr("td"), 10861 VulnerabilityAlerts: Ptr("va"), 10862 Workflows: Ptr("w"), 10863 }, 10864 CreatedAt: &Timestamp{referenceTime}, 10865 UpdatedAt: &Timestamp{referenceTime}, 10866 HasMultipleSingleFiles: Ptr(false), 10867 SuspendedBy: &User{ 10868 Login: Ptr("l"), 10869 ID: Ptr(int64(1)), 10870 URL: Ptr("u"), 10871 AvatarURL: Ptr("a"), 10872 GravatarID: Ptr("g"), 10873 Name: Ptr("n"), 10874 Company: Ptr("c"), 10875 Blog: Ptr("b"), 10876 Location: Ptr("l"), 10877 Email: Ptr("e"), 10878 Hireable: Ptr(true), 10879 Bio: Ptr("b"), 10880 TwitterUsername: Ptr("t"), 10881 PublicRepos: Ptr(1), 10882 Followers: Ptr(1), 10883 Following: Ptr(1), 10884 CreatedAt: &Timestamp{referenceTime}, 10885 SuspendedAt: &Timestamp{referenceTime}, 10886 }, 10887 SuspendedAt: &Timestamp{referenceTime}, 10888 }, 10889 } 10890 10891 want := `{ 10892 "action": "a", 10893 "reason": "r", 10894 "merge_group": { 10895 "head_sha": "hs", 10896 "head_ref": "hr", 10897 "base_sha": "bs", 10898 "base_ref": "br", 10899 "head_commit": { 10900 "node_id": "nid" 10901 } 10902 }, 10903 "repository": { 10904 "id": 1, 10905 "name": "n", 10906 "url": "s" 10907 }, 10908 "organization": { 10909 "name": "n", 10910 "company": "c", 10911 "blog": "b", 10912 "location": "loc", 10913 "email": "e", 10914 "twitter_username": "tu", 10915 "description": "d", 10916 "billing_email": "be", 10917 "is_verified": true, 10918 "has_organization_projects": true, 10919 "has_repository_projects": true, 10920 "default_repository_permission": "drp", 10921 "members_can_create_repositories": true, 10922 "members_can_create_public_repositories": false, 10923 "members_can_create_private_repositories": true, 10924 "members_can_create_internal_repositories": true, 10925 "members_allowed_repository_creation_type": "marct", 10926 "members_can_create_pages": true, 10927 "members_can_create_public_pages": false, 10928 "members_can_create_private_pages": true 10929 }, 10930 "sender": { 10931 "login": "l", 10932 "id": 1, 10933 "node_id": "n", 10934 "avatar_url": "a", 10935 "url": "u", 10936 "events_url": "e", 10937 "repos_url": "r" 10938 }, 10939 "installation": { 10940 "id": 1, 10941 "node_id": "nid", 10942 "app_id": 1, 10943 "app_slug": "as", 10944 "target_id": 1, 10945 "account": { 10946 "login": "l", 10947 "id": 1, 10948 "avatar_url": "a", 10949 "gravatar_id": "g", 10950 "name": "n", 10951 "company": "c", 10952 "blog": "b", 10953 "location": "l", 10954 "email": "e", 10955 "hireable": true, 10956 "bio": "b", 10957 "twitter_username": "t", 10958 "public_repos": 1, 10959 "followers": 1, 10960 "following": 1, 10961 "created_at": ` + referenceTimeStr + `, 10962 "suspended_at": ` + referenceTimeStr + `, 10963 "url": "u" 10964 }, 10965 "access_tokens_url": "atu", 10966 "repositories_url": "ru", 10967 "html_url": "hu", 10968 "target_type": "tt", 10969 "single_file_name": "sfn", 10970 "repository_selection": "rs", 10971 "events": [ 10972 "e" 10973 ], 10974 "single_file_paths": [ 10975 "s" 10976 ], 10977 "permissions": { 10978 "actions": "a", 10979 "administration": "ad", 10980 "checks": "c", 10981 "contents": "co", 10982 "content_references": "cr", 10983 "deployments": "d", 10984 "environments": "e", 10985 "issues": "i", 10986 "metadata": "md", 10987 "members": "m", 10988 "organization_administration": "oa", 10989 "organization_hooks": "oh", 10990 "organization_plan": "op", 10991 "organization_pre_receive_hooks": "opr", 10992 "organization_projects": "op", 10993 "organization_secrets": "os", 10994 "organization_self_hosted_runners": "osh", 10995 "organization_user_blocking": "oub", 10996 "packages": "pkg", 10997 "pages": "pg", 10998 "pull_requests": "pr", 10999 "repository_hooks": "rh", 11000 "repository_projects": "rp", 11001 "repository_pre_receive_hooks": "rprh", 11002 "secrets": "s", 11003 "secret_scanning_alerts": "ssa", 11004 "security_events": "se", 11005 "single_file": "sf", 11006 "statuses": "s", 11007 "team_discussions": "td", 11008 "vulnerability_alerts": "va", 11009 "workflows": "w" 11010 }, 11011 "created_at": ` + referenceTimeStr + `, 11012 "updated_at": ` + referenceTimeStr + `, 11013 "has_multiple_single_files": false, 11014 "suspended_by": { 11015 "login": "l", 11016 "id": 1, 11017 "avatar_url": "a", 11018 "gravatar_id": "g", 11019 "name": "n", 11020 "company": "c", 11021 "blog": "b", 11022 "location": "l", 11023 "email": "e", 11024 "hireable": true, 11025 "bio": "b", 11026 "twitter_username": "t", 11027 "public_repos": 1, 11028 "followers": 1, 11029 "following": 1, 11030 "created_at": ` + referenceTimeStr + `, 11031 "suspended_at": ` + referenceTimeStr + `, 11032 "url": "u" 11033 }, 11034 "suspended_at": ` + referenceTimeStr + ` 11035 } 11036 }` 11037 11038 testJSONMarshal(t, u, want) 11039 } 11040 11041 func TestOrgBlockEvent_Marshal(t *testing.T) { 11042 t.Parallel() 11043 testJSONMarshal(t, &OrgBlockEvent{}, "{}") 11044 11045 u := &OrgBlockEvent{ 11046 Action: Ptr("a"), 11047 BlockedUser: &User{ 11048 Login: Ptr("l"), 11049 ID: Ptr(int64(1)), 11050 NodeID: Ptr("n"), 11051 URL: Ptr("u"), 11052 ReposURL: Ptr("r"), 11053 EventsURL: Ptr("e"), 11054 AvatarURL: Ptr("a"), 11055 }, 11056 Organization: &Organization{ 11057 BillingEmail: Ptr("be"), 11058 Blog: Ptr("b"), 11059 Company: Ptr("c"), 11060 Email: Ptr("e"), 11061 TwitterUsername: Ptr("tu"), 11062 Location: Ptr("loc"), 11063 Name: Ptr("n"), 11064 Description: Ptr("d"), 11065 IsVerified: Ptr(true), 11066 HasOrganizationProjects: Ptr(true), 11067 HasRepositoryProjects: Ptr(true), 11068 DefaultRepoPermission: Ptr("drp"), 11069 MembersCanCreateRepos: Ptr(true), 11070 MembersCanCreateInternalRepos: Ptr(true), 11071 MembersCanCreatePrivateRepos: Ptr(true), 11072 MembersCanCreatePublicRepos: Ptr(false), 11073 MembersAllowedRepositoryCreationType: Ptr("marct"), 11074 MembersCanCreatePages: Ptr(true), 11075 MembersCanCreatePublicPages: Ptr(false), 11076 MembersCanCreatePrivatePages: Ptr(true), 11077 }, 11078 Sender: &User{ 11079 Login: Ptr("l"), 11080 ID: Ptr(int64(1)), 11081 NodeID: Ptr("n"), 11082 URL: Ptr("u"), 11083 ReposURL: Ptr("r"), 11084 EventsURL: Ptr("e"), 11085 AvatarURL: Ptr("a"), 11086 }, 11087 Installation: &Installation{ 11088 ID: Ptr(int64(1)), 11089 NodeID: Ptr("nid"), 11090 AppID: Ptr(int64(1)), 11091 AppSlug: Ptr("as"), 11092 TargetID: Ptr(int64(1)), 11093 Account: &User{ 11094 Login: Ptr("l"), 11095 ID: Ptr(int64(1)), 11096 URL: Ptr("u"), 11097 AvatarURL: Ptr("a"), 11098 GravatarID: Ptr("g"), 11099 Name: Ptr("n"), 11100 Company: Ptr("c"), 11101 Blog: Ptr("b"), 11102 Location: Ptr("l"), 11103 Email: Ptr("e"), 11104 Hireable: Ptr(true), 11105 Bio: Ptr("b"), 11106 TwitterUsername: Ptr("t"), 11107 PublicRepos: Ptr(1), 11108 Followers: Ptr(1), 11109 Following: Ptr(1), 11110 CreatedAt: &Timestamp{referenceTime}, 11111 SuspendedAt: &Timestamp{referenceTime}, 11112 }, 11113 AccessTokensURL: Ptr("atu"), 11114 RepositoriesURL: Ptr("ru"), 11115 HTMLURL: Ptr("hu"), 11116 TargetType: Ptr("tt"), 11117 SingleFileName: Ptr("sfn"), 11118 RepositorySelection: Ptr("rs"), 11119 Events: []string{"e"}, 11120 SingleFilePaths: []string{"s"}, 11121 Permissions: &InstallationPermissions{ 11122 Actions: Ptr("a"), 11123 Administration: Ptr("ad"), 11124 Checks: Ptr("c"), 11125 Contents: Ptr("co"), 11126 ContentReferences: Ptr("cr"), 11127 Deployments: Ptr("d"), 11128 Environments: Ptr("e"), 11129 Issues: Ptr("i"), 11130 Metadata: Ptr("md"), 11131 Members: Ptr("m"), 11132 OrganizationAdministration: Ptr("oa"), 11133 OrganizationHooks: Ptr("oh"), 11134 OrganizationPlan: Ptr("op"), 11135 OrganizationPreReceiveHooks: Ptr("opr"), 11136 OrganizationProjects: Ptr("op"), 11137 OrganizationSecrets: Ptr("os"), 11138 OrganizationSelfHostedRunners: Ptr("osh"), 11139 OrganizationUserBlocking: Ptr("oub"), 11140 Packages: Ptr("pkg"), 11141 Pages: Ptr("pg"), 11142 PullRequests: Ptr("pr"), 11143 RepositoryHooks: Ptr("rh"), 11144 RepositoryProjects: Ptr("rp"), 11145 RepositoryPreReceiveHooks: Ptr("rprh"), 11146 Secrets: Ptr("s"), 11147 SecretScanningAlerts: Ptr("ssa"), 11148 SecurityEvents: Ptr("se"), 11149 SingleFile: Ptr("sf"), 11150 Statuses: Ptr("s"), 11151 TeamDiscussions: Ptr("td"), 11152 VulnerabilityAlerts: Ptr("va"), 11153 Workflows: Ptr("w"), 11154 }, 11155 CreatedAt: &Timestamp{referenceTime}, 11156 UpdatedAt: &Timestamp{referenceTime}, 11157 HasMultipleSingleFiles: Ptr(false), 11158 SuspendedBy: &User{ 11159 Login: Ptr("l"), 11160 ID: Ptr(int64(1)), 11161 URL: Ptr("u"), 11162 AvatarURL: Ptr("a"), 11163 GravatarID: Ptr("g"), 11164 Name: Ptr("n"), 11165 Company: Ptr("c"), 11166 Blog: Ptr("b"), 11167 Location: Ptr("l"), 11168 Email: Ptr("e"), 11169 Hireable: Ptr(true), 11170 Bio: Ptr("b"), 11171 TwitterUsername: Ptr("t"), 11172 PublicRepos: Ptr(1), 11173 Followers: Ptr(1), 11174 Following: Ptr(1), 11175 CreatedAt: &Timestamp{referenceTime}, 11176 SuspendedAt: &Timestamp{referenceTime}, 11177 }, 11178 SuspendedAt: &Timestamp{referenceTime}, 11179 }, 11180 } 11181 11182 want := `{ 11183 "action": "a", 11184 "blocked_user": { 11185 "login": "l", 11186 "id": 1, 11187 "node_id": "n", 11188 "avatar_url": "a", 11189 "url": "u", 11190 "events_url": "e", 11191 "repos_url": "r" 11192 }, 11193 "organization": { 11194 "name": "n", 11195 "company": "c", 11196 "blog": "b", 11197 "location": "loc", 11198 "email": "e", 11199 "twitter_username": "tu", 11200 "description": "d", 11201 "billing_email": "be", 11202 "is_verified": true, 11203 "has_organization_projects": true, 11204 "has_repository_projects": true, 11205 "default_repository_permission": "drp", 11206 "members_can_create_repositories": true, 11207 "members_can_create_public_repositories": false, 11208 "members_can_create_private_repositories": true, 11209 "members_can_create_internal_repositories": true, 11210 "members_allowed_repository_creation_type": "marct", 11211 "members_can_create_pages": true, 11212 "members_can_create_public_pages": false, 11213 "members_can_create_private_pages": true 11214 }, 11215 "sender": { 11216 "login": "l", 11217 "id": 1, 11218 "node_id": "n", 11219 "avatar_url": "a", 11220 "url": "u", 11221 "events_url": "e", 11222 "repos_url": "r" 11223 }, 11224 "installation": { 11225 "id": 1, 11226 "node_id": "nid", 11227 "app_id": 1, 11228 "app_slug": "as", 11229 "target_id": 1, 11230 "account": { 11231 "login": "l", 11232 "id": 1, 11233 "avatar_url": "a", 11234 "gravatar_id": "g", 11235 "name": "n", 11236 "company": "c", 11237 "blog": "b", 11238 "location": "l", 11239 "email": "e", 11240 "hireable": true, 11241 "bio": "b", 11242 "twitter_username": "t", 11243 "public_repos": 1, 11244 "followers": 1, 11245 "following": 1, 11246 "created_at": ` + referenceTimeStr + `, 11247 "suspended_at": ` + referenceTimeStr + `, 11248 "url": "u" 11249 }, 11250 "access_tokens_url": "atu", 11251 "repositories_url": "ru", 11252 "html_url": "hu", 11253 "target_type": "tt", 11254 "single_file_name": "sfn", 11255 "repository_selection": "rs", 11256 "events": [ 11257 "e" 11258 ], 11259 "single_file_paths": [ 11260 "s" 11261 ], 11262 "permissions": { 11263 "actions": "a", 11264 "administration": "ad", 11265 "checks": "c", 11266 "contents": "co", 11267 "content_references": "cr", 11268 "deployments": "d", 11269 "environments": "e", 11270 "issues": "i", 11271 "metadata": "md", 11272 "members": "m", 11273 "organization_administration": "oa", 11274 "organization_hooks": "oh", 11275 "organization_plan": "op", 11276 "organization_pre_receive_hooks": "opr", 11277 "organization_projects": "op", 11278 "organization_secrets": "os", 11279 "organization_self_hosted_runners": "osh", 11280 "organization_user_blocking": "oub", 11281 "packages": "pkg", 11282 "pages": "pg", 11283 "pull_requests": "pr", 11284 "repository_hooks": "rh", 11285 "repository_projects": "rp", 11286 "repository_pre_receive_hooks": "rprh", 11287 "secrets": "s", 11288 "secret_scanning_alerts": "ssa", 11289 "security_events": "se", 11290 "single_file": "sf", 11291 "statuses": "s", 11292 "team_discussions": "td", 11293 "vulnerability_alerts": "va", 11294 "workflows": "w" 11295 }, 11296 "created_at": ` + referenceTimeStr + `, 11297 "updated_at": ` + referenceTimeStr + `, 11298 "has_multiple_single_files": false, 11299 "suspended_by": { 11300 "login": "l", 11301 "id": 1, 11302 "avatar_url": "a", 11303 "gravatar_id": "g", 11304 "name": "n", 11305 "company": "c", 11306 "blog": "b", 11307 "location": "l", 11308 "email": "e", 11309 "hireable": true, 11310 "bio": "b", 11311 "twitter_username": "t", 11312 "public_repos": 1, 11313 "followers": 1, 11314 "following": 1, 11315 "created_at": ` + referenceTimeStr + `, 11316 "suspended_at": ` + referenceTimeStr + `, 11317 "url": "u" 11318 }, 11319 "suspended_at": ` + referenceTimeStr + ` 11320 } 11321 }` 11322 11323 testJSONMarshal(t, u, want) 11324 } 11325 11326 func TestGollumEvent_Marshal(t *testing.T) { 11327 t.Parallel() 11328 testJSONMarshal(t, &GollumEvent{}, "{}") 11329 11330 u := &GollumEvent{ 11331 Pages: []*Page{ 11332 { 11333 PageName: Ptr("pn"), 11334 Title: Ptr("t"), 11335 Summary: Ptr("s"), 11336 Action: Ptr("a"), 11337 SHA: Ptr("sha"), 11338 HTMLURL: Ptr("hu"), 11339 }, 11340 }, 11341 Repo: &Repository{ 11342 ID: Ptr(int64(1)), 11343 URL: Ptr("s"), 11344 Name: Ptr("n"), 11345 }, 11346 Sender: &User{ 11347 Login: Ptr("l"), 11348 ID: Ptr(int64(1)), 11349 NodeID: Ptr("n"), 11350 URL: Ptr("u"), 11351 ReposURL: Ptr("r"), 11352 EventsURL: Ptr("e"), 11353 AvatarURL: Ptr("a"), 11354 }, 11355 Installation: &Installation{ 11356 ID: Ptr(int64(1)), 11357 NodeID: Ptr("nid"), 11358 AppID: Ptr(int64(1)), 11359 AppSlug: Ptr("as"), 11360 TargetID: Ptr(int64(1)), 11361 Account: &User{ 11362 Login: Ptr("l"), 11363 ID: Ptr(int64(1)), 11364 URL: Ptr("u"), 11365 AvatarURL: Ptr("a"), 11366 GravatarID: Ptr("g"), 11367 Name: Ptr("n"), 11368 Company: Ptr("c"), 11369 Blog: Ptr("b"), 11370 Location: Ptr("l"), 11371 Email: Ptr("e"), 11372 Hireable: Ptr(true), 11373 Bio: Ptr("b"), 11374 TwitterUsername: Ptr("t"), 11375 PublicRepos: Ptr(1), 11376 Followers: Ptr(1), 11377 Following: Ptr(1), 11378 CreatedAt: &Timestamp{referenceTime}, 11379 SuspendedAt: &Timestamp{referenceTime}, 11380 }, 11381 AccessTokensURL: Ptr("atu"), 11382 RepositoriesURL: Ptr("ru"), 11383 HTMLURL: Ptr("hu"), 11384 TargetType: Ptr("tt"), 11385 SingleFileName: Ptr("sfn"), 11386 RepositorySelection: Ptr("rs"), 11387 Events: []string{"e"}, 11388 SingleFilePaths: []string{"s"}, 11389 Permissions: &InstallationPermissions{ 11390 Actions: Ptr("a"), 11391 Administration: Ptr("ad"), 11392 Checks: Ptr("c"), 11393 Contents: Ptr("co"), 11394 ContentReferences: Ptr("cr"), 11395 Deployments: Ptr("d"), 11396 Environments: Ptr("e"), 11397 Issues: Ptr("i"), 11398 Metadata: Ptr("md"), 11399 Members: Ptr("m"), 11400 OrganizationAdministration: Ptr("oa"), 11401 OrganizationHooks: Ptr("oh"), 11402 OrganizationPlan: Ptr("op"), 11403 OrganizationPreReceiveHooks: Ptr("opr"), 11404 OrganizationProjects: Ptr("op"), 11405 OrganizationSecrets: Ptr("os"), 11406 OrganizationSelfHostedRunners: Ptr("osh"), 11407 OrganizationUserBlocking: Ptr("oub"), 11408 Packages: Ptr("pkg"), 11409 Pages: Ptr("pg"), 11410 PullRequests: Ptr("pr"), 11411 RepositoryHooks: Ptr("rh"), 11412 RepositoryProjects: Ptr("rp"), 11413 RepositoryPreReceiveHooks: Ptr("rprh"), 11414 Secrets: Ptr("s"), 11415 SecretScanningAlerts: Ptr("ssa"), 11416 SecurityEvents: Ptr("se"), 11417 SingleFile: Ptr("sf"), 11418 Statuses: Ptr("s"), 11419 TeamDiscussions: Ptr("td"), 11420 VulnerabilityAlerts: Ptr("va"), 11421 Workflows: Ptr("w"), 11422 }, 11423 CreatedAt: &Timestamp{referenceTime}, 11424 UpdatedAt: &Timestamp{referenceTime}, 11425 HasMultipleSingleFiles: Ptr(false), 11426 SuspendedBy: &User{ 11427 Login: Ptr("l"), 11428 ID: Ptr(int64(1)), 11429 URL: Ptr("u"), 11430 AvatarURL: Ptr("a"), 11431 GravatarID: Ptr("g"), 11432 Name: Ptr("n"), 11433 Company: Ptr("c"), 11434 Blog: Ptr("b"), 11435 Location: Ptr("l"), 11436 Email: Ptr("e"), 11437 Hireable: Ptr(true), 11438 Bio: Ptr("b"), 11439 TwitterUsername: Ptr("t"), 11440 PublicRepos: Ptr(1), 11441 Followers: Ptr(1), 11442 Following: Ptr(1), 11443 CreatedAt: &Timestamp{referenceTime}, 11444 SuspendedAt: &Timestamp{referenceTime}, 11445 }, 11446 SuspendedAt: &Timestamp{referenceTime}, 11447 }, 11448 } 11449 11450 want := `{ 11451 "pages": [ 11452 { 11453 "page_name": "pn", 11454 "title": "t", 11455 "summary": "s", 11456 "action": "a", 11457 "sha": "sha", 11458 "html_url": "hu" 11459 } 11460 ], 11461 "repository": { 11462 "id": 1, 11463 "name": "n", 11464 "url": "s" 11465 }, 11466 "sender": { 11467 "login": "l", 11468 "id": 1, 11469 "node_id": "n", 11470 "avatar_url": "a", 11471 "url": "u", 11472 "events_url": "e", 11473 "repos_url": "r" 11474 }, 11475 "installation": { 11476 "id": 1, 11477 "node_id": "nid", 11478 "app_id": 1, 11479 "app_slug": "as", 11480 "target_id": 1, 11481 "account": { 11482 "login": "l", 11483 "id": 1, 11484 "avatar_url": "a", 11485 "gravatar_id": "g", 11486 "name": "n", 11487 "company": "c", 11488 "blog": "b", 11489 "location": "l", 11490 "email": "e", 11491 "hireable": true, 11492 "bio": "b", 11493 "twitter_username": "t", 11494 "public_repos": 1, 11495 "followers": 1, 11496 "following": 1, 11497 "created_at": ` + referenceTimeStr + `, 11498 "suspended_at": ` + referenceTimeStr + `, 11499 "url": "u" 11500 }, 11501 "access_tokens_url": "atu", 11502 "repositories_url": "ru", 11503 "html_url": "hu", 11504 "target_type": "tt", 11505 "single_file_name": "sfn", 11506 "repository_selection": "rs", 11507 "events": [ 11508 "e" 11509 ], 11510 "single_file_paths": [ 11511 "s" 11512 ], 11513 "permissions": { 11514 "actions": "a", 11515 "administration": "ad", 11516 "checks": "c", 11517 "contents": "co", 11518 "content_references": "cr", 11519 "deployments": "d", 11520 "environments": "e", 11521 "issues": "i", 11522 "metadata": "md", 11523 "members": "m", 11524 "organization_administration": "oa", 11525 "organization_hooks": "oh", 11526 "organization_plan": "op", 11527 "organization_pre_receive_hooks": "opr", 11528 "organization_projects": "op", 11529 "organization_secrets": "os", 11530 "organization_self_hosted_runners": "osh", 11531 "organization_user_blocking": "oub", 11532 "packages": "pkg", 11533 "pages": "pg", 11534 "pull_requests": "pr", 11535 "repository_hooks": "rh", 11536 "repository_projects": "rp", 11537 "repository_pre_receive_hooks": "rprh", 11538 "secrets": "s", 11539 "secret_scanning_alerts": "ssa", 11540 "security_events": "se", 11541 "single_file": "sf", 11542 "statuses": "s", 11543 "team_discussions": "td", 11544 "vulnerability_alerts": "va", 11545 "workflows": "w" 11546 }, 11547 "created_at": ` + referenceTimeStr + `, 11548 "updated_at": ` + referenceTimeStr + `, 11549 "has_multiple_single_files": false, 11550 "suspended_by": { 11551 "login": "l", 11552 "id": 1, 11553 "avatar_url": "a", 11554 "gravatar_id": "g", 11555 "name": "n", 11556 "company": "c", 11557 "blog": "b", 11558 "location": "l", 11559 "email": "e", 11560 "hireable": true, 11561 "bio": "b", 11562 "twitter_username": "t", 11563 "public_repos": 1, 11564 "followers": 1, 11565 "following": 1, 11566 "created_at": ` + referenceTimeStr + `, 11567 "suspended_at": ` + referenceTimeStr + `, 11568 "url": "u" 11569 }, 11570 "suspended_at": ` + referenceTimeStr + ` 11571 } 11572 }` 11573 11574 testJSONMarshal(t, u, want) 11575 } 11576 11577 func TestWorkflowRunEvent_Marshal(t *testing.T) { 11578 t.Parallel() 11579 testJSONMarshal(t, &WorkflowRunEvent{}, "{}") 11580 11581 u := &WorkflowRunEvent{ 11582 Action: Ptr("a"), 11583 Workflow: &Workflow{ 11584 ID: Ptr(int64(1)), 11585 NodeID: Ptr("nid"), 11586 Name: Ptr("n"), 11587 Path: Ptr("p"), 11588 State: Ptr("s"), 11589 CreatedAt: &Timestamp{referenceTime}, 11590 UpdatedAt: &Timestamp{referenceTime}, 11591 URL: Ptr("u"), 11592 HTMLURL: Ptr("h"), 11593 BadgeURL: Ptr("b"), 11594 }, 11595 WorkflowRun: &WorkflowRun{ 11596 ID: Ptr(int64(1)), 11597 Name: Ptr("n"), 11598 NodeID: Ptr("nid"), 11599 HeadBranch: Ptr("hb"), 11600 HeadSHA: Ptr("hs"), 11601 RunNumber: Ptr(1), 11602 RunAttempt: Ptr(1), 11603 Event: Ptr("e"), 11604 Status: Ptr("s"), 11605 Conclusion: Ptr("c"), 11606 WorkflowID: Ptr(int64(1)), 11607 URL: Ptr("u"), 11608 HTMLURL: Ptr("h"), 11609 PullRequests: []*PullRequest{ 11610 { 11611 URL: Ptr("u"), 11612 ID: Ptr(int64(1)), 11613 Number: Ptr(1), 11614 Head: &PullRequestBranch{ 11615 Ref: Ptr("r"), 11616 SHA: Ptr("s"), 11617 Repo: &Repository{ 11618 ID: Ptr(int64(1)), 11619 URL: Ptr("s"), 11620 Name: Ptr("n"), 11621 }, 11622 }, 11623 Base: &PullRequestBranch{ 11624 Ref: Ptr("r"), 11625 SHA: Ptr("s"), 11626 Repo: &Repository{ 11627 ID: Ptr(int64(1)), 11628 URL: Ptr("u"), 11629 Name: Ptr("n"), 11630 }, 11631 }, 11632 }, 11633 }, 11634 CreatedAt: &Timestamp{referenceTime}, 11635 UpdatedAt: &Timestamp{referenceTime}, 11636 RunStartedAt: &Timestamp{referenceTime}, 11637 JobsURL: Ptr("j"), 11638 LogsURL: Ptr("l"), 11639 CheckSuiteURL: Ptr("c"), 11640 ArtifactsURL: Ptr("a"), 11641 CancelURL: Ptr("c"), 11642 RerunURL: Ptr("r"), 11643 PreviousAttemptURL: Ptr("p"), 11644 HeadCommit: &HeadCommit{ 11645 Message: Ptr("m"), 11646 Author: &CommitAuthor{ 11647 Name: Ptr("n"), 11648 Email: Ptr("e"), 11649 Login: Ptr("l"), 11650 }, 11651 URL: Ptr("u"), 11652 Distinct: Ptr(false), 11653 SHA: Ptr("s"), 11654 ID: Ptr("i"), 11655 TreeID: Ptr("tid"), 11656 Timestamp: &Timestamp{referenceTime}, 11657 Committer: &CommitAuthor{ 11658 Name: Ptr("n"), 11659 Email: Ptr("e"), 11660 Login: Ptr("l"), 11661 }, 11662 }, 11663 WorkflowURL: Ptr("w"), 11664 Repository: &Repository{ 11665 ID: Ptr(int64(1)), 11666 URL: Ptr("u"), 11667 Name: Ptr("n"), 11668 }, 11669 HeadRepository: &Repository{ 11670 ID: Ptr(int64(1)), 11671 URL: Ptr("u"), 11672 Name: Ptr("n"), 11673 }, 11674 }, 11675 Org: &Organization{ 11676 BillingEmail: Ptr("be"), 11677 Blog: Ptr("b"), 11678 Company: Ptr("c"), 11679 Email: Ptr("e"), 11680 TwitterUsername: Ptr("tu"), 11681 Location: Ptr("loc"), 11682 Name: Ptr("n"), 11683 Description: Ptr("d"), 11684 IsVerified: Ptr(true), 11685 HasOrganizationProjects: Ptr(true), 11686 HasRepositoryProjects: Ptr(true), 11687 DefaultRepoPermission: Ptr("drp"), 11688 MembersCanCreateRepos: Ptr(true), 11689 MembersCanCreateInternalRepos: Ptr(true), 11690 MembersCanCreatePrivateRepos: Ptr(true), 11691 MembersCanCreatePublicRepos: Ptr(false), 11692 MembersAllowedRepositoryCreationType: Ptr("marct"), 11693 MembersCanCreatePages: Ptr(true), 11694 MembersCanCreatePublicPages: Ptr(false), 11695 MembersCanCreatePrivatePages: Ptr(true), 11696 }, 11697 Repo: &Repository{ 11698 ID: Ptr(int64(1)), 11699 URL: Ptr("s"), 11700 Name: Ptr("n"), 11701 }, 11702 Sender: &User{ 11703 Login: Ptr("l"), 11704 ID: Ptr(int64(1)), 11705 NodeID: Ptr("n"), 11706 URL: Ptr("u"), 11707 ReposURL: Ptr("r"), 11708 EventsURL: Ptr("e"), 11709 AvatarURL: Ptr("a"), 11710 }, 11711 } 11712 11713 want := `{ 11714 "action": "a", 11715 "workflow": { 11716 "id": 1, 11717 "node_id": "nid", 11718 "name": "n", 11719 "path": "p", 11720 "state": "s", 11721 "created_at": ` + referenceTimeStr + `, 11722 "updated_at": ` + referenceTimeStr + `, 11723 "url": "u", 11724 "html_url": "h", 11725 "badge_url": "b" 11726 }, 11727 "workflow_run": { 11728 "id": 1, 11729 "name": "n", 11730 "node_id": "nid", 11731 "head_branch": "hb", 11732 "head_sha": "hs", 11733 "run_number": 1, 11734 "run_attempt": 1, 11735 "event": "e", 11736 "status": "s", 11737 "conclusion": "c", 11738 "workflow_id": 1, 11739 "url": "u", 11740 "html_url": "h", 11741 "pull_requests": [ 11742 { 11743 "id": 1, 11744 "number": 1, 11745 "url": "u", 11746 "head": { 11747 "ref": "r", 11748 "sha": "s", 11749 "repo": { 11750 "id": 1, 11751 "name": "n", 11752 "url": "s" 11753 } 11754 }, 11755 "base": { 11756 "ref": "r", 11757 "sha": "s", 11758 "repo": { 11759 "id": 1, 11760 "name": "n", 11761 "url": "u" 11762 } 11763 } 11764 } 11765 ], 11766 "created_at": ` + referenceTimeStr + `, 11767 "updated_at": ` + referenceTimeStr + `, 11768 "run_started_at": ` + referenceTimeStr + `, 11769 "jobs_url": "j", 11770 "logs_url": "l", 11771 "check_suite_url": "c", 11772 "artifacts_url": "a", 11773 "cancel_url": "c", 11774 "rerun_url": "r", 11775 "previous_attempt_url": "p", 11776 "head_commit": { 11777 "message": "m", 11778 "author": { 11779 "name": "n", 11780 "email": "e", 11781 "username": "l" 11782 }, 11783 "url": "u", 11784 "distinct": false, 11785 "sha": "s", 11786 "id": "i", 11787 "tree_id": "tid", 11788 "timestamp": ` + referenceTimeStr + `, 11789 "committer": { 11790 "name": "n", 11791 "email": "e", 11792 "username": "l" 11793 } 11794 }, 11795 "workflow_url": "w", 11796 "repository": { 11797 "id": 1, 11798 "name": "n", 11799 "url": "u" 11800 }, 11801 "head_repository": { 11802 "id": 1, 11803 "name": "n", 11804 "url": "u" 11805 } 11806 }, 11807 "organization": { 11808 "name": "n", 11809 "company": "c", 11810 "blog": "b", 11811 "location": "loc", 11812 "email": "e", 11813 "twitter_username": "tu", 11814 "description": "d", 11815 "billing_email": "be", 11816 "is_verified": true, 11817 "has_organization_projects": true, 11818 "has_repository_projects": true, 11819 "default_repository_permission": "drp", 11820 "members_can_create_repositories": true, 11821 "members_can_create_public_repositories": false, 11822 "members_can_create_private_repositories": true, 11823 "members_can_create_internal_repositories": true, 11824 "members_allowed_repository_creation_type": "marct", 11825 "members_can_create_pages": true, 11826 "members_can_create_public_pages": false, 11827 "members_can_create_private_pages": true 11828 }, 11829 "repository": { 11830 "id": 1, 11831 "name": "n", 11832 "url": "s" 11833 }, 11834 "sender": { 11835 "login": "l", 11836 "id": 1, 11837 "node_id": "n", 11838 "avatar_url": "a", 11839 "url": "u", 11840 "events_url": "e", 11841 "repos_url": "r" 11842 } 11843 }` 11844 11845 testJSONMarshal(t, u, want) 11846 } 11847 11848 func TestWorkflowDispatchEvent_Marshal(t *testing.T) { 11849 t.Parallel() 11850 testJSONMarshal(t, &WorkflowDispatchEvent{}, "{}") 11851 11852 i := make(map[string]interface{}) 11853 i["key"] = "value" 11854 11855 jsonMsg, _ := json.Marshal(i) 11856 u := &WorkflowDispatchEvent{ 11857 Inputs: jsonMsg, 11858 Ref: Ptr("r"), 11859 Workflow: Ptr("w"), 11860 Repo: &Repository{ 11861 ID: Ptr(int64(1)), 11862 URL: Ptr("s"), 11863 Name: Ptr("n"), 11864 }, 11865 Org: &Organization{ 11866 BillingEmail: Ptr("be"), 11867 Blog: Ptr("b"), 11868 Company: Ptr("c"), 11869 Email: Ptr("e"), 11870 TwitterUsername: Ptr("tu"), 11871 Location: Ptr("loc"), 11872 Name: Ptr("n"), 11873 Description: Ptr("d"), 11874 IsVerified: Ptr(true), 11875 HasOrganizationProjects: Ptr(true), 11876 HasRepositoryProjects: Ptr(true), 11877 DefaultRepoPermission: Ptr("drp"), 11878 MembersCanCreateRepos: Ptr(true), 11879 MembersCanCreateInternalRepos: Ptr(true), 11880 MembersCanCreatePrivateRepos: Ptr(true), 11881 MembersCanCreatePublicRepos: Ptr(false), 11882 MembersAllowedRepositoryCreationType: Ptr("marct"), 11883 MembersCanCreatePages: Ptr(true), 11884 MembersCanCreatePublicPages: Ptr(false), 11885 MembersCanCreatePrivatePages: Ptr(true), 11886 }, 11887 Sender: &User{ 11888 Login: Ptr("l"), 11889 ID: Ptr(int64(1)), 11890 NodeID: Ptr("n"), 11891 URL: Ptr("u"), 11892 ReposURL: Ptr("r"), 11893 EventsURL: Ptr("e"), 11894 AvatarURL: Ptr("a"), 11895 }, 11896 } 11897 11898 want := `{ 11899 "inputs": { 11900 "key": "value" 11901 }, 11902 "ref": "r", 11903 "workflow": "w", 11904 "repository": { 11905 "id": 1, 11906 "name": "n", 11907 "url": "s" 11908 }, 11909 "organization": { 11910 "name": "n", 11911 "company": "c", 11912 "blog": "b", 11913 "location": "loc", 11914 "email": "e", 11915 "twitter_username": "tu", 11916 "description": "d", 11917 "billing_email": "be", 11918 "is_verified": true, 11919 "has_organization_projects": true, 11920 "has_repository_projects": true, 11921 "default_repository_permission": "drp", 11922 "members_can_create_repositories": true, 11923 "members_can_create_public_repositories": false, 11924 "members_can_create_private_repositories": true, 11925 "members_can_create_internal_repositories": true, 11926 "members_allowed_repository_creation_type": "marct", 11927 "members_can_create_pages": true, 11928 "members_can_create_public_pages": false, 11929 "members_can_create_private_pages": true 11930 }, 11931 "sender": { 11932 "login": "l", 11933 "id": 1, 11934 "node_id": "n", 11935 "avatar_url": "a", 11936 "url": "u", 11937 "events_url": "e", 11938 "repos_url": "r" 11939 } 11940 }` 11941 11942 testJSONMarshal(t, u, want) 11943 } 11944 11945 func TestWatchEvent_Marshal(t *testing.T) { 11946 t.Parallel() 11947 testJSONMarshal(t, &WatchEvent{}, "{}") 11948 11949 u := &WatchEvent{ 11950 Action: Ptr("a"), 11951 Repo: &Repository{ 11952 ID: Ptr(int64(1)), 11953 URL: Ptr("s"), 11954 Name: Ptr("n"), 11955 }, 11956 Sender: &User{ 11957 Login: Ptr("l"), 11958 ID: Ptr(int64(1)), 11959 NodeID: Ptr("n"), 11960 URL: Ptr("u"), 11961 ReposURL: Ptr("r"), 11962 EventsURL: Ptr("e"), 11963 AvatarURL: Ptr("a"), 11964 }, 11965 Installation: &Installation{ 11966 ID: Ptr(int64(1)), 11967 NodeID: Ptr("nid"), 11968 AppID: Ptr(int64(1)), 11969 AppSlug: Ptr("as"), 11970 TargetID: Ptr(int64(1)), 11971 Account: &User{ 11972 Login: Ptr("l"), 11973 ID: Ptr(int64(1)), 11974 URL: Ptr("u"), 11975 AvatarURL: Ptr("a"), 11976 GravatarID: Ptr("g"), 11977 Name: Ptr("n"), 11978 Company: Ptr("c"), 11979 Blog: Ptr("b"), 11980 Location: Ptr("l"), 11981 Email: Ptr("e"), 11982 Hireable: Ptr(true), 11983 Bio: Ptr("b"), 11984 TwitterUsername: Ptr("t"), 11985 PublicRepos: Ptr(1), 11986 Followers: Ptr(1), 11987 Following: Ptr(1), 11988 CreatedAt: &Timestamp{referenceTime}, 11989 SuspendedAt: &Timestamp{referenceTime}, 11990 }, 11991 AccessTokensURL: Ptr("atu"), 11992 RepositoriesURL: Ptr("ru"), 11993 HTMLURL: Ptr("hu"), 11994 TargetType: Ptr("tt"), 11995 SingleFileName: Ptr("sfn"), 11996 RepositorySelection: Ptr("rs"), 11997 Events: []string{"e"}, 11998 SingleFilePaths: []string{"s"}, 11999 Permissions: &InstallationPermissions{ 12000 Actions: Ptr("a"), 12001 Administration: Ptr("ad"), 12002 Checks: Ptr("c"), 12003 Contents: Ptr("co"), 12004 ContentReferences: Ptr("cr"), 12005 Deployments: Ptr("d"), 12006 Environments: Ptr("e"), 12007 Issues: Ptr("i"), 12008 Metadata: Ptr("md"), 12009 Members: Ptr("m"), 12010 OrganizationAdministration: Ptr("oa"), 12011 OrganizationHooks: Ptr("oh"), 12012 OrganizationPlan: Ptr("op"), 12013 OrganizationPreReceiveHooks: Ptr("opr"), 12014 OrganizationProjects: Ptr("op"), 12015 OrganizationSecrets: Ptr("os"), 12016 OrganizationSelfHostedRunners: Ptr("osh"), 12017 OrganizationUserBlocking: Ptr("oub"), 12018 Packages: Ptr("pkg"), 12019 Pages: Ptr("pg"), 12020 PullRequests: Ptr("pr"), 12021 RepositoryHooks: Ptr("rh"), 12022 RepositoryProjects: Ptr("rp"), 12023 RepositoryPreReceiveHooks: Ptr("rprh"), 12024 Secrets: Ptr("s"), 12025 SecretScanningAlerts: Ptr("ssa"), 12026 SecurityEvents: Ptr("se"), 12027 SingleFile: Ptr("sf"), 12028 Statuses: Ptr("s"), 12029 TeamDiscussions: Ptr("td"), 12030 VulnerabilityAlerts: Ptr("va"), 12031 Workflows: Ptr("w"), 12032 }, 12033 CreatedAt: &Timestamp{referenceTime}, 12034 UpdatedAt: &Timestamp{referenceTime}, 12035 HasMultipleSingleFiles: Ptr(false), 12036 SuspendedBy: &User{ 12037 Login: Ptr("l"), 12038 ID: Ptr(int64(1)), 12039 URL: Ptr("u"), 12040 AvatarURL: Ptr("a"), 12041 GravatarID: Ptr("g"), 12042 Name: Ptr("n"), 12043 Company: Ptr("c"), 12044 Blog: Ptr("b"), 12045 Location: Ptr("l"), 12046 Email: Ptr("e"), 12047 Hireable: Ptr(true), 12048 Bio: Ptr("b"), 12049 TwitterUsername: Ptr("t"), 12050 PublicRepos: Ptr(1), 12051 Followers: Ptr(1), 12052 Following: Ptr(1), 12053 CreatedAt: &Timestamp{referenceTime}, 12054 SuspendedAt: &Timestamp{referenceTime}, 12055 }, 12056 SuspendedAt: &Timestamp{referenceTime}, 12057 }, 12058 } 12059 12060 want := `{ 12061 "action": "a", 12062 "repository": { 12063 "id": 1, 12064 "name": "n", 12065 "url": "s" 12066 }, 12067 "sender": { 12068 "login": "l", 12069 "id": 1, 12070 "node_id": "n", 12071 "avatar_url": "a", 12072 "url": "u", 12073 "events_url": "e", 12074 "repos_url": "r" 12075 }, 12076 "installation": { 12077 "id": 1, 12078 "node_id": "nid", 12079 "app_id": 1, 12080 "app_slug": "as", 12081 "target_id": 1, 12082 "account": { 12083 "login": "l", 12084 "id": 1, 12085 "avatar_url": "a", 12086 "gravatar_id": "g", 12087 "name": "n", 12088 "company": "c", 12089 "blog": "b", 12090 "location": "l", 12091 "email": "e", 12092 "hireable": true, 12093 "bio": "b", 12094 "twitter_username": "t", 12095 "public_repos": 1, 12096 "followers": 1, 12097 "following": 1, 12098 "created_at": ` + referenceTimeStr + `, 12099 "suspended_at": ` + referenceTimeStr + `, 12100 "url": "u" 12101 }, 12102 "access_tokens_url": "atu", 12103 "repositories_url": "ru", 12104 "html_url": "hu", 12105 "target_type": "tt", 12106 "single_file_name": "sfn", 12107 "repository_selection": "rs", 12108 "events": [ 12109 "e" 12110 ], 12111 "single_file_paths": [ 12112 "s" 12113 ], 12114 "permissions": { 12115 "actions": "a", 12116 "administration": "ad", 12117 "checks": "c", 12118 "contents": "co", 12119 "content_references": "cr", 12120 "deployments": "d", 12121 "environments": "e", 12122 "issues": "i", 12123 "metadata": "md", 12124 "members": "m", 12125 "organization_administration": "oa", 12126 "organization_hooks": "oh", 12127 "organization_plan": "op", 12128 "organization_pre_receive_hooks": "opr", 12129 "organization_projects": "op", 12130 "organization_secrets": "os", 12131 "organization_self_hosted_runners": "osh", 12132 "organization_user_blocking": "oub", 12133 "packages": "pkg", 12134 "pages": "pg", 12135 "pull_requests": "pr", 12136 "repository_hooks": "rh", 12137 "repository_projects": "rp", 12138 "repository_pre_receive_hooks": "rprh", 12139 "secrets": "s", 12140 "secret_scanning_alerts": "ssa", 12141 "security_events": "se", 12142 "single_file": "sf", 12143 "statuses": "s", 12144 "team_discussions": "td", 12145 "vulnerability_alerts": "va", 12146 "workflows": "w" 12147 }, 12148 "created_at": ` + referenceTimeStr + `, 12149 "updated_at": ` + referenceTimeStr + `, 12150 "has_multiple_single_files": false, 12151 "suspended_by": { 12152 "login": "l", 12153 "id": 1, 12154 "avatar_url": "a", 12155 "gravatar_id": "g", 12156 "name": "n", 12157 "company": "c", 12158 "blog": "b", 12159 "location": "l", 12160 "email": "e", 12161 "hireable": true, 12162 "bio": "b", 12163 "twitter_username": "t", 12164 "public_repos": 1, 12165 "followers": 1, 12166 "following": 1, 12167 "created_at": ` + referenceTimeStr + `, 12168 "suspended_at": ` + referenceTimeStr + `, 12169 "url": "u" 12170 }, 12171 "suspended_at": ` + referenceTimeStr + ` 12172 } 12173 }` 12174 12175 testJSONMarshal(t, u, want) 12176 } 12177 12178 func TestUserEvent_Marshal(t *testing.T) { 12179 t.Parallel() 12180 testJSONMarshal(t, &UserEvent{}, "{}") 12181 12182 u := &UserEvent{ 12183 User: &User{ 12184 Login: Ptr("l"), 12185 ID: Ptr(int64(1)), 12186 NodeID: Ptr("n"), 12187 URL: Ptr("u"), 12188 ReposURL: Ptr("r"), 12189 EventsURL: Ptr("e"), 12190 AvatarURL: Ptr("a"), 12191 }, 12192 // The action performed. Possible values are: "created" or "deleted". 12193 Action: Ptr("a"), 12194 Enterprise: &Enterprise{ 12195 ID: Ptr(1), 12196 Slug: Ptr("s"), 12197 Name: Ptr("n"), 12198 NodeID: Ptr("nid"), 12199 AvatarURL: Ptr("au"), 12200 Description: Ptr("d"), 12201 WebsiteURL: Ptr("wu"), 12202 HTMLURL: Ptr("hu"), 12203 CreatedAt: &Timestamp{referenceTime}, 12204 UpdatedAt: &Timestamp{referenceTime}, 12205 }, 12206 Sender: &User{ 12207 Login: Ptr("l"), 12208 ID: Ptr(int64(1)), 12209 NodeID: Ptr("n"), 12210 URL: Ptr("u"), 12211 ReposURL: Ptr("r"), 12212 EventsURL: Ptr("e"), 12213 AvatarURL: Ptr("a"), 12214 }, 12215 } 12216 12217 want := `{ 12218 "user": { 12219 "login": "l", 12220 "id": 1, 12221 "node_id": "n", 12222 "avatar_url": "a", 12223 "url": "u", 12224 "events_url": "e", 12225 "repos_url": "r" 12226 }, 12227 "action": "a", 12228 "enterprise": { 12229 "id": 1, 12230 "slug": "s", 12231 "name": "n", 12232 "node_id": "nid", 12233 "avatar_url": "au", 12234 "description": "d", 12235 "website_url": "wu", 12236 "html_url": "hu", 12237 "created_at": ` + referenceTimeStr + `, 12238 "updated_at": ` + referenceTimeStr + ` 12239 }, 12240 "sender": { 12241 "login": "l", 12242 "id": 1, 12243 "node_id": "n", 12244 "avatar_url": "a", 12245 "url": "u", 12246 "events_url": "e", 12247 "repos_url": "r" 12248 } 12249 }` 12250 12251 testJSONMarshal(t, u, want) 12252 } 12253 12254 func TestCheckRunEvent_Marshal(t *testing.T) { 12255 t.Parallel() 12256 testJSONMarshal(t, &CheckRunEvent{}, "{}") 12257 12258 r := &CheckRunEvent{ 12259 CheckRun: &CheckRun{ 12260 ID: Ptr(int64(1)), 12261 NodeID: Ptr("n"), 12262 HeadSHA: Ptr("h"), 12263 ExternalID: Ptr("1"), 12264 URL: Ptr("u"), 12265 HTMLURL: Ptr("u"), 12266 DetailsURL: Ptr("u"), 12267 Status: Ptr("s"), 12268 Conclusion: Ptr("c"), 12269 StartedAt: &Timestamp{referenceTime}, 12270 CompletedAt: &Timestamp{referenceTime}, 12271 Output: &CheckRunOutput{ 12272 Annotations: []*CheckRunAnnotation{ 12273 { 12274 AnnotationLevel: Ptr("a"), 12275 EndLine: Ptr(1), 12276 Message: Ptr("m"), 12277 Path: Ptr("p"), 12278 RawDetails: Ptr("r"), 12279 StartLine: Ptr(1), 12280 Title: Ptr("t"), 12281 }, 12282 }, 12283 AnnotationsCount: Ptr(1), 12284 AnnotationsURL: Ptr("a"), 12285 Images: []*CheckRunImage{ 12286 { 12287 Alt: Ptr("a"), 12288 ImageURL: Ptr("i"), 12289 Caption: Ptr("c"), 12290 }, 12291 }, 12292 Title: Ptr("t"), 12293 Summary: Ptr("s"), 12294 Text: Ptr("t"), 12295 }, 12296 Name: Ptr("n"), 12297 CheckSuite: &CheckSuite{ 12298 ID: Ptr(int64(1)), 12299 }, 12300 App: &App{ 12301 ID: Ptr(int64(1)), 12302 NodeID: Ptr("n"), 12303 Owner: &User{ 12304 Login: Ptr("l"), 12305 ID: Ptr(int64(1)), 12306 NodeID: Ptr("n"), 12307 URL: Ptr("u"), 12308 ReposURL: Ptr("r"), 12309 EventsURL: Ptr("e"), 12310 AvatarURL: Ptr("a"), 12311 }, 12312 Name: Ptr("n"), 12313 Description: Ptr("d"), 12314 HTMLURL: Ptr("h"), 12315 ExternalURL: Ptr("u"), 12316 CreatedAt: &Timestamp{referenceTime}, 12317 UpdatedAt: &Timestamp{referenceTime}, 12318 }, 12319 PullRequests: []*PullRequest{ 12320 { 12321 URL: Ptr("u"), 12322 ID: Ptr(int64(1)), 12323 Number: Ptr(1), 12324 Head: &PullRequestBranch{ 12325 Ref: Ptr("r"), 12326 SHA: Ptr("s"), 12327 Repo: &Repository{ 12328 ID: Ptr(int64(1)), 12329 URL: Ptr("s"), 12330 Name: Ptr("n"), 12331 }, 12332 }, 12333 Base: &PullRequestBranch{ 12334 Ref: Ptr("r"), 12335 SHA: Ptr("s"), 12336 Repo: &Repository{ 12337 ID: Ptr(int64(1)), 12338 URL: Ptr("u"), 12339 Name: Ptr("n"), 12340 }, 12341 }, 12342 }, 12343 }, 12344 }, 12345 Action: Ptr("a"), 12346 Repo: &Repository{ 12347 ID: Ptr(int64(1)), 12348 URL: Ptr("s"), 12349 Name: Ptr("n"), 12350 }, 12351 Org: &Organization{ 12352 BillingEmail: Ptr("be"), 12353 Blog: Ptr("b"), 12354 Company: Ptr("c"), 12355 Email: Ptr("e"), 12356 TwitterUsername: Ptr("tu"), 12357 Location: Ptr("loc"), 12358 Name: Ptr("n"), 12359 Description: Ptr("d"), 12360 IsVerified: Ptr(true), 12361 HasOrganizationProjects: Ptr(true), 12362 HasRepositoryProjects: Ptr(true), 12363 DefaultRepoPermission: Ptr("drp"), 12364 MembersCanCreateRepos: Ptr(true), 12365 MembersCanCreateInternalRepos: Ptr(true), 12366 MembersCanCreatePrivateRepos: Ptr(true), 12367 MembersCanCreatePublicRepos: Ptr(false), 12368 MembersAllowedRepositoryCreationType: Ptr("marct"), 12369 MembersCanCreatePages: Ptr(true), 12370 MembersCanCreatePublicPages: Ptr(false), 12371 MembersCanCreatePrivatePages: Ptr(true), 12372 }, 12373 Sender: &User{ 12374 Login: Ptr("l"), 12375 ID: Ptr(int64(1)), 12376 NodeID: Ptr("n"), 12377 URL: Ptr("u"), 12378 ReposURL: Ptr("r"), 12379 EventsURL: Ptr("e"), 12380 AvatarURL: Ptr("a"), 12381 }, 12382 Installation: &Installation{ 12383 ID: Ptr(int64(1)), 12384 NodeID: Ptr("nid"), 12385 AppID: Ptr(int64(1)), 12386 AppSlug: Ptr("as"), 12387 TargetID: Ptr(int64(1)), 12388 Account: &User{ 12389 Login: Ptr("l"), 12390 ID: Ptr(int64(1)), 12391 URL: Ptr("u"), 12392 AvatarURL: Ptr("a"), 12393 GravatarID: Ptr("g"), 12394 Name: Ptr("n"), 12395 Company: Ptr("c"), 12396 Blog: Ptr("b"), 12397 Location: Ptr("l"), 12398 Email: Ptr("e"), 12399 Hireable: Ptr(true), 12400 Bio: Ptr("b"), 12401 TwitterUsername: Ptr("t"), 12402 PublicRepos: Ptr(1), 12403 Followers: Ptr(1), 12404 Following: Ptr(1), 12405 CreatedAt: &Timestamp{referenceTime}, 12406 SuspendedAt: &Timestamp{referenceTime}, 12407 }, 12408 AccessTokensURL: Ptr("atu"), 12409 RepositoriesURL: Ptr("ru"), 12410 HTMLURL: Ptr("hu"), 12411 TargetType: Ptr("tt"), 12412 SingleFileName: Ptr("sfn"), 12413 RepositorySelection: Ptr("rs"), 12414 Events: []string{"e"}, 12415 SingleFilePaths: []string{"s"}, 12416 Permissions: &InstallationPermissions{ 12417 Actions: Ptr("a"), 12418 Administration: Ptr("ad"), 12419 Checks: Ptr("c"), 12420 Contents: Ptr("co"), 12421 ContentReferences: Ptr("cr"), 12422 Deployments: Ptr("d"), 12423 Environments: Ptr("e"), 12424 Issues: Ptr("i"), 12425 Metadata: Ptr("md"), 12426 Members: Ptr("m"), 12427 OrganizationAdministration: Ptr("oa"), 12428 OrganizationHooks: Ptr("oh"), 12429 OrganizationPlan: Ptr("op"), 12430 OrganizationPreReceiveHooks: Ptr("opr"), 12431 OrganizationProjects: Ptr("op"), 12432 OrganizationSecrets: Ptr("os"), 12433 OrganizationSelfHostedRunners: Ptr("osh"), 12434 OrganizationUserBlocking: Ptr("oub"), 12435 Packages: Ptr("pkg"), 12436 Pages: Ptr("pg"), 12437 PullRequests: Ptr("pr"), 12438 RepositoryHooks: Ptr("rh"), 12439 RepositoryProjects: Ptr("rp"), 12440 RepositoryPreReceiveHooks: Ptr("rprh"), 12441 Secrets: Ptr("s"), 12442 SecretScanningAlerts: Ptr("ssa"), 12443 SecurityEvents: Ptr("se"), 12444 SingleFile: Ptr("sf"), 12445 Statuses: Ptr("s"), 12446 TeamDiscussions: Ptr("td"), 12447 VulnerabilityAlerts: Ptr("va"), 12448 Workflows: Ptr("w"), 12449 }, 12450 CreatedAt: &Timestamp{referenceTime}, 12451 UpdatedAt: &Timestamp{referenceTime}, 12452 HasMultipleSingleFiles: Ptr(false), 12453 SuspendedBy: &User{ 12454 Login: Ptr("l"), 12455 ID: Ptr(int64(1)), 12456 URL: Ptr("u"), 12457 AvatarURL: Ptr("a"), 12458 GravatarID: Ptr("g"), 12459 Name: Ptr("n"), 12460 Company: Ptr("c"), 12461 Blog: Ptr("b"), 12462 Location: Ptr("l"), 12463 Email: Ptr("e"), 12464 Hireable: Ptr(true), 12465 Bio: Ptr("b"), 12466 TwitterUsername: Ptr("t"), 12467 PublicRepos: Ptr(1), 12468 Followers: Ptr(1), 12469 Following: Ptr(1), 12470 CreatedAt: &Timestamp{referenceTime}, 12471 SuspendedAt: &Timestamp{referenceTime}, 12472 }, 12473 SuspendedAt: &Timestamp{referenceTime}, 12474 }, 12475 RequestedAction: &RequestedAction{ 12476 Identifier: "i", 12477 }, 12478 } 12479 12480 want := `{ 12481 "check_run": { 12482 "id": 1, 12483 "node_id": "n", 12484 "head_sha": "h", 12485 "external_id": "1", 12486 "url": "u", 12487 "html_url": "u", 12488 "details_url": "u", 12489 "status": "s", 12490 "conclusion": "c", 12491 "started_at": ` + referenceTimeStr + `, 12492 "completed_at": ` + referenceTimeStr + `, 12493 "output": { 12494 "title": "t", 12495 "summary": "s", 12496 "text": "t", 12497 "annotations_count": 1, 12498 "annotations_url": "a", 12499 "annotations": [ 12500 { 12501 "path": "p", 12502 "start_line": 1, 12503 "end_line": 1, 12504 "annotation_level": "a", 12505 "message": "m", 12506 "title": "t", 12507 "raw_details": "r" 12508 } 12509 ], 12510 "images": [ 12511 { 12512 "alt": "a", 12513 "image_url": "i", 12514 "caption": "c" 12515 } 12516 ] 12517 }, 12518 "name": "n", 12519 "check_suite": { 12520 "id": 1 12521 }, 12522 "app": { 12523 "id": 1, 12524 "node_id": "n", 12525 "owner": { 12526 "login": "l", 12527 "id": 1, 12528 "node_id": "n", 12529 "avatar_url": "a", 12530 "url": "u", 12531 "events_url": "e", 12532 "repos_url": "r" 12533 }, 12534 "name": "n", 12535 "description": "d", 12536 "external_url": "u", 12537 "html_url": "h", 12538 "created_at": ` + referenceTimeStr + `, 12539 "updated_at": ` + referenceTimeStr + ` 12540 }, 12541 "pull_requests": [ 12542 { 12543 "id": 1, 12544 "number": 1, 12545 "url": "u", 12546 "head": { 12547 "ref": "r", 12548 "sha": "s", 12549 "repo": { 12550 "id": 1, 12551 "name": "n", 12552 "url": "s" 12553 } 12554 }, 12555 "base": { 12556 "ref": "r", 12557 "sha": "s", 12558 "repo": { 12559 "id": 1, 12560 "name": "n", 12561 "url": "u" 12562 } 12563 } 12564 } 12565 ] 12566 }, 12567 "action": "a", 12568 "repository": { 12569 "id": 1, 12570 "name": "n", 12571 "url": "s" 12572 }, 12573 "organization": { 12574 "name": "n", 12575 "company": "c", 12576 "blog": "b", 12577 "location": "loc", 12578 "email": "e", 12579 "twitter_username": "tu", 12580 "description": "d", 12581 "billing_email": "be", 12582 "is_verified": true, 12583 "has_organization_projects": true, 12584 "has_repository_projects": true, 12585 "default_repository_permission": "drp", 12586 "members_can_create_repositories": true, 12587 "members_can_create_public_repositories": false, 12588 "members_can_create_private_repositories": true, 12589 "members_can_create_internal_repositories": true, 12590 "members_allowed_repository_creation_type": "marct", 12591 "members_can_create_pages": true, 12592 "members_can_create_public_pages": false, 12593 "members_can_create_private_pages": true 12594 }, 12595 "sender": { 12596 "login": "l", 12597 "id": 1, 12598 "node_id": "n", 12599 "avatar_url": "a", 12600 "url": "u", 12601 "events_url": "e", 12602 "repos_url": "r" 12603 }, 12604 "installation": { 12605 "id": 1, 12606 "node_id": "nid", 12607 "app_id": 1, 12608 "app_slug": "as", 12609 "target_id": 1, 12610 "account": { 12611 "login": "l", 12612 "id": 1, 12613 "avatar_url": "a", 12614 "gravatar_id": "g", 12615 "name": "n", 12616 "company": "c", 12617 "blog": "b", 12618 "location": "l", 12619 "email": "e", 12620 "hireable": true, 12621 "bio": "b", 12622 "twitter_username": "t", 12623 "public_repos": 1, 12624 "followers": 1, 12625 "following": 1, 12626 "created_at": ` + referenceTimeStr + `, 12627 "suspended_at": ` + referenceTimeStr + `, 12628 "url": "u" 12629 }, 12630 "access_tokens_url": "atu", 12631 "repositories_url": "ru", 12632 "html_url": "hu", 12633 "target_type": "tt", 12634 "single_file_name": "sfn", 12635 "repository_selection": "rs", 12636 "events": [ 12637 "e" 12638 ], 12639 "single_file_paths": [ 12640 "s" 12641 ], 12642 "permissions": { 12643 "actions": "a", 12644 "administration": "ad", 12645 "checks": "c", 12646 "contents": "co", 12647 "content_references": "cr", 12648 "deployments": "d", 12649 "environments": "e", 12650 "issues": "i", 12651 "metadata": "md", 12652 "members": "m", 12653 "organization_administration": "oa", 12654 "organization_hooks": "oh", 12655 "organization_plan": "op", 12656 "organization_pre_receive_hooks": "opr", 12657 "organization_projects": "op", 12658 "organization_secrets": "os", 12659 "organization_self_hosted_runners": "osh", 12660 "organization_user_blocking": "oub", 12661 "packages": "pkg", 12662 "pages": "pg", 12663 "pull_requests": "pr", 12664 "repository_hooks": "rh", 12665 "repository_projects": "rp", 12666 "repository_pre_receive_hooks": "rprh", 12667 "secrets": "s", 12668 "secret_scanning_alerts": "ssa", 12669 "security_events": "se", 12670 "single_file": "sf", 12671 "statuses": "s", 12672 "team_discussions": "td", 12673 "vulnerability_alerts": "va", 12674 "workflows": "w" 12675 }, 12676 "created_at": ` + referenceTimeStr + `, 12677 "updated_at": ` + referenceTimeStr + `, 12678 "has_multiple_single_files": false, 12679 "suspended_by": { 12680 "login": "l", 12681 "id": 1, 12682 "avatar_url": "a", 12683 "gravatar_id": "g", 12684 "name": "n", 12685 "company": "c", 12686 "blog": "b", 12687 "location": "l", 12688 "email": "e", 12689 "hireable": true, 12690 "bio": "b", 12691 "twitter_username": "t", 12692 "public_repos": 1, 12693 "followers": 1, 12694 "following": 1, 12695 "created_at": ` + referenceTimeStr + `, 12696 "suspended_at": ` + referenceTimeStr + `, 12697 "url": "u" 12698 }, 12699 "suspended_at": ` + referenceTimeStr + ` 12700 }, 12701 "requested_action": { 12702 "identifier": "i" 12703 } 12704 }` 12705 12706 testJSONMarshal(t, r, want) 12707 } 12708 12709 func TestCheckSuiteEvent_Marshal(t *testing.T) { 12710 t.Parallel() 12711 testJSONMarshal(t, &CheckSuiteEvent{}, "{}") 12712 12713 r := &CheckSuiteEvent{ 12714 CheckSuite: &CheckSuite{ 12715 ID: Ptr(int64(1)), 12716 NodeID: Ptr("n"), 12717 HeadBranch: Ptr("h"), 12718 HeadSHA: Ptr("h"), 12719 URL: Ptr("u"), 12720 BeforeSHA: Ptr("b"), 12721 AfterSHA: Ptr("a"), 12722 Status: Ptr("s"), 12723 Conclusion: Ptr("c"), 12724 App: &App{ 12725 ID: Ptr(int64(1)), 12726 NodeID: Ptr("n"), 12727 Owner: &User{ 12728 Login: Ptr("l"), 12729 ID: Ptr(int64(1)), 12730 NodeID: Ptr("n"), 12731 URL: Ptr("u"), 12732 ReposURL: Ptr("r"), 12733 EventsURL: Ptr("e"), 12734 AvatarURL: Ptr("a"), 12735 }, 12736 Name: Ptr("n"), 12737 Description: Ptr("d"), 12738 HTMLURL: Ptr("h"), 12739 ExternalURL: Ptr("u"), 12740 CreatedAt: &Timestamp{referenceTime}, 12741 UpdatedAt: &Timestamp{referenceTime}, 12742 }, 12743 Repository: &Repository{ 12744 ID: Ptr(int64(1)), 12745 }, 12746 PullRequests: []*PullRequest{ 12747 { 12748 URL: Ptr("u"), 12749 ID: Ptr(int64(1)), 12750 Number: Ptr(1), 12751 Head: &PullRequestBranch{ 12752 Ref: Ptr("r"), 12753 SHA: Ptr("s"), 12754 Repo: &Repository{ 12755 ID: Ptr(int64(1)), 12756 URL: Ptr("s"), 12757 Name: Ptr("n"), 12758 }, 12759 }, 12760 Base: &PullRequestBranch{ 12761 Ref: Ptr("r"), 12762 SHA: Ptr("s"), 12763 Repo: &Repository{ 12764 ID: Ptr(int64(1)), 12765 URL: Ptr("u"), 12766 Name: Ptr("n"), 12767 }, 12768 }, 12769 }, 12770 }, 12771 HeadCommit: &Commit{ 12772 SHA: Ptr("s"), 12773 }, 12774 }, 12775 Action: Ptr("a"), 12776 Repo: &Repository{ 12777 ID: Ptr(int64(1)), 12778 URL: Ptr("s"), 12779 Name: Ptr("n"), 12780 }, 12781 Org: &Organization{ 12782 BillingEmail: Ptr("be"), 12783 Blog: Ptr("b"), 12784 Company: Ptr("c"), 12785 Email: Ptr("e"), 12786 TwitterUsername: Ptr("tu"), 12787 Location: Ptr("loc"), 12788 Name: Ptr("n"), 12789 Description: Ptr("d"), 12790 IsVerified: Ptr(true), 12791 HasOrganizationProjects: Ptr(true), 12792 HasRepositoryProjects: Ptr(true), 12793 DefaultRepoPermission: Ptr("drp"), 12794 MembersCanCreateRepos: Ptr(true), 12795 MembersCanCreateInternalRepos: Ptr(true), 12796 MembersCanCreatePrivateRepos: Ptr(true), 12797 MembersCanCreatePublicRepos: Ptr(false), 12798 MembersAllowedRepositoryCreationType: Ptr("marct"), 12799 MembersCanCreatePages: Ptr(true), 12800 MembersCanCreatePublicPages: Ptr(false), 12801 MembersCanCreatePrivatePages: Ptr(true), 12802 }, 12803 Sender: &User{ 12804 Login: Ptr("l"), 12805 ID: Ptr(int64(1)), 12806 NodeID: Ptr("n"), 12807 URL: Ptr("u"), 12808 ReposURL: Ptr("r"), 12809 EventsURL: Ptr("e"), 12810 AvatarURL: Ptr("a"), 12811 }, 12812 Installation: &Installation{ 12813 ID: Ptr(int64(1)), 12814 NodeID: Ptr("nid"), 12815 AppID: Ptr(int64(1)), 12816 AppSlug: Ptr("as"), 12817 TargetID: Ptr(int64(1)), 12818 Account: &User{ 12819 Login: Ptr("l"), 12820 ID: Ptr(int64(1)), 12821 URL: Ptr("u"), 12822 AvatarURL: Ptr("a"), 12823 GravatarID: Ptr("g"), 12824 Name: Ptr("n"), 12825 Company: Ptr("c"), 12826 Blog: Ptr("b"), 12827 Location: Ptr("l"), 12828 Email: Ptr("e"), 12829 Hireable: Ptr(true), 12830 Bio: Ptr("b"), 12831 TwitterUsername: Ptr("t"), 12832 PublicRepos: Ptr(1), 12833 Followers: Ptr(1), 12834 Following: Ptr(1), 12835 CreatedAt: &Timestamp{referenceTime}, 12836 SuspendedAt: &Timestamp{referenceTime}, 12837 }, 12838 AccessTokensURL: Ptr("atu"), 12839 RepositoriesURL: Ptr("ru"), 12840 HTMLURL: Ptr("hu"), 12841 TargetType: Ptr("tt"), 12842 SingleFileName: Ptr("sfn"), 12843 RepositorySelection: Ptr("rs"), 12844 Events: []string{"e"}, 12845 SingleFilePaths: []string{"s"}, 12846 Permissions: &InstallationPermissions{ 12847 Actions: Ptr("a"), 12848 Administration: Ptr("ad"), 12849 Checks: Ptr("c"), 12850 Contents: Ptr("co"), 12851 ContentReferences: Ptr("cr"), 12852 Deployments: Ptr("d"), 12853 Environments: Ptr("e"), 12854 Issues: Ptr("i"), 12855 Metadata: Ptr("md"), 12856 Members: Ptr("m"), 12857 OrganizationAdministration: Ptr("oa"), 12858 OrganizationHooks: Ptr("oh"), 12859 OrganizationPlan: Ptr("op"), 12860 OrganizationPreReceiveHooks: Ptr("opr"), 12861 OrganizationProjects: Ptr("op"), 12862 OrganizationSecrets: Ptr("os"), 12863 OrganizationSelfHostedRunners: Ptr("osh"), 12864 OrganizationUserBlocking: Ptr("oub"), 12865 Packages: Ptr("pkg"), 12866 Pages: Ptr("pg"), 12867 PullRequests: Ptr("pr"), 12868 RepositoryHooks: Ptr("rh"), 12869 RepositoryProjects: Ptr("rp"), 12870 RepositoryPreReceiveHooks: Ptr("rprh"), 12871 Secrets: Ptr("s"), 12872 SecretScanningAlerts: Ptr("ssa"), 12873 SecurityEvents: Ptr("se"), 12874 SingleFile: Ptr("sf"), 12875 Statuses: Ptr("s"), 12876 TeamDiscussions: Ptr("td"), 12877 VulnerabilityAlerts: Ptr("va"), 12878 Workflows: Ptr("w"), 12879 }, 12880 CreatedAt: &Timestamp{referenceTime}, 12881 UpdatedAt: &Timestamp{referenceTime}, 12882 HasMultipleSingleFiles: Ptr(false), 12883 SuspendedBy: &User{ 12884 Login: Ptr("l"), 12885 ID: Ptr(int64(1)), 12886 URL: Ptr("u"), 12887 AvatarURL: Ptr("a"), 12888 GravatarID: Ptr("g"), 12889 Name: Ptr("n"), 12890 Company: Ptr("c"), 12891 Blog: Ptr("b"), 12892 Location: Ptr("l"), 12893 Email: Ptr("e"), 12894 Hireable: Ptr(true), 12895 Bio: Ptr("b"), 12896 TwitterUsername: Ptr("t"), 12897 PublicRepos: Ptr(1), 12898 Followers: Ptr(1), 12899 Following: Ptr(1), 12900 CreatedAt: &Timestamp{referenceTime}, 12901 SuspendedAt: &Timestamp{referenceTime}, 12902 }, 12903 SuspendedAt: &Timestamp{referenceTime}, 12904 }, 12905 } 12906 12907 want := `{ 12908 "check_suite": { 12909 "id": 1, 12910 "node_id": "n", 12911 "head_branch": "h", 12912 "head_sha": "h", 12913 "url": "u", 12914 "before": "b", 12915 "after": "a", 12916 "status": "s", 12917 "conclusion": "c", 12918 "app": { 12919 "id": 1, 12920 "node_id": "n", 12921 "owner": { 12922 "login": "l", 12923 "id": 1, 12924 "node_id": "n", 12925 "avatar_url": "a", 12926 "url": "u", 12927 "events_url": "e", 12928 "repos_url": "r" 12929 }, 12930 "name": "n", 12931 "description": "d", 12932 "external_url": "u", 12933 "html_url": "h", 12934 "created_at": ` + referenceTimeStr + `, 12935 "updated_at": ` + referenceTimeStr + ` 12936 }, 12937 "repository": { 12938 "id": 1 12939 }, 12940 "pull_requests": [ 12941 { 12942 "id": 1, 12943 "number": 1, 12944 "url": "u", 12945 "head": { 12946 "ref": "r", 12947 "sha": "s", 12948 "repo": { 12949 "id": 1, 12950 "name": "n", 12951 "url": "s" 12952 } 12953 }, 12954 "base": { 12955 "ref": "r", 12956 "sha": "s", 12957 "repo": { 12958 "id": 1, 12959 "name": "n", 12960 "url": "u" 12961 } 12962 } 12963 } 12964 ], 12965 "head_commit": { 12966 "sha": "s" 12967 } 12968 }, 12969 "action": "a", 12970 "repository": { 12971 "id": 1, 12972 "name": "n", 12973 "url": "s" 12974 }, 12975 "organization": { 12976 "name": "n", 12977 "company": "c", 12978 "blog": "b", 12979 "location": "loc", 12980 "email": "e", 12981 "twitter_username": "tu", 12982 "description": "d", 12983 "billing_email": "be", 12984 "is_verified": true, 12985 "has_organization_projects": true, 12986 "has_repository_projects": true, 12987 "default_repository_permission": "drp", 12988 "members_can_create_repositories": true, 12989 "members_can_create_public_repositories": false, 12990 "members_can_create_private_repositories": true, 12991 "members_can_create_internal_repositories": true, 12992 "members_allowed_repository_creation_type": "marct", 12993 "members_can_create_pages": true, 12994 "members_can_create_public_pages": false, 12995 "members_can_create_private_pages": true 12996 }, 12997 "sender": { 12998 "login": "l", 12999 "id": 1, 13000 "node_id": "n", 13001 "avatar_url": "a", 13002 "url": "u", 13003 "events_url": "e", 13004 "repos_url": "r" 13005 }, 13006 "installation": { 13007 "id": 1, 13008 "node_id": "nid", 13009 "app_id": 1, 13010 "app_slug": "as", 13011 "target_id": 1, 13012 "account": { 13013 "login": "l", 13014 "id": 1, 13015 "avatar_url": "a", 13016 "gravatar_id": "g", 13017 "name": "n", 13018 "company": "c", 13019 "blog": "b", 13020 "location": "l", 13021 "email": "e", 13022 "hireable": true, 13023 "bio": "b", 13024 "twitter_username": "t", 13025 "public_repos": 1, 13026 "followers": 1, 13027 "following": 1, 13028 "created_at": ` + referenceTimeStr + `, 13029 "suspended_at": ` + referenceTimeStr + `, 13030 "url": "u" 13031 }, 13032 "access_tokens_url": "atu", 13033 "repositories_url": "ru", 13034 "html_url": "hu", 13035 "target_type": "tt", 13036 "single_file_name": "sfn", 13037 "repository_selection": "rs", 13038 "events": [ 13039 "e" 13040 ], 13041 "single_file_paths": [ 13042 "s" 13043 ], 13044 "permissions": { 13045 "actions": "a", 13046 "administration": "ad", 13047 "checks": "c", 13048 "contents": "co", 13049 "content_references": "cr", 13050 "deployments": "d", 13051 "environments": "e", 13052 "issues": "i", 13053 "metadata": "md", 13054 "members": "m", 13055 "organization_administration": "oa", 13056 "organization_hooks": "oh", 13057 "organization_plan": "op", 13058 "organization_pre_receive_hooks": "opr", 13059 "organization_projects": "op", 13060 "organization_secrets": "os", 13061 "organization_self_hosted_runners": "osh", 13062 "organization_user_blocking": "oub", 13063 "packages": "pkg", 13064 "pages": "pg", 13065 "pull_requests": "pr", 13066 "repository_hooks": "rh", 13067 "repository_projects": "rp", 13068 "repository_pre_receive_hooks": "rprh", 13069 "secrets": "s", 13070 "secret_scanning_alerts": "ssa", 13071 "security_events": "se", 13072 "single_file": "sf", 13073 "statuses": "s", 13074 "team_discussions": "td", 13075 "vulnerability_alerts": "va", 13076 "workflows": "w" 13077 }, 13078 "created_at": ` + referenceTimeStr + `, 13079 "updated_at": ` + referenceTimeStr + `, 13080 "has_multiple_single_files": false, 13081 "suspended_by": { 13082 "login": "l", 13083 "id": 1, 13084 "avatar_url": "a", 13085 "gravatar_id": "g", 13086 "name": "n", 13087 "company": "c", 13088 "blog": "b", 13089 "location": "l", 13090 "email": "e", 13091 "hireable": true, 13092 "bio": "b", 13093 "twitter_username": "t", 13094 "public_repos": 1, 13095 "followers": 1, 13096 "following": 1, 13097 "created_at": ` + referenceTimeStr + `, 13098 "suspended_at": ` + referenceTimeStr + `, 13099 "url": "u" 13100 }, 13101 "suspended_at": ` + referenceTimeStr + ` 13102 } 13103 }` 13104 13105 testJSONMarshal(t, r, want) 13106 } 13107 13108 func TestDeployKeyEvent_Marshal(t *testing.T) { 13109 t.Parallel() 13110 testJSONMarshal(t, &DeployKeyEvent{}, "{}") 13111 13112 u := &DeployKeyEvent{ 13113 Action: Ptr("a"), 13114 Key: &Key{ 13115 ID: Ptr(int64(1)), 13116 Key: Ptr("k"), 13117 URL: Ptr("k"), 13118 Title: Ptr("k"), 13119 ReadOnly: Ptr(false), 13120 Verified: Ptr(false), 13121 CreatedAt: &Timestamp{referenceTime}, 13122 }, 13123 Repo: &Repository{ 13124 ID: Ptr(int64(1)), 13125 URL: Ptr("s"), 13126 Name: Ptr("n"), 13127 }, 13128 Organization: &Organization{ 13129 BillingEmail: Ptr("be"), 13130 Blog: Ptr("b"), 13131 Company: Ptr("c"), 13132 Email: Ptr("e"), 13133 TwitterUsername: Ptr("tu"), 13134 Location: Ptr("loc"), 13135 Name: Ptr("n"), 13136 Description: Ptr("d"), 13137 IsVerified: Ptr(true), 13138 HasOrganizationProjects: Ptr(true), 13139 HasRepositoryProjects: Ptr(true), 13140 DefaultRepoPermission: Ptr("drp"), 13141 MembersCanCreateRepos: Ptr(true), 13142 MembersCanCreateInternalRepos: Ptr(true), 13143 MembersCanCreatePrivateRepos: Ptr(true), 13144 MembersCanCreatePublicRepos: Ptr(false), 13145 MembersAllowedRepositoryCreationType: Ptr("marct"), 13146 MembersCanCreatePages: Ptr(true), 13147 MembersCanCreatePublicPages: Ptr(false), 13148 MembersCanCreatePrivatePages: Ptr(true), 13149 }, 13150 Sender: &User{ 13151 Login: Ptr("l"), 13152 ID: Ptr(int64(1)), 13153 NodeID: Ptr("n"), 13154 AvatarURL: Ptr("a"), 13155 URL: Ptr("u"), 13156 EventsURL: Ptr("e"), 13157 ReposURL: Ptr("r"), 13158 }, 13159 } 13160 13161 want := `{ 13162 "action": "a", 13163 "key": { 13164 "id": 1, 13165 "key": "k", 13166 "url": "k", 13167 "title": "k", 13168 "read_only": false, 13169 "verified": false, 13170 "created_at": ` + referenceTimeStr + ` 13171 }, 13172 "repository": { 13173 "id": 1, 13174 "name": "n", 13175 "url": "s" 13176 }, 13177 "organization": { 13178 "name": "n", 13179 "company": "c", 13180 "blog": "b", 13181 "location": "loc", 13182 "email": "e", 13183 "twitter_username": "tu", 13184 "description": "d", 13185 "billing_email": "be", 13186 "is_verified": true, 13187 "has_organization_projects": true, 13188 "has_repository_projects": true, 13189 "default_repository_permission": "drp", 13190 "members_can_create_repositories": true, 13191 "members_can_create_public_repositories": false, 13192 "members_can_create_private_repositories": true, 13193 "members_can_create_internal_repositories": true, 13194 "members_allowed_repository_creation_type": "marct", 13195 "members_can_create_pages": true, 13196 "members_can_create_public_pages": false, 13197 "members_can_create_private_pages": true 13198 }, 13199 "sender": { 13200 "login": "l", 13201 "id": 1, 13202 "node_id": "n", 13203 "avatar_url": "a", 13204 "url": "u", 13205 "events_url": "e", 13206 "repos_url": "r" 13207 } 13208 }` 13209 13210 testJSONMarshal(t, u, want) 13211 } 13212 13213 func TestMetaEvent_Marshal(t *testing.T) { 13214 t.Parallel() 13215 testJSONMarshal(t, &MetaEvent{}, "{}") 13216 13217 v := make(map[string]interface{}) 13218 v["a"] = "b" 13219 hookConfig := &HookConfig{ 13220 ContentType: Ptr("json"), 13221 } 13222 13223 u := &MetaEvent{ 13224 Action: Ptr("a"), 13225 HookID: Ptr(int64(1)), 13226 Hook: &Hook{ 13227 CreatedAt: &Timestamp{referenceTime}, 13228 UpdatedAt: &Timestamp{referenceTime}, 13229 URL: Ptr("u"), 13230 ID: Ptr(int64(1)), 13231 Type: Ptr("t"), 13232 Name: Ptr("n"), 13233 TestURL: Ptr("tu"), 13234 PingURL: Ptr("pu"), 13235 LastResponse: v, 13236 Config: hookConfig, 13237 Events: []string{"a"}, 13238 Active: Ptr(true), 13239 }, 13240 } 13241 13242 want := `{ 13243 "action": "a", 13244 "hook_id": 1, 13245 "hook": { 13246 "created_at": ` + referenceTimeStr + `, 13247 "updated_at": ` + referenceTimeStr + `, 13248 "url": "u", 13249 "id": 1, 13250 "type": "t", 13251 "name": "n", 13252 "test_url": "tu", 13253 "ping_url": "pu", 13254 "last_response": { 13255 "a": "b" 13256 }, 13257 "config": { 13258 "content_type": "json" 13259 }, 13260 "events": [ 13261 "a" 13262 ], 13263 "active": true 13264 } 13265 }` 13266 13267 testJSONMarshal(t, u, want) 13268 } 13269 13270 func TestRequestedAction_Marshal(t *testing.T) { 13271 t.Parallel() 13272 testJSONMarshal(t, &RequestedAction{}, "{}") 13273 13274 r := &RequestedAction{ 13275 Identifier: "i", 13276 } 13277 13278 want := `{ 13279 "identifier": "i" 13280 }` 13281 13282 testJSONMarshal(t, r, want) 13283 } 13284 13285 func TestCreateEvent_Marshal(t *testing.T) { 13286 t.Parallel() 13287 testJSONMarshal(t, &CreateEvent{}, "{}") 13288 13289 r := &CreateEvent{ 13290 Ref: Ptr("r"), 13291 RefType: Ptr("rt"), 13292 MasterBranch: Ptr("mb"), 13293 Description: Ptr("d"), 13294 PusherType: Ptr("pt"), 13295 Repo: &Repository{ 13296 ID: Ptr(int64(1)), 13297 URL: Ptr("s"), 13298 Name: Ptr("n"), 13299 }, 13300 Sender: &User{ 13301 Login: Ptr("l"), 13302 ID: Ptr(int64(1)), 13303 NodeID: Ptr("n"), 13304 URL: Ptr("u"), 13305 ReposURL: Ptr("r"), 13306 EventsURL: Ptr("e"), 13307 AvatarURL: Ptr("a"), 13308 }, 13309 Installation: &Installation{ 13310 ID: Ptr(int64(1)), 13311 NodeID: Ptr("nid"), 13312 AppID: Ptr(int64(1)), 13313 AppSlug: Ptr("as"), 13314 TargetID: Ptr(int64(1)), 13315 Account: &User{ 13316 Login: Ptr("l"), 13317 ID: Ptr(int64(1)), 13318 URL: Ptr("u"), 13319 AvatarURL: Ptr("a"), 13320 GravatarID: Ptr("g"), 13321 Name: Ptr("n"), 13322 Company: Ptr("c"), 13323 Blog: Ptr("b"), 13324 Location: Ptr("l"), 13325 Email: Ptr("e"), 13326 Hireable: Ptr(true), 13327 Bio: Ptr("b"), 13328 TwitterUsername: Ptr("t"), 13329 PublicRepos: Ptr(1), 13330 Followers: Ptr(1), 13331 Following: Ptr(1), 13332 CreatedAt: &Timestamp{referenceTime}, 13333 SuspendedAt: &Timestamp{referenceTime}, 13334 }, 13335 AccessTokensURL: Ptr("atu"), 13336 RepositoriesURL: Ptr("ru"), 13337 HTMLURL: Ptr("hu"), 13338 TargetType: Ptr("tt"), 13339 SingleFileName: Ptr("sfn"), 13340 RepositorySelection: Ptr("rs"), 13341 Events: []string{"e"}, 13342 SingleFilePaths: []string{"s"}, 13343 Permissions: &InstallationPermissions{ 13344 Actions: Ptr("a"), 13345 Administration: Ptr("ad"), 13346 Checks: Ptr("c"), 13347 Contents: Ptr("co"), 13348 ContentReferences: Ptr("cr"), 13349 Deployments: Ptr("d"), 13350 Environments: Ptr("e"), 13351 Issues: Ptr("i"), 13352 Metadata: Ptr("md"), 13353 Members: Ptr("m"), 13354 OrganizationAdministration: Ptr("oa"), 13355 OrganizationHooks: Ptr("oh"), 13356 OrganizationPlan: Ptr("op"), 13357 OrganizationPreReceiveHooks: Ptr("opr"), 13358 OrganizationProjects: Ptr("op"), 13359 OrganizationSecrets: Ptr("os"), 13360 OrganizationSelfHostedRunners: Ptr("osh"), 13361 OrganizationUserBlocking: Ptr("oub"), 13362 Packages: Ptr("pkg"), 13363 Pages: Ptr("pg"), 13364 PullRequests: Ptr("pr"), 13365 RepositoryHooks: Ptr("rh"), 13366 RepositoryProjects: Ptr("rp"), 13367 RepositoryPreReceiveHooks: Ptr("rprh"), 13368 Secrets: Ptr("s"), 13369 SecretScanningAlerts: Ptr("ssa"), 13370 SecurityEvents: Ptr("se"), 13371 SingleFile: Ptr("sf"), 13372 Statuses: Ptr("s"), 13373 TeamDiscussions: Ptr("td"), 13374 VulnerabilityAlerts: Ptr("va"), 13375 Workflows: Ptr("w"), 13376 }, 13377 CreatedAt: &Timestamp{referenceTime}, 13378 UpdatedAt: &Timestamp{referenceTime}, 13379 HasMultipleSingleFiles: Ptr(false), 13380 SuspendedBy: &User{ 13381 Login: Ptr("l"), 13382 ID: Ptr(int64(1)), 13383 URL: Ptr("u"), 13384 AvatarURL: Ptr("a"), 13385 GravatarID: Ptr("g"), 13386 Name: Ptr("n"), 13387 Company: Ptr("c"), 13388 Blog: Ptr("b"), 13389 Location: Ptr("l"), 13390 Email: Ptr("e"), 13391 Hireable: Ptr(true), 13392 Bio: Ptr("b"), 13393 TwitterUsername: Ptr("t"), 13394 PublicRepos: Ptr(1), 13395 Followers: Ptr(1), 13396 Following: Ptr(1), 13397 CreatedAt: &Timestamp{referenceTime}, 13398 SuspendedAt: &Timestamp{referenceTime}, 13399 }, 13400 SuspendedAt: &Timestamp{referenceTime}, 13401 }, 13402 } 13403 13404 want := `{ 13405 "ref": "r", 13406 "ref_type": "rt", 13407 "master_branch": "mb", 13408 "description": "d", 13409 "pusher_type": "pt", 13410 "repository": { 13411 "id": 1, 13412 "name": "n", 13413 "url": "s" 13414 }, 13415 "sender": { 13416 "login": "l", 13417 "id": 1, 13418 "node_id": "n", 13419 "avatar_url": "a", 13420 "url": "u", 13421 "events_url": "e", 13422 "repos_url": "r" 13423 }, 13424 "installation": { 13425 "id": 1, 13426 "node_id": "nid", 13427 "app_id": 1, 13428 "app_slug": "as", 13429 "target_id": 1, 13430 "account": { 13431 "login": "l", 13432 "id": 1, 13433 "avatar_url": "a", 13434 "gravatar_id": "g", 13435 "name": "n", 13436 "company": "c", 13437 "blog": "b", 13438 "location": "l", 13439 "email": "e", 13440 "hireable": true, 13441 "bio": "b", 13442 "twitter_username": "t", 13443 "public_repos": 1, 13444 "followers": 1, 13445 "following": 1, 13446 "created_at": ` + referenceTimeStr + `, 13447 "suspended_at": ` + referenceTimeStr + `, 13448 "url": "u" 13449 }, 13450 "access_tokens_url": "atu", 13451 "repositories_url": "ru", 13452 "html_url": "hu", 13453 "target_type": "tt", 13454 "single_file_name": "sfn", 13455 "repository_selection": "rs", 13456 "events": [ 13457 "e" 13458 ], 13459 "single_file_paths": [ 13460 "s" 13461 ], 13462 "permissions": { 13463 "actions": "a", 13464 "administration": "ad", 13465 "checks": "c", 13466 "contents": "co", 13467 "content_references": "cr", 13468 "deployments": "d", 13469 "environments": "e", 13470 "issues": "i", 13471 "metadata": "md", 13472 "members": "m", 13473 "organization_administration": "oa", 13474 "organization_hooks": "oh", 13475 "organization_plan": "op", 13476 "organization_pre_receive_hooks": "opr", 13477 "organization_projects": "op", 13478 "organization_secrets": "os", 13479 "organization_self_hosted_runners": "osh", 13480 "organization_user_blocking": "oub", 13481 "packages": "pkg", 13482 "pages": "pg", 13483 "pull_requests": "pr", 13484 "repository_hooks": "rh", 13485 "repository_projects": "rp", 13486 "repository_pre_receive_hooks": "rprh", 13487 "secrets": "s", 13488 "secret_scanning_alerts": "ssa", 13489 "security_events": "se", 13490 "single_file": "sf", 13491 "statuses": "s", 13492 "team_discussions": "td", 13493 "vulnerability_alerts": "va", 13494 "workflows": "w" 13495 }, 13496 "created_at": ` + referenceTimeStr + `, 13497 "updated_at": ` + referenceTimeStr + `, 13498 "has_multiple_single_files": false, 13499 "suspended_by": { 13500 "login": "l", 13501 "id": 1, 13502 "avatar_url": "a", 13503 "gravatar_id": "g", 13504 "name": "n", 13505 "company": "c", 13506 "blog": "b", 13507 "location": "l", 13508 "email": "e", 13509 "hireable": true, 13510 "bio": "b", 13511 "twitter_username": "t", 13512 "public_repos": 1, 13513 "followers": 1, 13514 "following": 1, 13515 "created_at": ` + referenceTimeStr + `, 13516 "suspended_at": ` + referenceTimeStr + `, 13517 "url": "u" 13518 }, 13519 "suspended_at": ` + referenceTimeStr + ` 13520 } 13521 }` 13522 13523 testJSONMarshal(t, r, want) 13524 } 13525 13526 func TestCustomPropertyEvent_Marshal(t *testing.T) { 13527 t.Parallel() 13528 testJSONMarshal(t, &CustomPropertyEvent{}, "{}") 13529 13530 r := &CustomPropertyEvent{ 13531 Action: Ptr("created"), 13532 Definition: &CustomProperty{ 13533 PropertyName: Ptr("name"), 13534 ValueType: "single_select", 13535 SourceType: Ptr("enterprise"), 13536 Required: Ptr(true), 13537 DefaultValue: Ptr("production"), 13538 Description: Ptr("Prod or dev environment"), 13539 AllowedValues: []string{"production", "development"}, 13540 ValuesEditableBy: Ptr("org_actors"), 13541 }, 13542 Sender: &User{ 13543 Login: Ptr("l"), 13544 ID: Ptr(int64(1)), 13545 NodeID: Ptr("n"), 13546 URL: Ptr("u"), 13547 ReposURL: Ptr("r"), 13548 EventsURL: Ptr("e"), 13549 AvatarURL: Ptr("a"), 13550 }, 13551 Installation: &Installation{ 13552 ID: Ptr(int64(1)), 13553 NodeID: Ptr("nid"), 13554 AppID: Ptr(int64(1)), 13555 AppSlug: Ptr("as"), 13556 TargetID: Ptr(int64(1)), 13557 Account: &User{ 13558 Login: Ptr("l"), 13559 ID: Ptr(int64(1)), 13560 URL: Ptr("u"), 13561 AvatarURL: Ptr("a"), 13562 GravatarID: Ptr("g"), 13563 Name: Ptr("n"), 13564 Company: Ptr("c"), 13565 Blog: Ptr("b"), 13566 Location: Ptr("l"), 13567 Email: Ptr("e"), 13568 Hireable: Ptr(true), 13569 Bio: Ptr("b"), 13570 TwitterUsername: Ptr("t"), 13571 PublicRepos: Ptr(1), 13572 Followers: Ptr(1), 13573 Following: Ptr(1), 13574 CreatedAt: &Timestamp{referenceTime}, 13575 SuspendedAt: &Timestamp{referenceTime}, 13576 }, 13577 AccessTokensURL: Ptr("atu"), 13578 RepositoriesURL: Ptr("ru"), 13579 HTMLURL: Ptr("hu"), 13580 TargetType: Ptr("tt"), 13581 SingleFileName: Ptr("sfn"), 13582 RepositorySelection: Ptr("rs"), 13583 Events: []string{"e"}, 13584 SingleFilePaths: []string{"s"}, 13585 Permissions: &InstallationPermissions{ 13586 Actions: Ptr("a"), 13587 Administration: Ptr("ad"), 13588 Checks: Ptr("c"), 13589 Contents: Ptr("co"), 13590 ContentReferences: Ptr("cr"), 13591 Deployments: Ptr("d"), 13592 Environments: Ptr("e"), 13593 Issues: Ptr("i"), 13594 Metadata: Ptr("md"), 13595 Members: Ptr("m"), 13596 OrganizationAdministration: Ptr("oa"), 13597 OrganizationHooks: Ptr("oh"), 13598 OrganizationPlan: Ptr("op"), 13599 OrganizationPreReceiveHooks: Ptr("opr"), 13600 OrganizationProjects: Ptr("op"), 13601 OrganizationSecrets: Ptr("os"), 13602 OrganizationSelfHostedRunners: Ptr("osh"), 13603 OrganizationUserBlocking: Ptr("oub"), 13604 Packages: Ptr("pkg"), 13605 Pages: Ptr("pg"), 13606 PullRequests: Ptr("pr"), 13607 RepositoryHooks: Ptr("rh"), 13608 RepositoryProjects: Ptr("rp"), 13609 RepositoryPreReceiveHooks: Ptr("rprh"), 13610 Secrets: Ptr("s"), 13611 SecretScanningAlerts: Ptr("ssa"), 13612 SecurityEvents: Ptr("se"), 13613 SingleFile: Ptr("sf"), 13614 Statuses: Ptr("s"), 13615 TeamDiscussions: Ptr("td"), 13616 VulnerabilityAlerts: Ptr("va"), 13617 Workflows: Ptr("w"), 13618 }, 13619 CreatedAt: &Timestamp{referenceTime}, 13620 UpdatedAt: &Timestamp{referenceTime}, 13621 HasMultipleSingleFiles: Ptr(false), 13622 SuspendedBy: &User{ 13623 Login: Ptr("l"), 13624 ID: Ptr(int64(1)), 13625 URL: Ptr("u"), 13626 AvatarURL: Ptr("a"), 13627 GravatarID: Ptr("g"), 13628 Name: Ptr("n"), 13629 Company: Ptr("c"), 13630 Blog: Ptr("b"), 13631 Location: Ptr("l"), 13632 Email: Ptr("e"), 13633 Hireable: Ptr(true), 13634 Bio: Ptr("b"), 13635 TwitterUsername: Ptr("t"), 13636 PublicRepos: Ptr(1), 13637 Followers: Ptr(1), 13638 Following: Ptr(1), 13639 CreatedAt: &Timestamp{referenceTime}, 13640 SuspendedAt: &Timestamp{referenceTime}, 13641 }, 13642 SuspendedAt: &Timestamp{referenceTime}, 13643 }, 13644 } 13645 13646 want := `{ 13647 "action": "created", 13648 "definition": { 13649 "property_name": "name", 13650 "source_type": "enterprise", 13651 "value_type": "single_select", 13652 "required": true, 13653 "default_value": "production", 13654 "description": "Prod or dev environment", 13655 "allowed_values": [ 13656 "production", 13657 "development" 13658 ], 13659 "values_editable_by": "org_actors" 13660 }, 13661 "repository": { 13662 "id": 1, 13663 "name": "n", 13664 "url": "s" 13665 }, 13666 "sender": { 13667 "login": "l", 13668 "id": 1, 13669 "node_id": "n", 13670 "avatar_url": "a", 13671 "url": "u", 13672 "events_url": "e", 13673 "repos_url": "r" 13674 }, 13675 "installation": { 13676 "id": 1, 13677 "node_id": "nid", 13678 "app_id": 1, 13679 "app_slug": "as", 13680 "target_id": 1, 13681 "account": { 13682 "login": "l", 13683 "id": 1, 13684 "avatar_url": "a", 13685 "gravatar_id": "g", 13686 "name": "n", 13687 "company": "c", 13688 "blog": "b", 13689 "location": "l", 13690 "email": "e", 13691 "hireable": true, 13692 "bio": "b", 13693 "twitter_username": "t", 13694 "public_repos": 1, 13695 "followers": 1, 13696 "following": 1, 13697 "created_at": ` + referenceTimeStr + `, 13698 "suspended_at": ` + referenceTimeStr + `, 13699 "url": "u" 13700 }, 13701 "access_tokens_url": "atu", 13702 "repositories_url": "ru", 13703 "html_url": "hu", 13704 "target_type": "tt", 13705 "single_file_name": "sfn", 13706 "repository_selection": "rs", 13707 "events": [ 13708 "e" 13709 ], 13710 "single_file_paths": [ 13711 "s" 13712 ], 13713 "permissions": { 13714 "actions": "a", 13715 "administration": "ad", 13716 "checks": "c", 13717 "contents": "co", 13718 "content_references": "cr", 13719 "deployments": "d", 13720 "environments": "e", 13721 "issues": "i", 13722 "metadata": "md", 13723 "members": "m", 13724 "organization_administration": "oa", 13725 "organization_hooks": "oh", 13726 "organization_plan": "op", 13727 "organization_pre_receive_hooks": "opr", 13728 "organization_projects": "op", 13729 "organization_secrets": "os", 13730 "organization_self_hosted_runners": "osh", 13731 "organization_user_blocking": "oub", 13732 "packages": "pkg", 13733 "pages": "pg", 13734 "pull_requests": "pr", 13735 "repository_hooks": "rh", 13736 "repository_projects": "rp", 13737 "repository_pre_receive_hooks": "rprh", 13738 "secrets": "s", 13739 "secret_scanning_alerts": "ssa", 13740 "security_events": "se", 13741 "single_file": "sf", 13742 "statuses": "s", 13743 "team_discussions": "td", 13744 "vulnerability_alerts": "va", 13745 "workflows": "w" 13746 }, 13747 "created_at": ` + referenceTimeStr + `, 13748 "updated_at": ` + referenceTimeStr + `, 13749 "has_multiple_single_files": false, 13750 "suspended_by": { 13751 "login": "l", 13752 "id": 1, 13753 "avatar_url": "a", 13754 "gravatar_id": "g", 13755 "name": "n", 13756 "company": "c", 13757 "blog": "b", 13758 "location": "l", 13759 "email": "e", 13760 "hireable": true, 13761 "bio": "b", 13762 "twitter_username": "t", 13763 "public_repos": 1, 13764 "followers": 1, 13765 "following": 1, 13766 "created_at": ` + referenceTimeStr + `, 13767 "suspended_at": ` + referenceTimeStr + `, 13768 "url": "u" 13769 }, 13770 "suspended_at": ` + referenceTimeStr + ` 13771 } 13772 }` 13773 13774 testJSONMarshal(t, r, want) 13775 } 13776 13777 func TestCustomPropertyValuesEvent_Marshal(t *testing.T) { 13778 t.Parallel() 13779 testJSONMarshal(t, &CustomPropertyValuesEvent{}, "{}") 13780 13781 r := &CustomPropertyValuesEvent{ 13782 Action: Ptr("updated"), 13783 NewPropertyValues: []*CustomPropertyValue{ 13784 { 13785 PropertyName: "environment", 13786 Value: "production", 13787 }, 13788 }, 13789 OldPropertyValues: []*CustomPropertyValue{ 13790 { 13791 PropertyName: "environment", 13792 Value: "staging", 13793 }, 13794 }, 13795 Sender: &User{ 13796 Login: Ptr("l"), 13797 ID: Ptr(int64(1)), 13798 NodeID: Ptr("n"), 13799 URL: Ptr("u"), 13800 ReposURL: Ptr("r"), 13801 EventsURL: Ptr("e"), 13802 AvatarURL: Ptr("a"), 13803 }, 13804 Installation: &Installation{ 13805 ID: Ptr(int64(1)), 13806 NodeID: Ptr("nid"), 13807 AppID: Ptr(int64(1)), 13808 AppSlug: Ptr("as"), 13809 TargetID: Ptr(int64(1)), 13810 Account: &User{ 13811 Login: Ptr("l"), 13812 ID: Ptr(int64(1)), 13813 URL: Ptr("u"), 13814 AvatarURL: Ptr("a"), 13815 GravatarID: Ptr("g"), 13816 Name: Ptr("n"), 13817 Company: Ptr("c"), 13818 Blog: Ptr("b"), 13819 Location: Ptr("l"), 13820 Email: Ptr("e"), 13821 Hireable: Ptr(true), 13822 Bio: Ptr("b"), 13823 TwitterUsername: Ptr("t"), 13824 PublicRepos: Ptr(1), 13825 Followers: Ptr(1), 13826 Following: Ptr(1), 13827 CreatedAt: &Timestamp{referenceTime}, 13828 SuspendedAt: &Timestamp{referenceTime}, 13829 }, 13830 AccessTokensURL: Ptr("atu"), 13831 RepositoriesURL: Ptr("ru"), 13832 HTMLURL: Ptr("hu"), 13833 TargetType: Ptr("tt"), 13834 SingleFileName: Ptr("sfn"), 13835 RepositorySelection: Ptr("rs"), 13836 Events: []string{"e"}, 13837 SingleFilePaths: []string{"s"}, 13838 Permissions: &InstallationPermissions{ 13839 Actions: Ptr("a"), 13840 Administration: Ptr("ad"), 13841 Checks: Ptr("c"), 13842 Contents: Ptr("co"), 13843 ContentReferences: Ptr("cr"), 13844 Deployments: Ptr("d"), 13845 Environments: Ptr("e"), 13846 Issues: Ptr("i"), 13847 Metadata: Ptr("md"), 13848 Members: Ptr("m"), 13849 OrganizationAdministration: Ptr("oa"), 13850 OrganizationHooks: Ptr("oh"), 13851 OrganizationPlan: Ptr("op"), 13852 OrganizationPreReceiveHooks: Ptr("opr"), 13853 OrganizationProjects: Ptr("op"), 13854 OrganizationSecrets: Ptr("os"), 13855 OrganizationSelfHostedRunners: Ptr("osh"), 13856 OrganizationUserBlocking: Ptr("oub"), 13857 Packages: Ptr("pkg"), 13858 Pages: Ptr("pg"), 13859 PullRequests: Ptr("pr"), 13860 RepositoryHooks: Ptr("rh"), 13861 RepositoryProjects: Ptr("rp"), 13862 RepositoryPreReceiveHooks: Ptr("rprh"), 13863 Secrets: Ptr("s"), 13864 SecretScanningAlerts: Ptr("ssa"), 13865 SecurityEvents: Ptr("se"), 13866 SingleFile: Ptr("sf"), 13867 Statuses: Ptr("s"), 13868 TeamDiscussions: Ptr("td"), 13869 VulnerabilityAlerts: Ptr("va"), 13870 Workflows: Ptr("w"), 13871 }, 13872 CreatedAt: &Timestamp{referenceTime}, 13873 UpdatedAt: &Timestamp{referenceTime}, 13874 HasMultipleSingleFiles: Ptr(false), 13875 SuspendedBy: &User{ 13876 Login: Ptr("l"), 13877 ID: Ptr(int64(1)), 13878 URL: Ptr("u"), 13879 AvatarURL: Ptr("a"), 13880 GravatarID: Ptr("g"), 13881 Name: Ptr("n"), 13882 Company: Ptr("c"), 13883 Blog: Ptr("b"), 13884 Location: Ptr("l"), 13885 Email: Ptr("e"), 13886 Hireable: Ptr(true), 13887 Bio: Ptr("b"), 13888 TwitterUsername: Ptr("t"), 13889 PublicRepos: Ptr(1), 13890 Followers: Ptr(1), 13891 Following: Ptr(1), 13892 CreatedAt: &Timestamp{referenceTime}, 13893 SuspendedAt: &Timestamp{referenceTime}, 13894 }, 13895 SuspendedAt: &Timestamp{referenceTime}, 13896 }, 13897 } 13898 13899 want := `{ 13900 "action": "updated", 13901 "new_property_values": [{ 13902 "property_name": "environment", 13903 "value": "production" 13904 }], 13905 "old_property_values": [{ 13906 "property_name": "environment", 13907 "value": "staging" 13908 }], 13909 "sender": { 13910 "login": "l", 13911 "id": 1, 13912 "node_id": "n", 13913 "avatar_url": "a", 13914 "url": "u", 13915 "events_url": "e", 13916 "repos_url": "r" 13917 }, 13918 "installation": { 13919 "id": 1, 13920 "node_id": "nid", 13921 "app_id": 1, 13922 "app_slug": "as", 13923 "target_id": 1, 13924 "account": { 13925 "login": "l", 13926 "id": 1, 13927 "avatar_url": "a", 13928 "gravatar_id": "g", 13929 "name": "n", 13930 "company": "c", 13931 "blog": "b", 13932 "location": "l", 13933 "email": "e", 13934 "hireable": true, 13935 "bio": "b", 13936 "twitter_username": "t", 13937 "public_repos": 1, 13938 "followers": 1, 13939 "following": 1, 13940 "created_at": ` + referenceTimeStr + `, 13941 "suspended_at": ` + referenceTimeStr + `, 13942 "url": "u" 13943 }, 13944 "access_tokens_url": "atu", 13945 "repositories_url": "ru", 13946 "html_url": "hu", 13947 "target_type": "tt", 13948 "single_file_name": "sfn", 13949 "repository_selection": "rs", 13950 "events": [ 13951 "e" 13952 ], 13953 "single_file_paths": [ 13954 "s" 13955 ], 13956 "permissions": { 13957 "actions": "a", 13958 "administration": "ad", 13959 "checks": "c", 13960 "contents": "co", 13961 "content_references": "cr", 13962 "deployments": "d", 13963 "environments": "e", 13964 "issues": "i", 13965 "metadata": "md", 13966 "members": "m", 13967 "organization_administration": "oa", 13968 "organization_hooks": "oh", 13969 "organization_plan": "op", 13970 "organization_pre_receive_hooks": "opr", 13971 "organization_projects": "op", 13972 "organization_secrets": "os", 13973 "organization_self_hosted_runners": "osh", 13974 "organization_user_blocking": "oub", 13975 "packages": "pkg", 13976 "pages": "pg", 13977 "pull_requests": "pr", 13978 "repository_hooks": "rh", 13979 "repository_projects": "rp", 13980 "repository_pre_receive_hooks": "rprh", 13981 "secrets": "s", 13982 "secret_scanning_alerts": "ssa", 13983 "security_events": "se", 13984 "single_file": "sf", 13985 "statuses": "s", 13986 "team_discussions": "td", 13987 "vulnerability_alerts": "va", 13988 "workflows": "w" 13989 }, 13990 "created_at": ` + referenceTimeStr + `, 13991 "updated_at": ` + referenceTimeStr + `, 13992 "has_multiple_single_files": false, 13993 "suspended_by": { 13994 "login": "l", 13995 "id": 1, 13996 "avatar_url": "a", 13997 "gravatar_id": "g", 13998 "name": "n", 13999 "company": "c", 14000 "blog": "b", 14001 "location": "l", 14002 "email": "e", 14003 "hireable": true, 14004 "bio": "b", 14005 "twitter_username": "t", 14006 "public_repos": 1, 14007 "followers": 1, 14008 "following": 1, 14009 "created_at": ` + referenceTimeStr + `, 14010 "suspended_at": ` + referenceTimeStr + `, 14011 "url": "u" 14012 }, 14013 "suspended_at": ` + referenceTimeStr + ` 14014 } 14015 }` 14016 14017 testJSONMarshal(t, r, want) 14018 } 14019 14020 func TestDeleteEvent_Marshal(t *testing.T) { 14021 t.Parallel() 14022 testJSONMarshal(t, &DeleteEvent{}, "{}") 14023 14024 r := &DeleteEvent{ 14025 Ref: Ptr("r"), 14026 RefType: Ptr("rt"), 14027 PusherType: Ptr("pt"), 14028 Repo: &Repository{ 14029 ID: Ptr(int64(1)), 14030 URL: Ptr("s"), 14031 Name: Ptr("n"), 14032 }, 14033 Sender: &User{ 14034 Login: Ptr("l"), 14035 ID: Ptr(int64(1)), 14036 NodeID: Ptr("n"), 14037 URL: Ptr("u"), 14038 ReposURL: Ptr("r"), 14039 EventsURL: Ptr("e"), 14040 AvatarURL: Ptr("a"), 14041 }, 14042 Installation: &Installation{ 14043 ID: Ptr(int64(1)), 14044 NodeID: Ptr("nid"), 14045 AppID: Ptr(int64(1)), 14046 AppSlug: Ptr("as"), 14047 TargetID: Ptr(int64(1)), 14048 Account: &User{ 14049 Login: Ptr("l"), 14050 ID: Ptr(int64(1)), 14051 URL: Ptr("u"), 14052 AvatarURL: Ptr("a"), 14053 GravatarID: Ptr("g"), 14054 Name: Ptr("n"), 14055 Company: Ptr("c"), 14056 Blog: Ptr("b"), 14057 Location: Ptr("l"), 14058 Email: Ptr("e"), 14059 Hireable: Ptr(true), 14060 Bio: Ptr("b"), 14061 TwitterUsername: Ptr("t"), 14062 PublicRepos: Ptr(1), 14063 Followers: Ptr(1), 14064 Following: Ptr(1), 14065 CreatedAt: &Timestamp{referenceTime}, 14066 SuspendedAt: &Timestamp{referenceTime}, 14067 }, 14068 AccessTokensURL: Ptr("atu"), 14069 RepositoriesURL: Ptr("ru"), 14070 HTMLURL: Ptr("hu"), 14071 TargetType: Ptr("tt"), 14072 SingleFileName: Ptr("sfn"), 14073 RepositorySelection: Ptr("rs"), 14074 Events: []string{"e"}, 14075 SingleFilePaths: []string{"s"}, 14076 Permissions: &InstallationPermissions{ 14077 Actions: Ptr("a"), 14078 Administration: Ptr("ad"), 14079 Checks: Ptr("c"), 14080 Contents: Ptr("co"), 14081 ContentReferences: Ptr("cr"), 14082 Deployments: Ptr("d"), 14083 Environments: Ptr("e"), 14084 Issues: Ptr("i"), 14085 Metadata: Ptr("md"), 14086 Members: Ptr("m"), 14087 OrganizationAdministration: Ptr("oa"), 14088 OrganizationHooks: Ptr("oh"), 14089 OrganizationPlan: Ptr("op"), 14090 OrganizationPreReceiveHooks: Ptr("opr"), 14091 OrganizationProjects: Ptr("op"), 14092 OrganizationSecrets: Ptr("os"), 14093 OrganizationSelfHostedRunners: Ptr("osh"), 14094 OrganizationUserBlocking: Ptr("oub"), 14095 Packages: Ptr("pkg"), 14096 Pages: Ptr("pg"), 14097 PullRequests: Ptr("pr"), 14098 RepositoryHooks: Ptr("rh"), 14099 RepositoryProjects: Ptr("rp"), 14100 RepositoryPreReceiveHooks: Ptr("rprh"), 14101 Secrets: Ptr("s"), 14102 SecretScanningAlerts: Ptr("ssa"), 14103 SecurityEvents: Ptr("se"), 14104 SingleFile: Ptr("sf"), 14105 Statuses: Ptr("s"), 14106 TeamDiscussions: Ptr("td"), 14107 VulnerabilityAlerts: Ptr("va"), 14108 Workflows: Ptr("w"), 14109 }, 14110 CreatedAt: &Timestamp{referenceTime}, 14111 UpdatedAt: &Timestamp{referenceTime}, 14112 HasMultipleSingleFiles: Ptr(false), 14113 SuspendedBy: &User{ 14114 Login: Ptr("l"), 14115 ID: Ptr(int64(1)), 14116 URL: Ptr("u"), 14117 AvatarURL: Ptr("a"), 14118 GravatarID: Ptr("g"), 14119 Name: Ptr("n"), 14120 Company: Ptr("c"), 14121 Blog: Ptr("b"), 14122 Location: Ptr("l"), 14123 Email: Ptr("e"), 14124 Hireable: Ptr(true), 14125 Bio: Ptr("b"), 14126 TwitterUsername: Ptr("t"), 14127 PublicRepos: Ptr(1), 14128 Followers: Ptr(1), 14129 Following: Ptr(1), 14130 CreatedAt: &Timestamp{referenceTime}, 14131 SuspendedAt: &Timestamp{referenceTime}, 14132 }, 14133 SuspendedAt: &Timestamp{referenceTime}, 14134 }, 14135 } 14136 14137 want := `{ 14138 "ref": "r", 14139 "ref_type": "rt", 14140 "pusher_type": "pt", 14141 "repository": { 14142 "id": 1, 14143 "name": "n", 14144 "url": "s" 14145 }, 14146 "sender": { 14147 "login": "l", 14148 "id": 1, 14149 "node_id": "n", 14150 "avatar_url": "a", 14151 "url": "u", 14152 "events_url": "e", 14153 "repos_url": "r" 14154 }, 14155 "installation": { 14156 "id": 1, 14157 "node_id": "nid", 14158 "app_id": 1, 14159 "app_slug": "as", 14160 "target_id": 1, 14161 "account": { 14162 "login": "l", 14163 "id": 1, 14164 "avatar_url": "a", 14165 "gravatar_id": "g", 14166 "name": "n", 14167 "company": "c", 14168 "blog": "b", 14169 "location": "l", 14170 "email": "e", 14171 "hireable": true, 14172 "bio": "b", 14173 "twitter_username": "t", 14174 "public_repos": 1, 14175 "followers": 1, 14176 "following": 1, 14177 "created_at": ` + referenceTimeStr + `, 14178 "suspended_at": ` + referenceTimeStr + `, 14179 "url": "u" 14180 }, 14181 "access_tokens_url": "atu", 14182 "repositories_url": "ru", 14183 "html_url": "hu", 14184 "target_type": "tt", 14185 "single_file_name": "sfn", 14186 "repository_selection": "rs", 14187 "events": [ 14188 "e" 14189 ], 14190 "single_file_paths": [ 14191 "s" 14192 ], 14193 "permissions": { 14194 "actions": "a", 14195 "administration": "ad", 14196 "checks": "c", 14197 "contents": "co", 14198 "content_references": "cr", 14199 "deployments": "d", 14200 "environments": "e", 14201 "issues": "i", 14202 "metadata": "md", 14203 "members": "m", 14204 "organization_administration": "oa", 14205 "organization_hooks": "oh", 14206 "organization_plan": "op", 14207 "organization_pre_receive_hooks": "opr", 14208 "organization_projects": "op", 14209 "organization_secrets": "os", 14210 "organization_self_hosted_runners": "osh", 14211 "organization_user_blocking": "oub", 14212 "packages": "pkg", 14213 "pages": "pg", 14214 "pull_requests": "pr", 14215 "repository_hooks": "rh", 14216 "repository_projects": "rp", 14217 "repository_pre_receive_hooks": "rprh", 14218 "secrets": "s", 14219 "secret_scanning_alerts": "ssa", 14220 "security_events": "se", 14221 "single_file": "sf", 14222 "statuses": "s", 14223 "team_discussions": "td", 14224 "vulnerability_alerts": "va", 14225 "workflows": "w" 14226 }, 14227 "created_at": ` + referenceTimeStr + `, 14228 "updated_at": ` + referenceTimeStr + `, 14229 "has_multiple_single_files": false, 14230 "suspended_by": { 14231 "login": "l", 14232 "id": 1, 14233 "avatar_url": "a", 14234 "gravatar_id": "g", 14235 "name": "n", 14236 "company": "c", 14237 "blog": "b", 14238 "location": "l", 14239 "email": "e", 14240 "hireable": true, 14241 "bio": "b", 14242 "twitter_username": "t", 14243 "public_repos": 1, 14244 "followers": 1, 14245 "following": 1, 14246 "created_at": ` + referenceTimeStr + `, 14247 "suspended_at": ` + referenceTimeStr + `, 14248 "url": "u" 14249 }, 14250 "suspended_at": ` + referenceTimeStr + ` 14251 } 14252 }` 14253 14254 testJSONMarshal(t, r, want) 14255 } 14256 14257 func TestDependabotAlertEvent_Marshal(t *testing.T) { 14258 t.Parallel() 14259 testJSONMarshal(t, &DependabotAlertEvent{}, "{}") 14260 14261 e := &DependabotAlertEvent{ 14262 Action: Ptr("a"), 14263 Alert: &DependabotAlert{ 14264 Number: Ptr(1), 14265 State: Ptr("s"), 14266 Dependency: &Dependency{ 14267 Package: &VulnerabilityPackage{ 14268 Ecosystem: Ptr("e"), 14269 Name: Ptr("n"), 14270 }, 14271 ManifestPath: Ptr("mp"), 14272 Scope: Ptr("s"), 14273 }, 14274 SecurityAdvisory: &DependabotSecurityAdvisory{ 14275 GHSAID: Ptr("ghsaid"), 14276 CVEID: Ptr("cveid"), 14277 Summary: Ptr("s"), 14278 Description: Ptr("d"), 14279 Vulnerabilities: []*AdvisoryVulnerability{ 14280 { 14281 Package: &VulnerabilityPackage{ 14282 Ecosystem: Ptr("e"), 14283 Name: Ptr("n"), 14284 }, 14285 Severity: Ptr("s"), 14286 }, 14287 }, 14288 Severity: Ptr("s"), 14289 CVSS: &AdvisoryCVSS{ 14290 Score: Ptr(1.0), 14291 VectorString: Ptr("vs"), 14292 }, 14293 CWEs: []*AdvisoryCWEs{ 14294 { 14295 CWEID: Ptr("cweid"), 14296 Name: Ptr("n"), 14297 }, 14298 }, 14299 Identifiers: []*AdvisoryIdentifier{ 14300 { 14301 Value: Ptr("v"), 14302 Type: Ptr("t"), 14303 }, 14304 }, 14305 References: []*AdvisoryReference{ 14306 { 14307 URL: Ptr("u"), 14308 }, 14309 }, 14310 PublishedAt: &Timestamp{referenceTime}, 14311 UpdatedAt: &Timestamp{referenceTime}, 14312 WithdrawnAt: &Timestamp{referenceTime}, 14313 }, 14314 SecurityVulnerability: &AdvisoryVulnerability{ 14315 Package: &VulnerabilityPackage{ 14316 Ecosystem: Ptr("e"), 14317 Name: Ptr("n"), 14318 }, 14319 Severity: Ptr("s"), 14320 VulnerableVersionRange: Ptr("vvr"), 14321 FirstPatchedVersion: &FirstPatchedVersion{ 14322 Identifier: Ptr("i"), 14323 }, 14324 }, 14325 URL: Ptr("u"), 14326 HTMLURL: Ptr("hu"), 14327 CreatedAt: &Timestamp{referenceTime}, 14328 UpdatedAt: &Timestamp{referenceTime}, 14329 DismissedAt: &Timestamp{referenceTime}, 14330 DismissedBy: &User{ 14331 Login: Ptr("l"), 14332 ID: Ptr(int64(1)), 14333 NodeID: Ptr("n"), 14334 URL: Ptr("u"), 14335 ReposURL: Ptr("r"), 14336 EventsURL: Ptr("e"), 14337 AvatarURL: Ptr("a"), 14338 }, 14339 DismissedReason: Ptr("dr"), 14340 DismissedComment: Ptr("dc"), 14341 FixedAt: &Timestamp{referenceTime}, 14342 AutoDismissedAt: &Timestamp{referenceTime}, 14343 }, 14344 Repo: &Repository{ 14345 ID: Ptr(int64(1)), 14346 URL: Ptr("s"), 14347 Name: Ptr("n"), 14348 }, 14349 Organization: &Organization{ 14350 BillingEmail: Ptr("be"), 14351 Blog: Ptr("b"), 14352 Company: Ptr("c"), 14353 Email: Ptr("e"), 14354 TwitterUsername: Ptr("tu"), 14355 Location: Ptr("loc"), 14356 Name: Ptr("n"), 14357 Description: Ptr("d"), 14358 IsVerified: Ptr(true), 14359 HasOrganizationProjects: Ptr(true), 14360 HasRepositoryProjects: Ptr(true), 14361 DefaultRepoPermission: Ptr("drp"), 14362 MembersCanCreateRepos: Ptr(true), 14363 MembersCanCreateInternalRepos: Ptr(true), 14364 MembersCanCreatePrivateRepos: Ptr(true), 14365 MembersCanCreatePublicRepos: Ptr(false), 14366 MembersAllowedRepositoryCreationType: Ptr("marct"), 14367 MembersCanCreatePages: Ptr(true), 14368 MembersCanCreatePublicPages: Ptr(false), 14369 MembersCanCreatePrivatePages: Ptr(true), 14370 }, 14371 Enterprise: &Enterprise{ 14372 ID: Ptr(1), 14373 Slug: Ptr("s"), 14374 Name: Ptr("n"), 14375 NodeID: Ptr("nid"), 14376 AvatarURL: Ptr("au"), 14377 Description: Ptr("d"), 14378 WebsiteURL: Ptr("wu"), 14379 HTMLURL: Ptr("hu"), 14380 CreatedAt: &Timestamp{referenceTime}, 14381 UpdatedAt: &Timestamp{referenceTime}, 14382 }, 14383 Sender: &User{ 14384 Login: Ptr("l"), 14385 ID: Ptr(int64(1)), 14386 NodeID: Ptr("n"), 14387 URL: Ptr("u"), 14388 ReposURL: Ptr("r"), 14389 EventsURL: Ptr("e"), 14390 AvatarURL: Ptr("a"), 14391 }, 14392 Installation: &Installation{ 14393 ID: Ptr(int64(1)), 14394 NodeID: Ptr("nid"), 14395 AppID: Ptr(int64(1)), 14396 AppSlug: Ptr("as"), 14397 TargetID: Ptr(int64(1)), 14398 Account: &User{ 14399 Login: Ptr("l"), 14400 ID: Ptr(int64(1)), 14401 URL: Ptr("u"), 14402 AvatarURL: Ptr("a"), 14403 GravatarID: Ptr("g"), 14404 Name: Ptr("n"), 14405 Company: Ptr("c"), 14406 Blog: Ptr("b"), 14407 Location: Ptr("l"), 14408 Email: Ptr("e"), 14409 Hireable: Ptr(true), 14410 Bio: Ptr("b"), 14411 TwitterUsername: Ptr("t"), 14412 PublicRepos: Ptr(1), 14413 Followers: Ptr(1), 14414 Following: Ptr(1), 14415 CreatedAt: &Timestamp{referenceTime}, 14416 SuspendedAt: &Timestamp{referenceTime}, 14417 }, 14418 AccessTokensURL: Ptr("atu"), 14419 RepositoriesURL: Ptr("ru"), 14420 HTMLURL: Ptr("hu"), 14421 TargetType: Ptr("tt"), 14422 SingleFileName: Ptr("sfn"), 14423 RepositorySelection: Ptr("rs"), 14424 Events: []string{"e"}, 14425 SingleFilePaths: []string{"s"}, 14426 Permissions: &InstallationPermissions{ 14427 Actions: Ptr("a"), 14428 Administration: Ptr("ad"), 14429 Checks: Ptr("c"), 14430 Contents: Ptr("co"), 14431 ContentReferences: Ptr("cr"), 14432 Deployments: Ptr("d"), 14433 Environments: Ptr("e"), 14434 Issues: Ptr("i"), 14435 Metadata: Ptr("md"), 14436 Members: Ptr("m"), 14437 OrganizationAdministration: Ptr("oa"), 14438 OrganizationHooks: Ptr("oh"), 14439 OrganizationPlan: Ptr("op"), 14440 OrganizationPreReceiveHooks: Ptr("opr"), 14441 OrganizationProjects: Ptr("op"), 14442 OrganizationSecrets: Ptr("os"), 14443 OrganizationSelfHostedRunners: Ptr("osh"), 14444 OrganizationUserBlocking: Ptr("oub"), 14445 Packages: Ptr("pkg"), 14446 Pages: Ptr("pg"), 14447 PullRequests: Ptr("pr"), 14448 RepositoryHooks: Ptr("rh"), 14449 RepositoryProjects: Ptr("rp"), 14450 RepositoryPreReceiveHooks: Ptr("rprh"), 14451 Secrets: Ptr("s"), 14452 SecretScanningAlerts: Ptr("ssa"), 14453 SecurityEvents: Ptr("se"), 14454 SingleFile: Ptr("sf"), 14455 Statuses: Ptr("s"), 14456 TeamDiscussions: Ptr("td"), 14457 VulnerabilityAlerts: Ptr("va"), 14458 Workflows: Ptr("w"), 14459 }, 14460 CreatedAt: &Timestamp{referenceTime}, 14461 UpdatedAt: &Timestamp{referenceTime}, 14462 HasMultipleSingleFiles: Ptr(false), 14463 SuspendedBy: &User{ 14464 Login: Ptr("l"), 14465 ID: Ptr(int64(1)), 14466 URL: Ptr("u"), 14467 AvatarURL: Ptr("a"), 14468 GravatarID: Ptr("g"), 14469 Name: Ptr("n"), 14470 Company: Ptr("c"), 14471 Blog: Ptr("b"), 14472 Location: Ptr("l"), 14473 Email: Ptr("e"), 14474 Hireable: Ptr(true), 14475 Bio: Ptr("b"), 14476 TwitterUsername: Ptr("t"), 14477 PublicRepos: Ptr(1), 14478 Followers: Ptr(1), 14479 Following: Ptr(1), 14480 CreatedAt: &Timestamp{referenceTime}, 14481 SuspendedAt: &Timestamp{referenceTime}, 14482 }, 14483 SuspendedAt: &Timestamp{referenceTime}, 14484 }, 14485 } 14486 want := `{ 14487 "action": "a", 14488 "alert": { 14489 "number": 1, 14490 "state": "s", 14491 "dependency": { 14492 "package": { 14493 "ecosystem": "e", 14494 "name": "n" 14495 }, 14496 "manifest_path": "mp", 14497 "scope": "s" 14498 }, 14499 "security_advisory": { 14500 "ghsa_id": "ghsaid", 14501 "cve_id": "cveid", 14502 "summary": "s", 14503 "description": "d", 14504 "vulnerabilities": [ 14505 { 14506 "package": { 14507 "ecosystem": "e", 14508 "name": "n" 14509 }, 14510 "severity": "s" 14511 } 14512 ], 14513 "severity": "s", 14514 "cvss": { 14515 "score": 1.0, 14516 "vector_string": "vs" 14517 }, 14518 "cwes": [ 14519 { 14520 "cwe_id": "cweid", 14521 "name": "n" 14522 } 14523 ], 14524 "identifiers": [ 14525 { 14526 "value": "v", 14527 "type": "t" 14528 } 14529 ], 14530 "references": [ 14531 { 14532 "url": "u" 14533 } 14534 ], 14535 "published_at": ` + referenceTimeStr + `, 14536 "updated_at": ` + referenceTimeStr + `, 14537 "withdrawn_at": ` + referenceTimeStr + ` 14538 }, 14539 "security_vulnerability": { 14540 "package": { 14541 "ecosystem": "e", 14542 "name": "n" 14543 }, 14544 "severity": "s", 14545 "vulnerable_version_range": "vvr", 14546 "first_patched_version": { 14547 "identifier": "i" 14548 } 14549 }, 14550 "url": "u", 14551 "html_url": "hu", 14552 "created_at": ` + referenceTimeStr + `, 14553 "updated_at": ` + referenceTimeStr + `, 14554 "dismissed_at": ` + referenceTimeStr + `, 14555 "dismissed_by": { 14556 "login": "l", 14557 "id": 1, 14558 "node_id": "n", 14559 "avatar_url": "a", 14560 "url": "u", 14561 "events_url": "e", 14562 "repos_url": "r" 14563 }, 14564 "dismissed_reason": "dr", 14565 "dismissed_comment": "dc", 14566 "fixed_at": ` + referenceTimeStr + `, 14567 "auto_dismissed_at": ` + referenceTimeStr + ` 14568 }, 14569 "repository": { 14570 "id": 1, 14571 "name": "n", 14572 "url": "s" 14573 }, 14574 "organization": { 14575 "name": "n", 14576 "company": "c", 14577 "blog": "b", 14578 "location": "loc", 14579 "email": "e", 14580 "twitter_username": "tu", 14581 "description": "d", 14582 "billing_email": "be", 14583 "is_verified": true, 14584 "has_organization_projects": true, 14585 "has_repository_projects": true, 14586 "default_repository_permission": "drp", 14587 "members_can_create_repositories": true, 14588 "members_can_create_public_repositories": false, 14589 "members_can_create_private_repositories": true, 14590 "members_can_create_internal_repositories": true, 14591 "members_allowed_repository_creation_type": "marct", 14592 "members_can_create_pages": true, 14593 "members_can_create_public_pages": false, 14594 "members_can_create_private_pages": true 14595 }, 14596 "enterprise": { 14597 "id": 1, 14598 "slug": "s", 14599 "name": "n", 14600 "node_id": "nid", 14601 "avatar_url": "au", 14602 "description": "d", 14603 "website_url": "wu", 14604 "html_url": "hu", 14605 "created_at": ` + referenceTimeStr + `, 14606 "updated_at": ` + referenceTimeStr + ` 14607 }, 14608 "sender": { 14609 "login": "l", 14610 "id": 1, 14611 "node_id": "n", 14612 "avatar_url": "a", 14613 "url": "u", 14614 "events_url": "e", 14615 "repos_url": "r" 14616 }, 14617 "installation": { 14618 "id": 1, 14619 "node_id": "nid", 14620 "app_id": 1, 14621 "app_slug": "as", 14622 "target_id": 1, 14623 "account": { 14624 "login": "l", 14625 "id": 1, 14626 "avatar_url": "a", 14627 "gravatar_id": "g", 14628 "name": "n", 14629 "company": "c", 14630 "blog": "b", 14631 "location": "l", 14632 "email": "e", 14633 "hireable": true, 14634 "bio": "b", 14635 "twitter_username": "t", 14636 "public_repos": 1, 14637 "followers": 1, 14638 "following": 1, 14639 "created_at": ` + referenceTimeStr + `, 14640 "suspended_at": ` + referenceTimeStr + `, 14641 "url": "u" 14642 }, 14643 "access_tokens_url": "atu", 14644 "repositories_url": "ru", 14645 "html_url": "hu", 14646 "target_type": "tt", 14647 "single_file_name": "sfn", 14648 "repository_selection": "rs", 14649 "events": [ 14650 "e" 14651 ], 14652 "single_file_paths": [ 14653 "s" 14654 ], 14655 "permissions": { 14656 "actions": "a", 14657 "administration": "ad", 14658 "checks": "c", 14659 "contents": "co", 14660 "content_references": "cr", 14661 "deployments": "d", 14662 "environments": "e", 14663 "issues": "i", 14664 "metadata": "md", 14665 "members": "m", 14666 "organization_administration": "oa", 14667 "organization_hooks": "oh", 14668 "organization_plan": "op", 14669 "organization_pre_receive_hooks": "opr", 14670 "organization_projects": "op", 14671 "organization_secrets": "os", 14672 "organization_self_hosted_runners": "osh", 14673 "organization_user_blocking": "oub", 14674 "packages": "pkg", 14675 "pages": "pg", 14676 "pull_requests": "pr", 14677 "repository_hooks": "rh", 14678 "repository_projects": "rp", 14679 "repository_pre_receive_hooks": "rprh", 14680 "secrets": "s", 14681 "secret_scanning_alerts": "ssa", 14682 "security_events": "se", 14683 "single_file": "sf", 14684 "statuses": "s", 14685 "team_discussions": "td", 14686 "vulnerability_alerts": "va", 14687 "workflows": "w" 14688 }, 14689 "created_at": ` + referenceTimeStr + `, 14690 "updated_at": ` + referenceTimeStr + `, 14691 "has_multiple_single_files": false, 14692 "suspended_by": { 14693 "login": "l", 14694 "id": 1, 14695 "avatar_url": "a", 14696 "gravatar_id": "g", 14697 "name": "n", 14698 "company": "c", 14699 "blog": "b", 14700 "location": "l", 14701 "email": "e", 14702 "hireable": true, 14703 "bio": "b", 14704 "twitter_username": "t", 14705 "public_repos": 1, 14706 "followers": 1, 14707 "following": 1, 14708 "created_at": ` + referenceTimeStr + `, 14709 "suspended_at": ` + referenceTimeStr + `, 14710 "url": "u" 14711 }, 14712 "suspended_at": ` + referenceTimeStr + ` 14713 } 14714 }` 14715 14716 testJSONMarshal(t, e, want) 14717 } 14718 14719 func TestForkEvent_Marshal(t *testing.T) { 14720 t.Parallel() 14721 testJSONMarshal(t, &ForkEvent{}, "{}") 14722 14723 u := &ForkEvent{ 14724 Forkee: &Repository{ 14725 ID: Ptr(int64(1)), 14726 URL: Ptr("s"), 14727 Name: Ptr("n"), 14728 }, 14729 Repo: &Repository{ 14730 ID: Ptr(int64(1)), 14731 URL: Ptr("s"), 14732 Name: Ptr("n"), 14733 }, 14734 Sender: &User{ 14735 Login: Ptr("l"), 14736 ID: Ptr(int64(1)), 14737 NodeID: Ptr("n"), 14738 URL: Ptr("u"), 14739 ReposURL: Ptr("r"), 14740 EventsURL: Ptr("e"), 14741 AvatarURL: Ptr("a"), 14742 }, 14743 Installation: &Installation{ 14744 ID: Ptr(int64(1)), 14745 NodeID: Ptr("nid"), 14746 AppID: Ptr(int64(1)), 14747 AppSlug: Ptr("as"), 14748 TargetID: Ptr(int64(1)), 14749 Account: &User{ 14750 Login: Ptr("l"), 14751 ID: Ptr(int64(1)), 14752 URL: Ptr("u"), 14753 AvatarURL: Ptr("a"), 14754 GravatarID: Ptr("g"), 14755 Name: Ptr("n"), 14756 Company: Ptr("c"), 14757 Blog: Ptr("b"), 14758 Location: Ptr("l"), 14759 Email: Ptr("e"), 14760 Hireable: Ptr(true), 14761 Bio: Ptr("b"), 14762 TwitterUsername: Ptr("t"), 14763 PublicRepos: Ptr(1), 14764 Followers: Ptr(1), 14765 Following: Ptr(1), 14766 CreatedAt: &Timestamp{referenceTime}, 14767 SuspendedAt: &Timestamp{referenceTime}, 14768 }, 14769 AccessTokensURL: Ptr("atu"), 14770 RepositoriesURL: Ptr("ru"), 14771 HTMLURL: Ptr("hu"), 14772 TargetType: Ptr("tt"), 14773 SingleFileName: Ptr("sfn"), 14774 RepositorySelection: Ptr("rs"), 14775 Events: []string{"e"}, 14776 SingleFilePaths: []string{"s"}, 14777 Permissions: &InstallationPermissions{ 14778 Actions: Ptr("a"), 14779 Administration: Ptr("ad"), 14780 Checks: Ptr("c"), 14781 Contents: Ptr("co"), 14782 ContentReferences: Ptr("cr"), 14783 Deployments: Ptr("d"), 14784 Environments: Ptr("e"), 14785 Issues: Ptr("i"), 14786 Metadata: Ptr("md"), 14787 Members: Ptr("m"), 14788 OrganizationAdministration: Ptr("oa"), 14789 OrganizationHooks: Ptr("oh"), 14790 OrganizationPlan: Ptr("op"), 14791 OrganizationPreReceiveHooks: Ptr("opr"), 14792 OrganizationProjects: Ptr("op"), 14793 OrganizationSecrets: Ptr("os"), 14794 OrganizationSelfHostedRunners: Ptr("osh"), 14795 OrganizationUserBlocking: Ptr("oub"), 14796 Packages: Ptr("pkg"), 14797 Pages: Ptr("pg"), 14798 PullRequests: Ptr("pr"), 14799 RepositoryHooks: Ptr("rh"), 14800 RepositoryProjects: Ptr("rp"), 14801 RepositoryPreReceiveHooks: Ptr("rprh"), 14802 Secrets: Ptr("s"), 14803 SecretScanningAlerts: Ptr("ssa"), 14804 SecurityEvents: Ptr("se"), 14805 SingleFile: Ptr("sf"), 14806 Statuses: Ptr("s"), 14807 TeamDiscussions: Ptr("td"), 14808 VulnerabilityAlerts: Ptr("va"), 14809 Workflows: Ptr("w"), 14810 }, 14811 CreatedAt: &Timestamp{referenceTime}, 14812 UpdatedAt: &Timestamp{referenceTime}, 14813 HasMultipleSingleFiles: Ptr(false), 14814 SuspendedBy: &User{ 14815 Login: Ptr("l"), 14816 ID: Ptr(int64(1)), 14817 URL: Ptr("u"), 14818 AvatarURL: Ptr("a"), 14819 GravatarID: Ptr("g"), 14820 Name: Ptr("n"), 14821 Company: Ptr("c"), 14822 Blog: Ptr("b"), 14823 Location: Ptr("l"), 14824 Email: Ptr("e"), 14825 Hireable: Ptr(true), 14826 Bio: Ptr("b"), 14827 TwitterUsername: Ptr("t"), 14828 PublicRepos: Ptr(1), 14829 Followers: Ptr(1), 14830 Following: Ptr(1), 14831 CreatedAt: &Timestamp{referenceTime}, 14832 SuspendedAt: &Timestamp{referenceTime}, 14833 }, 14834 SuspendedAt: &Timestamp{referenceTime}, 14835 }, 14836 } 14837 14838 want := `{ 14839 "forkee": { 14840 "id": 1, 14841 "name": "n", 14842 "url": "s" 14843 }, 14844 "repository": { 14845 "id": 1, 14846 "name": "n", 14847 "url": "s" 14848 }, 14849 "sender": { 14850 "login": "l", 14851 "id": 1, 14852 "node_id": "n", 14853 "avatar_url": "a", 14854 "url": "u", 14855 "events_url": "e", 14856 "repos_url": "r" 14857 }, 14858 "installation": { 14859 "id": 1, 14860 "node_id": "nid", 14861 "app_id": 1, 14862 "app_slug": "as", 14863 "target_id": 1, 14864 "account": { 14865 "login": "l", 14866 "id": 1, 14867 "avatar_url": "a", 14868 "gravatar_id": "g", 14869 "name": "n", 14870 "company": "c", 14871 "blog": "b", 14872 "location": "l", 14873 "email": "e", 14874 "hireable": true, 14875 "bio": "b", 14876 "twitter_username": "t", 14877 "public_repos": 1, 14878 "followers": 1, 14879 "following": 1, 14880 "created_at": ` + referenceTimeStr + `, 14881 "suspended_at": ` + referenceTimeStr + `, 14882 "url": "u" 14883 }, 14884 "access_tokens_url": "atu", 14885 "repositories_url": "ru", 14886 "html_url": "hu", 14887 "target_type": "tt", 14888 "single_file_name": "sfn", 14889 "repository_selection": "rs", 14890 "events": [ 14891 "e" 14892 ], 14893 "single_file_paths": [ 14894 "s" 14895 ], 14896 "permissions": { 14897 "actions": "a", 14898 "administration": "ad", 14899 "checks": "c", 14900 "contents": "co", 14901 "content_references": "cr", 14902 "deployments": "d", 14903 "environments": "e", 14904 "issues": "i", 14905 "metadata": "md", 14906 "members": "m", 14907 "organization_administration": "oa", 14908 "organization_hooks": "oh", 14909 "organization_plan": "op", 14910 "organization_pre_receive_hooks": "opr", 14911 "organization_projects": "op", 14912 "organization_secrets": "os", 14913 "organization_self_hosted_runners": "osh", 14914 "organization_user_blocking": "oub", 14915 "packages": "pkg", 14916 "pages": "pg", 14917 "pull_requests": "pr", 14918 "repository_hooks": "rh", 14919 "repository_projects": "rp", 14920 "repository_pre_receive_hooks": "rprh", 14921 "secrets": "s", 14922 "secret_scanning_alerts": "ssa", 14923 "security_events": "se", 14924 "single_file": "sf", 14925 "statuses": "s", 14926 "team_discussions": "td", 14927 "vulnerability_alerts": "va", 14928 "workflows": "w" 14929 }, 14930 "created_at": ` + referenceTimeStr + `, 14931 "updated_at": ` + referenceTimeStr + `, 14932 "has_multiple_single_files": false, 14933 "suspended_by": { 14934 "login": "l", 14935 "id": 1, 14936 "avatar_url": "a", 14937 "gravatar_id": "g", 14938 "name": "n", 14939 "company": "c", 14940 "blog": "b", 14941 "location": "l", 14942 "email": "e", 14943 "hireable": true, 14944 "bio": "b", 14945 "twitter_username": "t", 14946 "public_repos": 1, 14947 "followers": 1, 14948 "following": 1, 14949 "created_at": ` + referenceTimeStr + `, 14950 "suspended_at": ` + referenceTimeStr + `, 14951 "url": "u" 14952 }, 14953 "suspended_at": ` + referenceTimeStr + ` 14954 } 14955 }` 14956 14957 testJSONMarshal(t, u, want) 14958 } 14959 14960 func TestGitHubAppAuthorizationEvent_Marshal(t *testing.T) { 14961 t.Parallel() 14962 testJSONMarshal(t, &GitHubAppAuthorizationEvent{}, "{}") 14963 14964 u := &GitHubAppAuthorizationEvent{ 14965 Action: Ptr("a"), 14966 Sender: &User{ 14967 Login: Ptr("l"), 14968 ID: Ptr(int64(1)), 14969 NodeID: Ptr("n"), 14970 URL: Ptr("u"), 14971 ReposURL: Ptr("r"), 14972 EventsURL: Ptr("e"), 14973 AvatarURL: Ptr("a"), 14974 }, 14975 } 14976 14977 want := `{ 14978 "action": "a", 14979 "sender": { 14980 "login": "l", 14981 "id": 1, 14982 "node_id": "n", 14983 "avatar_url": "a", 14984 "url": "u", 14985 "events_url": "e", 14986 "repos_url": "r" 14987 } 14988 }` 14989 14990 testJSONMarshal(t, u, want) 14991 } 14992 14993 func TestInstallationEvent_Marshal(t *testing.T) { 14994 t.Parallel() 14995 testJSONMarshal(t, &InstallationEvent{}, "{}") 14996 14997 u := &InstallationEvent{ 14998 Action: Ptr("a"), 14999 Repositories: []*Repository{ 15000 { 15001 ID: Ptr(int64(1)), 15002 URL: Ptr("u"), 15003 Name: Ptr("n"), 15004 }, 15005 }, 15006 Sender: &User{ 15007 Login: Ptr("l"), 15008 ID: Ptr(int64(1)), 15009 NodeID: Ptr("n"), 15010 URL: Ptr("u"), 15011 ReposURL: Ptr("r"), 15012 EventsURL: Ptr("e"), 15013 AvatarURL: Ptr("a"), 15014 }, 15015 Installation: &Installation{ 15016 ID: Ptr(int64(1)), 15017 NodeID: Ptr("nid"), 15018 AppID: Ptr(int64(1)), 15019 AppSlug: Ptr("as"), 15020 TargetID: Ptr(int64(1)), 15021 Account: &User{ 15022 Login: Ptr("l"), 15023 ID: Ptr(int64(1)), 15024 URL: Ptr("u"), 15025 AvatarURL: Ptr("a"), 15026 GravatarID: Ptr("g"), 15027 Name: Ptr("n"), 15028 Company: Ptr("c"), 15029 Blog: Ptr("b"), 15030 Location: Ptr("l"), 15031 Email: Ptr("e"), 15032 Hireable: Ptr(true), 15033 Bio: Ptr("b"), 15034 TwitterUsername: Ptr("t"), 15035 PublicRepos: Ptr(1), 15036 Followers: Ptr(1), 15037 Following: Ptr(1), 15038 CreatedAt: &Timestamp{referenceTime}, 15039 SuspendedAt: &Timestamp{referenceTime}, 15040 }, 15041 AccessTokensURL: Ptr("atu"), 15042 RepositoriesURL: Ptr("ru"), 15043 HTMLURL: Ptr("hu"), 15044 TargetType: Ptr("tt"), 15045 SingleFileName: Ptr("sfn"), 15046 RepositorySelection: Ptr("rs"), 15047 Events: []string{"e"}, 15048 SingleFilePaths: []string{"s"}, 15049 Permissions: &InstallationPermissions{ 15050 Actions: Ptr("a"), 15051 Administration: Ptr("ad"), 15052 Checks: Ptr("c"), 15053 Contents: Ptr("co"), 15054 ContentReferences: Ptr("cr"), 15055 Deployments: Ptr("d"), 15056 Environments: Ptr("e"), 15057 Issues: Ptr("i"), 15058 Metadata: Ptr("md"), 15059 Members: Ptr("m"), 15060 OrganizationAdministration: Ptr("oa"), 15061 OrganizationHooks: Ptr("oh"), 15062 OrganizationPlan: Ptr("op"), 15063 OrganizationPreReceiveHooks: Ptr("opr"), 15064 OrganizationProjects: Ptr("op"), 15065 OrganizationSecrets: Ptr("os"), 15066 OrganizationSelfHostedRunners: Ptr("osh"), 15067 OrganizationUserBlocking: Ptr("oub"), 15068 Packages: Ptr("pkg"), 15069 Pages: Ptr("pg"), 15070 PullRequests: Ptr("pr"), 15071 RepositoryHooks: Ptr("rh"), 15072 RepositoryProjects: Ptr("rp"), 15073 RepositoryPreReceiveHooks: Ptr("rprh"), 15074 Secrets: Ptr("s"), 15075 SecretScanningAlerts: Ptr("ssa"), 15076 SecurityEvents: Ptr("se"), 15077 SingleFile: Ptr("sf"), 15078 Statuses: Ptr("s"), 15079 TeamDiscussions: Ptr("td"), 15080 VulnerabilityAlerts: Ptr("va"), 15081 Workflows: Ptr("w"), 15082 }, 15083 CreatedAt: &Timestamp{referenceTime}, 15084 UpdatedAt: &Timestamp{referenceTime}, 15085 HasMultipleSingleFiles: Ptr(false), 15086 SuspendedBy: &User{ 15087 Login: Ptr("l"), 15088 ID: Ptr(int64(1)), 15089 URL: Ptr("u"), 15090 AvatarURL: Ptr("a"), 15091 GravatarID: Ptr("g"), 15092 Name: Ptr("n"), 15093 Company: Ptr("c"), 15094 Blog: Ptr("b"), 15095 Location: Ptr("l"), 15096 Email: Ptr("e"), 15097 Hireable: Ptr(true), 15098 Bio: Ptr("b"), 15099 TwitterUsername: Ptr("t"), 15100 PublicRepos: Ptr(1), 15101 Followers: Ptr(1), 15102 Following: Ptr(1), 15103 CreatedAt: &Timestamp{referenceTime}, 15104 SuspendedAt: &Timestamp{referenceTime}, 15105 }, 15106 SuspendedAt: &Timestamp{referenceTime}, 15107 }, 15108 } 15109 15110 want := `{ 15111 "action": "a", 15112 "repositories": [ 15113 { 15114 "id":1, 15115 "name":"n", 15116 "url":"u" 15117 } 15118 ], 15119 "sender": { 15120 "login": "l", 15121 "id": 1, 15122 "node_id": "n", 15123 "avatar_url": "a", 15124 "url": "u", 15125 "events_url": "e", 15126 "repos_url": "r" 15127 }, 15128 "installation": { 15129 "id": 1, 15130 "node_id": "nid", 15131 "app_id": 1, 15132 "app_slug": "as", 15133 "target_id": 1, 15134 "account": { 15135 "login": "l", 15136 "id": 1, 15137 "avatar_url": "a", 15138 "gravatar_id": "g", 15139 "name": "n", 15140 "company": "c", 15141 "blog": "b", 15142 "location": "l", 15143 "email": "e", 15144 "hireable": true, 15145 "bio": "b", 15146 "twitter_username": "t", 15147 "public_repos": 1, 15148 "followers": 1, 15149 "following": 1, 15150 "created_at": ` + referenceTimeStr + `, 15151 "suspended_at": ` + referenceTimeStr + `, 15152 "url": "u" 15153 }, 15154 "access_tokens_url": "atu", 15155 "repositories_url": "ru", 15156 "html_url": "hu", 15157 "target_type": "tt", 15158 "single_file_name": "sfn", 15159 "repository_selection": "rs", 15160 "events": [ 15161 "e" 15162 ], 15163 "single_file_paths": [ 15164 "s" 15165 ], 15166 "permissions": { 15167 "actions": "a", 15168 "administration": "ad", 15169 "checks": "c", 15170 "contents": "co", 15171 "content_references": "cr", 15172 "deployments": "d", 15173 "environments": "e", 15174 "issues": "i", 15175 "metadata": "md", 15176 "members": "m", 15177 "organization_administration": "oa", 15178 "organization_hooks": "oh", 15179 "organization_plan": "op", 15180 "organization_pre_receive_hooks": "opr", 15181 "organization_projects": "op", 15182 "organization_secrets": "os", 15183 "organization_self_hosted_runners": "osh", 15184 "organization_user_blocking": "oub", 15185 "packages": "pkg", 15186 "pages": "pg", 15187 "pull_requests": "pr", 15188 "repository_hooks": "rh", 15189 "repository_projects": "rp", 15190 "repository_pre_receive_hooks": "rprh", 15191 "secrets": "s", 15192 "secret_scanning_alerts": "ssa", 15193 "security_events": "se", 15194 "single_file": "sf", 15195 "statuses": "s", 15196 "team_discussions": "td", 15197 "vulnerability_alerts": "va", 15198 "workflows": "w" 15199 }, 15200 "created_at": ` + referenceTimeStr + `, 15201 "updated_at": ` + referenceTimeStr + `, 15202 "has_multiple_single_files": false, 15203 "suspended_by": { 15204 "login": "l", 15205 "id": 1, 15206 "avatar_url": "a", 15207 "gravatar_id": "g", 15208 "name": "n", 15209 "company": "c", 15210 "blog": "b", 15211 "location": "l", 15212 "email": "e", 15213 "hireable": true, 15214 "bio": "b", 15215 "twitter_username": "t", 15216 "public_repos": 1, 15217 "followers": 1, 15218 "following": 1, 15219 "created_at": ` + referenceTimeStr + `, 15220 "suspended_at": ` + referenceTimeStr + `, 15221 "url": "u" 15222 }, 15223 "suspended_at": ` + referenceTimeStr + ` 15224 } 15225 }` 15226 15227 testJSONMarshal(t, u, want) 15228 } 15229 15230 func TestHeadCommit_Marshal(t *testing.T) { 15231 t.Parallel() 15232 testJSONMarshal(t, &HeadCommit{}, "{}") 15233 15234 u := &HeadCommit{ 15235 Message: Ptr("m"), 15236 Author: &CommitAuthor{ 15237 Date: &Timestamp{referenceTime}, 15238 Name: Ptr("n"), 15239 Email: Ptr("e"), 15240 Login: Ptr("u"), 15241 }, 15242 URL: Ptr("u"), 15243 Distinct: Ptr(true), 15244 SHA: Ptr("s"), 15245 ID: Ptr("id"), 15246 TreeID: Ptr("tid"), 15247 Timestamp: &Timestamp{referenceTime}, 15248 Committer: &CommitAuthor{ 15249 Date: &Timestamp{referenceTime}, 15250 Name: Ptr("n"), 15251 Email: Ptr("e"), 15252 Login: Ptr("u"), 15253 }, 15254 Added: []string{"a"}, 15255 Removed: []string{"r"}, 15256 Modified: []string{"m"}, 15257 } 15258 15259 want := `{ 15260 "message": "m", 15261 "author": { 15262 "date": ` + referenceTimeStr + `, 15263 "name": "n", 15264 "email": "e", 15265 "username": "u" 15266 }, 15267 "url": "u", 15268 "distinct": true, 15269 "sha": "s", 15270 "id": "id", 15271 "tree_id": "tid", 15272 "timestamp": ` + referenceTimeStr + `, 15273 "committer": { 15274 "date": ` + referenceTimeStr + `, 15275 "name": "n", 15276 "email": "e", 15277 "username": "u" 15278 }, 15279 "added": [ 15280 "a" 15281 ], 15282 "removed": [ 15283 "r" 15284 ], 15285 "modified": [ 15286 "m" 15287 ] 15288 }` 15289 15290 testJSONMarshal(t, u, want) 15291 } 15292 15293 func TestPushEventRepository_Marshal(t *testing.T) { 15294 t.Parallel() 15295 testJSONMarshal(t, &PushEventRepository{}, "{}") 15296 15297 u := &PushEventRepository{ 15298 ID: Ptr(int64(1)), 15299 NodeID: Ptr("nid"), 15300 Name: Ptr("n"), 15301 FullName: Ptr("fn"), 15302 Owner: &User{ 15303 Login: Ptr("l"), 15304 ID: Ptr(int64(1)), 15305 AvatarURL: Ptr("a"), 15306 GravatarID: Ptr("g"), 15307 Name: Ptr("n"), 15308 Company: Ptr("c"), 15309 Blog: Ptr("b"), 15310 Location: Ptr("l"), 15311 Email: Ptr("e"), 15312 Hireable: Ptr(true), 15313 PublicRepos: Ptr(1), 15314 Followers: Ptr(1), 15315 Following: Ptr(1), 15316 CreatedAt: &Timestamp{referenceTime}, 15317 URL: Ptr("u"), 15318 }, 15319 Private: Ptr(true), 15320 Description: Ptr("d"), 15321 Fork: Ptr(true), 15322 CreatedAt: &Timestamp{referenceTime}, 15323 PushedAt: &Timestamp{referenceTime}, 15324 UpdatedAt: &Timestamp{referenceTime}, 15325 Homepage: Ptr("h"), 15326 PullsURL: Ptr("p"), 15327 Size: Ptr(1), 15328 StargazersCount: Ptr(1), 15329 WatchersCount: Ptr(1), 15330 Language: Ptr("l"), 15331 HasIssues: Ptr(true), 15332 HasDownloads: Ptr(true), 15333 HasWiki: Ptr(true), 15334 HasPages: Ptr(true), 15335 ForksCount: Ptr(1), 15336 Archived: Ptr(true), 15337 Disabled: Ptr(true), 15338 OpenIssuesCount: Ptr(1), 15339 DefaultBranch: Ptr("d"), 15340 MasterBranch: Ptr("m"), 15341 Organization: Ptr("o"), 15342 URL: Ptr("u"), 15343 ArchiveURL: Ptr("a"), 15344 HTMLURL: Ptr("h"), 15345 StatusesURL: Ptr("s"), 15346 GitURL: Ptr("g"), 15347 SSHURL: Ptr("s"), 15348 CloneURL: Ptr("c"), 15349 SVNURL: Ptr("s"), 15350 Topics: []string{"octocat", "api"}, 15351 } 15352 15353 want := `{ 15354 "id": 1, 15355 "node_id": "nid", 15356 "name": "n", 15357 "full_name": "fn", 15358 "owner": { 15359 "login": "l", 15360 "id": 1, 15361 "avatar_url": "a", 15362 "gravatar_id": "g", 15363 "name": "n", 15364 "company": "c", 15365 "blog": "b", 15366 "location": "l", 15367 "email": "e", 15368 "hireable": true, 15369 "public_repos": 1, 15370 "followers": 1, 15371 "following": 1, 15372 "created_at": ` + referenceTimeStr + `, 15373 "url": "u" 15374 }, 15375 "private": true, 15376 "description": "d", 15377 "fork": true, 15378 "created_at": ` + referenceTimeStr + `, 15379 "pushed_at": ` + referenceTimeStr + `, 15380 "updated_at": ` + referenceTimeStr + `, 15381 "homepage": "h", 15382 "pulls_url": "p", 15383 "size": 1, 15384 "stargazers_count": 1, 15385 "watchers_count": 1, 15386 "language": "l", 15387 "has_issues": true, 15388 "has_downloads": true, 15389 "has_wiki": true, 15390 "has_pages": true, 15391 "forks_count": 1, 15392 "archived": true, 15393 "disabled": true, 15394 "open_issues_count": 1, 15395 "default_branch": "d", 15396 "master_branch": "m", 15397 "organization": "o", 15398 "url": "u", 15399 "archive_url": "a", 15400 "html_url": "h", 15401 "statuses_url": "s", 15402 "git_url": "g", 15403 "ssh_url": "s", 15404 "clone_url": "c", 15405 "svn_url": "s", 15406 "topics": ["octocat","api"] 15407 }` 15408 15409 testJSONMarshal(t, u, want) 15410 } 15411 15412 func TestPushEventRepoOwner_Marshal(t *testing.T) { 15413 t.Parallel() 15414 testJSONMarshal(t, &PushEventRepoOwner{}, "{}") 15415 15416 u := &PushEventRepoOwner{ 15417 Name: Ptr("n"), 15418 Email: Ptr("e"), 15419 } 15420 15421 want := `{ 15422 "name": "n", 15423 "email": "e" 15424 }` 15425 15426 testJSONMarshal(t, u, want) 15427 } 15428 15429 func TestProjectV2Event_Marshal(t *testing.T) { 15430 t.Parallel() 15431 testJSONMarshal(t, &ProjectV2Event{}, "{}") 15432 15433 u := &ProjectV2Event{ 15434 Action: Ptr("a"), 15435 ProjectsV2: &ProjectV2{ 15436 ID: Ptr(int64(1)), 15437 NodeID: Ptr("nid"), 15438 Owner: &User{ 15439 Login: Ptr("l"), 15440 ID: Ptr(int64(1)), 15441 NodeID: Ptr("n"), 15442 URL: Ptr("u"), 15443 ReposURL: Ptr("r"), 15444 EventsURL: Ptr("e"), 15445 AvatarURL: Ptr("a"), 15446 }, 15447 Creator: &User{ 15448 Login: Ptr("l"), 15449 ID: Ptr(int64(1)), 15450 NodeID: Ptr("n"), 15451 URL: Ptr("u"), 15452 ReposURL: Ptr("r"), 15453 EventsURL: Ptr("e"), 15454 AvatarURL: Ptr("a"), 15455 }, 15456 Title: Ptr("t"), 15457 Description: Ptr("d"), 15458 Public: Ptr(true), 15459 ClosedAt: &Timestamp{referenceTime}, 15460 CreatedAt: &Timestamp{referenceTime}, 15461 UpdatedAt: &Timestamp{referenceTime}, 15462 DeletedAt: &Timestamp{referenceTime}, 15463 Number: Ptr(1), 15464 ShortDescription: Ptr("sd"), 15465 DeletedBy: &User{ 15466 Login: Ptr("l"), 15467 ID: Ptr(int64(1)), 15468 NodeID: Ptr("n"), 15469 URL: Ptr("u"), 15470 ReposURL: Ptr("r"), 15471 EventsURL: Ptr("e"), 15472 AvatarURL: Ptr("a"), 15473 }, 15474 }, 15475 Org: &Organization{ 15476 BillingEmail: Ptr("be"), 15477 Blog: Ptr("b"), 15478 Company: Ptr("c"), 15479 Email: Ptr("e"), 15480 TwitterUsername: Ptr("tu"), 15481 Location: Ptr("loc"), 15482 Name: Ptr("n"), 15483 Description: Ptr("d"), 15484 IsVerified: Ptr(true), 15485 HasOrganizationProjects: Ptr(true), 15486 HasRepositoryProjects: Ptr(true), 15487 DefaultRepoPermission: Ptr("drp"), 15488 MembersCanCreateRepos: Ptr(true), 15489 MembersCanCreateInternalRepos: Ptr(true), 15490 MembersCanCreatePrivateRepos: Ptr(true), 15491 MembersCanCreatePublicRepos: Ptr(false), 15492 MembersAllowedRepositoryCreationType: Ptr("marct"), 15493 MembersCanCreatePages: Ptr(true), 15494 MembersCanCreatePublicPages: Ptr(false), 15495 MembersCanCreatePrivatePages: Ptr(true), 15496 }, 15497 Sender: &User{ 15498 Login: Ptr("l"), 15499 ID: Ptr(int64(1)), 15500 NodeID: Ptr("n"), 15501 URL: Ptr("u"), 15502 ReposURL: Ptr("r"), 15503 EventsURL: Ptr("e"), 15504 AvatarURL: Ptr("a"), 15505 }, 15506 Installation: &Installation{ 15507 ID: Ptr(int64(1)), 15508 NodeID: Ptr("nid"), 15509 AppID: Ptr(int64(1)), 15510 AppSlug: Ptr("as"), 15511 TargetID: Ptr(int64(1)), 15512 Account: &User{ 15513 Login: Ptr("l"), 15514 ID: Ptr(int64(1)), 15515 URL: Ptr("u"), 15516 AvatarURL: Ptr("a"), 15517 GravatarID: Ptr("g"), 15518 Name: Ptr("n"), 15519 Company: Ptr("c"), 15520 Blog: Ptr("b"), 15521 Location: Ptr("l"), 15522 Email: Ptr("e"), 15523 Hireable: Ptr(true), 15524 Bio: Ptr("b"), 15525 TwitterUsername: Ptr("t"), 15526 PublicRepos: Ptr(1), 15527 Followers: Ptr(1), 15528 Following: Ptr(1), 15529 CreatedAt: &Timestamp{referenceTime}, 15530 SuspendedAt: &Timestamp{referenceTime}, 15531 }, 15532 }, 15533 } 15534 15535 want := `{ 15536 "action": "a", 15537 "projects_v2": { 15538 "id": 1, 15539 "node_id": "nid", 15540 "owner": { 15541 "login": "l", 15542 "id": 1, 15543 "node_id": "n", 15544 "avatar_url": "a", 15545 "url": "u", 15546 "events_url": "e", 15547 "repos_url": "r" 15548 }, 15549 "creator": { 15550 "login": "l", 15551 "id": 1, 15552 "node_id": "n", 15553 "avatar_url": "a", 15554 "url": "u", 15555 "events_url": "e", 15556 "repos_url": "r" 15557 }, 15558 "title": "t", 15559 "description": "d", 15560 "public": true, 15561 "closed_at": ` + referenceTimeStr + `, 15562 "created_at": ` + referenceTimeStr + `, 15563 "updated_at": ` + referenceTimeStr + `, 15564 "deleted_at": ` + referenceTimeStr + `, 15565 "number": 1, 15566 "short_description": "sd", 15567 "deleted_by": { 15568 "login": "l", 15569 "id": 1, 15570 "node_id": "n", 15571 "avatar_url": "a", 15572 "url": "u", 15573 "events_url": "e", 15574 "repos_url": "r" 15575 } 15576 }, 15577 "organization": { 15578 "name": "n", 15579 "company": "c", 15580 "blog": "b", 15581 "location": "loc", 15582 "email": "e", 15583 "twitter_username": "tu", 15584 "description": "d", 15585 "billing_email": "be", 15586 "is_verified": true, 15587 "has_organization_projects": true, 15588 "has_repository_projects": true, 15589 "default_repository_permission": "drp", 15590 "members_can_create_repositories": true, 15591 "members_can_create_public_repositories": false, 15592 "members_can_create_private_repositories": true, 15593 "members_can_create_internal_repositories": true, 15594 "members_allowed_repository_creation_type": "marct", 15595 "members_can_create_pages": true, 15596 "members_can_create_public_pages": false, 15597 "members_can_create_private_pages": true 15598 }, 15599 "sender": { 15600 "login": "l", 15601 "id": 1, 15602 "node_id": "n", 15603 "avatar_url": "a", 15604 "url": "u", 15605 "events_url": "e", 15606 "repos_url": "r" 15607 }, 15608 "installation": { 15609 "id": 1, 15610 "node_id": "nid", 15611 "app_id": 1, 15612 "app_slug": "as", 15613 "target_id": 1, 15614 "account": { 15615 "login": "l", 15616 "id": 1, 15617 "avatar_url": "a", 15618 "gravatar_id": "g", 15619 "name": "n", 15620 "company": "c", 15621 "blog": "b", 15622 "location": "l", 15623 "email": "e", 15624 "hireable": true, 15625 "bio": "b", 15626 "twitter_username": "t", 15627 "public_repos": 1, 15628 "followers": 1, 15629 "following": 1, 15630 "created_at": ` + referenceTimeStr + `, 15631 "suspended_at": ` + referenceTimeStr + `, 15632 "url": "u" 15633 } 15634 } 15635 }` 15636 15637 testJSONMarshal(t, u, want) 15638 } 15639 15640 func TestProjectV2ItemEvent_Marshal(t *testing.T) { 15641 t.Parallel() 15642 testJSONMarshal(t, &ProjectV2ItemEvent{}, "{}") 15643 15644 u := &ProjectV2ItemEvent{ 15645 Action: Ptr("a"), 15646 Changes: &ProjectV2ItemChange{ 15647 ArchivedAt: &ArchivedAt{ 15648 From: &Timestamp{referenceTime}, 15649 To: &Timestamp{referenceTime}, 15650 }, 15651 }, 15652 ProjectV2Item: &ProjectV2Item{ 15653 ID: Ptr(int64(1)), 15654 NodeID: Ptr("nid"), 15655 ProjectNodeID: Ptr("pnid"), 15656 ContentNodeID: Ptr("cnid"), 15657 ContentType: Ptr("ct"), 15658 Creator: &User{ 15659 Login: Ptr("l"), 15660 ID: Ptr(int64(1)), 15661 NodeID: Ptr("n"), 15662 URL: Ptr("u"), 15663 ReposURL: Ptr("r"), 15664 EventsURL: Ptr("e"), 15665 AvatarURL: Ptr("a"), 15666 }, 15667 CreatedAt: &Timestamp{referenceTime}, 15668 UpdatedAt: &Timestamp{referenceTime}, 15669 ArchivedAt: &Timestamp{referenceTime}, 15670 }, 15671 Org: &Organization{ 15672 BillingEmail: Ptr("be"), 15673 Blog: Ptr("b"), 15674 Company: Ptr("c"), 15675 Email: Ptr("e"), 15676 TwitterUsername: Ptr("tu"), 15677 Location: Ptr("loc"), 15678 Name: Ptr("n"), 15679 Description: Ptr("d"), 15680 IsVerified: Ptr(true), 15681 HasOrganizationProjects: Ptr(true), 15682 HasRepositoryProjects: Ptr(true), 15683 DefaultRepoPermission: Ptr("drp"), 15684 MembersCanCreateRepos: Ptr(true), 15685 MembersCanCreateInternalRepos: Ptr(true), 15686 MembersCanCreatePrivateRepos: Ptr(true), 15687 MembersCanCreatePublicRepos: Ptr(false), 15688 MembersAllowedRepositoryCreationType: Ptr("marct"), 15689 MembersCanCreatePages: Ptr(true), 15690 MembersCanCreatePublicPages: Ptr(false), 15691 MembersCanCreatePrivatePages: Ptr(true), 15692 }, 15693 Sender: &User{ 15694 Login: Ptr("l"), 15695 ID: Ptr(int64(1)), 15696 NodeID: Ptr("n"), 15697 URL: Ptr("u"), 15698 ReposURL: Ptr("r"), 15699 EventsURL: Ptr("e"), 15700 AvatarURL: Ptr("a"), 15701 }, 15702 Installation: &Installation{ 15703 ID: Ptr(int64(1)), 15704 NodeID: Ptr("nid"), 15705 AppID: Ptr(int64(1)), 15706 AppSlug: Ptr("as"), 15707 TargetID: Ptr(int64(1)), 15708 Account: &User{ 15709 Login: Ptr("l"), 15710 ID: Ptr(int64(1)), 15711 URL: Ptr("u"), 15712 AvatarURL: Ptr("a"), 15713 GravatarID: Ptr("g"), 15714 Name: Ptr("n"), 15715 Company: Ptr("c"), 15716 Blog: Ptr("b"), 15717 Location: Ptr("l"), 15718 Email: Ptr("e"), 15719 Hireable: Ptr(true), 15720 Bio: Ptr("b"), 15721 TwitterUsername: Ptr("t"), 15722 PublicRepos: Ptr(1), 15723 Followers: Ptr(1), 15724 Following: Ptr(1), 15725 CreatedAt: &Timestamp{referenceTime}, 15726 SuspendedAt: &Timestamp{referenceTime}, 15727 }, 15728 }, 15729 } 15730 15731 want := `{ 15732 "action": "a", 15733 "changes": { 15734 "archived_at": { 15735 "from": ` + referenceTimeStr + `, 15736 "to": ` + referenceTimeStr + ` 15737 } 15738 }, 15739 "projects_v2_item": { 15740 "id": 1, 15741 "node_id": "nid", 15742 "project_node_id": "pnid", 15743 "content_node_id": "cnid", 15744 "content_type": "ct", 15745 "creator": { 15746 "login": "l", 15747 "id": 1, 15748 "node_id": "n", 15749 "avatar_url": "a", 15750 "url": "u", 15751 "events_url": "e", 15752 "repos_url": "r" 15753 }, 15754 "created_at": ` + referenceTimeStr + `, 15755 "updated_at": ` + referenceTimeStr + `, 15756 "archived_at": ` + referenceTimeStr + ` 15757 }, 15758 "organization": { 15759 "name": "n", 15760 "company": "c", 15761 "blog": "b", 15762 "location": "loc", 15763 "email": "e", 15764 "twitter_username": "tu", 15765 "description": "d", 15766 "billing_email": "be", 15767 "is_verified": true, 15768 "has_organization_projects": true, 15769 "has_repository_projects": true, 15770 "default_repository_permission": "drp", 15771 "members_can_create_repositories": true, 15772 "members_can_create_public_repositories": false, 15773 "members_can_create_private_repositories": true, 15774 "members_can_create_internal_repositories": true, 15775 "members_allowed_repository_creation_type": "marct", 15776 "members_can_create_pages": true, 15777 "members_can_create_public_pages": false, 15778 "members_can_create_private_pages": true 15779 }, 15780 "sender": { 15781 "login": "l", 15782 "id": 1, 15783 "node_id": "n", 15784 "avatar_url": "a", 15785 "url": "u", 15786 "events_url": "e", 15787 "repos_url": "r" 15788 }, 15789 "installation": { 15790 "id": 1, 15791 "node_id": "nid", 15792 "app_id": 1, 15793 "app_slug": "as", 15794 "target_id": 1, 15795 "account": { 15796 "login": "l", 15797 "id": 1, 15798 "avatar_url": "a", 15799 "gravatar_id": "g", 15800 "name": "n", 15801 "company": "c", 15802 "blog": "b", 15803 "location": "l", 15804 "email": "e", 15805 "hireable": true, 15806 "bio": "b", 15807 "twitter_username": "t", 15808 "public_repos": 1, 15809 "followers": 1, 15810 "following": 1, 15811 "created_at": ` + referenceTimeStr + `, 15812 "suspended_at": ` + referenceTimeStr + `, 15813 "url": "u" 15814 } 15815 } 15816 }` 15817 15818 testJSONMarshal(t, u, want) 15819 } 15820 15821 func TestPullRequestEvent_Marshal(t *testing.T) { 15822 t.Parallel() 15823 testJSONMarshal(t, &PullRequestEvent{}, "{}") 15824 15825 u := &PullRequestEvent{ 15826 Action: Ptr("a"), 15827 Assignee: &User{ 15828 Login: Ptr("l"), 15829 ID: Ptr(int64(1)), 15830 NodeID: Ptr("n"), 15831 URL: Ptr("u"), 15832 ReposURL: Ptr("r"), 15833 EventsURL: Ptr("e"), 15834 AvatarURL: Ptr("a"), 15835 }, 15836 Number: Ptr(1), 15837 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 15838 Changes: &EditChange{ 15839 Title: &EditTitle{ 15840 From: Ptr("TitleFrom"), 15841 }, 15842 Body: &EditBody{ 15843 From: Ptr("BodyFrom"), 15844 }, 15845 Base: &EditBase{ 15846 Ref: &EditRef{ 15847 From: Ptr("BaseRefFrom"), 15848 }, 15849 SHA: &EditSHA{ 15850 From: Ptr("BaseSHAFrom"), 15851 }, 15852 }, 15853 }, 15854 RequestedReviewer: &User{ 15855 Login: Ptr("l"), 15856 ID: Ptr(int64(1)), 15857 NodeID: Ptr("n"), 15858 URL: Ptr("u"), 15859 ReposURL: Ptr("r"), 15860 EventsURL: Ptr("e"), 15861 AvatarURL: Ptr("a"), 15862 }, 15863 RequestedTeam: &Team{ID: Ptr(int64(1))}, 15864 Label: &Label{ID: Ptr(int64(1))}, 15865 Before: Ptr("before"), 15866 After: Ptr("after"), 15867 Repo: &Repository{ 15868 ID: Ptr(int64(1)), 15869 URL: Ptr("s"), 15870 Name: Ptr("n"), 15871 }, 15872 PerformedViaGithubApp: &App{ 15873 ID: Ptr(int64(1)), 15874 NodeID: Ptr("n"), 15875 Slug: Ptr("s"), 15876 Name: Ptr("n"), 15877 Description: Ptr("d"), 15878 ExternalURL: Ptr("e"), 15879 HTMLURL: Ptr("h"), 15880 }, 15881 Organization: &Organization{ 15882 BillingEmail: Ptr("be"), 15883 Blog: Ptr("b"), 15884 Company: Ptr("c"), 15885 Email: Ptr("e"), 15886 TwitterUsername: Ptr("tu"), 15887 Location: Ptr("loc"), 15888 Name: Ptr("n"), 15889 Description: Ptr("d"), 15890 IsVerified: Ptr(true), 15891 HasOrganizationProjects: Ptr(true), 15892 HasRepositoryProjects: Ptr(true), 15893 DefaultRepoPermission: Ptr("drp"), 15894 MembersCanCreateRepos: Ptr(true), 15895 MembersCanCreateInternalRepos: Ptr(true), 15896 MembersCanCreatePrivateRepos: Ptr(true), 15897 MembersCanCreatePublicRepos: Ptr(false), 15898 MembersAllowedRepositoryCreationType: Ptr("marct"), 15899 MembersCanCreatePages: Ptr(true), 15900 MembersCanCreatePublicPages: Ptr(false), 15901 MembersCanCreatePrivatePages: Ptr(true), 15902 }, 15903 Sender: &User{ 15904 Login: Ptr("l"), 15905 ID: Ptr(int64(1)), 15906 NodeID: Ptr("n"), 15907 URL: Ptr("u"), 15908 ReposURL: Ptr("r"), 15909 EventsURL: Ptr("e"), 15910 AvatarURL: Ptr("a"), 15911 }, 15912 Installation: &Installation{ 15913 ID: Ptr(int64(1)), 15914 NodeID: Ptr("nid"), 15915 AppID: Ptr(int64(1)), 15916 AppSlug: Ptr("as"), 15917 TargetID: Ptr(int64(1)), 15918 Account: &User{ 15919 Login: Ptr("l"), 15920 ID: Ptr(int64(1)), 15921 URL: Ptr("u"), 15922 AvatarURL: Ptr("a"), 15923 GravatarID: Ptr("g"), 15924 Name: Ptr("n"), 15925 Company: Ptr("c"), 15926 Blog: Ptr("b"), 15927 Location: Ptr("l"), 15928 Email: Ptr("e"), 15929 Hireable: Ptr(true), 15930 Bio: Ptr("b"), 15931 TwitterUsername: Ptr("t"), 15932 PublicRepos: Ptr(1), 15933 Followers: Ptr(1), 15934 Following: Ptr(1), 15935 CreatedAt: &Timestamp{referenceTime}, 15936 SuspendedAt: &Timestamp{referenceTime}, 15937 }, 15938 AccessTokensURL: Ptr("atu"), 15939 RepositoriesURL: Ptr("ru"), 15940 HTMLURL: Ptr("hu"), 15941 TargetType: Ptr("tt"), 15942 SingleFileName: Ptr("sfn"), 15943 RepositorySelection: Ptr("rs"), 15944 Events: []string{"e"}, 15945 SingleFilePaths: []string{"s"}, 15946 Permissions: &InstallationPermissions{ 15947 Actions: Ptr("a"), 15948 Administration: Ptr("ad"), 15949 Checks: Ptr("c"), 15950 Contents: Ptr("co"), 15951 ContentReferences: Ptr("cr"), 15952 Deployments: Ptr("d"), 15953 Environments: Ptr("e"), 15954 Issues: Ptr("i"), 15955 Metadata: Ptr("md"), 15956 Members: Ptr("m"), 15957 OrganizationAdministration: Ptr("oa"), 15958 OrganizationHooks: Ptr("oh"), 15959 OrganizationPlan: Ptr("op"), 15960 OrganizationPreReceiveHooks: Ptr("opr"), 15961 OrganizationProjects: Ptr("op"), 15962 OrganizationSecrets: Ptr("os"), 15963 OrganizationSelfHostedRunners: Ptr("osh"), 15964 OrganizationUserBlocking: Ptr("oub"), 15965 Packages: Ptr("pkg"), 15966 Pages: Ptr("pg"), 15967 PullRequests: Ptr("pr"), 15968 RepositoryHooks: Ptr("rh"), 15969 RepositoryProjects: Ptr("rp"), 15970 RepositoryPreReceiveHooks: Ptr("rprh"), 15971 Secrets: Ptr("s"), 15972 SecretScanningAlerts: Ptr("ssa"), 15973 SecurityEvents: Ptr("se"), 15974 SingleFile: Ptr("sf"), 15975 Statuses: Ptr("s"), 15976 TeamDiscussions: Ptr("td"), 15977 VulnerabilityAlerts: Ptr("va"), 15978 Workflows: Ptr("w"), 15979 }, 15980 CreatedAt: &Timestamp{referenceTime}, 15981 UpdatedAt: &Timestamp{referenceTime}, 15982 HasMultipleSingleFiles: Ptr(false), 15983 SuspendedBy: &User{ 15984 Login: Ptr("l"), 15985 ID: Ptr(int64(1)), 15986 URL: Ptr("u"), 15987 AvatarURL: Ptr("a"), 15988 GravatarID: Ptr("g"), 15989 Name: Ptr("n"), 15990 Company: Ptr("c"), 15991 Blog: Ptr("b"), 15992 Location: Ptr("l"), 15993 Email: Ptr("e"), 15994 Hireable: Ptr(true), 15995 Bio: Ptr("b"), 15996 TwitterUsername: Ptr("t"), 15997 PublicRepos: Ptr(1), 15998 Followers: Ptr(1), 15999 Following: Ptr(1), 16000 CreatedAt: &Timestamp{referenceTime}, 16001 SuspendedAt: &Timestamp{referenceTime}, 16002 }, 16003 SuspendedAt: &Timestamp{referenceTime}, 16004 }, 16005 } 16006 16007 want := `{ 16008 "action": "a", 16009 "assignee": { 16010 "login": "l", 16011 "id": 1, 16012 "node_id": "n", 16013 "avatar_url": "a", 16014 "url": "u", 16015 "events_url": "e", 16016 "repos_url": "r" 16017 }, 16018 "number": 1, 16019 "pull_request": { 16020 "id": 1 16021 }, 16022 "changes": { 16023 "title": { 16024 "from": "TitleFrom" 16025 }, 16026 "body": { 16027 "from": "BodyFrom" 16028 }, 16029 "base": { 16030 "ref": { 16031 "from": "BaseRefFrom" 16032 }, 16033 "sha": { 16034 "from": "BaseSHAFrom" 16035 } 16036 } 16037 }, 16038 "requested_reviewer": { 16039 "login": "l", 16040 "id": 1, 16041 "node_id": "n", 16042 "avatar_url": "a", 16043 "url": "u", 16044 "events_url": "e", 16045 "repos_url": "r" 16046 }, 16047 "requested_team": { 16048 "id": 1 16049 }, 16050 "label": { 16051 "id": 1 16052 }, 16053 "before": "before", 16054 "after": "after", 16055 "repository": { 16056 "id": 1, 16057 "name": "n", 16058 "url": "s" 16059 }, 16060 "performed_via_github_app": { 16061 "id": 1, 16062 "node_id": "n", 16063 "slug": "s", 16064 "name": "n", 16065 "description": "d", 16066 "external_url": "e", 16067 "html_url": "h" 16068 }, 16069 "organization": { 16070 "name": "n", 16071 "company": "c", 16072 "blog": "b", 16073 "location": "loc", 16074 "email": "e", 16075 "twitter_username": "tu", 16076 "description": "d", 16077 "billing_email": "be", 16078 "is_verified": true, 16079 "has_organization_projects": true, 16080 "has_repository_projects": true, 16081 "default_repository_permission": "drp", 16082 "members_can_create_repositories": true, 16083 "members_can_create_public_repositories": false, 16084 "members_can_create_private_repositories": true, 16085 "members_can_create_internal_repositories": true, 16086 "members_allowed_repository_creation_type": "marct", 16087 "members_can_create_pages": true, 16088 "members_can_create_public_pages": false, 16089 "members_can_create_private_pages": true 16090 }, 16091 "sender": { 16092 "login": "l", 16093 "id": 1, 16094 "node_id": "n", 16095 "avatar_url": "a", 16096 "url": "u", 16097 "events_url": "e", 16098 "repos_url": "r" 16099 }, 16100 "installation": { 16101 "id": 1, 16102 "node_id": "nid", 16103 "app_id": 1, 16104 "app_slug": "as", 16105 "target_id": 1, 16106 "account": { 16107 "login": "l", 16108 "id": 1, 16109 "avatar_url": "a", 16110 "gravatar_id": "g", 16111 "name": "n", 16112 "company": "c", 16113 "blog": "b", 16114 "location": "l", 16115 "email": "e", 16116 "hireable": true, 16117 "bio": "b", 16118 "twitter_username": "t", 16119 "public_repos": 1, 16120 "followers": 1, 16121 "following": 1, 16122 "created_at": ` + referenceTimeStr + `, 16123 "suspended_at": ` + referenceTimeStr + `, 16124 "url": "u" 16125 }, 16126 "access_tokens_url": "atu", 16127 "repositories_url": "ru", 16128 "html_url": "hu", 16129 "target_type": "tt", 16130 "single_file_name": "sfn", 16131 "repository_selection": "rs", 16132 "events": [ 16133 "e" 16134 ], 16135 "single_file_paths": [ 16136 "s" 16137 ], 16138 "permissions": { 16139 "actions": "a", 16140 "administration": "ad", 16141 "checks": "c", 16142 "contents": "co", 16143 "content_references": "cr", 16144 "deployments": "d", 16145 "environments": "e", 16146 "issues": "i", 16147 "metadata": "md", 16148 "members": "m", 16149 "organization_administration": "oa", 16150 "organization_hooks": "oh", 16151 "organization_plan": "op", 16152 "organization_pre_receive_hooks": "opr", 16153 "organization_projects": "op", 16154 "organization_secrets": "os", 16155 "organization_self_hosted_runners": "osh", 16156 "organization_user_blocking": "oub", 16157 "packages": "pkg", 16158 "pages": "pg", 16159 "pull_requests": "pr", 16160 "repository_hooks": "rh", 16161 "repository_projects": "rp", 16162 "repository_pre_receive_hooks": "rprh", 16163 "secrets": "s", 16164 "secret_scanning_alerts": "ssa", 16165 "security_events": "se", 16166 "single_file": "sf", 16167 "statuses": "s", 16168 "team_discussions": "td", 16169 "vulnerability_alerts": "va", 16170 "workflows": "w" 16171 }, 16172 "created_at": ` + referenceTimeStr + `, 16173 "updated_at": ` + referenceTimeStr + `, 16174 "has_multiple_single_files": false, 16175 "suspended_by": { 16176 "login": "l", 16177 "id": 1, 16178 "avatar_url": "a", 16179 "gravatar_id": "g", 16180 "name": "n", 16181 "company": "c", 16182 "blog": "b", 16183 "location": "l", 16184 "email": "e", 16185 "hireable": true, 16186 "bio": "b", 16187 "twitter_username": "t", 16188 "public_repos": 1, 16189 "followers": 1, 16190 "following": 1, 16191 "created_at": ` + referenceTimeStr + `, 16192 "suspended_at": ` + referenceTimeStr + `, 16193 "url": "u" 16194 }, 16195 "suspended_at": ` + referenceTimeStr + ` 16196 } 16197 }` 16198 16199 testJSONMarshal(t, u, want) 16200 } 16201 16202 func TestPullRequestReviewCommentEvent_Marshal(t *testing.T) { 16203 t.Parallel() 16204 testJSONMarshal(t, &PullRequestReviewCommentEvent{}, "{}") 16205 16206 u := &PullRequestReviewCommentEvent{ 16207 Action: Ptr("a"), 16208 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 16209 Comment: &PullRequestComment{ID: Ptr(int64(1))}, 16210 Changes: &EditChange{ 16211 Title: &EditTitle{ 16212 From: Ptr("TitleFrom"), 16213 }, 16214 Body: &EditBody{ 16215 From: Ptr("BodyFrom"), 16216 }, 16217 Base: &EditBase{ 16218 Ref: &EditRef{ 16219 From: Ptr("BaseRefFrom"), 16220 }, 16221 SHA: &EditSHA{ 16222 From: Ptr("BaseSHAFrom"), 16223 }, 16224 }, 16225 }, 16226 Repo: &Repository{ 16227 ID: Ptr(int64(1)), 16228 URL: Ptr("s"), 16229 Name: Ptr("n"), 16230 }, 16231 Sender: &User{ 16232 Login: Ptr("l"), 16233 ID: Ptr(int64(1)), 16234 NodeID: Ptr("n"), 16235 URL: Ptr("u"), 16236 ReposURL: Ptr("r"), 16237 EventsURL: Ptr("e"), 16238 AvatarURL: Ptr("a"), 16239 }, 16240 Installation: &Installation{ 16241 ID: Ptr(int64(1)), 16242 NodeID: Ptr("nid"), 16243 AppID: Ptr(int64(1)), 16244 AppSlug: Ptr("as"), 16245 TargetID: Ptr(int64(1)), 16246 Account: &User{ 16247 Login: Ptr("l"), 16248 ID: Ptr(int64(1)), 16249 URL: Ptr("u"), 16250 AvatarURL: Ptr("a"), 16251 GravatarID: Ptr("g"), 16252 Name: Ptr("n"), 16253 Company: Ptr("c"), 16254 Blog: Ptr("b"), 16255 Location: Ptr("l"), 16256 Email: Ptr("e"), 16257 Hireable: Ptr(true), 16258 Bio: Ptr("b"), 16259 TwitterUsername: Ptr("t"), 16260 PublicRepos: Ptr(1), 16261 Followers: Ptr(1), 16262 Following: Ptr(1), 16263 CreatedAt: &Timestamp{referenceTime}, 16264 SuspendedAt: &Timestamp{referenceTime}, 16265 }, 16266 AccessTokensURL: Ptr("atu"), 16267 RepositoriesURL: Ptr("ru"), 16268 HTMLURL: Ptr("hu"), 16269 TargetType: Ptr("tt"), 16270 SingleFileName: Ptr("sfn"), 16271 RepositorySelection: Ptr("rs"), 16272 Events: []string{"e"}, 16273 SingleFilePaths: []string{"s"}, 16274 Permissions: &InstallationPermissions{ 16275 Actions: Ptr("a"), 16276 Administration: Ptr("ad"), 16277 Checks: Ptr("c"), 16278 Contents: Ptr("co"), 16279 ContentReferences: Ptr("cr"), 16280 Deployments: Ptr("d"), 16281 Environments: Ptr("e"), 16282 Issues: Ptr("i"), 16283 Metadata: Ptr("md"), 16284 Members: Ptr("m"), 16285 OrganizationAdministration: Ptr("oa"), 16286 OrganizationHooks: Ptr("oh"), 16287 OrganizationPlan: Ptr("op"), 16288 OrganizationPreReceiveHooks: Ptr("opr"), 16289 OrganizationProjects: Ptr("op"), 16290 OrganizationSecrets: Ptr("os"), 16291 OrganizationSelfHostedRunners: Ptr("osh"), 16292 OrganizationUserBlocking: Ptr("oub"), 16293 Packages: Ptr("pkg"), 16294 Pages: Ptr("pg"), 16295 PullRequests: Ptr("pr"), 16296 RepositoryHooks: Ptr("rh"), 16297 RepositoryProjects: Ptr("rp"), 16298 RepositoryPreReceiveHooks: Ptr("rprh"), 16299 Secrets: Ptr("s"), 16300 SecretScanningAlerts: Ptr("ssa"), 16301 SecurityEvents: Ptr("se"), 16302 SingleFile: Ptr("sf"), 16303 Statuses: Ptr("s"), 16304 TeamDiscussions: Ptr("td"), 16305 VulnerabilityAlerts: Ptr("va"), 16306 Workflows: Ptr("w"), 16307 }, 16308 CreatedAt: &Timestamp{referenceTime}, 16309 UpdatedAt: &Timestamp{referenceTime}, 16310 HasMultipleSingleFiles: Ptr(false), 16311 SuspendedBy: &User{ 16312 Login: Ptr("l"), 16313 ID: Ptr(int64(1)), 16314 URL: Ptr("u"), 16315 AvatarURL: Ptr("a"), 16316 GravatarID: Ptr("g"), 16317 Name: Ptr("n"), 16318 Company: Ptr("c"), 16319 Blog: Ptr("b"), 16320 Location: Ptr("l"), 16321 Email: Ptr("e"), 16322 Hireable: Ptr(true), 16323 Bio: Ptr("b"), 16324 TwitterUsername: Ptr("t"), 16325 PublicRepos: Ptr(1), 16326 Followers: Ptr(1), 16327 Following: Ptr(1), 16328 CreatedAt: &Timestamp{referenceTime}, 16329 SuspendedAt: &Timestamp{referenceTime}, 16330 }, 16331 SuspendedAt: &Timestamp{referenceTime}, 16332 }, 16333 } 16334 16335 want := `{ 16336 "action": "a", 16337 "pull_request": { 16338 "id": 1 16339 }, 16340 "comment": { 16341 "id": 1 16342 }, 16343 "changes": { 16344 "title": { 16345 "from": "TitleFrom" 16346 }, 16347 "body": { 16348 "from": "BodyFrom" 16349 }, 16350 "base": { 16351 "ref": { 16352 "from": "BaseRefFrom" 16353 }, 16354 "sha": { 16355 "from": "BaseSHAFrom" 16356 } 16357 } 16358 }, 16359 "repository": { 16360 "id": 1, 16361 "name": "n", 16362 "url": "s" 16363 }, 16364 "sender": { 16365 "login": "l", 16366 "id": 1, 16367 "node_id": "n", 16368 "avatar_url": "a", 16369 "url": "u", 16370 "events_url": "e", 16371 "repos_url": "r" 16372 }, 16373 "installation": { 16374 "id": 1, 16375 "node_id": "nid", 16376 "app_id": 1, 16377 "app_slug": "as", 16378 "target_id": 1, 16379 "account": { 16380 "login": "l", 16381 "id": 1, 16382 "avatar_url": "a", 16383 "gravatar_id": "g", 16384 "name": "n", 16385 "company": "c", 16386 "blog": "b", 16387 "location": "l", 16388 "email": "e", 16389 "hireable": true, 16390 "bio": "b", 16391 "twitter_username": "t", 16392 "public_repos": 1, 16393 "followers": 1, 16394 "following": 1, 16395 "created_at": ` + referenceTimeStr + `, 16396 "suspended_at": ` + referenceTimeStr + `, 16397 "url": "u" 16398 }, 16399 "access_tokens_url": "atu", 16400 "repositories_url": "ru", 16401 "html_url": "hu", 16402 "target_type": "tt", 16403 "single_file_name": "sfn", 16404 "repository_selection": "rs", 16405 "events": [ 16406 "e" 16407 ], 16408 "single_file_paths": [ 16409 "s" 16410 ], 16411 "permissions": { 16412 "actions": "a", 16413 "administration": "ad", 16414 "checks": "c", 16415 "contents": "co", 16416 "content_references": "cr", 16417 "deployments": "d", 16418 "environments": "e", 16419 "issues": "i", 16420 "metadata": "md", 16421 "members": "m", 16422 "organization_administration": "oa", 16423 "organization_hooks": "oh", 16424 "organization_plan": "op", 16425 "organization_pre_receive_hooks": "opr", 16426 "organization_projects": "op", 16427 "organization_secrets": "os", 16428 "organization_self_hosted_runners": "osh", 16429 "organization_user_blocking": "oub", 16430 "packages": "pkg", 16431 "pages": "pg", 16432 "pull_requests": "pr", 16433 "repository_hooks": "rh", 16434 "repository_projects": "rp", 16435 "repository_pre_receive_hooks": "rprh", 16436 "secrets": "s", 16437 "secret_scanning_alerts": "ssa", 16438 "security_events": "se", 16439 "single_file": "sf", 16440 "statuses": "s", 16441 "team_discussions": "td", 16442 "vulnerability_alerts": "va", 16443 "workflows": "w" 16444 }, 16445 "created_at": ` + referenceTimeStr + `, 16446 "updated_at": ` + referenceTimeStr + `, 16447 "has_multiple_single_files": false, 16448 "suspended_by": { 16449 "login": "l", 16450 "id": 1, 16451 "avatar_url": "a", 16452 "gravatar_id": "g", 16453 "name": "n", 16454 "company": "c", 16455 "blog": "b", 16456 "location": "l", 16457 "email": "e", 16458 "hireable": true, 16459 "bio": "b", 16460 "twitter_username": "t", 16461 "public_repos": 1, 16462 "followers": 1, 16463 "following": 1, 16464 "created_at": ` + referenceTimeStr + `, 16465 "suspended_at": ` + referenceTimeStr + `, 16466 "url": "u" 16467 }, 16468 "suspended_at": ` + referenceTimeStr + ` 16469 } 16470 }` 16471 16472 testJSONMarshal(t, u, want) 16473 } 16474 16475 func TestPullRequestReviewThreadEvent_Marshal(t *testing.T) { 16476 t.Parallel() 16477 testJSONMarshal(t, &PullRequestReviewThreadEvent{}, "{}") 16478 16479 u := &PullRequestReviewThreadEvent{ 16480 Action: Ptr("a"), 16481 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 16482 Thread: &PullRequestThread{ 16483 Comments: []*PullRequestComment{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}}, 16484 }, 16485 Repo: &Repository{ 16486 ID: Ptr(int64(1)), 16487 URL: Ptr("s"), 16488 Name: Ptr("n"), 16489 }, 16490 Sender: &User{ 16491 Login: Ptr("l"), 16492 ID: Ptr(int64(1)), 16493 NodeID: Ptr("n"), 16494 URL: Ptr("u"), 16495 ReposURL: Ptr("r"), 16496 EventsURL: Ptr("e"), 16497 AvatarURL: Ptr("a"), 16498 }, 16499 Installation: &Installation{ 16500 ID: Ptr(int64(1)), 16501 NodeID: Ptr("nid"), 16502 AppID: Ptr(int64(1)), 16503 AppSlug: Ptr("as"), 16504 TargetID: Ptr(int64(1)), 16505 Account: &User{ 16506 Login: Ptr("l"), 16507 ID: Ptr(int64(1)), 16508 URL: Ptr("u"), 16509 AvatarURL: Ptr("a"), 16510 GravatarID: Ptr("g"), 16511 Name: Ptr("n"), 16512 Company: Ptr("c"), 16513 Blog: Ptr("b"), 16514 Location: Ptr("l"), 16515 Email: Ptr("e"), 16516 Hireable: Ptr(true), 16517 Bio: Ptr("b"), 16518 TwitterUsername: Ptr("t"), 16519 PublicRepos: Ptr(1), 16520 Followers: Ptr(1), 16521 Following: Ptr(1), 16522 CreatedAt: &Timestamp{referenceTime}, 16523 SuspendedAt: &Timestamp{referenceTime}, 16524 }, 16525 AccessTokensURL: Ptr("atu"), 16526 RepositoriesURL: Ptr("ru"), 16527 HTMLURL: Ptr("hu"), 16528 TargetType: Ptr("tt"), 16529 SingleFileName: Ptr("sfn"), 16530 RepositorySelection: Ptr("rs"), 16531 Events: []string{"e"}, 16532 SingleFilePaths: []string{"s"}, 16533 Permissions: &InstallationPermissions{ 16534 Actions: Ptr("a"), 16535 Administration: Ptr("ad"), 16536 Checks: Ptr("c"), 16537 Contents: Ptr("co"), 16538 ContentReferences: Ptr("cr"), 16539 Deployments: Ptr("d"), 16540 Environments: Ptr("e"), 16541 Issues: Ptr("i"), 16542 Metadata: Ptr("md"), 16543 Members: Ptr("m"), 16544 OrganizationAdministration: Ptr("oa"), 16545 OrganizationHooks: Ptr("oh"), 16546 OrganizationPlan: Ptr("op"), 16547 OrganizationPreReceiveHooks: Ptr("opr"), 16548 OrganizationProjects: Ptr("op"), 16549 OrganizationSecrets: Ptr("os"), 16550 OrganizationSelfHostedRunners: Ptr("osh"), 16551 OrganizationUserBlocking: Ptr("oub"), 16552 Packages: Ptr("pkg"), 16553 Pages: Ptr("pg"), 16554 PullRequests: Ptr("pr"), 16555 RepositoryHooks: Ptr("rh"), 16556 RepositoryProjects: Ptr("rp"), 16557 RepositoryPreReceiveHooks: Ptr("rprh"), 16558 Secrets: Ptr("s"), 16559 SecretScanningAlerts: Ptr("ssa"), 16560 SecurityEvents: Ptr("se"), 16561 SingleFile: Ptr("sf"), 16562 Statuses: Ptr("s"), 16563 TeamDiscussions: Ptr("td"), 16564 VulnerabilityAlerts: Ptr("va"), 16565 Workflows: Ptr("w"), 16566 }, 16567 CreatedAt: &Timestamp{referenceTime}, 16568 UpdatedAt: &Timestamp{referenceTime}, 16569 HasMultipleSingleFiles: Ptr(false), 16570 SuspendedBy: &User{ 16571 Login: Ptr("l"), 16572 ID: Ptr(int64(1)), 16573 URL: Ptr("u"), 16574 AvatarURL: Ptr("a"), 16575 GravatarID: Ptr("g"), 16576 Name: Ptr("n"), 16577 Company: Ptr("c"), 16578 Blog: Ptr("b"), 16579 Location: Ptr("l"), 16580 Email: Ptr("e"), 16581 Hireable: Ptr(true), 16582 Bio: Ptr("b"), 16583 TwitterUsername: Ptr("t"), 16584 PublicRepos: Ptr(1), 16585 Followers: Ptr(1), 16586 Following: Ptr(1), 16587 CreatedAt: &Timestamp{referenceTime}, 16588 SuspendedAt: &Timestamp{referenceTime}, 16589 }, 16590 SuspendedAt: &Timestamp{referenceTime}, 16591 }, 16592 } 16593 16594 want := `{ 16595 "action": "a", 16596 "pull_request": { 16597 "id": 1 16598 }, 16599 "thread": { 16600 "comments": [ 16601 { 16602 "id": 1 16603 }, 16604 { 16605 "id": 2 16606 } 16607 ] 16608 }, 16609 "repository": { 16610 "id": 1, 16611 "name": "n", 16612 "url": "s" 16613 }, 16614 "sender": { 16615 "login": "l", 16616 "id": 1, 16617 "node_id": "n", 16618 "avatar_url": "a", 16619 "url": "u", 16620 "events_url": "e", 16621 "repos_url": "r" 16622 }, 16623 "installation": { 16624 "id": 1, 16625 "node_id": "nid", 16626 "app_id": 1, 16627 "app_slug": "as", 16628 "target_id": 1, 16629 "account": { 16630 "login": "l", 16631 "id": 1, 16632 "avatar_url": "a", 16633 "gravatar_id": "g", 16634 "name": "n", 16635 "company": "c", 16636 "blog": "b", 16637 "location": "l", 16638 "email": "e", 16639 "hireable": true, 16640 "bio": "b", 16641 "twitter_username": "t", 16642 "public_repos": 1, 16643 "followers": 1, 16644 "following": 1, 16645 "created_at": ` + referenceTimeStr + `, 16646 "suspended_at": ` + referenceTimeStr + `, 16647 "url": "u" 16648 }, 16649 "access_tokens_url": "atu", 16650 "repositories_url": "ru", 16651 "html_url": "hu", 16652 "target_type": "tt", 16653 "single_file_name": "sfn", 16654 "repository_selection": "rs", 16655 "events": [ 16656 "e" 16657 ], 16658 "single_file_paths": [ 16659 "s" 16660 ], 16661 "permissions": { 16662 "actions": "a", 16663 "administration": "ad", 16664 "checks": "c", 16665 "contents": "co", 16666 "content_references": "cr", 16667 "deployments": "d", 16668 "environments": "e", 16669 "issues": "i", 16670 "metadata": "md", 16671 "members": "m", 16672 "organization_administration": "oa", 16673 "organization_hooks": "oh", 16674 "organization_plan": "op", 16675 "organization_pre_receive_hooks": "opr", 16676 "organization_projects": "op", 16677 "organization_secrets": "os", 16678 "organization_self_hosted_runners": "osh", 16679 "organization_user_blocking": "oub", 16680 "packages": "pkg", 16681 "pages": "pg", 16682 "pull_requests": "pr", 16683 "repository_hooks": "rh", 16684 "repository_projects": "rp", 16685 "repository_pre_receive_hooks": "rprh", 16686 "secrets": "s", 16687 "secret_scanning_alerts": "ssa", 16688 "security_events": "se", 16689 "single_file": "sf", 16690 "statuses": "s", 16691 "team_discussions": "td", 16692 "vulnerability_alerts": "va", 16693 "workflows": "w" 16694 }, 16695 "created_at": ` + referenceTimeStr + `, 16696 "updated_at": ` + referenceTimeStr + `, 16697 "has_multiple_single_files": false, 16698 "suspended_by": { 16699 "login": "l", 16700 "id": 1, 16701 "avatar_url": "a", 16702 "gravatar_id": "g", 16703 "name": "n", 16704 "company": "c", 16705 "blog": "b", 16706 "location": "l", 16707 "email": "e", 16708 "hireable": true, 16709 "bio": "b", 16710 "twitter_username": "t", 16711 "public_repos": 1, 16712 "followers": 1, 16713 "following": 1, 16714 "created_at": ` + referenceTimeStr + `, 16715 "suspended_at": ` + referenceTimeStr + `, 16716 "url": "u" 16717 }, 16718 "suspended_at": ` + referenceTimeStr + ` 16719 } 16720 }` 16721 16722 testJSONMarshal(t, u, want) 16723 } 16724 16725 func TestPullRequestTargetEvent_Marshal(t *testing.T) { 16726 t.Parallel() 16727 testJSONMarshal(t, &PullRequestTargetEvent{}, "{}") 16728 16729 u := &PullRequestTargetEvent{ 16730 Action: Ptr("a"), 16731 Assignee: &User{ 16732 Login: Ptr("l"), 16733 ID: Ptr(int64(1)), 16734 NodeID: Ptr("n"), 16735 URL: Ptr("u"), 16736 ReposURL: Ptr("r"), 16737 EventsURL: Ptr("e"), 16738 AvatarURL: Ptr("a"), 16739 }, 16740 Number: Ptr(1), 16741 PullRequest: &PullRequest{ID: Ptr(int64(1))}, 16742 Changes: &EditChange{ 16743 Title: &EditTitle{ 16744 From: Ptr("TitleFrom"), 16745 }, 16746 Body: &EditBody{ 16747 From: Ptr("BodyFrom"), 16748 }, 16749 Base: &EditBase{ 16750 Ref: &EditRef{ 16751 From: Ptr("BaseRefFrom"), 16752 }, 16753 SHA: &EditSHA{ 16754 From: Ptr("BaseSHAFrom"), 16755 }, 16756 }, 16757 }, 16758 RequestedReviewer: &User{ 16759 Login: Ptr("l"), 16760 ID: Ptr(int64(1)), 16761 NodeID: Ptr("n"), 16762 URL: Ptr("u"), 16763 ReposURL: Ptr("r"), 16764 EventsURL: Ptr("e"), 16765 AvatarURL: Ptr("a"), 16766 }, 16767 RequestedTeam: &Team{ID: Ptr(int64(1))}, 16768 Label: &Label{ID: Ptr(int64(1))}, 16769 Before: Ptr("before"), 16770 After: Ptr("after"), 16771 Repo: &Repository{ 16772 ID: Ptr(int64(1)), 16773 URL: Ptr("s"), 16774 Name: Ptr("n"), 16775 }, 16776 PerformedViaGithubApp: &App{ 16777 ID: Ptr(int64(1)), 16778 NodeID: Ptr("n"), 16779 Slug: Ptr("s"), 16780 Name: Ptr("n"), 16781 Description: Ptr("d"), 16782 ExternalURL: Ptr("e"), 16783 HTMLURL: Ptr("h"), 16784 }, 16785 Organization: &Organization{ 16786 BillingEmail: Ptr("be"), 16787 Blog: Ptr("b"), 16788 Company: Ptr("c"), 16789 Email: Ptr("e"), 16790 TwitterUsername: Ptr("tu"), 16791 Location: Ptr("loc"), 16792 Name: Ptr("n"), 16793 Description: Ptr("d"), 16794 IsVerified: Ptr(true), 16795 HasOrganizationProjects: Ptr(true), 16796 HasRepositoryProjects: Ptr(true), 16797 DefaultRepoPermission: Ptr("drp"), 16798 MembersCanCreateRepos: Ptr(true), 16799 MembersCanCreateInternalRepos: Ptr(true), 16800 MembersCanCreatePrivateRepos: Ptr(true), 16801 MembersCanCreatePublicRepos: Ptr(false), 16802 MembersAllowedRepositoryCreationType: Ptr("marct"), 16803 MembersCanCreatePages: Ptr(true), 16804 MembersCanCreatePublicPages: Ptr(false), 16805 MembersCanCreatePrivatePages: Ptr(true), 16806 }, 16807 Sender: &User{ 16808 Login: Ptr("l"), 16809 ID: Ptr(int64(1)), 16810 NodeID: Ptr("n"), 16811 URL: Ptr("u"), 16812 ReposURL: Ptr("r"), 16813 EventsURL: Ptr("e"), 16814 AvatarURL: Ptr("a"), 16815 }, 16816 Installation: &Installation{ 16817 ID: Ptr(int64(1)), 16818 NodeID: Ptr("nid"), 16819 AppID: Ptr(int64(1)), 16820 AppSlug: Ptr("as"), 16821 TargetID: Ptr(int64(1)), 16822 Account: &User{ 16823 Login: Ptr("l"), 16824 ID: Ptr(int64(1)), 16825 URL: Ptr("u"), 16826 AvatarURL: Ptr("a"), 16827 GravatarID: Ptr("g"), 16828 Name: Ptr("n"), 16829 Company: Ptr("c"), 16830 Blog: Ptr("b"), 16831 Location: Ptr("l"), 16832 Email: Ptr("e"), 16833 Hireable: Ptr(true), 16834 Bio: Ptr("b"), 16835 TwitterUsername: Ptr("t"), 16836 PublicRepos: Ptr(1), 16837 Followers: Ptr(1), 16838 Following: Ptr(1), 16839 CreatedAt: &Timestamp{referenceTime}, 16840 SuspendedAt: &Timestamp{referenceTime}, 16841 }, 16842 AccessTokensURL: Ptr("atu"), 16843 RepositoriesURL: Ptr("ru"), 16844 HTMLURL: Ptr("hu"), 16845 TargetType: Ptr("tt"), 16846 SingleFileName: Ptr("sfn"), 16847 RepositorySelection: Ptr("rs"), 16848 Events: []string{"e"}, 16849 SingleFilePaths: []string{"s"}, 16850 Permissions: &InstallationPermissions{ 16851 Actions: Ptr("a"), 16852 Administration: Ptr("ad"), 16853 Checks: Ptr("c"), 16854 Contents: Ptr("co"), 16855 ContentReferences: Ptr("cr"), 16856 Deployments: Ptr("d"), 16857 Environments: Ptr("e"), 16858 Issues: Ptr("i"), 16859 Metadata: Ptr("md"), 16860 Members: Ptr("m"), 16861 OrganizationAdministration: Ptr("oa"), 16862 OrganizationHooks: Ptr("oh"), 16863 OrganizationPlan: Ptr("op"), 16864 OrganizationPreReceiveHooks: Ptr("opr"), 16865 OrganizationProjects: Ptr("op"), 16866 OrganizationSecrets: Ptr("os"), 16867 OrganizationSelfHostedRunners: Ptr("osh"), 16868 OrganizationUserBlocking: Ptr("oub"), 16869 Packages: Ptr("pkg"), 16870 Pages: Ptr("pg"), 16871 PullRequests: Ptr("pr"), 16872 RepositoryHooks: Ptr("rh"), 16873 RepositoryProjects: Ptr("rp"), 16874 RepositoryPreReceiveHooks: Ptr("rprh"), 16875 Secrets: Ptr("s"), 16876 SecretScanningAlerts: Ptr("ssa"), 16877 SecurityEvents: Ptr("se"), 16878 SingleFile: Ptr("sf"), 16879 Statuses: Ptr("s"), 16880 TeamDiscussions: Ptr("td"), 16881 VulnerabilityAlerts: Ptr("va"), 16882 Workflows: Ptr("w"), 16883 }, 16884 CreatedAt: &Timestamp{referenceTime}, 16885 UpdatedAt: &Timestamp{referenceTime}, 16886 HasMultipleSingleFiles: Ptr(false), 16887 SuspendedBy: &User{ 16888 Login: Ptr("l"), 16889 ID: Ptr(int64(1)), 16890 URL: Ptr("u"), 16891 AvatarURL: Ptr("a"), 16892 GravatarID: Ptr("g"), 16893 Name: Ptr("n"), 16894 Company: Ptr("c"), 16895 Blog: Ptr("b"), 16896 Location: Ptr("l"), 16897 Email: Ptr("e"), 16898 Hireable: Ptr(true), 16899 Bio: Ptr("b"), 16900 TwitterUsername: Ptr("t"), 16901 PublicRepos: Ptr(1), 16902 Followers: Ptr(1), 16903 Following: Ptr(1), 16904 CreatedAt: &Timestamp{referenceTime}, 16905 SuspendedAt: &Timestamp{referenceTime}, 16906 }, 16907 SuspendedAt: &Timestamp{referenceTime}, 16908 }, 16909 } 16910 16911 want := `{ 16912 "action": "a", 16913 "assignee": { 16914 "login": "l", 16915 "id": 1, 16916 "node_id": "n", 16917 "avatar_url": "a", 16918 "url": "u", 16919 "events_url": "e", 16920 "repos_url": "r" 16921 }, 16922 "number": 1, 16923 "pull_request": { 16924 "id": 1 16925 }, 16926 "changes": { 16927 "title": { 16928 "from": "TitleFrom" 16929 }, 16930 "body": { 16931 "from": "BodyFrom" 16932 }, 16933 "base": { 16934 "ref": { 16935 "from": "BaseRefFrom" 16936 }, 16937 "sha": { 16938 "from": "BaseSHAFrom" 16939 } 16940 } 16941 }, 16942 "requested_reviewer": { 16943 "login": "l", 16944 "id": 1, 16945 "node_id": "n", 16946 "avatar_url": "a", 16947 "url": "u", 16948 "events_url": "e", 16949 "repos_url": "r" 16950 }, 16951 "requested_team": { 16952 "id": 1 16953 }, 16954 "label": { 16955 "id": 1 16956 }, 16957 "before": "before", 16958 "after": "after", 16959 "repository": { 16960 "id": 1, 16961 "name": "n", 16962 "url": "s" 16963 }, 16964 "performed_via_github_app": { 16965 "id": 1, 16966 "node_id": "n", 16967 "slug": "s", 16968 "name": "n", 16969 "description": "d", 16970 "external_url": "e", 16971 "html_url": "h" 16972 }, 16973 "organization": { 16974 "name": "n", 16975 "company": "c", 16976 "blog": "b", 16977 "location": "loc", 16978 "email": "e", 16979 "twitter_username": "tu", 16980 "description": "d", 16981 "billing_email": "be", 16982 "is_verified": true, 16983 "has_organization_projects": true, 16984 "has_repository_projects": true, 16985 "default_repository_permission": "drp", 16986 "members_can_create_repositories": true, 16987 "members_can_create_public_repositories": false, 16988 "members_can_create_private_repositories": true, 16989 "members_can_create_internal_repositories": true, 16990 "members_allowed_repository_creation_type": "marct", 16991 "members_can_create_pages": true, 16992 "members_can_create_public_pages": false, 16993 "members_can_create_private_pages": true 16994 }, 16995 "sender": { 16996 "login": "l", 16997 "id": 1, 16998 "node_id": "n", 16999 "avatar_url": "a", 17000 "url": "u", 17001 "events_url": "e", 17002 "repos_url": "r" 17003 }, 17004 "installation": { 17005 "id": 1, 17006 "node_id": "nid", 17007 "app_id": 1, 17008 "app_slug": "as", 17009 "target_id": 1, 17010 "account": { 17011 "login": "l", 17012 "id": 1, 17013 "avatar_url": "a", 17014 "gravatar_id": "g", 17015 "name": "n", 17016 "company": "c", 17017 "blog": "b", 17018 "location": "l", 17019 "email": "e", 17020 "hireable": true, 17021 "bio": "b", 17022 "twitter_username": "t", 17023 "public_repos": 1, 17024 "followers": 1, 17025 "following": 1, 17026 "created_at": ` + referenceTimeStr + `, 17027 "suspended_at": ` + referenceTimeStr + `, 17028 "url": "u" 17029 }, 17030 "access_tokens_url": "atu", 17031 "repositories_url": "ru", 17032 "html_url": "hu", 17033 "target_type": "tt", 17034 "single_file_name": "sfn", 17035 "repository_selection": "rs", 17036 "events": [ 17037 "e" 17038 ], 17039 "single_file_paths": [ 17040 "s" 17041 ], 17042 "permissions": { 17043 "actions": "a", 17044 "administration": "ad", 17045 "checks": "c", 17046 "contents": "co", 17047 "content_references": "cr", 17048 "deployments": "d", 17049 "environments": "e", 17050 "issues": "i", 17051 "metadata": "md", 17052 "members": "m", 17053 "organization_administration": "oa", 17054 "organization_hooks": "oh", 17055 "organization_plan": "op", 17056 "organization_pre_receive_hooks": "opr", 17057 "organization_projects": "op", 17058 "organization_secrets": "os", 17059 "organization_self_hosted_runners": "osh", 17060 "organization_user_blocking": "oub", 17061 "packages": "pkg", 17062 "pages": "pg", 17063 "pull_requests": "pr", 17064 "repository_hooks": "rh", 17065 "repository_projects": "rp", 17066 "repository_pre_receive_hooks": "rprh", 17067 "secrets": "s", 17068 "secret_scanning_alerts": "ssa", 17069 "security_events": "se", 17070 "single_file": "sf", 17071 "statuses": "s", 17072 "team_discussions": "td", 17073 "vulnerability_alerts": "va", 17074 "workflows": "w" 17075 }, 17076 "created_at": ` + referenceTimeStr + `, 17077 "updated_at": ` + referenceTimeStr + `, 17078 "has_multiple_single_files": false, 17079 "suspended_by": { 17080 "login": "l", 17081 "id": 1, 17082 "avatar_url": "a", 17083 "gravatar_id": "g", 17084 "name": "n", 17085 "company": "c", 17086 "blog": "b", 17087 "location": "l", 17088 "email": "e", 17089 "hireable": true, 17090 "bio": "b", 17091 "twitter_username": "t", 17092 "public_repos": 1, 17093 "followers": 1, 17094 "following": 1, 17095 "created_at": ` + referenceTimeStr + `, 17096 "suspended_at": ` + referenceTimeStr + `, 17097 "url": "u" 17098 }, 17099 "suspended_at": ` + referenceTimeStr + ` 17100 } 17101 }` 17102 17103 testJSONMarshal(t, u, want) 17104 } 17105 17106 func TestRepositoryVulnerabilityAlertEvent_Marshal(t *testing.T) { 17107 t.Parallel() 17108 testJSONMarshal(t, &RepositoryVulnerabilityAlertEvent{}, "{}") 17109 17110 u := &RepositoryVulnerabilityAlertEvent{ 17111 Action: Ptr("a"), 17112 Alert: &RepositoryVulnerabilityAlert{ 17113 ID: Ptr(int64(1)), 17114 AffectedRange: Ptr("ar"), 17115 AffectedPackageName: Ptr("apn"), 17116 ExternalReference: Ptr("er"), 17117 ExternalIdentifier: Ptr("ei"), 17118 FixedIn: Ptr("fi"), 17119 Dismisser: &User{ 17120 Login: Ptr("l"), 17121 ID: Ptr(int64(1)), 17122 NodeID: Ptr("n"), 17123 URL: Ptr("u"), 17124 ReposURL: Ptr("r"), 17125 EventsURL: Ptr("e"), 17126 AvatarURL: Ptr("a"), 17127 }, 17128 DismissReason: Ptr("dr"), 17129 DismissedAt: &Timestamp{referenceTime}, 17130 }, 17131 Repository: &Repository{ 17132 ID: Ptr(int64(1)), 17133 URL: Ptr("s"), 17134 Name: Ptr("n"), 17135 }, 17136 } 17137 17138 want := `{ 17139 "action": "a", 17140 "alert": { 17141 "id": 1, 17142 "affected_range": "ar", 17143 "affected_package_name": "apn", 17144 "external_reference": "er", 17145 "external_identifier": "ei", 17146 "fixed_in": "fi", 17147 "dismisser": { 17148 "login": "l", 17149 "id": 1, 17150 "node_id": "n", 17151 "avatar_url": "a", 17152 "url": "u", 17153 "events_url": "e", 17154 "repos_url": "r" 17155 }, 17156 "dismiss_reason": "dr", 17157 "dismissed_at": ` + referenceTimeStr + ` 17158 }, 17159 "repository": { 17160 "id": 1, 17161 "name": "n", 17162 "url": "s" 17163 } 17164 }` 17165 17166 testJSONMarshal(t, u, want) 17167 } 17168 17169 func TestSecretScanningAlertEvent_Marshal(t *testing.T) { 17170 t.Parallel() 17171 testJSONMarshal(t, &SecretScanningAlertEvent{}, "{}") 17172 17173 u := &SecretScanningAlertEvent{ 17174 Action: Ptr("a"), 17175 Alert: &SecretScanningAlert{ 17176 Number: Ptr(1), 17177 SecretType: Ptr("t"), 17178 Resolution: Ptr("r"), 17179 ResolvedBy: &User{ 17180 Login: Ptr("l"), 17181 ID: Ptr(int64(1)), 17182 NodeID: Ptr("n"), 17183 URL: Ptr("u"), 17184 ReposURL: Ptr("r"), 17185 EventsURL: Ptr("e"), 17186 AvatarURL: Ptr("a"), 17187 }, 17188 ResolvedAt: &Timestamp{referenceTime}, 17189 }, 17190 Repo: &Repository{ 17191 ID: Ptr(int64(1)), 17192 URL: Ptr("s"), 17193 Name: Ptr("n"), 17194 }, 17195 Organization: &Organization{ 17196 BillingEmail: Ptr("be"), 17197 Blog: Ptr("b"), 17198 Company: Ptr("c"), 17199 Email: Ptr("e"), 17200 TwitterUsername: Ptr("tu"), 17201 Location: Ptr("loc"), 17202 Name: Ptr("n"), 17203 Description: Ptr("d"), 17204 IsVerified: Ptr(true), 17205 HasOrganizationProjects: Ptr(true), 17206 HasRepositoryProjects: Ptr(true), 17207 DefaultRepoPermission: Ptr("drp"), 17208 MembersCanCreateRepos: Ptr(true), 17209 MembersCanCreateInternalRepos: Ptr(true), 17210 MembersCanCreatePrivateRepos: Ptr(true), 17211 MembersCanCreatePublicRepos: Ptr(false), 17212 MembersAllowedRepositoryCreationType: Ptr("marct"), 17213 MembersCanCreatePages: Ptr(true), 17214 MembersCanCreatePublicPages: Ptr(false), 17215 MembersCanCreatePrivatePages: Ptr(true), 17216 }, 17217 Enterprise: &Enterprise{ 17218 ID: Ptr(1), 17219 Slug: Ptr("s"), 17220 Name: Ptr("n"), 17221 NodeID: Ptr("nid"), 17222 AvatarURL: Ptr("au"), 17223 Description: Ptr("d"), 17224 WebsiteURL: Ptr("wu"), 17225 HTMLURL: Ptr("hu"), 17226 CreatedAt: &Timestamp{referenceTime}, 17227 UpdatedAt: &Timestamp{referenceTime}, 17228 }, 17229 Sender: &User{ 17230 Login: Ptr("l"), 17231 ID: Ptr(int64(1)), 17232 NodeID: Ptr("n"), 17233 URL: Ptr("u"), 17234 ReposURL: Ptr("r"), 17235 EventsURL: Ptr("e"), 17236 AvatarURL: Ptr("a"), 17237 }, 17238 Installation: &Installation{ 17239 ID: Ptr(int64(1)), 17240 NodeID: Ptr("nid"), 17241 AppID: Ptr(int64(1)), 17242 AppSlug: Ptr("as"), 17243 TargetID: Ptr(int64(1)), 17244 Account: &User{ 17245 Login: Ptr("l"), 17246 ID: Ptr(int64(1)), 17247 URL: Ptr("u"), 17248 AvatarURL: Ptr("a"), 17249 GravatarID: Ptr("g"), 17250 Name: Ptr("n"), 17251 Company: Ptr("c"), 17252 Blog: Ptr("b"), 17253 Location: Ptr("l"), 17254 Email: Ptr("e"), 17255 Hireable: Ptr(true), 17256 Bio: Ptr("b"), 17257 TwitterUsername: Ptr("t"), 17258 PublicRepos: Ptr(1), 17259 Followers: Ptr(1), 17260 Following: Ptr(1), 17261 CreatedAt: &Timestamp{referenceTime}, 17262 SuspendedAt: &Timestamp{referenceTime}, 17263 }, 17264 AccessTokensURL: Ptr("atu"), 17265 RepositoriesURL: Ptr("ru"), 17266 HTMLURL: Ptr("hu"), 17267 TargetType: Ptr("tt"), 17268 SingleFileName: Ptr("sfn"), 17269 RepositorySelection: Ptr("rs"), 17270 Events: []string{"e"}, 17271 SingleFilePaths: []string{"s"}, 17272 Permissions: &InstallationPermissions{ 17273 Actions: Ptr("a"), 17274 Administration: Ptr("ad"), 17275 Checks: Ptr("c"), 17276 Contents: Ptr("co"), 17277 ContentReferences: Ptr("cr"), 17278 Deployments: Ptr("d"), 17279 Environments: Ptr("e"), 17280 Issues: Ptr("i"), 17281 Metadata: Ptr("md"), 17282 Members: Ptr("m"), 17283 OrganizationAdministration: Ptr("oa"), 17284 OrganizationHooks: Ptr("oh"), 17285 OrganizationPlan: Ptr("op"), 17286 OrganizationPreReceiveHooks: Ptr("opr"), 17287 OrganizationProjects: Ptr("op"), 17288 OrganizationSecrets: Ptr("os"), 17289 OrganizationSelfHostedRunners: Ptr("osh"), 17290 OrganizationUserBlocking: Ptr("oub"), 17291 Packages: Ptr("pkg"), 17292 Pages: Ptr("pg"), 17293 PullRequests: Ptr("pr"), 17294 RepositoryHooks: Ptr("rh"), 17295 RepositoryProjects: Ptr("rp"), 17296 RepositoryPreReceiveHooks: Ptr("rprh"), 17297 Secrets: Ptr("s"), 17298 SecretScanningAlerts: Ptr("ssa"), 17299 SecurityEvents: Ptr("se"), 17300 SingleFile: Ptr("sf"), 17301 Statuses: Ptr("s"), 17302 TeamDiscussions: Ptr("td"), 17303 VulnerabilityAlerts: Ptr("va"), 17304 Workflows: Ptr("w"), 17305 }, 17306 CreatedAt: &Timestamp{referenceTime}, 17307 UpdatedAt: &Timestamp{referenceTime}, 17308 HasMultipleSingleFiles: Ptr(false), 17309 SuspendedBy: &User{ 17310 Login: Ptr("l"), 17311 ID: Ptr(int64(1)), 17312 URL: Ptr("u"), 17313 AvatarURL: Ptr("a"), 17314 GravatarID: Ptr("g"), 17315 Name: Ptr("n"), 17316 Company: Ptr("c"), 17317 Blog: Ptr("b"), 17318 Location: Ptr("l"), 17319 Email: Ptr("e"), 17320 Hireable: Ptr(true), 17321 Bio: Ptr("b"), 17322 TwitterUsername: Ptr("t"), 17323 PublicRepos: Ptr(1), 17324 Followers: Ptr(1), 17325 Following: Ptr(1), 17326 CreatedAt: &Timestamp{referenceTime}, 17327 SuspendedAt: &Timestamp{referenceTime}, 17328 }, 17329 SuspendedAt: &Timestamp{referenceTime}, 17330 }, 17331 } 17332 17333 want := `{ 17334 "action": "a", 17335 "alert": { 17336 "number": 1, 17337 "secret_type": "t", 17338 "resolution": "r", 17339 "resolved_by": { 17340 "login": "l", 17341 "id": 1, 17342 "node_id": "n", 17343 "avatar_url": "a", 17344 "url": "u", 17345 "events_url": "e", 17346 "repos_url": "r" 17347 }, 17348 "resolved_at": ` + referenceTimeStr + ` 17349 }, 17350 "repository": { 17351 "id": 1, 17352 "name": "n", 17353 "url": "s" 17354 }, 17355 "organization": { 17356 "name": "n", 17357 "company": "c", 17358 "blog": "b", 17359 "location": "loc", 17360 "email": "e", 17361 "twitter_username": "tu", 17362 "description": "d", 17363 "billing_email": "be", 17364 "is_verified": true, 17365 "has_organization_projects": true, 17366 "has_repository_projects": true, 17367 "default_repository_permission": "drp", 17368 "members_can_create_repositories": true, 17369 "members_can_create_public_repositories": false, 17370 "members_can_create_private_repositories": true, 17371 "members_can_create_internal_repositories": true, 17372 "members_allowed_repository_creation_type": "marct", 17373 "members_can_create_pages": true, 17374 "members_can_create_public_pages": false, 17375 "members_can_create_private_pages": true 17376 }, 17377 "enterprise": { 17378 "id": 1, 17379 "slug": "s", 17380 "name": "n", 17381 "node_id": "nid", 17382 "avatar_url": "au", 17383 "description": "d", 17384 "website_url": "wu", 17385 "html_url": "hu", 17386 "created_at": ` + referenceTimeStr + `, 17387 "updated_at": ` + referenceTimeStr + ` 17388 }, 17389 "sender": { 17390 "login": "l", 17391 "id": 1, 17392 "node_id": "n", 17393 "avatar_url": "a", 17394 "url": "u", 17395 "events_url": "e", 17396 "repos_url": "r" 17397 }, 17398 "installation": { 17399 "id": 1, 17400 "node_id": "nid", 17401 "app_id": 1, 17402 "app_slug": "as", 17403 "target_id": 1, 17404 "account": { 17405 "login": "l", 17406 "id": 1, 17407 "avatar_url": "a", 17408 "gravatar_id": "g", 17409 "name": "n", 17410 "company": "c", 17411 "blog": "b", 17412 "location": "l", 17413 "email": "e", 17414 "hireable": true, 17415 "bio": "b", 17416 "twitter_username": "t", 17417 "public_repos": 1, 17418 "followers": 1, 17419 "following": 1, 17420 "created_at": ` + referenceTimeStr + `, 17421 "suspended_at": ` + referenceTimeStr + `, 17422 "url": "u" 17423 }, 17424 "access_tokens_url": "atu", 17425 "repositories_url": "ru", 17426 "html_url": "hu", 17427 "target_type": "tt", 17428 "single_file_name": "sfn", 17429 "repository_selection": "rs", 17430 "events": [ 17431 "e" 17432 ], 17433 "single_file_paths": [ 17434 "s" 17435 ], 17436 "permissions": { 17437 "actions": "a", 17438 "administration": "ad", 17439 "checks": "c", 17440 "contents": "co", 17441 "content_references": "cr", 17442 "deployments": "d", 17443 "environments": "e", 17444 "issues": "i", 17445 "metadata": "md", 17446 "members": "m", 17447 "organization_administration": "oa", 17448 "organization_hooks": "oh", 17449 "organization_plan": "op", 17450 "organization_pre_receive_hooks": "opr", 17451 "organization_projects": "op", 17452 "organization_secrets": "os", 17453 "organization_self_hosted_runners": "osh", 17454 "organization_user_blocking": "oub", 17455 "packages": "pkg", 17456 "pages": "pg", 17457 "pull_requests": "pr", 17458 "repository_hooks": "rh", 17459 "repository_projects": "rp", 17460 "repository_pre_receive_hooks": "rprh", 17461 "secrets": "s", 17462 "secret_scanning_alerts": "ssa", 17463 "security_events": "se", 17464 "single_file": "sf", 17465 "statuses": "s", 17466 "team_discussions": "td", 17467 "vulnerability_alerts": "va", 17468 "workflows": "w" 17469 }, 17470 "created_at": ` + referenceTimeStr + `, 17471 "updated_at": ` + referenceTimeStr + `, 17472 "has_multiple_single_files": false, 17473 "suspended_by": { 17474 "login": "l", 17475 "id": 1, 17476 "avatar_url": "a", 17477 "gravatar_id": "g", 17478 "name": "n", 17479 "company": "c", 17480 "blog": "b", 17481 "location": "l", 17482 "email": "e", 17483 "hireable": true, 17484 "bio": "b", 17485 "twitter_username": "t", 17486 "public_repos": 1, 17487 "followers": 1, 17488 "following": 1, 17489 "created_at": ` + referenceTimeStr + `, 17490 "suspended_at": ` + referenceTimeStr + `, 17491 "url": "u" 17492 }, 17493 "suspended_at": ` + referenceTimeStr + ` 17494 } 17495 }` 17496 17497 testJSONMarshal(t, u, want) 17498 } 17499 17500 func TestSecretScanningAlertLocationEvent_Marshal(t *testing.T) { 17501 t.Parallel() 17502 testJSONMarshal(t, &SecretScanningAlertLocationEvent{}, "{}") 17503 u := &SecretScanningAlertLocationEvent{ 17504 Action: Ptr("created"), 17505 Alert: &SecretScanningAlert{ 17506 Number: Ptr(10), 17507 CreatedAt: &Timestamp{referenceTime}, 17508 UpdatedAt: &Timestamp{referenceTime}, 17509 URL: Ptr("a"), 17510 HTMLURL: Ptr("a"), 17511 SecretType: Ptr("mailchimp_api_key"), 17512 }, 17513 Location: &SecretScanningAlertLocation{ 17514 Type: Ptr("blob"), 17515 Details: &SecretScanningAlertLocationDetails{ 17516 Path: Ptr("path/to/file"), 17517 Startline: Ptr(10), 17518 EndLine: Ptr(20), 17519 StartColumn: Ptr(1), 17520 EndColumn: Ptr(2), 17521 BlobSHA: Ptr("d6e4c75c141dbacecc279b721b8bsomeSHA"), 17522 BlobURL: Ptr("a"), 17523 CommitSHA: Ptr("d6e4c75c141dbacecc279b721b8bsomeSHA"), 17524 CommitURL: Ptr("a"), 17525 }, 17526 }, 17527 Repo: &Repository{ 17528 ID: Ptr(int64(12345)), 17529 NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjM0NQ=="), 17530 Name: Ptr("example-repo"), 17531 }, 17532 Organization: &Organization{ 17533 Login: Ptr("example-org"), 17534 ID: Ptr(int64(67890)), 17535 }, 17536 Sender: &User{ 17537 Login: Ptr("example-user"), 17538 ID: Ptr(int64(1111)), 17539 }, 17540 Installation: &Installation{ 17541 ID: Ptr(int64(2222)), 17542 }, 17543 } 17544 17545 want := `{ 17546 "action": "created", 17547 "alert": { 17548 "number": 10, 17549 "created_at": ` + referenceTimeStr + `, 17550 "updated_at": ` + referenceTimeStr + `, 17551 "url": "a", 17552 "html_url": "a", 17553 "secret_type": "mailchimp_api_key" 17554 }, 17555 "location": { 17556 17557 "type": "blob", 17558 "details": { 17559 "path": "path/to/file", 17560 "start_line": 10, 17561 "end_line": 20, 17562 "start_column": 1, 17563 "end_column": 2, 17564 "blob_sha": "d6e4c75c141dbacecc279b721b8bsomeSHA", 17565 "blob_url": "a", 17566 "commit_sha": "d6e4c75c141dbacecc279b721b8bsomeSHA", 17567 "commit_url": "a" 17568 } 17569 }, 17570 "repository": { 17571 17572 "id": 12345, 17573 "node_id": "MDEwOlJlcG9zaXRvcnkxMjM0NQ==", 17574 "name": "example-repo" 17575 }, 17576 "organization": { 17577 "login": "example-org", 17578 "id": 67890 17579 }, 17580 "sender": { 17581 "login": "example-user", 17582 "id": 1111 17583 }, 17584 "installation": { 17585 "id": 2222 17586 } 17587 }` 17588 17589 testJSONMarshal(t, u, want) 17590 } 17591 17592 func TestSecurityAdvisoryEvent_Marshal(t *testing.T) { 17593 t.Parallel() 17594 testJSONMarshal(t, &SecurityAdvisoryEvent{}, "{}") 17595 u := &SecurityAdvisoryEvent{ 17596 Action: Ptr("published"), 17597 SecurityAdvisory: &SecurityAdvisory{ 17598 CVSS: &AdvisoryCVSS{ 17599 Score: Ptr(1.0), 17600 VectorString: Ptr("vs"), 17601 }, 17602 CWEs: []*AdvisoryCWEs{ 17603 { 17604 CWEID: Ptr("cweid"), 17605 Name: Ptr("n"), 17606 }, 17607 }, 17608 GHSAID: Ptr("GHSA-rf4j-j272-some"), 17609 Summary: Ptr("Siuuuuuuuuu"), 17610 Description: Ptr("desc"), 17611 Severity: Ptr("moderate"), 17612 Identifiers: []*AdvisoryIdentifier{ 17613 { 17614 Value: Ptr("GHSA-rf4j-j272-some"), 17615 Type: Ptr("GHSA"), 17616 }, 17617 }, 17618 References: []*AdvisoryReference{ 17619 { 17620 URL: Ptr("https://some-url"), 17621 }, 17622 }, 17623 PublishedAt: &Timestamp{referenceTime}, 17624 UpdatedAt: &Timestamp{referenceTime}, 17625 WithdrawnAt: nil, 17626 Vulnerabilities: []*AdvisoryVulnerability{ 17627 { 17628 Package: &VulnerabilityPackage{ 17629 Ecosystem: Ptr("ucl"), 17630 Name: Ptr("penaldo"), 17631 }, 17632 Severity: Ptr("moderate"), 17633 VulnerableVersionRange: Ptr(">= 2.0.0, < 2.0.2"), 17634 FirstPatchedVersion: &FirstPatchedVersion{ 17635 Identifier: Ptr("2.0.2"), 17636 }, 17637 }, 17638 }, 17639 }, 17640 Enterprise: &Enterprise{ 17641 ID: Ptr(1), 17642 Slug: Ptr("s"), 17643 Name: Ptr("n"), 17644 NodeID: Ptr("nid"), 17645 AvatarURL: Ptr("au"), 17646 Description: Ptr("d"), 17647 WebsiteURL: Ptr("wu"), 17648 HTMLURL: Ptr("hu"), 17649 CreatedAt: &Timestamp{referenceTime}, 17650 UpdatedAt: &Timestamp{referenceTime}, 17651 }, 17652 Installation: &Installation{ 17653 ID: Ptr(int64(1)), 17654 NodeID: Ptr("nid"), 17655 AppID: Ptr(int64(1)), 17656 AppSlug: Ptr("as"), 17657 TargetID: Ptr(int64(1)), 17658 Account: &User{ 17659 Login: Ptr("l"), 17660 ID: Ptr(int64(1)), 17661 URL: Ptr("u"), 17662 AvatarURL: Ptr("a"), 17663 GravatarID: Ptr("g"), 17664 Name: Ptr("n"), 17665 Company: Ptr("c"), 17666 Blog: Ptr("b"), 17667 Location: Ptr("l"), 17668 Email: Ptr("e"), 17669 Hireable: Ptr(true), 17670 Bio: Ptr("b"), 17671 TwitterUsername: Ptr("t"), 17672 PublicRepos: Ptr(1), 17673 Followers: Ptr(1), 17674 Following: Ptr(1), 17675 CreatedAt: &Timestamp{referenceTime}, 17676 SuspendedAt: &Timestamp{referenceTime}, 17677 }, 17678 AccessTokensURL: Ptr("atu"), 17679 RepositoriesURL: Ptr("ru"), 17680 HTMLURL: Ptr("hu"), 17681 TargetType: Ptr("tt"), 17682 SingleFileName: Ptr("sfn"), 17683 RepositorySelection: Ptr("rs"), 17684 Events: []string{"e"}, 17685 SingleFilePaths: []string{"s"}, 17686 Permissions: &InstallationPermissions{ 17687 Actions: Ptr("a"), 17688 Administration: Ptr("ad"), 17689 Checks: Ptr("c"), 17690 Contents: Ptr("co"), 17691 ContentReferences: Ptr("cr"), 17692 Deployments: Ptr("d"), 17693 Environments: Ptr("e"), 17694 Issues: Ptr("i"), 17695 Metadata: Ptr("md"), 17696 Members: Ptr("m"), 17697 OrganizationAdministration: Ptr("oa"), 17698 OrganizationHooks: Ptr("oh"), 17699 OrganizationPlan: Ptr("op"), 17700 OrganizationPreReceiveHooks: Ptr("opr"), 17701 OrganizationProjects: Ptr("op"), 17702 OrganizationSecrets: Ptr("os"), 17703 OrganizationSelfHostedRunners: Ptr("osh"), 17704 OrganizationUserBlocking: Ptr("oub"), 17705 Packages: Ptr("pkg"), 17706 Pages: Ptr("pg"), 17707 PullRequests: Ptr("pr"), 17708 RepositoryHooks: Ptr("rh"), 17709 RepositoryProjects: Ptr("rp"), 17710 RepositoryPreReceiveHooks: Ptr("rprh"), 17711 Secrets: Ptr("s"), 17712 SecretScanningAlerts: Ptr("ssa"), 17713 SecurityEvents: Ptr("se"), 17714 SingleFile: Ptr("sf"), 17715 Statuses: Ptr("s"), 17716 TeamDiscussions: Ptr("td"), 17717 VulnerabilityAlerts: Ptr("va"), 17718 Workflows: Ptr("w"), 17719 }, 17720 CreatedAt: &Timestamp{referenceTime}, 17721 UpdatedAt: &Timestamp{referenceTime}, 17722 HasMultipleSingleFiles: Ptr(false), 17723 SuspendedBy: &User{ 17724 Login: Ptr("l"), 17725 ID: Ptr(int64(1)), 17726 URL: Ptr("u"), 17727 AvatarURL: Ptr("a"), 17728 GravatarID: Ptr("g"), 17729 Name: Ptr("n"), 17730 Company: Ptr("c"), 17731 Blog: Ptr("b"), 17732 Location: Ptr("l"), 17733 Email: Ptr("e"), 17734 Hireable: Ptr(true), 17735 Bio: Ptr("b"), 17736 TwitterUsername: Ptr("t"), 17737 PublicRepos: Ptr(1), 17738 Followers: Ptr(1), 17739 Following: Ptr(1), 17740 CreatedAt: &Timestamp{referenceTime}, 17741 SuspendedAt: &Timestamp{referenceTime}, 17742 }, 17743 SuspendedAt: &Timestamp{referenceTime}, 17744 }, 17745 Organization: &Organization{ 17746 BillingEmail: Ptr("be"), 17747 Blog: Ptr("b"), 17748 Company: Ptr("c"), 17749 Email: Ptr("e"), 17750 TwitterUsername: Ptr("tu"), 17751 Location: Ptr("loc"), 17752 Name: Ptr("n"), 17753 Description: Ptr("d"), 17754 IsVerified: Ptr(true), 17755 HasOrganizationProjects: Ptr(true), 17756 HasRepositoryProjects: Ptr(true), 17757 DefaultRepoPermission: Ptr("drp"), 17758 MembersCanCreateRepos: Ptr(true), 17759 MembersCanCreateInternalRepos: Ptr(true), 17760 MembersCanCreatePrivateRepos: Ptr(true), 17761 MembersCanCreatePublicRepos: Ptr(false), 17762 MembersAllowedRepositoryCreationType: Ptr("marct"), 17763 MembersCanCreatePages: Ptr(true), 17764 MembersCanCreatePublicPages: Ptr(false), 17765 MembersCanCreatePrivatePages: Ptr(true), 17766 }, 17767 Repository: &Repository{ 17768 ID: Ptr(int64(1)), 17769 URL: Ptr("s"), 17770 Name: Ptr("n"), 17771 }, 17772 Sender: &User{ 17773 Login: Ptr("l"), 17774 ID: Ptr(int64(1)), 17775 NodeID: Ptr("n"), 17776 URL: Ptr("u"), 17777 ReposURL: Ptr("r"), 17778 EventsURL: Ptr("e"), 17779 AvatarURL: Ptr("a"), 17780 }, 17781 } 17782 17783 want := `{ 17784 "action": "published", 17785 "security_advisory": { 17786 "ghsa_id": "GHSA-rf4j-j272-some", 17787 "summary": "Siuuuuuuuuu", 17788 "cvss": { 17789 "score": 1.0, 17790 "vector_string": "vs" 17791 }, 17792 "cwes": [ 17793 { 17794 "cwe_id": "cweid", 17795 "name": "n" 17796 } 17797 ], 17798 "description": "desc", 17799 "severity": "moderate", 17800 "identifiers": [ 17801 { 17802 "value": "GHSA-rf4j-j272-some", 17803 "type": "GHSA" 17804 } 17805 ], 17806 "references": [ 17807 { 17808 "url": "https://some-url" 17809 } 17810 ], 17811 "published_at": ` + referenceTimeStr + `, 17812 "updated_at": ` + referenceTimeStr + `, 17813 "withdrawn_at": null, 17814 "vulnerabilities": [ 17815 { 17816 "package": { 17817 "ecosystem": "ucl", 17818 "name": "penaldo" 17819 }, 17820 "severity": "moderate", 17821 "vulnerable_version_range": ">= 2.0.0, < 2.0.2", 17822 "first_patched_version": { 17823 "identifier": "2.0.2" 17824 } 17825 } 17826 ] 17827 }, 17828 "enterprise": { 17829 "id": 1, 17830 "slug": "s", 17831 "name": "n", 17832 "node_id": "nid", 17833 "avatar_url": "au", 17834 "description": "d", 17835 "website_url": "wu", 17836 "html_url": "hu", 17837 "created_at": ` + referenceTimeStr + `, 17838 "updated_at": ` + referenceTimeStr + ` 17839 }, 17840 "installation": { 17841 "id": 1, 17842 "node_id": "nid", 17843 "app_id": 1, 17844 "app_slug": "as", 17845 "target_id": 1, 17846 "account": { 17847 "login": "l", 17848 "id": 1, 17849 "avatar_url": "a", 17850 "gravatar_id": "g", 17851 "name": "n", 17852 "company": "c", 17853 "blog": "b", 17854 "location": "l", 17855 "email": "e", 17856 "hireable": true, 17857 "bio": "b", 17858 "twitter_username": "t", 17859 "public_repos": 1, 17860 "followers": 1, 17861 "following": 1, 17862 "created_at": ` + referenceTimeStr + `, 17863 "suspended_at": ` + referenceTimeStr + `, 17864 "url": "u" 17865 }, 17866 "access_tokens_url": "atu", 17867 "repositories_url": "ru", 17868 "html_url": "hu", 17869 "target_type": "tt", 17870 "single_file_name": "sfn", 17871 "repository_selection": "rs", 17872 "events": [ 17873 "e" 17874 ], 17875 "single_file_paths": [ 17876 "s" 17877 ], 17878 "permissions": { 17879 "actions": "a", 17880 "administration": "ad", 17881 "checks": "c", 17882 "contents": "co", 17883 "content_references": "cr", 17884 "deployments": "d", 17885 "environments": "e", 17886 "issues": "i", 17887 "metadata": "md", 17888 "members": "m", 17889 "organization_administration": "oa", 17890 "organization_hooks": "oh", 17891 "organization_plan": "op", 17892 "organization_pre_receive_hooks": "opr", 17893 "organization_projects": "op", 17894 "organization_secrets": "os", 17895 "organization_self_hosted_runners": "osh", 17896 "organization_user_blocking": "oub", 17897 "packages": "pkg", 17898 "pages": "pg", 17899 "pull_requests": "pr", 17900 "repository_hooks": "rh", 17901 "repository_projects": "rp", 17902 "repository_pre_receive_hooks": "rprh", 17903 "secrets": "s", 17904 "secret_scanning_alerts": "ssa", 17905 "security_events": "se", 17906 "single_file": "sf", 17907 "statuses": "s", 17908 "team_discussions": "td", 17909 "vulnerability_alerts": "va", 17910 "workflows": "w" 17911 }, 17912 "created_at": ` + referenceTimeStr + `, 17913 "updated_at": ` + referenceTimeStr + `, 17914 "has_multiple_single_files": false, 17915 "suspended_by": { 17916 "login": "l", 17917 "id": 1, 17918 "avatar_url": "a", 17919 "gravatar_id": "g", 17920 "name": "n", 17921 "company": "c", 17922 "blog": "b", 17923 "location": "l", 17924 "email": "e", 17925 "hireable": true, 17926 "bio": "b", 17927 "twitter_username": "t", 17928 "public_repos": 1, 17929 "followers": 1, 17930 "following": 1, 17931 "created_at": ` + referenceTimeStr + `, 17932 "suspended_at": ` + referenceTimeStr + `, 17933 "url": "u" 17934 }, 17935 "suspended_at": ` + referenceTimeStr + ` 17936 }, 17937 "organization": { 17938 "name": "n", 17939 "company": "c", 17940 "blog": "b", 17941 "location": "loc", 17942 "email": "e", 17943 "twitter_username": "tu", 17944 "description": "d", 17945 "billing_email": "be", 17946 "is_verified": true, 17947 "has_organization_projects": true, 17948 "has_repository_projects": true, 17949 "default_repository_permission": "drp", 17950 "members_can_create_repositories": true, 17951 "members_can_create_public_repositories": false, 17952 "members_can_create_private_repositories": true, 17953 "members_can_create_internal_repositories": true, 17954 "members_allowed_repository_creation_type": "marct", 17955 "members_can_create_pages": true, 17956 "members_can_create_public_pages": false, 17957 "members_can_create_private_pages": true 17958 }, 17959 "repository": { 17960 "id": 1, 17961 "url": "s", 17962 "name": "n" 17963 }, 17964 "sender": { 17965 "login": "l", 17966 "id": 1, 17967 "node_id": "n", 17968 "avatar_url": "a", 17969 "url": "u", 17970 "events_url": "e", 17971 "repos_url": "r" 17972 } 17973 }` 17974 17975 testJSONMarshal(t, u, want) 17976 } 17977 17978 func TestSecurityAndAnalysisEvent_Marshal(t *testing.T) { 17979 t.Parallel() 17980 testJSONMarshal(t, &SecurityAndAnalysisEvent{}, "{}") 17981 17982 u := &SecurityAndAnalysisEvent{ 17983 Changes: &SecurityAndAnalysisChange{ 17984 From: &SecurityAndAnalysisChangeFrom{ 17985 SecurityAndAnalysis: &SecurityAndAnalysis{ 17986 AdvancedSecurity: &AdvancedSecurity{ 17987 Status: Ptr("enabled"), 17988 }, 17989 SecretScanning: &SecretScanning{ 17990 Status: Ptr("enabled"), 17991 }, 17992 SecretScanningPushProtection: &SecretScanningPushProtection{ 17993 Status: Ptr("enabled"), 17994 }, 17995 DependabotSecurityUpdates: &DependabotSecurityUpdates{ 17996 Status: Ptr("enabled"), 17997 }, 17998 }, 17999 }, 18000 }, 18001 Enterprise: &Enterprise{ 18002 ID: Ptr(1), 18003 Slug: Ptr("s"), 18004 Name: Ptr("n"), 18005 NodeID: Ptr("nid"), 18006 AvatarURL: Ptr("au"), 18007 Description: Ptr("d"), 18008 WebsiteURL: Ptr("wu"), 18009 HTMLURL: Ptr("hu"), 18010 CreatedAt: &Timestamp{referenceTime}, 18011 UpdatedAt: &Timestamp{referenceTime}, 18012 }, 18013 Installation: &Installation{ 18014 ID: Ptr(int64(1)), 18015 NodeID: Ptr("nid"), 18016 AppID: Ptr(int64(1)), 18017 AppSlug: Ptr("as"), 18018 TargetID: Ptr(int64(1)), 18019 Account: &User{ 18020 Login: Ptr("l"), 18021 ID: Ptr(int64(1)), 18022 URL: Ptr("u"), 18023 AvatarURL: Ptr("a"), 18024 GravatarID: Ptr("g"), 18025 Name: Ptr("n"), 18026 Company: Ptr("c"), 18027 Blog: Ptr("b"), 18028 Location: Ptr("l"), 18029 Email: Ptr("e"), 18030 Hireable: Ptr(true), 18031 Bio: Ptr("b"), 18032 TwitterUsername: Ptr("t"), 18033 PublicRepos: Ptr(1), 18034 Followers: Ptr(1), 18035 Following: Ptr(1), 18036 CreatedAt: &Timestamp{referenceTime}, 18037 SuspendedAt: &Timestamp{referenceTime}, 18038 }, 18039 AccessTokensURL: Ptr("atu"), 18040 RepositoriesURL: Ptr("ru"), 18041 HTMLURL: Ptr("hu"), 18042 TargetType: Ptr("tt"), 18043 SingleFileName: Ptr("sfn"), 18044 RepositorySelection: Ptr("rs"), 18045 Events: []string{"e"}, 18046 SingleFilePaths: []string{"s"}, 18047 Permissions: &InstallationPermissions{ 18048 Actions: Ptr("a"), 18049 Administration: Ptr("ad"), 18050 Checks: Ptr("c"), 18051 Contents: Ptr("co"), 18052 ContentReferences: Ptr("cr"), 18053 Deployments: Ptr("d"), 18054 Environments: Ptr("e"), 18055 Issues: Ptr("i"), 18056 Metadata: Ptr("md"), 18057 Members: Ptr("m"), 18058 OrganizationAdministration: Ptr("oa"), 18059 OrganizationHooks: Ptr("oh"), 18060 OrganizationPlan: Ptr("op"), 18061 OrganizationPreReceiveHooks: Ptr("opr"), 18062 OrganizationProjects: Ptr("op"), 18063 OrganizationSecrets: Ptr("os"), 18064 OrganizationSelfHostedRunners: Ptr("osh"), 18065 OrganizationUserBlocking: Ptr("oub"), 18066 Packages: Ptr("pkg"), 18067 Pages: Ptr("pg"), 18068 PullRequests: Ptr("pr"), 18069 RepositoryHooks: Ptr("rh"), 18070 RepositoryProjects: Ptr("rp"), 18071 RepositoryPreReceiveHooks: Ptr("rprh"), 18072 Secrets: Ptr("s"), 18073 SecretScanningAlerts: Ptr("ssa"), 18074 SecurityEvents: Ptr("se"), 18075 SingleFile: Ptr("sf"), 18076 Statuses: Ptr("s"), 18077 TeamDiscussions: Ptr("td"), 18078 VulnerabilityAlerts: Ptr("va"), 18079 Workflows: Ptr("w"), 18080 }, 18081 CreatedAt: &Timestamp{referenceTime}, 18082 UpdatedAt: &Timestamp{referenceTime}, 18083 HasMultipleSingleFiles: Ptr(false), 18084 SuspendedBy: &User{ 18085 Login: Ptr("l"), 18086 ID: Ptr(int64(1)), 18087 URL: Ptr("u"), 18088 AvatarURL: Ptr("a"), 18089 GravatarID: Ptr("g"), 18090 Name: Ptr("n"), 18091 Company: Ptr("c"), 18092 Blog: Ptr("b"), 18093 Location: Ptr("l"), 18094 Email: Ptr("e"), 18095 Hireable: Ptr(true), 18096 Bio: Ptr("b"), 18097 TwitterUsername: Ptr("t"), 18098 PublicRepos: Ptr(1), 18099 Followers: Ptr(1), 18100 Following: Ptr(1), 18101 CreatedAt: &Timestamp{referenceTime}, 18102 SuspendedAt: &Timestamp{referenceTime}, 18103 }, 18104 SuspendedAt: &Timestamp{referenceTime}, 18105 }, 18106 Organization: &Organization{ 18107 BillingEmail: Ptr("be"), 18108 Blog: Ptr("b"), 18109 Company: Ptr("c"), 18110 Email: Ptr("e"), 18111 TwitterUsername: Ptr("tu"), 18112 Location: Ptr("loc"), 18113 Name: Ptr("n"), 18114 Description: Ptr("d"), 18115 IsVerified: Ptr(true), 18116 HasOrganizationProjects: Ptr(true), 18117 HasRepositoryProjects: Ptr(true), 18118 DefaultRepoPermission: Ptr("drp"), 18119 MembersCanCreateRepos: Ptr(true), 18120 MembersCanCreateInternalRepos: Ptr(true), 18121 MembersCanCreatePrivateRepos: Ptr(true), 18122 MembersCanCreatePublicRepos: Ptr(false), 18123 MembersAllowedRepositoryCreationType: Ptr("marct"), 18124 MembersCanCreatePages: Ptr(true), 18125 MembersCanCreatePublicPages: Ptr(false), 18126 MembersCanCreatePrivatePages: Ptr(true), 18127 }, 18128 Repository: &Repository{ 18129 ID: Ptr(int64(1)), 18130 URL: Ptr("s"), 18131 Name: Ptr("n"), 18132 }, 18133 Sender: &User{ 18134 Login: Ptr("l"), 18135 ID: Ptr(int64(1)), 18136 NodeID: Ptr("n"), 18137 URL: Ptr("u"), 18138 ReposURL: Ptr("r"), 18139 EventsURL: Ptr("e"), 18140 AvatarURL: Ptr("a"), 18141 }, 18142 } 18143 18144 want := `{ 18145 "changes": { 18146 "from": { 18147 "security_and_analysis": { 18148 "advanced_security": { 18149 "status": "enabled" 18150 }, 18151 "secret_scanning": { 18152 "status": "enabled" 18153 }, 18154 "secret_scanning_push_protection": { 18155 "status": "enabled" 18156 }, 18157 "dependabot_security_updates": { 18158 "status": "enabled" 18159 } 18160 } 18161 } 18162 }, 18163 "enterprise": { 18164 "id": 1, 18165 "slug": "s", 18166 "name": "n", 18167 "node_id": "nid", 18168 "avatar_url": "au", 18169 "description": "d", 18170 "website_url": "wu", 18171 "html_url": "hu", 18172 "created_at": ` + referenceTimeStr + `, 18173 "updated_at": ` + referenceTimeStr + ` 18174 }, 18175 "installation": { 18176 "id": 1, 18177 "node_id": "nid", 18178 "app_id": 1, 18179 "app_slug": "as", 18180 "target_id": 1, 18181 "account": { 18182 "login": "l", 18183 "id": 1, 18184 "avatar_url": "a", 18185 "gravatar_id": "g", 18186 "name": "n", 18187 "company": "c", 18188 "blog": "b", 18189 "location": "l", 18190 "email": "e", 18191 "hireable": true, 18192 "bio": "b", 18193 "twitter_username": "t", 18194 "public_repos": 1, 18195 "followers": 1, 18196 "following": 1, 18197 "created_at": ` + referenceTimeStr + `, 18198 "suspended_at": ` + referenceTimeStr + `, 18199 "url": "u" 18200 }, 18201 "access_tokens_url": "atu", 18202 "repositories_url": "ru", 18203 "html_url": "hu", 18204 "target_type": "tt", 18205 "single_file_name": "sfn", 18206 "repository_selection": "rs", 18207 "events": [ 18208 "e" 18209 ], 18210 "single_file_paths": [ 18211 "s" 18212 ], 18213 "permissions": { 18214 "actions": "a", 18215 "administration": "ad", 18216 "checks": "c", 18217 "contents": "co", 18218 "content_references": "cr", 18219 "deployments": "d", 18220 "environments": "e", 18221 "issues": "i", 18222 "metadata": "md", 18223 "members": "m", 18224 "organization_administration": "oa", 18225 "organization_hooks": "oh", 18226 "organization_plan": "op", 18227 "organization_pre_receive_hooks": "opr", 18228 "organization_projects": "op", 18229 "organization_secrets": "os", 18230 "organization_self_hosted_runners": "osh", 18231 "organization_user_blocking": "oub", 18232 "packages": "pkg", 18233 "pages": "pg", 18234 "pull_requests": "pr", 18235 "repository_hooks": "rh", 18236 "repository_projects": "rp", 18237 "repository_pre_receive_hooks": "rprh", 18238 "secrets": "s", 18239 "secret_scanning_alerts": "ssa", 18240 "security_events": "se", 18241 "single_file": "sf", 18242 "statuses": "s", 18243 "team_discussions": "td", 18244 "vulnerability_alerts": "va", 18245 "workflows": "w" 18246 }, 18247 "created_at": ` + referenceTimeStr + `, 18248 "updated_at": ` + referenceTimeStr + `, 18249 "has_multiple_single_files": false, 18250 "suspended_by": { 18251 "login": "l", 18252 "id": 1, 18253 "avatar_url": "a", 18254 "gravatar_id": "g", 18255 "name": "n", 18256 "company": "c", 18257 "blog": "b", 18258 "location": "l", 18259 "email": "e", 18260 "hireable": true, 18261 "bio": "b", 18262 "twitter_username": "t", 18263 "public_repos": 1, 18264 "followers": 1, 18265 "following": 1, 18266 "created_at": ` + referenceTimeStr + `, 18267 "suspended_at": ` + referenceTimeStr + `, 18268 "url": "u" 18269 }, 18270 "suspended_at": ` + referenceTimeStr + ` 18271 }, 18272 "organization": { 18273 "name": "n", 18274 "company": "c", 18275 "blog": "b", 18276 "location": "loc", 18277 "email": "e", 18278 "twitter_username": "tu", 18279 "description": "d", 18280 "billing_email": "be", 18281 "is_verified": true, 18282 "has_organization_projects": true, 18283 "has_repository_projects": true, 18284 "default_repository_permission": "drp", 18285 "members_can_create_repositories": true, 18286 "members_can_create_public_repositories": false, 18287 "members_can_create_private_repositories": true, 18288 "members_can_create_internal_repositories": true, 18289 "members_allowed_repository_creation_type": "marct", 18290 "members_can_create_pages": true, 18291 "members_can_create_public_pages": false, 18292 "members_can_create_private_pages": true 18293 }, 18294 "repository": { 18295 "id": 1, 18296 "url": "s", 18297 "name": "n" 18298 }, 18299 "sender": { 18300 "login": "l", 18301 "id": 1, 18302 "node_id": "n", 18303 "avatar_url": "a", 18304 "url": "u", 18305 "events_url": "e", 18306 "repos_url": "r" 18307 }, 18308 "target_type": "running" 18309 }` 18310 18311 testJSONMarshal(t, u, want) 18312 } 18313 18314 func TestCodeScanningAlertEvent_Marshal(t *testing.T) { 18315 t.Parallel() 18316 testJSONMarshal(t, &CodeScanningAlertEvent{}, "{}") 18317 18318 u := &CodeScanningAlertEvent{ 18319 Action: Ptr("reopened"), 18320 Alert: &Alert{ 18321 Number: Ptr(10), 18322 Rule: &Rule{ 18323 ID: Ptr("Style/FrozenStringLiteralComment"), 18324 Severity: Ptr("note"), 18325 Description: Ptr("desc"), 18326 FullDescription: Ptr("full desc"), 18327 Tags: []string{"style"}, 18328 Help: Ptr("help"), 18329 }, 18330 Tool: &Tool{ 18331 Name: Ptr("Rubocop"), 18332 Version: nil, 18333 }, 18334 CreatedAt: &Timestamp{referenceTime}, 18335 UpdatedAt: &Timestamp{referenceTime}, 18336 FixedAt: nil, 18337 State: Ptr("open"), 18338 URL: Ptr("a"), 18339 HTMLURL: Ptr("a"), 18340 Instances: []*MostRecentInstance{ 18341 { 18342 Ref: Ptr("refs/heads/main"), 18343 AnalysisKey: Ptr(".github/workflows/workflow.yml:upload"), 18344 Environment: Ptr("{}"), 18345 State: Ptr("open"), 18346 }, 18347 }, 18348 DismissedBy: nil, 18349 DismissedAt: nil, 18350 DismissedReason: nil, 18351 }, 18352 Ref: Ptr("refs/heads/main"), 18353 CommitOID: Ptr("d6e4c75c141dbacecc279b721b8bsomeSHA"), 18354 Repo: &Repository{ 18355 ID: Ptr(int64(1234234535)), 18356 NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxODY4NT=="), 18357 Owner: &User{ 18358 Login: Ptr("Codertocat"), 18359 ID: Ptr(int64(21031067)), 18360 NodeID: Ptr("MDQ6VXNlcjIxMDMxMDY3"), 18361 AvatarURL: Ptr("a"), 18362 GravatarID: Ptr(""), 18363 URL: Ptr("a"), 18364 HTMLURL: Ptr("a"), 18365 Type: Ptr("User"), 18366 SiteAdmin: Ptr(false), 18367 FollowersURL: Ptr("a"), 18368 FollowingURL: Ptr("a"), 18369 EventsURL: Ptr("a"), 18370 GistsURL: Ptr("a"), 18371 OrganizationsURL: Ptr("a"), 18372 ReceivedEventsURL: Ptr("a"), 18373 ReposURL: Ptr("a"), 18374 StarredURL: Ptr("a"), 18375 SubscriptionsURL: Ptr("a"), 18376 }, 18377 HTMLURL: Ptr("a"), 18378 Name: Ptr("Hello-World"), 18379 FullName: Ptr("Codertocat/Hello-World"), 18380 Description: nil, 18381 Fork: Ptr(false), 18382 Homepage: nil, 18383 DefaultBranch: Ptr("main"), 18384 CreatedAt: &Timestamp{referenceTime}, 18385 PushedAt: &Timestamp{referenceTime}, 18386 UpdatedAt: &Timestamp{referenceTime}, 18387 CloneURL: Ptr("a"), 18388 GitURL: Ptr("a"), 18389 MirrorURL: nil, 18390 SSHURL: Ptr("a"), 18391 SVNURL: Ptr("a"), 18392 Language: nil, 18393 ForksCount: Ptr(0), 18394 OpenIssuesCount: Ptr(2), 18395 OpenIssues: Ptr(2), 18396 StargazersCount: Ptr(0), 18397 WatchersCount: Ptr(0), 18398 Watchers: Ptr(0), 18399 Size: Ptr(0), 18400 Archived: Ptr(false), 18401 Disabled: Ptr(false), 18402 License: nil, 18403 Private: Ptr(false), 18404 HasIssues: Ptr(true), 18405 HasWiki: Ptr(true), 18406 HasPages: Ptr(true), 18407 HasProjects: Ptr(true), 18408 HasDownloads: Ptr(true), 18409 URL: Ptr("a"), 18410 ArchiveURL: Ptr("a"), 18411 AssigneesURL: Ptr("a"), 18412 BlobsURL: Ptr("a"), 18413 BranchesURL: Ptr("a"), 18414 CollaboratorsURL: Ptr("a"), 18415 CommentsURL: Ptr("a"), 18416 CommitsURL: Ptr("a"), 18417 CompareURL: Ptr("a"), 18418 ContentsURL: Ptr("a"), 18419 ContributorsURL: Ptr("a"), 18420 DeploymentsURL: Ptr("a"), 18421 DownloadsURL: Ptr("a"), 18422 EventsURL: Ptr("a"), 18423 ForksURL: Ptr("a"), 18424 GitCommitsURL: Ptr("a"), 18425 GitRefsURL: Ptr("a"), 18426 GitTagsURL: Ptr("a"), 18427 HooksURL: Ptr("a"), 18428 IssueCommentURL: Ptr("a"), 18429 IssueEventsURL: Ptr("a"), 18430 IssuesURL: Ptr("a"), 18431 KeysURL: Ptr("a"), 18432 LabelsURL: Ptr("a"), 18433 LanguagesURL: Ptr("a"), 18434 MergesURL: Ptr("a"), 18435 MilestonesURL: Ptr("a"), 18436 NotificationsURL: Ptr("a"), 18437 PullsURL: Ptr("a"), 18438 ReleasesURL: Ptr("a"), 18439 StargazersURL: Ptr("a"), 18440 StatusesURL: Ptr("a"), 18441 SubscribersURL: Ptr("a"), 18442 SubscriptionURL: Ptr("a"), 18443 TagsURL: Ptr("a"), 18444 TreesURL: Ptr("a"), 18445 TeamsURL: Ptr("a"), 18446 }, 18447 Org: &Organization{ 18448 Login: Ptr("Octocoders"), 18449 ID: Ptr(int64(6)), 18450 NodeID: Ptr("MDEyOk9yZ2FuaXphdGlvbjY="), 18451 AvatarURL: Ptr("a"), 18452 Description: Ptr(""), 18453 URL: Ptr("a"), 18454 EventsURL: Ptr("a"), 18455 HooksURL: Ptr("a"), 18456 IssuesURL: Ptr("a"), 18457 MembersURL: Ptr("a"), 18458 PublicMembersURL: Ptr("a"), 18459 ReposURL: Ptr("a"), 18460 }, 18461 Sender: &User{ 18462 Login: Ptr("github"), 18463 ID: Ptr(int64(9919)), 18464 NodeID: Ptr("MDEyOk9yZ2FuaXphdGlvbjk5MTk="), 18465 AvatarURL: Ptr("a"), 18466 HTMLURL: Ptr("a"), 18467 GravatarID: Ptr(""), 18468 Type: Ptr("Organization"), 18469 SiteAdmin: Ptr(false), 18470 URL: Ptr("a"), 18471 EventsURL: Ptr("a"), 18472 FollowingURL: Ptr("a"), 18473 FollowersURL: Ptr("a"), 18474 GistsURL: Ptr("a"), 18475 OrganizationsURL: Ptr("a"), 18476 ReceivedEventsURL: Ptr("a"), 18477 ReposURL: Ptr("a"), 18478 StarredURL: Ptr("a"), 18479 SubscriptionsURL: Ptr("a"), 18480 }, 18481 } 18482 18483 want := `{ 18484 "action": "reopened", 18485 "alert": { 18486 "number": 10, 18487 "created_at": ` + referenceTimeStr + `, 18488 "updated_at": ` + referenceTimeStr + `, 18489 "url": "a", 18490 "html_url": "a", 18491 "instances": [ 18492 { 18493 "ref": "refs/heads/main", 18494 "analysis_key": ".github/workflows/workflow.yml:upload", 18495 "environment": "{}", 18496 "state": "open" 18497 } 18498 ], 18499 "state": "open", 18500 "fixed_at": null, 18501 "dismissed_by": null, 18502 "dismissed_at": null, 18503 "dismissed_reason": null, 18504 "rule": { 18505 "id": "Style/FrozenStringLiteralComment", 18506 "severity": "note", 18507 "description": "desc", 18508 "full_description": "full desc", 18509 "tags": [ 18510 "style" 18511 ], 18512 "help": "help" 18513 }, 18514 "tool": { 18515 "name": "Rubocop", 18516 "version": null 18517 } 18518 }, 18519 "ref": "refs/heads/main", 18520 "commit_oid": "d6e4c75c141dbacecc279b721b8bsomeSHA", 18521 "repository": { 18522 "id": 1234234535, 18523 "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NT==", 18524 "name": "Hello-World", 18525 "full_name": "Codertocat/Hello-World", 18526 "private": false, 18527 "owner": { 18528 "login": "Codertocat", 18529 "id": 21031067, 18530 "node_id": "MDQ6VXNlcjIxMDMxMDY3", 18531 "avatar_url": "a", 18532 "gravatar_id": "", 18533 "url": "a", 18534 "html_url": "a", 18535 "followers_url": "a", 18536 "following_url": "a", 18537 "gists_url": "a", 18538 "starred_url": "a", 18539 "subscriptions_url": "a", 18540 "organizations_url": "a", 18541 "repos_url": "a", 18542 "events_url": "a", 18543 "received_events_url": "a", 18544 "type": "User", 18545 "site_admin": false 18546 }, 18547 "html_url": "a", 18548 "description": null, 18549 "fork": false, 18550 "url": "a", 18551 "forks_url": "a", 18552 "keys_url": "a", 18553 "collaborators_url": "a", 18554 "teams_url": "a", 18555 "hooks_url": "a", 18556 "issue_events_url": "a", 18557 "events_url": "a", 18558 "assignees_url": "a", 18559 "branches_url": "a", 18560 "tags_url": "a", 18561 "blobs_url": "a", 18562 "git_tags_url": "a", 18563 "git_refs_url": "a", 18564 "trees_url": "a", 18565 "statuses_url": "a", 18566 "languages_url": "a", 18567 "stargazers_url": "a", 18568 "contributors_url": "a", 18569 "subscribers_url": "a", 18570 "subscription_url": "a", 18571 "commits_url": "a", 18572 "git_commits_url": "a", 18573 "comments_url": "a", 18574 "issue_comment_url": "a", 18575 "contents_url": "a", 18576 "compare_url": "a", 18577 "merges_url": "a", 18578 "archive_url": "a", 18579 "downloads_url": "a", 18580 "issues_url": "a", 18581 "pulls_url": "a", 18582 "milestones_url": "a", 18583 "notifications_url": "a", 18584 "labels_url": "a", 18585 "releases_url": "a", 18586 "deployments_url": "a", 18587 "created_at": ` + referenceTimeStr + `, 18588 "updated_at": ` + referenceTimeStr + `, 18589 "pushed_at": ` + referenceTimeStr + `, 18590 "git_url": "a", 18591 "ssh_url": "a", 18592 "clone_url": "a", 18593 "svn_url": "a", 18594 "homepage": null, 18595 "size": 0, 18596 "stargazers_count": 0, 18597 "watchers_count": 0, 18598 "language": null, 18599 "has_issues": true, 18600 "has_projects": true, 18601 "has_downloads": true, 18602 "has_wiki": true, 18603 "has_pages": true, 18604 "forks_count": 0, 18605 "mirror_url": null, 18606 "archived": false, 18607 "disabled": false, 18608 "open_issues_count": 2, 18609 "license": null, 18610 "forks": 0, 18611 "open_issues": 2, 18612 "watchers": 0, 18613 "default_branch": "main" 18614 }, 18615 "organization": { 18616 "login": "Octocoders", 18617 "id": 6, 18618 "node_id": "MDEyOk9yZ2FuaXphdGlvbjY=", 18619 "url": "a", 18620 "repos_url": "a", 18621 "events_url": "a", 18622 "hooks_url": "a", 18623 "issues_url": "a", 18624 "members_url": "a", 18625 "public_members_url": "a", 18626 "avatar_url": "a", 18627 "description": "" 18628 }, 18629 "sender": { 18630 "login": "github", 18631 "id": 9919, 18632 "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", 18633 "avatar_url": "a", 18634 "gravatar_id": "", 18635 "url": "a", 18636 "html_url": "a", 18637 "followers_url": "a", 18638 "following_url": "a", 18639 "gists_url": "a", 18640 "starred_url": "a", 18641 "subscriptions_url": "a", 18642 "organizations_url": "a", 18643 "repos_url": "a", 18644 "events_url": "a", 18645 "received_events_url": "a", 18646 "type": "Organization", 18647 "site_admin": false 18648 } 18649 }` 18650 18651 testJSONMarshal(t, u, want) 18652 } 18653 18654 func TestSponsorshipEvent_Marshal(t *testing.T) { 18655 t.Parallel() 18656 testJSONMarshal(t, &SponsorshipEvent{}, "{}") 18657 18658 u := &SponsorshipEvent{ 18659 Action: Ptr("created"), 18660 EffectiveDate: Ptr("2023-01-01T00:00:00Z"), 18661 Changes: &SponsorshipChanges{ 18662 Tier: &SponsorshipTier{ 18663 From: Ptr("basic"), 18664 }, 18665 PrivacyLevel: Ptr("public"), 18666 }, 18667 Repository: &Repository{ 18668 ID: Ptr(int64(12345)), 18669 NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjM0NQ=="), 18670 Name: Ptr("example-repo"), 18671 }, 18672 Organization: &Organization{ 18673 Login: Ptr("example-org"), 18674 ID: Ptr(int64(67890)), 18675 }, 18676 Sender: &User{ 18677 Login: Ptr("example-user"), 18678 ID: Ptr(int64(1111)), 18679 }, 18680 Installation: &Installation{ 18681 ID: Ptr(int64(2222)), 18682 }, 18683 } 18684 18685 want := `{ 18686 "action": "created", 18687 "effective_date": "2023-01-01T00:00:00Z", 18688 "changes": { 18689 "tier": { 18690 "from": "basic" 18691 }, 18692 "privacy_level": "public" 18693 }, 18694 "repository": { 18695 "id": 12345, 18696 "node_id": "MDEwOlJlcG9zaXRvcnkxMjM0NQ==", 18697 "name": "example-repo" 18698 }, 18699 "organization": { 18700 "login": "example-org", 18701 "id": 67890 18702 }, 18703 "sender": { 18704 "login": "example-user", 18705 "id": 1111 18706 }, 18707 "installation": { 18708 "id": 2222 18709 } 18710 }` 18711 18712 testJSONMarshal(t, u, want) 18713 } 18714 18715 func TestSponsorshipChanges_Marshal(t *testing.T) { 18716 t.Parallel() 18717 testJSONMarshal(t, &SponsorshipChanges{}, "{}") 18718 18719 u := &SponsorshipChanges{ 18720 Tier: &SponsorshipTier{ 18721 From: Ptr("premium"), 18722 }, 18723 PrivacyLevel: Ptr("private"), 18724 } 18725 18726 want := `{ 18727 "tier": { 18728 "from": "premium" 18729 }, 18730 "privacy_level": "private" 18731 }` 18732 18733 testJSONMarshal(t, u, want) 18734 } 18735 18736 func TestSponsorshipTier_Marshal(t *testing.T) { 18737 t.Parallel() 18738 testJSONMarshal(t, &SponsorshipTier{}, "{}") 18739 18740 u := &SponsorshipTier{ 18741 From: Ptr("gold"), 18742 } 18743 18744 want := `{ 18745 "from": "gold" 18746 }` 18747 18748 testJSONMarshal(t, u, want) 18749 }