github.com/google/go-github/v57@v57.0.0/github/event_types_test.go (about) 1 // Copyright 2020 The go-github AUTHORS. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 package github 7 8 import ( 9 "encoding/json" 10 "testing" 11 ) 12 13 func TestEditChange_Marshal_TitleChange(t *testing.T) { 14 testJSONMarshal(t, &EditChange{}, "{}") 15 16 u := &EditChange{ 17 Title: &EditTitle{ 18 From: String("TitleFrom"), 19 }, 20 Body: nil, 21 Base: nil, 22 } 23 24 want := `{ 25 "title": { 26 "from": "TitleFrom" 27 } 28 }` 29 30 testJSONMarshal(t, u, want) 31 } 32 33 func TestEditChange_Marshal_BodyChange(t *testing.T) { 34 testJSONMarshal(t, &EditChange{}, "{}") 35 36 u := &EditChange{ 37 Title: nil, 38 Body: &EditBody{ 39 From: String("BodyFrom"), 40 }, 41 Base: nil, 42 } 43 44 want := `{ 45 "body": { 46 "from": "BodyFrom" 47 } 48 }` 49 50 testJSONMarshal(t, u, want) 51 } 52 53 func TestEditChange_Marshal_BaseChange(t *testing.T) { 54 testJSONMarshal(t, &EditChange{}, "{}") 55 56 Base := EditBase{ 57 Ref: &EditRef{ 58 From: String("BaseRefFrom"), 59 }, 60 SHA: &EditSHA{ 61 From: String("BaseSHAFrom"), 62 }, 63 } 64 65 u := &EditChange{ 66 Title: nil, 67 Body: nil, 68 Base: &Base, 69 } 70 71 want := `{ 72 "base": { 73 "ref": { 74 "from": "BaseRefFrom" 75 }, 76 "sha": { 77 "from": "BaseSHAFrom" 78 } 79 } 80 }` 81 82 testJSONMarshal(t, u, want) 83 } 84 85 func TestEditChange_Marshal_Repo(t *testing.T) { 86 testJSONMarshal(t, &EditChange{}, "{}") 87 88 u := &EditChange{ 89 Repo: &EditRepo{ 90 Name: &RepoName{ 91 From: String("old-repo-name"), 92 }, 93 }, 94 } 95 96 want := `{ 97 "repository": { 98 "name": { 99 "from": "old-repo-name" 100 } 101 } 102 }` 103 104 testJSONMarshal(t, u, want) 105 } 106 107 func TestEditChange_Marshal_TransferFromUser(t *testing.T) { 108 testJSONMarshal(t, &EditChange{}, "{}") 109 110 u := &EditChange{ 111 Owner: &EditOwner{ 112 OwnerInfo: &OwnerInfo{ 113 User: &User{ 114 Login: String("l"), 115 ID: Int64(1), 116 NodeID: String("n"), 117 URL: String("u"), 118 ReposURL: String("r"), 119 EventsURL: String("e"), 120 AvatarURL: String("a"), 121 }, 122 }, 123 }, 124 } 125 126 want := `{ 127 "owner": { 128 "from": { 129 "user": { 130 "login": "l", 131 "id": 1, 132 "node_id": "n", 133 "avatar_url": "a", 134 "url": "u", 135 "repos_url": "r", 136 "events_url": "e" 137 } 138 } 139 } 140 }` 141 142 testJSONMarshal(t, u, want) 143 } 144 145 func TestEditChange_Marshal_TransferFromOrg(t *testing.T) { 146 testJSONMarshal(t, &EditChange{}, "{}") 147 148 u := &EditChange{ 149 Owner: &EditOwner{ 150 OwnerInfo: &OwnerInfo{ 151 Org: &User{ 152 Login: String("l"), 153 ID: Int64(1), 154 NodeID: String("n"), 155 URL: String("u"), 156 ReposURL: String("r"), 157 EventsURL: String("e"), 158 AvatarURL: String("a"), 159 }, 160 }, 161 }, 162 } 163 164 want := `{ 165 "owner": { 166 "from": { 167 "organization": { 168 "login": "l", 169 "id": 1, 170 "node_id": "n", 171 "avatar_url": "a", 172 "url": "u", 173 "repos_url": "r", 174 "events_url": "e" 175 } 176 } 177 } 178 }` 179 180 testJSONMarshal(t, u, want) 181 } 182 183 func TestProjectChange_Marshal_NameChange(t *testing.T) { 184 testJSONMarshal(t, &ProjectChange{}, "{}") 185 186 u := &ProjectChange{ 187 Name: &ProjectName{From: String("NameFrom")}, 188 Body: nil, 189 } 190 191 want := `{ 192 "name": { 193 "from": "NameFrom" 194 } 195 }` 196 197 testJSONMarshal(t, u, want) 198 } 199 200 func TestProjectChange_Marshal_BodyChange(t *testing.T) { 201 testJSONMarshal(t, &ProjectChange{}, "{}") 202 203 u := &ProjectChange{ 204 Name: nil, 205 Body: &ProjectBody{From: String("BodyFrom")}, 206 } 207 208 want := `{ 209 "body": { 210 "from": "BodyFrom" 211 } 212 }` 213 214 testJSONMarshal(t, u, want) 215 } 216 217 func TestProjectCardChange_Marshal_NoteChange(t *testing.T) { 218 testJSONMarshal(t, &ProjectCardChange{}, "{}") 219 220 u := &ProjectCardChange{ 221 Note: &ProjectCardNote{From: String("NoteFrom")}, 222 } 223 224 want := `{ 225 "note": { 226 "from": "NoteFrom" 227 } 228 }` 229 230 testJSONMarshal(t, u, want) 231 } 232 233 func TestProjectColumnChange_Marshal_NameChange(t *testing.T) { 234 testJSONMarshal(t, &ProjectColumnChange{}, "{}") 235 236 u := &ProjectColumnChange{ 237 Name: &ProjectColumnName{From: String("NameFrom")}, 238 } 239 240 want := `{ 241 "name": { 242 "from": "NameFrom" 243 } 244 }` 245 246 testJSONMarshal(t, u, want) 247 } 248 249 func TestTeamAddEvent_Marshal(t *testing.T) { 250 testJSONMarshal(t, &TeamAddEvent{}, "{}") 251 252 u := &TeamAddEvent{ 253 Team: &Team{ 254 ID: Int64(1), 255 NodeID: String("n"), 256 Name: String("n"), 257 Description: String("d"), 258 URL: String("u"), 259 Slug: String("s"), 260 Permission: String("p"), 261 Privacy: String("p"), 262 MembersCount: Int(1), 263 ReposCount: Int(1), 264 MembersURL: String("m"), 265 RepositoriesURL: String("r"), 266 Organization: &Organization{ 267 Login: String("l"), 268 ID: Int64(1), 269 NodeID: String("n"), 270 AvatarURL: String("a"), 271 HTMLURL: String("h"), 272 Name: String("n"), 273 Company: String("c"), 274 Blog: String("b"), 275 Location: String("l"), 276 Email: String("e"), 277 }, 278 Parent: &Team{ 279 ID: Int64(1), 280 NodeID: String("n"), 281 Name: String("n"), 282 Description: String("d"), 283 URL: String("u"), 284 Slug: String("s"), 285 Permission: String("p"), 286 Privacy: String("p"), 287 MembersCount: Int(1), 288 ReposCount: Int(1), 289 }, 290 LDAPDN: String("l"), 291 }, 292 Repo: &Repository{ 293 ID: Int64(1), 294 URL: String("s"), 295 Name: String("n"), 296 }, 297 Org: &Organization{ 298 BillingEmail: String("be"), 299 Blog: String("b"), 300 Company: String("c"), 301 Email: String("e"), 302 TwitterUsername: String("tu"), 303 Location: String("loc"), 304 Name: String("n"), 305 Description: String("d"), 306 IsVerified: Bool(true), 307 HasOrganizationProjects: Bool(true), 308 HasRepositoryProjects: Bool(true), 309 DefaultRepoPermission: String("drp"), 310 MembersCanCreateRepos: Bool(true), 311 MembersCanCreateInternalRepos: Bool(true), 312 MembersCanCreatePrivateRepos: Bool(true), 313 MembersCanCreatePublicRepos: Bool(false), 314 MembersAllowedRepositoryCreationType: String("marct"), 315 MembersCanCreatePages: Bool(true), 316 MembersCanCreatePublicPages: Bool(false), 317 MembersCanCreatePrivatePages: Bool(true), 318 }, 319 Sender: &User{ 320 Login: String("l"), 321 ID: Int64(1), 322 NodeID: String("n"), 323 URL: String("u"), 324 ReposURL: String("r"), 325 EventsURL: String("e"), 326 AvatarURL: String("a"), 327 }, 328 Installation: &Installation{ 329 ID: Int64(1), 330 NodeID: String("nid"), 331 AppID: Int64(1), 332 AppSlug: String("as"), 333 TargetID: Int64(1), 334 Account: &User{ 335 Login: String("l"), 336 ID: Int64(1), 337 URL: String("u"), 338 AvatarURL: String("a"), 339 GravatarID: String("g"), 340 Name: String("n"), 341 Company: String("c"), 342 Blog: String("b"), 343 Location: String("l"), 344 Email: String("e"), 345 Hireable: Bool(true), 346 Bio: String("b"), 347 TwitterUsername: String("t"), 348 PublicRepos: Int(1), 349 Followers: Int(1), 350 Following: Int(1), 351 CreatedAt: &Timestamp{referenceTime}, 352 SuspendedAt: &Timestamp{referenceTime}, 353 }, 354 AccessTokensURL: String("atu"), 355 RepositoriesURL: String("ru"), 356 HTMLURL: String("hu"), 357 TargetType: String("tt"), 358 SingleFileName: String("sfn"), 359 RepositorySelection: String("rs"), 360 Events: []string{"e"}, 361 SingleFilePaths: []string{"s"}, 362 Permissions: &InstallationPermissions{ 363 Actions: String("a"), 364 Administration: String("ad"), 365 Checks: String("c"), 366 Contents: String("co"), 367 ContentReferences: String("cr"), 368 Deployments: String("d"), 369 Environments: String("e"), 370 Issues: String("i"), 371 Metadata: String("md"), 372 Members: String("m"), 373 OrganizationAdministration: String("oa"), 374 OrganizationHooks: String("oh"), 375 OrganizationPlan: String("op"), 376 OrganizationPreReceiveHooks: String("opr"), 377 OrganizationProjects: String("op"), 378 OrganizationSecrets: String("os"), 379 OrganizationSelfHostedRunners: String("osh"), 380 OrganizationUserBlocking: String("oub"), 381 Packages: String("pkg"), 382 Pages: String("pg"), 383 PullRequests: String("pr"), 384 RepositoryHooks: String("rh"), 385 RepositoryProjects: String("rp"), 386 RepositoryPreReceiveHooks: String("rprh"), 387 Secrets: String("s"), 388 SecretScanningAlerts: String("ssa"), 389 SecurityEvents: String("se"), 390 SingleFile: String("sf"), 391 Statuses: String("s"), 392 TeamDiscussions: String("td"), 393 VulnerabilityAlerts: String("va"), 394 Workflows: String("w"), 395 }, 396 CreatedAt: &Timestamp{referenceTime}, 397 UpdatedAt: &Timestamp{referenceTime}, 398 HasMultipleSingleFiles: Bool(false), 399 SuspendedBy: &User{ 400 Login: String("l"), 401 ID: Int64(1), 402 URL: String("u"), 403 AvatarURL: String("a"), 404 GravatarID: String("g"), 405 Name: String("n"), 406 Company: String("c"), 407 Blog: String("b"), 408 Location: String("l"), 409 Email: String("e"), 410 Hireable: Bool(true), 411 Bio: String("b"), 412 TwitterUsername: String("t"), 413 PublicRepos: Int(1), 414 Followers: Int(1), 415 Following: Int(1), 416 CreatedAt: &Timestamp{referenceTime}, 417 SuspendedAt: &Timestamp{referenceTime}, 418 }, 419 SuspendedAt: &Timestamp{referenceTime}, 420 }, 421 } 422 423 want := `{ 424 "team": { 425 "id": 1, 426 "node_id": "n", 427 "name": "n", 428 "description": "d", 429 "url": "u", 430 "slug": "s", 431 "permission": "p", 432 "privacy": "p", 433 "members_count": 1, 434 "repos_count": 1, 435 "organization": { 436 "login": "l", 437 "id": 1, 438 "node_id": "n", 439 "avatar_url": "a", 440 "html_url": "h", 441 "name": "n", 442 "company": "c", 443 "blog": "b", 444 "location": "l", 445 "email": "e" 446 }, 447 "members_url": "m", 448 "repositories_url": "r", 449 "parent": { 450 "id": 1, 451 "node_id": "n", 452 "name": "n", 453 "description": "d", 454 "url": "u", 455 "slug": "s", 456 "permission": "p", 457 "privacy": "p", 458 "members_count": 1, 459 "repos_count": 1 460 }, 461 "ldap_dn": "l" 462 }, 463 "repository": { 464 "id": 1, 465 "name": "n", 466 "url": "s" 467 }, 468 "organization": { 469 "name": "n", 470 "company": "c", 471 "blog": "b", 472 "location": "loc", 473 "email": "e", 474 "twitter_username": "tu", 475 "description": "d", 476 "billing_email": "be", 477 "is_verified": true, 478 "has_organization_projects": true, 479 "has_repository_projects": true, 480 "default_repository_permission": "drp", 481 "members_can_create_repositories": true, 482 "members_can_create_public_repositories": false, 483 "members_can_create_private_repositories": true, 484 "members_can_create_internal_repositories": true, 485 "members_allowed_repository_creation_type": "marct", 486 "members_can_create_pages": true, 487 "members_can_create_public_pages": false, 488 "members_can_create_private_pages": true 489 }, 490 "sender": { 491 "login": "l", 492 "id": 1, 493 "node_id": "n", 494 "avatar_url": "a", 495 "url": "u", 496 "events_url": "e", 497 "repos_url": "r" 498 }, 499 "installation": { 500 "id": 1, 501 "node_id": "nid", 502 "app_id": 1, 503 "app_slug": "as", 504 "target_id": 1, 505 "account": { 506 "login": "l", 507 "id": 1, 508 "avatar_url": "a", 509 "gravatar_id": "g", 510 "name": "n", 511 "company": "c", 512 "blog": "b", 513 "location": "l", 514 "email": "e", 515 "hireable": true, 516 "bio": "b", 517 "twitter_username": "t", 518 "public_repos": 1, 519 "followers": 1, 520 "following": 1, 521 "created_at": ` + referenceTimeStr + `, 522 "suspended_at": ` + referenceTimeStr + `, 523 "url": "u" 524 }, 525 "access_tokens_url": "atu", 526 "repositories_url": "ru", 527 "html_url": "hu", 528 "target_type": "tt", 529 "single_file_name": "sfn", 530 "repository_selection": "rs", 531 "events": [ 532 "e" 533 ], 534 "single_file_paths": [ 535 "s" 536 ], 537 "permissions": { 538 "actions": "a", 539 "administration": "ad", 540 "checks": "c", 541 "contents": "co", 542 "content_references": "cr", 543 "deployments": "d", 544 "environments": "e", 545 "issues": "i", 546 "metadata": "md", 547 "members": "m", 548 "organization_administration": "oa", 549 "organization_hooks": "oh", 550 "organization_plan": "op", 551 "organization_pre_receive_hooks": "opr", 552 "organization_projects": "op", 553 "organization_secrets": "os", 554 "organization_self_hosted_runners": "osh", 555 "organization_user_blocking": "oub", 556 "packages": "pkg", 557 "pages": "pg", 558 "pull_requests": "pr", 559 "repository_hooks": "rh", 560 "repository_projects": "rp", 561 "repository_pre_receive_hooks": "rprh", 562 "secrets": "s", 563 "secret_scanning_alerts": "ssa", 564 "security_events": "se", 565 "single_file": "sf", 566 "statuses": "s", 567 "team_discussions": "td", 568 "vulnerability_alerts": "va", 569 "workflows": "w" 570 }, 571 "created_at": ` + referenceTimeStr + `, 572 "updated_at": ` + referenceTimeStr + `, 573 "has_multiple_single_files": false, 574 "suspended_by": { 575 "login": "l", 576 "id": 1, 577 "avatar_url": "a", 578 "gravatar_id": "g", 579 "name": "n", 580 "company": "c", 581 "blog": "b", 582 "location": "l", 583 "email": "e", 584 "hireable": true, 585 "bio": "b", 586 "twitter_username": "t", 587 "public_repos": 1, 588 "followers": 1, 589 "following": 1, 590 "created_at": ` + referenceTimeStr + `, 591 "suspended_at": ` + referenceTimeStr + `, 592 "url": "u" 593 }, 594 "suspended_at": ` + referenceTimeStr + ` 595 } 596 }` 597 598 testJSONMarshal(t, u, want) 599 } 600 601 func TestStarEvent_Marshal(t *testing.T) { 602 testJSONMarshal(t, &StarEvent{}, "{}") 603 604 u := &StarEvent{ 605 Action: String("a"), 606 StarredAt: &Timestamp{referenceTime}, 607 Org: &Organization{ 608 BillingEmail: String("be"), 609 Blog: String("b"), 610 Company: String("c"), 611 Email: String("e"), 612 TwitterUsername: String("tu"), 613 Location: String("loc"), 614 Name: String("n"), 615 Description: String("d"), 616 IsVerified: Bool(true), 617 HasOrganizationProjects: Bool(true), 618 HasRepositoryProjects: Bool(true), 619 DefaultRepoPermission: String("drp"), 620 MembersCanCreateRepos: Bool(true), 621 MembersCanCreateInternalRepos: Bool(true), 622 MembersCanCreatePrivateRepos: Bool(true), 623 MembersCanCreatePublicRepos: Bool(false), 624 MembersAllowedRepositoryCreationType: String("marct"), 625 MembersCanCreatePages: Bool(true), 626 MembersCanCreatePublicPages: Bool(false), 627 MembersCanCreatePrivatePages: Bool(true), 628 }, 629 Repo: &Repository{ 630 ID: Int64(1), 631 URL: String("s"), 632 Name: String("n"), 633 }, 634 Sender: &User{ 635 Login: String("l"), 636 ID: Int64(1), 637 NodeID: String("n"), 638 URL: String("u"), 639 ReposURL: String("r"), 640 EventsURL: String("e"), 641 AvatarURL: String("a"), 642 }, 643 } 644 645 want := `{ 646 "action": "a", 647 "starred_at": ` + referenceTimeStr + `, 648 "organization": { 649 "name": "n", 650 "company": "c", 651 "blog": "b", 652 "location": "loc", 653 "email": "e", 654 "twitter_username": "tu", 655 "description": "d", 656 "billing_email": "be", 657 "is_verified": true, 658 "has_organization_projects": true, 659 "has_repository_projects": true, 660 "default_repository_permission": "drp", 661 "members_can_create_repositories": true, 662 "members_can_create_public_repositories": false, 663 "members_can_create_private_repositories": true, 664 "members_can_create_internal_repositories": true, 665 "members_allowed_repository_creation_type": "marct", 666 "members_can_create_pages": true, 667 "members_can_create_public_pages": false, 668 "members_can_create_private_pages": true 669 }, 670 "repository": { 671 "id": 1, 672 "name": "n", 673 "url": "s" 674 }, 675 "sender": { 676 "login": "l", 677 "id": 1, 678 "node_id": "n", 679 "avatar_url": "a", 680 "url": "u", 681 "events_url": "e", 682 "repos_url": "r" 683 } 684 }` 685 686 testJSONMarshal(t, u, want) 687 } 688 689 func TestTeamEvent_Marshal(t *testing.T) { 690 testJSONMarshal(t, &TeamEvent{}, "{}") 691 692 u := &TeamEvent{ 693 Action: String("a"), 694 Team: &Team{ 695 ID: Int64(1), 696 NodeID: String("n"), 697 Name: String("n"), 698 Description: String("d"), 699 URL: String("u"), 700 Slug: String("s"), 701 Permission: String("p"), 702 Privacy: String("p"), 703 MembersCount: Int(1), 704 ReposCount: Int(1), 705 MembersURL: String("m"), 706 RepositoriesURL: String("r"), 707 Organization: &Organization{ 708 Login: String("l"), 709 ID: Int64(1), 710 NodeID: String("n"), 711 AvatarURL: String("a"), 712 HTMLURL: String("h"), 713 Name: String("n"), 714 Company: String("c"), 715 Blog: String("b"), 716 Location: String("l"), 717 Email: String("e"), 718 }, 719 Parent: &Team{ 720 ID: Int64(1), 721 NodeID: String("n"), 722 Name: String("n"), 723 Description: String("d"), 724 URL: String("u"), 725 Slug: String("s"), 726 Permission: String("p"), 727 Privacy: String("p"), 728 MembersCount: Int(1), 729 ReposCount: Int(1), 730 }, 731 LDAPDN: String("l"), 732 }, 733 Changes: &TeamChange{ 734 Description: &TeamDescription{ 735 From: String("from"), 736 }, 737 Name: &TeamName{ 738 From: String("from"), 739 }, 740 Privacy: &TeamPrivacy{ 741 From: String("from"), 742 }, 743 Repository: &TeamRepository{ 744 Permissions: &TeamPermissions{ 745 From: &TeamPermissionsFrom{ 746 Admin: Bool(true), 747 Pull: Bool(true), 748 Push: Bool(true), 749 }, 750 }, 751 }, 752 }, 753 Repo: &Repository{ 754 ID: Int64(1), 755 URL: String("s"), 756 Name: String("n"), 757 }, 758 Org: &Organization{ 759 BillingEmail: String("be"), 760 Blog: String("b"), 761 Company: String("c"), 762 Email: String("e"), 763 TwitterUsername: String("tu"), 764 Location: String("loc"), 765 Name: String("n"), 766 Description: String("d"), 767 IsVerified: Bool(true), 768 HasOrganizationProjects: Bool(true), 769 HasRepositoryProjects: Bool(true), 770 DefaultRepoPermission: String("drp"), 771 MembersCanCreateRepos: Bool(true), 772 MembersCanCreateInternalRepos: Bool(true), 773 MembersCanCreatePrivateRepos: Bool(true), 774 MembersCanCreatePublicRepos: Bool(false), 775 MembersAllowedRepositoryCreationType: String("marct"), 776 MembersCanCreatePages: Bool(true), 777 MembersCanCreatePublicPages: Bool(false), 778 MembersCanCreatePrivatePages: Bool(true), 779 }, 780 Sender: &User{ 781 Login: String("l"), 782 ID: Int64(1), 783 NodeID: String("n"), 784 URL: String("u"), 785 ReposURL: String("r"), 786 EventsURL: String("e"), 787 AvatarURL: String("a"), 788 }, 789 Installation: &Installation{ 790 ID: Int64(1), 791 NodeID: String("nid"), 792 AppID: Int64(1), 793 AppSlug: String("as"), 794 TargetID: Int64(1), 795 Account: &User{ 796 Login: String("l"), 797 ID: Int64(1), 798 URL: String("u"), 799 AvatarURL: String("a"), 800 GravatarID: String("g"), 801 Name: String("n"), 802 Company: String("c"), 803 Blog: String("b"), 804 Location: String("l"), 805 Email: String("e"), 806 Hireable: Bool(true), 807 Bio: String("b"), 808 TwitterUsername: String("t"), 809 PublicRepos: Int(1), 810 Followers: Int(1), 811 Following: Int(1), 812 CreatedAt: &Timestamp{referenceTime}, 813 SuspendedAt: &Timestamp{referenceTime}, 814 }, 815 AccessTokensURL: String("atu"), 816 RepositoriesURL: String("ru"), 817 HTMLURL: String("hu"), 818 TargetType: String("tt"), 819 SingleFileName: String("sfn"), 820 RepositorySelection: String("rs"), 821 Events: []string{"e"}, 822 SingleFilePaths: []string{"s"}, 823 Permissions: &InstallationPermissions{ 824 Actions: String("a"), 825 Administration: String("ad"), 826 Checks: String("c"), 827 Contents: String("co"), 828 ContentReferences: String("cr"), 829 Deployments: String("d"), 830 Environments: String("e"), 831 Issues: String("i"), 832 Metadata: String("md"), 833 Members: String("m"), 834 OrganizationAdministration: String("oa"), 835 OrganizationHooks: String("oh"), 836 OrganizationPlan: String("op"), 837 OrganizationPreReceiveHooks: String("opr"), 838 OrganizationProjects: String("op"), 839 OrganizationSecrets: String("os"), 840 OrganizationSelfHostedRunners: String("osh"), 841 OrganizationUserBlocking: String("oub"), 842 Packages: String("pkg"), 843 Pages: String("pg"), 844 PullRequests: String("pr"), 845 RepositoryHooks: String("rh"), 846 RepositoryProjects: String("rp"), 847 RepositoryPreReceiveHooks: String("rprh"), 848 Secrets: String("s"), 849 SecretScanningAlerts: String("ssa"), 850 SecurityEvents: String("se"), 851 SingleFile: String("sf"), 852 Statuses: String("s"), 853 TeamDiscussions: String("td"), 854 VulnerabilityAlerts: String("va"), 855 Workflows: String("w"), 856 }, 857 CreatedAt: &Timestamp{referenceTime}, 858 UpdatedAt: &Timestamp{referenceTime}, 859 HasMultipleSingleFiles: Bool(false), 860 SuspendedBy: &User{ 861 Login: String("l"), 862 ID: Int64(1), 863 URL: String("u"), 864 AvatarURL: String("a"), 865 GravatarID: String("g"), 866 Name: String("n"), 867 Company: String("c"), 868 Blog: String("b"), 869 Location: String("l"), 870 Email: String("e"), 871 Hireable: Bool(true), 872 Bio: String("b"), 873 TwitterUsername: String("t"), 874 PublicRepos: Int(1), 875 Followers: Int(1), 876 Following: Int(1), 877 CreatedAt: &Timestamp{referenceTime}, 878 SuspendedAt: &Timestamp{referenceTime}, 879 }, 880 SuspendedAt: &Timestamp{referenceTime}, 881 }, 882 } 883 884 want := `{ 885 "action": "a", 886 "team": { 887 "id": 1, 888 "node_id": "n", 889 "name": "n", 890 "description": "d", 891 "url": "u", 892 "slug": "s", 893 "permission": "p", 894 "privacy": "p", 895 "members_count": 1, 896 "repos_count": 1, 897 "organization": { 898 "login": "l", 899 "id": 1, 900 "node_id": "n", 901 "avatar_url": "a", 902 "html_url": "h", 903 "name": "n", 904 "company": "c", 905 "blog": "b", 906 "location": "l", 907 "email": "e" 908 }, 909 "members_url": "m", 910 "repositories_url": "r", 911 "parent": { 912 "id": 1, 913 "node_id": "n", 914 "name": "n", 915 "description": "d", 916 "url": "u", 917 "slug": "s", 918 "permission": "p", 919 "privacy": "p", 920 "members_count": 1, 921 "repos_count": 1 922 }, 923 "ldap_dn": "l" 924 }, 925 "changes": { 926 "description": { 927 "from": "from" 928 }, 929 "name": { 930 "from": "from" 931 }, 932 "privacy": { 933 "from": "from" 934 }, 935 "repository": { 936 "permissions": { 937 "from": { 938 "admin": true, 939 "pull": true, 940 "push": true 941 } 942 } 943 } 944 }, 945 "repository": { 946 "id": 1, 947 "name": "n", 948 "url": "s" 949 }, 950 "organization": { 951 "name": "n", 952 "company": "c", 953 "blog": "b", 954 "location": "loc", 955 "email": "e", 956 "twitter_username": "tu", 957 "description": "d", 958 "billing_email": "be", 959 "is_verified": true, 960 "has_organization_projects": true, 961 "has_repository_projects": true, 962 "default_repository_permission": "drp", 963 "members_can_create_repositories": true, 964 "members_can_create_public_repositories": false, 965 "members_can_create_private_repositories": true, 966 "members_can_create_internal_repositories": true, 967 "members_allowed_repository_creation_type": "marct", 968 "members_can_create_pages": true, 969 "members_can_create_public_pages": false, 970 "members_can_create_private_pages": true 971 }, 972 "sender": { 973 "login": "l", 974 "id": 1, 975 "node_id": "n", 976 "avatar_url": "a", 977 "url": "u", 978 "events_url": "e", 979 "repos_url": "r" 980 }, 981 "installation": { 982 "id": 1, 983 "node_id": "nid", 984 "app_id": 1, 985 "app_slug": "as", 986 "target_id": 1, 987 "account": { 988 "login": "l", 989 "id": 1, 990 "avatar_url": "a", 991 "gravatar_id": "g", 992 "name": "n", 993 "company": "c", 994 "blog": "b", 995 "location": "l", 996 "email": "e", 997 "hireable": true, 998 "bio": "b", 999 "twitter_username": "t", 1000 "public_repos": 1, 1001 "followers": 1, 1002 "following": 1, 1003 "created_at": ` + referenceTimeStr + `, 1004 "suspended_at": ` + referenceTimeStr + `, 1005 "url": "u" 1006 }, 1007 "access_tokens_url": "atu", 1008 "repositories_url": "ru", 1009 "html_url": "hu", 1010 "target_type": "tt", 1011 "single_file_name": "sfn", 1012 "repository_selection": "rs", 1013 "events": [ 1014 "e" 1015 ], 1016 "single_file_paths": [ 1017 "s" 1018 ], 1019 "permissions": { 1020 "actions": "a", 1021 "administration": "ad", 1022 "checks": "c", 1023 "contents": "co", 1024 "content_references": "cr", 1025 "deployments": "d", 1026 "environments": "e", 1027 "issues": "i", 1028 "metadata": "md", 1029 "members": "m", 1030 "organization_administration": "oa", 1031 "organization_hooks": "oh", 1032 "organization_plan": "op", 1033 "organization_pre_receive_hooks": "opr", 1034 "organization_projects": "op", 1035 "organization_secrets": "os", 1036 "organization_self_hosted_runners": "osh", 1037 "organization_user_blocking": "oub", 1038 "packages": "pkg", 1039 "pages": "pg", 1040 "pull_requests": "pr", 1041 "repository_hooks": "rh", 1042 "repository_projects": "rp", 1043 "repository_pre_receive_hooks": "rprh", 1044 "secrets": "s", 1045 "secret_scanning_alerts": "ssa", 1046 "security_events": "se", 1047 "single_file": "sf", 1048 "statuses": "s", 1049 "team_discussions": "td", 1050 "vulnerability_alerts": "va", 1051 "workflows": "w" 1052 }, 1053 "created_at": ` + referenceTimeStr + `, 1054 "updated_at": ` + referenceTimeStr + `, 1055 "has_multiple_single_files": false, 1056 "suspended_by": { 1057 "login": "l", 1058 "id": 1, 1059 "avatar_url": "a", 1060 "gravatar_id": "g", 1061 "name": "n", 1062 "company": "c", 1063 "blog": "b", 1064 "location": "l", 1065 "email": "e", 1066 "hireable": true, 1067 "bio": "b", 1068 "twitter_username": "t", 1069 "public_repos": 1, 1070 "followers": 1, 1071 "following": 1, 1072 "created_at": ` + referenceTimeStr + `, 1073 "suspended_at": ` + referenceTimeStr + `, 1074 "url": "u" 1075 }, 1076 "suspended_at": ` + referenceTimeStr + ` 1077 } 1078 }` 1079 1080 testJSONMarshal(t, u, want) 1081 } 1082 1083 func TestInstallationRepositoriesEvent_Marshal(t *testing.T) { 1084 testJSONMarshal(t, &InstallationRepositoriesEvent{}, "{}") 1085 1086 u := &InstallationRepositoriesEvent{ 1087 Action: String("a"), 1088 RepositoriesAdded: []*Repository{ 1089 { 1090 ID: Int64(1), 1091 URL: String("s"), 1092 Name: String("n"), 1093 }, 1094 }, 1095 RepositoriesRemoved: []*Repository{ 1096 { 1097 ID: Int64(1), 1098 URL: String("s"), 1099 Name: String("n"), 1100 }, 1101 }, 1102 RepositorySelection: String("rs"), 1103 Sender: &User{ 1104 Login: String("l"), 1105 ID: Int64(1), 1106 NodeID: String("n"), 1107 URL: String("u"), 1108 ReposURL: String("r"), 1109 EventsURL: String("e"), 1110 AvatarURL: String("a"), 1111 }, 1112 Installation: &Installation{ 1113 ID: Int64(1), 1114 NodeID: String("nid"), 1115 AppID: Int64(1), 1116 AppSlug: String("as"), 1117 TargetID: Int64(1), 1118 Account: &User{ 1119 Login: String("l"), 1120 ID: Int64(1), 1121 URL: String("u"), 1122 AvatarURL: String("a"), 1123 GravatarID: String("g"), 1124 Name: String("n"), 1125 Company: String("c"), 1126 Blog: String("b"), 1127 Location: String("l"), 1128 Email: String("e"), 1129 Hireable: Bool(true), 1130 Bio: String("b"), 1131 TwitterUsername: String("t"), 1132 PublicRepos: Int(1), 1133 Followers: Int(1), 1134 Following: Int(1), 1135 CreatedAt: &Timestamp{referenceTime}, 1136 SuspendedAt: &Timestamp{referenceTime}, 1137 }, 1138 AccessTokensURL: String("atu"), 1139 RepositoriesURL: String("ru"), 1140 HTMLURL: String("hu"), 1141 TargetType: String("tt"), 1142 SingleFileName: String("sfn"), 1143 RepositorySelection: String("rs"), 1144 Events: []string{"e"}, 1145 SingleFilePaths: []string{"s"}, 1146 Permissions: &InstallationPermissions{ 1147 Actions: String("a"), 1148 Administration: String("ad"), 1149 Checks: String("c"), 1150 Contents: String("co"), 1151 ContentReferences: String("cr"), 1152 Deployments: String("d"), 1153 Environments: String("e"), 1154 Issues: String("i"), 1155 Metadata: String("md"), 1156 Members: String("m"), 1157 OrganizationAdministration: String("oa"), 1158 OrganizationHooks: String("oh"), 1159 OrganizationPlan: String("op"), 1160 OrganizationPreReceiveHooks: String("opr"), 1161 OrganizationProjects: String("op"), 1162 OrganizationSecrets: String("os"), 1163 OrganizationSelfHostedRunners: String("osh"), 1164 OrganizationUserBlocking: String("oub"), 1165 Packages: String("pkg"), 1166 Pages: String("pg"), 1167 PullRequests: String("pr"), 1168 RepositoryHooks: String("rh"), 1169 RepositoryProjects: String("rp"), 1170 RepositoryPreReceiveHooks: String("rprh"), 1171 Secrets: String("s"), 1172 SecretScanningAlerts: String("ssa"), 1173 SecurityEvents: String("se"), 1174 SingleFile: String("sf"), 1175 Statuses: String("s"), 1176 TeamDiscussions: String("td"), 1177 VulnerabilityAlerts: String("va"), 1178 Workflows: String("w"), 1179 }, 1180 CreatedAt: &Timestamp{referenceTime}, 1181 UpdatedAt: &Timestamp{referenceTime}, 1182 HasMultipleSingleFiles: Bool(false), 1183 SuspendedBy: &User{ 1184 Login: String("l"), 1185 ID: Int64(1), 1186 URL: String("u"), 1187 AvatarURL: String("a"), 1188 GravatarID: String("g"), 1189 Name: String("n"), 1190 Company: String("c"), 1191 Blog: String("b"), 1192 Location: String("l"), 1193 Email: String("e"), 1194 Hireable: Bool(true), 1195 Bio: String("b"), 1196 TwitterUsername: String("t"), 1197 PublicRepos: Int(1), 1198 Followers: Int(1), 1199 Following: Int(1), 1200 CreatedAt: &Timestamp{referenceTime}, 1201 SuspendedAt: &Timestamp{referenceTime}, 1202 }, 1203 SuspendedAt: &Timestamp{referenceTime}, 1204 }, 1205 } 1206 1207 want := `{ 1208 "action": "a", 1209 "repositories_added": [ 1210 { 1211 "id": 1, 1212 "name": "n", 1213 "url": "s" 1214 } 1215 ], 1216 "repositories_removed": [ 1217 { 1218 "id": 1, 1219 "name": "n", 1220 "url": "s" 1221 } 1222 ], 1223 "repository_selection": "rs", 1224 "sender": { 1225 "login": "l", 1226 "id": 1, 1227 "node_id": "n", 1228 "avatar_url": "a", 1229 "url": "u", 1230 "events_url": "e", 1231 "repos_url": "r" 1232 }, 1233 "installation": { 1234 "id": 1, 1235 "node_id": "nid", 1236 "app_id": 1, 1237 "app_slug": "as", 1238 "target_id": 1, 1239 "account": { 1240 "login": "l", 1241 "id": 1, 1242 "avatar_url": "a", 1243 "gravatar_id": "g", 1244 "name": "n", 1245 "company": "c", 1246 "blog": "b", 1247 "location": "l", 1248 "email": "e", 1249 "hireable": true, 1250 "bio": "b", 1251 "twitter_username": "t", 1252 "public_repos": 1, 1253 "followers": 1, 1254 "following": 1, 1255 "created_at": ` + referenceTimeStr + `, 1256 "suspended_at": ` + referenceTimeStr + `, 1257 "url": "u" 1258 }, 1259 "access_tokens_url": "atu", 1260 "repositories_url": "ru", 1261 "html_url": "hu", 1262 "target_type": "tt", 1263 "single_file_name": "sfn", 1264 "repository_selection": "rs", 1265 "events": [ 1266 "e" 1267 ], 1268 "single_file_paths": [ 1269 "s" 1270 ], 1271 "permissions": { 1272 "actions": "a", 1273 "administration": "ad", 1274 "checks": "c", 1275 "contents": "co", 1276 "content_references": "cr", 1277 "deployments": "d", 1278 "environments": "e", 1279 "issues": "i", 1280 "metadata": "md", 1281 "members": "m", 1282 "organization_administration": "oa", 1283 "organization_hooks": "oh", 1284 "organization_plan": "op", 1285 "organization_pre_receive_hooks": "opr", 1286 "organization_projects": "op", 1287 "organization_secrets": "os", 1288 "organization_self_hosted_runners": "osh", 1289 "organization_user_blocking": "oub", 1290 "packages": "pkg", 1291 "pages": "pg", 1292 "pull_requests": "pr", 1293 "repository_hooks": "rh", 1294 "repository_projects": "rp", 1295 "repository_pre_receive_hooks": "rprh", 1296 "secrets": "s", 1297 "secret_scanning_alerts": "ssa", 1298 "security_events": "se", 1299 "single_file": "sf", 1300 "statuses": "s", 1301 "team_discussions": "td", 1302 "vulnerability_alerts": "va", 1303 "workflows": "w" 1304 }, 1305 "created_at": ` + referenceTimeStr + `, 1306 "updated_at": ` + referenceTimeStr + `, 1307 "has_multiple_single_files": false, 1308 "suspended_by": { 1309 "login": "l", 1310 "id": 1, 1311 "avatar_url": "a", 1312 "gravatar_id": "g", 1313 "name": "n", 1314 "company": "c", 1315 "blog": "b", 1316 "location": "l", 1317 "email": "e", 1318 "hireable": true, 1319 "bio": "b", 1320 "twitter_username": "t", 1321 "public_repos": 1, 1322 "followers": 1, 1323 "following": 1, 1324 "created_at": ` + referenceTimeStr + `, 1325 "suspended_at": ` + referenceTimeStr + `, 1326 "url": "u" 1327 }, 1328 "suspended_at": ` + referenceTimeStr + ` 1329 } 1330 }` 1331 1332 testJSONMarshal(t, u, want) 1333 } 1334 1335 func TestInstallationTargetEvent_Marshal(t *testing.T) { 1336 testJSONMarshal(t, &InstallationTargetEvent{}, "{}") 1337 1338 u := &InstallationTargetEvent{ 1339 Account: &User{ 1340 Login: String("u"), 1341 ID: Int64(1), 1342 NodeID: String("n"), 1343 URL: String("u"), 1344 ReposURL: String("r"), 1345 EventsURL: String("e"), 1346 AvatarURL: String("l"), 1347 }, 1348 Action: String("a"), 1349 Changes: &InstallationChanges{ 1350 Login: &InstallationLoginChange{ 1351 From: String("p"), 1352 }, 1353 Slug: &InstallationSlugChange{ 1354 From: String("j"), 1355 }, 1356 }, 1357 Enterprise: &Enterprise{ 1358 ID: Int(1), 1359 Slug: String("s"), 1360 Name: String("n"), 1361 NodeID: String("nid"), 1362 AvatarURL: String("au"), 1363 Description: String("d"), 1364 WebsiteURL: String("wu"), 1365 HTMLURL: String("hu"), 1366 CreatedAt: &Timestamp{referenceTime}, 1367 UpdatedAt: &Timestamp{referenceTime}, 1368 }, 1369 Installation: &Installation{ 1370 ID: Int64(1), 1371 NodeID: String("nid"), 1372 AppID: Int64(1), 1373 AppSlug: String("as"), 1374 TargetID: Int64(1), 1375 Account: &User{ 1376 Login: String("l"), 1377 ID: Int64(1), 1378 URL: String("u"), 1379 AvatarURL: String("a"), 1380 GravatarID: String("g"), 1381 Name: String("n"), 1382 Company: String("c"), 1383 Blog: String("b"), 1384 Location: String("l"), 1385 Email: String("e"), 1386 Hireable: Bool(true), 1387 Bio: String("b"), 1388 TwitterUsername: String("t"), 1389 PublicRepos: Int(1), 1390 Followers: Int(1), 1391 Following: Int(1), 1392 CreatedAt: &Timestamp{referenceTime}, 1393 SuspendedAt: &Timestamp{referenceTime}, 1394 }, 1395 AccessTokensURL: String("atu"), 1396 RepositoriesURL: String("ru"), 1397 HTMLURL: String("hu"), 1398 TargetType: String("tt"), 1399 SingleFileName: String("sfn"), 1400 RepositorySelection: String("rs"), 1401 Events: []string{"e"}, 1402 SingleFilePaths: []string{"s"}, 1403 Permissions: &InstallationPermissions{ 1404 Actions: String("a"), 1405 Administration: String("ad"), 1406 Checks: String("c"), 1407 Contents: String("co"), 1408 ContentReferences: String("cr"), 1409 Deployments: String("d"), 1410 Environments: String("e"), 1411 Issues: String("i"), 1412 Metadata: String("md"), 1413 Members: String("m"), 1414 OrganizationAdministration: String("oa"), 1415 OrganizationHooks: String("oh"), 1416 OrganizationPlan: String("op"), 1417 OrganizationPreReceiveHooks: String("opr"), 1418 OrganizationProjects: String("op"), 1419 OrganizationSecrets: String("os"), 1420 OrganizationSelfHostedRunners: String("osh"), 1421 OrganizationUserBlocking: String("oub"), 1422 Packages: String("pkg"), 1423 Pages: String("pg"), 1424 PullRequests: String("pr"), 1425 RepositoryHooks: String("rh"), 1426 RepositoryProjects: String("rp"), 1427 RepositoryPreReceiveHooks: String("rprh"), 1428 Secrets: String("s"), 1429 SecretScanningAlerts: String("ssa"), 1430 SecurityEvents: String("se"), 1431 SingleFile: String("sf"), 1432 Statuses: String("s"), 1433 TeamDiscussions: String("td"), 1434 VulnerabilityAlerts: String("va"), 1435 Workflows: String("w"), 1436 }, 1437 CreatedAt: &Timestamp{referenceTime}, 1438 UpdatedAt: &Timestamp{referenceTime}, 1439 HasMultipleSingleFiles: Bool(false), 1440 SuspendedBy: &User{ 1441 Login: String("l"), 1442 ID: Int64(1), 1443 URL: String("u"), 1444 AvatarURL: String("a"), 1445 GravatarID: String("g"), 1446 Name: String("n"), 1447 Company: String("c"), 1448 Blog: String("b"), 1449 Location: String("l"), 1450 Email: String("e"), 1451 Hireable: Bool(true), 1452 Bio: String("b"), 1453 TwitterUsername: String("t"), 1454 PublicRepos: Int(1), 1455 Followers: Int(1), 1456 Following: Int(1), 1457 CreatedAt: &Timestamp{referenceTime}, 1458 SuspendedAt: &Timestamp{referenceTime}, 1459 }, 1460 SuspendedAt: &Timestamp{referenceTime}, 1461 }, 1462 Organization: &Organization{ 1463 BillingEmail: String("be"), 1464 Blog: String("b"), 1465 Company: String("c"), 1466 Email: String("e"), 1467 TwitterUsername: String("tu"), 1468 Location: String("loc"), 1469 Name: String("n"), 1470 Description: String("d"), 1471 IsVerified: Bool(true), 1472 HasOrganizationProjects: Bool(true), 1473 HasRepositoryProjects: Bool(true), 1474 DefaultRepoPermission: String("drp"), 1475 MembersCanCreateRepos: Bool(true), 1476 MembersCanCreateInternalRepos: Bool(true), 1477 MembersCanCreatePrivateRepos: Bool(true), 1478 MembersCanCreatePublicRepos: Bool(false), 1479 MembersAllowedRepositoryCreationType: String("marct"), 1480 MembersCanCreatePages: Bool(true), 1481 MembersCanCreatePublicPages: Bool(false), 1482 MembersCanCreatePrivatePages: Bool(true), 1483 }, 1484 Repository: &Repository{ 1485 ID: Int64(1), 1486 URL: String("s"), 1487 Name: String("n"), 1488 }, 1489 Sender: &User{ 1490 Login: String("l"), 1491 ID: Int64(1), 1492 NodeID: String("n"), 1493 URL: String("u"), 1494 ReposURL: String("r"), 1495 EventsURL: String("e"), 1496 AvatarURL: String("a"), 1497 }, 1498 TargetType: String("running"), 1499 } 1500 1501 want := `{ 1502 "account": { 1503 "login": "u", 1504 "id": 1, 1505 "node_id": "n", 1506 "avatar_url": "l", 1507 "url": "u", 1508 "events_url": "e", 1509 "repos_url": "r" 1510 }, 1511 "action": "a", 1512 "changes": { 1513 "login": { 1514 "from": "p" 1515 }, 1516 "slug": { 1517 "from": "j" 1518 } 1519 }, 1520 "enterprise": { 1521 "id": 1, 1522 "slug": "s", 1523 "name": "n", 1524 "node_id": "nid", 1525 "avatar_url": "au", 1526 "description": "d", 1527 "website_url": "wu", 1528 "html_url": "hu", 1529 "created_at": ` + referenceTimeStr + `, 1530 "updated_at": ` + referenceTimeStr + ` 1531 }, 1532 "installation": { 1533 "id": 1, 1534 "node_id": "nid", 1535 "app_id": 1, 1536 "app_slug": "as", 1537 "target_id": 1, 1538 "account": { 1539 "login": "l", 1540 "id": 1, 1541 "avatar_url": "a", 1542 "gravatar_id": "g", 1543 "name": "n", 1544 "company": "c", 1545 "blog": "b", 1546 "location": "l", 1547 "email": "e", 1548 "hireable": true, 1549 "bio": "b", 1550 "twitter_username": "t", 1551 "public_repos": 1, 1552 "followers": 1, 1553 "following": 1, 1554 "created_at": ` + referenceTimeStr + `, 1555 "suspended_at": ` + referenceTimeStr + `, 1556 "url": "u" 1557 }, 1558 "access_tokens_url": "atu", 1559 "repositories_url": "ru", 1560 "html_url": "hu", 1561 "target_type": "tt", 1562 "single_file_name": "sfn", 1563 "repository_selection": "rs", 1564 "events": [ 1565 "e" 1566 ], 1567 "single_file_paths": [ 1568 "s" 1569 ], 1570 "permissions": { 1571 "actions": "a", 1572 "administration": "ad", 1573 "checks": "c", 1574 "contents": "co", 1575 "content_references": "cr", 1576 "deployments": "d", 1577 "environments": "e", 1578 "issues": "i", 1579 "metadata": "md", 1580 "members": "m", 1581 "organization_administration": "oa", 1582 "organization_hooks": "oh", 1583 "organization_plan": "op", 1584 "organization_pre_receive_hooks": "opr", 1585 "organization_projects": "op", 1586 "organization_secrets": "os", 1587 "organization_self_hosted_runners": "osh", 1588 "organization_user_blocking": "oub", 1589 "packages": "pkg", 1590 "pages": "pg", 1591 "pull_requests": "pr", 1592 "repository_hooks": "rh", 1593 "repository_projects": "rp", 1594 "repository_pre_receive_hooks": "rprh", 1595 "secrets": "s", 1596 "secret_scanning_alerts": "ssa", 1597 "security_events": "se", 1598 "single_file": "sf", 1599 "statuses": "s", 1600 "team_discussions": "td", 1601 "vulnerability_alerts": "va", 1602 "workflows": "w" 1603 }, 1604 "created_at": ` + referenceTimeStr + `, 1605 "updated_at": ` + referenceTimeStr + `, 1606 "has_multiple_single_files": false, 1607 "suspended_by": { 1608 "login": "l", 1609 "id": 1, 1610 "avatar_url": "a", 1611 "gravatar_id": "g", 1612 "name": "n", 1613 "company": "c", 1614 "blog": "b", 1615 "location": "l", 1616 "email": "e", 1617 "hireable": true, 1618 "bio": "b", 1619 "twitter_username": "t", 1620 "public_repos": 1, 1621 "followers": 1, 1622 "following": 1, 1623 "created_at": ` + referenceTimeStr + `, 1624 "suspended_at": ` + referenceTimeStr + `, 1625 "url": "u" 1626 }, 1627 "suspended_at": ` + referenceTimeStr + ` 1628 }, 1629 "organization": { 1630 "name": "n", 1631 "company": "c", 1632 "blog": "b", 1633 "location": "loc", 1634 "email": "e", 1635 "twitter_username": "tu", 1636 "description": "d", 1637 "billing_email": "be", 1638 "is_verified": true, 1639 "has_organization_projects": true, 1640 "has_repository_projects": true, 1641 "default_repository_permission": "drp", 1642 "members_can_create_repositories": true, 1643 "members_can_create_public_repositories": false, 1644 "members_can_create_private_repositories": true, 1645 "members_can_create_internal_repositories": true, 1646 "members_allowed_repository_creation_type": "marct", 1647 "members_can_create_pages": true, 1648 "members_can_create_public_pages": false, 1649 "members_can_create_private_pages": true 1650 }, 1651 "repository": { 1652 "id": 1, 1653 "url": "s", 1654 "name": "n" 1655 }, 1656 "sender": { 1657 "login": "l", 1658 "id": 1, 1659 "node_id": "n", 1660 "avatar_url": "a", 1661 "url": "u", 1662 "events_url": "e", 1663 "repos_url": "r" 1664 }, 1665 "target_type": "running" 1666 }` 1667 1668 testJSONMarshal(t, u, want) 1669 } 1670 1671 func TestEditTitle_Marshal(t *testing.T) { 1672 testJSONMarshal(t, &EditTitle{}, "{}") 1673 1674 u := &EditTitle{ 1675 From: String("EditTitleFrom"), 1676 } 1677 1678 want := `{ 1679 "from": "EditTitleFrom" 1680 }` 1681 1682 testJSONMarshal(t, u, want) 1683 } 1684 1685 func TestEditBody_Marshal(t *testing.T) { 1686 testJSONMarshal(t, &EditBody{}, "{}") 1687 1688 u := &EditBody{ 1689 From: String("EditBodyFrom"), 1690 } 1691 1692 want := `{ 1693 "from": "EditBodyFrom" 1694 }` 1695 1696 testJSONMarshal(t, u, want) 1697 } 1698 1699 func TestEditBase_Marshal(t *testing.T) { 1700 testJSONMarshal(t, &EditBase{}, "{}") 1701 1702 u := &EditBase{ 1703 Ref: &EditRef{ 1704 From: String("EditRefFrom"), 1705 }, 1706 SHA: &EditSHA{ 1707 From: String("EditSHAFrom"), 1708 }, 1709 } 1710 1711 want := `{ 1712 "ref": { 1713 "from": "EditRefFrom" 1714 }, 1715 "sha": { 1716 "from": "EditSHAFrom" 1717 } 1718 }` 1719 1720 testJSONMarshal(t, u, want) 1721 } 1722 1723 func TestEditRef_Marshal(t *testing.T) { 1724 testJSONMarshal(t, &EditRef{}, "{}") 1725 1726 u := &EditRef{ 1727 From: String("EditRefFrom"), 1728 } 1729 1730 want := `{ 1731 "from": "EditRefFrom" 1732 }` 1733 1734 testJSONMarshal(t, u, want) 1735 } 1736 1737 func TestEditSHA_Marshal(t *testing.T) { 1738 testJSONMarshal(t, &EditSHA{}, "{}") 1739 1740 u := &EditSHA{ 1741 From: String("EditSHAFrom"), 1742 } 1743 1744 want := `{ 1745 "from": "EditSHAFrom" 1746 }` 1747 1748 testJSONMarshal(t, u, want) 1749 } 1750 1751 func TestProjectName_Marshal(t *testing.T) { 1752 testJSONMarshal(t, &ProjectName{}, "{}") 1753 1754 u := &ProjectName{ 1755 From: String("ProjectNameFrom"), 1756 } 1757 1758 want := `{ 1759 "from": "ProjectNameFrom" 1760 }` 1761 1762 testJSONMarshal(t, u, want) 1763 } 1764 1765 func TestProjectBody_Marshal(t *testing.T) { 1766 testJSONMarshal(t, &ProjectBody{}, "{}") 1767 1768 u := &ProjectBody{ 1769 From: String("ProjectBodyFrom"), 1770 } 1771 1772 want := `{ 1773 "from": "ProjectBodyFrom" 1774 }` 1775 1776 testJSONMarshal(t, u, want) 1777 } 1778 1779 func TestProjectCardNote_Marshal(t *testing.T) { 1780 testJSONMarshal(t, &ProjectCardNote{}, "{}") 1781 1782 u := &ProjectCardNote{ 1783 From: String("ProjectCardNoteFrom"), 1784 } 1785 1786 want := `{ 1787 "from": "ProjectCardNoteFrom" 1788 }` 1789 1790 testJSONMarshal(t, u, want) 1791 } 1792 1793 func TestProjectColumnName_Marshal(t *testing.T) { 1794 testJSONMarshal(t, &ProjectColumnName{}, "{}") 1795 1796 u := &ProjectColumnName{ 1797 From: String("ProjectColumnNameFrom"), 1798 } 1799 1800 want := `{ 1801 "from": "ProjectColumnNameFrom" 1802 }` 1803 1804 testJSONMarshal(t, u, want) 1805 } 1806 1807 func TestTeamDescription_Marshal(t *testing.T) { 1808 testJSONMarshal(t, &TeamDescription{}, "{}") 1809 1810 u := &TeamDescription{ 1811 From: String("TeamDescriptionFrom"), 1812 } 1813 1814 want := `{ 1815 "from": "TeamDescriptionFrom" 1816 }` 1817 1818 testJSONMarshal(t, u, want) 1819 } 1820 1821 func TestTeamName_Marshal(t *testing.T) { 1822 testJSONMarshal(t, &TeamName{}, "{}") 1823 1824 u := &TeamName{ 1825 From: String("TeamNameFrom"), 1826 } 1827 1828 want := `{ 1829 "from": "TeamNameFrom" 1830 }` 1831 1832 testJSONMarshal(t, u, want) 1833 } 1834 1835 func TestTeamPrivacy_Marshal(t *testing.T) { 1836 testJSONMarshal(t, &TeamPrivacy{}, "{}") 1837 1838 u := &TeamPrivacy{ 1839 From: String("TeamPrivacyFrom"), 1840 } 1841 1842 want := `{ 1843 "from": "TeamPrivacyFrom" 1844 }` 1845 1846 testJSONMarshal(t, u, want) 1847 } 1848 1849 func TestTeamRepository_Marshal(t *testing.T) { 1850 testJSONMarshal(t, &TeamRepository{}, "{}") 1851 1852 u := &TeamRepository{ 1853 Permissions: &TeamPermissions{ 1854 From: &TeamPermissionsFrom{ 1855 Admin: Bool(true), 1856 Pull: Bool(true), 1857 Push: Bool(true), 1858 }, 1859 }, 1860 } 1861 1862 want := `{ 1863 "permissions": { 1864 "from": { 1865 "admin": true, 1866 "pull": true, 1867 "push": true 1868 } 1869 } 1870 }` 1871 1872 testJSONMarshal(t, u, want) 1873 } 1874 1875 func TestTeamPermissions_Marshal(t *testing.T) { 1876 testJSONMarshal(t, &TeamPermissions{}, "{}") 1877 1878 u := &TeamPermissions{ 1879 From: &TeamPermissionsFrom{ 1880 Admin: Bool(true), 1881 Pull: Bool(true), 1882 Push: Bool(true), 1883 }, 1884 } 1885 1886 want := `{ 1887 "from": { 1888 "admin": true, 1889 "pull": true, 1890 "push": true 1891 } 1892 }` 1893 1894 testJSONMarshal(t, u, want) 1895 } 1896 1897 func TestTeamPermissionsFrom_Marshal(t *testing.T) { 1898 testJSONMarshal(t, &TeamPermissionsFrom{}, "{}") 1899 1900 u := &TeamPermissionsFrom{ 1901 Admin: Bool(true), 1902 Pull: Bool(true), 1903 Push: Bool(true), 1904 } 1905 1906 want := `{ 1907 "admin": true, 1908 "pull": true, 1909 "push": true 1910 }` 1911 1912 testJSONMarshal(t, u, want) 1913 } 1914 1915 func TestRepositoryVulnerabilityAlert_Marshal(t *testing.T) { 1916 testJSONMarshal(t, &RepositoryVulnerabilityAlert{}, "{}") 1917 1918 u := &RepositoryVulnerabilityAlert{ 1919 ID: Int64(1), 1920 AffectedRange: String("ar"), 1921 AffectedPackageName: String("apn"), 1922 ExternalReference: String("er"), 1923 ExternalIdentifier: String("ei"), 1924 FixedIn: String("fi"), 1925 Dismisser: &User{ 1926 Login: String("l"), 1927 ID: Int64(1), 1928 NodeID: String("n"), 1929 URL: String("u"), 1930 ReposURL: String("r"), 1931 EventsURL: String("e"), 1932 AvatarURL: String("a"), 1933 }, 1934 DismissReason: String("dr"), 1935 DismissedAt: &Timestamp{referenceTime}, 1936 } 1937 1938 want := `{ 1939 "id": 1, 1940 "affected_range": "ar", 1941 "affected_package_name": "apn", 1942 "external_reference": "er", 1943 "external_identifier": "ei", 1944 "fixed_in": "fi", 1945 "dismisser": { 1946 "login": "l", 1947 "id": 1, 1948 "node_id": "n", 1949 "avatar_url": "a", 1950 "url": "u", 1951 "events_url": "e", 1952 "repos_url": "r" 1953 }, 1954 "dismiss_reason": "dr", 1955 "dismissed_at": ` + referenceTimeStr + ` 1956 }` 1957 1958 testJSONMarshal(t, u, want) 1959 } 1960 1961 func TestPage_Marshal(t *testing.T) { 1962 testJSONMarshal(t, &Page{}, "{}") 1963 1964 u := &Page{ 1965 PageName: String("p"), 1966 Title: String("t"), 1967 Summary: String("s"), 1968 Action: String("a"), 1969 SHA: String("s"), 1970 HTMLURL: String("h"), 1971 } 1972 1973 want := `{ 1974 "page_name": "p", 1975 "title": "t", 1976 "summary": "s", 1977 "action": "a", 1978 "sha": "s", 1979 "html_url": "h" 1980 }` 1981 1982 testJSONMarshal(t, u, want) 1983 } 1984 1985 func TestTeamChange_Marshal(t *testing.T) { 1986 testJSONMarshal(t, &TeamChange{}, "{}") 1987 1988 u := &TeamChange{ 1989 Description: &TeamDescription{ 1990 From: String("DescriptionFrom"), 1991 }, 1992 Name: &TeamName{ 1993 From: String("NameFrom"), 1994 }, 1995 Privacy: &TeamPrivacy{ 1996 From: String("PrivacyFrom"), 1997 }, 1998 Repository: &TeamRepository{ 1999 Permissions: &TeamPermissions{ 2000 From: &TeamPermissionsFrom{ 2001 Admin: Bool(false), 2002 Pull: Bool(false), 2003 Push: Bool(false), 2004 }, 2005 }, 2006 }, 2007 } 2008 2009 want := `{ 2010 "description": { 2011 "from": "DescriptionFrom" 2012 }, 2013 "name": { 2014 "from": "NameFrom" 2015 }, 2016 "privacy": { 2017 "from": "PrivacyFrom" 2018 }, 2019 "repository": { 2020 "permissions": { 2021 "from": { 2022 "admin": false, 2023 "pull": false, 2024 "push": false 2025 } 2026 } 2027 } 2028 }` 2029 2030 testJSONMarshal(t, u, want) 2031 } 2032 2033 func TestIssueCommentEvent_Marshal(t *testing.T) { 2034 testJSONMarshal(t, &IssueCommentEvent{}, "{}") 2035 2036 u := &IssueCommentEvent{ 2037 Action: String("a"), 2038 Issue: &Issue{ID: Int64(1)}, 2039 Comment: &IssueComment{ID: Int64(1)}, 2040 Changes: &EditChange{ 2041 Title: &EditTitle{ 2042 From: String("TitleFrom"), 2043 }, 2044 Body: &EditBody{ 2045 From: String("BodyFrom"), 2046 }, 2047 Base: &EditBase{ 2048 Ref: &EditRef{ 2049 From: String("BaseRefFrom"), 2050 }, 2051 SHA: &EditSHA{ 2052 From: String("BaseSHAFrom"), 2053 }, 2054 }, 2055 }, 2056 Repo: &Repository{ 2057 ID: Int64(1), 2058 URL: String("s"), 2059 Name: String("n"), 2060 }, 2061 Sender: &User{ 2062 Login: String("l"), 2063 ID: Int64(1), 2064 NodeID: String("n"), 2065 URL: String("u"), 2066 ReposURL: String("r"), 2067 EventsURL: String("e"), 2068 AvatarURL: String("a"), 2069 }, 2070 Installation: &Installation{ 2071 ID: Int64(1), 2072 NodeID: String("nid"), 2073 AppID: Int64(1), 2074 AppSlug: String("as"), 2075 TargetID: Int64(1), 2076 Account: &User{ 2077 Login: String("l"), 2078 ID: Int64(1), 2079 URL: String("u"), 2080 AvatarURL: String("a"), 2081 GravatarID: String("g"), 2082 Name: String("n"), 2083 Company: String("c"), 2084 Blog: String("b"), 2085 Location: String("l"), 2086 Email: String("e"), 2087 Hireable: Bool(true), 2088 Bio: String("b"), 2089 TwitterUsername: String("t"), 2090 PublicRepos: Int(1), 2091 Followers: Int(1), 2092 Following: Int(1), 2093 CreatedAt: &Timestamp{referenceTime}, 2094 SuspendedAt: &Timestamp{referenceTime}, 2095 }, 2096 AccessTokensURL: String("atu"), 2097 RepositoriesURL: String("ru"), 2098 HTMLURL: String("hu"), 2099 TargetType: String("tt"), 2100 SingleFileName: String("sfn"), 2101 RepositorySelection: String("rs"), 2102 Events: []string{"e"}, 2103 SingleFilePaths: []string{"s"}, 2104 Permissions: &InstallationPermissions{ 2105 Actions: String("a"), 2106 Administration: String("ad"), 2107 Checks: String("c"), 2108 Contents: String("co"), 2109 ContentReferences: String("cr"), 2110 Deployments: String("d"), 2111 Environments: String("e"), 2112 Issues: String("i"), 2113 Metadata: String("md"), 2114 Members: String("m"), 2115 OrganizationAdministration: String("oa"), 2116 OrganizationHooks: String("oh"), 2117 OrganizationPlan: String("op"), 2118 OrganizationPreReceiveHooks: String("opr"), 2119 OrganizationProjects: String("op"), 2120 OrganizationSecrets: String("os"), 2121 OrganizationSelfHostedRunners: String("osh"), 2122 OrganizationUserBlocking: String("oub"), 2123 Packages: String("pkg"), 2124 Pages: String("pg"), 2125 PullRequests: String("pr"), 2126 RepositoryHooks: String("rh"), 2127 RepositoryProjects: String("rp"), 2128 RepositoryPreReceiveHooks: String("rprh"), 2129 Secrets: String("s"), 2130 SecretScanningAlerts: String("ssa"), 2131 SecurityEvents: String("se"), 2132 SingleFile: String("sf"), 2133 Statuses: String("s"), 2134 TeamDiscussions: String("td"), 2135 VulnerabilityAlerts: String("va"), 2136 Workflows: String("w"), 2137 }, 2138 CreatedAt: &Timestamp{referenceTime}, 2139 UpdatedAt: &Timestamp{referenceTime}, 2140 HasMultipleSingleFiles: Bool(false), 2141 SuspendedBy: &User{ 2142 Login: String("l"), 2143 ID: Int64(1), 2144 URL: String("u"), 2145 AvatarURL: String("a"), 2146 GravatarID: String("g"), 2147 Name: String("n"), 2148 Company: String("c"), 2149 Blog: String("b"), 2150 Location: String("l"), 2151 Email: String("e"), 2152 Hireable: Bool(true), 2153 Bio: String("b"), 2154 TwitterUsername: String("t"), 2155 PublicRepos: Int(1), 2156 Followers: Int(1), 2157 Following: Int(1), 2158 CreatedAt: &Timestamp{referenceTime}, 2159 SuspendedAt: &Timestamp{referenceTime}, 2160 }, 2161 SuspendedAt: &Timestamp{referenceTime}, 2162 }, 2163 Organization: &Organization{ 2164 BillingEmail: String("be"), 2165 Blog: String("b"), 2166 Company: String("c"), 2167 Email: String("e"), 2168 TwitterUsername: String("tu"), 2169 Location: String("loc"), 2170 Name: String("n"), 2171 Description: String("d"), 2172 IsVerified: Bool(true), 2173 HasOrganizationProjects: Bool(true), 2174 HasRepositoryProjects: Bool(true), 2175 DefaultRepoPermission: String("drp"), 2176 MembersCanCreateRepos: Bool(true), 2177 MembersCanCreateInternalRepos: Bool(true), 2178 MembersCanCreatePrivateRepos: Bool(true), 2179 MembersCanCreatePublicRepos: Bool(false), 2180 MembersAllowedRepositoryCreationType: String("marct"), 2181 MembersCanCreatePages: Bool(true), 2182 MembersCanCreatePublicPages: Bool(false), 2183 MembersCanCreatePrivatePages: Bool(true), 2184 }, 2185 } 2186 2187 want := `{ 2188 "action": "a", 2189 "issue": { 2190 "id": 1 2191 }, 2192 "comment": { 2193 "id": 1 2194 }, 2195 "changes": { 2196 "title": { 2197 "from": "TitleFrom" 2198 }, 2199 "body": { 2200 "from": "BodyFrom" 2201 }, 2202 "base": { 2203 "ref": { 2204 "from": "BaseRefFrom" 2205 }, 2206 "sha": { 2207 "from": "BaseSHAFrom" 2208 } 2209 } 2210 }, 2211 "repository": { 2212 "id": 1, 2213 "name": "n", 2214 "url": "s" 2215 }, 2216 "sender": { 2217 "login": "l", 2218 "id": 1, 2219 "node_id": "n", 2220 "avatar_url": "a", 2221 "url": "u", 2222 "events_url": "e", 2223 "repos_url": "r" 2224 }, 2225 "installation": { 2226 "id": 1, 2227 "node_id": "nid", 2228 "app_id": 1, 2229 "app_slug": "as", 2230 "target_id": 1, 2231 "account": { 2232 "login": "l", 2233 "id": 1, 2234 "avatar_url": "a", 2235 "gravatar_id": "g", 2236 "name": "n", 2237 "company": "c", 2238 "blog": "b", 2239 "location": "l", 2240 "email": "e", 2241 "hireable": true, 2242 "bio": "b", 2243 "twitter_username": "t", 2244 "public_repos": 1, 2245 "followers": 1, 2246 "following": 1, 2247 "created_at": ` + referenceTimeStr + `, 2248 "suspended_at": ` + referenceTimeStr + `, 2249 "url": "u" 2250 }, 2251 "access_tokens_url": "atu", 2252 "repositories_url": "ru", 2253 "html_url": "hu", 2254 "target_type": "tt", 2255 "single_file_name": "sfn", 2256 "repository_selection": "rs", 2257 "events": [ 2258 "e" 2259 ], 2260 "single_file_paths": [ 2261 "s" 2262 ], 2263 "permissions": { 2264 "actions": "a", 2265 "administration": "ad", 2266 "checks": "c", 2267 "contents": "co", 2268 "content_references": "cr", 2269 "deployments": "d", 2270 "environments": "e", 2271 "issues": "i", 2272 "metadata": "md", 2273 "members": "m", 2274 "organization_administration": "oa", 2275 "organization_hooks": "oh", 2276 "organization_plan": "op", 2277 "organization_pre_receive_hooks": "opr", 2278 "organization_projects": "op", 2279 "organization_secrets": "os", 2280 "organization_self_hosted_runners": "osh", 2281 "organization_user_blocking": "oub", 2282 "packages": "pkg", 2283 "pages": "pg", 2284 "pull_requests": "pr", 2285 "repository_hooks": "rh", 2286 "repository_projects": "rp", 2287 "repository_pre_receive_hooks": "rprh", 2288 "secrets": "s", 2289 "secret_scanning_alerts": "ssa", 2290 "security_events": "se", 2291 "single_file": "sf", 2292 "statuses": "s", 2293 "team_discussions": "td", 2294 "vulnerability_alerts": "va", 2295 "workflows": "w" 2296 }, 2297 "created_at": ` + referenceTimeStr + `, 2298 "updated_at": ` + referenceTimeStr + `, 2299 "has_multiple_single_files": false, 2300 "suspended_by": { 2301 "login": "l", 2302 "id": 1, 2303 "avatar_url": "a", 2304 "gravatar_id": "g", 2305 "name": "n", 2306 "company": "c", 2307 "blog": "b", 2308 "location": "l", 2309 "email": "e", 2310 "hireable": true, 2311 "bio": "b", 2312 "twitter_username": "t", 2313 "public_repos": 1, 2314 "followers": 1, 2315 "following": 1, 2316 "created_at": ` + referenceTimeStr + `, 2317 "suspended_at": ` + referenceTimeStr + `, 2318 "url": "u" 2319 }, 2320 "suspended_at": ` + referenceTimeStr + ` 2321 }, 2322 "organization": { 2323 "name": "n", 2324 "company": "c", 2325 "blog": "b", 2326 "location": "loc", 2327 "email": "e", 2328 "twitter_username": "tu", 2329 "description": "d", 2330 "billing_email": "be", 2331 "is_verified": true, 2332 "has_organization_projects": true, 2333 "has_repository_projects": true, 2334 "default_repository_permission": "drp", 2335 "members_can_create_repositories": true, 2336 "members_can_create_public_repositories": false, 2337 "members_can_create_private_repositories": true, 2338 "members_can_create_internal_repositories": true, 2339 "members_allowed_repository_creation_type": "marct", 2340 "members_can_create_pages": true, 2341 "members_can_create_public_pages": false, 2342 "members_can_create_private_pages": true 2343 } 2344 }` 2345 2346 testJSONMarshal(t, u, want) 2347 } 2348 2349 func TestIssuesEvent_Marshal(t *testing.T) { 2350 testJSONMarshal(t, &IssuesEvent{}, "{}") 2351 2352 u := &IssuesEvent{ 2353 Action: String("a"), 2354 Issue: &Issue{ID: Int64(1)}, 2355 Assignee: &User{ 2356 Login: String("l"), 2357 ID: Int64(1), 2358 NodeID: String("n"), 2359 URL: String("u"), 2360 ReposURL: String("r"), 2361 EventsURL: String("e"), 2362 AvatarURL: String("a"), 2363 }, 2364 Label: &Label{ID: Int64(1)}, 2365 Changes: &EditChange{ 2366 Title: &EditTitle{ 2367 From: String("TitleFrom"), 2368 }, 2369 Body: &EditBody{ 2370 From: String("BodyFrom"), 2371 }, 2372 Base: &EditBase{ 2373 Ref: &EditRef{ 2374 From: String("BaseRefFrom"), 2375 }, 2376 SHA: &EditSHA{ 2377 From: String("BaseSHAFrom"), 2378 }, 2379 }, 2380 }, 2381 Repo: &Repository{ 2382 ID: Int64(1), 2383 URL: String("s"), 2384 Name: String("n"), 2385 }, 2386 Sender: &User{ 2387 Login: String("l"), 2388 ID: Int64(1), 2389 NodeID: String("n"), 2390 URL: String("u"), 2391 ReposURL: String("r"), 2392 EventsURL: String("e"), 2393 AvatarURL: String("a"), 2394 }, 2395 Installation: &Installation{ 2396 ID: Int64(1), 2397 NodeID: String("nid"), 2398 AppID: Int64(1), 2399 AppSlug: String("as"), 2400 TargetID: Int64(1), 2401 Account: &User{ 2402 Login: String("l"), 2403 ID: Int64(1), 2404 URL: String("u"), 2405 AvatarURL: String("a"), 2406 GravatarID: String("g"), 2407 Name: String("n"), 2408 Company: String("c"), 2409 Blog: String("b"), 2410 Location: String("l"), 2411 Email: String("e"), 2412 Hireable: Bool(true), 2413 Bio: String("b"), 2414 TwitterUsername: String("t"), 2415 PublicRepos: Int(1), 2416 Followers: Int(1), 2417 Following: Int(1), 2418 CreatedAt: &Timestamp{referenceTime}, 2419 SuspendedAt: &Timestamp{referenceTime}, 2420 }, 2421 AccessTokensURL: String("atu"), 2422 RepositoriesURL: String("ru"), 2423 HTMLURL: String("hu"), 2424 TargetType: String("tt"), 2425 SingleFileName: String("sfn"), 2426 RepositorySelection: String("rs"), 2427 Events: []string{"e"}, 2428 SingleFilePaths: []string{"s"}, 2429 Permissions: &InstallationPermissions{ 2430 Actions: String("a"), 2431 Administration: String("ad"), 2432 Checks: String("c"), 2433 Contents: String("co"), 2434 ContentReferences: String("cr"), 2435 Deployments: String("d"), 2436 Environments: String("e"), 2437 Issues: String("i"), 2438 Metadata: String("md"), 2439 Members: String("m"), 2440 OrganizationAdministration: String("oa"), 2441 OrganizationHooks: String("oh"), 2442 OrganizationPlan: String("op"), 2443 OrganizationPreReceiveHooks: String("opr"), 2444 OrganizationProjects: String("op"), 2445 OrganizationSecrets: String("os"), 2446 OrganizationSelfHostedRunners: String("osh"), 2447 OrganizationUserBlocking: String("oub"), 2448 Packages: String("pkg"), 2449 Pages: String("pg"), 2450 PullRequests: String("pr"), 2451 RepositoryHooks: String("rh"), 2452 RepositoryProjects: String("rp"), 2453 RepositoryPreReceiveHooks: String("rprh"), 2454 Secrets: String("s"), 2455 SecretScanningAlerts: String("ssa"), 2456 SecurityEvents: String("se"), 2457 SingleFile: String("sf"), 2458 Statuses: String("s"), 2459 TeamDiscussions: String("td"), 2460 VulnerabilityAlerts: String("va"), 2461 Workflows: String("w"), 2462 }, 2463 CreatedAt: &Timestamp{referenceTime}, 2464 UpdatedAt: &Timestamp{referenceTime}, 2465 HasMultipleSingleFiles: Bool(false), 2466 SuspendedBy: &User{ 2467 Login: String("l"), 2468 ID: Int64(1), 2469 URL: String("u"), 2470 AvatarURL: String("a"), 2471 GravatarID: String("g"), 2472 Name: String("n"), 2473 Company: String("c"), 2474 Blog: String("b"), 2475 Location: String("l"), 2476 Email: String("e"), 2477 Hireable: Bool(true), 2478 Bio: String("b"), 2479 TwitterUsername: String("t"), 2480 PublicRepos: Int(1), 2481 Followers: Int(1), 2482 Following: Int(1), 2483 CreatedAt: &Timestamp{referenceTime}, 2484 SuspendedAt: &Timestamp{referenceTime}, 2485 }, 2486 SuspendedAt: &Timestamp{referenceTime}, 2487 }, 2488 } 2489 2490 want := `{ 2491 "action": "a", 2492 "issue": { 2493 "id": 1 2494 }, 2495 "assignee": { 2496 "login": "l", 2497 "id": 1, 2498 "node_id": "n", 2499 "avatar_url": "a", 2500 "url": "u", 2501 "events_url": "e", 2502 "repos_url": "r" 2503 }, 2504 "label": { 2505 "id": 1 2506 }, 2507 "changes": { 2508 "title": { 2509 "from": "TitleFrom" 2510 }, 2511 "body": { 2512 "from": "BodyFrom" 2513 }, 2514 "base": { 2515 "ref": { 2516 "from": "BaseRefFrom" 2517 }, 2518 "sha": { 2519 "from": "BaseSHAFrom" 2520 } 2521 } 2522 }, 2523 "repository": { 2524 "id": 1, 2525 "name": "n", 2526 "url": "s" 2527 }, 2528 "sender": { 2529 "login": "l", 2530 "id": 1, 2531 "node_id": "n", 2532 "avatar_url": "a", 2533 "url": "u", 2534 "events_url": "e", 2535 "repos_url": "r" 2536 }, 2537 "installation": { 2538 "id": 1, 2539 "node_id": "nid", 2540 "app_id": 1, 2541 "app_slug": "as", 2542 "target_id": 1, 2543 "account": { 2544 "login": "l", 2545 "id": 1, 2546 "avatar_url": "a", 2547 "gravatar_id": "g", 2548 "name": "n", 2549 "company": "c", 2550 "blog": "b", 2551 "location": "l", 2552 "email": "e", 2553 "hireable": true, 2554 "bio": "b", 2555 "twitter_username": "t", 2556 "public_repos": 1, 2557 "followers": 1, 2558 "following": 1, 2559 "created_at": ` + referenceTimeStr + `, 2560 "suspended_at": ` + referenceTimeStr + `, 2561 "url": "u" 2562 }, 2563 "access_tokens_url": "atu", 2564 "repositories_url": "ru", 2565 "html_url": "hu", 2566 "target_type": "tt", 2567 "single_file_name": "sfn", 2568 "repository_selection": "rs", 2569 "events": [ 2570 "e" 2571 ], 2572 "single_file_paths": [ 2573 "s" 2574 ], 2575 "permissions": { 2576 "actions": "a", 2577 "administration": "ad", 2578 "checks": "c", 2579 "contents": "co", 2580 "content_references": "cr", 2581 "deployments": "d", 2582 "environments": "e", 2583 "issues": "i", 2584 "metadata": "md", 2585 "members": "m", 2586 "organization_administration": "oa", 2587 "organization_hooks": "oh", 2588 "organization_plan": "op", 2589 "organization_pre_receive_hooks": "opr", 2590 "organization_projects": "op", 2591 "organization_secrets": "os", 2592 "organization_self_hosted_runners": "osh", 2593 "organization_user_blocking": "oub", 2594 "packages": "pkg", 2595 "pages": "pg", 2596 "pull_requests": "pr", 2597 "repository_hooks": "rh", 2598 "repository_projects": "rp", 2599 "repository_pre_receive_hooks": "rprh", 2600 "secrets": "s", 2601 "secret_scanning_alerts": "ssa", 2602 "security_events": "se", 2603 "single_file": "sf", 2604 "statuses": "s", 2605 "team_discussions": "td", 2606 "vulnerability_alerts": "va", 2607 "workflows": "w" 2608 }, 2609 "created_at": ` + referenceTimeStr + `, 2610 "updated_at": ` + referenceTimeStr + `, 2611 "has_multiple_single_files": false, 2612 "suspended_by": { 2613 "login": "l", 2614 "id": 1, 2615 "avatar_url": "a", 2616 "gravatar_id": "g", 2617 "name": "n", 2618 "company": "c", 2619 "blog": "b", 2620 "location": "l", 2621 "email": "e", 2622 "hireable": true, 2623 "bio": "b", 2624 "twitter_username": "t", 2625 "public_repos": 1, 2626 "followers": 1, 2627 "following": 1, 2628 "created_at": ` + referenceTimeStr + `, 2629 "suspended_at": ` + referenceTimeStr + `, 2630 "url": "u" 2631 }, 2632 "suspended_at": ` + referenceTimeStr + ` 2633 } 2634 }` 2635 2636 testJSONMarshal(t, u, want) 2637 } 2638 2639 func TestLabelEvent_Marshal(t *testing.T) { 2640 testJSONMarshal(t, &LabelEvent{}, "{}") 2641 2642 u := &LabelEvent{ 2643 Action: String("a"), 2644 Label: &Label{ID: Int64(1)}, 2645 Changes: &EditChange{ 2646 Title: &EditTitle{ 2647 From: String("TitleFrom"), 2648 }, 2649 Body: &EditBody{ 2650 From: String("BodyFrom"), 2651 }, 2652 Base: &EditBase{ 2653 Ref: &EditRef{ 2654 From: String("BaseRefFrom"), 2655 }, 2656 SHA: &EditSHA{ 2657 From: String("BaseSHAFrom"), 2658 }, 2659 }, 2660 }, 2661 Repo: &Repository{ 2662 ID: Int64(1), 2663 URL: String("s"), 2664 Name: String("n"), 2665 }, 2666 Org: &Organization{ 2667 BillingEmail: String("be"), 2668 Blog: String("b"), 2669 Company: String("c"), 2670 Email: String("e"), 2671 TwitterUsername: String("tu"), 2672 Location: String("loc"), 2673 Name: String("n"), 2674 Description: String("d"), 2675 IsVerified: Bool(true), 2676 HasOrganizationProjects: Bool(true), 2677 HasRepositoryProjects: Bool(true), 2678 DefaultRepoPermission: String("drp"), 2679 MembersCanCreateRepos: Bool(true), 2680 MembersCanCreateInternalRepos: Bool(true), 2681 MembersCanCreatePrivateRepos: Bool(true), 2682 MembersCanCreatePublicRepos: Bool(false), 2683 MembersAllowedRepositoryCreationType: String("marct"), 2684 MembersCanCreatePages: Bool(true), 2685 MembersCanCreatePublicPages: Bool(false), 2686 MembersCanCreatePrivatePages: Bool(true), 2687 }, 2688 Installation: &Installation{ 2689 ID: Int64(1), 2690 NodeID: String("nid"), 2691 AppID: Int64(1), 2692 AppSlug: String("as"), 2693 TargetID: Int64(1), 2694 Account: &User{ 2695 Login: String("l"), 2696 ID: Int64(1), 2697 URL: String("u"), 2698 AvatarURL: String("a"), 2699 GravatarID: String("g"), 2700 Name: String("n"), 2701 Company: String("c"), 2702 Blog: String("b"), 2703 Location: String("l"), 2704 Email: String("e"), 2705 Hireable: Bool(true), 2706 Bio: String("b"), 2707 TwitterUsername: String("t"), 2708 PublicRepos: Int(1), 2709 Followers: Int(1), 2710 Following: Int(1), 2711 CreatedAt: &Timestamp{referenceTime}, 2712 SuspendedAt: &Timestamp{referenceTime}, 2713 }, 2714 AccessTokensURL: String("atu"), 2715 RepositoriesURL: String("ru"), 2716 HTMLURL: String("hu"), 2717 TargetType: String("tt"), 2718 SingleFileName: String("sfn"), 2719 RepositorySelection: String("rs"), 2720 Events: []string{"e"}, 2721 SingleFilePaths: []string{"s"}, 2722 Permissions: &InstallationPermissions{ 2723 Actions: String("a"), 2724 Administration: String("ad"), 2725 Checks: String("c"), 2726 Contents: String("co"), 2727 ContentReferences: String("cr"), 2728 Deployments: String("d"), 2729 Environments: String("e"), 2730 Issues: String("i"), 2731 Metadata: String("md"), 2732 Members: String("m"), 2733 OrganizationAdministration: String("oa"), 2734 OrganizationHooks: String("oh"), 2735 OrganizationPlan: String("op"), 2736 OrganizationPreReceiveHooks: String("opr"), 2737 OrganizationProjects: String("op"), 2738 OrganizationSecrets: String("os"), 2739 OrganizationSelfHostedRunners: String("osh"), 2740 OrganizationUserBlocking: String("oub"), 2741 Packages: String("pkg"), 2742 Pages: String("pg"), 2743 PullRequests: String("pr"), 2744 RepositoryHooks: String("rh"), 2745 RepositoryProjects: String("rp"), 2746 RepositoryPreReceiveHooks: String("rprh"), 2747 Secrets: String("s"), 2748 SecretScanningAlerts: String("ssa"), 2749 SecurityEvents: String("se"), 2750 SingleFile: String("sf"), 2751 Statuses: String("s"), 2752 TeamDiscussions: String("td"), 2753 VulnerabilityAlerts: String("va"), 2754 Workflows: String("w"), 2755 }, 2756 CreatedAt: &Timestamp{referenceTime}, 2757 UpdatedAt: &Timestamp{referenceTime}, 2758 HasMultipleSingleFiles: Bool(false), 2759 SuspendedBy: &User{ 2760 Login: String("l"), 2761 ID: Int64(1), 2762 URL: String("u"), 2763 AvatarURL: String("a"), 2764 GravatarID: String("g"), 2765 Name: String("n"), 2766 Company: String("c"), 2767 Blog: String("b"), 2768 Location: String("l"), 2769 Email: String("e"), 2770 Hireable: Bool(true), 2771 Bio: String("b"), 2772 TwitterUsername: String("t"), 2773 PublicRepos: Int(1), 2774 Followers: Int(1), 2775 Following: Int(1), 2776 CreatedAt: &Timestamp{referenceTime}, 2777 SuspendedAt: &Timestamp{referenceTime}, 2778 }, 2779 SuspendedAt: &Timestamp{referenceTime}, 2780 }, 2781 } 2782 2783 want := `{ 2784 "action": "a", 2785 "label": { 2786 "id": 1 2787 }, 2788 "changes": { 2789 "title": { 2790 "from": "TitleFrom" 2791 }, 2792 "body": { 2793 "from": "BodyFrom" 2794 }, 2795 "base": { 2796 "ref": { 2797 "from": "BaseRefFrom" 2798 }, 2799 "sha": { 2800 "from": "BaseSHAFrom" 2801 } 2802 } 2803 }, 2804 "repository": { 2805 "id": 1, 2806 "name": "n", 2807 "url": "s" 2808 }, 2809 "organization": { 2810 "name": "n", 2811 "company": "c", 2812 "blog": "b", 2813 "location": "loc", 2814 "email": "e", 2815 "twitter_username": "tu", 2816 "description": "d", 2817 "billing_email": "be", 2818 "is_verified": true, 2819 "has_organization_projects": true, 2820 "has_repository_projects": true, 2821 "default_repository_permission": "drp", 2822 "members_can_create_repositories": true, 2823 "members_can_create_public_repositories": false, 2824 "members_can_create_private_repositories": true, 2825 "members_can_create_internal_repositories": true, 2826 "members_allowed_repository_creation_type": "marct", 2827 "members_can_create_pages": true, 2828 "members_can_create_public_pages": false, 2829 "members_can_create_private_pages": true 2830 }, 2831 "installation": { 2832 "id": 1, 2833 "node_id": "nid", 2834 "app_id": 1, 2835 "app_slug": "as", 2836 "target_id": 1, 2837 "account": { 2838 "login": "l", 2839 "id": 1, 2840 "avatar_url": "a", 2841 "gravatar_id": "g", 2842 "name": "n", 2843 "company": "c", 2844 "blog": "b", 2845 "location": "l", 2846 "email": "e", 2847 "hireable": true, 2848 "bio": "b", 2849 "twitter_username": "t", 2850 "public_repos": 1, 2851 "followers": 1, 2852 "following": 1, 2853 "created_at": ` + referenceTimeStr + `, 2854 "suspended_at": ` + referenceTimeStr + `, 2855 "url": "u" 2856 }, 2857 "access_tokens_url": "atu", 2858 "repositories_url": "ru", 2859 "html_url": "hu", 2860 "target_type": "tt", 2861 "single_file_name": "sfn", 2862 "repository_selection": "rs", 2863 "events": [ 2864 "e" 2865 ], 2866 "single_file_paths": [ 2867 "s" 2868 ], 2869 "permissions": { 2870 "actions": "a", 2871 "administration": "ad", 2872 "checks": "c", 2873 "contents": "co", 2874 "content_references": "cr", 2875 "deployments": "d", 2876 "environments": "e", 2877 "issues": "i", 2878 "metadata": "md", 2879 "members": "m", 2880 "organization_administration": "oa", 2881 "organization_hooks": "oh", 2882 "organization_plan": "op", 2883 "organization_pre_receive_hooks": "opr", 2884 "organization_projects": "op", 2885 "organization_secrets": "os", 2886 "organization_self_hosted_runners": "osh", 2887 "organization_user_blocking": "oub", 2888 "packages": "pkg", 2889 "pages": "pg", 2890 "pull_requests": "pr", 2891 "repository_hooks": "rh", 2892 "repository_projects": "rp", 2893 "repository_pre_receive_hooks": "rprh", 2894 "secrets": "s", 2895 "secret_scanning_alerts": "ssa", 2896 "security_events": "se", 2897 "single_file": "sf", 2898 "statuses": "s", 2899 "team_discussions": "td", 2900 "vulnerability_alerts": "va", 2901 "workflows": "w" 2902 }, 2903 "created_at": ` + referenceTimeStr + `, 2904 "updated_at": ` + referenceTimeStr + `, 2905 "has_multiple_single_files": false, 2906 "suspended_by": { 2907 "login": "l", 2908 "id": 1, 2909 "avatar_url": "a", 2910 "gravatar_id": "g", 2911 "name": "n", 2912 "company": "c", 2913 "blog": "b", 2914 "location": "l", 2915 "email": "e", 2916 "hireable": true, 2917 "bio": "b", 2918 "twitter_username": "t", 2919 "public_repos": 1, 2920 "followers": 1, 2921 "following": 1, 2922 "created_at": ` + referenceTimeStr + `, 2923 "suspended_at": ` + referenceTimeStr + `, 2924 "url": "u" 2925 }, 2926 "suspended_at": ` + referenceTimeStr + ` 2927 } 2928 }` 2929 2930 testJSONMarshal(t, u, want) 2931 } 2932 2933 func TestMilestoneEvent_Marshal(t *testing.T) { 2934 testJSONMarshal(t, &MilestoneEvent{}, "{}") 2935 2936 u := &MilestoneEvent{ 2937 Action: String("a"), 2938 Milestone: &Milestone{ID: Int64(1)}, 2939 Changes: &EditChange{ 2940 Title: &EditTitle{ 2941 From: String("TitleFrom"), 2942 }, 2943 Body: &EditBody{ 2944 From: String("BodyFrom"), 2945 }, 2946 Base: &EditBase{ 2947 Ref: &EditRef{ 2948 From: String("BaseRefFrom"), 2949 }, 2950 SHA: &EditSHA{ 2951 From: String("BaseSHAFrom"), 2952 }, 2953 }, 2954 }, 2955 Repo: &Repository{ 2956 ID: Int64(1), 2957 URL: String("s"), 2958 Name: String("n"), 2959 }, 2960 Sender: &User{ 2961 Login: String("l"), 2962 ID: Int64(1), 2963 NodeID: String("n"), 2964 URL: String("u"), 2965 ReposURL: String("r"), 2966 EventsURL: String("e"), 2967 AvatarURL: String("a"), 2968 }, 2969 Org: &Organization{ 2970 BillingEmail: String("be"), 2971 Blog: String("b"), 2972 Company: String("c"), 2973 Email: String("e"), 2974 TwitterUsername: String("tu"), 2975 Location: String("loc"), 2976 Name: String("n"), 2977 Description: String("d"), 2978 IsVerified: Bool(true), 2979 HasOrganizationProjects: Bool(true), 2980 HasRepositoryProjects: Bool(true), 2981 DefaultRepoPermission: String("drp"), 2982 MembersCanCreateRepos: Bool(true), 2983 MembersCanCreateInternalRepos: Bool(true), 2984 MembersCanCreatePrivateRepos: Bool(true), 2985 MembersCanCreatePublicRepos: Bool(false), 2986 MembersAllowedRepositoryCreationType: String("marct"), 2987 MembersCanCreatePages: Bool(true), 2988 MembersCanCreatePublicPages: Bool(false), 2989 MembersCanCreatePrivatePages: Bool(true), 2990 }, 2991 Installation: &Installation{ 2992 ID: Int64(1), 2993 NodeID: String("nid"), 2994 AppID: Int64(1), 2995 AppSlug: String("as"), 2996 TargetID: Int64(1), 2997 Account: &User{ 2998 Login: String("l"), 2999 ID: Int64(1), 3000 URL: String("u"), 3001 AvatarURL: String("a"), 3002 GravatarID: String("g"), 3003 Name: String("n"), 3004 Company: String("c"), 3005 Blog: String("b"), 3006 Location: String("l"), 3007 Email: String("e"), 3008 Hireable: Bool(true), 3009 Bio: String("b"), 3010 TwitterUsername: String("t"), 3011 PublicRepos: Int(1), 3012 Followers: Int(1), 3013 Following: Int(1), 3014 CreatedAt: &Timestamp{referenceTime}, 3015 SuspendedAt: &Timestamp{referenceTime}, 3016 }, 3017 AccessTokensURL: String("atu"), 3018 RepositoriesURL: String("ru"), 3019 HTMLURL: String("hu"), 3020 TargetType: String("tt"), 3021 SingleFileName: String("sfn"), 3022 RepositorySelection: String("rs"), 3023 Events: []string{"e"}, 3024 SingleFilePaths: []string{"s"}, 3025 Permissions: &InstallationPermissions{ 3026 Actions: String("a"), 3027 Administration: String("ad"), 3028 Checks: String("c"), 3029 Contents: String("co"), 3030 ContentReferences: String("cr"), 3031 Deployments: String("d"), 3032 Environments: String("e"), 3033 Issues: String("i"), 3034 Metadata: String("md"), 3035 Members: String("m"), 3036 OrganizationAdministration: String("oa"), 3037 OrganizationHooks: String("oh"), 3038 OrganizationPlan: String("op"), 3039 OrganizationPreReceiveHooks: String("opr"), 3040 OrganizationProjects: String("op"), 3041 OrganizationSecrets: String("os"), 3042 OrganizationSelfHostedRunners: String("osh"), 3043 OrganizationUserBlocking: String("oub"), 3044 Packages: String("pkg"), 3045 Pages: String("pg"), 3046 PullRequests: String("pr"), 3047 RepositoryHooks: String("rh"), 3048 RepositoryProjects: String("rp"), 3049 RepositoryPreReceiveHooks: String("rprh"), 3050 Secrets: String("s"), 3051 SecretScanningAlerts: String("ssa"), 3052 SecurityEvents: String("se"), 3053 SingleFile: String("sf"), 3054 Statuses: String("s"), 3055 TeamDiscussions: String("td"), 3056 VulnerabilityAlerts: String("va"), 3057 Workflows: String("w"), 3058 }, 3059 CreatedAt: &Timestamp{referenceTime}, 3060 UpdatedAt: &Timestamp{referenceTime}, 3061 HasMultipleSingleFiles: Bool(false), 3062 SuspendedBy: &User{ 3063 Login: String("l"), 3064 ID: Int64(1), 3065 URL: String("u"), 3066 AvatarURL: String("a"), 3067 GravatarID: String("g"), 3068 Name: String("n"), 3069 Company: String("c"), 3070 Blog: String("b"), 3071 Location: String("l"), 3072 Email: String("e"), 3073 Hireable: Bool(true), 3074 Bio: String("b"), 3075 TwitterUsername: String("t"), 3076 PublicRepos: Int(1), 3077 Followers: Int(1), 3078 Following: Int(1), 3079 CreatedAt: &Timestamp{referenceTime}, 3080 SuspendedAt: &Timestamp{referenceTime}, 3081 }, 3082 SuspendedAt: &Timestamp{referenceTime}, 3083 }, 3084 } 3085 3086 want := `{ 3087 "action": "a", 3088 "milestone": { 3089 "id": 1 3090 }, 3091 "changes": { 3092 "title": { 3093 "from": "TitleFrom" 3094 }, 3095 "body": { 3096 "from": "BodyFrom" 3097 }, 3098 "base": { 3099 "ref": { 3100 "from": "BaseRefFrom" 3101 }, 3102 "sha": { 3103 "from": "BaseSHAFrom" 3104 } 3105 } 3106 }, 3107 "repository": { 3108 "id": 1, 3109 "name": "n", 3110 "url": "s" 3111 }, 3112 "sender": { 3113 "login": "l", 3114 "id": 1, 3115 "node_id": "n", 3116 "avatar_url": "a", 3117 "url": "u", 3118 "events_url": "e", 3119 "repos_url": "r" 3120 }, 3121 "organization": { 3122 "name": "n", 3123 "company": "c", 3124 "blog": "b", 3125 "location": "loc", 3126 "email": "e", 3127 "twitter_username": "tu", 3128 "description": "d", 3129 "billing_email": "be", 3130 "is_verified": true, 3131 "has_organization_projects": true, 3132 "has_repository_projects": true, 3133 "default_repository_permission": "drp", 3134 "members_can_create_repositories": true, 3135 "members_can_create_public_repositories": false, 3136 "members_can_create_private_repositories": true, 3137 "members_can_create_internal_repositories": true, 3138 "members_allowed_repository_creation_type": "marct", 3139 "members_can_create_pages": true, 3140 "members_can_create_public_pages": false, 3141 "members_can_create_private_pages": true 3142 }, 3143 "installation": { 3144 "id": 1, 3145 "node_id": "nid", 3146 "app_id": 1, 3147 "app_slug": "as", 3148 "target_id": 1, 3149 "account": { 3150 "login": "l", 3151 "id": 1, 3152 "avatar_url": "a", 3153 "gravatar_id": "g", 3154 "name": "n", 3155 "company": "c", 3156 "blog": "b", 3157 "location": "l", 3158 "email": "e", 3159 "hireable": true, 3160 "bio": "b", 3161 "twitter_username": "t", 3162 "public_repos": 1, 3163 "followers": 1, 3164 "following": 1, 3165 "created_at": ` + referenceTimeStr + `, 3166 "suspended_at": ` + referenceTimeStr + `, 3167 "url": "u" 3168 }, 3169 "access_tokens_url": "atu", 3170 "repositories_url": "ru", 3171 "html_url": "hu", 3172 "target_type": "tt", 3173 "single_file_name": "sfn", 3174 "repository_selection": "rs", 3175 "events": [ 3176 "e" 3177 ], 3178 "single_file_paths": [ 3179 "s" 3180 ], 3181 "permissions": { 3182 "actions": "a", 3183 "administration": "ad", 3184 "checks": "c", 3185 "contents": "co", 3186 "content_references": "cr", 3187 "deployments": "d", 3188 "environments": "e", 3189 "issues": "i", 3190 "metadata": "md", 3191 "members": "m", 3192 "organization_administration": "oa", 3193 "organization_hooks": "oh", 3194 "organization_plan": "op", 3195 "organization_pre_receive_hooks": "opr", 3196 "organization_projects": "op", 3197 "organization_secrets": "os", 3198 "organization_self_hosted_runners": "osh", 3199 "organization_user_blocking": "oub", 3200 "packages": "pkg", 3201 "pages": "pg", 3202 "pull_requests": "pr", 3203 "repository_hooks": "rh", 3204 "repository_projects": "rp", 3205 "repository_pre_receive_hooks": "rprh", 3206 "secrets": "s", 3207 "secret_scanning_alerts": "ssa", 3208 "security_events": "se", 3209 "single_file": "sf", 3210 "statuses": "s", 3211 "team_discussions": "td", 3212 "vulnerability_alerts": "va", 3213 "workflows": "w" 3214 }, 3215 "created_at": ` + referenceTimeStr + `, 3216 "updated_at": ` + referenceTimeStr + `, 3217 "has_multiple_single_files": false, 3218 "suspended_by": { 3219 "login": "l", 3220 "id": 1, 3221 "avatar_url": "a", 3222 "gravatar_id": "g", 3223 "name": "n", 3224 "company": "c", 3225 "blog": "b", 3226 "location": "l", 3227 "email": "e", 3228 "hireable": true, 3229 "bio": "b", 3230 "twitter_username": "t", 3231 "public_repos": 1, 3232 "followers": 1, 3233 "following": 1, 3234 "created_at": ` + referenceTimeStr + `, 3235 "suspended_at": ` + referenceTimeStr + `, 3236 "url": "u" 3237 }, 3238 "suspended_at": ` + referenceTimeStr + ` 3239 } 3240 }` 3241 3242 testJSONMarshal(t, u, want) 3243 } 3244 3245 func TestPublicEvent_Marshal(t *testing.T) { 3246 testJSONMarshal(t, &PublicEvent{}, "{}") 3247 3248 u := &PublicEvent{ 3249 Repo: &Repository{ 3250 ID: Int64(1), 3251 URL: String("s"), 3252 Name: String("n"), 3253 }, 3254 Sender: &User{ 3255 Login: String("l"), 3256 ID: Int64(1), 3257 NodeID: String("n"), 3258 URL: String("u"), 3259 ReposURL: String("r"), 3260 EventsURL: String("e"), 3261 AvatarURL: String("a"), 3262 }, 3263 Installation: &Installation{ 3264 ID: Int64(1), 3265 NodeID: String("nid"), 3266 AppID: Int64(1), 3267 AppSlug: String("as"), 3268 TargetID: Int64(1), 3269 Account: &User{ 3270 Login: String("l"), 3271 ID: Int64(1), 3272 URL: String("u"), 3273 AvatarURL: String("a"), 3274 GravatarID: String("g"), 3275 Name: String("n"), 3276 Company: String("c"), 3277 Blog: String("b"), 3278 Location: String("l"), 3279 Email: String("e"), 3280 Hireable: Bool(true), 3281 Bio: String("b"), 3282 TwitterUsername: String("t"), 3283 PublicRepos: Int(1), 3284 Followers: Int(1), 3285 Following: Int(1), 3286 CreatedAt: &Timestamp{referenceTime}, 3287 SuspendedAt: &Timestamp{referenceTime}, 3288 }, 3289 AccessTokensURL: String("atu"), 3290 RepositoriesURL: String("ru"), 3291 HTMLURL: String("hu"), 3292 TargetType: String("tt"), 3293 SingleFileName: String("sfn"), 3294 RepositorySelection: String("rs"), 3295 Events: []string{"e"}, 3296 SingleFilePaths: []string{"s"}, 3297 Permissions: &InstallationPermissions{ 3298 Actions: String("a"), 3299 Administration: String("ad"), 3300 Checks: String("c"), 3301 Contents: String("co"), 3302 ContentReferences: String("cr"), 3303 Deployments: String("d"), 3304 Environments: String("e"), 3305 Issues: String("i"), 3306 Metadata: String("md"), 3307 Members: String("m"), 3308 OrganizationAdministration: String("oa"), 3309 OrganizationHooks: String("oh"), 3310 OrganizationPlan: String("op"), 3311 OrganizationPreReceiveHooks: String("opr"), 3312 OrganizationProjects: String("op"), 3313 OrganizationSecrets: String("os"), 3314 OrganizationSelfHostedRunners: String("osh"), 3315 OrganizationUserBlocking: String("oub"), 3316 Packages: String("pkg"), 3317 Pages: String("pg"), 3318 PullRequests: String("pr"), 3319 RepositoryHooks: String("rh"), 3320 RepositoryProjects: String("rp"), 3321 RepositoryPreReceiveHooks: String("rprh"), 3322 Secrets: String("s"), 3323 SecretScanningAlerts: String("ssa"), 3324 SecurityEvents: String("se"), 3325 SingleFile: String("sf"), 3326 Statuses: String("s"), 3327 TeamDiscussions: String("td"), 3328 VulnerabilityAlerts: String("va"), 3329 Workflows: String("w"), 3330 }, 3331 CreatedAt: &Timestamp{referenceTime}, 3332 UpdatedAt: &Timestamp{referenceTime}, 3333 HasMultipleSingleFiles: Bool(false), 3334 SuspendedBy: &User{ 3335 Login: String("l"), 3336 ID: Int64(1), 3337 URL: String("u"), 3338 AvatarURL: String("a"), 3339 GravatarID: String("g"), 3340 Name: String("n"), 3341 Company: String("c"), 3342 Blog: String("b"), 3343 Location: String("l"), 3344 Email: String("e"), 3345 Hireable: Bool(true), 3346 Bio: String("b"), 3347 TwitterUsername: String("t"), 3348 PublicRepos: Int(1), 3349 Followers: Int(1), 3350 Following: Int(1), 3351 CreatedAt: &Timestamp{referenceTime}, 3352 SuspendedAt: &Timestamp{referenceTime}, 3353 }, 3354 SuspendedAt: &Timestamp{referenceTime}, 3355 }, 3356 } 3357 3358 want := `{ 3359 "repository": { 3360 "id": 1, 3361 "name": "n", 3362 "url": "s" 3363 }, 3364 "sender": { 3365 "login": "l", 3366 "id": 1, 3367 "node_id": "n", 3368 "avatar_url": "a", 3369 "url": "u", 3370 "events_url": "e", 3371 "repos_url": "r" 3372 }, 3373 "installation": { 3374 "id": 1, 3375 "node_id": "nid", 3376 "app_id": 1, 3377 "app_slug": "as", 3378 "target_id": 1, 3379 "account": { 3380 "login": "l", 3381 "id": 1, 3382 "avatar_url": "a", 3383 "gravatar_id": "g", 3384 "name": "n", 3385 "company": "c", 3386 "blog": "b", 3387 "location": "l", 3388 "email": "e", 3389 "hireable": true, 3390 "bio": "b", 3391 "twitter_username": "t", 3392 "public_repos": 1, 3393 "followers": 1, 3394 "following": 1, 3395 "created_at": ` + referenceTimeStr + `, 3396 "suspended_at": ` + referenceTimeStr + `, 3397 "url": "u" 3398 }, 3399 "access_tokens_url": "atu", 3400 "repositories_url": "ru", 3401 "html_url": "hu", 3402 "target_type": "tt", 3403 "single_file_name": "sfn", 3404 "repository_selection": "rs", 3405 "events": [ 3406 "e" 3407 ], 3408 "single_file_paths": [ 3409 "s" 3410 ], 3411 "permissions": { 3412 "actions": "a", 3413 "administration": "ad", 3414 "checks": "c", 3415 "contents": "co", 3416 "content_references": "cr", 3417 "deployments": "d", 3418 "environments": "e", 3419 "issues": "i", 3420 "metadata": "md", 3421 "members": "m", 3422 "organization_administration": "oa", 3423 "organization_hooks": "oh", 3424 "organization_plan": "op", 3425 "organization_pre_receive_hooks": "opr", 3426 "organization_projects": "op", 3427 "organization_secrets": "os", 3428 "organization_self_hosted_runners": "osh", 3429 "organization_user_blocking": "oub", 3430 "packages": "pkg", 3431 "pages": "pg", 3432 "pull_requests": "pr", 3433 "repository_hooks": "rh", 3434 "repository_projects": "rp", 3435 "repository_pre_receive_hooks": "rprh", 3436 "secrets": "s", 3437 "secret_scanning_alerts": "ssa", 3438 "security_events": "se", 3439 "single_file": "sf", 3440 "statuses": "s", 3441 "team_discussions": "td", 3442 "vulnerability_alerts": "va", 3443 "workflows": "w" 3444 }, 3445 "created_at": ` + referenceTimeStr + `, 3446 "updated_at": ` + referenceTimeStr + `, 3447 "has_multiple_single_files": false, 3448 "suspended_by": { 3449 "login": "l", 3450 "id": 1, 3451 "avatar_url": "a", 3452 "gravatar_id": "g", 3453 "name": "n", 3454 "company": "c", 3455 "blog": "b", 3456 "location": "l", 3457 "email": "e", 3458 "hireable": true, 3459 "bio": "b", 3460 "twitter_username": "t", 3461 "public_repos": 1, 3462 "followers": 1, 3463 "following": 1, 3464 "created_at": ` + referenceTimeStr + `, 3465 "suspended_at": ` + referenceTimeStr + `, 3466 "url": "u" 3467 }, 3468 "suspended_at": ` + referenceTimeStr + ` 3469 } 3470 }` 3471 3472 testJSONMarshal(t, u, want) 3473 } 3474 3475 func TestPullRequestReviewEvent_Marshal(t *testing.T) { 3476 testJSONMarshal(t, &PullRequestReviewEvent{}, "{}") 3477 3478 u := &PullRequestReviewEvent{ 3479 Action: String("a"), 3480 Review: &PullRequestReview{ID: Int64(1)}, 3481 PullRequest: &PullRequest{ID: Int64(1)}, 3482 Repo: &Repository{ 3483 ID: Int64(1), 3484 URL: String("s"), 3485 Name: String("n"), 3486 }, 3487 Sender: &User{ 3488 Login: String("l"), 3489 ID: Int64(1), 3490 NodeID: String("n"), 3491 URL: String("u"), 3492 ReposURL: String("r"), 3493 EventsURL: String("e"), 3494 AvatarURL: String("a"), 3495 }, 3496 Installation: &Installation{ 3497 ID: Int64(1), 3498 NodeID: String("nid"), 3499 AppID: Int64(1), 3500 AppSlug: String("as"), 3501 TargetID: Int64(1), 3502 Account: &User{ 3503 Login: String("l"), 3504 ID: Int64(1), 3505 URL: String("u"), 3506 AvatarURL: String("a"), 3507 GravatarID: String("g"), 3508 Name: String("n"), 3509 Company: String("c"), 3510 Blog: String("b"), 3511 Location: String("l"), 3512 Email: String("e"), 3513 Hireable: Bool(true), 3514 Bio: String("b"), 3515 TwitterUsername: String("t"), 3516 PublicRepos: Int(1), 3517 Followers: Int(1), 3518 Following: Int(1), 3519 CreatedAt: &Timestamp{referenceTime}, 3520 SuspendedAt: &Timestamp{referenceTime}, 3521 }, 3522 AccessTokensURL: String("atu"), 3523 RepositoriesURL: String("ru"), 3524 HTMLURL: String("hu"), 3525 TargetType: String("tt"), 3526 SingleFileName: String("sfn"), 3527 RepositorySelection: String("rs"), 3528 Events: []string{"e"}, 3529 SingleFilePaths: []string{"s"}, 3530 Permissions: &InstallationPermissions{ 3531 Actions: String("a"), 3532 Administration: String("ad"), 3533 Checks: String("c"), 3534 Contents: String("co"), 3535 ContentReferences: String("cr"), 3536 Deployments: String("d"), 3537 Environments: String("e"), 3538 Issues: String("i"), 3539 Metadata: String("md"), 3540 Members: String("m"), 3541 OrganizationAdministration: String("oa"), 3542 OrganizationHooks: String("oh"), 3543 OrganizationPlan: String("op"), 3544 OrganizationPreReceiveHooks: String("opr"), 3545 OrganizationProjects: String("op"), 3546 OrganizationSecrets: String("os"), 3547 OrganizationSelfHostedRunners: String("osh"), 3548 OrganizationUserBlocking: String("oub"), 3549 Packages: String("pkg"), 3550 Pages: String("pg"), 3551 PullRequests: String("pr"), 3552 RepositoryHooks: String("rh"), 3553 RepositoryProjects: String("rp"), 3554 RepositoryPreReceiveHooks: String("rprh"), 3555 Secrets: String("s"), 3556 SecretScanningAlerts: String("ssa"), 3557 SecurityEvents: String("se"), 3558 SingleFile: String("sf"), 3559 Statuses: String("s"), 3560 TeamDiscussions: String("td"), 3561 VulnerabilityAlerts: String("va"), 3562 Workflows: String("w"), 3563 }, 3564 CreatedAt: &Timestamp{referenceTime}, 3565 UpdatedAt: &Timestamp{referenceTime}, 3566 HasMultipleSingleFiles: Bool(false), 3567 SuspendedBy: &User{ 3568 Login: String("l"), 3569 ID: Int64(1), 3570 URL: String("u"), 3571 AvatarURL: String("a"), 3572 GravatarID: String("g"), 3573 Name: String("n"), 3574 Company: String("c"), 3575 Blog: String("b"), 3576 Location: String("l"), 3577 Email: String("e"), 3578 Hireable: Bool(true), 3579 Bio: String("b"), 3580 TwitterUsername: String("t"), 3581 PublicRepos: Int(1), 3582 Followers: Int(1), 3583 Following: Int(1), 3584 CreatedAt: &Timestamp{referenceTime}, 3585 SuspendedAt: &Timestamp{referenceTime}, 3586 }, 3587 SuspendedAt: &Timestamp{referenceTime}, 3588 }, 3589 Organization: &Organization{ 3590 BillingEmail: String("be"), 3591 Blog: String("b"), 3592 Company: String("c"), 3593 Email: String("e"), 3594 TwitterUsername: String("tu"), 3595 Location: String("loc"), 3596 Name: String("n"), 3597 Description: String("d"), 3598 IsVerified: Bool(true), 3599 HasOrganizationProjects: Bool(true), 3600 HasRepositoryProjects: Bool(true), 3601 DefaultRepoPermission: String("drp"), 3602 MembersCanCreateRepos: Bool(true), 3603 MembersCanCreateInternalRepos: Bool(true), 3604 MembersCanCreatePrivateRepos: Bool(true), 3605 MembersCanCreatePublicRepos: Bool(false), 3606 MembersAllowedRepositoryCreationType: String("marct"), 3607 MembersCanCreatePages: Bool(true), 3608 MembersCanCreatePublicPages: Bool(false), 3609 MembersCanCreatePrivatePages: Bool(true), 3610 }, 3611 } 3612 3613 want := `{ 3614 "action": "a", 3615 "review": { 3616 "id": 1 3617 }, 3618 "pull_request": { 3619 "id": 1 3620 }, 3621 "repository": { 3622 "id": 1, 3623 "name": "n", 3624 "url": "s" 3625 }, 3626 "sender": { 3627 "login": "l", 3628 "id": 1, 3629 "node_id": "n", 3630 "avatar_url": "a", 3631 "url": "u", 3632 "events_url": "e", 3633 "repos_url": "r" 3634 }, 3635 "installation": { 3636 "id": 1, 3637 "node_id": "nid", 3638 "app_id": 1, 3639 "app_slug": "as", 3640 "target_id": 1, 3641 "account": { 3642 "login": "l", 3643 "id": 1, 3644 "avatar_url": "a", 3645 "gravatar_id": "g", 3646 "name": "n", 3647 "company": "c", 3648 "blog": "b", 3649 "location": "l", 3650 "email": "e", 3651 "hireable": true, 3652 "bio": "b", 3653 "twitter_username": "t", 3654 "public_repos": 1, 3655 "followers": 1, 3656 "following": 1, 3657 "created_at": ` + referenceTimeStr + `, 3658 "suspended_at": ` + referenceTimeStr + `, 3659 "url": "u" 3660 }, 3661 "access_tokens_url": "atu", 3662 "repositories_url": "ru", 3663 "html_url": "hu", 3664 "target_type": "tt", 3665 "single_file_name": "sfn", 3666 "repository_selection": "rs", 3667 "events": [ 3668 "e" 3669 ], 3670 "single_file_paths": [ 3671 "s" 3672 ], 3673 "permissions": { 3674 "actions": "a", 3675 "administration": "ad", 3676 "checks": "c", 3677 "contents": "co", 3678 "content_references": "cr", 3679 "deployments": "d", 3680 "environments": "e", 3681 "issues": "i", 3682 "metadata": "md", 3683 "members": "m", 3684 "organization_administration": "oa", 3685 "organization_hooks": "oh", 3686 "organization_plan": "op", 3687 "organization_pre_receive_hooks": "opr", 3688 "organization_projects": "op", 3689 "organization_secrets": "os", 3690 "organization_self_hosted_runners": "osh", 3691 "organization_user_blocking": "oub", 3692 "packages": "pkg", 3693 "pages": "pg", 3694 "pull_requests": "pr", 3695 "repository_hooks": "rh", 3696 "repository_projects": "rp", 3697 "repository_pre_receive_hooks": "rprh", 3698 "secrets": "s", 3699 "secret_scanning_alerts": "ssa", 3700 "security_events": "se", 3701 "single_file": "sf", 3702 "statuses": "s", 3703 "team_discussions": "td", 3704 "vulnerability_alerts": "va", 3705 "workflows": "w" 3706 }, 3707 "created_at": ` + referenceTimeStr + `, 3708 "updated_at": ` + referenceTimeStr + `, 3709 "has_multiple_single_files": false, 3710 "suspended_by": { 3711 "login": "l", 3712 "id": 1, 3713 "avatar_url": "a", 3714 "gravatar_id": "g", 3715 "name": "n", 3716 "company": "c", 3717 "blog": "b", 3718 "location": "l", 3719 "email": "e", 3720 "hireable": true, 3721 "bio": "b", 3722 "twitter_username": "t", 3723 "public_repos": 1, 3724 "followers": 1, 3725 "following": 1, 3726 "created_at": ` + referenceTimeStr + `, 3727 "suspended_at": ` + referenceTimeStr + `, 3728 "url": "u" 3729 }, 3730 "suspended_at": ` + referenceTimeStr + ` 3731 }, 3732 "organization": { 3733 "name": "n", 3734 "company": "c", 3735 "blog": "b", 3736 "location": "loc", 3737 "email": "e", 3738 "twitter_username": "tu", 3739 "description": "d", 3740 "billing_email": "be", 3741 "is_verified": true, 3742 "has_organization_projects": true, 3743 "has_repository_projects": true, 3744 "default_repository_permission": "drp", 3745 "members_can_create_repositories": true, 3746 "members_can_create_public_repositories": false, 3747 "members_can_create_private_repositories": true, 3748 "members_can_create_internal_repositories": true, 3749 "members_allowed_repository_creation_type": "marct", 3750 "members_can_create_pages": true, 3751 "members_can_create_public_pages": false, 3752 "members_can_create_private_pages": true 3753 } 3754 }` 3755 3756 testJSONMarshal(t, u, want) 3757 } 3758 3759 func TestPushEvent_Marshal(t *testing.T) { 3760 testJSONMarshal(t, &PushEvent{}, "{}") 3761 3762 u := &PushEvent{ 3763 PushID: Int64(1), 3764 Head: String("h"), 3765 Ref: String("ref"), 3766 Size: Int(1), 3767 Commits: []*HeadCommit{ 3768 {ID: String("id")}, 3769 }, 3770 Before: String("b"), 3771 DistinctSize: Int(1), 3772 After: String("a"), 3773 Created: Bool(true), 3774 Deleted: Bool(true), 3775 Forced: Bool(true), 3776 BaseRef: String("a"), 3777 Compare: String("a"), 3778 Repo: &PushEventRepository{ID: Int64(1)}, 3779 HeadCommit: &HeadCommit{ID: String("id")}, 3780 Pusher: &CommitAuthor{ 3781 Login: String("l"), 3782 Date: &Timestamp{referenceTime}, 3783 Name: String("n"), 3784 Email: String("e"), 3785 }, 3786 Sender: &User{ 3787 Login: String("l"), 3788 ID: Int64(1), 3789 NodeID: String("n"), 3790 URL: String("u"), 3791 ReposURL: String("r"), 3792 EventsURL: String("e"), 3793 AvatarURL: String("a"), 3794 }, 3795 Installation: &Installation{ 3796 ID: Int64(1), 3797 NodeID: String("nid"), 3798 AppID: Int64(1), 3799 AppSlug: String("as"), 3800 TargetID: Int64(1), 3801 Account: &User{ 3802 Login: String("l"), 3803 ID: Int64(1), 3804 URL: String("u"), 3805 AvatarURL: String("a"), 3806 GravatarID: String("g"), 3807 Name: String("n"), 3808 Company: String("c"), 3809 Blog: String("b"), 3810 Location: String("l"), 3811 Email: String("e"), 3812 Hireable: Bool(true), 3813 Bio: String("b"), 3814 TwitterUsername: String("t"), 3815 PublicRepos: Int(1), 3816 Followers: Int(1), 3817 Following: Int(1), 3818 CreatedAt: &Timestamp{referenceTime}, 3819 SuspendedAt: &Timestamp{referenceTime}, 3820 }, 3821 AccessTokensURL: String("atu"), 3822 RepositoriesURL: String("ru"), 3823 HTMLURL: String("hu"), 3824 TargetType: String("tt"), 3825 SingleFileName: String("sfn"), 3826 RepositorySelection: String("rs"), 3827 Events: []string{"e"}, 3828 SingleFilePaths: []string{"s"}, 3829 Permissions: &InstallationPermissions{ 3830 Actions: String("a"), 3831 Administration: String("ad"), 3832 Checks: String("c"), 3833 Contents: String("co"), 3834 ContentReferences: String("cr"), 3835 Deployments: String("d"), 3836 Environments: String("e"), 3837 Issues: String("i"), 3838 Metadata: String("md"), 3839 Members: String("m"), 3840 OrganizationAdministration: String("oa"), 3841 OrganizationHooks: String("oh"), 3842 OrganizationPlan: String("op"), 3843 OrganizationPreReceiveHooks: String("opr"), 3844 OrganizationProjects: String("op"), 3845 OrganizationSecrets: String("os"), 3846 OrganizationSelfHostedRunners: String("osh"), 3847 OrganizationUserBlocking: String("oub"), 3848 Packages: String("pkg"), 3849 Pages: String("pg"), 3850 PullRequests: String("pr"), 3851 RepositoryHooks: String("rh"), 3852 RepositoryProjects: String("rp"), 3853 RepositoryPreReceiveHooks: String("rprh"), 3854 Secrets: String("s"), 3855 SecretScanningAlerts: String("ssa"), 3856 SecurityEvents: String("se"), 3857 SingleFile: String("sf"), 3858 Statuses: String("s"), 3859 TeamDiscussions: String("td"), 3860 VulnerabilityAlerts: String("va"), 3861 Workflows: String("w"), 3862 }, 3863 CreatedAt: &Timestamp{referenceTime}, 3864 UpdatedAt: &Timestamp{referenceTime}, 3865 HasMultipleSingleFiles: Bool(false), 3866 SuspendedBy: &User{ 3867 Login: String("l"), 3868 ID: Int64(1), 3869 URL: String("u"), 3870 AvatarURL: String("a"), 3871 GravatarID: String("g"), 3872 Name: String("n"), 3873 Company: String("c"), 3874 Blog: String("b"), 3875 Location: String("l"), 3876 Email: String("e"), 3877 Hireable: Bool(true), 3878 Bio: String("b"), 3879 TwitterUsername: String("t"), 3880 PublicRepos: Int(1), 3881 Followers: Int(1), 3882 Following: Int(1), 3883 CreatedAt: &Timestamp{referenceTime}, 3884 SuspendedAt: &Timestamp{referenceTime}, 3885 }, 3886 SuspendedAt: &Timestamp{referenceTime}, 3887 }, 3888 Organization: &Organization{ 3889 BillingEmail: String("be"), 3890 Blog: String("b"), 3891 Company: String("c"), 3892 Email: String("e"), 3893 TwitterUsername: String("tu"), 3894 Location: String("loc"), 3895 Name: String("n"), 3896 Description: String("d"), 3897 IsVerified: Bool(true), 3898 HasOrganizationProjects: Bool(true), 3899 HasRepositoryProjects: Bool(true), 3900 DefaultRepoPermission: String("drp"), 3901 MembersCanCreateRepos: Bool(true), 3902 MembersCanCreateInternalRepos: Bool(true), 3903 MembersCanCreatePrivateRepos: Bool(true), 3904 MembersCanCreatePublicRepos: Bool(false), 3905 MembersAllowedRepositoryCreationType: String("marct"), 3906 MembersCanCreatePages: Bool(true), 3907 MembersCanCreatePublicPages: Bool(false), 3908 MembersCanCreatePrivatePages: Bool(true), 3909 }, 3910 } 3911 3912 want := `{ 3913 "push_id": 1, 3914 "head": "h", 3915 "ref": "ref", 3916 "size": 1, 3917 "commits": [ 3918 { 3919 "id": "id" 3920 } 3921 ], 3922 "before": "b", 3923 "distinct_size": 1, 3924 "after": "a", 3925 "created": true, 3926 "deleted": true, 3927 "forced": true, 3928 "base_ref": "a", 3929 "compare": "a", 3930 "repository": { 3931 "id": 1 3932 }, 3933 "head_commit": { 3934 "id": "id" 3935 }, 3936 "pusher": { 3937 "date": ` + referenceTimeStr + `, 3938 "name": "n", 3939 "email": "e", 3940 "username": "l" 3941 }, 3942 "sender": { 3943 "login": "l", 3944 "id": 1, 3945 "node_id": "n", 3946 "avatar_url": "a", 3947 "url": "u", 3948 "events_url": "e", 3949 "repos_url": "r" 3950 }, 3951 "installation": { 3952 "id": 1, 3953 "node_id": "nid", 3954 "app_id": 1, 3955 "app_slug": "as", 3956 "target_id": 1, 3957 "account": { 3958 "login": "l", 3959 "id": 1, 3960 "avatar_url": "a", 3961 "gravatar_id": "g", 3962 "name": "n", 3963 "company": "c", 3964 "blog": "b", 3965 "location": "l", 3966 "email": "e", 3967 "hireable": true, 3968 "bio": "b", 3969 "twitter_username": "t", 3970 "public_repos": 1, 3971 "followers": 1, 3972 "following": 1, 3973 "created_at": ` + referenceTimeStr + `, 3974 "suspended_at": ` + referenceTimeStr + `, 3975 "url": "u" 3976 }, 3977 "access_tokens_url": "atu", 3978 "repositories_url": "ru", 3979 "html_url": "hu", 3980 "target_type": "tt", 3981 "single_file_name": "sfn", 3982 "repository_selection": "rs", 3983 "events": [ 3984 "e" 3985 ], 3986 "single_file_paths": [ 3987 "s" 3988 ], 3989 "permissions": { 3990 "actions": "a", 3991 "administration": "ad", 3992 "checks": "c", 3993 "contents": "co", 3994 "content_references": "cr", 3995 "deployments": "d", 3996 "environments": "e", 3997 "issues": "i", 3998 "metadata": "md", 3999 "members": "m", 4000 "organization_administration": "oa", 4001 "organization_hooks": "oh", 4002 "organization_plan": "op", 4003 "organization_pre_receive_hooks": "opr", 4004 "organization_projects": "op", 4005 "organization_secrets": "os", 4006 "organization_self_hosted_runners": "osh", 4007 "organization_user_blocking": "oub", 4008 "packages": "pkg", 4009 "pages": "pg", 4010 "pull_requests": "pr", 4011 "repository_hooks": "rh", 4012 "repository_projects": "rp", 4013 "repository_pre_receive_hooks": "rprh", 4014 "secrets": "s", 4015 "secret_scanning_alerts": "ssa", 4016 "security_events": "se", 4017 "single_file": "sf", 4018 "statuses": "s", 4019 "team_discussions": "td", 4020 "vulnerability_alerts": "va", 4021 "workflows": "w" 4022 }, 4023 "created_at": ` + referenceTimeStr + `, 4024 "updated_at": ` + referenceTimeStr + `, 4025 "has_multiple_single_files": false, 4026 "suspended_by": { 4027 "login": "l", 4028 "id": 1, 4029 "avatar_url": "a", 4030 "gravatar_id": "g", 4031 "name": "n", 4032 "company": "c", 4033 "blog": "b", 4034 "location": "l", 4035 "email": "e", 4036 "hireable": true, 4037 "bio": "b", 4038 "twitter_username": "t", 4039 "public_repos": 1, 4040 "followers": 1, 4041 "following": 1, 4042 "created_at": ` + referenceTimeStr + `, 4043 "suspended_at": ` + referenceTimeStr + `, 4044 "url": "u" 4045 }, 4046 "suspended_at": ` + referenceTimeStr + ` 4047 }, 4048 "organization": { 4049 "name": "n", 4050 "company": "c", 4051 "blog": "b", 4052 "location": "loc", 4053 "email": "e", 4054 "twitter_username": "tu", 4055 "description": "d", 4056 "billing_email": "be", 4057 "is_verified": true, 4058 "has_organization_projects": true, 4059 "has_repository_projects": true, 4060 "default_repository_permission": "drp", 4061 "members_can_create_repositories": true, 4062 "members_can_create_public_repositories": false, 4063 "members_can_create_private_repositories": true, 4064 "members_can_create_internal_repositories": true, 4065 "members_allowed_repository_creation_type": "marct", 4066 "members_can_create_pages": true, 4067 "members_can_create_public_pages": false, 4068 "members_can_create_private_pages": true 4069 } 4070 }` 4071 4072 testJSONMarshal(t, u, want) 4073 } 4074 4075 func TestStatusEvent_Marshal(t *testing.T) { 4076 testJSONMarshal(t, &StatusEvent{}, "{}") 4077 4078 u := &StatusEvent{ 4079 SHA: String("sha"), 4080 State: String("s"), 4081 Description: String("d"), 4082 TargetURL: String("turl"), 4083 Branches: []*Branch{ 4084 { 4085 Name: String("n"), 4086 Commit: &RepositoryCommit{NodeID: String("nid")}, 4087 Protected: Bool(false), 4088 }, 4089 }, 4090 ID: Int64(1), 4091 Name: String("n"), 4092 Context: String("c"), 4093 Commit: &RepositoryCommit{NodeID: String("nid")}, 4094 CreatedAt: &Timestamp{referenceTime}, 4095 UpdatedAt: &Timestamp{referenceTime}, 4096 Sender: &User{ 4097 Login: String("l"), 4098 ID: Int64(1), 4099 NodeID: String("n"), 4100 URL: String("u"), 4101 ReposURL: String("r"), 4102 EventsURL: String("e"), 4103 AvatarURL: String("a"), 4104 }, 4105 Installation: &Installation{ 4106 ID: Int64(1), 4107 NodeID: String("nid"), 4108 AppID: Int64(1), 4109 AppSlug: String("as"), 4110 TargetID: Int64(1), 4111 Account: &User{ 4112 Login: String("l"), 4113 ID: Int64(1), 4114 URL: String("u"), 4115 AvatarURL: String("a"), 4116 GravatarID: String("g"), 4117 Name: String("n"), 4118 Company: String("c"), 4119 Blog: String("b"), 4120 Location: String("l"), 4121 Email: String("e"), 4122 Hireable: Bool(true), 4123 Bio: String("b"), 4124 TwitterUsername: String("t"), 4125 PublicRepos: Int(1), 4126 Followers: Int(1), 4127 Following: Int(1), 4128 CreatedAt: &Timestamp{referenceTime}, 4129 SuspendedAt: &Timestamp{referenceTime}, 4130 }, 4131 AccessTokensURL: String("atu"), 4132 RepositoriesURL: String("ru"), 4133 HTMLURL: String("hu"), 4134 TargetType: String("tt"), 4135 SingleFileName: String("sfn"), 4136 RepositorySelection: String("rs"), 4137 Events: []string{"e"}, 4138 SingleFilePaths: []string{"s"}, 4139 Permissions: &InstallationPermissions{ 4140 Actions: String("a"), 4141 Administration: String("ad"), 4142 Checks: String("c"), 4143 Contents: String("co"), 4144 ContentReferences: String("cr"), 4145 Deployments: String("d"), 4146 Environments: String("e"), 4147 Issues: String("i"), 4148 Metadata: String("md"), 4149 Members: String("m"), 4150 OrganizationAdministration: String("oa"), 4151 OrganizationHooks: String("oh"), 4152 OrganizationPlan: String("op"), 4153 OrganizationPreReceiveHooks: String("opr"), 4154 OrganizationProjects: String("op"), 4155 OrganizationSecrets: String("os"), 4156 OrganizationSelfHostedRunners: String("osh"), 4157 OrganizationUserBlocking: String("oub"), 4158 Packages: String("pkg"), 4159 Pages: String("pg"), 4160 PullRequests: String("pr"), 4161 RepositoryHooks: String("rh"), 4162 RepositoryProjects: String("rp"), 4163 RepositoryPreReceiveHooks: String("rprh"), 4164 Secrets: String("s"), 4165 SecretScanningAlerts: String("ssa"), 4166 SecurityEvents: String("se"), 4167 SingleFile: String("sf"), 4168 Statuses: String("s"), 4169 TeamDiscussions: String("td"), 4170 VulnerabilityAlerts: String("va"), 4171 Workflows: String("w"), 4172 }, 4173 CreatedAt: &Timestamp{referenceTime}, 4174 UpdatedAt: &Timestamp{referenceTime}, 4175 HasMultipleSingleFiles: Bool(false), 4176 SuspendedBy: &User{ 4177 Login: String("l"), 4178 ID: Int64(1), 4179 URL: String("u"), 4180 AvatarURL: String("a"), 4181 GravatarID: String("g"), 4182 Name: String("n"), 4183 Company: String("c"), 4184 Blog: String("b"), 4185 Location: String("l"), 4186 Email: String("e"), 4187 Hireable: Bool(true), 4188 Bio: String("b"), 4189 TwitterUsername: String("t"), 4190 PublicRepos: Int(1), 4191 Followers: Int(1), 4192 Following: Int(1), 4193 CreatedAt: &Timestamp{referenceTime}, 4194 SuspendedAt: &Timestamp{referenceTime}, 4195 }, 4196 SuspendedAt: &Timestamp{referenceTime}, 4197 }, 4198 } 4199 4200 want := `{ 4201 "sha": "sha", 4202 "state": "s", 4203 "description": "d", 4204 "target_url": "turl", 4205 "branches": [ 4206 { 4207 "name": "n", 4208 "commit": { 4209 "node_id": "nid" 4210 }, 4211 "protected": false 4212 } 4213 ], 4214 "id": 1, 4215 "name": "n", 4216 "context": "c", 4217 "commit": { 4218 "node_id": "nid" 4219 }, 4220 "created_at": ` + referenceTimeStr + `, 4221 "updated_at": ` + referenceTimeStr + `, 4222 "sender": { 4223 "login": "l", 4224 "id": 1, 4225 "node_id": "n", 4226 "avatar_url": "a", 4227 "url": "u", 4228 "events_url": "e", 4229 "repos_url": "r" 4230 }, 4231 "installation": { 4232 "id": 1, 4233 "node_id": "nid", 4234 "app_id": 1, 4235 "app_slug": "as", 4236 "target_id": 1, 4237 "account": { 4238 "login": "l", 4239 "id": 1, 4240 "avatar_url": "a", 4241 "gravatar_id": "g", 4242 "name": "n", 4243 "company": "c", 4244 "blog": "b", 4245 "location": "l", 4246 "email": "e", 4247 "hireable": true, 4248 "bio": "b", 4249 "twitter_username": "t", 4250 "public_repos": 1, 4251 "followers": 1, 4252 "following": 1, 4253 "created_at": ` + referenceTimeStr + `, 4254 "suspended_at": ` + referenceTimeStr + `, 4255 "url": "u" 4256 }, 4257 "access_tokens_url": "atu", 4258 "repositories_url": "ru", 4259 "html_url": "hu", 4260 "target_type": "tt", 4261 "single_file_name": "sfn", 4262 "repository_selection": "rs", 4263 "events": [ 4264 "e" 4265 ], 4266 "single_file_paths": [ 4267 "s" 4268 ], 4269 "permissions": { 4270 "actions": "a", 4271 "administration": "ad", 4272 "checks": "c", 4273 "contents": "co", 4274 "content_references": "cr", 4275 "deployments": "d", 4276 "environments": "e", 4277 "issues": "i", 4278 "metadata": "md", 4279 "members": "m", 4280 "organization_administration": "oa", 4281 "organization_hooks": "oh", 4282 "organization_plan": "op", 4283 "organization_pre_receive_hooks": "opr", 4284 "organization_projects": "op", 4285 "organization_secrets": "os", 4286 "organization_self_hosted_runners": "osh", 4287 "organization_user_blocking": "oub", 4288 "packages": "pkg", 4289 "pages": "pg", 4290 "pull_requests": "pr", 4291 "repository_hooks": "rh", 4292 "repository_projects": "rp", 4293 "repository_pre_receive_hooks": "rprh", 4294 "secrets": "s", 4295 "secret_scanning_alerts": "ssa", 4296 "security_events": "se", 4297 "single_file": "sf", 4298 "statuses": "s", 4299 "team_discussions": "td", 4300 "vulnerability_alerts": "va", 4301 "workflows": "w" 4302 }, 4303 "created_at": ` + referenceTimeStr + `, 4304 "updated_at": ` + referenceTimeStr + `, 4305 "has_multiple_single_files": false, 4306 "suspended_by": { 4307 "login": "l", 4308 "id": 1, 4309 "avatar_url": "a", 4310 "gravatar_id": "g", 4311 "name": "n", 4312 "company": "c", 4313 "blog": "b", 4314 "location": "l", 4315 "email": "e", 4316 "hireable": true, 4317 "bio": "b", 4318 "twitter_username": "t", 4319 "public_repos": 1, 4320 "followers": 1, 4321 "following": 1, 4322 "created_at": ` + referenceTimeStr + `, 4323 "suspended_at": ` + referenceTimeStr + `, 4324 "url": "u" 4325 }, 4326 "suspended_at": ` + referenceTimeStr + ` 4327 } 4328 }` 4329 4330 testJSONMarshal(t, u, want) 4331 } 4332 4333 func TestMarketplacePurchaseEvent_Marshal(t *testing.T) { 4334 testJSONMarshal(t, &MarketplacePurchaseEvent{}, "{}") 4335 4336 u := &MarketplacePurchaseEvent{ 4337 Action: String("a"), 4338 EffectiveDate: &Timestamp{referenceTime}, 4339 MarketplacePurchase: &MarketplacePurchase{ 4340 BillingCycle: String("bc"), 4341 NextBillingDate: &Timestamp{referenceTime}, 4342 UnitCount: Int(1), 4343 Plan: &MarketplacePlan{ 4344 URL: String("u"), 4345 AccountsURL: String("au"), 4346 ID: Int64(1), 4347 Number: Int(1), 4348 Name: String("n"), 4349 Description: String("d"), 4350 MonthlyPriceInCents: Int(1), 4351 YearlyPriceInCents: Int(1), 4352 PriceModel: String("pm"), 4353 UnitName: String("un"), 4354 Bullets: &[]string{"b"}, 4355 State: String("s"), 4356 HasFreeTrial: Bool(false), 4357 }, 4358 OnFreeTrial: Bool(false), 4359 FreeTrialEndsOn: &Timestamp{referenceTime}, 4360 UpdatedAt: &Timestamp{referenceTime}, 4361 }, 4362 PreviousMarketplacePurchase: &MarketplacePurchase{ 4363 BillingCycle: String("bc"), 4364 NextBillingDate: &Timestamp{referenceTime}, 4365 UnitCount: Int(1), 4366 Plan: &MarketplacePlan{ 4367 URL: String("u"), 4368 AccountsURL: String("au"), 4369 ID: Int64(1), 4370 Number: Int(1), 4371 Name: String("n"), 4372 Description: String("d"), 4373 MonthlyPriceInCents: Int(1), 4374 YearlyPriceInCents: Int(1), 4375 PriceModel: String("pm"), 4376 UnitName: String("un"), 4377 Bullets: &[]string{"b"}, 4378 State: String("s"), 4379 HasFreeTrial: Bool(false), 4380 }, 4381 OnFreeTrial: Bool(false), 4382 FreeTrialEndsOn: &Timestamp{referenceTime}, 4383 UpdatedAt: &Timestamp{referenceTime}, 4384 }, 4385 Sender: &User{ 4386 Login: String("l"), 4387 ID: Int64(1), 4388 NodeID: String("n"), 4389 URL: String("u"), 4390 ReposURL: String("r"), 4391 EventsURL: String("e"), 4392 AvatarURL: String("a"), 4393 }, 4394 Installation: &Installation{ 4395 ID: Int64(1), 4396 NodeID: String("nid"), 4397 AppID: Int64(1), 4398 AppSlug: String("as"), 4399 TargetID: Int64(1), 4400 Account: &User{ 4401 Login: String("l"), 4402 ID: Int64(1), 4403 URL: String("u"), 4404 AvatarURL: String("a"), 4405 GravatarID: String("g"), 4406 Name: String("n"), 4407 Company: String("c"), 4408 Blog: String("b"), 4409 Location: String("l"), 4410 Email: String("e"), 4411 Hireable: Bool(true), 4412 Bio: String("b"), 4413 TwitterUsername: String("t"), 4414 PublicRepos: Int(1), 4415 Followers: Int(1), 4416 Following: Int(1), 4417 CreatedAt: &Timestamp{referenceTime}, 4418 SuspendedAt: &Timestamp{referenceTime}, 4419 }, 4420 AccessTokensURL: String("atu"), 4421 RepositoriesURL: String("ru"), 4422 HTMLURL: String("hu"), 4423 TargetType: String("tt"), 4424 SingleFileName: String("sfn"), 4425 RepositorySelection: String("rs"), 4426 Events: []string{"e"}, 4427 SingleFilePaths: []string{"s"}, 4428 Permissions: &InstallationPermissions{ 4429 Actions: String("a"), 4430 Administration: String("ad"), 4431 Checks: String("c"), 4432 Contents: String("co"), 4433 ContentReferences: String("cr"), 4434 Deployments: String("d"), 4435 Environments: String("e"), 4436 Issues: String("i"), 4437 Metadata: String("md"), 4438 Members: String("m"), 4439 OrganizationAdministration: String("oa"), 4440 OrganizationHooks: String("oh"), 4441 OrganizationPlan: String("op"), 4442 OrganizationPreReceiveHooks: String("opr"), 4443 OrganizationProjects: String("op"), 4444 OrganizationSecrets: String("os"), 4445 OrganizationSelfHostedRunners: String("osh"), 4446 OrganizationUserBlocking: String("oub"), 4447 Packages: String("pkg"), 4448 Pages: String("pg"), 4449 PullRequests: String("pr"), 4450 RepositoryHooks: String("rh"), 4451 RepositoryProjects: String("rp"), 4452 RepositoryPreReceiveHooks: String("rprh"), 4453 Secrets: String("s"), 4454 SecretScanningAlerts: String("ssa"), 4455 SecurityEvents: String("se"), 4456 SingleFile: String("sf"), 4457 Statuses: String("s"), 4458 TeamDiscussions: String("td"), 4459 VulnerabilityAlerts: String("va"), 4460 Workflows: String("w"), 4461 }, 4462 CreatedAt: &Timestamp{referenceTime}, 4463 UpdatedAt: &Timestamp{referenceTime}, 4464 HasMultipleSingleFiles: Bool(false), 4465 SuspendedBy: &User{ 4466 Login: String("l"), 4467 ID: Int64(1), 4468 URL: String("u"), 4469 AvatarURL: String("a"), 4470 GravatarID: String("g"), 4471 Name: String("n"), 4472 Company: String("c"), 4473 Blog: String("b"), 4474 Location: String("l"), 4475 Email: String("e"), 4476 Hireable: Bool(true), 4477 Bio: String("b"), 4478 TwitterUsername: String("t"), 4479 PublicRepos: Int(1), 4480 Followers: Int(1), 4481 Following: Int(1), 4482 CreatedAt: &Timestamp{referenceTime}, 4483 SuspendedAt: &Timestamp{referenceTime}, 4484 }, 4485 SuspendedAt: &Timestamp{referenceTime}, 4486 }, 4487 } 4488 4489 want := `{ 4490 "action": "a", 4491 "effective_date": ` + referenceTimeStr + `, 4492 "marketplace_purchase": { 4493 "billing_cycle": "bc", 4494 "next_billing_date": ` + referenceTimeStr + `, 4495 "unit_count": 1, 4496 "plan": { 4497 "url": "u", 4498 "accounts_url": "au", 4499 "id": 1, 4500 "number": 1, 4501 "name": "n", 4502 "description": "d", 4503 "monthly_price_in_cents": 1, 4504 "yearly_price_in_cents": 1, 4505 "price_model": "pm", 4506 "unit_name": "un", 4507 "bullets": [ 4508 "b" 4509 ], 4510 "state": "s", 4511 "has_free_trial": false 4512 }, 4513 "on_free_trial": false, 4514 "free_trial_ends_on": ` + referenceTimeStr + `, 4515 "updated_at": ` + referenceTimeStr + ` 4516 }, 4517 "previous_marketplace_purchase": { 4518 "billing_cycle": "bc", 4519 "next_billing_date": ` + referenceTimeStr + `, 4520 "unit_count": 1, 4521 "plan": { 4522 "url": "u", 4523 "accounts_url": "au", 4524 "id": 1, 4525 "number": 1, 4526 "name": "n", 4527 "description": "d", 4528 "monthly_price_in_cents": 1, 4529 "yearly_price_in_cents": 1, 4530 "price_model": "pm", 4531 "unit_name": "un", 4532 "bullets": [ 4533 "b" 4534 ], 4535 "state": "s", 4536 "has_free_trial": false 4537 }, 4538 "on_free_trial": false, 4539 "free_trial_ends_on": ` + referenceTimeStr + `, 4540 "updated_at": ` + referenceTimeStr + ` 4541 }, 4542 "sender": { 4543 "login": "l", 4544 "id": 1, 4545 "node_id": "n", 4546 "avatar_url": "a", 4547 "url": "u", 4548 "events_url": "e", 4549 "repos_url": "r" 4550 }, 4551 "installation": { 4552 "id": 1, 4553 "node_id": "nid", 4554 "app_id": 1, 4555 "app_slug": "as", 4556 "target_id": 1, 4557 "account": { 4558 "login": "l", 4559 "id": 1, 4560 "avatar_url": "a", 4561 "gravatar_id": "g", 4562 "name": "n", 4563 "company": "c", 4564 "blog": "b", 4565 "location": "l", 4566 "email": "e", 4567 "hireable": true, 4568 "bio": "b", 4569 "twitter_username": "t", 4570 "public_repos": 1, 4571 "followers": 1, 4572 "following": 1, 4573 "created_at": ` + referenceTimeStr + `, 4574 "suspended_at": ` + referenceTimeStr + `, 4575 "url": "u" 4576 }, 4577 "access_tokens_url": "atu", 4578 "repositories_url": "ru", 4579 "html_url": "hu", 4580 "target_type": "tt", 4581 "single_file_name": "sfn", 4582 "repository_selection": "rs", 4583 "events": [ 4584 "e" 4585 ], 4586 "single_file_paths": [ 4587 "s" 4588 ], 4589 "permissions": { 4590 "actions": "a", 4591 "administration": "ad", 4592 "checks": "c", 4593 "contents": "co", 4594 "content_references": "cr", 4595 "deployments": "d", 4596 "environments": "e", 4597 "issues": "i", 4598 "metadata": "md", 4599 "members": "m", 4600 "organization_administration": "oa", 4601 "organization_hooks": "oh", 4602 "organization_plan": "op", 4603 "organization_pre_receive_hooks": "opr", 4604 "organization_projects": "op", 4605 "organization_secrets": "os", 4606 "organization_self_hosted_runners": "osh", 4607 "organization_user_blocking": "oub", 4608 "packages": "pkg", 4609 "pages": "pg", 4610 "pull_requests": "pr", 4611 "repository_hooks": "rh", 4612 "repository_projects": "rp", 4613 "repository_pre_receive_hooks": "rprh", 4614 "secrets": "s", 4615 "secret_scanning_alerts": "ssa", 4616 "security_events": "se", 4617 "single_file": "sf", 4618 "statuses": "s", 4619 "team_discussions": "td", 4620 "vulnerability_alerts": "va", 4621 "workflows": "w" 4622 }, 4623 "created_at": ` + referenceTimeStr + `, 4624 "updated_at": ` + referenceTimeStr + `, 4625 "has_multiple_single_files": false, 4626 "suspended_by": { 4627 "login": "l", 4628 "id": 1, 4629 "avatar_url": "a", 4630 "gravatar_id": "g", 4631 "name": "n", 4632 "company": "c", 4633 "blog": "b", 4634 "location": "l", 4635 "email": "e", 4636 "hireable": true, 4637 "bio": "b", 4638 "twitter_username": "t", 4639 "public_repos": 1, 4640 "followers": 1, 4641 "following": 1, 4642 "created_at": ` + referenceTimeStr + `, 4643 "suspended_at": ` + referenceTimeStr + `, 4644 "url": "u" 4645 }, 4646 "suspended_at": ` + referenceTimeStr + ` 4647 } 4648 }` 4649 4650 testJSONMarshal(t, u, want) 4651 } 4652 4653 func TestOrganizationEvent_Marshal(t *testing.T) { 4654 testJSONMarshal(t, &OrganizationEvent{}, "{}") 4655 4656 u := &OrganizationEvent{ 4657 Action: String("a"), 4658 Invitation: &Invitation{ID: Int64(1)}, 4659 Membership: &Membership{ 4660 URL: String("url"), 4661 State: String("s"), 4662 Role: String("r"), 4663 OrganizationURL: String("ou"), 4664 Organization: &Organization{ 4665 BillingEmail: String("be"), 4666 Blog: String("b"), 4667 Company: String("c"), 4668 Email: String("e"), 4669 TwitterUsername: String("tu"), 4670 Location: String("loc"), 4671 Name: String("n"), 4672 Description: String("d"), 4673 IsVerified: Bool(true), 4674 HasOrganizationProjects: Bool(true), 4675 HasRepositoryProjects: Bool(true), 4676 DefaultRepoPermission: String("drp"), 4677 MembersCanCreateRepos: Bool(true), 4678 MembersCanCreateInternalRepos: Bool(true), 4679 MembersCanCreatePrivateRepos: Bool(true), 4680 MembersCanCreatePublicRepos: Bool(false), 4681 MembersAllowedRepositoryCreationType: String("marct"), 4682 MembersCanCreatePages: Bool(true), 4683 MembersCanCreatePublicPages: Bool(false), 4684 MembersCanCreatePrivatePages: Bool(true), 4685 }, 4686 User: &User{ 4687 Login: String("l"), 4688 ID: Int64(1), 4689 NodeID: String("n"), 4690 URL: String("u"), 4691 ReposURL: String("r"), 4692 EventsURL: String("e"), 4693 AvatarURL: String("a"), 4694 }, 4695 }, 4696 Organization: &Organization{ 4697 BillingEmail: String("be"), 4698 Blog: String("b"), 4699 Company: String("c"), 4700 Email: String("e"), 4701 TwitterUsername: String("tu"), 4702 Location: String("loc"), 4703 Name: String("n"), 4704 Description: String("d"), 4705 IsVerified: Bool(true), 4706 HasOrganizationProjects: Bool(true), 4707 HasRepositoryProjects: Bool(true), 4708 DefaultRepoPermission: String("drp"), 4709 MembersCanCreateRepos: Bool(true), 4710 MembersCanCreateInternalRepos: Bool(true), 4711 MembersCanCreatePrivateRepos: Bool(true), 4712 MembersCanCreatePublicRepos: Bool(false), 4713 MembersAllowedRepositoryCreationType: String("marct"), 4714 MembersCanCreatePages: Bool(true), 4715 MembersCanCreatePublicPages: Bool(false), 4716 MembersCanCreatePrivatePages: Bool(true), 4717 }, 4718 Sender: &User{ 4719 Login: String("l"), 4720 ID: Int64(1), 4721 NodeID: String("n"), 4722 URL: String("u"), 4723 ReposURL: String("r"), 4724 EventsURL: String("e"), 4725 AvatarURL: String("a"), 4726 }, 4727 Installation: &Installation{ 4728 ID: Int64(1), 4729 NodeID: String("nid"), 4730 AppID: Int64(1), 4731 AppSlug: String("as"), 4732 TargetID: Int64(1), 4733 Account: &User{ 4734 Login: String("l"), 4735 ID: Int64(1), 4736 URL: String("u"), 4737 AvatarURL: String("a"), 4738 GravatarID: String("g"), 4739 Name: String("n"), 4740 Company: String("c"), 4741 Blog: String("b"), 4742 Location: String("l"), 4743 Email: String("e"), 4744 Hireable: Bool(true), 4745 Bio: String("b"), 4746 TwitterUsername: String("t"), 4747 PublicRepos: Int(1), 4748 Followers: Int(1), 4749 Following: Int(1), 4750 CreatedAt: &Timestamp{referenceTime}, 4751 SuspendedAt: &Timestamp{referenceTime}, 4752 }, 4753 AccessTokensURL: String("atu"), 4754 RepositoriesURL: String("ru"), 4755 HTMLURL: String("hu"), 4756 TargetType: String("tt"), 4757 SingleFileName: String("sfn"), 4758 RepositorySelection: String("rs"), 4759 Events: []string{"e"}, 4760 SingleFilePaths: []string{"s"}, 4761 Permissions: &InstallationPermissions{ 4762 Actions: String("a"), 4763 Administration: String("ad"), 4764 Checks: String("c"), 4765 Contents: String("co"), 4766 ContentReferences: String("cr"), 4767 Deployments: String("d"), 4768 Environments: String("e"), 4769 Issues: String("i"), 4770 Metadata: String("md"), 4771 Members: String("m"), 4772 OrganizationAdministration: String("oa"), 4773 OrganizationHooks: String("oh"), 4774 OrganizationPlan: String("op"), 4775 OrganizationPreReceiveHooks: String("opr"), 4776 OrganizationProjects: String("op"), 4777 OrganizationSecrets: String("os"), 4778 OrganizationSelfHostedRunners: String("osh"), 4779 OrganizationUserBlocking: String("oub"), 4780 Packages: String("pkg"), 4781 Pages: String("pg"), 4782 PullRequests: String("pr"), 4783 RepositoryHooks: String("rh"), 4784 RepositoryProjects: String("rp"), 4785 RepositoryPreReceiveHooks: String("rprh"), 4786 Secrets: String("s"), 4787 SecretScanningAlerts: String("ssa"), 4788 SecurityEvents: String("se"), 4789 SingleFile: String("sf"), 4790 Statuses: String("s"), 4791 TeamDiscussions: String("td"), 4792 VulnerabilityAlerts: String("va"), 4793 Workflows: String("w"), 4794 }, 4795 CreatedAt: &Timestamp{referenceTime}, 4796 UpdatedAt: &Timestamp{referenceTime}, 4797 HasMultipleSingleFiles: Bool(false), 4798 SuspendedBy: &User{ 4799 Login: String("l"), 4800 ID: Int64(1), 4801 URL: String("u"), 4802 AvatarURL: String("a"), 4803 GravatarID: String("g"), 4804 Name: String("n"), 4805 Company: String("c"), 4806 Blog: String("b"), 4807 Location: String("l"), 4808 Email: String("e"), 4809 Hireable: Bool(true), 4810 Bio: String("b"), 4811 TwitterUsername: String("t"), 4812 PublicRepos: Int(1), 4813 Followers: Int(1), 4814 Following: Int(1), 4815 CreatedAt: &Timestamp{referenceTime}, 4816 SuspendedAt: &Timestamp{referenceTime}, 4817 }, 4818 SuspendedAt: &Timestamp{referenceTime}, 4819 }, 4820 } 4821 4822 want := `{ 4823 "action": "a", 4824 "invitation": { 4825 "id": 1 4826 }, 4827 "membership": { 4828 "url": "url", 4829 "state": "s", 4830 "role": "r", 4831 "organization_url": "ou", 4832 "organization": { 4833 "name": "n", 4834 "company": "c", 4835 "blog": "b", 4836 "location": "loc", 4837 "email": "e", 4838 "twitter_username": "tu", 4839 "description": "d", 4840 "billing_email": "be", 4841 "is_verified": true, 4842 "has_organization_projects": true, 4843 "has_repository_projects": true, 4844 "default_repository_permission": "drp", 4845 "members_can_create_repositories": true, 4846 "members_can_create_public_repositories": false, 4847 "members_can_create_private_repositories": true, 4848 "members_can_create_internal_repositories": true, 4849 "members_allowed_repository_creation_type": "marct", 4850 "members_can_create_pages": true, 4851 "members_can_create_public_pages": false, 4852 "members_can_create_private_pages": true 4853 }, 4854 "user": { 4855 "login": "l", 4856 "id": 1, 4857 "node_id": "n", 4858 "avatar_url": "a", 4859 "url": "u", 4860 "events_url": "e", 4861 "repos_url": "r" 4862 } 4863 }, 4864 "organization": { 4865 "name": "n", 4866 "company": "c", 4867 "blog": "b", 4868 "location": "loc", 4869 "email": "e", 4870 "twitter_username": "tu", 4871 "description": "d", 4872 "billing_email": "be", 4873 "is_verified": true, 4874 "has_organization_projects": true, 4875 "has_repository_projects": true, 4876 "default_repository_permission": "drp", 4877 "members_can_create_repositories": true, 4878 "members_can_create_public_repositories": false, 4879 "members_can_create_private_repositories": true, 4880 "members_can_create_internal_repositories": true, 4881 "members_allowed_repository_creation_type": "marct", 4882 "members_can_create_pages": true, 4883 "members_can_create_public_pages": false, 4884 "members_can_create_private_pages": true 4885 }, 4886 "sender": { 4887 "login": "l", 4888 "id": 1, 4889 "node_id": "n", 4890 "avatar_url": "a", 4891 "url": "u", 4892 "events_url": "e", 4893 "repos_url": "r" 4894 }, 4895 "installation": { 4896 "id": 1, 4897 "node_id": "nid", 4898 "app_id": 1, 4899 "app_slug": "as", 4900 "target_id": 1, 4901 "account": { 4902 "login": "l", 4903 "id": 1, 4904 "avatar_url": "a", 4905 "gravatar_id": "g", 4906 "name": "n", 4907 "company": "c", 4908 "blog": "b", 4909 "location": "l", 4910 "email": "e", 4911 "hireable": true, 4912 "bio": "b", 4913 "twitter_username": "t", 4914 "public_repos": 1, 4915 "followers": 1, 4916 "following": 1, 4917 "created_at": ` + referenceTimeStr + `, 4918 "suspended_at": ` + referenceTimeStr + `, 4919 "url": "u" 4920 }, 4921 "access_tokens_url": "atu", 4922 "repositories_url": "ru", 4923 "html_url": "hu", 4924 "target_type": "tt", 4925 "single_file_name": "sfn", 4926 "repository_selection": "rs", 4927 "events": [ 4928 "e" 4929 ], 4930 "single_file_paths": [ 4931 "s" 4932 ], 4933 "permissions": { 4934 "actions": "a", 4935 "administration": "ad", 4936 "checks": "c", 4937 "contents": "co", 4938 "content_references": "cr", 4939 "deployments": "d", 4940 "environments": "e", 4941 "issues": "i", 4942 "metadata": "md", 4943 "members": "m", 4944 "organization_administration": "oa", 4945 "organization_hooks": "oh", 4946 "organization_plan": "op", 4947 "organization_pre_receive_hooks": "opr", 4948 "organization_projects": "op", 4949 "organization_secrets": "os", 4950 "organization_self_hosted_runners": "osh", 4951 "organization_user_blocking": "oub", 4952 "packages": "pkg", 4953 "pages": "pg", 4954 "pull_requests": "pr", 4955 "repository_hooks": "rh", 4956 "repository_projects": "rp", 4957 "repository_pre_receive_hooks": "rprh", 4958 "secrets": "s", 4959 "secret_scanning_alerts": "ssa", 4960 "security_events": "se", 4961 "single_file": "sf", 4962 "statuses": "s", 4963 "team_discussions": "td", 4964 "vulnerability_alerts": "va", 4965 "workflows": "w" 4966 }, 4967 "created_at": ` + referenceTimeStr + `, 4968 "updated_at": ` + referenceTimeStr + `, 4969 "has_multiple_single_files": false, 4970 "suspended_by": { 4971 "login": "l", 4972 "id": 1, 4973 "avatar_url": "a", 4974 "gravatar_id": "g", 4975 "name": "n", 4976 "company": "c", 4977 "blog": "b", 4978 "location": "l", 4979 "email": "e", 4980 "hireable": true, 4981 "bio": "b", 4982 "twitter_username": "t", 4983 "public_repos": 1, 4984 "followers": 1, 4985 "following": 1, 4986 "created_at": ` + referenceTimeStr + `, 4987 "suspended_at": ` + referenceTimeStr + `, 4988 "url": "u" 4989 }, 4990 "suspended_at": ` + referenceTimeStr + ` 4991 } 4992 }` 4993 4994 testJSONMarshal(t, u, want) 4995 } 4996 4997 func TestPageBuildEvent_Marshal(t *testing.T) { 4998 testJSONMarshal(t, &PageBuildEvent{}, "{}") 4999 5000 u := &PageBuildEvent{ 5001 Build: &PagesBuild{URL: String("url")}, 5002 ID: Int64(1), 5003 Repo: &Repository{ 5004 ID: Int64(1), 5005 URL: String("s"), 5006 Name: String("n"), 5007 }, 5008 Sender: &User{ 5009 Login: String("l"), 5010 ID: Int64(1), 5011 NodeID: String("n"), 5012 URL: String("u"), 5013 ReposURL: String("r"), 5014 EventsURL: String("e"), 5015 AvatarURL: String("a"), 5016 }, 5017 Installation: &Installation{ 5018 ID: Int64(1), 5019 NodeID: String("nid"), 5020 AppID: Int64(1), 5021 AppSlug: String("as"), 5022 TargetID: Int64(1), 5023 Account: &User{ 5024 Login: String("l"), 5025 ID: Int64(1), 5026 URL: String("u"), 5027 AvatarURL: String("a"), 5028 GravatarID: String("g"), 5029 Name: String("n"), 5030 Company: String("c"), 5031 Blog: String("b"), 5032 Location: String("l"), 5033 Email: String("e"), 5034 Hireable: Bool(true), 5035 Bio: String("b"), 5036 TwitterUsername: String("t"), 5037 PublicRepos: Int(1), 5038 Followers: Int(1), 5039 Following: Int(1), 5040 CreatedAt: &Timestamp{referenceTime}, 5041 SuspendedAt: &Timestamp{referenceTime}, 5042 }, 5043 AccessTokensURL: String("atu"), 5044 RepositoriesURL: String("ru"), 5045 HTMLURL: String("hu"), 5046 TargetType: String("tt"), 5047 SingleFileName: String("sfn"), 5048 RepositorySelection: String("rs"), 5049 Events: []string{"e"}, 5050 SingleFilePaths: []string{"s"}, 5051 Permissions: &InstallationPermissions{ 5052 Actions: String("a"), 5053 Administration: String("ad"), 5054 Checks: String("c"), 5055 Contents: String("co"), 5056 ContentReferences: String("cr"), 5057 Deployments: String("d"), 5058 Environments: String("e"), 5059 Issues: String("i"), 5060 Metadata: String("md"), 5061 Members: String("m"), 5062 OrganizationAdministration: String("oa"), 5063 OrganizationHooks: String("oh"), 5064 OrganizationPlan: String("op"), 5065 OrganizationPreReceiveHooks: String("opr"), 5066 OrganizationProjects: String("op"), 5067 OrganizationSecrets: String("os"), 5068 OrganizationSelfHostedRunners: String("osh"), 5069 OrganizationUserBlocking: String("oub"), 5070 Packages: String("pkg"), 5071 Pages: String("pg"), 5072 PullRequests: String("pr"), 5073 RepositoryHooks: String("rh"), 5074 RepositoryProjects: String("rp"), 5075 RepositoryPreReceiveHooks: String("rprh"), 5076 Secrets: String("s"), 5077 SecretScanningAlerts: String("ssa"), 5078 SecurityEvents: String("se"), 5079 SingleFile: String("sf"), 5080 Statuses: String("s"), 5081 TeamDiscussions: String("td"), 5082 VulnerabilityAlerts: String("va"), 5083 Workflows: String("w"), 5084 }, 5085 CreatedAt: &Timestamp{referenceTime}, 5086 UpdatedAt: &Timestamp{referenceTime}, 5087 HasMultipleSingleFiles: Bool(false), 5088 SuspendedBy: &User{ 5089 Login: String("l"), 5090 ID: Int64(1), 5091 URL: String("u"), 5092 AvatarURL: String("a"), 5093 GravatarID: String("g"), 5094 Name: String("n"), 5095 Company: String("c"), 5096 Blog: String("b"), 5097 Location: String("l"), 5098 Email: String("e"), 5099 Hireable: Bool(true), 5100 Bio: String("b"), 5101 TwitterUsername: String("t"), 5102 PublicRepos: Int(1), 5103 Followers: Int(1), 5104 Following: Int(1), 5105 CreatedAt: &Timestamp{referenceTime}, 5106 SuspendedAt: &Timestamp{referenceTime}, 5107 }, 5108 SuspendedAt: &Timestamp{referenceTime}, 5109 }, 5110 } 5111 5112 want := `{ 5113 "build": { 5114 "url": "url" 5115 }, 5116 "id": 1, 5117 "repository": { 5118 "id": 1, 5119 "name": "n", 5120 "url": "s" 5121 }, 5122 "sender": { 5123 "login": "l", 5124 "id": 1, 5125 "node_id": "n", 5126 "avatar_url": "a", 5127 "url": "u", 5128 "events_url": "e", 5129 "repos_url": "r" 5130 }, 5131 "installation": { 5132 "id": 1, 5133 "node_id": "nid", 5134 "app_id": 1, 5135 "app_slug": "as", 5136 "target_id": 1, 5137 "account": { 5138 "login": "l", 5139 "id": 1, 5140 "avatar_url": "a", 5141 "gravatar_id": "g", 5142 "name": "n", 5143 "company": "c", 5144 "blog": "b", 5145 "location": "l", 5146 "email": "e", 5147 "hireable": true, 5148 "bio": "b", 5149 "twitter_username": "t", 5150 "public_repos": 1, 5151 "followers": 1, 5152 "following": 1, 5153 "created_at": ` + referenceTimeStr + `, 5154 "suspended_at": ` + referenceTimeStr + `, 5155 "url": "u" 5156 }, 5157 "access_tokens_url": "atu", 5158 "repositories_url": "ru", 5159 "html_url": "hu", 5160 "target_type": "tt", 5161 "single_file_name": "sfn", 5162 "repository_selection": "rs", 5163 "events": [ 5164 "e" 5165 ], 5166 "single_file_paths": [ 5167 "s" 5168 ], 5169 "permissions": { 5170 "actions": "a", 5171 "administration": "ad", 5172 "checks": "c", 5173 "contents": "co", 5174 "content_references": "cr", 5175 "deployments": "d", 5176 "environments": "e", 5177 "issues": "i", 5178 "metadata": "md", 5179 "members": "m", 5180 "organization_administration": "oa", 5181 "organization_hooks": "oh", 5182 "organization_plan": "op", 5183 "organization_pre_receive_hooks": "opr", 5184 "organization_projects": "op", 5185 "organization_secrets": "os", 5186 "organization_self_hosted_runners": "osh", 5187 "organization_user_blocking": "oub", 5188 "packages": "pkg", 5189 "pages": "pg", 5190 "pull_requests": "pr", 5191 "repository_hooks": "rh", 5192 "repository_projects": "rp", 5193 "repository_pre_receive_hooks": "rprh", 5194 "secrets": "s", 5195 "secret_scanning_alerts": "ssa", 5196 "security_events": "se", 5197 "single_file": "sf", 5198 "statuses": "s", 5199 "team_discussions": "td", 5200 "vulnerability_alerts": "va", 5201 "workflows": "w" 5202 }, 5203 "created_at": ` + referenceTimeStr + `, 5204 "updated_at": ` + referenceTimeStr + `, 5205 "has_multiple_single_files": false, 5206 "suspended_by": { 5207 "login": "l", 5208 "id": 1, 5209 "avatar_url": "a", 5210 "gravatar_id": "g", 5211 "name": "n", 5212 "company": "c", 5213 "blog": "b", 5214 "location": "l", 5215 "email": "e", 5216 "hireable": true, 5217 "bio": "b", 5218 "twitter_username": "t", 5219 "public_repos": 1, 5220 "followers": 1, 5221 "following": 1, 5222 "created_at": ` + referenceTimeStr + `, 5223 "suspended_at": ` + referenceTimeStr + `, 5224 "url": "u" 5225 }, 5226 "suspended_at": ` + referenceTimeStr + ` 5227 } 5228 }` 5229 5230 testJSONMarshal(t, u, want) 5231 } 5232 5233 func TestCommitCommentEvent_Marshal(t *testing.T) { 5234 testJSONMarshal(t, &CommitCommentEvent{}, "{}") 5235 5236 u := &CommitCommentEvent{ 5237 Comment: &RepositoryComment{ 5238 HTMLURL: String("hurl"), 5239 URL: String("url"), 5240 ID: Int64(1), 5241 NodeID: String("nid"), 5242 CommitID: String("cid"), 5243 User: &User{ 5244 Login: String("l"), 5245 ID: Int64(1), 5246 NodeID: String("n"), 5247 URL: String("u"), 5248 ReposURL: String("r"), 5249 EventsURL: String("e"), 5250 AvatarURL: String("a"), 5251 }, 5252 Reactions: &Reactions{ 5253 TotalCount: Int(1), 5254 PlusOne: Int(1), 5255 MinusOne: Int(1), 5256 Laugh: Int(1), 5257 Confused: Int(1), 5258 Heart: Int(1), 5259 Hooray: Int(1), 5260 Rocket: Int(1), 5261 Eyes: Int(1), 5262 URL: String("url"), 5263 }, 5264 CreatedAt: &Timestamp{referenceTime}, 5265 UpdatedAt: &Timestamp{referenceTime}, 5266 Body: String("b"), 5267 Path: String("path"), 5268 Position: Int(1), 5269 }, 5270 Action: String("a"), 5271 Repo: &Repository{ 5272 ID: Int64(1), 5273 URL: String("s"), 5274 Name: String("n"), 5275 }, 5276 Sender: &User{ 5277 Login: String("l"), 5278 ID: Int64(1), 5279 NodeID: String("n"), 5280 URL: String("u"), 5281 ReposURL: String("r"), 5282 EventsURL: String("e"), 5283 AvatarURL: String("a"), 5284 }, 5285 Installation: &Installation{ 5286 ID: Int64(1), 5287 NodeID: String("nid"), 5288 AppID: Int64(1), 5289 AppSlug: String("as"), 5290 TargetID: Int64(1), 5291 Account: &User{ 5292 Login: String("l"), 5293 ID: Int64(1), 5294 URL: String("u"), 5295 AvatarURL: String("a"), 5296 GravatarID: String("g"), 5297 Name: String("n"), 5298 Company: String("c"), 5299 Blog: String("b"), 5300 Location: String("l"), 5301 Email: String("e"), 5302 Hireable: Bool(true), 5303 Bio: String("b"), 5304 TwitterUsername: String("t"), 5305 PublicRepos: Int(1), 5306 Followers: Int(1), 5307 Following: Int(1), 5308 CreatedAt: &Timestamp{referenceTime}, 5309 SuspendedAt: &Timestamp{referenceTime}, 5310 }, 5311 AccessTokensURL: String("atu"), 5312 RepositoriesURL: String("ru"), 5313 HTMLURL: String("hu"), 5314 TargetType: String("tt"), 5315 SingleFileName: String("sfn"), 5316 RepositorySelection: String("rs"), 5317 Events: []string{"e"}, 5318 SingleFilePaths: []string{"s"}, 5319 Permissions: &InstallationPermissions{ 5320 Actions: String("a"), 5321 Administration: String("ad"), 5322 Checks: String("c"), 5323 Contents: String("co"), 5324 ContentReferences: String("cr"), 5325 Deployments: String("d"), 5326 Environments: String("e"), 5327 Issues: String("i"), 5328 Metadata: String("md"), 5329 Members: String("m"), 5330 OrganizationAdministration: String("oa"), 5331 OrganizationHooks: String("oh"), 5332 OrganizationPlan: String("op"), 5333 OrganizationPreReceiveHooks: String("opr"), 5334 OrganizationProjects: String("op"), 5335 OrganizationSecrets: String("os"), 5336 OrganizationSelfHostedRunners: String("osh"), 5337 OrganizationUserBlocking: String("oub"), 5338 Packages: String("pkg"), 5339 Pages: String("pg"), 5340 PullRequests: String("pr"), 5341 RepositoryHooks: String("rh"), 5342 RepositoryProjects: String("rp"), 5343 RepositoryPreReceiveHooks: String("rprh"), 5344 Secrets: String("s"), 5345 SecretScanningAlerts: String("ssa"), 5346 SecurityEvents: String("se"), 5347 SingleFile: String("sf"), 5348 Statuses: String("s"), 5349 TeamDiscussions: String("td"), 5350 VulnerabilityAlerts: String("va"), 5351 Workflows: String("w"), 5352 }, 5353 CreatedAt: &Timestamp{referenceTime}, 5354 UpdatedAt: &Timestamp{referenceTime}, 5355 HasMultipleSingleFiles: Bool(false), 5356 SuspendedBy: &User{ 5357 Login: String("l"), 5358 ID: Int64(1), 5359 URL: String("u"), 5360 AvatarURL: String("a"), 5361 GravatarID: String("g"), 5362 Name: String("n"), 5363 Company: String("c"), 5364 Blog: String("b"), 5365 Location: String("l"), 5366 Email: String("e"), 5367 Hireable: Bool(true), 5368 Bio: String("b"), 5369 TwitterUsername: String("t"), 5370 PublicRepos: Int(1), 5371 Followers: Int(1), 5372 Following: Int(1), 5373 CreatedAt: &Timestamp{referenceTime}, 5374 SuspendedAt: &Timestamp{referenceTime}, 5375 }, 5376 SuspendedAt: &Timestamp{referenceTime}, 5377 }, 5378 } 5379 5380 want := `{ 5381 "comment": { 5382 "html_url": "hurl", 5383 "url": "url", 5384 "id": 1, 5385 "node_id": "nid", 5386 "commit_id": "cid", 5387 "user": { 5388 "login": "l", 5389 "id": 1, 5390 "node_id": "n", 5391 "avatar_url": "a", 5392 "url": "u", 5393 "events_url": "e", 5394 "repos_url": "r" 5395 }, 5396 "reactions": { 5397 "total_count": 1, 5398 "+1": 1, 5399 "-1": 1, 5400 "laugh": 1, 5401 "confused": 1, 5402 "heart": 1, 5403 "hooray": 1, 5404 "rocket": 1, 5405 "eyes": 1, 5406 "url": "url" 5407 }, 5408 "created_at": ` + referenceTimeStr + `, 5409 "updated_at": ` + referenceTimeStr + `, 5410 "body": "b", 5411 "path": "path", 5412 "position": 1 5413 }, 5414 "action": "a", 5415 "repository": { 5416 "id": 1, 5417 "name": "n", 5418 "url": "s" 5419 }, 5420 "sender": { 5421 "login": "l", 5422 "id": 1, 5423 "node_id": "n", 5424 "avatar_url": "a", 5425 "url": "u", 5426 "events_url": "e", 5427 "repos_url": "r" 5428 }, 5429 "installation": { 5430 "id": 1, 5431 "node_id": "nid", 5432 "app_id": 1, 5433 "app_slug": "as", 5434 "target_id": 1, 5435 "account": { 5436 "login": "l", 5437 "id": 1, 5438 "avatar_url": "a", 5439 "gravatar_id": "g", 5440 "name": "n", 5441 "company": "c", 5442 "blog": "b", 5443 "location": "l", 5444 "email": "e", 5445 "hireable": true, 5446 "bio": "b", 5447 "twitter_username": "t", 5448 "public_repos": 1, 5449 "followers": 1, 5450 "following": 1, 5451 "created_at": ` + referenceTimeStr + `, 5452 "suspended_at": ` + referenceTimeStr + `, 5453 "url": "u" 5454 }, 5455 "access_tokens_url": "atu", 5456 "repositories_url": "ru", 5457 "html_url": "hu", 5458 "target_type": "tt", 5459 "single_file_name": "sfn", 5460 "repository_selection": "rs", 5461 "events": [ 5462 "e" 5463 ], 5464 "single_file_paths": [ 5465 "s" 5466 ], 5467 "permissions": { 5468 "actions": "a", 5469 "administration": "ad", 5470 "checks": "c", 5471 "contents": "co", 5472 "content_references": "cr", 5473 "deployments": "d", 5474 "environments": "e", 5475 "issues": "i", 5476 "metadata": "md", 5477 "members": "m", 5478 "organization_administration": "oa", 5479 "organization_hooks": "oh", 5480 "organization_plan": "op", 5481 "organization_pre_receive_hooks": "opr", 5482 "organization_projects": "op", 5483 "organization_secrets": "os", 5484 "organization_self_hosted_runners": "osh", 5485 "organization_user_blocking": "oub", 5486 "packages": "pkg", 5487 "pages": "pg", 5488 "pull_requests": "pr", 5489 "repository_hooks": "rh", 5490 "repository_projects": "rp", 5491 "repository_pre_receive_hooks": "rprh", 5492 "secrets": "s", 5493 "secret_scanning_alerts": "ssa", 5494 "security_events": "se", 5495 "single_file": "sf", 5496 "statuses": "s", 5497 "team_discussions": "td", 5498 "vulnerability_alerts": "va", 5499 "workflows": "w" 5500 }, 5501 "created_at": ` + referenceTimeStr + `, 5502 "updated_at": ` + referenceTimeStr + `, 5503 "has_multiple_single_files": false, 5504 "suspended_by": { 5505 "login": "l", 5506 "id": 1, 5507 "avatar_url": "a", 5508 "gravatar_id": "g", 5509 "name": "n", 5510 "company": "c", 5511 "blog": "b", 5512 "location": "l", 5513 "email": "e", 5514 "hireable": true, 5515 "bio": "b", 5516 "twitter_username": "t", 5517 "public_repos": 1, 5518 "followers": 1, 5519 "following": 1, 5520 "created_at": ` + referenceTimeStr + `, 5521 "suspended_at": ` + referenceTimeStr + `, 5522 "url": "u" 5523 }, 5524 "suspended_at": ` + referenceTimeStr + ` 5525 } 5526 }` 5527 5528 testJSONMarshal(t, u, want) 5529 } 5530 5531 func TestDeploymentEvent_Marshal(t *testing.T) { 5532 testJSONMarshal(t, &DeploymentEvent{}, "{}") 5533 5534 l := make(map[string]interface{}) 5535 l["key"] = "value" 5536 5537 jsonMsg, _ := json.Marshal(&l) 5538 5539 u := &DeploymentEvent{ 5540 Deployment: &Deployment{ 5541 URL: String("url"), 5542 ID: Int64(1), 5543 SHA: String("sha"), 5544 Ref: String("ref"), 5545 Task: String("t"), 5546 Payload: jsonMsg, 5547 Environment: String("e"), 5548 Description: String("d"), 5549 Creator: &User{ 5550 Login: String("l"), 5551 ID: Int64(1), 5552 NodeID: String("n"), 5553 URL: String("u"), 5554 ReposURL: String("r"), 5555 EventsURL: String("e"), 5556 AvatarURL: String("a"), 5557 }, 5558 CreatedAt: &Timestamp{referenceTime}, 5559 UpdatedAt: &Timestamp{referenceTime}, 5560 StatusesURL: String("surl"), 5561 RepositoryURL: String("rurl"), 5562 NodeID: String("nid"), 5563 }, 5564 Repo: &Repository{ 5565 ID: Int64(1), 5566 URL: String("s"), 5567 Name: String("n"), 5568 }, 5569 Sender: &User{ 5570 Login: String("l"), 5571 ID: Int64(1), 5572 NodeID: String("n"), 5573 URL: String("u"), 5574 ReposURL: String("r"), 5575 EventsURL: String("e"), 5576 AvatarURL: String("a"), 5577 }, 5578 Installation: &Installation{ 5579 ID: Int64(1), 5580 NodeID: String("nid"), 5581 AppID: Int64(1), 5582 AppSlug: String("as"), 5583 TargetID: Int64(1), 5584 Account: &User{ 5585 Login: String("l"), 5586 ID: Int64(1), 5587 URL: String("u"), 5588 AvatarURL: String("a"), 5589 GravatarID: String("g"), 5590 Name: String("n"), 5591 Company: String("c"), 5592 Blog: String("b"), 5593 Location: String("l"), 5594 Email: String("e"), 5595 Hireable: Bool(true), 5596 Bio: String("b"), 5597 TwitterUsername: String("t"), 5598 PublicRepos: Int(1), 5599 Followers: Int(1), 5600 Following: Int(1), 5601 CreatedAt: &Timestamp{referenceTime}, 5602 SuspendedAt: &Timestamp{referenceTime}, 5603 }, 5604 AccessTokensURL: String("atu"), 5605 RepositoriesURL: String("ru"), 5606 HTMLURL: String("hu"), 5607 TargetType: String("tt"), 5608 SingleFileName: String("sfn"), 5609 RepositorySelection: String("rs"), 5610 Events: []string{"e"}, 5611 SingleFilePaths: []string{"s"}, 5612 Permissions: &InstallationPermissions{ 5613 Actions: String("a"), 5614 Administration: String("ad"), 5615 Checks: String("c"), 5616 Contents: String("co"), 5617 ContentReferences: String("cr"), 5618 Deployments: String("d"), 5619 Environments: String("e"), 5620 Issues: String("i"), 5621 Metadata: String("md"), 5622 Members: String("m"), 5623 OrganizationAdministration: String("oa"), 5624 OrganizationHooks: String("oh"), 5625 OrganizationPlan: String("op"), 5626 OrganizationPreReceiveHooks: String("opr"), 5627 OrganizationProjects: String("op"), 5628 OrganizationSecrets: String("os"), 5629 OrganizationSelfHostedRunners: String("osh"), 5630 OrganizationUserBlocking: String("oub"), 5631 Packages: String("pkg"), 5632 Pages: String("pg"), 5633 PullRequests: String("pr"), 5634 RepositoryHooks: String("rh"), 5635 RepositoryProjects: String("rp"), 5636 RepositoryPreReceiveHooks: String("rprh"), 5637 Secrets: String("s"), 5638 SecretScanningAlerts: String("ssa"), 5639 SecurityEvents: String("se"), 5640 SingleFile: String("sf"), 5641 Statuses: String("s"), 5642 TeamDiscussions: String("td"), 5643 VulnerabilityAlerts: String("va"), 5644 Workflows: String("w"), 5645 }, 5646 CreatedAt: &Timestamp{referenceTime}, 5647 UpdatedAt: &Timestamp{referenceTime}, 5648 HasMultipleSingleFiles: Bool(false), 5649 SuspendedBy: &User{ 5650 Login: String("l"), 5651 ID: Int64(1), 5652 URL: String("u"), 5653 AvatarURL: String("a"), 5654 GravatarID: String("g"), 5655 Name: String("n"), 5656 Company: String("c"), 5657 Blog: String("b"), 5658 Location: String("l"), 5659 Email: String("e"), 5660 Hireable: Bool(true), 5661 Bio: String("b"), 5662 TwitterUsername: String("t"), 5663 PublicRepos: Int(1), 5664 Followers: Int(1), 5665 Following: Int(1), 5666 CreatedAt: &Timestamp{referenceTime}, 5667 SuspendedAt: &Timestamp{referenceTime}, 5668 }, 5669 SuspendedAt: &Timestamp{referenceTime}, 5670 }, 5671 Workflow: &Workflow{ 5672 ID: Int64(1), 5673 NodeID: String("nid"), 5674 Name: String("n"), 5675 Path: String("p"), 5676 State: String("s"), 5677 CreatedAt: &Timestamp{referenceTime}, 5678 UpdatedAt: &Timestamp{referenceTime}, 5679 URL: String("u"), 5680 HTMLURL: String("h"), 5681 BadgeURL: String("b"), 5682 }, 5683 WorkflowRun: &WorkflowRun{ 5684 ID: Int64(1), 5685 Name: String("n"), 5686 NodeID: String("nid"), 5687 HeadBranch: String("hb"), 5688 HeadSHA: String("hs"), 5689 RunNumber: Int(1), 5690 RunAttempt: Int(1), 5691 Event: String("e"), 5692 Status: String("s"), 5693 Conclusion: String("c"), 5694 WorkflowID: Int64(1), 5695 URL: String("u"), 5696 HTMLURL: String("h"), 5697 PullRequests: []*PullRequest{ 5698 { 5699 URL: String("u"), 5700 ID: Int64(1), 5701 Number: Int(1), 5702 Head: &PullRequestBranch{ 5703 Ref: String("r"), 5704 SHA: String("s"), 5705 Repo: &Repository{ 5706 ID: Int64(1), 5707 URL: String("s"), 5708 Name: String("n"), 5709 }, 5710 }, 5711 Base: &PullRequestBranch{ 5712 Ref: String("r"), 5713 SHA: String("s"), 5714 Repo: &Repository{ 5715 ID: Int64(1), 5716 URL: String("u"), 5717 Name: String("n"), 5718 }, 5719 }, 5720 }, 5721 }, 5722 CreatedAt: &Timestamp{referenceTime}, 5723 UpdatedAt: &Timestamp{referenceTime}, 5724 RunStartedAt: &Timestamp{referenceTime}, 5725 JobsURL: String("j"), 5726 LogsURL: String("l"), 5727 CheckSuiteURL: String("c"), 5728 ArtifactsURL: String("a"), 5729 CancelURL: String("c"), 5730 RerunURL: String("r"), 5731 PreviousAttemptURL: String("p"), 5732 HeadCommit: &HeadCommit{ 5733 Message: String("m"), 5734 Author: &CommitAuthor{ 5735 Name: String("n"), 5736 Email: String("e"), 5737 Login: String("l"), 5738 }, 5739 URL: String("u"), 5740 Distinct: Bool(false), 5741 SHA: String("s"), 5742 ID: String("i"), 5743 TreeID: String("tid"), 5744 Timestamp: &Timestamp{referenceTime}, 5745 Committer: &CommitAuthor{ 5746 Name: String("n"), 5747 Email: String("e"), 5748 Login: String("l"), 5749 }, 5750 }, 5751 WorkflowURL: String("w"), 5752 Repository: &Repository{ 5753 ID: Int64(1), 5754 URL: String("u"), 5755 Name: String("n"), 5756 }, 5757 HeadRepository: &Repository{ 5758 ID: Int64(1), 5759 URL: String("u"), 5760 Name: String("n"), 5761 }, 5762 }, 5763 } 5764 5765 want := `{ 5766 "deployment": { 5767 "url": "url", 5768 "id": 1, 5769 "sha": "sha", 5770 "ref": "ref", 5771 "task": "t", 5772 "payload": { 5773 "key": "value" 5774 }, 5775 "environment": "e", 5776 "description": "d", 5777 "creator": { 5778 "login": "l", 5779 "id": 1, 5780 "node_id": "n", 5781 "avatar_url": "a", 5782 "url": "u", 5783 "events_url": "e", 5784 "repos_url": "r" 5785 }, 5786 "created_at": ` + referenceTimeStr + `, 5787 "updated_at": ` + referenceTimeStr + `, 5788 "statuses_url": "surl", 5789 "repository_url": "rurl", 5790 "node_id": "nid" 5791 }, 5792 "repository": { 5793 "id": 1, 5794 "name": "n", 5795 "url": "s" 5796 }, 5797 "sender": { 5798 "login": "l", 5799 "id": 1, 5800 "node_id": "n", 5801 "avatar_url": "a", 5802 "url": "u", 5803 "events_url": "e", 5804 "repos_url": "r" 5805 }, 5806 "installation": { 5807 "id": 1, 5808 "node_id": "nid", 5809 "app_id": 1, 5810 "app_slug": "as", 5811 "target_id": 1, 5812 "account": { 5813 "login": "l", 5814 "id": 1, 5815 "avatar_url": "a", 5816 "gravatar_id": "g", 5817 "name": "n", 5818 "company": "c", 5819 "blog": "b", 5820 "location": "l", 5821 "email": "e", 5822 "hireable": true, 5823 "bio": "b", 5824 "twitter_username": "t", 5825 "public_repos": 1, 5826 "followers": 1, 5827 "following": 1, 5828 "created_at": ` + referenceTimeStr + `, 5829 "suspended_at": ` + referenceTimeStr + `, 5830 "url": "u" 5831 }, 5832 "access_tokens_url": "atu", 5833 "repositories_url": "ru", 5834 "html_url": "hu", 5835 "target_type": "tt", 5836 "single_file_name": "sfn", 5837 "repository_selection": "rs", 5838 "events": [ 5839 "e" 5840 ], 5841 "single_file_paths": [ 5842 "s" 5843 ], 5844 "permissions": { 5845 "actions": "a", 5846 "administration": "ad", 5847 "checks": "c", 5848 "contents": "co", 5849 "content_references": "cr", 5850 "deployments": "d", 5851 "environments": "e", 5852 "issues": "i", 5853 "metadata": "md", 5854 "members": "m", 5855 "organization_administration": "oa", 5856 "organization_hooks": "oh", 5857 "organization_plan": "op", 5858 "organization_pre_receive_hooks": "opr", 5859 "organization_projects": "op", 5860 "organization_secrets": "os", 5861 "organization_self_hosted_runners": "osh", 5862 "organization_user_blocking": "oub", 5863 "packages": "pkg", 5864 "pages": "pg", 5865 "pull_requests": "pr", 5866 "repository_hooks": "rh", 5867 "repository_projects": "rp", 5868 "repository_pre_receive_hooks": "rprh", 5869 "secrets": "s", 5870 "secret_scanning_alerts": "ssa", 5871 "security_events": "se", 5872 "single_file": "sf", 5873 "statuses": "s", 5874 "team_discussions": "td", 5875 "vulnerability_alerts": "va", 5876 "workflows": "w" 5877 }, 5878 "created_at": ` + referenceTimeStr + `, 5879 "updated_at": ` + referenceTimeStr + `, 5880 "has_multiple_single_files": false, 5881 "suspended_by": { 5882 "login": "l", 5883 "id": 1, 5884 "avatar_url": "a", 5885 "gravatar_id": "g", 5886 "name": "n", 5887 "company": "c", 5888 "blog": "b", 5889 "location": "l", 5890 "email": "e", 5891 "hireable": true, 5892 "bio": "b", 5893 "twitter_username": "t", 5894 "public_repos": 1, 5895 "followers": 1, 5896 "following": 1, 5897 "created_at": ` + referenceTimeStr + `, 5898 "suspended_at": ` + referenceTimeStr + `, 5899 "url": "u" 5900 }, 5901 "suspended_at": ` + referenceTimeStr + ` 5902 }, 5903 "workflow": { 5904 "id": 1, 5905 "node_id": "nid", 5906 "name": "n", 5907 "path": "p", 5908 "state": "s", 5909 "created_at": ` + referenceTimeStr + `, 5910 "updated_at": ` + referenceTimeStr + `, 5911 "url": "u", 5912 "html_url": "h", 5913 "badge_url": "b" 5914 }, 5915 "workflow_run": { 5916 "id": 1, 5917 "name": "n", 5918 "node_id": "nid", 5919 "head_branch": "hb", 5920 "head_sha": "hs", 5921 "run_number": 1, 5922 "run_attempt": 1, 5923 "event": "e", 5924 "status": "s", 5925 "conclusion": "c", 5926 "workflow_id": 1, 5927 "url": "u", 5928 "html_url": "h", 5929 "pull_requests": [ 5930 { 5931 "id": 1, 5932 "number": 1, 5933 "url": "u", 5934 "head": { 5935 "ref": "r", 5936 "sha": "s", 5937 "repo": { 5938 "id": 1, 5939 "name": "n", 5940 "url": "s" 5941 } 5942 }, 5943 "base": { 5944 "ref": "r", 5945 "sha": "s", 5946 "repo": { 5947 "id": 1, 5948 "name": "n", 5949 "url": "u" 5950 } 5951 } 5952 } 5953 ], 5954 "created_at": ` + referenceTimeStr + `, 5955 "updated_at": ` + referenceTimeStr + `, 5956 "run_started_at": ` + referenceTimeStr + `, 5957 "jobs_url": "j", 5958 "logs_url": "l", 5959 "check_suite_url": "c", 5960 "artifacts_url": "a", 5961 "cancel_url": "c", 5962 "rerun_url": "r", 5963 "previous_attempt_url": "p", 5964 "head_commit": { 5965 "message": "m", 5966 "author": { 5967 "name": "n", 5968 "email": "e", 5969 "username": "l" 5970 }, 5971 "url": "u", 5972 "distinct": false, 5973 "sha": "s", 5974 "id": "i", 5975 "tree_id": "tid", 5976 "timestamp": ` + referenceTimeStr + `, 5977 "committer": { 5978 "name": "n", 5979 "email": "e", 5980 "username": "l" 5981 } 5982 }, 5983 "workflow_url": "w", 5984 "repository": { 5985 "id": 1, 5986 "name": "n", 5987 "url": "u" 5988 }, 5989 "head_repository": { 5990 "id": 1, 5991 "name": "n", 5992 "url": "u" 5993 } 5994 } 5995 }` 5996 5997 testJSONMarshal(t, u, want) 5998 } 5999 6000 func TestDeploymentProtectionRuleEvent_Marshal(t *testing.T) { 6001 testJSONMarshal(t, &DeploymentProtectionRuleEvent{}, "{}") 6002 6003 l := make(map[string]interface{}) 6004 l["key"] = "value" 6005 6006 jsonMsg, _ := json.Marshal(&l) 6007 6008 u := &DeploymentProtectionRuleEvent{ 6009 Action: String("a"), 6010 Environment: String("e"), 6011 DeploymentCallbackURL: String("b"), 6012 Deployment: &Deployment{ 6013 URL: String("url"), 6014 ID: Int64(1), 6015 SHA: String("sha"), 6016 Ref: String("ref"), 6017 Task: String("t"), 6018 Payload: jsonMsg, 6019 Environment: String("e"), 6020 Description: String("d"), 6021 Creator: &User{ 6022 Login: String("l"), 6023 ID: Int64(1), 6024 NodeID: String("n"), 6025 URL: String("u"), 6026 ReposURL: String("r"), 6027 EventsURL: String("e"), 6028 AvatarURL: String("a"), 6029 }, 6030 CreatedAt: &Timestamp{referenceTime}, 6031 UpdatedAt: &Timestamp{referenceTime}, 6032 StatusesURL: String("surl"), 6033 RepositoryURL: String("rurl"), 6034 NodeID: String("nid"), 6035 }, 6036 Repo: &Repository{ 6037 ID: Int64(1), 6038 URL: String("s"), 6039 Name: String("n"), 6040 }, 6041 Organization: &Organization{ 6042 BillingEmail: String("be"), 6043 Blog: String("b"), 6044 Company: String("c"), 6045 Email: String("e"), 6046 TwitterUsername: String("tu"), 6047 Location: String("loc"), 6048 Name: String("n"), 6049 Description: String("d"), 6050 IsVerified: Bool(true), 6051 HasOrganizationProjects: Bool(true), 6052 HasRepositoryProjects: Bool(true), 6053 DefaultRepoPermission: String("drp"), 6054 MembersCanCreateRepos: Bool(true), 6055 MembersCanCreateInternalRepos: Bool(true), 6056 MembersCanCreatePrivateRepos: Bool(true), 6057 MembersCanCreatePublicRepos: Bool(false), 6058 MembersAllowedRepositoryCreationType: String("marct"), 6059 MembersCanCreatePages: Bool(true), 6060 MembersCanCreatePublicPages: Bool(false), 6061 MembersCanCreatePrivatePages: Bool(true), 6062 }, 6063 PullRequests: []*PullRequest{ 6064 { 6065 URL: String("u"), 6066 ID: Int64(1), 6067 Number: Int(1), 6068 Head: &PullRequestBranch{ 6069 Ref: String("r"), 6070 SHA: String("s"), 6071 Repo: &Repository{ 6072 ID: Int64(1), 6073 URL: String("s"), 6074 Name: String("n"), 6075 }, 6076 }, 6077 Base: &PullRequestBranch{ 6078 Ref: String("r"), 6079 SHA: String("s"), 6080 Repo: &Repository{ 6081 ID: Int64(1), 6082 URL: String("u"), 6083 Name: String("n"), 6084 }, 6085 }, 6086 }, 6087 }, 6088 Sender: &User{ 6089 Login: String("l"), 6090 ID: Int64(1), 6091 NodeID: String("n"), 6092 URL: String("u"), 6093 ReposURL: String("r"), 6094 EventsURL: String("e"), 6095 AvatarURL: String("a"), 6096 }, 6097 Installation: &Installation{ 6098 ID: Int64(1), 6099 NodeID: String("nid"), 6100 AppID: Int64(1), 6101 AppSlug: String("as"), 6102 TargetID: Int64(1), 6103 Account: &User{ 6104 Login: String("l"), 6105 ID: Int64(1), 6106 URL: String("u"), 6107 AvatarURL: String("a"), 6108 GravatarID: String("g"), 6109 Name: String("n"), 6110 Company: String("c"), 6111 Blog: String("b"), 6112 Location: String("l"), 6113 Email: String("e"), 6114 Hireable: Bool(true), 6115 Bio: String("b"), 6116 TwitterUsername: String("t"), 6117 PublicRepos: Int(1), 6118 Followers: Int(1), 6119 Following: Int(1), 6120 CreatedAt: &Timestamp{referenceTime}, 6121 SuspendedAt: &Timestamp{referenceTime}, 6122 }, 6123 AccessTokensURL: String("atu"), 6124 RepositoriesURL: String("ru"), 6125 HTMLURL: String("hu"), 6126 TargetType: String("tt"), 6127 SingleFileName: String("sfn"), 6128 RepositorySelection: String("rs"), 6129 Events: []string{"e"}, 6130 SingleFilePaths: []string{"s"}, 6131 Permissions: &InstallationPermissions{ 6132 Actions: String("a"), 6133 Administration: String("ad"), 6134 Checks: String("c"), 6135 Contents: String("co"), 6136 ContentReferences: String("cr"), 6137 Deployments: String("d"), 6138 Environments: String("e"), 6139 Issues: String("i"), 6140 Metadata: String("md"), 6141 Members: String("m"), 6142 OrganizationAdministration: String("oa"), 6143 OrganizationHooks: String("oh"), 6144 OrganizationPlan: String("op"), 6145 OrganizationPreReceiveHooks: String("opr"), 6146 OrganizationProjects: String("op"), 6147 OrganizationSecrets: String("os"), 6148 OrganizationSelfHostedRunners: String("osh"), 6149 OrganizationUserBlocking: String("oub"), 6150 Packages: String("pkg"), 6151 Pages: String("pg"), 6152 PullRequests: String("pr"), 6153 RepositoryHooks: String("rh"), 6154 RepositoryProjects: String("rp"), 6155 RepositoryPreReceiveHooks: String("rprh"), 6156 Secrets: String("s"), 6157 SecretScanningAlerts: String("ssa"), 6158 SecurityEvents: String("se"), 6159 SingleFile: String("sf"), 6160 Statuses: String("s"), 6161 TeamDiscussions: String("td"), 6162 VulnerabilityAlerts: String("va"), 6163 Workflows: String("w"), 6164 }, 6165 CreatedAt: &Timestamp{referenceTime}, 6166 UpdatedAt: &Timestamp{referenceTime}, 6167 HasMultipleSingleFiles: Bool(false), 6168 SuspendedBy: &User{ 6169 Login: String("l"), 6170 ID: Int64(1), 6171 URL: String("u"), 6172 AvatarURL: String("a"), 6173 GravatarID: String("g"), 6174 Name: String("n"), 6175 Company: String("c"), 6176 Blog: String("b"), 6177 Location: String("l"), 6178 Email: String("e"), 6179 Hireable: Bool(true), 6180 Bio: String("b"), 6181 TwitterUsername: String("t"), 6182 PublicRepos: Int(1), 6183 Followers: Int(1), 6184 Following: Int(1), 6185 CreatedAt: &Timestamp{referenceTime}, 6186 SuspendedAt: &Timestamp{referenceTime}, 6187 }, 6188 SuspendedAt: &Timestamp{referenceTime}, 6189 }, 6190 } 6191 6192 want := `{ 6193 "action": "a", 6194 "environment": "e", 6195 "deployment_callback_url": "b", 6196 "deployment": { 6197 "url": "url", 6198 "id": 1, 6199 "sha": "sha", 6200 "ref": "ref", 6201 "task": "t", 6202 "payload": { 6203 "key": "value" 6204 }, 6205 "environment": "e", 6206 "description": "d", 6207 "creator": { 6208 "login": "l", 6209 "id": 1, 6210 "node_id": "n", 6211 "avatar_url": "a", 6212 "url": "u", 6213 "events_url": "e", 6214 "repos_url": "r" 6215 }, 6216 "created_at": ` + referenceTimeStr + `, 6217 "updated_at": ` + referenceTimeStr + `, 6218 "statuses_url": "surl", 6219 "repository_url": "rurl", 6220 "node_id": "nid" 6221 }, 6222 "repository": { 6223 "id": 1, 6224 "name": "n", 6225 "url": "s" 6226 }, 6227 "organization": { 6228 "name": "n", 6229 "company": "c", 6230 "blog": "b", 6231 "location": "loc", 6232 "email": "e", 6233 "twitter_username": "tu", 6234 "description": "d", 6235 "billing_email": "be", 6236 "is_verified": true, 6237 "has_organization_projects": true, 6238 "has_repository_projects": true, 6239 "default_repository_permission": "drp", 6240 "members_can_create_repositories": true, 6241 "members_can_create_public_repositories": false, 6242 "members_can_create_private_repositories": true, 6243 "members_can_create_internal_repositories": true, 6244 "members_allowed_repository_creation_type": "marct", 6245 "members_can_create_pages": true, 6246 "members_can_create_public_pages": false, 6247 "members_can_create_private_pages": true 6248 }, 6249 "pull_requests": [ 6250 { 6251 "id": 1, 6252 "number": 1, 6253 "url": "u", 6254 "head": { 6255 "ref": "r", 6256 "sha": "s", 6257 "repo": { 6258 "id": 1, 6259 "name": "n", 6260 "url": "s" 6261 } 6262 }, 6263 "base": { 6264 "ref": "r", 6265 "sha": "s", 6266 "repo": { 6267 "id": 1, 6268 "name": "n", 6269 "url": "u" 6270 } 6271 } 6272 } 6273 ], 6274 "sender": { 6275 "login": "l", 6276 "id": 1, 6277 "node_id": "n", 6278 "avatar_url": "a", 6279 "url": "u", 6280 "events_url": "e", 6281 "repos_url": "r" 6282 }, 6283 "installation": { 6284 "id": 1, 6285 "node_id": "nid", 6286 "app_id": 1, 6287 "app_slug": "as", 6288 "target_id": 1, 6289 "account": { 6290 "login": "l", 6291 "id": 1, 6292 "avatar_url": "a", 6293 "gravatar_id": "g", 6294 "name": "n", 6295 "company": "c", 6296 "blog": "b", 6297 "location": "l", 6298 "email": "e", 6299 "hireable": true, 6300 "bio": "b", 6301 "twitter_username": "t", 6302 "public_repos": 1, 6303 "followers": 1, 6304 "following": 1, 6305 "created_at": ` + referenceTimeStr + `, 6306 "suspended_at": ` + referenceTimeStr + `, 6307 "url": "u" 6308 }, 6309 "access_tokens_url": "atu", 6310 "repositories_url": "ru", 6311 "html_url": "hu", 6312 "target_type": "tt", 6313 "single_file_name": "sfn", 6314 "repository_selection": "rs", 6315 "events": [ 6316 "e" 6317 ], 6318 "single_file_paths": [ 6319 "s" 6320 ], 6321 "permissions": { 6322 "actions": "a", 6323 "administration": "ad", 6324 "checks": "c", 6325 "contents": "co", 6326 "content_references": "cr", 6327 "deployments": "d", 6328 "environments": "e", 6329 "issues": "i", 6330 "metadata": "md", 6331 "members": "m", 6332 "organization_administration": "oa", 6333 "organization_hooks": "oh", 6334 "organization_plan": "op", 6335 "organization_pre_receive_hooks": "opr", 6336 "organization_projects": "op", 6337 "organization_secrets": "os", 6338 "organization_self_hosted_runners": "osh", 6339 "organization_user_blocking": "oub", 6340 "packages": "pkg", 6341 "pages": "pg", 6342 "pull_requests": "pr", 6343 "repository_hooks": "rh", 6344 "repository_projects": "rp", 6345 "repository_pre_receive_hooks": "rprh", 6346 "secrets": "s", 6347 "secret_scanning_alerts": "ssa", 6348 "security_events": "se", 6349 "single_file": "sf", 6350 "statuses": "s", 6351 "team_discussions": "td", 6352 "vulnerability_alerts": "va", 6353 "workflows": "w" 6354 }, 6355 "created_at": ` + referenceTimeStr + `, 6356 "updated_at": ` + referenceTimeStr + `, 6357 "has_multiple_single_files": false, 6358 "suspended_by": { 6359 "login": "l", 6360 "id": 1, 6361 "avatar_url": "a", 6362 "gravatar_id": "g", 6363 "name": "n", 6364 "company": "c", 6365 "blog": "b", 6366 "location": "l", 6367 "email": "e", 6368 "hireable": true, 6369 "bio": "b", 6370 "twitter_username": "t", 6371 "public_repos": 1, 6372 "followers": 1, 6373 "following": 1, 6374 "created_at": ` + referenceTimeStr + `, 6375 "suspended_at": ` + referenceTimeStr + `, 6376 "url": "u" 6377 }, 6378 "suspended_at": ` + referenceTimeStr + ` 6379 } 6380 }` 6381 6382 testJSONMarshal(t, u, want) 6383 } 6384 6385 func TestDeploymentStatusEvent_Marshal(t *testing.T) { 6386 testJSONMarshal(t, &DeploymentStatusEvent{}, "{}") 6387 6388 l := make(map[string]interface{}) 6389 l["key"] = "value" 6390 6391 jsonMsg, _ := json.Marshal(&l) 6392 6393 u := &DeploymentStatusEvent{ 6394 Deployment: &Deployment{ 6395 URL: String("url"), 6396 ID: Int64(1), 6397 SHA: String("sha"), 6398 Ref: String("ref"), 6399 Task: String("t"), 6400 Payload: jsonMsg, 6401 Environment: String("e"), 6402 Description: String("d"), 6403 Creator: &User{ 6404 Login: String("l"), 6405 ID: Int64(1), 6406 NodeID: String("n"), 6407 URL: String("u"), 6408 ReposURL: String("r"), 6409 EventsURL: String("e"), 6410 AvatarURL: String("a"), 6411 }, 6412 CreatedAt: &Timestamp{referenceTime}, 6413 UpdatedAt: &Timestamp{referenceTime}, 6414 StatusesURL: String("surl"), 6415 RepositoryURL: String("rurl"), 6416 NodeID: String("nid"), 6417 }, 6418 DeploymentStatus: &DeploymentStatus{ 6419 ID: Int64(1), 6420 State: String("s"), 6421 Creator: &User{ 6422 Login: String("l"), 6423 ID: Int64(1), 6424 NodeID: String("n"), 6425 URL: String("u"), 6426 ReposURL: String("r"), 6427 EventsURL: String("e"), 6428 AvatarURL: String("a"), 6429 }, 6430 Description: String("s"), 6431 Environment: String("s"), 6432 NodeID: String("s"), 6433 CreatedAt: &Timestamp{referenceTime}, 6434 UpdatedAt: &Timestamp{referenceTime}, 6435 TargetURL: String("s"), 6436 DeploymentURL: String("s"), 6437 RepositoryURL: String("s"), 6438 EnvironmentURL: String("s"), 6439 LogURL: String("s"), 6440 URL: String("s"), 6441 }, 6442 Repo: &Repository{ 6443 ID: Int64(1), 6444 URL: String("s"), 6445 Name: String("n"), 6446 }, 6447 Sender: &User{ 6448 Login: String("l"), 6449 ID: Int64(1), 6450 NodeID: String("n"), 6451 URL: String("u"), 6452 ReposURL: String("r"), 6453 EventsURL: String("e"), 6454 AvatarURL: String("a"), 6455 }, 6456 Installation: &Installation{ 6457 ID: Int64(1), 6458 NodeID: String("nid"), 6459 AppID: Int64(1), 6460 AppSlug: String("as"), 6461 TargetID: Int64(1), 6462 Account: &User{ 6463 Login: String("l"), 6464 ID: Int64(1), 6465 URL: String("u"), 6466 AvatarURL: String("a"), 6467 GravatarID: String("g"), 6468 Name: String("n"), 6469 Company: String("c"), 6470 Blog: String("b"), 6471 Location: String("l"), 6472 Email: String("e"), 6473 Hireable: Bool(true), 6474 Bio: String("b"), 6475 TwitterUsername: String("t"), 6476 PublicRepos: Int(1), 6477 Followers: Int(1), 6478 Following: Int(1), 6479 CreatedAt: &Timestamp{referenceTime}, 6480 SuspendedAt: &Timestamp{referenceTime}, 6481 }, 6482 AccessTokensURL: String("atu"), 6483 RepositoriesURL: String("ru"), 6484 HTMLURL: String("hu"), 6485 TargetType: String("tt"), 6486 SingleFileName: String("sfn"), 6487 RepositorySelection: String("rs"), 6488 Events: []string{"e"}, 6489 SingleFilePaths: []string{"s"}, 6490 Permissions: &InstallationPermissions{ 6491 Actions: String("a"), 6492 Administration: String("ad"), 6493 Checks: String("c"), 6494 Contents: String("co"), 6495 ContentReferences: String("cr"), 6496 Deployments: String("d"), 6497 Environments: String("e"), 6498 Issues: String("i"), 6499 Metadata: String("md"), 6500 Members: String("m"), 6501 OrganizationAdministration: String("oa"), 6502 OrganizationHooks: String("oh"), 6503 OrganizationPlan: String("op"), 6504 OrganizationPreReceiveHooks: String("opr"), 6505 OrganizationProjects: String("op"), 6506 OrganizationSecrets: String("os"), 6507 OrganizationSelfHostedRunners: String("osh"), 6508 OrganizationUserBlocking: String("oub"), 6509 Packages: String("pkg"), 6510 Pages: String("pg"), 6511 PullRequests: String("pr"), 6512 RepositoryHooks: String("rh"), 6513 RepositoryProjects: String("rp"), 6514 RepositoryPreReceiveHooks: String("rprh"), 6515 Secrets: String("s"), 6516 SecretScanningAlerts: String("ssa"), 6517 SecurityEvents: String("se"), 6518 SingleFile: String("sf"), 6519 Statuses: String("s"), 6520 TeamDiscussions: String("td"), 6521 VulnerabilityAlerts: String("va"), 6522 Workflows: String("w"), 6523 }, 6524 CreatedAt: &Timestamp{referenceTime}, 6525 UpdatedAt: &Timestamp{referenceTime}, 6526 HasMultipleSingleFiles: Bool(false), 6527 SuspendedBy: &User{ 6528 Login: String("l"), 6529 ID: Int64(1), 6530 URL: String("u"), 6531 AvatarURL: String("a"), 6532 GravatarID: String("g"), 6533 Name: String("n"), 6534 Company: String("c"), 6535 Blog: String("b"), 6536 Location: String("l"), 6537 Email: String("e"), 6538 Hireable: Bool(true), 6539 Bio: String("b"), 6540 TwitterUsername: String("t"), 6541 PublicRepos: Int(1), 6542 Followers: Int(1), 6543 Following: Int(1), 6544 CreatedAt: &Timestamp{referenceTime}, 6545 SuspendedAt: &Timestamp{referenceTime}, 6546 }, 6547 SuspendedAt: &Timestamp{referenceTime}, 6548 }, 6549 } 6550 6551 want := `{ 6552 "deployment": { 6553 "url": "url", 6554 "id": 1, 6555 "sha": "sha", 6556 "ref": "ref", 6557 "task": "t", 6558 "payload": { 6559 "key": "value" 6560 }, 6561 "environment": "e", 6562 "description": "d", 6563 "creator": { 6564 "login": "l", 6565 "id": 1, 6566 "node_id": "n", 6567 "avatar_url": "a", 6568 "url": "u", 6569 "events_url": "e", 6570 "repos_url": "r" 6571 }, 6572 "created_at": ` + referenceTimeStr + `, 6573 "updated_at": ` + referenceTimeStr + `, 6574 "statuses_url": "surl", 6575 "repository_url": "rurl", 6576 "node_id": "nid" 6577 }, 6578 "deployment_status": { 6579 "id": 1, 6580 "state": "s", 6581 "creator": { 6582 "login": "l", 6583 "id": 1, 6584 "node_id": "n", 6585 "avatar_url": "a", 6586 "url": "u", 6587 "events_url": "e", 6588 "repos_url": "r" 6589 }, 6590 "description": "s", 6591 "environment": "s", 6592 "node_id": "s", 6593 "created_at": ` + referenceTimeStr + `, 6594 "updated_at": ` + referenceTimeStr + `, 6595 "target_url": "s", 6596 "deployment_url": "s", 6597 "repository_url": "s", 6598 "environment_url": "s", 6599 "log_url": "s", 6600 "url": "s" 6601 }, 6602 "repository": { 6603 "id": 1, 6604 "name": "n", 6605 "url": "s" 6606 }, 6607 "sender": { 6608 "login": "l", 6609 "id": 1, 6610 "node_id": "n", 6611 "avatar_url": "a", 6612 "url": "u", 6613 "events_url": "e", 6614 "repos_url": "r" 6615 }, 6616 "installation": { 6617 "id": 1, 6618 "node_id": "nid", 6619 "app_id": 1, 6620 "app_slug": "as", 6621 "target_id": 1, 6622 "account": { 6623 "login": "l", 6624 "id": 1, 6625 "avatar_url": "a", 6626 "gravatar_id": "g", 6627 "name": "n", 6628 "company": "c", 6629 "blog": "b", 6630 "location": "l", 6631 "email": "e", 6632 "hireable": true, 6633 "bio": "b", 6634 "twitter_username": "t", 6635 "public_repos": 1, 6636 "followers": 1, 6637 "following": 1, 6638 "created_at": ` + referenceTimeStr + `, 6639 "suspended_at": ` + referenceTimeStr + `, 6640 "url": "u" 6641 }, 6642 "access_tokens_url": "atu", 6643 "repositories_url": "ru", 6644 "html_url": "hu", 6645 "target_type": "tt", 6646 "single_file_name": "sfn", 6647 "repository_selection": "rs", 6648 "events": [ 6649 "e" 6650 ], 6651 "single_file_paths": [ 6652 "s" 6653 ], 6654 "permissions": { 6655 "actions": "a", 6656 "administration": "ad", 6657 "checks": "c", 6658 "contents": "co", 6659 "content_references": "cr", 6660 "deployments": "d", 6661 "environments": "e", 6662 "issues": "i", 6663 "metadata": "md", 6664 "members": "m", 6665 "organization_administration": "oa", 6666 "organization_hooks": "oh", 6667 "organization_plan": "op", 6668 "organization_pre_receive_hooks": "opr", 6669 "organization_projects": "op", 6670 "organization_secrets": "os", 6671 "organization_self_hosted_runners": "osh", 6672 "organization_user_blocking": "oub", 6673 "packages": "pkg", 6674 "pages": "pg", 6675 "pull_requests": "pr", 6676 "repository_hooks": "rh", 6677 "repository_projects": "rp", 6678 "repository_pre_receive_hooks": "rprh", 6679 "secrets": "s", 6680 "secret_scanning_alerts": "ssa", 6681 "security_events": "se", 6682 "single_file": "sf", 6683 "statuses": "s", 6684 "team_discussions": "td", 6685 "vulnerability_alerts": "va", 6686 "workflows": "w" 6687 }, 6688 "created_at": ` + referenceTimeStr + `, 6689 "updated_at": ` + referenceTimeStr + `, 6690 "has_multiple_single_files": false, 6691 "suspended_by": { 6692 "login": "l", 6693 "id": 1, 6694 "avatar_url": "a", 6695 "gravatar_id": "g", 6696 "name": "n", 6697 "company": "c", 6698 "blog": "b", 6699 "location": "l", 6700 "email": "e", 6701 "hireable": true, 6702 "bio": "b", 6703 "twitter_username": "t", 6704 "public_repos": 1, 6705 "followers": 1, 6706 "following": 1, 6707 "created_at": ` + referenceTimeStr + `, 6708 "suspended_at": ` + referenceTimeStr + `, 6709 "url": "u" 6710 }, 6711 "suspended_at": ` + referenceTimeStr + ` 6712 } 6713 }` 6714 6715 testJSONMarshal(t, u, want) 6716 } 6717 6718 func TestDiscussionCommentEvent_Marshal(t *testing.T) { 6719 testJSONMarshal(t, &DiscussionCommentEvent{}, "{}") 6720 6721 u := &DiscussionCommentEvent{ 6722 Comment: &CommentDiscussion{ 6723 AuthorAssociation: String("aa"), 6724 Body: String("bo"), 6725 ChildCommentCount: Int(1), 6726 CreatedAt: &Timestamp{referenceTime}, 6727 DiscussionID: Int64(1), 6728 HTMLURL: String("hurl"), 6729 ID: Int64(1), 6730 NodeID: String("nid"), 6731 ParentID: Int64(1), 6732 Reactions: &Reactions{ 6733 TotalCount: Int(1), 6734 PlusOne: Int(1), 6735 MinusOne: Int(1), 6736 Laugh: Int(1), 6737 Confused: Int(1), 6738 Heart: Int(1), 6739 Hooray: Int(1), 6740 Rocket: Int(1), 6741 Eyes: Int(1), 6742 URL: String("url"), 6743 }, 6744 RepositoryURL: String("rurl"), 6745 UpdatedAt: &Timestamp{referenceTime}, 6746 User: &User{ 6747 Login: String("l"), 6748 ID: Int64(1), 6749 NodeID: String("n"), 6750 URL: String("u"), 6751 ReposURL: String("r"), 6752 EventsURL: String("e"), 6753 AvatarURL: String("a"), 6754 }, 6755 }, 6756 Discussion: &Discussion{ 6757 RepositoryURL: String("rurl"), 6758 DiscussionCategory: &DiscussionCategory{ 6759 ID: Int64(1), 6760 NodeID: String("nid"), 6761 RepositoryID: Int64(1), 6762 Emoji: String("emoji"), 6763 Name: String("name"), 6764 Description: String("description"), 6765 CreatedAt: &Timestamp{referenceTime}, 6766 UpdatedAt: &Timestamp{referenceTime}, 6767 Slug: String("slug"), 6768 IsAnswerable: Bool(false), 6769 }, 6770 HTMLURL: String("hurl"), 6771 ID: Int64(1), 6772 NodeID: String("nurl"), 6773 Number: Int(1), 6774 Title: String("title"), 6775 User: &User{ 6776 Login: String("l"), 6777 ID: Int64(1), 6778 NodeID: String("n"), 6779 URL: String("u"), 6780 ReposURL: String("r"), 6781 EventsURL: String("e"), 6782 AvatarURL: String("a"), 6783 }, 6784 State: String("st"), 6785 Locked: Bool(false), 6786 Comments: Int(1), 6787 CreatedAt: &Timestamp{referenceTime}, 6788 UpdatedAt: &Timestamp{referenceTime}, 6789 AuthorAssociation: String("aa"), 6790 Body: String("bo"), 6791 }, 6792 Repo: &Repository{ 6793 ID: Int64(1), 6794 URL: String("s"), 6795 Name: String("n"), 6796 }, 6797 Org: &Organization{ 6798 BillingEmail: String("be"), 6799 Blog: String("b"), 6800 Company: String("c"), 6801 Email: String("e"), 6802 TwitterUsername: String("tu"), 6803 Location: String("loc"), 6804 Name: String("n"), 6805 Description: String("d"), 6806 IsVerified: Bool(true), 6807 HasOrganizationProjects: Bool(true), 6808 HasRepositoryProjects: Bool(true), 6809 DefaultRepoPermission: String("drp"), 6810 MembersCanCreateRepos: Bool(true), 6811 MembersCanCreateInternalRepos: Bool(true), 6812 MembersCanCreatePrivateRepos: Bool(true), 6813 MembersCanCreatePublicRepos: Bool(false), 6814 MembersAllowedRepositoryCreationType: String("marct"), 6815 MembersCanCreatePages: Bool(true), 6816 MembersCanCreatePublicPages: Bool(false), 6817 MembersCanCreatePrivatePages: Bool(true), 6818 }, 6819 Sender: &User{ 6820 Login: String("l"), 6821 ID: Int64(1), 6822 NodeID: String("n"), 6823 URL: String("u"), 6824 ReposURL: String("r"), 6825 EventsURL: String("e"), 6826 AvatarURL: String("a"), 6827 }, 6828 Installation: &Installation{ 6829 ID: Int64(1), 6830 NodeID: String("nid"), 6831 AppID: Int64(1), 6832 AppSlug: String("as"), 6833 TargetID: Int64(1), 6834 Account: &User{ 6835 Login: String("l"), 6836 ID: Int64(1), 6837 URL: String("u"), 6838 AvatarURL: String("a"), 6839 GravatarID: String("g"), 6840 Name: String("n"), 6841 Company: String("c"), 6842 Blog: String("b"), 6843 Location: String("l"), 6844 Email: String("e"), 6845 Hireable: Bool(true), 6846 Bio: String("b"), 6847 TwitterUsername: String("t"), 6848 PublicRepos: Int(1), 6849 Followers: Int(1), 6850 Following: Int(1), 6851 CreatedAt: &Timestamp{referenceTime}, 6852 SuspendedAt: &Timestamp{referenceTime}, 6853 }, 6854 AccessTokensURL: String("atu"), 6855 RepositoriesURL: String("ru"), 6856 HTMLURL: String("hu"), 6857 TargetType: String("tt"), 6858 SingleFileName: String("sfn"), 6859 RepositorySelection: String("rs"), 6860 Events: []string{"e"}, 6861 SingleFilePaths: []string{"s"}, 6862 Permissions: &InstallationPermissions{ 6863 Actions: String("a"), 6864 Administration: String("ad"), 6865 Checks: String("c"), 6866 Contents: String("co"), 6867 ContentReferences: String("cr"), 6868 Deployments: String("d"), 6869 Environments: String("e"), 6870 Issues: String("i"), 6871 Metadata: String("md"), 6872 Members: String("m"), 6873 OrganizationAdministration: String("oa"), 6874 OrganizationHooks: String("oh"), 6875 OrganizationPlan: String("op"), 6876 OrganizationPreReceiveHooks: String("opr"), 6877 OrganizationProjects: String("op"), 6878 OrganizationSecrets: String("os"), 6879 OrganizationSelfHostedRunners: String("osh"), 6880 OrganizationUserBlocking: String("oub"), 6881 Packages: String("pkg"), 6882 Pages: String("pg"), 6883 PullRequests: String("pr"), 6884 RepositoryHooks: String("rh"), 6885 RepositoryProjects: String("rp"), 6886 RepositoryPreReceiveHooks: String("rprh"), 6887 Secrets: String("s"), 6888 SecretScanningAlerts: String("ssa"), 6889 SecurityEvents: String("se"), 6890 SingleFile: String("sf"), 6891 Statuses: String("s"), 6892 TeamDiscussions: String("td"), 6893 VulnerabilityAlerts: String("va"), 6894 Workflows: String("w"), 6895 }, 6896 CreatedAt: &Timestamp{referenceTime}, 6897 UpdatedAt: &Timestamp{referenceTime}, 6898 HasMultipleSingleFiles: Bool(false), 6899 SuspendedBy: &User{ 6900 Login: String("l"), 6901 ID: Int64(1), 6902 URL: String("u"), 6903 AvatarURL: String("a"), 6904 GravatarID: String("g"), 6905 Name: String("n"), 6906 Company: String("c"), 6907 Blog: String("b"), 6908 Location: String("l"), 6909 Email: String("e"), 6910 Hireable: Bool(true), 6911 Bio: String("b"), 6912 TwitterUsername: String("t"), 6913 PublicRepos: Int(1), 6914 Followers: Int(1), 6915 Following: Int(1), 6916 CreatedAt: &Timestamp{referenceTime}, 6917 SuspendedAt: &Timestamp{referenceTime}, 6918 }, 6919 SuspendedAt: &Timestamp{referenceTime}, 6920 }, 6921 } 6922 6923 want := `{ 6924 "comment": { 6925 "author_association": "aa", 6926 "body": "bo", 6927 "child_comment_count": 1, 6928 "created_at": ` + referenceTimeStr + `, 6929 "discussion_id": 1, 6930 "html_url": "hurl", 6931 "id": 1, 6932 "node_id": "nid", 6933 "parent_id": 1, 6934 "reactions": { 6935 "total_count": 1, 6936 "+1": 1, 6937 "-1": 1, 6938 "laugh": 1, 6939 "confused": 1, 6940 "heart": 1, 6941 "hooray": 1, 6942 "rocket": 1, 6943 "eyes": 1, 6944 "url": "url" 6945 }, 6946 "repository_url": "rurl", 6947 "updated_at": ` + referenceTimeStr + `, 6948 "user": { 6949 "login": "l", 6950 "id": 1, 6951 "node_id": "n", 6952 "avatar_url": "a", 6953 "url": "u", 6954 "events_url": "e", 6955 "repos_url": "r" 6956 } 6957 }, 6958 "discussion": { 6959 "repository_url": "rurl", 6960 "category": { 6961 "id": 1, 6962 "node_id": "nid", 6963 "repository_id": 1, 6964 "emoji": "emoji", 6965 "name": "name", 6966 "description": "description", 6967 "created_at": ` + referenceTimeStr + `, 6968 "updated_at": ` + referenceTimeStr + `, 6969 "slug": "slug", 6970 "is_answerable": false 6971 }, 6972 "html_url": "hurl", 6973 "id": 1, 6974 "node_id": "nurl", 6975 "number": 1, 6976 "title": "title", 6977 "user": { 6978 "login": "l", 6979 "id": 1, 6980 "node_id": "n", 6981 "avatar_url": "a", 6982 "url": "u", 6983 "events_url": "e", 6984 "repos_url": "r" 6985 }, 6986 "state": "st", 6987 "locked": false, 6988 "comments": 1, 6989 "created_at": ` + referenceTimeStr + `, 6990 "updated_at": ` + referenceTimeStr + `, 6991 "author_association": "aa", 6992 "body": "bo" 6993 }, 6994 "repository": { 6995 "id": 1, 6996 "name": "n", 6997 "url": "s" 6998 }, 6999 "organization": { 7000 "name": "n", 7001 "company": "c", 7002 "blog": "b", 7003 "location": "loc", 7004 "email": "e", 7005 "twitter_username": "tu", 7006 "description": "d", 7007 "billing_email": "be", 7008 "is_verified": true, 7009 "has_organization_projects": true, 7010 "has_repository_projects": true, 7011 "default_repository_permission": "drp", 7012 "members_can_create_repositories": true, 7013 "members_can_create_public_repositories": false, 7014 "members_can_create_private_repositories": true, 7015 "members_can_create_internal_repositories": true, 7016 "members_allowed_repository_creation_type": "marct", 7017 "members_can_create_pages": true, 7018 "members_can_create_public_pages": false, 7019 "members_can_create_private_pages": true 7020 }, 7021 "sender": { 7022 "login": "l", 7023 "id": 1, 7024 "node_id": "n", 7025 "avatar_url": "a", 7026 "url": "u", 7027 "events_url": "e", 7028 "repos_url": "r" 7029 }, 7030 "installation": { 7031 "id": 1, 7032 "node_id": "nid", 7033 "app_id": 1, 7034 "app_slug": "as", 7035 "target_id": 1, 7036 "account": { 7037 "login": "l", 7038 "id": 1, 7039 "avatar_url": "a", 7040 "gravatar_id": "g", 7041 "name": "n", 7042 "company": "c", 7043 "blog": "b", 7044 "location": "l", 7045 "email": "e", 7046 "hireable": true, 7047 "bio": "b", 7048 "twitter_username": "t", 7049 "public_repos": 1, 7050 "followers": 1, 7051 "following": 1, 7052 "created_at": ` + referenceTimeStr + `, 7053 "suspended_at": ` + referenceTimeStr + `, 7054 "url": "u" 7055 }, 7056 "access_tokens_url": "atu", 7057 "repositories_url": "ru", 7058 "html_url": "hu", 7059 "target_type": "tt", 7060 "single_file_name": "sfn", 7061 "repository_selection": "rs", 7062 "events": [ 7063 "e" 7064 ], 7065 "single_file_paths": [ 7066 "s" 7067 ], 7068 "permissions": { 7069 "actions": "a", 7070 "administration": "ad", 7071 "checks": "c", 7072 "contents": "co", 7073 "content_references": "cr", 7074 "deployments": "d", 7075 "environments": "e", 7076 "issues": "i", 7077 "metadata": "md", 7078 "members": "m", 7079 "organization_administration": "oa", 7080 "organization_hooks": "oh", 7081 "organization_plan": "op", 7082 "organization_pre_receive_hooks": "opr", 7083 "organization_projects": "op", 7084 "organization_secrets": "os", 7085 "organization_self_hosted_runners": "osh", 7086 "organization_user_blocking": "oub", 7087 "packages": "pkg", 7088 "pages": "pg", 7089 "pull_requests": "pr", 7090 "repository_hooks": "rh", 7091 "repository_projects": "rp", 7092 "repository_pre_receive_hooks": "rprh", 7093 "secrets": "s", 7094 "secret_scanning_alerts": "ssa", 7095 "security_events": "se", 7096 "single_file": "sf", 7097 "statuses": "s", 7098 "team_discussions": "td", 7099 "vulnerability_alerts": "va", 7100 "workflows": "w" 7101 }, 7102 "created_at": ` + referenceTimeStr + `, 7103 "updated_at": ` + referenceTimeStr + `, 7104 "has_multiple_single_files": false, 7105 "suspended_by": { 7106 "login": "l", 7107 "id": 1, 7108 "avatar_url": "a", 7109 "gravatar_id": "g", 7110 "name": "n", 7111 "company": "c", 7112 "blog": "b", 7113 "location": "l", 7114 "email": "e", 7115 "hireable": true, 7116 "bio": "b", 7117 "twitter_username": "t", 7118 "public_repos": 1, 7119 "followers": 1, 7120 "following": 1, 7121 "created_at": ` + referenceTimeStr + `, 7122 "suspended_at": ` + referenceTimeStr + `, 7123 "url": "u" 7124 }, 7125 "suspended_at": ` + referenceTimeStr + ` 7126 } 7127 }` 7128 7129 testJSONMarshal(t, u, want) 7130 } 7131 7132 func TestDiscussionEvent_Marshal(t *testing.T) { 7133 testJSONMarshal(t, &DiscussionEvent{}, "{}") 7134 7135 u := &DiscussionEvent{ 7136 Discussion: &Discussion{ 7137 RepositoryURL: String("rurl"), 7138 DiscussionCategory: &DiscussionCategory{ 7139 ID: Int64(1), 7140 NodeID: String("nid"), 7141 RepositoryID: Int64(1), 7142 Emoji: String("emoji"), 7143 Name: String("name"), 7144 Description: String("description"), 7145 CreatedAt: &Timestamp{referenceTime}, 7146 UpdatedAt: &Timestamp{referenceTime}, 7147 Slug: String("slug"), 7148 IsAnswerable: Bool(false), 7149 }, 7150 HTMLURL: String("hurl"), 7151 ID: Int64(1), 7152 NodeID: String("nurl"), 7153 Number: Int(1), 7154 Title: String("title"), 7155 User: &User{ 7156 Login: String("l"), 7157 ID: Int64(1), 7158 NodeID: String("n"), 7159 URL: String("u"), 7160 ReposURL: String("r"), 7161 EventsURL: String("e"), 7162 AvatarURL: String("a"), 7163 }, 7164 State: String("st"), 7165 Locked: Bool(false), 7166 Comments: Int(1), 7167 CreatedAt: &Timestamp{referenceTime}, 7168 UpdatedAt: &Timestamp{referenceTime}, 7169 AuthorAssociation: String("aa"), 7170 Body: String("bo"), 7171 }, 7172 Repo: &Repository{ 7173 ID: Int64(1), 7174 URL: String("s"), 7175 Name: String("n"), 7176 }, 7177 Org: &Organization{ 7178 BillingEmail: String("be"), 7179 Blog: String("b"), 7180 Company: String("c"), 7181 Email: String("e"), 7182 TwitterUsername: String("tu"), 7183 Location: String("loc"), 7184 Name: String("n"), 7185 Description: String("d"), 7186 IsVerified: Bool(true), 7187 HasOrganizationProjects: Bool(true), 7188 HasRepositoryProjects: Bool(true), 7189 DefaultRepoPermission: String("drp"), 7190 MembersCanCreateRepos: Bool(true), 7191 MembersCanCreateInternalRepos: Bool(true), 7192 MembersCanCreatePrivateRepos: Bool(true), 7193 MembersCanCreatePublicRepos: Bool(false), 7194 MembersAllowedRepositoryCreationType: String("marct"), 7195 MembersCanCreatePages: Bool(true), 7196 MembersCanCreatePublicPages: Bool(false), 7197 MembersCanCreatePrivatePages: Bool(true), 7198 }, 7199 Sender: &User{ 7200 Login: String("l"), 7201 ID: Int64(1), 7202 NodeID: String("n"), 7203 URL: String("u"), 7204 ReposURL: String("r"), 7205 EventsURL: String("e"), 7206 AvatarURL: String("a"), 7207 }, 7208 Installation: &Installation{ 7209 ID: Int64(1), 7210 NodeID: String("nid"), 7211 AppID: Int64(1), 7212 AppSlug: String("as"), 7213 TargetID: Int64(1), 7214 Account: &User{ 7215 Login: String("l"), 7216 ID: Int64(1), 7217 URL: String("u"), 7218 AvatarURL: String("a"), 7219 GravatarID: String("g"), 7220 Name: String("n"), 7221 Company: String("c"), 7222 Blog: String("b"), 7223 Location: String("l"), 7224 Email: String("e"), 7225 Hireable: Bool(true), 7226 Bio: String("b"), 7227 TwitterUsername: String("t"), 7228 PublicRepos: Int(1), 7229 Followers: Int(1), 7230 Following: Int(1), 7231 CreatedAt: &Timestamp{referenceTime}, 7232 SuspendedAt: &Timestamp{referenceTime}, 7233 }, 7234 AccessTokensURL: String("atu"), 7235 RepositoriesURL: String("ru"), 7236 HTMLURL: String("hu"), 7237 TargetType: String("tt"), 7238 SingleFileName: String("sfn"), 7239 RepositorySelection: String("rs"), 7240 Events: []string{"e"}, 7241 SingleFilePaths: []string{"s"}, 7242 Permissions: &InstallationPermissions{ 7243 Actions: String("a"), 7244 Administration: String("ad"), 7245 Checks: String("c"), 7246 Contents: String("co"), 7247 ContentReferences: String("cr"), 7248 Deployments: String("d"), 7249 Environments: String("e"), 7250 Issues: String("i"), 7251 Metadata: String("md"), 7252 Members: String("m"), 7253 OrganizationAdministration: String("oa"), 7254 OrganizationHooks: String("oh"), 7255 OrganizationPlan: String("op"), 7256 OrganizationPreReceiveHooks: String("opr"), 7257 OrganizationProjects: String("op"), 7258 OrganizationSecrets: String("os"), 7259 OrganizationSelfHostedRunners: String("osh"), 7260 OrganizationUserBlocking: String("oub"), 7261 Packages: String("pkg"), 7262 Pages: String("pg"), 7263 PullRequests: String("pr"), 7264 RepositoryHooks: String("rh"), 7265 RepositoryProjects: String("rp"), 7266 RepositoryPreReceiveHooks: String("rprh"), 7267 Secrets: String("s"), 7268 SecretScanningAlerts: String("ssa"), 7269 SecurityEvents: String("se"), 7270 SingleFile: String("sf"), 7271 Statuses: String("s"), 7272 TeamDiscussions: String("td"), 7273 VulnerabilityAlerts: String("va"), 7274 Workflows: String("w"), 7275 }, 7276 CreatedAt: &Timestamp{referenceTime}, 7277 UpdatedAt: &Timestamp{referenceTime}, 7278 HasMultipleSingleFiles: Bool(false), 7279 SuspendedBy: &User{ 7280 Login: String("l"), 7281 ID: Int64(1), 7282 URL: String("u"), 7283 AvatarURL: String("a"), 7284 GravatarID: String("g"), 7285 Name: String("n"), 7286 Company: String("c"), 7287 Blog: String("b"), 7288 Location: String("l"), 7289 Email: String("e"), 7290 Hireable: Bool(true), 7291 Bio: String("b"), 7292 TwitterUsername: String("t"), 7293 PublicRepos: Int(1), 7294 Followers: Int(1), 7295 Following: Int(1), 7296 CreatedAt: &Timestamp{referenceTime}, 7297 SuspendedAt: &Timestamp{referenceTime}, 7298 }, 7299 SuspendedAt: &Timestamp{referenceTime}, 7300 }, 7301 } 7302 7303 want := `{ 7304 "discussion": { 7305 "repository_url": "rurl", 7306 "category": { 7307 "id": 1, 7308 "node_id": "nid", 7309 "repository_id": 1, 7310 "emoji": "emoji", 7311 "name": "name", 7312 "description": "description", 7313 "created_at": ` + referenceTimeStr + `, 7314 "updated_at": ` + referenceTimeStr + `, 7315 "slug": "slug", 7316 "is_answerable": false 7317 }, 7318 "html_url": "hurl", 7319 "id": 1, 7320 "node_id": "nurl", 7321 "number": 1, 7322 "title": "title", 7323 "user": { 7324 "login": "l", 7325 "id": 1, 7326 "node_id": "n", 7327 "avatar_url": "a", 7328 "url": "u", 7329 "events_url": "e", 7330 "repos_url": "r" 7331 }, 7332 "state": "st", 7333 "locked": false, 7334 "comments": 1, 7335 "created_at": ` + referenceTimeStr + `, 7336 "updated_at": ` + referenceTimeStr + `, 7337 "author_association": "aa", 7338 "body": "bo" 7339 }, 7340 "repository": { 7341 "id": 1, 7342 "name": "n", 7343 "url": "s" 7344 }, 7345 "organization": { 7346 "name": "n", 7347 "company": "c", 7348 "blog": "b", 7349 "location": "loc", 7350 "email": "e", 7351 "twitter_username": "tu", 7352 "description": "d", 7353 "billing_email": "be", 7354 "is_verified": true, 7355 "has_organization_projects": true, 7356 "has_repository_projects": true, 7357 "default_repository_permission": "drp", 7358 "members_can_create_repositories": true, 7359 "members_can_create_public_repositories": false, 7360 "members_can_create_private_repositories": true, 7361 "members_can_create_internal_repositories": true, 7362 "members_allowed_repository_creation_type": "marct", 7363 "members_can_create_pages": true, 7364 "members_can_create_public_pages": false, 7365 "members_can_create_private_pages": true 7366 }, 7367 "sender": { 7368 "login": "l", 7369 "id": 1, 7370 "node_id": "n", 7371 "avatar_url": "a", 7372 "url": "u", 7373 "events_url": "e", 7374 "repos_url": "r" 7375 }, 7376 "installation": { 7377 "id": 1, 7378 "node_id": "nid", 7379 "app_id": 1, 7380 "app_slug": "as", 7381 "target_id": 1, 7382 "account": { 7383 "login": "l", 7384 "id": 1, 7385 "avatar_url": "a", 7386 "gravatar_id": "g", 7387 "name": "n", 7388 "company": "c", 7389 "blog": "b", 7390 "location": "l", 7391 "email": "e", 7392 "hireable": true, 7393 "bio": "b", 7394 "twitter_username": "t", 7395 "public_repos": 1, 7396 "followers": 1, 7397 "following": 1, 7398 "created_at": ` + referenceTimeStr + `, 7399 "suspended_at": ` + referenceTimeStr + `, 7400 "url": "u" 7401 }, 7402 "access_tokens_url": "atu", 7403 "repositories_url": "ru", 7404 "html_url": "hu", 7405 "target_type": "tt", 7406 "single_file_name": "sfn", 7407 "repository_selection": "rs", 7408 "events": [ 7409 "e" 7410 ], 7411 "single_file_paths": [ 7412 "s" 7413 ], 7414 "permissions": { 7415 "actions": "a", 7416 "administration": "ad", 7417 "checks": "c", 7418 "contents": "co", 7419 "content_references": "cr", 7420 "deployments": "d", 7421 "environments": "e", 7422 "issues": "i", 7423 "metadata": "md", 7424 "members": "m", 7425 "organization_administration": "oa", 7426 "organization_hooks": "oh", 7427 "organization_plan": "op", 7428 "organization_pre_receive_hooks": "opr", 7429 "organization_projects": "op", 7430 "organization_secrets": "os", 7431 "organization_self_hosted_runners": "osh", 7432 "organization_user_blocking": "oub", 7433 "packages": "pkg", 7434 "pages": "pg", 7435 "pull_requests": "pr", 7436 "repository_hooks": "rh", 7437 "repository_projects": "rp", 7438 "repository_pre_receive_hooks": "rprh", 7439 "secrets": "s", 7440 "secret_scanning_alerts": "ssa", 7441 "security_events": "se", 7442 "single_file": "sf", 7443 "statuses": "s", 7444 "team_discussions": "td", 7445 "vulnerability_alerts": "va", 7446 "workflows": "w" 7447 }, 7448 "created_at": ` + referenceTimeStr + `, 7449 "updated_at": ` + referenceTimeStr + `, 7450 "has_multiple_single_files": false, 7451 "suspended_by": { 7452 "login": "l", 7453 "id": 1, 7454 "avatar_url": "a", 7455 "gravatar_id": "g", 7456 "name": "n", 7457 "company": "c", 7458 "blog": "b", 7459 "location": "l", 7460 "email": "e", 7461 "hireable": true, 7462 "bio": "b", 7463 "twitter_username": "t", 7464 "public_repos": 1, 7465 "followers": 1, 7466 "following": 1, 7467 "created_at": ` + referenceTimeStr + `, 7468 "suspended_at": ` + referenceTimeStr + `, 7469 "url": "u" 7470 }, 7471 "suspended_at": ` + referenceTimeStr + ` 7472 } 7473 }` 7474 7475 testJSONMarshal(t, u, want) 7476 } 7477 7478 func TestPackageEvent_Marshal(t *testing.T) { 7479 testJSONMarshal(t, &PackageEvent{}, "{}") 7480 7481 u := &PackageEvent{ 7482 Action: String("a"), 7483 Package: &Package{ 7484 ID: Int64(1), 7485 Name: String("n"), 7486 PackageType: String("pt"), 7487 HTMLURL: String("hurl"), 7488 CreatedAt: &Timestamp{referenceTime}, 7489 UpdatedAt: &Timestamp{referenceTime}, 7490 Owner: &User{ 7491 Login: String("l"), 7492 ID: Int64(1), 7493 NodeID: String("n"), 7494 URL: String("u"), 7495 ReposURL: String("r"), 7496 EventsURL: String("e"), 7497 AvatarURL: String("a"), 7498 }, 7499 PackageVersion: &PackageVersion{ID: Int64(1)}, 7500 Registry: &PackageRegistry{Name: String("n")}, 7501 }, 7502 Repo: &Repository{ 7503 ID: Int64(1), 7504 URL: String("s"), 7505 Name: String("n"), 7506 }, 7507 Org: &Organization{ 7508 BillingEmail: String("be"), 7509 Blog: String("b"), 7510 Company: String("c"), 7511 Email: String("e"), 7512 TwitterUsername: String("tu"), 7513 Location: String("loc"), 7514 Name: String("n"), 7515 Description: String("d"), 7516 IsVerified: Bool(true), 7517 HasOrganizationProjects: Bool(true), 7518 HasRepositoryProjects: Bool(true), 7519 DefaultRepoPermission: String("drp"), 7520 MembersCanCreateRepos: Bool(true), 7521 MembersCanCreateInternalRepos: Bool(true), 7522 MembersCanCreatePrivateRepos: Bool(true), 7523 MembersCanCreatePublicRepos: Bool(false), 7524 MembersAllowedRepositoryCreationType: String("marct"), 7525 MembersCanCreatePages: Bool(true), 7526 MembersCanCreatePublicPages: Bool(false), 7527 MembersCanCreatePrivatePages: Bool(true), 7528 }, 7529 Sender: &User{ 7530 Login: String("l"), 7531 ID: Int64(1), 7532 NodeID: String("n"), 7533 URL: String("u"), 7534 ReposURL: String("r"), 7535 EventsURL: String("e"), 7536 AvatarURL: String("a"), 7537 }, 7538 } 7539 7540 want := `{ 7541 "action": "a", 7542 "package": { 7543 "id": 1, 7544 "name": "n", 7545 "package_type": "pt", 7546 "html_url": "hurl", 7547 "created_at": ` + referenceTimeStr + `, 7548 "updated_at": ` + referenceTimeStr + `, 7549 "owner": { 7550 "login": "l", 7551 "id": 1, 7552 "node_id": "n", 7553 "avatar_url": "a", 7554 "url": "u", 7555 "events_url": "e", 7556 "repos_url": "r" 7557 }, 7558 "package_version": { 7559 "id": 1 7560 }, 7561 "registry": { 7562 "name": "n" 7563 } 7564 }, 7565 "repository": { 7566 "id": 1, 7567 "name": "n", 7568 "url": "s" 7569 }, 7570 "organization": { 7571 "name": "n", 7572 "company": "c", 7573 "blog": "b", 7574 "location": "loc", 7575 "email": "e", 7576 "twitter_username": "tu", 7577 "description": "d", 7578 "billing_email": "be", 7579 "is_verified": true, 7580 "has_organization_projects": true, 7581 "has_repository_projects": true, 7582 "default_repository_permission": "drp", 7583 "members_can_create_repositories": true, 7584 "members_can_create_public_repositories": false, 7585 "members_can_create_private_repositories": true, 7586 "members_can_create_internal_repositories": true, 7587 "members_allowed_repository_creation_type": "marct", 7588 "members_can_create_pages": true, 7589 "members_can_create_public_pages": false, 7590 "members_can_create_private_pages": true 7591 }, 7592 "sender": { 7593 "login": "l", 7594 "id": 1, 7595 "node_id": "n", 7596 "avatar_url": "a", 7597 "url": "u", 7598 "events_url": "e", 7599 "repos_url": "r" 7600 } 7601 }` 7602 7603 testJSONMarshal(t, u, want) 7604 } 7605 7606 func TestPersonalAccessTokenRequestEvent_Marshal(t *testing.T) { 7607 testJSONMarshal(t, &PersonalAccessTokenRequestEvent{}, "{}") 7608 7609 event := &PersonalAccessTokenRequestEvent{ 7610 Action: String("a"), 7611 PersonalAccessTokenRequest: &PersonalAccessTokenRequest{ 7612 ID: Int64(1), 7613 Owner: &User{Login: String("l")}, 7614 PermissionsAdded: &PersonalAccessTokenPermissions{ 7615 Org: map[string]string{"organization_events": "read"}, 7616 Repo: map[string]string{"security_events": "write"}, 7617 }, 7618 CreatedAt: &Timestamp{referenceTime}, 7619 TokenExpired: Bool(false), 7620 TokenExpiresAt: &Timestamp{referenceTime}, 7621 TokenLastUsedAt: &Timestamp{referenceTime}, 7622 RepositoryCount: Int64(1), 7623 RepositorySelection: String("rs"), 7624 Repositories: []*Repository{ 7625 { 7626 Name: String("n"), 7627 }, 7628 }, 7629 }, 7630 Org: &Organization{Name: String("n")}, 7631 Sender: &User{ 7632 Login: String("l"), 7633 }, 7634 Installation: &Installation{ 7635 ID: Int64(1), 7636 }, 7637 } 7638 7639 want := `{ 7640 "action": "a", 7641 "personal_access_token_request": { 7642 "id": 1, 7643 "owner": { 7644 "login": "l" 7645 }, 7646 "permissions_added": { 7647 "organization": { 7648 "organization_events": "read" 7649 }, 7650 "repository": { 7651 "security_events": "write" 7652 } 7653 }, 7654 "created_at": ` + referenceTimeStr + `, 7655 "token_expired": false, 7656 "token_expires_at": ` + referenceTimeStr + `, 7657 "token_last_used_at": ` + referenceTimeStr + `, 7658 "repository_count": 1, 7659 "repository_selection": "rs", 7660 "repositories": [ 7661 { 7662 "name": "n" 7663 } 7664 ] 7665 }, 7666 "organization": { 7667 "name": "n" 7668 }, 7669 "sender": { 7670 "login": "l" 7671 }, 7672 "installation": { 7673 "id": 1 7674 } 7675 }` 7676 7677 testJSONMarshal(t, event, want) 7678 } 7679 7680 func TestPingEvent_Marshal(t *testing.T) { 7681 testJSONMarshal(t, &PingEvent{}, "{}") 7682 7683 l := make(map[string]interface{}) 7684 l["key"] = "value" 7685 7686 u := &PingEvent{ 7687 Zen: String("z"), 7688 HookID: Int64(1), 7689 Hook: &Hook{ 7690 CreatedAt: &Timestamp{referenceTime}, 7691 UpdatedAt: &Timestamp{referenceTime}, 7692 URL: String("url"), 7693 ID: Int64(1), 7694 Type: String("t"), 7695 Name: String("n"), 7696 TestURL: String("tu"), 7697 PingURL: String("pu"), 7698 LastResponse: l, 7699 Config: l, 7700 Events: []string{"a"}, 7701 Active: Bool(true), 7702 }, 7703 Installation: &Installation{ 7704 ID: Int64(1), 7705 NodeID: String("nid"), 7706 AppID: Int64(1), 7707 AppSlug: String("as"), 7708 TargetID: Int64(1), 7709 Account: &User{ 7710 Login: String("l"), 7711 ID: Int64(1), 7712 URL: String("u"), 7713 AvatarURL: String("a"), 7714 GravatarID: String("g"), 7715 Name: String("n"), 7716 Company: String("c"), 7717 Blog: String("b"), 7718 Location: String("l"), 7719 Email: String("e"), 7720 Hireable: Bool(true), 7721 Bio: String("b"), 7722 TwitterUsername: String("t"), 7723 PublicRepos: Int(1), 7724 Followers: Int(1), 7725 Following: Int(1), 7726 CreatedAt: &Timestamp{referenceTime}, 7727 SuspendedAt: &Timestamp{referenceTime}, 7728 }, 7729 AccessTokensURL: String("atu"), 7730 RepositoriesURL: String("ru"), 7731 HTMLURL: String("hu"), 7732 TargetType: String("tt"), 7733 SingleFileName: String("sfn"), 7734 RepositorySelection: String("rs"), 7735 Events: []string{"e"}, 7736 SingleFilePaths: []string{"s"}, 7737 Permissions: &InstallationPermissions{ 7738 Actions: String("a"), 7739 Administration: String("ad"), 7740 Checks: String("c"), 7741 Contents: String("co"), 7742 ContentReferences: String("cr"), 7743 Deployments: String("d"), 7744 Environments: String("e"), 7745 Issues: String("i"), 7746 Metadata: String("md"), 7747 Members: String("m"), 7748 OrganizationAdministration: String("oa"), 7749 OrganizationHooks: String("oh"), 7750 OrganizationPlan: String("op"), 7751 OrganizationPreReceiveHooks: String("opr"), 7752 OrganizationProjects: String("op"), 7753 OrganizationSecrets: String("os"), 7754 OrganizationSelfHostedRunners: String("osh"), 7755 OrganizationUserBlocking: String("oub"), 7756 Packages: String("pkg"), 7757 Pages: String("pg"), 7758 PullRequests: String("pr"), 7759 RepositoryHooks: String("rh"), 7760 RepositoryProjects: String("rp"), 7761 RepositoryPreReceiveHooks: String("rprh"), 7762 Secrets: String("s"), 7763 SecretScanningAlerts: String("ssa"), 7764 SecurityEvents: String("se"), 7765 SingleFile: String("sf"), 7766 Statuses: String("s"), 7767 TeamDiscussions: String("td"), 7768 VulnerabilityAlerts: String("va"), 7769 Workflows: String("w"), 7770 }, 7771 CreatedAt: &Timestamp{referenceTime}, 7772 UpdatedAt: &Timestamp{referenceTime}, 7773 HasMultipleSingleFiles: Bool(false), 7774 SuspendedBy: &User{ 7775 Login: String("l"), 7776 ID: Int64(1), 7777 URL: String("u"), 7778 AvatarURL: String("a"), 7779 GravatarID: String("g"), 7780 Name: String("n"), 7781 Company: String("c"), 7782 Blog: String("b"), 7783 Location: String("l"), 7784 Email: String("e"), 7785 Hireable: Bool(true), 7786 Bio: String("b"), 7787 TwitterUsername: String("t"), 7788 PublicRepos: Int(1), 7789 Followers: Int(1), 7790 Following: Int(1), 7791 CreatedAt: &Timestamp{referenceTime}, 7792 SuspendedAt: &Timestamp{referenceTime}, 7793 }, 7794 SuspendedAt: &Timestamp{referenceTime}, 7795 }, 7796 } 7797 7798 want := `{ 7799 "zen": "z", 7800 "hook_id": 1, 7801 "hook": { 7802 "created_at": ` + referenceTimeStr + `, 7803 "updated_at": ` + referenceTimeStr + `, 7804 "url": "url", 7805 "id": 1, 7806 "type": "t", 7807 "name": "n", 7808 "test_url": "tu", 7809 "ping_url": "pu", 7810 "last_response": { 7811 "key": "value" 7812 }, 7813 "config": { 7814 "key": "value" 7815 }, 7816 "events": [ 7817 "a" 7818 ], 7819 "active": true 7820 }, 7821 "installation": { 7822 "id": 1, 7823 "node_id": "nid", 7824 "app_id": 1, 7825 "app_slug": "as", 7826 "target_id": 1, 7827 "account": { 7828 "login": "l", 7829 "id": 1, 7830 "avatar_url": "a", 7831 "gravatar_id": "g", 7832 "name": "n", 7833 "company": "c", 7834 "blog": "b", 7835 "location": "l", 7836 "email": "e", 7837 "hireable": true, 7838 "bio": "b", 7839 "twitter_username": "t", 7840 "public_repos": 1, 7841 "followers": 1, 7842 "following": 1, 7843 "created_at": ` + referenceTimeStr + `, 7844 "suspended_at": ` + referenceTimeStr + `, 7845 "url": "u" 7846 }, 7847 "access_tokens_url": "atu", 7848 "repositories_url": "ru", 7849 "html_url": "hu", 7850 "target_type": "tt", 7851 "single_file_name": "sfn", 7852 "repository_selection": "rs", 7853 "events": [ 7854 "e" 7855 ], 7856 "single_file_paths": [ 7857 "s" 7858 ], 7859 "permissions": { 7860 "actions": "a", 7861 "administration": "ad", 7862 "checks": "c", 7863 "contents": "co", 7864 "content_references": "cr", 7865 "deployments": "d", 7866 "environments": "e", 7867 "issues": "i", 7868 "metadata": "md", 7869 "members": "m", 7870 "organization_administration": "oa", 7871 "organization_hooks": "oh", 7872 "organization_plan": "op", 7873 "organization_pre_receive_hooks": "opr", 7874 "organization_projects": "op", 7875 "organization_secrets": "os", 7876 "organization_self_hosted_runners": "osh", 7877 "organization_user_blocking": "oub", 7878 "packages": "pkg", 7879 "pages": "pg", 7880 "pull_requests": "pr", 7881 "repository_hooks": "rh", 7882 "repository_projects": "rp", 7883 "repository_pre_receive_hooks": "rprh", 7884 "secrets": "s", 7885 "secret_scanning_alerts": "ssa", 7886 "security_events": "se", 7887 "single_file": "sf", 7888 "statuses": "s", 7889 "team_discussions": "td", 7890 "vulnerability_alerts": "va", 7891 "workflows": "w" 7892 }, 7893 "created_at": ` + referenceTimeStr + `, 7894 "updated_at": ` + referenceTimeStr + `, 7895 "has_multiple_single_files": false, 7896 "suspended_by": { 7897 "login": "l", 7898 "id": 1, 7899 "avatar_url": "a", 7900 "gravatar_id": "g", 7901 "name": "n", 7902 "company": "c", 7903 "blog": "b", 7904 "location": "l", 7905 "email": "e", 7906 "hireable": true, 7907 "bio": "b", 7908 "twitter_username": "t", 7909 "public_repos": 1, 7910 "followers": 1, 7911 "following": 1, 7912 "created_at": ` + referenceTimeStr + `, 7913 "suspended_at": ` + referenceTimeStr + `, 7914 "url": "u" 7915 }, 7916 "suspended_at": ` + referenceTimeStr + ` 7917 } 7918 }` 7919 7920 testJSONMarshal(t, u, want) 7921 } 7922 7923 func TestRepositoryDispatchEvent_Marshal(t *testing.T) { 7924 testJSONMarshal(t, &RepositoryDispatchEvent{}, "{}") 7925 7926 l := make(map[string]interface{}) 7927 l["key"] = "value" 7928 7929 jsonMsg, _ := json.Marshal(&l) 7930 7931 u := &RepositoryDispatchEvent{ 7932 Action: String("a"), 7933 Branch: String("b"), 7934 ClientPayload: jsonMsg, 7935 Repo: &Repository{ 7936 7937 ID: Int64(1), 7938 URL: String("s"), 7939 Name: String("n"), 7940 }, 7941 Org: &Organization{ 7942 BillingEmail: String("be"), 7943 Blog: String("b"), 7944 Company: String("c"), 7945 Email: String("e"), 7946 TwitterUsername: String("tu"), 7947 Location: String("loc"), 7948 Name: String("n"), 7949 Description: String("d"), 7950 IsVerified: Bool(true), 7951 HasOrganizationProjects: Bool(true), 7952 HasRepositoryProjects: Bool(true), 7953 DefaultRepoPermission: String("drp"), 7954 MembersCanCreateRepos: Bool(true), 7955 MembersCanCreateInternalRepos: Bool(true), 7956 MembersCanCreatePrivateRepos: Bool(true), 7957 MembersCanCreatePublicRepos: Bool(false), 7958 MembersAllowedRepositoryCreationType: String("marct"), 7959 MembersCanCreatePages: Bool(true), 7960 MembersCanCreatePublicPages: Bool(false), 7961 MembersCanCreatePrivatePages: Bool(true), 7962 }, 7963 Sender: &User{ 7964 Login: String("l"), 7965 ID: Int64(1), 7966 NodeID: String("n"), 7967 URL: String("u"), 7968 ReposURL: String("r"), 7969 EventsURL: String("e"), 7970 AvatarURL: String("a"), 7971 }, 7972 Installation: &Installation{ 7973 ID: Int64(1), 7974 NodeID: String("nid"), 7975 AppID: Int64(1), 7976 AppSlug: String("as"), 7977 TargetID: Int64(1), 7978 Account: &User{ 7979 Login: String("l"), 7980 ID: Int64(1), 7981 URL: String("u"), 7982 AvatarURL: String("a"), 7983 GravatarID: String("g"), 7984 Name: String("n"), 7985 Company: String("c"), 7986 Blog: String("b"), 7987 Location: String("l"), 7988 Email: String("e"), 7989 Hireable: Bool(true), 7990 Bio: String("b"), 7991 TwitterUsername: String("t"), 7992 PublicRepos: Int(1), 7993 Followers: Int(1), 7994 Following: Int(1), 7995 CreatedAt: &Timestamp{referenceTime}, 7996 SuspendedAt: &Timestamp{referenceTime}, 7997 }, 7998 AccessTokensURL: String("atu"), 7999 RepositoriesURL: String("ru"), 8000 HTMLURL: String("hu"), 8001 TargetType: String("tt"), 8002 SingleFileName: String("sfn"), 8003 RepositorySelection: String("rs"), 8004 Events: []string{"e"}, 8005 SingleFilePaths: []string{"s"}, 8006 Permissions: &InstallationPermissions{ 8007 Actions: String("a"), 8008 Administration: String("ad"), 8009 Checks: String("c"), 8010 Contents: String("co"), 8011 ContentReferences: String("cr"), 8012 Deployments: String("d"), 8013 Environments: String("e"), 8014 Issues: String("i"), 8015 Metadata: String("md"), 8016 Members: String("m"), 8017 OrganizationAdministration: String("oa"), 8018 OrganizationHooks: String("oh"), 8019 OrganizationPlan: String("op"), 8020 OrganizationPreReceiveHooks: String("opr"), 8021 OrganizationProjects: String("op"), 8022 OrganizationSecrets: String("os"), 8023 OrganizationSelfHostedRunners: String("osh"), 8024 OrganizationUserBlocking: String("oub"), 8025 Packages: String("pkg"), 8026 Pages: String("pg"), 8027 PullRequests: String("pr"), 8028 RepositoryHooks: String("rh"), 8029 RepositoryProjects: String("rp"), 8030 RepositoryPreReceiveHooks: String("rprh"), 8031 Secrets: String("s"), 8032 SecretScanningAlerts: String("ssa"), 8033 SecurityEvents: String("se"), 8034 SingleFile: String("sf"), 8035 Statuses: String("s"), 8036 TeamDiscussions: String("td"), 8037 VulnerabilityAlerts: String("va"), 8038 Workflows: String("w"), 8039 }, 8040 CreatedAt: &Timestamp{referenceTime}, 8041 UpdatedAt: &Timestamp{referenceTime}, 8042 HasMultipleSingleFiles: Bool(false), 8043 SuspendedBy: &User{ 8044 Login: String("l"), 8045 ID: Int64(1), 8046 URL: String("u"), 8047 AvatarURL: String("a"), 8048 GravatarID: String("g"), 8049 Name: String("n"), 8050 Company: String("c"), 8051 Blog: String("b"), 8052 Location: String("l"), 8053 Email: String("e"), 8054 Hireable: Bool(true), 8055 Bio: String("b"), 8056 TwitterUsername: String("t"), 8057 PublicRepos: Int(1), 8058 Followers: Int(1), 8059 Following: Int(1), 8060 CreatedAt: &Timestamp{referenceTime}, 8061 SuspendedAt: &Timestamp{referenceTime}, 8062 }, 8063 SuspendedAt: &Timestamp{referenceTime}, 8064 }, 8065 } 8066 8067 want := `{ 8068 "action": "a", 8069 "branch": "b", 8070 "client_payload": { 8071 "key": "value" 8072 }, 8073 "repository": { 8074 "id": 1, 8075 "name": "n", 8076 "url": "s" 8077 }, 8078 "organization": { 8079 "name": "n", 8080 "company": "c", 8081 "blog": "b", 8082 "location": "loc", 8083 "email": "e", 8084 "twitter_username": "tu", 8085 "description": "d", 8086 "billing_email": "be", 8087 "is_verified": true, 8088 "has_organization_projects": true, 8089 "has_repository_projects": true, 8090 "default_repository_permission": "drp", 8091 "members_can_create_repositories": true, 8092 "members_can_create_public_repositories": false, 8093 "members_can_create_private_repositories": true, 8094 "members_can_create_internal_repositories": true, 8095 "members_allowed_repository_creation_type": "marct", 8096 "members_can_create_pages": true, 8097 "members_can_create_public_pages": false, 8098 "members_can_create_private_pages": true 8099 }, 8100 "sender": { 8101 "login": "l", 8102 "id": 1, 8103 "node_id": "n", 8104 "avatar_url": "a", 8105 "url": "u", 8106 "events_url": "e", 8107 "repos_url": "r" 8108 }, 8109 "installation": { 8110 "id": 1, 8111 "node_id": "nid", 8112 "app_id": 1, 8113 "app_slug": "as", 8114 "target_id": 1, 8115 "account": { 8116 "login": "l", 8117 "id": 1, 8118 "avatar_url": "a", 8119 "gravatar_id": "g", 8120 "name": "n", 8121 "company": "c", 8122 "blog": "b", 8123 "location": "l", 8124 "email": "e", 8125 "hireable": true, 8126 "bio": "b", 8127 "twitter_username": "t", 8128 "public_repos": 1, 8129 "followers": 1, 8130 "following": 1, 8131 "created_at": ` + referenceTimeStr + `, 8132 "suspended_at": ` + referenceTimeStr + `, 8133 "url": "u" 8134 }, 8135 "access_tokens_url": "atu", 8136 "repositories_url": "ru", 8137 "html_url": "hu", 8138 "target_type": "tt", 8139 "single_file_name": "sfn", 8140 "repository_selection": "rs", 8141 "events": [ 8142 "e" 8143 ], 8144 "single_file_paths": [ 8145 "s" 8146 ], 8147 "permissions": { 8148 "actions": "a", 8149 "administration": "ad", 8150 "checks": "c", 8151 "contents": "co", 8152 "content_references": "cr", 8153 "deployments": "d", 8154 "environments": "e", 8155 "issues": "i", 8156 "metadata": "md", 8157 "members": "m", 8158 "organization_administration": "oa", 8159 "organization_hooks": "oh", 8160 "organization_plan": "op", 8161 "organization_pre_receive_hooks": "opr", 8162 "organization_projects": "op", 8163 "organization_secrets": "os", 8164 "organization_self_hosted_runners": "osh", 8165 "organization_user_blocking": "oub", 8166 "packages": "pkg", 8167 "pages": "pg", 8168 "pull_requests": "pr", 8169 "repository_hooks": "rh", 8170 "repository_projects": "rp", 8171 "repository_pre_receive_hooks": "rprh", 8172 "secrets": "s", 8173 "secret_scanning_alerts": "ssa", 8174 "security_events": "se", 8175 "single_file": "sf", 8176 "statuses": "s", 8177 "team_discussions": "td", 8178 "vulnerability_alerts": "va", 8179 "workflows": "w" 8180 }, 8181 "created_at": ` + referenceTimeStr + `, 8182 "updated_at": ` + referenceTimeStr + `, 8183 "has_multiple_single_files": false, 8184 "suspended_by": { 8185 "login": "l", 8186 "id": 1, 8187 "avatar_url": "a", 8188 "gravatar_id": "g", 8189 "name": "n", 8190 "company": "c", 8191 "blog": "b", 8192 "location": "l", 8193 "email": "e", 8194 "hireable": true, 8195 "bio": "b", 8196 "twitter_username": "t", 8197 "public_repos": 1, 8198 "followers": 1, 8199 "following": 1, 8200 "created_at": ` + referenceTimeStr + `, 8201 "suspended_at": ` + referenceTimeStr + `, 8202 "url": "u" 8203 }, 8204 "suspended_at": ` + referenceTimeStr + ` 8205 } 8206 }` 8207 8208 testJSONMarshal(t, u, want) 8209 } 8210 8211 func TestRepositoryImportEvent_Marshal(t *testing.T) { 8212 testJSONMarshal(t, &RepositoryImportEvent{}, "{}") 8213 8214 u := &RepositoryImportEvent{ 8215 Status: String("success"), 8216 Repo: &Repository{ 8217 ID: Int64(1), 8218 URL: String("s"), 8219 Name: String("n"), 8220 }, 8221 Org: &Organization{ 8222 BillingEmail: String("be"), 8223 Blog: String("b"), 8224 Company: String("c"), 8225 Email: String("e"), 8226 TwitterUsername: String("tu"), 8227 Location: String("loc"), 8228 Name: String("n"), 8229 Description: String("d"), 8230 IsVerified: Bool(true), 8231 HasOrganizationProjects: Bool(true), 8232 HasRepositoryProjects: Bool(true), 8233 DefaultRepoPermission: String("drp"), 8234 MembersCanCreateRepos: Bool(true), 8235 MembersCanCreateInternalRepos: Bool(true), 8236 MembersCanCreatePrivateRepos: Bool(true), 8237 MembersCanCreatePublicRepos: Bool(false), 8238 MembersAllowedRepositoryCreationType: String("marct"), 8239 MembersCanCreatePages: Bool(true), 8240 MembersCanCreatePublicPages: Bool(false), 8241 MembersCanCreatePrivatePages: Bool(true), 8242 }, 8243 Sender: &User{ 8244 Login: String("l"), 8245 ID: Int64(1), 8246 NodeID: String("n"), 8247 URL: String("u"), 8248 ReposURL: String("r"), 8249 EventsURL: String("e"), 8250 AvatarURL: String("a"), 8251 }, 8252 } 8253 8254 want := `{ 8255 "status": "success", 8256 "repository": { 8257 "id": 1, 8258 "name": "n", 8259 "url": "s" 8260 }, 8261 "organization": { 8262 "name": "n", 8263 "company": "c", 8264 "blog": "b", 8265 "location": "loc", 8266 "email": "e", 8267 "twitter_username": "tu", 8268 "description": "d", 8269 "billing_email": "be", 8270 "is_verified": true, 8271 "has_organization_projects": true, 8272 "has_repository_projects": true, 8273 "default_repository_permission": "drp", 8274 "members_can_create_repositories": true, 8275 "members_can_create_public_repositories": false, 8276 "members_can_create_private_repositories": true, 8277 "members_can_create_internal_repositories": true, 8278 "members_allowed_repository_creation_type": "marct", 8279 "members_can_create_pages": true, 8280 "members_can_create_public_pages": false, 8281 "members_can_create_private_pages": true 8282 }, 8283 "sender": { 8284 "login": "l", 8285 "id": 1, 8286 "node_id": "n", 8287 "avatar_url": "a", 8288 "url": "u", 8289 "events_url": "e", 8290 "repos_url": "r" 8291 } 8292 }` 8293 8294 testJSONMarshal(t, u, want) 8295 } 8296 8297 func TestRepositoryEvent_Marshal(t *testing.T) { 8298 testJSONMarshal(t, &RepositoryEvent{}, "{}") 8299 8300 u := &RepositoryEvent{ 8301 Action: String("a"), 8302 Repo: &Repository{ 8303 ID: Int64(1), 8304 URL: String("s"), 8305 Name: String("n"), 8306 }, 8307 Org: &Organization{ 8308 BillingEmail: String("be"), 8309 Blog: String("b"), 8310 Company: String("c"), 8311 Email: String("e"), 8312 TwitterUsername: String("tu"), 8313 Location: String("loc"), 8314 Name: String("n"), 8315 Description: String("d"), 8316 IsVerified: Bool(true), 8317 HasOrganizationProjects: Bool(true), 8318 HasRepositoryProjects: Bool(true), 8319 DefaultRepoPermission: String("drp"), 8320 MembersCanCreateRepos: Bool(true), 8321 MembersCanCreateInternalRepos: Bool(true), 8322 MembersCanCreatePrivateRepos: Bool(true), 8323 MembersCanCreatePublicRepos: Bool(false), 8324 MembersAllowedRepositoryCreationType: String("marct"), 8325 MembersCanCreatePages: Bool(true), 8326 MembersCanCreatePublicPages: Bool(false), 8327 MembersCanCreatePrivatePages: Bool(true), 8328 }, 8329 Sender: &User{ 8330 Login: String("l"), 8331 ID: Int64(1), 8332 NodeID: String("n"), 8333 URL: String("u"), 8334 ReposURL: String("r"), 8335 EventsURL: String("e"), 8336 AvatarURL: String("a"), 8337 }, 8338 Installation: &Installation{ 8339 ID: Int64(1), 8340 NodeID: String("nid"), 8341 AppID: Int64(1), 8342 AppSlug: String("as"), 8343 TargetID: Int64(1), 8344 Account: &User{ 8345 Login: String("l"), 8346 ID: Int64(1), 8347 URL: String("u"), 8348 AvatarURL: String("a"), 8349 GravatarID: String("g"), 8350 Name: String("n"), 8351 Company: String("c"), 8352 Blog: String("b"), 8353 Location: String("l"), 8354 Email: String("e"), 8355 Hireable: Bool(true), 8356 Bio: String("b"), 8357 TwitterUsername: String("t"), 8358 PublicRepos: Int(1), 8359 Followers: Int(1), 8360 Following: Int(1), 8361 CreatedAt: &Timestamp{referenceTime}, 8362 SuspendedAt: &Timestamp{referenceTime}, 8363 }, 8364 AccessTokensURL: String("atu"), 8365 RepositoriesURL: String("ru"), 8366 HTMLURL: String("hu"), 8367 TargetType: String("tt"), 8368 SingleFileName: String("sfn"), 8369 RepositorySelection: String("rs"), 8370 Events: []string{"e"}, 8371 SingleFilePaths: []string{"s"}, 8372 Permissions: &InstallationPermissions{ 8373 Actions: String("a"), 8374 Administration: String("ad"), 8375 Checks: String("c"), 8376 Contents: String("co"), 8377 ContentReferences: String("cr"), 8378 Deployments: String("d"), 8379 Environments: String("e"), 8380 Issues: String("i"), 8381 Metadata: String("md"), 8382 Members: String("m"), 8383 OrganizationAdministration: String("oa"), 8384 OrganizationHooks: String("oh"), 8385 OrganizationPlan: String("op"), 8386 OrganizationPreReceiveHooks: String("opr"), 8387 OrganizationProjects: String("op"), 8388 OrganizationSecrets: String("os"), 8389 OrganizationSelfHostedRunners: String("osh"), 8390 OrganizationUserBlocking: String("oub"), 8391 Packages: String("pkg"), 8392 Pages: String("pg"), 8393 PullRequests: String("pr"), 8394 RepositoryHooks: String("rh"), 8395 RepositoryProjects: String("rp"), 8396 RepositoryPreReceiveHooks: String("rprh"), 8397 Secrets: String("s"), 8398 SecretScanningAlerts: String("ssa"), 8399 SecurityEvents: String("se"), 8400 SingleFile: String("sf"), 8401 Statuses: String("s"), 8402 TeamDiscussions: String("td"), 8403 VulnerabilityAlerts: String("va"), 8404 Workflows: String("w"), 8405 }, 8406 CreatedAt: &Timestamp{referenceTime}, 8407 UpdatedAt: &Timestamp{referenceTime}, 8408 HasMultipleSingleFiles: Bool(false), 8409 SuspendedBy: &User{ 8410 Login: String("l"), 8411 ID: Int64(1), 8412 URL: String("u"), 8413 AvatarURL: String("a"), 8414 GravatarID: String("g"), 8415 Name: String("n"), 8416 Company: String("c"), 8417 Blog: String("b"), 8418 Location: String("l"), 8419 Email: String("e"), 8420 Hireable: Bool(true), 8421 Bio: String("b"), 8422 TwitterUsername: String("t"), 8423 PublicRepos: Int(1), 8424 Followers: Int(1), 8425 Following: Int(1), 8426 CreatedAt: &Timestamp{referenceTime}, 8427 SuspendedAt: &Timestamp{referenceTime}, 8428 }, 8429 SuspendedAt: &Timestamp{referenceTime}, 8430 }, 8431 } 8432 8433 want := `{ 8434 "action": "a", 8435 "repository": { 8436 "id": 1, 8437 "name": "n", 8438 "url": "s" 8439 }, 8440 "organization": { 8441 "name": "n", 8442 "company": "c", 8443 "blog": "b", 8444 "location": "loc", 8445 "email": "e", 8446 "twitter_username": "tu", 8447 "description": "d", 8448 "billing_email": "be", 8449 "is_verified": true, 8450 "has_organization_projects": true, 8451 "has_repository_projects": true, 8452 "default_repository_permission": "drp", 8453 "members_can_create_repositories": true, 8454 "members_can_create_public_repositories": false, 8455 "members_can_create_private_repositories": true, 8456 "members_can_create_internal_repositories": true, 8457 "members_allowed_repository_creation_type": "marct", 8458 "members_can_create_pages": true, 8459 "members_can_create_public_pages": false, 8460 "members_can_create_private_pages": true 8461 }, 8462 "sender": { 8463 "login": "l", 8464 "id": 1, 8465 "node_id": "n", 8466 "avatar_url": "a", 8467 "url": "u", 8468 "events_url": "e", 8469 "repos_url": "r" 8470 }, 8471 "installation": { 8472 "id": 1, 8473 "node_id": "nid", 8474 "app_id": 1, 8475 "app_slug": "as", 8476 "target_id": 1, 8477 "account": { 8478 "login": "l", 8479 "id": 1, 8480 "avatar_url": "a", 8481 "gravatar_id": "g", 8482 "name": "n", 8483 "company": "c", 8484 "blog": "b", 8485 "location": "l", 8486 "email": "e", 8487 "hireable": true, 8488 "bio": "b", 8489 "twitter_username": "t", 8490 "public_repos": 1, 8491 "followers": 1, 8492 "following": 1, 8493 "created_at": ` + referenceTimeStr + `, 8494 "suspended_at": ` + referenceTimeStr + `, 8495 "url": "u" 8496 }, 8497 "access_tokens_url": "atu", 8498 "repositories_url": "ru", 8499 "html_url": "hu", 8500 "target_type": "tt", 8501 "single_file_name": "sfn", 8502 "repository_selection": "rs", 8503 "events": [ 8504 "e" 8505 ], 8506 "single_file_paths": [ 8507 "s" 8508 ], 8509 "permissions": { 8510 "actions": "a", 8511 "administration": "ad", 8512 "checks": "c", 8513 "contents": "co", 8514 "content_references": "cr", 8515 "deployments": "d", 8516 "environments": "e", 8517 "issues": "i", 8518 "metadata": "md", 8519 "members": "m", 8520 "organization_administration": "oa", 8521 "organization_hooks": "oh", 8522 "organization_plan": "op", 8523 "organization_pre_receive_hooks": "opr", 8524 "organization_projects": "op", 8525 "organization_secrets": "os", 8526 "organization_self_hosted_runners": "osh", 8527 "organization_user_blocking": "oub", 8528 "packages": "pkg", 8529 "pages": "pg", 8530 "pull_requests": "pr", 8531 "repository_hooks": "rh", 8532 "repository_projects": "rp", 8533 "repository_pre_receive_hooks": "rprh", 8534 "secrets": "s", 8535 "secret_scanning_alerts": "ssa", 8536 "security_events": "se", 8537 "single_file": "sf", 8538 "statuses": "s", 8539 "team_discussions": "td", 8540 "vulnerability_alerts": "va", 8541 "workflows": "w" 8542 }, 8543 "created_at": ` + referenceTimeStr + `, 8544 "updated_at": ` + referenceTimeStr + `, 8545 "has_multiple_single_files": false, 8546 "suspended_by": { 8547 "login": "l", 8548 "id": 1, 8549 "avatar_url": "a", 8550 "gravatar_id": "g", 8551 "name": "n", 8552 "company": "c", 8553 "blog": "b", 8554 "location": "l", 8555 "email": "e", 8556 "hireable": true, 8557 "bio": "b", 8558 "twitter_username": "t", 8559 "public_repos": 1, 8560 "followers": 1, 8561 "following": 1, 8562 "created_at": ` + referenceTimeStr + `, 8563 "suspended_at": ` + referenceTimeStr + `, 8564 "url": "u" 8565 }, 8566 "suspended_at": ` + referenceTimeStr + ` 8567 } 8568 }` 8569 8570 testJSONMarshal(t, u, want) 8571 } 8572 8573 func TestReleaseEvent_Marshal(t *testing.T) { 8574 testJSONMarshal(t, &ReleaseEvent{}, "{}") 8575 8576 u := &ReleaseEvent{ 8577 Action: String("a"), 8578 Release: &RepositoryRelease{ 8579 Name: String("n"), 8580 DiscussionCategoryName: String("dcn"), 8581 ID: Int64(2), 8582 CreatedAt: &Timestamp{referenceTime}, 8583 PublishedAt: &Timestamp{referenceTime}, 8584 URL: String("url"), 8585 HTMLURL: String("htmlurl"), 8586 AssetsURL: String("assetsurl"), 8587 Assets: []*ReleaseAsset{{ID: Int64(1)}}, 8588 UploadURL: String("uploadurl"), 8589 ZipballURL: String("zipballurl"), 8590 TarballURL: String("tarballurl"), 8591 Author: &User{Name: String("octocat")}, 8592 NodeID: String("nid"), 8593 }, 8594 Repo: &Repository{ 8595 ID: Int64(1), 8596 URL: String("s"), 8597 Name: String("n"), 8598 }, 8599 Sender: &User{ 8600 Login: String("l"), 8601 ID: Int64(1), 8602 NodeID: String("n"), 8603 URL: String("u"), 8604 ReposURL: String("r"), 8605 EventsURL: String("e"), 8606 AvatarURL: String("a"), 8607 }, 8608 Installation: &Installation{ 8609 ID: Int64(1), 8610 NodeID: String("nid"), 8611 AppID: Int64(1), 8612 AppSlug: String("as"), 8613 TargetID: Int64(1), 8614 Account: &User{ 8615 Login: String("l"), 8616 ID: Int64(1), 8617 URL: String("u"), 8618 AvatarURL: String("a"), 8619 GravatarID: String("g"), 8620 Name: String("n"), 8621 Company: String("c"), 8622 Blog: String("b"), 8623 Location: String("l"), 8624 Email: String("e"), 8625 Hireable: Bool(true), 8626 Bio: String("b"), 8627 TwitterUsername: String("t"), 8628 PublicRepos: Int(1), 8629 Followers: Int(1), 8630 Following: Int(1), 8631 CreatedAt: &Timestamp{referenceTime}, 8632 SuspendedAt: &Timestamp{referenceTime}, 8633 }, 8634 AccessTokensURL: String("atu"), 8635 RepositoriesURL: String("ru"), 8636 HTMLURL: String("hu"), 8637 TargetType: String("tt"), 8638 SingleFileName: String("sfn"), 8639 RepositorySelection: String("rs"), 8640 Events: []string{"e"}, 8641 SingleFilePaths: []string{"s"}, 8642 Permissions: &InstallationPermissions{ 8643 Actions: String("a"), 8644 Administration: String("ad"), 8645 Checks: String("c"), 8646 Contents: String("co"), 8647 ContentReferences: String("cr"), 8648 Deployments: String("d"), 8649 Environments: String("e"), 8650 Issues: String("i"), 8651 Metadata: String("md"), 8652 Members: String("m"), 8653 OrganizationAdministration: String("oa"), 8654 OrganizationHooks: String("oh"), 8655 OrganizationPlan: String("op"), 8656 OrganizationPreReceiveHooks: String("opr"), 8657 OrganizationProjects: String("op"), 8658 OrganizationSecrets: String("os"), 8659 OrganizationSelfHostedRunners: String("osh"), 8660 OrganizationUserBlocking: String("oub"), 8661 Packages: String("pkg"), 8662 Pages: String("pg"), 8663 PullRequests: String("pr"), 8664 RepositoryHooks: String("rh"), 8665 RepositoryProjects: String("rp"), 8666 RepositoryPreReceiveHooks: String("rprh"), 8667 Secrets: String("s"), 8668 SecretScanningAlerts: String("ssa"), 8669 SecurityEvents: String("se"), 8670 SingleFile: String("sf"), 8671 Statuses: String("s"), 8672 TeamDiscussions: String("td"), 8673 VulnerabilityAlerts: String("va"), 8674 Workflows: String("w"), 8675 }, 8676 CreatedAt: &Timestamp{referenceTime}, 8677 UpdatedAt: &Timestamp{referenceTime}, 8678 HasMultipleSingleFiles: Bool(false), 8679 SuspendedBy: &User{ 8680 Login: String("l"), 8681 ID: Int64(1), 8682 URL: String("u"), 8683 AvatarURL: String("a"), 8684 GravatarID: String("g"), 8685 Name: String("n"), 8686 Company: String("c"), 8687 Blog: String("b"), 8688 Location: String("l"), 8689 Email: String("e"), 8690 Hireable: Bool(true), 8691 Bio: String("b"), 8692 TwitterUsername: String("t"), 8693 PublicRepos: Int(1), 8694 Followers: Int(1), 8695 Following: Int(1), 8696 CreatedAt: &Timestamp{referenceTime}, 8697 SuspendedAt: &Timestamp{referenceTime}, 8698 }, 8699 SuspendedAt: &Timestamp{referenceTime}, 8700 }, 8701 } 8702 8703 want := `{ 8704 "action": "a", 8705 "release": { 8706 "name": "n", 8707 "discussion_category_name": "dcn", 8708 "id": 2, 8709 "created_at": ` + referenceTimeStr + `, 8710 "published_at": ` + referenceTimeStr + `, 8711 "url": "url", 8712 "html_url": "htmlurl", 8713 "assets_url": "assetsurl", 8714 "assets": [ 8715 { 8716 "id": 1 8717 } 8718 ], 8719 "upload_url": "uploadurl", 8720 "zipball_url": "zipballurl", 8721 "tarball_url": "tarballurl", 8722 "author": { 8723 "name": "octocat" 8724 }, 8725 "node_id": "nid" 8726 }, 8727 "repository": { 8728 "id": 1, 8729 "name": "n", 8730 "url": "s" 8731 }, 8732 "sender": { 8733 "login": "l", 8734 "id": 1, 8735 "node_id": "n", 8736 "avatar_url": "a", 8737 "url": "u", 8738 "events_url": "e", 8739 "repos_url": "r" 8740 }, 8741 "installation": { 8742 "id": 1, 8743 "node_id": "nid", 8744 "app_id": 1, 8745 "app_slug": "as", 8746 "target_id": 1, 8747 "account": { 8748 "login": "l", 8749 "id": 1, 8750 "avatar_url": "a", 8751 "gravatar_id": "g", 8752 "name": "n", 8753 "company": "c", 8754 "blog": "b", 8755 "location": "l", 8756 "email": "e", 8757 "hireable": true, 8758 "bio": "b", 8759 "twitter_username": "t", 8760 "public_repos": 1, 8761 "followers": 1, 8762 "following": 1, 8763 "created_at": ` + referenceTimeStr + `, 8764 "suspended_at": ` + referenceTimeStr + `, 8765 "url": "u" 8766 }, 8767 "access_tokens_url": "atu", 8768 "repositories_url": "ru", 8769 "html_url": "hu", 8770 "target_type": "tt", 8771 "single_file_name": "sfn", 8772 "repository_selection": "rs", 8773 "events": [ 8774 "e" 8775 ], 8776 "single_file_paths": [ 8777 "s" 8778 ], 8779 "permissions": { 8780 "actions": "a", 8781 "administration": "ad", 8782 "checks": "c", 8783 "contents": "co", 8784 "content_references": "cr", 8785 "deployments": "d", 8786 "environments": "e", 8787 "issues": "i", 8788 "metadata": "md", 8789 "members": "m", 8790 "organization_administration": "oa", 8791 "organization_hooks": "oh", 8792 "organization_plan": "op", 8793 "organization_pre_receive_hooks": "opr", 8794 "organization_projects": "op", 8795 "organization_secrets": "os", 8796 "organization_self_hosted_runners": "osh", 8797 "organization_user_blocking": "oub", 8798 "packages": "pkg", 8799 "pages": "pg", 8800 "pull_requests": "pr", 8801 "repository_hooks": "rh", 8802 "repository_projects": "rp", 8803 "repository_pre_receive_hooks": "rprh", 8804 "secrets": "s", 8805 "secret_scanning_alerts": "ssa", 8806 "security_events": "se", 8807 "single_file": "sf", 8808 "statuses": "s", 8809 "team_discussions": "td", 8810 "vulnerability_alerts": "va", 8811 "workflows": "w" 8812 }, 8813 "created_at": ` + referenceTimeStr + `, 8814 "updated_at": ` + referenceTimeStr + `, 8815 "has_multiple_single_files": false, 8816 "suspended_by": { 8817 "login": "l", 8818 "id": 1, 8819 "avatar_url": "a", 8820 "gravatar_id": "g", 8821 "name": "n", 8822 "company": "c", 8823 "blog": "b", 8824 "location": "l", 8825 "email": "e", 8826 "hireable": true, 8827 "bio": "b", 8828 "twitter_username": "t", 8829 "public_repos": 1, 8830 "followers": 1, 8831 "following": 1, 8832 "created_at": ` + referenceTimeStr + `, 8833 "suspended_at": ` + referenceTimeStr + `, 8834 "url": "u" 8835 }, 8836 "suspended_at": ` + referenceTimeStr + ` 8837 } 8838 }` 8839 8840 testJSONMarshal(t, u, want) 8841 } 8842 8843 func TestContentReferenceEvent_Marshal(t *testing.T) { 8844 testJSONMarshal(t, &ContentReferenceEvent{}, "{}") 8845 8846 u := &ContentReferenceEvent{ 8847 Action: String("a"), 8848 ContentReference: &ContentReference{ 8849 ID: Int64(1), 8850 NodeID: String("nid"), 8851 Reference: String("ref"), 8852 }, 8853 Repo: &Repository{ 8854 ID: Int64(1), 8855 URL: String("s"), 8856 Name: String("n"), 8857 }, 8858 Sender: &User{ 8859 Login: String("l"), 8860 ID: Int64(1), 8861 NodeID: String("n"), 8862 URL: String("u"), 8863 ReposURL: String("r"), 8864 EventsURL: String("e"), 8865 AvatarURL: String("a"), 8866 }, 8867 Installation: &Installation{ 8868 ID: Int64(1), 8869 NodeID: String("nid"), 8870 AppID: Int64(1), 8871 AppSlug: String("as"), 8872 TargetID: Int64(1), 8873 Account: &User{ 8874 Login: String("l"), 8875 ID: Int64(1), 8876 URL: String("u"), 8877 AvatarURL: String("a"), 8878 GravatarID: String("g"), 8879 Name: String("n"), 8880 Company: String("c"), 8881 Blog: String("b"), 8882 Location: String("l"), 8883 Email: String("e"), 8884 Hireable: Bool(true), 8885 Bio: String("b"), 8886 TwitterUsername: String("t"), 8887 PublicRepos: Int(1), 8888 Followers: Int(1), 8889 Following: Int(1), 8890 CreatedAt: &Timestamp{referenceTime}, 8891 SuspendedAt: &Timestamp{referenceTime}, 8892 }, 8893 AccessTokensURL: String("atu"), 8894 RepositoriesURL: String("ru"), 8895 HTMLURL: String("hu"), 8896 TargetType: String("tt"), 8897 SingleFileName: String("sfn"), 8898 RepositorySelection: String("rs"), 8899 Events: []string{"e"}, 8900 SingleFilePaths: []string{"s"}, 8901 Permissions: &InstallationPermissions{ 8902 Actions: String("a"), 8903 Administration: String("ad"), 8904 Checks: String("c"), 8905 Contents: String("co"), 8906 ContentReferences: String("cr"), 8907 Deployments: String("d"), 8908 Environments: String("e"), 8909 Issues: String("i"), 8910 Metadata: String("md"), 8911 Members: String("m"), 8912 OrganizationAdministration: String("oa"), 8913 OrganizationHooks: String("oh"), 8914 OrganizationPlan: String("op"), 8915 OrganizationPreReceiveHooks: String("opr"), 8916 OrganizationProjects: String("op"), 8917 OrganizationSecrets: String("os"), 8918 OrganizationSelfHostedRunners: String("osh"), 8919 OrganizationUserBlocking: String("oub"), 8920 Packages: String("pkg"), 8921 Pages: String("pg"), 8922 PullRequests: String("pr"), 8923 RepositoryHooks: String("rh"), 8924 RepositoryProjects: String("rp"), 8925 RepositoryPreReceiveHooks: String("rprh"), 8926 Secrets: String("s"), 8927 SecretScanningAlerts: String("ssa"), 8928 SecurityEvents: String("se"), 8929 SingleFile: String("sf"), 8930 Statuses: String("s"), 8931 TeamDiscussions: String("td"), 8932 VulnerabilityAlerts: String("va"), 8933 Workflows: String("w"), 8934 }, 8935 CreatedAt: &Timestamp{referenceTime}, 8936 UpdatedAt: &Timestamp{referenceTime}, 8937 HasMultipleSingleFiles: Bool(false), 8938 SuspendedBy: &User{ 8939 Login: String("l"), 8940 ID: Int64(1), 8941 URL: String("u"), 8942 AvatarURL: String("a"), 8943 GravatarID: String("g"), 8944 Name: String("n"), 8945 Company: String("c"), 8946 Blog: String("b"), 8947 Location: String("l"), 8948 Email: String("e"), 8949 Hireable: Bool(true), 8950 Bio: String("b"), 8951 TwitterUsername: String("t"), 8952 PublicRepos: Int(1), 8953 Followers: Int(1), 8954 Following: Int(1), 8955 CreatedAt: &Timestamp{referenceTime}, 8956 SuspendedAt: &Timestamp{referenceTime}, 8957 }, 8958 SuspendedAt: &Timestamp{referenceTime}, 8959 }, 8960 } 8961 8962 want := `{ 8963 "action": "a", 8964 "content_reference": { 8965 "id": 1, 8966 "node_id": "nid", 8967 "reference": "ref" 8968 }, 8969 "repository": { 8970 "id": 1, 8971 "name": "n", 8972 "url": "s" 8973 }, 8974 "sender": { 8975 "login": "l", 8976 "id": 1, 8977 "node_id": "n", 8978 "avatar_url": "a", 8979 "url": "u", 8980 "events_url": "e", 8981 "repos_url": "r" 8982 }, 8983 "installation": { 8984 "id": 1, 8985 "node_id": "nid", 8986 "app_id": 1, 8987 "app_slug": "as", 8988 "target_id": 1, 8989 "account": { 8990 "login": "l", 8991 "id": 1, 8992 "avatar_url": "a", 8993 "gravatar_id": "g", 8994 "name": "n", 8995 "company": "c", 8996 "blog": "b", 8997 "location": "l", 8998 "email": "e", 8999 "hireable": true, 9000 "bio": "b", 9001 "twitter_username": "t", 9002 "public_repos": 1, 9003 "followers": 1, 9004 "following": 1, 9005 "created_at": ` + referenceTimeStr + `, 9006 "suspended_at": ` + referenceTimeStr + `, 9007 "url": "u" 9008 }, 9009 "access_tokens_url": "atu", 9010 "repositories_url": "ru", 9011 "html_url": "hu", 9012 "target_type": "tt", 9013 "single_file_name": "sfn", 9014 "repository_selection": "rs", 9015 "events": [ 9016 "e" 9017 ], 9018 "single_file_paths": [ 9019 "s" 9020 ], 9021 "permissions": { 9022 "actions": "a", 9023 "administration": "ad", 9024 "checks": "c", 9025 "contents": "co", 9026 "content_references": "cr", 9027 "deployments": "d", 9028 "environments": "e", 9029 "issues": "i", 9030 "metadata": "md", 9031 "members": "m", 9032 "organization_administration": "oa", 9033 "organization_hooks": "oh", 9034 "organization_plan": "op", 9035 "organization_pre_receive_hooks": "opr", 9036 "organization_projects": "op", 9037 "organization_secrets": "os", 9038 "organization_self_hosted_runners": "osh", 9039 "organization_user_blocking": "oub", 9040 "packages": "pkg", 9041 "pages": "pg", 9042 "pull_requests": "pr", 9043 "repository_hooks": "rh", 9044 "repository_projects": "rp", 9045 "repository_pre_receive_hooks": "rprh", 9046 "secrets": "s", 9047 "secret_scanning_alerts": "ssa", 9048 "security_events": "se", 9049 "single_file": "sf", 9050 "statuses": "s", 9051 "team_discussions": "td", 9052 "vulnerability_alerts": "va", 9053 "workflows": "w" 9054 }, 9055 "created_at": ` + referenceTimeStr + `, 9056 "updated_at": ` + referenceTimeStr + `, 9057 "has_multiple_single_files": false, 9058 "suspended_by": { 9059 "login": "l", 9060 "id": 1, 9061 "avatar_url": "a", 9062 "gravatar_id": "g", 9063 "name": "n", 9064 "company": "c", 9065 "blog": "b", 9066 "location": "l", 9067 "email": "e", 9068 "hireable": true, 9069 "bio": "b", 9070 "twitter_username": "t", 9071 "public_repos": 1, 9072 "followers": 1, 9073 "following": 1, 9074 "created_at": ` + referenceTimeStr + `, 9075 "suspended_at": ` + referenceTimeStr + `, 9076 "url": "u" 9077 }, 9078 "suspended_at": ` + referenceTimeStr + ` 9079 } 9080 }` 9081 9082 testJSONMarshal(t, u, want) 9083 } 9084 9085 func TestMemberEvent_Marshal(t *testing.T) { 9086 testJSONMarshal(t, &MemberEvent{}, "{}") 9087 9088 u := &MemberEvent{ 9089 Action: String("a"), 9090 Member: &User{ 9091 Login: String("l"), 9092 ID: Int64(1), 9093 NodeID: String("n"), 9094 URL: String("u"), 9095 ReposURL: String("r"), 9096 EventsURL: String("e"), 9097 AvatarURL: String("a"), 9098 }, 9099 Repo: &Repository{ 9100 ID: Int64(1), 9101 URL: String("s"), 9102 Name: String("n"), 9103 }, 9104 Sender: &User{ 9105 Login: String("l"), 9106 ID: Int64(1), 9107 NodeID: String("n"), 9108 URL: String("u"), 9109 ReposURL: String("r"), 9110 EventsURL: String("e"), 9111 AvatarURL: String("a"), 9112 }, 9113 Installation: &Installation{ 9114 ID: Int64(1), 9115 NodeID: String("nid"), 9116 AppID: Int64(1), 9117 AppSlug: String("as"), 9118 TargetID: Int64(1), 9119 Account: &User{ 9120 Login: String("l"), 9121 ID: Int64(1), 9122 URL: String("u"), 9123 AvatarURL: String("a"), 9124 GravatarID: String("g"), 9125 Name: String("n"), 9126 Company: String("c"), 9127 Blog: String("b"), 9128 Location: String("l"), 9129 Email: String("e"), 9130 Hireable: Bool(true), 9131 Bio: String("b"), 9132 TwitterUsername: String("t"), 9133 PublicRepos: Int(1), 9134 Followers: Int(1), 9135 Following: Int(1), 9136 CreatedAt: &Timestamp{referenceTime}, 9137 SuspendedAt: &Timestamp{referenceTime}, 9138 }, 9139 AccessTokensURL: String("atu"), 9140 RepositoriesURL: String("ru"), 9141 HTMLURL: String("hu"), 9142 TargetType: String("tt"), 9143 SingleFileName: String("sfn"), 9144 RepositorySelection: String("rs"), 9145 Events: []string{"e"}, 9146 SingleFilePaths: []string{"s"}, 9147 Permissions: &InstallationPermissions{ 9148 Actions: String("a"), 9149 Administration: String("ad"), 9150 Checks: String("c"), 9151 Contents: String("co"), 9152 ContentReferences: String("cr"), 9153 Deployments: String("d"), 9154 Environments: String("e"), 9155 Issues: String("i"), 9156 Metadata: String("md"), 9157 Members: String("m"), 9158 OrganizationAdministration: String("oa"), 9159 OrganizationHooks: String("oh"), 9160 OrganizationPlan: String("op"), 9161 OrganizationPreReceiveHooks: String("opr"), 9162 OrganizationProjects: String("op"), 9163 OrganizationSecrets: String("os"), 9164 OrganizationSelfHostedRunners: String("osh"), 9165 OrganizationUserBlocking: String("oub"), 9166 Packages: String("pkg"), 9167 Pages: String("pg"), 9168 PullRequests: String("pr"), 9169 RepositoryHooks: String("rh"), 9170 RepositoryProjects: String("rp"), 9171 RepositoryPreReceiveHooks: String("rprh"), 9172 Secrets: String("s"), 9173 SecretScanningAlerts: String("ssa"), 9174 SecurityEvents: String("se"), 9175 SingleFile: String("sf"), 9176 Statuses: String("s"), 9177 TeamDiscussions: String("td"), 9178 VulnerabilityAlerts: String("va"), 9179 Workflows: String("w"), 9180 }, 9181 CreatedAt: &Timestamp{referenceTime}, 9182 UpdatedAt: &Timestamp{referenceTime}, 9183 HasMultipleSingleFiles: Bool(false), 9184 SuspendedBy: &User{ 9185 Login: String("l"), 9186 ID: Int64(1), 9187 URL: String("u"), 9188 AvatarURL: String("a"), 9189 GravatarID: String("g"), 9190 Name: String("n"), 9191 Company: String("c"), 9192 Blog: String("b"), 9193 Location: String("l"), 9194 Email: String("e"), 9195 Hireable: Bool(true), 9196 Bio: String("b"), 9197 TwitterUsername: String("t"), 9198 PublicRepos: Int(1), 9199 Followers: Int(1), 9200 Following: Int(1), 9201 CreatedAt: &Timestamp{referenceTime}, 9202 SuspendedAt: &Timestamp{referenceTime}, 9203 }, 9204 SuspendedAt: &Timestamp{referenceTime}, 9205 }, 9206 } 9207 9208 want := `{ 9209 "action": "a", 9210 "member": { 9211 "login": "l", 9212 "id": 1, 9213 "node_id": "n", 9214 "avatar_url": "a", 9215 "url": "u", 9216 "events_url": "e", 9217 "repos_url": "r" 9218 }, 9219 "repository": { 9220 "id": 1, 9221 "name": "n", 9222 "url": "s" 9223 }, 9224 "sender": { 9225 "login": "l", 9226 "id": 1, 9227 "node_id": "n", 9228 "avatar_url": "a", 9229 "url": "u", 9230 "events_url": "e", 9231 "repos_url": "r" 9232 }, 9233 "installation": { 9234 "id": 1, 9235 "node_id": "nid", 9236 "app_id": 1, 9237 "app_slug": "as", 9238 "target_id": 1, 9239 "account": { 9240 "login": "l", 9241 "id": 1, 9242 "avatar_url": "a", 9243 "gravatar_id": "g", 9244 "name": "n", 9245 "company": "c", 9246 "blog": "b", 9247 "location": "l", 9248 "email": "e", 9249 "hireable": true, 9250 "bio": "b", 9251 "twitter_username": "t", 9252 "public_repos": 1, 9253 "followers": 1, 9254 "following": 1, 9255 "created_at": ` + referenceTimeStr + `, 9256 "suspended_at": ` + referenceTimeStr + `, 9257 "url": "u" 9258 }, 9259 "access_tokens_url": "atu", 9260 "repositories_url": "ru", 9261 "html_url": "hu", 9262 "target_type": "tt", 9263 "single_file_name": "sfn", 9264 "repository_selection": "rs", 9265 "events": [ 9266 "e" 9267 ], 9268 "single_file_paths": [ 9269 "s" 9270 ], 9271 "permissions": { 9272 "actions": "a", 9273 "administration": "ad", 9274 "checks": "c", 9275 "contents": "co", 9276 "content_references": "cr", 9277 "deployments": "d", 9278 "environments": "e", 9279 "issues": "i", 9280 "metadata": "md", 9281 "members": "m", 9282 "organization_administration": "oa", 9283 "organization_hooks": "oh", 9284 "organization_plan": "op", 9285 "organization_pre_receive_hooks": "opr", 9286 "organization_projects": "op", 9287 "organization_secrets": "os", 9288 "organization_self_hosted_runners": "osh", 9289 "organization_user_blocking": "oub", 9290 "packages": "pkg", 9291 "pages": "pg", 9292 "pull_requests": "pr", 9293 "repository_hooks": "rh", 9294 "repository_projects": "rp", 9295 "repository_pre_receive_hooks": "rprh", 9296 "secrets": "s", 9297 "secret_scanning_alerts": "ssa", 9298 "security_events": "se", 9299 "single_file": "sf", 9300 "statuses": "s", 9301 "team_discussions": "td", 9302 "vulnerability_alerts": "va", 9303 "workflows": "w" 9304 }, 9305 "created_at": ` + referenceTimeStr + `, 9306 "updated_at": ` + referenceTimeStr + `, 9307 "has_multiple_single_files": false, 9308 "suspended_by": { 9309 "login": "l", 9310 "id": 1, 9311 "avatar_url": "a", 9312 "gravatar_id": "g", 9313 "name": "n", 9314 "company": "c", 9315 "blog": "b", 9316 "location": "l", 9317 "email": "e", 9318 "hireable": true, 9319 "bio": "b", 9320 "twitter_username": "t", 9321 "public_repos": 1, 9322 "followers": 1, 9323 "following": 1, 9324 "created_at": ` + referenceTimeStr + `, 9325 "suspended_at": ` + referenceTimeStr + `, 9326 "url": "u" 9327 }, 9328 "suspended_at": ` + referenceTimeStr + ` 9329 } 9330 }` 9331 9332 testJSONMarshal(t, u, want) 9333 } 9334 9335 func TestMembershipEvent_Marshal(t *testing.T) { 9336 testJSONMarshal(t, &MembershipEvent{}, "{}") 9337 9338 u := &MembershipEvent{ 9339 Action: String("a"), 9340 Scope: String("s"), 9341 Member: &User{ 9342 Login: String("l"), 9343 ID: Int64(1), 9344 NodeID: String("n"), 9345 URL: String("u"), 9346 ReposURL: String("r"), 9347 EventsURL: String("e"), 9348 AvatarURL: String("a"), 9349 }, 9350 Team: &Team{ 9351 ID: Int64(1), 9352 NodeID: String("n"), 9353 Name: String("n"), 9354 Description: String("d"), 9355 URL: String("u"), 9356 Slug: String("s"), 9357 Permission: String("p"), 9358 Privacy: String("p"), 9359 MembersCount: Int(1), 9360 ReposCount: Int(1), 9361 MembersURL: String("m"), 9362 RepositoriesURL: String("r"), 9363 Organization: &Organization{ 9364 Login: String("l"), 9365 ID: Int64(1), 9366 NodeID: String("n"), 9367 AvatarURL: String("a"), 9368 HTMLURL: String("h"), 9369 Name: String("n"), 9370 Company: String("c"), 9371 Blog: String("b"), 9372 Location: String("l"), 9373 Email: String("e"), 9374 }, 9375 Parent: &Team{ 9376 ID: Int64(1), 9377 NodeID: String("n"), 9378 Name: String("n"), 9379 Description: String("d"), 9380 URL: String("u"), 9381 Slug: String("s"), 9382 Permission: String("p"), 9383 Privacy: String("p"), 9384 MembersCount: Int(1), 9385 ReposCount: Int(1), 9386 }, 9387 LDAPDN: String("l"), 9388 }, 9389 Org: &Organization{ 9390 BillingEmail: String("be"), 9391 Blog: String("b"), 9392 Company: String("c"), 9393 Email: String("e"), 9394 TwitterUsername: String("tu"), 9395 Location: String("loc"), 9396 Name: String("n"), 9397 Description: String("d"), 9398 IsVerified: Bool(true), 9399 HasOrganizationProjects: Bool(true), 9400 HasRepositoryProjects: Bool(true), 9401 DefaultRepoPermission: String("drp"), 9402 MembersCanCreateRepos: Bool(true), 9403 MembersCanCreateInternalRepos: Bool(true), 9404 MembersCanCreatePrivateRepos: Bool(true), 9405 MembersCanCreatePublicRepos: Bool(false), 9406 MembersAllowedRepositoryCreationType: String("marct"), 9407 MembersCanCreatePages: Bool(true), 9408 MembersCanCreatePublicPages: Bool(false), 9409 MembersCanCreatePrivatePages: Bool(true), 9410 }, 9411 Sender: &User{ 9412 Login: String("l"), 9413 ID: Int64(1), 9414 NodeID: String("n"), 9415 URL: String("u"), 9416 ReposURL: String("r"), 9417 EventsURL: String("e"), 9418 AvatarURL: String("a"), 9419 }, 9420 Installation: &Installation{ 9421 ID: Int64(1), 9422 NodeID: String("nid"), 9423 AppID: Int64(1), 9424 AppSlug: String("as"), 9425 TargetID: Int64(1), 9426 Account: &User{ 9427 Login: String("l"), 9428 ID: Int64(1), 9429 URL: String("u"), 9430 AvatarURL: String("a"), 9431 GravatarID: String("g"), 9432 Name: String("n"), 9433 Company: String("c"), 9434 Blog: String("b"), 9435 Location: String("l"), 9436 Email: String("e"), 9437 Hireable: Bool(true), 9438 Bio: String("b"), 9439 TwitterUsername: String("t"), 9440 PublicRepos: Int(1), 9441 Followers: Int(1), 9442 Following: Int(1), 9443 CreatedAt: &Timestamp{referenceTime}, 9444 SuspendedAt: &Timestamp{referenceTime}, 9445 }, 9446 AccessTokensURL: String("atu"), 9447 RepositoriesURL: String("ru"), 9448 HTMLURL: String("hu"), 9449 TargetType: String("tt"), 9450 SingleFileName: String("sfn"), 9451 RepositorySelection: String("rs"), 9452 Events: []string{"e"}, 9453 SingleFilePaths: []string{"s"}, 9454 Permissions: &InstallationPermissions{ 9455 Actions: String("a"), 9456 Administration: String("ad"), 9457 Checks: String("c"), 9458 Contents: String("co"), 9459 ContentReferences: String("cr"), 9460 Deployments: String("d"), 9461 Environments: String("e"), 9462 Issues: String("i"), 9463 Metadata: String("md"), 9464 Members: String("m"), 9465 OrganizationAdministration: String("oa"), 9466 OrganizationHooks: String("oh"), 9467 OrganizationPlan: String("op"), 9468 OrganizationPreReceiveHooks: String("opr"), 9469 OrganizationProjects: String("op"), 9470 OrganizationSecrets: String("os"), 9471 OrganizationSelfHostedRunners: String("osh"), 9472 OrganizationUserBlocking: String("oub"), 9473 Packages: String("pkg"), 9474 Pages: String("pg"), 9475 PullRequests: String("pr"), 9476 RepositoryHooks: String("rh"), 9477 RepositoryProjects: String("rp"), 9478 RepositoryPreReceiveHooks: String("rprh"), 9479 Secrets: String("s"), 9480 SecretScanningAlerts: String("ssa"), 9481 SecurityEvents: String("se"), 9482 SingleFile: String("sf"), 9483 Statuses: String("s"), 9484 TeamDiscussions: String("td"), 9485 VulnerabilityAlerts: String("va"), 9486 Workflows: String("w"), 9487 }, 9488 CreatedAt: &Timestamp{referenceTime}, 9489 UpdatedAt: &Timestamp{referenceTime}, 9490 HasMultipleSingleFiles: Bool(false), 9491 SuspendedBy: &User{ 9492 Login: String("l"), 9493 ID: Int64(1), 9494 URL: String("u"), 9495 AvatarURL: String("a"), 9496 GravatarID: String("g"), 9497 Name: String("n"), 9498 Company: String("c"), 9499 Blog: String("b"), 9500 Location: String("l"), 9501 Email: String("e"), 9502 Hireable: Bool(true), 9503 Bio: String("b"), 9504 TwitterUsername: String("t"), 9505 PublicRepos: Int(1), 9506 Followers: Int(1), 9507 Following: Int(1), 9508 CreatedAt: &Timestamp{referenceTime}, 9509 SuspendedAt: &Timestamp{referenceTime}, 9510 }, 9511 SuspendedAt: &Timestamp{referenceTime}, 9512 }, 9513 } 9514 9515 want := `{ 9516 "action": "a", 9517 "scope": "s", 9518 "member": { 9519 "login": "l", 9520 "id": 1, 9521 "node_id": "n", 9522 "avatar_url": "a", 9523 "url": "u", 9524 "events_url": "e", 9525 "repos_url": "r" 9526 }, 9527 "team": { 9528 "id": 1, 9529 "node_id": "n", 9530 "name": "n", 9531 "description": "d", 9532 "url": "u", 9533 "slug": "s", 9534 "permission": "p", 9535 "privacy": "p", 9536 "members_count": 1, 9537 "repos_count": 1, 9538 "organization": { 9539 "login": "l", 9540 "id": 1, 9541 "node_id": "n", 9542 "avatar_url": "a", 9543 "html_url": "h", 9544 "name": "n", 9545 "company": "c", 9546 "blog": "b", 9547 "location": "l", 9548 "email": "e" 9549 }, 9550 "members_url": "m", 9551 "repositories_url": "r", 9552 "parent": { 9553 "id": 1, 9554 "node_id": "n", 9555 "name": "n", 9556 "description": "d", 9557 "url": "u", 9558 "slug": "s", 9559 "permission": "p", 9560 "privacy": "p", 9561 "members_count": 1, 9562 "repos_count": 1 9563 }, 9564 "ldap_dn": "l" 9565 }, 9566 "organization": { 9567 "name": "n", 9568 "company": "c", 9569 "blog": "b", 9570 "location": "loc", 9571 "email": "e", 9572 "twitter_username": "tu", 9573 "description": "d", 9574 "billing_email": "be", 9575 "is_verified": true, 9576 "has_organization_projects": true, 9577 "has_repository_projects": true, 9578 "default_repository_permission": "drp", 9579 "members_can_create_repositories": true, 9580 "members_can_create_public_repositories": false, 9581 "members_can_create_private_repositories": true, 9582 "members_can_create_internal_repositories": true, 9583 "members_allowed_repository_creation_type": "marct", 9584 "members_can_create_pages": true, 9585 "members_can_create_public_pages": false, 9586 "members_can_create_private_pages": true 9587 }, 9588 "sender": { 9589 "login": "l", 9590 "id": 1, 9591 "node_id": "n", 9592 "avatar_url": "a", 9593 "url": "u", 9594 "events_url": "e", 9595 "repos_url": "r" 9596 }, 9597 "installation": { 9598 "id": 1, 9599 "node_id": "nid", 9600 "app_id": 1, 9601 "app_slug": "as", 9602 "target_id": 1, 9603 "account": { 9604 "login": "l", 9605 "id": 1, 9606 "avatar_url": "a", 9607 "gravatar_id": "g", 9608 "name": "n", 9609 "company": "c", 9610 "blog": "b", 9611 "location": "l", 9612 "email": "e", 9613 "hireable": true, 9614 "bio": "b", 9615 "twitter_username": "t", 9616 "public_repos": 1, 9617 "followers": 1, 9618 "following": 1, 9619 "created_at": ` + referenceTimeStr + `, 9620 "suspended_at": ` + referenceTimeStr + `, 9621 "url": "u" 9622 }, 9623 "access_tokens_url": "atu", 9624 "repositories_url": "ru", 9625 "html_url": "hu", 9626 "target_type": "tt", 9627 "single_file_name": "sfn", 9628 "repository_selection": "rs", 9629 "events": [ 9630 "e" 9631 ], 9632 "single_file_paths": [ 9633 "s" 9634 ], 9635 "permissions": { 9636 "actions": "a", 9637 "administration": "ad", 9638 "checks": "c", 9639 "contents": "co", 9640 "content_references": "cr", 9641 "deployments": "d", 9642 "environments": "e", 9643 "issues": "i", 9644 "metadata": "md", 9645 "members": "m", 9646 "organization_administration": "oa", 9647 "organization_hooks": "oh", 9648 "organization_plan": "op", 9649 "organization_pre_receive_hooks": "opr", 9650 "organization_projects": "op", 9651 "organization_secrets": "os", 9652 "organization_self_hosted_runners": "osh", 9653 "organization_user_blocking": "oub", 9654 "packages": "pkg", 9655 "pages": "pg", 9656 "pull_requests": "pr", 9657 "repository_hooks": "rh", 9658 "repository_projects": "rp", 9659 "repository_pre_receive_hooks": "rprh", 9660 "secrets": "s", 9661 "secret_scanning_alerts": "ssa", 9662 "security_events": "se", 9663 "single_file": "sf", 9664 "statuses": "s", 9665 "team_discussions": "td", 9666 "vulnerability_alerts": "va", 9667 "workflows": "w" 9668 }, 9669 "created_at": ` + referenceTimeStr + `, 9670 "updated_at": ` + referenceTimeStr + `, 9671 "has_multiple_single_files": false, 9672 "suspended_by": { 9673 "login": "l", 9674 "id": 1, 9675 "avatar_url": "a", 9676 "gravatar_id": "g", 9677 "name": "n", 9678 "company": "c", 9679 "blog": "b", 9680 "location": "l", 9681 "email": "e", 9682 "hireable": true, 9683 "bio": "b", 9684 "twitter_username": "t", 9685 "public_repos": 1, 9686 "followers": 1, 9687 "following": 1, 9688 "created_at": ` + referenceTimeStr + `, 9689 "suspended_at": ` + referenceTimeStr + `, 9690 "url": "u" 9691 }, 9692 "suspended_at": ` + referenceTimeStr + ` 9693 } 9694 }` 9695 9696 testJSONMarshal(t, u, want) 9697 } 9698 9699 func TestMergeGroupEvent_Marshal(t *testing.T) { 9700 testJSONMarshal(t, &MergeGroupEvent{}, "{}") 9701 9702 u := &MergeGroupEvent{ 9703 Action: String("a"), 9704 MergeGroup: &MergeGroup{ 9705 HeadSHA: String("hs"), 9706 HeadRef: String("hr"), 9707 BaseSHA: String("bs"), 9708 BaseRef: String("br"), 9709 HeadCommit: &Commit{NodeID: String("nid")}, 9710 }, 9711 Repo: &Repository{ 9712 ID: Int64(1), 9713 URL: String("s"), 9714 Name: String("n"), 9715 }, 9716 Org: &Organization{ 9717 BillingEmail: String("be"), 9718 Blog: String("b"), 9719 Company: String("c"), 9720 Email: String("e"), 9721 TwitterUsername: String("tu"), 9722 Location: String("loc"), 9723 Name: String("n"), 9724 Description: String("d"), 9725 IsVerified: Bool(true), 9726 HasOrganizationProjects: Bool(true), 9727 HasRepositoryProjects: Bool(true), 9728 DefaultRepoPermission: String("drp"), 9729 MembersCanCreateRepos: Bool(true), 9730 MembersCanCreateInternalRepos: Bool(true), 9731 MembersCanCreatePrivateRepos: Bool(true), 9732 MembersCanCreatePublicRepos: Bool(false), 9733 MembersAllowedRepositoryCreationType: String("marct"), 9734 MembersCanCreatePages: Bool(true), 9735 MembersCanCreatePublicPages: Bool(false), 9736 MembersCanCreatePrivatePages: Bool(true), 9737 }, 9738 Sender: &User{ 9739 Login: String("l"), 9740 ID: Int64(1), 9741 NodeID: String("n"), 9742 URL: String("u"), 9743 ReposURL: String("r"), 9744 EventsURL: String("e"), 9745 AvatarURL: String("a"), 9746 }, 9747 Installation: &Installation{ 9748 ID: Int64(1), 9749 NodeID: String("nid"), 9750 AppID: Int64(1), 9751 AppSlug: String("as"), 9752 TargetID: Int64(1), 9753 Account: &User{ 9754 Login: String("l"), 9755 ID: Int64(1), 9756 URL: String("u"), 9757 AvatarURL: String("a"), 9758 GravatarID: String("g"), 9759 Name: String("n"), 9760 Company: String("c"), 9761 Blog: String("b"), 9762 Location: String("l"), 9763 Email: String("e"), 9764 Hireable: Bool(true), 9765 Bio: String("b"), 9766 TwitterUsername: String("t"), 9767 PublicRepos: Int(1), 9768 Followers: Int(1), 9769 Following: Int(1), 9770 CreatedAt: &Timestamp{referenceTime}, 9771 SuspendedAt: &Timestamp{referenceTime}, 9772 }, 9773 AccessTokensURL: String("atu"), 9774 RepositoriesURL: String("ru"), 9775 HTMLURL: String("hu"), 9776 TargetType: String("tt"), 9777 SingleFileName: String("sfn"), 9778 RepositorySelection: String("rs"), 9779 Events: []string{"e"}, 9780 SingleFilePaths: []string{"s"}, 9781 Permissions: &InstallationPermissions{ 9782 Actions: String("a"), 9783 Administration: String("ad"), 9784 Checks: String("c"), 9785 Contents: String("co"), 9786 ContentReferences: String("cr"), 9787 Deployments: String("d"), 9788 Environments: String("e"), 9789 Issues: String("i"), 9790 Metadata: String("md"), 9791 Members: String("m"), 9792 OrganizationAdministration: String("oa"), 9793 OrganizationHooks: String("oh"), 9794 OrganizationPlan: String("op"), 9795 OrganizationPreReceiveHooks: String("opr"), 9796 OrganizationProjects: String("op"), 9797 OrganizationSecrets: String("os"), 9798 OrganizationSelfHostedRunners: String("osh"), 9799 OrganizationUserBlocking: String("oub"), 9800 Packages: String("pkg"), 9801 Pages: String("pg"), 9802 PullRequests: String("pr"), 9803 RepositoryHooks: String("rh"), 9804 RepositoryProjects: String("rp"), 9805 RepositoryPreReceiveHooks: String("rprh"), 9806 Secrets: String("s"), 9807 SecretScanningAlerts: String("ssa"), 9808 SecurityEvents: String("se"), 9809 SingleFile: String("sf"), 9810 Statuses: String("s"), 9811 TeamDiscussions: String("td"), 9812 VulnerabilityAlerts: String("va"), 9813 Workflows: String("w"), 9814 }, 9815 CreatedAt: &Timestamp{referenceTime}, 9816 UpdatedAt: &Timestamp{referenceTime}, 9817 HasMultipleSingleFiles: Bool(false), 9818 SuspendedBy: &User{ 9819 Login: String("l"), 9820 ID: Int64(1), 9821 URL: String("u"), 9822 AvatarURL: String("a"), 9823 GravatarID: String("g"), 9824 Name: String("n"), 9825 Company: String("c"), 9826 Blog: String("b"), 9827 Location: String("l"), 9828 Email: String("e"), 9829 Hireable: Bool(true), 9830 Bio: String("b"), 9831 TwitterUsername: String("t"), 9832 PublicRepos: Int(1), 9833 Followers: Int(1), 9834 Following: Int(1), 9835 CreatedAt: &Timestamp{referenceTime}, 9836 SuspendedAt: &Timestamp{referenceTime}, 9837 }, 9838 SuspendedAt: &Timestamp{referenceTime}, 9839 }, 9840 } 9841 9842 want := `{ 9843 "action": "a", 9844 "merge_group": { 9845 "head_sha": "hs", 9846 "head_ref": "hr", 9847 "base_sha": "bs", 9848 "base_ref": "br", 9849 "head_commit": { 9850 "node_id": "nid" 9851 } 9852 }, 9853 "repository": { 9854 "id": 1, 9855 "name": "n", 9856 "url": "s" 9857 }, 9858 "organization": { 9859 "name": "n", 9860 "company": "c", 9861 "blog": "b", 9862 "location": "loc", 9863 "email": "e", 9864 "twitter_username": "tu", 9865 "description": "d", 9866 "billing_email": "be", 9867 "is_verified": true, 9868 "has_organization_projects": true, 9869 "has_repository_projects": true, 9870 "default_repository_permission": "drp", 9871 "members_can_create_repositories": true, 9872 "members_can_create_public_repositories": false, 9873 "members_can_create_private_repositories": true, 9874 "members_can_create_internal_repositories": true, 9875 "members_allowed_repository_creation_type": "marct", 9876 "members_can_create_pages": true, 9877 "members_can_create_public_pages": false, 9878 "members_can_create_private_pages": true 9879 }, 9880 "sender": { 9881 "login": "l", 9882 "id": 1, 9883 "node_id": "n", 9884 "avatar_url": "a", 9885 "url": "u", 9886 "events_url": "e", 9887 "repos_url": "r" 9888 }, 9889 "installation": { 9890 "id": 1, 9891 "node_id": "nid", 9892 "app_id": 1, 9893 "app_slug": "as", 9894 "target_id": 1, 9895 "account": { 9896 "login": "l", 9897 "id": 1, 9898 "avatar_url": "a", 9899 "gravatar_id": "g", 9900 "name": "n", 9901 "company": "c", 9902 "blog": "b", 9903 "location": "l", 9904 "email": "e", 9905 "hireable": true, 9906 "bio": "b", 9907 "twitter_username": "t", 9908 "public_repos": 1, 9909 "followers": 1, 9910 "following": 1, 9911 "created_at": ` + referenceTimeStr + `, 9912 "suspended_at": ` + referenceTimeStr + `, 9913 "url": "u" 9914 }, 9915 "access_tokens_url": "atu", 9916 "repositories_url": "ru", 9917 "html_url": "hu", 9918 "target_type": "tt", 9919 "single_file_name": "sfn", 9920 "repository_selection": "rs", 9921 "events": [ 9922 "e" 9923 ], 9924 "single_file_paths": [ 9925 "s" 9926 ], 9927 "permissions": { 9928 "actions": "a", 9929 "administration": "ad", 9930 "checks": "c", 9931 "contents": "co", 9932 "content_references": "cr", 9933 "deployments": "d", 9934 "environments": "e", 9935 "issues": "i", 9936 "metadata": "md", 9937 "members": "m", 9938 "organization_administration": "oa", 9939 "organization_hooks": "oh", 9940 "organization_plan": "op", 9941 "organization_pre_receive_hooks": "opr", 9942 "organization_projects": "op", 9943 "organization_secrets": "os", 9944 "organization_self_hosted_runners": "osh", 9945 "organization_user_blocking": "oub", 9946 "packages": "pkg", 9947 "pages": "pg", 9948 "pull_requests": "pr", 9949 "repository_hooks": "rh", 9950 "repository_projects": "rp", 9951 "repository_pre_receive_hooks": "rprh", 9952 "secrets": "s", 9953 "secret_scanning_alerts": "ssa", 9954 "security_events": "se", 9955 "single_file": "sf", 9956 "statuses": "s", 9957 "team_discussions": "td", 9958 "vulnerability_alerts": "va", 9959 "workflows": "w" 9960 }, 9961 "created_at": ` + referenceTimeStr + `, 9962 "updated_at": ` + referenceTimeStr + `, 9963 "has_multiple_single_files": false, 9964 "suspended_by": { 9965 "login": "l", 9966 "id": 1, 9967 "avatar_url": "a", 9968 "gravatar_id": "g", 9969 "name": "n", 9970 "company": "c", 9971 "blog": "b", 9972 "location": "l", 9973 "email": "e", 9974 "hireable": true, 9975 "bio": "b", 9976 "twitter_username": "t", 9977 "public_repos": 1, 9978 "followers": 1, 9979 "following": 1, 9980 "created_at": ` + referenceTimeStr + `, 9981 "suspended_at": ` + referenceTimeStr + `, 9982 "url": "u" 9983 }, 9984 "suspended_at": ` + referenceTimeStr + ` 9985 } 9986 }` 9987 9988 testJSONMarshal(t, u, want) 9989 } 9990 9991 func TestOrgBlockEvent_Marshal(t *testing.T) { 9992 testJSONMarshal(t, &OrgBlockEvent{}, "{}") 9993 9994 u := &OrgBlockEvent{ 9995 Action: String("a"), 9996 BlockedUser: &User{ 9997 Login: String("l"), 9998 ID: Int64(1), 9999 NodeID: String("n"), 10000 URL: String("u"), 10001 ReposURL: String("r"), 10002 EventsURL: String("e"), 10003 AvatarURL: String("a"), 10004 }, 10005 Organization: &Organization{ 10006 BillingEmail: String("be"), 10007 Blog: String("b"), 10008 Company: String("c"), 10009 Email: String("e"), 10010 TwitterUsername: String("tu"), 10011 Location: String("loc"), 10012 Name: String("n"), 10013 Description: String("d"), 10014 IsVerified: Bool(true), 10015 HasOrganizationProjects: Bool(true), 10016 HasRepositoryProjects: Bool(true), 10017 DefaultRepoPermission: String("drp"), 10018 MembersCanCreateRepos: Bool(true), 10019 MembersCanCreateInternalRepos: Bool(true), 10020 MembersCanCreatePrivateRepos: Bool(true), 10021 MembersCanCreatePublicRepos: Bool(false), 10022 MembersAllowedRepositoryCreationType: String("marct"), 10023 MembersCanCreatePages: Bool(true), 10024 MembersCanCreatePublicPages: Bool(false), 10025 MembersCanCreatePrivatePages: Bool(true), 10026 }, 10027 Sender: &User{ 10028 Login: String("l"), 10029 ID: Int64(1), 10030 NodeID: String("n"), 10031 URL: String("u"), 10032 ReposURL: String("r"), 10033 EventsURL: String("e"), 10034 AvatarURL: String("a"), 10035 }, 10036 Installation: &Installation{ 10037 ID: Int64(1), 10038 NodeID: String("nid"), 10039 AppID: Int64(1), 10040 AppSlug: String("as"), 10041 TargetID: Int64(1), 10042 Account: &User{ 10043 Login: String("l"), 10044 ID: Int64(1), 10045 URL: String("u"), 10046 AvatarURL: String("a"), 10047 GravatarID: String("g"), 10048 Name: String("n"), 10049 Company: String("c"), 10050 Blog: String("b"), 10051 Location: String("l"), 10052 Email: String("e"), 10053 Hireable: Bool(true), 10054 Bio: String("b"), 10055 TwitterUsername: String("t"), 10056 PublicRepos: Int(1), 10057 Followers: Int(1), 10058 Following: Int(1), 10059 CreatedAt: &Timestamp{referenceTime}, 10060 SuspendedAt: &Timestamp{referenceTime}, 10061 }, 10062 AccessTokensURL: String("atu"), 10063 RepositoriesURL: String("ru"), 10064 HTMLURL: String("hu"), 10065 TargetType: String("tt"), 10066 SingleFileName: String("sfn"), 10067 RepositorySelection: String("rs"), 10068 Events: []string{"e"}, 10069 SingleFilePaths: []string{"s"}, 10070 Permissions: &InstallationPermissions{ 10071 Actions: String("a"), 10072 Administration: String("ad"), 10073 Checks: String("c"), 10074 Contents: String("co"), 10075 ContentReferences: String("cr"), 10076 Deployments: String("d"), 10077 Environments: String("e"), 10078 Issues: String("i"), 10079 Metadata: String("md"), 10080 Members: String("m"), 10081 OrganizationAdministration: String("oa"), 10082 OrganizationHooks: String("oh"), 10083 OrganizationPlan: String("op"), 10084 OrganizationPreReceiveHooks: String("opr"), 10085 OrganizationProjects: String("op"), 10086 OrganizationSecrets: String("os"), 10087 OrganizationSelfHostedRunners: String("osh"), 10088 OrganizationUserBlocking: String("oub"), 10089 Packages: String("pkg"), 10090 Pages: String("pg"), 10091 PullRequests: String("pr"), 10092 RepositoryHooks: String("rh"), 10093 RepositoryProjects: String("rp"), 10094 RepositoryPreReceiveHooks: String("rprh"), 10095 Secrets: String("s"), 10096 SecretScanningAlerts: String("ssa"), 10097 SecurityEvents: String("se"), 10098 SingleFile: String("sf"), 10099 Statuses: String("s"), 10100 TeamDiscussions: String("td"), 10101 VulnerabilityAlerts: String("va"), 10102 Workflows: String("w"), 10103 }, 10104 CreatedAt: &Timestamp{referenceTime}, 10105 UpdatedAt: &Timestamp{referenceTime}, 10106 HasMultipleSingleFiles: Bool(false), 10107 SuspendedBy: &User{ 10108 Login: String("l"), 10109 ID: Int64(1), 10110 URL: String("u"), 10111 AvatarURL: String("a"), 10112 GravatarID: String("g"), 10113 Name: String("n"), 10114 Company: String("c"), 10115 Blog: String("b"), 10116 Location: String("l"), 10117 Email: String("e"), 10118 Hireable: Bool(true), 10119 Bio: String("b"), 10120 TwitterUsername: String("t"), 10121 PublicRepos: Int(1), 10122 Followers: Int(1), 10123 Following: Int(1), 10124 CreatedAt: &Timestamp{referenceTime}, 10125 SuspendedAt: &Timestamp{referenceTime}, 10126 }, 10127 SuspendedAt: &Timestamp{referenceTime}, 10128 }, 10129 } 10130 10131 want := `{ 10132 "action": "a", 10133 "blocked_user": { 10134 "login": "l", 10135 "id": 1, 10136 "node_id": "n", 10137 "avatar_url": "a", 10138 "url": "u", 10139 "events_url": "e", 10140 "repos_url": "r" 10141 }, 10142 "organization": { 10143 "name": "n", 10144 "company": "c", 10145 "blog": "b", 10146 "location": "loc", 10147 "email": "e", 10148 "twitter_username": "tu", 10149 "description": "d", 10150 "billing_email": "be", 10151 "is_verified": true, 10152 "has_organization_projects": true, 10153 "has_repository_projects": true, 10154 "default_repository_permission": "drp", 10155 "members_can_create_repositories": true, 10156 "members_can_create_public_repositories": false, 10157 "members_can_create_private_repositories": true, 10158 "members_can_create_internal_repositories": true, 10159 "members_allowed_repository_creation_type": "marct", 10160 "members_can_create_pages": true, 10161 "members_can_create_public_pages": false, 10162 "members_can_create_private_pages": true 10163 }, 10164 "sender": { 10165 "login": "l", 10166 "id": 1, 10167 "node_id": "n", 10168 "avatar_url": "a", 10169 "url": "u", 10170 "events_url": "e", 10171 "repos_url": "r" 10172 }, 10173 "installation": { 10174 "id": 1, 10175 "node_id": "nid", 10176 "app_id": 1, 10177 "app_slug": "as", 10178 "target_id": 1, 10179 "account": { 10180 "login": "l", 10181 "id": 1, 10182 "avatar_url": "a", 10183 "gravatar_id": "g", 10184 "name": "n", 10185 "company": "c", 10186 "blog": "b", 10187 "location": "l", 10188 "email": "e", 10189 "hireable": true, 10190 "bio": "b", 10191 "twitter_username": "t", 10192 "public_repos": 1, 10193 "followers": 1, 10194 "following": 1, 10195 "created_at": ` + referenceTimeStr + `, 10196 "suspended_at": ` + referenceTimeStr + `, 10197 "url": "u" 10198 }, 10199 "access_tokens_url": "atu", 10200 "repositories_url": "ru", 10201 "html_url": "hu", 10202 "target_type": "tt", 10203 "single_file_name": "sfn", 10204 "repository_selection": "rs", 10205 "events": [ 10206 "e" 10207 ], 10208 "single_file_paths": [ 10209 "s" 10210 ], 10211 "permissions": { 10212 "actions": "a", 10213 "administration": "ad", 10214 "checks": "c", 10215 "contents": "co", 10216 "content_references": "cr", 10217 "deployments": "d", 10218 "environments": "e", 10219 "issues": "i", 10220 "metadata": "md", 10221 "members": "m", 10222 "organization_administration": "oa", 10223 "organization_hooks": "oh", 10224 "organization_plan": "op", 10225 "organization_pre_receive_hooks": "opr", 10226 "organization_projects": "op", 10227 "organization_secrets": "os", 10228 "organization_self_hosted_runners": "osh", 10229 "organization_user_blocking": "oub", 10230 "packages": "pkg", 10231 "pages": "pg", 10232 "pull_requests": "pr", 10233 "repository_hooks": "rh", 10234 "repository_projects": "rp", 10235 "repository_pre_receive_hooks": "rprh", 10236 "secrets": "s", 10237 "secret_scanning_alerts": "ssa", 10238 "security_events": "se", 10239 "single_file": "sf", 10240 "statuses": "s", 10241 "team_discussions": "td", 10242 "vulnerability_alerts": "va", 10243 "workflows": "w" 10244 }, 10245 "created_at": ` + referenceTimeStr + `, 10246 "updated_at": ` + referenceTimeStr + `, 10247 "has_multiple_single_files": false, 10248 "suspended_by": { 10249 "login": "l", 10250 "id": 1, 10251 "avatar_url": "a", 10252 "gravatar_id": "g", 10253 "name": "n", 10254 "company": "c", 10255 "blog": "b", 10256 "location": "l", 10257 "email": "e", 10258 "hireable": true, 10259 "bio": "b", 10260 "twitter_username": "t", 10261 "public_repos": 1, 10262 "followers": 1, 10263 "following": 1, 10264 "created_at": ` + referenceTimeStr + `, 10265 "suspended_at": ` + referenceTimeStr + `, 10266 "url": "u" 10267 }, 10268 "suspended_at": ` + referenceTimeStr + ` 10269 } 10270 }` 10271 10272 testJSONMarshal(t, u, want) 10273 } 10274 10275 func TestGollumEvent_Marshal(t *testing.T) { 10276 testJSONMarshal(t, &GollumEvent{}, "{}") 10277 10278 u := &GollumEvent{ 10279 Pages: []*Page{ 10280 { 10281 PageName: String("pn"), 10282 Title: String("t"), 10283 Summary: String("s"), 10284 Action: String("a"), 10285 SHA: String("sha"), 10286 HTMLURL: String("hu"), 10287 }, 10288 }, 10289 Repo: &Repository{ 10290 ID: Int64(1), 10291 URL: String("s"), 10292 Name: String("n"), 10293 }, 10294 Sender: &User{ 10295 Login: String("l"), 10296 ID: Int64(1), 10297 NodeID: String("n"), 10298 URL: String("u"), 10299 ReposURL: String("r"), 10300 EventsURL: String("e"), 10301 AvatarURL: String("a"), 10302 }, 10303 Installation: &Installation{ 10304 ID: Int64(1), 10305 NodeID: String("nid"), 10306 AppID: Int64(1), 10307 AppSlug: String("as"), 10308 TargetID: Int64(1), 10309 Account: &User{ 10310 Login: String("l"), 10311 ID: Int64(1), 10312 URL: String("u"), 10313 AvatarURL: String("a"), 10314 GravatarID: String("g"), 10315 Name: String("n"), 10316 Company: String("c"), 10317 Blog: String("b"), 10318 Location: String("l"), 10319 Email: String("e"), 10320 Hireable: Bool(true), 10321 Bio: String("b"), 10322 TwitterUsername: String("t"), 10323 PublicRepos: Int(1), 10324 Followers: Int(1), 10325 Following: Int(1), 10326 CreatedAt: &Timestamp{referenceTime}, 10327 SuspendedAt: &Timestamp{referenceTime}, 10328 }, 10329 AccessTokensURL: String("atu"), 10330 RepositoriesURL: String("ru"), 10331 HTMLURL: String("hu"), 10332 TargetType: String("tt"), 10333 SingleFileName: String("sfn"), 10334 RepositorySelection: String("rs"), 10335 Events: []string{"e"}, 10336 SingleFilePaths: []string{"s"}, 10337 Permissions: &InstallationPermissions{ 10338 Actions: String("a"), 10339 Administration: String("ad"), 10340 Checks: String("c"), 10341 Contents: String("co"), 10342 ContentReferences: String("cr"), 10343 Deployments: String("d"), 10344 Environments: String("e"), 10345 Issues: String("i"), 10346 Metadata: String("md"), 10347 Members: String("m"), 10348 OrganizationAdministration: String("oa"), 10349 OrganizationHooks: String("oh"), 10350 OrganizationPlan: String("op"), 10351 OrganizationPreReceiveHooks: String("opr"), 10352 OrganizationProjects: String("op"), 10353 OrganizationSecrets: String("os"), 10354 OrganizationSelfHostedRunners: String("osh"), 10355 OrganizationUserBlocking: String("oub"), 10356 Packages: String("pkg"), 10357 Pages: String("pg"), 10358 PullRequests: String("pr"), 10359 RepositoryHooks: String("rh"), 10360 RepositoryProjects: String("rp"), 10361 RepositoryPreReceiveHooks: String("rprh"), 10362 Secrets: String("s"), 10363 SecretScanningAlerts: String("ssa"), 10364 SecurityEvents: String("se"), 10365 SingleFile: String("sf"), 10366 Statuses: String("s"), 10367 TeamDiscussions: String("td"), 10368 VulnerabilityAlerts: String("va"), 10369 Workflows: String("w"), 10370 }, 10371 CreatedAt: &Timestamp{referenceTime}, 10372 UpdatedAt: &Timestamp{referenceTime}, 10373 HasMultipleSingleFiles: Bool(false), 10374 SuspendedBy: &User{ 10375 Login: String("l"), 10376 ID: Int64(1), 10377 URL: String("u"), 10378 AvatarURL: String("a"), 10379 GravatarID: String("g"), 10380 Name: String("n"), 10381 Company: String("c"), 10382 Blog: String("b"), 10383 Location: String("l"), 10384 Email: String("e"), 10385 Hireable: Bool(true), 10386 Bio: String("b"), 10387 TwitterUsername: String("t"), 10388 PublicRepos: Int(1), 10389 Followers: Int(1), 10390 Following: Int(1), 10391 CreatedAt: &Timestamp{referenceTime}, 10392 SuspendedAt: &Timestamp{referenceTime}, 10393 }, 10394 SuspendedAt: &Timestamp{referenceTime}, 10395 }, 10396 } 10397 10398 want := `{ 10399 "pages": [ 10400 { 10401 "page_name": "pn", 10402 "title": "t", 10403 "summary": "s", 10404 "action": "a", 10405 "sha": "sha", 10406 "html_url": "hu" 10407 } 10408 ], 10409 "repository": { 10410 "id": 1, 10411 "name": "n", 10412 "url": "s" 10413 }, 10414 "sender": { 10415 "login": "l", 10416 "id": 1, 10417 "node_id": "n", 10418 "avatar_url": "a", 10419 "url": "u", 10420 "events_url": "e", 10421 "repos_url": "r" 10422 }, 10423 "installation": { 10424 "id": 1, 10425 "node_id": "nid", 10426 "app_id": 1, 10427 "app_slug": "as", 10428 "target_id": 1, 10429 "account": { 10430 "login": "l", 10431 "id": 1, 10432 "avatar_url": "a", 10433 "gravatar_id": "g", 10434 "name": "n", 10435 "company": "c", 10436 "blog": "b", 10437 "location": "l", 10438 "email": "e", 10439 "hireable": true, 10440 "bio": "b", 10441 "twitter_username": "t", 10442 "public_repos": 1, 10443 "followers": 1, 10444 "following": 1, 10445 "created_at": ` + referenceTimeStr + `, 10446 "suspended_at": ` + referenceTimeStr + `, 10447 "url": "u" 10448 }, 10449 "access_tokens_url": "atu", 10450 "repositories_url": "ru", 10451 "html_url": "hu", 10452 "target_type": "tt", 10453 "single_file_name": "sfn", 10454 "repository_selection": "rs", 10455 "events": [ 10456 "e" 10457 ], 10458 "single_file_paths": [ 10459 "s" 10460 ], 10461 "permissions": { 10462 "actions": "a", 10463 "administration": "ad", 10464 "checks": "c", 10465 "contents": "co", 10466 "content_references": "cr", 10467 "deployments": "d", 10468 "environments": "e", 10469 "issues": "i", 10470 "metadata": "md", 10471 "members": "m", 10472 "organization_administration": "oa", 10473 "organization_hooks": "oh", 10474 "organization_plan": "op", 10475 "organization_pre_receive_hooks": "opr", 10476 "organization_projects": "op", 10477 "organization_secrets": "os", 10478 "organization_self_hosted_runners": "osh", 10479 "organization_user_blocking": "oub", 10480 "packages": "pkg", 10481 "pages": "pg", 10482 "pull_requests": "pr", 10483 "repository_hooks": "rh", 10484 "repository_projects": "rp", 10485 "repository_pre_receive_hooks": "rprh", 10486 "secrets": "s", 10487 "secret_scanning_alerts": "ssa", 10488 "security_events": "se", 10489 "single_file": "sf", 10490 "statuses": "s", 10491 "team_discussions": "td", 10492 "vulnerability_alerts": "va", 10493 "workflows": "w" 10494 }, 10495 "created_at": ` + referenceTimeStr + `, 10496 "updated_at": ` + referenceTimeStr + `, 10497 "has_multiple_single_files": false, 10498 "suspended_by": { 10499 "login": "l", 10500 "id": 1, 10501 "avatar_url": "a", 10502 "gravatar_id": "g", 10503 "name": "n", 10504 "company": "c", 10505 "blog": "b", 10506 "location": "l", 10507 "email": "e", 10508 "hireable": true, 10509 "bio": "b", 10510 "twitter_username": "t", 10511 "public_repos": 1, 10512 "followers": 1, 10513 "following": 1, 10514 "created_at": ` + referenceTimeStr + `, 10515 "suspended_at": ` + referenceTimeStr + `, 10516 "url": "u" 10517 }, 10518 "suspended_at": ` + referenceTimeStr + ` 10519 } 10520 }` 10521 10522 testJSONMarshal(t, u, want) 10523 } 10524 10525 func TestWorkflowRunEvent_Marshal(t *testing.T) { 10526 testJSONMarshal(t, &WorkflowRunEvent{}, "{}") 10527 10528 u := &WorkflowRunEvent{ 10529 Action: String("a"), 10530 Workflow: &Workflow{ 10531 ID: Int64(1), 10532 NodeID: String("nid"), 10533 Name: String("n"), 10534 Path: String("p"), 10535 State: String("s"), 10536 CreatedAt: &Timestamp{referenceTime}, 10537 UpdatedAt: &Timestamp{referenceTime}, 10538 URL: String("u"), 10539 HTMLURL: String("h"), 10540 BadgeURL: String("b"), 10541 }, 10542 WorkflowRun: &WorkflowRun{ 10543 ID: Int64(1), 10544 Name: String("n"), 10545 NodeID: String("nid"), 10546 HeadBranch: String("hb"), 10547 HeadSHA: String("hs"), 10548 RunNumber: Int(1), 10549 RunAttempt: Int(1), 10550 Event: String("e"), 10551 Status: String("s"), 10552 Conclusion: String("c"), 10553 WorkflowID: Int64(1), 10554 URL: String("u"), 10555 HTMLURL: String("h"), 10556 PullRequests: []*PullRequest{ 10557 { 10558 URL: String("u"), 10559 ID: Int64(1), 10560 Number: Int(1), 10561 Head: &PullRequestBranch{ 10562 Ref: String("r"), 10563 SHA: String("s"), 10564 Repo: &Repository{ 10565 ID: Int64(1), 10566 URL: String("s"), 10567 Name: String("n"), 10568 }, 10569 }, 10570 Base: &PullRequestBranch{ 10571 Ref: String("r"), 10572 SHA: String("s"), 10573 Repo: &Repository{ 10574 ID: Int64(1), 10575 URL: String("u"), 10576 Name: String("n"), 10577 }, 10578 }, 10579 }, 10580 }, 10581 CreatedAt: &Timestamp{referenceTime}, 10582 UpdatedAt: &Timestamp{referenceTime}, 10583 RunStartedAt: &Timestamp{referenceTime}, 10584 JobsURL: String("j"), 10585 LogsURL: String("l"), 10586 CheckSuiteURL: String("c"), 10587 ArtifactsURL: String("a"), 10588 CancelURL: String("c"), 10589 RerunURL: String("r"), 10590 PreviousAttemptURL: String("p"), 10591 HeadCommit: &HeadCommit{ 10592 Message: String("m"), 10593 Author: &CommitAuthor{ 10594 Name: String("n"), 10595 Email: String("e"), 10596 Login: String("l"), 10597 }, 10598 URL: String("u"), 10599 Distinct: Bool(false), 10600 SHA: String("s"), 10601 ID: String("i"), 10602 TreeID: String("tid"), 10603 Timestamp: &Timestamp{referenceTime}, 10604 Committer: &CommitAuthor{ 10605 Name: String("n"), 10606 Email: String("e"), 10607 Login: String("l"), 10608 }, 10609 }, 10610 WorkflowURL: String("w"), 10611 Repository: &Repository{ 10612 ID: Int64(1), 10613 URL: String("u"), 10614 Name: String("n"), 10615 }, 10616 HeadRepository: &Repository{ 10617 ID: Int64(1), 10618 URL: String("u"), 10619 Name: String("n"), 10620 }, 10621 }, 10622 Org: &Organization{ 10623 BillingEmail: String("be"), 10624 Blog: String("b"), 10625 Company: String("c"), 10626 Email: String("e"), 10627 TwitterUsername: String("tu"), 10628 Location: String("loc"), 10629 Name: String("n"), 10630 Description: String("d"), 10631 IsVerified: Bool(true), 10632 HasOrganizationProjects: Bool(true), 10633 HasRepositoryProjects: Bool(true), 10634 DefaultRepoPermission: String("drp"), 10635 MembersCanCreateRepos: Bool(true), 10636 MembersCanCreateInternalRepos: Bool(true), 10637 MembersCanCreatePrivateRepos: Bool(true), 10638 MembersCanCreatePublicRepos: Bool(false), 10639 MembersAllowedRepositoryCreationType: String("marct"), 10640 MembersCanCreatePages: Bool(true), 10641 MembersCanCreatePublicPages: Bool(false), 10642 MembersCanCreatePrivatePages: Bool(true), 10643 }, 10644 Repo: &Repository{ 10645 ID: Int64(1), 10646 URL: String("s"), 10647 Name: String("n"), 10648 }, 10649 Sender: &User{ 10650 Login: String("l"), 10651 ID: Int64(1), 10652 NodeID: String("n"), 10653 URL: String("u"), 10654 ReposURL: String("r"), 10655 EventsURL: String("e"), 10656 AvatarURL: String("a"), 10657 }, 10658 } 10659 10660 want := `{ 10661 "action": "a", 10662 "workflow": { 10663 "id": 1, 10664 "node_id": "nid", 10665 "name": "n", 10666 "path": "p", 10667 "state": "s", 10668 "created_at": ` + referenceTimeStr + `, 10669 "updated_at": ` + referenceTimeStr + `, 10670 "url": "u", 10671 "html_url": "h", 10672 "badge_url": "b" 10673 }, 10674 "workflow_run": { 10675 "id": 1, 10676 "name": "n", 10677 "node_id": "nid", 10678 "head_branch": "hb", 10679 "head_sha": "hs", 10680 "run_number": 1, 10681 "run_attempt": 1, 10682 "event": "e", 10683 "status": "s", 10684 "conclusion": "c", 10685 "workflow_id": 1, 10686 "url": "u", 10687 "html_url": "h", 10688 "pull_requests": [ 10689 { 10690 "id": 1, 10691 "number": 1, 10692 "url": "u", 10693 "head": { 10694 "ref": "r", 10695 "sha": "s", 10696 "repo": { 10697 "id": 1, 10698 "name": "n", 10699 "url": "s" 10700 } 10701 }, 10702 "base": { 10703 "ref": "r", 10704 "sha": "s", 10705 "repo": { 10706 "id": 1, 10707 "name": "n", 10708 "url": "u" 10709 } 10710 } 10711 } 10712 ], 10713 "created_at": ` + referenceTimeStr + `, 10714 "updated_at": ` + referenceTimeStr + `, 10715 "run_started_at": ` + referenceTimeStr + `, 10716 "jobs_url": "j", 10717 "logs_url": "l", 10718 "check_suite_url": "c", 10719 "artifacts_url": "a", 10720 "cancel_url": "c", 10721 "rerun_url": "r", 10722 "previous_attempt_url": "p", 10723 "head_commit": { 10724 "message": "m", 10725 "author": { 10726 "name": "n", 10727 "email": "e", 10728 "username": "l" 10729 }, 10730 "url": "u", 10731 "distinct": false, 10732 "sha": "s", 10733 "id": "i", 10734 "tree_id": "tid", 10735 "timestamp": ` + referenceTimeStr + `, 10736 "committer": { 10737 "name": "n", 10738 "email": "e", 10739 "username": "l" 10740 } 10741 }, 10742 "workflow_url": "w", 10743 "repository": { 10744 "id": 1, 10745 "name": "n", 10746 "url": "u" 10747 }, 10748 "head_repository": { 10749 "id": 1, 10750 "name": "n", 10751 "url": "u" 10752 } 10753 }, 10754 "organization": { 10755 "name": "n", 10756 "company": "c", 10757 "blog": "b", 10758 "location": "loc", 10759 "email": "e", 10760 "twitter_username": "tu", 10761 "description": "d", 10762 "billing_email": "be", 10763 "is_verified": true, 10764 "has_organization_projects": true, 10765 "has_repository_projects": true, 10766 "default_repository_permission": "drp", 10767 "members_can_create_repositories": true, 10768 "members_can_create_public_repositories": false, 10769 "members_can_create_private_repositories": true, 10770 "members_can_create_internal_repositories": true, 10771 "members_allowed_repository_creation_type": "marct", 10772 "members_can_create_pages": true, 10773 "members_can_create_public_pages": false, 10774 "members_can_create_private_pages": true 10775 }, 10776 "repository": { 10777 "id": 1, 10778 "name": "n", 10779 "url": "s" 10780 }, 10781 "sender": { 10782 "login": "l", 10783 "id": 1, 10784 "node_id": "n", 10785 "avatar_url": "a", 10786 "url": "u", 10787 "events_url": "e", 10788 "repos_url": "r" 10789 } 10790 }` 10791 10792 testJSONMarshal(t, u, want) 10793 } 10794 10795 func TestWorkflowDispatchEvent_Marshal(t *testing.T) { 10796 testJSONMarshal(t, &WorkflowDispatchEvent{}, "{}") 10797 10798 i := make(map[string]interface{}) 10799 i["key"] = "value" 10800 10801 jsonMsg, _ := json.Marshal(i) 10802 u := &WorkflowDispatchEvent{ 10803 Inputs: jsonMsg, 10804 Ref: String("r"), 10805 Workflow: String("w"), 10806 Repo: &Repository{ 10807 ID: Int64(1), 10808 URL: String("s"), 10809 Name: String("n"), 10810 }, 10811 Org: &Organization{ 10812 BillingEmail: String("be"), 10813 Blog: String("b"), 10814 Company: String("c"), 10815 Email: String("e"), 10816 TwitterUsername: String("tu"), 10817 Location: String("loc"), 10818 Name: String("n"), 10819 Description: String("d"), 10820 IsVerified: Bool(true), 10821 HasOrganizationProjects: Bool(true), 10822 HasRepositoryProjects: Bool(true), 10823 DefaultRepoPermission: String("drp"), 10824 MembersCanCreateRepos: Bool(true), 10825 MembersCanCreateInternalRepos: Bool(true), 10826 MembersCanCreatePrivateRepos: Bool(true), 10827 MembersCanCreatePublicRepos: Bool(false), 10828 MembersAllowedRepositoryCreationType: String("marct"), 10829 MembersCanCreatePages: Bool(true), 10830 MembersCanCreatePublicPages: Bool(false), 10831 MembersCanCreatePrivatePages: Bool(true), 10832 }, 10833 Sender: &User{ 10834 Login: String("l"), 10835 ID: Int64(1), 10836 NodeID: String("n"), 10837 URL: String("u"), 10838 ReposURL: String("r"), 10839 EventsURL: String("e"), 10840 AvatarURL: String("a"), 10841 }, 10842 } 10843 10844 want := `{ 10845 "inputs": { 10846 "key": "value" 10847 }, 10848 "ref": "r", 10849 "workflow": "w", 10850 "repository": { 10851 "id": 1, 10852 "name": "n", 10853 "url": "s" 10854 }, 10855 "organization": { 10856 "name": "n", 10857 "company": "c", 10858 "blog": "b", 10859 "location": "loc", 10860 "email": "e", 10861 "twitter_username": "tu", 10862 "description": "d", 10863 "billing_email": "be", 10864 "is_verified": true, 10865 "has_organization_projects": true, 10866 "has_repository_projects": true, 10867 "default_repository_permission": "drp", 10868 "members_can_create_repositories": true, 10869 "members_can_create_public_repositories": false, 10870 "members_can_create_private_repositories": true, 10871 "members_can_create_internal_repositories": true, 10872 "members_allowed_repository_creation_type": "marct", 10873 "members_can_create_pages": true, 10874 "members_can_create_public_pages": false, 10875 "members_can_create_private_pages": true 10876 }, 10877 "sender": { 10878 "login": "l", 10879 "id": 1, 10880 "node_id": "n", 10881 "avatar_url": "a", 10882 "url": "u", 10883 "events_url": "e", 10884 "repos_url": "r" 10885 } 10886 }` 10887 10888 testJSONMarshal(t, u, want) 10889 } 10890 10891 func TestWatchEvent_Marshal(t *testing.T) { 10892 testJSONMarshal(t, &WatchEvent{}, "{}") 10893 10894 u := &WatchEvent{ 10895 Action: String("a"), 10896 Repo: &Repository{ 10897 ID: Int64(1), 10898 URL: String("s"), 10899 Name: String("n"), 10900 }, 10901 Sender: &User{ 10902 Login: String("l"), 10903 ID: Int64(1), 10904 NodeID: String("n"), 10905 URL: String("u"), 10906 ReposURL: String("r"), 10907 EventsURL: String("e"), 10908 AvatarURL: String("a"), 10909 }, 10910 Installation: &Installation{ 10911 ID: Int64(1), 10912 NodeID: String("nid"), 10913 AppID: Int64(1), 10914 AppSlug: String("as"), 10915 TargetID: Int64(1), 10916 Account: &User{ 10917 Login: String("l"), 10918 ID: Int64(1), 10919 URL: String("u"), 10920 AvatarURL: String("a"), 10921 GravatarID: String("g"), 10922 Name: String("n"), 10923 Company: String("c"), 10924 Blog: String("b"), 10925 Location: String("l"), 10926 Email: String("e"), 10927 Hireable: Bool(true), 10928 Bio: String("b"), 10929 TwitterUsername: String("t"), 10930 PublicRepos: Int(1), 10931 Followers: Int(1), 10932 Following: Int(1), 10933 CreatedAt: &Timestamp{referenceTime}, 10934 SuspendedAt: &Timestamp{referenceTime}, 10935 }, 10936 AccessTokensURL: String("atu"), 10937 RepositoriesURL: String("ru"), 10938 HTMLURL: String("hu"), 10939 TargetType: String("tt"), 10940 SingleFileName: String("sfn"), 10941 RepositorySelection: String("rs"), 10942 Events: []string{"e"}, 10943 SingleFilePaths: []string{"s"}, 10944 Permissions: &InstallationPermissions{ 10945 Actions: String("a"), 10946 Administration: String("ad"), 10947 Checks: String("c"), 10948 Contents: String("co"), 10949 ContentReferences: String("cr"), 10950 Deployments: String("d"), 10951 Environments: String("e"), 10952 Issues: String("i"), 10953 Metadata: String("md"), 10954 Members: String("m"), 10955 OrganizationAdministration: String("oa"), 10956 OrganizationHooks: String("oh"), 10957 OrganizationPlan: String("op"), 10958 OrganizationPreReceiveHooks: String("opr"), 10959 OrganizationProjects: String("op"), 10960 OrganizationSecrets: String("os"), 10961 OrganizationSelfHostedRunners: String("osh"), 10962 OrganizationUserBlocking: String("oub"), 10963 Packages: String("pkg"), 10964 Pages: String("pg"), 10965 PullRequests: String("pr"), 10966 RepositoryHooks: String("rh"), 10967 RepositoryProjects: String("rp"), 10968 RepositoryPreReceiveHooks: String("rprh"), 10969 Secrets: String("s"), 10970 SecretScanningAlerts: String("ssa"), 10971 SecurityEvents: String("se"), 10972 SingleFile: String("sf"), 10973 Statuses: String("s"), 10974 TeamDiscussions: String("td"), 10975 VulnerabilityAlerts: String("va"), 10976 Workflows: String("w"), 10977 }, 10978 CreatedAt: &Timestamp{referenceTime}, 10979 UpdatedAt: &Timestamp{referenceTime}, 10980 HasMultipleSingleFiles: Bool(false), 10981 SuspendedBy: &User{ 10982 Login: String("l"), 10983 ID: Int64(1), 10984 URL: String("u"), 10985 AvatarURL: String("a"), 10986 GravatarID: String("g"), 10987 Name: String("n"), 10988 Company: String("c"), 10989 Blog: String("b"), 10990 Location: String("l"), 10991 Email: String("e"), 10992 Hireable: Bool(true), 10993 Bio: String("b"), 10994 TwitterUsername: String("t"), 10995 PublicRepos: Int(1), 10996 Followers: Int(1), 10997 Following: Int(1), 10998 CreatedAt: &Timestamp{referenceTime}, 10999 SuspendedAt: &Timestamp{referenceTime}, 11000 }, 11001 SuspendedAt: &Timestamp{referenceTime}, 11002 }, 11003 } 11004 11005 want := `{ 11006 "action": "a", 11007 "repository": { 11008 "id": 1, 11009 "name": "n", 11010 "url": "s" 11011 }, 11012 "sender": { 11013 "login": "l", 11014 "id": 1, 11015 "node_id": "n", 11016 "avatar_url": "a", 11017 "url": "u", 11018 "events_url": "e", 11019 "repos_url": "r" 11020 }, 11021 "installation": { 11022 "id": 1, 11023 "node_id": "nid", 11024 "app_id": 1, 11025 "app_slug": "as", 11026 "target_id": 1, 11027 "account": { 11028 "login": "l", 11029 "id": 1, 11030 "avatar_url": "a", 11031 "gravatar_id": "g", 11032 "name": "n", 11033 "company": "c", 11034 "blog": "b", 11035 "location": "l", 11036 "email": "e", 11037 "hireable": true, 11038 "bio": "b", 11039 "twitter_username": "t", 11040 "public_repos": 1, 11041 "followers": 1, 11042 "following": 1, 11043 "created_at": ` + referenceTimeStr + `, 11044 "suspended_at": ` + referenceTimeStr + `, 11045 "url": "u" 11046 }, 11047 "access_tokens_url": "atu", 11048 "repositories_url": "ru", 11049 "html_url": "hu", 11050 "target_type": "tt", 11051 "single_file_name": "sfn", 11052 "repository_selection": "rs", 11053 "events": [ 11054 "e" 11055 ], 11056 "single_file_paths": [ 11057 "s" 11058 ], 11059 "permissions": { 11060 "actions": "a", 11061 "administration": "ad", 11062 "checks": "c", 11063 "contents": "co", 11064 "content_references": "cr", 11065 "deployments": "d", 11066 "environments": "e", 11067 "issues": "i", 11068 "metadata": "md", 11069 "members": "m", 11070 "organization_administration": "oa", 11071 "organization_hooks": "oh", 11072 "organization_plan": "op", 11073 "organization_pre_receive_hooks": "opr", 11074 "organization_projects": "op", 11075 "organization_secrets": "os", 11076 "organization_self_hosted_runners": "osh", 11077 "organization_user_blocking": "oub", 11078 "packages": "pkg", 11079 "pages": "pg", 11080 "pull_requests": "pr", 11081 "repository_hooks": "rh", 11082 "repository_projects": "rp", 11083 "repository_pre_receive_hooks": "rprh", 11084 "secrets": "s", 11085 "secret_scanning_alerts": "ssa", 11086 "security_events": "se", 11087 "single_file": "sf", 11088 "statuses": "s", 11089 "team_discussions": "td", 11090 "vulnerability_alerts": "va", 11091 "workflows": "w" 11092 }, 11093 "created_at": ` + referenceTimeStr + `, 11094 "updated_at": ` + referenceTimeStr + `, 11095 "has_multiple_single_files": false, 11096 "suspended_by": { 11097 "login": "l", 11098 "id": 1, 11099 "avatar_url": "a", 11100 "gravatar_id": "g", 11101 "name": "n", 11102 "company": "c", 11103 "blog": "b", 11104 "location": "l", 11105 "email": "e", 11106 "hireable": true, 11107 "bio": "b", 11108 "twitter_username": "t", 11109 "public_repos": 1, 11110 "followers": 1, 11111 "following": 1, 11112 "created_at": ` + referenceTimeStr + `, 11113 "suspended_at": ` + referenceTimeStr + `, 11114 "url": "u" 11115 }, 11116 "suspended_at": ` + referenceTimeStr + ` 11117 } 11118 }` 11119 11120 testJSONMarshal(t, u, want) 11121 } 11122 11123 func TestUserEvent_Marshal(t *testing.T) { 11124 testJSONMarshal(t, &UserEvent{}, "{}") 11125 11126 u := &UserEvent{ 11127 User: &User{ 11128 Login: String("l"), 11129 ID: Int64(1), 11130 NodeID: String("n"), 11131 URL: String("u"), 11132 ReposURL: String("r"), 11133 EventsURL: String("e"), 11134 AvatarURL: String("a"), 11135 }, 11136 // The action performed. Possible values are: "created" or "deleted". 11137 Action: String("a"), 11138 Enterprise: &Enterprise{ 11139 ID: Int(1), 11140 Slug: String("s"), 11141 Name: String("n"), 11142 NodeID: String("nid"), 11143 AvatarURL: String("au"), 11144 Description: String("d"), 11145 WebsiteURL: String("wu"), 11146 HTMLURL: String("hu"), 11147 CreatedAt: &Timestamp{referenceTime}, 11148 UpdatedAt: &Timestamp{referenceTime}, 11149 }, 11150 Sender: &User{ 11151 Login: String("l"), 11152 ID: Int64(1), 11153 NodeID: String("n"), 11154 URL: String("u"), 11155 ReposURL: String("r"), 11156 EventsURL: String("e"), 11157 AvatarURL: String("a"), 11158 }, 11159 } 11160 11161 want := `{ 11162 "user": { 11163 "login": "l", 11164 "id": 1, 11165 "node_id": "n", 11166 "avatar_url": "a", 11167 "url": "u", 11168 "events_url": "e", 11169 "repos_url": "r" 11170 }, 11171 "action": "a", 11172 "enterprise": { 11173 "id": 1, 11174 "slug": "s", 11175 "name": "n", 11176 "node_id": "nid", 11177 "avatar_url": "au", 11178 "description": "d", 11179 "website_url": "wu", 11180 "html_url": "hu", 11181 "created_at": ` + referenceTimeStr + `, 11182 "updated_at": ` + referenceTimeStr + ` 11183 }, 11184 "sender": { 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 }` 11194 11195 testJSONMarshal(t, u, want) 11196 } 11197 11198 func TestCheckRunEvent_Marshal(t *testing.T) { 11199 testJSONMarshal(t, &CheckRunEvent{}, "{}") 11200 11201 r := &CheckRunEvent{ 11202 CheckRun: &CheckRun{ 11203 ID: Int64(1), 11204 NodeID: String("n"), 11205 HeadSHA: String("h"), 11206 ExternalID: String("1"), 11207 URL: String("u"), 11208 HTMLURL: String("u"), 11209 DetailsURL: String("u"), 11210 Status: String("s"), 11211 Conclusion: String("c"), 11212 StartedAt: &Timestamp{referenceTime}, 11213 CompletedAt: &Timestamp{referenceTime}, 11214 Output: &CheckRunOutput{ 11215 Annotations: []*CheckRunAnnotation{ 11216 { 11217 AnnotationLevel: String("a"), 11218 EndLine: Int(1), 11219 Message: String("m"), 11220 Path: String("p"), 11221 RawDetails: String("r"), 11222 StartLine: Int(1), 11223 Title: String("t"), 11224 }, 11225 }, 11226 AnnotationsCount: Int(1), 11227 AnnotationsURL: String("a"), 11228 Images: []*CheckRunImage{ 11229 { 11230 Alt: String("a"), 11231 ImageURL: String("i"), 11232 Caption: String("c"), 11233 }, 11234 }, 11235 Title: String("t"), 11236 Summary: String("s"), 11237 Text: String("t"), 11238 }, 11239 Name: String("n"), 11240 CheckSuite: &CheckSuite{ 11241 ID: Int64(1), 11242 }, 11243 App: &App{ 11244 ID: Int64(1), 11245 NodeID: String("n"), 11246 Owner: &User{ 11247 Login: String("l"), 11248 ID: Int64(1), 11249 NodeID: String("n"), 11250 URL: String("u"), 11251 ReposURL: String("r"), 11252 EventsURL: String("e"), 11253 AvatarURL: String("a"), 11254 }, 11255 Name: String("n"), 11256 Description: String("d"), 11257 HTMLURL: String("h"), 11258 ExternalURL: String("u"), 11259 CreatedAt: &Timestamp{referenceTime}, 11260 UpdatedAt: &Timestamp{referenceTime}, 11261 }, 11262 PullRequests: []*PullRequest{ 11263 { 11264 URL: String("u"), 11265 ID: Int64(1), 11266 Number: Int(1), 11267 Head: &PullRequestBranch{ 11268 Ref: String("r"), 11269 SHA: String("s"), 11270 Repo: &Repository{ 11271 ID: Int64(1), 11272 URL: String("s"), 11273 Name: String("n"), 11274 }, 11275 }, 11276 Base: &PullRequestBranch{ 11277 Ref: String("r"), 11278 SHA: String("s"), 11279 Repo: &Repository{ 11280 ID: Int64(1), 11281 URL: String("u"), 11282 Name: String("n"), 11283 }, 11284 }, 11285 }, 11286 }, 11287 }, 11288 Action: String("a"), 11289 Repo: &Repository{ 11290 ID: Int64(1), 11291 URL: String("s"), 11292 Name: String("n"), 11293 }, 11294 Org: &Organization{ 11295 BillingEmail: String("be"), 11296 Blog: String("b"), 11297 Company: String("c"), 11298 Email: String("e"), 11299 TwitterUsername: String("tu"), 11300 Location: String("loc"), 11301 Name: String("n"), 11302 Description: String("d"), 11303 IsVerified: Bool(true), 11304 HasOrganizationProjects: Bool(true), 11305 HasRepositoryProjects: Bool(true), 11306 DefaultRepoPermission: String("drp"), 11307 MembersCanCreateRepos: Bool(true), 11308 MembersCanCreateInternalRepos: Bool(true), 11309 MembersCanCreatePrivateRepos: Bool(true), 11310 MembersCanCreatePublicRepos: Bool(false), 11311 MembersAllowedRepositoryCreationType: String("marct"), 11312 MembersCanCreatePages: Bool(true), 11313 MembersCanCreatePublicPages: Bool(false), 11314 MembersCanCreatePrivatePages: Bool(true), 11315 }, 11316 Sender: &User{ 11317 Login: String("l"), 11318 ID: Int64(1), 11319 NodeID: String("n"), 11320 URL: String("u"), 11321 ReposURL: String("r"), 11322 EventsURL: String("e"), 11323 AvatarURL: String("a"), 11324 }, 11325 Installation: &Installation{ 11326 ID: Int64(1), 11327 NodeID: String("nid"), 11328 AppID: Int64(1), 11329 AppSlug: String("as"), 11330 TargetID: Int64(1), 11331 Account: &User{ 11332 Login: String("l"), 11333 ID: Int64(1), 11334 URL: String("u"), 11335 AvatarURL: String("a"), 11336 GravatarID: String("g"), 11337 Name: String("n"), 11338 Company: String("c"), 11339 Blog: String("b"), 11340 Location: String("l"), 11341 Email: String("e"), 11342 Hireable: Bool(true), 11343 Bio: String("b"), 11344 TwitterUsername: String("t"), 11345 PublicRepos: Int(1), 11346 Followers: Int(1), 11347 Following: Int(1), 11348 CreatedAt: &Timestamp{referenceTime}, 11349 SuspendedAt: &Timestamp{referenceTime}, 11350 }, 11351 AccessTokensURL: String("atu"), 11352 RepositoriesURL: String("ru"), 11353 HTMLURL: String("hu"), 11354 TargetType: String("tt"), 11355 SingleFileName: String("sfn"), 11356 RepositorySelection: String("rs"), 11357 Events: []string{"e"}, 11358 SingleFilePaths: []string{"s"}, 11359 Permissions: &InstallationPermissions{ 11360 Actions: String("a"), 11361 Administration: String("ad"), 11362 Checks: String("c"), 11363 Contents: String("co"), 11364 ContentReferences: String("cr"), 11365 Deployments: String("d"), 11366 Environments: String("e"), 11367 Issues: String("i"), 11368 Metadata: String("md"), 11369 Members: String("m"), 11370 OrganizationAdministration: String("oa"), 11371 OrganizationHooks: String("oh"), 11372 OrganizationPlan: String("op"), 11373 OrganizationPreReceiveHooks: String("opr"), 11374 OrganizationProjects: String("op"), 11375 OrganizationSecrets: String("os"), 11376 OrganizationSelfHostedRunners: String("osh"), 11377 OrganizationUserBlocking: String("oub"), 11378 Packages: String("pkg"), 11379 Pages: String("pg"), 11380 PullRequests: String("pr"), 11381 RepositoryHooks: String("rh"), 11382 RepositoryProjects: String("rp"), 11383 RepositoryPreReceiveHooks: String("rprh"), 11384 Secrets: String("s"), 11385 SecretScanningAlerts: String("ssa"), 11386 SecurityEvents: String("se"), 11387 SingleFile: String("sf"), 11388 Statuses: String("s"), 11389 TeamDiscussions: String("td"), 11390 VulnerabilityAlerts: String("va"), 11391 Workflows: String("w"), 11392 }, 11393 CreatedAt: &Timestamp{referenceTime}, 11394 UpdatedAt: &Timestamp{referenceTime}, 11395 HasMultipleSingleFiles: Bool(false), 11396 SuspendedBy: &User{ 11397 Login: String("l"), 11398 ID: Int64(1), 11399 URL: String("u"), 11400 AvatarURL: String("a"), 11401 GravatarID: String("g"), 11402 Name: String("n"), 11403 Company: String("c"), 11404 Blog: String("b"), 11405 Location: String("l"), 11406 Email: String("e"), 11407 Hireable: Bool(true), 11408 Bio: String("b"), 11409 TwitterUsername: String("t"), 11410 PublicRepos: Int(1), 11411 Followers: Int(1), 11412 Following: Int(1), 11413 CreatedAt: &Timestamp{referenceTime}, 11414 SuspendedAt: &Timestamp{referenceTime}, 11415 }, 11416 SuspendedAt: &Timestamp{referenceTime}, 11417 }, 11418 RequestedAction: &RequestedAction{ 11419 Identifier: "i", 11420 }, 11421 } 11422 11423 want := `{ 11424 "check_run": { 11425 "id": 1, 11426 "node_id": "n", 11427 "head_sha": "h", 11428 "external_id": "1", 11429 "url": "u", 11430 "html_url": "u", 11431 "details_url": "u", 11432 "status": "s", 11433 "conclusion": "c", 11434 "started_at": ` + referenceTimeStr + `, 11435 "completed_at": ` + referenceTimeStr + `, 11436 "output": { 11437 "title": "t", 11438 "summary": "s", 11439 "text": "t", 11440 "annotations_count": 1, 11441 "annotations_url": "a", 11442 "annotations": [ 11443 { 11444 "path": "p", 11445 "start_line": 1, 11446 "end_line": 1, 11447 "annotation_level": "a", 11448 "message": "m", 11449 "title": "t", 11450 "raw_details": "r" 11451 } 11452 ], 11453 "images": [ 11454 { 11455 "alt": "a", 11456 "image_url": "i", 11457 "caption": "c" 11458 } 11459 ] 11460 }, 11461 "name": "n", 11462 "check_suite": { 11463 "id": 1 11464 }, 11465 "app": { 11466 "id": 1, 11467 "node_id": "n", 11468 "owner": { 11469 "login": "l", 11470 "id": 1, 11471 "node_id": "n", 11472 "avatar_url": "a", 11473 "url": "u", 11474 "events_url": "e", 11475 "repos_url": "r" 11476 }, 11477 "name": "n", 11478 "description": "d", 11479 "external_url": "u", 11480 "html_url": "h", 11481 "created_at": ` + referenceTimeStr + `, 11482 "updated_at": ` + referenceTimeStr + ` 11483 }, 11484 "pull_requests": [ 11485 { 11486 "id": 1, 11487 "number": 1, 11488 "url": "u", 11489 "head": { 11490 "ref": "r", 11491 "sha": "s", 11492 "repo": { 11493 "id": 1, 11494 "name": "n", 11495 "url": "s" 11496 } 11497 }, 11498 "base": { 11499 "ref": "r", 11500 "sha": "s", 11501 "repo": { 11502 "id": 1, 11503 "name": "n", 11504 "url": "u" 11505 } 11506 } 11507 } 11508 ] 11509 }, 11510 "action": "a", 11511 "repository": { 11512 "id": 1, 11513 "name": "n", 11514 "url": "s" 11515 }, 11516 "organization": { 11517 "name": "n", 11518 "company": "c", 11519 "blog": "b", 11520 "location": "loc", 11521 "email": "e", 11522 "twitter_username": "tu", 11523 "description": "d", 11524 "billing_email": "be", 11525 "is_verified": true, 11526 "has_organization_projects": true, 11527 "has_repository_projects": true, 11528 "default_repository_permission": "drp", 11529 "members_can_create_repositories": true, 11530 "members_can_create_public_repositories": false, 11531 "members_can_create_private_repositories": true, 11532 "members_can_create_internal_repositories": true, 11533 "members_allowed_repository_creation_type": "marct", 11534 "members_can_create_pages": true, 11535 "members_can_create_public_pages": false, 11536 "members_can_create_private_pages": true 11537 }, 11538 "sender": { 11539 "login": "l", 11540 "id": 1, 11541 "node_id": "n", 11542 "avatar_url": "a", 11543 "url": "u", 11544 "events_url": "e", 11545 "repos_url": "r" 11546 }, 11547 "installation": { 11548 "id": 1, 11549 "node_id": "nid", 11550 "app_id": 1, 11551 "app_slug": "as", 11552 "target_id": 1, 11553 "account": { 11554 "login": "l", 11555 "id": 1, 11556 "avatar_url": "a", 11557 "gravatar_id": "g", 11558 "name": "n", 11559 "company": "c", 11560 "blog": "b", 11561 "location": "l", 11562 "email": "e", 11563 "hireable": true, 11564 "bio": "b", 11565 "twitter_username": "t", 11566 "public_repos": 1, 11567 "followers": 1, 11568 "following": 1, 11569 "created_at": ` + referenceTimeStr + `, 11570 "suspended_at": ` + referenceTimeStr + `, 11571 "url": "u" 11572 }, 11573 "access_tokens_url": "atu", 11574 "repositories_url": "ru", 11575 "html_url": "hu", 11576 "target_type": "tt", 11577 "single_file_name": "sfn", 11578 "repository_selection": "rs", 11579 "events": [ 11580 "e" 11581 ], 11582 "single_file_paths": [ 11583 "s" 11584 ], 11585 "permissions": { 11586 "actions": "a", 11587 "administration": "ad", 11588 "checks": "c", 11589 "contents": "co", 11590 "content_references": "cr", 11591 "deployments": "d", 11592 "environments": "e", 11593 "issues": "i", 11594 "metadata": "md", 11595 "members": "m", 11596 "organization_administration": "oa", 11597 "organization_hooks": "oh", 11598 "organization_plan": "op", 11599 "organization_pre_receive_hooks": "opr", 11600 "organization_projects": "op", 11601 "organization_secrets": "os", 11602 "organization_self_hosted_runners": "osh", 11603 "organization_user_blocking": "oub", 11604 "packages": "pkg", 11605 "pages": "pg", 11606 "pull_requests": "pr", 11607 "repository_hooks": "rh", 11608 "repository_projects": "rp", 11609 "repository_pre_receive_hooks": "rprh", 11610 "secrets": "s", 11611 "secret_scanning_alerts": "ssa", 11612 "security_events": "se", 11613 "single_file": "sf", 11614 "statuses": "s", 11615 "team_discussions": "td", 11616 "vulnerability_alerts": "va", 11617 "workflows": "w" 11618 }, 11619 "created_at": ` + referenceTimeStr + `, 11620 "updated_at": ` + referenceTimeStr + `, 11621 "has_multiple_single_files": false, 11622 "suspended_by": { 11623 "login": "l", 11624 "id": 1, 11625 "avatar_url": "a", 11626 "gravatar_id": "g", 11627 "name": "n", 11628 "company": "c", 11629 "blog": "b", 11630 "location": "l", 11631 "email": "e", 11632 "hireable": true, 11633 "bio": "b", 11634 "twitter_username": "t", 11635 "public_repos": 1, 11636 "followers": 1, 11637 "following": 1, 11638 "created_at": ` + referenceTimeStr + `, 11639 "suspended_at": ` + referenceTimeStr + `, 11640 "url": "u" 11641 }, 11642 "suspended_at": ` + referenceTimeStr + ` 11643 }, 11644 "requested_action": { 11645 "identifier": "i" 11646 } 11647 }` 11648 11649 testJSONMarshal(t, r, want) 11650 } 11651 11652 func TestCheckSuiteEvent_Marshal(t *testing.T) { 11653 testJSONMarshal(t, &CheckSuiteEvent{}, "{}") 11654 11655 r := &CheckSuiteEvent{ 11656 CheckSuite: &CheckSuite{ 11657 ID: Int64(1), 11658 NodeID: String("n"), 11659 HeadBranch: String("h"), 11660 HeadSHA: String("h"), 11661 URL: String("u"), 11662 BeforeSHA: String("b"), 11663 AfterSHA: String("a"), 11664 Status: String("s"), 11665 Conclusion: String("c"), 11666 App: &App{ 11667 ID: Int64(1), 11668 NodeID: String("n"), 11669 Owner: &User{ 11670 Login: String("l"), 11671 ID: Int64(1), 11672 NodeID: String("n"), 11673 URL: String("u"), 11674 ReposURL: String("r"), 11675 EventsURL: String("e"), 11676 AvatarURL: String("a"), 11677 }, 11678 Name: String("n"), 11679 Description: String("d"), 11680 HTMLURL: String("h"), 11681 ExternalURL: String("u"), 11682 CreatedAt: &Timestamp{referenceTime}, 11683 UpdatedAt: &Timestamp{referenceTime}, 11684 }, 11685 Repository: &Repository{ 11686 ID: Int64(1), 11687 }, 11688 PullRequests: []*PullRequest{ 11689 { 11690 URL: String("u"), 11691 ID: Int64(1), 11692 Number: Int(1), 11693 Head: &PullRequestBranch{ 11694 Ref: String("r"), 11695 SHA: String("s"), 11696 Repo: &Repository{ 11697 ID: Int64(1), 11698 URL: String("s"), 11699 Name: String("n"), 11700 }, 11701 }, 11702 Base: &PullRequestBranch{ 11703 Ref: String("r"), 11704 SHA: String("s"), 11705 Repo: &Repository{ 11706 ID: Int64(1), 11707 URL: String("u"), 11708 Name: String("n"), 11709 }, 11710 }, 11711 }, 11712 }, 11713 HeadCommit: &Commit{ 11714 SHA: String("s"), 11715 }, 11716 }, 11717 Action: String("a"), 11718 Repo: &Repository{ 11719 ID: Int64(1), 11720 URL: String("s"), 11721 Name: String("n"), 11722 }, 11723 Org: &Organization{ 11724 BillingEmail: String("be"), 11725 Blog: String("b"), 11726 Company: String("c"), 11727 Email: String("e"), 11728 TwitterUsername: String("tu"), 11729 Location: String("loc"), 11730 Name: String("n"), 11731 Description: String("d"), 11732 IsVerified: Bool(true), 11733 HasOrganizationProjects: Bool(true), 11734 HasRepositoryProjects: Bool(true), 11735 DefaultRepoPermission: String("drp"), 11736 MembersCanCreateRepos: Bool(true), 11737 MembersCanCreateInternalRepos: Bool(true), 11738 MembersCanCreatePrivateRepos: Bool(true), 11739 MembersCanCreatePublicRepos: Bool(false), 11740 MembersAllowedRepositoryCreationType: String("marct"), 11741 MembersCanCreatePages: Bool(true), 11742 MembersCanCreatePublicPages: Bool(false), 11743 MembersCanCreatePrivatePages: Bool(true), 11744 }, 11745 Sender: &User{ 11746 Login: String("l"), 11747 ID: Int64(1), 11748 NodeID: String("n"), 11749 URL: String("u"), 11750 ReposURL: String("r"), 11751 EventsURL: String("e"), 11752 AvatarURL: String("a"), 11753 }, 11754 Installation: &Installation{ 11755 ID: Int64(1), 11756 NodeID: String("nid"), 11757 AppID: Int64(1), 11758 AppSlug: String("as"), 11759 TargetID: Int64(1), 11760 Account: &User{ 11761 Login: String("l"), 11762 ID: Int64(1), 11763 URL: String("u"), 11764 AvatarURL: String("a"), 11765 GravatarID: String("g"), 11766 Name: String("n"), 11767 Company: String("c"), 11768 Blog: String("b"), 11769 Location: String("l"), 11770 Email: String("e"), 11771 Hireable: Bool(true), 11772 Bio: String("b"), 11773 TwitterUsername: String("t"), 11774 PublicRepos: Int(1), 11775 Followers: Int(1), 11776 Following: Int(1), 11777 CreatedAt: &Timestamp{referenceTime}, 11778 SuspendedAt: &Timestamp{referenceTime}, 11779 }, 11780 AccessTokensURL: String("atu"), 11781 RepositoriesURL: String("ru"), 11782 HTMLURL: String("hu"), 11783 TargetType: String("tt"), 11784 SingleFileName: String("sfn"), 11785 RepositorySelection: String("rs"), 11786 Events: []string{"e"}, 11787 SingleFilePaths: []string{"s"}, 11788 Permissions: &InstallationPermissions{ 11789 Actions: String("a"), 11790 Administration: String("ad"), 11791 Checks: String("c"), 11792 Contents: String("co"), 11793 ContentReferences: String("cr"), 11794 Deployments: String("d"), 11795 Environments: String("e"), 11796 Issues: String("i"), 11797 Metadata: String("md"), 11798 Members: String("m"), 11799 OrganizationAdministration: String("oa"), 11800 OrganizationHooks: String("oh"), 11801 OrganizationPlan: String("op"), 11802 OrganizationPreReceiveHooks: String("opr"), 11803 OrganizationProjects: String("op"), 11804 OrganizationSecrets: String("os"), 11805 OrganizationSelfHostedRunners: String("osh"), 11806 OrganizationUserBlocking: String("oub"), 11807 Packages: String("pkg"), 11808 Pages: String("pg"), 11809 PullRequests: String("pr"), 11810 RepositoryHooks: String("rh"), 11811 RepositoryProjects: String("rp"), 11812 RepositoryPreReceiveHooks: String("rprh"), 11813 Secrets: String("s"), 11814 SecretScanningAlerts: String("ssa"), 11815 SecurityEvents: String("se"), 11816 SingleFile: String("sf"), 11817 Statuses: String("s"), 11818 TeamDiscussions: String("td"), 11819 VulnerabilityAlerts: String("va"), 11820 Workflows: String("w"), 11821 }, 11822 CreatedAt: &Timestamp{referenceTime}, 11823 UpdatedAt: &Timestamp{referenceTime}, 11824 HasMultipleSingleFiles: Bool(false), 11825 SuspendedBy: &User{ 11826 Login: String("l"), 11827 ID: Int64(1), 11828 URL: String("u"), 11829 AvatarURL: String("a"), 11830 GravatarID: String("g"), 11831 Name: String("n"), 11832 Company: String("c"), 11833 Blog: String("b"), 11834 Location: String("l"), 11835 Email: String("e"), 11836 Hireable: Bool(true), 11837 Bio: String("b"), 11838 TwitterUsername: String("t"), 11839 PublicRepos: Int(1), 11840 Followers: Int(1), 11841 Following: Int(1), 11842 CreatedAt: &Timestamp{referenceTime}, 11843 SuspendedAt: &Timestamp{referenceTime}, 11844 }, 11845 SuspendedAt: &Timestamp{referenceTime}, 11846 }, 11847 } 11848 11849 want := `{ 11850 "check_suite": { 11851 "id": 1, 11852 "node_id": "n", 11853 "head_branch": "h", 11854 "head_sha": "h", 11855 "url": "u", 11856 "before": "b", 11857 "after": "a", 11858 "status": "s", 11859 "conclusion": "c", 11860 "app": { 11861 "id": 1, 11862 "node_id": "n", 11863 "owner": { 11864 "login": "l", 11865 "id": 1, 11866 "node_id": "n", 11867 "avatar_url": "a", 11868 "url": "u", 11869 "events_url": "e", 11870 "repos_url": "r" 11871 }, 11872 "name": "n", 11873 "description": "d", 11874 "external_url": "u", 11875 "html_url": "h", 11876 "created_at": ` + referenceTimeStr + `, 11877 "updated_at": ` + referenceTimeStr + ` 11878 }, 11879 "repository": { 11880 "id": 1 11881 }, 11882 "pull_requests": [ 11883 { 11884 "id": 1, 11885 "number": 1, 11886 "url": "u", 11887 "head": { 11888 "ref": "r", 11889 "sha": "s", 11890 "repo": { 11891 "id": 1, 11892 "name": "n", 11893 "url": "s" 11894 } 11895 }, 11896 "base": { 11897 "ref": "r", 11898 "sha": "s", 11899 "repo": { 11900 "id": 1, 11901 "name": "n", 11902 "url": "u" 11903 } 11904 } 11905 } 11906 ], 11907 "head_commit": { 11908 "sha": "s" 11909 } 11910 }, 11911 "action": "a", 11912 "repository": { 11913 "id": 1, 11914 "name": "n", 11915 "url": "s" 11916 }, 11917 "organization": { 11918 "name": "n", 11919 "company": "c", 11920 "blog": "b", 11921 "location": "loc", 11922 "email": "e", 11923 "twitter_username": "tu", 11924 "description": "d", 11925 "billing_email": "be", 11926 "is_verified": true, 11927 "has_organization_projects": true, 11928 "has_repository_projects": true, 11929 "default_repository_permission": "drp", 11930 "members_can_create_repositories": true, 11931 "members_can_create_public_repositories": false, 11932 "members_can_create_private_repositories": true, 11933 "members_can_create_internal_repositories": true, 11934 "members_allowed_repository_creation_type": "marct", 11935 "members_can_create_pages": true, 11936 "members_can_create_public_pages": false, 11937 "members_can_create_private_pages": true 11938 }, 11939 "sender": { 11940 "login": "l", 11941 "id": 1, 11942 "node_id": "n", 11943 "avatar_url": "a", 11944 "url": "u", 11945 "events_url": "e", 11946 "repos_url": "r" 11947 }, 11948 "installation": { 11949 "id": 1, 11950 "node_id": "nid", 11951 "app_id": 1, 11952 "app_slug": "as", 11953 "target_id": 1, 11954 "account": { 11955 "login": "l", 11956 "id": 1, 11957 "avatar_url": "a", 11958 "gravatar_id": "g", 11959 "name": "n", 11960 "company": "c", 11961 "blog": "b", 11962 "location": "l", 11963 "email": "e", 11964 "hireable": true, 11965 "bio": "b", 11966 "twitter_username": "t", 11967 "public_repos": 1, 11968 "followers": 1, 11969 "following": 1, 11970 "created_at": ` + referenceTimeStr + `, 11971 "suspended_at": ` + referenceTimeStr + `, 11972 "url": "u" 11973 }, 11974 "access_tokens_url": "atu", 11975 "repositories_url": "ru", 11976 "html_url": "hu", 11977 "target_type": "tt", 11978 "single_file_name": "sfn", 11979 "repository_selection": "rs", 11980 "events": [ 11981 "e" 11982 ], 11983 "single_file_paths": [ 11984 "s" 11985 ], 11986 "permissions": { 11987 "actions": "a", 11988 "administration": "ad", 11989 "checks": "c", 11990 "contents": "co", 11991 "content_references": "cr", 11992 "deployments": "d", 11993 "environments": "e", 11994 "issues": "i", 11995 "metadata": "md", 11996 "members": "m", 11997 "organization_administration": "oa", 11998 "organization_hooks": "oh", 11999 "organization_plan": "op", 12000 "organization_pre_receive_hooks": "opr", 12001 "organization_projects": "op", 12002 "organization_secrets": "os", 12003 "organization_self_hosted_runners": "osh", 12004 "organization_user_blocking": "oub", 12005 "packages": "pkg", 12006 "pages": "pg", 12007 "pull_requests": "pr", 12008 "repository_hooks": "rh", 12009 "repository_projects": "rp", 12010 "repository_pre_receive_hooks": "rprh", 12011 "secrets": "s", 12012 "secret_scanning_alerts": "ssa", 12013 "security_events": "se", 12014 "single_file": "sf", 12015 "statuses": "s", 12016 "team_discussions": "td", 12017 "vulnerability_alerts": "va", 12018 "workflows": "w" 12019 }, 12020 "created_at": ` + referenceTimeStr + `, 12021 "updated_at": ` + referenceTimeStr + `, 12022 "has_multiple_single_files": false, 12023 "suspended_by": { 12024 "login": "l", 12025 "id": 1, 12026 "avatar_url": "a", 12027 "gravatar_id": "g", 12028 "name": "n", 12029 "company": "c", 12030 "blog": "b", 12031 "location": "l", 12032 "email": "e", 12033 "hireable": true, 12034 "bio": "b", 12035 "twitter_username": "t", 12036 "public_repos": 1, 12037 "followers": 1, 12038 "following": 1, 12039 "created_at": ` + referenceTimeStr + `, 12040 "suspended_at": ` + referenceTimeStr + `, 12041 "url": "u" 12042 }, 12043 "suspended_at": ` + referenceTimeStr + ` 12044 } 12045 }` 12046 12047 testJSONMarshal(t, r, want) 12048 } 12049 12050 func TestDeployKeyEvent_Marshal(t *testing.T) { 12051 testJSONMarshal(t, &DeployKeyEvent{}, "{}") 12052 12053 u := &DeployKeyEvent{ 12054 Action: String("a"), 12055 Key: &Key{ 12056 ID: Int64(1), 12057 Key: String("k"), 12058 URL: String("k"), 12059 Title: String("k"), 12060 ReadOnly: Bool(false), 12061 Verified: Bool(false), 12062 CreatedAt: &Timestamp{referenceTime}, 12063 }, 12064 Repo: &Repository{ 12065 ID: Int64(1), 12066 URL: String("s"), 12067 Name: String("n"), 12068 }, 12069 Organization: &Organization{ 12070 BillingEmail: String("be"), 12071 Blog: String("b"), 12072 Company: String("c"), 12073 Email: String("e"), 12074 TwitterUsername: String("tu"), 12075 Location: String("loc"), 12076 Name: String("n"), 12077 Description: String("d"), 12078 IsVerified: Bool(true), 12079 HasOrganizationProjects: Bool(true), 12080 HasRepositoryProjects: Bool(true), 12081 DefaultRepoPermission: String("drp"), 12082 MembersCanCreateRepos: Bool(true), 12083 MembersCanCreateInternalRepos: Bool(true), 12084 MembersCanCreatePrivateRepos: Bool(true), 12085 MembersCanCreatePublicRepos: Bool(false), 12086 MembersAllowedRepositoryCreationType: String("marct"), 12087 MembersCanCreatePages: Bool(true), 12088 MembersCanCreatePublicPages: Bool(false), 12089 MembersCanCreatePrivatePages: Bool(true), 12090 }, 12091 Sender: &User{ 12092 Login: String("l"), 12093 ID: Int64(1), 12094 NodeID: String("n"), 12095 AvatarURL: String("a"), 12096 URL: String("u"), 12097 EventsURL: String("e"), 12098 ReposURL: String("r"), 12099 }, 12100 } 12101 12102 want := `{ 12103 "action": "a", 12104 "key": { 12105 "id": 1, 12106 "key": "k", 12107 "url": "k", 12108 "title": "k", 12109 "read_only": false, 12110 "verified": false, 12111 "created_at": ` + referenceTimeStr + ` 12112 }, 12113 "repository": { 12114 "id": 1, 12115 "name": "n", 12116 "url": "s" 12117 }, 12118 "organization": { 12119 "name": "n", 12120 "company": "c", 12121 "blog": "b", 12122 "location": "loc", 12123 "email": "e", 12124 "twitter_username": "tu", 12125 "description": "d", 12126 "billing_email": "be", 12127 "is_verified": true, 12128 "has_organization_projects": true, 12129 "has_repository_projects": true, 12130 "default_repository_permission": "drp", 12131 "members_can_create_repositories": true, 12132 "members_can_create_public_repositories": false, 12133 "members_can_create_private_repositories": true, 12134 "members_can_create_internal_repositories": true, 12135 "members_allowed_repository_creation_type": "marct", 12136 "members_can_create_pages": true, 12137 "members_can_create_public_pages": false, 12138 "members_can_create_private_pages": true 12139 }, 12140 "sender": { 12141 "login": "l", 12142 "id": 1, 12143 "node_id": "n", 12144 "avatar_url": "a", 12145 "url": "u", 12146 "events_url": "e", 12147 "repos_url": "r" 12148 } 12149 }` 12150 12151 testJSONMarshal(t, u, want) 12152 } 12153 12154 func TestMetaEvent_Marshal(t *testing.T) { 12155 testJSONMarshal(t, &MetaEvent{}, "{}") 12156 12157 v := make(map[string]interface{}) 12158 v["a"] = "b" 12159 12160 u := &MetaEvent{ 12161 Action: String("a"), 12162 HookID: Int64(1), 12163 Hook: &Hook{ 12164 CreatedAt: &Timestamp{referenceTime}, 12165 UpdatedAt: &Timestamp{referenceTime}, 12166 URL: String("u"), 12167 ID: Int64(1), 12168 Type: String("t"), 12169 Name: String("n"), 12170 TestURL: String("tu"), 12171 PingURL: String("pu"), 12172 LastResponse: v, 12173 Config: v, 12174 Events: []string{"a"}, 12175 Active: Bool(true), 12176 }, 12177 } 12178 12179 want := `{ 12180 "action": "a", 12181 "hook_id": 1, 12182 "hook": { 12183 "created_at": ` + referenceTimeStr + `, 12184 "updated_at": ` + referenceTimeStr + `, 12185 "url": "u", 12186 "id": 1, 12187 "type": "t", 12188 "name": "n", 12189 "test_url": "tu", 12190 "ping_url": "pu", 12191 "last_response": { 12192 "a": "b" 12193 }, 12194 "config": { 12195 "a": "b" 12196 }, 12197 "events": [ 12198 "a" 12199 ], 12200 "active": true 12201 } 12202 }` 12203 12204 testJSONMarshal(t, u, want) 12205 } 12206 12207 func TestRequestedAction_Marshal(t *testing.T) { 12208 testJSONMarshal(t, &RequestedAction{}, "{}") 12209 12210 r := &RequestedAction{ 12211 Identifier: "i", 12212 } 12213 12214 want := `{ 12215 "identifier": "i" 12216 }` 12217 12218 testJSONMarshal(t, r, want) 12219 } 12220 12221 func TestCreateEvent_Marshal(t *testing.T) { 12222 testJSONMarshal(t, &CreateEvent{}, "{}") 12223 12224 r := &CreateEvent{ 12225 Ref: String("r"), 12226 RefType: String("rt"), 12227 MasterBranch: String("mb"), 12228 Description: String("d"), 12229 PusherType: String("pt"), 12230 Repo: &Repository{ 12231 ID: Int64(1), 12232 URL: String("s"), 12233 Name: String("n"), 12234 }, 12235 Sender: &User{ 12236 Login: String("l"), 12237 ID: Int64(1), 12238 NodeID: String("n"), 12239 URL: String("u"), 12240 ReposURL: String("r"), 12241 EventsURL: String("e"), 12242 AvatarURL: String("a"), 12243 }, 12244 Installation: &Installation{ 12245 ID: Int64(1), 12246 NodeID: String("nid"), 12247 AppID: Int64(1), 12248 AppSlug: String("as"), 12249 TargetID: Int64(1), 12250 Account: &User{ 12251 Login: String("l"), 12252 ID: Int64(1), 12253 URL: String("u"), 12254 AvatarURL: String("a"), 12255 GravatarID: String("g"), 12256 Name: String("n"), 12257 Company: String("c"), 12258 Blog: String("b"), 12259 Location: String("l"), 12260 Email: String("e"), 12261 Hireable: Bool(true), 12262 Bio: String("b"), 12263 TwitterUsername: String("t"), 12264 PublicRepos: Int(1), 12265 Followers: Int(1), 12266 Following: Int(1), 12267 CreatedAt: &Timestamp{referenceTime}, 12268 SuspendedAt: &Timestamp{referenceTime}, 12269 }, 12270 AccessTokensURL: String("atu"), 12271 RepositoriesURL: String("ru"), 12272 HTMLURL: String("hu"), 12273 TargetType: String("tt"), 12274 SingleFileName: String("sfn"), 12275 RepositorySelection: String("rs"), 12276 Events: []string{"e"}, 12277 SingleFilePaths: []string{"s"}, 12278 Permissions: &InstallationPermissions{ 12279 Actions: String("a"), 12280 Administration: String("ad"), 12281 Checks: String("c"), 12282 Contents: String("co"), 12283 ContentReferences: String("cr"), 12284 Deployments: String("d"), 12285 Environments: String("e"), 12286 Issues: String("i"), 12287 Metadata: String("md"), 12288 Members: String("m"), 12289 OrganizationAdministration: String("oa"), 12290 OrganizationHooks: String("oh"), 12291 OrganizationPlan: String("op"), 12292 OrganizationPreReceiveHooks: String("opr"), 12293 OrganizationProjects: String("op"), 12294 OrganizationSecrets: String("os"), 12295 OrganizationSelfHostedRunners: String("osh"), 12296 OrganizationUserBlocking: String("oub"), 12297 Packages: String("pkg"), 12298 Pages: String("pg"), 12299 PullRequests: String("pr"), 12300 RepositoryHooks: String("rh"), 12301 RepositoryProjects: String("rp"), 12302 RepositoryPreReceiveHooks: String("rprh"), 12303 Secrets: String("s"), 12304 SecretScanningAlerts: String("ssa"), 12305 SecurityEvents: String("se"), 12306 SingleFile: String("sf"), 12307 Statuses: String("s"), 12308 TeamDiscussions: String("td"), 12309 VulnerabilityAlerts: String("va"), 12310 Workflows: String("w"), 12311 }, 12312 CreatedAt: &Timestamp{referenceTime}, 12313 UpdatedAt: &Timestamp{referenceTime}, 12314 HasMultipleSingleFiles: Bool(false), 12315 SuspendedBy: &User{ 12316 Login: String("l"), 12317 ID: Int64(1), 12318 URL: String("u"), 12319 AvatarURL: String("a"), 12320 GravatarID: String("g"), 12321 Name: String("n"), 12322 Company: String("c"), 12323 Blog: String("b"), 12324 Location: String("l"), 12325 Email: String("e"), 12326 Hireable: Bool(true), 12327 Bio: String("b"), 12328 TwitterUsername: String("t"), 12329 PublicRepos: Int(1), 12330 Followers: Int(1), 12331 Following: Int(1), 12332 CreatedAt: &Timestamp{referenceTime}, 12333 SuspendedAt: &Timestamp{referenceTime}, 12334 }, 12335 SuspendedAt: &Timestamp{referenceTime}, 12336 }, 12337 } 12338 12339 want := `{ 12340 "ref": "r", 12341 "ref_type": "rt", 12342 "master_branch": "mb", 12343 "description": "d", 12344 "pusher_type": "pt", 12345 "repository": { 12346 "id": 1, 12347 "name": "n", 12348 "url": "s" 12349 }, 12350 "sender": { 12351 "login": "l", 12352 "id": 1, 12353 "node_id": "n", 12354 "avatar_url": "a", 12355 "url": "u", 12356 "events_url": "e", 12357 "repos_url": "r" 12358 }, 12359 "installation": { 12360 "id": 1, 12361 "node_id": "nid", 12362 "app_id": 1, 12363 "app_slug": "as", 12364 "target_id": 1, 12365 "account": { 12366 "login": "l", 12367 "id": 1, 12368 "avatar_url": "a", 12369 "gravatar_id": "g", 12370 "name": "n", 12371 "company": "c", 12372 "blog": "b", 12373 "location": "l", 12374 "email": "e", 12375 "hireable": true, 12376 "bio": "b", 12377 "twitter_username": "t", 12378 "public_repos": 1, 12379 "followers": 1, 12380 "following": 1, 12381 "created_at": ` + referenceTimeStr + `, 12382 "suspended_at": ` + referenceTimeStr + `, 12383 "url": "u" 12384 }, 12385 "access_tokens_url": "atu", 12386 "repositories_url": "ru", 12387 "html_url": "hu", 12388 "target_type": "tt", 12389 "single_file_name": "sfn", 12390 "repository_selection": "rs", 12391 "events": [ 12392 "e" 12393 ], 12394 "single_file_paths": [ 12395 "s" 12396 ], 12397 "permissions": { 12398 "actions": "a", 12399 "administration": "ad", 12400 "checks": "c", 12401 "contents": "co", 12402 "content_references": "cr", 12403 "deployments": "d", 12404 "environments": "e", 12405 "issues": "i", 12406 "metadata": "md", 12407 "members": "m", 12408 "organization_administration": "oa", 12409 "organization_hooks": "oh", 12410 "organization_plan": "op", 12411 "organization_pre_receive_hooks": "opr", 12412 "organization_projects": "op", 12413 "organization_secrets": "os", 12414 "organization_self_hosted_runners": "osh", 12415 "organization_user_blocking": "oub", 12416 "packages": "pkg", 12417 "pages": "pg", 12418 "pull_requests": "pr", 12419 "repository_hooks": "rh", 12420 "repository_projects": "rp", 12421 "repository_pre_receive_hooks": "rprh", 12422 "secrets": "s", 12423 "secret_scanning_alerts": "ssa", 12424 "security_events": "se", 12425 "single_file": "sf", 12426 "statuses": "s", 12427 "team_discussions": "td", 12428 "vulnerability_alerts": "va", 12429 "workflows": "w" 12430 }, 12431 "created_at": ` + referenceTimeStr + `, 12432 "updated_at": ` + referenceTimeStr + `, 12433 "has_multiple_single_files": false, 12434 "suspended_by": { 12435 "login": "l", 12436 "id": 1, 12437 "avatar_url": "a", 12438 "gravatar_id": "g", 12439 "name": "n", 12440 "company": "c", 12441 "blog": "b", 12442 "location": "l", 12443 "email": "e", 12444 "hireable": true, 12445 "bio": "b", 12446 "twitter_username": "t", 12447 "public_repos": 1, 12448 "followers": 1, 12449 "following": 1, 12450 "created_at": ` + referenceTimeStr + `, 12451 "suspended_at": ` + referenceTimeStr + `, 12452 "url": "u" 12453 }, 12454 "suspended_at": ` + referenceTimeStr + ` 12455 } 12456 }` 12457 12458 testJSONMarshal(t, r, want) 12459 } 12460 12461 func TestDeleteEvent_Marshal(t *testing.T) { 12462 testJSONMarshal(t, &DeleteEvent{}, "{}") 12463 12464 r := &DeleteEvent{ 12465 Ref: String("r"), 12466 RefType: String("rt"), 12467 PusherType: String("pt"), 12468 Repo: &Repository{ 12469 ID: Int64(1), 12470 URL: String("s"), 12471 Name: String("n"), 12472 }, 12473 Sender: &User{ 12474 Login: String("l"), 12475 ID: Int64(1), 12476 NodeID: String("n"), 12477 URL: String("u"), 12478 ReposURL: String("r"), 12479 EventsURL: String("e"), 12480 AvatarURL: String("a"), 12481 }, 12482 Installation: &Installation{ 12483 ID: Int64(1), 12484 NodeID: String("nid"), 12485 AppID: Int64(1), 12486 AppSlug: String("as"), 12487 TargetID: Int64(1), 12488 Account: &User{ 12489 Login: String("l"), 12490 ID: Int64(1), 12491 URL: String("u"), 12492 AvatarURL: String("a"), 12493 GravatarID: String("g"), 12494 Name: String("n"), 12495 Company: String("c"), 12496 Blog: String("b"), 12497 Location: String("l"), 12498 Email: String("e"), 12499 Hireable: Bool(true), 12500 Bio: String("b"), 12501 TwitterUsername: String("t"), 12502 PublicRepos: Int(1), 12503 Followers: Int(1), 12504 Following: Int(1), 12505 CreatedAt: &Timestamp{referenceTime}, 12506 SuspendedAt: &Timestamp{referenceTime}, 12507 }, 12508 AccessTokensURL: String("atu"), 12509 RepositoriesURL: String("ru"), 12510 HTMLURL: String("hu"), 12511 TargetType: String("tt"), 12512 SingleFileName: String("sfn"), 12513 RepositorySelection: String("rs"), 12514 Events: []string{"e"}, 12515 SingleFilePaths: []string{"s"}, 12516 Permissions: &InstallationPermissions{ 12517 Actions: String("a"), 12518 Administration: String("ad"), 12519 Checks: String("c"), 12520 Contents: String("co"), 12521 ContentReferences: String("cr"), 12522 Deployments: String("d"), 12523 Environments: String("e"), 12524 Issues: String("i"), 12525 Metadata: String("md"), 12526 Members: String("m"), 12527 OrganizationAdministration: String("oa"), 12528 OrganizationHooks: String("oh"), 12529 OrganizationPlan: String("op"), 12530 OrganizationPreReceiveHooks: String("opr"), 12531 OrganizationProjects: String("op"), 12532 OrganizationSecrets: String("os"), 12533 OrganizationSelfHostedRunners: String("osh"), 12534 OrganizationUserBlocking: String("oub"), 12535 Packages: String("pkg"), 12536 Pages: String("pg"), 12537 PullRequests: String("pr"), 12538 RepositoryHooks: String("rh"), 12539 RepositoryProjects: String("rp"), 12540 RepositoryPreReceiveHooks: String("rprh"), 12541 Secrets: String("s"), 12542 SecretScanningAlerts: String("ssa"), 12543 SecurityEvents: String("se"), 12544 SingleFile: String("sf"), 12545 Statuses: String("s"), 12546 TeamDiscussions: String("td"), 12547 VulnerabilityAlerts: String("va"), 12548 Workflows: String("w"), 12549 }, 12550 CreatedAt: &Timestamp{referenceTime}, 12551 UpdatedAt: &Timestamp{referenceTime}, 12552 HasMultipleSingleFiles: Bool(false), 12553 SuspendedBy: &User{ 12554 Login: String("l"), 12555 ID: Int64(1), 12556 URL: String("u"), 12557 AvatarURL: String("a"), 12558 GravatarID: String("g"), 12559 Name: String("n"), 12560 Company: String("c"), 12561 Blog: String("b"), 12562 Location: String("l"), 12563 Email: String("e"), 12564 Hireable: Bool(true), 12565 Bio: String("b"), 12566 TwitterUsername: String("t"), 12567 PublicRepos: Int(1), 12568 Followers: Int(1), 12569 Following: Int(1), 12570 CreatedAt: &Timestamp{referenceTime}, 12571 SuspendedAt: &Timestamp{referenceTime}, 12572 }, 12573 SuspendedAt: &Timestamp{referenceTime}, 12574 }, 12575 } 12576 12577 want := `{ 12578 "ref": "r", 12579 "ref_type": "rt", 12580 "pusher_type": "pt", 12581 "repository": { 12582 "id": 1, 12583 "name": "n", 12584 "url": "s" 12585 }, 12586 "sender": { 12587 "login": "l", 12588 "id": 1, 12589 "node_id": "n", 12590 "avatar_url": "a", 12591 "url": "u", 12592 "events_url": "e", 12593 "repos_url": "r" 12594 }, 12595 "installation": { 12596 "id": 1, 12597 "node_id": "nid", 12598 "app_id": 1, 12599 "app_slug": "as", 12600 "target_id": 1, 12601 "account": { 12602 "login": "l", 12603 "id": 1, 12604 "avatar_url": "a", 12605 "gravatar_id": "g", 12606 "name": "n", 12607 "company": "c", 12608 "blog": "b", 12609 "location": "l", 12610 "email": "e", 12611 "hireable": true, 12612 "bio": "b", 12613 "twitter_username": "t", 12614 "public_repos": 1, 12615 "followers": 1, 12616 "following": 1, 12617 "created_at": ` + referenceTimeStr + `, 12618 "suspended_at": ` + referenceTimeStr + `, 12619 "url": "u" 12620 }, 12621 "access_tokens_url": "atu", 12622 "repositories_url": "ru", 12623 "html_url": "hu", 12624 "target_type": "tt", 12625 "single_file_name": "sfn", 12626 "repository_selection": "rs", 12627 "events": [ 12628 "e" 12629 ], 12630 "single_file_paths": [ 12631 "s" 12632 ], 12633 "permissions": { 12634 "actions": "a", 12635 "administration": "ad", 12636 "checks": "c", 12637 "contents": "co", 12638 "content_references": "cr", 12639 "deployments": "d", 12640 "environments": "e", 12641 "issues": "i", 12642 "metadata": "md", 12643 "members": "m", 12644 "organization_administration": "oa", 12645 "organization_hooks": "oh", 12646 "organization_plan": "op", 12647 "organization_pre_receive_hooks": "opr", 12648 "organization_projects": "op", 12649 "organization_secrets": "os", 12650 "organization_self_hosted_runners": "osh", 12651 "organization_user_blocking": "oub", 12652 "packages": "pkg", 12653 "pages": "pg", 12654 "pull_requests": "pr", 12655 "repository_hooks": "rh", 12656 "repository_projects": "rp", 12657 "repository_pre_receive_hooks": "rprh", 12658 "secrets": "s", 12659 "secret_scanning_alerts": "ssa", 12660 "security_events": "se", 12661 "single_file": "sf", 12662 "statuses": "s", 12663 "team_discussions": "td", 12664 "vulnerability_alerts": "va", 12665 "workflows": "w" 12666 }, 12667 "created_at": ` + referenceTimeStr + `, 12668 "updated_at": ` + referenceTimeStr + `, 12669 "has_multiple_single_files": false, 12670 "suspended_by": { 12671 "login": "l", 12672 "id": 1, 12673 "avatar_url": "a", 12674 "gravatar_id": "g", 12675 "name": "n", 12676 "company": "c", 12677 "blog": "b", 12678 "location": "l", 12679 "email": "e", 12680 "hireable": true, 12681 "bio": "b", 12682 "twitter_username": "t", 12683 "public_repos": 1, 12684 "followers": 1, 12685 "following": 1, 12686 "created_at": ` + referenceTimeStr + `, 12687 "suspended_at": ` + referenceTimeStr + `, 12688 "url": "u" 12689 }, 12690 "suspended_at": ` + referenceTimeStr + ` 12691 } 12692 }` 12693 12694 testJSONMarshal(t, r, want) 12695 } 12696 12697 func TestDependabotAlertEvent_Marshal(t *testing.T) { 12698 testJSONMarshal(t, &DependabotAlertEvent{}, "{}") 12699 12700 e := &DependabotAlertEvent{ 12701 Action: String("a"), 12702 Alert: &DependabotAlert{ 12703 Number: Int(1), 12704 State: String("s"), 12705 Dependency: &Dependency{ 12706 Package: &VulnerabilityPackage{ 12707 Ecosystem: String("e"), 12708 Name: String("n"), 12709 }, 12710 ManifestPath: String("mp"), 12711 Scope: String("s"), 12712 }, 12713 SecurityAdvisory: &DependabotSecurityAdvisory{ 12714 GHSAID: String("ghsaid"), 12715 CVEID: String("cveid"), 12716 Summary: String("s"), 12717 Description: String("d"), 12718 Vulnerabilities: []*AdvisoryVulnerability{ 12719 { 12720 Package: &VulnerabilityPackage{ 12721 Ecosystem: String("e"), 12722 Name: String("n"), 12723 }, 12724 Severity: String("s"), 12725 }, 12726 }, 12727 Severity: String("s"), 12728 CVSS: &AdvisoryCVSS{ 12729 Score: Float64(1.0), 12730 VectorString: String("vs"), 12731 }, 12732 CWEs: []*AdvisoryCWEs{ 12733 { 12734 CWEID: String("cweid"), 12735 Name: String("n"), 12736 }, 12737 }, 12738 Identifiers: []*AdvisoryIdentifier{ 12739 { 12740 Value: String("v"), 12741 Type: String("t"), 12742 }, 12743 }, 12744 References: []*AdvisoryReference{ 12745 { 12746 URL: String("u"), 12747 }, 12748 }, 12749 PublishedAt: &Timestamp{referenceTime}, 12750 UpdatedAt: &Timestamp{referenceTime}, 12751 WithdrawnAt: &Timestamp{referenceTime}, 12752 }, 12753 SecurityVulnerability: &AdvisoryVulnerability{ 12754 Package: &VulnerabilityPackage{ 12755 Ecosystem: String("e"), 12756 Name: String("n"), 12757 }, 12758 Severity: String("s"), 12759 VulnerableVersionRange: String("vvr"), 12760 FirstPatchedVersion: &FirstPatchedVersion{ 12761 Identifier: String("i"), 12762 }, 12763 }, 12764 URL: String("u"), 12765 HTMLURL: String("hu"), 12766 CreatedAt: &Timestamp{referenceTime}, 12767 UpdatedAt: &Timestamp{referenceTime}, 12768 DismissedAt: &Timestamp{referenceTime}, 12769 DismissedBy: &User{ 12770 Login: String("l"), 12771 ID: Int64(1), 12772 NodeID: String("n"), 12773 URL: String("u"), 12774 ReposURL: String("r"), 12775 EventsURL: String("e"), 12776 AvatarURL: String("a"), 12777 }, 12778 DismissedReason: String("dr"), 12779 DismissedComment: String("dc"), 12780 FixedAt: &Timestamp{referenceTime}, 12781 AutoDismissedAt: &Timestamp{referenceTime}, 12782 }, 12783 Repo: &Repository{ 12784 ID: Int64(1), 12785 URL: String("s"), 12786 Name: String("n"), 12787 }, 12788 Organization: &Organization{ 12789 BillingEmail: String("be"), 12790 Blog: String("b"), 12791 Company: String("c"), 12792 Email: String("e"), 12793 TwitterUsername: String("tu"), 12794 Location: String("loc"), 12795 Name: String("n"), 12796 Description: String("d"), 12797 IsVerified: Bool(true), 12798 HasOrganizationProjects: Bool(true), 12799 HasRepositoryProjects: Bool(true), 12800 DefaultRepoPermission: String("drp"), 12801 MembersCanCreateRepos: Bool(true), 12802 MembersCanCreateInternalRepos: Bool(true), 12803 MembersCanCreatePrivateRepos: Bool(true), 12804 MembersCanCreatePublicRepos: Bool(false), 12805 MembersAllowedRepositoryCreationType: String("marct"), 12806 MembersCanCreatePages: Bool(true), 12807 MembersCanCreatePublicPages: Bool(false), 12808 MembersCanCreatePrivatePages: Bool(true), 12809 }, 12810 Enterprise: &Enterprise{ 12811 ID: Int(1), 12812 Slug: String("s"), 12813 Name: String("n"), 12814 NodeID: String("nid"), 12815 AvatarURL: String("au"), 12816 Description: String("d"), 12817 WebsiteURL: String("wu"), 12818 HTMLURL: String("hu"), 12819 CreatedAt: &Timestamp{referenceTime}, 12820 UpdatedAt: &Timestamp{referenceTime}, 12821 }, 12822 Sender: &User{ 12823 Login: String("l"), 12824 ID: Int64(1), 12825 NodeID: String("n"), 12826 URL: String("u"), 12827 ReposURL: String("r"), 12828 EventsURL: String("e"), 12829 AvatarURL: String("a"), 12830 }, 12831 Installation: &Installation{ 12832 ID: Int64(1), 12833 NodeID: String("nid"), 12834 AppID: Int64(1), 12835 AppSlug: String("as"), 12836 TargetID: Int64(1), 12837 Account: &User{ 12838 Login: String("l"), 12839 ID: Int64(1), 12840 URL: String("u"), 12841 AvatarURL: String("a"), 12842 GravatarID: String("g"), 12843 Name: String("n"), 12844 Company: String("c"), 12845 Blog: String("b"), 12846 Location: String("l"), 12847 Email: String("e"), 12848 Hireable: Bool(true), 12849 Bio: String("b"), 12850 TwitterUsername: String("t"), 12851 PublicRepos: Int(1), 12852 Followers: Int(1), 12853 Following: Int(1), 12854 CreatedAt: &Timestamp{referenceTime}, 12855 SuspendedAt: &Timestamp{referenceTime}, 12856 }, 12857 AccessTokensURL: String("atu"), 12858 RepositoriesURL: String("ru"), 12859 HTMLURL: String("hu"), 12860 TargetType: String("tt"), 12861 SingleFileName: String("sfn"), 12862 RepositorySelection: String("rs"), 12863 Events: []string{"e"}, 12864 SingleFilePaths: []string{"s"}, 12865 Permissions: &InstallationPermissions{ 12866 Actions: String("a"), 12867 Administration: String("ad"), 12868 Checks: String("c"), 12869 Contents: String("co"), 12870 ContentReferences: String("cr"), 12871 Deployments: String("d"), 12872 Environments: String("e"), 12873 Issues: String("i"), 12874 Metadata: String("md"), 12875 Members: String("m"), 12876 OrganizationAdministration: String("oa"), 12877 OrganizationHooks: String("oh"), 12878 OrganizationPlan: String("op"), 12879 OrganizationPreReceiveHooks: String("opr"), 12880 OrganizationProjects: String("op"), 12881 OrganizationSecrets: String("os"), 12882 OrganizationSelfHostedRunners: String("osh"), 12883 OrganizationUserBlocking: String("oub"), 12884 Packages: String("pkg"), 12885 Pages: String("pg"), 12886 PullRequests: String("pr"), 12887 RepositoryHooks: String("rh"), 12888 RepositoryProjects: String("rp"), 12889 RepositoryPreReceiveHooks: String("rprh"), 12890 Secrets: String("s"), 12891 SecretScanningAlerts: String("ssa"), 12892 SecurityEvents: String("se"), 12893 SingleFile: String("sf"), 12894 Statuses: String("s"), 12895 TeamDiscussions: String("td"), 12896 VulnerabilityAlerts: String("va"), 12897 Workflows: String("w"), 12898 }, 12899 CreatedAt: &Timestamp{referenceTime}, 12900 UpdatedAt: &Timestamp{referenceTime}, 12901 HasMultipleSingleFiles: Bool(false), 12902 SuspendedBy: &User{ 12903 Login: String("l"), 12904 ID: Int64(1), 12905 URL: String("u"), 12906 AvatarURL: String("a"), 12907 GravatarID: String("g"), 12908 Name: String("n"), 12909 Company: String("c"), 12910 Blog: String("b"), 12911 Location: String("l"), 12912 Email: String("e"), 12913 Hireable: Bool(true), 12914 Bio: String("b"), 12915 TwitterUsername: String("t"), 12916 PublicRepos: Int(1), 12917 Followers: Int(1), 12918 Following: Int(1), 12919 CreatedAt: &Timestamp{referenceTime}, 12920 SuspendedAt: &Timestamp{referenceTime}, 12921 }, 12922 SuspendedAt: &Timestamp{referenceTime}, 12923 }, 12924 } 12925 want := `{ 12926 "action": "a", 12927 "alert": { 12928 "number": 1, 12929 "state": "s", 12930 "dependency": { 12931 "package": { 12932 "ecosystem": "e", 12933 "name": "n" 12934 }, 12935 "manifest_path": "mp", 12936 "scope": "s" 12937 }, 12938 "security_advisory": { 12939 "ghsa_id": "ghsaid", 12940 "cve_id": "cveid", 12941 "summary": "s", 12942 "description": "d", 12943 "vulnerabilities": [ 12944 { 12945 "package": { 12946 "ecosystem": "e", 12947 "name": "n" 12948 }, 12949 "severity": "s" 12950 } 12951 ], 12952 "severity": "s", 12953 "cvss": { 12954 "score": 1.0, 12955 "vector_string": "vs" 12956 }, 12957 "cwes": [ 12958 { 12959 "cwe_id": "cweid", 12960 "name": "n" 12961 } 12962 ], 12963 "identifiers": [ 12964 { 12965 "value": "v", 12966 "type": "t" 12967 } 12968 ], 12969 "references": [ 12970 { 12971 "url": "u" 12972 } 12973 ], 12974 "published_at": ` + referenceTimeStr + `, 12975 "updated_at": ` + referenceTimeStr + `, 12976 "withdrawn_at": ` + referenceTimeStr + ` 12977 }, 12978 "security_vulnerability": { 12979 "package": { 12980 "ecosystem": "e", 12981 "name": "n" 12982 }, 12983 "severity": "s", 12984 "vulnerable_version_range": "vvr", 12985 "first_patched_version": { 12986 "identifier": "i" 12987 } 12988 }, 12989 "url": "u", 12990 "html_url": "hu", 12991 "created_at": ` + referenceTimeStr + `, 12992 "updated_at": ` + referenceTimeStr + `, 12993 "dismissed_at": ` + referenceTimeStr + `, 12994 "dismissed_by": { 12995 "login": "l", 12996 "id": 1, 12997 "node_id": "n", 12998 "avatar_url": "a", 12999 "url": "u", 13000 "events_url": "e", 13001 "repos_url": "r" 13002 }, 13003 "dismissed_reason": "dr", 13004 "dismissed_comment": "dc", 13005 "fixed_at": ` + referenceTimeStr + `, 13006 "auto_dismissed_at": ` + referenceTimeStr + ` 13007 }, 13008 "repository": { 13009 "id": 1, 13010 "name": "n", 13011 "url": "s" 13012 }, 13013 "organization": { 13014 "name": "n", 13015 "company": "c", 13016 "blog": "b", 13017 "location": "loc", 13018 "email": "e", 13019 "twitter_username": "tu", 13020 "description": "d", 13021 "billing_email": "be", 13022 "is_verified": true, 13023 "has_organization_projects": true, 13024 "has_repository_projects": true, 13025 "default_repository_permission": "drp", 13026 "members_can_create_repositories": true, 13027 "members_can_create_public_repositories": false, 13028 "members_can_create_private_repositories": true, 13029 "members_can_create_internal_repositories": true, 13030 "members_allowed_repository_creation_type": "marct", 13031 "members_can_create_pages": true, 13032 "members_can_create_public_pages": false, 13033 "members_can_create_private_pages": true 13034 }, 13035 "enterprise": { 13036 "id": 1, 13037 "slug": "s", 13038 "name": "n", 13039 "node_id": "nid", 13040 "avatar_url": "au", 13041 "description": "d", 13042 "website_url": "wu", 13043 "html_url": "hu", 13044 "created_at": ` + referenceTimeStr + `, 13045 "updated_at": ` + referenceTimeStr + ` 13046 }, 13047 "sender": { 13048 "login": "l", 13049 "id": 1, 13050 "node_id": "n", 13051 "avatar_url": "a", 13052 "url": "u", 13053 "events_url": "e", 13054 "repos_url": "r" 13055 }, 13056 "installation": { 13057 "id": 1, 13058 "node_id": "nid", 13059 "app_id": 1, 13060 "app_slug": "as", 13061 "target_id": 1, 13062 "account": { 13063 "login": "l", 13064 "id": 1, 13065 "avatar_url": "a", 13066 "gravatar_id": "g", 13067 "name": "n", 13068 "company": "c", 13069 "blog": "b", 13070 "location": "l", 13071 "email": "e", 13072 "hireable": true, 13073 "bio": "b", 13074 "twitter_username": "t", 13075 "public_repos": 1, 13076 "followers": 1, 13077 "following": 1, 13078 "created_at": ` + referenceTimeStr + `, 13079 "suspended_at": ` + referenceTimeStr + `, 13080 "url": "u" 13081 }, 13082 "access_tokens_url": "atu", 13083 "repositories_url": "ru", 13084 "html_url": "hu", 13085 "target_type": "tt", 13086 "single_file_name": "sfn", 13087 "repository_selection": "rs", 13088 "events": [ 13089 "e" 13090 ], 13091 "single_file_paths": [ 13092 "s" 13093 ], 13094 "permissions": { 13095 "actions": "a", 13096 "administration": "ad", 13097 "checks": "c", 13098 "contents": "co", 13099 "content_references": "cr", 13100 "deployments": "d", 13101 "environments": "e", 13102 "issues": "i", 13103 "metadata": "md", 13104 "members": "m", 13105 "organization_administration": "oa", 13106 "organization_hooks": "oh", 13107 "organization_plan": "op", 13108 "organization_pre_receive_hooks": "opr", 13109 "organization_projects": "op", 13110 "organization_secrets": "os", 13111 "organization_self_hosted_runners": "osh", 13112 "organization_user_blocking": "oub", 13113 "packages": "pkg", 13114 "pages": "pg", 13115 "pull_requests": "pr", 13116 "repository_hooks": "rh", 13117 "repository_projects": "rp", 13118 "repository_pre_receive_hooks": "rprh", 13119 "secrets": "s", 13120 "secret_scanning_alerts": "ssa", 13121 "security_events": "se", 13122 "single_file": "sf", 13123 "statuses": "s", 13124 "team_discussions": "td", 13125 "vulnerability_alerts": "va", 13126 "workflows": "w" 13127 }, 13128 "created_at": ` + referenceTimeStr + `, 13129 "updated_at": ` + referenceTimeStr + `, 13130 "has_multiple_single_files": false, 13131 "suspended_by": { 13132 "login": "l", 13133 "id": 1, 13134 "avatar_url": "a", 13135 "gravatar_id": "g", 13136 "name": "n", 13137 "company": "c", 13138 "blog": "b", 13139 "location": "l", 13140 "email": "e", 13141 "hireable": true, 13142 "bio": "b", 13143 "twitter_username": "t", 13144 "public_repos": 1, 13145 "followers": 1, 13146 "following": 1, 13147 "created_at": ` + referenceTimeStr + `, 13148 "suspended_at": ` + referenceTimeStr + `, 13149 "url": "u" 13150 }, 13151 "suspended_at": ` + referenceTimeStr + ` 13152 } 13153 }` 13154 13155 testJSONMarshal(t, e, want) 13156 } 13157 13158 func TestForkEvent_Marshal(t *testing.T) { 13159 testJSONMarshal(t, &ForkEvent{}, "{}") 13160 13161 u := &ForkEvent{ 13162 Forkee: &Repository{ 13163 ID: Int64(1), 13164 URL: String("s"), 13165 Name: String("n"), 13166 }, 13167 Repo: &Repository{ 13168 ID: Int64(1), 13169 URL: String("s"), 13170 Name: String("n"), 13171 }, 13172 Sender: &User{ 13173 Login: String("l"), 13174 ID: Int64(1), 13175 NodeID: String("n"), 13176 URL: String("u"), 13177 ReposURL: String("r"), 13178 EventsURL: String("e"), 13179 AvatarURL: String("a"), 13180 }, 13181 Installation: &Installation{ 13182 ID: Int64(1), 13183 NodeID: String("nid"), 13184 AppID: Int64(1), 13185 AppSlug: String("as"), 13186 TargetID: Int64(1), 13187 Account: &User{ 13188 Login: String("l"), 13189 ID: Int64(1), 13190 URL: String("u"), 13191 AvatarURL: String("a"), 13192 GravatarID: String("g"), 13193 Name: String("n"), 13194 Company: String("c"), 13195 Blog: String("b"), 13196 Location: String("l"), 13197 Email: String("e"), 13198 Hireable: Bool(true), 13199 Bio: String("b"), 13200 TwitterUsername: String("t"), 13201 PublicRepos: Int(1), 13202 Followers: Int(1), 13203 Following: Int(1), 13204 CreatedAt: &Timestamp{referenceTime}, 13205 SuspendedAt: &Timestamp{referenceTime}, 13206 }, 13207 AccessTokensURL: String("atu"), 13208 RepositoriesURL: String("ru"), 13209 HTMLURL: String("hu"), 13210 TargetType: String("tt"), 13211 SingleFileName: String("sfn"), 13212 RepositorySelection: String("rs"), 13213 Events: []string{"e"}, 13214 SingleFilePaths: []string{"s"}, 13215 Permissions: &InstallationPermissions{ 13216 Actions: String("a"), 13217 Administration: String("ad"), 13218 Checks: String("c"), 13219 Contents: String("co"), 13220 ContentReferences: String("cr"), 13221 Deployments: String("d"), 13222 Environments: String("e"), 13223 Issues: String("i"), 13224 Metadata: String("md"), 13225 Members: String("m"), 13226 OrganizationAdministration: String("oa"), 13227 OrganizationHooks: String("oh"), 13228 OrganizationPlan: String("op"), 13229 OrganizationPreReceiveHooks: String("opr"), 13230 OrganizationProjects: String("op"), 13231 OrganizationSecrets: String("os"), 13232 OrganizationSelfHostedRunners: String("osh"), 13233 OrganizationUserBlocking: String("oub"), 13234 Packages: String("pkg"), 13235 Pages: String("pg"), 13236 PullRequests: String("pr"), 13237 RepositoryHooks: String("rh"), 13238 RepositoryProjects: String("rp"), 13239 RepositoryPreReceiveHooks: String("rprh"), 13240 Secrets: String("s"), 13241 SecretScanningAlerts: String("ssa"), 13242 SecurityEvents: String("se"), 13243 SingleFile: String("sf"), 13244 Statuses: String("s"), 13245 TeamDiscussions: String("td"), 13246 VulnerabilityAlerts: String("va"), 13247 Workflows: String("w"), 13248 }, 13249 CreatedAt: &Timestamp{referenceTime}, 13250 UpdatedAt: &Timestamp{referenceTime}, 13251 HasMultipleSingleFiles: Bool(false), 13252 SuspendedBy: &User{ 13253 Login: String("l"), 13254 ID: Int64(1), 13255 URL: String("u"), 13256 AvatarURL: String("a"), 13257 GravatarID: String("g"), 13258 Name: String("n"), 13259 Company: String("c"), 13260 Blog: String("b"), 13261 Location: String("l"), 13262 Email: String("e"), 13263 Hireable: Bool(true), 13264 Bio: String("b"), 13265 TwitterUsername: String("t"), 13266 PublicRepos: Int(1), 13267 Followers: Int(1), 13268 Following: Int(1), 13269 CreatedAt: &Timestamp{referenceTime}, 13270 SuspendedAt: &Timestamp{referenceTime}, 13271 }, 13272 SuspendedAt: &Timestamp{referenceTime}, 13273 }, 13274 } 13275 13276 want := `{ 13277 "forkee": { 13278 "id": 1, 13279 "name": "n", 13280 "url": "s" 13281 }, 13282 "repository": { 13283 "id": 1, 13284 "name": "n", 13285 "url": "s" 13286 }, 13287 "sender": { 13288 "login": "l", 13289 "id": 1, 13290 "node_id": "n", 13291 "avatar_url": "a", 13292 "url": "u", 13293 "events_url": "e", 13294 "repos_url": "r" 13295 }, 13296 "installation": { 13297 "id": 1, 13298 "node_id": "nid", 13299 "app_id": 1, 13300 "app_slug": "as", 13301 "target_id": 1, 13302 "account": { 13303 "login": "l", 13304 "id": 1, 13305 "avatar_url": "a", 13306 "gravatar_id": "g", 13307 "name": "n", 13308 "company": "c", 13309 "blog": "b", 13310 "location": "l", 13311 "email": "e", 13312 "hireable": true, 13313 "bio": "b", 13314 "twitter_username": "t", 13315 "public_repos": 1, 13316 "followers": 1, 13317 "following": 1, 13318 "created_at": ` + referenceTimeStr + `, 13319 "suspended_at": ` + referenceTimeStr + `, 13320 "url": "u" 13321 }, 13322 "access_tokens_url": "atu", 13323 "repositories_url": "ru", 13324 "html_url": "hu", 13325 "target_type": "tt", 13326 "single_file_name": "sfn", 13327 "repository_selection": "rs", 13328 "events": [ 13329 "e" 13330 ], 13331 "single_file_paths": [ 13332 "s" 13333 ], 13334 "permissions": { 13335 "actions": "a", 13336 "administration": "ad", 13337 "checks": "c", 13338 "contents": "co", 13339 "content_references": "cr", 13340 "deployments": "d", 13341 "environments": "e", 13342 "issues": "i", 13343 "metadata": "md", 13344 "members": "m", 13345 "organization_administration": "oa", 13346 "organization_hooks": "oh", 13347 "organization_plan": "op", 13348 "organization_pre_receive_hooks": "opr", 13349 "organization_projects": "op", 13350 "organization_secrets": "os", 13351 "organization_self_hosted_runners": "osh", 13352 "organization_user_blocking": "oub", 13353 "packages": "pkg", 13354 "pages": "pg", 13355 "pull_requests": "pr", 13356 "repository_hooks": "rh", 13357 "repository_projects": "rp", 13358 "repository_pre_receive_hooks": "rprh", 13359 "secrets": "s", 13360 "secret_scanning_alerts": "ssa", 13361 "security_events": "se", 13362 "single_file": "sf", 13363 "statuses": "s", 13364 "team_discussions": "td", 13365 "vulnerability_alerts": "va", 13366 "workflows": "w" 13367 }, 13368 "created_at": ` + referenceTimeStr + `, 13369 "updated_at": ` + referenceTimeStr + `, 13370 "has_multiple_single_files": false, 13371 "suspended_by": { 13372 "login": "l", 13373 "id": 1, 13374 "avatar_url": "a", 13375 "gravatar_id": "g", 13376 "name": "n", 13377 "company": "c", 13378 "blog": "b", 13379 "location": "l", 13380 "email": "e", 13381 "hireable": true, 13382 "bio": "b", 13383 "twitter_username": "t", 13384 "public_repos": 1, 13385 "followers": 1, 13386 "following": 1, 13387 "created_at": ` + referenceTimeStr + `, 13388 "suspended_at": ` + referenceTimeStr + `, 13389 "url": "u" 13390 }, 13391 "suspended_at": ` + referenceTimeStr + ` 13392 } 13393 }` 13394 13395 testJSONMarshal(t, u, want) 13396 } 13397 13398 func TestGitHubAppAuthorizationEvent_Marshal(t *testing.T) { 13399 testJSONMarshal(t, &GitHubAppAuthorizationEvent{}, "{}") 13400 13401 u := &GitHubAppAuthorizationEvent{ 13402 Action: String("a"), 13403 Sender: &User{ 13404 Login: String("l"), 13405 ID: Int64(1), 13406 NodeID: String("n"), 13407 URL: String("u"), 13408 ReposURL: String("r"), 13409 EventsURL: String("e"), 13410 AvatarURL: String("a"), 13411 }, 13412 } 13413 13414 want := `{ 13415 "action": "a", 13416 "sender": { 13417 "login": "l", 13418 "id": 1, 13419 "node_id": "n", 13420 "avatar_url": "a", 13421 "url": "u", 13422 "events_url": "e", 13423 "repos_url": "r" 13424 } 13425 }` 13426 13427 testJSONMarshal(t, u, want) 13428 } 13429 13430 func TestInstallationEvent_Marshal(t *testing.T) { 13431 testJSONMarshal(t, &InstallationEvent{}, "{}") 13432 13433 u := &InstallationEvent{ 13434 Action: String("a"), 13435 Repositories: []*Repository{ 13436 { 13437 ID: Int64(1), 13438 URL: String("u"), 13439 Name: String("n"), 13440 }, 13441 }, 13442 Sender: &User{ 13443 Login: String("l"), 13444 ID: Int64(1), 13445 NodeID: String("n"), 13446 URL: String("u"), 13447 ReposURL: String("r"), 13448 EventsURL: String("e"), 13449 AvatarURL: String("a"), 13450 }, 13451 Installation: &Installation{ 13452 ID: Int64(1), 13453 NodeID: String("nid"), 13454 AppID: Int64(1), 13455 AppSlug: String("as"), 13456 TargetID: Int64(1), 13457 Account: &User{ 13458 Login: String("l"), 13459 ID: Int64(1), 13460 URL: String("u"), 13461 AvatarURL: String("a"), 13462 GravatarID: String("g"), 13463 Name: String("n"), 13464 Company: String("c"), 13465 Blog: String("b"), 13466 Location: String("l"), 13467 Email: String("e"), 13468 Hireable: Bool(true), 13469 Bio: String("b"), 13470 TwitterUsername: String("t"), 13471 PublicRepos: Int(1), 13472 Followers: Int(1), 13473 Following: Int(1), 13474 CreatedAt: &Timestamp{referenceTime}, 13475 SuspendedAt: &Timestamp{referenceTime}, 13476 }, 13477 AccessTokensURL: String("atu"), 13478 RepositoriesURL: String("ru"), 13479 HTMLURL: String("hu"), 13480 TargetType: String("tt"), 13481 SingleFileName: String("sfn"), 13482 RepositorySelection: String("rs"), 13483 Events: []string{"e"}, 13484 SingleFilePaths: []string{"s"}, 13485 Permissions: &InstallationPermissions{ 13486 Actions: String("a"), 13487 Administration: String("ad"), 13488 Checks: String("c"), 13489 Contents: String("co"), 13490 ContentReferences: String("cr"), 13491 Deployments: String("d"), 13492 Environments: String("e"), 13493 Issues: String("i"), 13494 Metadata: String("md"), 13495 Members: String("m"), 13496 OrganizationAdministration: String("oa"), 13497 OrganizationHooks: String("oh"), 13498 OrganizationPlan: String("op"), 13499 OrganizationPreReceiveHooks: String("opr"), 13500 OrganizationProjects: String("op"), 13501 OrganizationSecrets: String("os"), 13502 OrganizationSelfHostedRunners: String("osh"), 13503 OrganizationUserBlocking: String("oub"), 13504 Packages: String("pkg"), 13505 Pages: String("pg"), 13506 PullRequests: String("pr"), 13507 RepositoryHooks: String("rh"), 13508 RepositoryProjects: String("rp"), 13509 RepositoryPreReceiveHooks: String("rprh"), 13510 Secrets: String("s"), 13511 SecretScanningAlerts: String("ssa"), 13512 SecurityEvents: String("se"), 13513 SingleFile: String("sf"), 13514 Statuses: String("s"), 13515 TeamDiscussions: String("td"), 13516 VulnerabilityAlerts: String("va"), 13517 Workflows: String("w"), 13518 }, 13519 CreatedAt: &Timestamp{referenceTime}, 13520 UpdatedAt: &Timestamp{referenceTime}, 13521 HasMultipleSingleFiles: Bool(false), 13522 SuspendedBy: &User{ 13523 Login: String("l"), 13524 ID: Int64(1), 13525 URL: String("u"), 13526 AvatarURL: String("a"), 13527 GravatarID: String("g"), 13528 Name: String("n"), 13529 Company: String("c"), 13530 Blog: String("b"), 13531 Location: String("l"), 13532 Email: String("e"), 13533 Hireable: Bool(true), 13534 Bio: String("b"), 13535 TwitterUsername: String("t"), 13536 PublicRepos: Int(1), 13537 Followers: Int(1), 13538 Following: Int(1), 13539 CreatedAt: &Timestamp{referenceTime}, 13540 SuspendedAt: &Timestamp{referenceTime}, 13541 }, 13542 SuspendedAt: &Timestamp{referenceTime}, 13543 }, 13544 } 13545 13546 want := `{ 13547 "action": "a", 13548 "repositories": [ 13549 { 13550 "id":1, 13551 "name":"n", 13552 "url":"u" 13553 } 13554 ], 13555 "sender": { 13556 "login": "l", 13557 "id": 1, 13558 "node_id": "n", 13559 "avatar_url": "a", 13560 "url": "u", 13561 "events_url": "e", 13562 "repos_url": "r" 13563 }, 13564 "installation": { 13565 "id": 1, 13566 "node_id": "nid", 13567 "app_id": 1, 13568 "app_slug": "as", 13569 "target_id": 1, 13570 "account": { 13571 "login": "l", 13572 "id": 1, 13573 "avatar_url": "a", 13574 "gravatar_id": "g", 13575 "name": "n", 13576 "company": "c", 13577 "blog": "b", 13578 "location": "l", 13579 "email": "e", 13580 "hireable": true, 13581 "bio": "b", 13582 "twitter_username": "t", 13583 "public_repos": 1, 13584 "followers": 1, 13585 "following": 1, 13586 "created_at": ` + referenceTimeStr + `, 13587 "suspended_at": ` + referenceTimeStr + `, 13588 "url": "u" 13589 }, 13590 "access_tokens_url": "atu", 13591 "repositories_url": "ru", 13592 "html_url": "hu", 13593 "target_type": "tt", 13594 "single_file_name": "sfn", 13595 "repository_selection": "rs", 13596 "events": [ 13597 "e" 13598 ], 13599 "single_file_paths": [ 13600 "s" 13601 ], 13602 "permissions": { 13603 "actions": "a", 13604 "administration": "ad", 13605 "checks": "c", 13606 "contents": "co", 13607 "content_references": "cr", 13608 "deployments": "d", 13609 "environments": "e", 13610 "issues": "i", 13611 "metadata": "md", 13612 "members": "m", 13613 "organization_administration": "oa", 13614 "organization_hooks": "oh", 13615 "organization_plan": "op", 13616 "organization_pre_receive_hooks": "opr", 13617 "organization_projects": "op", 13618 "organization_secrets": "os", 13619 "organization_self_hosted_runners": "osh", 13620 "organization_user_blocking": "oub", 13621 "packages": "pkg", 13622 "pages": "pg", 13623 "pull_requests": "pr", 13624 "repository_hooks": "rh", 13625 "repository_projects": "rp", 13626 "repository_pre_receive_hooks": "rprh", 13627 "secrets": "s", 13628 "secret_scanning_alerts": "ssa", 13629 "security_events": "se", 13630 "single_file": "sf", 13631 "statuses": "s", 13632 "team_discussions": "td", 13633 "vulnerability_alerts": "va", 13634 "workflows": "w" 13635 }, 13636 "created_at": ` + referenceTimeStr + `, 13637 "updated_at": ` + referenceTimeStr + `, 13638 "has_multiple_single_files": false, 13639 "suspended_by": { 13640 "login": "l", 13641 "id": 1, 13642 "avatar_url": "a", 13643 "gravatar_id": "g", 13644 "name": "n", 13645 "company": "c", 13646 "blog": "b", 13647 "location": "l", 13648 "email": "e", 13649 "hireable": true, 13650 "bio": "b", 13651 "twitter_username": "t", 13652 "public_repos": 1, 13653 "followers": 1, 13654 "following": 1, 13655 "created_at": ` + referenceTimeStr + `, 13656 "suspended_at": ` + referenceTimeStr + `, 13657 "url": "u" 13658 }, 13659 "suspended_at": ` + referenceTimeStr + ` 13660 } 13661 }` 13662 13663 testJSONMarshal(t, u, want) 13664 } 13665 13666 func TestHeadCommit_Marshal(t *testing.T) { 13667 testJSONMarshal(t, &HeadCommit{}, "{}") 13668 13669 u := &HeadCommit{ 13670 Message: String("m"), 13671 Author: &CommitAuthor{ 13672 Date: &Timestamp{referenceTime}, 13673 Name: String("n"), 13674 Email: String("e"), 13675 Login: String("u"), 13676 }, 13677 URL: String("u"), 13678 Distinct: Bool(true), 13679 SHA: String("s"), 13680 ID: String("id"), 13681 TreeID: String("tid"), 13682 Timestamp: &Timestamp{referenceTime}, 13683 Committer: &CommitAuthor{ 13684 Date: &Timestamp{referenceTime}, 13685 Name: String("n"), 13686 Email: String("e"), 13687 Login: String("u"), 13688 }, 13689 Added: []string{"a"}, 13690 Removed: []string{"r"}, 13691 Modified: []string{"m"}, 13692 } 13693 13694 want := `{ 13695 "message": "m", 13696 "author": { 13697 "date": ` + referenceTimeStr + `, 13698 "name": "n", 13699 "email": "e", 13700 "username": "u" 13701 }, 13702 "url": "u", 13703 "distinct": true, 13704 "sha": "s", 13705 "id": "id", 13706 "tree_id": "tid", 13707 "timestamp": ` + referenceTimeStr + `, 13708 "committer": { 13709 "date": ` + referenceTimeStr + `, 13710 "name": "n", 13711 "email": "e", 13712 "username": "u" 13713 }, 13714 "added": [ 13715 "a" 13716 ], 13717 "removed": [ 13718 "r" 13719 ], 13720 "modified": [ 13721 "m" 13722 ] 13723 }` 13724 13725 testJSONMarshal(t, u, want) 13726 } 13727 13728 func TestPushEventRepository_Marshal(t *testing.T) { 13729 testJSONMarshal(t, &PushEventRepository{}, "{}") 13730 13731 u := &PushEventRepository{ 13732 ID: Int64(1), 13733 NodeID: String("nid"), 13734 Name: String("n"), 13735 FullName: String("fn"), 13736 Owner: &User{ 13737 Login: String("l"), 13738 ID: Int64(1), 13739 AvatarURL: String("a"), 13740 GravatarID: String("g"), 13741 Name: String("n"), 13742 Company: String("c"), 13743 Blog: String("b"), 13744 Location: String("l"), 13745 Email: String("e"), 13746 Hireable: Bool(true), 13747 PublicRepos: Int(1), 13748 Followers: Int(1), 13749 Following: Int(1), 13750 CreatedAt: &Timestamp{referenceTime}, 13751 URL: String("u"), 13752 }, 13753 Private: Bool(true), 13754 Description: String("d"), 13755 Fork: Bool(true), 13756 CreatedAt: &Timestamp{referenceTime}, 13757 PushedAt: &Timestamp{referenceTime}, 13758 UpdatedAt: &Timestamp{referenceTime}, 13759 Homepage: String("h"), 13760 PullsURL: String("p"), 13761 Size: Int(1), 13762 StargazersCount: Int(1), 13763 WatchersCount: Int(1), 13764 Language: String("l"), 13765 HasIssues: Bool(true), 13766 HasDownloads: Bool(true), 13767 HasWiki: Bool(true), 13768 HasPages: Bool(true), 13769 ForksCount: Int(1), 13770 Archived: Bool(true), 13771 Disabled: Bool(true), 13772 OpenIssuesCount: Int(1), 13773 DefaultBranch: String("d"), 13774 MasterBranch: String("m"), 13775 Organization: String("o"), 13776 URL: String("u"), 13777 ArchiveURL: String("a"), 13778 HTMLURL: String("h"), 13779 StatusesURL: String("s"), 13780 GitURL: String("g"), 13781 SSHURL: String("s"), 13782 CloneURL: String("c"), 13783 SVNURL: String("s"), 13784 Topics: []string{"octocat", "api"}, 13785 } 13786 13787 want := `{ 13788 "id": 1, 13789 "node_id": "nid", 13790 "name": "n", 13791 "full_name": "fn", 13792 "owner": { 13793 "login": "l", 13794 "id": 1, 13795 "avatar_url": "a", 13796 "gravatar_id": "g", 13797 "name": "n", 13798 "company": "c", 13799 "blog": "b", 13800 "location": "l", 13801 "email": "e", 13802 "hireable": true, 13803 "public_repos": 1, 13804 "followers": 1, 13805 "following": 1, 13806 "created_at": ` + referenceTimeStr + `, 13807 "url": "u" 13808 }, 13809 "private": true, 13810 "description": "d", 13811 "fork": true, 13812 "created_at": ` + referenceTimeStr + `, 13813 "pushed_at": ` + referenceTimeStr + `, 13814 "updated_at": ` + referenceTimeStr + `, 13815 "homepage": "h", 13816 "pulls_url": "p", 13817 "size": 1, 13818 "stargazers_count": 1, 13819 "watchers_count": 1, 13820 "language": "l", 13821 "has_issues": true, 13822 "has_downloads": true, 13823 "has_wiki": true, 13824 "has_pages": true, 13825 "forks_count": 1, 13826 "archived": true, 13827 "disabled": true, 13828 "open_issues_count": 1, 13829 "default_branch": "d", 13830 "master_branch": "m", 13831 "organization": "o", 13832 "url": "u", 13833 "archive_url": "a", 13834 "html_url": "h", 13835 "statuses_url": "s", 13836 "git_url": "g", 13837 "ssh_url": "s", 13838 "clone_url": "c", 13839 "svn_url": "s", 13840 "topics": ["octocat","api"] 13841 }` 13842 13843 testJSONMarshal(t, u, want) 13844 } 13845 13846 func TestPushEventRepoOwner_Marshal(t *testing.T) { 13847 testJSONMarshal(t, &PushEventRepoOwner{}, "{}") 13848 13849 u := &PushEventRepoOwner{ 13850 Name: String("n"), 13851 Email: String("e"), 13852 } 13853 13854 want := `{ 13855 "name": "n", 13856 "email": "e" 13857 }` 13858 13859 testJSONMarshal(t, u, want) 13860 } 13861 13862 func TestProjectEvent_Marshal(t *testing.T) { 13863 testJSONMarshal(t, &ProjectEvent{}, "{}") 13864 13865 u := &ProjectEvent{ 13866 Project: &Project{ID: Int64(1)}, 13867 Action: String("a"), 13868 Changes: &ProjectChange{ 13869 Name: &ProjectName{From: String("NameFrom")}, 13870 Body: &ProjectBody{From: String("BodyFrom")}, 13871 }, 13872 Repo: &Repository{ 13873 ID: Int64(1), 13874 URL: String("s"), 13875 Name: String("n"), 13876 }, 13877 Org: &Organization{ 13878 BillingEmail: String("be"), 13879 Blog: String("b"), 13880 Company: String("c"), 13881 Email: String("e"), 13882 TwitterUsername: String("tu"), 13883 Location: String("loc"), 13884 Name: String("n"), 13885 Description: String("d"), 13886 IsVerified: Bool(true), 13887 HasOrganizationProjects: Bool(true), 13888 HasRepositoryProjects: Bool(true), 13889 DefaultRepoPermission: String("drp"), 13890 MembersCanCreateRepos: Bool(true), 13891 MembersCanCreateInternalRepos: Bool(true), 13892 MembersCanCreatePrivateRepos: Bool(true), 13893 MembersCanCreatePublicRepos: Bool(false), 13894 MembersAllowedRepositoryCreationType: String("marct"), 13895 MembersCanCreatePages: Bool(true), 13896 MembersCanCreatePublicPages: Bool(false), 13897 MembersCanCreatePrivatePages: Bool(true), 13898 }, 13899 Sender: &User{ 13900 Login: String("l"), 13901 ID: Int64(1), 13902 NodeID: String("n"), 13903 URL: String("u"), 13904 ReposURL: String("r"), 13905 EventsURL: String("e"), 13906 AvatarURL: String("a"), 13907 }, 13908 Installation: &Installation{ 13909 ID: Int64(1), 13910 NodeID: String("nid"), 13911 AppID: Int64(1), 13912 AppSlug: String("as"), 13913 TargetID: Int64(1), 13914 Account: &User{ 13915 Login: String("l"), 13916 ID: Int64(1), 13917 URL: String("u"), 13918 AvatarURL: String("a"), 13919 GravatarID: String("g"), 13920 Name: String("n"), 13921 Company: String("c"), 13922 Blog: String("b"), 13923 Location: String("l"), 13924 Email: String("e"), 13925 Hireable: Bool(true), 13926 Bio: String("b"), 13927 TwitterUsername: String("t"), 13928 PublicRepos: Int(1), 13929 Followers: Int(1), 13930 Following: Int(1), 13931 CreatedAt: &Timestamp{referenceTime}, 13932 SuspendedAt: &Timestamp{referenceTime}, 13933 }, 13934 AccessTokensURL: String("atu"), 13935 RepositoriesURL: String("ru"), 13936 HTMLURL: String("hu"), 13937 TargetType: String("tt"), 13938 SingleFileName: String("sfn"), 13939 RepositorySelection: String("rs"), 13940 Events: []string{"e"}, 13941 SingleFilePaths: []string{"s"}, 13942 Permissions: &InstallationPermissions{ 13943 Actions: String("a"), 13944 Administration: String("ad"), 13945 Checks: String("c"), 13946 Contents: String("co"), 13947 ContentReferences: String("cr"), 13948 Deployments: String("d"), 13949 Environments: String("e"), 13950 Issues: String("i"), 13951 Metadata: String("md"), 13952 Members: String("m"), 13953 OrganizationAdministration: String("oa"), 13954 OrganizationHooks: String("oh"), 13955 OrganizationPlan: String("op"), 13956 OrganizationPreReceiveHooks: String("opr"), 13957 OrganizationProjects: String("op"), 13958 OrganizationSecrets: String("os"), 13959 OrganizationSelfHostedRunners: String("osh"), 13960 OrganizationUserBlocking: String("oub"), 13961 Packages: String("pkg"), 13962 Pages: String("pg"), 13963 PullRequests: String("pr"), 13964 RepositoryHooks: String("rh"), 13965 RepositoryProjects: String("rp"), 13966 RepositoryPreReceiveHooks: String("rprh"), 13967 Secrets: String("s"), 13968 SecretScanningAlerts: String("ssa"), 13969 SecurityEvents: String("se"), 13970 SingleFile: String("sf"), 13971 Statuses: String("s"), 13972 TeamDiscussions: String("td"), 13973 VulnerabilityAlerts: String("va"), 13974 Workflows: String("w"), 13975 }, 13976 CreatedAt: &Timestamp{referenceTime}, 13977 UpdatedAt: &Timestamp{referenceTime}, 13978 HasMultipleSingleFiles: Bool(false), 13979 SuspendedBy: &User{ 13980 Login: String("l"), 13981 ID: Int64(1), 13982 URL: String("u"), 13983 AvatarURL: String("a"), 13984 GravatarID: String("g"), 13985 Name: String("n"), 13986 Company: String("c"), 13987 Blog: String("b"), 13988 Location: String("l"), 13989 Email: String("e"), 13990 Hireable: Bool(true), 13991 Bio: String("b"), 13992 TwitterUsername: String("t"), 13993 PublicRepos: Int(1), 13994 Followers: Int(1), 13995 Following: Int(1), 13996 CreatedAt: &Timestamp{referenceTime}, 13997 SuspendedAt: &Timestamp{referenceTime}, 13998 }, 13999 SuspendedAt: &Timestamp{referenceTime}, 14000 }, 14001 } 14002 14003 want := `{ 14004 "action": "a", 14005 "changes": { 14006 "name": { 14007 "from": "NameFrom" 14008 }, 14009 "body": { 14010 "from": "BodyFrom" 14011 } 14012 }, 14013 "project": { 14014 "id": 1 14015 }, 14016 "repository": { 14017 "id": 1, 14018 "name": "n", 14019 "url": "s" 14020 }, 14021 "organization": { 14022 "name": "n", 14023 "company": "c", 14024 "blog": "b", 14025 "location": "loc", 14026 "email": "e", 14027 "twitter_username": "tu", 14028 "description": "d", 14029 "billing_email": "be", 14030 "is_verified": true, 14031 "has_organization_projects": true, 14032 "has_repository_projects": true, 14033 "default_repository_permission": "drp", 14034 "members_can_create_repositories": true, 14035 "members_can_create_public_repositories": false, 14036 "members_can_create_private_repositories": true, 14037 "members_can_create_internal_repositories": true, 14038 "members_allowed_repository_creation_type": "marct", 14039 "members_can_create_pages": true, 14040 "members_can_create_public_pages": false, 14041 "members_can_create_private_pages": true 14042 }, 14043 "sender": { 14044 "login": "l", 14045 "id": 1, 14046 "node_id": "n", 14047 "avatar_url": "a", 14048 "url": "u", 14049 "events_url": "e", 14050 "repos_url": "r" 14051 }, 14052 "installation": { 14053 "id": 1, 14054 "node_id": "nid", 14055 "app_id": 1, 14056 "app_slug": "as", 14057 "target_id": 1, 14058 "account": { 14059 "login": "l", 14060 "id": 1, 14061 "avatar_url": "a", 14062 "gravatar_id": "g", 14063 "name": "n", 14064 "company": "c", 14065 "blog": "b", 14066 "location": "l", 14067 "email": "e", 14068 "hireable": true, 14069 "bio": "b", 14070 "twitter_username": "t", 14071 "public_repos": 1, 14072 "followers": 1, 14073 "following": 1, 14074 "created_at": ` + referenceTimeStr + `, 14075 "suspended_at": ` + referenceTimeStr + `, 14076 "url": "u" 14077 }, 14078 "access_tokens_url": "atu", 14079 "repositories_url": "ru", 14080 "html_url": "hu", 14081 "target_type": "tt", 14082 "single_file_name": "sfn", 14083 "repository_selection": "rs", 14084 "events": [ 14085 "e" 14086 ], 14087 "single_file_paths": [ 14088 "s" 14089 ], 14090 "permissions": { 14091 "actions": "a", 14092 "administration": "ad", 14093 "checks": "c", 14094 "contents": "co", 14095 "content_references": "cr", 14096 "deployments": "d", 14097 "environments": "e", 14098 "issues": "i", 14099 "metadata": "md", 14100 "members": "m", 14101 "organization_administration": "oa", 14102 "organization_hooks": "oh", 14103 "organization_plan": "op", 14104 "organization_pre_receive_hooks": "opr", 14105 "organization_projects": "op", 14106 "organization_secrets": "os", 14107 "organization_self_hosted_runners": "osh", 14108 "organization_user_blocking": "oub", 14109 "packages": "pkg", 14110 "pages": "pg", 14111 "pull_requests": "pr", 14112 "repository_hooks": "rh", 14113 "repository_projects": "rp", 14114 "repository_pre_receive_hooks": "rprh", 14115 "secrets": "s", 14116 "secret_scanning_alerts": "ssa", 14117 "security_events": "se", 14118 "single_file": "sf", 14119 "statuses": "s", 14120 "team_discussions": "td", 14121 "vulnerability_alerts": "va", 14122 "workflows": "w" 14123 }, 14124 "created_at": ` + referenceTimeStr + `, 14125 "updated_at": ` + referenceTimeStr + `, 14126 "has_multiple_single_files": false, 14127 "suspended_by": { 14128 "login": "l", 14129 "id": 1, 14130 "avatar_url": "a", 14131 "gravatar_id": "g", 14132 "name": "n", 14133 "company": "c", 14134 "blog": "b", 14135 "location": "l", 14136 "email": "e", 14137 "hireable": true, 14138 "bio": "b", 14139 "twitter_username": "t", 14140 "public_repos": 1, 14141 "followers": 1, 14142 "following": 1, 14143 "created_at": ` + referenceTimeStr + `, 14144 "suspended_at": ` + referenceTimeStr + `, 14145 "url": "u" 14146 }, 14147 "suspended_at": ` + referenceTimeStr + ` 14148 } 14149 }` 14150 14151 testJSONMarshal(t, u, want) 14152 } 14153 14154 func TestProjectCardEvent_Marshal(t *testing.T) { 14155 testJSONMarshal(t, &ProjectCardEvent{}, "{}") 14156 14157 u := &ProjectCardEvent{ 14158 Action: String("a"), 14159 Changes: &ProjectCardChange{ 14160 Note: &ProjectCardNote{From: String("NoteFrom")}, 14161 }, 14162 AfterID: Int64(1), 14163 ProjectCard: &ProjectCard{ID: Int64(1)}, 14164 Repo: &Repository{ 14165 ID: Int64(1), 14166 URL: String("s"), 14167 Name: String("n"), 14168 }, 14169 Org: &Organization{ 14170 BillingEmail: String("be"), 14171 Blog: String("b"), 14172 Company: String("c"), 14173 Email: String("e"), 14174 TwitterUsername: String("tu"), 14175 Location: String("loc"), 14176 Name: String("n"), 14177 Description: String("d"), 14178 IsVerified: Bool(true), 14179 HasOrganizationProjects: Bool(true), 14180 HasRepositoryProjects: Bool(true), 14181 DefaultRepoPermission: String("drp"), 14182 MembersCanCreateRepos: Bool(true), 14183 MembersCanCreateInternalRepos: Bool(true), 14184 MembersCanCreatePrivateRepos: Bool(true), 14185 MembersCanCreatePublicRepos: Bool(false), 14186 MembersAllowedRepositoryCreationType: String("marct"), 14187 MembersCanCreatePages: Bool(true), 14188 MembersCanCreatePublicPages: Bool(false), 14189 MembersCanCreatePrivatePages: Bool(true), 14190 }, 14191 Sender: &User{ 14192 Login: String("l"), 14193 ID: Int64(1), 14194 NodeID: String("n"), 14195 URL: String("u"), 14196 ReposURL: String("r"), 14197 EventsURL: String("e"), 14198 AvatarURL: String("a"), 14199 }, 14200 Installation: &Installation{ 14201 ID: Int64(1), 14202 NodeID: String("nid"), 14203 AppID: Int64(1), 14204 AppSlug: String("as"), 14205 TargetID: Int64(1), 14206 Account: &User{ 14207 Login: String("l"), 14208 ID: Int64(1), 14209 URL: String("u"), 14210 AvatarURL: String("a"), 14211 GravatarID: String("g"), 14212 Name: String("n"), 14213 Company: String("c"), 14214 Blog: String("b"), 14215 Location: String("l"), 14216 Email: String("e"), 14217 Hireable: Bool(true), 14218 Bio: String("b"), 14219 TwitterUsername: String("t"), 14220 PublicRepos: Int(1), 14221 Followers: Int(1), 14222 Following: Int(1), 14223 CreatedAt: &Timestamp{referenceTime}, 14224 SuspendedAt: &Timestamp{referenceTime}, 14225 }, 14226 AccessTokensURL: String("atu"), 14227 RepositoriesURL: String("ru"), 14228 HTMLURL: String("hu"), 14229 TargetType: String("tt"), 14230 SingleFileName: String("sfn"), 14231 RepositorySelection: String("rs"), 14232 Events: []string{"e"}, 14233 SingleFilePaths: []string{"s"}, 14234 Permissions: &InstallationPermissions{ 14235 Actions: String("a"), 14236 Administration: String("ad"), 14237 Checks: String("c"), 14238 Contents: String("co"), 14239 ContentReferences: String("cr"), 14240 Deployments: String("d"), 14241 Environments: String("e"), 14242 Issues: String("i"), 14243 Metadata: String("md"), 14244 Members: String("m"), 14245 OrganizationAdministration: String("oa"), 14246 OrganizationHooks: String("oh"), 14247 OrganizationPlan: String("op"), 14248 OrganizationPreReceiveHooks: String("opr"), 14249 OrganizationProjects: String("op"), 14250 OrganizationSecrets: String("os"), 14251 OrganizationSelfHostedRunners: String("osh"), 14252 OrganizationUserBlocking: String("oub"), 14253 Packages: String("pkg"), 14254 Pages: String("pg"), 14255 PullRequests: String("pr"), 14256 RepositoryHooks: String("rh"), 14257 RepositoryProjects: String("rp"), 14258 RepositoryPreReceiveHooks: String("rprh"), 14259 Secrets: String("s"), 14260 SecretScanningAlerts: String("ssa"), 14261 SecurityEvents: String("se"), 14262 SingleFile: String("sf"), 14263 Statuses: String("s"), 14264 TeamDiscussions: String("td"), 14265 VulnerabilityAlerts: String("va"), 14266 Workflows: String("w"), 14267 }, 14268 CreatedAt: &Timestamp{referenceTime}, 14269 UpdatedAt: &Timestamp{referenceTime}, 14270 HasMultipleSingleFiles: Bool(false), 14271 SuspendedBy: &User{ 14272 Login: String("l"), 14273 ID: Int64(1), 14274 URL: String("u"), 14275 AvatarURL: String("a"), 14276 GravatarID: String("g"), 14277 Name: String("n"), 14278 Company: String("c"), 14279 Blog: String("b"), 14280 Location: String("l"), 14281 Email: String("e"), 14282 Hireable: Bool(true), 14283 Bio: String("b"), 14284 TwitterUsername: String("t"), 14285 PublicRepos: Int(1), 14286 Followers: Int(1), 14287 Following: Int(1), 14288 CreatedAt: &Timestamp{referenceTime}, 14289 SuspendedAt: &Timestamp{referenceTime}, 14290 }, 14291 SuspendedAt: &Timestamp{referenceTime}, 14292 }, 14293 } 14294 14295 want := `{ 14296 "action": "a", 14297 "changes": { 14298 "note": { 14299 "from": "NoteFrom" 14300 } 14301 }, 14302 "after_id": 1, 14303 "project_card": { 14304 "id": 1 14305 }, 14306 "repository": { 14307 "id": 1, 14308 "name": "n", 14309 "url": "s" 14310 }, 14311 "organization": { 14312 "name": "n", 14313 "company": "c", 14314 "blog": "b", 14315 "location": "loc", 14316 "email": "e", 14317 "twitter_username": "tu", 14318 "description": "d", 14319 "billing_email": "be", 14320 "is_verified": true, 14321 "has_organization_projects": true, 14322 "has_repository_projects": true, 14323 "default_repository_permission": "drp", 14324 "members_can_create_repositories": true, 14325 "members_can_create_public_repositories": false, 14326 "members_can_create_private_repositories": true, 14327 "members_can_create_internal_repositories": true, 14328 "members_allowed_repository_creation_type": "marct", 14329 "members_can_create_pages": true, 14330 "members_can_create_public_pages": false, 14331 "members_can_create_private_pages": true 14332 }, 14333 "sender": { 14334 "login": "l", 14335 "id": 1, 14336 "node_id": "n", 14337 "avatar_url": "a", 14338 "url": "u", 14339 "events_url": "e", 14340 "repos_url": "r" 14341 }, 14342 "installation": { 14343 "id": 1, 14344 "node_id": "nid", 14345 "app_id": 1, 14346 "app_slug": "as", 14347 "target_id": 1, 14348 "account": { 14349 "login": "l", 14350 "id": 1, 14351 "avatar_url": "a", 14352 "gravatar_id": "g", 14353 "name": "n", 14354 "company": "c", 14355 "blog": "b", 14356 "location": "l", 14357 "email": "e", 14358 "hireable": true, 14359 "bio": "b", 14360 "twitter_username": "t", 14361 "public_repos": 1, 14362 "followers": 1, 14363 "following": 1, 14364 "created_at": ` + referenceTimeStr + `, 14365 "suspended_at": ` + referenceTimeStr + `, 14366 "url": "u" 14367 }, 14368 "access_tokens_url": "atu", 14369 "repositories_url": "ru", 14370 "html_url": "hu", 14371 "target_type": "tt", 14372 "single_file_name": "sfn", 14373 "repository_selection": "rs", 14374 "events": [ 14375 "e" 14376 ], 14377 "single_file_paths": [ 14378 "s" 14379 ], 14380 "permissions": { 14381 "actions": "a", 14382 "administration": "ad", 14383 "checks": "c", 14384 "contents": "co", 14385 "content_references": "cr", 14386 "deployments": "d", 14387 "environments": "e", 14388 "issues": "i", 14389 "metadata": "md", 14390 "members": "m", 14391 "organization_administration": "oa", 14392 "organization_hooks": "oh", 14393 "organization_plan": "op", 14394 "organization_pre_receive_hooks": "opr", 14395 "organization_projects": "op", 14396 "organization_secrets": "os", 14397 "organization_self_hosted_runners": "osh", 14398 "organization_user_blocking": "oub", 14399 "packages": "pkg", 14400 "pages": "pg", 14401 "pull_requests": "pr", 14402 "repository_hooks": "rh", 14403 "repository_projects": "rp", 14404 "repository_pre_receive_hooks": "rprh", 14405 "secrets": "s", 14406 "secret_scanning_alerts": "ssa", 14407 "security_events": "se", 14408 "single_file": "sf", 14409 "statuses": "s", 14410 "team_discussions": "td", 14411 "vulnerability_alerts": "va", 14412 "workflows": "w" 14413 }, 14414 "created_at": ` + referenceTimeStr + `, 14415 "updated_at": ` + referenceTimeStr + `, 14416 "has_multiple_single_files": false, 14417 "suspended_by": { 14418 "login": "l", 14419 "id": 1, 14420 "avatar_url": "a", 14421 "gravatar_id": "g", 14422 "name": "n", 14423 "company": "c", 14424 "blog": "b", 14425 "location": "l", 14426 "email": "e", 14427 "hireable": true, 14428 "bio": "b", 14429 "twitter_username": "t", 14430 "public_repos": 1, 14431 "followers": 1, 14432 "following": 1, 14433 "created_at": ` + referenceTimeStr + `, 14434 "suspended_at": ` + referenceTimeStr + `, 14435 "url": "u" 14436 }, 14437 "suspended_at": ` + referenceTimeStr + ` 14438 } 14439 }` 14440 14441 testJSONMarshal(t, u, want) 14442 } 14443 14444 func TestProjectColumnEvent_Marshal(t *testing.T) { 14445 testJSONMarshal(t, &ProjectColumnEvent{}, "{}") 14446 14447 u := &ProjectColumnEvent{ 14448 Action: String("a"), 14449 Changes: &ProjectColumnChange{ 14450 Name: &ProjectColumnName{From: String("NameFrom")}, 14451 }, 14452 AfterID: Int64(1), 14453 ProjectColumn: &ProjectColumn{ID: Int64(1)}, 14454 Repo: &Repository{ 14455 ID: Int64(1), 14456 URL: String("s"), 14457 Name: String("n"), 14458 }, 14459 Org: &Organization{ 14460 BillingEmail: String("be"), 14461 Blog: String("b"), 14462 Company: String("c"), 14463 Email: String("e"), 14464 TwitterUsername: String("tu"), 14465 Location: String("loc"), 14466 Name: String("n"), 14467 Description: String("d"), 14468 IsVerified: Bool(true), 14469 HasOrganizationProjects: Bool(true), 14470 HasRepositoryProjects: Bool(true), 14471 DefaultRepoPermission: String("drp"), 14472 MembersCanCreateRepos: Bool(true), 14473 MembersCanCreateInternalRepos: Bool(true), 14474 MembersCanCreatePrivateRepos: Bool(true), 14475 MembersCanCreatePublicRepos: Bool(false), 14476 MembersAllowedRepositoryCreationType: String("marct"), 14477 MembersCanCreatePages: Bool(true), 14478 MembersCanCreatePublicPages: Bool(false), 14479 MembersCanCreatePrivatePages: Bool(true), 14480 }, 14481 Sender: &User{ 14482 Login: String("l"), 14483 ID: Int64(1), 14484 NodeID: String("n"), 14485 URL: String("u"), 14486 ReposURL: String("r"), 14487 EventsURL: String("e"), 14488 AvatarURL: String("a"), 14489 }, 14490 Installation: &Installation{ 14491 ID: Int64(1), 14492 NodeID: String("nid"), 14493 AppID: Int64(1), 14494 AppSlug: String("as"), 14495 TargetID: Int64(1), 14496 Account: &User{ 14497 Login: String("l"), 14498 ID: Int64(1), 14499 URL: String("u"), 14500 AvatarURL: String("a"), 14501 GravatarID: String("g"), 14502 Name: String("n"), 14503 Company: String("c"), 14504 Blog: String("b"), 14505 Location: String("l"), 14506 Email: String("e"), 14507 Hireable: Bool(true), 14508 Bio: String("b"), 14509 TwitterUsername: String("t"), 14510 PublicRepos: Int(1), 14511 Followers: Int(1), 14512 Following: Int(1), 14513 CreatedAt: &Timestamp{referenceTime}, 14514 SuspendedAt: &Timestamp{referenceTime}, 14515 }, 14516 AccessTokensURL: String("atu"), 14517 RepositoriesURL: String("ru"), 14518 HTMLURL: String("hu"), 14519 TargetType: String("tt"), 14520 SingleFileName: String("sfn"), 14521 RepositorySelection: String("rs"), 14522 Events: []string{"e"}, 14523 SingleFilePaths: []string{"s"}, 14524 Permissions: &InstallationPermissions{ 14525 Actions: String("a"), 14526 Administration: String("ad"), 14527 Checks: String("c"), 14528 Contents: String("co"), 14529 ContentReferences: String("cr"), 14530 Deployments: String("d"), 14531 Environments: String("e"), 14532 Issues: String("i"), 14533 Metadata: String("md"), 14534 Members: String("m"), 14535 OrganizationAdministration: String("oa"), 14536 OrganizationHooks: String("oh"), 14537 OrganizationPlan: String("op"), 14538 OrganizationPreReceiveHooks: String("opr"), 14539 OrganizationProjects: String("op"), 14540 OrganizationSecrets: String("os"), 14541 OrganizationSelfHostedRunners: String("osh"), 14542 OrganizationUserBlocking: String("oub"), 14543 Packages: String("pkg"), 14544 Pages: String("pg"), 14545 PullRequests: String("pr"), 14546 RepositoryHooks: String("rh"), 14547 RepositoryProjects: String("rp"), 14548 RepositoryPreReceiveHooks: String("rprh"), 14549 Secrets: String("s"), 14550 SecretScanningAlerts: String("ssa"), 14551 SecurityEvents: String("se"), 14552 SingleFile: String("sf"), 14553 Statuses: String("s"), 14554 TeamDiscussions: String("td"), 14555 VulnerabilityAlerts: String("va"), 14556 Workflows: String("w"), 14557 }, 14558 CreatedAt: &Timestamp{referenceTime}, 14559 UpdatedAt: &Timestamp{referenceTime}, 14560 HasMultipleSingleFiles: Bool(false), 14561 SuspendedBy: &User{ 14562 Login: String("l"), 14563 ID: Int64(1), 14564 URL: String("u"), 14565 AvatarURL: String("a"), 14566 GravatarID: String("g"), 14567 Name: String("n"), 14568 Company: String("c"), 14569 Blog: String("b"), 14570 Location: String("l"), 14571 Email: String("e"), 14572 Hireable: Bool(true), 14573 Bio: String("b"), 14574 TwitterUsername: String("t"), 14575 PublicRepos: Int(1), 14576 Followers: Int(1), 14577 Following: Int(1), 14578 CreatedAt: &Timestamp{referenceTime}, 14579 SuspendedAt: &Timestamp{referenceTime}, 14580 }, 14581 SuspendedAt: &Timestamp{referenceTime}, 14582 }, 14583 } 14584 14585 want := `{ 14586 "action": "a", 14587 "changes": { 14588 "name": { 14589 "from": "NameFrom" 14590 } 14591 }, 14592 "after_id": 1, 14593 "project_column": { 14594 "id": 1 14595 }, 14596 "repository": { 14597 "id": 1, 14598 "name": "n", 14599 "url": "s" 14600 }, 14601 "organization": { 14602 "name": "n", 14603 "company": "c", 14604 "blog": "b", 14605 "location": "loc", 14606 "email": "e", 14607 "twitter_username": "tu", 14608 "description": "d", 14609 "billing_email": "be", 14610 "is_verified": true, 14611 "has_organization_projects": true, 14612 "has_repository_projects": true, 14613 "default_repository_permission": "drp", 14614 "members_can_create_repositories": true, 14615 "members_can_create_public_repositories": false, 14616 "members_can_create_private_repositories": true, 14617 "members_can_create_internal_repositories": true, 14618 "members_allowed_repository_creation_type": "marct", 14619 "members_can_create_pages": true, 14620 "members_can_create_public_pages": false, 14621 "members_can_create_private_pages": true 14622 }, 14623 "sender": { 14624 "login": "l", 14625 "id": 1, 14626 "node_id": "n", 14627 "avatar_url": "a", 14628 "url": "u", 14629 "events_url": "e", 14630 "repos_url": "r" 14631 }, 14632 "installation": { 14633 "id": 1, 14634 "node_id": "nid", 14635 "app_id": 1, 14636 "app_slug": "as", 14637 "target_id": 1, 14638 "account": { 14639 "login": "l", 14640 "id": 1, 14641 "avatar_url": "a", 14642 "gravatar_id": "g", 14643 "name": "n", 14644 "company": "c", 14645 "blog": "b", 14646 "location": "l", 14647 "email": "e", 14648 "hireable": true, 14649 "bio": "b", 14650 "twitter_username": "t", 14651 "public_repos": 1, 14652 "followers": 1, 14653 "following": 1, 14654 "created_at": ` + referenceTimeStr + `, 14655 "suspended_at": ` + referenceTimeStr + `, 14656 "url": "u" 14657 }, 14658 "access_tokens_url": "atu", 14659 "repositories_url": "ru", 14660 "html_url": "hu", 14661 "target_type": "tt", 14662 "single_file_name": "sfn", 14663 "repository_selection": "rs", 14664 "events": [ 14665 "e" 14666 ], 14667 "single_file_paths": [ 14668 "s" 14669 ], 14670 "permissions": { 14671 "actions": "a", 14672 "administration": "ad", 14673 "checks": "c", 14674 "contents": "co", 14675 "content_references": "cr", 14676 "deployments": "d", 14677 "environments": "e", 14678 "issues": "i", 14679 "metadata": "md", 14680 "members": "m", 14681 "organization_administration": "oa", 14682 "organization_hooks": "oh", 14683 "organization_plan": "op", 14684 "organization_pre_receive_hooks": "opr", 14685 "organization_projects": "op", 14686 "organization_secrets": "os", 14687 "organization_self_hosted_runners": "osh", 14688 "organization_user_blocking": "oub", 14689 "packages": "pkg", 14690 "pages": "pg", 14691 "pull_requests": "pr", 14692 "repository_hooks": "rh", 14693 "repository_projects": "rp", 14694 "repository_pre_receive_hooks": "rprh", 14695 "secrets": "s", 14696 "secret_scanning_alerts": "ssa", 14697 "security_events": "se", 14698 "single_file": "sf", 14699 "statuses": "s", 14700 "team_discussions": "td", 14701 "vulnerability_alerts": "va", 14702 "workflows": "w" 14703 }, 14704 "created_at": ` + referenceTimeStr + `, 14705 "updated_at": ` + referenceTimeStr + `, 14706 "has_multiple_single_files": false, 14707 "suspended_by": { 14708 "login": "l", 14709 "id": 1, 14710 "avatar_url": "a", 14711 "gravatar_id": "g", 14712 "name": "n", 14713 "company": "c", 14714 "blog": "b", 14715 "location": "l", 14716 "email": "e", 14717 "hireable": true, 14718 "bio": "b", 14719 "twitter_username": "t", 14720 "public_repos": 1, 14721 "followers": 1, 14722 "following": 1, 14723 "created_at": ` + referenceTimeStr + `, 14724 "suspended_at": ` + referenceTimeStr + `, 14725 "url": "u" 14726 }, 14727 "suspended_at": ` + referenceTimeStr + ` 14728 } 14729 }` 14730 14731 testJSONMarshal(t, u, want) 14732 } 14733 14734 func TestProjectV2Event_Marshal(t *testing.T) { 14735 testJSONMarshal(t, &ProjectV2Event{}, "{}") 14736 14737 u := &ProjectV2Event{ 14738 Action: String("a"), 14739 ProjectsV2: &ProjectsV2{ 14740 ID: Int64(1), 14741 NodeID: String("nid"), 14742 Owner: &User{ 14743 Login: String("l"), 14744 ID: Int64(1), 14745 NodeID: String("n"), 14746 URL: String("u"), 14747 ReposURL: String("r"), 14748 EventsURL: String("e"), 14749 AvatarURL: String("a"), 14750 }, 14751 Creator: &User{ 14752 Login: String("l"), 14753 ID: Int64(1), 14754 NodeID: String("n"), 14755 URL: String("u"), 14756 ReposURL: String("r"), 14757 EventsURL: String("e"), 14758 AvatarURL: String("a"), 14759 }, 14760 Title: String("t"), 14761 Description: String("d"), 14762 Public: Bool(true), 14763 ClosedAt: &Timestamp{referenceTime}, 14764 CreatedAt: &Timestamp{referenceTime}, 14765 UpdatedAt: &Timestamp{referenceTime}, 14766 DeletedAt: &Timestamp{referenceTime}, 14767 Number: Int(1), 14768 ShortDescription: String("sd"), 14769 DeletedBy: &User{ 14770 Login: String("l"), 14771 ID: Int64(1), 14772 NodeID: String("n"), 14773 URL: String("u"), 14774 ReposURL: String("r"), 14775 EventsURL: String("e"), 14776 AvatarURL: String("a"), 14777 }, 14778 }, 14779 Org: &Organization{ 14780 BillingEmail: String("be"), 14781 Blog: String("b"), 14782 Company: String("c"), 14783 Email: String("e"), 14784 TwitterUsername: String("tu"), 14785 Location: String("loc"), 14786 Name: String("n"), 14787 Description: String("d"), 14788 IsVerified: Bool(true), 14789 HasOrganizationProjects: Bool(true), 14790 HasRepositoryProjects: Bool(true), 14791 DefaultRepoPermission: String("drp"), 14792 MembersCanCreateRepos: Bool(true), 14793 MembersCanCreateInternalRepos: Bool(true), 14794 MembersCanCreatePrivateRepos: Bool(true), 14795 MembersCanCreatePublicRepos: Bool(false), 14796 MembersAllowedRepositoryCreationType: String("marct"), 14797 MembersCanCreatePages: Bool(true), 14798 MembersCanCreatePublicPages: Bool(false), 14799 MembersCanCreatePrivatePages: Bool(true), 14800 }, 14801 Sender: &User{ 14802 Login: String("l"), 14803 ID: Int64(1), 14804 NodeID: String("n"), 14805 URL: String("u"), 14806 ReposURL: String("r"), 14807 EventsURL: String("e"), 14808 AvatarURL: String("a"), 14809 }, 14810 Installation: &Installation{ 14811 ID: Int64(1), 14812 NodeID: String("nid"), 14813 AppID: Int64(1), 14814 AppSlug: String("as"), 14815 TargetID: Int64(1), 14816 Account: &User{ 14817 Login: String("l"), 14818 ID: Int64(1), 14819 URL: String("u"), 14820 AvatarURL: String("a"), 14821 GravatarID: String("g"), 14822 Name: String("n"), 14823 Company: String("c"), 14824 Blog: String("b"), 14825 Location: String("l"), 14826 Email: String("e"), 14827 Hireable: Bool(true), 14828 Bio: String("b"), 14829 TwitterUsername: String("t"), 14830 PublicRepos: Int(1), 14831 Followers: Int(1), 14832 Following: Int(1), 14833 CreatedAt: &Timestamp{referenceTime}, 14834 SuspendedAt: &Timestamp{referenceTime}, 14835 }, 14836 }, 14837 } 14838 14839 want := `{ 14840 "action": "a", 14841 "projects_v2": { 14842 "id": 1, 14843 "node_id": "nid", 14844 "owner": { 14845 "login": "l", 14846 "id": 1, 14847 "node_id": "n", 14848 "avatar_url": "a", 14849 "url": "u", 14850 "events_url": "e", 14851 "repos_url": "r" 14852 }, 14853 "creator": { 14854 "login": "l", 14855 "id": 1, 14856 "node_id": "n", 14857 "avatar_url": "a", 14858 "url": "u", 14859 "events_url": "e", 14860 "repos_url": "r" 14861 }, 14862 "title": "t", 14863 "description": "d", 14864 "public": true, 14865 "closed_at": ` + referenceTimeStr + `, 14866 "created_at": ` + referenceTimeStr + `, 14867 "updated_at": ` + referenceTimeStr + `, 14868 "deleted_at": ` + referenceTimeStr + `, 14869 "number": 1, 14870 "short_description": "sd", 14871 "deleted_by": { 14872 "login": "l", 14873 "id": 1, 14874 "node_id": "n", 14875 "avatar_url": "a", 14876 "url": "u", 14877 "events_url": "e", 14878 "repos_url": "r" 14879 } 14880 }, 14881 "organization": { 14882 "name": "n", 14883 "company": "c", 14884 "blog": "b", 14885 "location": "loc", 14886 "email": "e", 14887 "twitter_username": "tu", 14888 "description": "d", 14889 "billing_email": "be", 14890 "is_verified": true, 14891 "has_organization_projects": true, 14892 "has_repository_projects": true, 14893 "default_repository_permission": "drp", 14894 "members_can_create_repositories": true, 14895 "members_can_create_public_repositories": false, 14896 "members_can_create_private_repositories": true, 14897 "members_can_create_internal_repositories": true, 14898 "members_allowed_repository_creation_type": "marct", 14899 "members_can_create_pages": true, 14900 "members_can_create_public_pages": false, 14901 "members_can_create_private_pages": true 14902 }, 14903 "sender": { 14904 "login": "l", 14905 "id": 1, 14906 "node_id": "n", 14907 "avatar_url": "a", 14908 "url": "u", 14909 "events_url": "e", 14910 "repos_url": "r" 14911 }, 14912 "installation": { 14913 "id": 1, 14914 "node_id": "nid", 14915 "app_id": 1, 14916 "app_slug": "as", 14917 "target_id": 1, 14918 "account": { 14919 "login": "l", 14920 "id": 1, 14921 "avatar_url": "a", 14922 "gravatar_id": "g", 14923 "name": "n", 14924 "company": "c", 14925 "blog": "b", 14926 "location": "l", 14927 "email": "e", 14928 "hireable": true, 14929 "bio": "b", 14930 "twitter_username": "t", 14931 "public_repos": 1, 14932 "followers": 1, 14933 "following": 1, 14934 "created_at": ` + referenceTimeStr + `, 14935 "suspended_at": ` + referenceTimeStr + `, 14936 "url": "u" 14937 } 14938 } 14939 }` 14940 14941 testJSONMarshal(t, u, want) 14942 } 14943 14944 func TestProjectV2ItemEvent_Marshal(t *testing.T) { 14945 testJSONMarshal(t, &ProjectV2ItemEvent{}, "{}") 14946 14947 u := &ProjectV2ItemEvent{ 14948 Action: String("a"), 14949 Changes: &ProjectV2ItemChange{ 14950 ArchivedAt: &ArchivedAt{ 14951 From: &Timestamp{referenceTime}, 14952 To: &Timestamp{referenceTime}, 14953 }, 14954 }, 14955 ProjectV2Item: &ProjectV2Item{ 14956 ID: Int64(1), 14957 NodeID: String("nid"), 14958 ProjectNodeID: String("pnid"), 14959 ContentNodeID: String("cnid"), 14960 ContentType: String("ct"), 14961 Creator: &User{ 14962 Login: String("l"), 14963 ID: Int64(1), 14964 NodeID: String("n"), 14965 URL: String("u"), 14966 ReposURL: String("r"), 14967 EventsURL: String("e"), 14968 AvatarURL: String("a"), 14969 }, 14970 CreatedAt: &Timestamp{referenceTime}, 14971 UpdatedAt: &Timestamp{referenceTime}, 14972 ArchivedAt: &Timestamp{referenceTime}, 14973 }, 14974 Org: &Organization{ 14975 BillingEmail: String("be"), 14976 Blog: String("b"), 14977 Company: String("c"), 14978 Email: String("e"), 14979 TwitterUsername: String("tu"), 14980 Location: String("loc"), 14981 Name: String("n"), 14982 Description: String("d"), 14983 IsVerified: Bool(true), 14984 HasOrganizationProjects: Bool(true), 14985 HasRepositoryProjects: Bool(true), 14986 DefaultRepoPermission: String("drp"), 14987 MembersCanCreateRepos: Bool(true), 14988 MembersCanCreateInternalRepos: Bool(true), 14989 MembersCanCreatePrivateRepos: Bool(true), 14990 MembersCanCreatePublicRepos: Bool(false), 14991 MembersAllowedRepositoryCreationType: String("marct"), 14992 MembersCanCreatePages: Bool(true), 14993 MembersCanCreatePublicPages: Bool(false), 14994 MembersCanCreatePrivatePages: Bool(true), 14995 }, 14996 Sender: &User{ 14997 Login: String("l"), 14998 ID: Int64(1), 14999 NodeID: String("n"), 15000 URL: String("u"), 15001 ReposURL: String("r"), 15002 EventsURL: String("e"), 15003 AvatarURL: String("a"), 15004 }, 15005 Installation: &Installation{ 15006 ID: Int64(1), 15007 NodeID: String("nid"), 15008 AppID: Int64(1), 15009 AppSlug: String("as"), 15010 TargetID: Int64(1), 15011 Account: &User{ 15012 Login: String("l"), 15013 ID: Int64(1), 15014 URL: String("u"), 15015 AvatarURL: String("a"), 15016 GravatarID: String("g"), 15017 Name: String("n"), 15018 Company: String("c"), 15019 Blog: String("b"), 15020 Location: String("l"), 15021 Email: String("e"), 15022 Hireable: Bool(true), 15023 Bio: String("b"), 15024 TwitterUsername: String("t"), 15025 PublicRepos: Int(1), 15026 Followers: Int(1), 15027 Following: Int(1), 15028 CreatedAt: &Timestamp{referenceTime}, 15029 SuspendedAt: &Timestamp{referenceTime}, 15030 }, 15031 }, 15032 } 15033 15034 want := `{ 15035 "action": "a", 15036 "changes": { 15037 "archived_at": { 15038 "from": ` + referenceTimeStr + `, 15039 "to": ` + referenceTimeStr + ` 15040 } 15041 }, 15042 "projects_v2_item": { 15043 "id": 1, 15044 "node_id": "nid", 15045 "project_node_id": "pnid", 15046 "content_node_id": "cnid", 15047 "content_type": "ct", 15048 "creator": { 15049 "login": "l", 15050 "id": 1, 15051 "node_id": "n", 15052 "avatar_url": "a", 15053 "url": "u", 15054 "events_url": "e", 15055 "repos_url": "r" 15056 }, 15057 "created_at": ` + referenceTimeStr + `, 15058 "updated_at": ` + referenceTimeStr + `, 15059 "archived_at": ` + referenceTimeStr + ` 15060 }, 15061 "organization": { 15062 "name": "n", 15063 "company": "c", 15064 "blog": "b", 15065 "location": "loc", 15066 "email": "e", 15067 "twitter_username": "tu", 15068 "description": "d", 15069 "billing_email": "be", 15070 "is_verified": true, 15071 "has_organization_projects": true, 15072 "has_repository_projects": true, 15073 "default_repository_permission": "drp", 15074 "members_can_create_repositories": true, 15075 "members_can_create_public_repositories": false, 15076 "members_can_create_private_repositories": true, 15077 "members_can_create_internal_repositories": true, 15078 "members_allowed_repository_creation_type": "marct", 15079 "members_can_create_pages": true, 15080 "members_can_create_public_pages": false, 15081 "members_can_create_private_pages": true 15082 }, 15083 "sender": { 15084 "login": "l", 15085 "id": 1, 15086 "node_id": "n", 15087 "avatar_url": "a", 15088 "url": "u", 15089 "events_url": "e", 15090 "repos_url": "r" 15091 }, 15092 "installation": { 15093 "id": 1, 15094 "node_id": "nid", 15095 "app_id": 1, 15096 "app_slug": "as", 15097 "target_id": 1, 15098 "account": { 15099 "login": "l", 15100 "id": 1, 15101 "avatar_url": "a", 15102 "gravatar_id": "g", 15103 "name": "n", 15104 "company": "c", 15105 "blog": "b", 15106 "location": "l", 15107 "email": "e", 15108 "hireable": true, 15109 "bio": "b", 15110 "twitter_username": "t", 15111 "public_repos": 1, 15112 "followers": 1, 15113 "following": 1, 15114 "created_at": ` + referenceTimeStr + `, 15115 "suspended_at": ` + referenceTimeStr + `, 15116 "url": "u" 15117 } 15118 } 15119 }` 15120 15121 testJSONMarshal(t, u, want) 15122 } 15123 15124 func TestPullRequestEvent_Marshal(t *testing.T) { 15125 testJSONMarshal(t, &PullRequestEvent{}, "{}") 15126 15127 u := &PullRequestEvent{ 15128 Action: String("a"), 15129 Assignee: &User{ 15130 Login: String("l"), 15131 ID: Int64(1), 15132 NodeID: String("n"), 15133 URL: String("u"), 15134 ReposURL: String("r"), 15135 EventsURL: String("e"), 15136 AvatarURL: String("a"), 15137 }, 15138 Number: Int(1), 15139 PullRequest: &PullRequest{ID: Int64(1)}, 15140 Changes: &EditChange{ 15141 Title: &EditTitle{ 15142 From: String("TitleFrom"), 15143 }, 15144 Body: &EditBody{ 15145 From: String("BodyFrom"), 15146 }, 15147 Base: &EditBase{ 15148 Ref: &EditRef{ 15149 From: String("BaseRefFrom"), 15150 }, 15151 SHA: &EditSHA{ 15152 From: String("BaseSHAFrom"), 15153 }, 15154 }, 15155 }, 15156 RequestedReviewer: &User{ 15157 Login: String("l"), 15158 ID: Int64(1), 15159 NodeID: String("n"), 15160 URL: String("u"), 15161 ReposURL: String("r"), 15162 EventsURL: String("e"), 15163 AvatarURL: String("a"), 15164 }, 15165 RequestedTeam: &Team{ID: Int64(1)}, 15166 Label: &Label{ID: Int64(1)}, 15167 Before: String("before"), 15168 After: String("after"), 15169 Repo: &Repository{ 15170 ID: Int64(1), 15171 URL: String("s"), 15172 Name: String("n"), 15173 }, 15174 PerformedViaGithubApp: &App{ 15175 ID: Int64(1), 15176 NodeID: String("n"), 15177 Slug: String("s"), 15178 Name: String("n"), 15179 Description: String("d"), 15180 ExternalURL: String("e"), 15181 HTMLURL: String("h"), 15182 }, 15183 Organization: &Organization{ 15184 BillingEmail: String("be"), 15185 Blog: String("b"), 15186 Company: String("c"), 15187 Email: String("e"), 15188 TwitterUsername: String("tu"), 15189 Location: String("loc"), 15190 Name: String("n"), 15191 Description: String("d"), 15192 IsVerified: Bool(true), 15193 HasOrganizationProjects: Bool(true), 15194 HasRepositoryProjects: Bool(true), 15195 DefaultRepoPermission: String("drp"), 15196 MembersCanCreateRepos: Bool(true), 15197 MembersCanCreateInternalRepos: Bool(true), 15198 MembersCanCreatePrivateRepos: Bool(true), 15199 MembersCanCreatePublicRepos: Bool(false), 15200 MembersAllowedRepositoryCreationType: String("marct"), 15201 MembersCanCreatePages: Bool(true), 15202 MembersCanCreatePublicPages: Bool(false), 15203 MembersCanCreatePrivatePages: Bool(true), 15204 }, 15205 Sender: &User{ 15206 Login: String("l"), 15207 ID: Int64(1), 15208 NodeID: String("n"), 15209 URL: String("u"), 15210 ReposURL: String("r"), 15211 EventsURL: String("e"), 15212 AvatarURL: String("a"), 15213 }, 15214 Installation: &Installation{ 15215 ID: Int64(1), 15216 NodeID: String("nid"), 15217 AppID: Int64(1), 15218 AppSlug: String("as"), 15219 TargetID: Int64(1), 15220 Account: &User{ 15221 Login: String("l"), 15222 ID: Int64(1), 15223 URL: String("u"), 15224 AvatarURL: String("a"), 15225 GravatarID: String("g"), 15226 Name: String("n"), 15227 Company: String("c"), 15228 Blog: String("b"), 15229 Location: String("l"), 15230 Email: String("e"), 15231 Hireable: Bool(true), 15232 Bio: String("b"), 15233 TwitterUsername: String("t"), 15234 PublicRepos: Int(1), 15235 Followers: Int(1), 15236 Following: Int(1), 15237 CreatedAt: &Timestamp{referenceTime}, 15238 SuspendedAt: &Timestamp{referenceTime}, 15239 }, 15240 AccessTokensURL: String("atu"), 15241 RepositoriesURL: String("ru"), 15242 HTMLURL: String("hu"), 15243 TargetType: String("tt"), 15244 SingleFileName: String("sfn"), 15245 RepositorySelection: String("rs"), 15246 Events: []string{"e"}, 15247 SingleFilePaths: []string{"s"}, 15248 Permissions: &InstallationPermissions{ 15249 Actions: String("a"), 15250 Administration: String("ad"), 15251 Checks: String("c"), 15252 Contents: String("co"), 15253 ContentReferences: String("cr"), 15254 Deployments: String("d"), 15255 Environments: String("e"), 15256 Issues: String("i"), 15257 Metadata: String("md"), 15258 Members: String("m"), 15259 OrganizationAdministration: String("oa"), 15260 OrganizationHooks: String("oh"), 15261 OrganizationPlan: String("op"), 15262 OrganizationPreReceiveHooks: String("opr"), 15263 OrganizationProjects: String("op"), 15264 OrganizationSecrets: String("os"), 15265 OrganizationSelfHostedRunners: String("osh"), 15266 OrganizationUserBlocking: String("oub"), 15267 Packages: String("pkg"), 15268 Pages: String("pg"), 15269 PullRequests: String("pr"), 15270 RepositoryHooks: String("rh"), 15271 RepositoryProjects: String("rp"), 15272 RepositoryPreReceiveHooks: String("rprh"), 15273 Secrets: String("s"), 15274 SecretScanningAlerts: String("ssa"), 15275 SecurityEvents: String("se"), 15276 SingleFile: String("sf"), 15277 Statuses: String("s"), 15278 TeamDiscussions: String("td"), 15279 VulnerabilityAlerts: String("va"), 15280 Workflows: String("w"), 15281 }, 15282 CreatedAt: &Timestamp{referenceTime}, 15283 UpdatedAt: &Timestamp{referenceTime}, 15284 HasMultipleSingleFiles: Bool(false), 15285 SuspendedBy: &User{ 15286 Login: String("l"), 15287 ID: Int64(1), 15288 URL: String("u"), 15289 AvatarURL: String("a"), 15290 GravatarID: String("g"), 15291 Name: String("n"), 15292 Company: String("c"), 15293 Blog: String("b"), 15294 Location: String("l"), 15295 Email: String("e"), 15296 Hireable: Bool(true), 15297 Bio: String("b"), 15298 TwitterUsername: String("t"), 15299 PublicRepos: Int(1), 15300 Followers: Int(1), 15301 Following: Int(1), 15302 CreatedAt: &Timestamp{referenceTime}, 15303 SuspendedAt: &Timestamp{referenceTime}, 15304 }, 15305 SuspendedAt: &Timestamp{referenceTime}, 15306 }, 15307 } 15308 15309 want := `{ 15310 "action": "a", 15311 "assignee": { 15312 "login": "l", 15313 "id": 1, 15314 "node_id": "n", 15315 "avatar_url": "a", 15316 "url": "u", 15317 "events_url": "e", 15318 "repos_url": "r" 15319 }, 15320 "number": 1, 15321 "pull_request": { 15322 "id": 1 15323 }, 15324 "changes": { 15325 "title": { 15326 "from": "TitleFrom" 15327 }, 15328 "body": { 15329 "from": "BodyFrom" 15330 }, 15331 "base": { 15332 "ref": { 15333 "from": "BaseRefFrom" 15334 }, 15335 "sha": { 15336 "from": "BaseSHAFrom" 15337 } 15338 } 15339 }, 15340 "requested_reviewer": { 15341 "login": "l", 15342 "id": 1, 15343 "node_id": "n", 15344 "avatar_url": "a", 15345 "url": "u", 15346 "events_url": "e", 15347 "repos_url": "r" 15348 }, 15349 "requested_team": { 15350 "id": 1 15351 }, 15352 "label": { 15353 "id": 1 15354 }, 15355 "before": "before", 15356 "after": "after", 15357 "repository": { 15358 "id": 1, 15359 "name": "n", 15360 "url": "s" 15361 }, 15362 "performed_via_github_app": { 15363 "id": 1, 15364 "node_id": "n", 15365 "slug": "s", 15366 "name": "n", 15367 "description": "d", 15368 "external_url": "e", 15369 "html_url": "h" 15370 }, 15371 "organization": { 15372 "name": "n", 15373 "company": "c", 15374 "blog": "b", 15375 "location": "loc", 15376 "email": "e", 15377 "twitter_username": "tu", 15378 "description": "d", 15379 "billing_email": "be", 15380 "is_verified": true, 15381 "has_organization_projects": true, 15382 "has_repository_projects": true, 15383 "default_repository_permission": "drp", 15384 "members_can_create_repositories": true, 15385 "members_can_create_public_repositories": false, 15386 "members_can_create_private_repositories": true, 15387 "members_can_create_internal_repositories": true, 15388 "members_allowed_repository_creation_type": "marct", 15389 "members_can_create_pages": true, 15390 "members_can_create_public_pages": false, 15391 "members_can_create_private_pages": true 15392 }, 15393 "sender": { 15394 "login": "l", 15395 "id": 1, 15396 "node_id": "n", 15397 "avatar_url": "a", 15398 "url": "u", 15399 "events_url": "e", 15400 "repos_url": "r" 15401 }, 15402 "installation": { 15403 "id": 1, 15404 "node_id": "nid", 15405 "app_id": 1, 15406 "app_slug": "as", 15407 "target_id": 1, 15408 "account": { 15409 "login": "l", 15410 "id": 1, 15411 "avatar_url": "a", 15412 "gravatar_id": "g", 15413 "name": "n", 15414 "company": "c", 15415 "blog": "b", 15416 "location": "l", 15417 "email": "e", 15418 "hireable": true, 15419 "bio": "b", 15420 "twitter_username": "t", 15421 "public_repos": 1, 15422 "followers": 1, 15423 "following": 1, 15424 "created_at": ` + referenceTimeStr + `, 15425 "suspended_at": ` + referenceTimeStr + `, 15426 "url": "u" 15427 }, 15428 "access_tokens_url": "atu", 15429 "repositories_url": "ru", 15430 "html_url": "hu", 15431 "target_type": "tt", 15432 "single_file_name": "sfn", 15433 "repository_selection": "rs", 15434 "events": [ 15435 "e" 15436 ], 15437 "single_file_paths": [ 15438 "s" 15439 ], 15440 "permissions": { 15441 "actions": "a", 15442 "administration": "ad", 15443 "checks": "c", 15444 "contents": "co", 15445 "content_references": "cr", 15446 "deployments": "d", 15447 "environments": "e", 15448 "issues": "i", 15449 "metadata": "md", 15450 "members": "m", 15451 "organization_administration": "oa", 15452 "organization_hooks": "oh", 15453 "organization_plan": "op", 15454 "organization_pre_receive_hooks": "opr", 15455 "organization_projects": "op", 15456 "organization_secrets": "os", 15457 "organization_self_hosted_runners": "osh", 15458 "organization_user_blocking": "oub", 15459 "packages": "pkg", 15460 "pages": "pg", 15461 "pull_requests": "pr", 15462 "repository_hooks": "rh", 15463 "repository_projects": "rp", 15464 "repository_pre_receive_hooks": "rprh", 15465 "secrets": "s", 15466 "secret_scanning_alerts": "ssa", 15467 "security_events": "se", 15468 "single_file": "sf", 15469 "statuses": "s", 15470 "team_discussions": "td", 15471 "vulnerability_alerts": "va", 15472 "workflows": "w" 15473 }, 15474 "created_at": ` + referenceTimeStr + `, 15475 "updated_at": ` + referenceTimeStr + `, 15476 "has_multiple_single_files": false, 15477 "suspended_by": { 15478 "login": "l", 15479 "id": 1, 15480 "avatar_url": "a", 15481 "gravatar_id": "g", 15482 "name": "n", 15483 "company": "c", 15484 "blog": "b", 15485 "location": "l", 15486 "email": "e", 15487 "hireable": true, 15488 "bio": "b", 15489 "twitter_username": "t", 15490 "public_repos": 1, 15491 "followers": 1, 15492 "following": 1, 15493 "created_at": ` + referenceTimeStr + `, 15494 "suspended_at": ` + referenceTimeStr + `, 15495 "url": "u" 15496 }, 15497 "suspended_at": ` + referenceTimeStr + ` 15498 } 15499 }` 15500 15501 testJSONMarshal(t, u, want) 15502 } 15503 15504 func TestPullRequestReviewCommentEvent_Marshal(t *testing.T) { 15505 testJSONMarshal(t, &PullRequestReviewCommentEvent{}, "{}") 15506 15507 u := &PullRequestReviewCommentEvent{ 15508 Action: String("a"), 15509 PullRequest: &PullRequest{ID: Int64(1)}, 15510 Comment: &PullRequestComment{ID: Int64(1)}, 15511 Changes: &EditChange{ 15512 Title: &EditTitle{ 15513 From: String("TitleFrom"), 15514 }, 15515 Body: &EditBody{ 15516 From: String("BodyFrom"), 15517 }, 15518 Base: &EditBase{ 15519 Ref: &EditRef{ 15520 From: String("BaseRefFrom"), 15521 }, 15522 SHA: &EditSHA{ 15523 From: String("BaseSHAFrom"), 15524 }, 15525 }, 15526 }, 15527 Repo: &Repository{ 15528 ID: Int64(1), 15529 URL: String("s"), 15530 Name: String("n"), 15531 }, 15532 Sender: &User{ 15533 Login: String("l"), 15534 ID: Int64(1), 15535 NodeID: String("n"), 15536 URL: String("u"), 15537 ReposURL: String("r"), 15538 EventsURL: String("e"), 15539 AvatarURL: String("a"), 15540 }, 15541 Installation: &Installation{ 15542 ID: Int64(1), 15543 NodeID: String("nid"), 15544 AppID: Int64(1), 15545 AppSlug: String("as"), 15546 TargetID: Int64(1), 15547 Account: &User{ 15548 Login: String("l"), 15549 ID: Int64(1), 15550 URL: String("u"), 15551 AvatarURL: String("a"), 15552 GravatarID: String("g"), 15553 Name: String("n"), 15554 Company: String("c"), 15555 Blog: String("b"), 15556 Location: String("l"), 15557 Email: String("e"), 15558 Hireable: Bool(true), 15559 Bio: String("b"), 15560 TwitterUsername: String("t"), 15561 PublicRepos: Int(1), 15562 Followers: Int(1), 15563 Following: Int(1), 15564 CreatedAt: &Timestamp{referenceTime}, 15565 SuspendedAt: &Timestamp{referenceTime}, 15566 }, 15567 AccessTokensURL: String("atu"), 15568 RepositoriesURL: String("ru"), 15569 HTMLURL: String("hu"), 15570 TargetType: String("tt"), 15571 SingleFileName: String("sfn"), 15572 RepositorySelection: String("rs"), 15573 Events: []string{"e"}, 15574 SingleFilePaths: []string{"s"}, 15575 Permissions: &InstallationPermissions{ 15576 Actions: String("a"), 15577 Administration: String("ad"), 15578 Checks: String("c"), 15579 Contents: String("co"), 15580 ContentReferences: String("cr"), 15581 Deployments: String("d"), 15582 Environments: String("e"), 15583 Issues: String("i"), 15584 Metadata: String("md"), 15585 Members: String("m"), 15586 OrganizationAdministration: String("oa"), 15587 OrganizationHooks: String("oh"), 15588 OrganizationPlan: String("op"), 15589 OrganizationPreReceiveHooks: String("opr"), 15590 OrganizationProjects: String("op"), 15591 OrganizationSecrets: String("os"), 15592 OrganizationSelfHostedRunners: String("osh"), 15593 OrganizationUserBlocking: String("oub"), 15594 Packages: String("pkg"), 15595 Pages: String("pg"), 15596 PullRequests: String("pr"), 15597 RepositoryHooks: String("rh"), 15598 RepositoryProjects: String("rp"), 15599 RepositoryPreReceiveHooks: String("rprh"), 15600 Secrets: String("s"), 15601 SecretScanningAlerts: String("ssa"), 15602 SecurityEvents: String("se"), 15603 SingleFile: String("sf"), 15604 Statuses: String("s"), 15605 TeamDiscussions: String("td"), 15606 VulnerabilityAlerts: String("va"), 15607 Workflows: String("w"), 15608 }, 15609 CreatedAt: &Timestamp{referenceTime}, 15610 UpdatedAt: &Timestamp{referenceTime}, 15611 HasMultipleSingleFiles: Bool(false), 15612 SuspendedBy: &User{ 15613 Login: String("l"), 15614 ID: Int64(1), 15615 URL: String("u"), 15616 AvatarURL: String("a"), 15617 GravatarID: String("g"), 15618 Name: String("n"), 15619 Company: String("c"), 15620 Blog: String("b"), 15621 Location: String("l"), 15622 Email: String("e"), 15623 Hireable: Bool(true), 15624 Bio: String("b"), 15625 TwitterUsername: String("t"), 15626 PublicRepos: Int(1), 15627 Followers: Int(1), 15628 Following: Int(1), 15629 CreatedAt: &Timestamp{referenceTime}, 15630 SuspendedAt: &Timestamp{referenceTime}, 15631 }, 15632 SuspendedAt: &Timestamp{referenceTime}, 15633 }, 15634 } 15635 15636 want := `{ 15637 "action": "a", 15638 "pull_request": { 15639 "id": 1 15640 }, 15641 "comment": { 15642 "id": 1 15643 }, 15644 "changes": { 15645 "title": { 15646 "from": "TitleFrom" 15647 }, 15648 "body": { 15649 "from": "BodyFrom" 15650 }, 15651 "base": { 15652 "ref": { 15653 "from": "BaseRefFrom" 15654 }, 15655 "sha": { 15656 "from": "BaseSHAFrom" 15657 } 15658 } 15659 }, 15660 "repository": { 15661 "id": 1, 15662 "name": "n", 15663 "url": "s" 15664 }, 15665 "sender": { 15666 "login": "l", 15667 "id": 1, 15668 "node_id": "n", 15669 "avatar_url": "a", 15670 "url": "u", 15671 "events_url": "e", 15672 "repos_url": "r" 15673 }, 15674 "installation": { 15675 "id": 1, 15676 "node_id": "nid", 15677 "app_id": 1, 15678 "app_slug": "as", 15679 "target_id": 1, 15680 "account": { 15681 "login": "l", 15682 "id": 1, 15683 "avatar_url": "a", 15684 "gravatar_id": "g", 15685 "name": "n", 15686 "company": "c", 15687 "blog": "b", 15688 "location": "l", 15689 "email": "e", 15690 "hireable": true, 15691 "bio": "b", 15692 "twitter_username": "t", 15693 "public_repos": 1, 15694 "followers": 1, 15695 "following": 1, 15696 "created_at": ` + referenceTimeStr + `, 15697 "suspended_at": ` + referenceTimeStr + `, 15698 "url": "u" 15699 }, 15700 "access_tokens_url": "atu", 15701 "repositories_url": "ru", 15702 "html_url": "hu", 15703 "target_type": "tt", 15704 "single_file_name": "sfn", 15705 "repository_selection": "rs", 15706 "events": [ 15707 "e" 15708 ], 15709 "single_file_paths": [ 15710 "s" 15711 ], 15712 "permissions": { 15713 "actions": "a", 15714 "administration": "ad", 15715 "checks": "c", 15716 "contents": "co", 15717 "content_references": "cr", 15718 "deployments": "d", 15719 "environments": "e", 15720 "issues": "i", 15721 "metadata": "md", 15722 "members": "m", 15723 "organization_administration": "oa", 15724 "organization_hooks": "oh", 15725 "organization_plan": "op", 15726 "organization_pre_receive_hooks": "opr", 15727 "organization_projects": "op", 15728 "organization_secrets": "os", 15729 "organization_self_hosted_runners": "osh", 15730 "organization_user_blocking": "oub", 15731 "packages": "pkg", 15732 "pages": "pg", 15733 "pull_requests": "pr", 15734 "repository_hooks": "rh", 15735 "repository_projects": "rp", 15736 "repository_pre_receive_hooks": "rprh", 15737 "secrets": "s", 15738 "secret_scanning_alerts": "ssa", 15739 "security_events": "se", 15740 "single_file": "sf", 15741 "statuses": "s", 15742 "team_discussions": "td", 15743 "vulnerability_alerts": "va", 15744 "workflows": "w" 15745 }, 15746 "created_at": ` + referenceTimeStr + `, 15747 "updated_at": ` + referenceTimeStr + `, 15748 "has_multiple_single_files": false, 15749 "suspended_by": { 15750 "login": "l", 15751 "id": 1, 15752 "avatar_url": "a", 15753 "gravatar_id": "g", 15754 "name": "n", 15755 "company": "c", 15756 "blog": "b", 15757 "location": "l", 15758 "email": "e", 15759 "hireable": true, 15760 "bio": "b", 15761 "twitter_username": "t", 15762 "public_repos": 1, 15763 "followers": 1, 15764 "following": 1, 15765 "created_at": ` + referenceTimeStr + `, 15766 "suspended_at": ` + referenceTimeStr + `, 15767 "url": "u" 15768 }, 15769 "suspended_at": ` + referenceTimeStr + ` 15770 } 15771 }` 15772 15773 testJSONMarshal(t, u, want) 15774 } 15775 15776 func TestPullRequestReviewThreadEvent_Marshal(t *testing.T) { 15777 testJSONMarshal(t, &PullRequestReviewThreadEvent{}, "{}") 15778 15779 u := &PullRequestReviewThreadEvent{ 15780 Action: String("a"), 15781 PullRequest: &PullRequest{ID: Int64(1)}, 15782 Thread: &PullRequestThread{ 15783 Comments: []*PullRequestComment{{ID: Int64(1)}, {ID: Int64(2)}}, 15784 }, 15785 Repo: &Repository{ 15786 ID: Int64(1), 15787 URL: String("s"), 15788 Name: String("n"), 15789 }, 15790 Sender: &User{ 15791 Login: String("l"), 15792 ID: Int64(1), 15793 NodeID: String("n"), 15794 URL: String("u"), 15795 ReposURL: String("r"), 15796 EventsURL: String("e"), 15797 AvatarURL: String("a"), 15798 }, 15799 Installation: &Installation{ 15800 ID: Int64(1), 15801 NodeID: String("nid"), 15802 AppID: Int64(1), 15803 AppSlug: String("as"), 15804 TargetID: Int64(1), 15805 Account: &User{ 15806 Login: String("l"), 15807 ID: Int64(1), 15808 URL: String("u"), 15809 AvatarURL: String("a"), 15810 GravatarID: String("g"), 15811 Name: String("n"), 15812 Company: String("c"), 15813 Blog: String("b"), 15814 Location: String("l"), 15815 Email: String("e"), 15816 Hireable: Bool(true), 15817 Bio: String("b"), 15818 TwitterUsername: String("t"), 15819 PublicRepos: Int(1), 15820 Followers: Int(1), 15821 Following: Int(1), 15822 CreatedAt: &Timestamp{referenceTime}, 15823 SuspendedAt: &Timestamp{referenceTime}, 15824 }, 15825 AccessTokensURL: String("atu"), 15826 RepositoriesURL: String("ru"), 15827 HTMLURL: String("hu"), 15828 TargetType: String("tt"), 15829 SingleFileName: String("sfn"), 15830 RepositorySelection: String("rs"), 15831 Events: []string{"e"}, 15832 SingleFilePaths: []string{"s"}, 15833 Permissions: &InstallationPermissions{ 15834 Actions: String("a"), 15835 Administration: String("ad"), 15836 Checks: String("c"), 15837 Contents: String("co"), 15838 ContentReferences: String("cr"), 15839 Deployments: String("d"), 15840 Environments: String("e"), 15841 Issues: String("i"), 15842 Metadata: String("md"), 15843 Members: String("m"), 15844 OrganizationAdministration: String("oa"), 15845 OrganizationHooks: String("oh"), 15846 OrganizationPlan: String("op"), 15847 OrganizationPreReceiveHooks: String("opr"), 15848 OrganizationProjects: String("op"), 15849 OrganizationSecrets: String("os"), 15850 OrganizationSelfHostedRunners: String("osh"), 15851 OrganizationUserBlocking: String("oub"), 15852 Packages: String("pkg"), 15853 Pages: String("pg"), 15854 PullRequests: String("pr"), 15855 RepositoryHooks: String("rh"), 15856 RepositoryProjects: String("rp"), 15857 RepositoryPreReceiveHooks: String("rprh"), 15858 Secrets: String("s"), 15859 SecretScanningAlerts: String("ssa"), 15860 SecurityEvents: String("se"), 15861 SingleFile: String("sf"), 15862 Statuses: String("s"), 15863 TeamDiscussions: String("td"), 15864 VulnerabilityAlerts: String("va"), 15865 Workflows: String("w"), 15866 }, 15867 CreatedAt: &Timestamp{referenceTime}, 15868 UpdatedAt: &Timestamp{referenceTime}, 15869 HasMultipleSingleFiles: Bool(false), 15870 SuspendedBy: &User{ 15871 Login: String("l"), 15872 ID: Int64(1), 15873 URL: String("u"), 15874 AvatarURL: String("a"), 15875 GravatarID: String("g"), 15876 Name: String("n"), 15877 Company: String("c"), 15878 Blog: String("b"), 15879 Location: String("l"), 15880 Email: String("e"), 15881 Hireable: Bool(true), 15882 Bio: String("b"), 15883 TwitterUsername: String("t"), 15884 PublicRepos: Int(1), 15885 Followers: Int(1), 15886 Following: Int(1), 15887 CreatedAt: &Timestamp{referenceTime}, 15888 SuspendedAt: &Timestamp{referenceTime}, 15889 }, 15890 SuspendedAt: &Timestamp{referenceTime}, 15891 }, 15892 } 15893 15894 want := `{ 15895 "action": "a", 15896 "pull_request": { 15897 "id": 1 15898 }, 15899 "thread": { 15900 "comments": [ 15901 { 15902 "id": 1 15903 }, 15904 { 15905 "id": 2 15906 } 15907 ] 15908 }, 15909 "repository": { 15910 "id": 1, 15911 "name": "n", 15912 "url": "s" 15913 }, 15914 "sender": { 15915 "login": "l", 15916 "id": 1, 15917 "node_id": "n", 15918 "avatar_url": "a", 15919 "url": "u", 15920 "events_url": "e", 15921 "repos_url": "r" 15922 }, 15923 "installation": { 15924 "id": 1, 15925 "node_id": "nid", 15926 "app_id": 1, 15927 "app_slug": "as", 15928 "target_id": 1, 15929 "account": { 15930 "login": "l", 15931 "id": 1, 15932 "avatar_url": "a", 15933 "gravatar_id": "g", 15934 "name": "n", 15935 "company": "c", 15936 "blog": "b", 15937 "location": "l", 15938 "email": "e", 15939 "hireable": true, 15940 "bio": "b", 15941 "twitter_username": "t", 15942 "public_repos": 1, 15943 "followers": 1, 15944 "following": 1, 15945 "created_at": ` + referenceTimeStr + `, 15946 "suspended_at": ` + referenceTimeStr + `, 15947 "url": "u" 15948 }, 15949 "access_tokens_url": "atu", 15950 "repositories_url": "ru", 15951 "html_url": "hu", 15952 "target_type": "tt", 15953 "single_file_name": "sfn", 15954 "repository_selection": "rs", 15955 "events": [ 15956 "e" 15957 ], 15958 "single_file_paths": [ 15959 "s" 15960 ], 15961 "permissions": { 15962 "actions": "a", 15963 "administration": "ad", 15964 "checks": "c", 15965 "contents": "co", 15966 "content_references": "cr", 15967 "deployments": "d", 15968 "environments": "e", 15969 "issues": "i", 15970 "metadata": "md", 15971 "members": "m", 15972 "organization_administration": "oa", 15973 "organization_hooks": "oh", 15974 "organization_plan": "op", 15975 "organization_pre_receive_hooks": "opr", 15976 "organization_projects": "op", 15977 "organization_secrets": "os", 15978 "organization_self_hosted_runners": "osh", 15979 "organization_user_blocking": "oub", 15980 "packages": "pkg", 15981 "pages": "pg", 15982 "pull_requests": "pr", 15983 "repository_hooks": "rh", 15984 "repository_projects": "rp", 15985 "repository_pre_receive_hooks": "rprh", 15986 "secrets": "s", 15987 "secret_scanning_alerts": "ssa", 15988 "security_events": "se", 15989 "single_file": "sf", 15990 "statuses": "s", 15991 "team_discussions": "td", 15992 "vulnerability_alerts": "va", 15993 "workflows": "w" 15994 }, 15995 "created_at": ` + referenceTimeStr + `, 15996 "updated_at": ` + referenceTimeStr + `, 15997 "has_multiple_single_files": false, 15998 "suspended_by": { 15999 "login": "l", 16000 "id": 1, 16001 "avatar_url": "a", 16002 "gravatar_id": "g", 16003 "name": "n", 16004 "company": "c", 16005 "blog": "b", 16006 "location": "l", 16007 "email": "e", 16008 "hireable": true, 16009 "bio": "b", 16010 "twitter_username": "t", 16011 "public_repos": 1, 16012 "followers": 1, 16013 "following": 1, 16014 "created_at": ` + referenceTimeStr + `, 16015 "suspended_at": ` + referenceTimeStr + `, 16016 "url": "u" 16017 }, 16018 "suspended_at": ` + referenceTimeStr + ` 16019 } 16020 }` 16021 16022 testJSONMarshal(t, u, want) 16023 } 16024 16025 func TestPullRequestTargetEvent_Marshal(t *testing.T) { 16026 testJSONMarshal(t, &PullRequestTargetEvent{}, "{}") 16027 16028 u := &PullRequestTargetEvent{ 16029 Action: String("a"), 16030 Assignee: &User{ 16031 Login: String("l"), 16032 ID: Int64(1), 16033 NodeID: String("n"), 16034 URL: String("u"), 16035 ReposURL: String("r"), 16036 EventsURL: String("e"), 16037 AvatarURL: String("a"), 16038 }, 16039 Number: Int(1), 16040 PullRequest: &PullRequest{ID: Int64(1)}, 16041 Changes: &EditChange{ 16042 Title: &EditTitle{ 16043 From: String("TitleFrom"), 16044 }, 16045 Body: &EditBody{ 16046 From: String("BodyFrom"), 16047 }, 16048 Base: &EditBase{ 16049 Ref: &EditRef{ 16050 From: String("BaseRefFrom"), 16051 }, 16052 SHA: &EditSHA{ 16053 From: String("BaseSHAFrom"), 16054 }, 16055 }, 16056 }, 16057 RequestedReviewer: &User{ 16058 Login: String("l"), 16059 ID: Int64(1), 16060 NodeID: String("n"), 16061 URL: String("u"), 16062 ReposURL: String("r"), 16063 EventsURL: String("e"), 16064 AvatarURL: String("a"), 16065 }, 16066 RequestedTeam: &Team{ID: Int64(1)}, 16067 Label: &Label{ID: Int64(1)}, 16068 Before: String("before"), 16069 After: String("after"), 16070 Repo: &Repository{ 16071 ID: Int64(1), 16072 URL: String("s"), 16073 Name: String("n"), 16074 }, 16075 PerformedViaGithubApp: &App{ 16076 ID: Int64(1), 16077 NodeID: String("n"), 16078 Slug: String("s"), 16079 Name: String("n"), 16080 Description: String("d"), 16081 ExternalURL: String("e"), 16082 HTMLURL: String("h"), 16083 }, 16084 Organization: &Organization{ 16085 BillingEmail: String("be"), 16086 Blog: String("b"), 16087 Company: String("c"), 16088 Email: String("e"), 16089 TwitterUsername: String("tu"), 16090 Location: String("loc"), 16091 Name: String("n"), 16092 Description: String("d"), 16093 IsVerified: Bool(true), 16094 HasOrganizationProjects: Bool(true), 16095 HasRepositoryProjects: Bool(true), 16096 DefaultRepoPermission: String("drp"), 16097 MembersCanCreateRepos: Bool(true), 16098 MembersCanCreateInternalRepos: Bool(true), 16099 MembersCanCreatePrivateRepos: Bool(true), 16100 MembersCanCreatePublicRepos: Bool(false), 16101 MembersAllowedRepositoryCreationType: String("marct"), 16102 MembersCanCreatePages: Bool(true), 16103 MembersCanCreatePublicPages: Bool(false), 16104 MembersCanCreatePrivatePages: Bool(true), 16105 }, 16106 Sender: &User{ 16107 Login: String("l"), 16108 ID: Int64(1), 16109 NodeID: String("n"), 16110 URL: String("u"), 16111 ReposURL: String("r"), 16112 EventsURL: String("e"), 16113 AvatarURL: String("a"), 16114 }, 16115 Installation: &Installation{ 16116 ID: Int64(1), 16117 NodeID: String("nid"), 16118 AppID: Int64(1), 16119 AppSlug: String("as"), 16120 TargetID: Int64(1), 16121 Account: &User{ 16122 Login: String("l"), 16123 ID: Int64(1), 16124 URL: String("u"), 16125 AvatarURL: String("a"), 16126 GravatarID: String("g"), 16127 Name: String("n"), 16128 Company: String("c"), 16129 Blog: String("b"), 16130 Location: String("l"), 16131 Email: String("e"), 16132 Hireable: Bool(true), 16133 Bio: String("b"), 16134 TwitterUsername: String("t"), 16135 PublicRepos: Int(1), 16136 Followers: Int(1), 16137 Following: Int(1), 16138 CreatedAt: &Timestamp{referenceTime}, 16139 SuspendedAt: &Timestamp{referenceTime}, 16140 }, 16141 AccessTokensURL: String("atu"), 16142 RepositoriesURL: String("ru"), 16143 HTMLURL: String("hu"), 16144 TargetType: String("tt"), 16145 SingleFileName: String("sfn"), 16146 RepositorySelection: String("rs"), 16147 Events: []string{"e"}, 16148 SingleFilePaths: []string{"s"}, 16149 Permissions: &InstallationPermissions{ 16150 Actions: String("a"), 16151 Administration: String("ad"), 16152 Checks: String("c"), 16153 Contents: String("co"), 16154 ContentReferences: String("cr"), 16155 Deployments: String("d"), 16156 Environments: String("e"), 16157 Issues: String("i"), 16158 Metadata: String("md"), 16159 Members: String("m"), 16160 OrganizationAdministration: String("oa"), 16161 OrganizationHooks: String("oh"), 16162 OrganizationPlan: String("op"), 16163 OrganizationPreReceiveHooks: String("opr"), 16164 OrganizationProjects: String("op"), 16165 OrganizationSecrets: String("os"), 16166 OrganizationSelfHostedRunners: String("osh"), 16167 OrganizationUserBlocking: String("oub"), 16168 Packages: String("pkg"), 16169 Pages: String("pg"), 16170 PullRequests: String("pr"), 16171 RepositoryHooks: String("rh"), 16172 RepositoryProjects: String("rp"), 16173 RepositoryPreReceiveHooks: String("rprh"), 16174 Secrets: String("s"), 16175 SecretScanningAlerts: String("ssa"), 16176 SecurityEvents: String("se"), 16177 SingleFile: String("sf"), 16178 Statuses: String("s"), 16179 TeamDiscussions: String("td"), 16180 VulnerabilityAlerts: String("va"), 16181 Workflows: String("w"), 16182 }, 16183 CreatedAt: &Timestamp{referenceTime}, 16184 UpdatedAt: &Timestamp{referenceTime}, 16185 HasMultipleSingleFiles: Bool(false), 16186 SuspendedBy: &User{ 16187 Login: String("l"), 16188 ID: Int64(1), 16189 URL: String("u"), 16190 AvatarURL: String("a"), 16191 GravatarID: String("g"), 16192 Name: String("n"), 16193 Company: String("c"), 16194 Blog: String("b"), 16195 Location: String("l"), 16196 Email: String("e"), 16197 Hireable: Bool(true), 16198 Bio: String("b"), 16199 TwitterUsername: String("t"), 16200 PublicRepos: Int(1), 16201 Followers: Int(1), 16202 Following: Int(1), 16203 CreatedAt: &Timestamp{referenceTime}, 16204 SuspendedAt: &Timestamp{referenceTime}, 16205 }, 16206 SuspendedAt: &Timestamp{referenceTime}, 16207 }, 16208 } 16209 16210 want := `{ 16211 "action": "a", 16212 "assignee": { 16213 "login": "l", 16214 "id": 1, 16215 "node_id": "n", 16216 "avatar_url": "a", 16217 "url": "u", 16218 "events_url": "e", 16219 "repos_url": "r" 16220 }, 16221 "number": 1, 16222 "pull_request": { 16223 "id": 1 16224 }, 16225 "changes": { 16226 "title": { 16227 "from": "TitleFrom" 16228 }, 16229 "body": { 16230 "from": "BodyFrom" 16231 }, 16232 "base": { 16233 "ref": { 16234 "from": "BaseRefFrom" 16235 }, 16236 "sha": { 16237 "from": "BaseSHAFrom" 16238 } 16239 } 16240 }, 16241 "requested_reviewer": { 16242 "login": "l", 16243 "id": 1, 16244 "node_id": "n", 16245 "avatar_url": "a", 16246 "url": "u", 16247 "events_url": "e", 16248 "repos_url": "r" 16249 }, 16250 "requested_team": { 16251 "id": 1 16252 }, 16253 "label": { 16254 "id": 1 16255 }, 16256 "before": "before", 16257 "after": "after", 16258 "repository": { 16259 "id": 1, 16260 "name": "n", 16261 "url": "s" 16262 }, 16263 "performed_via_github_app": { 16264 "id": 1, 16265 "node_id": "n", 16266 "slug": "s", 16267 "name": "n", 16268 "description": "d", 16269 "external_url": "e", 16270 "html_url": "h" 16271 }, 16272 "organization": { 16273 "name": "n", 16274 "company": "c", 16275 "blog": "b", 16276 "location": "loc", 16277 "email": "e", 16278 "twitter_username": "tu", 16279 "description": "d", 16280 "billing_email": "be", 16281 "is_verified": true, 16282 "has_organization_projects": true, 16283 "has_repository_projects": true, 16284 "default_repository_permission": "drp", 16285 "members_can_create_repositories": true, 16286 "members_can_create_public_repositories": false, 16287 "members_can_create_private_repositories": true, 16288 "members_can_create_internal_repositories": true, 16289 "members_allowed_repository_creation_type": "marct", 16290 "members_can_create_pages": true, 16291 "members_can_create_public_pages": false, 16292 "members_can_create_private_pages": true 16293 }, 16294 "sender": { 16295 "login": "l", 16296 "id": 1, 16297 "node_id": "n", 16298 "avatar_url": "a", 16299 "url": "u", 16300 "events_url": "e", 16301 "repos_url": "r" 16302 }, 16303 "installation": { 16304 "id": 1, 16305 "node_id": "nid", 16306 "app_id": 1, 16307 "app_slug": "as", 16308 "target_id": 1, 16309 "account": { 16310 "login": "l", 16311 "id": 1, 16312 "avatar_url": "a", 16313 "gravatar_id": "g", 16314 "name": "n", 16315 "company": "c", 16316 "blog": "b", 16317 "location": "l", 16318 "email": "e", 16319 "hireable": true, 16320 "bio": "b", 16321 "twitter_username": "t", 16322 "public_repos": 1, 16323 "followers": 1, 16324 "following": 1, 16325 "created_at": ` + referenceTimeStr + `, 16326 "suspended_at": ` + referenceTimeStr + `, 16327 "url": "u" 16328 }, 16329 "access_tokens_url": "atu", 16330 "repositories_url": "ru", 16331 "html_url": "hu", 16332 "target_type": "tt", 16333 "single_file_name": "sfn", 16334 "repository_selection": "rs", 16335 "events": [ 16336 "e" 16337 ], 16338 "single_file_paths": [ 16339 "s" 16340 ], 16341 "permissions": { 16342 "actions": "a", 16343 "administration": "ad", 16344 "checks": "c", 16345 "contents": "co", 16346 "content_references": "cr", 16347 "deployments": "d", 16348 "environments": "e", 16349 "issues": "i", 16350 "metadata": "md", 16351 "members": "m", 16352 "organization_administration": "oa", 16353 "organization_hooks": "oh", 16354 "organization_plan": "op", 16355 "organization_pre_receive_hooks": "opr", 16356 "organization_projects": "op", 16357 "organization_secrets": "os", 16358 "organization_self_hosted_runners": "osh", 16359 "organization_user_blocking": "oub", 16360 "packages": "pkg", 16361 "pages": "pg", 16362 "pull_requests": "pr", 16363 "repository_hooks": "rh", 16364 "repository_projects": "rp", 16365 "repository_pre_receive_hooks": "rprh", 16366 "secrets": "s", 16367 "secret_scanning_alerts": "ssa", 16368 "security_events": "se", 16369 "single_file": "sf", 16370 "statuses": "s", 16371 "team_discussions": "td", 16372 "vulnerability_alerts": "va", 16373 "workflows": "w" 16374 }, 16375 "created_at": ` + referenceTimeStr + `, 16376 "updated_at": ` + referenceTimeStr + `, 16377 "has_multiple_single_files": false, 16378 "suspended_by": { 16379 "login": "l", 16380 "id": 1, 16381 "avatar_url": "a", 16382 "gravatar_id": "g", 16383 "name": "n", 16384 "company": "c", 16385 "blog": "b", 16386 "location": "l", 16387 "email": "e", 16388 "hireable": true, 16389 "bio": "b", 16390 "twitter_username": "t", 16391 "public_repos": 1, 16392 "followers": 1, 16393 "following": 1, 16394 "created_at": ` + referenceTimeStr + `, 16395 "suspended_at": ` + referenceTimeStr + `, 16396 "url": "u" 16397 }, 16398 "suspended_at": ` + referenceTimeStr + ` 16399 } 16400 }` 16401 16402 testJSONMarshal(t, u, want) 16403 } 16404 16405 func TestRepositoryVulnerabilityAlertEvent_Marshal(t *testing.T) { 16406 testJSONMarshal(t, &RepositoryVulnerabilityAlertEvent{}, "{}") 16407 16408 u := &RepositoryVulnerabilityAlertEvent{ 16409 Action: String("a"), 16410 Alert: &RepositoryVulnerabilityAlert{ 16411 ID: Int64(1), 16412 AffectedRange: String("ar"), 16413 AffectedPackageName: String("apn"), 16414 ExternalReference: String("er"), 16415 ExternalIdentifier: String("ei"), 16416 FixedIn: String("fi"), 16417 Dismisser: &User{ 16418 Login: String("l"), 16419 ID: Int64(1), 16420 NodeID: String("n"), 16421 URL: String("u"), 16422 ReposURL: String("r"), 16423 EventsURL: String("e"), 16424 AvatarURL: String("a"), 16425 }, 16426 DismissReason: String("dr"), 16427 DismissedAt: &Timestamp{referenceTime}, 16428 }, 16429 Repository: &Repository{ 16430 ID: Int64(1), 16431 URL: String("s"), 16432 Name: String("n"), 16433 }, 16434 } 16435 16436 want := `{ 16437 "action": "a", 16438 "alert": { 16439 "id": 1, 16440 "affected_range": "ar", 16441 "affected_package_name": "apn", 16442 "external_reference": "er", 16443 "external_identifier": "ei", 16444 "fixed_in": "fi", 16445 "dismisser": { 16446 "login": "l", 16447 "id": 1, 16448 "node_id": "n", 16449 "avatar_url": "a", 16450 "url": "u", 16451 "events_url": "e", 16452 "repos_url": "r" 16453 }, 16454 "dismiss_reason": "dr", 16455 "dismissed_at": ` + referenceTimeStr + ` 16456 }, 16457 "repository": { 16458 "id": 1, 16459 "name": "n", 16460 "url": "s" 16461 } 16462 }` 16463 16464 testJSONMarshal(t, u, want) 16465 } 16466 16467 func TestSecretScanningAlertEvent_Marshal(t *testing.T) { 16468 testJSONMarshal(t, &SecretScanningAlertEvent{}, "{}") 16469 16470 u := &SecretScanningAlertEvent{ 16471 Action: String("a"), 16472 Alert: &SecretScanningAlert{ 16473 Number: Int(1), 16474 SecretType: String("t"), 16475 Resolution: String("r"), 16476 ResolvedBy: &User{ 16477 Login: String("l"), 16478 ID: Int64(1), 16479 NodeID: String("n"), 16480 URL: String("u"), 16481 ReposURL: String("r"), 16482 EventsURL: String("e"), 16483 AvatarURL: String("a"), 16484 }, 16485 ResolvedAt: &Timestamp{referenceTime}, 16486 }, 16487 Repo: &Repository{ 16488 ID: Int64(1), 16489 URL: String("s"), 16490 Name: String("n"), 16491 }, 16492 Organization: &Organization{ 16493 BillingEmail: String("be"), 16494 Blog: String("b"), 16495 Company: String("c"), 16496 Email: String("e"), 16497 TwitterUsername: String("tu"), 16498 Location: String("loc"), 16499 Name: String("n"), 16500 Description: String("d"), 16501 IsVerified: Bool(true), 16502 HasOrganizationProjects: Bool(true), 16503 HasRepositoryProjects: Bool(true), 16504 DefaultRepoPermission: String("drp"), 16505 MembersCanCreateRepos: Bool(true), 16506 MembersCanCreateInternalRepos: Bool(true), 16507 MembersCanCreatePrivateRepos: Bool(true), 16508 MembersCanCreatePublicRepos: Bool(false), 16509 MembersAllowedRepositoryCreationType: String("marct"), 16510 MembersCanCreatePages: Bool(true), 16511 MembersCanCreatePublicPages: Bool(false), 16512 MembersCanCreatePrivatePages: Bool(true), 16513 }, 16514 Enterprise: &Enterprise{ 16515 ID: Int(1), 16516 Slug: String("s"), 16517 Name: String("n"), 16518 NodeID: String("nid"), 16519 AvatarURL: String("au"), 16520 Description: String("d"), 16521 WebsiteURL: String("wu"), 16522 HTMLURL: String("hu"), 16523 CreatedAt: &Timestamp{referenceTime}, 16524 UpdatedAt: &Timestamp{referenceTime}, 16525 }, 16526 Sender: &User{ 16527 Login: String("l"), 16528 ID: Int64(1), 16529 NodeID: String("n"), 16530 URL: String("u"), 16531 ReposURL: String("r"), 16532 EventsURL: String("e"), 16533 AvatarURL: String("a"), 16534 }, 16535 Installation: &Installation{ 16536 ID: Int64(1), 16537 NodeID: String("nid"), 16538 AppID: Int64(1), 16539 AppSlug: String("as"), 16540 TargetID: Int64(1), 16541 Account: &User{ 16542 Login: String("l"), 16543 ID: Int64(1), 16544 URL: String("u"), 16545 AvatarURL: String("a"), 16546 GravatarID: String("g"), 16547 Name: String("n"), 16548 Company: String("c"), 16549 Blog: String("b"), 16550 Location: String("l"), 16551 Email: String("e"), 16552 Hireable: Bool(true), 16553 Bio: String("b"), 16554 TwitterUsername: String("t"), 16555 PublicRepos: Int(1), 16556 Followers: Int(1), 16557 Following: Int(1), 16558 CreatedAt: &Timestamp{referenceTime}, 16559 SuspendedAt: &Timestamp{referenceTime}, 16560 }, 16561 AccessTokensURL: String("atu"), 16562 RepositoriesURL: String("ru"), 16563 HTMLURL: String("hu"), 16564 TargetType: String("tt"), 16565 SingleFileName: String("sfn"), 16566 RepositorySelection: String("rs"), 16567 Events: []string{"e"}, 16568 SingleFilePaths: []string{"s"}, 16569 Permissions: &InstallationPermissions{ 16570 Actions: String("a"), 16571 Administration: String("ad"), 16572 Checks: String("c"), 16573 Contents: String("co"), 16574 ContentReferences: String("cr"), 16575 Deployments: String("d"), 16576 Environments: String("e"), 16577 Issues: String("i"), 16578 Metadata: String("md"), 16579 Members: String("m"), 16580 OrganizationAdministration: String("oa"), 16581 OrganizationHooks: String("oh"), 16582 OrganizationPlan: String("op"), 16583 OrganizationPreReceiveHooks: String("opr"), 16584 OrganizationProjects: String("op"), 16585 OrganizationSecrets: String("os"), 16586 OrganizationSelfHostedRunners: String("osh"), 16587 OrganizationUserBlocking: String("oub"), 16588 Packages: String("pkg"), 16589 Pages: String("pg"), 16590 PullRequests: String("pr"), 16591 RepositoryHooks: String("rh"), 16592 RepositoryProjects: String("rp"), 16593 RepositoryPreReceiveHooks: String("rprh"), 16594 Secrets: String("s"), 16595 SecretScanningAlerts: String("ssa"), 16596 SecurityEvents: String("se"), 16597 SingleFile: String("sf"), 16598 Statuses: String("s"), 16599 TeamDiscussions: String("td"), 16600 VulnerabilityAlerts: String("va"), 16601 Workflows: String("w"), 16602 }, 16603 CreatedAt: &Timestamp{referenceTime}, 16604 UpdatedAt: &Timestamp{referenceTime}, 16605 HasMultipleSingleFiles: Bool(false), 16606 SuspendedBy: &User{ 16607 Login: String("l"), 16608 ID: Int64(1), 16609 URL: String("u"), 16610 AvatarURL: String("a"), 16611 GravatarID: String("g"), 16612 Name: String("n"), 16613 Company: String("c"), 16614 Blog: String("b"), 16615 Location: String("l"), 16616 Email: String("e"), 16617 Hireable: Bool(true), 16618 Bio: String("b"), 16619 TwitterUsername: String("t"), 16620 PublicRepos: Int(1), 16621 Followers: Int(1), 16622 Following: Int(1), 16623 CreatedAt: &Timestamp{referenceTime}, 16624 SuspendedAt: &Timestamp{referenceTime}, 16625 }, 16626 SuspendedAt: &Timestamp{referenceTime}, 16627 }, 16628 } 16629 16630 want := `{ 16631 "action": "a", 16632 "alert": { 16633 "number": 1, 16634 "secret_type": "t", 16635 "resolution": "r", 16636 "resolved_by": { 16637 "login": "l", 16638 "id": 1, 16639 "node_id": "n", 16640 "avatar_url": "a", 16641 "url": "u", 16642 "events_url": "e", 16643 "repos_url": "r" 16644 }, 16645 "resolved_at": ` + referenceTimeStr + ` 16646 }, 16647 "repository": { 16648 "id": 1, 16649 "name": "n", 16650 "url": "s" 16651 }, 16652 "organization": { 16653 "name": "n", 16654 "company": "c", 16655 "blog": "b", 16656 "location": "loc", 16657 "email": "e", 16658 "twitter_username": "tu", 16659 "description": "d", 16660 "billing_email": "be", 16661 "is_verified": true, 16662 "has_organization_projects": true, 16663 "has_repository_projects": true, 16664 "default_repository_permission": "drp", 16665 "members_can_create_repositories": true, 16666 "members_can_create_public_repositories": false, 16667 "members_can_create_private_repositories": true, 16668 "members_can_create_internal_repositories": true, 16669 "members_allowed_repository_creation_type": "marct", 16670 "members_can_create_pages": true, 16671 "members_can_create_public_pages": false, 16672 "members_can_create_private_pages": true 16673 }, 16674 "enterprise": { 16675 "id": 1, 16676 "slug": "s", 16677 "name": "n", 16678 "node_id": "nid", 16679 "avatar_url": "au", 16680 "description": "d", 16681 "website_url": "wu", 16682 "html_url": "hu", 16683 "created_at": ` + referenceTimeStr + `, 16684 "updated_at": ` + referenceTimeStr + ` 16685 }, 16686 "sender": { 16687 "login": "l", 16688 "id": 1, 16689 "node_id": "n", 16690 "avatar_url": "a", 16691 "url": "u", 16692 "events_url": "e", 16693 "repos_url": "r" 16694 }, 16695 "installation": { 16696 "id": 1, 16697 "node_id": "nid", 16698 "app_id": 1, 16699 "app_slug": "as", 16700 "target_id": 1, 16701 "account": { 16702 "login": "l", 16703 "id": 1, 16704 "avatar_url": "a", 16705 "gravatar_id": "g", 16706 "name": "n", 16707 "company": "c", 16708 "blog": "b", 16709 "location": "l", 16710 "email": "e", 16711 "hireable": true, 16712 "bio": "b", 16713 "twitter_username": "t", 16714 "public_repos": 1, 16715 "followers": 1, 16716 "following": 1, 16717 "created_at": ` + referenceTimeStr + `, 16718 "suspended_at": ` + referenceTimeStr + `, 16719 "url": "u" 16720 }, 16721 "access_tokens_url": "atu", 16722 "repositories_url": "ru", 16723 "html_url": "hu", 16724 "target_type": "tt", 16725 "single_file_name": "sfn", 16726 "repository_selection": "rs", 16727 "events": [ 16728 "e" 16729 ], 16730 "single_file_paths": [ 16731 "s" 16732 ], 16733 "permissions": { 16734 "actions": "a", 16735 "administration": "ad", 16736 "checks": "c", 16737 "contents": "co", 16738 "content_references": "cr", 16739 "deployments": "d", 16740 "environments": "e", 16741 "issues": "i", 16742 "metadata": "md", 16743 "members": "m", 16744 "organization_administration": "oa", 16745 "organization_hooks": "oh", 16746 "organization_plan": "op", 16747 "organization_pre_receive_hooks": "opr", 16748 "organization_projects": "op", 16749 "organization_secrets": "os", 16750 "organization_self_hosted_runners": "osh", 16751 "organization_user_blocking": "oub", 16752 "packages": "pkg", 16753 "pages": "pg", 16754 "pull_requests": "pr", 16755 "repository_hooks": "rh", 16756 "repository_projects": "rp", 16757 "repository_pre_receive_hooks": "rprh", 16758 "secrets": "s", 16759 "secret_scanning_alerts": "ssa", 16760 "security_events": "se", 16761 "single_file": "sf", 16762 "statuses": "s", 16763 "team_discussions": "td", 16764 "vulnerability_alerts": "va", 16765 "workflows": "w" 16766 }, 16767 "created_at": ` + referenceTimeStr + `, 16768 "updated_at": ` + referenceTimeStr + `, 16769 "has_multiple_single_files": false, 16770 "suspended_by": { 16771 "login": "l", 16772 "id": 1, 16773 "avatar_url": "a", 16774 "gravatar_id": "g", 16775 "name": "n", 16776 "company": "c", 16777 "blog": "b", 16778 "location": "l", 16779 "email": "e", 16780 "hireable": true, 16781 "bio": "b", 16782 "twitter_username": "t", 16783 "public_repos": 1, 16784 "followers": 1, 16785 "following": 1, 16786 "created_at": ` + referenceTimeStr + `, 16787 "suspended_at": ` + referenceTimeStr + `, 16788 "url": "u" 16789 }, 16790 "suspended_at": ` + referenceTimeStr + ` 16791 } 16792 }` 16793 16794 testJSONMarshal(t, u, want) 16795 } 16796 16797 func TestSecurityAdvisoryEvent_Marshal(t *testing.T) { 16798 testJSONMarshal(t, &SecurityAdvisoryEvent{}, "{}") 16799 u := &SecurityAdvisoryEvent{ 16800 Action: String("published"), 16801 SecurityAdvisory: &SecurityAdvisory{ 16802 CVSS: &AdvisoryCVSS{ 16803 Score: Float64(1.0), 16804 VectorString: String("vs"), 16805 }, 16806 CWEs: []*AdvisoryCWEs{ 16807 { 16808 CWEID: String("cweid"), 16809 Name: String("n"), 16810 }, 16811 }, 16812 GHSAID: String("GHSA-rf4j-j272-some"), 16813 Summary: String("Siuuuuuuuuu"), 16814 Description: String("desc"), 16815 Severity: String("moderate"), 16816 Identifiers: []*AdvisoryIdentifier{ 16817 { 16818 Value: String("GHSA-rf4j-j272-some"), 16819 Type: String("GHSA"), 16820 }, 16821 }, 16822 References: []*AdvisoryReference{ 16823 { 16824 URL: String("https://some-url"), 16825 }, 16826 }, 16827 PublishedAt: &Timestamp{referenceTime}, 16828 UpdatedAt: &Timestamp{referenceTime}, 16829 WithdrawnAt: nil, 16830 Vulnerabilities: []*AdvisoryVulnerability{ 16831 { 16832 Package: &VulnerabilityPackage{ 16833 Ecosystem: String("ucl"), 16834 Name: String("penaldo"), 16835 }, 16836 Severity: String("moderate"), 16837 VulnerableVersionRange: String(">= 2.0.0, < 2.0.2"), 16838 FirstPatchedVersion: &FirstPatchedVersion{ 16839 Identifier: String("2.0.2"), 16840 }, 16841 }, 16842 }, 16843 }, 16844 Enterprise: &Enterprise{ 16845 ID: Int(1), 16846 Slug: String("s"), 16847 Name: String("n"), 16848 NodeID: String("nid"), 16849 AvatarURL: String("au"), 16850 Description: String("d"), 16851 WebsiteURL: String("wu"), 16852 HTMLURL: String("hu"), 16853 CreatedAt: &Timestamp{referenceTime}, 16854 UpdatedAt: &Timestamp{referenceTime}, 16855 }, 16856 Installation: &Installation{ 16857 ID: Int64(1), 16858 NodeID: String("nid"), 16859 AppID: Int64(1), 16860 AppSlug: String("as"), 16861 TargetID: Int64(1), 16862 Account: &User{ 16863 Login: String("l"), 16864 ID: Int64(1), 16865 URL: String("u"), 16866 AvatarURL: String("a"), 16867 GravatarID: String("g"), 16868 Name: String("n"), 16869 Company: String("c"), 16870 Blog: String("b"), 16871 Location: String("l"), 16872 Email: String("e"), 16873 Hireable: Bool(true), 16874 Bio: String("b"), 16875 TwitterUsername: String("t"), 16876 PublicRepos: Int(1), 16877 Followers: Int(1), 16878 Following: Int(1), 16879 CreatedAt: &Timestamp{referenceTime}, 16880 SuspendedAt: &Timestamp{referenceTime}, 16881 }, 16882 AccessTokensURL: String("atu"), 16883 RepositoriesURL: String("ru"), 16884 HTMLURL: String("hu"), 16885 TargetType: String("tt"), 16886 SingleFileName: String("sfn"), 16887 RepositorySelection: String("rs"), 16888 Events: []string{"e"}, 16889 SingleFilePaths: []string{"s"}, 16890 Permissions: &InstallationPermissions{ 16891 Actions: String("a"), 16892 Administration: String("ad"), 16893 Checks: String("c"), 16894 Contents: String("co"), 16895 ContentReferences: String("cr"), 16896 Deployments: String("d"), 16897 Environments: String("e"), 16898 Issues: String("i"), 16899 Metadata: String("md"), 16900 Members: String("m"), 16901 OrganizationAdministration: String("oa"), 16902 OrganizationHooks: String("oh"), 16903 OrganizationPlan: String("op"), 16904 OrganizationPreReceiveHooks: String("opr"), 16905 OrganizationProjects: String("op"), 16906 OrganizationSecrets: String("os"), 16907 OrganizationSelfHostedRunners: String("osh"), 16908 OrganizationUserBlocking: String("oub"), 16909 Packages: String("pkg"), 16910 Pages: String("pg"), 16911 PullRequests: String("pr"), 16912 RepositoryHooks: String("rh"), 16913 RepositoryProjects: String("rp"), 16914 RepositoryPreReceiveHooks: String("rprh"), 16915 Secrets: String("s"), 16916 SecretScanningAlerts: String("ssa"), 16917 SecurityEvents: String("se"), 16918 SingleFile: String("sf"), 16919 Statuses: String("s"), 16920 TeamDiscussions: String("td"), 16921 VulnerabilityAlerts: String("va"), 16922 Workflows: String("w"), 16923 }, 16924 CreatedAt: &Timestamp{referenceTime}, 16925 UpdatedAt: &Timestamp{referenceTime}, 16926 HasMultipleSingleFiles: Bool(false), 16927 SuspendedBy: &User{ 16928 Login: String("l"), 16929 ID: Int64(1), 16930 URL: String("u"), 16931 AvatarURL: String("a"), 16932 GravatarID: String("g"), 16933 Name: String("n"), 16934 Company: String("c"), 16935 Blog: String("b"), 16936 Location: String("l"), 16937 Email: String("e"), 16938 Hireable: Bool(true), 16939 Bio: String("b"), 16940 TwitterUsername: String("t"), 16941 PublicRepos: Int(1), 16942 Followers: Int(1), 16943 Following: Int(1), 16944 CreatedAt: &Timestamp{referenceTime}, 16945 SuspendedAt: &Timestamp{referenceTime}, 16946 }, 16947 SuspendedAt: &Timestamp{referenceTime}, 16948 }, 16949 Organization: &Organization{ 16950 BillingEmail: String("be"), 16951 Blog: String("b"), 16952 Company: String("c"), 16953 Email: String("e"), 16954 TwitterUsername: String("tu"), 16955 Location: String("loc"), 16956 Name: String("n"), 16957 Description: String("d"), 16958 IsVerified: Bool(true), 16959 HasOrganizationProjects: Bool(true), 16960 HasRepositoryProjects: Bool(true), 16961 DefaultRepoPermission: String("drp"), 16962 MembersCanCreateRepos: Bool(true), 16963 MembersCanCreateInternalRepos: Bool(true), 16964 MembersCanCreatePrivateRepos: Bool(true), 16965 MembersCanCreatePublicRepos: Bool(false), 16966 MembersAllowedRepositoryCreationType: String("marct"), 16967 MembersCanCreatePages: Bool(true), 16968 MembersCanCreatePublicPages: Bool(false), 16969 MembersCanCreatePrivatePages: Bool(true), 16970 }, 16971 Repository: &Repository{ 16972 ID: Int64(1), 16973 URL: String("s"), 16974 Name: String("n"), 16975 }, 16976 Sender: &User{ 16977 Login: String("l"), 16978 ID: Int64(1), 16979 NodeID: String("n"), 16980 URL: String("u"), 16981 ReposURL: String("r"), 16982 EventsURL: String("e"), 16983 AvatarURL: String("a"), 16984 }, 16985 } 16986 16987 want := `{ 16988 "action": "published", 16989 "security_advisory": { 16990 "ghsa_id": "GHSA-rf4j-j272-some", 16991 "summary": "Siuuuuuuuuu", 16992 "cvss": { 16993 "score": 1.0, 16994 "vector_string": "vs" 16995 }, 16996 "cwes": [ 16997 { 16998 "cwe_id": "cweid", 16999 "name": "n" 17000 } 17001 ], 17002 "description": "desc", 17003 "severity": "moderate", 17004 "identifiers": [ 17005 { 17006 "value": "GHSA-rf4j-j272-some", 17007 "type": "GHSA" 17008 } 17009 ], 17010 "references": [ 17011 { 17012 "url": "https://some-url" 17013 } 17014 ], 17015 "published_at": ` + referenceTimeStr + `, 17016 "updated_at": ` + referenceTimeStr + `, 17017 "withdrawn_at": null, 17018 "vulnerabilities": [ 17019 { 17020 "package": { 17021 "ecosystem": "ucl", 17022 "name": "penaldo" 17023 }, 17024 "severity": "moderate", 17025 "vulnerable_version_range": ">= 2.0.0, < 2.0.2", 17026 "first_patched_version": { 17027 "identifier": "2.0.2" 17028 } 17029 } 17030 ] 17031 }, 17032 "enterprise": { 17033 "id": 1, 17034 "slug": "s", 17035 "name": "n", 17036 "node_id": "nid", 17037 "avatar_url": "au", 17038 "description": "d", 17039 "website_url": "wu", 17040 "html_url": "hu", 17041 "created_at": ` + referenceTimeStr + `, 17042 "updated_at": ` + referenceTimeStr + ` 17043 }, 17044 "installation": { 17045 "id": 1, 17046 "node_id": "nid", 17047 "app_id": 1, 17048 "app_slug": "as", 17049 "target_id": 1, 17050 "account": { 17051 "login": "l", 17052 "id": 1, 17053 "avatar_url": "a", 17054 "gravatar_id": "g", 17055 "name": "n", 17056 "company": "c", 17057 "blog": "b", 17058 "location": "l", 17059 "email": "e", 17060 "hireable": true, 17061 "bio": "b", 17062 "twitter_username": "t", 17063 "public_repos": 1, 17064 "followers": 1, 17065 "following": 1, 17066 "created_at": ` + referenceTimeStr + `, 17067 "suspended_at": ` + referenceTimeStr + `, 17068 "url": "u" 17069 }, 17070 "access_tokens_url": "atu", 17071 "repositories_url": "ru", 17072 "html_url": "hu", 17073 "target_type": "tt", 17074 "single_file_name": "sfn", 17075 "repository_selection": "rs", 17076 "events": [ 17077 "e" 17078 ], 17079 "single_file_paths": [ 17080 "s" 17081 ], 17082 "permissions": { 17083 "actions": "a", 17084 "administration": "ad", 17085 "checks": "c", 17086 "contents": "co", 17087 "content_references": "cr", 17088 "deployments": "d", 17089 "environments": "e", 17090 "issues": "i", 17091 "metadata": "md", 17092 "members": "m", 17093 "organization_administration": "oa", 17094 "organization_hooks": "oh", 17095 "organization_plan": "op", 17096 "organization_pre_receive_hooks": "opr", 17097 "organization_projects": "op", 17098 "organization_secrets": "os", 17099 "organization_self_hosted_runners": "osh", 17100 "organization_user_blocking": "oub", 17101 "packages": "pkg", 17102 "pages": "pg", 17103 "pull_requests": "pr", 17104 "repository_hooks": "rh", 17105 "repository_projects": "rp", 17106 "repository_pre_receive_hooks": "rprh", 17107 "secrets": "s", 17108 "secret_scanning_alerts": "ssa", 17109 "security_events": "se", 17110 "single_file": "sf", 17111 "statuses": "s", 17112 "team_discussions": "td", 17113 "vulnerability_alerts": "va", 17114 "workflows": "w" 17115 }, 17116 "created_at": ` + referenceTimeStr + `, 17117 "updated_at": ` + referenceTimeStr + `, 17118 "has_multiple_single_files": false, 17119 "suspended_by": { 17120 "login": "l", 17121 "id": 1, 17122 "avatar_url": "a", 17123 "gravatar_id": "g", 17124 "name": "n", 17125 "company": "c", 17126 "blog": "b", 17127 "location": "l", 17128 "email": "e", 17129 "hireable": true, 17130 "bio": "b", 17131 "twitter_username": "t", 17132 "public_repos": 1, 17133 "followers": 1, 17134 "following": 1, 17135 "created_at": ` + referenceTimeStr + `, 17136 "suspended_at": ` + referenceTimeStr + `, 17137 "url": "u" 17138 }, 17139 "suspended_at": ` + referenceTimeStr + ` 17140 }, 17141 "organization": { 17142 "name": "n", 17143 "company": "c", 17144 "blog": "b", 17145 "location": "loc", 17146 "email": "e", 17147 "twitter_username": "tu", 17148 "description": "d", 17149 "billing_email": "be", 17150 "is_verified": true, 17151 "has_organization_projects": true, 17152 "has_repository_projects": true, 17153 "default_repository_permission": "drp", 17154 "members_can_create_repositories": true, 17155 "members_can_create_public_repositories": false, 17156 "members_can_create_private_repositories": true, 17157 "members_can_create_internal_repositories": true, 17158 "members_allowed_repository_creation_type": "marct", 17159 "members_can_create_pages": true, 17160 "members_can_create_public_pages": false, 17161 "members_can_create_private_pages": true 17162 }, 17163 "repository": { 17164 "id": 1, 17165 "url": "s", 17166 "name": "n" 17167 }, 17168 "sender": { 17169 "login": "l", 17170 "id": 1, 17171 "node_id": "n", 17172 "avatar_url": "a", 17173 "url": "u", 17174 "events_url": "e", 17175 "repos_url": "r" 17176 } 17177 }` 17178 17179 testJSONMarshal(t, u, want) 17180 } 17181 17182 func TestSecurityAndAnalysisEvent_Marshal(t *testing.T) { 17183 testJSONMarshal(t, &SecurityAndAnalysisEvent{}, "{}") 17184 17185 u := &SecurityAndAnalysisEvent{ 17186 Changes: &SecurityAndAnalysisChange{ 17187 From: &SecurityAndAnalysisChangeFrom{ 17188 SecurityAndAnalysis: &SecurityAndAnalysis{ 17189 AdvancedSecurity: &AdvancedSecurity{ 17190 Status: String("enabled"), 17191 }, 17192 SecretScanning: &SecretScanning{ 17193 Status: String("enabled"), 17194 }, 17195 SecretScanningPushProtection: &SecretScanningPushProtection{ 17196 Status: String("enabled"), 17197 }, 17198 DependabotSecurityUpdates: &DependabotSecurityUpdates{ 17199 Status: String("enabled"), 17200 }, 17201 }, 17202 }, 17203 }, 17204 Enterprise: &Enterprise{ 17205 ID: Int(1), 17206 Slug: String("s"), 17207 Name: String("n"), 17208 NodeID: String("nid"), 17209 AvatarURL: String("au"), 17210 Description: String("d"), 17211 WebsiteURL: String("wu"), 17212 HTMLURL: String("hu"), 17213 CreatedAt: &Timestamp{referenceTime}, 17214 UpdatedAt: &Timestamp{referenceTime}, 17215 }, 17216 Installation: &Installation{ 17217 ID: Int64(1), 17218 NodeID: String("nid"), 17219 AppID: Int64(1), 17220 AppSlug: String("as"), 17221 TargetID: Int64(1), 17222 Account: &User{ 17223 Login: String("l"), 17224 ID: Int64(1), 17225 URL: String("u"), 17226 AvatarURL: String("a"), 17227 GravatarID: String("g"), 17228 Name: String("n"), 17229 Company: String("c"), 17230 Blog: String("b"), 17231 Location: String("l"), 17232 Email: String("e"), 17233 Hireable: Bool(true), 17234 Bio: String("b"), 17235 TwitterUsername: String("t"), 17236 PublicRepos: Int(1), 17237 Followers: Int(1), 17238 Following: Int(1), 17239 CreatedAt: &Timestamp{referenceTime}, 17240 SuspendedAt: &Timestamp{referenceTime}, 17241 }, 17242 AccessTokensURL: String("atu"), 17243 RepositoriesURL: String("ru"), 17244 HTMLURL: String("hu"), 17245 TargetType: String("tt"), 17246 SingleFileName: String("sfn"), 17247 RepositorySelection: String("rs"), 17248 Events: []string{"e"}, 17249 SingleFilePaths: []string{"s"}, 17250 Permissions: &InstallationPermissions{ 17251 Actions: String("a"), 17252 Administration: String("ad"), 17253 Checks: String("c"), 17254 Contents: String("co"), 17255 ContentReferences: String("cr"), 17256 Deployments: String("d"), 17257 Environments: String("e"), 17258 Issues: String("i"), 17259 Metadata: String("md"), 17260 Members: String("m"), 17261 OrganizationAdministration: String("oa"), 17262 OrganizationHooks: String("oh"), 17263 OrganizationPlan: String("op"), 17264 OrganizationPreReceiveHooks: String("opr"), 17265 OrganizationProjects: String("op"), 17266 OrganizationSecrets: String("os"), 17267 OrganizationSelfHostedRunners: String("osh"), 17268 OrganizationUserBlocking: String("oub"), 17269 Packages: String("pkg"), 17270 Pages: String("pg"), 17271 PullRequests: String("pr"), 17272 RepositoryHooks: String("rh"), 17273 RepositoryProjects: String("rp"), 17274 RepositoryPreReceiveHooks: String("rprh"), 17275 Secrets: String("s"), 17276 SecretScanningAlerts: String("ssa"), 17277 SecurityEvents: String("se"), 17278 SingleFile: String("sf"), 17279 Statuses: String("s"), 17280 TeamDiscussions: String("td"), 17281 VulnerabilityAlerts: String("va"), 17282 Workflows: String("w"), 17283 }, 17284 CreatedAt: &Timestamp{referenceTime}, 17285 UpdatedAt: &Timestamp{referenceTime}, 17286 HasMultipleSingleFiles: Bool(false), 17287 SuspendedBy: &User{ 17288 Login: String("l"), 17289 ID: Int64(1), 17290 URL: String("u"), 17291 AvatarURL: String("a"), 17292 GravatarID: String("g"), 17293 Name: String("n"), 17294 Company: String("c"), 17295 Blog: String("b"), 17296 Location: String("l"), 17297 Email: String("e"), 17298 Hireable: Bool(true), 17299 Bio: String("b"), 17300 TwitterUsername: String("t"), 17301 PublicRepos: Int(1), 17302 Followers: Int(1), 17303 Following: Int(1), 17304 CreatedAt: &Timestamp{referenceTime}, 17305 SuspendedAt: &Timestamp{referenceTime}, 17306 }, 17307 SuspendedAt: &Timestamp{referenceTime}, 17308 }, 17309 Organization: &Organization{ 17310 BillingEmail: String("be"), 17311 Blog: String("b"), 17312 Company: String("c"), 17313 Email: String("e"), 17314 TwitterUsername: String("tu"), 17315 Location: String("loc"), 17316 Name: String("n"), 17317 Description: String("d"), 17318 IsVerified: Bool(true), 17319 HasOrganizationProjects: Bool(true), 17320 HasRepositoryProjects: Bool(true), 17321 DefaultRepoPermission: String("drp"), 17322 MembersCanCreateRepos: Bool(true), 17323 MembersCanCreateInternalRepos: Bool(true), 17324 MembersCanCreatePrivateRepos: Bool(true), 17325 MembersCanCreatePublicRepos: Bool(false), 17326 MembersAllowedRepositoryCreationType: String("marct"), 17327 MembersCanCreatePages: Bool(true), 17328 MembersCanCreatePublicPages: Bool(false), 17329 MembersCanCreatePrivatePages: Bool(true), 17330 }, 17331 Repository: &Repository{ 17332 ID: Int64(1), 17333 URL: String("s"), 17334 Name: String("n"), 17335 }, 17336 Sender: &User{ 17337 Login: String("l"), 17338 ID: Int64(1), 17339 NodeID: String("n"), 17340 URL: String("u"), 17341 ReposURL: String("r"), 17342 EventsURL: String("e"), 17343 AvatarURL: String("a"), 17344 }, 17345 } 17346 17347 want := `{ 17348 "changes": { 17349 "from": { 17350 "security_and_analysis": { 17351 "advanced_security": { 17352 "status": "enabled" 17353 }, 17354 "secret_scanning": { 17355 "status": "enabled" 17356 }, 17357 "secret_scanning_push_protection": { 17358 "status": "enabled" 17359 }, 17360 "dependabot_security_updates": { 17361 "status": "enabled" 17362 } 17363 } 17364 } 17365 }, 17366 "enterprise": { 17367 "id": 1, 17368 "slug": "s", 17369 "name": "n", 17370 "node_id": "nid", 17371 "avatar_url": "au", 17372 "description": "d", 17373 "website_url": "wu", 17374 "html_url": "hu", 17375 "created_at": ` + referenceTimeStr + `, 17376 "updated_at": ` + referenceTimeStr + ` 17377 }, 17378 "installation": { 17379 "id": 1, 17380 "node_id": "nid", 17381 "app_id": 1, 17382 "app_slug": "as", 17383 "target_id": 1, 17384 "account": { 17385 "login": "l", 17386 "id": 1, 17387 "avatar_url": "a", 17388 "gravatar_id": "g", 17389 "name": "n", 17390 "company": "c", 17391 "blog": "b", 17392 "location": "l", 17393 "email": "e", 17394 "hireable": true, 17395 "bio": "b", 17396 "twitter_username": "t", 17397 "public_repos": 1, 17398 "followers": 1, 17399 "following": 1, 17400 "created_at": ` + referenceTimeStr + `, 17401 "suspended_at": ` + referenceTimeStr + `, 17402 "url": "u" 17403 }, 17404 "access_tokens_url": "atu", 17405 "repositories_url": "ru", 17406 "html_url": "hu", 17407 "target_type": "tt", 17408 "single_file_name": "sfn", 17409 "repository_selection": "rs", 17410 "events": [ 17411 "e" 17412 ], 17413 "single_file_paths": [ 17414 "s" 17415 ], 17416 "permissions": { 17417 "actions": "a", 17418 "administration": "ad", 17419 "checks": "c", 17420 "contents": "co", 17421 "content_references": "cr", 17422 "deployments": "d", 17423 "environments": "e", 17424 "issues": "i", 17425 "metadata": "md", 17426 "members": "m", 17427 "organization_administration": "oa", 17428 "organization_hooks": "oh", 17429 "organization_plan": "op", 17430 "organization_pre_receive_hooks": "opr", 17431 "organization_projects": "op", 17432 "organization_secrets": "os", 17433 "organization_self_hosted_runners": "osh", 17434 "organization_user_blocking": "oub", 17435 "packages": "pkg", 17436 "pages": "pg", 17437 "pull_requests": "pr", 17438 "repository_hooks": "rh", 17439 "repository_projects": "rp", 17440 "repository_pre_receive_hooks": "rprh", 17441 "secrets": "s", 17442 "secret_scanning_alerts": "ssa", 17443 "security_events": "se", 17444 "single_file": "sf", 17445 "statuses": "s", 17446 "team_discussions": "td", 17447 "vulnerability_alerts": "va", 17448 "workflows": "w" 17449 }, 17450 "created_at": ` + referenceTimeStr + `, 17451 "updated_at": ` + referenceTimeStr + `, 17452 "has_multiple_single_files": false, 17453 "suspended_by": { 17454 "login": "l", 17455 "id": 1, 17456 "avatar_url": "a", 17457 "gravatar_id": "g", 17458 "name": "n", 17459 "company": "c", 17460 "blog": "b", 17461 "location": "l", 17462 "email": "e", 17463 "hireable": true, 17464 "bio": "b", 17465 "twitter_username": "t", 17466 "public_repos": 1, 17467 "followers": 1, 17468 "following": 1, 17469 "created_at": ` + referenceTimeStr + `, 17470 "suspended_at": ` + referenceTimeStr + `, 17471 "url": "u" 17472 }, 17473 "suspended_at": ` + referenceTimeStr + ` 17474 }, 17475 "organization": { 17476 "name": "n", 17477 "company": "c", 17478 "blog": "b", 17479 "location": "loc", 17480 "email": "e", 17481 "twitter_username": "tu", 17482 "description": "d", 17483 "billing_email": "be", 17484 "is_verified": true, 17485 "has_organization_projects": true, 17486 "has_repository_projects": true, 17487 "default_repository_permission": "drp", 17488 "members_can_create_repositories": true, 17489 "members_can_create_public_repositories": false, 17490 "members_can_create_private_repositories": true, 17491 "members_can_create_internal_repositories": true, 17492 "members_allowed_repository_creation_type": "marct", 17493 "members_can_create_pages": true, 17494 "members_can_create_public_pages": false, 17495 "members_can_create_private_pages": true 17496 }, 17497 "repository": { 17498 "id": 1, 17499 "url": "s", 17500 "name": "n" 17501 }, 17502 "sender": { 17503 "login": "l", 17504 "id": 1, 17505 "node_id": "n", 17506 "avatar_url": "a", 17507 "url": "u", 17508 "events_url": "e", 17509 "repos_url": "r" 17510 }, 17511 "target_type": "running" 17512 }` 17513 17514 testJSONMarshal(t, u, want) 17515 } 17516 17517 func TestCodeScanningAlertEvent_Marshal(t *testing.T) { 17518 testJSONMarshal(t, &CodeScanningAlertEvent{}, "{}") 17519 17520 u := &CodeScanningAlertEvent{ 17521 Action: String("reopened"), 17522 Alert: &Alert{ 17523 Number: Int(10), 17524 Rule: &Rule{ 17525 ID: String("Style/FrozenStringLiteralComment"), 17526 Severity: String("note"), 17527 Description: String("desc"), 17528 FullDescription: String("full desc"), 17529 Tags: []string{"style"}, 17530 Help: String("help"), 17531 }, 17532 Tool: &Tool{ 17533 Name: String("Rubocop"), 17534 Version: nil, 17535 }, 17536 CreatedAt: &Timestamp{referenceTime}, 17537 UpdatedAt: &Timestamp{referenceTime}, 17538 FixedAt: nil, 17539 State: String("open"), 17540 URL: String("a"), 17541 HTMLURL: String("a"), 17542 Instances: []*MostRecentInstance{ 17543 { 17544 Ref: String("refs/heads/main"), 17545 AnalysisKey: String(".github/workflows/workflow.yml:upload"), 17546 Environment: String("{}"), 17547 State: String("open"), 17548 }, 17549 }, 17550 DismissedBy: nil, 17551 DismissedAt: nil, 17552 DismissedReason: nil, 17553 }, 17554 Ref: String("refs/heads/main"), 17555 CommitOID: String("d6e4c75c141dbacecc279b721b8bsomeSHA"), 17556 Repo: &Repository{ 17557 ID: Int64(1234234535), 17558 NodeID: String("MDEwOlJlcG9zaXRvcnkxODY4NT=="), 17559 Owner: &User{ 17560 Login: String("Codertocat"), 17561 ID: Int64(21031067), 17562 NodeID: String("MDQ6VXNlcjIxMDMxMDY3"), 17563 AvatarURL: String("a"), 17564 GravatarID: String(""), 17565 URL: String("a"), 17566 HTMLURL: String("a"), 17567 Type: String("User"), 17568 SiteAdmin: Bool(false), 17569 FollowersURL: String("a"), 17570 FollowingURL: String("a"), 17571 EventsURL: String("a"), 17572 GistsURL: String("a"), 17573 OrganizationsURL: String("a"), 17574 ReceivedEventsURL: String("a"), 17575 ReposURL: String("a"), 17576 StarredURL: String("a"), 17577 SubscriptionsURL: String("a"), 17578 }, 17579 HTMLURL: String("a"), 17580 Name: String("Hello-World"), 17581 FullName: String("Codertocat/Hello-World"), 17582 Description: nil, 17583 Fork: Bool(false), 17584 Homepage: nil, 17585 DefaultBranch: String("main"), 17586 CreatedAt: &Timestamp{referenceTime}, 17587 PushedAt: &Timestamp{referenceTime}, 17588 UpdatedAt: &Timestamp{referenceTime}, 17589 CloneURL: String("a"), 17590 GitURL: String("a"), 17591 MirrorURL: nil, 17592 SSHURL: String("a"), 17593 SVNURL: String("a"), 17594 Language: nil, 17595 ForksCount: Int(0), 17596 OpenIssuesCount: Int(2), 17597 OpenIssues: Int(2), 17598 StargazersCount: Int(0), 17599 WatchersCount: Int(0), 17600 Watchers: Int(0), 17601 Size: Int(0), 17602 Archived: Bool(false), 17603 Disabled: Bool(false), 17604 License: nil, 17605 Private: Bool(false), 17606 HasIssues: Bool(true), 17607 HasWiki: Bool(true), 17608 HasPages: Bool(true), 17609 HasProjects: Bool(true), 17610 HasDownloads: Bool(true), 17611 URL: String("a"), 17612 ArchiveURL: String("a"), 17613 AssigneesURL: String("a"), 17614 BlobsURL: String("a"), 17615 BranchesURL: String("a"), 17616 CollaboratorsURL: String("a"), 17617 CommentsURL: String("a"), 17618 CommitsURL: String("a"), 17619 CompareURL: String("a"), 17620 ContentsURL: String("a"), 17621 ContributorsURL: String("a"), 17622 DeploymentsURL: String("a"), 17623 DownloadsURL: String("a"), 17624 EventsURL: String("a"), 17625 ForksURL: String("a"), 17626 GitCommitsURL: String("a"), 17627 GitRefsURL: String("a"), 17628 GitTagsURL: String("a"), 17629 HooksURL: String("a"), 17630 IssueCommentURL: String("a"), 17631 IssueEventsURL: String("a"), 17632 IssuesURL: String("a"), 17633 KeysURL: String("a"), 17634 LabelsURL: String("a"), 17635 LanguagesURL: String("a"), 17636 MergesURL: String("a"), 17637 MilestonesURL: String("a"), 17638 NotificationsURL: String("a"), 17639 PullsURL: String("a"), 17640 ReleasesURL: String("a"), 17641 StargazersURL: String("a"), 17642 StatusesURL: String("a"), 17643 SubscribersURL: String("a"), 17644 SubscriptionURL: String("a"), 17645 TagsURL: String("a"), 17646 TreesURL: String("a"), 17647 TeamsURL: String("a"), 17648 }, 17649 Org: &Organization{ 17650 Login: String("Octocoders"), 17651 ID: Int64(6), 17652 NodeID: String("MDEyOk9yZ2FuaXphdGlvbjY="), 17653 AvatarURL: String("a"), 17654 Description: String(""), 17655 URL: String("a"), 17656 EventsURL: String("a"), 17657 HooksURL: String("a"), 17658 IssuesURL: String("a"), 17659 MembersURL: String("a"), 17660 PublicMembersURL: String("a"), 17661 ReposURL: String("a"), 17662 }, 17663 Sender: &User{ 17664 Login: String("github"), 17665 ID: Int64(9919), 17666 NodeID: String("MDEyOk9yZ2FuaXphdGlvbjk5MTk="), 17667 AvatarURL: String("a"), 17668 HTMLURL: String("a"), 17669 GravatarID: String(""), 17670 Type: String("Organization"), 17671 SiteAdmin: Bool(false), 17672 URL: String("a"), 17673 EventsURL: String("a"), 17674 FollowingURL: String("a"), 17675 FollowersURL: String("a"), 17676 GistsURL: String("a"), 17677 OrganizationsURL: String("a"), 17678 ReceivedEventsURL: String("a"), 17679 ReposURL: String("a"), 17680 StarredURL: String("a"), 17681 SubscriptionsURL: String("a"), 17682 }, 17683 } 17684 17685 want := `{ 17686 "action": "reopened", 17687 "alert": { 17688 "number": 10, 17689 "created_at": ` + referenceTimeStr + `, 17690 "updated_at": ` + referenceTimeStr + `, 17691 "url": "a", 17692 "html_url": "a", 17693 "instances": [ 17694 { 17695 "ref": "refs/heads/main", 17696 "analysis_key": ".github/workflows/workflow.yml:upload", 17697 "environment": "{}", 17698 "state": "open" 17699 } 17700 ], 17701 "state": "open", 17702 "fixed_at": null, 17703 "dismissed_by": null, 17704 "dismissed_at": null, 17705 "dismissed_reason": null, 17706 "rule": { 17707 "id": "Style/FrozenStringLiteralComment", 17708 "severity": "note", 17709 "description": "desc", 17710 "full_description": "full desc", 17711 "tags": [ 17712 "style" 17713 ], 17714 "help": "help" 17715 }, 17716 "tool": { 17717 "name": "Rubocop", 17718 "version": null 17719 } 17720 }, 17721 "ref": "refs/heads/main", 17722 "commit_oid": "d6e4c75c141dbacecc279b721b8bsomeSHA", 17723 "repository": { 17724 "id": 1234234535, 17725 "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NT==", 17726 "name": "Hello-World", 17727 "full_name": "Codertocat/Hello-World", 17728 "private": false, 17729 "owner": { 17730 "login": "Codertocat", 17731 "id": 21031067, 17732 "node_id": "MDQ6VXNlcjIxMDMxMDY3", 17733 "avatar_url": "a", 17734 "gravatar_id": "", 17735 "url": "a", 17736 "html_url": "a", 17737 "followers_url": "a", 17738 "following_url": "a", 17739 "gists_url": "a", 17740 "starred_url": "a", 17741 "subscriptions_url": "a", 17742 "organizations_url": "a", 17743 "repos_url": "a", 17744 "events_url": "a", 17745 "received_events_url": "a", 17746 "type": "User", 17747 "site_admin": false 17748 }, 17749 "html_url": "a", 17750 "description": null, 17751 "fork": false, 17752 "url": "a", 17753 "forks_url": "a", 17754 "keys_url": "a", 17755 "collaborators_url": "a", 17756 "teams_url": "a", 17757 "hooks_url": "a", 17758 "issue_events_url": "a", 17759 "events_url": "a", 17760 "assignees_url": "a", 17761 "branches_url": "a", 17762 "tags_url": "a", 17763 "blobs_url": "a", 17764 "git_tags_url": "a", 17765 "git_refs_url": "a", 17766 "trees_url": "a", 17767 "statuses_url": "a", 17768 "languages_url": "a", 17769 "stargazers_url": "a", 17770 "contributors_url": "a", 17771 "subscribers_url": "a", 17772 "subscription_url": "a", 17773 "commits_url": "a", 17774 "git_commits_url": "a", 17775 "comments_url": "a", 17776 "issue_comment_url": "a", 17777 "contents_url": "a", 17778 "compare_url": "a", 17779 "merges_url": "a", 17780 "archive_url": "a", 17781 "downloads_url": "a", 17782 "issues_url": "a", 17783 "pulls_url": "a", 17784 "milestones_url": "a", 17785 "notifications_url": "a", 17786 "labels_url": "a", 17787 "releases_url": "a", 17788 "deployments_url": "a", 17789 "created_at": ` + referenceTimeStr + `, 17790 "updated_at": ` + referenceTimeStr + `, 17791 "pushed_at": ` + referenceTimeStr + `, 17792 "git_url": "a", 17793 "ssh_url": "a", 17794 "clone_url": "a", 17795 "svn_url": "a", 17796 "homepage": null, 17797 "size": 0, 17798 "stargazers_count": 0, 17799 "watchers_count": 0, 17800 "language": null, 17801 "has_issues": true, 17802 "has_projects": true, 17803 "has_downloads": true, 17804 "has_wiki": true, 17805 "has_pages": true, 17806 "forks_count": 0, 17807 "mirror_url": null, 17808 "archived": false, 17809 "disabled": false, 17810 "open_issues_count": 2, 17811 "license": null, 17812 "forks": 0, 17813 "open_issues": 2, 17814 "watchers": 0, 17815 "default_branch": "main" 17816 }, 17817 "organization": { 17818 "login": "Octocoders", 17819 "id": 6, 17820 "node_id": "MDEyOk9yZ2FuaXphdGlvbjY=", 17821 "url": "a", 17822 "repos_url": "a", 17823 "events_url": "a", 17824 "hooks_url": "a", 17825 "issues_url": "a", 17826 "members_url": "a", 17827 "public_members_url": "a", 17828 "avatar_url": "a", 17829 "description": "" 17830 }, 17831 "sender": { 17832 "login": "github", 17833 "id": 9919, 17834 "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", 17835 "avatar_url": "a", 17836 "gravatar_id": "", 17837 "url": "a", 17838 "html_url": "a", 17839 "followers_url": "a", 17840 "following_url": "a", 17841 "gists_url": "a", 17842 "starred_url": "a", 17843 "subscriptions_url": "a", 17844 "organizations_url": "a", 17845 "repos_url": "a", 17846 "events_url": "a", 17847 "received_events_url": "a", 17848 "type": "Organization", 17849 "site_admin": false 17850 } 17851 }` 17852 17853 testJSONMarshal(t, u, want) 17854 }