github.com/google/go-github/v64@v64.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 Topics: &EditTopics{ 95 From: []string{"topic1", "topic2"}, 96 }, 97 } 98 99 want := `{ 100 "repository": { 101 "name": { 102 "from": "old-repo-name" 103 } 104 }, 105 "topics": { 106 "from": [ 107 "topic1", 108 "topic2" 109 ] 110 } 111 }` 112 113 testJSONMarshal(t, u, want) 114 } 115 116 func TestEditChange_Marshal_TransferFromUser(t *testing.T) { 117 testJSONMarshal(t, &EditChange{}, "{}") 118 119 u := &EditChange{ 120 Owner: &EditOwner{ 121 OwnerInfo: &OwnerInfo{ 122 User: &User{ 123 Login: String("l"), 124 ID: Int64(1), 125 NodeID: String("n"), 126 URL: String("u"), 127 ReposURL: String("r"), 128 EventsURL: String("e"), 129 AvatarURL: String("a"), 130 }, 131 }, 132 }, 133 } 134 135 want := `{ 136 "owner": { 137 "from": { 138 "user": { 139 "login": "l", 140 "id": 1, 141 "node_id": "n", 142 "avatar_url": "a", 143 "url": "u", 144 "repos_url": "r", 145 "events_url": "e" 146 } 147 } 148 } 149 }` 150 151 testJSONMarshal(t, u, want) 152 } 153 154 func TestEditChange_Marshal_TransferFromOrg(t *testing.T) { 155 testJSONMarshal(t, &EditChange{}, "{}") 156 157 u := &EditChange{ 158 Owner: &EditOwner{ 159 OwnerInfo: &OwnerInfo{ 160 Org: &User{ 161 Login: String("l"), 162 ID: Int64(1), 163 NodeID: String("n"), 164 URL: String("u"), 165 ReposURL: String("r"), 166 EventsURL: String("e"), 167 AvatarURL: String("a"), 168 }, 169 }, 170 }, 171 } 172 173 want := `{ 174 "owner": { 175 "from": { 176 "organization": { 177 "login": "l", 178 "id": 1, 179 "node_id": "n", 180 "avatar_url": "a", 181 "url": "u", 182 "repos_url": "r", 183 "events_url": "e" 184 } 185 } 186 } 187 }` 188 189 testJSONMarshal(t, u, want) 190 } 191 192 func TestProjectChange_Marshal_NameChange(t *testing.T) { 193 testJSONMarshal(t, &ProjectChange{}, "{}") 194 195 u := &ProjectChange{ 196 Name: &ProjectName{From: String("NameFrom")}, 197 Body: nil, 198 } 199 200 want := `{ 201 "name": { 202 "from": "NameFrom" 203 } 204 }` 205 206 testJSONMarshal(t, u, want) 207 } 208 209 func TestProjectChange_Marshal_BodyChange(t *testing.T) { 210 testJSONMarshal(t, &ProjectChange{}, "{}") 211 212 u := &ProjectChange{ 213 Name: nil, 214 Body: &ProjectBody{From: String("BodyFrom")}, 215 } 216 217 want := `{ 218 "body": { 219 "from": "BodyFrom" 220 } 221 }` 222 223 testJSONMarshal(t, u, want) 224 } 225 226 func TestProjectCardChange_Marshal_NoteChange(t *testing.T) { 227 testJSONMarshal(t, &ProjectCardChange{}, "{}") 228 229 u := &ProjectCardChange{ 230 Note: &ProjectCardNote{From: String("NoteFrom")}, 231 } 232 233 want := `{ 234 "note": { 235 "from": "NoteFrom" 236 } 237 }` 238 239 testJSONMarshal(t, u, want) 240 } 241 242 func TestProjectColumnChange_Marshal_NameChange(t *testing.T) { 243 testJSONMarshal(t, &ProjectColumnChange{}, "{}") 244 245 u := &ProjectColumnChange{ 246 Name: &ProjectColumnName{From: String("NameFrom")}, 247 } 248 249 want := `{ 250 "name": { 251 "from": "NameFrom" 252 } 253 }` 254 255 testJSONMarshal(t, u, want) 256 } 257 258 func TestTeamAddEvent_Marshal(t *testing.T) { 259 testJSONMarshal(t, &TeamAddEvent{}, "{}") 260 261 u := &TeamAddEvent{ 262 Team: &Team{ 263 ID: Int64(1), 264 NodeID: String("n"), 265 Name: String("n"), 266 Description: String("d"), 267 URL: String("u"), 268 Slug: String("s"), 269 Permission: String("p"), 270 Privacy: String("p"), 271 MembersCount: Int(1), 272 ReposCount: Int(1), 273 MembersURL: String("m"), 274 RepositoriesURL: String("r"), 275 Organization: &Organization{ 276 Login: String("l"), 277 ID: Int64(1), 278 NodeID: String("n"), 279 AvatarURL: String("a"), 280 HTMLURL: String("h"), 281 Name: String("n"), 282 Company: String("c"), 283 Blog: String("b"), 284 Location: String("l"), 285 Email: String("e"), 286 }, 287 Parent: &Team{ 288 ID: Int64(1), 289 NodeID: String("n"), 290 Name: String("n"), 291 Description: String("d"), 292 URL: String("u"), 293 Slug: String("s"), 294 Permission: String("p"), 295 Privacy: String("p"), 296 MembersCount: Int(1), 297 ReposCount: Int(1), 298 }, 299 LDAPDN: String("l"), 300 }, 301 Repo: &Repository{ 302 ID: Int64(1), 303 URL: String("s"), 304 Name: String("n"), 305 }, 306 Org: &Organization{ 307 BillingEmail: String("be"), 308 Blog: String("b"), 309 Company: String("c"), 310 Email: String("e"), 311 TwitterUsername: String("tu"), 312 Location: String("loc"), 313 Name: String("n"), 314 Description: String("d"), 315 IsVerified: Bool(true), 316 HasOrganizationProjects: Bool(true), 317 HasRepositoryProjects: Bool(true), 318 DefaultRepoPermission: String("drp"), 319 MembersCanCreateRepos: Bool(true), 320 MembersCanCreateInternalRepos: Bool(true), 321 MembersCanCreatePrivateRepos: Bool(true), 322 MembersCanCreatePublicRepos: Bool(false), 323 MembersAllowedRepositoryCreationType: String("marct"), 324 MembersCanCreatePages: Bool(true), 325 MembersCanCreatePublicPages: Bool(false), 326 MembersCanCreatePrivatePages: Bool(true), 327 }, 328 Sender: &User{ 329 Login: String("l"), 330 ID: Int64(1), 331 NodeID: String("n"), 332 URL: String("u"), 333 ReposURL: String("r"), 334 EventsURL: String("e"), 335 AvatarURL: String("a"), 336 }, 337 Installation: &Installation{ 338 ID: Int64(1), 339 NodeID: String("nid"), 340 AppID: Int64(1), 341 AppSlug: String("as"), 342 TargetID: Int64(1), 343 Account: &User{ 344 Login: String("l"), 345 ID: Int64(1), 346 URL: String("u"), 347 AvatarURL: String("a"), 348 GravatarID: String("g"), 349 Name: String("n"), 350 Company: String("c"), 351 Blog: String("b"), 352 Location: String("l"), 353 Email: String("e"), 354 Hireable: Bool(true), 355 Bio: String("b"), 356 TwitterUsername: String("t"), 357 PublicRepos: Int(1), 358 Followers: Int(1), 359 Following: Int(1), 360 CreatedAt: &Timestamp{referenceTime}, 361 SuspendedAt: &Timestamp{referenceTime}, 362 }, 363 AccessTokensURL: String("atu"), 364 RepositoriesURL: String("ru"), 365 HTMLURL: String("hu"), 366 TargetType: String("tt"), 367 SingleFileName: String("sfn"), 368 RepositorySelection: String("rs"), 369 Events: []string{"e"}, 370 SingleFilePaths: []string{"s"}, 371 Permissions: &InstallationPermissions{ 372 Actions: String("a"), 373 Administration: String("ad"), 374 Checks: String("c"), 375 Contents: String("co"), 376 ContentReferences: String("cr"), 377 Deployments: String("d"), 378 Environments: String("e"), 379 Issues: String("i"), 380 Metadata: String("md"), 381 Members: String("m"), 382 OrganizationAdministration: String("oa"), 383 OrganizationHooks: String("oh"), 384 OrganizationPlan: String("op"), 385 OrganizationPreReceiveHooks: String("opr"), 386 OrganizationProjects: String("op"), 387 OrganizationSecrets: String("os"), 388 OrganizationSelfHostedRunners: String("osh"), 389 OrganizationUserBlocking: String("oub"), 390 Packages: String("pkg"), 391 Pages: String("pg"), 392 PullRequests: String("pr"), 393 RepositoryHooks: String("rh"), 394 RepositoryProjects: String("rp"), 395 RepositoryPreReceiveHooks: String("rprh"), 396 Secrets: String("s"), 397 SecretScanningAlerts: String("ssa"), 398 SecurityEvents: String("se"), 399 SingleFile: String("sf"), 400 Statuses: String("s"), 401 TeamDiscussions: String("td"), 402 VulnerabilityAlerts: String("va"), 403 Workflows: String("w"), 404 }, 405 CreatedAt: &Timestamp{referenceTime}, 406 UpdatedAt: &Timestamp{referenceTime}, 407 HasMultipleSingleFiles: Bool(false), 408 SuspendedBy: &User{ 409 Login: String("l"), 410 ID: Int64(1), 411 URL: String("u"), 412 AvatarURL: String("a"), 413 GravatarID: String("g"), 414 Name: String("n"), 415 Company: String("c"), 416 Blog: String("b"), 417 Location: String("l"), 418 Email: String("e"), 419 Hireable: Bool(true), 420 Bio: String("b"), 421 TwitterUsername: String("t"), 422 PublicRepos: Int(1), 423 Followers: Int(1), 424 Following: Int(1), 425 CreatedAt: &Timestamp{referenceTime}, 426 SuspendedAt: &Timestamp{referenceTime}, 427 }, 428 SuspendedAt: &Timestamp{referenceTime}, 429 }, 430 } 431 432 want := `{ 433 "team": { 434 "id": 1, 435 "node_id": "n", 436 "name": "n", 437 "description": "d", 438 "url": "u", 439 "slug": "s", 440 "permission": "p", 441 "privacy": "p", 442 "members_count": 1, 443 "repos_count": 1, 444 "organization": { 445 "login": "l", 446 "id": 1, 447 "node_id": "n", 448 "avatar_url": "a", 449 "html_url": "h", 450 "name": "n", 451 "company": "c", 452 "blog": "b", 453 "location": "l", 454 "email": "e" 455 }, 456 "members_url": "m", 457 "repositories_url": "r", 458 "parent": { 459 "id": 1, 460 "node_id": "n", 461 "name": "n", 462 "description": "d", 463 "url": "u", 464 "slug": "s", 465 "permission": "p", 466 "privacy": "p", 467 "members_count": 1, 468 "repos_count": 1 469 }, 470 "ldap_dn": "l" 471 }, 472 "repository": { 473 "id": 1, 474 "name": "n", 475 "url": "s" 476 }, 477 "organization": { 478 "name": "n", 479 "company": "c", 480 "blog": "b", 481 "location": "loc", 482 "email": "e", 483 "twitter_username": "tu", 484 "description": "d", 485 "billing_email": "be", 486 "is_verified": true, 487 "has_organization_projects": true, 488 "has_repository_projects": true, 489 "default_repository_permission": "drp", 490 "members_can_create_repositories": true, 491 "members_can_create_public_repositories": false, 492 "members_can_create_private_repositories": true, 493 "members_can_create_internal_repositories": true, 494 "members_allowed_repository_creation_type": "marct", 495 "members_can_create_pages": true, 496 "members_can_create_public_pages": false, 497 "members_can_create_private_pages": true 498 }, 499 "sender": { 500 "login": "l", 501 "id": 1, 502 "node_id": "n", 503 "avatar_url": "a", 504 "url": "u", 505 "events_url": "e", 506 "repos_url": "r" 507 }, 508 "installation": { 509 "id": 1, 510 "node_id": "nid", 511 "app_id": 1, 512 "app_slug": "as", 513 "target_id": 1, 514 "account": { 515 "login": "l", 516 "id": 1, 517 "avatar_url": "a", 518 "gravatar_id": "g", 519 "name": "n", 520 "company": "c", 521 "blog": "b", 522 "location": "l", 523 "email": "e", 524 "hireable": true, 525 "bio": "b", 526 "twitter_username": "t", 527 "public_repos": 1, 528 "followers": 1, 529 "following": 1, 530 "created_at": ` + referenceTimeStr + `, 531 "suspended_at": ` + referenceTimeStr + `, 532 "url": "u" 533 }, 534 "access_tokens_url": "atu", 535 "repositories_url": "ru", 536 "html_url": "hu", 537 "target_type": "tt", 538 "single_file_name": "sfn", 539 "repository_selection": "rs", 540 "events": [ 541 "e" 542 ], 543 "single_file_paths": [ 544 "s" 545 ], 546 "permissions": { 547 "actions": "a", 548 "administration": "ad", 549 "checks": "c", 550 "contents": "co", 551 "content_references": "cr", 552 "deployments": "d", 553 "environments": "e", 554 "issues": "i", 555 "metadata": "md", 556 "members": "m", 557 "organization_administration": "oa", 558 "organization_hooks": "oh", 559 "organization_plan": "op", 560 "organization_pre_receive_hooks": "opr", 561 "organization_projects": "op", 562 "organization_secrets": "os", 563 "organization_self_hosted_runners": "osh", 564 "organization_user_blocking": "oub", 565 "packages": "pkg", 566 "pages": "pg", 567 "pull_requests": "pr", 568 "repository_hooks": "rh", 569 "repository_projects": "rp", 570 "repository_pre_receive_hooks": "rprh", 571 "secrets": "s", 572 "secret_scanning_alerts": "ssa", 573 "security_events": "se", 574 "single_file": "sf", 575 "statuses": "s", 576 "team_discussions": "td", 577 "vulnerability_alerts": "va", 578 "workflows": "w" 579 }, 580 "created_at": ` + referenceTimeStr + `, 581 "updated_at": ` + referenceTimeStr + `, 582 "has_multiple_single_files": false, 583 "suspended_by": { 584 "login": "l", 585 "id": 1, 586 "avatar_url": "a", 587 "gravatar_id": "g", 588 "name": "n", 589 "company": "c", 590 "blog": "b", 591 "location": "l", 592 "email": "e", 593 "hireable": true, 594 "bio": "b", 595 "twitter_username": "t", 596 "public_repos": 1, 597 "followers": 1, 598 "following": 1, 599 "created_at": ` + referenceTimeStr + `, 600 "suspended_at": ` + referenceTimeStr + `, 601 "url": "u" 602 }, 603 "suspended_at": ` + referenceTimeStr + ` 604 } 605 }` 606 607 testJSONMarshal(t, u, want) 608 } 609 610 func TestStarEvent_Marshal(t *testing.T) { 611 testJSONMarshal(t, &StarEvent{}, "{}") 612 613 u := &StarEvent{ 614 Action: String("a"), 615 StarredAt: &Timestamp{referenceTime}, 616 Org: &Organization{ 617 BillingEmail: String("be"), 618 Blog: String("b"), 619 Company: String("c"), 620 Email: String("e"), 621 TwitterUsername: String("tu"), 622 Location: String("loc"), 623 Name: String("n"), 624 Description: String("d"), 625 IsVerified: Bool(true), 626 HasOrganizationProjects: Bool(true), 627 HasRepositoryProjects: Bool(true), 628 DefaultRepoPermission: String("drp"), 629 MembersCanCreateRepos: Bool(true), 630 MembersCanCreateInternalRepos: Bool(true), 631 MembersCanCreatePrivateRepos: Bool(true), 632 MembersCanCreatePublicRepos: Bool(false), 633 MembersAllowedRepositoryCreationType: String("marct"), 634 MembersCanCreatePages: Bool(true), 635 MembersCanCreatePublicPages: Bool(false), 636 MembersCanCreatePrivatePages: Bool(true), 637 }, 638 Repo: &Repository{ 639 ID: Int64(1), 640 URL: String("s"), 641 Name: String("n"), 642 }, 643 Sender: &User{ 644 Login: String("l"), 645 ID: Int64(1), 646 NodeID: String("n"), 647 URL: String("u"), 648 ReposURL: String("r"), 649 EventsURL: String("e"), 650 AvatarURL: String("a"), 651 }, 652 } 653 654 want := `{ 655 "action": "a", 656 "starred_at": ` + referenceTimeStr + `, 657 "organization": { 658 "name": "n", 659 "company": "c", 660 "blog": "b", 661 "location": "loc", 662 "email": "e", 663 "twitter_username": "tu", 664 "description": "d", 665 "billing_email": "be", 666 "is_verified": true, 667 "has_organization_projects": true, 668 "has_repository_projects": true, 669 "default_repository_permission": "drp", 670 "members_can_create_repositories": true, 671 "members_can_create_public_repositories": false, 672 "members_can_create_private_repositories": true, 673 "members_can_create_internal_repositories": true, 674 "members_allowed_repository_creation_type": "marct", 675 "members_can_create_pages": true, 676 "members_can_create_public_pages": false, 677 "members_can_create_private_pages": true 678 }, 679 "repository": { 680 "id": 1, 681 "name": "n", 682 "url": "s" 683 }, 684 "sender": { 685 "login": "l", 686 "id": 1, 687 "node_id": "n", 688 "avatar_url": "a", 689 "url": "u", 690 "events_url": "e", 691 "repos_url": "r" 692 } 693 }` 694 695 testJSONMarshal(t, u, want) 696 } 697 698 func TestTeamEvent_Marshal(t *testing.T) { 699 testJSONMarshal(t, &TeamEvent{}, "{}") 700 701 u := &TeamEvent{ 702 Action: String("a"), 703 Team: &Team{ 704 ID: Int64(1), 705 NodeID: String("n"), 706 Name: String("n"), 707 Description: String("d"), 708 URL: String("u"), 709 Slug: String("s"), 710 Permission: String("p"), 711 Privacy: String("p"), 712 MembersCount: Int(1), 713 ReposCount: Int(1), 714 MembersURL: String("m"), 715 RepositoriesURL: String("r"), 716 Organization: &Organization{ 717 Login: String("l"), 718 ID: Int64(1), 719 NodeID: String("n"), 720 AvatarURL: String("a"), 721 HTMLURL: String("h"), 722 Name: String("n"), 723 Company: String("c"), 724 Blog: String("b"), 725 Location: String("l"), 726 Email: String("e"), 727 }, 728 Parent: &Team{ 729 ID: Int64(1), 730 NodeID: String("n"), 731 Name: String("n"), 732 Description: String("d"), 733 URL: String("u"), 734 Slug: String("s"), 735 Permission: String("p"), 736 Privacy: String("p"), 737 MembersCount: Int(1), 738 ReposCount: Int(1), 739 }, 740 LDAPDN: String("l"), 741 }, 742 Changes: &TeamChange{ 743 Description: &TeamDescription{ 744 From: String("from"), 745 }, 746 Name: &TeamName{ 747 From: String("from"), 748 }, 749 Privacy: &TeamPrivacy{ 750 From: String("from"), 751 }, 752 Repository: &TeamRepository{ 753 Permissions: &TeamPermissions{ 754 From: &TeamPermissionsFrom{ 755 Admin: Bool(true), 756 Pull: Bool(true), 757 Push: Bool(true), 758 }, 759 }, 760 }, 761 }, 762 Repo: &Repository{ 763 ID: Int64(1), 764 URL: String("s"), 765 Name: String("n"), 766 }, 767 Org: &Organization{ 768 BillingEmail: String("be"), 769 Blog: String("b"), 770 Company: String("c"), 771 Email: String("e"), 772 TwitterUsername: String("tu"), 773 Location: String("loc"), 774 Name: String("n"), 775 Description: String("d"), 776 IsVerified: Bool(true), 777 HasOrganizationProjects: Bool(true), 778 HasRepositoryProjects: Bool(true), 779 DefaultRepoPermission: String("drp"), 780 MembersCanCreateRepos: Bool(true), 781 MembersCanCreateInternalRepos: Bool(true), 782 MembersCanCreatePrivateRepos: Bool(true), 783 MembersCanCreatePublicRepos: Bool(false), 784 MembersAllowedRepositoryCreationType: String("marct"), 785 MembersCanCreatePages: Bool(true), 786 MembersCanCreatePublicPages: Bool(false), 787 MembersCanCreatePrivatePages: Bool(true), 788 }, 789 Sender: &User{ 790 Login: String("l"), 791 ID: Int64(1), 792 NodeID: String("n"), 793 URL: String("u"), 794 ReposURL: String("r"), 795 EventsURL: String("e"), 796 AvatarURL: String("a"), 797 }, 798 Installation: &Installation{ 799 ID: Int64(1), 800 NodeID: String("nid"), 801 AppID: Int64(1), 802 AppSlug: String("as"), 803 TargetID: Int64(1), 804 Account: &User{ 805 Login: String("l"), 806 ID: Int64(1), 807 URL: String("u"), 808 AvatarURL: String("a"), 809 GravatarID: String("g"), 810 Name: String("n"), 811 Company: String("c"), 812 Blog: String("b"), 813 Location: String("l"), 814 Email: String("e"), 815 Hireable: Bool(true), 816 Bio: String("b"), 817 TwitterUsername: String("t"), 818 PublicRepos: Int(1), 819 Followers: Int(1), 820 Following: Int(1), 821 CreatedAt: &Timestamp{referenceTime}, 822 SuspendedAt: &Timestamp{referenceTime}, 823 }, 824 AccessTokensURL: String("atu"), 825 RepositoriesURL: String("ru"), 826 HTMLURL: String("hu"), 827 TargetType: String("tt"), 828 SingleFileName: String("sfn"), 829 RepositorySelection: String("rs"), 830 Events: []string{"e"}, 831 SingleFilePaths: []string{"s"}, 832 Permissions: &InstallationPermissions{ 833 Actions: String("a"), 834 Administration: String("ad"), 835 Checks: String("c"), 836 Contents: String("co"), 837 ContentReferences: String("cr"), 838 Deployments: String("d"), 839 Environments: String("e"), 840 Issues: String("i"), 841 Metadata: String("md"), 842 Members: String("m"), 843 OrganizationAdministration: String("oa"), 844 OrganizationHooks: String("oh"), 845 OrganizationPlan: String("op"), 846 OrganizationPreReceiveHooks: String("opr"), 847 OrganizationProjects: String("op"), 848 OrganizationSecrets: String("os"), 849 OrganizationSelfHostedRunners: String("osh"), 850 OrganizationUserBlocking: String("oub"), 851 Packages: String("pkg"), 852 Pages: String("pg"), 853 PullRequests: String("pr"), 854 RepositoryHooks: String("rh"), 855 RepositoryProjects: String("rp"), 856 RepositoryPreReceiveHooks: String("rprh"), 857 Secrets: String("s"), 858 SecretScanningAlerts: String("ssa"), 859 SecurityEvents: String("se"), 860 SingleFile: String("sf"), 861 Statuses: String("s"), 862 TeamDiscussions: String("td"), 863 VulnerabilityAlerts: String("va"), 864 Workflows: String("w"), 865 }, 866 CreatedAt: &Timestamp{referenceTime}, 867 UpdatedAt: &Timestamp{referenceTime}, 868 HasMultipleSingleFiles: Bool(false), 869 SuspendedBy: &User{ 870 Login: String("l"), 871 ID: Int64(1), 872 URL: String("u"), 873 AvatarURL: String("a"), 874 GravatarID: String("g"), 875 Name: String("n"), 876 Company: String("c"), 877 Blog: String("b"), 878 Location: String("l"), 879 Email: String("e"), 880 Hireable: Bool(true), 881 Bio: String("b"), 882 TwitterUsername: String("t"), 883 PublicRepos: Int(1), 884 Followers: Int(1), 885 Following: Int(1), 886 CreatedAt: &Timestamp{referenceTime}, 887 SuspendedAt: &Timestamp{referenceTime}, 888 }, 889 SuspendedAt: &Timestamp{referenceTime}, 890 }, 891 } 892 893 want := `{ 894 "action": "a", 895 "team": { 896 "id": 1, 897 "node_id": "n", 898 "name": "n", 899 "description": "d", 900 "url": "u", 901 "slug": "s", 902 "permission": "p", 903 "privacy": "p", 904 "members_count": 1, 905 "repos_count": 1, 906 "organization": { 907 "login": "l", 908 "id": 1, 909 "node_id": "n", 910 "avatar_url": "a", 911 "html_url": "h", 912 "name": "n", 913 "company": "c", 914 "blog": "b", 915 "location": "l", 916 "email": "e" 917 }, 918 "members_url": "m", 919 "repositories_url": "r", 920 "parent": { 921 "id": 1, 922 "node_id": "n", 923 "name": "n", 924 "description": "d", 925 "url": "u", 926 "slug": "s", 927 "permission": "p", 928 "privacy": "p", 929 "members_count": 1, 930 "repos_count": 1 931 }, 932 "ldap_dn": "l" 933 }, 934 "changes": { 935 "description": { 936 "from": "from" 937 }, 938 "name": { 939 "from": "from" 940 }, 941 "privacy": { 942 "from": "from" 943 }, 944 "repository": { 945 "permissions": { 946 "from": { 947 "admin": true, 948 "pull": true, 949 "push": true 950 } 951 } 952 } 953 }, 954 "repository": { 955 "id": 1, 956 "name": "n", 957 "url": "s" 958 }, 959 "organization": { 960 "name": "n", 961 "company": "c", 962 "blog": "b", 963 "location": "loc", 964 "email": "e", 965 "twitter_username": "tu", 966 "description": "d", 967 "billing_email": "be", 968 "is_verified": true, 969 "has_organization_projects": true, 970 "has_repository_projects": true, 971 "default_repository_permission": "drp", 972 "members_can_create_repositories": true, 973 "members_can_create_public_repositories": false, 974 "members_can_create_private_repositories": true, 975 "members_can_create_internal_repositories": true, 976 "members_allowed_repository_creation_type": "marct", 977 "members_can_create_pages": true, 978 "members_can_create_public_pages": false, 979 "members_can_create_private_pages": true 980 }, 981 "sender": { 982 "login": "l", 983 "id": 1, 984 "node_id": "n", 985 "avatar_url": "a", 986 "url": "u", 987 "events_url": "e", 988 "repos_url": "r" 989 }, 990 "installation": { 991 "id": 1, 992 "node_id": "nid", 993 "app_id": 1, 994 "app_slug": "as", 995 "target_id": 1, 996 "account": { 997 "login": "l", 998 "id": 1, 999 "avatar_url": "a", 1000 "gravatar_id": "g", 1001 "name": "n", 1002 "company": "c", 1003 "blog": "b", 1004 "location": "l", 1005 "email": "e", 1006 "hireable": true, 1007 "bio": "b", 1008 "twitter_username": "t", 1009 "public_repos": 1, 1010 "followers": 1, 1011 "following": 1, 1012 "created_at": ` + referenceTimeStr + `, 1013 "suspended_at": ` + referenceTimeStr + `, 1014 "url": "u" 1015 }, 1016 "access_tokens_url": "atu", 1017 "repositories_url": "ru", 1018 "html_url": "hu", 1019 "target_type": "tt", 1020 "single_file_name": "sfn", 1021 "repository_selection": "rs", 1022 "events": [ 1023 "e" 1024 ], 1025 "single_file_paths": [ 1026 "s" 1027 ], 1028 "permissions": { 1029 "actions": "a", 1030 "administration": "ad", 1031 "checks": "c", 1032 "contents": "co", 1033 "content_references": "cr", 1034 "deployments": "d", 1035 "environments": "e", 1036 "issues": "i", 1037 "metadata": "md", 1038 "members": "m", 1039 "organization_administration": "oa", 1040 "organization_hooks": "oh", 1041 "organization_plan": "op", 1042 "organization_pre_receive_hooks": "opr", 1043 "organization_projects": "op", 1044 "organization_secrets": "os", 1045 "organization_self_hosted_runners": "osh", 1046 "organization_user_blocking": "oub", 1047 "packages": "pkg", 1048 "pages": "pg", 1049 "pull_requests": "pr", 1050 "repository_hooks": "rh", 1051 "repository_projects": "rp", 1052 "repository_pre_receive_hooks": "rprh", 1053 "secrets": "s", 1054 "secret_scanning_alerts": "ssa", 1055 "security_events": "se", 1056 "single_file": "sf", 1057 "statuses": "s", 1058 "team_discussions": "td", 1059 "vulnerability_alerts": "va", 1060 "workflows": "w" 1061 }, 1062 "created_at": ` + referenceTimeStr + `, 1063 "updated_at": ` + referenceTimeStr + `, 1064 "has_multiple_single_files": false, 1065 "suspended_by": { 1066 "login": "l", 1067 "id": 1, 1068 "avatar_url": "a", 1069 "gravatar_id": "g", 1070 "name": "n", 1071 "company": "c", 1072 "blog": "b", 1073 "location": "l", 1074 "email": "e", 1075 "hireable": true, 1076 "bio": "b", 1077 "twitter_username": "t", 1078 "public_repos": 1, 1079 "followers": 1, 1080 "following": 1, 1081 "created_at": ` + referenceTimeStr + `, 1082 "suspended_at": ` + referenceTimeStr + `, 1083 "url": "u" 1084 }, 1085 "suspended_at": ` + referenceTimeStr + ` 1086 } 1087 }` 1088 1089 testJSONMarshal(t, u, want) 1090 } 1091 1092 func TestInstallationRepositoriesEvent_Marshal(t *testing.T) { 1093 testJSONMarshal(t, &InstallationRepositoriesEvent{}, "{}") 1094 1095 u := &InstallationRepositoriesEvent{ 1096 Action: String("a"), 1097 RepositoriesAdded: []*Repository{ 1098 { 1099 ID: Int64(1), 1100 URL: String("s"), 1101 Name: String("n"), 1102 }, 1103 }, 1104 RepositoriesRemoved: []*Repository{ 1105 { 1106 ID: Int64(1), 1107 URL: String("s"), 1108 Name: String("n"), 1109 }, 1110 }, 1111 RepositorySelection: String("rs"), 1112 Sender: &User{ 1113 Login: String("l"), 1114 ID: Int64(1), 1115 NodeID: String("n"), 1116 URL: String("u"), 1117 ReposURL: String("r"), 1118 EventsURL: String("e"), 1119 AvatarURL: String("a"), 1120 }, 1121 Installation: &Installation{ 1122 ID: Int64(1), 1123 NodeID: String("nid"), 1124 AppID: Int64(1), 1125 AppSlug: String("as"), 1126 TargetID: Int64(1), 1127 Account: &User{ 1128 Login: String("l"), 1129 ID: Int64(1), 1130 URL: String("u"), 1131 AvatarURL: String("a"), 1132 GravatarID: String("g"), 1133 Name: String("n"), 1134 Company: String("c"), 1135 Blog: String("b"), 1136 Location: String("l"), 1137 Email: String("e"), 1138 Hireable: Bool(true), 1139 Bio: String("b"), 1140 TwitterUsername: String("t"), 1141 PublicRepos: Int(1), 1142 Followers: Int(1), 1143 Following: Int(1), 1144 CreatedAt: &Timestamp{referenceTime}, 1145 SuspendedAt: &Timestamp{referenceTime}, 1146 }, 1147 AccessTokensURL: String("atu"), 1148 RepositoriesURL: String("ru"), 1149 HTMLURL: String("hu"), 1150 TargetType: String("tt"), 1151 SingleFileName: String("sfn"), 1152 RepositorySelection: String("rs"), 1153 Events: []string{"e"}, 1154 SingleFilePaths: []string{"s"}, 1155 Permissions: &InstallationPermissions{ 1156 Actions: String("a"), 1157 Administration: String("ad"), 1158 Checks: String("c"), 1159 Contents: String("co"), 1160 ContentReferences: String("cr"), 1161 Deployments: String("d"), 1162 Environments: String("e"), 1163 Issues: String("i"), 1164 Metadata: String("md"), 1165 Members: String("m"), 1166 OrganizationAdministration: String("oa"), 1167 OrganizationHooks: String("oh"), 1168 OrganizationPlan: String("op"), 1169 OrganizationPreReceiveHooks: String("opr"), 1170 OrganizationProjects: String("op"), 1171 OrganizationSecrets: String("os"), 1172 OrganizationSelfHostedRunners: String("osh"), 1173 OrganizationUserBlocking: String("oub"), 1174 Packages: String("pkg"), 1175 Pages: String("pg"), 1176 PullRequests: String("pr"), 1177 RepositoryHooks: String("rh"), 1178 RepositoryProjects: String("rp"), 1179 RepositoryPreReceiveHooks: String("rprh"), 1180 Secrets: String("s"), 1181 SecretScanningAlerts: String("ssa"), 1182 SecurityEvents: String("se"), 1183 SingleFile: String("sf"), 1184 Statuses: String("s"), 1185 TeamDiscussions: String("td"), 1186 VulnerabilityAlerts: String("va"), 1187 Workflows: String("w"), 1188 }, 1189 CreatedAt: &Timestamp{referenceTime}, 1190 UpdatedAt: &Timestamp{referenceTime}, 1191 HasMultipleSingleFiles: Bool(false), 1192 SuspendedBy: &User{ 1193 Login: String("l"), 1194 ID: Int64(1), 1195 URL: String("u"), 1196 AvatarURL: String("a"), 1197 GravatarID: String("g"), 1198 Name: String("n"), 1199 Company: String("c"), 1200 Blog: String("b"), 1201 Location: String("l"), 1202 Email: String("e"), 1203 Hireable: Bool(true), 1204 Bio: String("b"), 1205 TwitterUsername: String("t"), 1206 PublicRepos: Int(1), 1207 Followers: Int(1), 1208 Following: Int(1), 1209 CreatedAt: &Timestamp{referenceTime}, 1210 SuspendedAt: &Timestamp{referenceTime}, 1211 }, 1212 SuspendedAt: &Timestamp{referenceTime}, 1213 }, 1214 } 1215 1216 want := `{ 1217 "action": "a", 1218 "repositories_added": [ 1219 { 1220 "id": 1, 1221 "name": "n", 1222 "url": "s" 1223 } 1224 ], 1225 "repositories_removed": [ 1226 { 1227 "id": 1, 1228 "name": "n", 1229 "url": "s" 1230 } 1231 ], 1232 "repository_selection": "rs", 1233 "sender": { 1234 "login": "l", 1235 "id": 1, 1236 "node_id": "n", 1237 "avatar_url": "a", 1238 "url": "u", 1239 "events_url": "e", 1240 "repos_url": "r" 1241 }, 1242 "installation": { 1243 "id": 1, 1244 "node_id": "nid", 1245 "app_id": 1, 1246 "app_slug": "as", 1247 "target_id": 1, 1248 "account": { 1249 "login": "l", 1250 "id": 1, 1251 "avatar_url": "a", 1252 "gravatar_id": "g", 1253 "name": "n", 1254 "company": "c", 1255 "blog": "b", 1256 "location": "l", 1257 "email": "e", 1258 "hireable": true, 1259 "bio": "b", 1260 "twitter_username": "t", 1261 "public_repos": 1, 1262 "followers": 1, 1263 "following": 1, 1264 "created_at": ` + referenceTimeStr + `, 1265 "suspended_at": ` + referenceTimeStr + `, 1266 "url": "u" 1267 }, 1268 "access_tokens_url": "atu", 1269 "repositories_url": "ru", 1270 "html_url": "hu", 1271 "target_type": "tt", 1272 "single_file_name": "sfn", 1273 "repository_selection": "rs", 1274 "events": [ 1275 "e" 1276 ], 1277 "single_file_paths": [ 1278 "s" 1279 ], 1280 "permissions": { 1281 "actions": "a", 1282 "administration": "ad", 1283 "checks": "c", 1284 "contents": "co", 1285 "content_references": "cr", 1286 "deployments": "d", 1287 "environments": "e", 1288 "issues": "i", 1289 "metadata": "md", 1290 "members": "m", 1291 "organization_administration": "oa", 1292 "organization_hooks": "oh", 1293 "organization_plan": "op", 1294 "organization_pre_receive_hooks": "opr", 1295 "organization_projects": "op", 1296 "organization_secrets": "os", 1297 "organization_self_hosted_runners": "osh", 1298 "organization_user_blocking": "oub", 1299 "packages": "pkg", 1300 "pages": "pg", 1301 "pull_requests": "pr", 1302 "repository_hooks": "rh", 1303 "repository_projects": "rp", 1304 "repository_pre_receive_hooks": "rprh", 1305 "secrets": "s", 1306 "secret_scanning_alerts": "ssa", 1307 "security_events": "se", 1308 "single_file": "sf", 1309 "statuses": "s", 1310 "team_discussions": "td", 1311 "vulnerability_alerts": "va", 1312 "workflows": "w" 1313 }, 1314 "created_at": ` + referenceTimeStr + `, 1315 "updated_at": ` + referenceTimeStr + `, 1316 "has_multiple_single_files": false, 1317 "suspended_by": { 1318 "login": "l", 1319 "id": 1, 1320 "avatar_url": "a", 1321 "gravatar_id": "g", 1322 "name": "n", 1323 "company": "c", 1324 "blog": "b", 1325 "location": "l", 1326 "email": "e", 1327 "hireable": true, 1328 "bio": "b", 1329 "twitter_username": "t", 1330 "public_repos": 1, 1331 "followers": 1, 1332 "following": 1, 1333 "created_at": ` + referenceTimeStr + `, 1334 "suspended_at": ` + referenceTimeStr + `, 1335 "url": "u" 1336 }, 1337 "suspended_at": ` + referenceTimeStr + ` 1338 } 1339 }` 1340 1341 testJSONMarshal(t, u, want) 1342 } 1343 1344 func TestInstallationTargetEvent_Marshal(t *testing.T) { 1345 testJSONMarshal(t, &InstallationTargetEvent{}, "{}") 1346 1347 u := &InstallationTargetEvent{ 1348 Account: &User{ 1349 Login: String("u"), 1350 ID: Int64(1), 1351 NodeID: String("n"), 1352 URL: String("u"), 1353 ReposURL: String("r"), 1354 EventsURL: String("e"), 1355 AvatarURL: String("l"), 1356 }, 1357 Action: String("a"), 1358 Changes: &InstallationChanges{ 1359 Login: &InstallationLoginChange{ 1360 From: String("p"), 1361 }, 1362 Slug: &InstallationSlugChange{ 1363 From: String("j"), 1364 }, 1365 }, 1366 Enterprise: &Enterprise{ 1367 ID: Int(1), 1368 Slug: String("s"), 1369 Name: String("n"), 1370 NodeID: String("nid"), 1371 AvatarURL: String("au"), 1372 Description: String("d"), 1373 WebsiteURL: String("wu"), 1374 HTMLURL: String("hu"), 1375 CreatedAt: &Timestamp{referenceTime}, 1376 UpdatedAt: &Timestamp{referenceTime}, 1377 }, 1378 Installation: &Installation{ 1379 ID: Int64(1), 1380 NodeID: String("nid"), 1381 AppID: Int64(1), 1382 AppSlug: String("as"), 1383 TargetID: Int64(1), 1384 Account: &User{ 1385 Login: String("l"), 1386 ID: Int64(1), 1387 URL: String("u"), 1388 AvatarURL: String("a"), 1389 GravatarID: String("g"), 1390 Name: String("n"), 1391 Company: String("c"), 1392 Blog: String("b"), 1393 Location: String("l"), 1394 Email: String("e"), 1395 Hireable: Bool(true), 1396 Bio: String("b"), 1397 TwitterUsername: String("t"), 1398 PublicRepos: Int(1), 1399 Followers: Int(1), 1400 Following: Int(1), 1401 CreatedAt: &Timestamp{referenceTime}, 1402 SuspendedAt: &Timestamp{referenceTime}, 1403 }, 1404 AccessTokensURL: String("atu"), 1405 RepositoriesURL: String("ru"), 1406 HTMLURL: String("hu"), 1407 TargetType: String("tt"), 1408 SingleFileName: String("sfn"), 1409 RepositorySelection: String("rs"), 1410 Events: []string{"e"}, 1411 SingleFilePaths: []string{"s"}, 1412 Permissions: &InstallationPermissions{ 1413 Actions: String("a"), 1414 Administration: String("ad"), 1415 Checks: String("c"), 1416 Contents: String("co"), 1417 ContentReferences: String("cr"), 1418 Deployments: String("d"), 1419 Environments: String("e"), 1420 Issues: String("i"), 1421 Metadata: String("md"), 1422 Members: String("m"), 1423 OrganizationAdministration: String("oa"), 1424 OrganizationHooks: String("oh"), 1425 OrganizationPlan: String("op"), 1426 OrganizationPreReceiveHooks: String("opr"), 1427 OrganizationProjects: String("op"), 1428 OrganizationSecrets: String("os"), 1429 OrganizationSelfHostedRunners: String("osh"), 1430 OrganizationUserBlocking: String("oub"), 1431 Packages: String("pkg"), 1432 Pages: String("pg"), 1433 PullRequests: String("pr"), 1434 RepositoryHooks: String("rh"), 1435 RepositoryProjects: String("rp"), 1436 RepositoryPreReceiveHooks: String("rprh"), 1437 Secrets: String("s"), 1438 SecretScanningAlerts: String("ssa"), 1439 SecurityEvents: String("se"), 1440 SingleFile: String("sf"), 1441 Statuses: String("s"), 1442 TeamDiscussions: String("td"), 1443 VulnerabilityAlerts: String("va"), 1444 Workflows: String("w"), 1445 }, 1446 CreatedAt: &Timestamp{referenceTime}, 1447 UpdatedAt: &Timestamp{referenceTime}, 1448 HasMultipleSingleFiles: Bool(false), 1449 SuspendedBy: &User{ 1450 Login: String("l"), 1451 ID: Int64(1), 1452 URL: String("u"), 1453 AvatarURL: String("a"), 1454 GravatarID: String("g"), 1455 Name: String("n"), 1456 Company: String("c"), 1457 Blog: String("b"), 1458 Location: String("l"), 1459 Email: String("e"), 1460 Hireable: Bool(true), 1461 Bio: String("b"), 1462 TwitterUsername: String("t"), 1463 PublicRepos: Int(1), 1464 Followers: Int(1), 1465 Following: Int(1), 1466 CreatedAt: &Timestamp{referenceTime}, 1467 SuspendedAt: &Timestamp{referenceTime}, 1468 }, 1469 SuspendedAt: &Timestamp{referenceTime}, 1470 }, 1471 Organization: &Organization{ 1472 BillingEmail: String("be"), 1473 Blog: String("b"), 1474 Company: String("c"), 1475 Email: String("e"), 1476 TwitterUsername: String("tu"), 1477 Location: String("loc"), 1478 Name: String("n"), 1479 Description: String("d"), 1480 IsVerified: Bool(true), 1481 HasOrganizationProjects: Bool(true), 1482 HasRepositoryProjects: Bool(true), 1483 DefaultRepoPermission: String("drp"), 1484 MembersCanCreateRepos: Bool(true), 1485 MembersCanCreateInternalRepos: Bool(true), 1486 MembersCanCreatePrivateRepos: Bool(true), 1487 MembersCanCreatePublicRepos: Bool(false), 1488 MembersAllowedRepositoryCreationType: String("marct"), 1489 MembersCanCreatePages: Bool(true), 1490 MembersCanCreatePublicPages: Bool(false), 1491 MembersCanCreatePrivatePages: Bool(true), 1492 }, 1493 Repository: &Repository{ 1494 ID: Int64(1), 1495 URL: String("s"), 1496 Name: String("n"), 1497 }, 1498 Sender: &User{ 1499 Login: String("l"), 1500 ID: Int64(1), 1501 NodeID: String("n"), 1502 URL: String("u"), 1503 ReposURL: String("r"), 1504 EventsURL: String("e"), 1505 AvatarURL: String("a"), 1506 }, 1507 TargetType: String("running"), 1508 } 1509 1510 want := `{ 1511 "account": { 1512 "login": "u", 1513 "id": 1, 1514 "node_id": "n", 1515 "avatar_url": "l", 1516 "url": "u", 1517 "events_url": "e", 1518 "repos_url": "r" 1519 }, 1520 "action": "a", 1521 "changes": { 1522 "login": { 1523 "from": "p" 1524 }, 1525 "slug": { 1526 "from": "j" 1527 } 1528 }, 1529 "enterprise": { 1530 "id": 1, 1531 "slug": "s", 1532 "name": "n", 1533 "node_id": "nid", 1534 "avatar_url": "au", 1535 "description": "d", 1536 "website_url": "wu", 1537 "html_url": "hu", 1538 "created_at": ` + referenceTimeStr + `, 1539 "updated_at": ` + referenceTimeStr + ` 1540 }, 1541 "installation": { 1542 "id": 1, 1543 "node_id": "nid", 1544 "app_id": 1, 1545 "app_slug": "as", 1546 "target_id": 1, 1547 "account": { 1548 "login": "l", 1549 "id": 1, 1550 "avatar_url": "a", 1551 "gravatar_id": "g", 1552 "name": "n", 1553 "company": "c", 1554 "blog": "b", 1555 "location": "l", 1556 "email": "e", 1557 "hireable": true, 1558 "bio": "b", 1559 "twitter_username": "t", 1560 "public_repos": 1, 1561 "followers": 1, 1562 "following": 1, 1563 "created_at": ` + referenceTimeStr + `, 1564 "suspended_at": ` + referenceTimeStr + `, 1565 "url": "u" 1566 }, 1567 "access_tokens_url": "atu", 1568 "repositories_url": "ru", 1569 "html_url": "hu", 1570 "target_type": "tt", 1571 "single_file_name": "sfn", 1572 "repository_selection": "rs", 1573 "events": [ 1574 "e" 1575 ], 1576 "single_file_paths": [ 1577 "s" 1578 ], 1579 "permissions": { 1580 "actions": "a", 1581 "administration": "ad", 1582 "checks": "c", 1583 "contents": "co", 1584 "content_references": "cr", 1585 "deployments": "d", 1586 "environments": "e", 1587 "issues": "i", 1588 "metadata": "md", 1589 "members": "m", 1590 "organization_administration": "oa", 1591 "organization_hooks": "oh", 1592 "organization_plan": "op", 1593 "organization_pre_receive_hooks": "opr", 1594 "organization_projects": "op", 1595 "organization_secrets": "os", 1596 "organization_self_hosted_runners": "osh", 1597 "organization_user_blocking": "oub", 1598 "packages": "pkg", 1599 "pages": "pg", 1600 "pull_requests": "pr", 1601 "repository_hooks": "rh", 1602 "repository_projects": "rp", 1603 "repository_pre_receive_hooks": "rprh", 1604 "secrets": "s", 1605 "secret_scanning_alerts": "ssa", 1606 "security_events": "se", 1607 "single_file": "sf", 1608 "statuses": "s", 1609 "team_discussions": "td", 1610 "vulnerability_alerts": "va", 1611 "workflows": "w" 1612 }, 1613 "created_at": ` + referenceTimeStr + `, 1614 "updated_at": ` + referenceTimeStr + `, 1615 "has_multiple_single_files": false, 1616 "suspended_by": { 1617 "login": "l", 1618 "id": 1, 1619 "avatar_url": "a", 1620 "gravatar_id": "g", 1621 "name": "n", 1622 "company": "c", 1623 "blog": "b", 1624 "location": "l", 1625 "email": "e", 1626 "hireable": true, 1627 "bio": "b", 1628 "twitter_username": "t", 1629 "public_repos": 1, 1630 "followers": 1, 1631 "following": 1, 1632 "created_at": ` + referenceTimeStr + `, 1633 "suspended_at": ` + referenceTimeStr + `, 1634 "url": "u" 1635 }, 1636 "suspended_at": ` + referenceTimeStr + ` 1637 }, 1638 "organization": { 1639 "name": "n", 1640 "company": "c", 1641 "blog": "b", 1642 "location": "loc", 1643 "email": "e", 1644 "twitter_username": "tu", 1645 "description": "d", 1646 "billing_email": "be", 1647 "is_verified": true, 1648 "has_organization_projects": true, 1649 "has_repository_projects": true, 1650 "default_repository_permission": "drp", 1651 "members_can_create_repositories": true, 1652 "members_can_create_public_repositories": false, 1653 "members_can_create_private_repositories": true, 1654 "members_can_create_internal_repositories": true, 1655 "members_allowed_repository_creation_type": "marct", 1656 "members_can_create_pages": true, 1657 "members_can_create_public_pages": false, 1658 "members_can_create_private_pages": true 1659 }, 1660 "repository": { 1661 "id": 1, 1662 "url": "s", 1663 "name": "n" 1664 }, 1665 "sender": { 1666 "login": "l", 1667 "id": 1, 1668 "node_id": "n", 1669 "avatar_url": "a", 1670 "url": "u", 1671 "events_url": "e", 1672 "repos_url": "r" 1673 }, 1674 "target_type": "running" 1675 }` 1676 1677 testJSONMarshal(t, u, want) 1678 } 1679 1680 func TestEditTitle_Marshal(t *testing.T) { 1681 testJSONMarshal(t, &EditTitle{}, "{}") 1682 1683 u := &EditTitle{ 1684 From: String("EditTitleFrom"), 1685 } 1686 1687 want := `{ 1688 "from": "EditTitleFrom" 1689 }` 1690 1691 testJSONMarshal(t, u, want) 1692 } 1693 1694 func TestEditBody_Marshal(t *testing.T) { 1695 testJSONMarshal(t, &EditBody{}, "{}") 1696 1697 u := &EditBody{ 1698 From: String("EditBodyFrom"), 1699 } 1700 1701 want := `{ 1702 "from": "EditBodyFrom" 1703 }` 1704 1705 testJSONMarshal(t, u, want) 1706 } 1707 1708 func TestEditBase_Marshal(t *testing.T) { 1709 testJSONMarshal(t, &EditBase{}, "{}") 1710 1711 u := &EditBase{ 1712 Ref: &EditRef{ 1713 From: String("EditRefFrom"), 1714 }, 1715 SHA: &EditSHA{ 1716 From: String("EditSHAFrom"), 1717 }, 1718 } 1719 1720 want := `{ 1721 "ref": { 1722 "from": "EditRefFrom" 1723 }, 1724 "sha": { 1725 "from": "EditSHAFrom" 1726 } 1727 }` 1728 1729 testJSONMarshal(t, u, want) 1730 } 1731 1732 func TestEditRef_Marshal(t *testing.T) { 1733 testJSONMarshal(t, &EditRef{}, "{}") 1734 1735 u := &EditRef{ 1736 From: String("EditRefFrom"), 1737 } 1738 1739 want := `{ 1740 "from": "EditRefFrom" 1741 }` 1742 1743 testJSONMarshal(t, u, want) 1744 } 1745 1746 func TestEditSHA_Marshal(t *testing.T) { 1747 testJSONMarshal(t, &EditSHA{}, "{}") 1748 1749 u := &EditSHA{ 1750 From: String("EditSHAFrom"), 1751 } 1752 1753 want := `{ 1754 "from": "EditSHAFrom" 1755 }` 1756 1757 testJSONMarshal(t, u, want) 1758 } 1759 1760 func TestProjectName_Marshal(t *testing.T) { 1761 testJSONMarshal(t, &ProjectName{}, "{}") 1762 1763 u := &ProjectName{ 1764 From: String("ProjectNameFrom"), 1765 } 1766 1767 want := `{ 1768 "from": "ProjectNameFrom" 1769 }` 1770 1771 testJSONMarshal(t, u, want) 1772 } 1773 1774 func TestProjectBody_Marshal(t *testing.T) { 1775 testJSONMarshal(t, &ProjectBody{}, "{}") 1776 1777 u := &ProjectBody{ 1778 From: String("ProjectBodyFrom"), 1779 } 1780 1781 want := `{ 1782 "from": "ProjectBodyFrom" 1783 }` 1784 1785 testJSONMarshal(t, u, want) 1786 } 1787 1788 func TestProjectCardNote_Marshal(t *testing.T) { 1789 testJSONMarshal(t, &ProjectCardNote{}, "{}") 1790 1791 u := &ProjectCardNote{ 1792 From: String("ProjectCardNoteFrom"), 1793 } 1794 1795 want := `{ 1796 "from": "ProjectCardNoteFrom" 1797 }` 1798 1799 testJSONMarshal(t, u, want) 1800 } 1801 1802 func TestProjectColumnName_Marshal(t *testing.T) { 1803 testJSONMarshal(t, &ProjectColumnName{}, "{}") 1804 1805 u := &ProjectColumnName{ 1806 From: String("ProjectColumnNameFrom"), 1807 } 1808 1809 want := `{ 1810 "from": "ProjectColumnNameFrom" 1811 }` 1812 1813 testJSONMarshal(t, u, want) 1814 } 1815 1816 func TestTeamDescription_Marshal(t *testing.T) { 1817 testJSONMarshal(t, &TeamDescription{}, "{}") 1818 1819 u := &TeamDescription{ 1820 From: String("TeamDescriptionFrom"), 1821 } 1822 1823 want := `{ 1824 "from": "TeamDescriptionFrom" 1825 }` 1826 1827 testJSONMarshal(t, u, want) 1828 } 1829 1830 func TestTeamName_Marshal(t *testing.T) { 1831 testJSONMarshal(t, &TeamName{}, "{}") 1832 1833 u := &TeamName{ 1834 From: String("TeamNameFrom"), 1835 } 1836 1837 want := `{ 1838 "from": "TeamNameFrom" 1839 }` 1840 1841 testJSONMarshal(t, u, want) 1842 } 1843 1844 func TestTeamPrivacy_Marshal(t *testing.T) { 1845 testJSONMarshal(t, &TeamPrivacy{}, "{}") 1846 1847 u := &TeamPrivacy{ 1848 From: String("TeamPrivacyFrom"), 1849 } 1850 1851 want := `{ 1852 "from": "TeamPrivacyFrom" 1853 }` 1854 1855 testJSONMarshal(t, u, want) 1856 } 1857 1858 func TestTeamRepository_Marshal(t *testing.T) { 1859 testJSONMarshal(t, &TeamRepository{}, "{}") 1860 1861 u := &TeamRepository{ 1862 Permissions: &TeamPermissions{ 1863 From: &TeamPermissionsFrom{ 1864 Admin: Bool(true), 1865 Pull: Bool(true), 1866 Push: Bool(true), 1867 }, 1868 }, 1869 } 1870 1871 want := `{ 1872 "permissions": { 1873 "from": { 1874 "admin": true, 1875 "pull": true, 1876 "push": true 1877 } 1878 } 1879 }` 1880 1881 testJSONMarshal(t, u, want) 1882 } 1883 1884 func TestTeamPermissions_Marshal(t *testing.T) { 1885 testJSONMarshal(t, &TeamPermissions{}, "{}") 1886 1887 u := &TeamPermissions{ 1888 From: &TeamPermissionsFrom{ 1889 Admin: Bool(true), 1890 Pull: Bool(true), 1891 Push: Bool(true), 1892 }, 1893 } 1894 1895 want := `{ 1896 "from": { 1897 "admin": true, 1898 "pull": true, 1899 "push": true 1900 } 1901 }` 1902 1903 testJSONMarshal(t, u, want) 1904 } 1905 1906 func TestTeamPermissionsFrom_Marshal(t *testing.T) { 1907 testJSONMarshal(t, &TeamPermissionsFrom{}, "{}") 1908 1909 u := &TeamPermissionsFrom{ 1910 Admin: Bool(true), 1911 Pull: Bool(true), 1912 Push: Bool(true), 1913 } 1914 1915 want := `{ 1916 "admin": true, 1917 "pull": true, 1918 "push": true 1919 }` 1920 1921 testJSONMarshal(t, u, want) 1922 } 1923 1924 func TestRepositoryVulnerabilityAlert_Marshal(t *testing.T) { 1925 testJSONMarshal(t, &RepositoryVulnerabilityAlert{}, "{}") 1926 1927 u := &RepositoryVulnerabilityAlert{ 1928 ID: Int64(1), 1929 AffectedRange: String("ar"), 1930 AffectedPackageName: String("apn"), 1931 ExternalReference: String("er"), 1932 ExternalIdentifier: String("ei"), 1933 FixedIn: String("fi"), 1934 Dismisser: &User{ 1935 Login: String("l"), 1936 ID: Int64(1), 1937 NodeID: String("n"), 1938 URL: String("u"), 1939 ReposURL: String("r"), 1940 EventsURL: String("e"), 1941 AvatarURL: String("a"), 1942 }, 1943 DismissReason: String("dr"), 1944 DismissedAt: &Timestamp{referenceTime}, 1945 } 1946 1947 want := `{ 1948 "id": 1, 1949 "affected_range": "ar", 1950 "affected_package_name": "apn", 1951 "external_reference": "er", 1952 "external_identifier": "ei", 1953 "fixed_in": "fi", 1954 "dismisser": { 1955 "login": "l", 1956 "id": 1, 1957 "node_id": "n", 1958 "avatar_url": "a", 1959 "url": "u", 1960 "events_url": "e", 1961 "repos_url": "r" 1962 }, 1963 "dismiss_reason": "dr", 1964 "dismissed_at": ` + referenceTimeStr + ` 1965 }` 1966 1967 testJSONMarshal(t, u, want) 1968 } 1969 1970 func TestPage_Marshal(t *testing.T) { 1971 testJSONMarshal(t, &Page{}, "{}") 1972 1973 u := &Page{ 1974 PageName: String("p"), 1975 Title: String("t"), 1976 Summary: String("s"), 1977 Action: String("a"), 1978 SHA: String("s"), 1979 HTMLURL: String("h"), 1980 } 1981 1982 want := `{ 1983 "page_name": "p", 1984 "title": "t", 1985 "summary": "s", 1986 "action": "a", 1987 "sha": "s", 1988 "html_url": "h" 1989 }` 1990 1991 testJSONMarshal(t, u, want) 1992 } 1993 1994 func TestTeamChange_Marshal(t *testing.T) { 1995 testJSONMarshal(t, &TeamChange{}, "{}") 1996 1997 u := &TeamChange{ 1998 Description: &TeamDescription{ 1999 From: String("DescriptionFrom"), 2000 }, 2001 Name: &TeamName{ 2002 From: String("NameFrom"), 2003 }, 2004 Privacy: &TeamPrivacy{ 2005 From: String("PrivacyFrom"), 2006 }, 2007 Repository: &TeamRepository{ 2008 Permissions: &TeamPermissions{ 2009 From: &TeamPermissionsFrom{ 2010 Admin: Bool(false), 2011 Pull: Bool(false), 2012 Push: Bool(false), 2013 }, 2014 }, 2015 }, 2016 } 2017 2018 want := `{ 2019 "description": { 2020 "from": "DescriptionFrom" 2021 }, 2022 "name": { 2023 "from": "NameFrom" 2024 }, 2025 "privacy": { 2026 "from": "PrivacyFrom" 2027 }, 2028 "repository": { 2029 "permissions": { 2030 "from": { 2031 "admin": false, 2032 "pull": false, 2033 "push": false 2034 } 2035 } 2036 } 2037 }` 2038 2039 testJSONMarshal(t, u, want) 2040 } 2041 2042 func TestIssueCommentEvent_Marshal(t *testing.T) { 2043 testJSONMarshal(t, &IssueCommentEvent{}, "{}") 2044 2045 u := &IssueCommentEvent{ 2046 Action: String("a"), 2047 Issue: &Issue{ID: Int64(1)}, 2048 Comment: &IssueComment{ID: Int64(1)}, 2049 Changes: &EditChange{ 2050 Title: &EditTitle{ 2051 From: String("TitleFrom"), 2052 }, 2053 Body: &EditBody{ 2054 From: String("BodyFrom"), 2055 }, 2056 Base: &EditBase{ 2057 Ref: &EditRef{ 2058 From: String("BaseRefFrom"), 2059 }, 2060 SHA: &EditSHA{ 2061 From: String("BaseSHAFrom"), 2062 }, 2063 }, 2064 }, 2065 Repo: &Repository{ 2066 ID: Int64(1), 2067 URL: String("s"), 2068 Name: String("n"), 2069 }, 2070 Sender: &User{ 2071 Login: String("l"), 2072 ID: Int64(1), 2073 NodeID: String("n"), 2074 URL: String("u"), 2075 ReposURL: String("r"), 2076 EventsURL: String("e"), 2077 AvatarURL: String("a"), 2078 }, 2079 Installation: &Installation{ 2080 ID: Int64(1), 2081 NodeID: String("nid"), 2082 AppID: Int64(1), 2083 AppSlug: String("as"), 2084 TargetID: Int64(1), 2085 Account: &User{ 2086 Login: String("l"), 2087 ID: Int64(1), 2088 URL: String("u"), 2089 AvatarURL: String("a"), 2090 GravatarID: String("g"), 2091 Name: String("n"), 2092 Company: String("c"), 2093 Blog: String("b"), 2094 Location: String("l"), 2095 Email: String("e"), 2096 Hireable: Bool(true), 2097 Bio: String("b"), 2098 TwitterUsername: String("t"), 2099 PublicRepos: Int(1), 2100 Followers: Int(1), 2101 Following: Int(1), 2102 CreatedAt: &Timestamp{referenceTime}, 2103 SuspendedAt: &Timestamp{referenceTime}, 2104 }, 2105 AccessTokensURL: String("atu"), 2106 RepositoriesURL: String("ru"), 2107 HTMLURL: String("hu"), 2108 TargetType: String("tt"), 2109 SingleFileName: String("sfn"), 2110 RepositorySelection: String("rs"), 2111 Events: []string{"e"}, 2112 SingleFilePaths: []string{"s"}, 2113 Permissions: &InstallationPermissions{ 2114 Actions: String("a"), 2115 Administration: String("ad"), 2116 Checks: String("c"), 2117 Contents: String("co"), 2118 ContentReferences: String("cr"), 2119 Deployments: String("d"), 2120 Environments: String("e"), 2121 Issues: String("i"), 2122 Metadata: String("md"), 2123 Members: String("m"), 2124 OrganizationAdministration: String("oa"), 2125 OrganizationHooks: String("oh"), 2126 OrganizationPlan: String("op"), 2127 OrganizationPreReceiveHooks: String("opr"), 2128 OrganizationProjects: String("op"), 2129 OrganizationSecrets: String("os"), 2130 OrganizationSelfHostedRunners: String("osh"), 2131 OrganizationUserBlocking: String("oub"), 2132 Packages: String("pkg"), 2133 Pages: String("pg"), 2134 PullRequests: String("pr"), 2135 RepositoryHooks: String("rh"), 2136 RepositoryProjects: String("rp"), 2137 RepositoryPreReceiveHooks: String("rprh"), 2138 Secrets: String("s"), 2139 SecretScanningAlerts: String("ssa"), 2140 SecurityEvents: String("se"), 2141 SingleFile: String("sf"), 2142 Statuses: String("s"), 2143 TeamDiscussions: String("td"), 2144 VulnerabilityAlerts: String("va"), 2145 Workflows: String("w"), 2146 }, 2147 CreatedAt: &Timestamp{referenceTime}, 2148 UpdatedAt: &Timestamp{referenceTime}, 2149 HasMultipleSingleFiles: Bool(false), 2150 SuspendedBy: &User{ 2151 Login: String("l"), 2152 ID: Int64(1), 2153 URL: String("u"), 2154 AvatarURL: String("a"), 2155 GravatarID: String("g"), 2156 Name: String("n"), 2157 Company: String("c"), 2158 Blog: String("b"), 2159 Location: String("l"), 2160 Email: String("e"), 2161 Hireable: Bool(true), 2162 Bio: String("b"), 2163 TwitterUsername: String("t"), 2164 PublicRepos: Int(1), 2165 Followers: Int(1), 2166 Following: Int(1), 2167 CreatedAt: &Timestamp{referenceTime}, 2168 SuspendedAt: &Timestamp{referenceTime}, 2169 }, 2170 SuspendedAt: &Timestamp{referenceTime}, 2171 }, 2172 Organization: &Organization{ 2173 BillingEmail: String("be"), 2174 Blog: String("b"), 2175 Company: String("c"), 2176 Email: String("e"), 2177 TwitterUsername: String("tu"), 2178 Location: String("loc"), 2179 Name: String("n"), 2180 Description: String("d"), 2181 IsVerified: Bool(true), 2182 HasOrganizationProjects: Bool(true), 2183 HasRepositoryProjects: Bool(true), 2184 DefaultRepoPermission: String("drp"), 2185 MembersCanCreateRepos: Bool(true), 2186 MembersCanCreateInternalRepos: Bool(true), 2187 MembersCanCreatePrivateRepos: Bool(true), 2188 MembersCanCreatePublicRepos: Bool(false), 2189 MembersAllowedRepositoryCreationType: String("marct"), 2190 MembersCanCreatePages: Bool(true), 2191 MembersCanCreatePublicPages: Bool(false), 2192 MembersCanCreatePrivatePages: Bool(true), 2193 }, 2194 } 2195 2196 want := `{ 2197 "action": "a", 2198 "issue": { 2199 "id": 1 2200 }, 2201 "comment": { 2202 "id": 1 2203 }, 2204 "changes": { 2205 "title": { 2206 "from": "TitleFrom" 2207 }, 2208 "body": { 2209 "from": "BodyFrom" 2210 }, 2211 "base": { 2212 "ref": { 2213 "from": "BaseRefFrom" 2214 }, 2215 "sha": { 2216 "from": "BaseSHAFrom" 2217 } 2218 } 2219 }, 2220 "repository": { 2221 "id": 1, 2222 "name": "n", 2223 "url": "s" 2224 }, 2225 "sender": { 2226 "login": "l", 2227 "id": 1, 2228 "node_id": "n", 2229 "avatar_url": "a", 2230 "url": "u", 2231 "events_url": "e", 2232 "repos_url": "r" 2233 }, 2234 "installation": { 2235 "id": 1, 2236 "node_id": "nid", 2237 "app_id": 1, 2238 "app_slug": "as", 2239 "target_id": 1, 2240 "account": { 2241 "login": "l", 2242 "id": 1, 2243 "avatar_url": "a", 2244 "gravatar_id": "g", 2245 "name": "n", 2246 "company": "c", 2247 "blog": "b", 2248 "location": "l", 2249 "email": "e", 2250 "hireable": true, 2251 "bio": "b", 2252 "twitter_username": "t", 2253 "public_repos": 1, 2254 "followers": 1, 2255 "following": 1, 2256 "created_at": ` + referenceTimeStr + `, 2257 "suspended_at": ` + referenceTimeStr + `, 2258 "url": "u" 2259 }, 2260 "access_tokens_url": "atu", 2261 "repositories_url": "ru", 2262 "html_url": "hu", 2263 "target_type": "tt", 2264 "single_file_name": "sfn", 2265 "repository_selection": "rs", 2266 "events": [ 2267 "e" 2268 ], 2269 "single_file_paths": [ 2270 "s" 2271 ], 2272 "permissions": { 2273 "actions": "a", 2274 "administration": "ad", 2275 "checks": "c", 2276 "contents": "co", 2277 "content_references": "cr", 2278 "deployments": "d", 2279 "environments": "e", 2280 "issues": "i", 2281 "metadata": "md", 2282 "members": "m", 2283 "organization_administration": "oa", 2284 "organization_hooks": "oh", 2285 "organization_plan": "op", 2286 "organization_pre_receive_hooks": "opr", 2287 "organization_projects": "op", 2288 "organization_secrets": "os", 2289 "organization_self_hosted_runners": "osh", 2290 "organization_user_blocking": "oub", 2291 "packages": "pkg", 2292 "pages": "pg", 2293 "pull_requests": "pr", 2294 "repository_hooks": "rh", 2295 "repository_projects": "rp", 2296 "repository_pre_receive_hooks": "rprh", 2297 "secrets": "s", 2298 "secret_scanning_alerts": "ssa", 2299 "security_events": "se", 2300 "single_file": "sf", 2301 "statuses": "s", 2302 "team_discussions": "td", 2303 "vulnerability_alerts": "va", 2304 "workflows": "w" 2305 }, 2306 "created_at": ` + referenceTimeStr + `, 2307 "updated_at": ` + referenceTimeStr + `, 2308 "has_multiple_single_files": false, 2309 "suspended_by": { 2310 "login": "l", 2311 "id": 1, 2312 "avatar_url": "a", 2313 "gravatar_id": "g", 2314 "name": "n", 2315 "company": "c", 2316 "blog": "b", 2317 "location": "l", 2318 "email": "e", 2319 "hireable": true, 2320 "bio": "b", 2321 "twitter_username": "t", 2322 "public_repos": 1, 2323 "followers": 1, 2324 "following": 1, 2325 "created_at": ` + referenceTimeStr + `, 2326 "suspended_at": ` + referenceTimeStr + `, 2327 "url": "u" 2328 }, 2329 "suspended_at": ` + referenceTimeStr + ` 2330 }, 2331 "organization": { 2332 "name": "n", 2333 "company": "c", 2334 "blog": "b", 2335 "location": "loc", 2336 "email": "e", 2337 "twitter_username": "tu", 2338 "description": "d", 2339 "billing_email": "be", 2340 "is_verified": true, 2341 "has_organization_projects": true, 2342 "has_repository_projects": true, 2343 "default_repository_permission": "drp", 2344 "members_can_create_repositories": true, 2345 "members_can_create_public_repositories": false, 2346 "members_can_create_private_repositories": true, 2347 "members_can_create_internal_repositories": true, 2348 "members_allowed_repository_creation_type": "marct", 2349 "members_can_create_pages": true, 2350 "members_can_create_public_pages": false, 2351 "members_can_create_private_pages": true 2352 } 2353 }` 2354 2355 testJSONMarshal(t, u, want) 2356 } 2357 2358 func TestIssuesEvent_Marshal(t *testing.T) { 2359 testJSONMarshal(t, &IssuesEvent{}, "{}") 2360 2361 u := &IssuesEvent{ 2362 Action: String("a"), 2363 Issue: &Issue{ID: Int64(1)}, 2364 Assignee: &User{ 2365 Login: String("l"), 2366 ID: Int64(1), 2367 NodeID: String("n"), 2368 URL: String("u"), 2369 ReposURL: String("r"), 2370 EventsURL: String("e"), 2371 AvatarURL: String("a"), 2372 }, 2373 Label: &Label{ID: Int64(1)}, 2374 Changes: &EditChange{ 2375 Title: &EditTitle{ 2376 From: String("TitleFrom"), 2377 }, 2378 Body: &EditBody{ 2379 From: String("BodyFrom"), 2380 }, 2381 Base: &EditBase{ 2382 Ref: &EditRef{ 2383 From: String("BaseRefFrom"), 2384 }, 2385 SHA: &EditSHA{ 2386 From: String("BaseSHAFrom"), 2387 }, 2388 }, 2389 }, 2390 Repo: &Repository{ 2391 ID: Int64(1), 2392 URL: String("s"), 2393 Name: String("n"), 2394 }, 2395 Sender: &User{ 2396 Login: String("l"), 2397 ID: Int64(1), 2398 NodeID: String("n"), 2399 URL: String("u"), 2400 ReposURL: String("r"), 2401 EventsURL: String("e"), 2402 AvatarURL: String("a"), 2403 }, 2404 Installation: &Installation{ 2405 ID: Int64(1), 2406 NodeID: String("nid"), 2407 AppID: Int64(1), 2408 AppSlug: String("as"), 2409 TargetID: Int64(1), 2410 Account: &User{ 2411 Login: String("l"), 2412 ID: Int64(1), 2413 URL: String("u"), 2414 AvatarURL: String("a"), 2415 GravatarID: String("g"), 2416 Name: String("n"), 2417 Company: String("c"), 2418 Blog: String("b"), 2419 Location: String("l"), 2420 Email: String("e"), 2421 Hireable: Bool(true), 2422 Bio: String("b"), 2423 TwitterUsername: String("t"), 2424 PublicRepos: Int(1), 2425 Followers: Int(1), 2426 Following: Int(1), 2427 CreatedAt: &Timestamp{referenceTime}, 2428 SuspendedAt: &Timestamp{referenceTime}, 2429 }, 2430 AccessTokensURL: String("atu"), 2431 RepositoriesURL: String("ru"), 2432 HTMLURL: String("hu"), 2433 TargetType: String("tt"), 2434 SingleFileName: String("sfn"), 2435 RepositorySelection: String("rs"), 2436 Events: []string{"e"}, 2437 SingleFilePaths: []string{"s"}, 2438 Permissions: &InstallationPermissions{ 2439 Actions: String("a"), 2440 Administration: String("ad"), 2441 Checks: String("c"), 2442 Contents: String("co"), 2443 ContentReferences: String("cr"), 2444 Deployments: String("d"), 2445 Environments: String("e"), 2446 Issues: String("i"), 2447 Metadata: String("md"), 2448 Members: String("m"), 2449 OrganizationAdministration: String("oa"), 2450 OrganizationHooks: String("oh"), 2451 OrganizationPlan: String("op"), 2452 OrganizationPreReceiveHooks: String("opr"), 2453 OrganizationProjects: String("op"), 2454 OrganizationSecrets: String("os"), 2455 OrganizationSelfHostedRunners: String("osh"), 2456 OrganizationUserBlocking: String("oub"), 2457 Packages: String("pkg"), 2458 Pages: String("pg"), 2459 PullRequests: String("pr"), 2460 RepositoryHooks: String("rh"), 2461 RepositoryProjects: String("rp"), 2462 RepositoryPreReceiveHooks: String("rprh"), 2463 Secrets: String("s"), 2464 SecretScanningAlerts: String("ssa"), 2465 SecurityEvents: String("se"), 2466 SingleFile: String("sf"), 2467 Statuses: String("s"), 2468 TeamDiscussions: String("td"), 2469 VulnerabilityAlerts: String("va"), 2470 Workflows: String("w"), 2471 }, 2472 CreatedAt: &Timestamp{referenceTime}, 2473 UpdatedAt: &Timestamp{referenceTime}, 2474 HasMultipleSingleFiles: Bool(false), 2475 SuspendedBy: &User{ 2476 Login: String("l"), 2477 ID: Int64(1), 2478 URL: String("u"), 2479 AvatarURL: String("a"), 2480 GravatarID: String("g"), 2481 Name: String("n"), 2482 Company: String("c"), 2483 Blog: String("b"), 2484 Location: String("l"), 2485 Email: String("e"), 2486 Hireable: Bool(true), 2487 Bio: String("b"), 2488 TwitterUsername: String("t"), 2489 PublicRepos: Int(1), 2490 Followers: Int(1), 2491 Following: Int(1), 2492 CreatedAt: &Timestamp{referenceTime}, 2493 SuspendedAt: &Timestamp{referenceTime}, 2494 }, 2495 SuspendedAt: &Timestamp{referenceTime}, 2496 }, 2497 } 2498 2499 want := `{ 2500 "action": "a", 2501 "issue": { 2502 "id": 1 2503 }, 2504 "assignee": { 2505 "login": "l", 2506 "id": 1, 2507 "node_id": "n", 2508 "avatar_url": "a", 2509 "url": "u", 2510 "events_url": "e", 2511 "repos_url": "r" 2512 }, 2513 "label": { 2514 "id": 1 2515 }, 2516 "changes": { 2517 "title": { 2518 "from": "TitleFrom" 2519 }, 2520 "body": { 2521 "from": "BodyFrom" 2522 }, 2523 "base": { 2524 "ref": { 2525 "from": "BaseRefFrom" 2526 }, 2527 "sha": { 2528 "from": "BaseSHAFrom" 2529 } 2530 } 2531 }, 2532 "repository": { 2533 "id": 1, 2534 "name": "n", 2535 "url": "s" 2536 }, 2537 "sender": { 2538 "login": "l", 2539 "id": 1, 2540 "node_id": "n", 2541 "avatar_url": "a", 2542 "url": "u", 2543 "events_url": "e", 2544 "repos_url": "r" 2545 }, 2546 "installation": { 2547 "id": 1, 2548 "node_id": "nid", 2549 "app_id": 1, 2550 "app_slug": "as", 2551 "target_id": 1, 2552 "account": { 2553 "login": "l", 2554 "id": 1, 2555 "avatar_url": "a", 2556 "gravatar_id": "g", 2557 "name": "n", 2558 "company": "c", 2559 "blog": "b", 2560 "location": "l", 2561 "email": "e", 2562 "hireable": true, 2563 "bio": "b", 2564 "twitter_username": "t", 2565 "public_repos": 1, 2566 "followers": 1, 2567 "following": 1, 2568 "created_at": ` + referenceTimeStr + `, 2569 "suspended_at": ` + referenceTimeStr + `, 2570 "url": "u" 2571 }, 2572 "access_tokens_url": "atu", 2573 "repositories_url": "ru", 2574 "html_url": "hu", 2575 "target_type": "tt", 2576 "single_file_name": "sfn", 2577 "repository_selection": "rs", 2578 "events": [ 2579 "e" 2580 ], 2581 "single_file_paths": [ 2582 "s" 2583 ], 2584 "permissions": { 2585 "actions": "a", 2586 "administration": "ad", 2587 "checks": "c", 2588 "contents": "co", 2589 "content_references": "cr", 2590 "deployments": "d", 2591 "environments": "e", 2592 "issues": "i", 2593 "metadata": "md", 2594 "members": "m", 2595 "organization_administration": "oa", 2596 "organization_hooks": "oh", 2597 "organization_plan": "op", 2598 "organization_pre_receive_hooks": "opr", 2599 "organization_projects": "op", 2600 "organization_secrets": "os", 2601 "organization_self_hosted_runners": "osh", 2602 "organization_user_blocking": "oub", 2603 "packages": "pkg", 2604 "pages": "pg", 2605 "pull_requests": "pr", 2606 "repository_hooks": "rh", 2607 "repository_projects": "rp", 2608 "repository_pre_receive_hooks": "rprh", 2609 "secrets": "s", 2610 "secret_scanning_alerts": "ssa", 2611 "security_events": "se", 2612 "single_file": "sf", 2613 "statuses": "s", 2614 "team_discussions": "td", 2615 "vulnerability_alerts": "va", 2616 "workflows": "w" 2617 }, 2618 "created_at": ` + referenceTimeStr + `, 2619 "updated_at": ` + referenceTimeStr + `, 2620 "has_multiple_single_files": false, 2621 "suspended_by": { 2622 "login": "l", 2623 "id": 1, 2624 "avatar_url": "a", 2625 "gravatar_id": "g", 2626 "name": "n", 2627 "company": "c", 2628 "blog": "b", 2629 "location": "l", 2630 "email": "e", 2631 "hireable": true, 2632 "bio": "b", 2633 "twitter_username": "t", 2634 "public_repos": 1, 2635 "followers": 1, 2636 "following": 1, 2637 "created_at": ` + referenceTimeStr + `, 2638 "suspended_at": ` + referenceTimeStr + `, 2639 "url": "u" 2640 }, 2641 "suspended_at": ` + referenceTimeStr + ` 2642 } 2643 }` 2644 2645 testJSONMarshal(t, u, want) 2646 } 2647 2648 func TestLabelEvent_Marshal(t *testing.T) { 2649 testJSONMarshal(t, &LabelEvent{}, "{}") 2650 2651 u := &LabelEvent{ 2652 Action: String("a"), 2653 Label: &Label{ID: Int64(1)}, 2654 Changes: &EditChange{ 2655 Title: &EditTitle{ 2656 From: String("TitleFrom"), 2657 }, 2658 Body: &EditBody{ 2659 From: String("BodyFrom"), 2660 }, 2661 Base: &EditBase{ 2662 Ref: &EditRef{ 2663 From: String("BaseRefFrom"), 2664 }, 2665 SHA: &EditSHA{ 2666 From: String("BaseSHAFrom"), 2667 }, 2668 }, 2669 }, 2670 Repo: &Repository{ 2671 ID: Int64(1), 2672 URL: String("s"), 2673 Name: String("n"), 2674 }, 2675 Org: &Organization{ 2676 BillingEmail: String("be"), 2677 Blog: String("b"), 2678 Company: String("c"), 2679 Email: String("e"), 2680 TwitterUsername: String("tu"), 2681 Location: String("loc"), 2682 Name: String("n"), 2683 Description: String("d"), 2684 IsVerified: Bool(true), 2685 HasOrganizationProjects: Bool(true), 2686 HasRepositoryProjects: Bool(true), 2687 DefaultRepoPermission: String("drp"), 2688 MembersCanCreateRepos: Bool(true), 2689 MembersCanCreateInternalRepos: Bool(true), 2690 MembersCanCreatePrivateRepos: Bool(true), 2691 MembersCanCreatePublicRepos: Bool(false), 2692 MembersAllowedRepositoryCreationType: String("marct"), 2693 MembersCanCreatePages: Bool(true), 2694 MembersCanCreatePublicPages: Bool(false), 2695 MembersCanCreatePrivatePages: Bool(true), 2696 }, 2697 Installation: &Installation{ 2698 ID: Int64(1), 2699 NodeID: String("nid"), 2700 AppID: Int64(1), 2701 AppSlug: String("as"), 2702 TargetID: Int64(1), 2703 Account: &User{ 2704 Login: String("l"), 2705 ID: Int64(1), 2706 URL: String("u"), 2707 AvatarURL: String("a"), 2708 GravatarID: String("g"), 2709 Name: String("n"), 2710 Company: String("c"), 2711 Blog: String("b"), 2712 Location: String("l"), 2713 Email: String("e"), 2714 Hireable: Bool(true), 2715 Bio: String("b"), 2716 TwitterUsername: String("t"), 2717 PublicRepos: Int(1), 2718 Followers: Int(1), 2719 Following: Int(1), 2720 CreatedAt: &Timestamp{referenceTime}, 2721 SuspendedAt: &Timestamp{referenceTime}, 2722 }, 2723 AccessTokensURL: String("atu"), 2724 RepositoriesURL: String("ru"), 2725 HTMLURL: String("hu"), 2726 TargetType: String("tt"), 2727 SingleFileName: String("sfn"), 2728 RepositorySelection: String("rs"), 2729 Events: []string{"e"}, 2730 SingleFilePaths: []string{"s"}, 2731 Permissions: &InstallationPermissions{ 2732 Actions: String("a"), 2733 Administration: String("ad"), 2734 Checks: String("c"), 2735 Contents: String("co"), 2736 ContentReferences: String("cr"), 2737 Deployments: String("d"), 2738 Environments: String("e"), 2739 Issues: String("i"), 2740 Metadata: String("md"), 2741 Members: String("m"), 2742 OrganizationAdministration: String("oa"), 2743 OrganizationHooks: String("oh"), 2744 OrganizationPlan: String("op"), 2745 OrganizationPreReceiveHooks: String("opr"), 2746 OrganizationProjects: String("op"), 2747 OrganizationSecrets: String("os"), 2748 OrganizationSelfHostedRunners: String("osh"), 2749 OrganizationUserBlocking: String("oub"), 2750 Packages: String("pkg"), 2751 Pages: String("pg"), 2752 PullRequests: String("pr"), 2753 RepositoryHooks: String("rh"), 2754 RepositoryProjects: String("rp"), 2755 RepositoryPreReceiveHooks: String("rprh"), 2756 Secrets: String("s"), 2757 SecretScanningAlerts: String("ssa"), 2758 SecurityEvents: String("se"), 2759 SingleFile: String("sf"), 2760 Statuses: String("s"), 2761 TeamDiscussions: String("td"), 2762 VulnerabilityAlerts: String("va"), 2763 Workflows: String("w"), 2764 }, 2765 CreatedAt: &Timestamp{referenceTime}, 2766 UpdatedAt: &Timestamp{referenceTime}, 2767 HasMultipleSingleFiles: Bool(false), 2768 SuspendedBy: &User{ 2769 Login: String("l"), 2770 ID: Int64(1), 2771 URL: String("u"), 2772 AvatarURL: String("a"), 2773 GravatarID: String("g"), 2774 Name: String("n"), 2775 Company: String("c"), 2776 Blog: String("b"), 2777 Location: String("l"), 2778 Email: String("e"), 2779 Hireable: Bool(true), 2780 Bio: String("b"), 2781 TwitterUsername: String("t"), 2782 PublicRepos: Int(1), 2783 Followers: Int(1), 2784 Following: Int(1), 2785 CreatedAt: &Timestamp{referenceTime}, 2786 SuspendedAt: &Timestamp{referenceTime}, 2787 }, 2788 SuspendedAt: &Timestamp{referenceTime}, 2789 }, 2790 } 2791 2792 want := `{ 2793 "action": "a", 2794 "label": { 2795 "id": 1 2796 }, 2797 "changes": { 2798 "title": { 2799 "from": "TitleFrom" 2800 }, 2801 "body": { 2802 "from": "BodyFrom" 2803 }, 2804 "base": { 2805 "ref": { 2806 "from": "BaseRefFrom" 2807 }, 2808 "sha": { 2809 "from": "BaseSHAFrom" 2810 } 2811 } 2812 }, 2813 "repository": { 2814 "id": 1, 2815 "name": "n", 2816 "url": "s" 2817 }, 2818 "organization": { 2819 "name": "n", 2820 "company": "c", 2821 "blog": "b", 2822 "location": "loc", 2823 "email": "e", 2824 "twitter_username": "tu", 2825 "description": "d", 2826 "billing_email": "be", 2827 "is_verified": true, 2828 "has_organization_projects": true, 2829 "has_repository_projects": true, 2830 "default_repository_permission": "drp", 2831 "members_can_create_repositories": true, 2832 "members_can_create_public_repositories": false, 2833 "members_can_create_private_repositories": true, 2834 "members_can_create_internal_repositories": true, 2835 "members_allowed_repository_creation_type": "marct", 2836 "members_can_create_pages": true, 2837 "members_can_create_public_pages": false, 2838 "members_can_create_private_pages": true 2839 }, 2840 "installation": { 2841 "id": 1, 2842 "node_id": "nid", 2843 "app_id": 1, 2844 "app_slug": "as", 2845 "target_id": 1, 2846 "account": { 2847 "login": "l", 2848 "id": 1, 2849 "avatar_url": "a", 2850 "gravatar_id": "g", 2851 "name": "n", 2852 "company": "c", 2853 "blog": "b", 2854 "location": "l", 2855 "email": "e", 2856 "hireable": true, 2857 "bio": "b", 2858 "twitter_username": "t", 2859 "public_repos": 1, 2860 "followers": 1, 2861 "following": 1, 2862 "created_at": ` + referenceTimeStr + `, 2863 "suspended_at": ` + referenceTimeStr + `, 2864 "url": "u" 2865 }, 2866 "access_tokens_url": "atu", 2867 "repositories_url": "ru", 2868 "html_url": "hu", 2869 "target_type": "tt", 2870 "single_file_name": "sfn", 2871 "repository_selection": "rs", 2872 "events": [ 2873 "e" 2874 ], 2875 "single_file_paths": [ 2876 "s" 2877 ], 2878 "permissions": { 2879 "actions": "a", 2880 "administration": "ad", 2881 "checks": "c", 2882 "contents": "co", 2883 "content_references": "cr", 2884 "deployments": "d", 2885 "environments": "e", 2886 "issues": "i", 2887 "metadata": "md", 2888 "members": "m", 2889 "organization_administration": "oa", 2890 "organization_hooks": "oh", 2891 "organization_plan": "op", 2892 "organization_pre_receive_hooks": "opr", 2893 "organization_projects": "op", 2894 "organization_secrets": "os", 2895 "organization_self_hosted_runners": "osh", 2896 "organization_user_blocking": "oub", 2897 "packages": "pkg", 2898 "pages": "pg", 2899 "pull_requests": "pr", 2900 "repository_hooks": "rh", 2901 "repository_projects": "rp", 2902 "repository_pre_receive_hooks": "rprh", 2903 "secrets": "s", 2904 "secret_scanning_alerts": "ssa", 2905 "security_events": "se", 2906 "single_file": "sf", 2907 "statuses": "s", 2908 "team_discussions": "td", 2909 "vulnerability_alerts": "va", 2910 "workflows": "w" 2911 }, 2912 "created_at": ` + referenceTimeStr + `, 2913 "updated_at": ` + referenceTimeStr + `, 2914 "has_multiple_single_files": false, 2915 "suspended_by": { 2916 "login": "l", 2917 "id": 1, 2918 "avatar_url": "a", 2919 "gravatar_id": "g", 2920 "name": "n", 2921 "company": "c", 2922 "blog": "b", 2923 "location": "l", 2924 "email": "e", 2925 "hireable": true, 2926 "bio": "b", 2927 "twitter_username": "t", 2928 "public_repos": 1, 2929 "followers": 1, 2930 "following": 1, 2931 "created_at": ` + referenceTimeStr + `, 2932 "suspended_at": ` + referenceTimeStr + `, 2933 "url": "u" 2934 }, 2935 "suspended_at": ` + referenceTimeStr + ` 2936 } 2937 }` 2938 2939 testJSONMarshal(t, u, want) 2940 } 2941 2942 func TestMilestoneEvent_Marshal(t *testing.T) { 2943 testJSONMarshal(t, &MilestoneEvent{}, "{}") 2944 2945 u := &MilestoneEvent{ 2946 Action: String("a"), 2947 Milestone: &Milestone{ID: Int64(1)}, 2948 Changes: &EditChange{ 2949 Title: &EditTitle{ 2950 From: String("TitleFrom"), 2951 }, 2952 Body: &EditBody{ 2953 From: String("BodyFrom"), 2954 }, 2955 Base: &EditBase{ 2956 Ref: &EditRef{ 2957 From: String("BaseRefFrom"), 2958 }, 2959 SHA: &EditSHA{ 2960 From: String("BaseSHAFrom"), 2961 }, 2962 }, 2963 }, 2964 Repo: &Repository{ 2965 ID: Int64(1), 2966 URL: String("s"), 2967 Name: String("n"), 2968 }, 2969 Sender: &User{ 2970 Login: String("l"), 2971 ID: Int64(1), 2972 NodeID: String("n"), 2973 URL: String("u"), 2974 ReposURL: String("r"), 2975 EventsURL: String("e"), 2976 AvatarURL: String("a"), 2977 }, 2978 Org: &Organization{ 2979 BillingEmail: String("be"), 2980 Blog: String("b"), 2981 Company: String("c"), 2982 Email: String("e"), 2983 TwitterUsername: String("tu"), 2984 Location: String("loc"), 2985 Name: String("n"), 2986 Description: String("d"), 2987 IsVerified: Bool(true), 2988 HasOrganizationProjects: Bool(true), 2989 HasRepositoryProjects: Bool(true), 2990 DefaultRepoPermission: String("drp"), 2991 MembersCanCreateRepos: Bool(true), 2992 MembersCanCreateInternalRepos: Bool(true), 2993 MembersCanCreatePrivateRepos: Bool(true), 2994 MembersCanCreatePublicRepos: Bool(false), 2995 MembersAllowedRepositoryCreationType: String("marct"), 2996 MembersCanCreatePages: Bool(true), 2997 MembersCanCreatePublicPages: Bool(false), 2998 MembersCanCreatePrivatePages: Bool(true), 2999 }, 3000 Installation: &Installation{ 3001 ID: Int64(1), 3002 NodeID: String("nid"), 3003 AppID: Int64(1), 3004 AppSlug: String("as"), 3005 TargetID: Int64(1), 3006 Account: &User{ 3007 Login: String("l"), 3008 ID: Int64(1), 3009 URL: String("u"), 3010 AvatarURL: String("a"), 3011 GravatarID: String("g"), 3012 Name: String("n"), 3013 Company: String("c"), 3014 Blog: String("b"), 3015 Location: String("l"), 3016 Email: String("e"), 3017 Hireable: Bool(true), 3018 Bio: String("b"), 3019 TwitterUsername: String("t"), 3020 PublicRepos: Int(1), 3021 Followers: Int(1), 3022 Following: Int(1), 3023 CreatedAt: &Timestamp{referenceTime}, 3024 SuspendedAt: &Timestamp{referenceTime}, 3025 }, 3026 AccessTokensURL: String("atu"), 3027 RepositoriesURL: String("ru"), 3028 HTMLURL: String("hu"), 3029 TargetType: String("tt"), 3030 SingleFileName: String("sfn"), 3031 RepositorySelection: String("rs"), 3032 Events: []string{"e"}, 3033 SingleFilePaths: []string{"s"}, 3034 Permissions: &InstallationPermissions{ 3035 Actions: String("a"), 3036 Administration: String("ad"), 3037 Checks: String("c"), 3038 Contents: String("co"), 3039 ContentReferences: String("cr"), 3040 Deployments: String("d"), 3041 Environments: String("e"), 3042 Issues: String("i"), 3043 Metadata: String("md"), 3044 Members: String("m"), 3045 OrganizationAdministration: String("oa"), 3046 OrganizationHooks: String("oh"), 3047 OrganizationPlan: String("op"), 3048 OrganizationPreReceiveHooks: String("opr"), 3049 OrganizationProjects: String("op"), 3050 OrganizationSecrets: String("os"), 3051 OrganizationSelfHostedRunners: String("osh"), 3052 OrganizationUserBlocking: String("oub"), 3053 Packages: String("pkg"), 3054 Pages: String("pg"), 3055 PullRequests: String("pr"), 3056 RepositoryHooks: String("rh"), 3057 RepositoryProjects: String("rp"), 3058 RepositoryPreReceiveHooks: String("rprh"), 3059 Secrets: String("s"), 3060 SecretScanningAlerts: String("ssa"), 3061 SecurityEvents: String("se"), 3062 SingleFile: String("sf"), 3063 Statuses: String("s"), 3064 TeamDiscussions: String("td"), 3065 VulnerabilityAlerts: String("va"), 3066 Workflows: String("w"), 3067 }, 3068 CreatedAt: &Timestamp{referenceTime}, 3069 UpdatedAt: &Timestamp{referenceTime}, 3070 HasMultipleSingleFiles: Bool(false), 3071 SuspendedBy: &User{ 3072 Login: String("l"), 3073 ID: Int64(1), 3074 URL: String("u"), 3075 AvatarURL: String("a"), 3076 GravatarID: String("g"), 3077 Name: String("n"), 3078 Company: String("c"), 3079 Blog: String("b"), 3080 Location: String("l"), 3081 Email: String("e"), 3082 Hireable: Bool(true), 3083 Bio: String("b"), 3084 TwitterUsername: String("t"), 3085 PublicRepos: Int(1), 3086 Followers: Int(1), 3087 Following: Int(1), 3088 CreatedAt: &Timestamp{referenceTime}, 3089 SuspendedAt: &Timestamp{referenceTime}, 3090 }, 3091 SuspendedAt: &Timestamp{referenceTime}, 3092 }, 3093 } 3094 3095 want := `{ 3096 "action": "a", 3097 "milestone": { 3098 "id": 1 3099 }, 3100 "changes": { 3101 "title": { 3102 "from": "TitleFrom" 3103 }, 3104 "body": { 3105 "from": "BodyFrom" 3106 }, 3107 "base": { 3108 "ref": { 3109 "from": "BaseRefFrom" 3110 }, 3111 "sha": { 3112 "from": "BaseSHAFrom" 3113 } 3114 } 3115 }, 3116 "repository": { 3117 "id": 1, 3118 "name": "n", 3119 "url": "s" 3120 }, 3121 "sender": { 3122 "login": "l", 3123 "id": 1, 3124 "node_id": "n", 3125 "avatar_url": "a", 3126 "url": "u", 3127 "events_url": "e", 3128 "repos_url": "r" 3129 }, 3130 "organization": { 3131 "name": "n", 3132 "company": "c", 3133 "blog": "b", 3134 "location": "loc", 3135 "email": "e", 3136 "twitter_username": "tu", 3137 "description": "d", 3138 "billing_email": "be", 3139 "is_verified": true, 3140 "has_organization_projects": true, 3141 "has_repository_projects": true, 3142 "default_repository_permission": "drp", 3143 "members_can_create_repositories": true, 3144 "members_can_create_public_repositories": false, 3145 "members_can_create_private_repositories": true, 3146 "members_can_create_internal_repositories": true, 3147 "members_allowed_repository_creation_type": "marct", 3148 "members_can_create_pages": true, 3149 "members_can_create_public_pages": false, 3150 "members_can_create_private_pages": true 3151 }, 3152 "installation": { 3153 "id": 1, 3154 "node_id": "nid", 3155 "app_id": 1, 3156 "app_slug": "as", 3157 "target_id": 1, 3158 "account": { 3159 "login": "l", 3160 "id": 1, 3161 "avatar_url": "a", 3162 "gravatar_id": "g", 3163 "name": "n", 3164 "company": "c", 3165 "blog": "b", 3166 "location": "l", 3167 "email": "e", 3168 "hireable": true, 3169 "bio": "b", 3170 "twitter_username": "t", 3171 "public_repos": 1, 3172 "followers": 1, 3173 "following": 1, 3174 "created_at": ` + referenceTimeStr + `, 3175 "suspended_at": ` + referenceTimeStr + `, 3176 "url": "u" 3177 }, 3178 "access_tokens_url": "atu", 3179 "repositories_url": "ru", 3180 "html_url": "hu", 3181 "target_type": "tt", 3182 "single_file_name": "sfn", 3183 "repository_selection": "rs", 3184 "events": [ 3185 "e" 3186 ], 3187 "single_file_paths": [ 3188 "s" 3189 ], 3190 "permissions": { 3191 "actions": "a", 3192 "administration": "ad", 3193 "checks": "c", 3194 "contents": "co", 3195 "content_references": "cr", 3196 "deployments": "d", 3197 "environments": "e", 3198 "issues": "i", 3199 "metadata": "md", 3200 "members": "m", 3201 "organization_administration": "oa", 3202 "organization_hooks": "oh", 3203 "organization_plan": "op", 3204 "organization_pre_receive_hooks": "opr", 3205 "organization_projects": "op", 3206 "organization_secrets": "os", 3207 "organization_self_hosted_runners": "osh", 3208 "organization_user_blocking": "oub", 3209 "packages": "pkg", 3210 "pages": "pg", 3211 "pull_requests": "pr", 3212 "repository_hooks": "rh", 3213 "repository_projects": "rp", 3214 "repository_pre_receive_hooks": "rprh", 3215 "secrets": "s", 3216 "secret_scanning_alerts": "ssa", 3217 "security_events": "se", 3218 "single_file": "sf", 3219 "statuses": "s", 3220 "team_discussions": "td", 3221 "vulnerability_alerts": "va", 3222 "workflows": "w" 3223 }, 3224 "created_at": ` + referenceTimeStr + `, 3225 "updated_at": ` + referenceTimeStr + `, 3226 "has_multiple_single_files": false, 3227 "suspended_by": { 3228 "login": "l", 3229 "id": 1, 3230 "avatar_url": "a", 3231 "gravatar_id": "g", 3232 "name": "n", 3233 "company": "c", 3234 "blog": "b", 3235 "location": "l", 3236 "email": "e", 3237 "hireable": true, 3238 "bio": "b", 3239 "twitter_username": "t", 3240 "public_repos": 1, 3241 "followers": 1, 3242 "following": 1, 3243 "created_at": ` + referenceTimeStr + `, 3244 "suspended_at": ` + referenceTimeStr + `, 3245 "url": "u" 3246 }, 3247 "suspended_at": ` + referenceTimeStr + ` 3248 } 3249 }` 3250 3251 testJSONMarshal(t, u, want) 3252 } 3253 3254 func TestPublicEvent_Marshal(t *testing.T) { 3255 testJSONMarshal(t, &PublicEvent{}, "{}") 3256 3257 u := &PublicEvent{ 3258 Repo: &Repository{ 3259 ID: Int64(1), 3260 URL: String("s"), 3261 Name: String("n"), 3262 }, 3263 Sender: &User{ 3264 Login: String("l"), 3265 ID: Int64(1), 3266 NodeID: String("n"), 3267 URL: String("u"), 3268 ReposURL: String("r"), 3269 EventsURL: String("e"), 3270 AvatarURL: String("a"), 3271 }, 3272 Installation: &Installation{ 3273 ID: Int64(1), 3274 NodeID: String("nid"), 3275 AppID: Int64(1), 3276 AppSlug: String("as"), 3277 TargetID: Int64(1), 3278 Account: &User{ 3279 Login: String("l"), 3280 ID: Int64(1), 3281 URL: String("u"), 3282 AvatarURL: String("a"), 3283 GravatarID: String("g"), 3284 Name: String("n"), 3285 Company: String("c"), 3286 Blog: String("b"), 3287 Location: String("l"), 3288 Email: String("e"), 3289 Hireable: Bool(true), 3290 Bio: String("b"), 3291 TwitterUsername: String("t"), 3292 PublicRepos: Int(1), 3293 Followers: Int(1), 3294 Following: Int(1), 3295 CreatedAt: &Timestamp{referenceTime}, 3296 SuspendedAt: &Timestamp{referenceTime}, 3297 }, 3298 AccessTokensURL: String("atu"), 3299 RepositoriesURL: String("ru"), 3300 HTMLURL: String("hu"), 3301 TargetType: String("tt"), 3302 SingleFileName: String("sfn"), 3303 RepositorySelection: String("rs"), 3304 Events: []string{"e"}, 3305 SingleFilePaths: []string{"s"}, 3306 Permissions: &InstallationPermissions{ 3307 Actions: String("a"), 3308 Administration: String("ad"), 3309 Checks: String("c"), 3310 Contents: String("co"), 3311 ContentReferences: String("cr"), 3312 Deployments: String("d"), 3313 Environments: String("e"), 3314 Issues: String("i"), 3315 Metadata: String("md"), 3316 Members: String("m"), 3317 OrganizationAdministration: String("oa"), 3318 OrganizationHooks: String("oh"), 3319 OrganizationPlan: String("op"), 3320 OrganizationPreReceiveHooks: String("opr"), 3321 OrganizationProjects: String("op"), 3322 OrganizationSecrets: String("os"), 3323 OrganizationSelfHostedRunners: String("osh"), 3324 OrganizationUserBlocking: String("oub"), 3325 Packages: String("pkg"), 3326 Pages: String("pg"), 3327 PullRequests: String("pr"), 3328 RepositoryHooks: String("rh"), 3329 RepositoryProjects: String("rp"), 3330 RepositoryPreReceiveHooks: String("rprh"), 3331 Secrets: String("s"), 3332 SecretScanningAlerts: String("ssa"), 3333 SecurityEvents: String("se"), 3334 SingleFile: String("sf"), 3335 Statuses: String("s"), 3336 TeamDiscussions: String("td"), 3337 VulnerabilityAlerts: String("va"), 3338 Workflows: String("w"), 3339 }, 3340 CreatedAt: &Timestamp{referenceTime}, 3341 UpdatedAt: &Timestamp{referenceTime}, 3342 HasMultipleSingleFiles: Bool(false), 3343 SuspendedBy: &User{ 3344 Login: String("l"), 3345 ID: Int64(1), 3346 URL: String("u"), 3347 AvatarURL: String("a"), 3348 GravatarID: String("g"), 3349 Name: String("n"), 3350 Company: String("c"), 3351 Blog: String("b"), 3352 Location: String("l"), 3353 Email: String("e"), 3354 Hireable: Bool(true), 3355 Bio: String("b"), 3356 TwitterUsername: String("t"), 3357 PublicRepos: Int(1), 3358 Followers: Int(1), 3359 Following: Int(1), 3360 CreatedAt: &Timestamp{referenceTime}, 3361 SuspendedAt: &Timestamp{referenceTime}, 3362 }, 3363 SuspendedAt: &Timestamp{referenceTime}, 3364 }, 3365 } 3366 3367 want := `{ 3368 "repository": { 3369 "id": 1, 3370 "name": "n", 3371 "url": "s" 3372 }, 3373 "sender": { 3374 "login": "l", 3375 "id": 1, 3376 "node_id": "n", 3377 "avatar_url": "a", 3378 "url": "u", 3379 "events_url": "e", 3380 "repos_url": "r" 3381 }, 3382 "installation": { 3383 "id": 1, 3384 "node_id": "nid", 3385 "app_id": 1, 3386 "app_slug": "as", 3387 "target_id": 1, 3388 "account": { 3389 "login": "l", 3390 "id": 1, 3391 "avatar_url": "a", 3392 "gravatar_id": "g", 3393 "name": "n", 3394 "company": "c", 3395 "blog": "b", 3396 "location": "l", 3397 "email": "e", 3398 "hireable": true, 3399 "bio": "b", 3400 "twitter_username": "t", 3401 "public_repos": 1, 3402 "followers": 1, 3403 "following": 1, 3404 "created_at": ` + referenceTimeStr + `, 3405 "suspended_at": ` + referenceTimeStr + `, 3406 "url": "u" 3407 }, 3408 "access_tokens_url": "atu", 3409 "repositories_url": "ru", 3410 "html_url": "hu", 3411 "target_type": "tt", 3412 "single_file_name": "sfn", 3413 "repository_selection": "rs", 3414 "events": [ 3415 "e" 3416 ], 3417 "single_file_paths": [ 3418 "s" 3419 ], 3420 "permissions": { 3421 "actions": "a", 3422 "administration": "ad", 3423 "checks": "c", 3424 "contents": "co", 3425 "content_references": "cr", 3426 "deployments": "d", 3427 "environments": "e", 3428 "issues": "i", 3429 "metadata": "md", 3430 "members": "m", 3431 "organization_administration": "oa", 3432 "organization_hooks": "oh", 3433 "organization_plan": "op", 3434 "organization_pre_receive_hooks": "opr", 3435 "organization_projects": "op", 3436 "organization_secrets": "os", 3437 "organization_self_hosted_runners": "osh", 3438 "organization_user_blocking": "oub", 3439 "packages": "pkg", 3440 "pages": "pg", 3441 "pull_requests": "pr", 3442 "repository_hooks": "rh", 3443 "repository_projects": "rp", 3444 "repository_pre_receive_hooks": "rprh", 3445 "secrets": "s", 3446 "secret_scanning_alerts": "ssa", 3447 "security_events": "se", 3448 "single_file": "sf", 3449 "statuses": "s", 3450 "team_discussions": "td", 3451 "vulnerability_alerts": "va", 3452 "workflows": "w" 3453 }, 3454 "created_at": ` + referenceTimeStr + `, 3455 "updated_at": ` + referenceTimeStr + `, 3456 "has_multiple_single_files": false, 3457 "suspended_by": { 3458 "login": "l", 3459 "id": 1, 3460 "avatar_url": "a", 3461 "gravatar_id": "g", 3462 "name": "n", 3463 "company": "c", 3464 "blog": "b", 3465 "location": "l", 3466 "email": "e", 3467 "hireable": true, 3468 "bio": "b", 3469 "twitter_username": "t", 3470 "public_repos": 1, 3471 "followers": 1, 3472 "following": 1, 3473 "created_at": ` + referenceTimeStr + `, 3474 "suspended_at": ` + referenceTimeStr + `, 3475 "url": "u" 3476 }, 3477 "suspended_at": ` + referenceTimeStr + ` 3478 } 3479 }` 3480 3481 testJSONMarshal(t, u, want) 3482 } 3483 3484 func TestPullRequestReviewEvent_Marshal(t *testing.T) { 3485 testJSONMarshal(t, &PullRequestReviewEvent{}, "{}") 3486 3487 u := &PullRequestReviewEvent{ 3488 Action: String("a"), 3489 Review: &PullRequestReview{ID: Int64(1)}, 3490 PullRequest: &PullRequest{ID: Int64(1)}, 3491 Repo: &Repository{ 3492 ID: Int64(1), 3493 URL: String("s"), 3494 Name: String("n"), 3495 }, 3496 Sender: &User{ 3497 Login: String("l"), 3498 ID: Int64(1), 3499 NodeID: String("n"), 3500 URL: String("u"), 3501 ReposURL: String("r"), 3502 EventsURL: String("e"), 3503 AvatarURL: String("a"), 3504 }, 3505 Installation: &Installation{ 3506 ID: Int64(1), 3507 NodeID: String("nid"), 3508 AppID: Int64(1), 3509 AppSlug: String("as"), 3510 TargetID: Int64(1), 3511 Account: &User{ 3512 Login: String("l"), 3513 ID: Int64(1), 3514 URL: String("u"), 3515 AvatarURL: String("a"), 3516 GravatarID: String("g"), 3517 Name: String("n"), 3518 Company: String("c"), 3519 Blog: String("b"), 3520 Location: String("l"), 3521 Email: String("e"), 3522 Hireable: Bool(true), 3523 Bio: String("b"), 3524 TwitterUsername: String("t"), 3525 PublicRepos: Int(1), 3526 Followers: Int(1), 3527 Following: Int(1), 3528 CreatedAt: &Timestamp{referenceTime}, 3529 SuspendedAt: &Timestamp{referenceTime}, 3530 }, 3531 AccessTokensURL: String("atu"), 3532 RepositoriesURL: String("ru"), 3533 HTMLURL: String("hu"), 3534 TargetType: String("tt"), 3535 SingleFileName: String("sfn"), 3536 RepositorySelection: String("rs"), 3537 Events: []string{"e"}, 3538 SingleFilePaths: []string{"s"}, 3539 Permissions: &InstallationPermissions{ 3540 Actions: String("a"), 3541 Administration: String("ad"), 3542 Checks: String("c"), 3543 Contents: String("co"), 3544 ContentReferences: String("cr"), 3545 Deployments: String("d"), 3546 Environments: String("e"), 3547 Issues: String("i"), 3548 Metadata: String("md"), 3549 Members: String("m"), 3550 OrganizationAdministration: String("oa"), 3551 OrganizationHooks: String("oh"), 3552 OrganizationPlan: String("op"), 3553 OrganizationPreReceiveHooks: String("opr"), 3554 OrganizationProjects: String("op"), 3555 OrganizationSecrets: String("os"), 3556 OrganizationSelfHostedRunners: String("osh"), 3557 OrganizationUserBlocking: String("oub"), 3558 Packages: String("pkg"), 3559 Pages: String("pg"), 3560 PullRequests: String("pr"), 3561 RepositoryHooks: String("rh"), 3562 RepositoryProjects: String("rp"), 3563 RepositoryPreReceiveHooks: String("rprh"), 3564 Secrets: String("s"), 3565 SecretScanningAlerts: String("ssa"), 3566 SecurityEvents: String("se"), 3567 SingleFile: String("sf"), 3568 Statuses: String("s"), 3569 TeamDiscussions: String("td"), 3570 VulnerabilityAlerts: String("va"), 3571 Workflows: String("w"), 3572 }, 3573 CreatedAt: &Timestamp{referenceTime}, 3574 UpdatedAt: &Timestamp{referenceTime}, 3575 HasMultipleSingleFiles: Bool(false), 3576 SuspendedBy: &User{ 3577 Login: String("l"), 3578 ID: Int64(1), 3579 URL: String("u"), 3580 AvatarURL: String("a"), 3581 GravatarID: String("g"), 3582 Name: String("n"), 3583 Company: String("c"), 3584 Blog: String("b"), 3585 Location: String("l"), 3586 Email: String("e"), 3587 Hireable: Bool(true), 3588 Bio: String("b"), 3589 TwitterUsername: String("t"), 3590 PublicRepos: Int(1), 3591 Followers: Int(1), 3592 Following: Int(1), 3593 CreatedAt: &Timestamp{referenceTime}, 3594 SuspendedAt: &Timestamp{referenceTime}, 3595 }, 3596 SuspendedAt: &Timestamp{referenceTime}, 3597 }, 3598 Organization: &Organization{ 3599 BillingEmail: String("be"), 3600 Blog: String("b"), 3601 Company: String("c"), 3602 Email: String("e"), 3603 TwitterUsername: String("tu"), 3604 Location: String("loc"), 3605 Name: String("n"), 3606 Description: String("d"), 3607 IsVerified: Bool(true), 3608 HasOrganizationProjects: Bool(true), 3609 HasRepositoryProjects: Bool(true), 3610 DefaultRepoPermission: String("drp"), 3611 MembersCanCreateRepos: Bool(true), 3612 MembersCanCreateInternalRepos: Bool(true), 3613 MembersCanCreatePrivateRepos: Bool(true), 3614 MembersCanCreatePublicRepos: Bool(false), 3615 MembersAllowedRepositoryCreationType: String("marct"), 3616 MembersCanCreatePages: Bool(true), 3617 MembersCanCreatePublicPages: Bool(false), 3618 MembersCanCreatePrivatePages: Bool(true), 3619 }, 3620 } 3621 3622 want := `{ 3623 "action": "a", 3624 "review": { 3625 "id": 1 3626 }, 3627 "pull_request": { 3628 "id": 1 3629 }, 3630 "repository": { 3631 "id": 1, 3632 "name": "n", 3633 "url": "s" 3634 }, 3635 "sender": { 3636 "login": "l", 3637 "id": 1, 3638 "node_id": "n", 3639 "avatar_url": "a", 3640 "url": "u", 3641 "events_url": "e", 3642 "repos_url": "r" 3643 }, 3644 "installation": { 3645 "id": 1, 3646 "node_id": "nid", 3647 "app_id": 1, 3648 "app_slug": "as", 3649 "target_id": 1, 3650 "account": { 3651 "login": "l", 3652 "id": 1, 3653 "avatar_url": "a", 3654 "gravatar_id": "g", 3655 "name": "n", 3656 "company": "c", 3657 "blog": "b", 3658 "location": "l", 3659 "email": "e", 3660 "hireable": true, 3661 "bio": "b", 3662 "twitter_username": "t", 3663 "public_repos": 1, 3664 "followers": 1, 3665 "following": 1, 3666 "created_at": ` + referenceTimeStr + `, 3667 "suspended_at": ` + referenceTimeStr + `, 3668 "url": "u" 3669 }, 3670 "access_tokens_url": "atu", 3671 "repositories_url": "ru", 3672 "html_url": "hu", 3673 "target_type": "tt", 3674 "single_file_name": "sfn", 3675 "repository_selection": "rs", 3676 "events": [ 3677 "e" 3678 ], 3679 "single_file_paths": [ 3680 "s" 3681 ], 3682 "permissions": { 3683 "actions": "a", 3684 "administration": "ad", 3685 "checks": "c", 3686 "contents": "co", 3687 "content_references": "cr", 3688 "deployments": "d", 3689 "environments": "e", 3690 "issues": "i", 3691 "metadata": "md", 3692 "members": "m", 3693 "organization_administration": "oa", 3694 "organization_hooks": "oh", 3695 "organization_plan": "op", 3696 "organization_pre_receive_hooks": "opr", 3697 "organization_projects": "op", 3698 "organization_secrets": "os", 3699 "organization_self_hosted_runners": "osh", 3700 "organization_user_blocking": "oub", 3701 "packages": "pkg", 3702 "pages": "pg", 3703 "pull_requests": "pr", 3704 "repository_hooks": "rh", 3705 "repository_projects": "rp", 3706 "repository_pre_receive_hooks": "rprh", 3707 "secrets": "s", 3708 "secret_scanning_alerts": "ssa", 3709 "security_events": "se", 3710 "single_file": "sf", 3711 "statuses": "s", 3712 "team_discussions": "td", 3713 "vulnerability_alerts": "va", 3714 "workflows": "w" 3715 }, 3716 "created_at": ` + referenceTimeStr + `, 3717 "updated_at": ` + referenceTimeStr + `, 3718 "has_multiple_single_files": false, 3719 "suspended_by": { 3720 "login": "l", 3721 "id": 1, 3722 "avatar_url": "a", 3723 "gravatar_id": "g", 3724 "name": "n", 3725 "company": "c", 3726 "blog": "b", 3727 "location": "l", 3728 "email": "e", 3729 "hireable": true, 3730 "bio": "b", 3731 "twitter_username": "t", 3732 "public_repos": 1, 3733 "followers": 1, 3734 "following": 1, 3735 "created_at": ` + referenceTimeStr + `, 3736 "suspended_at": ` + referenceTimeStr + `, 3737 "url": "u" 3738 }, 3739 "suspended_at": ` + referenceTimeStr + ` 3740 }, 3741 "organization": { 3742 "name": "n", 3743 "company": "c", 3744 "blog": "b", 3745 "location": "loc", 3746 "email": "e", 3747 "twitter_username": "tu", 3748 "description": "d", 3749 "billing_email": "be", 3750 "is_verified": true, 3751 "has_organization_projects": true, 3752 "has_repository_projects": true, 3753 "default_repository_permission": "drp", 3754 "members_can_create_repositories": true, 3755 "members_can_create_public_repositories": false, 3756 "members_can_create_private_repositories": true, 3757 "members_can_create_internal_repositories": true, 3758 "members_allowed_repository_creation_type": "marct", 3759 "members_can_create_pages": true, 3760 "members_can_create_public_pages": false, 3761 "members_can_create_private_pages": true 3762 } 3763 }` 3764 3765 testJSONMarshal(t, u, want) 3766 } 3767 3768 func TestPushEvent_Marshal(t *testing.T) { 3769 testJSONMarshal(t, &PushEvent{}, "{}") 3770 3771 u := &PushEvent{ 3772 PushID: Int64(1), 3773 Head: String("h"), 3774 Ref: String("ref"), 3775 Size: Int(1), 3776 Commits: []*HeadCommit{ 3777 {ID: String("id")}, 3778 }, 3779 Before: String("b"), 3780 DistinctSize: Int(1), 3781 After: String("a"), 3782 Created: Bool(true), 3783 Deleted: Bool(true), 3784 Forced: Bool(true), 3785 BaseRef: String("a"), 3786 Compare: String("a"), 3787 Repo: &PushEventRepository{ID: Int64(1)}, 3788 HeadCommit: &HeadCommit{ID: String("id")}, 3789 Pusher: &CommitAuthor{ 3790 Login: String("l"), 3791 Date: &Timestamp{referenceTime}, 3792 Name: String("n"), 3793 Email: String("e"), 3794 }, 3795 Sender: &User{ 3796 Login: String("l"), 3797 ID: Int64(1), 3798 NodeID: String("n"), 3799 URL: String("u"), 3800 ReposURL: String("r"), 3801 EventsURL: String("e"), 3802 AvatarURL: String("a"), 3803 }, 3804 Installation: &Installation{ 3805 ID: Int64(1), 3806 NodeID: String("nid"), 3807 AppID: Int64(1), 3808 AppSlug: String("as"), 3809 TargetID: Int64(1), 3810 Account: &User{ 3811 Login: String("l"), 3812 ID: Int64(1), 3813 URL: String("u"), 3814 AvatarURL: String("a"), 3815 GravatarID: String("g"), 3816 Name: String("n"), 3817 Company: String("c"), 3818 Blog: String("b"), 3819 Location: String("l"), 3820 Email: String("e"), 3821 Hireable: Bool(true), 3822 Bio: String("b"), 3823 TwitterUsername: String("t"), 3824 PublicRepos: Int(1), 3825 Followers: Int(1), 3826 Following: Int(1), 3827 CreatedAt: &Timestamp{referenceTime}, 3828 SuspendedAt: &Timestamp{referenceTime}, 3829 }, 3830 AccessTokensURL: String("atu"), 3831 RepositoriesURL: String("ru"), 3832 HTMLURL: String("hu"), 3833 TargetType: String("tt"), 3834 SingleFileName: String("sfn"), 3835 RepositorySelection: String("rs"), 3836 Events: []string{"e"}, 3837 SingleFilePaths: []string{"s"}, 3838 Permissions: &InstallationPermissions{ 3839 Actions: String("a"), 3840 Administration: String("ad"), 3841 Checks: String("c"), 3842 Contents: String("co"), 3843 ContentReferences: String("cr"), 3844 Deployments: String("d"), 3845 Environments: String("e"), 3846 Issues: String("i"), 3847 Metadata: String("md"), 3848 Members: String("m"), 3849 OrganizationAdministration: String("oa"), 3850 OrganizationHooks: String("oh"), 3851 OrganizationPlan: String("op"), 3852 OrganizationPreReceiveHooks: String("opr"), 3853 OrganizationProjects: String("op"), 3854 OrganizationSecrets: String("os"), 3855 OrganizationSelfHostedRunners: String("osh"), 3856 OrganizationUserBlocking: String("oub"), 3857 Packages: String("pkg"), 3858 Pages: String("pg"), 3859 PullRequests: String("pr"), 3860 RepositoryHooks: String("rh"), 3861 RepositoryProjects: String("rp"), 3862 RepositoryPreReceiveHooks: String("rprh"), 3863 Secrets: String("s"), 3864 SecretScanningAlerts: String("ssa"), 3865 SecurityEvents: String("se"), 3866 SingleFile: String("sf"), 3867 Statuses: String("s"), 3868 TeamDiscussions: String("td"), 3869 VulnerabilityAlerts: String("va"), 3870 Workflows: String("w"), 3871 }, 3872 CreatedAt: &Timestamp{referenceTime}, 3873 UpdatedAt: &Timestamp{referenceTime}, 3874 HasMultipleSingleFiles: Bool(false), 3875 SuspendedBy: &User{ 3876 Login: String("l"), 3877 ID: Int64(1), 3878 URL: String("u"), 3879 AvatarURL: String("a"), 3880 GravatarID: String("g"), 3881 Name: String("n"), 3882 Company: String("c"), 3883 Blog: String("b"), 3884 Location: String("l"), 3885 Email: String("e"), 3886 Hireable: Bool(true), 3887 Bio: String("b"), 3888 TwitterUsername: String("t"), 3889 PublicRepos: Int(1), 3890 Followers: Int(1), 3891 Following: Int(1), 3892 CreatedAt: &Timestamp{referenceTime}, 3893 SuspendedAt: &Timestamp{referenceTime}, 3894 }, 3895 SuspendedAt: &Timestamp{referenceTime}, 3896 }, 3897 Organization: &Organization{ 3898 BillingEmail: String("be"), 3899 Blog: String("b"), 3900 Company: String("c"), 3901 Email: String("e"), 3902 TwitterUsername: String("tu"), 3903 Location: String("loc"), 3904 Name: String("n"), 3905 Description: String("d"), 3906 IsVerified: Bool(true), 3907 HasOrganizationProjects: Bool(true), 3908 HasRepositoryProjects: Bool(true), 3909 DefaultRepoPermission: String("drp"), 3910 MembersCanCreateRepos: Bool(true), 3911 MembersCanCreateInternalRepos: Bool(true), 3912 MembersCanCreatePrivateRepos: Bool(true), 3913 MembersCanCreatePublicRepos: Bool(false), 3914 MembersAllowedRepositoryCreationType: String("marct"), 3915 MembersCanCreatePages: Bool(true), 3916 MembersCanCreatePublicPages: Bool(false), 3917 MembersCanCreatePrivatePages: Bool(true), 3918 }, 3919 } 3920 3921 want := `{ 3922 "push_id": 1, 3923 "head": "h", 3924 "ref": "ref", 3925 "size": 1, 3926 "commits": [ 3927 { 3928 "id": "id" 3929 } 3930 ], 3931 "before": "b", 3932 "distinct_size": 1, 3933 "after": "a", 3934 "created": true, 3935 "deleted": true, 3936 "forced": true, 3937 "base_ref": "a", 3938 "compare": "a", 3939 "repository": { 3940 "id": 1 3941 }, 3942 "head_commit": { 3943 "id": "id" 3944 }, 3945 "pusher": { 3946 "date": ` + referenceTimeStr + `, 3947 "name": "n", 3948 "email": "e", 3949 "username": "l" 3950 }, 3951 "sender": { 3952 "login": "l", 3953 "id": 1, 3954 "node_id": "n", 3955 "avatar_url": "a", 3956 "url": "u", 3957 "events_url": "e", 3958 "repos_url": "r" 3959 }, 3960 "installation": { 3961 "id": 1, 3962 "node_id": "nid", 3963 "app_id": 1, 3964 "app_slug": "as", 3965 "target_id": 1, 3966 "account": { 3967 "login": "l", 3968 "id": 1, 3969 "avatar_url": "a", 3970 "gravatar_id": "g", 3971 "name": "n", 3972 "company": "c", 3973 "blog": "b", 3974 "location": "l", 3975 "email": "e", 3976 "hireable": true, 3977 "bio": "b", 3978 "twitter_username": "t", 3979 "public_repos": 1, 3980 "followers": 1, 3981 "following": 1, 3982 "created_at": ` + referenceTimeStr + `, 3983 "suspended_at": ` + referenceTimeStr + `, 3984 "url": "u" 3985 }, 3986 "access_tokens_url": "atu", 3987 "repositories_url": "ru", 3988 "html_url": "hu", 3989 "target_type": "tt", 3990 "single_file_name": "sfn", 3991 "repository_selection": "rs", 3992 "events": [ 3993 "e" 3994 ], 3995 "single_file_paths": [ 3996 "s" 3997 ], 3998 "permissions": { 3999 "actions": "a", 4000 "administration": "ad", 4001 "checks": "c", 4002 "contents": "co", 4003 "content_references": "cr", 4004 "deployments": "d", 4005 "environments": "e", 4006 "issues": "i", 4007 "metadata": "md", 4008 "members": "m", 4009 "organization_administration": "oa", 4010 "organization_hooks": "oh", 4011 "organization_plan": "op", 4012 "organization_pre_receive_hooks": "opr", 4013 "organization_projects": "op", 4014 "organization_secrets": "os", 4015 "organization_self_hosted_runners": "osh", 4016 "organization_user_blocking": "oub", 4017 "packages": "pkg", 4018 "pages": "pg", 4019 "pull_requests": "pr", 4020 "repository_hooks": "rh", 4021 "repository_projects": "rp", 4022 "repository_pre_receive_hooks": "rprh", 4023 "secrets": "s", 4024 "secret_scanning_alerts": "ssa", 4025 "security_events": "se", 4026 "single_file": "sf", 4027 "statuses": "s", 4028 "team_discussions": "td", 4029 "vulnerability_alerts": "va", 4030 "workflows": "w" 4031 }, 4032 "created_at": ` + referenceTimeStr + `, 4033 "updated_at": ` + referenceTimeStr + `, 4034 "has_multiple_single_files": false, 4035 "suspended_by": { 4036 "login": "l", 4037 "id": 1, 4038 "avatar_url": "a", 4039 "gravatar_id": "g", 4040 "name": "n", 4041 "company": "c", 4042 "blog": "b", 4043 "location": "l", 4044 "email": "e", 4045 "hireable": true, 4046 "bio": "b", 4047 "twitter_username": "t", 4048 "public_repos": 1, 4049 "followers": 1, 4050 "following": 1, 4051 "created_at": ` + referenceTimeStr + `, 4052 "suspended_at": ` + referenceTimeStr + `, 4053 "url": "u" 4054 }, 4055 "suspended_at": ` + referenceTimeStr + ` 4056 }, 4057 "organization": { 4058 "name": "n", 4059 "company": "c", 4060 "blog": "b", 4061 "location": "loc", 4062 "email": "e", 4063 "twitter_username": "tu", 4064 "description": "d", 4065 "billing_email": "be", 4066 "is_verified": true, 4067 "has_organization_projects": true, 4068 "has_repository_projects": true, 4069 "default_repository_permission": "drp", 4070 "members_can_create_repositories": true, 4071 "members_can_create_public_repositories": false, 4072 "members_can_create_private_repositories": true, 4073 "members_can_create_internal_repositories": true, 4074 "members_allowed_repository_creation_type": "marct", 4075 "members_can_create_pages": true, 4076 "members_can_create_public_pages": false, 4077 "members_can_create_private_pages": true 4078 } 4079 }` 4080 4081 testJSONMarshal(t, u, want) 4082 } 4083 4084 func TestStatusEvent_Marshal(t *testing.T) { 4085 testJSONMarshal(t, &StatusEvent{}, "{}") 4086 4087 u := &StatusEvent{ 4088 SHA: String("sha"), 4089 State: String("s"), 4090 Description: String("d"), 4091 TargetURL: String("turl"), 4092 Branches: []*Branch{ 4093 { 4094 Name: String("n"), 4095 Commit: &RepositoryCommit{NodeID: String("nid")}, 4096 Protected: Bool(false), 4097 }, 4098 }, 4099 ID: Int64(1), 4100 Name: String("n"), 4101 Context: String("c"), 4102 Commit: &RepositoryCommit{NodeID: String("nid")}, 4103 CreatedAt: &Timestamp{referenceTime}, 4104 UpdatedAt: &Timestamp{referenceTime}, 4105 Sender: &User{ 4106 Login: String("l"), 4107 ID: Int64(1), 4108 NodeID: String("n"), 4109 URL: String("u"), 4110 ReposURL: String("r"), 4111 EventsURL: String("e"), 4112 AvatarURL: String("a"), 4113 }, 4114 Installation: &Installation{ 4115 ID: Int64(1), 4116 NodeID: String("nid"), 4117 AppID: Int64(1), 4118 AppSlug: String("as"), 4119 TargetID: Int64(1), 4120 Account: &User{ 4121 Login: String("l"), 4122 ID: Int64(1), 4123 URL: String("u"), 4124 AvatarURL: String("a"), 4125 GravatarID: String("g"), 4126 Name: String("n"), 4127 Company: String("c"), 4128 Blog: String("b"), 4129 Location: String("l"), 4130 Email: String("e"), 4131 Hireable: Bool(true), 4132 Bio: String("b"), 4133 TwitterUsername: String("t"), 4134 PublicRepos: Int(1), 4135 Followers: Int(1), 4136 Following: Int(1), 4137 CreatedAt: &Timestamp{referenceTime}, 4138 SuspendedAt: &Timestamp{referenceTime}, 4139 }, 4140 AccessTokensURL: String("atu"), 4141 RepositoriesURL: String("ru"), 4142 HTMLURL: String("hu"), 4143 TargetType: String("tt"), 4144 SingleFileName: String("sfn"), 4145 RepositorySelection: String("rs"), 4146 Events: []string{"e"}, 4147 SingleFilePaths: []string{"s"}, 4148 Permissions: &InstallationPermissions{ 4149 Actions: String("a"), 4150 Administration: String("ad"), 4151 Checks: String("c"), 4152 Contents: String("co"), 4153 ContentReferences: String("cr"), 4154 Deployments: String("d"), 4155 Environments: String("e"), 4156 Issues: String("i"), 4157 Metadata: String("md"), 4158 Members: String("m"), 4159 OrganizationAdministration: String("oa"), 4160 OrganizationHooks: String("oh"), 4161 OrganizationPlan: String("op"), 4162 OrganizationPreReceiveHooks: String("opr"), 4163 OrganizationProjects: String("op"), 4164 OrganizationSecrets: String("os"), 4165 OrganizationSelfHostedRunners: String("osh"), 4166 OrganizationUserBlocking: String("oub"), 4167 Packages: String("pkg"), 4168 Pages: String("pg"), 4169 PullRequests: String("pr"), 4170 RepositoryHooks: String("rh"), 4171 RepositoryProjects: String("rp"), 4172 RepositoryPreReceiveHooks: String("rprh"), 4173 Secrets: String("s"), 4174 SecretScanningAlerts: String("ssa"), 4175 SecurityEvents: String("se"), 4176 SingleFile: String("sf"), 4177 Statuses: String("s"), 4178 TeamDiscussions: String("td"), 4179 VulnerabilityAlerts: String("va"), 4180 Workflows: String("w"), 4181 }, 4182 CreatedAt: &Timestamp{referenceTime}, 4183 UpdatedAt: &Timestamp{referenceTime}, 4184 HasMultipleSingleFiles: Bool(false), 4185 SuspendedBy: &User{ 4186 Login: String("l"), 4187 ID: Int64(1), 4188 URL: String("u"), 4189 AvatarURL: String("a"), 4190 GravatarID: String("g"), 4191 Name: String("n"), 4192 Company: String("c"), 4193 Blog: String("b"), 4194 Location: String("l"), 4195 Email: String("e"), 4196 Hireable: Bool(true), 4197 Bio: String("b"), 4198 TwitterUsername: String("t"), 4199 PublicRepos: Int(1), 4200 Followers: Int(1), 4201 Following: Int(1), 4202 CreatedAt: &Timestamp{referenceTime}, 4203 SuspendedAt: &Timestamp{referenceTime}, 4204 }, 4205 SuspendedAt: &Timestamp{referenceTime}, 4206 }, 4207 } 4208 4209 want := `{ 4210 "sha": "sha", 4211 "state": "s", 4212 "description": "d", 4213 "target_url": "turl", 4214 "branches": [ 4215 { 4216 "name": "n", 4217 "commit": { 4218 "node_id": "nid" 4219 }, 4220 "protected": false 4221 } 4222 ], 4223 "id": 1, 4224 "name": "n", 4225 "context": "c", 4226 "commit": { 4227 "node_id": "nid" 4228 }, 4229 "created_at": ` + referenceTimeStr + `, 4230 "updated_at": ` + referenceTimeStr + `, 4231 "sender": { 4232 "login": "l", 4233 "id": 1, 4234 "node_id": "n", 4235 "avatar_url": "a", 4236 "url": "u", 4237 "events_url": "e", 4238 "repos_url": "r" 4239 }, 4240 "installation": { 4241 "id": 1, 4242 "node_id": "nid", 4243 "app_id": 1, 4244 "app_slug": "as", 4245 "target_id": 1, 4246 "account": { 4247 "login": "l", 4248 "id": 1, 4249 "avatar_url": "a", 4250 "gravatar_id": "g", 4251 "name": "n", 4252 "company": "c", 4253 "blog": "b", 4254 "location": "l", 4255 "email": "e", 4256 "hireable": true, 4257 "bio": "b", 4258 "twitter_username": "t", 4259 "public_repos": 1, 4260 "followers": 1, 4261 "following": 1, 4262 "created_at": ` + referenceTimeStr + `, 4263 "suspended_at": ` + referenceTimeStr + `, 4264 "url": "u" 4265 }, 4266 "access_tokens_url": "atu", 4267 "repositories_url": "ru", 4268 "html_url": "hu", 4269 "target_type": "tt", 4270 "single_file_name": "sfn", 4271 "repository_selection": "rs", 4272 "events": [ 4273 "e" 4274 ], 4275 "single_file_paths": [ 4276 "s" 4277 ], 4278 "permissions": { 4279 "actions": "a", 4280 "administration": "ad", 4281 "checks": "c", 4282 "contents": "co", 4283 "content_references": "cr", 4284 "deployments": "d", 4285 "environments": "e", 4286 "issues": "i", 4287 "metadata": "md", 4288 "members": "m", 4289 "organization_administration": "oa", 4290 "organization_hooks": "oh", 4291 "organization_plan": "op", 4292 "organization_pre_receive_hooks": "opr", 4293 "organization_projects": "op", 4294 "organization_secrets": "os", 4295 "organization_self_hosted_runners": "osh", 4296 "organization_user_blocking": "oub", 4297 "packages": "pkg", 4298 "pages": "pg", 4299 "pull_requests": "pr", 4300 "repository_hooks": "rh", 4301 "repository_projects": "rp", 4302 "repository_pre_receive_hooks": "rprh", 4303 "secrets": "s", 4304 "secret_scanning_alerts": "ssa", 4305 "security_events": "se", 4306 "single_file": "sf", 4307 "statuses": "s", 4308 "team_discussions": "td", 4309 "vulnerability_alerts": "va", 4310 "workflows": "w" 4311 }, 4312 "created_at": ` + referenceTimeStr + `, 4313 "updated_at": ` + referenceTimeStr + `, 4314 "has_multiple_single_files": false, 4315 "suspended_by": { 4316 "login": "l", 4317 "id": 1, 4318 "avatar_url": "a", 4319 "gravatar_id": "g", 4320 "name": "n", 4321 "company": "c", 4322 "blog": "b", 4323 "location": "l", 4324 "email": "e", 4325 "hireable": true, 4326 "bio": "b", 4327 "twitter_username": "t", 4328 "public_repos": 1, 4329 "followers": 1, 4330 "following": 1, 4331 "created_at": ` + referenceTimeStr + `, 4332 "suspended_at": ` + referenceTimeStr + `, 4333 "url": "u" 4334 }, 4335 "suspended_at": ` + referenceTimeStr + ` 4336 } 4337 }` 4338 4339 testJSONMarshal(t, u, want) 4340 } 4341 4342 func TestMarketplacePurchaseEvent_Marshal(t *testing.T) { 4343 testJSONMarshal(t, &MarketplacePurchaseEvent{}, "{}") 4344 4345 u := &MarketplacePurchaseEvent{ 4346 Action: String("a"), 4347 EffectiveDate: &Timestamp{referenceTime}, 4348 MarketplacePurchase: &MarketplacePurchase{ 4349 BillingCycle: String("bc"), 4350 NextBillingDate: &Timestamp{referenceTime}, 4351 UnitCount: Int(1), 4352 Plan: &MarketplacePlan{ 4353 URL: String("u"), 4354 AccountsURL: String("au"), 4355 ID: Int64(1), 4356 Number: Int(1), 4357 Name: String("n"), 4358 Description: String("d"), 4359 MonthlyPriceInCents: Int(1), 4360 YearlyPriceInCents: Int(1), 4361 PriceModel: String("pm"), 4362 UnitName: String("un"), 4363 Bullets: &[]string{"b"}, 4364 State: String("s"), 4365 HasFreeTrial: Bool(false), 4366 }, 4367 OnFreeTrial: Bool(false), 4368 FreeTrialEndsOn: &Timestamp{referenceTime}, 4369 UpdatedAt: &Timestamp{referenceTime}, 4370 }, 4371 PreviousMarketplacePurchase: &MarketplacePurchase{ 4372 BillingCycle: String("bc"), 4373 NextBillingDate: &Timestamp{referenceTime}, 4374 UnitCount: Int(1), 4375 Plan: &MarketplacePlan{ 4376 URL: String("u"), 4377 AccountsURL: String("au"), 4378 ID: Int64(1), 4379 Number: Int(1), 4380 Name: String("n"), 4381 Description: String("d"), 4382 MonthlyPriceInCents: Int(1), 4383 YearlyPriceInCents: Int(1), 4384 PriceModel: String("pm"), 4385 UnitName: String("un"), 4386 Bullets: &[]string{"b"}, 4387 State: String("s"), 4388 HasFreeTrial: Bool(false), 4389 }, 4390 OnFreeTrial: Bool(false), 4391 FreeTrialEndsOn: &Timestamp{referenceTime}, 4392 UpdatedAt: &Timestamp{referenceTime}, 4393 }, 4394 Sender: &User{ 4395 Login: String("l"), 4396 ID: Int64(1), 4397 NodeID: String("n"), 4398 URL: String("u"), 4399 ReposURL: String("r"), 4400 EventsURL: String("e"), 4401 AvatarURL: String("a"), 4402 }, 4403 Installation: &Installation{ 4404 ID: Int64(1), 4405 NodeID: String("nid"), 4406 AppID: Int64(1), 4407 AppSlug: String("as"), 4408 TargetID: Int64(1), 4409 Account: &User{ 4410 Login: String("l"), 4411 ID: Int64(1), 4412 URL: String("u"), 4413 AvatarURL: String("a"), 4414 GravatarID: String("g"), 4415 Name: String("n"), 4416 Company: String("c"), 4417 Blog: String("b"), 4418 Location: String("l"), 4419 Email: String("e"), 4420 Hireable: Bool(true), 4421 Bio: String("b"), 4422 TwitterUsername: String("t"), 4423 PublicRepos: Int(1), 4424 Followers: Int(1), 4425 Following: Int(1), 4426 CreatedAt: &Timestamp{referenceTime}, 4427 SuspendedAt: &Timestamp{referenceTime}, 4428 }, 4429 AccessTokensURL: String("atu"), 4430 RepositoriesURL: String("ru"), 4431 HTMLURL: String("hu"), 4432 TargetType: String("tt"), 4433 SingleFileName: String("sfn"), 4434 RepositorySelection: String("rs"), 4435 Events: []string{"e"}, 4436 SingleFilePaths: []string{"s"}, 4437 Permissions: &InstallationPermissions{ 4438 Actions: String("a"), 4439 Administration: String("ad"), 4440 Checks: String("c"), 4441 Contents: String("co"), 4442 ContentReferences: String("cr"), 4443 Deployments: String("d"), 4444 Environments: String("e"), 4445 Issues: String("i"), 4446 Metadata: String("md"), 4447 Members: String("m"), 4448 OrganizationAdministration: String("oa"), 4449 OrganizationHooks: String("oh"), 4450 OrganizationPlan: String("op"), 4451 OrganizationPreReceiveHooks: String("opr"), 4452 OrganizationProjects: String("op"), 4453 OrganizationSecrets: String("os"), 4454 OrganizationSelfHostedRunners: String("osh"), 4455 OrganizationUserBlocking: String("oub"), 4456 Packages: String("pkg"), 4457 Pages: String("pg"), 4458 PullRequests: String("pr"), 4459 RepositoryHooks: String("rh"), 4460 RepositoryProjects: String("rp"), 4461 RepositoryPreReceiveHooks: String("rprh"), 4462 Secrets: String("s"), 4463 SecretScanningAlerts: String("ssa"), 4464 SecurityEvents: String("se"), 4465 SingleFile: String("sf"), 4466 Statuses: String("s"), 4467 TeamDiscussions: String("td"), 4468 VulnerabilityAlerts: String("va"), 4469 Workflows: String("w"), 4470 }, 4471 CreatedAt: &Timestamp{referenceTime}, 4472 UpdatedAt: &Timestamp{referenceTime}, 4473 HasMultipleSingleFiles: Bool(false), 4474 SuspendedBy: &User{ 4475 Login: String("l"), 4476 ID: Int64(1), 4477 URL: String("u"), 4478 AvatarURL: String("a"), 4479 GravatarID: String("g"), 4480 Name: String("n"), 4481 Company: String("c"), 4482 Blog: String("b"), 4483 Location: String("l"), 4484 Email: String("e"), 4485 Hireable: Bool(true), 4486 Bio: String("b"), 4487 TwitterUsername: String("t"), 4488 PublicRepos: Int(1), 4489 Followers: Int(1), 4490 Following: Int(1), 4491 CreatedAt: &Timestamp{referenceTime}, 4492 SuspendedAt: &Timestamp{referenceTime}, 4493 }, 4494 SuspendedAt: &Timestamp{referenceTime}, 4495 }, 4496 } 4497 4498 want := `{ 4499 "action": "a", 4500 "effective_date": ` + referenceTimeStr + `, 4501 "marketplace_purchase": { 4502 "billing_cycle": "bc", 4503 "next_billing_date": ` + referenceTimeStr + `, 4504 "unit_count": 1, 4505 "plan": { 4506 "url": "u", 4507 "accounts_url": "au", 4508 "id": 1, 4509 "number": 1, 4510 "name": "n", 4511 "description": "d", 4512 "monthly_price_in_cents": 1, 4513 "yearly_price_in_cents": 1, 4514 "price_model": "pm", 4515 "unit_name": "un", 4516 "bullets": [ 4517 "b" 4518 ], 4519 "state": "s", 4520 "has_free_trial": false 4521 }, 4522 "on_free_trial": false, 4523 "free_trial_ends_on": ` + referenceTimeStr + `, 4524 "updated_at": ` + referenceTimeStr + ` 4525 }, 4526 "previous_marketplace_purchase": { 4527 "billing_cycle": "bc", 4528 "next_billing_date": ` + referenceTimeStr + `, 4529 "unit_count": 1, 4530 "plan": { 4531 "url": "u", 4532 "accounts_url": "au", 4533 "id": 1, 4534 "number": 1, 4535 "name": "n", 4536 "description": "d", 4537 "monthly_price_in_cents": 1, 4538 "yearly_price_in_cents": 1, 4539 "price_model": "pm", 4540 "unit_name": "un", 4541 "bullets": [ 4542 "b" 4543 ], 4544 "state": "s", 4545 "has_free_trial": false 4546 }, 4547 "on_free_trial": false, 4548 "free_trial_ends_on": ` + referenceTimeStr + `, 4549 "updated_at": ` + referenceTimeStr + ` 4550 }, 4551 "sender": { 4552 "login": "l", 4553 "id": 1, 4554 "node_id": "n", 4555 "avatar_url": "a", 4556 "url": "u", 4557 "events_url": "e", 4558 "repos_url": "r" 4559 }, 4560 "installation": { 4561 "id": 1, 4562 "node_id": "nid", 4563 "app_id": 1, 4564 "app_slug": "as", 4565 "target_id": 1, 4566 "account": { 4567 "login": "l", 4568 "id": 1, 4569 "avatar_url": "a", 4570 "gravatar_id": "g", 4571 "name": "n", 4572 "company": "c", 4573 "blog": "b", 4574 "location": "l", 4575 "email": "e", 4576 "hireable": true, 4577 "bio": "b", 4578 "twitter_username": "t", 4579 "public_repos": 1, 4580 "followers": 1, 4581 "following": 1, 4582 "created_at": ` + referenceTimeStr + `, 4583 "suspended_at": ` + referenceTimeStr + `, 4584 "url": "u" 4585 }, 4586 "access_tokens_url": "atu", 4587 "repositories_url": "ru", 4588 "html_url": "hu", 4589 "target_type": "tt", 4590 "single_file_name": "sfn", 4591 "repository_selection": "rs", 4592 "events": [ 4593 "e" 4594 ], 4595 "single_file_paths": [ 4596 "s" 4597 ], 4598 "permissions": { 4599 "actions": "a", 4600 "administration": "ad", 4601 "checks": "c", 4602 "contents": "co", 4603 "content_references": "cr", 4604 "deployments": "d", 4605 "environments": "e", 4606 "issues": "i", 4607 "metadata": "md", 4608 "members": "m", 4609 "organization_administration": "oa", 4610 "organization_hooks": "oh", 4611 "organization_plan": "op", 4612 "organization_pre_receive_hooks": "opr", 4613 "organization_projects": "op", 4614 "organization_secrets": "os", 4615 "organization_self_hosted_runners": "osh", 4616 "organization_user_blocking": "oub", 4617 "packages": "pkg", 4618 "pages": "pg", 4619 "pull_requests": "pr", 4620 "repository_hooks": "rh", 4621 "repository_projects": "rp", 4622 "repository_pre_receive_hooks": "rprh", 4623 "secrets": "s", 4624 "secret_scanning_alerts": "ssa", 4625 "security_events": "se", 4626 "single_file": "sf", 4627 "statuses": "s", 4628 "team_discussions": "td", 4629 "vulnerability_alerts": "va", 4630 "workflows": "w" 4631 }, 4632 "created_at": ` + referenceTimeStr + `, 4633 "updated_at": ` + referenceTimeStr + `, 4634 "has_multiple_single_files": false, 4635 "suspended_by": { 4636 "login": "l", 4637 "id": 1, 4638 "avatar_url": "a", 4639 "gravatar_id": "g", 4640 "name": "n", 4641 "company": "c", 4642 "blog": "b", 4643 "location": "l", 4644 "email": "e", 4645 "hireable": true, 4646 "bio": "b", 4647 "twitter_username": "t", 4648 "public_repos": 1, 4649 "followers": 1, 4650 "following": 1, 4651 "created_at": ` + referenceTimeStr + `, 4652 "suspended_at": ` + referenceTimeStr + `, 4653 "url": "u" 4654 }, 4655 "suspended_at": ` + referenceTimeStr + ` 4656 } 4657 }` 4658 4659 testJSONMarshal(t, u, want) 4660 } 4661 4662 func TestOrganizationEvent_Marshal(t *testing.T) { 4663 testJSONMarshal(t, &OrganizationEvent{}, "{}") 4664 4665 u := &OrganizationEvent{ 4666 Action: String("a"), 4667 Invitation: &Invitation{ID: Int64(1)}, 4668 Membership: &Membership{ 4669 URL: String("url"), 4670 State: String("s"), 4671 Role: String("r"), 4672 OrganizationURL: String("ou"), 4673 Organization: &Organization{ 4674 BillingEmail: String("be"), 4675 Blog: String("b"), 4676 Company: String("c"), 4677 Email: String("e"), 4678 TwitterUsername: String("tu"), 4679 Location: String("loc"), 4680 Name: String("n"), 4681 Description: String("d"), 4682 IsVerified: Bool(true), 4683 HasOrganizationProjects: Bool(true), 4684 HasRepositoryProjects: Bool(true), 4685 DefaultRepoPermission: String("drp"), 4686 MembersCanCreateRepos: Bool(true), 4687 MembersCanCreateInternalRepos: Bool(true), 4688 MembersCanCreatePrivateRepos: Bool(true), 4689 MembersCanCreatePublicRepos: Bool(false), 4690 MembersAllowedRepositoryCreationType: String("marct"), 4691 MembersCanCreatePages: Bool(true), 4692 MembersCanCreatePublicPages: Bool(false), 4693 MembersCanCreatePrivatePages: Bool(true), 4694 }, 4695 User: &User{ 4696 Login: String("l"), 4697 ID: Int64(1), 4698 NodeID: String("n"), 4699 URL: String("u"), 4700 ReposURL: String("r"), 4701 EventsURL: String("e"), 4702 AvatarURL: String("a"), 4703 }, 4704 }, 4705 Organization: &Organization{ 4706 BillingEmail: String("be"), 4707 Blog: String("b"), 4708 Company: String("c"), 4709 Email: String("e"), 4710 TwitterUsername: String("tu"), 4711 Location: String("loc"), 4712 Name: String("n"), 4713 Description: String("d"), 4714 IsVerified: Bool(true), 4715 HasOrganizationProjects: Bool(true), 4716 HasRepositoryProjects: Bool(true), 4717 DefaultRepoPermission: String("drp"), 4718 MembersCanCreateRepos: Bool(true), 4719 MembersCanCreateInternalRepos: Bool(true), 4720 MembersCanCreatePrivateRepos: Bool(true), 4721 MembersCanCreatePublicRepos: Bool(false), 4722 MembersAllowedRepositoryCreationType: String("marct"), 4723 MembersCanCreatePages: Bool(true), 4724 MembersCanCreatePublicPages: Bool(false), 4725 MembersCanCreatePrivatePages: Bool(true), 4726 }, 4727 Sender: &User{ 4728 Login: String("l"), 4729 ID: Int64(1), 4730 NodeID: String("n"), 4731 URL: String("u"), 4732 ReposURL: String("r"), 4733 EventsURL: String("e"), 4734 AvatarURL: String("a"), 4735 }, 4736 Installation: &Installation{ 4737 ID: Int64(1), 4738 NodeID: String("nid"), 4739 AppID: Int64(1), 4740 AppSlug: String("as"), 4741 TargetID: Int64(1), 4742 Account: &User{ 4743 Login: String("l"), 4744 ID: Int64(1), 4745 URL: String("u"), 4746 AvatarURL: String("a"), 4747 GravatarID: String("g"), 4748 Name: String("n"), 4749 Company: String("c"), 4750 Blog: String("b"), 4751 Location: String("l"), 4752 Email: String("e"), 4753 Hireable: Bool(true), 4754 Bio: String("b"), 4755 TwitterUsername: String("t"), 4756 PublicRepos: Int(1), 4757 Followers: Int(1), 4758 Following: Int(1), 4759 CreatedAt: &Timestamp{referenceTime}, 4760 SuspendedAt: &Timestamp{referenceTime}, 4761 }, 4762 AccessTokensURL: String("atu"), 4763 RepositoriesURL: String("ru"), 4764 HTMLURL: String("hu"), 4765 TargetType: String("tt"), 4766 SingleFileName: String("sfn"), 4767 RepositorySelection: String("rs"), 4768 Events: []string{"e"}, 4769 SingleFilePaths: []string{"s"}, 4770 Permissions: &InstallationPermissions{ 4771 Actions: String("a"), 4772 Administration: String("ad"), 4773 Checks: String("c"), 4774 Contents: String("co"), 4775 ContentReferences: String("cr"), 4776 Deployments: String("d"), 4777 Environments: String("e"), 4778 Issues: String("i"), 4779 Metadata: String("md"), 4780 Members: String("m"), 4781 OrganizationAdministration: String("oa"), 4782 OrganizationHooks: String("oh"), 4783 OrganizationPlan: String("op"), 4784 OrganizationPreReceiveHooks: String("opr"), 4785 OrganizationProjects: String("op"), 4786 OrganizationSecrets: String("os"), 4787 OrganizationSelfHostedRunners: String("osh"), 4788 OrganizationUserBlocking: String("oub"), 4789 Packages: String("pkg"), 4790 Pages: String("pg"), 4791 PullRequests: String("pr"), 4792 RepositoryHooks: String("rh"), 4793 RepositoryProjects: String("rp"), 4794 RepositoryPreReceiveHooks: String("rprh"), 4795 Secrets: String("s"), 4796 SecretScanningAlerts: String("ssa"), 4797 SecurityEvents: String("se"), 4798 SingleFile: String("sf"), 4799 Statuses: String("s"), 4800 TeamDiscussions: String("td"), 4801 VulnerabilityAlerts: String("va"), 4802 Workflows: String("w"), 4803 }, 4804 CreatedAt: &Timestamp{referenceTime}, 4805 UpdatedAt: &Timestamp{referenceTime}, 4806 HasMultipleSingleFiles: Bool(false), 4807 SuspendedBy: &User{ 4808 Login: String("l"), 4809 ID: Int64(1), 4810 URL: String("u"), 4811 AvatarURL: String("a"), 4812 GravatarID: String("g"), 4813 Name: String("n"), 4814 Company: String("c"), 4815 Blog: String("b"), 4816 Location: String("l"), 4817 Email: String("e"), 4818 Hireable: Bool(true), 4819 Bio: String("b"), 4820 TwitterUsername: String("t"), 4821 PublicRepos: Int(1), 4822 Followers: Int(1), 4823 Following: Int(1), 4824 CreatedAt: &Timestamp{referenceTime}, 4825 SuspendedAt: &Timestamp{referenceTime}, 4826 }, 4827 SuspendedAt: &Timestamp{referenceTime}, 4828 }, 4829 } 4830 4831 want := `{ 4832 "action": "a", 4833 "invitation": { 4834 "id": 1 4835 }, 4836 "membership": { 4837 "url": "url", 4838 "state": "s", 4839 "role": "r", 4840 "organization_url": "ou", 4841 "organization": { 4842 "name": "n", 4843 "company": "c", 4844 "blog": "b", 4845 "location": "loc", 4846 "email": "e", 4847 "twitter_username": "tu", 4848 "description": "d", 4849 "billing_email": "be", 4850 "is_verified": true, 4851 "has_organization_projects": true, 4852 "has_repository_projects": true, 4853 "default_repository_permission": "drp", 4854 "members_can_create_repositories": true, 4855 "members_can_create_public_repositories": false, 4856 "members_can_create_private_repositories": true, 4857 "members_can_create_internal_repositories": true, 4858 "members_allowed_repository_creation_type": "marct", 4859 "members_can_create_pages": true, 4860 "members_can_create_public_pages": false, 4861 "members_can_create_private_pages": true 4862 }, 4863 "user": { 4864 "login": "l", 4865 "id": 1, 4866 "node_id": "n", 4867 "avatar_url": "a", 4868 "url": "u", 4869 "events_url": "e", 4870 "repos_url": "r" 4871 } 4872 }, 4873 "organization": { 4874 "name": "n", 4875 "company": "c", 4876 "blog": "b", 4877 "location": "loc", 4878 "email": "e", 4879 "twitter_username": "tu", 4880 "description": "d", 4881 "billing_email": "be", 4882 "is_verified": true, 4883 "has_organization_projects": true, 4884 "has_repository_projects": true, 4885 "default_repository_permission": "drp", 4886 "members_can_create_repositories": true, 4887 "members_can_create_public_repositories": false, 4888 "members_can_create_private_repositories": true, 4889 "members_can_create_internal_repositories": true, 4890 "members_allowed_repository_creation_type": "marct", 4891 "members_can_create_pages": true, 4892 "members_can_create_public_pages": false, 4893 "members_can_create_private_pages": true 4894 }, 4895 "sender": { 4896 "login": "l", 4897 "id": 1, 4898 "node_id": "n", 4899 "avatar_url": "a", 4900 "url": "u", 4901 "events_url": "e", 4902 "repos_url": "r" 4903 }, 4904 "installation": { 4905 "id": 1, 4906 "node_id": "nid", 4907 "app_id": 1, 4908 "app_slug": "as", 4909 "target_id": 1, 4910 "account": { 4911 "login": "l", 4912 "id": 1, 4913 "avatar_url": "a", 4914 "gravatar_id": "g", 4915 "name": "n", 4916 "company": "c", 4917 "blog": "b", 4918 "location": "l", 4919 "email": "e", 4920 "hireable": true, 4921 "bio": "b", 4922 "twitter_username": "t", 4923 "public_repos": 1, 4924 "followers": 1, 4925 "following": 1, 4926 "created_at": ` + referenceTimeStr + `, 4927 "suspended_at": ` + referenceTimeStr + `, 4928 "url": "u" 4929 }, 4930 "access_tokens_url": "atu", 4931 "repositories_url": "ru", 4932 "html_url": "hu", 4933 "target_type": "tt", 4934 "single_file_name": "sfn", 4935 "repository_selection": "rs", 4936 "events": [ 4937 "e" 4938 ], 4939 "single_file_paths": [ 4940 "s" 4941 ], 4942 "permissions": { 4943 "actions": "a", 4944 "administration": "ad", 4945 "checks": "c", 4946 "contents": "co", 4947 "content_references": "cr", 4948 "deployments": "d", 4949 "environments": "e", 4950 "issues": "i", 4951 "metadata": "md", 4952 "members": "m", 4953 "organization_administration": "oa", 4954 "organization_hooks": "oh", 4955 "organization_plan": "op", 4956 "organization_pre_receive_hooks": "opr", 4957 "organization_projects": "op", 4958 "organization_secrets": "os", 4959 "organization_self_hosted_runners": "osh", 4960 "organization_user_blocking": "oub", 4961 "packages": "pkg", 4962 "pages": "pg", 4963 "pull_requests": "pr", 4964 "repository_hooks": "rh", 4965 "repository_projects": "rp", 4966 "repository_pre_receive_hooks": "rprh", 4967 "secrets": "s", 4968 "secret_scanning_alerts": "ssa", 4969 "security_events": "se", 4970 "single_file": "sf", 4971 "statuses": "s", 4972 "team_discussions": "td", 4973 "vulnerability_alerts": "va", 4974 "workflows": "w" 4975 }, 4976 "created_at": ` + referenceTimeStr + `, 4977 "updated_at": ` + referenceTimeStr + `, 4978 "has_multiple_single_files": false, 4979 "suspended_by": { 4980 "login": "l", 4981 "id": 1, 4982 "avatar_url": "a", 4983 "gravatar_id": "g", 4984 "name": "n", 4985 "company": "c", 4986 "blog": "b", 4987 "location": "l", 4988 "email": "e", 4989 "hireable": true, 4990 "bio": "b", 4991 "twitter_username": "t", 4992 "public_repos": 1, 4993 "followers": 1, 4994 "following": 1, 4995 "created_at": ` + referenceTimeStr + `, 4996 "suspended_at": ` + referenceTimeStr + `, 4997 "url": "u" 4998 }, 4999 "suspended_at": ` + referenceTimeStr + ` 5000 } 5001 }` 5002 5003 testJSONMarshal(t, u, want) 5004 } 5005 5006 func TestPageBuildEvent_Marshal(t *testing.T) { 5007 testJSONMarshal(t, &PageBuildEvent{}, "{}") 5008 5009 u := &PageBuildEvent{ 5010 Build: &PagesBuild{URL: String("url")}, 5011 ID: Int64(1), 5012 Repo: &Repository{ 5013 ID: Int64(1), 5014 URL: String("s"), 5015 Name: String("n"), 5016 }, 5017 Sender: &User{ 5018 Login: String("l"), 5019 ID: Int64(1), 5020 NodeID: String("n"), 5021 URL: String("u"), 5022 ReposURL: String("r"), 5023 EventsURL: String("e"), 5024 AvatarURL: String("a"), 5025 }, 5026 Installation: &Installation{ 5027 ID: Int64(1), 5028 NodeID: String("nid"), 5029 AppID: Int64(1), 5030 AppSlug: String("as"), 5031 TargetID: Int64(1), 5032 Account: &User{ 5033 Login: String("l"), 5034 ID: Int64(1), 5035 URL: String("u"), 5036 AvatarURL: String("a"), 5037 GravatarID: String("g"), 5038 Name: String("n"), 5039 Company: String("c"), 5040 Blog: String("b"), 5041 Location: String("l"), 5042 Email: String("e"), 5043 Hireable: Bool(true), 5044 Bio: String("b"), 5045 TwitterUsername: String("t"), 5046 PublicRepos: Int(1), 5047 Followers: Int(1), 5048 Following: Int(1), 5049 CreatedAt: &Timestamp{referenceTime}, 5050 SuspendedAt: &Timestamp{referenceTime}, 5051 }, 5052 AccessTokensURL: String("atu"), 5053 RepositoriesURL: String("ru"), 5054 HTMLURL: String("hu"), 5055 TargetType: String("tt"), 5056 SingleFileName: String("sfn"), 5057 RepositorySelection: String("rs"), 5058 Events: []string{"e"}, 5059 SingleFilePaths: []string{"s"}, 5060 Permissions: &InstallationPermissions{ 5061 Actions: String("a"), 5062 Administration: String("ad"), 5063 Checks: String("c"), 5064 Contents: String("co"), 5065 ContentReferences: String("cr"), 5066 Deployments: String("d"), 5067 Environments: String("e"), 5068 Issues: String("i"), 5069 Metadata: String("md"), 5070 Members: String("m"), 5071 OrganizationAdministration: String("oa"), 5072 OrganizationHooks: String("oh"), 5073 OrganizationPlan: String("op"), 5074 OrganizationPreReceiveHooks: String("opr"), 5075 OrganizationProjects: String("op"), 5076 OrganizationSecrets: String("os"), 5077 OrganizationSelfHostedRunners: String("osh"), 5078 OrganizationUserBlocking: String("oub"), 5079 Packages: String("pkg"), 5080 Pages: String("pg"), 5081 PullRequests: String("pr"), 5082 RepositoryHooks: String("rh"), 5083 RepositoryProjects: String("rp"), 5084 RepositoryPreReceiveHooks: String("rprh"), 5085 Secrets: String("s"), 5086 SecretScanningAlerts: String("ssa"), 5087 SecurityEvents: String("se"), 5088 SingleFile: String("sf"), 5089 Statuses: String("s"), 5090 TeamDiscussions: String("td"), 5091 VulnerabilityAlerts: String("va"), 5092 Workflows: String("w"), 5093 }, 5094 CreatedAt: &Timestamp{referenceTime}, 5095 UpdatedAt: &Timestamp{referenceTime}, 5096 HasMultipleSingleFiles: Bool(false), 5097 SuspendedBy: &User{ 5098 Login: String("l"), 5099 ID: Int64(1), 5100 URL: String("u"), 5101 AvatarURL: String("a"), 5102 GravatarID: String("g"), 5103 Name: String("n"), 5104 Company: String("c"), 5105 Blog: String("b"), 5106 Location: String("l"), 5107 Email: String("e"), 5108 Hireable: Bool(true), 5109 Bio: String("b"), 5110 TwitterUsername: String("t"), 5111 PublicRepos: Int(1), 5112 Followers: Int(1), 5113 Following: Int(1), 5114 CreatedAt: &Timestamp{referenceTime}, 5115 SuspendedAt: &Timestamp{referenceTime}, 5116 }, 5117 SuspendedAt: &Timestamp{referenceTime}, 5118 }, 5119 } 5120 5121 want := `{ 5122 "build": { 5123 "url": "url" 5124 }, 5125 "id": 1, 5126 "repository": { 5127 "id": 1, 5128 "name": "n", 5129 "url": "s" 5130 }, 5131 "sender": { 5132 "login": "l", 5133 "id": 1, 5134 "node_id": "n", 5135 "avatar_url": "a", 5136 "url": "u", 5137 "events_url": "e", 5138 "repos_url": "r" 5139 }, 5140 "installation": { 5141 "id": 1, 5142 "node_id": "nid", 5143 "app_id": 1, 5144 "app_slug": "as", 5145 "target_id": 1, 5146 "account": { 5147 "login": "l", 5148 "id": 1, 5149 "avatar_url": "a", 5150 "gravatar_id": "g", 5151 "name": "n", 5152 "company": "c", 5153 "blog": "b", 5154 "location": "l", 5155 "email": "e", 5156 "hireable": true, 5157 "bio": "b", 5158 "twitter_username": "t", 5159 "public_repos": 1, 5160 "followers": 1, 5161 "following": 1, 5162 "created_at": ` + referenceTimeStr + `, 5163 "suspended_at": ` + referenceTimeStr + `, 5164 "url": "u" 5165 }, 5166 "access_tokens_url": "atu", 5167 "repositories_url": "ru", 5168 "html_url": "hu", 5169 "target_type": "tt", 5170 "single_file_name": "sfn", 5171 "repository_selection": "rs", 5172 "events": [ 5173 "e" 5174 ], 5175 "single_file_paths": [ 5176 "s" 5177 ], 5178 "permissions": { 5179 "actions": "a", 5180 "administration": "ad", 5181 "checks": "c", 5182 "contents": "co", 5183 "content_references": "cr", 5184 "deployments": "d", 5185 "environments": "e", 5186 "issues": "i", 5187 "metadata": "md", 5188 "members": "m", 5189 "organization_administration": "oa", 5190 "organization_hooks": "oh", 5191 "organization_plan": "op", 5192 "organization_pre_receive_hooks": "opr", 5193 "organization_projects": "op", 5194 "organization_secrets": "os", 5195 "organization_self_hosted_runners": "osh", 5196 "organization_user_blocking": "oub", 5197 "packages": "pkg", 5198 "pages": "pg", 5199 "pull_requests": "pr", 5200 "repository_hooks": "rh", 5201 "repository_projects": "rp", 5202 "repository_pre_receive_hooks": "rprh", 5203 "secrets": "s", 5204 "secret_scanning_alerts": "ssa", 5205 "security_events": "se", 5206 "single_file": "sf", 5207 "statuses": "s", 5208 "team_discussions": "td", 5209 "vulnerability_alerts": "va", 5210 "workflows": "w" 5211 }, 5212 "created_at": ` + referenceTimeStr + `, 5213 "updated_at": ` + referenceTimeStr + `, 5214 "has_multiple_single_files": false, 5215 "suspended_by": { 5216 "login": "l", 5217 "id": 1, 5218 "avatar_url": "a", 5219 "gravatar_id": "g", 5220 "name": "n", 5221 "company": "c", 5222 "blog": "b", 5223 "location": "l", 5224 "email": "e", 5225 "hireable": true, 5226 "bio": "b", 5227 "twitter_username": "t", 5228 "public_repos": 1, 5229 "followers": 1, 5230 "following": 1, 5231 "created_at": ` + referenceTimeStr + `, 5232 "suspended_at": ` + referenceTimeStr + `, 5233 "url": "u" 5234 }, 5235 "suspended_at": ` + referenceTimeStr + ` 5236 } 5237 }` 5238 5239 testJSONMarshal(t, u, want) 5240 } 5241 5242 func TestCommitCommentEvent_Marshal(t *testing.T) { 5243 testJSONMarshal(t, &CommitCommentEvent{}, "{}") 5244 5245 u := &CommitCommentEvent{ 5246 Comment: &RepositoryComment{ 5247 HTMLURL: String("hurl"), 5248 URL: String("url"), 5249 ID: Int64(1), 5250 NodeID: String("nid"), 5251 CommitID: String("cid"), 5252 User: &User{ 5253 Login: String("l"), 5254 ID: Int64(1), 5255 NodeID: String("n"), 5256 URL: String("u"), 5257 ReposURL: String("r"), 5258 EventsURL: String("e"), 5259 AvatarURL: String("a"), 5260 }, 5261 Reactions: &Reactions{ 5262 TotalCount: Int(1), 5263 PlusOne: Int(1), 5264 MinusOne: Int(1), 5265 Laugh: Int(1), 5266 Confused: Int(1), 5267 Heart: Int(1), 5268 Hooray: Int(1), 5269 Rocket: Int(1), 5270 Eyes: Int(1), 5271 URL: String("url"), 5272 }, 5273 CreatedAt: &Timestamp{referenceTime}, 5274 UpdatedAt: &Timestamp{referenceTime}, 5275 Body: String("b"), 5276 Path: String("path"), 5277 Position: Int(1), 5278 }, 5279 Action: String("a"), 5280 Repo: &Repository{ 5281 ID: Int64(1), 5282 URL: String("s"), 5283 Name: String("n"), 5284 }, 5285 Sender: &User{ 5286 Login: String("l"), 5287 ID: Int64(1), 5288 NodeID: String("n"), 5289 URL: String("u"), 5290 ReposURL: String("r"), 5291 EventsURL: String("e"), 5292 AvatarURL: String("a"), 5293 }, 5294 Installation: &Installation{ 5295 ID: Int64(1), 5296 NodeID: String("nid"), 5297 AppID: Int64(1), 5298 AppSlug: String("as"), 5299 TargetID: Int64(1), 5300 Account: &User{ 5301 Login: String("l"), 5302 ID: Int64(1), 5303 URL: String("u"), 5304 AvatarURL: String("a"), 5305 GravatarID: String("g"), 5306 Name: String("n"), 5307 Company: String("c"), 5308 Blog: String("b"), 5309 Location: String("l"), 5310 Email: String("e"), 5311 Hireable: Bool(true), 5312 Bio: String("b"), 5313 TwitterUsername: String("t"), 5314 PublicRepos: Int(1), 5315 Followers: Int(1), 5316 Following: Int(1), 5317 CreatedAt: &Timestamp{referenceTime}, 5318 SuspendedAt: &Timestamp{referenceTime}, 5319 }, 5320 AccessTokensURL: String("atu"), 5321 RepositoriesURL: String("ru"), 5322 HTMLURL: String("hu"), 5323 TargetType: String("tt"), 5324 SingleFileName: String("sfn"), 5325 RepositorySelection: String("rs"), 5326 Events: []string{"e"}, 5327 SingleFilePaths: []string{"s"}, 5328 Permissions: &InstallationPermissions{ 5329 Actions: String("a"), 5330 Administration: String("ad"), 5331 Checks: String("c"), 5332 Contents: String("co"), 5333 ContentReferences: String("cr"), 5334 Deployments: String("d"), 5335 Environments: String("e"), 5336 Issues: String("i"), 5337 Metadata: String("md"), 5338 Members: String("m"), 5339 OrganizationAdministration: String("oa"), 5340 OrganizationHooks: String("oh"), 5341 OrganizationPlan: String("op"), 5342 OrganizationPreReceiveHooks: String("opr"), 5343 OrganizationProjects: String("op"), 5344 OrganizationSecrets: String("os"), 5345 OrganizationSelfHostedRunners: String("osh"), 5346 OrganizationUserBlocking: String("oub"), 5347 Packages: String("pkg"), 5348 Pages: String("pg"), 5349 PullRequests: String("pr"), 5350 RepositoryHooks: String("rh"), 5351 RepositoryProjects: String("rp"), 5352 RepositoryPreReceiveHooks: String("rprh"), 5353 Secrets: String("s"), 5354 SecretScanningAlerts: String("ssa"), 5355 SecurityEvents: String("se"), 5356 SingleFile: String("sf"), 5357 Statuses: String("s"), 5358 TeamDiscussions: String("td"), 5359 VulnerabilityAlerts: String("va"), 5360 Workflows: String("w"), 5361 }, 5362 CreatedAt: &Timestamp{referenceTime}, 5363 UpdatedAt: &Timestamp{referenceTime}, 5364 HasMultipleSingleFiles: Bool(false), 5365 SuspendedBy: &User{ 5366 Login: String("l"), 5367 ID: Int64(1), 5368 URL: String("u"), 5369 AvatarURL: String("a"), 5370 GravatarID: String("g"), 5371 Name: String("n"), 5372 Company: String("c"), 5373 Blog: String("b"), 5374 Location: String("l"), 5375 Email: String("e"), 5376 Hireable: Bool(true), 5377 Bio: String("b"), 5378 TwitterUsername: String("t"), 5379 PublicRepos: Int(1), 5380 Followers: Int(1), 5381 Following: Int(1), 5382 CreatedAt: &Timestamp{referenceTime}, 5383 SuspendedAt: &Timestamp{referenceTime}, 5384 }, 5385 SuspendedAt: &Timestamp{referenceTime}, 5386 }, 5387 } 5388 5389 want := `{ 5390 "comment": { 5391 "html_url": "hurl", 5392 "url": "url", 5393 "id": 1, 5394 "node_id": "nid", 5395 "commit_id": "cid", 5396 "user": { 5397 "login": "l", 5398 "id": 1, 5399 "node_id": "n", 5400 "avatar_url": "a", 5401 "url": "u", 5402 "events_url": "e", 5403 "repos_url": "r" 5404 }, 5405 "reactions": { 5406 "total_count": 1, 5407 "+1": 1, 5408 "-1": 1, 5409 "laugh": 1, 5410 "confused": 1, 5411 "heart": 1, 5412 "hooray": 1, 5413 "rocket": 1, 5414 "eyes": 1, 5415 "url": "url" 5416 }, 5417 "created_at": ` + referenceTimeStr + `, 5418 "updated_at": ` + referenceTimeStr + `, 5419 "body": "b", 5420 "path": "path", 5421 "position": 1 5422 }, 5423 "action": "a", 5424 "repository": { 5425 "id": 1, 5426 "name": "n", 5427 "url": "s" 5428 }, 5429 "sender": { 5430 "login": "l", 5431 "id": 1, 5432 "node_id": "n", 5433 "avatar_url": "a", 5434 "url": "u", 5435 "events_url": "e", 5436 "repos_url": "r" 5437 }, 5438 "installation": { 5439 "id": 1, 5440 "node_id": "nid", 5441 "app_id": 1, 5442 "app_slug": "as", 5443 "target_id": 1, 5444 "account": { 5445 "login": "l", 5446 "id": 1, 5447 "avatar_url": "a", 5448 "gravatar_id": "g", 5449 "name": "n", 5450 "company": "c", 5451 "blog": "b", 5452 "location": "l", 5453 "email": "e", 5454 "hireable": true, 5455 "bio": "b", 5456 "twitter_username": "t", 5457 "public_repos": 1, 5458 "followers": 1, 5459 "following": 1, 5460 "created_at": ` + referenceTimeStr + `, 5461 "suspended_at": ` + referenceTimeStr + `, 5462 "url": "u" 5463 }, 5464 "access_tokens_url": "atu", 5465 "repositories_url": "ru", 5466 "html_url": "hu", 5467 "target_type": "tt", 5468 "single_file_name": "sfn", 5469 "repository_selection": "rs", 5470 "events": [ 5471 "e" 5472 ], 5473 "single_file_paths": [ 5474 "s" 5475 ], 5476 "permissions": { 5477 "actions": "a", 5478 "administration": "ad", 5479 "checks": "c", 5480 "contents": "co", 5481 "content_references": "cr", 5482 "deployments": "d", 5483 "environments": "e", 5484 "issues": "i", 5485 "metadata": "md", 5486 "members": "m", 5487 "organization_administration": "oa", 5488 "organization_hooks": "oh", 5489 "organization_plan": "op", 5490 "organization_pre_receive_hooks": "opr", 5491 "organization_projects": "op", 5492 "organization_secrets": "os", 5493 "organization_self_hosted_runners": "osh", 5494 "organization_user_blocking": "oub", 5495 "packages": "pkg", 5496 "pages": "pg", 5497 "pull_requests": "pr", 5498 "repository_hooks": "rh", 5499 "repository_projects": "rp", 5500 "repository_pre_receive_hooks": "rprh", 5501 "secrets": "s", 5502 "secret_scanning_alerts": "ssa", 5503 "security_events": "se", 5504 "single_file": "sf", 5505 "statuses": "s", 5506 "team_discussions": "td", 5507 "vulnerability_alerts": "va", 5508 "workflows": "w" 5509 }, 5510 "created_at": ` + referenceTimeStr + `, 5511 "updated_at": ` + referenceTimeStr + `, 5512 "has_multiple_single_files": false, 5513 "suspended_by": { 5514 "login": "l", 5515 "id": 1, 5516 "avatar_url": "a", 5517 "gravatar_id": "g", 5518 "name": "n", 5519 "company": "c", 5520 "blog": "b", 5521 "location": "l", 5522 "email": "e", 5523 "hireable": true, 5524 "bio": "b", 5525 "twitter_username": "t", 5526 "public_repos": 1, 5527 "followers": 1, 5528 "following": 1, 5529 "created_at": ` + referenceTimeStr + `, 5530 "suspended_at": ` + referenceTimeStr + `, 5531 "url": "u" 5532 }, 5533 "suspended_at": ` + referenceTimeStr + ` 5534 } 5535 }` 5536 5537 testJSONMarshal(t, u, want) 5538 } 5539 5540 func TestDeploymentEvent_Marshal(t *testing.T) { 5541 testJSONMarshal(t, &DeploymentEvent{}, "{}") 5542 5543 l := make(map[string]interface{}) 5544 l["key"] = "value" 5545 5546 jsonMsg, _ := json.Marshal(&l) 5547 5548 u := &DeploymentEvent{ 5549 Deployment: &Deployment{ 5550 URL: String("url"), 5551 ID: Int64(1), 5552 SHA: String("sha"), 5553 Ref: String("ref"), 5554 Task: String("t"), 5555 Payload: jsonMsg, 5556 Environment: String("e"), 5557 Description: String("d"), 5558 Creator: &User{ 5559 Login: String("l"), 5560 ID: Int64(1), 5561 NodeID: String("n"), 5562 URL: String("u"), 5563 ReposURL: String("r"), 5564 EventsURL: String("e"), 5565 AvatarURL: String("a"), 5566 }, 5567 CreatedAt: &Timestamp{referenceTime}, 5568 UpdatedAt: &Timestamp{referenceTime}, 5569 StatusesURL: String("surl"), 5570 RepositoryURL: String("rurl"), 5571 NodeID: String("nid"), 5572 }, 5573 Repo: &Repository{ 5574 ID: Int64(1), 5575 URL: String("s"), 5576 Name: String("n"), 5577 }, 5578 Sender: &User{ 5579 Login: String("l"), 5580 ID: Int64(1), 5581 NodeID: String("n"), 5582 URL: String("u"), 5583 ReposURL: String("r"), 5584 EventsURL: String("e"), 5585 AvatarURL: String("a"), 5586 }, 5587 Installation: &Installation{ 5588 ID: Int64(1), 5589 NodeID: String("nid"), 5590 AppID: Int64(1), 5591 AppSlug: String("as"), 5592 TargetID: Int64(1), 5593 Account: &User{ 5594 Login: String("l"), 5595 ID: Int64(1), 5596 URL: String("u"), 5597 AvatarURL: String("a"), 5598 GravatarID: String("g"), 5599 Name: String("n"), 5600 Company: String("c"), 5601 Blog: String("b"), 5602 Location: String("l"), 5603 Email: String("e"), 5604 Hireable: Bool(true), 5605 Bio: String("b"), 5606 TwitterUsername: String("t"), 5607 PublicRepos: Int(1), 5608 Followers: Int(1), 5609 Following: Int(1), 5610 CreatedAt: &Timestamp{referenceTime}, 5611 SuspendedAt: &Timestamp{referenceTime}, 5612 }, 5613 AccessTokensURL: String("atu"), 5614 RepositoriesURL: String("ru"), 5615 HTMLURL: String("hu"), 5616 TargetType: String("tt"), 5617 SingleFileName: String("sfn"), 5618 RepositorySelection: String("rs"), 5619 Events: []string{"e"}, 5620 SingleFilePaths: []string{"s"}, 5621 Permissions: &InstallationPermissions{ 5622 Actions: String("a"), 5623 Administration: String("ad"), 5624 Checks: String("c"), 5625 Contents: String("co"), 5626 ContentReferences: String("cr"), 5627 Deployments: String("d"), 5628 Environments: String("e"), 5629 Issues: String("i"), 5630 Metadata: String("md"), 5631 Members: String("m"), 5632 OrganizationAdministration: String("oa"), 5633 OrganizationHooks: String("oh"), 5634 OrganizationPlan: String("op"), 5635 OrganizationPreReceiveHooks: String("opr"), 5636 OrganizationProjects: String("op"), 5637 OrganizationSecrets: String("os"), 5638 OrganizationSelfHostedRunners: String("osh"), 5639 OrganizationUserBlocking: String("oub"), 5640 Packages: String("pkg"), 5641 Pages: String("pg"), 5642 PullRequests: String("pr"), 5643 RepositoryHooks: String("rh"), 5644 RepositoryProjects: String("rp"), 5645 RepositoryPreReceiveHooks: String("rprh"), 5646 Secrets: String("s"), 5647 SecretScanningAlerts: String("ssa"), 5648 SecurityEvents: String("se"), 5649 SingleFile: String("sf"), 5650 Statuses: String("s"), 5651 TeamDiscussions: String("td"), 5652 VulnerabilityAlerts: String("va"), 5653 Workflows: String("w"), 5654 }, 5655 CreatedAt: &Timestamp{referenceTime}, 5656 UpdatedAt: &Timestamp{referenceTime}, 5657 HasMultipleSingleFiles: Bool(false), 5658 SuspendedBy: &User{ 5659 Login: String("l"), 5660 ID: Int64(1), 5661 URL: String("u"), 5662 AvatarURL: String("a"), 5663 GravatarID: String("g"), 5664 Name: String("n"), 5665 Company: String("c"), 5666 Blog: String("b"), 5667 Location: String("l"), 5668 Email: String("e"), 5669 Hireable: Bool(true), 5670 Bio: String("b"), 5671 TwitterUsername: String("t"), 5672 PublicRepos: Int(1), 5673 Followers: Int(1), 5674 Following: Int(1), 5675 CreatedAt: &Timestamp{referenceTime}, 5676 SuspendedAt: &Timestamp{referenceTime}, 5677 }, 5678 SuspendedAt: &Timestamp{referenceTime}, 5679 }, 5680 Workflow: &Workflow{ 5681 ID: Int64(1), 5682 NodeID: String("nid"), 5683 Name: String("n"), 5684 Path: String("p"), 5685 State: String("s"), 5686 CreatedAt: &Timestamp{referenceTime}, 5687 UpdatedAt: &Timestamp{referenceTime}, 5688 URL: String("u"), 5689 HTMLURL: String("h"), 5690 BadgeURL: String("b"), 5691 }, 5692 WorkflowRun: &WorkflowRun{ 5693 ID: Int64(1), 5694 Name: String("n"), 5695 NodeID: String("nid"), 5696 HeadBranch: String("hb"), 5697 HeadSHA: String("hs"), 5698 RunNumber: Int(1), 5699 RunAttempt: Int(1), 5700 Event: String("e"), 5701 Status: String("s"), 5702 Conclusion: String("c"), 5703 WorkflowID: Int64(1), 5704 URL: String("u"), 5705 HTMLURL: String("h"), 5706 PullRequests: []*PullRequest{ 5707 { 5708 URL: String("u"), 5709 ID: Int64(1), 5710 Number: Int(1), 5711 Head: &PullRequestBranch{ 5712 Ref: String("r"), 5713 SHA: String("s"), 5714 Repo: &Repository{ 5715 ID: Int64(1), 5716 URL: String("s"), 5717 Name: String("n"), 5718 }, 5719 }, 5720 Base: &PullRequestBranch{ 5721 Ref: String("r"), 5722 SHA: String("s"), 5723 Repo: &Repository{ 5724 ID: Int64(1), 5725 URL: String("u"), 5726 Name: String("n"), 5727 }, 5728 }, 5729 }, 5730 }, 5731 CreatedAt: &Timestamp{referenceTime}, 5732 UpdatedAt: &Timestamp{referenceTime}, 5733 RunStartedAt: &Timestamp{referenceTime}, 5734 JobsURL: String("j"), 5735 LogsURL: String("l"), 5736 CheckSuiteURL: String("c"), 5737 ArtifactsURL: String("a"), 5738 CancelURL: String("c"), 5739 RerunURL: String("r"), 5740 PreviousAttemptURL: String("p"), 5741 HeadCommit: &HeadCommit{ 5742 Message: String("m"), 5743 Author: &CommitAuthor{ 5744 Name: String("n"), 5745 Email: String("e"), 5746 Login: String("l"), 5747 }, 5748 URL: String("u"), 5749 Distinct: Bool(false), 5750 SHA: String("s"), 5751 ID: String("i"), 5752 TreeID: String("tid"), 5753 Timestamp: &Timestamp{referenceTime}, 5754 Committer: &CommitAuthor{ 5755 Name: String("n"), 5756 Email: String("e"), 5757 Login: String("l"), 5758 }, 5759 }, 5760 WorkflowURL: String("w"), 5761 Repository: &Repository{ 5762 ID: Int64(1), 5763 URL: String("u"), 5764 Name: String("n"), 5765 }, 5766 HeadRepository: &Repository{ 5767 ID: Int64(1), 5768 URL: String("u"), 5769 Name: String("n"), 5770 }, 5771 }, 5772 } 5773 5774 want := `{ 5775 "deployment": { 5776 "url": "url", 5777 "id": 1, 5778 "sha": "sha", 5779 "ref": "ref", 5780 "task": "t", 5781 "payload": { 5782 "key": "value" 5783 }, 5784 "environment": "e", 5785 "description": "d", 5786 "creator": { 5787 "login": "l", 5788 "id": 1, 5789 "node_id": "n", 5790 "avatar_url": "a", 5791 "url": "u", 5792 "events_url": "e", 5793 "repos_url": "r" 5794 }, 5795 "created_at": ` + referenceTimeStr + `, 5796 "updated_at": ` + referenceTimeStr + `, 5797 "statuses_url": "surl", 5798 "repository_url": "rurl", 5799 "node_id": "nid" 5800 }, 5801 "repository": { 5802 "id": 1, 5803 "name": "n", 5804 "url": "s" 5805 }, 5806 "sender": { 5807 "login": "l", 5808 "id": 1, 5809 "node_id": "n", 5810 "avatar_url": "a", 5811 "url": "u", 5812 "events_url": "e", 5813 "repos_url": "r" 5814 }, 5815 "installation": { 5816 "id": 1, 5817 "node_id": "nid", 5818 "app_id": 1, 5819 "app_slug": "as", 5820 "target_id": 1, 5821 "account": { 5822 "login": "l", 5823 "id": 1, 5824 "avatar_url": "a", 5825 "gravatar_id": "g", 5826 "name": "n", 5827 "company": "c", 5828 "blog": "b", 5829 "location": "l", 5830 "email": "e", 5831 "hireable": true, 5832 "bio": "b", 5833 "twitter_username": "t", 5834 "public_repos": 1, 5835 "followers": 1, 5836 "following": 1, 5837 "created_at": ` + referenceTimeStr + `, 5838 "suspended_at": ` + referenceTimeStr + `, 5839 "url": "u" 5840 }, 5841 "access_tokens_url": "atu", 5842 "repositories_url": "ru", 5843 "html_url": "hu", 5844 "target_type": "tt", 5845 "single_file_name": "sfn", 5846 "repository_selection": "rs", 5847 "events": [ 5848 "e" 5849 ], 5850 "single_file_paths": [ 5851 "s" 5852 ], 5853 "permissions": { 5854 "actions": "a", 5855 "administration": "ad", 5856 "checks": "c", 5857 "contents": "co", 5858 "content_references": "cr", 5859 "deployments": "d", 5860 "environments": "e", 5861 "issues": "i", 5862 "metadata": "md", 5863 "members": "m", 5864 "organization_administration": "oa", 5865 "organization_hooks": "oh", 5866 "organization_plan": "op", 5867 "organization_pre_receive_hooks": "opr", 5868 "organization_projects": "op", 5869 "organization_secrets": "os", 5870 "organization_self_hosted_runners": "osh", 5871 "organization_user_blocking": "oub", 5872 "packages": "pkg", 5873 "pages": "pg", 5874 "pull_requests": "pr", 5875 "repository_hooks": "rh", 5876 "repository_projects": "rp", 5877 "repository_pre_receive_hooks": "rprh", 5878 "secrets": "s", 5879 "secret_scanning_alerts": "ssa", 5880 "security_events": "se", 5881 "single_file": "sf", 5882 "statuses": "s", 5883 "team_discussions": "td", 5884 "vulnerability_alerts": "va", 5885 "workflows": "w" 5886 }, 5887 "created_at": ` + referenceTimeStr + `, 5888 "updated_at": ` + referenceTimeStr + `, 5889 "has_multiple_single_files": false, 5890 "suspended_by": { 5891 "login": "l", 5892 "id": 1, 5893 "avatar_url": "a", 5894 "gravatar_id": "g", 5895 "name": "n", 5896 "company": "c", 5897 "blog": "b", 5898 "location": "l", 5899 "email": "e", 5900 "hireable": true, 5901 "bio": "b", 5902 "twitter_username": "t", 5903 "public_repos": 1, 5904 "followers": 1, 5905 "following": 1, 5906 "created_at": ` + referenceTimeStr + `, 5907 "suspended_at": ` + referenceTimeStr + `, 5908 "url": "u" 5909 }, 5910 "suspended_at": ` + referenceTimeStr + ` 5911 }, 5912 "workflow": { 5913 "id": 1, 5914 "node_id": "nid", 5915 "name": "n", 5916 "path": "p", 5917 "state": "s", 5918 "created_at": ` + referenceTimeStr + `, 5919 "updated_at": ` + referenceTimeStr + `, 5920 "url": "u", 5921 "html_url": "h", 5922 "badge_url": "b" 5923 }, 5924 "workflow_run": { 5925 "id": 1, 5926 "name": "n", 5927 "node_id": "nid", 5928 "head_branch": "hb", 5929 "head_sha": "hs", 5930 "run_number": 1, 5931 "run_attempt": 1, 5932 "event": "e", 5933 "status": "s", 5934 "conclusion": "c", 5935 "workflow_id": 1, 5936 "url": "u", 5937 "html_url": "h", 5938 "pull_requests": [ 5939 { 5940 "id": 1, 5941 "number": 1, 5942 "url": "u", 5943 "head": { 5944 "ref": "r", 5945 "sha": "s", 5946 "repo": { 5947 "id": 1, 5948 "name": "n", 5949 "url": "s" 5950 } 5951 }, 5952 "base": { 5953 "ref": "r", 5954 "sha": "s", 5955 "repo": { 5956 "id": 1, 5957 "name": "n", 5958 "url": "u" 5959 } 5960 } 5961 } 5962 ], 5963 "created_at": ` + referenceTimeStr + `, 5964 "updated_at": ` + referenceTimeStr + `, 5965 "run_started_at": ` + referenceTimeStr + `, 5966 "jobs_url": "j", 5967 "logs_url": "l", 5968 "check_suite_url": "c", 5969 "artifacts_url": "a", 5970 "cancel_url": "c", 5971 "rerun_url": "r", 5972 "previous_attempt_url": "p", 5973 "head_commit": { 5974 "message": "m", 5975 "author": { 5976 "name": "n", 5977 "email": "e", 5978 "username": "l" 5979 }, 5980 "url": "u", 5981 "distinct": false, 5982 "sha": "s", 5983 "id": "i", 5984 "tree_id": "tid", 5985 "timestamp": ` + referenceTimeStr + `, 5986 "committer": { 5987 "name": "n", 5988 "email": "e", 5989 "username": "l" 5990 } 5991 }, 5992 "workflow_url": "w", 5993 "repository": { 5994 "id": 1, 5995 "name": "n", 5996 "url": "u" 5997 }, 5998 "head_repository": { 5999 "id": 1, 6000 "name": "n", 6001 "url": "u" 6002 } 6003 } 6004 }` 6005 6006 testJSONMarshal(t, u, want) 6007 } 6008 6009 func TestDeploymentProtectionRuleEvent_Marshal(t *testing.T) { 6010 testJSONMarshal(t, &DeploymentProtectionRuleEvent{}, "{}") 6011 6012 l := make(map[string]interface{}) 6013 l["key"] = "value" 6014 6015 jsonMsg, _ := json.Marshal(&l) 6016 6017 u := &DeploymentProtectionRuleEvent{ 6018 Action: String("a"), 6019 Environment: String("e"), 6020 DeploymentCallbackURL: String("b"), 6021 Deployment: &Deployment{ 6022 URL: String("url"), 6023 ID: Int64(1), 6024 SHA: String("sha"), 6025 Ref: String("ref"), 6026 Task: String("t"), 6027 Payload: jsonMsg, 6028 Environment: String("e"), 6029 Description: String("d"), 6030 Creator: &User{ 6031 Login: String("l"), 6032 ID: Int64(1), 6033 NodeID: String("n"), 6034 URL: String("u"), 6035 ReposURL: String("r"), 6036 EventsURL: String("e"), 6037 AvatarURL: String("a"), 6038 }, 6039 CreatedAt: &Timestamp{referenceTime}, 6040 UpdatedAt: &Timestamp{referenceTime}, 6041 StatusesURL: String("surl"), 6042 RepositoryURL: String("rurl"), 6043 NodeID: String("nid"), 6044 }, 6045 Repo: &Repository{ 6046 ID: Int64(1), 6047 URL: String("s"), 6048 Name: String("n"), 6049 }, 6050 Organization: &Organization{ 6051 BillingEmail: String("be"), 6052 Blog: String("b"), 6053 Company: String("c"), 6054 Email: String("e"), 6055 TwitterUsername: String("tu"), 6056 Location: String("loc"), 6057 Name: String("n"), 6058 Description: String("d"), 6059 IsVerified: Bool(true), 6060 HasOrganizationProjects: Bool(true), 6061 HasRepositoryProjects: Bool(true), 6062 DefaultRepoPermission: String("drp"), 6063 MembersCanCreateRepos: Bool(true), 6064 MembersCanCreateInternalRepos: Bool(true), 6065 MembersCanCreatePrivateRepos: Bool(true), 6066 MembersCanCreatePublicRepos: Bool(false), 6067 MembersAllowedRepositoryCreationType: String("marct"), 6068 MembersCanCreatePages: Bool(true), 6069 MembersCanCreatePublicPages: Bool(false), 6070 MembersCanCreatePrivatePages: Bool(true), 6071 }, 6072 PullRequests: []*PullRequest{ 6073 { 6074 URL: String("u"), 6075 ID: Int64(1), 6076 Number: Int(1), 6077 Head: &PullRequestBranch{ 6078 Ref: String("r"), 6079 SHA: String("s"), 6080 Repo: &Repository{ 6081 ID: Int64(1), 6082 URL: String("s"), 6083 Name: String("n"), 6084 }, 6085 }, 6086 Base: &PullRequestBranch{ 6087 Ref: String("r"), 6088 SHA: String("s"), 6089 Repo: &Repository{ 6090 ID: Int64(1), 6091 URL: String("u"), 6092 Name: String("n"), 6093 }, 6094 }, 6095 }, 6096 }, 6097 Sender: &User{ 6098 Login: String("l"), 6099 ID: Int64(1), 6100 NodeID: String("n"), 6101 URL: String("u"), 6102 ReposURL: String("r"), 6103 EventsURL: String("e"), 6104 AvatarURL: String("a"), 6105 }, 6106 Installation: &Installation{ 6107 ID: Int64(1), 6108 NodeID: String("nid"), 6109 AppID: Int64(1), 6110 AppSlug: String("as"), 6111 TargetID: Int64(1), 6112 Account: &User{ 6113 Login: String("l"), 6114 ID: Int64(1), 6115 URL: String("u"), 6116 AvatarURL: String("a"), 6117 GravatarID: String("g"), 6118 Name: String("n"), 6119 Company: String("c"), 6120 Blog: String("b"), 6121 Location: String("l"), 6122 Email: String("e"), 6123 Hireable: Bool(true), 6124 Bio: String("b"), 6125 TwitterUsername: String("t"), 6126 PublicRepos: Int(1), 6127 Followers: Int(1), 6128 Following: Int(1), 6129 CreatedAt: &Timestamp{referenceTime}, 6130 SuspendedAt: &Timestamp{referenceTime}, 6131 }, 6132 AccessTokensURL: String("atu"), 6133 RepositoriesURL: String("ru"), 6134 HTMLURL: String("hu"), 6135 TargetType: String("tt"), 6136 SingleFileName: String("sfn"), 6137 RepositorySelection: String("rs"), 6138 Events: []string{"e"}, 6139 SingleFilePaths: []string{"s"}, 6140 Permissions: &InstallationPermissions{ 6141 Actions: String("a"), 6142 Administration: String("ad"), 6143 Checks: String("c"), 6144 Contents: String("co"), 6145 ContentReferences: String("cr"), 6146 Deployments: String("d"), 6147 Environments: String("e"), 6148 Issues: String("i"), 6149 Metadata: String("md"), 6150 Members: String("m"), 6151 OrganizationAdministration: String("oa"), 6152 OrganizationHooks: String("oh"), 6153 OrganizationPlan: String("op"), 6154 OrganizationPreReceiveHooks: String("opr"), 6155 OrganizationProjects: String("op"), 6156 OrganizationSecrets: String("os"), 6157 OrganizationSelfHostedRunners: String("osh"), 6158 OrganizationUserBlocking: String("oub"), 6159 Packages: String("pkg"), 6160 Pages: String("pg"), 6161 PullRequests: String("pr"), 6162 RepositoryHooks: String("rh"), 6163 RepositoryProjects: String("rp"), 6164 RepositoryPreReceiveHooks: String("rprh"), 6165 Secrets: String("s"), 6166 SecretScanningAlerts: String("ssa"), 6167 SecurityEvents: String("se"), 6168 SingleFile: String("sf"), 6169 Statuses: String("s"), 6170 TeamDiscussions: String("td"), 6171 VulnerabilityAlerts: String("va"), 6172 Workflows: String("w"), 6173 }, 6174 CreatedAt: &Timestamp{referenceTime}, 6175 UpdatedAt: &Timestamp{referenceTime}, 6176 HasMultipleSingleFiles: Bool(false), 6177 SuspendedBy: &User{ 6178 Login: String("l"), 6179 ID: Int64(1), 6180 URL: String("u"), 6181 AvatarURL: String("a"), 6182 GravatarID: String("g"), 6183 Name: String("n"), 6184 Company: String("c"), 6185 Blog: String("b"), 6186 Location: String("l"), 6187 Email: String("e"), 6188 Hireable: Bool(true), 6189 Bio: String("b"), 6190 TwitterUsername: String("t"), 6191 PublicRepos: Int(1), 6192 Followers: Int(1), 6193 Following: Int(1), 6194 CreatedAt: &Timestamp{referenceTime}, 6195 SuspendedAt: &Timestamp{referenceTime}, 6196 }, 6197 SuspendedAt: &Timestamp{referenceTime}, 6198 }, 6199 } 6200 6201 want := `{ 6202 "action": "a", 6203 "environment": "e", 6204 "deployment_callback_url": "b", 6205 "deployment": { 6206 "url": "url", 6207 "id": 1, 6208 "sha": "sha", 6209 "ref": "ref", 6210 "task": "t", 6211 "payload": { 6212 "key": "value" 6213 }, 6214 "environment": "e", 6215 "description": "d", 6216 "creator": { 6217 "login": "l", 6218 "id": 1, 6219 "node_id": "n", 6220 "avatar_url": "a", 6221 "url": "u", 6222 "events_url": "e", 6223 "repos_url": "r" 6224 }, 6225 "created_at": ` + referenceTimeStr + `, 6226 "updated_at": ` + referenceTimeStr + `, 6227 "statuses_url": "surl", 6228 "repository_url": "rurl", 6229 "node_id": "nid" 6230 }, 6231 "repository": { 6232 "id": 1, 6233 "name": "n", 6234 "url": "s" 6235 }, 6236 "organization": { 6237 "name": "n", 6238 "company": "c", 6239 "blog": "b", 6240 "location": "loc", 6241 "email": "e", 6242 "twitter_username": "tu", 6243 "description": "d", 6244 "billing_email": "be", 6245 "is_verified": true, 6246 "has_organization_projects": true, 6247 "has_repository_projects": true, 6248 "default_repository_permission": "drp", 6249 "members_can_create_repositories": true, 6250 "members_can_create_public_repositories": false, 6251 "members_can_create_private_repositories": true, 6252 "members_can_create_internal_repositories": true, 6253 "members_allowed_repository_creation_type": "marct", 6254 "members_can_create_pages": true, 6255 "members_can_create_public_pages": false, 6256 "members_can_create_private_pages": true 6257 }, 6258 "pull_requests": [ 6259 { 6260 "id": 1, 6261 "number": 1, 6262 "url": "u", 6263 "head": { 6264 "ref": "r", 6265 "sha": "s", 6266 "repo": { 6267 "id": 1, 6268 "name": "n", 6269 "url": "s" 6270 } 6271 }, 6272 "base": { 6273 "ref": "r", 6274 "sha": "s", 6275 "repo": { 6276 "id": 1, 6277 "name": "n", 6278 "url": "u" 6279 } 6280 } 6281 } 6282 ], 6283 "sender": { 6284 "login": "l", 6285 "id": 1, 6286 "node_id": "n", 6287 "avatar_url": "a", 6288 "url": "u", 6289 "events_url": "e", 6290 "repos_url": "r" 6291 }, 6292 "installation": { 6293 "id": 1, 6294 "node_id": "nid", 6295 "app_id": 1, 6296 "app_slug": "as", 6297 "target_id": 1, 6298 "account": { 6299 "login": "l", 6300 "id": 1, 6301 "avatar_url": "a", 6302 "gravatar_id": "g", 6303 "name": "n", 6304 "company": "c", 6305 "blog": "b", 6306 "location": "l", 6307 "email": "e", 6308 "hireable": true, 6309 "bio": "b", 6310 "twitter_username": "t", 6311 "public_repos": 1, 6312 "followers": 1, 6313 "following": 1, 6314 "created_at": ` + referenceTimeStr + `, 6315 "suspended_at": ` + referenceTimeStr + `, 6316 "url": "u" 6317 }, 6318 "access_tokens_url": "atu", 6319 "repositories_url": "ru", 6320 "html_url": "hu", 6321 "target_type": "tt", 6322 "single_file_name": "sfn", 6323 "repository_selection": "rs", 6324 "events": [ 6325 "e" 6326 ], 6327 "single_file_paths": [ 6328 "s" 6329 ], 6330 "permissions": { 6331 "actions": "a", 6332 "administration": "ad", 6333 "checks": "c", 6334 "contents": "co", 6335 "content_references": "cr", 6336 "deployments": "d", 6337 "environments": "e", 6338 "issues": "i", 6339 "metadata": "md", 6340 "members": "m", 6341 "organization_administration": "oa", 6342 "organization_hooks": "oh", 6343 "organization_plan": "op", 6344 "organization_pre_receive_hooks": "opr", 6345 "organization_projects": "op", 6346 "organization_secrets": "os", 6347 "organization_self_hosted_runners": "osh", 6348 "organization_user_blocking": "oub", 6349 "packages": "pkg", 6350 "pages": "pg", 6351 "pull_requests": "pr", 6352 "repository_hooks": "rh", 6353 "repository_projects": "rp", 6354 "repository_pre_receive_hooks": "rprh", 6355 "secrets": "s", 6356 "secret_scanning_alerts": "ssa", 6357 "security_events": "se", 6358 "single_file": "sf", 6359 "statuses": "s", 6360 "team_discussions": "td", 6361 "vulnerability_alerts": "va", 6362 "workflows": "w" 6363 }, 6364 "created_at": ` + referenceTimeStr + `, 6365 "updated_at": ` + referenceTimeStr + `, 6366 "has_multiple_single_files": false, 6367 "suspended_by": { 6368 "login": "l", 6369 "id": 1, 6370 "avatar_url": "a", 6371 "gravatar_id": "g", 6372 "name": "n", 6373 "company": "c", 6374 "blog": "b", 6375 "location": "l", 6376 "email": "e", 6377 "hireable": true, 6378 "bio": "b", 6379 "twitter_username": "t", 6380 "public_repos": 1, 6381 "followers": 1, 6382 "following": 1, 6383 "created_at": ` + referenceTimeStr + `, 6384 "suspended_at": ` + referenceTimeStr + `, 6385 "url": "u" 6386 }, 6387 "suspended_at": ` + referenceTimeStr + ` 6388 } 6389 }` 6390 6391 testJSONMarshal(t, u, want) 6392 } 6393 6394 func TestDeploymentStatusEvent_Marshal(t *testing.T) { 6395 testJSONMarshal(t, &DeploymentStatusEvent{}, "{}") 6396 6397 l := make(map[string]interface{}) 6398 l["key"] = "value" 6399 6400 jsonMsg, _ := json.Marshal(&l) 6401 6402 u := &DeploymentStatusEvent{ 6403 Deployment: &Deployment{ 6404 URL: String("url"), 6405 ID: Int64(1), 6406 SHA: String("sha"), 6407 Ref: String("ref"), 6408 Task: String("t"), 6409 Payload: jsonMsg, 6410 Environment: String("e"), 6411 Description: String("d"), 6412 Creator: &User{ 6413 Login: String("l"), 6414 ID: Int64(1), 6415 NodeID: String("n"), 6416 URL: String("u"), 6417 ReposURL: String("r"), 6418 EventsURL: String("e"), 6419 AvatarURL: String("a"), 6420 }, 6421 CreatedAt: &Timestamp{referenceTime}, 6422 UpdatedAt: &Timestamp{referenceTime}, 6423 StatusesURL: String("surl"), 6424 RepositoryURL: String("rurl"), 6425 NodeID: String("nid"), 6426 }, 6427 DeploymentStatus: &DeploymentStatus{ 6428 ID: Int64(1), 6429 State: String("s"), 6430 Creator: &User{ 6431 Login: String("l"), 6432 ID: Int64(1), 6433 NodeID: String("n"), 6434 URL: String("u"), 6435 ReposURL: String("r"), 6436 EventsURL: String("e"), 6437 AvatarURL: String("a"), 6438 }, 6439 Description: String("s"), 6440 Environment: String("s"), 6441 NodeID: String("s"), 6442 CreatedAt: &Timestamp{referenceTime}, 6443 UpdatedAt: &Timestamp{referenceTime}, 6444 TargetURL: String("s"), 6445 DeploymentURL: String("s"), 6446 RepositoryURL: String("s"), 6447 EnvironmentURL: String("s"), 6448 LogURL: String("s"), 6449 URL: String("s"), 6450 }, 6451 Repo: &Repository{ 6452 ID: Int64(1), 6453 URL: String("s"), 6454 Name: String("n"), 6455 }, 6456 Sender: &User{ 6457 Login: String("l"), 6458 ID: Int64(1), 6459 NodeID: String("n"), 6460 URL: String("u"), 6461 ReposURL: String("r"), 6462 EventsURL: String("e"), 6463 AvatarURL: String("a"), 6464 }, 6465 Installation: &Installation{ 6466 ID: Int64(1), 6467 NodeID: String("nid"), 6468 AppID: Int64(1), 6469 AppSlug: String("as"), 6470 TargetID: Int64(1), 6471 Account: &User{ 6472 Login: String("l"), 6473 ID: Int64(1), 6474 URL: String("u"), 6475 AvatarURL: String("a"), 6476 GravatarID: String("g"), 6477 Name: String("n"), 6478 Company: String("c"), 6479 Blog: String("b"), 6480 Location: String("l"), 6481 Email: String("e"), 6482 Hireable: Bool(true), 6483 Bio: String("b"), 6484 TwitterUsername: String("t"), 6485 PublicRepos: Int(1), 6486 Followers: Int(1), 6487 Following: Int(1), 6488 CreatedAt: &Timestamp{referenceTime}, 6489 SuspendedAt: &Timestamp{referenceTime}, 6490 }, 6491 AccessTokensURL: String("atu"), 6492 RepositoriesURL: String("ru"), 6493 HTMLURL: String("hu"), 6494 TargetType: String("tt"), 6495 SingleFileName: String("sfn"), 6496 RepositorySelection: String("rs"), 6497 Events: []string{"e"}, 6498 SingleFilePaths: []string{"s"}, 6499 Permissions: &InstallationPermissions{ 6500 Actions: String("a"), 6501 Administration: String("ad"), 6502 Checks: String("c"), 6503 Contents: String("co"), 6504 ContentReferences: String("cr"), 6505 Deployments: String("d"), 6506 Environments: String("e"), 6507 Issues: String("i"), 6508 Metadata: String("md"), 6509 Members: String("m"), 6510 OrganizationAdministration: String("oa"), 6511 OrganizationHooks: String("oh"), 6512 OrganizationPlan: String("op"), 6513 OrganizationPreReceiveHooks: String("opr"), 6514 OrganizationProjects: String("op"), 6515 OrganizationSecrets: String("os"), 6516 OrganizationSelfHostedRunners: String("osh"), 6517 OrganizationUserBlocking: String("oub"), 6518 Packages: String("pkg"), 6519 Pages: String("pg"), 6520 PullRequests: String("pr"), 6521 RepositoryHooks: String("rh"), 6522 RepositoryProjects: String("rp"), 6523 RepositoryPreReceiveHooks: String("rprh"), 6524 Secrets: String("s"), 6525 SecretScanningAlerts: String("ssa"), 6526 SecurityEvents: String("se"), 6527 SingleFile: String("sf"), 6528 Statuses: String("s"), 6529 TeamDiscussions: String("td"), 6530 VulnerabilityAlerts: String("va"), 6531 Workflows: String("w"), 6532 }, 6533 CreatedAt: &Timestamp{referenceTime}, 6534 UpdatedAt: &Timestamp{referenceTime}, 6535 HasMultipleSingleFiles: Bool(false), 6536 SuspendedBy: &User{ 6537 Login: String("l"), 6538 ID: Int64(1), 6539 URL: String("u"), 6540 AvatarURL: String("a"), 6541 GravatarID: String("g"), 6542 Name: String("n"), 6543 Company: String("c"), 6544 Blog: String("b"), 6545 Location: String("l"), 6546 Email: String("e"), 6547 Hireable: Bool(true), 6548 Bio: String("b"), 6549 TwitterUsername: String("t"), 6550 PublicRepos: Int(1), 6551 Followers: Int(1), 6552 Following: Int(1), 6553 CreatedAt: &Timestamp{referenceTime}, 6554 SuspendedAt: &Timestamp{referenceTime}, 6555 }, 6556 SuspendedAt: &Timestamp{referenceTime}, 6557 }, 6558 } 6559 6560 want := `{ 6561 "deployment": { 6562 "url": "url", 6563 "id": 1, 6564 "sha": "sha", 6565 "ref": "ref", 6566 "task": "t", 6567 "payload": { 6568 "key": "value" 6569 }, 6570 "environment": "e", 6571 "description": "d", 6572 "creator": { 6573 "login": "l", 6574 "id": 1, 6575 "node_id": "n", 6576 "avatar_url": "a", 6577 "url": "u", 6578 "events_url": "e", 6579 "repos_url": "r" 6580 }, 6581 "created_at": ` + referenceTimeStr + `, 6582 "updated_at": ` + referenceTimeStr + `, 6583 "statuses_url": "surl", 6584 "repository_url": "rurl", 6585 "node_id": "nid" 6586 }, 6587 "deployment_status": { 6588 "id": 1, 6589 "state": "s", 6590 "creator": { 6591 "login": "l", 6592 "id": 1, 6593 "node_id": "n", 6594 "avatar_url": "a", 6595 "url": "u", 6596 "events_url": "e", 6597 "repos_url": "r" 6598 }, 6599 "description": "s", 6600 "environment": "s", 6601 "node_id": "s", 6602 "created_at": ` + referenceTimeStr + `, 6603 "updated_at": ` + referenceTimeStr + `, 6604 "target_url": "s", 6605 "deployment_url": "s", 6606 "repository_url": "s", 6607 "environment_url": "s", 6608 "log_url": "s", 6609 "url": "s" 6610 }, 6611 "repository": { 6612 "id": 1, 6613 "name": "n", 6614 "url": "s" 6615 }, 6616 "sender": { 6617 "login": "l", 6618 "id": 1, 6619 "node_id": "n", 6620 "avatar_url": "a", 6621 "url": "u", 6622 "events_url": "e", 6623 "repos_url": "r" 6624 }, 6625 "installation": { 6626 "id": 1, 6627 "node_id": "nid", 6628 "app_id": 1, 6629 "app_slug": "as", 6630 "target_id": 1, 6631 "account": { 6632 "login": "l", 6633 "id": 1, 6634 "avatar_url": "a", 6635 "gravatar_id": "g", 6636 "name": "n", 6637 "company": "c", 6638 "blog": "b", 6639 "location": "l", 6640 "email": "e", 6641 "hireable": true, 6642 "bio": "b", 6643 "twitter_username": "t", 6644 "public_repos": 1, 6645 "followers": 1, 6646 "following": 1, 6647 "created_at": ` + referenceTimeStr + `, 6648 "suspended_at": ` + referenceTimeStr + `, 6649 "url": "u" 6650 }, 6651 "access_tokens_url": "atu", 6652 "repositories_url": "ru", 6653 "html_url": "hu", 6654 "target_type": "tt", 6655 "single_file_name": "sfn", 6656 "repository_selection": "rs", 6657 "events": [ 6658 "e" 6659 ], 6660 "single_file_paths": [ 6661 "s" 6662 ], 6663 "permissions": { 6664 "actions": "a", 6665 "administration": "ad", 6666 "checks": "c", 6667 "contents": "co", 6668 "content_references": "cr", 6669 "deployments": "d", 6670 "environments": "e", 6671 "issues": "i", 6672 "metadata": "md", 6673 "members": "m", 6674 "organization_administration": "oa", 6675 "organization_hooks": "oh", 6676 "organization_plan": "op", 6677 "organization_pre_receive_hooks": "opr", 6678 "organization_projects": "op", 6679 "organization_secrets": "os", 6680 "organization_self_hosted_runners": "osh", 6681 "organization_user_blocking": "oub", 6682 "packages": "pkg", 6683 "pages": "pg", 6684 "pull_requests": "pr", 6685 "repository_hooks": "rh", 6686 "repository_projects": "rp", 6687 "repository_pre_receive_hooks": "rprh", 6688 "secrets": "s", 6689 "secret_scanning_alerts": "ssa", 6690 "security_events": "se", 6691 "single_file": "sf", 6692 "statuses": "s", 6693 "team_discussions": "td", 6694 "vulnerability_alerts": "va", 6695 "workflows": "w" 6696 }, 6697 "created_at": ` + referenceTimeStr + `, 6698 "updated_at": ` + referenceTimeStr + `, 6699 "has_multiple_single_files": false, 6700 "suspended_by": { 6701 "login": "l", 6702 "id": 1, 6703 "avatar_url": "a", 6704 "gravatar_id": "g", 6705 "name": "n", 6706 "company": "c", 6707 "blog": "b", 6708 "location": "l", 6709 "email": "e", 6710 "hireable": true, 6711 "bio": "b", 6712 "twitter_username": "t", 6713 "public_repos": 1, 6714 "followers": 1, 6715 "following": 1, 6716 "created_at": ` + referenceTimeStr + `, 6717 "suspended_at": ` + referenceTimeStr + `, 6718 "url": "u" 6719 }, 6720 "suspended_at": ` + referenceTimeStr + ` 6721 } 6722 }` 6723 6724 testJSONMarshal(t, u, want) 6725 } 6726 6727 func TestDiscussionCommentEvent_Marshal(t *testing.T) { 6728 testJSONMarshal(t, &DiscussionCommentEvent{}, "{}") 6729 6730 u := &DiscussionCommentEvent{ 6731 Comment: &CommentDiscussion{ 6732 AuthorAssociation: String("aa"), 6733 Body: String("bo"), 6734 ChildCommentCount: Int(1), 6735 CreatedAt: &Timestamp{referenceTime}, 6736 DiscussionID: Int64(1), 6737 HTMLURL: String("hurl"), 6738 ID: Int64(1), 6739 NodeID: String("nid"), 6740 ParentID: Int64(1), 6741 Reactions: &Reactions{ 6742 TotalCount: Int(1), 6743 PlusOne: Int(1), 6744 MinusOne: Int(1), 6745 Laugh: Int(1), 6746 Confused: Int(1), 6747 Heart: Int(1), 6748 Hooray: Int(1), 6749 Rocket: Int(1), 6750 Eyes: Int(1), 6751 URL: String("url"), 6752 }, 6753 RepositoryURL: String("rurl"), 6754 UpdatedAt: &Timestamp{referenceTime}, 6755 User: &User{ 6756 Login: String("l"), 6757 ID: Int64(1), 6758 NodeID: String("n"), 6759 URL: String("u"), 6760 ReposURL: String("r"), 6761 EventsURL: String("e"), 6762 AvatarURL: String("a"), 6763 }, 6764 }, 6765 Discussion: &Discussion{ 6766 RepositoryURL: String("rurl"), 6767 DiscussionCategory: &DiscussionCategory{ 6768 ID: Int64(1), 6769 NodeID: String("nid"), 6770 RepositoryID: Int64(1), 6771 Emoji: String("emoji"), 6772 Name: String("name"), 6773 Description: String("description"), 6774 CreatedAt: &Timestamp{referenceTime}, 6775 UpdatedAt: &Timestamp{referenceTime}, 6776 Slug: String("slug"), 6777 IsAnswerable: Bool(false), 6778 }, 6779 HTMLURL: String("hurl"), 6780 ID: Int64(1), 6781 NodeID: String("nurl"), 6782 Number: Int(1), 6783 Title: String("title"), 6784 User: &User{ 6785 Login: String("l"), 6786 ID: Int64(1), 6787 NodeID: String("n"), 6788 URL: String("u"), 6789 ReposURL: String("r"), 6790 EventsURL: String("e"), 6791 AvatarURL: String("a"), 6792 }, 6793 State: String("st"), 6794 Locked: Bool(false), 6795 Comments: Int(1), 6796 CreatedAt: &Timestamp{referenceTime}, 6797 UpdatedAt: &Timestamp{referenceTime}, 6798 AuthorAssociation: String("aa"), 6799 Body: String("bo"), 6800 }, 6801 Repo: &Repository{ 6802 ID: Int64(1), 6803 URL: String("s"), 6804 Name: String("n"), 6805 }, 6806 Org: &Organization{ 6807 BillingEmail: String("be"), 6808 Blog: String("b"), 6809 Company: String("c"), 6810 Email: String("e"), 6811 TwitterUsername: String("tu"), 6812 Location: String("loc"), 6813 Name: String("n"), 6814 Description: String("d"), 6815 IsVerified: Bool(true), 6816 HasOrganizationProjects: Bool(true), 6817 HasRepositoryProjects: Bool(true), 6818 DefaultRepoPermission: String("drp"), 6819 MembersCanCreateRepos: Bool(true), 6820 MembersCanCreateInternalRepos: Bool(true), 6821 MembersCanCreatePrivateRepos: Bool(true), 6822 MembersCanCreatePublicRepos: Bool(false), 6823 MembersAllowedRepositoryCreationType: String("marct"), 6824 MembersCanCreatePages: Bool(true), 6825 MembersCanCreatePublicPages: Bool(false), 6826 MembersCanCreatePrivatePages: Bool(true), 6827 }, 6828 Sender: &User{ 6829 Login: String("l"), 6830 ID: Int64(1), 6831 NodeID: String("n"), 6832 URL: String("u"), 6833 ReposURL: String("r"), 6834 EventsURL: String("e"), 6835 AvatarURL: String("a"), 6836 }, 6837 Installation: &Installation{ 6838 ID: Int64(1), 6839 NodeID: String("nid"), 6840 AppID: Int64(1), 6841 AppSlug: String("as"), 6842 TargetID: Int64(1), 6843 Account: &User{ 6844 Login: String("l"), 6845 ID: Int64(1), 6846 URL: String("u"), 6847 AvatarURL: String("a"), 6848 GravatarID: String("g"), 6849 Name: String("n"), 6850 Company: String("c"), 6851 Blog: String("b"), 6852 Location: String("l"), 6853 Email: String("e"), 6854 Hireable: Bool(true), 6855 Bio: String("b"), 6856 TwitterUsername: String("t"), 6857 PublicRepos: Int(1), 6858 Followers: Int(1), 6859 Following: Int(1), 6860 CreatedAt: &Timestamp{referenceTime}, 6861 SuspendedAt: &Timestamp{referenceTime}, 6862 }, 6863 AccessTokensURL: String("atu"), 6864 RepositoriesURL: String("ru"), 6865 HTMLURL: String("hu"), 6866 TargetType: String("tt"), 6867 SingleFileName: String("sfn"), 6868 RepositorySelection: String("rs"), 6869 Events: []string{"e"}, 6870 SingleFilePaths: []string{"s"}, 6871 Permissions: &InstallationPermissions{ 6872 Actions: String("a"), 6873 Administration: String("ad"), 6874 Checks: String("c"), 6875 Contents: String("co"), 6876 ContentReferences: String("cr"), 6877 Deployments: String("d"), 6878 Environments: String("e"), 6879 Issues: String("i"), 6880 Metadata: String("md"), 6881 Members: String("m"), 6882 OrganizationAdministration: String("oa"), 6883 OrganizationHooks: String("oh"), 6884 OrganizationPlan: String("op"), 6885 OrganizationPreReceiveHooks: String("opr"), 6886 OrganizationProjects: String("op"), 6887 OrganizationSecrets: String("os"), 6888 OrganizationSelfHostedRunners: String("osh"), 6889 OrganizationUserBlocking: String("oub"), 6890 Packages: String("pkg"), 6891 Pages: String("pg"), 6892 PullRequests: String("pr"), 6893 RepositoryHooks: String("rh"), 6894 RepositoryProjects: String("rp"), 6895 RepositoryPreReceiveHooks: String("rprh"), 6896 Secrets: String("s"), 6897 SecretScanningAlerts: String("ssa"), 6898 SecurityEvents: String("se"), 6899 SingleFile: String("sf"), 6900 Statuses: String("s"), 6901 TeamDiscussions: String("td"), 6902 VulnerabilityAlerts: String("va"), 6903 Workflows: String("w"), 6904 }, 6905 CreatedAt: &Timestamp{referenceTime}, 6906 UpdatedAt: &Timestamp{referenceTime}, 6907 HasMultipleSingleFiles: Bool(false), 6908 SuspendedBy: &User{ 6909 Login: String("l"), 6910 ID: Int64(1), 6911 URL: String("u"), 6912 AvatarURL: String("a"), 6913 GravatarID: String("g"), 6914 Name: String("n"), 6915 Company: String("c"), 6916 Blog: String("b"), 6917 Location: String("l"), 6918 Email: String("e"), 6919 Hireable: Bool(true), 6920 Bio: String("b"), 6921 TwitterUsername: String("t"), 6922 PublicRepos: Int(1), 6923 Followers: Int(1), 6924 Following: Int(1), 6925 CreatedAt: &Timestamp{referenceTime}, 6926 SuspendedAt: &Timestamp{referenceTime}, 6927 }, 6928 SuspendedAt: &Timestamp{referenceTime}, 6929 }, 6930 } 6931 6932 want := `{ 6933 "comment": { 6934 "author_association": "aa", 6935 "body": "bo", 6936 "child_comment_count": 1, 6937 "created_at": ` + referenceTimeStr + `, 6938 "discussion_id": 1, 6939 "html_url": "hurl", 6940 "id": 1, 6941 "node_id": "nid", 6942 "parent_id": 1, 6943 "reactions": { 6944 "total_count": 1, 6945 "+1": 1, 6946 "-1": 1, 6947 "laugh": 1, 6948 "confused": 1, 6949 "heart": 1, 6950 "hooray": 1, 6951 "rocket": 1, 6952 "eyes": 1, 6953 "url": "url" 6954 }, 6955 "repository_url": "rurl", 6956 "updated_at": ` + referenceTimeStr + `, 6957 "user": { 6958 "login": "l", 6959 "id": 1, 6960 "node_id": "n", 6961 "avatar_url": "a", 6962 "url": "u", 6963 "events_url": "e", 6964 "repos_url": "r" 6965 } 6966 }, 6967 "discussion": { 6968 "repository_url": "rurl", 6969 "category": { 6970 "id": 1, 6971 "node_id": "nid", 6972 "repository_id": 1, 6973 "emoji": "emoji", 6974 "name": "name", 6975 "description": "description", 6976 "created_at": ` + referenceTimeStr + `, 6977 "updated_at": ` + referenceTimeStr + `, 6978 "slug": "slug", 6979 "is_answerable": false 6980 }, 6981 "html_url": "hurl", 6982 "id": 1, 6983 "node_id": "nurl", 6984 "number": 1, 6985 "title": "title", 6986 "user": { 6987 "login": "l", 6988 "id": 1, 6989 "node_id": "n", 6990 "avatar_url": "a", 6991 "url": "u", 6992 "events_url": "e", 6993 "repos_url": "r" 6994 }, 6995 "state": "st", 6996 "locked": false, 6997 "comments": 1, 6998 "created_at": ` + referenceTimeStr + `, 6999 "updated_at": ` + referenceTimeStr + `, 7000 "author_association": "aa", 7001 "body": "bo" 7002 }, 7003 "repository": { 7004 "id": 1, 7005 "name": "n", 7006 "url": "s" 7007 }, 7008 "organization": { 7009 "name": "n", 7010 "company": "c", 7011 "blog": "b", 7012 "location": "loc", 7013 "email": "e", 7014 "twitter_username": "tu", 7015 "description": "d", 7016 "billing_email": "be", 7017 "is_verified": true, 7018 "has_organization_projects": true, 7019 "has_repository_projects": true, 7020 "default_repository_permission": "drp", 7021 "members_can_create_repositories": true, 7022 "members_can_create_public_repositories": false, 7023 "members_can_create_private_repositories": true, 7024 "members_can_create_internal_repositories": true, 7025 "members_allowed_repository_creation_type": "marct", 7026 "members_can_create_pages": true, 7027 "members_can_create_public_pages": false, 7028 "members_can_create_private_pages": true 7029 }, 7030 "sender": { 7031 "login": "l", 7032 "id": 1, 7033 "node_id": "n", 7034 "avatar_url": "a", 7035 "url": "u", 7036 "events_url": "e", 7037 "repos_url": "r" 7038 }, 7039 "installation": { 7040 "id": 1, 7041 "node_id": "nid", 7042 "app_id": 1, 7043 "app_slug": "as", 7044 "target_id": 1, 7045 "account": { 7046 "login": "l", 7047 "id": 1, 7048 "avatar_url": "a", 7049 "gravatar_id": "g", 7050 "name": "n", 7051 "company": "c", 7052 "blog": "b", 7053 "location": "l", 7054 "email": "e", 7055 "hireable": true, 7056 "bio": "b", 7057 "twitter_username": "t", 7058 "public_repos": 1, 7059 "followers": 1, 7060 "following": 1, 7061 "created_at": ` + referenceTimeStr + `, 7062 "suspended_at": ` + referenceTimeStr + `, 7063 "url": "u" 7064 }, 7065 "access_tokens_url": "atu", 7066 "repositories_url": "ru", 7067 "html_url": "hu", 7068 "target_type": "tt", 7069 "single_file_name": "sfn", 7070 "repository_selection": "rs", 7071 "events": [ 7072 "e" 7073 ], 7074 "single_file_paths": [ 7075 "s" 7076 ], 7077 "permissions": { 7078 "actions": "a", 7079 "administration": "ad", 7080 "checks": "c", 7081 "contents": "co", 7082 "content_references": "cr", 7083 "deployments": "d", 7084 "environments": "e", 7085 "issues": "i", 7086 "metadata": "md", 7087 "members": "m", 7088 "organization_administration": "oa", 7089 "organization_hooks": "oh", 7090 "organization_plan": "op", 7091 "organization_pre_receive_hooks": "opr", 7092 "organization_projects": "op", 7093 "organization_secrets": "os", 7094 "organization_self_hosted_runners": "osh", 7095 "organization_user_blocking": "oub", 7096 "packages": "pkg", 7097 "pages": "pg", 7098 "pull_requests": "pr", 7099 "repository_hooks": "rh", 7100 "repository_projects": "rp", 7101 "repository_pre_receive_hooks": "rprh", 7102 "secrets": "s", 7103 "secret_scanning_alerts": "ssa", 7104 "security_events": "se", 7105 "single_file": "sf", 7106 "statuses": "s", 7107 "team_discussions": "td", 7108 "vulnerability_alerts": "va", 7109 "workflows": "w" 7110 }, 7111 "created_at": ` + referenceTimeStr + `, 7112 "updated_at": ` + referenceTimeStr + `, 7113 "has_multiple_single_files": false, 7114 "suspended_by": { 7115 "login": "l", 7116 "id": 1, 7117 "avatar_url": "a", 7118 "gravatar_id": "g", 7119 "name": "n", 7120 "company": "c", 7121 "blog": "b", 7122 "location": "l", 7123 "email": "e", 7124 "hireable": true, 7125 "bio": "b", 7126 "twitter_username": "t", 7127 "public_repos": 1, 7128 "followers": 1, 7129 "following": 1, 7130 "created_at": ` + referenceTimeStr + `, 7131 "suspended_at": ` + referenceTimeStr + `, 7132 "url": "u" 7133 }, 7134 "suspended_at": ` + referenceTimeStr + ` 7135 } 7136 }` 7137 7138 testJSONMarshal(t, u, want) 7139 } 7140 7141 func TestDiscussionEvent_Marshal(t *testing.T) { 7142 testJSONMarshal(t, &DiscussionEvent{}, "{}") 7143 7144 u := &DiscussionEvent{ 7145 Discussion: &Discussion{ 7146 RepositoryURL: String("rurl"), 7147 DiscussionCategory: &DiscussionCategory{ 7148 ID: Int64(1), 7149 NodeID: String("nid"), 7150 RepositoryID: Int64(1), 7151 Emoji: String("emoji"), 7152 Name: String("name"), 7153 Description: String("description"), 7154 CreatedAt: &Timestamp{referenceTime}, 7155 UpdatedAt: &Timestamp{referenceTime}, 7156 Slug: String("slug"), 7157 IsAnswerable: Bool(false), 7158 }, 7159 HTMLURL: String("hurl"), 7160 ID: Int64(1), 7161 NodeID: String("nurl"), 7162 Number: Int(1), 7163 Title: String("title"), 7164 User: &User{ 7165 Login: String("l"), 7166 ID: Int64(1), 7167 NodeID: String("n"), 7168 URL: String("u"), 7169 ReposURL: String("r"), 7170 EventsURL: String("e"), 7171 AvatarURL: String("a"), 7172 }, 7173 State: String("st"), 7174 Locked: Bool(false), 7175 Comments: Int(1), 7176 CreatedAt: &Timestamp{referenceTime}, 7177 UpdatedAt: &Timestamp{referenceTime}, 7178 AuthorAssociation: String("aa"), 7179 Body: String("bo"), 7180 }, 7181 Repo: &Repository{ 7182 ID: Int64(1), 7183 URL: String("s"), 7184 Name: String("n"), 7185 }, 7186 Org: &Organization{ 7187 BillingEmail: String("be"), 7188 Blog: String("b"), 7189 Company: String("c"), 7190 Email: String("e"), 7191 TwitterUsername: String("tu"), 7192 Location: String("loc"), 7193 Name: String("n"), 7194 Description: String("d"), 7195 IsVerified: Bool(true), 7196 HasOrganizationProjects: Bool(true), 7197 HasRepositoryProjects: Bool(true), 7198 DefaultRepoPermission: String("drp"), 7199 MembersCanCreateRepos: Bool(true), 7200 MembersCanCreateInternalRepos: Bool(true), 7201 MembersCanCreatePrivateRepos: Bool(true), 7202 MembersCanCreatePublicRepos: Bool(false), 7203 MembersAllowedRepositoryCreationType: String("marct"), 7204 MembersCanCreatePages: Bool(true), 7205 MembersCanCreatePublicPages: Bool(false), 7206 MembersCanCreatePrivatePages: Bool(true), 7207 }, 7208 Sender: &User{ 7209 Login: String("l"), 7210 ID: Int64(1), 7211 NodeID: String("n"), 7212 URL: String("u"), 7213 ReposURL: String("r"), 7214 EventsURL: String("e"), 7215 AvatarURL: String("a"), 7216 }, 7217 Installation: &Installation{ 7218 ID: Int64(1), 7219 NodeID: String("nid"), 7220 AppID: Int64(1), 7221 AppSlug: String("as"), 7222 TargetID: Int64(1), 7223 Account: &User{ 7224 Login: String("l"), 7225 ID: Int64(1), 7226 URL: String("u"), 7227 AvatarURL: String("a"), 7228 GravatarID: String("g"), 7229 Name: String("n"), 7230 Company: String("c"), 7231 Blog: String("b"), 7232 Location: String("l"), 7233 Email: String("e"), 7234 Hireable: Bool(true), 7235 Bio: String("b"), 7236 TwitterUsername: String("t"), 7237 PublicRepos: Int(1), 7238 Followers: Int(1), 7239 Following: Int(1), 7240 CreatedAt: &Timestamp{referenceTime}, 7241 SuspendedAt: &Timestamp{referenceTime}, 7242 }, 7243 AccessTokensURL: String("atu"), 7244 RepositoriesURL: String("ru"), 7245 HTMLURL: String("hu"), 7246 TargetType: String("tt"), 7247 SingleFileName: String("sfn"), 7248 RepositorySelection: String("rs"), 7249 Events: []string{"e"}, 7250 SingleFilePaths: []string{"s"}, 7251 Permissions: &InstallationPermissions{ 7252 Actions: String("a"), 7253 Administration: String("ad"), 7254 Checks: String("c"), 7255 Contents: String("co"), 7256 ContentReferences: String("cr"), 7257 Deployments: String("d"), 7258 Environments: String("e"), 7259 Issues: String("i"), 7260 Metadata: String("md"), 7261 Members: String("m"), 7262 OrganizationAdministration: String("oa"), 7263 OrganizationHooks: String("oh"), 7264 OrganizationPlan: String("op"), 7265 OrganizationPreReceiveHooks: String("opr"), 7266 OrganizationProjects: String("op"), 7267 OrganizationSecrets: String("os"), 7268 OrganizationSelfHostedRunners: String("osh"), 7269 OrganizationUserBlocking: String("oub"), 7270 Packages: String("pkg"), 7271 Pages: String("pg"), 7272 PullRequests: String("pr"), 7273 RepositoryHooks: String("rh"), 7274 RepositoryProjects: String("rp"), 7275 RepositoryPreReceiveHooks: String("rprh"), 7276 Secrets: String("s"), 7277 SecretScanningAlerts: String("ssa"), 7278 SecurityEvents: String("se"), 7279 SingleFile: String("sf"), 7280 Statuses: String("s"), 7281 TeamDiscussions: String("td"), 7282 VulnerabilityAlerts: String("va"), 7283 Workflows: String("w"), 7284 }, 7285 CreatedAt: &Timestamp{referenceTime}, 7286 UpdatedAt: &Timestamp{referenceTime}, 7287 HasMultipleSingleFiles: Bool(false), 7288 SuspendedBy: &User{ 7289 Login: String("l"), 7290 ID: Int64(1), 7291 URL: String("u"), 7292 AvatarURL: String("a"), 7293 GravatarID: String("g"), 7294 Name: String("n"), 7295 Company: String("c"), 7296 Blog: String("b"), 7297 Location: String("l"), 7298 Email: String("e"), 7299 Hireable: Bool(true), 7300 Bio: String("b"), 7301 TwitterUsername: String("t"), 7302 PublicRepos: Int(1), 7303 Followers: Int(1), 7304 Following: Int(1), 7305 CreatedAt: &Timestamp{referenceTime}, 7306 SuspendedAt: &Timestamp{referenceTime}, 7307 }, 7308 SuspendedAt: &Timestamp{referenceTime}, 7309 }, 7310 } 7311 7312 want := `{ 7313 "discussion": { 7314 "repository_url": "rurl", 7315 "category": { 7316 "id": 1, 7317 "node_id": "nid", 7318 "repository_id": 1, 7319 "emoji": "emoji", 7320 "name": "name", 7321 "description": "description", 7322 "created_at": ` + referenceTimeStr + `, 7323 "updated_at": ` + referenceTimeStr + `, 7324 "slug": "slug", 7325 "is_answerable": false 7326 }, 7327 "html_url": "hurl", 7328 "id": 1, 7329 "node_id": "nurl", 7330 "number": 1, 7331 "title": "title", 7332 "user": { 7333 "login": "l", 7334 "id": 1, 7335 "node_id": "n", 7336 "avatar_url": "a", 7337 "url": "u", 7338 "events_url": "e", 7339 "repos_url": "r" 7340 }, 7341 "state": "st", 7342 "locked": false, 7343 "comments": 1, 7344 "created_at": ` + referenceTimeStr + `, 7345 "updated_at": ` + referenceTimeStr + `, 7346 "author_association": "aa", 7347 "body": "bo" 7348 }, 7349 "repository": { 7350 "id": 1, 7351 "name": "n", 7352 "url": "s" 7353 }, 7354 "organization": { 7355 "name": "n", 7356 "company": "c", 7357 "blog": "b", 7358 "location": "loc", 7359 "email": "e", 7360 "twitter_username": "tu", 7361 "description": "d", 7362 "billing_email": "be", 7363 "is_verified": true, 7364 "has_organization_projects": true, 7365 "has_repository_projects": true, 7366 "default_repository_permission": "drp", 7367 "members_can_create_repositories": true, 7368 "members_can_create_public_repositories": false, 7369 "members_can_create_private_repositories": true, 7370 "members_can_create_internal_repositories": true, 7371 "members_allowed_repository_creation_type": "marct", 7372 "members_can_create_pages": true, 7373 "members_can_create_public_pages": false, 7374 "members_can_create_private_pages": true 7375 }, 7376 "sender": { 7377 "login": "l", 7378 "id": 1, 7379 "node_id": "n", 7380 "avatar_url": "a", 7381 "url": "u", 7382 "events_url": "e", 7383 "repos_url": "r" 7384 }, 7385 "installation": { 7386 "id": 1, 7387 "node_id": "nid", 7388 "app_id": 1, 7389 "app_slug": "as", 7390 "target_id": 1, 7391 "account": { 7392 "login": "l", 7393 "id": 1, 7394 "avatar_url": "a", 7395 "gravatar_id": "g", 7396 "name": "n", 7397 "company": "c", 7398 "blog": "b", 7399 "location": "l", 7400 "email": "e", 7401 "hireable": true, 7402 "bio": "b", 7403 "twitter_username": "t", 7404 "public_repos": 1, 7405 "followers": 1, 7406 "following": 1, 7407 "created_at": ` + referenceTimeStr + `, 7408 "suspended_at": ` + referenceTimeStr + `, 7409 "url": "u" 7410 }, 7411 "access_tokens_url": "atu", 7412 "repositories_url": "ru", 7413 "html_url": "hu", 7414 "target_type": "tt", 7415 "single_file_name": "sfn", 7416 "repository_selection": "rs", 7417 "events": [ 7418 "e" 7419 ], 7420 "single_file_paths": [ 7421 "s" 7422 ], 7423 "permissions": { 7424 "actions": "a", 7425 "administration": "ad", 7426 "checks": "c", 7427 "contents": "co", 7428 "content_references": "cr", 7429 "deployments": "d", 7430 "environments": "e", 7431 "issues": "i", 7432 "metadata": "md", 7433 "members": "m", 7434 "organization_administration": "oa", 7435 "organization_hooks": "oh", 7436 "organization_plan": "op", 7437 "organization_pre_receive_hooks": "opr", 7438 "organization_projects": "op", 7439 "organization_secrets": "os", 7440 "organization_self_hosted_runners": "osh", 7441 "organization_user_blocking": "oub", 7442 "packages": "pkg", 7443 "pages": "pg", 7444 "pull_requests": "pr", 7445 "repository_hooks": "rh", 7446 "repository_projects": "rp", 7447 "repository_pre_receive_hooks": "rprh", 7448 "secrets": "s", 7449 "secret_scanning_alerts": "ssa", 7450 "security_events": "se", 7451 "single_file": "sf", 7452 "statuses": "s", 7453 "team_discussions": "td", 7454 "vulnerability_alerts": "va", 7455 "workflows": "w" 7456 }, 7457 "created_at": ` + referenceTimeStr + `, 7458 "updated_at": ` + referenceTimeStr + `, 7459 "has_multiple_single_files": false, 7460 "suspended_by": { 7461 "login": "l", 7462 "id": 1, 7463 "avatar_url": "a", 7464 "gravatar_id": "g", 7465 "name": "n", 7466 "company": "c", 7467 "blog": "b", 7468 "location": "l", 7469 "email": "e", 7470 "hireable": true, 7471 "bio": "b", 7472 "twitter_username": "t", 7473 "public_repos": 1, 7474 "followers": 1, 7475 "following": 1, 7476 "created_at": ` + referenceTimeStr + `, 7477 "suspended_at": ` + referenceTimeStr + `, 7478 "url": "u" 7479 }, 7480 "suspended_at": ` + referenceTimeStr + ` 7481 } 7482 }` 7483 7484 testJSONMarshal(t, u, want) 7485 } 7486 7487 func TestPackageEvent_Marshal(t *testing.T) { 7488 testJSONMarshal(t, &PackageEvent{}, "{}") 7489 7490 u := &PackageEvent{ 7491 Action: String("a"), 7492 Package: &Package{ 7493 ID: Int64(1), 7494 Name: String("n"), 7495 PackageType: String("pt"), 7496 HTMLURL: String("hurl"), 7497 CreatedAt: &Timestamp{referenceTime}, 7498 UpdatedAt: &Timestamp{referenceTime}, 7499 Owner: &User{ 7500 Login: String("l"), 7501 ID: Int64(1), 7502 NodeID: String("n"), 7503 URL: String("u"), 7504 ReposURL: String("r"), 7505 EventsURL: String("e"), 7506 AvatarURL: String("a"), 7507 }, 7508 PackageVersion: &PackageVersion{ID: Int64(1)}, 7509 Registry: &PackageRegistry{Name: String("n")}, 7510 }, 7511 Repo: &Repository{ 7512 ID: Int64(1), 7513 URL: String("s"), 7514 Name: String("n"), 7515 }, 7516 Org: &Organization{ 7517 BillingEmail: String("be"), 7518 Blog: String("b"), 7519 Company: String("c"), 7520 Email: String("e"), 7521 TwitterUsername: String("tu"), 7522 Location: String("loc"), 7523 Name: String("n"), 7524 Description: String("d"), 7525 IsVerified: Bool(true), 7526 HasOrganizationProjects: Bool(true), 7527 HasRepositoryProjects: Bool(true), 7528 DefaultRepoPermission: String("drp"), 7529 MembersCanCreateRepos: Bool(true), 7530 MembersCanCreateInternalRepos: Bool(true), 7531 MembersCanCreatePrivateRepos: Bool(true), 7532 MembersCanCreatePublicRepos: Bool(false), 7533 MembersAllowedRepositoryCreationType: String("marct"), 7534 MembersCanCreatePages: Bool(true), 7535 MembersCanCreatePublicPages: Bool(false), 7536 MembersCanCreatePrivatePages: Bool(true), 7537 }, 7538 Sender: &User{ 7539 Login: String("l"), 7540 ID: Int64(1), 7541 NodeID: String("n"), 7542 URL: String("u"), 7543 ReposURL: String("r"), 7544 EventsURL: String("e"), 7545 AvatarURL: String("a"), 7546 }, 7547 } 7548 7549 want := `{ 7550 "action": "a", 7551 "package": { 7552 "id": 1, 7553 "name": "n", 7554 "package_type": "pt", 7555 "html_url": "hurl", 7556 "created_at": ` + referenceTimeStr + `, 7557 "updated_at": ` + referenceTimeStr + `, 7558 "owner": { 7559 "login": "l", 7560 "id": 1, 7561 "node_id": "n", 7562 "avatar_url": "a", 7563 "url": "u", 7564 "events_url": "e", 7565 "repos_url": "r" 7566 }, 7567 "package_version": { 7568 "id": 1 7569 }, 7570 "registry": { 7571 "name": "n" 7572 } 7573 }, 7574 "repository": { 7575 "id": 1, 7576 "name": "n", 7577 "url": "s" 7578 }, 7579 "organization": { 7580 "name": "n", 7581 "company": "c", 7582 "blog": "b", 7583 "location": "loc", 7584 "email": "e", 7585 "twitter_username": "tu", 7586 "description": "d", 7587 "billing_email": "be", 7588 "is_verified": true, 7589 "has_organization_projects": true, 7590 "has_repository_projects": true, 7591 "default_repository_permission": "drp", 7592 "members_can_create_repositories": true, 7593 "members_can_create_public_repositories": false, 7594 "members_can_create_private_repositories": true, 7595 "members_can_create_internal_repositories": true, 7596 "members_allowed_repository_creation_type": "marct", 7597 "members_can_create_pages": true, 7598 "members_can_create_public_pages": false, 7599 "members_can_create_private_pages": true 7600 }, 7601 "sender": { 7602 "login": "l", 7603 "id": 1, 7604 "node_id": "n", 7605 "avatar_url": "a", 7606 "url": "u", 7607 "events_url": "e", 7608 "repos_url": "r" 7609 } 7610 }` 7611 7612 testJSONMarshal(t, u, want) 7613 } 7614 7615 func TestPersonalAccessTokenRequestEvent_Marshal(t *testing.T) { 7616 testJSONMarshal(t, &PersonalAccessTokenRequestEvent{}, "{}") 7617 7618 event := &PersonalAccessTokenRequestEvent{ 7619 Action: String("a"), 7620 PersonalAccessTokenRequest: &PersonalAccessTokenRequest{ 7621 ID: Int64(1), 7622 Owner: &User{Login: String("l")}, 7623 PermissionsAdded: &PersonalAccessTokenPermissions{ 7624 Org: map[string]string{"organization_events": "read"}, 7625 Repo: map[string]string{"security_events": "write"}, 7626 }, 7627 CreatedAt: &Timestamp{referenceTime}, 7628 TokenExpired: Bool(false), 7629 TokenExpiresAt: &Timestamp{referenceTime}, 7630 TokenLastUsedAt: &Timestamp{referenceTime}, 7631 RepositoryCount: Int64(1), 7632 RepositorySelection: String("rs"), 7633 Repositories: []*Repository{ 7634 { 7635 Name: String("n"), 7636 }, 7637 }, 7638 }, 7639 Org: &Organization{Name: String("n")}, 7640 Sender: &User{ 7641 Login: String("l"), 7642 }, 7643 Installation: &Installation{ 7644 ID: Int64(1), 7645 }, 7646 } 7647 7648 want := `{ 7649 "action": "a", 7650 "personal_access_token_request": { 7651 "id": 1, 7652 "owner": { 7653 "login": "l" 7654 }, 7655 "permissions_added": { 7656 "organization": { 7657 "organization_events": "read" 7658 }, 7659 "repository": { 7660 "security_events": "write" 7661 } 7662 }, 7663 "created_at": ` + referenceTimeStr + `, 7664 "token_expired": false, 7665 "token_expires_at": ` + referenceTimeStr + `, 7666 "token_last_used_at": ` + referenceTimeStr + `, 7667 "repository_count": 1, 7668 "repository_selection": "rs", 7669 "repositories": [ 7670 { 7671 "name": "n" 7672 } 7673 ] 7674 }, 7675 "organization": { 7676 "name": "n" 7677 }, 7678 "sender": { 7679 "login": "l" 7680 }, 7681 "installation": { 7682 "id": 1 7683 } 7684 }` 7685 7686 testJSONMarshal(t, event, want) 7687 } 7688 7689 func TestPingEvent_Marshal(t *testing.T) { 7690 testJSONMarshal(t, &PingEvent{}, "{}") 7691 7692 l := make(map[string]interface{}) 7693 l["key"] = "value" 7694 hookConfig := new(HookConfig) 7695 7696 u := &PingEvent{ 7697 Zen: String("z"), 7698 HookID: Int64(1), 7699 Hook: &Hook{ 7700 CreatedAt: &Timestamp{referenceTime}, 7701 UpdatedAt: &Timestamp{referenceTime}, 7702 URL: String("url"), 7703 ID: Int64(1), 7704 Type: String("t"), 7705 Name: String("n"), 7706 TestURL: String("tu"), 7707 PingURL: String("pu"), 7708 LastResponse: l, 7709 Config: hookConfig, 7710 Events: []string{"a"}, 7711 Active: Bool(true), 7712 }, 7713 Installation: &Installation{ 7714 ID: Int64(1), 7715 NodeID: String("nid"), 7716 AppID: Int64(1), 7717 AppSlug: String("as"), 7718 TargetID: Int64(1), 7719 Account: &User{ 7720 Login: String("l"), 7721 ID: Int64(1), 7722 URL: String("u"), 7723 AvatarURL: String("a"), 7724 GravatarID: String("g"), 7725 Name: String("n"), 7726 Company: String("c"), 7727 Blog: String("b"), 7728 Location: String("l"), 7729 Email: String("e"), 7730 Hireable: Bool(true), 7731 Bio: String("b"), 7732 TwitterUsername: String("t"), 7733 PublicRepos: Int(1), 7734 Followers: Int(1), 7735 Following: Int(1), 7736 CreatedAt: &Timestamp{referenceTime}, 7737 SuspendedAt: &Timestamp{referenceTime}, 7738 }, 7739 AccessTokensURL: String("atu"), 7740 RepositoriesURL: String("ru"), 7741 HTMLURL: String("hu"), 7742 TargetType: String("tt"), 7743 SingleFileName: String("sfn"), 7744 RepositorySelection: String("rs"), 7745 Events: []string{"e"}, 7746 SingleFilePaths: []string{"s"}, 7747 Permissions: &InstallationPermissions{ 7748 Actions: String("a"), 7749 Administration: String("ad"), 7750 Checks: String("c"), 7751 Contents: String("co"), 7752 ContentReferences: String("cr"), 7753 Deployments: String("d"), 7754 Environments: String("e"), 7755 Issues: String("i"), 7756 Metadata: String("md"), 7757 Members: String("m"), 7758 OrganizationAdministration: String("oa"), 7759 OrganizationHooks: String("oh"), 7760 OrganizationPlan: String("op"), 7761 OrganizationPreReceiveHooks: String("opr"), 7762 OrganizationProjects: String("op"), 7763 OrganizationSecrets: String("os"), 7764 OrganizationSelfHostedRunners: String("osh"), 7765 OrganizationUserBlocking: String("oub"), 7766 Packages: String("pkg"), 7767 Pages: String("pg"), 7768 PullRequests: String("pr"), 7769 RepositoryHooks: String("rh"), 7770 RepositoryProjects: String("rp"), 7771 RepositoryPreReceiveHooks: String("rprh"), 7772 Secrets: String("s"), 7773 SecretScanningAlerts: String("ssa"), 7774 SecurityEvents: String("se"), 7775 SingleFile: String("sf"), 7776 Statuses: String("s"), 7777 TeamDiscussions: String("td"), 7778 VulnerabilityAlerts: String("va"), 7779 Workflows: String("w"), 7780 }, 7781 CreatedAt: &Timestamp{referenceTime}, 7782 UpdatedAt: &Timestamp{referenceTime}, 7783 HasMultipleSingleFiles: Bool(false), 7784 SuspendedBy: &User{ 7785 Login: String("l"), 7786 ID: Int64(1), 7787 URL: String("u"), 7788 AvatarURL: String("a"), 7789 GravatarID: String("g"), 7790 Name: String("n"), 7791 Company: String("c"), 7792 Blog: String("b"), 7793 Location: String("l"), 7794 Email: String("e"), 7795 Hireable: Bool(true), 7796 Bio: String("b"), 7797 TwitterUsername: String("t"), 7798 PublicRepos: Int(1), 7799 Followers: Int(1), 7800 Following: Int(1), 7801 CreatedAt: &Timestamp{referenceTime}, 7802 SuspendedAt: &Timestamp{referenceTime}, 7803 }, 7804 SuspendedAt: &Timestamp{referenceTime}, 7805 }, 7806 } 7807 7808 want := `{ 7809 "zen": "z", 7810 "hook_id": 1, 7811 "hook": { 7812 "created_at": ` + referenceTimeStr + `, 7813 "updated_at": ` + referenceTimeStr + `, 7814 "url": "url", 7815 "id": 1, 7816 "type": "t", 7817 "name": "n", 7818 "test_url": "tu", 7819 "ping_url": "pu", 7820 "last_response": { 7821 "key": "value" 7822 }, 7823 "config": { 7824 "key": "value" 7825 }, 7826 "events": [ 7827 "a" 7828 ], 7829 "active": true 7830 }, 7831 "installation": { 7832 "id": 1, 7833 "node_id": "nid", 7834 "app_id": 1, 7835 "app_slug": "as", 7836 "target_id": 1, 7837 "account": { 7838 "login": "l", 7839 "id": 1, 7840 "avatar_url": "a", 7841 "gravatar_id": "g", 7842 "name": "n", 7843 "company": "c", 7844 "blog": "b", 7845 "location": "l", 7846 "email": "e", 7847 "hireable": true, 7848 "bio": "b", 7849 "twitter_username": "t", 7850 "public_repos": 1, 7851 "followers": 1, 7852 "following": 1, 7853 "created_at": ` + referenceTimeStr + `, 7854 "suspended_at": ` + referenceTimeStr + `, 7855 "url": "u" 7856 }, 7857 "access_tokens_url": "atu", 7858 "repositories_url": "ru", 7859 "html_url": "hu", 7860 "target_type": "tt", 7861 "single_file_name": "sfn", 7862 "repository_selection": "rs", 7863 "events": [ 7864 "e" 7865 ], 7866 "single_file_paths": [ 7867 "s" 7868 ], 7869 "permissions": { 7870 "actions": "a", 7871 "administration": "ad", 7872 "checks": "c", 7873 "contents": "co", 7874 "content_references": "cr", 7875 "deployments": "d", 7876 "environments": "e", 7877 "issues": "i", 7878 "metadata": "md", 7879 "members": "m", 7880 "organization_administration": "oa", 7881 "organization_hooks": "oh", 7882 "organization_plan": "op", 7883 "organization_pre_receive_hooks": "opr", 7884 "organization_projects": "op", 7885 "organization_secrets": "os", 7886 "organization_self_hosted_runners": "osh", 7887 "organization_user_blocking": "oub", 7888 "packages": "pkg", 7889 "pages": "pg", 7890 "pull_requests": "pr", 7891 "repository_hooks": "rh", 7892 "repository_projects": "rp", 7893 "repository_pre_receive_hooks": "rprh", 7894 "secrets": "s", 7895 "secret_scanning_alerts": "ssa", 7896 "security_events": "se", 7897 "single_file": "sf", 7898 "statuses": "s", 7899 "team_discussions": "td", 7900 "vulnerability_alerts": "va", 7901 "workflows": "w" 7902 }, 7903 "created_at": ` + referenceTimeStr + `, 7904 "updated_at": ` + referenceTimeStr + `, 7905 "has_multiple_single_files": false, 7906 "suspended_by": { 7907 "login": "l", 7908 "id": 1, 7909 "avatar_url": "a", 7910 "gravatar_id": "g", 7911 "name": "n", 7912 "company": "c", 7913 "blog": "b", 7914 "location": "l", 7915 "email": "e", 7916 "hireable": true, 7917 "bio": "b", 7918 "twitter_username": "t", 7919 "public_repos": 1, 7920 "followers": 1, 7921 "following": 1, 7922 "created_at": ` + referenceTimeStr + `, 7923 "suspended_at": ` + referenceTimeStr + `, 7924 "url": "u" 7925 }, 7926 "suspended_at": ` + referenceTimeStr + ` 7927 } 7928 }` 7929 7930 testJSONMarshal(t, u, want) 7931 } 7932 7933 func TestRepositoryDispatchEvent_Marshal(t *testing.T) { 7934 testJSONMarshal(t, &RepositoryDispatchEvent{}, "{}") 7935 7936 l := make(map[string]interface{}) 7937 l["key"] = "value" 7938 7939 jsonMsg, _ := json.Marshal(&l) 7940 7941 u := &RepositoryDispatchEvent{ 7942 Action: String("a"), 7943 Branch: String("b"), 7944 ClientPayload: jsonMsg, 7945 Repo: &Repository{ 7946 7947 ID: Int64(1), 7948 URL: String("s"), 7949 Name: String("n"), 7950 }, 7951 Org: &Organization{ 7952 BillingEmail: String("be"), 7953 Blog: String("b"), 7954 Company: String("c"), 7955 Email: String("e"), 7956 TwitterUsername: String("tu"), 7957 Location: String("loc"), 7958 Name: String("n"), 7959 Description: String("d"), 7960 IsVerified: Bool(true), 7961 HasOrganizationProjects: Bool(true), 7962 HasRepositoryProjects: Bool(true), 7963 DefaultRepoPermission: String("drp"), 7964 MembersCanCreateRepos: Bool(true), 7965 MembersCanCreateInternalRepos: Bool(true), 7966 MembersCanCreatePrivateRepos: Bool(true), 7967 MembersCanCreatePublicRepos: Bool(false), 7968 MembersAllowedRepositoryCreationType: String("marct"), 7969 MembersCanCreatePages: Bool(true), 7970 MembersCanCreatePublicPages: Bool(false), 7971 MembersCanCreatePrivatePages: Bool(true), 7972 }, 7973 Sender: &User{ 7974 Login: String("l"), 7975 ID: Int64(1), 7976 NodeID: String("n"), 7977 URL: String("u"), 7978 ReposURL: String("r"), 7979 EventsURL: String("e"), 7980 AvatarURL: String("a"), 7981 }, 7982 Installation: &Installation{ 7983 ID: Int64(1), 7984 NodeID: String("nid"), 7985 AppID: Int64(1), 7986 AppSlug: String("as"), 7987 TargetID: Int64(1), 7988 Account: &User{ 7989 Login: String("l"), 7990 ID: Int64(1), 7991 URL: String("u"), 7992 AvatarURL: String("a"), 7993 GravatarID: String("g"), 7994 Name: String("n"), 7995 Company: String("c"), 7996 Blog: String("b"), 7997 Location: String("l"), 7998 Email: String("e"), 7999 Hireable: Bool(true), 8000 Bio: String("b"), 8001 TwitterUsername: String("t"), 8002 PublicRepos: Int(1), 8003 Followers: Int(1), 8004 Following: Int(1), 8005 CreatedAt: &Timestamp{referenceTime}, 8006 SuspendedAt: &Timestamp{referenceTime}, 8007 }, 8008 AccessTokensURL: String("atu"), 8009 RepositoriesURL: String("ru"), 8010 HTMLURL: String("hu"), 8011 TargetType: String("tt"), 8012 SingleFileName: String("sfn"), 8013 RepositorySelection: String("rs"), 8014 Events: []string{"e"}, 8015 SingleFilePaths: []string{"s"}, 8016 Permissions: &InstallationPermissions{ 8017 Actions: String("a"), 8018 Administration: String("ad"), 8019 Checks: String("c"), 8020 Contents: String("co"), 8021 ContentReferences: String("cr"), 8022 Deployments: String("d"), 8023 Environments: String("e"), 8024 Issues: String("i"), 8025 Metadata: String("md"), 8026 Members: String("m"), 8027 OrganizationAdministration: String("oa"), 8028 OrganizationHooks: String("oh"), 8029 OrganizationPlan: String("op"), 8030 OrganizationPreReceiveHooks: String("opr"), 8031 OrganizationProjects: String("op"), 8032 OrganizationSecrets: String("os"), 8033 OrganizationSelfHostedRunners: String("osh"), 8034 OrganizationUserBlocking: String("oub"), 8035 Packages: String("pkg"), 8036 Pages: String("pg"), 8037 PullRequests: String("pr"), 8038 RepositoryHooks: String("rh"), 8039 RepositoryProjects: String("rp"), 8040 RepositoryPreReceiveHooks: String("rprh"), 8041 Secrets: String("s"), 8042 SecretScanningAlerts: String("ssa"), 8043 SecurityEvents: String("se"), 8044 SingleFile: String("sf"), 8045 Statuses: String("s"), 8046 TeamDiscussions: String("td"), 8047 VulnerabilityAlerts: String("va"), 8048 Workflows: String("w"), 8049 }, 8050 CreatedAt: &Timestamp{referenceTime}, 8051 UpdatedAt: &Timestamp{referenceTime}, 8052 HasMultipleSingleFiles: Bool(false), 8053 SuspendedBy: &User{ 8054 Login: String("l"), 8055 ID: Int64(1), 8056 URL: String("u"), 8057 AvatarURL: String("a"), 8058 GravatarID: String("g"), 8059 Name: String("n"), 8060 Company: String("c"), 8061 Blog: String("b"), 8062 Location: String("l"), 8063 Email: String("e"), 8064 Hireable: Bool(true), 8065 Bio: String("b"), 8066 TwitterUsername: String("t"), 8067 PublicRepos: Int(1), 8068 Followers: Int(1), 8069 Following: Int(1), 8070 CreatedAt: &Timestamp{referenceTime}, 8071 SuspendedAt: &Timestamp{referenceTime}, 8072 }, 8073 SuspendedAt: &Timestamp{referenceTime}, 8074 }, 8075 } 8076 8077 want := `{ 8078 "action": "a", 8079 "branch": "b", 8080 "client_payload": { 8081 "key": "value" 8082 }, 8083 "repository": { 8084 "id": 1, 8085 "name": "n", 8086 "url": "s" 8087 }, 8088 "organization": { 8089 "name": "n", 8090 "company": "c", 8091 "blog": "b", 8092 "location": "loc", 8093 "email": "e", 8094 "twitter_username": "tu", 8095 "description": "d", 8096 "billing_email": "be", 8097 "is_verified": true, 8098 "has_organization_projects": true, 8099 "has_repository_projects": true, 8100 "default_repository_permission": "drp", 8101 "members_can_create_repositories": true, 8102 "members_can_create_public_repositories": false, 8103 "members_can_create_private_repositories": true, 8104 "members_can_create_internal_repositories": true, 8105 "members_allowed_repository_creation_type": "marct", 8106 "members_can_create_pages": true, 8107 "members_can_create_public_pages": false, 8108 "members_can_create_private_pages": true 8109 }, 8110 "sender": { 8111 "login": "l", 8112 "id": 1, 8113 "node_id": "n", 8114 "avatar_url": "a", 8115 "url": "u", 8116 "events_url": "e", 8117 "repos_url": "r" 8118 }, 8119 "installation": { 8120 "id": 1, 8121 "node_id": "nid", 8122 "app_id": 1, 8123 "app_slug": "as", 8124 "target_id": 1, 8125 "account": { 8126 "login": "l", 8127 "id": 1, 8128 "avatar_url": "a", 8129 "gravatar_id": "g", 8130 "name": "n", 8131 "company": "c", 8132 "blog": "b", 8133 "location": "l", 8134 "email": "e", 8135 "hireable": true, 8136 "bio": "b", 8137 "twitter_username": "t", 8138 "public_repos": 1, 8139 "followers": 1, 8140 "following": 1, 8141 "created_at": ` + referenceTimeStr + `, 8142 "suspended_at": ` + referenceTimeStr + `, 8143 "url": "u" 8144 }, 8145 "access_tokens_url": "atu", 8146 "repositories_url": "ru", 8147 "html_url": "hu", 8148 "target_type": "tt", 8149 "single_file_name": "sfn", 8150 "repository_selection": "rs", 8151 "events": [ 8152 "e" 8153 ], 8154 "single_file_paths": [ 8155 "s" 8156 ], 8157 "permissions": { 8158 "actions": "a", 8159 "administration": "ad", 8160 "checks": "c", 8161 "contents": "co", 8162 "content_references": "cr", 8163 "deployments": "d", 8164 "environments": "e", 8165 "issues": "i", 8166 "metadata": "md", 8167 "members": "m", 8168 "organization_administration": "oa", 8169 "organization_hooks": "oh", 8170 "organization_plan": "op", 8171 "organization_pre_receive_hooks": "opr", 8172 "organization_projects": "op", 8173 "organization_secrets": "os", 8174 "organization_self_hosted_runners": "osh", 8175 "organization_user_blocking": "oub", 8176 "packages": "pkg", 8177 "pages": "pg", 8178 "pull_requests": "pr", 8179 "repository_hooks": "rh", 8180 "repository_projects": "rp", 8181 "repository_pre_receive_hooks": "rprh", 8182 "secrets": "s", 8183 "secret_scanning_alerts": "ssa", 8184 "security_events": "se", 8185 "single_file": "sf", 8186 "statuses": "s", 8187 "team_discussions": "td", 8188 "vulnerability_alerts": "va", 8189 "workflows": "w" 8190 }, 8191 "created_at": ` + referenceTimeStr + `, 8192 "updated_at": ` + referenceTimeStr + `, 8193 "has_multiple_single_files": false, 8194 "suspended_by": { 8195 "login": "l", 8196 "id": 1, 8197 "avatar_url": "a", 8198 "gravatar_id": "g", 8199 "name": "n", 8200 "company": "c", 8201 "blog": "b", 8202 "location": "l", 8203 "email": "e", 8204 "hireable": true, 8205 "bio": "b", 8206 "twitter_username": "t", 8207 "public_repos": 1, 8208 "followers": 1, 8209 "following": 1, 8210 "created_at": ` + referenceTimeStr + `, 8211 "suspended_at": ` + referenceTimeStr + `, 8212 "url": "u" 8213 }, 8214 "suspended_at": ` + referenceTimeStr + ` 8215 } 8216 }` 8217 8218 testJSONMarshal(t, u, want) 8219 } 8220 8221 func TestRepositoryImportEvent_Marshal(t *testing.T) { 8222 testJSONMarshal(t, &RepositoryImportEvent{}, "{}") 8223 8224 u := &RepositoryImportEvent{ 8225 Status: String("success"), 8226 Repo: &Repository{ 8227 ID: Int64(1), 8228 URL: String("s"), 8229 Name: String("n"), 8230 }, 8231 Org: &Organization{ 8232 BillingEmail: String("be"), 8233 Blog: String("b"), 8234 Company: String("c"), 8235 Email: String("e"), 8236 TwitterUsername: String("tu"), 8237 Location: String("loc"), 8238 Name: String("n"), 8239 Description: String("d"), 8240 IsVerified: Bool(true), 8241 HasOrganizationProjects: Bool(true), 8242 HasRepositoryProjects: Bool(true), 8243 DefaultRepoPermission: String("drp"), 8244 MembersCanCreateRepos: Bool(true), 8245 MembersCanCreateInternalRepos: Bool(true), 8246 MembersCanCreatePrivateRepos: Bool(true), 8247 MembersCanCreatePublicRepos: Bool(false), 8248 MembersAllowedRepositoryCreationType: String("marct"), 8249 MembersCanCreatePages: Bool(true), 8250 MembersCanCreatePublicPages: Bool(false), 8251 MembersCanCreatePrivatePages: Bool(true), 8252 }, 8253 Sender: &User{ 8254 Login: String("l"), 8255 ID: Int64(1), 8256 NodeID: String("n"), 8257 URL: String("u"), 8258 ReposURL: String("r"), 8259 EventsURL: String("e"), 8260 AvatarURL: String("a"), 8261 }, 8262 } 8263 8264 want := `{ 8265 "status": "success", 8266 "repository": { 8267 "id": 1, 8268 "name": "n", 8269 "url": "s" 8270 }, 8271 "organization": { 8272 "name": "n", 8273 "company": "c", 8274 "blog": "b", 8275 "location": "loc", 8276 "email": "e", 8277 "twitter_username": "tu", 8278 "description": "d", 8279 "billing_email": "be", 8280 "is_verified": true, 8281 "has_organization_projects": true, 8282 "has_repository_projects": true, 8283 "default_repository_permission": "drp", 8284 "members_can_create_repositories": true, 8285 "members_can_create_public_repositories": false, 8286 "members_can_create_private_repositories": true, 8287 "members_can_create_internal_repositories": true, 8288 "members_allowed_repository_creation_type": "marct", 8289 "members_can_create_pages": true, 8290 "members_can_create_public_pages": false, 8291 "members_can_create_private_pages": true 8292 }, 8293 "sender": { 8294 "login": "l", 8295 "id": 1, 8296 "node_id": "n", 8297 "avatar_url": "a", 8298 "url": "u", 8299 "events_url": "e", 8300 "repos_url": "r" 8301 } 8302 }` 8303 8304 testJSONMarshal(t, u, want) 8305 } 8306 8307 func TestRepositoryEvent_Marshal(t *testing.T) { 8308 testJSONMarshal(t, &RepositoryEvent{}, "{}") 8309 8310 u := &RepositoryEvent{ 8311 Action: String("a"), 8312 Repo: &Repository{ 8313 ID: Int64(1), 8314 URL: String("s"), 8315 Name: String("n"), 8316 }, 8317 Org: &Organization{ 8318 BillingEmail: String("be"), 8319 Blog: String("b"), 8320 Company: String("c"), 8321 Email: String("e"), 8322 TwitterUsername: String("tu"), 8323 Location: String("loc"), 8324 Name: String("n"), 8325 Description: String("d"), 8326 IsVerified: Bool(true), 8327 HasOrganizationProjects: Bool(true), 8328 HasRepositoryProjects: Bool(true), 8329 DefaultRepoPermission: String("drp"), 8330 MembersCanCreateRepos: Bool(true), 8331 MembersCanCreateInternalRepos: Bool(true), 8332 MembersCanCreatePrivateRepos: Bool(true), 8333 MembersCanCreatePublicRepos: Bool(false), 8334 MembersAllowedRepositoryCreationType: String("marct"), 8335 MembersCanCreatePages: Bool(true), 8336 MembersCanCreatePublicPages: Bool(false), 8337 MembersCanCreatePrivatePages: Bool(true), 8338 }, 8339 Sender: &User{ 8340 Login: String("l"), 8341 ID: Int64(1), 8342 NodeID: String("n"), 8343 URL: String("u"), 8344 ReposURL: String("r"), 8345 EventsURL: String("e"), 8346 AvatarURL: String("a"), 8347 }, 8348 Installation: &Installation{ 8349 ID: Int64(1), 8350 NodeID: String("nid"), 8351 AppID: Int64(1), 8352 AppSlug: String("as"), 8353 TargetID: Int64(1), 8354 Account: &User{ 8355 Login: String("l"), 8356 ID: Int64(1), 8357 URL: String("u"), 8358 AvatarURL: String("a"), 8359 GravatarID: String("g"), 8360 Name: String("n"), 8361 Company: String("c"), 8362 Blog: String("b"), 8363 Location: String("l"), 8364 Email: String("e"), 8365 Hireable: Bool(true), 8366 Bio: String("b"), 8367 TwitterUsername: String("t"), 8368 PublicRepos: Int(1), 8369 Followers: Int(1), 8370 Following: Int(1), 8371 CreatedAt: &Timestamp{referenceTime}, 8372 SuspendedAt: &Timestamp{referenceTime}, 8373 }, 8374 AccessTokensURL: String("atu"), 8375 RepositoriesURL: String("ru"), 8376 HTMLURL: String("hu"), 8377 TargetType: String("tt"), 8378 SingleFileName: String("sfn"), 8379 RepositorySelection: String("rs"), 8380 Events: []string{"e"}, 8381 SingleFilePaths: []string{"s"}, 8382 Permissions: &InstallationPermissions{ 8383 Actions: String("a"), 8384 Administration: String("ad"), 8385 Checks: String("c"), 8386 Contents: String("co"), 8387 ContentReferences: String("cr"), 8388 Deployments: String("d"), 8389 Environments: String("e"), 8390 Issues: String("i"), 8391 Metadata: String("md"), 8392 Members: String("m"), 8393 OrganizationAdministration: String("oa"), 8394 OrganizationHooks: String("oh"), 8395 OrganizationPlan: String("op"), 8396 OrganizationPreReceiveHooks: String("opr"), 8397 OrganizationProjects: String("op"), 8398 OrganizationSecrets: String("os"), 8399 OrganizationSelfHostedRunners: String("osh"), 8400 OrganizationUserBlocking: String("oub"), 8401 Packages: String("pkg"), 8402 Pages: String("pg"), 8403 PullRequests: String("pr"), 8404 RepositoryHooks: String("rh"), 8405 RepositoryProjects: String("rp"), 8406 RepositoryPreReceiveHooks: String("rprh"), 8407 Secrets: String("s"), 8408 SecretScanningAlerts: String("ssa"), 8409 SecurityEvents: String("se"), 8410 SingleFile: String("sf"), 8411 Statuses: String("s"), 8412 TeamDiscussions: String("td"), 8413 VulnerabilityAlerts: String("va"), 8414 Workflows: String("w"), 8415 }, 8416 CreatedAt: &Timestamp{referenceTime}, 8417 UpdatedAt: &Timestamp{referenceTime}, 8418 HasMultipleSingleFiles: Bool(false), 8419 SuspendedBy: &User{ 8420 Login: String("l"), 8421 ID: Int64(1), 8422 URL: String("u"), 8423 AvatarURL: String("a"), 8424 GravatarID: String("g"), 8425 Name: String("n"), 8426 Company: String("c"), 8427 Blog: String("b"), 8428 Location: String("l"), 8429 Email: String("e"), 8430 Hireable: Bool(true), 8431 Bio: String("b"), 8432 TwitterUsername: String("t"), 8433 PublicRepos: Int(1), 8434 Followers: Int(1), 8435 Following: Int(1), 8436 CreatedAt: &Timestamp{referenceTime}, 8437 SuspendedAt: &Timestamp{referenceTime}, 8438 }, 8439 SuspendedAt: &Timestamp{referenceTime}, 8440 }, 8441 } 8442 8443 want := `{ 8444 "action": "a", 8445 "repository": { 8446 "id": 1, 8447 "name": "n", 8448 "url": "s" 8449 }, 8450 "organization": { 8451 "name": "n", 8452 "company": "c", 8453 "blog": "b", 8454 "location": "loc", 8455 "email": "e", 8456 "twitter_username": "tu", 8457 "description": "d", 8458 "billing_email": "be", 8459 "is_verified": true, 8460 "has_organization_projects": true, 8461 "has_repository_projects": true, 8462 "default_repository_permission": "drp", 8463 "members_can_create_repositories": true, 8464 "members_can_create_public_repositories": false, 8465 "members_can_create_private_repositories": true, 8466 "members_can_create_internal_repositories": true, 8467 "members_allowed_repository_creation_type": "marct", 8468 "members_can_create_pages": true, 8469 "members_can_create_public_pages": false, 8470 "members_can_create_private_pages": true 8471 }, 8472 "sender": { 8473 "login": "l", 8474 "id": 1, 8475 "node_id": "n", 8476 "avatar_url": "a", 8477 "url": "u", 8478 "events_url": "e", 8479 "repos_url": "r" 8480 }, 8481 "installation": { 8482 "id": 1, 8483 "node_id": "nid", 8484 "app_id": 1, 8485 "app_slug": "as", 8486 "target_id": 1, 8487 "account": { 8488 "login": "l", 8489 "id": 1, 8490 "avatar_url": "a", 8491 "gravatar_id": "g", 8492 "name": "n", 8493 "company": "c", 8494 "blog": "b", 8495 "location": "l", 8496 "email": "e", 8497 "hireable": true, 8498 "bio": "b", 8499 "twitter_username": "t", 8500 "public_repos": 1, 8501 "followers": 1, 8502 "following": 1, 8503 "created_at": ` + referenceTimeStr + `, 8504 "suspended_at": ` + referenceTimeStr + `, 8505 "url": "u" 8506 }, 8507 "access_tokens_url": "atu", 8508 "repositories_url": "ru", 8509 "html_url": "hu", 8510 "target_type": "tt", 8511 "single_file_name": "sfn", 8512 "repository_selection": "rs", 8513 "events": [ 8514 "e" 8515 ], 8516 "single_file_paths": [ 8517 "s" 8518 ], 8519 "permissions": { 8520 "actions": "a", 8521 "administration": "ad", 8522 "checks": "c", 8523 "contents": "co", 8524 "content_references": "cr", 8525 "deployments": "d", 8526 "environments": "e", 8527 "issues": "i", 8528 "metadata": "md", 8529 "members": "m", 8530 "organization_administration": "oa", 8531 "organization_hooks": "oh", 8532 "organization_plan": "op", 8533 "organization_pre_receive_hooks": "opr", 8534 "organization_projects": "op", 8535 "organization_secrets": "os", 8536 "organization_self_hosted_runners": "osh", 8537 "organization_user_blocking": "oub", 8538 "packages": "pkg", 8539 "pages": "pg", 8540 "pull_requests": "pr", 8541 "repository_hooks": "rh", 8542 "repository_projects": "rp", 8543 "repository_pre_receive_hooks": "rprh", 8544 "secrets": "s", 8545 "secret_scanning_alerts": "ssa", 8546 "security_events": "se", 8547 "single_file": "sf", 8548 "statuses": "s", 8549 "team_discussions": "td", 8550 "vulnerability_alerts": "va", 8551 "workflows": "w" 8552 }, 8553 "created_at": ` + referenceTimeStr + `, 8554 "updated_at": ` + referenceTimeStr + `, 8555 "has_multiple_single_files": false, 8556 "suspended_by": { 8557 "login": "l", 8558 "id": 1, 8559 "avatar_url": "a", 8560 "gravatar_id": "g", 8561 "name": "n", 8562 "company": "c", 8563 "blog": "b", 8564 "location": "l", 8565 "email": "e", 8566 "hireable": true, 8567 "bio": "b", 8568 "twitter_username": "t", 8569 "public_repos": 1, 8570 "followers": 1, 8571 "following": 1, 8572 "created_at": ` + referenceTimeStr + `, 8573 "suspended_at": ` + referenceTimeStr + `, 8574 "url": "u" 8575 }, 8576 "suspended_at": ` + referenceTimeStr + ` 8577 } 8578 }` 8579 8580 testJSONMarshal(t, u, want) 8581 } 8582 8583 func TestReleaseEvent_Marshal(t *testing.T) { 8584 testJSONMarshal(t, &ReleaseEvent{}, "{}") 8585 8586 u := &ReleaseEvent{ 8587 Action: String("a"), 8588 Release: &RepositoryRelease{ 8589 Name: String("n"), 8590 DiscussionCategoryName: String("dcn"), 8591 ID: Int64(2), 8592 CreatedAt: &Timestamp{referenceTime}, 8593 PublishedAt: &Timestamp{referenceTime}, 8594 URL: String("url"), 8595 HTMLURL: String("htmlurl"), 8596 AssetsURL: String("assetsurl"), 8597 Assets: []*ReleaseAsset{{ID: Int64(1)}}, 8598 UploadURL: String("uploadurl"), 8599 ZipballURL: String("zipballurl"), 8600 TarballURL: String("tarballurl"), 8601 Author: &User{Name: String("octocat")}, 8602 NodeID: String("nid"), 8603 }, 8604 Repo: &Repository{ 8605 ID: Int64(1), 8606 URL: String("s"), 8607 Name: String("n"), 8608 }, 8609 Sender: &User{ 8610 Login: String("l"), 8611 ID: Int64(1), 8612 NodeID: String("n"), 8613 URL: String("u"), 8614 ReposURL: String("r"), 8615 EventsURL: String("e"), 8616 AvatarURL: String("a"), 8617 }, 8618 Installation: &Installation{ 8619 ID: Int64(1), 8620 NodeID: String("nid"), 8621 AppID: Int64(1), 8622 AppSlug: String("as"), 8623 TargetID: Int64(1), 8624 Account: &User{ 8625 Login: String("l"), 8626 ID: Int64(1), 8627 URL: String("u"), 8628 AvatarURL: String("a"), 8629 GravatarID: String("g"), 8630 Name: String("n"), 8631 Company: String("c"), 8632 Blog: String("b"), 8633 Location: String("l"), 8634 Email: String("e"), 8635 Hireable: Bool(true), 8636 Bio: String("b"), 8637 TwitterUsername: String("t"), 8638 PublicRepos: Int(1), 8639 Followers: Int(1), 8640 Following: Int(1), 8641 CreatedAt: &Timestamp{referenceTime}, 8642 SuspendedAt: &Timestamp{referenceTime}, 8643 }, 8644 AccessTokensURL: String("atu"), 8645 RepositoriesURL: String("ru"), 8646 HTMLURL: String("hu"), 8647 TargetType: String("tt"), 8648 SingleFileName: String("sfn"), 8649 RepositorySelection: String("rs"), 8650 Events: []string{"e"}, 8651 SingleFilePaths: []string{"s"}, 8652 Permissions: &InstallationPermissions{ 8653 Actions: String("a"), 8654 Administration: String("ad"), 8655 Checks: String("c"), 8656 Contents: String("co"), 8657 ContentReferences: String("cr"), 8658 Deployments: String("d"), 8659 Environments: String("e"), 8660 Issues: String("i"), 8661 Metadata: String("md"), 8662 Members: String("m"), 8663 OrganizationAdministration: String("oa"), 8664 OrganizationHooks: String("oh"), 8665 OrganizationPlan: String("op"), 8666 OrganizationPreReceiveHooks: String("opr"), 8667 OrganizationProjects: String("op"), 8668 OrganizationSecrets: String("os"), 8669 OrganizationSelfHostedRunners: String("osh"), 8670 OrganizationUserBlocking: String("oub"), 8671 Packages: String("pkg"), 8672 Pages: String("pg"), 8673 PullRequests: String("pr"), 8674 RepositoryHooks: String("rh"), 8675 RepositoryProjects: String("rp"), 8676 RepositoryPreReceiveHooks: String("rprh"), 8677 Secrets: String("s"), 8678 SecretScanningAlerts: String("ssa"), 8679 SecurityEvents: String("se"), 8680 SingleFile: String("sf"), 8681 Statuses: String("s"), 8682 TeamDiscussions: String("td"), 8683 VulnerabilityAlerts: String("va"), 8684 Workflows: String("w"), 8685 }, 8686 CreatedAt: &Timestamp{referenceTime}, 8687 UpdatedAt: &Timestamp{referenceTime}, 8688 HasMultipleSingleFiles: Bool(false), 8689 SuspendedBy: &User{ 8690 Login: String("l"), 8691 ID: Int64(1), 8692 URL: String("u"), 8693 AvatarURL: String("a"), 8694 GravatarID: String("g"), 8695 Name: String("n"), 8696 Company: String("c"), 8697 Blog: String("b"), 8698 Location: String("l"), 8699 Email: String("e"), 8700 Hireable: Bool(true), 8701 Bio: String("b"), 8702 TwitterUsername: String("t"), 8703 PublicRepos: Int(1), 8704 Followers: Int(1), 8705 Following: Int(1), 8706 CreatedAt: &Timestamp{referenceTime}, 8707 SuspendedAt: &Timestamp{referenceTime}, 8708 }, 8709 SuspendedAt: &Timestamp{referenceTime}, 8710 }, 8711 } 8712 8713 want := `{ 8714 "action": "a", 8715 "release": { 8716 "name": "n", 8717 "discussion_category_name": "dcn", 8718 "id": 2, 8719 "created_at": ` + referenceTimeStr + `, 8720 "published_at": ` + referenceTimeStr + `, 8721 "url": "url", 8722 "html_url": "htmlurl", 8723 "assets_url": "assetsurl", 8724 "assets": [ 8725 { 8726 "id": 1 8727 } 8728 ], 8729 "upload_url": "uploadurl", 8730 "zipball_url": "zipballurl", 8731 "tarball_url": "tarballurl", 8732 "author": { 8733 "name": "octocat" 8734 }, 8735 "node_id": "nid" 8736 }, 8737 "repository": { 8738 "id": 1, 8739 "name": "n", 8740 "url": "s" 8741 }, 8742 "sender": { 8743 "login": "l", 8744 "id": 1, 8745 "node_id": "n", 8746 "avatar_url": "a", 8747 "url": "u", 8748 "events_url": "e", 8749 "repos_url": "r" 8750 }, 8751 "installation": { 8752 "id": 1, 8753 "node_id": "nid", 8754 "app_id": 1, 8755 "app_slug": "as", 8756 "target_id": 1, 8757 "account": { 8758 "login": "l", 8759 "id": 1, 8760 "avatar_url": "a", 8761 "gravatar_id": "g", 8762 "name": "n", 8763 "company": "c", 8764 "blog": "b", 8765 "location": "l", 8766 "email": "e", 8767 "hireable": true, 8768 "bio": "b", 8769 "twitter_username": "t", 8770 "public_repos": 1, 8771 "followers": 1, 8772 "following": 1, 8773 "created_at": ` + referenceTimeStr + `, 8774 "suspended_at": ` + referenceTimeStr + `, 8775 "url": "u" 8776 }, 8777 "access_tokens_url": "atu", 8778 "repositories_url": "ru", 8779 "html_url": "hu", 8780 "target_type": "tt", 8781 "single_file_name": "sfn", 8782 "repository_selection": "rs", 8783 "events": [ 8784 "e" 8785 ], 8786 "single_file_paths": [ 8787 "s" 8788 ], 8789 "permissions": { 8790 "actions": "a", 8791 "administration": "ad", 8792 "checks": "c", 8793 "contents": "co", 8794 "content_references": "cr", 8795 "deployments": "d", 8796 "environments": "e", 8797 "issues": "i", 8798 "metadata": "md", 8799 "members": "m", 8800 "organization_administration": "oa", 8801 "organization_hooks": "oh", 8802 "organization_plan": "op", 8803 "organization_pre_receive_hooks": "opr", 8804 "organization_projects": "op", 8805 "organization_secrets": "os", 8806 "organization_self_hosted_runners": "osh", 8807 "organization_user_blocking": "oub", 8808 "packages": "pkg", 8809 "pages": "pg", 8810 "pull_requests": "pr", 8811 "repository_hooks": "rh", 8812 "repository_projects": "rp", 8813 "repository_pre_receive_hooks": "rprh", 8814 "secrets": "s", 8815 "secret_scanning_alerts": "ssa", 8816 "security_events": "se", 8817 "single_file": "sf", 8818 "statuses": "s", 8819 "team_discussions": "td", 8820 "vulnerability_alerts": "va", 8821 "workflows": "w" 8822 }, 8823 "created_at": ` + referenceTimeStr + `, 8824 "updated_at": ` + referenceTimeStr + `, 8825 "has_multiple_single_files": false, 8826 "suspended_by": { 8827 "login": "l", 8828 "id": 1, 8829 "avatar_url": "a", 8830 "gravatar_id": "g", 8831 "name": "n", 8832 "company": "c", 8833 "blog": "b", 8834 "location": "l", 8835 "email": "e", 8836 "hireable": true, 8837 "bio": "b", 8838 "twitter_username": "t", 8839 "public_repos": 1, 8840 "followers": 1, 8841 "following": 1, 8842 "created_at": ` + referenceTimeStr + `, 8843 "suspended_at": ` + referenceTimeStr + `, 8844 "url": "u" 8845 }, 8846 "suspended_at": ` + referenceTimeStr + ` 8847 } 8848 }` 8849 8850 testJSONMarshal(t, u, want) 8851 } 8852 8853 func TestContentReferenceEvent_Marshal(t *testing.T) { 8854 testJSONMarshal(t, &ContentReferenceEvent{}, "{}") 8855 8856 u := &ContentReferenceEvent{ 8857 Action: String("a"), 8858 ContentReference: &ContentReference{ 8859 ID: Int64(1), 8860 NodeID: String("nid"), 8861 Reference: String("ref"), 8862 }, 8863 Repo: &Repository{ 8864 ID: Int64(1), 8865 URL: String("s"), 8866 Name: String("n"), 8867 }, 8868 Sender: &User{ 8869 Login: String("l"), 8870 ID: Int64(1), 8871 NodeID: String("n"), 8872 URL: String("u"), 8873 ReposURL: String("r"), 8874 EventsURL: String("e"), 8875 AvatarURL: String("a"), 8876 }, 8877 Installation: &Installation{ 8878 ID: Int64(1), 8879 NodeID: String("nid"), 8880 AppID: Int64(1), 8881 AppSlug: String("as"), 8882 TargetID: Int64(1), 8883 Account: &User{ 8884 Login: String("l"), 8885 ID: Int64(1), 8886 URL: String("u"), 8887 AvatarURL: String("a"), 8888 GravatarID: String("g"), 8889 Name: String("n"), 8890 Company: String("c"), 8891 Blog: String("b"), 8892 Location: String("l"), 8893 Email: String("e"), 8894 Hireable: Bool(true), 8895 Bio: String("b"), 8896 TwitterUsername: String("t"), 8897 PublicRepos: Int(1), 8898 Followers: Int(1), 8899 Following: Int(1), 8900 CreatedAt: &Timestamp{referenceTime}, 8901 SuspendedAt: &Timestamp{referenceTime}, 8902 }, 8903 AccessTokensURL: String("atu"), 8904 RepositoriesURL: String("ru"), 8905 HTMLURL: String("hu"), 8906 TargetType: String("tt"), 8907 SingleFileName: String("sfn"), 8908 RepositorySelection: String("rs"), 8909 Events: []string{"e"}, 8910 SingleFilePaths: []string{"s"}, 8911 Permissions: &InstallationPermissions{ 8912 Actions: String("a"), 8913 Administration: String("ad"), 8914 Checks: String("c"), 8915 Contents: String("co"), 8916 ContentReferences: String("cr"), 8917 Deployments: String("d"), 8918 Environments: String("e"), 8919 Issues: String("i"), 8920 Metadata: String("md"), 8921 Members: String("m"), 8922 OrganizationAdministration: String("oa"), 8923 OrganizationHooks: String("oh"), 8924 OrganizationPlan: String("op"), 8925 OrganizationPreReceiveHooks: String("opr"), 8926 OrganizationProjects: String("op"), 8927 OrganizationSecrets: String("os"), 8928 OrganizationSelfHostedRunners: String("osh"), 8929 OrganizationUserBlocking: String("oub"), 8930 Packages: String("pkg"), 8931 Pages: String("pg"), 8932 PullRequests: String("pr"), 8933 RepositoryHooks: String("rh"), 8934 RepositoryProjects: String("rp"), 8935 RepositoryPreReceiveHooks: String("rprh"), 8936 Secrets: String("s"), 8937 SecretScanningAlerts: String("ssa"), 8938 SecurityEvents: String("se"), 8939 SingleFile: String("sf"), 8940 Statuses: String("s"), 8941 TeamDiscussions: String("td"), 8942 VulnerabilityAlerts: String("va"), 8943 Workflows: String("w"), 8944 }, 8945 CreatedAt: &Timestamp{referenceTime}, 8946 UpdatedAt: &Timestamp{referenceTime}, 8947 HasMultipleSingleFiles: Bool(false), 8948 SuspendedBy: &User{ 8949 Login: String("l"), 8950 ID: Int64(1), 8951 URL: String("u"), 8952 AvatarURL: String("a"), 8953 GravatarID: String("g"), 8954 Name: String("n"), 8955 Company: String("c"), 8956 Blog: String("b"), 8957 Location: String("l"), 8958 Email: String("e"), 8959 Hireable: Bool(true), 8960 Bio: String("b"), 8961 TwitterUsername: String("t"), 8962 PublicRepos: Int(1), 8963 Followers: Int(1), 8964 Following: Int(1), 8965 CreatedAt: &Timestamp{referenceTime}, 8966 SuspendedAt: &Timestamp{referenceTime}, 8967 }, 8968 SuspendedAt: &Timestamp{referenceTime}, 8969 }, 8970 } 8971 8972 want := `{ 8973 "action": "a", 8974 "content_reference": { 8975 "id": 1, 8976 "node_id": "nid", 8977 "reference": "ref" 8978 }, 8979 "repository": { 8980 "id": 1, 8981 "name": "n", 8982 "url": "s" 8983 }, 8984 "sender": { 8985 "login": "l", 8986 "id": 1, 8987 "node_id": "n", 8988 "avatar_url": "a", 8989 "url": "u", 8990 "events_url": "e", 8991 "repos_url": "r" 8992 }, 8993 "installation": { 8994 "id": 1, 8995 "node_id": "nid", 8996 "app_id": 1, 8997 "app_slug": "as", 8998 "target_id": 1, 8999 "account": { 9000 "login": "l", 9001 "id": 1, 9002 "avatar_url": "a", 9003 "gravatar_id": "g", 9004 "name": "n", 9005 "company": "c", 9006 "blog": "b", 9007 "location": "l", 9008 "email": "e", 9009 "hireable": true, 9010 "bio": "b", 9011 "twitter_username": "t", 9012 "public_repos": 1, 9013 "followers": 1, 9014 "following": 1, 9015 "created_at": ` + referenceTimeStr + `, 9016 "suspended_at": ` + referenceTimeStr + `, 9017 "url": "u" 9018 }, 9019 "access_tokens_url": "atu", 9020 "repositories_url": "ru", 9021 "html_url": "hu", 9022 "target_type": "tt", 9023 "single_file_name": "sfn", 9024 "repository_selection": "rs", 9025 "events": [ 9026 "e" 9027 ], 9028 "single_file_paths": [ 9029 "s" 9030 ], 9031 "permissions": { 9032 "actions": "a", 9033 "administration": "ad", 9034 "checks": "c", 9035 "contents": "co", 9036 "content_references": "cr", 9037 "deployments": "d", 9038 "environments": "e", 9039 "issues": "i", 9040 "metadata": "md", 9041 "members": "m", 9042 "organization_administration": "oa", 9043 "organization_hooks": "oh", 9044 "organization_plan": "op", 9045 "organization_pre_receive_hooks": "opr", 9046 "organization_projects": "op", 9047 "organization_secrets": "os", 9048 "organization_self_hosted_runners": "osh", 9049 "organization_user_blocking": "oub", 9050 "packages": "pkg", 9051 "pages": "pg", 9052 "pull_requests": "pr", 9053 "repository_hooks": "rh", 9054 "repository_projects": "rp", 9055 "repository_pre_receive_hooks": "rprh", 9056 "secrets": "s", 9057 "secret_scanning_alerts": "ssa", 9058 "security_events": "se", 9059 "single_file": "sf", 9060 "statuses": "s", 9061 "team_discussions": "td", 9062 "vulnerability_alerts": "va", 9063 "workflows": "w" 9064 }, 9065 "created_at": ` + referenceTimeStr + `, 9066 "updated_at": ` + referenceTimeStr + `, 9067 "has_multiple_single_files": false, 9068 "suspended_by": { 9069 "login": "l", 9070 "id": 1, 9071 "avatar_url": "a", 9072 "gravatar_id": "g", 9073 "name": "n", 9074 "company": "c", 9075 "blog": "b", 9076 "location": "l", 9077 "email": "e", 9078 "hireable": true, 9079 "bio": "b", 9080 "twitter_username": "t", 9081 "public_repos": 1, 9082 "followers": 1, 9083 "following": 1, 9084 "created_at": ` + referenceTimeStr + `, 9085 "suspended_at": ` + referenceTimeStr + `, 9086 "url": "u" 9087 }, 9088 "suspended_at": ` + referenceTimeStr + ` 9089 } 9090 }` 9091 9092 testJSONMarshal(t, u, want) 9093 } 9094 9095 func TestMemberEvent_Marshal(t *testing.T) { 9096 testJSONMarshal(t, &MemberEvent{}, "{}") 9097 9098 u := &MemberEvent{ 9099 Action: String("a"), 9100 Member: &User{ 9101 Login: String("l"), 9102 ID: Int64(1), 9103 NodeID: String("n"), 9104 URL: String("u"), 9105 ReposURL: String("r"), 9106 EventsURL: String("e"), 9107 AvatarURL: String("a"), 9108 }, 9109 Changes: &MemberChanges{ 9110 Permission: &MemberChangesPermission{ 9111 From: String("f"), 9112 To: String("t"), 9113 }, 9114 RoleName: &MemberChangesRoleName{ 9115 From: String("f"), 9116 To: String("t"), 9117 }, 9118 }, 9119 Repo: &Repository{ 9120 ID: Int64(1), 9121 URL: String("s"), 9122 Name: String("n"), 9123 }, 9124 Sender: &User{ 9125 Login: String("l"), 9126 ID: Int64(1), 9127 NodeID: String("n"), 9128 URL: String("u"), 9129 ReposURL: String("r"), 9130 EventsURL: String("e"), 9131 AvatarURL: String("a"), 9132 }, 9133 Installation: &Installation{ 9134 ID: Int64(1), 9135 NodeID: String("nid"), 9136 AppID: Int64(1), 9137 AppSlug: String("as"), 9138 TargetID: Int64(1), 9139 Account: &User{ 9140 Login: String("l"), 9141 ID: Int64(1), 9142 URL: String("u"), 9143 AvatarURL: String("a"), 9144 GravatarID: String("g"), 9145 Name: String("n"), 9146 Company: String("c"), 9147 Blog: String("b"), 9148 Location: String("l"), 9149 Email: String("e"), 9150 Hireable: Bool(true), 9151 Bio: String("b"), 9152 TwitterUsername: String("t"), 9153 PublicRepos: Int(1), 9154 Followers: Int(1), 9155 Following: Int(1), 9156 CreatedAt: &Timestamp{referenceTime}, 9157 SuspendedAt: &Timestamp{referenceTime}, 9158 }, 9159 AccessTokensURL: String("atu"), 9160 RepositoriesURL: String("ru"), 9161 HTMLURL: String("hu"), 9162 TargetType: String("tt"), 9163 SingleFileName: String("sfn"), 9164 RepositorySelection: String("rs"), 9165 Events: []string{"e"}, 9166 SingleFilePaths: []string{"s"}, 9167 Permissions: &InstallationPermissions{ 9168 Actions: String("a"), 9169 Administration: String("ad"), 9170 Checks: String("c"), 9171 Contents: String("co"), 9172 ContentReferences: String("cr"), 9173 Deployments: String("d"), 9174 Environments: String("e"), 9175 Issues: String("i"), 9176 Metadata: String("md"), 9177 Members: String("m"), 9178 OrganizationAdministration: String("oa"), 9179 OrganizationHooks: String("oh"), 9180 OrganizationPlan: String("op"), 9181 OrganizationPreReceiveHooks: String("opr"), 9182 OrganizationProjects: String("op"), 9183 OrganizationSecrets: String("os"), 9184 OrganizationSelfHostedRunners: String("osh"), 9185 OrganizationUserBlocking: String("oub"), 9186 Packages: String("pkg"), 9187 Pages: String("pg"), 9188 PullRequests: String("pr"), 9189 RepositoryHooks: String("rh"), 9190 RepositoryProjects: String("rp"), 9191 RepositoryPreReceiveHooks: String("rprh"), 9192 Secrets: String("s"), 9193 SecretScanningAlerts: String("ssa"), 9194 SecurityEvents: String("se"), 9195 SingleFile: String("sf"), 9196 Statuses: String("s"), 9197 TeamDiscussions: String("td"), 9198 VulnerabilityAlerts: String("va"), 9199 Workflows: String("w"), 9200 }, 9201 CreatedAt: &Timestamp{referenceTime}, 9202 UpdatedAt: &Timestamp{referenceTime}, 9203 HasMultipleSingleFiles: Bool(false), 9204 SuspendedBy: &User{ 9205 Login: String("l"), 9206 ID: Int64(1), 9207 URL: String("u"), 9208 AvatarURL: String("a"), 9209 GravatarID: String("g"), 9210 Name: String("n"), 9211 Company: String("c"), 9212 Blog: String("b"), 9213 Location: String("l"), 9214 Email: String("e"), 9215 Hireable: Bool(true), 9216 Bio: String("b"), 9217 TwitterUsername: String("t"), 9218 PublicRepos: Int(1), 9219 Followers: Int(1), 9220 Following: Int(1), 9221 CreatedAt: &Timestamp{referenceTime}, 9222 SuspendedAt: &Timestamp{referenceTime}, 9223 }, 9224 SuspendedAt: &Timestamp{referenceTime}, 9225 }, 9226 } 9227 9228 want := `{ 9229 "action": "a", 9230 "member": { 9231 "login": "l", 9232 "id": 1, 9233 "node_id": "n", 9234 "avatar_url": "a", 9235 "url": "u", 9236 "events_url": "e", 9237 "repos_url": "r" 9238 }, 9239 "changes": { 9240 "permission": { 9241 "from": "f", 9242 "to": "t" 9243 }, 9244 "role_name": { 9245 "from": "f", 9246 "to": "t" 9247 } 9248 }, 9249 "repository": { 9250 "id": 1, 9251 "name": "n", 9252 "url": "s" 9253 }, 9254 "sender": { 9255 "login": "l", 9256 "id": 1, 9257 "node_id": "n", 9258 "avatar_url": "a", 9259 "url": "u", 9260 "events_url": "e", 9261 "repos_url": "r" 9262 }, 9263 "installation": { 9264 "id": 1, 9265 "node_id": "nid", 9266 "app_id": 1, 9267 "app_slug": "as", 9268 "target_id": 1, 9269 "account": { 9270 "login": "l", 9271 "id": 1, 9272 "avatar_url": "a", 9273 "gravatar_id": "g", 9274 "name": "n", 9275 "company": "c", 9276 "blog": "b", 9277 "location": "l", 9278 "email": "e", 9279 "hireable": true, 9280 "bio": "b", 9281 "twitter_username": "t", 9282 "public_repos": 1, 9283 "followers": 1, 9284 "following": 1, 9285 "created_at": ` + referenceTimeStr + `, 9286 "suspended_at": ` + referenceTimeStr + `, 9287 "url": "u" 9288 }, 9289 "access_tokens_url": "atu", 9290 "repositories_url": "ru", 9291 "html_url": "hu", 9292 "target_type": "tt", 9293 "single_file_name": "sfn", 9294 "repository_selection": "rs", 9295 "events": [ 9296 "e" 9297 ], 9298 "single_file_paths": [ 9299 "s" 9300 ], 9301 "permissions": { 9302 "actions": "a", 9303 "administration": "ad", 9304 "checks": "c", 9305 "contents": "co", 9306 "content_references": "cr", 9307 "deployments": "d", 9308 "environments": "e", 9309 "issues": "i", 9310 "metadata": "md", 9311 "members": "m", 9312 "organization_administration": "oa", 9313 "organization_hooks": "oh", 9314 "organization_plan": "op", 9315 "organization_pre_receive_hooks": "opr", 9316 "organization_projects": "op", 9317 "organization_secrets": "os", 9318 "organization_self_hosted_runners": "osh", 9319 "organization_user_blocking": "oub", 9320 "packages": "pkg", 9321 "pages": "pg", 9322 "pull_requests": "pr", 9323 "repository_hooks": "rh", 9324 "repository_projects": "rp", 9325 "repository_pre_receive_hooks": "rprh", 9326 "secrets": "s", 9327 "secret_scanning_alerts": "ssa", 9328 "security_events": "se", 9329 "single_file": "sf", 9330 "statuses": "s", 9331 "team_discussions": "td", 9332 "vulnerability_alerts": "va", 9333 "workflows": "w" 9334 }, 9335 "created_at": ` + referenceTimeStr + `, 9336 "updated_at": ` + referenceTimeStr + `, 9337 "has_multiple_single_files": false, 9338 "suspended_by": { 9339 "login": "l", 9340 "id": 1, 9341 "avatar_url": "a", 9342 "gravatar_id": "g", 9343 "name": "n", 9344 "company": "c", 9345 "blog": "b", 9346 "location": "l", 9347 "email": "e", 9348 "hireable": true, 9349 "bio": "b", 9350 "twitter_username": "t", 9351 "public_repos": 1, 9352 "followers": 1, 9353 "following": 1, 9354 "created_at": ` + referenceTimeStr + `, 9355 "suspended_at": ` + referenceTimeStr + `, 9356 "url": "u" 9357 }, 9358 "suspended_at": ` + referenceTimeStr + ` 9359 } 9360 }` 9361 9362 testJSONMarshal(t, u, want) 9363 } 9364 9365 func TestMembershipEvent_Marshal(t *testing.T) { 9366 testJSONMarshal(t, &MembershipEvent{}, "{}") 9367 9368 u := &MembershipEvent{ 9369 Action: String("a"), 9370 Scope: String("s"), 9371 Member: &User{ 9372 Login: String("l"), 9373 ID: Int64(1), 9374 NodeID: String("n"), 9375 URL: String("u"), 9376 ReposURL: String("r"), 9377 EventsURL: String("e"), 9378 AvatarURL: String("a"), 9379 }, 9380 Team: &Team{ 9381 ID: Int64(1), 9382 NodeID: String("n"), 9383 Name: String("n"), 9384 Description: String("d"), 9385 URL: String("u"), 9386 Slug: String("s"), 9387 Permission: String("p"), 9388 Privacy: String("p"), 9389 MembersCount: Int(1), 9390 ReposCount: Int(1), 9391 MembersURL: String("m"), 9392 RepositoriesURL: String("r"), 9393 Organization: &Organization{ 9394 Login: String("l"), 9395 ID: Int64(1), 9396 NodeID: String("n"), 9397 AvatarURL: String("a"), 9398 HTMLURL: String("h"), 9399 Name: String("n"), 9400 Company: String("c"), 9401 Blog: String("b"), 9402 Location: String("l"), 9403 Email: String("e"), 9404 }, 9405 Parent: &Team{ 9406 ID: Int64(1), 9407 NodeID: String("n"), 9408 Name: String("n"), 9409 Description: String("d"), 9410 URL: String("u"), 9411 Slug: String("s"), 9412 Permission: String("p"), 9413 Privacy: String("p"), 9414 MembersCount: Int(1), 9415 ReposCount: Int(1), 9416 }, 9417 LDAPDN: String("l"), 9418 }, 9419 Org: &Organization{ 9420 BillingEmail: String("be"), 9421 Blog: String("b"), 9422 Company: String("c"), 9423 Email: String("e"), 9424 TwitterUsername: String("tu"), 9425 Location: String("loc"), 9426 Name: String("n"), 9427 Description: String("d"), 9428 IsVerified: Bool(true), 9429 HasOrganizationProjects: Bool(true), 9430 HasRepositoryProjects: Bool(true), 9431 DefaultRepoPermission: String("drp"), 9432 MembersCanCreateRepos: Bool(true), 9433 MembersCanCreateInternalRepos: Bool(true), 9434 MembersCanCreatePrivateRepos: Bool(true), 9435 MembersCanCreatePublicRepos: Bool(false), 9436 MembersAllowedRepositoryCreationType: String("marct"), 9437 MembersCanCreatePages: Bool(true), 9438 MembersCanCreatePublicPages: Bool(false), 9439 MembersCanCreatePrivatePages: Bool(true), 9440 }, 9441 Sender: &User{ 9442 Login: String("l"), 9443 ID: Int64(1), 9444 NodeID: String("n"), 9445 URL: String("u"), 9446 ReposURL: String("r"), 9447 EventsURL: String("e"), 9448 AvatarURL: String("a"), 9449 }, 9450 Installation: &Installation{ 9451 ID: Int64(1), 9452 NodeID: String("nid"), 9453 AppID: Int64(1), 9454 AppSlug: String("as"), 9455 TargetID: Int64(1), 9456 Account: &User{ 9457 Login: String("l"), 9458 ID: Int64(1), 9459 URL: String("u"), 9460 AvatarURL: String("a"), 9461 GravatarID: String("g"), 9462 Name: String("n"), 9463 Company: String("c"), 9464 Blog: String("b"), 9465 Location: String("l"), 9466 Email: String("e"), 9467 Hireable: Bool(true), 9468 Bio: String("b"), 9469 TwitterUsername: String("t"), 9470 PublicRepos: Int(1), 9471 Followers: Int(1), 9472 Following: Int(1), 9473 CreatedAt: &Timestamp{referenceTime}, 9474 SuspendedAt: &Timestamp{referenceTime}, 9475 }, 9476 AccessTokensURL: String("atu"), 9477 RepositoriesURL: String("ru"), 9478 HTMLURL: String("hu"), 9479 TargetType: String("tt"), 9480 SingleFileName: String("sfn"), 9481 RepositorySelection: String("rs"), 9482 Events: []string{"e"}, 9483 SingleFilePaths: []string{"s"}, 9484 Permissions: &InstallationPermissions{ 9485 Actions: String("a"), 9486 Administration: String("ad"), 9487 Checks: String("c"), 9488 Contents: String("co"), 9489 ContentReferences: String("cr"), 9490 Deployments: String("d"), 9491 Environments: String("e"), 9492 Issues: String("i"), 9493 Metadata: String("md"), 9494 Members: String("m"), 9495 OrganizationAdministration: String("oa"), 9496 OrganizationHooks: String("oh"), 9497 OrganizationPlan: String("op"), 9498 OrganizationPreReceiveHooks: String("opr"), 9499 OrganizationProjects: String("op"), 9500 OrganizationSecrets: String("os"), 9501 OrganizationSelfHostedRunners: String("osh"), 9502 OrganizationUserBlocking: String("oub"), 9503 Packages: String("pkg"), 9504 Pages: String("pg"), 9505 PullRequests: String("pr"), 9506 RepositoryHooks: String("rh"), 9507 RepositoryProjects: String("rp"), 9508 RepositoryPreReceiveHooks: String("rprh"), 9509 Secrets: String("s"), 9510 SecretScanningAlerts: String("ssa"), 9511 SecurityEvents: String("se"), 9512 SingleFile: String("sf"), 9513 Statuses: String("s"), 9514 TeamDiscussions: String("td"), 9515 VulnerabilityAlerts: String("va"), 9516 Workflows: String("w"), 9517 }, 9518 CreatedAt: &Timestamp{referenceTime}, 9519 UpdatedAt: &Timestamp{referenceTime}, 9520 HasMultipleSingleFiles: Bool(false), 9521 SuspendedBy: &User{ 9522 Login: String("l"), 9523 ID: Int64(1), 9524 URL: String("u"), 9525 AvatarURL: String("a"), 9526 GravatarID: String("g"), 9527 Name: String("n"), 9528 Company: String("c"), 9529 Blog: String("b"), 9530 Location: String("l"), 9531 Email: String("e"), 9532 Hireable: Bool(true), 9533 Bio: String("b"), 9534 TwitterUsername: String("t"), 9535 PublicRepos: Int(1), 9536 Followers: Int(1), 9537 Following: Int(1), 9538 CreatedAt: &Timestamp{referenceTime}, 9539 SuspendedAt: &Timestamp{referenceTime}, 9540 }, 9541 SuspendedAt: &Timestamp{referenceTime}, 9542 }, 9543 } 9544 9545 want := `{ 9546 "action": "a", 9547 "scope": "s", 9548 "member": { 9549 "login": "l", 9550 "id": 1, 9551 "node_id": "n", 9552 "avatar_url": "a", 9553 "url": "u", 9554 "events_url": "e", 9555 "repos_url": "r" 9556 }, 9557 "team": { 9558 "id": 1, 9559 "node_id": "n", 9560 "name": "n", 9561 "description": "d", 9562 "url": "u", 9563 "slug": "s", 9564 "permission": "p", 9565 "privacy": "p", 9566 "members_count": 1, 9567 "repos_count": 1, 9568 "organization": { 9569 "login": "l", 9570 "id": 1, 9571 "node_id": "n", 9572 "avatar_url": "a", 9573 "html_url": "h", 9574 "name": "n", 9575 "company": "c", 9576 "blog": "b", 9577 "location": "l", 9578 "email": "e" 9579 }, 9580 "members_url": "m", 9581 "repositories_url": "r", 9582 "parent": { 9583 "id": 1, 9584 "node_id": "n", 9585 "name": "n", 9586 "description": "d", 9587 "url": "u", 9588 "slug": "s", 9589 "permission": "p", 9590 "privacy": "p", 9591 "members_count": 1, 9592 "repos_count": 1 9593 }, 9594 "ldap_dn": "l" 9595 }, 9596 "organization": { 9597 "name": "n", 9598 "company": "c", 9599 "blog": "b", 9600 "location": "loc", 9601 "email": "e", 9602 "twitter_username": "tu", 9603 "description": "d", 9604 "billing_email": "be", 9605 "is_verified": true, 9606 "has_organization_projects": true, 9607 "has_repository_projects": true, 9608 "default_repository_permission": "drp", 9609 "members_can_create_repositories": true, 9610 "members_can_create_public_repositories": false, 9611 "members_can_create_private_repositories": true, 9612 "members_can_create_internal_repositories": true, 9613 "members_allowed_repository_creation_type": "marct", 9614 "members_can_create_pages": true, 9615 "members_can_create_public_pages": false, 9616 "members_can_create_private_pages": true 9617 }, 9618 "sender": { 9619 "login": "l", 9620 "id": 1, 9621 "node_id": "n", 9622 "avatar_url": "a", 9623 "url": "u", 9624 "events_url": "e", 9625 "repos_url": "r" 9626 }, 9627 "installation": { 9628 "id": 1, 9629 "node_id": "nid", 9630 "app_id": 1, 9631 "app_slug": "as", 9632 "target_id": 1, 9633 "account": { 9634 "login": "l", 9635 "id": 1, 9636 "avatar_url": "a", 9637 "gravatar_id": "g", 9638 "name": "n", 9639 "company": "c", 9640 "blog": "b", 9641 "location": "l", 9642 "email": "e", 9643 "hireable": true, 9644 "bio": "b", 9645 "twitter_username": "t", 9646 "public_repos": 1, 9647 "followers": 1, 9648 "following": 1, 9649 "created_at": ` + referenceTimeStr + `, 9650 "suspended_at": ` + referenceTimeStr + `, 9651 "url": "u" 9652 }, 9653 "access_tokens_url": "atu", 9654 "repositories_url": "ru", 9655 "html_url": "hu", 9656 "target_type": "tt", 9657 "single_file_name": "sfn", 9658 "repository_selection": "rs", 9659 "events": [ 9660 "e" 9661 ], 9662 "single_file_paths": [ 9663 "s" 9664 ], 9665 "permissions": { 9666 "actions": "a", 9667 "administration": "ad", 9668 "checks": "c", 9669 "contents": "co", 9670 "content_references": "cr", 9671 "deployments": "d", 9672 "environments": "e", 9673 "issues": "i", 9674 "metadata": "md", 9675 "members": "m", 9676 "organization_administration": "oa", 9677 "organization_hooks": "oh", 9678 "organization_plan": "op", 9679 "organization_pre_receive_hooks": "opr", 9680 "organization_projects": "op", 9681 "organization_secrets": "os", 9682 "organization_self_hosted_runners": "osh", 9683 "organization_user_blocking": "oub", 9684 "packages": "pkg", 9685 "pages": "pg", 9686 "pull_requests": "pr", 9687 "repository_hooks": "rh", 9688 "repository_projects": "rp", 9689 "repository_pre_receive_hooks": "rprh", 9690 "secrets": "s", 9691 "secret_scanning_alerts": "ssa", 9692 "security_events": "se", 9693 "single_file": "sf", 9694 "statuses": "s", 9695 "team_discussions": "td", 9696 "vulnerability_alerts": "va", 9697 "workflows": "w" 9698 }, 9699 "created_at": ` + referenceTimeStr + `, 9700 "updated_at": ` + referenceTimeStr + `, 9701 "has_multiple_single_files": false, 9702 "suspended_by": { 9703 "login": "l", 9704 "id": 1, 9705 "avatar_url": "a", 9706 "gravatar_id": "g", 9707 "name": "n", 9708 "company": "c", 9709 "blog": "b", 9710 "location": "l", 9711 "email": "e", 9712 "hireable": true, 9713 "bio": "b", 9714 "twitter_username": "t", 9715 "public_repos": 1, 9716 "followers": 1, 9717 "following": 1, 9718 "created_at": ` + referenceTimeStr + `, 9719 "suspended_at": ` + referenceTimeStr + `, 9720 "url": "u" 9721 }, 9722 "suspended_at": ` + referenceTimeStr + ` 9723 } 9724 }` 9725 9726 testJSONMarshal(t, u, want) 9727 } 9728 9729 func TestMergeGroupEvent_Marshal(t *testing.T) { 9730 testJSONMarshal(t, &MergeGroupEvent{}, "{}") 9731 9732 u := &MergeGroupEvent{ 9733 Action: String("a"), 9734 MergeGroup: &MergeGroup{ 9735 HeadSHA: String("hs"), 9736 HeadRef: String("hr"), 9737 BaseSHA: String("bs"), 9738 BaseRef: String("br"), 9739 HeadCommit: &Commit{NodeID: String("nid")}, 9740 }, 9741 Repo: &Repository{ 9742 ID: Int64(1), 9743 URL: String("s"), 9744 Name: String("n"), 9745 }, 9746 Org: &Organization{ 9747 BillingEmail: String("be"), 9748 Blog: String("b"), 9749 Company: String("c"), 9750 Email: String("e"), 9751 TwitterUsername: String("tu"), 9752 Location: String("loc"), 9753 Name: String("n"), 9754 Description: String("d"), 9755 IsVerified: Bool(true), 9756 HasOrganizationProjects: Bool(true), 9757 HasRepositoryProjects: Bool(true), 9758 DefaultRepoPermission: String("drp"), 9759 MembersCanCreateRepos: Bool(true), 9760 MembersCanCreateInternalRepos: Bool(true), 9761 MembersCanCreatePrivateRepos: Bool(true), 9762 MembersCanCreatePublicRepos: Bool(false), 9763 MembersAllowedRepositoryCreationType: String("marct"), 9764 MembersCanCreatePages: Bool(true), 9765 MembersCanCreatePublicPages: Bool(false), 9766 MembersCanCreatePrivatePages: Bool(true), 9767 }, 9768 Sender: &User{ 9769 Login: String("l"), 9770 ID: Int64(1), 9771 NodeID: String("n"), 9772 URL: String("u"), 9773 ReposURL: String("r"), 9774 EventsURL: String("e"), 9775 AvatarURL: String("a"), 9776 }, 9777 Installation: &Installation{ 9778 ID: Int64(1), 9779 NodeID: String("nid"), 9780 AppID: Int64(1), 9781 AppSlug: String("as"), 9782 TargetID: Int64(1), 9783 Account: &User{ 9784 Login: String("l"), 9785 ID: Int64(1), 9786 URL: String("u"), 9787 AvatarURL: String("a"), 9788 GravatarID: String("g"), 9789 Name: String("n"), 9790 Company: String("c"), 9791 Blog: String("b"), 9792 Location: String("l"), 9793 Email: String("e"), 9794 Hireable: Bool(true), 9795 Bio: String("b"), 9796 TwitterUsername: String("t"), 9797 PublicRepos: Int(1), 9798 Followers: Int(1), 9799 Following: Int(1), 9800 CreatedAt: &Timestamp{referenceTime}, 9801 SuspendedAt: &Timestamp{referenceTime}, 9802 }, 9803 AccessTokensURL: String("atu"), 9804 RepositoriesURL: String("ru"), 9805 HTMLURL: String("hu"), 9806 TargetType: String("tt"), 9807 SingleFileName: String("sfn"), 9808 RepositorySelection: String("rs"), 9809 Events: []string{"e"}, 9810 SingleFilePaths: []string{"s"}, 9811 Permissions: &InstallationPermissions{ 9812 Actions: String("a"), 9813 Administration: String("ad"), 9814 Checks: String("c"), 9815 Contents: String("co"), 9816 ContentReferences: String("cr"), 9817 Deployments: String("d"), 9818 Environments: String("e"), 9819 Issues: String("i"), 9820 Metadata: String("md"), 9821 Members: String("m"), 9822 OrganizationAdministration: String("oa"), 9823 OrganizationHooks: String("oh"), 9824 OrganizationPlan: String("op"), 9825 OrganizationPreReceiveHooks: String("opr"), 9826 OrganizationProjects: String("op"), 9827 OrganizationSecrets: String("os"), 9828 OrganizationSelfHostedRunners: String("osh"), 9829 OrganizationUserBlocking: String("oub"), 9830 Packages: String("pkg"), 9831 Pages: String("pg"), 9832 PullRequests: String("pr"), 9833 RepositoryHooks: String("rh"), 9834 RepositoryProjects: String("rp"), 9835 RepositoryPreReceiveHooks: String("rprh"), 9836 Secrets: String("s"), 9837 SecretScanningAlerts: String("ssa"), 9838 SecurityEvents: String("se"), 9839 SingleFile: String("sf"), 9840 Statuses: String("s"), 9841 TeamDiscussions: String("td"), 9842 VulnerabilityAlerts: String("va"), 9843 Workflows: String("w"), 9844 }, 9845 CreatedAt: &Timestamp{referenceTime}, 9846 UpdatedAt: &Timestamp{referenceTime}, 9847 HasMultipleSingleFiles: Bool(false), 9848 SuspendedBy: &User{ 9849 Login: String("l"), 9850 ID: Int64(1), 9851 URL: String("u"), 9852 AvatarURL: String("a"), 9853 GravatarID: String("g"), 9854 Name: String("n"), 9855 Company: String("c"), 9856 Blog: String("b"), 9857 Location: String("l"), 9858 Email: String("e"), 9859 Hireable: Bool(true), 9860 Bio: String("b"), 9861 TwitterUsername: String("t"), 9862 PublicRepos: Int(1), 9863 Followers: Int(1), 9864 Following: Int(1), 9865 CreatedAt: &Timestamp{referenceTime}, 9866 SuspendedAt: &Timestamp{referenceTime}, 9867 }, 9868 SuspendedAt: &Timestamp{referenceTime}, 9869 }, 9870 } 9871 9872 want := `{ 9873 "action": "a", 9874 "merge_group": { 9875 "head_sha": "hs", 9876 "head_ref": "hr", 9877 "base_sha": "bs", 9878 "base_ref": "br", 9879 "head_commit": { 9880 "node_id": "nid" 9881 } 9882 }, 9883 "repository": { 9884 "id": 1, 9885 "name": "n", 9886 "url": "s" 9887 }, 9888 "organization": { 9889 "name": "n", 9890 "company": "c", 9891 "blog": "b", 9892 "location": "loc", 9893 "email": "e", 9894 "twitter_username": "tu", 9895 "description": "d", 9896 "billing_email": "be", 9897 "is_verified": true, 9898 "has_organization_projects": true, 9899 "has_repository_projects": true, 9900 "default_repository_permission": "drp", 9901 "members_can_create_repositories": true, 9902 "members_can_create_public_repositories": false, 9903 "members_can_create_private_repositories": true, 9904 "members_can_create_internal_repositories": true, 9905 "members_allowed_repository_creation_type": "marct", 9906 "members_can_create_pages": true, 9907 "members_can_create_public_pages": false, 9908 "members_can_create_private_pages": true 9909 }, 9910 "sender": { 9911 "login": "l", 9912 "id": 1, 9913 "node_id": "n", 9914 "avatar_url": "a", 9915 "url": "u", 9916 "events_url": "e", 9917 "repos_url": "r" 9918 }, 9919 "installation": { 9920 "id": 1, 9921 "node_id": "nid", 9922 "app_id": 1, 9923 "app_slug": "as", 9924 "target_id": 1, 9925 "account": { 9926 "login": "l", 9927 "id": 1, 9928 "avatar_url": "a", 9929 "gravatar_id": "g", 9930 "name": "n", 9931 "company": "c", 9932 "blog": "b", 9933 "location": "l", 9934 "email": "e", 9935 "hireable": true, 9936 "bio": "b", 9937 "twitter_username": "t", 9938 "public_repos": 1, 9939 "followers": 1, 9940 "following": 1, 9941 "created_at": ` + referenceTimeStr + `, 9942 "suspended_at": ` + referenceTimeStr + `, 9943 "url": "u" 9944 }, 9945 "access_tokens_url": "atu", 9946 "repositories_url": "ru", 9947 "html_url": "hu", 9948 "target_type": "tt", 9949 "single_file_name": "sfn", 9950 "repository_selection": "rs", 9951 "events": [ 9952 "e" 9953 ], 9954 "single_file_paths": [ 9955 "s" 9956 ], 9957 "permissions": { 9958 "actions": "a", 9959 "administration": "ad", 9960 "checks": "c", 9961 "contents": "co", 9962 "content_references": "cr", 9963 "deployments": "d", 9964 "environments": "e", 9965 "issues": "i", 9966 "metadata": "md", 9967 "members": "m", 9968 "organization_administration": "oa", 9969 "organization_hooks": "oh", 9970 "organization_plan": "op", 9971 "organization_pre_receive_hooks": "opr", 9972 "organization_projects": "op", 9973 "organization_secrets": "os", 9974 "organization_self_hosted_runners": "osh", 9975 "organization_user_blocking": "oub", 9976 "packages": "pkg", 9977 "pages": "pg", 9978 "pull_requests": "pr", 9979 "repository_hooks": "rh", 9980 "repository_projects": "rp", 9981 "repository_pre_receive_hooks": "rprh", 9982 "secrets": "s", 9983 "secret_scanning_alerts": "ssa", 9984 "security_events": "se", 9985 "single_file": "sf", 9986 "statuses": "s", 9987 "team_discussions": "td", 9988 "vulnerability_alerts": "va", 9989 "workflows": "w" 9990 }, 9991 "created_at": ` + referenceTimeStr + `, 9992 "updated_at": ` + referenceTimeStr + `, 9993 "has_multiple_single_files": false, 9994 "suspended_by": { 9995 "login": "l", 9996 "id": 1, 9997 "avatar_url": "a", 9998 "gravatar_id": "g", 9999 "name": "n", 10000 "company": "c", 10001 "blog": "b", 10002 "location": "l", 10003 "email": "e", 10004 "hireable": true, 10005 "bio": "b", 10006 "twitter_username": "t", 10007 "public_repos": 1, 10008 "followers": 1, 10009 "following": 1, 10010 "created_at": ` + referenceTimeStr + `, 10011 "suspended_at": ` + referenceTimeStr + `, 10012 "url": "u" 10013 }, 10014 "suspended_at": ` + referenceTimeStr + ` 10015 } 10016 }` 10017 10018 testJSONMarshal(t, u, want) 10019 } 10020 10021 func TestOrgBlockEvent_Marshal(t *testing.T) { 10022 testJSONMarshal(t, &OrgBlockEvent{}, "{}") 10023 10024 u := &OrgBlockEvent{ 10025 Action: String("a"), 10026 BlockedUser: &User{ 10027 Login: String("l"), 10028 ID: Int64(1), 10029 NodeID: String("n"), 10030 URL: String("u"), 10031 ReposURL: String("r"), 10032 EventsURL: String("e"), 10033 AvatarURL: String("a"), 10034 }, 10035 Organization: &Organization{ 10036 BillingEmail: String("be"), 10037 Blog: String("b"), 10038 Company: String("c"), 10039 Email: String("e"), 10040 TwitterUsername: String("tu"), 10041 Location: String("loc"), 10042 Name: String("n"), 10043 Description: String("d"), 10044 IsVerified: Bool(true), 10045 HasOrganizationProjects: Bool(true), 10046 HasRepositoryProjects: Bool(true), 10047 DefaultRepoPermission: String("drp"), 10048 MembersCanCreateRepos: Bool(true), 10049 MembersCanCreateInternalRepos: Bool(true), 10050 MembersCanCreatePrivateRepos: Bool(true), 10051 MembersCanCreatePublicRepos: Bool(false), 10052 MembersAllowedRepositoryCreationType: String("marct"), 10053 MembersCanCreatePages: Bool(true), 10054 MembersCanCreatePublicPages: Bool(false), 10055 MembersCanCreatePrivatePages: Bool(true), 10056 }, 10057 Sender: &User{ 10058 Login: String("l"), 10059 ID: Int64(1), 10060 NodeID: String("n"), 10061 URL: String("u"), 10062 ReposURL: String("r"), 10063 EventsURL: String("e"), 10064 AvatarURL: String("a"), 10065 }, 10066 Installation: &Installation{ 10067 ID: Int64(1), 10068 NodeID: String("nid"), 10069 AppID: Int64(1), 10070 AppSlug: String("as"), 10071 TargetID: Int64(1), 10072 Account: &User{ 10073 Login: String("l"), 10074 ID: Int64(1), 10075 URL: String("u"), 10076 AvatarURL: String("a"), 10077 GravatarID: String("g"), 10078 Name: String("n"), 10079 Company: String("c"), 10080 Blog: String("b"), 10081 Location: String("l"), 10082 Email: String("e"), 10083 Hireable: Bool(true), 10084 Bio: String("b"), 10085 TwitterUsername: String("t"), 10086 PublicRepos: Int(1), 10087 Followers: Int(1), 10088 Following: Int(1), 10089 CreatedAt: &Timestamp{referenceTime}, 10090 SuspendedAt: &Timestamp{referenceTime}, 10091 }, 10092 AccessTokensURL: String("atu"), 10093 RepositoriesURL: String("ru"), 10094 HTMLURL: String("hu"), 10095 TargetType: String("tt"), 10096 SingleFileName: String("sfn"), 10097 RepositorySelection: String("rs"), 10098 Events: []string{"e"}, 10099 SingleFilePaths: []string{"s"}, 10100 Permissions: &InstallationPermissions{ 10101 Actions: String("a"), 10102 Administration: String("ad"), 10103 Checks: String("c"), 10104 Contents: String("co"), 10105 ContentReferences: String("cr"), 10106 Deployments: String("d"), 10107 Environments: String("e"), 10108 Issues: String("i"), 10109 Metadata: String("md"), 10110 Members: String("m"), 10111 OrganizationAdministration: String("oa"), 10112 OrganizationHooks: String("oh"), 10113 OrganizationPlan: String("op"), 10114 OrganizationPreReceiveHooks: String("opr"), 10115 OrganizationProjects: String("op"), 10116 OrganizationSecrets: String("os"), 10117 OrganizationSelfHostedRunners: String("osh"), 10118 OrganizationUserBlocking: String("oub"), 10119 Packages: String("pkg"), 10120 Pages: String("pg"), 10121 PullRequests: String("pr"), 10122 RepositoryHooks: String("rh"), 10123 RepositoryProjects: String("rp"), 10124 RepositoryPreReceiveHooks: String("rprh"), 10125 Secrets: String("s"), 10126 SecretScanningAlerts: String("ssa"), 10127 SecurityEvents: String("se"), 10128 SingleFile: String("sf"), 10129 Statuses: String("s"), 10130 TeamDiscussions: String("td"), 10131 VulnerabilityAlerts: String("va"), 10132 Workflows: String("w"), 10133 }, 10134 CreatedAt: &Timestamp{referenceTime}, 10135 UpdatedAt: &Timestamp{referenceTime}, 10136 HasMultipleSingleFiles: Bool(false), 10137 SuspendedBy: &User{ 10138 Login: String("l"), 10139 ID: Int64(1), 10140 URL: String("u"), 10141 AvatarURL: String("a"), 10142 GravatarID: String("g"), 10143 Name: String("n"), 10144 Company: String("c"), 10145 Blog: String("b"), 10146 Location: String("l"), 10147 Email: String("e"), 10148 Hireable: Bool(true), 10149 Bio: String("b"), 10150 TwitterUsername: String("t"), 10151 PublicRepos: Int(1), 10152 Followers: Int(1), 10153 Following: Int(1), 10154 CreatedAt: &Timestamp{referenceTime}, 10155 SuspendedAt: &Timestamp{referenceTime}, 10156 }, 10157 SuspendedAt: &Timestamp{referenceTime}, 10158 }, 10159 } 10160 10161 want := `{ 10162 "action": "a", 10163 "blocked_user": { 10164 "login": "l", 10165 "id": 1, 10166 "node_id": "n", 10167 "avatar_url": "a", 10168 "url": "u", 10169 "events_url": "e", 10170 "repos_url": "r" 10171 }, 10172 "organization": { 10173 "name": "n", 10174 "company": "c", 10175 "blog": "b", 10176 "location": "loc", 10177 "email": "e", 10178 "twitter_username": "tu", 10179 "description": "d", 10180 "billing_email": "be", 10181 "is_verified": true, 10182 "has_organization_projects": true, 10183 "has_repository_projects": true, 10184 "default_repository_permission": "drp", 10185 "members_can_create_repositories": true, 10186 "members_can_create_public_repositories": false, 10187 "members_can_create_private_repositories": true, 10188 "members_can_create_internal_repositories": true, 10189 "members_allowed_repository_creation_type": "marct", 10190 "members_can_create_pages": true, 10191 "members_can_create_public_pages": false, 10192 "members_can_create_private_pages": true 10193 }, 10194 "sender": { 10195 "login": "l", 10196 "id": 1, 10197 "node_id": "n", 10198 "avatar_url": "a", 10199 "url": "u", 10200 "events_url": "e", 10201 "repos_url": "r" 10202 }, 10203 "installation": { 10204 "id": 1, 10205 "node_id": "nid", 10206 "app_id": 1, 10207 "app_slug": "as", 10208 "target_id": 1, 10209 "account": { 10210 "login": "l", 10211 "id": 1, 10212 "avatar_url": "a", 10213 "gravatar_id": "g", 10214 "name": "n", 10215 "company": "c", 10216 "blog": "b", 10217 "location": "l", 10218 "email": "e", 10219 "hireable": true, 10220 "bio": "b", 10221 "twitter_username": "t", 10222 "public_repos": 1, 10223 "followers": 1, 10224 "following": 1, 10225 "created_at": ` + referenceTimeStr + `, 10226 "suspended_at": ` + referenceTimeStr + `, 10227 "url": "u" 10228 }, 10229 "access_tokens_url": "atu", 10230 "repositories_url": "ru", 10231 "html_url": "hu", 10232 "target_type": "tt", 10233 "single_file_name": "sfn", 10234 "repository_selection": "rs", 10235 "events": [ 10236 "e" 10237 ], 10238 "single_file_paths": [ 10239 "s" 10240 ], 10241 "permissions": { 10242 "actions": "a", 10243 "administration": "ad", 10244 "checks": "c", 10245 "contents": "co", 10246 "content_references": "cr", 10247 "deployments": "d", 10248 "environments": "e", 10249 "issues": "i", 10250 "metadata": "md", 10251 "members": "m", 10252 "organization_administration": "oa", 10253 "organization_hooks": "oh", 10254 "organization_plan": "op", 10255 "organization_pre_receive_hooks": "opr", 10256 "organization_projects": "op", 10257 "organization_secrets": "os", 10258 "organization_self_hosted_runners": "osh", 10259 "organization_user_blocking": "oub", 10260 "packages": "pkg", 10261 "pages": "pg", 10262 "pull_requests": "pr", 10263 "repository_hooks": "rh", 10264 "repository_projects": "rp", 10265 "repository_pre_receive_hooks": "rprh", 10266 "secrets": "s", 10267 "secret_scanning_alerts": "ssa", 10268 "security_events": "se", 10269 "single_file": "sf", 10270 "statuses": "s", 10271 "team_discussions": "td", 10272 "vulnerability_alerts": "va", 10273 "workflows": "w" 10274 }, 10275 "created_at": ` + referenceTimeStr + `, 10276 "updated_at": ` + referenceTimeStr + `, 10277 "has_multiple_single_files": false, 10278 "suspended_by": { 10279 "login": "l", 10280 "id": 1, 10281 "avatar_url": "a", 10282 "gravatar_id": "g", 10283 "name": "n", 10284 "company": "c", 10285 "blog": "b", 10286 "location": "l", 10287 "email": "e", 10288 "hireable": true, 10289 "bio": "b", 10290 "twitter_username": "t", 10291 "public_repos": 1, 10292 "followers": 1, 10293 "following": 1, 10294 "created_at": ` + referenceTimeStr + `, 10295 "suspended_at": ` + referenceTimeStr + `, 10296 "url": "u" 10297 }, 10298 "suspended_at": ` + referenceTimeStr + ` 10299 } 10300 }` 10301 10302 testJSONMarshal(t, u, want) 10303 } 10304 10305 func TestGollumEvent_Marshal(t *testing.T) { 10306 testJSONMarshal(t, &GollumEvent{}, "{}") 10307 10308 u := &GollumEvent{ 10309 Pages: []*Page{ 10310 { 10311 PageName: String("pn"), 10312 Title: String("t"), 10313 Summary: String("s"), 10314 Action: String("a"), 10315 SHA: String("sha"), 10316 HTMLURL: String("hu"), 10317 }, 10318 }, 10319 Repo: &Repository{ 10320 ID: Int64(1), 10321 URL: String("s"), 10322 Name: String("n"), 10323 }, 10324 Sender: &User{ 10325 Login: String("l"), 10326 ID: Int64(1), 10327 NodeID: String("n"), 10328 URL: String("u"), 10329 ReposURL: String("r"), 10330 EventsURL: String("e"), 10331 AvatarURL: String("a"), 10332 }, 10333 Installation: &Installation{ 10334 ID: Int64(1), 10335 NodeID: String("nid"), 10336 AppID: Int64(1), 10337 AppSlug: String("as"), 10338 TargetID: Int64(1), 10339 Account: &User{ 10340 Login: String("l"), 10341 ID: Int64(1), 10342 URL: String("u"), 10343 AvatarURL: String("a"), 10344 GravatarID: String("g"), 10345 Name: String("n"), 10346 Company: String("c"), 10347 Blog: String("b"), 10348 Location: String("l"), 10349 Email: String("e"), 10350 Hireable: Bool(true), 10351 Bio: String("b"), 10352 TwitterUsername: String("t"), 10353 PublicRepos: Int(1), 10354 Followers: Int(1), 10355 Following: Int(1), 10356 CreatedAt: &Timestamp{referenceTime}, 10357 SuspendedAt: &Timestamp{referenceTime}, 10358 }, 10359 AccessTokensURL: String("atu"), 10360 RepositoriesURL: String("ru"), 10361 HTMLURL: String("hu"), 10362 TargetType: String("tt"), 10363 SingleFileName: String("sfn"), 10364 RepositorySelection: String("rs"), 10365 Events: []string{"e"}, 10366 SingleFilePaths: []string{"s"}, 10367 Permissions: &InstallationPermissions{ 10368 Actions: String("a"), 10369 Administration: String("ad"), 10370 Checks: String("c"), 10371 Contents: String("co"), 10372 ContentReferences: String("cr"), 10373 Deployments: String("d"), 10374 Environments: String("e"), 10375 Issues: String("i"), 10376 Metadata: String("md"), 10377 Members: String("m"), 10378 OrganizationAdministration: String("oa"), 10379 OrganizationHooks: String("oh"), 10380 OrganizationPlan: String("op"), 10381 OrganizationPreReceiveHooks: String("opr"), 10382 OrganizationProjects: String("op"), 10383 OrganizationSecrets: String("os"), 10384 OrganizationSelfHostedRunners: String("osh"), 10385 OrganizationUserBlocking: String("oub"), 10386 Packages: String("pkg"), 10387 Pages: String("pg"), 10388 PullRequests: String("pr"), 10389 RepositoryHooks: String("rh"), 10390 RepositoryProjects: String("rp"), 10391 RepositoryPreReceiveHooks: String("rprh"), 10392 Secrets: String("s"), 10393 SecretScanningAlerts: String("ssa"), 10394 SecurityEvents: String("se"), 10395 SingleFile: String("sf"), 10396 Statuses: String("s"), 10397 TeamDiscussions: String("td"), 10398 VulnerabilityAlerts: String("va"), 10399 Workflows: String("w"), 10400 }, 10401 CreatedAt: &Timestamp{referenceTime}, 10402 UpdatedAt: &Timestamp{referenceTime}, 10403 HasMultipleSingleFiles: Bool(false), 10404 SuspendedBy: &User{ 10405 Login: String("l"), 10406 ID: Int64(1), 10407 URL: String("u"), 10408 AvatarURL: String("a"), 10409 GravatarID: String("g"), 10410 Name: String("n"), 10411 Company: String("c"), 10412 Blog: String("b"), 10413 Location: String("l"), 10414 Email: String("e"), 10415 Hireable: Bool(true), 10416 Bio: String("b"), 10417 TwitterUsername: String("t"), 10418 PublicRepos: Int(1), 10419 Followers: Int(1), 10420 Following: Int(1), 10421 CreatedAt: &Timestamp{referenceTime}, 10422 SuspendedAt: &Timestamp{referenceTime}, 10423 }, 10424 SuspendedAt: &Timestamp{referenceTime}, 10425 }, 10426 } 10427 10428 want := `{ 10429 "pages": [ 10430 { 10431 "page_name": "pn", 10432 "title": "t", 10433 "summary": "s", 10434 "action": "a", 10435 "sha": "sha", 10436 "html_url": "hu" 10437 } 10438 ], 10439 "repository": { 10440 "id": 1, 10441 "name": "n", 10442 "url": "s" 10443 }, 10444 "sender": { 10445 "login": "l", 10446 "id": 1, 10447 "node_id": "n", 10448 "avatar_url": "a", 10449 "url": "u", 10450 "events_url": "e", 10451 "repos_url": "r" 10452 }, 10453 "installation": { 10454 "id": 1, 10455 "node_id": "nid", 10456 "app_id": 1, 10457 "app_slug": "as", 10458 "target_id": 1, 10459 "account": { 10460 "login": "l", 10461 "id": 1, 10462 "avatar_url": "a", 10463 "gravatar_id": "g", 10464 "name": "n", 10465 "company": "c", 10466 "blog": "b", 10467 "location": "l", 10468 "email": "e", 10469 "hireable": true, 10470 "bio": "b", 10471 "twitter_username": "t", 10472 "public_repos": 1, 10473 "followers": 1, 10474 "following": 1, 10475 "created_at": ` + referenceTimeStr + `, 10476 "suspended_at": ` + referenceTimeStr + `, 10477 "url": "u" 10478 }, 10479 "access_tokens_url": "atu", 10480 "repositories_url": "ru", 10481 "html_url": "hu", 10482 "target_type": "tt", 10483 "single_file_name": "sfn", 10484 "repository_selection": "rs", 10485 "events": [ 10486 "e" 10487 ], 10488 "single_file_paths": [ 10489 "s" 10490 ], 10491 "permissions": { 10492 "actions": "a", 10493 "administration": "ad", 10494 "checks": "c", 10495 "contents": "co", 10496 "content_references": "cr", 10497 "deployments": "d", 10498 "environments": "e", 10499 "issues": "i", 10500 "metadata": "md", 10501 "members": "m", 10502 "organization_administration": "oa", 10503 "organization_hooks": "oh", 10504 "organization_plan": "op", 10505 "organization_pre_receive_hooks": "opr", 10506 "organization_projects": "op", 10507 "organization_secrets": "os", 10508 "organization_self_hosted_runners": "osh", 10509 "organization_user_blocking": "oub", 10510 "packages": "pkg", 10511 "pages": "pg", 10512 "pull_requests": "pr", 10513 "repository_hooks": "rh", 10514 "repository_projects": "rp", 10515 "repository_pre_receive_hooks": "rprh", 10516 "secrets": "s", 10517 "secret_scanning_alerts": "ssa", 10518 "security_events": "se", 10519 "single_file": "sf", 10520 "statuses": "s", 10521 "team_discussions": "td", 10522 "vulnerability_alerts": "va", 10523 "workflows": "w" 10524 }, 10525 "created_at": ` + referenceTimeStr + `, 10526 "updated_at": ` + referenceTimeStr + `, 10527 "has_multiple_single_files": false, 10528 "suspended_by": { 10529 "login": "l", 10530 "id": 1, 10531 "avatar_url": "a", 10532 "gravatar_id": "g", 10533 "name": "n", 10534 "company": "c", 10535 "blog": "b", 10536 "location": "l", 10537 "email": "e", 10538 "hireable": true, 10539 "bio": "b", 10540 "twitter_username": "t", 10541 "public_repos": 1, 10542 "followers": 1, 10543 "following": 1, 10544 "created_at": ` + referenceTimeStr + `, 10545 "suspended_at": ` + referenceTimeStr + `, 10546 "url": "u" 10547 }, 10548 "suspended_at": ` + referenceTimeStr + ` 10549 } 10550 }` 10551 10552 testJSONMarshal(t, u, want) 10553 } 10554 10555 func TestWorkflowRunEvent_Marshal(t *testing.T) { 10556 testJSONMarshal(t, &WorkflowRunEvent{}, "{}") 10557 10558 u := &WorkflowRunEvent{ 10559 Action: String("a"), 10560 Workflow: &Workflow{ 10561 ID: Int64(1), 10562 NodeID: String("nid"), 10563 Name: String("n"), 10564 Path: String("p"), 10565 State: String("s"), 10566 CreatedAt: &Timestamp{referenceTime}, 10567 UpdatedAt: &Timestamp{referenceTime}, 10568 URL: String("u"), 10569 HTMLURL: String("h"), 10570 BadgeURL: String("b"), 10571 }, 10572 WorkflowRun: &WorkflowRun{ 10573 ID: Int64(1), 10574 Name: String("n"), 10575 NodeID: String("nid"), 10576 HeadBranch: String("hb"), 10577 HeadSHA: String("hs"), 10578 RunNumber: Int(1), 10579 RunAttempt: Int(1), 10580 Event: String("e"), 10581 Status: String("s"), 10582 Conclusion: String("c"), 10583 WorkflowID: Int64(1), 10584 URL: String("u"), 10585 HTMLURL: String("h"), 10586 PullRequests: []*PullRequest{ 10587 { 10588 URL: String("u"), 10589 ID: Int64(1), 10590 Number: Int(1), 10591 Head: &PullRequestBranch{ 10592 Ref: String("r"), 10593 SHA: String("s"), 10594 Repo: &Repository{ 10595 ID: Int64(1), 10596 URL: String("s"), 10597 Name: String("n"), 10598 }, 10599 }, 10600 Base: &PullRequestBranch{ 10601 Ref: String("r"), 10602 SHA: String("s"), 10603 Repo: &Repository{ 10604 ID: Int64(1), 10605 URL: String("u"), 10606 Name: String("n"), 10607 }, 10608 }, 10609 }, 10610 }, 10611 CreatedAt: &Timestamp{referenceTime}, 10612 UpdatedAt: &Timestamp{referenceTime}, 10613 RunStartedAt: &Timestamp{referenceTime}, 10614 JobsURL: String("j"), 10615 LogsURL: String("l"), 10616 CheckSuiteURL: String("c"), 10617 ArtifactsURL: String("a"), 10618 CancelURL: String("c"), 10619 RerunURL: String("r"), 10620 PreviousAttemptURL: String("p"), 10621 HeadCommit: &HeadCommit{ 10622 Message: String("m"), 10623 Author: &CommitAuthor{ 10624 Name: String("n"), 10625 Email: String("e"), 10626 Login: String("l"), 10627 }, 10628 URL: String("u"), 10629 Distinct: Bool(false), 10630 SHA: String("s"), 10631 ID: String("i"), 10632 TreeID: String("tid"), 10633 Timestamp: &Timestamp{referenceTime}, 10634 Committer: &CommitAuthor{ 10635 Name: String("n"), 10636 Email: String("e"), 10637 Login: String("l"), 10638 }, 10639 }, 10640 WorkflowURL: String("w"), 10641 Repository: &Repository{ 10642 ID: Int64(1), 10643 URL: String("u"), 10644 Name: String("n"), 10645 }, 10646 HeadRepository: &Repository{ 10647 ID: Int64(1), 10648 URL: String("u"), 10649 Name: String("n"), 10650 }, 10651 }, 10652 Org: &Organization{ 10653 BillingEmail: String("be"), 10654 Blog: String("b"), 10655 Company: String("c"), 10656 Email: String("e"), 10657 TwitterUsername: String("tu"), 10658 Location: String("loc"), 10659 Name: String("n"), 10660 Description: String("d"), 10661 IsVerified: Bool(true), 10662 HasOrganizationProjects: Bool(true), 10663 HasRepositoryProjects: Bool(true), 10664 DefaultRepoPermission: String("drp"), 10665 MembersCanCreateRepos: Bool(true), 10666 MembersCanCreateInternalRepos: Bool(true), 10667 MembersCanCreatePrivateRepos: Bool(true), 10668 MembersCanCreatePublicRepos: Bool(false), 10669 MembersAllowedRepositoryCreationType: String("marct"), 10670 MembersCanCreatePages: Bool(true), 10671 MembersCanCreatePublicPages: Bool(false), 10672 MembersCanCreatePrivatePages: Bool(true), 10673 }, 10674 Repo: &Repository{ 10675 ID: Int64(1), 10676 URL: String("s"), 10677 Name: String("n"), 10678 }, 10679 Sender: &User{ 10680 Login: String("l"), 10681 ID: Int64(1), 10682 NodeID: String("n"), 10683 URL: String("u"), 10684 ReposURL: String("r"), 10685 EventsURL: String("e"), 10686 AvatarURL: String("a"), 10687 }, 10688 } 10689 10690 want := `{ 10691 "action": "a", 10692 "workflow": { 10693 "id": 1, 10694 "node_id": "nid", 10695 "name": "n", 10696 "path": "p", 10697 "state": "s", 10698 "created_at": ` + referenceTimeStr + `, 10699 "updated_at": ` + referenceTimeStr + `, 10700 "url": "u", 10701 "html_url": "h", 10702 "badge_url": "b" 10703 }, 10704 "workflow_run": { 10705 "id": 1, 10706 "name": "n", 10707 "node_id": "nid", 10708 "head_branch": "hb", 10709 "head_sha": "hs", 10710 "run_number": 1, 10711 "run_attempt": 1, 10712 "event": "e", 10713 "status": "s", 10714 "conclusion": "c", 10715 "workflow_id": 1, 10716 "url": "u", 10717 "html_url": "h", 10718 "pull_requests": [ 10719 { 10720 "id": 1, 10721 "number": 1, 10722 "url": "u", 10723 "head": { 10724 "ref": "r", 10725 "sha": "s", 10726 "repo": { 10727 "id": 1, 10728 "name": "n", 10729 "url": "s" 10730 } 10731 }, 10732 "base": { 10733 "ref": "r", 10734 "sha": "s", 10735 "repo": { 10736 "id": 1, 10737 "name": "n", 10738 "url": "u" 10739 } 10740 } 10741 } 10742 ], 10743 "created_at": ` + referenceTimeStr + `, 10744 "updated_at": ` + referenceTimeStr + `, 10745 "run_started_at": ` + referenceTimeStr + `, 10746 "jobs_url": "j", 10747 "logs_url": "l", 10748 "check_suite_url": "c", 10749 "artifacts_url": "a", 10750 "cancel_url": "c", 10751 "rerun_url": "r", 10752 "previous_attempt_url": "p", 10753 "head_commit": { 10754 "message": "m", 10755 "author": { 10756 "name": "n", 10757 "email": "e", 10758 "username": "l" 10759 }, 10760 "url": "u", 10761 "distinct": false, 10762 "sha": "s", 10763 "id": "i", 10764 "tree_id": "tid", 10765 "timestamp": ` + referenceTimeStr + `, 10766 "committer": { 10767 "name": "n", 10768 "email": "e", 10769 "username": "l" 10770 } 10771 }, 10772 "workflow_url": "w", 10773 "repository": { 10774 "id": 1, 10775 "name": "n", 10776 "url": "u" 10777 }, 10778 "head_repository": { 10779 "id": 1, 10780 "name": "n", 10781 "url": "u" 10782 } 10783 }, 10784 "organization": { 10785 "name": "n", 10786 "company": "c", 10787 "blog": "b", 10788 "location": "loc", 10789 "email": "e", 10790 "twitter_username": "tu", 10791 "description": "d", 10792 "billing_email": "be", 10793 "is_verified": true, 10794 "has_organization_projects": true, 10795 "has_repository_projects": true, 10796 "default_repository_permission": "drp", 10797 "members_can_create_repositories": true, 10798 "members_can_create_public_repositories": false, 10799 "members_can_create_private_repositories": true, 10800 "members_can_create_internal_repositories": true, 10801 "members_allowed_repository_creation_type": "marct", 10802 "members_can_create_pages": true, 10803 "members_can_create_public_pages": false, 10804 "members_can_create_private_pages": true 10805 }, 10806 "repository": { 10807 "id": 1, 10808 "name": "n", 10809 "url": "s" 10810 }, 10811 "sender": { 10812 "login": "l", 10813 "id": 1, 10814 "node_id": "n", 10815 "avatar_url": "a", 10816 "url": "u", 10817 "events_url": "e", 10818 "repos_url": "r" 10819 } 10820 }` 10821 10822 testJSONMarshal(t, u, want) 10823 } 10824 10825 func TestWorkflowDispatchEvent_Marshal(t *testing.T) { 10826 testJSONMarshal(t, &WorkflowDispatchEvent{}, "{}") 10827 10828 i := make(map[string]interface{}) 10829 i["key"] = "value" 10830 10831 jsonMsg, _ := json.Marshal(i) 10832 u := &WorkflowDispatchEvent{ 10833 Inputs: jsonMsg, 10834 Ref: String("r"), 10835 Workflow: String("w"), 10836 Repo: &Repository{ 10837 ID: Int64(1), 10838 URL: String("s"), 10839 Name: String("n"), 10840 }, 10841 Org: &Organization{ 10842 BillingEmail: String("be"), 10843 Blog: String("b"), 10844 Company: String("c"), 10845 Email: String("e"), 10846 TwitterUsername: String("tu"), 10847 Location: String("loc"), 10848 Name: String("n"), 10849 Description: String("d"), 10850 IsVerified: Bool(true), 10851 HasOrganizationProjects: Bool(true), 10852 HasRepositoryProjects: Bool(true), 10853 DefaultRepoPermission: String("drp"), 10854 MembersCanCreateRepos: Bool(true), 10855 MembersCanCreateInternalRepos: Bool(true), 10856 MembersCanCreatePrivateRepos: Bool(true), 10857 MembersCanCreatePublicRepos: Bool(false), 10858 MembersAllowedRepositoryCreationType: String("marct"), 10859 MembersCanCreatePages: Bool(true), 10860 MembersCanCreatePublicPages: Bool(false), 10861 MembersCanCreatePrivatePages: Bool(true), 10862 }, 10863 Sender: &User{ 10864 Login: String("l"), 10865 ID: Int64(1), 10866 NodeID: String("n"), 10867 URL: String("u"), 10868 ReposURL: String("r"), 10869 EventsURL: String("e"), 10870 AvatarURL: String("a"), 10871 }, 10872 } 10873 10874 want := `{ 10875 "inputs": { 10876 "key": "value" 10877 }, 10878 "ref": "r", 10879 "workflow": "w", 10880 "repository": { 10881 "id": 1, 10882 "name": "n", 10883 "url": "s" 10884 }, 10885 "organization": { 10886 "name": "n", 10887 "company": "c", 10888 "blog": "b", 10889 "location": "loc", 10890 "email": "e", 10891 "twitter_username": "tu", 10892 "description": "d", 10893 "billing_email": "be", 10894 "is_verified": true, 10895 "has_organization_projects": true, 10896 "has_repository_projects": true, 10897 "default_repository_permission": "drp", 10898 "members_can_create_repositories": true, 10899 "members_can_create_public_repositories": false, 10900 "members_can_create_private_repositories": true, 10901 "members_can_create_internal_repositories": true, 10902 "members_allowed_repository_creation_type": "marct", 10903 "members_can_create_pages": true, 10904 "members_can_create_public_pages": false, 10905 "members_can_create_private_pages": true 10906 }, 10907 "sender": { 10908 "login": "l", 10909 "id": 1, 10910 "node_id": "n", 10911 "avatar_url": "a", 10912 "url": "u", 10913 "events_url": "e", 10914 "repos_url": "r" 10915 } 10916 }` 10917 10918 testJSONMarshal(t, u, want) 10919 } 10920 10921 func TestWatchEvent_Marshal(t *testing.T) { 10922 testJSONMarshal(t, &WatchEvent{}, "{}") 10923 10924 u := &WatchEvent{ 10925 Action: String("a"), 10926 Repo: &Repository{ 10927 ID: Int64(1), 10928 URL: String("s"), 10929 Name: String("n"), 10930 }, 10931 Sender: &User{ 10932 Login: String("l"), 10933 ID: Int64(1), 10934 NodeID: String("n"), 10935 URL: String("u"), 10936 ReposURL: String("r"), 10937 EventsURL: String("e"), 10938 AvatarURL: String("a"), 10939 }, 10940 Installation: &Installation{ 10941 ID: Int64(1), 10942 NodeID: String("nid"), 10943 AppID: Int64(1), 10944 AppSlug: String("as"), 10945 TargetID: Int64(1), 10946 Account: &User{ 10947 Login: String("l"), 10948 ID: Int64(1), 10949 URL: String("u"), 10950 AvatarURL: String("a"), 10951 GravatarID: String("g"), 10952 Name: String("n"), 10953 Company: String("c"), 10954 Blog: String("b"), 10955 Location: String("l"), 10956 Email: String("e"), 10957 Hireable: Bool(true), 10958 Bio: String("b"), 10959 TwitterUsername: String("t"), 10960 PublicRepos: Int(1), 10961 Followers: Int(1), 10962 Following: Int(1), 10963 CreatedAt: &Timestamp{referenceTime}, 10964 SuspendedAt: &Timestamp{referenceTime}, 10965 }, 10966 AccessTokensURL: String("atu"), 10967 RepositoriesURL: String("ru"), 10968 HTMLURL: String("hu"), 10969 TargetType: String("tt"), 10970 SingleFileName: String("sfn"), 10971 RepositorySelection: String("rs"), 10972 Events: []string{"e"}, 10973 SingleFilePaths: []string{"s"}, 10974 Permissions: &InstallationPermissions{ 10975 Actions: String("a"), 10976 Administration: String("ad"), 10977 Checks: String("c"), 10978 Contents: String("co"), 10979 ContentReferences: String("cr"), 10980 Deployments: String("d"), 10981 Environments: String("e"), 10982 Issues: String("i"), 10983 Metadata: String("md"), 10984 Members: String("m"), 10985 OrganizationAdministration: String("oa"), 10986 OrganizationHooks: String("oh"), 10987 OrganizationPlan: String("op"), 10988 OrganizationPreReceiveHooks: String("opr"), 10989 OrganizationProjects: String("op"), 10990 OrganizationSecrets: String("os"), 10991 OrganizationSelfHostedRunners: String("osh"), 10992 OrganizationUserBlocking: String("oub"), 10993 Packages: String("pkg"), 10994 Pages: String("pg"), 10995 PullRequests: String("pr"), 10996 RepositoryHooks: String("rh"), 10997 RepositoryProjects: String("rp"), 10998 RepositoryPreReceiveHooks: String("rprh"), 10999 Secrets: String("s"), 11000 SecretScanningAlerts: String("ssa"), 11001 SecurityEvents: String("se"), 11002 SingleFile: String("sf"), 11003 Statuses: String("s"), 11004 TeamDiscussions: String("td"), 11005 VulnerabilityAlerts: String("va"), 11006 Workflows: String("w"), 11007 }, 11008 CreatedAt: &Timestamp{referenceTime}, 11009 UpdatedAt: &Timestamp{referenceTime}, 11010 HasMultipleSingleFiles: Bool(false), 11011 SuspendedBy: &User{ 11012 Login: String("l"), 11013 ID: Int64(1), 11014 URL: String("u"), 11015 AvatarURL: String("a"), 11016 GravatarID: String("g"), 11017 Name: String("n"), 11018 Company: String("c"), 11019 Blog: String("b"), 11020 Location: String("l"), 11021 Email: String("e"), 11022 Hireable: Bool(true), 11023 Bio: String("b"), 11024 TwitterUsername: String("t"), 11025 PublicRepos: Int(1), 11026 Followers: Int(1), 11027 Following: Int(1), 11028 CreatedAt: &Timestamp{referenceTime}, 11029 SuspendedAt: &Timestamp{referenceTime}, 11030 }, 11031 SuspendedAt: &Timestamp{referenceTime}, 11032 }, 11033 } 11034 11035 want := `{ 11036 "action": "a", 11037 "repository": { 11038 "id": 1, 11039 "name": "n", 11040 "url": "s" 11041 }, 11042 "sender": { 11043 "login": "l", 11044 "id": 1, 11045 "node_id": "n", 11046 "avatar_url": "a", 11047 "url": "u", 11048 "events_url": "e", 11049 "repos_url": "r" 11050 }, 11051 "installation": { 11052 "id": 1, 11053 "node_id": "nid", 11054 "app_id": 1, 11055 "app_slug": "as", 11056 "target_id": 1, 11057 "account": { 11058 "login": "l", 11059 "id": 1, 11060 "avatar_url": "a", 11061 "gravatar_id": "g", 11062 "name": "n", 11063 "company": "c", 11064 "blog": "b", 11065 "location": "l", 11066 "email": "e", 11067 "hireable": true, 11068 "bio": "b", 11069 "twitter_username": "t", 11070 "public_repos": 1, 11071 "followers": 1, 11072 "following": 1, 11073 "created_at": ` + referenceTimeStr + `, 11074 "suspended_at": ` + referenceTimeStr + `, 11075 "url": "u" 11076 }, 11077 "access_tokens_url": "atu", 11078 "repositories_url": "ru", 11079 "html_url": "hu", 11080 "target_type": "tt", 11081 "single_file_name": "sfn", 11082 "repository_selection": "rs", 11083 "events": [ 11084 "e" 11085 ], 11086 "single_file_paths": [ 11087 "s" 11088 ], 11089 "permissions": { 11090 "actions": "a", 11091 "administration": "ad", 11092 "checks": "c", 11093 "contents": "co", 11094 "content_references": "cr", 11095 "deployments": "d", 11096 "environments": "e", 11097 "issues": "i", 11098 "metadata": "md", 11099 "members": "m", 11100 "organization_administration": "oa", 11101 "organization_hooks": "oh", 11102 "organization_plan": "op", 11103 "organization_pre_receive_hooks": "opr", 11104 "organization_projects": "op", 11105 "organization_secrets": "os", 11106 "organization_self_hosted_runners": "osh", 11107 "organization_user_blocking": "oub", 11108 "packages": "pkg", 11109 "pages": "pg", 11110 "pull_requests": "pr", 11111 "repository_hooks": "rh", 11112 "repository_projects": "rp", 11113 "repository_pre_receive_hooks": "rprh", 11114 "secrets": "s", 11115 "secret_scanning_alerts": "ssa", 11116 "security_events": "se", 11117 "single_file": "sf", 11118 "statuses": "s", 11119 "team_discussions": "td", 11120 "vulnerability_alerts": "va", 11121 "workflows": "w" 11122 }, 11123 "created_at": ` + referenceTimeStr + `, 11124 "updated_at": ` + referenceTimeStr + `, 11125 "has_multiple_single_files": false, 11126 "suspended_by": { 11127 "login": "l", 11128 "id": 1, 11129 "avatar_url": "a", 11130 "gravatar_id": "g", 11131 "name": "n", 11132 "company": "c", 11133 "blog": "b", 11134 "location": "l", 11135 "email": "e", 11136 "hireable": true, 11137 "bio": "b", 11138 "twitter_username": "t", 11139 "public_repos": 1, 11140 "followers": 1, 11141 "following": 1, 11142 "created_at": ` + referenceTimeStr + `, 11143 "suspended_at": ` + referenceTimeStr + `, 11144 "url": "u" 11145 }, 11146 "suspended_at": ` + referenceTimeStr + ` 11147 } 11148 }` 11149 11150 testJSONMarshal(t, u, want) 11151 } 11152 11153 func TestUserEvent_Marshal(t *testing.T) { 11154 testJSONMarshal(t, &UserEvent{}, "{}") 11155 11156 u := &UserEvent{ 11157 User: &User{ 11158 Login: String("l"), 11159 ID: Int64(1), 11160 NodeID: String("n"), 11161 URL: String("u"), 11162 ReposURL: String("r"), 11163 EventsURL: String("e"), 11164 AvatarURL: String("a"), 11165 }, 11166 // The action performed. Possible values are: "created" or "deleted". 11167 Action: String("a"), 11168 Enterprise: &Enterprise{ 11169 ID: Int(1), 11170 Slug: String("s"), 11171 Name: String("n"), 11172 NodeID: String("nid"), 11173 AvatarURL: String("au"), 11174 Description: String("d"), 11175 WebsiteURL: String("wu"), 11176 HTMLURL: String("hu"), 11177 CreatedAt: &Timestamp{referenceTime}, 11178 UpdatedAt: &Timestamp{referenceTime}, 11179 }, 11180 Sender: &User{ 11181 Login: String("l"), 11182 ID: Int64(1), 11183 NodeID: String("n"), 11184 URL: String("u"), 11185 ReposURL: String("r"), 11186 EventsURL: String("e"), 11187 AvatarURL: String("a"), 11188 }, 11189 } 11190 11191 want := `{ 11192 "user": { 11193 "login": "l", 11194 "id": 1, 11195 "node_id": "n", 11196 "avatar_url": "a", 11197 "url": "u", 11198 "events_url": "e", 11199 "repos_url": "r" 11200 }, 11201 "action": "a", 11202 "enterprise": { 11203 "id": 1, 11204 "slug": "s", 11205 "name": "n", 11206 "node_id": "nid", 11207 "avatar_url": "au", 11208 "description": "d", 11209 "website_url": "wu", 11210 "html_url": "hu", 11211 "created_at": ` + referenceTimeStr + `, 11212 "updated_at": ` + referenceTimeStr + ` 11213 }, 11214 "sender": { 11215 "login": "l", 11216 "id": 1, 11217 "node_id": "n", 11218 "avatar_url": "a", 11219 "url": "u", 11220 "events_url": "e", 11221 "repos_url": "r" 11222 } 11223 }` 11224 11225 testJSONMarshal(t, u, want) 11226 } 11227 11228 func TestCheckRunEvent_Marshal(t *testing.T) { 11229 testJSONMarshal(t, &CheckRunEvent{}, "{}") 11230 11231 r := &CheckRunEvent{ 11232 CheckRun: &CheckRun{ 11233 ID: Int64(1), 11234 NodeID: String("n"), 11235 HeadSHA: String("h"), 11236 ExternalID: String("1"), 11237 URL: String("u"), 11238 HTMLURL: String("u"), 11239 DetailsURL: String("u"), 11240 Status: String("s"), 11241 Conclusion: String("c"), 11242 StartedAt: &Timestamp{referenceTime}, 11243 CompletedAt: &Timestamp{referenceTime}, 11244 Output: &CheckRunOutput{ 11245 Annotations: []*CheckRunAnnotation{ 11246 { 11247 AnnotationLevel: String("a"), 11248 EndLine: Int(1), 11249 Message: String("m"), 11250 Path: String("p"), 11251 RawDetails: String("r"), 11252 StartLine: Int(1), 11253 Title: String("t"), 11254 }, 11255 }, 11256 AnnotationsCount: Int(1), 11257 AnnotationsURL: String("a"), 11258 Images: []*CheckRunImage{ 11259 { 11260 Alt: String("a"), 11261 ImageURL: String("i"), 11262 Caption: String("c"), 11263 }, 11264 }, 11265 Title: String("t"), 11266 Summary: String("s"), 11267 Text: String("t"), 11268 }, 11269 Name: String("n"), 11270 CheckSuite: &CheckSuite{ 11271 ID: Int64(1), 11272 }, 11273 App: &App{ 11274 ID: Int64(1), 11275 NodeID: String("n"), 11276 Owner: &User{ 11277 Login: String("l"), 11278 ID: Int64(1), 11279 NodeID: String("n"), 11280 URL: String("u"), 11281 ReposURL: String("r"), 11282 EventsURL: String("e"), 11283 AvatarURL: String("a"), 11284 }, 11285 Name: String("n"), 11286 Description: String("d"), 11287 HTMLURL: String("h"), 11288 ExternalURL: String("u"), 11289 CreatedAt: &Timestamp{referenceTime}, 11290 UpdatedAt: &Timestamp{referenceTime}, 11291 }, 11292 PullRequests: []*PullRequest{ 11293 { 11294 URL: String("u"), 11295 ID: Int64(1), 11296 Number: Int(1), 11297 Head: &PullRequestBranch{ 11298 Ref: String("r"), 11299 SHA: String("s"), 11300 Repo: &Repository{ 11301 ID: Int64(1), 11302 URL: String("s"), 11303 Name: String("n"), 11304 }, 11305 }, 11306 Base: &PullRequestBranch{ 11307 Ref: String("r"), 11308 SHA: String("s"), 11309 Repo: &Repository{ 11310 ID: Int64(1), 11311 URL: String("u"), 11312 Name: String("n"), 11313 }, 11314 }, 11315 }, 11316 }, 11317 }, 11318 Action: String("a"), 11319 Repo: &Repository{ 11320 ID: Int64(1), 11321 URL: String("s"), 11322 Name: String("n"), 11323 }, 11324 Org: &Organization{ 11325 BillingEmail: String("be"), 11326 Blog: String("b"), 11327 Company: String("c"), 11328 Email: String("e"), 11329 TwitterUsername: String("tu"), 11330 Location: String("loc"), 11331 Name: String("n"), 11332 Description: String("d"), 11333 IsVerified: Bool(true), 11334 HasOrganizationProjects: Bool(true), 11335 HasRepositoryProjects: Bool(true), 11336 DefaultRepoPermission: String("drp"), 11337 MembersCanCreateRepos: Bool(true), 11338 MembersCanCreateInternalRepos: Bool(true), 11339 MembersCanCreatePrivateRepos: Bool(true), 11340 MembersCanCreatePublicRepos: Bool(false), 11341 MembersAllowedRepositoryCreationType: String("marct"), 11342 MembersCanCreatePages: Bool(true), 11343 MembersCanCreatePublicPages: Bool(false), 11344 MembersCanCreatePrivatePages: Bool(true), 11345 }, 11346 Sender: &User{ 11347 Login: String("l"), 11348 ID: Int64(1), 11349 NodeID: String("n"), 11350 URL: String("u"), 11351 ReposURL: String("r"), 11352 EventsURL: String("e"), 11353 AvatarURL: String("a"), 11354 }, 11355 Installation: &Installation{ 11356 ID: Int64(1), 11357 NodeID: String("nid"), 11358 AppID: Int64(1), 11359 AppSlug: String("as"), 11360 TargetID: Int64(1), 11361 Account: &User{ 11362 Login: String("l"), 11363 ID: Int64(1), 11364 URL: String("u"), 11365 AvatarURL: String("a"), 11366 GravatarID: String("g"), 11367 Name: String("n"), 11368 Company: String("c"), 11369 Blog: String("b"), 11370 Location: String("l"), 11371 Email: String("e"), 11372 Hireable: Bool(true), 11373 Bio: String("b"), 11374 TwitterUsername: String("t"), 11375 PublicRepos: Int(1), 11376 Followers: Int(1), 11377 Following: Int(1), 11378 CreatedAt: &Timestamp{referenceTime}, 11379 SuspendedAt: &Timestamp{referenceTime}, 11380 }, 11381 AccessTokensURL: String("atu"), 11382 RepositoriesURL: String("ru"), 11383 HTMLURL: String("hu"), 11384 TargetType: String("tt"), 11385 SingleFileName: String("sfn"), 11386 RepositorySelection: String("rs"), 11387 Events: []string{"e"}, 11388 SingleFilePaths: []string{"s"}, 11389 Permissions: &InstallationPermissions{ 11390 Actions: String("a"), 11391 Administration: String("ad"), 11392 Checks: String("c"), 11393 Contents: String("co"), 11394 ContentReferences: String("cr"), 11395 Deployments: String("d"), 11396 Environments: String("e"), 11397 Issues: String("i"), 11398 Metadata: String("md"), 11399 Members: String("m"), 11400 OrganizationAdministration: String("oa"), 11401 OrganizationHooks: String("oh"), 11402 OrganizationPlan: String("op"), 11403 OrganizationPreReceiveHooks: String("opr"), 11404 OrganizationProjects: String("op"), 11405 OrganizationSecrets: String("os"), 11406 OrganizationSelfHostedRunners: String("osh"), 11407 OrganizationUserBlocking: String("oub"), 11408 Packages: String("pkg"), 11409 Pages: String("pg"), 11410 PullRequests: String("pr"), 11411 RepositoryHooks: String("rh"), 11412 RepositoryProjects: String("rp"), 11413 RepositoryPreReceiveHooks: String("rprh"), 11414 Secrets: String("s"), 11415 SecretScanningAlerts: String("ssa"), 11416 SecurityEvents: String("se"), 11417 SingleFile: String("sf"), 11418 Statuses: String("s"), 11419 TeamDiscussions: String("td"), 11420 VulnerabilityAlerts: String("va"), 11421 Workflows: String("w"), 11422 }, 11423 CreatedAt: &Timestamp{referenceTime}, 11424 UpdatedAt: &Timestamp{referenceTime}, 11425 HasMultipleSingleFiles: Bool(false), 11426 SuspendedBy: &User{ 11427 Login: String("l"), 11428 ID: Int64(1), 11429 URL: String("u"), 11430 AvatarURL: String("a"), 11431 GravatarID: String("g"), 11432 Name: String("n"), 11433 Company: String("c"), 11434 Blog: String("b"), 11435 Location: String("l"), 11436 Email: String("e"), 11437 Hireable: Bool(true), 11438 Bio: String("b"), 11439 TwitterUsername: String("t"), 11440 PublicRepos: Int(1), 11441 Followers: Int(1), 11442 Following: Int(1), 11443 CreatedAt: &Timestamp{referenceTime}, 11444 SuspendedAt: &Timestamp{referenceTime}, 11445 }, 11446 SuspendedAt: &Timestamp{referenceTime}, 11447 }, 11448 RequestedAction: &RequestedAction{ 11449 Identifier: "i", 11450 }, 11451 } 11452 11453 want := `{ 11454 "check_run": { 11455 "id": 1, 11456 "node_id": "n", 11457 "head_sha": "h", 11458 "external_id": "1", 11459 "url": "u", 11460 "html_url": "u", 11461 "details_url": "u", 11462 "status": "s", 11463 "conclusion": "c", 11464 "started_at": ` + referenceTimeStr + `, 11465 "completed_at": ` + referenceTimeStr + `, 11466 "output": { 11467 "title": "t", 11468 "summary": "s", 11469 "text": "t", 11470 "annotations_count": 1, 11471 "annotations_url": "a", 11472 "annotations": [ 11473 { 11474 "path": "p", 11475 "start_line": 1, 11476 "end_line": 1, 11477 "annotation_level": "a", 11478 "message": "m", 11479 "title": "t", 11480 "raw_details": "r" 11481 } 11482 ], 11483 "images": [ 11484 { 11485 "alt": "a", 11486 "image_url": "i", 11487 "caption": "c" 11488 } 11489 ] 11490 }, 11491 "name": "n", 11492 "check_suite": { 11493 "id": 1 11494 }, 11495 "app": { 11496 "id": 1, 11497 "node_id": "n", 11498 "owner": { 11499 "login": "l", 11500 "id": 1, 11501 "node_id": "n", 11502 "avatar_url": "a", 11503 "url": "u", 11504 "events_url": "e", 11505 "repos_url": "r" 11506 }, 11507 "name": "n", 11508 "description": "d", 11509 "external_url": "u", 11510 "html_url": "h", 11511 "created_at": ` + referenceTimeStr + `, 11512 "updated_at": ` + referenceTimeStr + ` 11513 }, 11514 "pull_requests": [ 11515 { 11516 "id": 1, 11517 "number": 1, 11518 "url": "u", 11519 "head": { 11520 "ref": "r", 11521 "sha": "s", 11522 "repo": { 11523 "id": 1, 11524 "name": "n", 11525 "url": "s" 11526 } 11527 }, 11528 "base": { 11529 "ref": "r", 11530 "sha": "s", 11531 "repo": { 11532 "id": 1, 11533 "name": "n", 11534 "url": "u" 11535 } 11536 } 11537 } 11538 ] 11539 }, 11540 "action": "a", 11541 "repository": { 11542 "id": 1, 11543 "name": "n", 11544 "url": "s" 11545 }, 11546 "organization": { 11547 "name": "n", 11548 "company": "c", 11549 "blog": "b", 11550 "location": "loc", 11551 "email": "e", 11552 "twitter_username": "tu", 11553 "description": "d", 11554 "billing_email": "be", 11555 "is_verified": true, 11556 "has_organization_projects": true, 11557 "has_repository_projects": true, 11558 "default_repository_permission": "drp", 11559 "members_can_create_repositories": true, 11560 "members_can_create_public_repositories": false, 11561 "members_can_create_private_repositories": true, 11562 "members_can_create_internal_repositories": true, 11563 "members_allowed_repository_creation_type": "marct", 11564 "members_can_create_pages": true, 11565 "members_can_create_public_pages": false, 11566 "members_can_create_private_pages": true 11567 }, 11568 "sender": { 11569 "login": "l", 11570 "id": 1, 11571 "node_id": "n", 11572 "avatar_url": "a", 11573 "url": "u", 11574 "events_url": "e", 11575 "repos_url": "r" 11576 }, 11577 "installation": { 11578 "id": 1, 11579 "node_id": "nid", 11580 "app_id": 1, 11581 "app_slug": "as", 11582 "target_id": 1, 11583 "account": { 11584 "login": "l", 11585 "id": 1, 11586 "avatar_url": "a", 11587 "gravatar_id": "g", 11588 "name": "n", 11589 "company": "c", 11590 "blog": "b", 11591 "location": "l", 11592 "email": "e", 11593 "hireable": true, 11594 "bio": "b", 11595 "twitter_username": "t", 11596 "public_repos": 1, 11597 "followers": 1, 11598 "following": 1, 11599 "created_at": ` + referenceTimeStr + `, 11600 "suspended_at": ` + referenceTimeStr + `, 11601 "url": "u" 11602 }, 11603 "access_tokens_url": "atu", 11604 "repositories_url": "ru", 11605 "html_url": "hu", 11606 "target_type": "tt", 11607 "single_file_name": "sfn", 11608 "repository_selection": "rs", 11609 "events": [ 11610 "e" 11611 ], 11612 "single_file_paths": [ 11613 "s" 11614 ], 11615 "permissions": { 11616 "actions": "a", 11617 "administration": "ad", 11618 "checks": "c", 11619 "contents": "co", 11620 "content_references": "cr", 11621 "deployments": "d", 11622 "environments": "e", 11623 "issues": "i", 11624 "metadata": "md", 11625 "members": "m", 11626 "organization_administration": "oa", 11627 "organization_hooks": "oh", 11628 "organization_plan": "op", 11629 "organization_pre_receive_hooks": "opr", 11630 "organization_projects": "op", 11631 "organization_secrets": "os", 11632 "organization_self_hosted_runners": "osh", 11633 "organization_user_blocking": "oub", 11634 "packages": "pkg", 11635 "pages": "pg", 11636 "pull_requests": "pr", 11637 "repository_hooks": "rh", 11638 "repository_projects": "rp", 11639 "repository_pre_receive_hooks": "rprh", 11640 "secrets": "s", 11641 "secret_scanning_alerts": "ssa", 11642 "security_events": "se", 11643 "single_file": "sf", 11644 "statuses": "s", 11645 "team_discussions": "td", 11646 "vulnerability_alerts": "va", 11647 "workflows": "w" 11648 }, 11649 "created_at": ` + referenceTimeStr + `, 11650 "updated_at": ` + referenceTimeStr + `, 11651 "has_multiple_single_files": false, 11652 "suspended_by": { 11653 "login": "l", 11654 "id": 1, 11655 "avatar_url": "a", 11656 "gravatar_id": "g", 11657 "name": "n", 11658 "company": "c", 11659 "blog": "b", 11660 "location": "l", 11661 "email": "e", 11662 "hireable": true, 11663 "bio": "b", 11664 "twitter_username": "t", 11665 "public_repos": 1, 11666 "followers": 1, 11667 "following": 1, 11668 "created_at": ` + referenceTimeStr + `, 11669 "suspended_at": ` + referenceTimeStr + `, 11670 "url": "u" 11671 }, 11672 "suspended_at": ` + referenceTimeStr + ` 11673 }, 11674 "requested_action": { 11675 "identifier": "i" 11676 } 11677 }` 11678 11679 testJSONMarshal(t, r, want) 11680 } 11681 11682 func TestCheckSuiteEvent_Marshal(t *testing.T) { 11683 testJSONMarshal(t, &CheckSuiteEvent{}, "{}") 11684 11685 r := &CheckSuiteEvent{ 11686 CheckSuite: &CheckSuite{ 11687 ID: Int64(1), 11688 NodeID: String("n"), 11689 HeadBranch: String("h"), 11690 HeadSHA: String("h"), 11691 URL: String("u"), 11692 BeforeSHA: String("b"), 11693 AfterSHA: String("a"), 11694 Status: String("s"), 11695 Conclusion: String("c"), 11696 App: &App{ 11697 ID: Int64(1), 11698 NodeID: String("n"), 11699 Owner: &User{ 11700 Login: String("l"), 11701 ID: Int64(1), 11702 NodeID: String("n"), 11703 URL: String("u"), 11704 ReposURL: String("r"), 11705 EventsURL: String("e"), 11706 AvatarURL: String("a"), 11707 }, 11708 Name: String("n"), 11709 Description: String("d"), 11710 HTMLURL: String("h"), 11711 ExternalURL: String("u"), 11712 CreatedAt: &Timestamp{referenceTime}, 11713 UpdatedAt: &Timestamp{referenceTime}, 11714 }, 11715 Repository: &Repository{ 11716 ID: Int64(1), 11717 }, 11718 PullRequests: []*PullRequest{ 11719 { 11720 URL: String("u"), 11721 ID: Int64(1), 11722 Number: Int(1), 11723 Head: &PullRequestBranch{ 11724 Ref: String("r"), 11725 SHA: String("s"), 11726 Repo: &Repository{ 11727 ID: Int64(1), 11728 URL: String("s"), 11729 Name: String("n"), 11730 }, 11731 }, 11732 Base: &PullRequestBranch{ 11733 Ref: String("r"), 11734 SHA: String("s"), 11735 Repo: &Repository{ 11736 ID: Int64(1), 11737 URL: String("u"), 11738 Name: String("n"), 11739 }, 11740 }, 11741 }, 11742 }, 11743 HeadCommit: &Commit{ 11744 SHA: String("s"), 11745 }, 11746 }, 11747 Action: String("a"), 11748 Repo: &Repository{ 11749 ID: Int64(1), 11750 URL: String("s"), 11751 Name: String("n"), 11752 }, 11753 Org: &Organization{ 11754 BillingEmail: String("be"), 11755 Blog: String("b"), 11756 Company: String("c"), 11757 Email: String("e"), 11758 TwitterUsername: String("tu"), 11759 Location: String("loc"), 11760 Name: String("n"), 11761 Description: String("d"), 11762 IsVerified: Bool(true), 11763 HasOrganizationProjects: Bool(true), 11764 HasRepositoryProjects: Bool(true), 11765 DefaultRepoPermission: String("drp"), 11766 MembersCanCreateRepos: Bool(true), 11767 MembersCanCreateInternalRepos: Bool(true), 11768 MembersCanCreatePrivateRepos: Bool(true), 11769 MembersCanCreatePublicRepos: Bool(false), 11770 MembersAllowedRepositoryCreationType: String("marct"), 11771 MembersCanCreatePages: Bool(true), 11772 MembersCanCreatePublicPages: Bool(false), 11773 MembersCanCreatePrivatePages: Bool(true), 11774 }, 11775 Sender: &User{ 11776 Login: String("l"), 11777 ID: Int64(1), 11778 NodeID: String("n"), 11779 URL: String("u"), 11780 ReposURL: String("r"), 11781 EventsURL: String("e"), 11782 AvatarURL: String("a"), 11783 }, 11784 Installation: &Installation{ 11785 ID: Int64(1), 11786 NodeID: String("nid"), 11787 AppID: Int64(1), 11788 AppSlug: String("as"), 11789 TargetID: Int64(1), 11790 Account: &User{ 11791 Login: String("l"), 11792 ID: Int64(1), 11793 URL: String("u"), 11794 AvatarURL: String("a"), 11795 GravatarID: String("g"), 11796 Name: String("n"), 11797 Company: String("c"), 11798 Blog: String("b"), 11799 Location: String("l"), 11800 Email: String("e"), 11801 Hireable: Bool(true), 11802 Bio: String("b"), 11803 TwitterUsername: String("t"), 11804 PublicRepos: Int(1), 11805 Followers: Int(1), 11806 Following: Int(1), 11807 CreatedAt: &Timestamp{referenceTime}, 11808 SuspendedAt: &Timestamp{referenceTime}, 11809 }, 11810 AccessTokensURL: String("atu"), 11811 RepositoriesURL: String("ru"), 11812 HTMLURL: String("hu"), 11813 TargetType: String("tt"), 11814 SingleFileName: String("sfn"), 11815 RepositorySelection: String("rs"), 11816 Events: []string{"e"}, 11817 SingleFilePaths: []string{"s"}, 11818 Permissions: &InstallationPermissions{ 11819 Actions: String("a"), 11820 Administration: String("ad"), 11821 Checks: String("c"), 11822 Contents: String("co"), 11823 ContentReferences: String("cr"), 11824 Deployments: String("d"), 11825 Environments: String("e"), 11826 Issues: String("i"), 11827 Metadata: String("md"), 11828 Members: String("m"), 11829 OrganizationAdministration: String("oa"), 11830 OrganizationHooks: String("oh"), 11831 OrganizationPlan: String("op"), 11832 OrganizationPreReceiveHooks: String("opr"), 11833 OrganizationProjects: String("op"), 11834 OrganizationSecrets: String("os"), 11835 OrganizationSelfHostedRunners: String("osh"), 11836 OrganizationUserBlocking: String("oub"), 11837 Packages: String("pkg"), 11838 Pages: String("pg"), 11839 PullRequests: String("pr"), 11840 RepositoryHooks: String("rh"), 11841 RepositoryProjects: String("rp"), 11842 RepositoryPreReceiveHooks: String("rprh"), 11843 Secrets: String("s"), 11844 SecretScanningAlerts: String("ssa"), 11845 SecurityEvents: String("se"), 11846 SingleFile: String("sf"), 11847 Statuses: String("s"), 11848 TeamDiscussions: String("td"), 11849 VulnerabilityAlerts: String("va"), 11850 Workflows: String("w"), 11851 }, 11852 CreatedAt: &Timestamp{referenceTime}, 11853 UpdatedAt: &Timestamp{referenceTime}, 11854 HasMultipleSingleFiles: Bool(false), 11855 SuspendedBy: &User{ 11856 Login: String("l"), 11857 ID: Int64(1), 11858 URL: String("u"), 11859 AvatarURL: String("a"), 11860 GravatarID: String("g"), 11861 Name: String("n"), 11862 Company: String("c"), 11863 Blog: String("b"), 11864 Location: String("l"), 11865 Email: String("e"), 11866 Hireable: Bool(true), 11867 Bio: String("b"), 11868 TwitterUsername: String("t"), 11869 PublicRepos: Int(1), 11870 Followers: Int(1), 11871 Following: Int(1), 11872 CreatedAt: &Timestamp{referenceTime}, 11873 SuspendedAt: &Timestamp{referenceTime}, 11874 }, 11875 SuspendedAt: &Timestamp{referenceTime}, 11876 }, 11877 } 11878 11879 want := `{ 11880 "check_suite": { 11881 "id": 1, 11882 "node_id": "n", 11883 "head_branch": "h", 11884 "head_sha": "h", 11885 "url": "u", 11886 "before": "b", 11887 "after": "a", 11888 "status": "s", 11889 "conclusion": "c", 11890 "app": { 11891 "id": 1, 11892 "node_id": "n", 11893 "owner": { 11894 "login": "l", 11895 "id": 1, 11896 "node_id": "n", 11897 "avatar_url": "a", 11898 "url": "u", 11899 "events_url": "e", 11900 "repos_url": "r" 11901 }, 11902 "name": "n", 11903 "description": "d", 11904 "external_url": "u", 11905 "html_url": "h", 11906 "created_at": ` + referenceTimeStr + `, 11907 "updated_at": ` + referenceTimeStr + ` 11908 }, 11909 "repository": { 11910 "id": 1 11911 }, 11912 "pull_requests": [ 11913 { 11914 "id": 1, 11915 "number": 1, 11916 "url": "u", 11917 "head": { 11918 "ref": "r", 11919 "sha": "s", 11920 "repo": { 11921 "id": 1, 11922 "name": "n", 11923 "url": "s" 11924 } 11925 }, 11926 "base": { 11927 "ref": "r", 11928 "sha": "s", 11929 "repo": { 11930 "id": 1, 11931 "name": "n", 11932 "url": "u" 11933 } 11934 } 11935 } 11936 ], 11937 "head_commit": { 11938 "sha": "s" 11939 } 11940 }, 11941 "action": "a", 11942 "repository": { 11943 "id": 1, 11944 "name": "n", 11945 "url": "s" 11946 }, 11947 "organization": { 11948 "name": "n", 11949 "company": "c", 11950 "blog": "b", 11951 "location": "loc", 11952 "email": "e", 11953 "twitter_username": "tu", 11954 "description": "d", 11955 "billing_email": "be", 11956 "is_verified": true, 11957 "has_organization_projects": true, 11958 "has_repository_projects": true, 11959 "default_repository_permission": "drp", 11960 "members_can_create_repositories": true, 11961 "members_can_create_public_repositories": false, 11962 "members_can_create_private_repositories": true, 11963 "members_can_create_internal_repositories": true, 11964 "members_allowed_repository_creation_type": "marct", 11965 "members_can_create_pages": true, 11966 "members_can_create_public_pages": false, 11967 "members_can_create_private_pages": true 11968 }, 11969 "sender": { 11970 "login": "l", 11971 "id": 1, 11972 "node_id": "n", 11973 "avatar_url": "a", 11974 "url": "u", 11975 "events_url": "e", 11976 "repos_url": "r" 11977 }, 11978 "installation": { 11979 "id": 1, 11980 "node_id": "nid", 11981 "app_id": 1, 11982 "app_slug": "as", 11983 "target_id": 1, 11984 "account": { 11985 "login": "l", 11986 "id": 1, 11987 "avatar_url": "a", 11988 "gravatar_id": "g", 11989 "name": "n", 11990 "company": "c", 11991 "blog": "b", 11992 "location": "l", 11993 "email": "e", 11994 "hireable": true, 11995 "bio": "b", 11996 "twitter_username": "t", 11997 "public_repos": 1, 11998 "followers": 1, 11999 "following": 1, 12000 "created_at": ` + referenceTimeStr + `, 12001 "suspended_at": ` + referenceTimeStr + `, 12002 "url": "u" 12003 }, 12004 "access_tokens_url": "atu", 12005 "repositories_url": "ru", 12006 "html_url": "hu", 12007 "target_type": "tt", 12008 "single_file_name": "sfn", 12009 "repository_selection": "rs", 12010 "events": [ 12011 "e" 12012 ], 12013 "single_file_paths": [ 12014 "s" 12015 ], 12016 "permissions": { 12017 "actions": "a", 12018 "administration": "ad", 12019 "checks": "c", 12020 "contents": "co", 12021 "content_references": "cr", 12022 "deployments": "d", 12023 "environments": "e", 12024 "issues": "i", 12025 "metadata": "md", 12026 "members": "m", 12027 "organization_administration": "oa", 12028 "organization_hooks": "oh", 12029 "organization_plan": "op", 12030 "organization_pre_receive_hooks": "opr", 12031 "organization_projects": "op", 12032 "organization_secrets": "os", 12033 "organization_self_hosted_runners": "osh", 12034 "organization_user_blocking": "oub", 12035 "packages": "pkg", 12036 "pages": "pg", 12037 "pull_requests": "pr", 12038 "repository_hooks": "rh", 12039 "repository_projects": "rp", 12040 "repository_pre_receive_hooks": "rprh", 12041 "secrets": "s", 12042 "secret_scanning_alerts": "ssa", 12043 "security_events": "se", 12044 "single_file": "sf", 12045 "statuses": "s", 12046 "team_discussions": "td", 12047 "vulnerability_alerts": "va", 12048 "workflows": "w" 12049 }, 12050 "created_at": ` + referenceTimeStr + `, 12051 "updated_at": ` + referenceTimeStr + `, 12052 "has_multiple_single_files": false, 12053 "suspended_by": { 12054 "login": "l", 12055 "id": 1, 12056 "avatar_url": "a", 12057 "gravatar_id": "g", 12058 "name": "n", 12059 "company": "c", 12060 "blog": "b", 12061 "location": "l", 12062 "email": "e", 12063 "hireable": true, 12064 "bio": "b", 12065 "twitter_username": "t", 12066 "public_repos": 1, 12067 "followers": 1, 12068 "following": 1, 12069 "created_at": ` + referenceTimeStr + `, 12070 "suspended_at": ` + referenceTimeStr + `, 12071 "url": "u" 12072 }, 12073 "suspended_at": ` + referenceTimeStr + ` 12074 } 12075 }` 12076 12077 testJSONMarshal(t, r, want) 12078 } 12079 12080 func TestDeployKeyEvent_Marshal(t *testing.T) { 12081 testJSONMarshal(t, &DeployKeyEvent{}, "{}") 12082 12083 u := &DeployKeyEvent{ 12084 Action: String("a"), 12085 Key: &Key{ 12086 ID: Int64(1), 12087 Key: String("k"), 12088 URL: String("k"), 12089 Title: String("k"), 12090 ReadOnly: Bool(false), 12091 Verified: Bool(false), 12092 CreatedAt: &Timestamp{referenceTime}, 12093 }, 12094 Repo: &Repository{ 12095 ID: Int64(1), 12096 URL: String("s"), 12097 Name: String("n"), 12098 }, 12099 Organization: &Organization{ 12100 BillingEmail: String("be"), 12101 Blog: String("b"), 12102 Company: String("c"), 12103 Email: String("e"), 12104 TwitterUsername: String("tu"), 12105 Location: String("loc"), 12106 Name: String("n"), 12107 Description: String("d"), 12108 IsVerified: Bool(true), 12109 HasOrganizationProjects: Bool(true), 12110 HasRepositoryProjects: Bool(true), 12111 DefaultRepoPermission: String("drp"), 12112 MembersCanCreateRepos: Bool(true), 12113 MembersCanCreateInternalRepos: Bool(true), 12114 MembersCanCreatePrivateRepos: Bool(true), 12115 MembersCanCreatePublicRepos: Bool(false), 12116 MembersAllowedRepositoryCreationType: String("marct"), 12117 MembersCanCreatePages: Bool(true), 12118 MembersCanCreatePublicPages: Bool(false), 12119 MembersCanCreatePrivatePages: Bool(true), 12120 }, 12121 Sender: &User{ 12122 Login: String("l"), 12123 ID: Int64(1), 12124 NodeID: String("n"), 12125 AvatarURL: String("a"), 12126 URL: String("u"), 12127 EventsURL: String("e"), 12128 ReposURL: String("r"), 12129 }, 12130 } 12131 12132 want := `{ 12133 "action": "a", 12134 "key": { 12135 "id": 1, 12136 "key": "k", 12137 "url": "k", 12138 "title": "k", 12139 "read_only": false, 12140 "verified": false, 12141 "created_at": ` + referenceTimeStr + ` 12142 }, 12143 "repository": { 12144 "id": 1, 12145 "name": "n", 12146 "url": "s" 12147 }, 12148 "organization": { 12149 "name": "n", 12150 "company": "c", 12151 "blog": "b", 12152 "location": "loc", 12153 "email": "e", 12154 "twitter_username": "tu", 12155 "description": "d", 12156 "billing_email": "be", 12157 "is_verified": true, 12158 "has_organization_projects": true, 12159 "has_repository_projects": true, 12160 "default_repository_permission": "drp", 12161 "members_can_create_repositories": true, 12162 "members_can_create_public_repositories": false, 12163 "members_can_create_private_repositories": true, 12164 "members_can_create_internal_repositories": true, 12165 "members_allowed_repository_creation_type": "marct", 12166 "members_can_create_pages": true, 12167 "members_can_create_public_pages": false, 12168 "members_can_create_private_pages": true 12169 }, 12170 "sender": { 12171 "login": "l", 12172 "id": 1, 12173 "node_id": "n", 12174 "avatar_url": "a", 12175 "url": "u", 12176 "events_url": "e", 12177 "repos_url": "r" 12178 } 12179 }` 12180 12181 testJSONMarshal(t, u, want) 12182 } 12183 12184 func TestMetaEvent_Marshal(t *testing.T) { 12185 testJSONMarshal(t, &MetaEvent{}, "{}") 12186 12187 v := make(map[string]interface{}) 12188 v["a"] = "b" 12189 hookConfig := &HookConfig{ 12190 ContentType: String("json"), 12191 } 12192 12193 u := &MetaEvent{ 12194 Action: String("a"), 12195 HookID: Int64(1), 12196 Hook: &Hook{ 12197 CreatedAt: &Timestamp{referenceTime}, 12198 UpdatedAt: &Timestamp{referenceTime}, 12199 URL: String("u"), 12200 ID: Int64(1), 12201 Type: String("t"), 12202 Name: String("n"), 12203 TestURL: String("tu"), 12204 PingURL: String("pu"), 12205 LastResponse: v, 12206 Config: hookConfig, 12207 Events: []string{"a"}, 12208 Active: Bool(true), 12209 }, 12210 } 12211 12212 want := `{ 12213 "action": "a", 12214 "hook_id": 1, 12215 "hook": { 12216 "created_at": ` + referenceTimeStr + `, 12217 "updated_at": ` + referenceTimeStr + `, 12218 "url": "u", 12219 "id": 1, 12220 "type": "t", 12221 "name": "n", 12222 "test_url": "tu", 12223 "ping_url": "pu", 12224 "last_response": { 12225 "a": "b" 12226 }, 12227 "config": { 12228 "content_type": "json" 12229 }, 12230 "events": [ 12231 "a" 12232 ], 12233 "active": true 12234 } 12235 }` 12236 12237 testJSONMarshal(t, u, want) 12238 } 12239 12240 func TestRequestedAction_Marshal(t *testing.T) { 12241 testJSONMarshal(t, &RequestedAction{}, "{}") 12242 12243 r := &RequestedAction{ 12244 Identifier: "i", 12245 } 12246 12247 want := `{ 12248 "identifier": "i" 12249 }` 12250 12251 testJSONMarshal(t, r, want) 12252 } 12253 12254 func TestCreateEvent_Marshal(t *testing.T) { 12255 testJSONMarshal(t, &CreateEvent{}, "{}") 12256 12257 r := &CreateEvent{ 12258 Ref: String("r"), 12259 RefType: String("rt"), 12260 MasterBranch: String("mb"), 12261 Description: String("d"), 12262 PusherType: String("pt"), 12263 Repo: &Repository{ 12264 ID: Int64(1), 12265 URL: String("s"), 12266 Name: String("n"), 12267 }, 12268 Sender: &User{ 12269 Login: String("l"), 12270 ID: Int64(1), 12271 NodeID: String("n"), 12272 URL: String("u"), 12273 ReposURL: String("r"), 12274 EventsURL: String("e"), 12275 AvatarURL: String("a"), 12276 }, 12277 Installation: &Installation{ 12278 ID: Int64(1), 12279 NodeID: String("nid"), 12280 AppID: Int64(1), 12281 AppSlug: String("as"), 12282 TargetID: Int64(1), 12283 Account: &User{ 12284 Login: String("l"), 12285 ID: Int64(1), 12286 URL: String("u"), 12287 AvatarURL: String("a"), 12288 GravatarID: String("g"), 12289 Name: String("n"), 12290 Company: String("c"), 12291 Blog: String("b"), 12292 Location: String("l"), 12293 Email: String("e"), 12294 Hireable: Bool(true), 12295 Bio: String("b"), 12296 TwitterUsername: String("t"), 12297 PublicRepos: Int(1), 12298 Followers: Int(1), 12299 Following: Int(1), 12300 CreatedAt: &Timestamp{referenceTime}, 12301 SuspendedAt: &Timestamp{referenceTime}, 12302 }, 12303 AccessTokensURL: String("atu"), 12304 RepositoriesURL: String("ru"), 12305 HTMLURL: String("hu"), 12306 TargetType: String("tt"), 12307 SingleFileName: String("sfn"), 12308 RepositorySelection: String("rs"), 12309 Events: []string{"e"}, 12310 SingleFilePaths: []string{"s"}, 12311 Permissions: &InstallationPermissions{ 12312 Actions: String("a"), 12313 Administration: String("ad"), 12314 Checks: String("c"), 12315 Contents: String("co"), 12316 ContentReferences: String("cr"), 12317 Deployments: String("d"), 12318 Environments: String("e"), 12319 Issues: String("i"), 12320 Metadata: String("md"), 12321 Members: String("m"), 12322 OrganizationAdministration: String("oa"), 12323 OrganizationHooks: String("oh"), 12324 OrganizationPlan: String("op"), 12325 OrganizationPreReceiveHooks: String("opr"), 12326 OrganizationProjects: String("op"), 12327 OrganizationSecrets: String("os"), 12328 OrganizationSelfHostedRunners: String("osh"), 12329 OrganizationUserBlocking: String("oub"), 12330 Packages: String("pkg"), 12331 Pages: String("pg"), 12332 PullRequests: String("pr"), 12333 RepositoryHooks: String("rh"), 12334 RepositoryProjects: String("rp"), 12335 RepositoryPreReceiveHooks: String("rprh"), 12336 Secrets: String("s"), 12337 SecretScanningAlerts: String("ssa"), 12338 SecurityEvents: String("se"), 12339 SingleFile: String("sf"), 12340 Statuses: String("s"), 12341 TeamDiscussions: String("td"), 12342 VulnerabilityAlerts: String("va"), 12343 Workflows: String("w"), 12344 }, 12345 CreatedAt: &Timestamp{referenceTime}, 12346 UpdatedAt: &Timestamp{referenceTime}, 12347 HasMultipleSingleFiles: Bool(false), 12348 SuspendedBy: &User{ 12349 Login: String("l"), 12350 ID: Int64(1), 12351 URL: String("u"), 12352 AvatarURL: String("a"), 12353 GravatarID: String("g"), 12354 Name: String("n"), 12355 Company: String("c"), 12356 Blog: String("b"), 12357 Location: String("l"), 12358 Email: String("e"), 12359 Hireable: Bool(true), 12360 Bio: String("b"), 12361 TwitterUsername: String("t"), 12362 PublicRepos: Int(1), 12363 Followers: Int(1), 12364 Following: Int(1), 12365 CreatedAt: &Timestamp{referenceTime}, 12366 SuspendedAt: &Timestamp{referenceTime}, 12367 }, 12368 SuspendedAt: &Timestamp{referenceTime}, 12369 }, 12370 } 12371 12372 want := `{ 12373 "ref": "r", 12374 "ref_type": "rt", 12375 "master_branch": "mb", 12376 "description": "d", 12377 "pusher_type": "pt", 12378 "repository": { 12379 "id": 1, 12380 "name": "n", 12381 "url": "s" 12382 }, 12383 "sender": { 12384 "login": "l", 12385 "id": 1, 12386 "node_id": "n", 12387 "avatar_url": "a", 12388 "url": "u", 12389 "events_url": "e", 12390 "repos_url": "r" 12391 }, 12392 "installation": { 12393 "id": 1, 12394 "node_id": "nid", 12395 "app_id": 1, 12396 "app_slug": "as", 12397 "target_id": 1, 12398 "account": { 12399 "login": "l", 12400 "id": 1, 12401 "avatar_url": "a", 12402 "gravatar_id": "g", 12403 "name": "n", 12404 "company": "c", 12405 "blog": "b", 12406 "location": "l", 12407 "email": "e", 12408 "hireable": true, 12409 "bio": "b", 12410 "twitter_username": "t", 12411 "public_repos": 1, 12412 "followers": 1, 12413 "following": 1, 12414 "created_at": ` + referenceTimeStr + `, 12415 "suspended_at": ` + referenceTimeStr + `, 12416 "url": "u" 12417 }, 12418 "access_tokens_url": "atu", 12419 "repositories_url": "ru", 12420 "html_url": "hu", 12421 "target_type": "tt", 12422 "single_file_name": "sfn", 12423 "repository_selection": "rs", 12424 "events": [ 12425 "e" 12426 ], 12427 "single_file_paths": [ 12428 "s" 12429 ], 12430 "permissions": { 12431 "actions": "a", 12432 "administration": "ad", 12433 "checks": "c", 12434 "contents": "co", 12435 "content_references": "cr", 12436 "deployments": "d", 12437 "environments": "e", 12438 "issues": "i", 12439 "metadata": "md", 12440 "members": "m", 12441 "organization_administration": "oa", 12442 "organization_hooks": "oh", 12443 "organization_plan": "op", 12444 "organization_pre_receive_hooks": "opr", 12445 "organization_projects": "op", 12446 "organization_secrets": "os", 12447 "organization_self_hosted_runners": "osh", 12448 "organization_user_blocking": "oub", 12449 "packages": "pkg", 12450 "pages": "pg", 12451 "pull_requests": "pr", 12452 "repository_hooks": "rh", 12453 "repository_projects": "rp", 12454 "repository_pre_receive_hooks": "rprh", 12455 "secrets": "s", 12456 "secret_scanning_alerts": "ssa", 12457 "security_events": "se", 12458 "single_file": "sf", 12459 "statuses": "s", 12460 "team_discussions": "td", 12461 "vulnerability_alerts": "va", 12462 "workflows": "w" 12463 }, 12464 "created_at": ` + referenceTimeStr + `, 12465 "updated_at": ` + referenceTimeStr + `, 12466 "has_multiple_single_files": false, 12467 "suspended_by": { 12468 "login": "l", 12469 "id": 1, 12470 "avatar_url": "a", 12471 "gravatar_id": "g", 12472 "name": "n", 12473 "company": "c", 12474 "blog": "b", 12475 "location": "l", 12476 "email": "e", 12477 "hireable": true, 12478 "bio": "b", 12479 "twitter_username": "t", 12480 "public_repos": 1, 12481 "followers": 1, 12482 "following": 1, 12483 "created_at": ` + referenceTimeStr + `, 12484 "suspended_at": ` + referenceTimeStr + `, 12485 "url": "u" 12486 }, 12487 "suspended_at": ` + referenceTimeStr + ` 12488 } 12489 }` 12490 12491 testJSONMarshal(t, r, want) 12492 } 12493 12494 func TestDeleteEvent_Marshal(t *testing.T) { 12495 testJSONMarshal(t, &DeleteEvent{}, "{}") 12496 12497 r := &DeleteEvent{ 12498 Ref: String("r"), 12499 RefType: String("rt"), 12500 PusherType: String("pt"), 12501 Repo: &Repository{ 12502 ID: Int64(1), 12503 URL: String("s"), 12504 Name: String("n"), 12505 }, 12506 Sender: &User{ 12507 Login: String("l"), 12508 ID: Int64(1), 12509 NodeID: String("n"), 12510 URL: String("u"), 12511 ReposURL: String("r"), 12512 EventsURL: String("e"), 12513 AvatarURL: String("a"), 12514 }, 12515 Installation: &Installation{ 12516 ID: Int64(1), 12517 NodeID: String("nid"), 12518 AppID: Int64(1), 12519 AppSlug: String("as"), 12520 TargetID: Int64(1), 12521 Account: &User{ 12522 Login: String("l"), 12523 ID: Int64(1), 12524 URL: String("u"), 12525 AvatarURL: String("a"), 12526 GravatarID: String("g"), 12527 Name: String("n"), 12528 Company: String("c"), 12529 Blog: String("b"), 12530 Location: String("l"), 12531 Email: String("e"), 12532 Hireable: Bool(true), 12533 Bio: String("b"), 12534 TwitterUsername: String("t"), 12535 PublicRepos: Int(1), 12536 Followers: Int(1), 12537 Following: Int(1), 12538 CreatedAt: &Timestamp{referenceTime}, 12539 SuspendedAt: &Timestamp{referenceTime}, 12540 }, 12541 AccessTokensURL: String("atu"), 12542 RepositoriesURL: String("ru"), 12543 HTMLURL: String("hu"), 12544 TargetType: String("tt"), 12545 SingleFileName: String("sfn"), 12546 RepositorySelection: String("rs"), 12547 Events: []string{"e"}, 12548 SingleFilePaths: []string{"s"}, 12549 Permissions: &InstallationPermissions{ 12550 Actions: String("a"), 12551 Administration: String("ad"), 12552 Checks: String("c"), 12553 Contents: String("co"), 12554 ContentReferences: String("cr"), 12555 Deployments: String("d"), 12556 Environments: String("e"), 12557 Issues: String("i"), 12558 Metadata: String("md"), 12559 Members: String("m"), 12560 OrganizationAdministration: String("oa"), 12561 OrganizationHooks: String("oh"), 12562 OrganizationPlan: String("op"), 12563 OrganizationPreReceiveHooks: String("opr"), 12564 OrganizationProjects: String("op"), 12565 OrganizationSecrets: String("os"), 12566 OrganizationSelfHostedRunners: String("osh"), 12567 OrganizationUserBlocking: String("oub"), 12568 Packages: String("pkg"), 12569 Pages: String("pg"), 12570 PullRequests: String("pr"), 12571 RepositoryHooks: String("rh"), 12572 RepositoryProjects: String("rp"), 12573 RepositoryPreReceiveHooks: String("rprh"), 12574 Secrets: String("s"), 12575 SecretScanningAlerts: String("ssa"), 12576 SecurityEvents: String("se"), 12577 SingleFile: String("sf"), 12578 Statuses: String("s"), 12579 TeamDiscussions: String("td"), 12580 VulnerabilityAlerts: String("va"), 12581 Workflows: String("w"), 12582 }, 12583 CreatedAt: &Timestamp{referenceTime}, 12584 UpdatedAt: &Timestamp{referenceTime}, 12585 HasMultipleSingleFiles: Bool(false), 12586 SuspendedBy: &User{ 12587 Login: String("l"), 12588 ID: Int64(1), 12589 URL: String("u"), 12590 AvatarURL: String("a"), 12591 GravatarID: String("g"), 12592 Name: String("n"), 12593 Company: String("c"), 12594 Blog: String("b"), 12595 Location: String("l"), 12596 Email: String("e"), 12597 Hireable: Bool(true), 12598 Bio: String("b"), 12599 TwitterUsername: String("t"), 12600 PublicRepos: Int(1), 12601 Followers: Int(1), 12602 Following: Int(1), 12603 CreatedAt: &Timestamp{referenceTime}, 12604 SuspendedAt: &Timestamp{referenceTime}, 12605 }, 12606 SuspendedAt: &Timestamp{referenceTime}, 12607 }, 12608 } 12609 12610 want := `{ 12611 "ref": "r", 12612 "ref_type": "rt", 12613 "pusher_type": "pt", 12614 "repository": { 12615 "id": 1, 12616 "name": "n", 12617 "url": "s" 12618 }, 12619 "sender": { 12620 "login": "l", 12621 "id": 1, 12622 "node_id": "n", 12623 "avatar_url": "a", 12624 "url": "u", 12625 "events_url": "e", 12626 "repos_url": "r" 12627 }, 12628 "installation": { 12629 "id": 1, 12630 "node_id": "nid", 12631 "app_id": 1, 12632 "app_slug": "as", 12633 "target_id": 1, 12634 "account": { 12635 "login": "l", 12636 "id": 1, 12637 "avatar_url": "a", 12638 "gravatar_id": "g", 12639 "name": "n", 12640 "company": "c", 12641 "blog": "b", 12642 "location": "l", 12643 "email": "e", 12644 "hireable": true, 12645 "bio": "b", 12646 "twitter_username": "t", 12647 "public_repos": 1, 12648 "followers": 1, 12649 "following": 1, 12650 "created_at": ` + referenceTimeStr + `, 12651 "suspended_at": ` + referenceTimeStr + `, 12652 "url": "u" 12653 }, 12654 "access_tokens_url": "atu", 12655 "repositories_url": "ru", 12656 "html_url": "hu", 12657 "target_type": "tt", 12658 "single_file_name": "sfn", 12659 "repository_selection": "rs", 12660 "events": [ 12661 "e" 12662 ], 12663 "single_file_paths": [ 12664 "s" 12665 ], 12666 "permissions": { 12667 "actions": "a", 12668 "administration": "ad", 12669 "checks": "c", 12670 "contents": "co", 12671 "content_references": "cr", 12672 "deployments": "d", 12673 "environments": "e", 12674 "issues": "i", 12675 "metadata": "md", 12676 "members": "m", 12677 "organization_administration": "oa", 12678 "organization_hooks": "oh", 12679 "organization_plan": "op", 12680 "organization_pre_receive_hooks": "opr", 12681 "organization_projects": "op", 12682 "organization_secrets": "os", 12683 "organization_self_hosted_runners": "osh", 12684 "organization_user_blocking": "oub", 12685 "packages": "pkg", 12686 "pages": "pg", 12687 "pull_requests": "pr", 12688 "repository_hooks": "rh", 12689 "repository_projects": "rp", 12690 "repository_pre_receive_hooks": "rprh", 12691 "secrets": "s", 12692 "secret_scanning_alerts": "ssa", 12693 "security_events": "se", 12694 "single_file": "sf", 12695 "statuses": "s", 12696 "team_discussions": "td", 12697 "vulnerability_alerts": "va", 12698 "workflows": "w" 12699 }, 12700 "created_at": ` + referenceTimeStr + `, 12701 "updated_at": ` + referenceTimeStr + `, 12702 "has_multiple_single_files": false, 12703 "suspended_by": { 12704 "login": "l", 12705 "id": 1, 12706 "avatar_url": "a", 12707 "gravatar_id": "g", 12708 "name": "n", 12709 "company": "c", 12710 "blog": "b", 12711 "location": "l", 12712 "email": "e", 12713 "hireable": true, 12714 "bio": "b", 12715 "twitter_username": "t", 12716 "public_repos": 1, 12717 "followers": 1, 12718 "following": 1, 12719 "created_at": ` + referenceTimeStr + `, 12720 "suspended_at": ` + referenceTimeStr + `, 12721 "url": "u" 12722 }, 12723 "suspended_at": ` + referenceTimeStr + ` 12724 } 12725 }` 12726 12727 testJSONMarshal(t, r, want) 12728 } 12729 12730 func TestDependabotAlertEvent_Marshal(t *testing.T) { 12731 testJSONMarshal(t, &DependabotAlertEvent{}, "{}") 12732 12733 e := &DependabotAlertEvent{ 12734 Action: String("a"), 12735 Alert: &DependabotAlert{ 12736 Number: Int(1), 12737 State: String("s"), 12738 Dependency: &Dependency{ 12739 Package: &VulnerabilityPackage{ 12740 Ecosystem: String("e"), 12741 Name: String("n"), 12742 }, 12743 ManifestPath: String("mp"), 12744 Scope: String("s"), 12745 }, 12746 SecurityAdvisory: &DependabotSecurityAdvisory{ 12747 GHSAID: String("ghsaid"), 12748 CVEID: String("cveid"), 12749 Summary: String("s"), 12750 Description: String("d"), 12751 Vulnerabilities: []*AdvisoryVulnerability{ 12752 { 12753 Package: &VulnerabilityPackage{ 12754 Ecosystem: String("e"), 12755 Name: String("n"), 12756 }, 12757 Severity: String("s"), 12758 }, 12759 }, 12760 Severity: String("s"), 12761 CVSS: &AdvisoryCVSS{ 12762 Score: Float64(1.0), 12763 VectorString: String("vs"), 12764 }, 12765 CWEs: []*AdvisoryCWEs{ 12766 { 12767 CWEID: String("cweid"), 12768 Name: String("n"), 12769 }, 12770 }, 12771 Identifiers: []*AdvisoryIdentifier{ 12772 { 12773 Value: String("v"), 12774 Type: String("t"), 12775 }, 12776 }, 12777 References: []*AdvisoryReference{ 12778 { 12779 URL: String("u"), 12780 }, 12781 }, 12782 PublishedAt: &Timestamp{referenceTime}, 12783 UpdatedAt: &Timestamp{referenceTime}, 12784 WithdrawnAt: &Timestamp{referenceTime}, 12785 }, 12786 SecurityVulnerability: &AdvisoryVulnerability{ 12787 Package: &VulnerabilityPackage{ 12788 Ecosystem: String("e"), 12789 Name: String("n"), 12790 }, 12791 Severity: String("s"), 12792 VulnerableVersionRange: String("vvr"), 12793 FirstPatchedVersion: &FirstPatchedVersion{ 12794 Identifier: String("i"), 12795 }, 12796 }, 12797 URL: String("u"), 12798 HTMLURL: String("hu"), 12799 CreatedAt: &Timestamp{referenceTime}, 12800 UpdatedAt: &Timestamp{referenceTime}, 12801 DismissedAt: &Timestamp{referenceTime}, 12802 DismissedBy: &User{ 12803 Login: String("l"), 12804 ID: Int64(1), 12805 NodeID: String("n"), 12806 URL: String("u"), 12807 ReposURL: String("r"), 12808 EventsURL: String("e"), 12809 AvatarURL: String("a"), 12810 }, 12811 DismissedReason: String("dr"), 12812 DismissedComment: String("dc"), 12813 FixedAt: &Timestamp{referenceTime}, 12814 AutoDismissedAt: &Timestamp{referenceTime}, 12815 }, 12816 Repo: &Repository{ 12817 ID: Int64(1), 12818 URL: String("s"), 12819 Name: String("n"), 12820 }, 12821 Organization: &Organization{ 12822 BillingEmail: String("be"), 12823 Blog: String("b"), 12824 Company: String("c"), 12825 Email: String("e"), 12826 TwitterUsername: String("tu"), 12827 Location: String("loc"), 12828 Name: String("n"), 12829 Description: String("d"), 12830 IsVerified: Bool(true), 12831 HasOrganizationProjects: Bool(true), 12832 HasRepositoryProjects: Bool(true), 12833 DefaultRepoPermission: String("drp"), 12834 MembersCanCreateRepos: Bool(true), 12835 MembersCanCreateInternalRepos: Bool(true), 12836 MembersCanCreatePrivateRepos: Bool(true), 12837 MembersCanCreatePublicRepos: Bool(false), 12838 MembersAllowedRepositoryCreationType: String("marct"), 12839 MembersCanCreatePages: Bool(true), 12840 MembersCanCreatePublicPages: Bool(false), 12841 MembersCanCreatePrivatePages: Bool(true), 12842 }, 12843 Enterprise: &Enterprise{ 12844 ID: Int(1), 12845 Slug: String("s"), 12846 Name: String("n"), 12847 NodeID: String("nid"), 12848 AvatarURL: String("au"), 12849 Description: String("d"), 12850 WebsiteURL: String("wu"), 12851 HTMLURL: String("hu"), 12852 CreatedAt: &Timestamp{referenceTime}, 12853 UpdatedAt: &Timestamp{referenceTime}, 12854 }, 12855 Sender: &User{ 12856 Login: String("l"), 12857 ID: Int64(1), 12858 NodeID: String("n"), 12859 URL: String("u"), 12860 ReposURL: String("r"), 12861 EventsURL: String("e"), 12862 AvatarURL: String("a"), 12863 }, 12864 Installation: &Installation{ 12865 ID: Int64(1), 12866 NodeID: String("nid"), 12867 AppID: Int64(1), 12868 AppSlug: String("as"), 12869 TargetID: Int64(1), 12870 Account: &User{ 12871 Login: String("l"), 12872 ID: Int64(1), 12873 URL: String("u"), 12874 AvatarURL: String("a"), 12875 GravatarID: String("g"), 12876 Name: String("n"), 12877 Company: String("c"), 12878 Blog: String("b"), 12879 Location: String("l"), 12880 Email: String("e"), 12881 Hireable: Bool(true), 12882 Bio: String("b"), 12883 TwitterUsername: String("t"), 12884 PublicRepos: Int(1), 12885 Followers: Int(1), 12886 Following: Int(1), 12887 CreatedAt: &Timestamp{referenceTime}, 12888 SuspendedAt: &Timestamp{referenceTime}, 12889 }, 12890 AccessTokensURL: String("atu"), 12891 RepositoriesURL: String("ru"), 12892 HTMLURL: String("hu"), 12893 TargetType: String("tt"), 12894 SingleFileName: String("sfn"), 12895 RepositorySelection: String("rs"), 12896 Events: []string{"e"}, 12897 SingleFilePaths: []string{"s"}, 12898 Permissions: &InstallationPermissions{ 12899 Actions: String("a"), 12900 Administration: String("ad"), 12901 Checks: String("c"), 12902 Contents: String("co"), 12903 ContentReferences: String("cr"), 12904 Deployments: String("d"), 12905 Environments: String("e"), 12906 Issues: String("i"), 12907 Metadata: String("md"), 12908 Members: String("m"), 12909 OrganizationAdministration: String("oa"), 12910 OrganizationHooks: String("oh"), 12911 OrganizationPlan: String("op"), 12912 OrganizationPreReceiveHooks: String("opr"), 12913 OrganizationProjects: String("op"), 12914 OrganizationSecrets: String("os"), 12915 OrganizationSelfHostedRunners: String("osh"), 12916 OrganizationUserBlocking: String("oub"), 12917 Packages: String("pkg"), 12918 Pages: String("pg"), 12919 PullRequests: String("pr"), 12920 RepositoryHooks: String("rh"), 12921 RepositoryProjects: String("rp"), 12922 RepositoryPreReceiveHooks: String("rprh"), 12923 Secrets: String("s"), 12924 SecretScanningAlerts: String("ssa"), 12925 SecurityEvents: String("se"), 12926 SingleFile: String("sf"), 12927 Statuses: String("s"), 12928 TeamDiscussions: String("td"), 12929 VulnerabilityAlerts: String("va"), 12930 Workflows: String("w"), 12931 }, 12932 CreatedAt: &Timestamp{referenceTime}, 12933 UpdatedAt: &Timestamp{referenceTime}, 12934 HasMultipleSingleFiles: Bool(false), 12935 SuspendedBy: &User{ 12936 Login: String("l"), 12937 ID: Int64(1), 12938 URL: String("u"), 12939 AvatarURL: String("a"), 12940 GravatarID: String("g"), 12941 Name: String("n"), 12942 Company: String("c"), 12943 Blog: String("b"), 12944 Location: String("l"), 12945 Email: String("e"), 12946 Hireable: Bool(true), 12947 Bio: String("b"), 12948 TwitterUsername: String("t"), 12949 PublicRepos: Int(1), 12950 Followers: Int(1), 12951 Following: Int(1), 12952 CreatedAt: &Timestamp{referenceTime}, 12953 SuspendedAt: &Timestamp{referenceTime}, 12954 }, 12955 SuspendedAt: &Timestamp{referenceTime}, 12956 }, 12957 } 12958 want := `{ 12959 "action": "a", 12960 "alert": { 12961 "number": 1, 12962 "state": "s", 12963 "dependency": { 12964 "package": { 12965 "ecosystem": "e", 12966 "name": "n" 12967 }, 12968 "manifest_path": "mp", 12969 "scope": "s" 12970 }, 12971 "security_advisory": { 12972 "ghsa_id": "ghsaid", 12973 "cve_id": "cveid", 12974 "summary": "s", 12975 "description": "d", 12976 "vulnerabilities": [ 12977 { 12978 "package": { 12979 "ecosystem": "e", 12980 "name": "n" 12981 }, 12982 "severity": "s" 12983 } 12984 ], 12985 "severity": "s", 12986 "cvss": { 12987 "score": 1.0, 12988 "vector_string": "vs" 12989 }, 12990 "cwes": [ 12991 { 12992 "cwe_id": "cweid", 12993 "name": "n" 12994 } 12995 ], 12996 "identifiers": [ 12997 { 12998 "value": "v", 12999 "type": "t" 13000 } 13001 ], 13002 "references": [ 13003 { 13004 "url": "u" 13005 } 13006 ], 13007 "published_at": ` + referenceTimeStr + `, 13008 "updated_at": ` + referenceTimeStr + `, 13009 "withdrawn_at": ` + referenceTimeStr + ` 13010 }, 13011 "security_vulnerability": { 13012 "package": { 13013 "ecosystem": "e", 13014 "name": "n" 13015 }, 13016 "severity": "s", 13017 "vulnerable_version_range": "vvr", 13018 "first_patched_version": { 13019 "identifier": "i" 13020 } 13021 }, 13022 "url": "u", 13023 "html_url": "hu", 13024 "created_at": ` + referenceTimeStr + `, 13025 "updated_at": ` + referenceTimeStr + `, 13026 "dismissed_at": ` + referenceTimeStr + `, 13027 "dismissed_by": { 13028 "login": "l", 13029 "id": 1, 13030 "node_id": "n", 13031 "avatar_url": "a", 13032 "url": "u", 13033 "events_url": "e", 13034 "repos_url": "r" 13035 }, 13036 "dismissed_reason": "dr", 13037 "dismissed_comment": "dc", 13038 "fixed_at": ` + referenceTimeStr + `, 13039 "auto_dismissed_at": ` + referenceTimeStr + ` 13040 }, 13041 "repository": { 13042 "id": 1, 13043 "name": "n", 13044 "url": "s" 13045 }, 13046 "organization": { 13047 "name": "n", 13048 "company": "c", 13049 "blog": "b", 13050 "location": "loc", 13051 "email": "e", 13052 "twitter_username": "tu", 13053 "description": "d", 13054 "billing_email": "be", 13055 "is_verified": true, 13056 "has_organization_projects": true, 13057 "has_repository_projects": true, 13058 "default_repository_permission": "drp", 13059 "members_can_create_repositories": true, 13060 "members_can_create_public_repositories": false, 13061 "members_can_create_private_repositories": true, 13062 "members_can_create_internal_repositories": true, 13063 "members_allowed_repository_creation_type": "marct", 13064 "members_can_create_pages": true, 13065 "members_can_create_public_pages": false, 13066 "members_can_create_private_pages": true 13067 }, 13068 "enterprise": { 13069 "id": 1, 13070 "slug": "s", 13071 "name": "n", 13072 "node_id": "nid", 13073 "avatar_url": "au", 13074 "description": "d", 13075 "website_url": "wu", 13076 "html_url": "hu", 13077 "created_at": ` + referenceTimeStr + `, 13078 "updated_at": ` + referenceTimeStr + ` 13079 }, 13080 "sender": { 13081 "login": "l", 13082 "id": 1, 13083 "node_id": "n", 13084 "avatar_url": "a", 13085 "url": "u", 13086 "events_url": "e", 13087 "repos_url": "r" 13088 }, 13089 "installation": { 13090 "id": 1, 13091 "node_id": "nid", 13092 "app_id": 1, 13093 "app_slug": "as", 13094 "target_id": 1, 13095 "account": { 13096 "login": "l", 13097 "id": 1, 13098 "avatar_url": "a", 13099 "gravatar_id": "g", 13100 "name": "n", 13101 "company": "c", 13102 "blog": "b", 13103 "location": "l", 13104 "email": "e", 13105 "hireable": true, 13106 "bio": "b", 13107 "twitter_username": "t", 13108 "public_repos": 1, 13109 "followers": 1, 13110 "following": 1, 13111 "created_at": ` + referenceTimeStr + `, 13112 "suspended_at": ` + referenceTimeStr + `, 13113 "url": "u" 13114 }, 13115 "access_tokens_url": "atu", 13116 "repositories_url": "ru", 13117 "html_url": "hu", 13118 "target_type": "tt", 13119 "single_file_name": "sfn", 13120 "repository_selection": "rs", 13121 "events": [ 13122 "e" 13123 ], 13124 "single_file_paths": [ 13125 "s" 13126 ], 13127 "permissions": { 13128 "actions": "a", 13129 "administration": "ad", 13130 "checks": "c", 13131 "contents": "co", 13132 "content_references": "cr", 13133 "deployments": "d", 13134 "environments": "e", 13135 "issues": "i", 13136 "metadata": "md", 13137 "members": "m", 13138 "organization_administration": "oa", 13139 "organization_hooks": "oh", 13140 "organization_plan": "op", 13141 "organization_pre_receive_hooks": "opr", 13142 "organization_projects": "op", 13143 "organization_secrets": "os", 13144 "organization_self_hosted_runners": "osh", 13145 "organization_user_blocking": "oub", 13146 "packages": "pkg", 13147 "pages": "pg", 13148 "pull_requests": "pr", 13149 "repository_hooks": "rh", 13150 "repository_projects": "rp", 13151 "repository_pre_receive_hooks": "rprh", 13152 "secrets": "s", 13153 "secret_scanning_alerts": "ssa", 13154 "security_events": "se", 13155 "single_file": "sf", 13156 "statuses": "s", 13157 "team_discussions": "td", 13158 "vulnerability_alerts": "va", 13159 "workflows": "w" 13160 }, 13161 "created_at": ` + referenceTimeStr + `, 13162 "updated_at": ` + referenceTimeStr + `, 13163 "has_multiple_single_files": false, 13164 "suspended_by": { 13165 "login": "l", 13166 "id": 1, 13167 "avatar_url": "a", 13168 "gravatar_id": "g", 13169 "name": "n", 13170 "company": "c", 13171 "blog": "b", 13172 "location": "l", 13173 "email": "e", 13174 "hireable": true, 13175 "bio": "b", 13176 "twitter_username": "t", 13177 "public_repos": 1, 13178 "followers": 1, 13179 "following": 1, 13180 "created_at": ` + referenceTimeStr + `, 13181 "suspended_at": ` + referenceTimeStr + `, 13182 "url": "u" 13183 }, 13184 "suspended_at": ` + referenceTimeStr + ` 13185 } 13186 }` 13187 13188 testJSONMarshal(t, e, want) 13189 } 13190 13191 func TestForkEvent_Marshal(t *testing.T) { 13192 testJSONMarshal(t, &ForkEvent{}, "{}") 13193 13194 u := &ForkEvent{ 13195 Forkee: &Repository{ 13196 ID: Int64(1), 13197 URL: String("s"), 13198 Name: String("n"), 13199 }, 13200 Repo: &Repository{ 13201 ID: Int64(1), 13202 URL: String("s"), 13203 Name: String("n"), 13204 }, 13205 Sender: &User{ 13206 Login: String("l"), 13207 ID: Int64(1), 13208 NodeID: String("n"), 13209 URL: String("u"), 13210 ReposURL: String("r"), 13211 EventsURL: String("e"), 13212 AvatarURL: String("a"), 13213 }, 13214 Installation: &Installation{ 13215 ID: Int64(1), 13216 NodeID: String("nid"), 13217 AppID: Int64(1), 13218 AppSlug: String("as"), 13219 TargetID: Int64(1), 13220 Account: &User{ 13221 Login: String("l"), 13222 ID: Int64(1), 13223 URL: String("u"), 13224 AvatarURL: String("a"), 13225 GravatarID: String("g"), 13226 Name: String("n"), 13227 Company: String("c"), 13228 Blog: String("b"), 13229 Location: String("l"), 13230 Email: String("e"), 13231 Hireable: Bool(true), 13232 Bio: String("b"), 13233 TwitterUsername: String("t"), 13234 PublicRepos: Int(1), 13235 Followers: Int(1), 13236 Following: Int(1), 13237 CreatedAt: &Timestamp{referenceTime}, 13238 SuspendedAt: &Timestamp{referenceTime}, 13239 }, 13240 AccessTokensURL: String("atu"), 13241 RepositoriesURL: String("ru"), 13242 HTMLURL: String("hu"), 13243 TargetType: String("tt"), 13244 SingleFileName: String("sfn"), 13245 RepositorySelection: String("rs"), 13246 Events: []string{"e"}, 13247 SingleFilePaths: []string{"s"}, 13248 Permissions: &InstallationPermissions{ 13249 Actions: String("a"), 13250 Administration: String("ad"), 13251 Checks: String("c"), 13252 Contents: String("co"), 13253 ContentReferences: String("cr"), 13254 Deployments: String("d"), 13255 Environments: String("e"), 13256 Issues: String("i"), 13257 Metadata: String("md"), 13258 Members: String("m"), 13259 OrganizationAdministration: String("oa"), 13260 OrganizationHooks: String("oh"), 13261 OrganizationPlan: String("op"), 13262 OrganizationPreReceiveHooks: String("opr"), 13263 OrganizationProjects: String("op"), 13264 OrganizationSecrets: String("os"), 13265 OrganizationSelfHostedRunners: String("osh"), 13266 OrganizationUserBlocking: String("oub"), 13267 Packages: String("pkg"), 13268 Pages: String("pg"), 13269 PullRequests: String("pr"), 13270 RepositoryHooks: String("rh"), 13271 RepositoryProjects: String("rp"), 13272 RepositoryPreReceiveHooks: String("rprh"), 13273 Secrets: String("s"), 13274 SecretScanningAlerts: String("ssa"), 13275 SecurityEvents: String("se"), 13276 SingleFile: String("sf"), 13277 Statuses: String("s"), 13278 TeamDiscussions: String("td"), 13279 VulnerabilityAlerts: String("va"), 13280 Workflows: String("w"), 13281 }, 13282 CreatedAt: &Timestamp{referenceTime}, 13283 UpdatedAt: &Timestamp{referenceTime}, 13284 HasMultipleSingleFiles: Bool(false), 13285 SuspendedBy: &User{ 13286 Login: String("l"), 13287 ID: Int64(1), 13288 URL: String("u"), 13289 AvatarURL: String("a"), 13290 GravatarID: String("g"), 13291 Name: String("n"), 13292 Company: String("c"), 13293 Blog: String("b"), 13294 Location: String("l"), 13295 Email: String("e"), 13296 Hireable: Bool(true), 13297 Bio: String("b"), 13298 TwitterUsername: String("t"), 13299 PublicRepos: Int(1), 13300 Followers: Int(1), 13301 Following: Int(1), 13302 CreatedAt: &Timestamp{referenceTime}, 13303 SuspendedAt: &Timestamp{referenceTime}, 13304 }, 13305 SuspendedAt: &Timestamp{referenceTime}, 13306 }, 13307 } 13308 13309 want := `{ 13310 "forkee": { 13311 "id": 1, 13312 "name": "n", 13313 "url": "s" 13314 }, 13315 "repository": { 13316 "id": 1, 13317 "name": "n", 13318 "url": "s" 13319 }, 13320 "sender": { 13321 "login": "l", 13322 "id": 1, 13323 "node_id": "n", 13324 "avatar_url": "a", 13325 "url": "u", 13326 "events_url": "e", 13327 "repos_url": "r" 13328 }, 13329 "installation": { 13330 "id": 1, 13331 "node_id": "nid", 13332 "app_id": 1, 13333 "app_slug": "as", 13334 "target_id": 1, 13335 "account": { 13336 "login": "l", 13337 "id": 1, 13338 "avatar_url": "a", 13339 "gravatar_id": "g", 13340 "name": "n", 13341 "company": "c", 13342 "blog": "b", 13343 "location": "l", 13344 "email": "e", 13345 "hireable": true, 13346 "bio": "b", 13347 "twitter_username": "t", 13348 "public_repos": 1, 13349 "followers": 1, 13350 "following": 1, 13351 "created_at": ` + referenceTimeStr + `, 13352 "suspended_at": ` + referenceTimeStr + `, 13353 "url": "u" 13354 }, 13355 "access_tokens_url": "atu", 13356 "repositories_url": "ru", 13357 "html_url": "hu", 13358 "target_type": "tt", 13359 "single_file_name": "sfn", 13360 "repository_selection": "rs", 13361 "events": [ 13362 "e" 13363 ], 13364 "single_file_paths": [ 13365 "s" 13366 ], 13367 "permissions": { 13368 "actions": "a", 13369 "administration": "ad", 13370 "checks": "c", 13371 "contents": "co", 13372 "content_references": "cr", 13373 "deployments": "d", 13374 "environments": "e", 13375 "issues": "i", 13376 "metadata": "md", 13377 "members": "m", 13378 "organization_administration": "oa", 13379 "organization_hooks": "oh", 13380 "organization_plan": "op", 13381 "organization_pre_receive_hooks": "opr", 13382 "organization_projects": "op", 13383 "organization_secrets": "os", 13384 "organization_self_hosted_runners": "osh", 13385 "organization_user_blocking": "oub", 13386 "packages": "pkg", 13387 "pages": "pg", 13388 "pull_requests": "pr", 13389 "repository_hooks": "rh", 13390 "repository_projects": "rp", 13391 "repository_pre_receive_hooks": "rprh", 13392 "secrets": "s", 13393 "secret_scanning_alerts": "ssa", 13394 "security_events": "se", 13395 "single_file": "sf", 13396 "statuses": "s", 13397 "team_discussions": "td", 13398 "vulnerability_alerts": "va", 13399 "workflows": "w" 13400 }, 13401 "created_at": ` + referenceTimeStr + `, 13402 "updated_at": ` + referenceTimeStr + `, 13403 "has_multiple_single_files": false, 13404 "suspended_by": { 13405 "login": "l", 13406 "id": 1, 13407 "avatar_url": "a", 13408 "gravatar_id": "g", 13409 "name": "n", 13410 "company": "c", 13411 "blog": "b", 13412 "location": "l", 13413 "email": "e", 13414 "hireable": true, 13415 "bio": "b", 13416 "twitter_username": "t", 13417 "public_repos": 1, 13418 "followers": 1, 13419 "following": 1, 13420 "created_at": ` + referenceTimeStr + `, 13421 "suspended_at": ` + referenceTimeStr + `, 13422 "url": "u" 13423 }, 13424 "suspended_at": ` + referenceTimeStr + ` 13425 } 13426 }` 13427 13428 testJSONMarshal(t, u, want) 13429 } 13430 13431 func TestGitHubAppAuthorizationEvent_Marshal(t *testing.T) { 13432 testJSONMarshal(t, &GitHubAppAuthorizationEvent{}, "{}") 13433 13434 u := &GitHubAppAuthorizationEvent{ 13435 Action: String("a"), 13436 Sender: &User{ 13437 Login: String("l"), 13438 ID: Int64(1), 13439 NodeID: String("n"), 13440 URL: String("u"), 13441 ReposURL: String("r"), 13442 EventsURL: String("e"), 13443 AvatarURL: String("a"), 13444 }, 13445 } 13446 13447 want := `{ 13448 "action": "a", 13449 "sender": { 13450 "login": "l", 13451 "id": 1, 13452 "node_id": "n", 13453 "avatar_url": "a", 13454 "url": "u", 13455 "events_url": "e", 13456 "repos_url": "r" 13457 } 13458 }` 13459 13460 testJSONMarshal(t, u, want) 13461 } 13462 13463 func TestInstallationEvent_Marshal(t *testing.T) { 13464 testJSONMarshal(t, &InstallationEvent{}, "{}") 13465 13466 u := &InstallationEvent{ 13467 Action: String("a"), 13468 Repositories: []*Repository{ 13469 { 13470 ID: Int64(1), 13471 URL: String("u"), 13472 Name: String("n"), 13473 }, 13474 }, 13475 Sender: &User{ 13476 Login: String("l"), 13477 ID: Int64(1), 13478 NodeID: String("n"), 13479 URL: String("u"), 13480 ReposURL: String("r"), 13481 EventsURL: String("e"), 13482 AvatarURL: String("a"), 13483 }, 13484 Installation: &Installation{ 13485 ID: Int64(1), 13486 NodeID: String("nid"), 13487 AppID: Int64(1), 13488 AppSlug: String("as"), 13489 TargetID: Int64(1), 13490 Account: &User{ 13491 Login: String("l"), 13492 ID: Int64(1), 13493 URL: String("u"), 13494 AvatarURL: String("a"), 13495 GravatarID: String("g"), 13496 Name: String("n"), 13497 Company: String("c"), 13498 Blog: String("b"), 13499 Location: String("l"), 13500 Email: String("e"), 13501 Hireable: Bool(true), 13502 Bio: String("b"), 13503 TwitterUsername: String("t"), 13504 PublicRepos: Int(1), 13505 Followers: Int(1), 13506 Following: Int(1), 13507 CreatedAt: &Timestamp{referenceTime}, 13508 SuspendedAt: &Timestamp{referenceTime}, 13509 }, 13510 AccessTokensURL: String("atu"), 13511 RepositoriesURL: String("ru"), 13512 HTMLURL: String("hu"), 13513 TargetType: String("tt"), 13514 SingleFileName: String("sfn"), 13515 RepositorySelection: String("rs"), 13516 Events: []string{"e"}, 13517 SingleFilePaths: []string{"s"}, 13518 Permissions: &InstallationPermissions{ 13519 Actions: String("a"), 13520 Administration: String("ad"), 13521 Checks: String("c"), 13522 Contents: String("co"), 13523 ContentReferences: String("cr"), 13524 Deployments: String("d"), 13525 Environments: String("e"), 13526 Issues: String("i"), 13527 Metadata: String("md"), 13528 Members: String("m"), 13529 OrganizationAdministration: String("oa"), 13530 OrganizationHooks: String("oh"), 13531 OrganizationPlan: String("op"), 13532 OrganizationPreReceiveHooks: String("opr"), 13533 OrganizationProjects: String("op"), 13534 OrganizationSecrets: String("os"), 13535 OrganizationSelfHostedRunners: String("osh"), 13536 OrganizationUserBlocking: String("oub"), 13537 Packages: String("pkg"), 13538 Pages: String("pg"), 13539 PullRequests: String("pr"), 13540 RepositoryHooks: String("rh"), 13541 RepositoryProjects: String("rp"), 13542 RepositoryPreReceiveHooks: String("rprh"), 13543 Secrets: String("s"), 13544 SecretScanningAlerts: String("ssa"), 13545 SecurityEvents: String("se"), 13546 SingleFile: String("sf"), 13547 Statuses: String("s"), 13548 TeamDiscussions: String("td"), 13549 VulnerabilityAlerts: String("va"), 13550 Workflows: String("w"), 13551 }, 13552 CreatedAt: &Timestamp{referenceTime}, 13553 UpdatedAt: &Timestamp{referenceTime}, 13554 HasMultipleSingleFiles: Bool(false), 13555 SuspendedBy: &User{ 13556 Login: String("l"), 13557 ID: Int64(1), 13558 URL: String("u"), 13559 AvatarURL: String("a"), 13560 GravatarID: String("g"), 13561 Name: String("n"), 13562 Company: String("c"), 13563 Blog: String("b"), 13564 Location: String("l"), 13565 Email: String("e"), 13566 Hireable: Bool(true), 13567 Bio: String("b"), 13568 TwitterUsername: String("t"), 13569 PublicRepos: Int(1), 13570 Followers: Int(1), 13571 Following: Int(1), 13572 CreatedAt: &Timestamp{referenceTime}, 13573 SuspendedAt: &Timestamp{referenceTime}, 13574 }, 13575 SuspendedAt: &Timestamp{referenceTime}, 13576 }, 13577 } 13578 13579 want := `{ 13580 "action": "a", 13581 "repositories": [ 13582 { 13583 "id":1, 13584 "name":"n", 13585 "url":"u" 13586 } 13587 ], 13588 "sender": { 13589 "login": "l", 13590 "id": 1, 13591 "node_id": "n", 13592 "avatar_url": "a", 13593 "url": "u", 13594 "events_url": "e", 13595 "repos_url": "r" 13596 }, 13597 "installation": { 13598 "id": 1, 13599 "node_id": "nid", 13600 "app_id": 1, 13601 "app_slug": "as", 13602 "target_id": 1, 13603 "account": { 13604 "login": "l", 13605 "id": 1, 13606 "avatar_url": "a", 13607 "gravatar_id": "g", 13608 "name": "n", 13609 "company": "c", 13610 "blog": "b", 13611 "location": "l", 13612 "email": "e", 13613 "hireable": true, 13614 "bio": "b", 13615 "twitter_username": "t", 13616 "public_repos": 1, 13617 "followers": 1, 13618 "following": 1, 13619 "created_at": ` + referenceTimeStr + `, 13620 "suspended_at": ` + referenceTimeStr + `, 13621 "url": "u" 13622 }, 13623 "access_tokens_url": "atu", 13624 "repositories_url": "ru", 13625 "html_url": "hu", 13626 "target_type": "tt", 13627 "single_file_name": "sfn", 13628 "repository_selection": "rs", 13629 "events": [ 13630 "e" 13631 ], 13632 "single_file_paths": [ 13633 "s" 13634 ], 13635 "permissions": { 13636 "actions": "a", 13637 "administration": "ad", 13638 "checks": "c", 13639 "contents": "co", 13640 "content_references": "cr", 13641 "deployments": "d", 13642 "environments": "e", 13643 "issues": "i", 13644 "metadata": "md", 13645 "members": "m", 13646 "organization_administration": "oa", 13647 "organization_hooks": "oh", 13648 "organization_plan": "op", 13649 "organization_pre_receive_hooks": "opr", 13650 "organization_projects": "op", 13651 "organization_secrets": "os", 13652 "organization_self_hosted_runners": "osh", 13653 "organization_user_blocking": "oub", 13654 "packages": "pkg", 13655 "pages": "pg", 13656 "pull_requests": "pr", 13657 "repository_hooks": "rh", 13658 "repository_projects": "rp", 13659 "repository_pre_receive_hooks": "rprh", 13660 "secrets": "s", 13661 "secret_scanning_alerts": "ssa", 13662 "security_events": "se", 13663 "single_file": "sf", 13664 "statuses": "s", 13665 "team_discussions": "td", 13666 "vulnerability_alerts": "va", 13667 "workflows": "w" 13668 }, 13669 "created_at": ` + referenceTimeStr + `, 13670 "updated_at": ` + referenceTimeStr + `, 13671 "has_multiple_single_files": false, 13672 "suspended_by": { 13673 "login": "l", 13674 "id": 1, 13675 "avatar_url": "a", 13676 "gravatar_id": "g", 13677 "name": "n", 13678 "company": "c", 13679 "blog": "b", 13680 "location": "l", 13681 "email": "e", 13682 "hireable": true, 13683 "bio": "b", 13684 "twitter_username": "t", 13685 "public_repos": 1, 13686 "followers": 1, 13687 "following": 1, 13688 "created_at": ` + referenceTimeStr + `, 13689 "suspended_at": ` + referenceTimeStr + `, 13690 "url": "u" 13691 }, 13692 "suspended_at": ` + referenceTimeStr + ` 13693 } 13694 }` 13695 13696 testJSONMarshal(t, u, want) 13697 } 13698 13699 func TestHeadCommit_Marshal(t *testing.T) { 13700 testJSONMarshal(t, &HeadCommit{}, "{}") 13701 13702 u := &HeadCommit{ 13703 Message: String("m"), 13704 Author: &CommitAuthor{ 13705 Date: &Timestamp{referenceTime}, 13706 Name: String("n"), 13707 Email: String("e"), 13708 Login: String("u"), 13709 }, 13710 URL: String("u"), 13711 Distinct: Bool(true), 13712 SHA: String("s"), 13713 ID: String("id"), 13714 TreeID: String("tid"), 13715 Timestamp: &Timestamp{referenceTime}, 13716 Committer: &CommitAuthor{ 13717 Date: &Timestamp{referenceTime}, 13718 Name: String("n"), 13719 Email: String("e"), 13720 Login: String("u"), 13721 }, 13722 Added: []string{"a"}, 13723 Removed: []string{"r"}, 13724 Modified: []string{"m"}, 13725 } 13726 13727 want := `{ 13728 "message": "m", 13729 "author": { 13730 "date": ` + referenceTimeStr + `, 13731 "name": "n", 13732 "email": "e", 13733 "username": "u" 13734 }, 13735 "url": "u", 13736 "distinct": true, 13737 "sha": "s", 13738 "id": "id", 13739 "tree_id": "tid", 13740 "timestamp": ` + referenceTimeStr + `, 13741 "committer": { 13742 "date": ` + referenceTimeStr + `, 13743 "name": "n", 13744 "email": "e", 13745 "username": "u" 13746 }, 13747 "added": [ 13748 "a" 13749 ], 13750 "removed": [ 13751 "r" 13752 ], 13753 "modified": [ 13754 "m" 13755 ] 13756 }` 13757 13758 testJSONMarshal(t, u, want) 13759 } 13760 13761 func TestPushEventRepository_Marshal(t *testing.T) { 13762 testJSONMarshal(t, &PushEventRepository{}, "{}") 13763 13764 u := &PushEventRepository{ 13765 ID: Int64(1), 13766 NodeID: String("nid"), 13767 Name: String("n"), 13768 FullName: String("fn"), 13769 Owner: &User{ 13770 Login: String("l"), 13771 ID: Int64(1), 13772 AvatarURL: String("a"), 13773 GravatarID: String("g"), 13774 Name: String("n"), 13775 Company: String("c"), 13776 Blog: String("b"), 13777 Location: String("l"), 13778 Email: String("e"), 13779 Hireable: Bool(true), 13780 PublicRepos: Int(1), 13781 Followers: Int(1), 13782 Following: Int(1), 13783 CreatedAt: &Timestamp{referenceTime}, 13784 URL: String("u"), 13785 }, 13786 Private: Bool(true), 13787 Description: String("d"), 13788 Fork: Bool(true), 13789 CreatedAt: &Timestamp{referenceTime}, 13790 PushedAt: &Timestamp{referenceTime}, 13791 UpdatedAt: &Timestamp{referenceTime}, 13792 Homepage: String("h"), 13793 PullsURL: String("p"), 13794 Size: Int(1), 13795 StargazersCount: Int(1), 13796 WatchersCount: Int(1), 13797 Language: String("l"), 13798 HasIssues: Bool(true), 13799 HasDownloads: Bool(true), 13800 HasWiki: Bool(true), 13801 HasPages: Bool(true), 13802 ForksCount: Int(1), 13803 Archived: Bool(true), 13804 Disabled: Bool(true), 13805 OpenIssuesCount: Int(1), 13806 DefaultBranch: String("d"), 13807 MasterBranch: String("m"), 13808 Organization: String("o"), 13809 URL: String("u"), 13810 ArchiveURL: String("a"), 13811 HTMLURL: String("h"), 13812 StatusesURL: String("s"), 13813 GitURL: String("g"), 13814 SSHURL: String("s"), 13815 CloneURL: String("c"), 13816 SVNURL: String("s"), 13817 Topics: []string{"octocat", "api"}, 13818 } 13819 13820 want := `{ 13821 "id": 1, 13822 "node_id": "nid", 13823 "name": "n", 13824 "full_name": "fn", 13825 "owner": { 13826 "login": "l", 13827 "id": 1, 13828 "avatar_url": "a", 13829 "gravatar_id": "g", 13830 "name": "n", 13831 "company": "c", 13832 "blog": "b", 13833 "location": "l", 13834 "email": "e", 13835 "hireable": true, 13836 "public_repos": 1, 13837 "followers": 1, 13838 "following": 1, 13839 "created_at": ` + referenceTimeStr + `, 13840 "url": "u" 13841 }, 13842 "private": true, 13843 "description": "d", 13844 "fork": true, 13845 "created_at": ` + referenceTimeStr + `, 13846 "pushed_at": ` + referenceTimeStr + `, 13847 "updated_at": ` + referenceTimeStr + `, 13848 "homepage": "h", 13849 "pulls_url": "p", 13850 "size": 1, 13851 "stargazers_count": 1, 13852 "watchers_count": 1, 13853 "language": "l", 13854 "has_issues": true, 13855 "has_downloads": true, 13856 "has_wiki": true, 13857 "has_pages": true, 13858 "forks_count": 1, 13859 "archived": true, 13860 "disabled": true, 13861 "open_issues_count": 1, 13862 "default_branch": "d", 13863 "master_branch": "m", 13864 "organization": "o", 13865 "url": "u", 13866 "archive_url": "a", 13867 "html_url": "h", 13868 "statuses_url": "s", 13869 "git_url": "g", 13870 "ssh_url": "s", 13871 "clone_url": "c", 13872 "svn_url": "s", 13873 "topics": ["octocat","api"] 13874 }` 13875 13876 testJSONMarshal(t, u, want) 13877 } 13878 13879 func TestPushEventRepoOwner_Marshal(t *testing.T) { 13880 testJSONMarshal(t, &PushEventRepoOwner{}, "{}") 13881 13882 u := &PushEventRepoOwner{ 13883 Name: String("n"), 13884 Email: String("e"), 13885 } 13886 13887 want := `{ 13888 "name": "n", 13889 "email": "e" 13890 }` 13891 13892 testJSONMarshal(t, u, want) 13893 } 13894 13895 func TestProjectEvent_Marshal(t *testing.T) { 13896 testJSONMarshal(t, &ProjectEvent{}, "{}") 13897 13898 u := &ProjectEvent{ 13899 Project: &Project{ID: Int64(1)}, 13900 Action: String("a"), 13901 Changes: &ProjectChange{ 13902 Name: &ProjectName{From: String("NameFrom")}, 13903 Body: &ProjectBody{From: String("BodyFrom")}, 13904 }, 13905 Repo: &Repository{ 13906 ID: Int64(1), 13907 URL: String("s"), 13908 Name: String("n"), 13909 }, 13910 Org: &Organization{ 13911 BillingEmail: String("be"), 13912 Blog: String("b"), 13913 Company: String("c"), 13914 Email: String("e"), 13915 TwitterUsername: String("tu"), 13916 Location: String("loc"), 13917 Name: String("n"), 13918 Description: String("d"), 13919 IsVerified: Bool(true), 13920 HasOrganizationProjects: Bool(true), 13921 HasRepositoryProjects: Bool(true), 13922 DefaultRepoPermission: String("drp"), 13923 MembersCanCreateRepos: Bool(true), 13924 MembersCanCreateInternalRepos: Bool(true), 13925 MembersCanCreatePrivateRepos: Bool(true), 13926 MembersCanCreatePublicRepos: Bool(false), 13927 MembersAllowedRepositoryCreationType: String("marct"), 13928 MembersCanCreatePages: Bool(true), 13929 MembersCanCreatePublicPages: Bool(false), 13930 MembersCanCreatePrivatePages: Bool(true), 13931 }, 13932 Sender: &User{ 13933 Login: String("l"), 13934 ID: Int64(1), 13935 NodeID: String("n"), 13936 URL: String("u"), 13937 ReposURL: String("r"), 13938 EventsURL: String("e"), 13939 AvatarURL: String("a"), 13940 }, 13941 Installation: &Installation{ 13942 ID: Int64(1), 13943 NodeID: String("nid"), 13944 AppID: Int64(1), 13945 AppSlug: String("as"), 13946 TargetID: Int64(1), 13947 Account: &User{ 13948 Login: String("l"), 13949 ID: Int64(1), 13950 URL: String("u"), 13951 AvatarURL: String("a"), 13952 GravatarID: String("g"), 13953 Name: String("n"), 13954 Company: String("c"), 13955 Blog: String("b"), 13956 Location: String("l"), 13957 Email: String("e"), 13958 Hireable: Bool(true), 13959 Bio: String("b"), 13960 TwitterUsername: String("t"), 13961 PublicRepos: Int(1), 13962 Followers: Int(1), 13963 Following: Int(1), 13964 CreatedAt: &Timestamp{referenceTime}, 13965 SuspendedAt: &Timestamp{referenceTime}, 13966 }, 13967 AccessTokensURL: String("atu"), 13968 RepositoriesURL: String("ru"), 13969 HTMLURL: String("hu"), 13970 TargetType: String("tt"), 13971 SingleFileName: String("sfn"), 13972 RepositorySelection: String("rs"), 13973 Events: []string{"e"}, 13974 SingleFilePaths: []string{"s"}, 13975 Permissions: &InstallationPermissions{ 13976 Actions: String("a"), 13977 Administration: String("ad"), 13978 Checks: String("c"), 13979 Contents: String("co"), 13980 ContentReferences: String("cr"), 13981 Deployments: String("d"), 13982 Environments: String("e"), 13983 Issues: String("i"), 13984 Metadata: String("md"), 13985 Members: String("m"), 13986 OrganizationAdministration: String("oa"), 13987 OrganizationHooks: String("oh"), 13988 OrganizationPlan: String("op"), 13989 OrganizationPreReceiveHooks: String("opr"), 13990 OrganizationProjects: String("op"), 13991 OrganizationSecrets: String("os"), 13992 OrganizationSelfHostedRunners: String("osh"), 13993 OrganizationUserBlocking: String("oub"), 13994 Packages: String("pkg"), 13995 Pages: String("pg"), 13996 PullRequests: String("pr"), 13997 RepositoryHooks: String("rh"), 13998 RepositoryProjects: String("rp"), 13999 RepositoryPreReceiveHooks: String("rprh"), 14000 Secrets: String("s"), 14001 SecretScanningAlerts: String("ssa"), 14002 SecurityEvents: String("se"), 14003 SingleFile: String("sf"), 14004 Statuses: String("s"), 14005 TeamDiscussions: String("td"), 14006 VulnerabilityAlerts: String("va"), 14007 Workflows: String("w"), 14008 }, 14009 CreatedAt: &Timestamp{referenceTime}, 14010 UpdatedAt: &Timestamp{referenceTime}, 14011 HasMultipleSingleFiles: Bool(false), 14012 SuspendedBy: &User{ 14013 Login: String("l"), 14014 ID: Int64(1), 14015 URL: String("u"), 14016 AvatarURL: String("a"), 14017 GravatarID: String("g"), 14018 Name: String("n"), 14019 Company: String("c"), 14020 Blog: String("b"), 14021 Location: String("l"), 14022 Email: String("e"), 14023 Hireable: Bool(true), 14024 Bio: String("b"), 14025 TwitterUsername: String("t"), 14026 PublicRepos: Int(1), 14027 Followers: Int(1), 14028 Following: Int(1), 14029 CreatedAt: &Timestamp{referenceTime}, 14030 SuspendedAt: &Timestamp{referenceTime}, 14031 }, 14032 SuspendedAt: &Timestamp{referenceTime}, 14033 }, 14034 } 14035 14036 want := `{ 14037 "action": "a", 14038 "changes": { 14039 "name": { 14040 "from": "NameFrom" 14041 }, 14042 "body": { 14043 "from": "BodyFrom" 14044 } 14045 }, 14046 "project": { 14047 "id": 1 14048 }, 14049 "repository": { 14050 "id": 1, 14051 "name": "n", 14052 "url": "s" 14053 }, 14054 "organization": { 14055 "name": "n", 14056 "company": "c", 14057 "blog": "b", 14058 "location": "loc", 14059 "email": "e", 14060 "twitter_username": "tu", 14061 "description": "d", 14062 "billing_email": "be", 14063 "is_verified": true, 14064 "has_organization_projects": true, 14065 "has_repository_projects": true, 14066 "default_repository_permission": "drp", 14067 "members_can_create_repositories": true, 14068 "members_can_create_public_repositories": false, 14069 "members_can_create_private_repositories": true, 14070 "members_can_create_internal_repositories": true, 14071 "members_allowed_repository_creation_type": "marct", 14072 "members_can_create_pages": true, 14073 "members_can_create_public_pages": false, 14074 "members_can_create_private_pages": true 14075 }, 14076 "sender": { 14077 "login": "l", 14078 "id": 1, 14079 "node_id": "n", 14080 "avatar_url": "a", 14081 "url": "u", 14082 "events_url": "e", 14083 "repos_url": "r" 14084 }, 14085 "installation": { 14086 "id": 1, 14087 "node_id": "nid", 14088 "app_id": 1, 14089 "app_slug": "as", 14090 "target_id": 1, 14091 "account": { 14092 "login": "l", 14093 "id": 1, 14094 "avatar_url": "a", 14095 "gravatar_id": "g", 14096 "name": "n", 14097 "company": "c", 14098 "blog": "b", 14099 "location": "l", 14100 "email": "e", 14101 "hireable": true, 14102 "bio": "b", 14103 "twitter_username": "t", 14104 "public_repos": 1, 14105 "followers": 1, 14106 "following": 1, 14107 "created_at": ` + referenceTimeStr + `, 14108 "suspended_at": ` + referenceTimeStr + `, 14109 "url": "u" 14110 }, 14111 "access_tokens_url": "atu", 14112 "repositories_url": "ru", 14113 "html_url": "hu", 14114 "target_type": "tt", 14115 "single_file_name": "sfn", 14116 "repository_selection": "rs", 14117 "events": [ 14118 "e" 14119 ], 14120 "single_file_paths": [ 14121 "s" 14122 ], 14123 "permissions": { 14124 "actions": "a", 14125 "administration": "ad", 14126 "checks": "c", 14127 "contents": "co", 14128 "content_references": "cr", 14129 "deployments": "d", 14130 "environments": "e", 14131 "issues": "i", 14132 "metadata": "md", 14133 "members": "m", 14134 "organization_administration": "oa", 14135 "organization_hooks": "oh", 14136 "organization_plan": "op", 14137 "organization_pre_receive_hooks": "opr", 14138 "organization_projects": "op", 14139 "organization_secrets": "os", 14140 "organization_self_hosted_runners": "osh", 14141 "organization_user_blocking": "oub", 14142 "packages": "pkg", 14143 "pages": "pg", 14144 "pull_requests": "pr", 14145 "repository_hooks": "rh", 14146 "repository_projects": "rp", 14147 "repository_pre_receive_hooks": "rprh", 14148 "secrets": "s", 14149 "secret_scanning_alerts": "ssa", 14150 "security_events": "se", 14151 "single_file": "sf", 14152 "statuses": "s", 14153 "team_discussions": "td", 14154 "vulnerability_alerts": "va", 14155 "workflows": "w" 14156 }, 14157 "created_at": ` + referenceTimeStr + `, 14158 "updated_at": ` + referenceTimeStr + `, 14159 "has_multiple_single_files": false, 14160 "suspended_by": { 14161 "login": "l", 14162 "id": 1, 14163 "avatar_url": "a", 14164 "gravatar_id": "g", 14165 "name": "n", 14166 "company": "c", 14167 "blog": "b", 14168 "location": "l", 14169 "email": "e", 14170 "hireable": true, 14171 "bio": "b", 14172 "twitter_username": "t", 14173 "public_repos": 1, 14174 "followers": 1, 14175 "following": 1, 14176 "created_at": ` + referenceTimeStr + `, 14177 "suspended_at": ` + referenceTimeStr + `, 14178 "url": "u" 14179 }, 14180 "suspended_at": ` + referenceTimeStr + ` 14181 } 14182 }` 14183 14184 testJSONMarshal(t, u, want) 14185 } 14186 14187 func TestProjectCardEvent_Marshal(t *testing.T) { 14188 testJSONMarshal(t, &ProjectCardEvent{}, "{}") 14189 14190 u := &ProjectCardEvent{ 14191 Action: String("a"), 14192 Changes: &ProjectCardChange{ 14193 Note: &ProjectCardNote{From: String("NoteFrom")}, 14194 }, 14195 AfterID: Int64(1), 14196 ProjectCard: &ProjectCard{ID: Int64(1)}, 14197 Repo: &Repository{ 14198 ID: Int64(1), 14199 URL: String("s"), 14200 Name: String("n"), 14201 }, 14202 Org: &Organization{ 14203 BillingEmail: String("be"), 14204 Blog: String("b"), 14205 Company: String("c"), 14206 Email: String("e"), 14207 TwitterUsername: String("tu"), 14208 Location: String("loc"), 14209 Name: String("n"), 14210 Description: String("d"), 14211 IsVerified: Bool(true), 14212 HasOrganizationProjects: Bool(true), 14213 HasRepositoryProjects: Bool(true), 14214 DefaultRepoPermission: String("drp"), 14215 MembersCanCreateRepos: Bool(true), 14216 MembersCanCreateInternalRepos: Bool(true), 14217 MembersCanCreatePrivateRepos: Bool(true), 14218 MembersCanCreatePublicRepos: Bool(false), 14219 MembersAllowedRepositoryCreationType: String("marct"), 14220 MembersCanCreatePages: Bool(true), 14221 MembersCanCreatePublicPages: Bool(false), 14222 MembersCanCreatePrivatePages: Bool(true), 14223 }, 14224 Sender: &User{ 14225 Login: String("l"), 14226 ID: Int64(1), 14227 NodeID: String("n"), 14228 URL: String("u"), 14229 ReposURL: String("r"), 14230 EventsURL: String("e"), 14231 AvatarURL: String("a"), 14232 }, 14233 Installation: &Installation{ 14234 ID: Int64(1), 14235 NodeID: String("nid"), 14236 AppID: Int64(1), 14237 AppSlug: String("as"), 14238 TargetID: Int64(1), 14239 Account: &User{ 14240 Login: String("l"), 14241 ID: Int64(1), 14242 URL: String("u"), 14243 AvatarURL: String("a"), 14244 GravatarID: String("g"), 14245 Name: String("n"), 14246 Company: String("c"), 14247 Blog: String("b"), 14248 Location: String("l"), 14249 Email: String("e"), 14250 Hireable: Bool(true), 14251 Bio: String("b"), 14252 TwitterUsername: String("t"), 14253 PublicRepos: Int(1), 14254 Followers: Int(1), 14255 Following: Int(1), 14256 CreatedAt: &Timestamp{referenceTime}, 14257 SuspendedAt: &Timestamp{referenceTime}, 14258 }, 14259 AccessTokensURL: String("atu"), 14260 RepositoriesURL: String("ru"), 14261 HTMLURL: String("hu"), 14262 TargetType: String("tt"), 14263 SingleFileName: String("sfn"), 14264 RepositorySelection: String("rs"), 14265 Events: []string{"e"}, 14266 SingleFilePaths: []string{"s"}, 14267 Permissions: &InstallationPermissions{ 14268 Actions: String("a"), 14269 Administration: String("ad"), 14270 Checks: String("c"), 14271 Contents: String("co"), 14272 ContentReferences: String("cr"), 14273 Deployments: String("d"), 14274 Environments: String("e"), 14275 Issues: String("i"), 14276 Metadata: String("md"), 14277 Members: String("m"), 14278 OrganizationAdministration: String("oa"), 14279 OrganizationHooks: String("oh"), 14280 OrganizationPlan: String("op"), 14281 OrganizationPreReceiveHooks: String("opr"), 14282 OrganizationProjects: String("op"), 14283 OrganizationSecrets: String("os"), 14284 OrganizationSelfHostedRunners: String("osh"), 14285 OrganizationUserBlocking: String("oub"), 14286 Packages: String("pkg"), 14287 Pages: String("pg"), 14288 PullRequests: String("pr"), 14289 RepositoryHooks: String("rh"), 14290 RepositoryProjects: String("rp"), 14291 RepositoryPreReceiveHooks: String("rprh"), 14292 Secrets: String("s"), 14293 SecretScanningAlerts: String("ssa"), 14294 SecurityEvents: String("se"), 14295 SingleFile: String("sf"), 14296 Statuses: String("s"), 14297 TeamDiscussions: String("td"), 14298 VulnerabilityAlerts: String("va"), 14299 Workflows: String("w"), 14300 }, 14301 CreatedAt: &Timestamp{referenceTime}, 14302 UpdatedAt: &Timestamp{referenceTime}, 14303 HasMultipleSingleFiles: Bool(false), 14304 SuspendedBy: &User{ 14305 Login: String("l"), 14306 ID: Int64(1), 14307 URL: String("u"), 14308 AvatarURL: String("a"), 14309 GravatarID: String("g"), 14310 Name: String("n"), 14311 Company: String("c"), 14312 Blog: String("b"), 14313 Location: String("l"), 14314 Email: String("e"), 14315 Hireable: Bool(true), 14316 Bio: String("b"), 14317 TwitterUsername: String("t"), 14318 PublicRepos: Int(1), 14319 Followers: Int(1), 14320 Following: Int(1), 14321 CreatedAt: &Timestamp{referenceTime}, 14322 SuspendedAt: &Timestamp{referenceTime}, 14323 }, 14324 SuspendedAt: &Timestamp{referenceTime}, 14325 }, 14326 } 14327 14328 want := `{ 14329 "action": "a", 14330 "changes": { 14331 "note": { 14332 "from": "NoteFrom" 14333 } 14334 }, 14335 "after_id": 1, 14336 "project_card": { 14337 "id": 1 14338 }, 14339 "repository": { 14340 "id": 1, 14341 "name": "n", 14342 "url": "s" 14343 }, 14344 "organization": { 14345 "name": "n", 14346 "company": "c", 14347 "blog": "b", 14348 "location": "loc", 14349 "email": "e", 14350 "twitter_username": "tu", 14351 "description": "d", 14352 "billing_email": "be", 14353 "is_verified": true, 14354 "has_organization_projects": true, 14355 "has_repository_projects": true, 14356 "default_repository_permission": "drp", 14357 "members_can_create_repositories": true, 14358 "members_can_create_public_repositories": false, 14359 "members_can_create_private_repositories": true, 14360 "members_can_create_internal_repositories": true, 14361 "members_allowed_repository_creation_type": "marct", 14362 "members_can_create_pages": true, 14363 "members_can_create_public_pages": false, 14364 "members_can_create_private_pages": true 14365 }, 14366 "sender": { 14367 "login": "l", 14368 "id": 1, 14369 "node_id": "n", 14370 "avatar_url": "a", 14371 "url": "u", 14372 "events_url": "e", 14373 "repos_url": "r" 14374 }, 14375 "installation": { 14376 "id": 1, 14377 "node_id": "nid", 14378 "app_id": 1, 14379 "app_slug": "as", 14380 "target_id": 1, 14381 "account": { 14382 "login": "l", 14383 "id": 1, 14384 "avatar_url": "a", 14385 "gravatar_id": "g", 14386 "name": "n", 14387 "company": "c", 14388 "blog": "b", 14389 "location": "l", 14390 "email": "e", 14391 "hireable": true, 14392 "bio": "b", 14393 "twitter_username": "t", 14394 "public_repos": 1, 14395 "followers": 1, 14396 "following": 1, 14397 "created_at": ` + referenceTimeStr + `, 14398 "suspended_at": ` + referenceTimeStr + `, 14399 "url": "u" 14400 }, 14401 "access_tokens_url": "atu", 14402 "repositories_url": "ru", 14403 "html_url": "hu", 14404 "target_type": "tt", 14405 "single_file_name": "sfn", 14406 "repository_selection": "rs", 14407 "events": [ 14408 "e" 14409 ], 14410 "single_file_paths": [ 14411 "s" 14412 ], 14413 "permissions": { 14414 "actions": "a", 14415 "administration": "ad", 14416 "checks": "c", 14417 "contents": "co", 14418 "content_references": "cr", 14419 "deployments": "d", 14420 "environments": "e", 14421 "issues": "i", 14422 "metadata": "md", 14423 "members": "m", 14424 "organization_administration": "oa", 14425 "organization_hooks": "oh", 14426 "organization_plan": "op", 14427 "organization_pre_receive_hooks": "opr", 14428 "organization_projects": "op", 14429 "organization_secrets": "os", 14430 "organization_self_hosted_runners": "osh", 14431 "organization_user_blocking": "oub", 14432 "packages": "pkg", 14433 "pages": "pg", 14434 "pull_requests": "pr", 14435 "repository_hooks": "rh", 14436 "repository_projects": "rp", 14437 "repository_pre_receive_hooks": "rprh", 14438 "secrets": "s", 14439 "secret_scanning_alerts": "ssa", 14440 "security_events": "se", 14441 "single_file": "sf", 14442 "statuses": "s", 14443 "team_discussions": "td", 14444 "vulnerability_alerts": "va", 14445 "workflows": "w" 14446 }, 14447 "created_at": ` + referenceTimeStr + `, 14448 "updated_at": ` + referenceTimeStr + `, 14449 "has_multiple_single_files": false, 14450 "suspended_by": { 14451 "login": "l", 14452 "id": 1, 14453 "avatar_url": "a", 14454 "gravatar_id": "g", 14455 "name": "n", 14456 "company": "c", 14457 "blog": "b", 14458 "location": "l", 14459 "email": "e", 14460 "hireable": true, 14461 "bio": "b", 14462 "twitter_username": "t", 14463 "public_repos": 1, 14464 "followers": 1, 14465 "following": 1, 14466 "created_at": ` + referenceTimeStr + `, 14467 "suspended_at": ` + referenceTimeStr + `, 14468 "url": "u" 14469 }, 14470 "suspended_at": ` + referenceTimeStr + ` 14471 } 14472 }` 14473 14474 testJSONMarshal(t, u, want) 14475 } 14476 14477 func TestProjectColumnEvent_Marshal(t *testing.T) { 14478 testJSONMarshal(t, &ProjectColumnEvent{}, "{}") 14479 14480 u := &ProjectColumnEvent{ 14481 Action: String("a"), 14482 Changes: &ProjectColumnChange{ 14483 Name: &ProjectColumnName{From: String("NameFrom")}, 14484 }, 14485 AfterID: Int64(1), 14486 ProjectColumn: &ProjectColumn{ID: Int64(1)}, 14487 Repo: &Repository{ 14488 ID: Int64(1), 14489 URL: String("s"), 14490 Name: String("n"), 14491 }, 14492 Org: &Organization{ 14493 BillingEmail: String("be"), 14494 Blog: String("b"), 14495 Company: String("c"), 14496 Email: String("e"), 14497 TwitterUsername: String("tu"), 14498 Location: String("loc"), 14499 Name: String("n"), 14500 Description: String("d"), 14501 IsVerified: Bool(true), 14502 HasOrganizationProjects: Bool(true), 14503 HasRepositoryProjects: Bool(true), 14504 DefaultRepoPermission: String("drp"), 14505 MembersCanCreateRepos: Bool(true), 14506 MembersCanCreateInternalRepos: Bool(true), 14507 MembersCanCreatePrivateRepos: Bool(true), 14508 MembersCanCreatePublicRepos: Bool(false), 14509 MembersAllowedRepositoryCreationType: String("marct"), 14510 MembersCanCreatePages: Bool(true), 14511 MembersCanCreatePublicPages: Bool(false), 14512 MembersCanCreatePrivatePages: Bool(true), 14513 }, 14514 Sender: &User{ 14515 Login: String("l"), 14516 ID: Int64(1), 14517 NodeID: String("n"), 14518 URL: String("u"), 14519 ReposURL: String("r"), 14520 EventsURL: String("e"), 14521 AvatarURL: String("a"), 14522 }, 14523 Installation: &Installation{ 14524 ID: Int64(1), 14525 NodeID: String("nid"), 14526 AppID: Int64(1), 14527 AppSlug: String("as"), 14528 TargetID: Int64(1), 14529 Account: &User{ 14530 Login: String("l"), 14531 ID: Int64(1), 14532 URL: String("u"), 14533 AvatarURL: String("a"), 14534 GravatarID: String("g"), 14535 Name: String("n"), 14536 Company: String("c"), 14537 Blog: String("b"), 14538 Location: String("l"), 14539 Email: String("e"), 14540 Hireable: Bool(true), 14541 Bio: String("b"), 14542 TwitterUsername: String("t"), 14543 PublicRepos: Int(1), 14544 Followers: Int(1), 14545 Following: Int(1), 14546 CreatedAt: &Timestamp{referenceTime}, 14547 SuspendedAt: &Timestamp{referenceTime}, 14548 }, 14549 AccessTokensURL: String("atu"), 14550 RepositoriesURL: String("ru"), 14551 HTMLURL: String("hu"), 14552 TargetType: String("tt"), 14553 SingleFileName: String("sfn"), 14554 RepositorySelection: String("rs"), 14555 Events: []string{"e"}, 14556 SingleFilePaths: []string{"s"}, 14557 Permissions: &InstallationPermissions{ 14558 Actions: String("a"), 14559 Administration: String("ad"), 14560 Checks: String("c"), 14561 Contents: String("co"), 14562 ContentReferences: String("cr"), 14563 Deployments: String("d"), 14564 Environments: String("e"), 14565 Issues: String("i"), 14566 Metadata: String("md"), 14567 Members: String("m"), 14568 OrganizationAdministration: String("oa"), 14569 OrganizationHooks: String("oh"), 14570 OrganizationPlan: String("op"), 14571 OrganizationPreReceiveHooks: String("opr"), 14572 OrganizationProjects: String("op"), 14573 OrganizationSecrets: String("os"), 14574 OrganizationSelfHostedRunners: String("osh"), 14575 OrganizationUserBlocking: String("oub"), 14576 Packages: String("pkg"), 14577 Pages: String("pg"), 14578 PullRequests: String("pr"), 14579 RepositoryHooks: String("rh"), 14580 RepositoryProjects: String("rp"), 14581 RepositoryPreReceiveHooks: String("rprh"), 14582 Secrets: String("s"), 14583 SecretScanningAlerts: String("ssa"), 14584 SecurityEvents: String("se"), 14585 SingleFile: String("sf"), 14586 Statuses: String("s"), 14587 TeamDiscussions: String("td"), 14588 VulnerabilityAlerts: String("va"), 14589 Workflows: String("w"), 14590 }, 14591 CreatedAt: &Timestamp{referenceTime}, 14592 UpdatedAt: &Timestamp{referenceTime}, 14593 HasMultipleSingleFiles: Bool(false), 14594 SuspendedBy: &User{ 14595 Login: String("l"), 14596 ID: Int64(1), 14597 URL: String("u"), 14598 AvatarURL: String("a"), 14599 GravatarID: String("g"), 14600 Name: String("n"), 14601 Company: String("c"), 14602 Blog: String("b"), 14603 Location: String("l"), 14604 Email: String("e"), 14605 Hireable: Bool(true), 14606 Bio: String("b"), 14607 TwitterUsername: String("t"), 14608 PublicRepos: Int(1), 14609 Followers: Int(1), 14610 Following: Int(1), 14611 CreatedAt: &Timestamp{referenceTime}, 14612 SuspendedAt: &Timestamp{referenceTime}, 14613 }, 14614 SuspendedAt: &Timestamp{referenceTime}, 14615 }, 14616 } 14617 14618 want := `{ 14619 "action": "a", 14620 "changes": { 14621 "name": { 14622 "from": "NameFrom" 14623 } 14624 }, 14625 "after_id": 1, 14626 "project_column": { 14627 "id": 1 14628 }, 14629 "repository": { 14630 "id": 1, 14631 "name": "n", 14632 "url": "s" 14633 }, 14634 "organization": { 14635 "name": "n", 14636 "company": "c", 14637 "blog": "b", 14638 "location": "loc", 14639 "email": "e", 14640 "twitter_username": "tu", 14641 "description": "d", 14642 "billing_email": "be", 14643 "is_verified": true, 14644 "has_organization_projects": true, 14645 "has_repository_projects": true, 14646 "default_repository_permission": "drp", 14647 "members_can_create_repositories": true, 14648 "members_can_create_public_repositories": false, 14649 "members_can_create_private_repositories": true, 14650 "members_can_create_internal_repositories": true, 14651 "members_allowed_repository_creation_type": "marct", 14652 "members_can_create_pages": true, 14653 "members_can_create_public_pages": false, 14654 "members_can_create_private_pages": true 14655 }, 14656 "sender": { 14657 "login": "l", 14658 "id": 1, 14659 "node_id": "n", 14660 "avatar_url": "a", 14661 "url": "u", 14662 "events_url": "e", 14663 "repos_url": "r" 14664 }, 14665 "installation": { 14666 "id": 1, 14667 "node_id": "nid", 14668 "app_id": 1, 14669 "app_slug": "as", 14670 "target_id": 1, 14671 "account": { 14672 "login": "l", 14673 "id": 1, 14674 "avatar_url": "a", 14675 "gravatar_id": "g", 14676 "name": "n", 14677 "company": "c", 14678 "blog": "b", 14679 "location": "l", 14680 "email": "e", 14681 "hireable": true, 14682 "bio": "b", 14683 "twitter_username": "t", 14684 "public_repos": 1, 14685 "followers": 1, 14686 "following": 1, 14687 "created_at": ` + referenceTimeStr + `, 14688 "suspended_at": ` + referenceTimeStr + `, 14689 "url": "u" 14690 }, 14691 "access_tokens_url": "atu", 14692 "repositories_url": "ru", 14693 "html_url": "hu", 14694 "target_type": "tt", 14695 "single_file_name": "sfn", 14696 "repository_selection": "rs", 14697 "events": [ 14698 "e" 14699 ], 14700 "single_file_paths": [ 14701 "s" 14702 ], 14703 "permissions": { 14704 "actions": "a", 14705 "administration": "ad", 14706 "checks": "c", 14707 "contents": "co", 14708 "content_references": "cr", 14709 "deployments": "d", 14710 "environments": "e", 14711 "issues": "i", 14712 "metadata": "md", 14713 "members": "m", 14714 "organization_administration": "oa", 14715 "organization_hooks": "oh", 14716 "organization_plan": "op", 14717 "organization_pre_receive_hooks": "opr", 14718 "organization_projects": "op", 14719 "organization_secrets": "os", 14720 "organization_self_hosted_runners": "osh", 14721 "organization_user_blocking": "oub", 14722 "packages": "pkg", 14723 "pages": "pg", 14724 "pull_requests": "pr", 14725 "repository_hooks": "rh", 14726 "repository_projects": "rp", 14727 "repository_pre_receive_hooks": "rprh", 14728 "secrets": "s", 14729 "secret_scanning_alerts": "ssa", 14730 "security_events": "se", 14731 "single_file": "sf", 14732 "statuses": "s", 14733 "team_discussions": "td", 14734 "vulnerability_alerts": "va", 14735 "workflows": "w" 14736 }, 14737 "created_at": ` + referenceTimeStr + `, 14738 "updated_at": ` + referenceTimeStr + `, 14739 "has_multiple_single_files": false, 14740 "suspended_by": { 14741 "login": "l", 14742 "id": 1, 14743 "avatar_url": "a", 14744 "gravatar_id": "g", 14745 "name": "n", 14746 "company": "c", 14747 "blog": "b", 14748 "location": "l", 14749 "email": "e", 14750 "hireable": true, 14751 "bio": "b", 14752 "twitter_username": "t", 14753 "public_repos": 1, 14754 "followers": 1, 14755 "following": 1, 14756 "created_at": ` + referenceTimeStr + `, 14757 "suspended_at": ` + referenceTimeStr + `, 14758 "url": "u" 14759 }, 14760 "suspended_at": ` + referenceTimeStr + ` 14761 } 14762 }` 14763 14764 testJSONMarshal(t, u, want) 14765 } 14766 14767 func TestProjectV2Event_Marshal(t *testing.T) { 14768 testJSONMarshal(t, &ProjectV2Event{}, "{}") 14769 14770 u := &ProjectV2Event{ 14771 Action: String("a"), 14772 ProjectsV2: &ProjectsV2{ 14773 ID: Int64(1), 14774 NodeID: String("nid"), 14775 Owner: &User{ 14776 Login: String("l"), 14777 ID: Int64(1), 14778 NodeID: String("n"), 14779 URL: String("u"), 14780 ReposURL: String("r"), 14781 EventsURL: String("e"), 14782 AvatarURL: String("a"), 14783 }, 14784 Creator: &User{ 14785 Login: String("l"), 14786 ID: Int64(1), 14787 NodeID: String("n"), 14788 URL: String("u"), 14789 ReposURL: String("r"), 14790 EventsURL: String("e"), 14791 AvatarURL: String("a"), 14792 }, 14793 Title: String("t"), 14794 Description: String("d"), 14795 Public: Bool(true), 14796 ClosedAt: &Timestamp{referenceTime}, 14797 CreatedAt: &Timestamp{referenceTime}, 14798 UpdatedAt: &Timestamp{referenceTime}, 14799 DeletedAt: &Timestamp{referenceTime}, 14800 Number: Int(1), 14801 ShortDescription: String("sd"), 14802 DeletedBy: &User{ 14803 Login: String("l"), 14804 ID: Int64(1), 14805 NodeID: String("n"), 14806 URL: String("u"), 14807 ReposURL: String("r"), 14808 EventsURL: String("e"), 14809 AvatarURL: String("a"), 14810 }, 14811 }, 14812 Org: &Organization{ 14813 BillingEmail: String("be"), 14814 Blog: String("b"), 14815 Company: String("c"), 14816 Email: String("e"), 14817 TwitterUsername: String("tu"), 14818 Location: String("loc"), 14819 Name: String("n"), 14820 Description: String("d"), 14821 IsVerified: Bool(true), 14822 HasOrganizationProjects: Bool(true), 14823 HasRepositoryProjects: Bool(true), 14824 DefaultRepoPermission: String("drp"), 14825 MembersCanCreateRepos: Bool(true), 14826 MembersCanCreateInternalRepos: Bool(true), 14827 MembersCanCreatePrivateRepos: Bool(true), 14828 MembersCanCreatePublicRepos: Bool(false), 14829 MembersAllowedRepositoryCreationType: String("marct"), 14830 MembersCanCreatePages: Bool(true), 14831 MembersCanCreatePublicPages: Bool(false), 14832 MembersCanCreatePrivatePages: Bool(true), 14833 }, 14834 Sender: &User{ 14835 Login: String("l"), 14836 ID: Int64(1), 14837 NodeID: String("n"), 14838 URL: String("u"), 14839 ReposURL: String("r"), 14840 EventsURL: String("e"), 14841 AvatarURL: String("a"), 14842 }, 14843 Installation: &Installation{ 14844 ID: Int64(1), 14845 NodeID: String("nid"), 14846 AppID: Int64(1), 14847 AppSlug: String("as"), 14848 TargetID: Int64(1), 14849 Account: &User{ 14850 Login: String("l"), 14851 ID: Int64(1), 14852 URL: String("u"), 14853 AvatarURL: String("a"), 14854 GravatarID: String("g"), 14855 Name: String("n"), 14856 Company: String("c"), 14857 Blog: String("b"), 14858 Location: String("l"), 14859 Email: String("e"), 14860 Hireable: Bool(true), 14861 Bio: String("b"), 14862 TwitterUsername: String("t"), 14863 PublicRepos: Int(1), 14864 Followers: Int(1), 14865 Following: Int(1), 14866 CreatedAt: &Timestamp{referenceTime}, 14867 SuspendedAt: &Timestamp{referenceTime}, 14868 }, 14869 }, 14870 } 14871 14872 want := `{ 14873 "action": "a", 14874 "projects_v2": { 14875 "id": 1, 14876 "node_id": "nid", 14877 "owner": { 14878 "login": "l", 14879 "id": 1, 14880 "node_id": "n", 14881 "avatar_url": "a", 14882 "url": "u", 14883 "events_url": "e", 14884 "repos_url": "r" 14885 }, 14886 "creator": { 14887 "login": "l", 14888 "id": 1, 14889 "node_id": "n", 14890 "avatar_url": "a", 14891 "url": "u", 14892 "events_url": "e", 14893 "repos_url": "r" 14894 }, 14895 "title": "t", 14896 "description": "d", 14897 "public": true, 14898 "closed_at": ` + referenceTimeStr + `, 14899 "created_at": ` + referenceTimeStr + `, 14900 "updated_at": ` + referenceTimeStr + `, 14901 "deleted_at": ` + referenceTimeStr + `, 14902 "number": 1, 14903 "short_description": "sd", 14904 "deleted_by": { 14905 "login": "l", 14906 "id": 1, 14907 "node_id": "n", 14908 "avatar_url": "a", 14909 "url": "u", 14910 "events_url": "e", 14911 "repos_url": "r" 14912 } 14913 }, 14914 "organization": { 14915 "name": "n", 14916 "company": "c", 14917 "blog": "b", 14918 "location": "loc", 14919 "email": "e", 14920 "twitter_username": "tu", 14921 "description": "d", 14922 "billing_email": "be", 14923 "is_verified": true, 14924 "has_organization_projects": true, 14925 "has_repository_projects": true, 14926 "default_repository_permission": "drp", 14927 "members_can_create_repositories": true, 14928 "members_can_create_public_repositories": false, 14929 "members_can_create_private_repositories": true, 14930 "members_can_create_internal_repositories": true, 14931 "members_allowed_repository_creation_type": "marct", 14932 "members_can_create_pages": true, 14933 "members_can_create_public_pages": false, 14934 "members_can_create_private_pages": true 14935 }, 14936 "sender": { 14937 "login": "l", 14938 "id": 1, 14939 "node_id": "n", 14940 "avatar_url": "a", 14941 "url": "u", 14942 "events_url": "e", 14943 "repos_url": "r" 14944 }, 14945 "installation": { 14946 "id": 1, 14947 "node_id": "nid", 14948 "app_id": 1, 14949 "app_slug": "as", 14950 "target_id": 1, 14951 "account": { 14952 "login": "l", 14953 "id": 1, 14954 "avatar_url": "a", 14955 "gravatar_id": "g", 14956 "name": "n", 14957 "company": "c", 14958 "blog": "b", 14959 "location": "l", 14960 "email": "e", 14961 "hireable": true, 14962 "bio": "b", 14963 "twitter_username": "t", 14964 "public_repos": 1, 14965 "followers": 1, 14966 "following": 1, 14967 "created_at": ` + referenceTimeStr + `, 14968 "suspended_at": ` + referenceTimeStr + `, 14969 "url": "u" 14970 } 14971 } 14972 }` 14973 14974 testJSONMarshal(t, u, want) 14975 } 14976 14977 func TestProjectV2ItemEvent_Marshal(t *testing.T) { 14978 testJSONMarshal(t, &ProjectV2ItemEvent{}, "{}") 14979 14980 u := &ProjectV2ItemEvent{ 14981 Action: String("a"), 14982 Changes: &ProjectV2ItemChange{ 14983 ArchivedAt: &ArchivedAt{ 14984 From: &Timestamp{referenceTime}, 14985 To: &Timestamp{referenceTime}, 14986 }, 14987 }, 14988 ProjectV2Item: &ProjectV2Item{ 14989 ID: Int64(1), 14990 NodeID: String("nid"), 14991 ProjectNodeID: String("pnid"), 14992 ContentNodeID: String("cnid"), 14993 ContentType: String("ct"), 14994 Creator: &User{ 14995 Login: String("l"), 14996 ID: Int64(1), 14997 NodeID: String("n"), 14998 URL: String("u"), 14999 ReposURL: String("r"), 15000 EventsURL: String("e"), 15001 AvatarURL: String("a"), 15002 }, 15003 CreatedAt: &Timestamp{referenceTime}, 15004 UpdatedAt: &Timestamp{referenceTime}, 15005 ArchivedAt: &Timestamp{referenceTime}, 15006 }, 15007 Org: &Organization{ 15008 BillingEmail: String("be"), 15009 Blog: String("b"), 15010 Company: String("c"), 15011 Email: String("e"), 15012 TwitterUsername: String("tu"), 15013 Location: String("loc"), 15014 Name: String("n"), 15015 Description: String("d"), 15016 IsVerified: Bool(true), 15017 HasOrganizationProjects: Bool(true), 15018 HasRepositoryProjects: Bool(true), 15019 DefaultRepoPermission: String("drp"), 15020 MembersCanCreateRepos: Bool(true), 15021 MembersCanCreateInternalRepos: Bool(true), 15022 MembersCanCreatePrivateRepos: Bool(true), 15023 MembersCanCreatePublicRepos: Bool(false), 15024 MembersAllowedRepositoryCreationType: String("marct"), 15025 MembersCanCreatePages: Bool(true), 15026 MembersCanCreatePublicPages: Bool(false), 15027 MembersCanCreatePrivatePages: Bool(true), 15028 }, 15029 Sender: &User{ 15030 Login: String("l"), 15031 ID: Int64(1), 15032 NodeID: String("n"), 15033 URL: String("u"), 15034 ReposURL: String("r"), 15035 EventsURL: String("e"), 15036 AvatarURL: String("a"), 15037 }, 15038 Installation: &Installation{ 15039 ID: Int64(1), 15040 NodeID: String("nid"), 15041 AppID: Int64(1), 15042 AppSlug: String("as"), 15043 TargetID: Int64(1), 15044 Account: &User{ 15045 Login: String("l"), 15046 ID: Int64(1), 15047 URL: String("u"), 15048 AvatarURL: String("a"), 15049 GravatarID: String("g"), 15050 Name: String("n"), 15051 Company: String("c"), 15052 Blog: String("b"), 15053 Location: String("l"), 15054 Email: String("e"), 15055 Hireable: Bool(true), 15056 Bio: String("b"), 15057 TwitterUsername: String("t"), 15058 PublicRepos: Int(1), 15059 Followers: Int(1), 15060 Following: Int(1), 15061 CreatedAt: &Timestamp{referenceTime}, 15062 SuspendedAt: &Timestamp{referenceTime}, 15063 }, 15064 }, 15065 } 15066 15067 want := `{ 15068 "action": "a", 15069 "changes": { 15070 "archived_at": { 15071 "from": ` + referenceTimeStr + `, 15072 "to": ` + referenceTimeStr + ` 15073 } 15074 }, 15075 "projects_v2_item": { 15076 "id": 1, 15077 "node_id": "nid", 15078 "project_node_id": "pnid", 15079 "content_node_id": "cnid", 15080 "content_type": "ct", 15081 "creator": { 15082 "login": "l", 15083 "id": 1, 15084 "node_id": "n", 15085 "avatar_url": "a", 15086 "url": "u", 15087 "events_url": "e", 15088 "repos_url": "r" 15089 }, 15090 "created_at": ` + referenceTimeStr + `, 15091 "updated_at": ` + referenceTimeStr + `, 15092 "archived_at": ` + referenceTimeStr + ` 15093 }, 15094 "organization": { 15095 "name": "n", 15096 "company": "c", 15097 "blog": "b", 15098 "location": "loc", 15099 "email": "e", 15100 "twitter_username": "tu", 15101 "description": "d", 15102 "billing_email": "be", 15103 "is_verified": true, 15104 "has_organization_projects": true, 15105 "has_repository_projects": true, 15106 "default_repository_permission": "drp", 15107 "members_can_create_repositories": true, 15108 "members_can_create_public_repositories": false, 15109 "members_can_create_private_repositories": true, 15110 "members_can_create_internal_repositories": true, 15111 "members_allowed_repository_creation_type": "marct", 15112 "members_can_create_pages": true, 15113 "members_can_create_public_pages": false, 15114 "members_can_create_private_pages": true 15115 }, 15116 "sender": { 15117 "login": "l", 15118 "id": 1, 15119 "node_id": "n", 15120 "avatar_url": "a", 15121 "url": "u", 15122 "events_url": "e", 15123 "repos_url": "r" 15124 }, 15125 "installation": { 15126 "id": 1, 15127 "node_id": "nid", 15128 "app_id": 1, 15129 "app_slug": "as", 15130 "target_id": 1, 15131 "account": { 15132 "login": "l", 15133 "id": 1, 15134 "avatar_url": "a", 15135 "gravatar_id": "g", 15136 "name": "n", 15137 "company": "c", 15138 "blog": "b", 15139 "location": "l", 15140 "email": "e", 15141 "hireable": true, 15142 "bio": "b", 15143 "twitter_username": "t", 15144 "public_repos": 1, 15145 "followers": 1, 15146 "following": 1, 15147 "created_at": ` + referenceTimeStr + `, 15148 "suspended_at": ` + referenceTimeStr + `, 15149 "url": "u" 15150 } 15151 } 15152 }` 15153 15154 testJSONMarshal(t, u, want) 15155 } 15156 15157 func TestPullRequestEvent_Marshal(t *testing.T) { 15158 testJSONMarshal(t, &PullRequestEvent{}, "{}") 15159 15160 u := &PullRequestEvent{ 15161 Action: String("a"), 15162 Assignee: &User{ 15163 Login: String("l"), 15164 ID: Int64(1), 15165 NodeID: String("n"), 15166 URL: String("u"), 15167 ReposURL: String("r"), 15168 EventsURL: String("e"), 15169 AvatarURL: String("a"), 15170 }, 15171 Number: Int(1), 15172 PullRequest: &PullRequest{ID: Int64(1)}, 15173 Changes: &EditChange{ 15174 Title: &EditTitle{ 15175 From: String("TitleFrom"), 15176 }, 15177 Body: &EditBody{ 15178 From: String("BodyFrom"), 15179 }, 15180 Base: &EditBase{ 15181 Ref: &EditRef{ 15182 From: String("BaseRefFrom"), 15183 }, 15184 SHA: &EditSHA{ 15185 From: String("BaseSHAFrom"), 15186 }, 15187 }, 15188 }, 15189 RequestedReviewer: &User{ 15190 Login: String("l"), 15191 ID: Int64(1), 15192 NodeID: String("n"), 15193 URL: String("u"), 15194 ReposURL: String("r"), 15195 EventsURL: String("e"), 15196 AvatarURL: String("a"), 15197 }, 15198 RequestedTeam: &Team{ID: Int64(1)}, 15199 Label: &Label{ID: Int64(1)}, 15200 Before: String("before"), 15201 After: String("after"), 15202 Repo: &Repository{ 15203 ID: Int64(1), 15204 URL: String("s"), 15205 Name: String("n"), 15206 }, 15207 PerformedViaGithubApp: &App{ 15208 ID: Int64(1), 15209 NodeID: String("n"), 15210 Slug: String("s"), 15211 Name: String("n"), 15212 Description: String("d"), 15213 ExternalURL: String("e"), 15214 HTMLURL: String("h"), 15215 }, 15216 Organization: &Organization{ 15217 BillingEmail: String("be"), 15218 Blog: String("b"), 15219 Company: String("c"), 15220 Email: String("e"), 15221 TwitterUsername: String("tu"), 15222 Location: String("loc"), 15223 Name: String("n"), 15224 Description: String("d"), 15225 IsVerified: Bool(true), 15226 HasOrganizationProjects: Bool(true), 15227 HasRepositoryProjects: Bool(true), 15228 DefaultRepoPermission: String("drp"), 15229 MembersCanCreateRepos: Bool(true), 15230 MembersCanCreateInternalRepos: Bool(true), 15231 MembersCanCreatePrivateRepos: Bool(true), 15232 MembersCanCreatePublicRepos: Bool(false), 15233 MembersAllowedRepositoryCreationType: String("marct"), 15234 MembersCanCreatePages: Bool(true), 15235 MembersCanCreatePublicPages: Bool(false), 15236 MembersCanCreatePrivatePages: Bool(true), 15237 }, 15238 Sender: &User{ 15239 Login: String("l"), 15240 ID: Int64(1), 15241 NodeID: String("n"), 15242 URL: String("u"), 15243 ReposURL: String("r"), 15244 EventsURL: String("e"), 15245 AvatarURL: String("a"), 15246 }, 15247 Installation: &Installation{ 15248 ID: Int64(1), 15249 NodeID: String("nid"), 15250 AppID: Int64(1), 15251 AppSlug: String("as"), 15252 TargetID: Int64(1), 15253 Account: &User{ 15254 Login: String("l"), 15255 ID: Int64(1), 15256 URL: String("u"), 15257 AvatarURL: String("a"), 15258 GravatarID: String("g"), 15259 Name: String("n"), 15260 Company: String("c"), 15261 Blog: String("b"), 15262 Location: String("l"), 15263 Email: String("e"), 15264 Hireable: Bool(true), 15265 Bio: String("b"), 15266 TwitterUsername: String("t"), 15267 PublicRepos: Int(1), 15268 Followers: Int(1), 15269 Following: Int(1), 15270 CreatedAt: &Timestamp{referenceTime}, 15271 SuspendedAt: &Timestamp{referenceTime}, 15272 }, 15273 AccessTokensURL: String("atu"), 15274 RepositoriesURL: String("ru"), 15275 HTMLURL: String("hu"), 15276 TargetType: String("tt"), 15277 SingleFileName: String("sfn"), 15278 RepositorySelection: String("rs"), 15279 Events: []string{"e"}, 15280 SingleFilePaths: []string{"s"}, 15281 Permissions: &InstallationPermissions{ 15282 Actions: String("a"), 15283 Administration: String("ad"), 15284 Checks: String("c"), 15285 Contents: String("co"), 15286 ContentReferences: String("cr"), 15287 Deployments: String("d"), 15288 Environments: String("e"), 15289 Issues: String("i"), 15290 Metadata: String("md"), 15291 Members: String("m"), 15292 OrganizationAdministration: String("oa"), 15293 OrganizationHooks: String("oh"), 15294 OrganizationPlan: String("op"), 15295 OrganizationPreReceiveHooks: String("opr"), 15296 OrganizationProjects: String("op"), 15297 OrganizationSecrets: String("os"), 15298 OrganizationSelfHostedRunners: String("osh"), 15299 OrganizationUserBlocking: String("oub"), 15300 Packages: String("pkg"), 15301 Pages: String("pg"), 15302 PullRequests: String("pr"), 15303 RepositoryHooks: String("rh"), 15304 RepositoryProjects: String("rp"), 15305 RepositoryPreReceiveHooks: String("rprh"), 15306 Secrets: String("s"), 15307 SecretScanningAlerts: String("ssa"), 15308 SecurityEvents: String("se"), 15309 SingleFile: String("sf"), 15310 Statuses: String("s"), 15311 TeamDiscussions: String("td"), 15312 VulnerabilityAlerts: String("va"), 15313 Workflows: String("w"), 15314 }, 15315 CreatedAt: &Timestamp{referenceTime}, 15316 UpdatedAt: &Timestamp{referenceTime}, 15317 HasMultipleSingleFiles: Bool(false), 15318 SuspendedBy: &User{ 15319 Login: String("l"), 15320 ID: Int64(1), 15321 URL: String("u"), 15322 AvatarURL: String("a"), 15323 GravatarID: String("g"), 15324 Name: String("n"), 15325 Company: String("c"), 15326 Blog: String("b"), 15327 Location: String("l"), 15328 Email: String("e"), 15329 Hireable: Bool(true), 15330 Bio: String("b"), 15331 TwitterUsername: String("t"), 15332 PublicRepos: Int(1), 15333 Followers: Int(1), 15334 Following: Int(1), 15335 CreatedAt: &Timestamp{referenceTime}, 15336 SuspendedAt: &Timestamp{referenceTime}, 15337 }, 15338 SuspendedAt: &Timestamp{referenceTime}, 15339 }, 15340 } 15341 15342 want := `{ 15343 "action": "a", 15344 "assignee": { 15345 "login": "l", 15346 "id": 1, 15347 "node_id": "n", 15348 "avatar_url": "a", 15349 "url": "u", 15350 "events_url": "e", 15351 "repos_url": "r" 15352 }, 15353 "number": 1, 15354 "pull_request": { 15355 "id": 1 15356 }, 15357 "changes": { 15358 "title": { 15359 "from": "TitleFrom" 15360 }, 15361 "body": { 15362 "from": "BodyFrom" 15363 }, 15364 "base": { 15365 "ref": { 15366 "from": "BaseRefFrom" 15367 }, 15368 "sha": { 15369 "from": "BaseSHAFrom" 15370 } 15371 } 15372 }, 15373 "requested_reviewer": { 15374 "login": "l", 15375 "id": 1, 15376 "node_id": "n", 15377 "avatar_url": "a", 15378 "url": "u", 15379 "events_url": "e", 15380 "repos_url": "r" 15381 }, 15382 "requested_team": { 15383 "id": 1 15384 }, 15385 "label": { 15386 "id": 1 15387 }, 15388 "before": "before", 15389 "after": "after", 15390 "repository": { 15391 "id": 1, 15392 "name": "n", 15393 "url": "s" 15394 }, 15395 "performed_via_github_app": { 15396 "id": 1, 15397 "node_id": "n", 15398 "slug": "s", 15399 "name": "n", 15400 "description": "d", 15401 "external_url": "e", 15402 "html_url": "h" 15403 }, 15404 "organization": { 15405 "name": "n", 15406 "company": "c", 15407 "blog": "b", 15408 "location": "loc", 15409 "email": "e", 15410 "twitter_username": "tu", 15411 "description": "d", 15412 "billing_email": "be", 15413 "is_verified": true, 15414 "has_organization_projects": true, 15415 "has_repository_projects": true, 15416 "default_repository_permission": "drp", 15417 "members_can_create_repositories": true, 15418 "members_can_create_public_repositories": false, 15419 "members_can_create_private_repositories": true, 15420 "members_can_create_internal_repositories": true, 15421 "members_allowed_repository_creation_type": "marct", 15422 "members_can_create_pages": true, 15423 "members_can_create_public_pages": false, 15424 "members_can_create_private_pages": true 15425 }, 15426 "sender": { 15427 "login": "l", 15428 "id": 1, 15429 "node_id": "n", 15430 "avatar_url": "a", 15431 "url": "u", 15432 "events_url": "e", 15433 "repos_url": "r" 15434 }, 15435 "installation": { 15436 "id": 1, 15437 "node_id": "nid", 15438 "app_id": 1, 15439 "app_slug": "as", 15440 "target_id": 1, 15441 "account": { 15442 "login": "l", 15443 "id": 1, 15444 "avatar_url": "a", 15445 "gravatar_id": "g", 15446 "name": "n", 15447 "company": "c", 15448 "blog": "b", 15449 "location": "l", 15450 "email": "e", 15451 "hireable": true, 15452 "bio": "b", 15453 "twitter_username": "t", 15454 "public_repos": 1, 15455 "followers": 1, 15456 "following": 1, 15457 "created_at": ` + referenceTimeStr + `, 15458 "suspended_at": ` + referenceTimeStr + `, 15459 "url": "u" 15460 }, 15461 "access_tokens_url": "atu", 15462 "repositories_url": "ru", 15463 "html_url": "hu", 15464 "target_type": "tt", 15465 "single_file_name": "sfn", 15466 "repository_selection": "rs", 15467 "events": [ 15468 "e" 15469 ], 15470 "single_file_paths": [ 15471 "s" 15472 ], 15473 "permissions": { 15474 "actions": "a", 15475 "administration": "ad", 15476 "checks": "c", 15477 "contents": "co", 15478 "content_references": "cr", 15479 "deployments": "d", 15480 "environments": "e", 15481 "issues": "i", 15482 "metadata": "md", 15483 "members": "m", 15484 "organization_administration": "oa", 15485 "organization_hooks": "oh", 15486 "organization_plan": "op", 15487 "organization_pre_receive_hooks": "opr", 15488 "organization_projects": "op", 15489 "organization_secrets": "os", 15490 "organization_self_hosted_runners": "osh", 15491 "organization_user_blocking": "oub", 15492 "packages": "pkg", 15493 "pages": "pg", 15494 "pull_requests": "pr", 15495 "repository_hooks": "rh", 15496 "repository_projects": "rp", 15497 "repository_pre_receive_hooks": "rprh", 15498 "secrets": "s", 15499 "secret_scanning_alerts": "ssa", 15500 "security_events": "se", 15501 "single_file": "sf", 15502 "statuses": "s", 15503 "team_discussions": "td", 15504 "vulnerability_alerts": "va", 15505 "workflows": "w" 15506 }, 15507 "created_at": ` + referenceTimeStr + `, 15508 "updated_at": ` + referenceTimeStr + `, 15509 "has_multiple_single_files": false, 15510 "suspended_by": { 15511 "login": "l", 15512 "id": 1, 15513 "avatar_url": "a", 15514 "gravatar_id": "g", 15515 "name": "n", 15516 "company": "c", 15517 "blog": "b", 15518 "location": "l", 15519 "email": "e", 15520 "hireable": true, 15521 "bio": "b", 15522 "twitter_username": "t", 15523 "public_repos": 1, 15524 "followers": 1, 15525 "following": 1, 15526 "created_at": ` + referenceTimeStr + `, 15527 "suspended_at": ` + referenceTimeStr + `, 15528 "url": "u" 15529 }, 15530 "suspended_at": ` + referenceTimeStr + ` 15531 } 15532 }` 15533 15534 testJSONMarshal(t, u, want) 15535 } 15536 15537 func TestPullRequestReviewCommentEvent_Marshal(t *testing.T) { 15538 testJSONMarshal(t, &PullRequestReviewCommentEvent{}, "{}") 15539 15540 u := &PullRequestReviewCommentEvent{ 15541 Action: String("a"), 15542 PullRequest: &PullRequest{ID: Int64(1)}, 15543 Comment: &PullRequestComment{ID: Int64(1)}, 15544 Changes: &EditChange{ 15545 Title: &EditTitle{ 15546 From: String("TitleFrom"), 15547 }, 15548 Body: &EditBody{ 15549 From: String("BodyFrom"), 15550 }, 15551 Base: &EditBase{ 15552 Ref: &EditRef{ 15553 From: String("BaseRefFrom"), 15554 }, 15555 SHA: &EditSHA{ 15556 From: String("BaseSHAFrom"), 15557 }, 15558 }, 15559 }, 15560 Repo: &Repository{ 15561 ID: Int64(1), 15562 URL: String("s"), 15563 Name: String("n"), 15564 }, 15565 Sender: &User{ 15566 Login: String("l"), 15567 ID: Int64(1), 15568 NodeID: String("n"), 15569 URL: String("u"), 15570 ReposURL: String("r"), 15571 EventsURL: String("e"), 15572 AvatarURL: String("a"), 15573 }, 15574 Installation: &Installation{ 15575 ID: Int64(1), 15576 NodeID: String("nid"), 15577 AppID: Int64(1), 15578 AppSlug: String("as"), 15579 TargetID: Int64(1), 15580 Account: &User{ 15581 Login: String("l"), 15582 ID: Int64(1), 15583 URL: String("u"), 15584 AvatarURL: String("a"), 15585 GravatarID: String("g"), 15586 Name: String("n"), 15587 Company: String("c"), 15588 Blog: String("b"), 15589 Location: String("l"), 15590 Email: String("e"), 15591 Hireable: Bool(true), 15592 Bio: String("b"), 15593 TwitterUsername: String("t"), 15594 PublicRepos: Int(1), 15595 Followers: Int(1), 15596 Following: Int(1), 15597 CreatedAt: &Timestamp{referenceTime}, 15598 SuspendedAt: &Timestamp{referenceTime}, 15599 }, 15600 AccessTokensURL: String("atu"), 15601 RepositoriesURL: String("ru"), 15602 HTMLURL: String("hu"), 15603 TargetType: String("tt"), 15604 SingleFileName: String("sfn"), 15605 RepositorySelection: String("rs"), 15606 Events: []string{"e"}, 15607 SingleFilePaths: []string{"s"}, 15608 Permissions: &InstallationPermissions{ 15609 Actions: String("a"), 15610 Administration: String("ad"), 15611 Checks: String("c"), 15612 Contents: String("co"), 15613 ContentReferences: String("cr"), 15614 Deployments: String("d"), 15615 Environments: String("e"), 15616 Issues: String("i"), 15617 Metadata: String("md"), 15618 Members: String("m"), 15619 OrganizationAdministration: String("oa"), 15620 OrganizationHooks: String("oh"), 15621 OrganizationPlan: String("op"), 15622 OrganizationPreReceiveHooks: String("opr"), 15623 OrganizationProjects: String("op"), 15624 OrganizationSecrets: String("os"), 15625 OrganizationSelfHostedRunners: String("osh"), 15626 OrganizationUserBlocking: String("oub"), 15627 Packages: String("pkg"), 15628 Pages: String("pg"), 15629 PullRequests: String("pr"), 15630 RepositoryHooks: String("rh"), 15631 RepositoryProjects: String("rp"), 15632 RepositoryPreReceiveHooks: String("rprh"), 15633 Secrets: String("s"), 15634 SecretScanningAlerts: String("ssa"), 15635 SecurityEvents: String("se"), 15636 SingleFile: String("sf"), 15637 Statuses: String("s"), 15638 TeamDiscussions: String("td"), 15639 VulnerabilityAlerts: String("va"), 15640 Workflows: String("w"), 15641 }, 15642 CreatedAt: &Timestamp{referenceTime}, 15643 UpdatedAt: &Timestamp{referenceTime}, 15644 HasMultipleSingleFiles: Bool(false), 15645 SuspendedBy: &User{ 15646 Login: String("l"), 15647 ID: Int64(1), 15648 URL: String("u"), 15649 AvatarURL: String("a"), 15650 GravatarID: String("g"), 15651 Name: String("n"), 15652 Company: String("c"), 15653 Blog: String("b"), 15654 Location: String("l"), 15655 Email: String("e"), 15656 Hireable: Bool(true), 15657 Bio: String("b"), 15658 TwitterUsername: String("t"), 15659 PublicRepos: Int(1), 15660 Followers: Int(1), 15661 Following: Int(1), 15662 CreatedAt: &Timestamp{referenceTime}, 15663 SuspendedAt: &Timestamp{referenceTime}, 15664 }, 15665 SuspendedAt: &Timestamp{referenceTime}, 15666 }, 15667 } 15668 15669 want := `{ 15670 "action": "a", 15671 "pull_request": { 15672 "id": 1 15673 }, 15674 "comment": { 15675 "id": 1 15676 }, 15677 "changes": { 15678 "title": { 15679 "from": "TitleFrom" 15680 }, 15681 "body": { 15682 "from": "BodyFrom" 15683 }, 15684 "base": { 15685 "ref": { 15686 "from": "BaseRefFrom" 15687 }, 15688 "sha": { 15689 "from": "BaseSHAFrom" 15690 } 15691 } 15692 }, 15693 "repository": { 15694 "id": 1, 15695 "name": "n", 15696 "url": "s" 15697 }, 15698 "sender": { 15699 "login": "l", 15700 "id": 1, 15701 "node_id": "n", 15702 "avatar_url": "a", 15703 "url": "u", 15704 "events_url": "e", 15705 "repos_url": "r" 15706 }, 15707 "installation": { 15708 "id": 1, 15709 "node_id": "nid", 15710 "app_id": 1, 15711 "app_slug": "as", 15712 "target_id": 1, 15713 "account": { 15714 "login": "l", 15715 "id": 1, 15716 "avatar_url": "a", 15717 "gravatar_id": "g", 15718 "name": "n", 15719 "company": "c", 15720 "blog": "b", 15721 "location": "l", 15722 "email": "e", 15723 "hireable": true, 15724 "bio": "b", 15725 "twitter_username": "t", 15726 "public_repos": 1, 15727 "followers": 1, 15728 "following": 1, 15729 "created_at": ` + referenceTimeStr + `, 15730 "suspended_at": ` + referenceTimeStr + `, 15731 "url": "u" 15732 }, 15733 "access_tokens_url": "atu", 15734 "repositories_url": "ru", 15735 "html_url": "hu", 15736 "target_type": "tt", 15737 "single_file_name": "sfn", 15738 "repository_selection": "rs", 15739 "events": [ 15740 "e" 15741 ], 15742 "single_file_paths": [ 15743 "s" 15744 ], 15745 "permissions": { 15746 "actions": "a", 15747 "administration": "ad", 15748 "checks": "c", 15749 "contents": "co", 15750 "content_references": "cr", 15751 "deployments": "d", 15752 "environments": "e", 15753 "issues": "i", 15754 "metadata": "md", 15755 "members": "m", 15756 "organization_administration": "oa", 15757 "organization_hooks": "oh", 15758 "organization_plan": "op", 15759 "organization_pre_receive_hooks": "opr", 15760 "organization_projects": "op", 15761 "organization_secrets": "os", 15762 "organization_self_hosted_runners": "osh", 15763 "organization_user_blocking": "oub", 15764 "packages": "pkg", 15765 "pages": "pg", 15766 "pull_requests": "pr", 15767 "repository_hooks": "rh", 15768 "repository_projects": "rp", 15769 "repository_pre_receive_hooks": "rprh", 15770 "secrets": "s", 15771 "secret_scanning_alerts": "ssa", 15772 "security_events": "se", 15773 "single_file": "sf", 15774 "statuses": "s", 15775 "team_discussions": "td", 15776 "vulnerability_alerts": "va", 15777 "workflows": "w" 15778 }, 15779 "created_at": ` + referenceTimeStr + `, 15780 "updated_at": ` + referenceTimeStr + `, 15781 "has_multiple_single_files": false, 15782 "suspended_by": { 15783 "login": "l", 15784 "id": 1, 15785 "avatar_url": "a", 15786 "gravatar_id": "g", 15787 "name": "n", 15788 "company": "c", 15789 "blog": "b", 15790 "location": "l", 15791 "email": "e", 15792 "hireable": true, 15793 "bio": "b", 15794 "twitter_username": "t", 15795 "public_repos": 1, 15796 "followers": 1, 15797 "following": 1, 15798 "created_at": ` + referenceTimeStr + `, 15799 "suspended_at": ` + referenceTimeStr + `, 15800 "url": "u" 15801 }, 15802 "suspended_at": ` + referenceTimeStr + ` 15803 } 15804 }` 15805 15806 testJSONMarshal(t, u, want) 15807 } 15808 15809 func TestPullRequestReviewThreadEvent_Marshal(t *testing.T) { 15810 testJSONMarshal(t, &PullRequestReviewThreadEvent{}, "{}") 15811 15812 u := &PullRequestReviewThreadEvent{ 15813 Action: String("a"), 15814 PullRequest: &PullRequest{ID: Int64(1)}, 15815 Thread: &PullRequestThread{ 15816 Comments: []*PullRequestComment{{ID: Int64(1)}, {ID: Int64(2)}}, 15817 }, 15818 Repo: &Repository{ 15819 ID: Int64(1), 15820 URL: String("s"), 15821 Name: String("n"), 15822 }, 15823 Sender: &User{ 15824 Login: String("l"), 15825 ID: Int64(1), 15826 NodeID: String("n"), 15827 URL: String("u"), 15828 ReposURL: String("r"), 15829 EventsURL: String("e"), 15830 AvatarURL: String("a"), 15831 }, 15832 Installation: &Installation{ 15833 ID: Int64(1), 15834 NodeID: String("nid"), 15835 AppID: Int64(1), 15836 AppSlug: String("as"), 15837 TargetID: Int64(1), 15838 Account: &User{ 15839 Login: String("l"), 15840 ID: Int64(1), 15841 URL: String("u"), 15842 AvatarURL: String("a"), 15843 GravatarID: String("g"), 15844 Name: String("n"), 15845 Company: String("c"), 15846 Blog: String("b"), 15847 Location: String("l"), 15848 Email: String("e"), 15849 Hireable: Bool(true), 15850 Bio: String("b"), 15851 TwitterUsername: String("t"), 15852 PublicRepos: Int(1), 15853 Followers: Int(1), 15854 Following: Int(1), 15855 CreatedAt: &Timestamp{referenceTime}, 15856 SuspendedAt: &Timestamp{referenceTime}, 15857 }, 15858 AccessTokensURL: String("atu"), 15859 RepositoriesURL: String("ru"), 15860 HTMLURL: String("hu"), 15861 TargetType: String("tt"), 15862 SingleFileName: String("sfn"), 15863 RepositorySelection: String("rs"), 15864 Events: []string{"e"}, 15865 SingleFilePaths: []string{"s"}, 15866 Permissions: &InstallationPermissions{ 15867 Actions: String("a"), 15868 Administration: String("ad"), 15869 Checks: String("c"), 15870 Contents: String("co"), 15871 ContentReferences: String("cr"), 15872 Deployments: String("d"), 15873 Environments: String("e"), 15874 Issues: String("i"), 15875 Metadata: String("md"), 15876 Members: String("m"), 15877 OrganizationAdministration: String("oa"), 15878 OrganizationHooks: String("oh"), 15879 OrganizationPlan: String("op"), 15880 OrganizationPreReceiveHooks: String("opr"), 15881 OrganizationProjects: String("op"), 15882 OrganizationSecrets: String("os"), 15883 OrganizationSelfHostedRunners: String("osh"), 15884 OrganizationUserBlocking: String("oub"), 15885 Packages: String("pkg"), 15886 Pages: String("pg"), 15887 PullRequests: String("pr"), 15888 RepositoryHooks: String("rh"), 15889 RepositoryProjects: String("rp"), 15890 RepositoryPreReceiveHooks: String("rprh"), 15891 Secrets: String("s"), 15892 SecretScanningAlerts: String("ssa"), 15893 SecurityEvents: String("se"), 15894 SingleFile: String("sf"), 15895 Statuses: String("s"), 15896 TeamDiscussions: String("td"), 15897 VulnerabilityAlerts: String("va"), 15898 Workflows: String("w"), 15899 }, 15900 CreatedAt: &Timestamp{referenceTime}, 15901 UpdatedAt: &Timestamp{referenceTime}, 15902 HasMultipleSingleFiles: Bool(false), 15903 SuspendedBy: &User{ 15904 Login: String("l"), 15905 ID: Int64(1), 15906 URL: String("u"), 15907 AvatarURL: String("a"), 15908 GravatarID: String("g"), 15909 Name: String("n"), 15910 Company: String("c"), 15911 Blog: String("b"), 15912 Location: String("l"), 15913 Email: String("e"), 15914 Hireable: Bool(true), 15915 Bio: String("b"), 15916 TwitterUsername: String("t"), 15917 PublicRepos: Int(1), 15918 Followers: Int(1), 15919 Following: Int(1), 15920 CreatedAt: &Timestamp{referenceTime}, 15921 SuspendedAt: &Timestamp{referenceTime}, 15922 }, 15923 SuspendedAt: &Timestamp{referenceTime}, 15924 }, 15925 } 15926 15927 want := `{ 15928 "action": "a", 15929 "pull_request": { 15930 "id": 1 15931 }, 15932 "thread": { 15933 "comments": [ 15934 { 15935 "id": 1 15936 }, 15937 { 15938 "id": 2 15939 } 15940 ] 15941 }, 15942 "repository": { 15943 "id": 1, 15944 "name": "n", 15945 "url": "s" 15946 }, 15947 "sender": { 15948 "login": "l", 15949 "id": 1, 15950 "node_id": "n", 15951 "avatar_url": "a", 15952 "url": "u", 15953 "events_url": "e", 15954 "repos_url": "r" 15955 }, 15956 "installation": { 15957 "id": 1, 15958 "node_id": "nid", 15959 "app_id": 1, 15960 "app_slug": "as", 15961 "target_id": 1, 15962 "account": { 15963 "login": "l", 15964 "id": 1, 15965 "avatar_url": "a", 15966 "gravatar_id": "g", 15967 "name": "n", 15968 "company": "c", 15969 "blog": "b", 15970 "location": "l", 15971 "email": "e", 15972 "hireable": true, 15973 "bio": "b", 15974 "twitter_username": "t", 15975 "public_repos": 1, 15976 "followers": 1, 15977 "following": 1, 15978 "created_at": ` + referenceTimeStr + `, 15979 "suspended_at": ` + referenceTimeStr + `, 15980 "url": "u" 15981 }, 15982 "access_tokens_url": "atu", 15983 "repositories_url": "ru", 15984 "html_url": "hu", 15985 "target_type": "tt", 15986 "single_file_name": "sfn", 15987 "repository_selection": "rs", 15988 "events": [ 15989 "e" 15990 ], 15991 "single_file_paths": [ 15992 "s" 15993 ], 15994 "permissions": { 15995 "actions": "a", 15996 "administration": "ad", 15997 "checks": "c", 15998 "contents": "co", 15999 "content_references": "cr", 16000 "deployments": "d", 16001 "environments": "e", 16002 "issues": "i", 16003 "metadata": "md", 16004 "members": "m", 16005 "organization_administration": "oa", 16006 "organization_hooks": "oh", 16007 "organization_plan": "op", 16008 "organization_pre_receive_hooks": "opr", 16009 "organization_projects": "op", 16010 "organization_secrets": "os", 16011 "organization_self_hosted_runners": "osh", 16012 "organization_user_blocking": "oub", 16013 "packages": "pkg", 16014 "pages": "pg", 16015 "pull_requests": "pr", 16016 "repository_hooks": "rh", 16017 "repository_projects": "rp", 16018 "repository_pre_receive_hooks": "rprh", 16019 "secrets": "s", 16020 "secret_scanning_alerts": "ssa", 16021 "security_events": "se", 16022 "single_file": "sf", 16023 "statuses": "s", 16024 "team_discussions": "td", 16025 "vulnerability_alerts": "va", 16026 "workflows": "w" 16027 }, 16028 "created_at": ` + referenceTimeStr + `, 16029 "updated_at": ` + referenceTimeStr + `, 16030 "has_multiple_single_files": false, 16031 "suspended_by": { 16032 "login": "l", 16033 "id": 1, 16034 "avatar_url": "a", 16035 "gravatar_id": "g", 16036 "name": "n", 16037 "company": "c", 16038 "blog": "b", 16039 "location": "l", 16040 "email": "e", 16041 "hireable": true, 16042 "bio": "b", 16043 "twitter_username": "t", 16044 "public_repos": 1, 16045 "followers": 1, 16046 "following": 1, 16047 "created_at": ` + referenceTimeStr + `, 16048 "suspended_at": ` + referenceTimeStr + `, 16049 "url": "u" 16050 }, 16051 "suspended_at": ` + referenceTimeStr + ` 16052 } 16053 }` 16054 16055 testJSONMarshal(t, u, want) 16056 } 16057 16058 func TestPullRequestTargetEvent_Marshal(t *testing.T) { 16059 testJSONMarshal(t, &PullRequestTargetEvent{}, "{}") 16060 16061 u := &PullRequestTargetEvent{ 16062 Action: String("a"), 16063 Assignee: &User{ 16064 Login: String("l"), 16065 ID: Int64(1), 16066 NodeID: String("n"), 16067 URL: String("u"), 16068 ReposURL: String("r"), 16069 EventsURL: String("e"), 16070 AvatarURL: String("a"), 16071 }, 16072 Number: Int(1), 16073 PullRequest: &PullRequest{ID: Int64(1)}, 16074 Changes: &EditChange{ 16075 Title: &EditTitle{ 16076 From: String("TitleFrom"), 16077 }, 16078 Body: &EditBody{ 16079 From: String("BodyFrom"), 16080 }, 16081 Base: &EditBase{ 16082 Ref: &EditRef{ 16083 From: String("BaseRefFrom"), 16084 }, 16085 SHA: &EditSHA{ 16086 From: String("BaseSHAFrom"), 16087 }, 16088 }, 16089 }, 16090 RequestedReviewer: &User{ 16091 Login: String("l"), 16092 ID: Int64(1), 16093 NodeID: String("n"), 16094 URL: String("u"), 16095 ReposURL: String("r"), 16096 EventsURL: String("e"), 16097 AvatarURL: String("a"), 16098 }, 16099 RequestedTeam: &Team{ID: Int64(1)}, 16100 Label: &Label{ID: Int64(1)}, 16101 Before: String("before"), 16102 After: String("after"), 16103 Repo: &Repository{ 16104 ID: Int64(1), 16105 URL: String("s"), 16106 Name: String("n"), 16107 }, 16108 PerformedViaGithubApp: &App{ 16109 ID: Int64(1), 16110 NodeID: String("n"), 16111 Slug: String("s"), 16112 Name: String("n"), 16113 Description: String("d"), 16114 ExternalURL: String("e"), 16115 HTMLURL: String("h"), 16116 }, 16117 Organization: &Organization{ 16118 BillingEmail: String("be"), 16119 Blog: String("b"), 16120 Company: String("c"), 16121 Email: String("e"), 16122 TwitterUsername: String("tu"), 16123 Location: String("loc"), 16124 Name: String("n"), 16125 Description: String("d"), 16126 IsVerified: Bool(true), 16127 HasOrganizationProjects: Bool(true), 16128 HasRepositoryProjects: Bool(true), 16129 DefaultRepoPermission: String("drp"), 16130 MembersCanCreateRepos: Bool(true), 16131 MembersCanCreateInternalRepos: Bool(true), 16132 MembersCanCreatePrivateRepos: Bool(true), 16133 MembersCanCreatePublicRepos: Bool(false), 16134 MembersAllowedRepositoryCreationType: String("marct"), 16135 MembersCanCreatePages: Bool(true), 16136 MembersCanCreatePublicPages: Bool(false), 16137 MembersCanCreatePrivatePages: Bool(true), 16138 }, 16139 Sender: &User{ 16140 Login: String("l"), 16141 ID: Int64(1), 16142 NodeID: String("n"), 16143 URL: String("u"), 16144 ReposURL: String("r"), 16145 EventsURL: String("e"), 16146 AvatarURL: String("a"), 16147 }, 16148 Installation: &Installation{ 16149 ID: Int64(1), 16150 NodeID: String("nid"), 16151 AppID: Int64(1), 16152 AppSlug: String("as"), 16153 TargetID: Int64(1), 16154 Account: &User{ 16155 Login: String("l"), 16156 ID: Int64(1), 16157 URL: String("u"), 16158 AvatarURL: String("a"), 16159 GravatarID: String("g"), 16160 Name: String("n"), 16161 Company: String("c"), 16162 Blog: String("b"), 16163 Location: String("l"), 16164 Email: String("e"), 16165 Hireable: Bool(true), 16166 Bio: String("b"), 16167 TwitterUsername: String("t"), 16168 PublicRepos: Int(1), 16169 Followers: Int(1), 16170 Following: Int(1), 16171 CreatedAt: &Timestamp{referenceTime}, 16172 SuspendedAt: &Timestamp{referenceTime}, 16173 }, 16174 AccessTokensURL: String("atu"), 16175 RepositoriesURL: String("ru"), 16176 HTMLURL: String("hu"), 16177 TargetType: String("tt"), 16178 SingleFileName: String("sfn"), 16179 RepositorySelection: String("rs"), 16180 Events: []string{"e"}, 16181 SingleFilePaths: []string{"s"}, 16182 Permissions: &InstallationPermissions{ 16183 Actions: String("a"), 16184 Administration: String("ad"), 16185 Checks: String("c"), 16186 Contents: String("co"), 16187 ContentReferences: String("cr"), 16188 Deployments: String("d"), 16189 Environments: String("e"), 16190 Issues: String("i"), 16191 Metadata: String("md"), 16192 Members: String("m"), 16193 OrganizationAdministration: String("oa"), 16194 OrganizationHooks: String("oh"), 16195 OrganizationPlan: String("op"), 16196 OrganizationPreReceiveHooks: String("opr"), 16197 OrganizationProjects: String("op"), 16198 OrganizationSecrets: String("os"), 16199 OrganizationSelfHostedRunners: String("osh"), 16200 OrganizationUserBlocking: String("oub"), 16201 Packages: String("pkg"), 16202 Pages: String("pg"), 16203 PullRequests: String("pr"), 16204 RepositoryHooks: String("rh"), 16205 RepositoryProjects: String("rp"), 16206 RepositoryPreReceiveHooks: String("rprh"), 16207 Secrets: String("s"), 16208 SecretScanningAlerts: String("ssa"), 16209 SecurityEvents: String("se"), 16210 SingleFile: String("sf"), 16211 Statuses: String("s"), 16212 TeamDiscussions: String("td"), 16213 VulnerabilityAlerts: String("va"), 16214 Workflows: String("w"), 16215 }, 16216 CreatedAt: &Timestamp{referenceTime}, 16217 UpdatedAt: &Timestamp{referenceTime}, 16218 HasMultipleSingleFiles: Bool(false), 16219 SuspendedBy: &User{ 16220 Login: String("l"), 16221 ID: Int64(1), 16222 URL: String("u"), 16223 AvatarURL: String("a"), 16224 GravatarID: String("g"), 16225 Name: String("n"), 16226 Company: String("c"), 16227 Blog: String("b"), 16228 Location: String("l"), 16229 Email: String("e"), 16230 Hireable: Bool(true), 16231 Bio: String("b"), 16232 TwitterUsername: String("t"), 16233 PublicRepos: Int(1), 16234 Followers: Int(1), 16235 Following: Int(1), 16236 CreatedAt: &Timestamp{referenceTime}, 16237 SuspendedAt: &Timestamp{referenceTime}, 16238 }, 16239 SuspendedAt: &Timestamp{referenceTime}, 16240 }, 16241 } 16242 16243 want := `{ 16244 "action": "a", 16245 "assignee": { 16246 "login": "l", 16247 "id": 1, 16248 "node_id": "n", 16249 "avatar_url": "a", 16250 "url": "u", 16251 "events_url": "e", 16252 "repos_url": "r" 16253 }, 16254 "number": 1, 16255 "pull_request": { 16256 "id": 1 16257 }, 16258 "changes": { 16259 "title": { 16260 "from": "TitleFrom" 16261 }, 16262 "body": { 16263 "from": "BodyFrom" 16264 }, 16265 "base": { 16266 "ref": { 16267 "from": "BaseRefFrom" 16268 }, 16269 "sha": { 16270 "from": "BaseSHAFrom" 16271 } 16272 } 16273 }, 16274 "requested_reviewer": { 16275 "login": "l", 16276 "id": 1, 16277 "node_id": "n", 16278 "avatar_url": "a", 16279 "url": "u", 16280 "events_url": "e", 16281 "repos_url": "r" 16282 }, 16283 "requested_team": { 16284 "id": 1 16285 }, 16286 "label": { 16287 "id": 1 16288 }, 16289 "before": "before", 16290 "after": "after", 16291 "repository": { 16292 "id": 1, 16293 "name": "n", 16294 "url": "s" 16295 }, 16296 "performed_via_github_app": { 16297 "id": 1, 16298 "node_id": "n", 16299 "slug": "s", 16300 "name": "n", 16301 "description": "d", 16302 "external_url": "e", 16303 "html_url": "h" 16304 }, 16305 "organization": { 16306 "name": "n", 16307 "company": "c", 16308 "blog": "b", 16309 "location": "loc", 16310 "email": "e", 16311 "twitter_username": "tu", 16312 "description": "d", 16313 "billing_email": "be", 16314 "is_verified": true, 16315 "has_organization_projects": true, 16316 "has_repository_projects": true, 16317 "default_repository_permission": "drp", 16318 "members_can_create_repositories": true, 16319 "members_can_create_public_repositories": false, 16320 "members_can_create_private_repositories": true, 16321 "members_can_create_internal_repositories": true, 16322 "members_allowed_repository_creation_type": "marct", 16323 "members_can_create_pages": true, 16324 "members_can_create_public_pages": false, 16325 "members_can_create_private_pages": true 16326 }, 16327 "sender": { 16328 "login": "l", 16329 "id": 1, 16330 "node_id": "n", 16331 "avatar_url": "a", 16332 "url": "u", 16333 "events_url": "e", 16334 "repos_url": "r" 16335 }, 16336 "installation": { 16337 "id": 1, 16338 "node_id": "nid", 16339 "app_id": 1, 16340 "app_slug": "as", 16341 "target_id": 1, 16342 "account": { 16343 "login": "l", 16344 "id": 1, 16345 "avatar_url": "a", 16346 "gravatar_id": "g", 16347 "name": "n", 16348 "company": "c", 16349 "blog": "b", 16350 "location": "l", 16351 "email": "e", 16352 "hireable": true, 16353 "bio": "b", 16354 "twitter_username": "t", 16355 "public_repos": 1, 16356 "followers": 1, 16357 "following": 1, 16358 "created_at": ` + referenceTimeStr + `, 16359 "suspended_at": ` + referenceTimeStr + `, 16360 "url": "u" 16361 }, 16362 "access_tokens_url": "atu", 16363 "repositories_url": "ru", 16364 "html_url": "hu", 16365 "target_type": "tt", 16366 "single_file_name": "sfn", 16367 "repository_selection": "rs", 16368 "events": [ 16369 "e" 16370 ], 16371 "single_file_paths": [ 16372 "s" 16373 ], 16374 "permissions": { 16375 "actions": "a", 16376 "administration": "ad", 16377 "checks": "c", 16378 "contents": "co", 16379 "content_references": "cr", 16380 "deployments": "d", 16381 "environments": "e", 16382 "issues": "i", 16383 "metadata": "md", 16384 "members": "m", 16385 "organization_administration": "oa", 16386 "organization_hooks": "oh", 16387 "organization_plan": "op", 16388 "organization_pre_receive_hooks": "opr", 16389 "organization_projects": "op", 16390 "organization_secrets": "os", 16391 "organization_self_hosted_runners": "osh", 16392 "organization_user_blocking": "oub", 16393 "packages": "pkg", 16394 "pages": "pg", 16395 "pull_requests": "pr", 16396 "repository_hooks": "rh", 16397 "repository_projects": "rp", 16398 "repository_pre_receive_hooks": "rprh", 16399 "secrets": "s", 16400 "secret_scanning_alerts": "ssa", 16401 "security_events": "se", 16402 "single_file": "sf", 16403 "statuses": "s", 16404 "team_discussions": "td", 16405 "vulnerability_alerts": "va", 16406 "workflows": "w" 16407 }, 16408 "created_at": ` + referenceTimeStr + `, 16409 "updated_at": ` + referenceTimeStr + `, 16410 "has_multiple_single_files": false, 16411 "suspended_by": { 16412 "login": "l", 16413 "id": 1, 16414 "avatar_url": "a", 16415 "gravatar_id": "g", 16416 "name": "n", 16417 "company": "c", 16418 "blog": "b", 16419 "location": "l", 16420 "email": "e", 16421 "hireable": true, 16422 "bio": "b", 16423 "twitter_username": "t", 16424 "public_repos": 1, 16425 "followers": 1, 16426 "following": 1, 16427 "created_at": ` + referenceTimeStr + `, 16428 "suspended_at": ` + referenceTimeStr + `, 16429 "url": "u" 16430 }, 16431 "suspended_at": ` + referenceTimeStr + ` 16432 } 16433 }` 16434 16435 testJSONMarshal(t, u, want) 16436 } 16437 16438 func TestRepositoryVulnerabilityAlertEvent_Marshal(t *testing.T) { 16439 testJSONMarshal(t, &RepositoryVulnerabilityAlertEvent{}, "{}") 16440 16441 u := &RepositoryVulnerabilityAlertEvent{ 16442 Action: String("a"), 16443 Alert: &RepositoryVulnerabilityAlert{ 16444 ID: Int64(1), 16445 AffectedRange: String("ar"), 16446 AffectedPackageName: String("apn"), 16447 ExternalReference: String("er"), 16448 ExternalIdentifier: String("ei"), 16449 FixedIn: String("fi"), 16450 Dismisser: &User{ 16451 Login: String("l"), 16452 ID: Int64(1), 16453 NodeID: String("n"), 16454 URL: String("u"), 16455 ReposURL: String("r"), 16456 EventsURL: String("e"), 16457 AvatarURL: String("a"), 16458 }, 16459 DismissReason: String("dr"), 16460 DismissedAt: &Timestamp{referenceTime}, 16461 }, 16462 Repository: &Repository{ 16463 ID: Int64(1), 16464 URL: String("s"), 16465 Name: String("n"), 16466 }, 16467 } 16468 16469 want := `{ 16470 "action": "a", 16471 "alert": { 16472 "id": 1, 16473 "affected_range": "ar", 16474 "affected_package_name": "apn", 16475 "external_reference": "er", 16476 "external_identifier": "ei", 16477 "fixed_in": "fi", 16478 "dismisser": { 16479 "login": "l", 16480 "id": 1, 16481 "node_id": "n", 16482 "avatar_url": "a", 16483 "url": "u", 16484 "events_url": "e", 16485 "repos_url": "r" 16486 }, 16487 "dismiss_reason": "dr", 16488 "dismissed_at": ` + referenceTimeStr + ` 16489 }, 16490 "repository": { 16491 "id": 1, 16492 "name": "n", 16493 "url": "s" 16494 } 16495 }` 16496 16497 testJSONMarshal(t, u, want) 16498 } 16499 16500 func TestSecretScanningAlertEvent_Marshal(t *testing.T) { 16501 testJSONMarshal(t, &SecretScanningAlertEvent{}, "{}") 16502 16503 u := &SecretScanningAlertEvent{ 16504 Action: String("a"), 16505 Alert: &SecretScanningAlert{ 16506 Number: Int(1), 16507 SecretType: String("t"), 16508 Resolution: String("r"), 16509 ResolvedBy: &User{ 16510 Login: String("l"), 16511 ID: Int64(1), 16512 NodeID: String("n"), 16513 URL: String("u"), 16514 ReposURL: String("r"), 16515 EventsURL: String("e"), 16516 AvatarURL: String("a"), 16517 }, 16518 ResolvedAt: &Timestamp{referenceTime}, 16519 }, 16520 Repo: &Repository{ 16521 ID: Int64(1), 16522 URL: String("s"), 16523 Name: String("n"), 16524 }, 16525 Organization: &Organization{ 16526 BillingEmail: String("be"), 16527 Blog: String("b"), 16528 Company: String("c"), 16529 Email: String("e"), 16530 TwitterUsername: String("tu"), 16531 Location: String("loc"), 16532 Name: String("n"), 16533 Description: String("d"), 16534 IsVerified: Bool(true), 16535 HasOrganizationProjects: Bool(true), 16536 HasRepositoryProjects: Bool(true), 16537 DefaultRepoPermission: String("drp"), 16538 MembersCanCreateRepos: Bool(true), 16539 MembersCanCreateInternalRepos: Bool(true), 16540 MembersCanCreatePrivateRepos: Bool(true), 16541 MembersCanCreatePublicRepos: Bool(false), 16542 MembersAllowedRepositoryCreationType: String("marct"), 16543 MembersCanCreatePages: Bool(true), 16544 MembersCanCreatePublicPages: Bool(false), 16545 MembersCanCreatePrivatePages: Bool(true), 16546 }, 16547 Enterprise: &Enterprise{ 16548 ID: Int(1), 16549 Slug: String("s"), 16550 Name: String("n"), 16551 NodeID: String("nid"), 16552 AvatarURL: String("au"), 16553 Description: String("d"), 16554 WebsiteURL: String("wu"), 16555 HTMLURL: String("hu"), 16556 CreatedAt: &Timestamp{referenceTime}, 16557 UpdatedAt: &Timestamp{referenceTime}, 16558 }, 16559 Sender: &User{ 16560 Login: String("l"), 16561 ID: Int64(1), 16562 NodeID: String("n"), 16563 URL: String("u"), 16564 ReposURL: String("r"), 16565 EventsURL: String("e"), 16566 AvatarURL: String("a"), 16567 }, 16568 Installation: &Installation{ 16569 ID: Int64(1), 16570 NodeID: String("nid"), 16571 AppID: Int64(1), 16572 AppSlug: String("as"), 16573 TargetID: Int64(1), 16574 Account: &User{ 16575 Login: String("l"), 16576 ID: Int64(1), 16577 URL: String("u"), 16578 AvatarURL: String("a"), 16579 GravatarID: String("g"), 16580 Name: String("n"), 16581 Company: String("c"), 16582 Blog: String("b"), 16583 Location: String("l"), 16584 Email: String("e"), 16585 Hireable: Bool(true), 16586 Bio: String("b"), 16587 TwitterUsername: String("t"), 16588 PublicRepos: Int(1), 16589 Followers: Int(1), 16590 Following: Int(1), 16591 CreatedAt: &Timestamp{referenceTime}, 16592 SuspendedAt: &Timestamp{referenceTime}, 16593 }, 16594 AccessTokensURL: String("atu"), 16595 RepositoriesURL: String("ru"), 16596 HTMLURL: String("hu"), 16597 TargetType: String("tt"), 16598 SingleFileName: String("sfn"), 16599 RepositorySelection: String("rs"), 16600 Events: []string{"e"}, 16601 SingleFilePaths: []string{"s"}, 16602 Permissions: &InstallationPermissions{ 16603 Actions: String("a"), 16604 Administration: String("ad"), 16605 Checks: String("c"), 16606 Contents: String("co"), 16607 ContentReferences: String("cr"), 16608 Deployments: String("d"), 16609 Environments: String("e"), 16610 Issues: String("i"), 16611 Metadata: String("md"), 16612 Members: String("m"), 16613 OrganizationAdministration: String("oa"), 16614 OrganizationHooks: String("oh"), 16615 OrganizationPlan: String("op"), 16616 OrganizationPreReceiveHooks: String("opr"), 16617 OrganizationProjects: String("op"), 16618 OrganizationSecrets: String("os"), 16619 OrganizationSelfHostedRunners: String("osh"), 16620 OrganizationUserBlocking: String("oub"), 16621 Packages: String("pkg"), 16622 Pages: String("pg"), 16623 PullRequests: String("pr"), 16624 RepositoryHooks: String("rh"), 16625 RepositoryProjects: String("rp"), 16626 RepositoryPreReceiveHooks: String("rprh"), 16627 Secrets: String("s"), 16628 SecretScanningAlerts: String("ssa"), 16629 SecurityEvents: String("se"), 16630 SingleFile: String("sf"), 16631 Statuses: String("s"), 16632 TeamDiscussions: String("td"), 16633 VulnerabilityAlerts: String("va"), 16634 Workflows: String("w"), 16635 }, 16636 CreatedAt: &Timestamp{referenceTime}, 16637 UpdatedAt: &Timestamp{referenceTime}, 16638 HasMultipleSingleFiles: Bool(false), 16639 SuspendedBy: &User{ 16640 Login: String("l"), 16641 ID: Int64(1), 16642 URL: String("u"), 16643 AvatarURL: String("a"), 16644 GravatarID: String("g"), 16645 Name: String("n"), 16646 Company: String("c"), 16647 Blog: String("b"), 16648 Location: String("l"), 16649 Email: String("e"), 16650 Hireable: Bool(true), 16651 Bio: String("b"), 16652 TwitterUsername: String("t"), 16653 PublicRepos: Int(1), 16654 Followers: Int(1), 16655 Following: Int(1), 16656 CreatedAt: &Timestamp{referenceTime}, 16657 SuspendedAt: &Timestamp{referenceTime}, 16658 }, 16659 SuspendedAt: &Timestamp{referenceTime}, 16660 }, 16661 } 16662 16663 want := `{ 16664 "action": "a", 16665 "alert": { 16666 "number": 1, 16667 "secret_type": "t", 16668 "resolution": "r", 16669 "resolved_by": { 16670 "login": "l", 16671 "id": 1, 16672 "node_id": "n", 16673 "avatar_url": "a", 16674 "url": "u", 16675 "events_url": "e", 16676 "repos_url": "r" 16677 }, 16678 "resolved_at": ` + referenceTimeStr + ` 16679 }, 16680 "repository": { 16681 "id": 1, 16682 "name": "n", 16683 "url": "s" 16684 }, 16685 "organization": { 16686 "name": "n", 16687 "company": "c", 16688 "blog": "b", 16689 "location": "loc", 16690 "email": "e", 16691 "twitter_username": "tu", 16692 "description": "d", 16693 "billing_email": "be", 16694 "is_verified": true, 16695 "has_organization_projects": true, 16696 "has_repository_projects": true, 16697 "default_repository_permission": "drp", 16698 "members_can_create_repositories": true, 16699 "members_can_create_public_repositories": false, 16700 "members_can_create_private_repositories": true, 16701 "members_can_create_internal_repositories": true, 16702 "members_allowed_repository_creation_type": "marct", 16703 "members_can_create_pages": true, 16704 "members_can_create_public_pages": false, 16705 "members_can_create_private_pages": true 16706 }, 16707 "enterprise": { 16708 "id": 1, 16709 "slug": "s", 16710 "name": "n", 16711 "node_id": "nid", 16712 "avatar_url": "au", 16713 "description": "d", 16714 "website_url": "wu", 16715 "html_url": "hu", 16716 "created_at": ` + referenceTimeStr + `, 16717 "updated_at": ` + referenceTimeStr + ` 16718 }, 16719 "sender": { 16720 "login": "l", 16721 "id": 1, 16722 "node_id": "n", 16723 "avatar_url": "a", 16724 "url": "u", 16725 "events_url": "e", 16726 "repos_url": "r" 16727 }, 16728 "installation": { 16729 "id": 1, 16730 "node_id": "nid", 16731 "app_id": 1, 16732 "app_slug": "as", 16733 "target_id": 1, 16734 "account": { 16735 "login": "l", 16736 "id": 1, 16737 "avatar_url": "a", 16738 "gravatar_id": "g", 16739 "name": "n", 16740 "company": "c", 16741 "blog": "b", 16742 "location": "l", 16743 "email": "e", 16744 "hireable": true, 16745 "bio": "b", 16746 "twitter_username": "t", 16747 "public_repos": 1, 16748 "followers": 1, 16749 "following": 1, 16750 "created_at": ` + referenceTimeStr + `, 16751 "suspended_at": ` + referenceTimeStr + `, 16752 "url": "u" 16753 }, 16754 "access_tokens_url": "atu", 16755 "repositories_url": "ru", 16756 "html_url": "hu", 16757 "target_type": "tt", 16758 "single_file_name": "sfn", 16759 "repository_selection": "rs", 16760 "events": [ 16761 "e" 16762 ], 16763 "single_file_paths": [ 16764 "s" 16765 ], 16766 "permissions": { 16767 "actions": "a", 16768 "administration": "ad", 16769 "checks": "c", 16770 "contents": "co", 16771 "content_references": "cr", 16772 "deployments": "d", 16773 "environments": "e", 16774 "issues": "i", 16775 "metadata": "md", 16776 "members": "m", 16777 "organization_administration": "oa", 16778 "organization_hooks": "oh", 16779 "organization_plan": "op", 16780 "organization_pre_receive_hooks": "opr", 16781 "organization_projects": "op", 16782 "organization_secrets": "os", 16783 "organization_self_hosted_runners": "osh", 16784 "organization_user_blocking": "oub", 16785 "packages": "pkg", 16786 "pages": "pg", 16787 "pull_requests": "pr", 16788 "repository_hooks": "rh", 16789 "repository_projects": "rp", 16790 "repository_pre_receive_hooks": "rprh", 16791 "secrets": "s", 16792 "secret_scanning_alerts": "ssa", 16793 "security_events": "se", 16794 "single_file": "sf", 16795 "statuses": "s", 16796 "team_discussions": "td", 16797 "vulnerability_alerts": "va", 16798 "workflows": "w" 16799 }, 16800 "created_at": ` + referenceTimeStr + `, 16801 "updated_at": ` + referenceTimeStr + `, 16802 "has_multiple_single_files": false, 16803 "suspended_by": { 16804 "login": "l", 16805 "id": 1, 16806 "avatar_url": "a", 16807 "gravatar_id": "g", 16808 "name": "n", 16809 "company": "c", 16810 "blog": "b", 16811 "location": "l", 16812 "email": "e", 16813 "hireable": true, 16814 "bio": "b", 16815 "twitter_username": "t", 16816 "public_repos": 1, 16817 "followers": 1, 16818 "following": 1, 16819 "created_at": ` + referenceTimeStr + `, 16820 "suspended_at": ` + referenceTimeStr + `, 16821 "url": "u" 16822 }, 16823 "suspended_at": ` + referenceTimeStr + ` 16824 } 16825 }` 16826 16827 testJSONMarshal(t, u, want) 16828 } 16829 16830 func TestSecurityAdvisoryEvent_Marshal(t *testing.T) { 16831 testJSONMarshal(t, &SecurityAdvisoryEvent{}, "{}") 16832 u := &SecurityAdvisoryEvent{ 16833 Action: String("published"), 16834 SecurityAdvisory: &SecurityAdvisory{ 16835 CVSS: &AdvisoryCVSS{ 16836 Score: Float64(1.0), 16837 VectorString: String("vs"), 16838 }, 16839 CWEs: []*AdvisoryCWEs{ 16840 { 16841 CWEID: String("cweid"), 16842 Name: String("n"), 16843 }, 16844 }, 16845 GHSAID: String("GHSA-rf4j-j272-some"), 16846 Summary: String("Siuuuuuuuuu"), 16847 Description: String("desc"), 16848 Severity: String("moderate"), 16849 Identifiers: []*AdvisoryIdentifier{ 16850 { 16851 Value: String("GHSA-rf4j-j272-some"), 16852 Type: String("GHSA"), 16853 }, 16854 }, 16855 References: []*AdvisoryReference{ 16856 { 16857 URL: String("https://some-url"), 16858 }, 16859 }, 16860 PublishedAt: &Timestamp{referenceTime}, 16861 UpdatedAt: &Timestamp{referenceTime}, 16862 WithdrawnAt: nil, 16863 Vulnerabilities: []*AdvisoryVulnerability{ 16864 { 16865 Package: &VulnerabilityPackage{ 16866 Ecosystem: String("ucl"), 16867 Name: String("penaldo"), 16868 }, 16869 Severity: String("moderate"), 16870 VulnerableVersionRange: String(">= 2.0.0, < 2.0.2"), 16871 FirstPatchedVersion: &FirstPatchedVersion{ 16872 Identifier: String("2.0.2"), 16873 }, 16874 }, 16875 }, 16876 }, 16877 Enterprise: &Enterprise{ 16878 ID: Int(1), 16879 Slug: String("s"), 16880 Name: String("n"), 16881 NodeID: String("nid"), 16882 AvatarURL: String("au"), 16883 Description: String("d"), 16884 WebsiteURL: String("wu"), 16885 HTMLURL: String("hu"), 16886 CreatedAt: &Timestamp{referenceTime}, 16887 UpdatedAt: &Timestamp{referenceTime}, 16888 }, 16889 Installation: &Installation{ 16890 ID: Int64(1), 16891 NodeID: String("nid"), 16892 AppID: Int64(1), 16893 AppSlug: String("as"), 16894 TargetID: Int64(1), 16895 Account: &User{ 16896 Login: String("l"), 16897 ID: Int64(1), 16898 URL: String("u"), 16899 AvatarURL: String("a"), 16900 GravatarID: String("g"), 16901 Name: String("n"), 16902 Company: String("c"), 16903 Blog: String("b"), 16904 Location: String("l"), 16905 Email: String("e"), 16906 Hireable: Bool(true), 16907 Bio: String("b"), 16908 TwitterUsername: String("t"), 16909 PublicRepos: Int(1), 16910 Followers: Int(1), 16911 Following: Int(1), 16912 CreatedAt: &Timestamp{referenceTime}, 16913 SuspendedAt: &Timestamp{referenceTime}, 16914 }, 16915 AccessTokensURL: String("atu"), 16916 RepositoriesURL: String("ru"), 16917 HTMLURL: String("hu"), 16918 TargetType: String("tt"), 16919 SingleFileName: String("sfn"), 16920 RepositorySelection: String("rs"), 16921 Events: []string{"e"}, 16922 SingleFilePaths: []string{"s"}, 16923 Permissions: &InstallationPermissions{ 16924 Actions: String("a"), 16925 Administration: String("ad"), 16926 Checks: String("c"), 16927 Contents: String("co"), 16928 ContentReferences: String("cr"), 16929 Deployments: String("d"), 16930 Environments: String("e"), 16931 Issues: String("i"), 16932 Metadata: String("md"), 16933 Members: String("m"), 16934 OrganizationAdministration: String("oa"), 16935 OrganizationHooks: String("oh"), 16936 OrganizationPlan: String("op"), 16937 OrganizationPreReceiveHooks: String("opr"), 16938 OrganizationProjects: String("op"), 16939 OrganizationSecrets: String("os"), 16940 OrganizationSelfHostedRunners: String("osh"), 16941 OrganizationUserBlocking: String("oub"), 16942 Packages: String("pkg"), 16943 Pages: String("pg"), 16944 PullRequests: String("pr"), 16945 RepositoryHooks: String("rh"), 16946 RepositoryProjects: String("rp"), 16947 RepositoryPreReceiveHooks: String("rprh"), 16948 Secrets: String("s"), 16949 SecretScanningAlerts: String("ssa"), 16950 SecurityEvents: String("se"), 16951 SingleFile: String("sf"), 16952 Statuses: String("s"), 16953 TeamDiscussions: String("td"), 16954 VulnerabilityAlerts: String("va"), 16955 Workflows: String("w"), 16956 }, 16957 CreatedAt: &Timestamp{referenceTime}, 16958 UpdatedAt: &Timestamp{referenceTime}, 16959 HasMultipleSingleFiles: Bool(false), 16960 SuspendedBy: &User{ 16961 Login: String("l"), 16962 ID: Int64(1), 16963 URL: String("u"), 16964 AvatarURL: String("a"), 16965 GravatarID: String("g"), 16966 Name: String("n"), 16967 Company: String("c"), 16968 Blog: String("b"), 16969 Location: String("l"), 16970 Email: String("e"), 16971 Hireable: Bool(true), 16972 Bio: String("b"), 16973 TwitterUsername: String("t"), 16974 PublicRepos: Int(1), 16975 Followers: Int(1), 16976 Following: Int(1), 16977 CreatedAt: &Timestamp{referenceTime}, 16978 SuspendedAt: &Timestamp{referenceTime}, 16979 }, 16980 SuspendedAt: &Timestamp{referenceTime}, 16981 }, 16982 Organization: &Organization{ 16983 BillingEmail: String("be"), 16984 Blog: String("b"), 16985 Company: String("c"), 16986 Email: String("e"), 16987 TwitterUsername: String("tu"), 16988 Location: String("loc"), 16989 Name: String("n"), 16990 Description: String("d"), 16991 IsVerified: Bool(true), 16992 HasOrganizationProjects: Bool(true), 16993 HasRepositoryProjects: Bool(true), 16994 DefaultRepoPermission: String("drp"), 16995 MembersCanCreateRepos: Bool(true), 16996 MembersCanCreateInternalRepos: Bool(true), 16997 MembersCanCreatePrivateRepos: Bool(true), 16998 MembersCanCreatePublicRepos: Bool(false), 16999 MembersAllowedRepositoryCreationType: String("marct"), 17000 MembersCanCreatePages: Bool(true), 17001 MembersCanCreatePublicPages: Bool(false), 17002 MembersCanCreatePrivatePages: Bool(true), 17003 }, 17004 Repository: &Repository{ 17005 ID: Int64(1), 17006 URL: String("s"), 17007 Name: String("n"), 17008 }, 17009 Sender: &User{ 17010 Login: String("l"), 17011 ID: Int64(1), 17012 NodeID: String("n"), 17013 URL: String("u"), 17014 ReposURL: String("r"), 17015 EventsURL: String("e"), 17016 AvatarURL: String("a"), 17017 }, 17018 } 17019 17020 want := `{ 17021 "action": "published", 17022 "security_advisory": { 17023 "ghsa_id": "GHSA-rf4j-j272-some", 17024 "summary": "Siuuuuuuuuu", 17025 "cvss": { 17026 "score": 1.0, 17027 "vector_string": "vs" 17028 }, 17029 "cwes": [ 17030 { 17031 "cwe_id": "cweid", 17032 "name": "n" 17033 } 17034 ], 17035 "description": "desc", 17036 "severity": "moderate", 17037 "identifiers": [ 17038 { 17039 "value": "GHSA-rf4j-j272-some", 17040 "type": "GHSA" 17041 } 17042 ], 17043 "references": [ 17044 { 17045 "url": "https://some-url" 17046 } 17047 ], 17048 "published_at": ` + referenceTimeStr + `, 17049 "updated_at": ` + referenceTimeStr + `, 17050 "withdrawn_at": null, 17051 "vulnerabilities": [ 17052 { 17053 "package": { 17054 "ecosystem": "ucl", 17055 "name": "penaldo" 17056 }, 17057 "severity": "moderate", 17058 "vulnerable_version_range": ">= 2.0.0, < 2.0.2", 17059 "first_patched_version": { 17060 "identifier": "2.0.2" 17061 } 17062 } 17063 ] 17064 }, 17065 "enterprise": { 17066 "id": 1, 17067 "slug": "s", 17068 "name": "n", 17069 "node_id": "nid", 17070 "avatar_url": "au", 17071 "description": "d", 17072 "website_url": "wu", 17073 "html_url": "hu", 17074 "created_at": ` + referenceTimeStr + `, 17075 "updated_at": ` + referenceTimeStr + ` 17076 }, 17077 "installation": { 17078 "id": 1, 17079 "node_id": "nid", 17080 "app_id": 1, 17081 "app_slug": "as", 17082 "target_id": 1, 17083 "account": { 17084 "login": "l", 17085 "id": 1, 17086 "avatar_url": "a", 17087 "gravatar_id": "g", 17088 "name": "n", 17089 "company": "c", 17090 "blog": "b", 17091 "location": "l", 17092 "email": "e", 17093 "hireable": true, 17094 "bio": "b", 17095 "twitter_username": "t", 17096 "public_repos": 1, 17097 "followers": 1, 17098 "following": 1, 17099 "created_at": ` + referenceTimeStr + `, 17100 "suspended_at": ` + referenceTimeStr + `, 17101 "url": "u" 17102 }, 17103 "access_tokens_url": "atu", 17104 "repositories_url": "ru", 17105 "html_url": "hu", 17106 "target_type": "tt", 17107 "single_file_name": "sfn", 17108 "repository_selection": "rs", 17109 "events": [ 17110 "e" 17111 ], 17112 "single_file_paths": [ 17113 "s" 17114 ], 17115 "permissions": { 17116 "actions": "a", 17117 "administration": "ad", 17118 "checks": "c", 17119 "contents": "co", 17120 "content_references": "cr", 17121 "deployments": "d", 17122 "environments": "e", 17123 "issues": "i", 17124 "metadata": "md", 17125 "members": "m", 17126 "organization_administration": "oa", 17127 "organization_hooks": "oh", 17128 "organization_plan": "op", 17129 "organization_pre_receive_hooks": "opr", 17130 "organization_projects": "op", 17131 "organization_secrets": "os", 17132 "organization_self_hosted_runners": "osh", 17133 "organization_user_blocking": "oub", 17134 "packages": "pkg", 17135 "pages": "pg", 17136 "pull_requests": "pr", 17137 "repository_hooks": "rh", 17138 "repository_projects": "rp", 17139 "repository_pre_receive_hooks": "rprh", 17140 "secrets": "s", 17141 "secret_scanning_alerts": "ssa", 17142 "security_events": "se", 17143 "single_file": "sf", 17144 "statuses": "s", 17145 "team_discussions": "td", 17146 "vulnerability_alerts": "va", 17147 "workflows": "w" 17148 }, 17149 "created_at": ` + referenceTimeStr + `, 17150 "updated_at": ` + referenceTimeStr + `, 17151 "has_multiple_single_files": false, 17152 "suspended_by": { 17153 "login": "l", 17154 "id": 1, 17155 "avatar_url": "a", 17156 "gravatar_id": "g", 17157 "name": "n", 17158 "company": "c", 17159 "blog": "b", 17160 "location": "l", 17161 "email": "e", 17162 "hireable": true, 17163 "bio": "b", 17164 "twitter_username": "t", 17165 "public_repos": 1, 17166 "followers": 1, 17167 "following": 1, 17168 "created_at": ` + referenceTimeStr + `, 17169 "suspended_at": ` + referenceTimeStr + `, 17170 "url": "u" 17171 }, 17172 "suspended_at": ` + referenceTimeStr + ` 17173 }, 17174 "organization": { 17175 "name": "n", 17176 "company": "c", 17177 "blog": "b", 17178 "location": "loc", 17179 "email": "e", 17180 "twitter_username": "tu", 17181 "description": "d", 17182 "billing_email": "be", 17183 "is_verified": true, 17184 "has_organization_projects": true, 17185 "has_repository_projects": true, 17186 "default_repository_permission": "drp", 17187 "members_can_create_repositories": true, 17188 "members_can_create_public_repositories": false, 17189 "members_can_create_private_repositories": true, 17190 "members_can_create_internal_repositories": true, 17191 "members_allowed_repository_creation_type": "marct", 17192 "members_can_create_pages": true, 17193 "members_can_create_public_pages": false, 17194 "members_can_create_private_pages": true 17195 }, 17196 "repository": { 17197 "id": 1, 17198 "url": "s", 17199 "name": "n" 17200 }, 17201 "sender": { 17202 "login": "l", 17203 "id": 1, 17204 "node_id": "n", 17205 "avatar_url": "a", 17206 "url": "u", 17207 "events_url": "e", 17208 "repos_url": "r" 17209 } 17210 }` 17211 17212 testJSONMarshal(t, u, want) 17213 } 17214 17215 func TestSecurityAndAnalysisEvent_Marshal(t *testing.T) { 17216 testJSONMarshal(t, &SecurityAndAnalysisEvent{}, "{}") 17217 17218 u := &SecurityAndAnalysisEvent{ 17219 Changes: &SecurityAndAnalysisChange{ 17220 From: &SecurityAndAnalysisChangeFrom{ 17221 SecurityAndAnalysis: &SecurityAndAnalysis{ 17222 AdvancedSecurity: &AdvancedSecurity{ 17223 Status: String("enabled"), 17224 }, 17225 SecretScanning: &SecretScanning{ 17226 Status: String("enabled"), 17227 }, 17228 SecretScanningPushProtection: &SecretScanningPushProtection{ 17229 Status: String("enabled"), 17230 }, 17231 DependabotSecurityUpdates: &DependabotSecurityUpdates{ 17232 Status: String("enabled"), 17233 }, 17234 }, 17235 }, 17236 }, 17237 Enterprise: &Enterprise{ 17238 ID: Int(1), 17239 Slug: String("s"), 17240 Name: String("n"), 17241 NodeID: String("nid"), 17242 AvatarURL: String("au"), 17243 Description: String("d"), 17244 WebsiteURL: String("wu"), 17245 HTMLURL: String("hu"), 17246 CreatedAt: &Timestamp{referenceTime}, 17247 UpdatedAt: &Timestamp{referenceTime}, 17248 }, 17249 Installation: &Installation{ 17250 ID: Int64(1), 17251 NodeID: String("nid"), 17252 AppID: Int64(1), 17253 AppSlug: String("as"), 17254 TargetID: Int64(1), 17255 Account: &User{ 17256 Login: String("l"), 17257 ID: Int64(1), 17258 URL: String("u"), 17259 AvatarURL: String("a"), 17260 GravatarID: String("g"), 17261 Name: String("n"), 17262 Company: String("c"), 17263 Blog: String("b"), 17264 Location: String("l"), 17265 Email: String("e"), 17266 Hireable: Bool(true), 17267 Bio: String("b"), 17268 TwitterUsername: String("t"), 17269 PublicRepos: Int(1), 17270 Followers: Int(1), 17271 Following: Int(1), 17272 CreatedAt: &Timestamp{referenceTime}, 17273 SuspendedAt: &Timestamp{referenceTime}, 17274 }, 17275 AccessTokensURL: String("atu"), 17276 RepositoriesURL: String("ru"), 17277 HTMLURL: String("hu"), 17278 TargetType: String("tt"), 17279 SingleFileName: String("sfn"), 17280 RepositorySelection: String("rs"), 17281 Events: []string{"e"}, 17282 SingleFilePaths: []string{"s"}, 17283 Permissions: &InstallationPermissions{ 17284 Actions: String("a"), 17285 Administration: String("ad"), 17286 Checks: String("c"), 17287 Contents: String("co"), 17288 ContentReferences: String("cr"), 17289 Deployments: String("d"), 17290 Environments: String("e"), 17291 Issues: String("i"), 17292 Metadata: String("md"), 17293 Members: String("m"), 17294 OrganizationAdministration: String("oa"), 17295 OrganizationHooks: String("oh"), 17296 OrganizationPlan: String("op"), 17297 OrganizationPreReceiveHooks: String("opr"), 17298 OrganizationProjects: String("op"), 17299 OrganizationSecrets: String("os"), 17300 OrganizationSelfHostedRunners: String("osh"), 17301 OrganizationUserBlocking: String("oub"), 17302 Packages: String("pkg"), 17303 Pages: String("pg"), 17304 PullRequests: String("pr"), 17305 RepositoryHooks: String("rh"), 17306 RepositoryProjects: String("rp"), 17307 RepositoryPreReceiveHooks: String("rprh"), 17308 Secrets: String("s"), 17309 SecretScanningAlerts: String("ssa"), 17310 SecurityEvents: String("se"), 17311 SingleFile: String("sf"), 17312 Statuses: String("s"), 17313 TeamDiscussions: String("td"), 17314 VulnerabilityAlerts: String("va"), 17315 Workflows: String("w"), 17316 }, 17317 CreatedAt: &Timestamp{referenceTime}, 17318 UpdatedAt: &Timestamp{referenceTime}, 17319 HasMultipleSingleFiles: Bool(false), 17320 SuspendedBy: &User{ 17321 Login: String("l"), 17322 ID: Int64(1), 17323 URL: String("u"), 17324 AvatarURL: String("a"), 17325 GravatarID: String("g"), 17326 Name: String("n"), 17327 Company: String("c"), 17328 Blog: String("b"), 17329 Location: String("l"), 17330 Email: String("e"), 17331 Hireable: Bool(true), 17332 Bio: String("b"), 17333 TwitterUsername: String("t"), 17334 PublicRepos: Int(1), 17335 Followers: Int(1), 17336 Following: Int(1), 17337 CreatedAt: &Timestamp{referenceTime}, 17338 SuspendedAt: &Timestamp{referenceTime}, 17339 }, 17340 SuspendedAt: &Timestamp{referenceTime}, 17341 }, 17342 Organization: &Organization{ 17343 BillingEmail: String("be"), 17344 Blog: String("b"), 17345 Company: String("c"), 17346 Email: String("e"), 17347 TwitterUsername: String("tu"), 17348 Location: String("loc"), 17349 Name: String("n"), 17350 Description: String("d"), 17351 IsVerified: Bool(true), 17352 HasOrganizationProjects: Bool(true), 17353 HasRepositoryProjects: Bool(true), 17354 DefaultRepoPermission: String("drp"), 17355 MembersCanCreateRepos: Bool(true), 17356 MembersCanCreateInternalRepos: Bool(true), 17357 MembersCanCreatePrivateRepos: Bool(true), 17358 MembersCanCreatePublicRepos: Bool(false), 17359 MembersAllowedRepositoryCreationType: String("marct"), 17360 MembersCanCreatePages: Bool(true), 17361 MembersCanCreatePublicPages: Bool(false), 17362 MembersCanCreatePrivatePages: Bool(true), 17363 }, 17364 Repository: &Repository{ 17365 ID: Int64(1), 17366 URL: String("s"), 17367 Name: String("n"), 17368 }, 17369 Sender: &User{ 17370 Login: String("l"), 17371 ID: Int64(1), 17372 NodeID: String("n"), 17373 URL: String("u"), 17374 ReposURL: String("r"), 17375 EventsURL: String("e"), 17376 AvatarURL: String("a"), 17377 }, 17378 } 17379 17380 want := `{ 17381 "changes": { 17382 "from": { 17383 "security_and_analysis": { 17384 "advanced_security": { 17385 "status": "enabled" 17386 }, 17387 "secret_scanning": { 17388 "status": "enabled" 17389 }, 17390 "secret_scanning_push_protection": { 17391 "status": "enabled" 17392 }, 17393 "dependabot_security_updates": { 17394 "status": "enabled" 17395 } 17396 } 17397 } 17398 }, 17399 "enterprise": { 17400 "id": 1, 17401 "slug": "s", 17402 "name": "n", 17403 "node_id": "nid", 17404 "avatar_url": "au", 17405 "description": "d", 17406 "website_url": "wu", 17407 "html_url": "hu", 17408 "created_at": ` + referenceTimeStr + `, 17409 "updated_at": ` + referenceTimeStr + ` 17410 }, 17411 "installation": { 17412 "id": 1, 17413 "node_id": "nid", 17414 "app_id": 1, 17415 "app_slug": "as", 17416 "target_id": 1, 17417 "account": { 17418 "login": "l", 17419 "id": 1, 17420 "avatar_url": "a", 17421 "gravatar_id": "g", 17422 "name": "n", 17423 "company": "c", 17424 "blog": "b", 17425 "location": "l", 17426 "email": "e", 17427 "hireable": true, 17428 "bio": "b", 17429 "twitter_username": "t", 17430 "public_repos": 1, 17431 "followers": 1, 17432 "following": 1, 17433 "created_at": ` + referenceTimeStr + `, 17434 "suspended_at": ` + referenceTimeStr + `, 17435 "url": "u" 17436 }, 17437 "access_tokens_url": "atu", 17438 "repositories_url": "ru", 17439 "html_url": "hu", 17440 "target_type": "tt", 17441 "single_file_name": "sfn", 17442 "repository_selection": "rs", 17443 "events": [ 17444 "e" 17445 ], 17446 "single_file_paths": [ 17447 "s" 17448 ], 17449 "permissions": { 17450 "actions": "a", 17451 "administration": "ad", 17452 "checks": "c", 17453 "contents": "co", 17454 "content_references": "cr", 17455 "deployments": "d", 17456 "environments": "e", 17457 "issues": "i", 17458 "metadata": "md", 17459 "members": "m", 17460 "organization_administration": "oa", 17461 "organization_hooks": "oh", 17462 "organization_plan": "op", 17463 "organization_pre_receive_hooks": "opr", 17464 "organization_projects": "op", 17465 "organization_secrets": "os", 17466 "organization_self_hosted_runners": "osh", 17467 "organization_user_blocking": "oub", 17468 "packages": "pkg", 17469 "pages": "pg", 17470 "pull_requests": "pr", 17471 "repository_hooks": "rh", 17472 "repository_projects": "rp", 17473 "repository_pre_receive_hooks": "rprh", 17474 "secrets": "s", 17475 "secret_scanning_alerts": "ssa", 17476 "security_events": "se", 17477 "single_file": "sf", 17478 "statuses": "s", 17479 "team_discussions": "td", 17480 "vulnerability_alerts": "va", 17481 "workflows": "w" 17482 }, 17483 "created_at": ` + referenceTimeStr + `, 17484 "updated_at": ` + referenceTimeStr + `, 17485 "has_multiple_single_files": false, 17486 "suspended_by": { 17487 "login": "l", 17488 "id": 1, 17489 "avatar_url": "a", 17490 "gravatar_id": "g", 17491 "name": "n", 17492 "company": "c", 17493 "blog": "b", 17494 "location": "l", 17495 "email": "e", 17496 "hireable": true, 17497 "bio": "b", 17498 "twitter_username": "t", 17499 "public_repos": 1, 17500 "followers": 1, 17501 "following": 1, 17502 "created_at": ` + referenceTimeStr + `, 17503 "suspended_at": ` + referenceTimeStr + `, 17504 "url": "u" 17505 }, 17506 "suspended_at": ` + referenceTimeStr + ` 17507 }, 17508 "organization": { 17509 "name": "n", 17510 "company": "c", 17511 "blog": "b", 17512 "location": "loc", 17513 "email": "e", 17514 "twitter_username": "tu", 17515 "description": "d", 17516 "billing_email": "be", 17517 "is_verified": true, 17518 "has_organization_projects": true, 17519 "has_repository_projects": true, 17520 "default_repository_permission": "drp", 17521 "members_can_create_repositories": true, 17522 "members_can_create_public_repositories": false, 17523 "members_can_create_private_repositories": true, 17524 "members_can_create_internal_repositories": true, 17525 "members_allowed_repository_creation_type": "marct", 17526 "members_can_create_pages": true, 17527 "members_can_create_public_pages": false, 17528 "members_can_create_private_pages": true 17529 }, 17530 "repository": { 17531 "id": 1, 17532 "url": "s", 17533 "name": "n" 17534 }, 17535 "sender": { 17536 "login": "l", 17537 "id": 1, 17538 "node_id": "n", 17539 "avatar_url": "a", 17540 "url": "u", 17541 "events_url": "e", 17542 "repos_url": "r" 17543 }, 17544 "target_type": "running" 17545 }` 17546 17547 testJSONMarshal(t, u, want) 17548 } 17549 17550 func TestCodeScanningAlertEvent_Marshal(t *testing.T) { 17551 testJSONMarshal(t, &CodeScanningAlertEvent{}, "{}") 17552 17553 u := &CodeScanningAlertEvent{ 17554 Action: String("reopened"), 17555 Alert: &Alert{ 17556 Number: Int(10), 17557 Rule: &Rule{ 17558 ID: String("Style/FrozenStringLiteralComment"), 17559 Severity: String("note"), 17560 Description: String("desc"), 17561 FullDescription: String("full desc"), 17562 Tags: []string{"style"}, 17563 Help: String("help"), 17564 }, 17565 Tool: &Tool{ 17566 Name: String("Rubocop"), 17567 Version: nil, 17568 }, 17569 CreatedAt: &Timestamp{referenceTime}, 17570 UpdatedAt: &Timestamp{referenceTime}, 17571 FixedAt: nil, 17572 State: String("open"), 17573 URL: String("a"), 17574 HTMLURL: String("a"), 17575 Instances: []*MostRecentInstance{ 17576 { 17577 Ref: String("refs/heads/main"), 17578 AnalysisKey: String(".github/workflows/workflow.yml:upload"), 17579 Environment: String("{}"), 17580 State: String("open"), 17581 }, 17582 }, 17583 DismissedBy: nil, 17584 DismissedAt: nil, 17585 DismissedReason: nil, 17586 }, 17587 Ref: String("refs/heads/main"), 17588 CommitOID: String("d6e4c75c141dbacecc279b721b8bsomeSHA"), 17589 Repo: &Repository{ 17590 ID: Int64(1234234535), 17591 NodeID: String("MDEwOlJlcG9zaXRvcnkxODY4NT=="), 17592 Owner: &User{ 17593 Login: String("Codertocat"), 17594 ID: Int64(21031067), 17595 NodeID: String("MDQ6VXNlcjIxMDMxMDY3"), 17596 AvatarURL: String("a"), 17597 GravatarID: String(""), 17598 URL: String("a"), 17599 HTMLURL: String("a"), 17600 Type: String("User"), 17601 SiteAdmin: Bool(false), 17602 FollowersURL: String("a"), 17603 FollowingURL: String("a"), 17604 EventsURL: String("a"), 17605 GistsURL: String("a"), 17606 OrganizationsURL: String("a"), 17607 ReceivedEventsURL: String("a"), 17608 ReposURL: String("a"), 17609 StarredURL: String("a"), 17610 SubscriptionsURL: String("a"), 17611 }, 17612 HTMLURL: String("a"), 17613 Name: String("Hello-World"), 17614 FullName: String("Codertocat/Hello-World"), 17615 Description: nil, 17616 Fork: Bool(false), 17617 Homepage: nil, 17618 DefaultBranch: String("main"), 17619 CreatedAt: &Timestamp{referenceTime}, 17620 PushedAt: &Timestamp{referenceTime}, 17621 UpdatedAt: &Timestamp{referenceTime}, 17622 CloneURL: String("a"), 17623 GitURL: String("a"), 17624 MirrorURL: nil, 17625 SSHURL: String("a"), 17626 SVNURL: String("a"), 17627 Language: nil, 17628 ForksCount: Int(0), 17629 OpenIssuesCount: Int(2), 17630 OpenIssues: Int(2), 17631 StargazersCount: Int(0), 17632 WatchersCount: Int(0), 17633 Watchers: Int(0), 17634 Size: Int(0), 17635 Archived: Bool(false), 17636 Disabled: Bool(false), 17637 License: nil, 17638 Private: Bool(false), 17639 HasIssues: Bool(true), 17640 HasWiki: Bool(true), 17641 HasPages: Bool(true), 17642 HasProjects: Bool(true), 17643 HasDownloads: Bool(true), 17644 URL: String("a"), 17645 ArchiveURL: String("a"), 17646 AssigneesURL: String("a"), 17647 BlobsURL: String("a"), 17648 BranchesURL: String("a"), 17649 CollaboratorsURL: String("a"), 17650 CommentsURL: String("a"), 17651 CommitsURL: String("a"), 17652 CompareURL: String("a"), 17653 ContentsURL: String("a"), 17654 ContributorsURL: String("a"), 17655 DeploymentsURL: String("a"), 17656 DownloadsURL: String("a"), 17657 EventsURL: String("a"), 17658 ForksURL: String("a"), 17659 GitCommitsURL: String("a"), 17660 GitRefsURL: String("a"), 17661 GitTagsURL: String("a"), 17662 HooksURL: String("a"), 17663 IssueCommentURL: String("a"), 17664 IssueEventsURL: String("a"), 17665 IssuesURL: String("a"), 17666 KeysURL: String("a"), 17667 LabelsURL: String("a"), 17668 LanguagesURL: String("a"), 17669 MergesURL: String("a"), 17670 MilestonesURL: String("a"), 17671 NotificationsURL: String("a"), 17672 PullsURL: String("a"), 17673 ReleasesURL: String("a"), 17674 StargazersURL: String("a"), 17675 StatusesURL: String("a"), 17676 SubscribersURL: String("a"), 17677 SubscriptionURL: String("a"), 17678 TagsURL: String("a"), 17679 TreesURL: String("a"), 17680 TeamsURL: String("a"), 17681 }, 17682 Org: &Organization{ 17683 Login: String("Octocoders"), 17684 ID: Int64(6), 17685 NodeID: String("MDEyOk9yZ2FuaXphdGlvbjY="), 17686 AvatarURL: String("a"), 17687 Description: String(""), 17688 URL: String("a"), 17689 EventsURL: String("a"), 17690 HooksURL: String("a"), 17691 IssuesURL: String("a"), 17692 MembersURL: String("a"), 17693 PublicMembersURL: String("a"), 17694 ReposURL: String("a"), 17695 }, 17696 Sender: &User{ 17697 Login: String("github"), 17698 ID: Int64(9919), 17699 NodeID: String("MDEyOk9yZ2FuaXphdGlvbjk5MTk="), 17700 AvatarURL: String("a"), 17701 HTMLURL: String("a"), 17702 GravatarID: String(""), 17703 Type: String("Organization"), 17704 SiteAdmin: Bool(false), 17705 URL: String("a"), 17706 EventsURL: String("a"), 17707 FollowingURL: String("a"), 17708 FollowersURL: String("a"), 17709 GistsURL: String("a"), 17710 OrganizationsURL: String("a"), 17711 ReceivedEventsURL: String("a"), 17712 ReposURL: String("a"), 17713 StarredURL: String("a"), 17714 SubscriptionsURL: String("a"), 17715 }, 17716 } 17717 17718 want := `{ 17719 "action": "reopened", 17720 "alert": { 17721 "number": 10, 17722 "created_at": ` + referenceTimeStr + `, 17723 "updated_at": ` + referenceTimeStr + `, 17724 "url": "a", 17725 "html_url": "a", 17726 "instances": [ 17727 { 17728 "ref": "refs/heads/main", 17729 "analysis_key": ".github/workflows/workflow.yml:upload", 17730 "environment": "{}", 17731 "state": "open" 17732 } 17733 ], 17734 "state": "open", 17735 "fixed_at": null, 17736 "dismissed_by": null, 17737 "dismissed_at": null, 17738 "dismissed_reason": null, 17739 "rule": { 17740 "id": "Style/FrozenStringLiteralComment", 17741 "severity": "note", 17742 "description": "desc", 17743 "full_description": "full desc", 17744 "tags": [ 17745 "style" 17746 ], 17747 "help": "help" 17748 }, 17749 "tool": { 17750 "name": "Rubocop", 17751 "version": null 17752 } 17753 }, 17754 "ref": "refs/heads/main", 17755 "commit_oid": "d6e4c75c141dbacecc279b721b8bsomeSHA", 17756 "repository": { 17757 "id": 1234234535, 17758 "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NT==", 17759 "name": "Hello-World", 17760 "full_name": "Codertocat/Hello-World", 17761 "private": false, 17762 "owner": { 17763 "login": "Codertocat", 17764 "id": 21031067, 17765 "node_id": "MDQ6VXNlcjIxMDMxMDY3", 17766 "avatar_url": "a", 17767 "gravatar_id": "", 17768 "url": "a", 17769 "html_url": "a", 17770 "followers_url": "a", 17771 "following_url": "a", 17772 "gists_url": "a", 17773 "starred_url": "a", 17774 "subscriptions_url": "a", 17775 "organizations_url": "a", 17776 "repos_url": "a", 17777 "events_url": "a", 17778 "received_events_url": "a", 17779 "type": "User", 17780 "site_admin": false 17781 }, 17782 "html_url": "a", 17783 "description": null, 17784 "fork": false, 17785 "url": "a", 17786 "forks_url": "a", 17787 "keys_url": "a", 17788 "collaborators_url": "a", 17789 "teams_url": "a", 17790 "hooks_url": "a", 17791 "issue_events_url": "a", 17792 "events_url": "a", 17793 "assignees_url": "a", 17794 "branches_url": "a", 17795 "tags_url": "a", 17796 "blobs_url": "a", 17797 "git_tags_url": "a", 17798 "git_refs_url": "a", 17799 "trees_url": "a", 17800 "statuses_url": "a", 17801 "languages_url": "a", 17802 "stargazers_url": "a", 17803 "contributors_url": "a", 17804 "subscribers_url": "a", 17805 "subscription_url": "a", 17806 "commits_url": "a", 17807 "git_commits_url": "a", 17808 "comments_url": "a", 17809 "issue_comment_url": "a", 17810 "contents_url": "a", 17811 "compare_url": "a", 17812 "merges_url": "a", 17813 "archive_url": "a", 17814 "downloads_url": "a", 17815 "issues_url": "a", 17816 "pulls_url": "a", 17817 "milestones_url": "a", 17818 "notifications_url": "a", 17819 "labels_url": "a", 17820 "releases_url": "a", 17821 "deployments_url": "a", 17822 "created_at": ` + referenceTimeStr + `, 17823 "updated_at": ` + referenceTimeStr + `, 17824 "pushed_at": ` + referenceTimeStr + `, 17825 "git_url": "a", 17826 "ssh_url": "a", 17827 "clone_url": "a", 17828 "svn_url": "a", 17829 "homepage": null, 17830 "size": 0, 17831 "stargazers_count": 0, 17832 "watchers_count": 0, 17833 "language": null, 17834 "has_issues": true, 17835 "has_projects": true, 17836 "has_downloads": true, 17837 "has_wiki": true, 17838 "has_pages": true, 17839 "forks_count": 0, 17840 "mirror_url": null, 17841 "archived": false, 17842 "disabled": false, 17843 "open_issues_count": 2, 17844 "license": null, 17845 "forks": 0, 17846 "open_issues": 2, 17847 "watchers": 0, 17848 "default_branch": "main" 17849 }, 17850 "organization": { 17851 "login": "Octocoders", 17852 "id": 6, 17853 "node_id": "MDEyOk9yZ2FuaXphdGlvbjY=", 17854 "url": "a", 17855 "repos_url": "a", 17856 "events_url": "a", 17857 "hooks_url": "a", 17858 "issues_url": "a", 17859 "members_url": "a", 17860 "public_members_url": "a", 17861 "avatar_url": "a", 17862 "description": "" 17863 }, 17864 "sender": { 17865 "login": "github", 17866 "id": 9919, 17867 "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", 17868 "avatar_url": "a", 17869 "gravatar_id": "", 17870 "url": "a", 17871 "html_url": "a", 17872 "followers_url": "a", 17873 "following_url": "a", 17874 "gists_url": "a", 17875 "starred_url": "a", 17876 "subscriptions_url": "a", 17877 "organizations_url": "a", 17878 "repos_url": "a", 17879 "events_url": "a", 17880 "received_events_url": "a", 17881 "type": "Organization", 17882 "site_admin": false 17883 } 17884 }` 17885 17886 testJSONMarshal(t, u, want) 17887 }