github.com/google/go-github/v49@v49.1.0/github/event_types_test.go (about) 1 // Copyright 2020 The go-github AUTHORS. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 package github 7 8 import ( 9 "encoding/json" 10 "testing" 11 ) 12 13 func TestEditChange_Marshal_TitleChange(t *testing.T) { 14 testJSONMarshal(t, &EditChange{}, "{}") 15 16 u := &EditChange{ 17 Title: &EditTitle{ 18 From: String("TitleFrom"), 19 }, 20 Body: nil, 21 Base: nil, 22 } 23 24 want := `{ 25 "title": { 26 "from": "TitleFrom" 27 } 28 }` 29 30 testJSONMarshal(t, u, want) 31 } 32 33 func TestEditChange_Marshal_BodyChange(t *testing.T) { 34 testJSONMarshal(t, &EditChange{}, "{}") 35 36 u := &EditChange{ 37 Title: nil, 38 Body: &EditBody{ 39 From: String("BodyFrom"), 40 }, 41 Base: nil, 42 } 43 44 want := `{ 45 "body": { 46 "from": "BodyFrom" 47 } 48 }` 49 50 testJSONMarshal(t, u, want) 51 } 52 53 func TestEditChange_Marshal_BaseChange(t *testing.T) { 54 testJSONMarshal(t, &EditChange{}, "{}") 55 56 Base := EditBase{ 57 Ref: &EditRef{ 58 From: String("BaseRefFrom"), 59 }, 60 SHA: &EditSHA{ 61 From: String("BaseSHAFrom"), 62 }, 63 } 64 65 u := &EditChange{ 66 Title: nil, 67 Body: nil, 68 Base: &Base, 69 } 70 71 want := `{ 72 "base": { 73 "ref": { 74 "from": "BaseRefFrom" 75 }, 76 "sha": { 77 "from": "BaseSHAFrom" 78 } 79 } 80 }` 81 82 testJSONMarshal(t, u, want) 83 } 84 85 func TestEditChange_Marshal_Repo(t *testing.T) { 86 testJSONMarshal(t, &EditChange{}, "{}") 87 88 u := &EditChange{ 89 Repo: &EditRepo{ 90 Name: &RepoName{ 91 From: String("old-repo-name"), 92 }, 93 }, 94 } 95 96 want := `{ 97 "repository": { 98 "name": { 99 "from": "old-repo-name" 100 } 101 } 102 }` 103 104 testJSONMarshal(t, u, want) 105 } 106 107 func TestProjectChange_Marshal_NameChange(t *testing.T) { 108 testJSONMarshal(t, &ProjectChange{}, "{}") 109 110 u := &ProjectChange{ 111 Name: &ProjectName{From: String("NameFrom")}, 112 Body: nil, 113 } 114 115 want := `{ 116 "name": { 117 "from": "NameFrom" 118 } 119 }` 120 121 testJSONMarshal(t, u, want) 122 } 123 124 func TestProjectChange_Marshal_BodyChange(t *testing.T) { 125 testJSONMarshal(t, &ProjectChange{}, "{}") 126 127 u := &ProjectChange{ 128 Name: nil, 129 Body: &ProjectBody{From: String("BodyFrom")}, 130 } 131 132 want := `{ 133 "body": { 134 "from": "BodyFrom" 135 } 136 }` 137 138 testJSONMarshal(t, u, want) 139 } 140 141 func TestProjectCardChange_Marshal_NoteChange(t *testing.T) { 142 testJSONMarshal(t, &ProjectCardChange{}, "{}") 143 144 u := &ProjectCardChange{ 145 Note: &ProjectCardNote{From: String("NoteFrom")}, 146 } 147 148 want := `{ 149 "note": { 150 "from": "NoteFrom" 151 } 152 }` 153 154 testJSONMarshal(t, u, want) 155 } 156 157 func TestProjectColumnChange_Marshal_NameChange(t *testing.T) { 158 testJSONMarshal(t, &ProjectColumnChange{}, "{}") 159 160 u := &ProjectColumnChange{ 161 Name: &ProjectColumnName{From: String("NameFrom")}, 162 } 163 164 want := `{ 165 "name": { 166 "from": "NameFrom" 167 } 168 }` 169 170 testJSONMarshal(t, u, want) 171 } 172 173 func TestTeamAddEvent_Marshal(t *testing.T) { 174 testJSONMarshal(t, &TeamAddEvent{}, "{}") 175 176 u := &TeamAddEvent{ 177 Team: &Team{ 178 ID: Int64(1), 179 NodeID: String("n"), 180 Name: String("n"), 181 Description: String("d"), 182 URL: String("u"), 183 Slug: String("s"), 184 Permission: String("p"), 185 Privacy: String("p"), 186 MembersCount: Int(1), 187 ReposCount: Int(1), 188 MembersURL: String("m"), 189 RepositoriesURL: String("r"), 190 Organization: &Organization{ 191 Login: String("l"), 192 ID: Int64(1), 193 NodeID: String("n"), 194 AvatarURL: String("a"), 195 HTMLURL: String("h"), 196 Name: String("n"), 197 Company: String("c"), 198 Blog: String("b"), 199 Location: String("l"), 200 Email: String("e"), 201 }, 202 Parent: &Team{ 203 ID: Int64(1), 204 NodeID: String("n"), 205 Name: String("n"), 206 Description: String("d"), 207 URL: String("u"), 208 Slug: String("s"), 209 Permission: String("p"), 210 Privacy: String("p"), 211 MembersCount: Int(1), 212 ReposCount: Int(1), 213 }, 214 LDAPDN: String("l"), 215 }, 216 Repo: &Repository{ 217 ID: Int64(1), 218 URL: String("s"), 219 Name: String("n"), 220 }, 221 Org: &Organization{ 222 BillingEmail: String("be"), 223 Blog: String("b"), 224 Company: String("c"), 225 Email: String("e"), 226 TwitterUsername: String("tu"), 227 Location: String("loc"), 228 Name: String("n"), 229 Description: String("d"), 230 IsVerified: Bool(true), 231 HasOrganizationProjects: Bool(true), 232 HasRepositoryProjects: Bool(true), 233 DefaultRepoPermission: String("drp"), 234 MembersCanCreateRepos: Bool(true), 235 MembersCanCreateInternalRepos: Bool(true), 236 MembersCanCreatePrivateRepos: Bool(true), 237 MembersCanCreatePublicRepos: Bool(false), 238 MembersAllowedRepositoryCreationType: String("marct"), 239 MembersCanCreatePages: Bool(true), 240 MembersCanCreatePublicPages: Bool(false), 241 MembersCanCreatePrivatePages: Bool(true), 242 }, 243 Sender: &User{ 244 Login: String("l"), 245 ID: Int64(1), 246 NodeID: String("n"), 247 URL: String("u"), 248 ReposURL: String("r"), 249 EventsURL: String("e"), 250 AvatarURL: String("a"), 251 }, 252 Installation: &Installation{ 253 ID: Int64(1), 254 NodeID: String("nid"), 255 AppID: Int64(1), 256 AppSlug: String("as"), 257 TargetID: Int64(1), 258 Account: &User{ 259 Login: String("l"), 260 ID: Int64(1), 261 URL: String("u"), 262 AvatarURL: String("a"), 263 GravatarID: String("g"), 264 Name: String("n"), 265 Company: String("c"), 266 Blog: String("b"), 267 Location: String("l"), 268 Email: String("e"), 269 Hireable: Bool(true), 270 Bio: String("b"), 271 TwitterUsername: String("t"), 272 PublicRepos: Int(1), 273 Followers: Int(1), 274 Following: Int(1), 275 CreatedAt: &Timestamp{referenceTime}, 276 SuspendedAt: &Timestamp{referenceTime}, 277 }, 278 AccessTokensURL: String("atu"), 279 RepositoriesURL: String("ru"), 280 HTMLURL: String("hu"), 281 TargetType: String("tt"), 282 SingleFileName: String("sfn"), 283 RepositorySelection: String("rs"), 284 Events: []string{"e"}, 285 SingleFilePaths: []string{"s"}, 286 Permissions: &InstallationPermissions{ 287 Actions: String("a"), 288 Administration: String("ad"), 289 Checks: String("c"), 290 Contents: String("co"), 291 ContentReferences: String("cr"), 292 Deployments: String("d"), 293 Environments: String("e"), 294 Issues: String("i"), 295 Metadata: String("md"), 296 Members: String("m"), 297 OrganizationAdministration: String("oa"), 298 OrganizationHooks: String("oh"), 299 OrganizationPlan: String("op"), 300 OrganizationPreReceiveHooks: String("opr"), 301 OrganizationProjects: String("op"), 302 OrganizationSecrets: String("os"), 303 OrganizationSelfHostedRunners: String("osh"), 304 OrganizationUserBlocking: String("oub"), 305 Packages: String("pkg"), 306 Pages: String("pg"), 307 PullRequests: String("pr"), 308 RepositoryHooks: String("rh"), 309 RepositoryProjects: String("rp"), 310 RepositoryPreReceiveHooks: String("rprh"), 311 Secrets: String("s"), 312 SecretScanningAlerts: String("ssa"), 313 SecurityEvents: String("se"), 314 SingleFile: String("sf"), 315 Statuses: String("s"), 316 TeamDiscussions: String("td"), 317 VulnerabilityAlerts: String("va"), 318 Workflows: String("w"), 319 }, 320 CreatedAt: &Timestamp{referenceTime}, 321 UpdatedAt: &Timestamp{referenceTime}, 322 HasMultipleSingleFiles: Bool(false), 323 SuspendedBy: &User{ 324 Login: String("l"), 325 ID: Int64(1), 326 URL: String("u"), 327 AvatarURL: String("a"), 328 GravatarID: String("g"), 329 Name: String("n"), 330 Company: String("c"), 331 Blog: String("b"), 332 Location: String("l"), 333 Email: String("e"), 334 Hireable: Bool(true), 335 Bio: String("b"), 336 TwitterUsername: String("t"), 337 PublicRepos: Int(1), 338 Followers: Int(1), 339 Following: Int(1), 340 CreatedAt: &Timestamp{referenceTime}, 341 SuspendedAt: &Timestamp{referenceTime}, 342 }, 343 SuspendedAt: &Timestamp{referenceTime}, 344 }, 345 } 346 347 want := `{ 348 "team": { 349 "id": 1, 350 "node_id": "n", 351 "name": "n", 352 "description": "d", 353 "url": "u", 354 "slug": "s", 355 "permission": "p", 356 "privacy": "p", 357 "members_count": 1, 358 "repos_count": 1, 359 "organization": { 360 "login": "l", 361 "id": 1, 362 "node_id": "n", 363 "avatar_url": "a", 364 "html_url": "h", 365 "name": "n", 366 "company": "c", 367 "blog": "b", 368 "location": "l", 369 "email": "e" 370 }, 371 "members_url": "m", 372 "repositories_url": "r", 373 "parent": { 374 "id": 1, 375 "node_id": "n", 376 "name": "n", 377 "description": "d", 378 "url": "u", 379 "slug": "s", 380 "permission": "p", 381 "privacy": "p", 382 "members_count": 1, 383 "repos_count": 1 384 }, 385 "ldap_dn": "l" 386 }, 387 "repository": { 388 "id": 1, 389 "name": "n", 390 "url": "s" 391 }, 392 "organization": { 393 "name": "n", 394 "company": "c", 395 "blog": "b", 396 "location": "loc", 397 "email": "e", 398 "twitter_username": "tu", 399 "description": "d", 400 "billing_email": "be", 401 "is_verified": true, 402 "has_organization_projects": true, 403 "has_repository_projects": true, 404 "default_repository_permission": "drp", 405 "members_can_create_repositories": true, 406 "members_can_create_public_repositories": false, 407 "members_can_create_private_repositories": true, 408 "members_can_create_internal_repositories": true, 409 "members_allowed_repository_creation_type": "marct", 410 "members_can_create_pages": true, 411 "members_can_create_public_pages": false, 412 "members_can_create_private_pages": true 413 }, 414 "sender": { 415 "login": "l", 416 "id": 1, 417 "node_id": "n", 418 "avatar_url": "a", 419 "url": "u", 420 "events_url": "e", 421 "repos_url": "r" 422 }, 423 "installation": { 424 "id": 1, 425 "node_id": "nid", 426 "app_id": 1, 427 "app_slug": "as", 428 "target_id": 1, 429 "account": { 430 "login": "l", 431 "id": 1, 432 "avatar_url": "a", 433 "gravatar_id": "g", 434 "name": "n", 435 "company": "c", 436 "blog": "b", 437 "location": "l", 438 "email": "e", 439 "hireable": true, 440 "bio": "b", 441 "twitter_username": "t", 442 "public_repos": 1, 443 "followers": 1, 444 "following": 1, 445 "created_at": ` + referenceTimeStr + `, 446 "suspended_at": ` + referenceTimeStr + `, 447 "url": "u" 448 }, 449 "access_tokens_url": "atu", 450 "repositories_url": "ru", 451 "html_url": "hu", 452 "target_type": "tt", 453 "single_file_name": "sfn", 454 "repository_selection": "rs", 455 "events": [ 456 "e" 457 ], 458 "single_file_paths": [ 459 "s" 460 ], 461 "permissions": { 462 "actions": "a", 463 "administration": "ad", 464 "checks": "c", 465 "contents": "co", 466 "content_references": "cr", 467 "deployments": "d", 468 "environments": "e", 469 "issues": "i", 470 "metadata": "md", 471 "members": "m", 472 "organization_administration": "oa", 473 "organization_hooks": "oh", 474 "organization_plan": "op", 475 "organization_pre_receive_hooks": "opr", 476 "organization_projects": "op", 477 "organization_secrets": "os", 478 "organization_self_hosted_runners": "osh", 479 "organization_user_blocking": "oub", 480 "packages": "pkg", 481 "pages": "pg", 482 "pull_requests": "pr", 483 "repository_hooks": "rh", 484 "repository_projects": "rp", 485 "repository_pre_receive_hooks": "rprh", 486 "secrets": "s", 487 "secret_scanning_alerts": "ssa", 488 "security_events": "se", 489 "single_file": "sf", 490 "statuses": "s", 491 "team_discussions": "td", 492 "vulnerability_alerts": "va", 493 "workflows": "w" 494 }, 495 "created_at": ` + referenceTimeStr + `, 496 "updated_at": ` + referenceTimeStr + `, 497 "has_multiple_single_files": false, 498 "suspended_by": { 499 "login": "l", 500 "id": 1, 501 "avatar_url": "a", 502 "gravatar_id": "g", 503 "name": "n", 504 "company": "c", 505 "blog": "b", 506 "location": "l", 507 "email": "e", 508 "hireable": true, 509 "bio": "b", 510 "twitter_username": "t", 511 "public_repos": 1, 512 "followers": 1, 513 "following": 1, 514 "created_at": ` + referenceTimeStr + `, 515 "suspended_at": ` + referenceTimeStr + `, 516 "url": "u" 517 }, 518 "suspended_at": ` + referenceTimeStr + ` 519 } 520 }` 521 522 testJSONMarshal(t, u, want) 523 } 524 525 func TestStarEvent_Marshal(t *testing.T) { 526 testJSONMarshal(t, &StarEvent{}, "{}") 527 528 u := &StarEvent{ 529 Action: String("a"), 530 StarredAt: &Timestamp{referenceTime}, 531 Org: &Organization{ 532 BillingEmail: String("be"), 533 Blog: String("b"), 534 Company: String("c"), 535 Email: String("e"), 536 TwitterUsername: String("tu"), 537 Location: String("loc"), 538 Name: String("n"), 539 Description: String("d"), 540 IsVerified: Bool(true), 541 HasOrganizationProjects: Bool(true), 542 HasRepositoryProjects: Bool(true), 543 DefaultRepoPermission: String("drp"), 544 MembersCanCreateRepos: Bool(true), 545 MembersCanCreateInternalRepos: Bool(true), 546 MembersCanCreatePrivateRepos: Bool(true), 547 MembersCanCreatePublicRepos: Bool(false), 548 MembersAllowedRepositoryCreationType: String("marct"), 549 MembersCanCreatePages: Bool(true), 550 MembersCanCreatePublicPages: Bool(false), 551 MembersCanCreatePrivatePages: Bool(true), 552 }, 553 Repo: &Repository{ 554 ID: Int64(1), 555 URL: String("s"), 556 Name: String("n"), 557 }, 558 Sender: &User{ 559 Login: String("l"), 560 ID: Int64(1), 561 NodeID: String("n"), 562 URL: String("u"), 563 ReposURL: String("r"), 564 EventsURL: String("e"), 565 AvatarURL: String("a"), 566 }, 567 } 568 569 want := `{ 570 "action": "a", 571 "starred_at": ` + referenceTimeStr + `, 572 "organization": { 573 "name": "n", 574 "company": "c", 575 "blog": "b", 576 "location": "loc", 577 "email": "e", 578 "twitter_username": "tu", 579 "description": "d", 580 "billing_email": "be", 581 "is_verified": true, 582 "has_organization_projects": true, 583 "has_repository_projects": true, 584 "default_repository_permission": "drp", 585 "members_can_create_repositories": true, 586 "members_can_create_public_repositories": false, 587 "members_can_create_private_repositories": true, 588 "members_can_create_internal_repositories": true, 589 "members_allowed_repository_creation_type": "marct", 590 "members_can_create_pages": true, 591 "members_can_create_public_pages": false, 592 "members_can_create_private_pages": true 593 }, 594 "repository": { 595 "id": 1, 596 "name": "n", 597 "url": "s" 598 }, 599 "sender": { 600 "login": "l", 601 "id": 1, 602 "node_id": "n", 603 "avatar_url": "a", 604 "url": "u", 605 "events_url": "e", 606 "repos_url": "r" 607 } 608 }` 609 610 testJSONMarshal(t, u, want) 611 } 612 613 func TestTeamEvent_Marshal(t *testing.T) { 614 testJSONMarshal(t, &TeamEvent{}, "{}") 615 616 u := &TeamEvent{ 617 Action: String("a"), 618 Team: &Team{ 619 ID: Int64(1), 620 NodeID: String("n"), 621 Name: String("n"), 622 Description: String("d"), 623 URL: String("u"), 624 Slug: String("s"), 625 Permission: String("p"), 626 Privacy: String("p"), 627 MembersCount: Int(1), 628 ReposCount: Int(1), 629 MembersURL: String("m"), 630 RepositoriesURL: String("r"), 631 Organization: &Organization{ 632 Login: String("l"), 633 ID: Int64(1), 634 NodeID: String("n"), 635 AvatarURL: String("a"), 636 HTMLURL: String("h"), 637 Name: String("n"), 638 Company: String("c"), 639 Blog: String("b"), 640 Location: String("l"), 641 Email: String("e"), 642 }, 643 Parent: &Team{ 644 ID: Int64(1), 645 NodeID: String("n"), 646 Name: String("n"), 647 Description: String("d"), 648 URL: String("u"), 649 Slug: String("s"), 650 Permission: String("p"), 651 Privacy: String("p"), 652 MembersCount: Int(1), 653 ReposCount: Int(1), 654 }, 655 LDAPDN: String("l"), 656 }, 657 Changes: &TeamChange{ 658 Description: &TeamDescription{ 659 From: String("from"), 660 }, 661 Name: &TeamName{ 662 From: String("from"), 663 }, 664 Privacy: &TeamPrivacy{ 665 From: String("from"), 666 }, 667 Repository: &TeamRepository{ 668 Permissions: &TeamPermissions{ 669 From: &TeamPermissionsFrom{ 670 Admin: Bool(true), 671 Pull: Bool(true), 672 Push: Bool(true), 673 }, 674 }, 675 }, 676 }, 677 Repo: &Repository{ 678 ID: Int64(1), 679 URL: String("s"), 680 Name: String("n"), 681 }, 682 Org: &Organization{ 683 BillingEmail: String("be"), 684 Blog: String("b"), 685 Company: String("c"), 686 Email: String("e"), 687 TwitterUsername: String("tu"), 688 Location: String("loc"), 689 Name: String("n"), 690 Description: String("d"), 691 IsVerified: Bool(true), 692 HasOrganizationProjects: Bool(true), 693 HasRepositoryProjects: Bool(true), 694 DefaultRepoPermission: String("drp"), 695 MembersCanCreateRepos: Bool(true), 696 MembersCanCreateInternalRepos: Bool(true), 697 MembersCanCreatePrivateRepos: Bool(true), 698 MembersCanCreatePublicRepos: Bool(false), 699 MembersAllowedRepositoryCreationType: String("marct"), 700 MembersCanCreatePages: Bool(true), 701 MembersCanCreatePublicPages: Bool(false), 702 MembersCanCreatePrivatePages: Bool(true), 703 }, 704 Sender: &User{ 705 Login: String("l"), 706 ID: Int64(1), 707 NodeID: String("n"), 708 URL: String("u"), 709 ReposURL: String("r"), 710 EventsURL: String("e"), 711 AvatarURL: String("a"), 712 }, 713 Installation: &Installation{ 714 ID: Int64(1), 715 NodeID: String("nid"), 716 AppID: Int64(1), 717 AppSlug: String("as"), 718 TargetID: Int64(1), 719 Account: &User{ 720 Login: String("l"), 721 ID: Int64(1), 722 URL: String("u"), 723 AvatarURL: String("a"), 724 GravatarID: String("g"), 725 Name: String("n"), 726 Company: String("c"), 727 Blog: String("b"), 728 Location: String("l"), 729 Email: String("e"), 730 Hireable: Bool(true), 731 Bio: String("b"), 732 TwitterUsername: String("t"), 733 PublicRepos: Int(1), 734 Followers: Int(1), 735 Following: Int(1), 736 CreatedAt: &Timestamp{referenceTime}, 737 SuspendedAt: &Timestamp{referenceTime}, 738 }, 739 AccessTokensURL: String("atu"), 740 RepositoriesURL: String("ru"), 741 HTMLURL: String("hu"), 742 TargetType: String("tt"), 743 SingleFileName: String("sfn"), 744 RepositorySelection: String("rs"), 745 Events: []string{"e"}, 746 SingleFilePaths: []string{"s"}, 747 Permissions: &InstallationPermissions{ 748 Actions: String("a"), 749 Administration: String("ad"), 750 Checks: String("c"), 751 Contents: String("co"), 752 ContentReferences: String("cr"), 753 Deployments: String("d"), 754 Environments: String("e"), 755 Issues: String("i"), 756 Metadata: String("md"), 757 Members: String("m"), 758 OrganizationAdministration: String("oa"), 759 OrganizationHooks: String("oh"), 760 OrganizationPlan: String("op"), 761 OrganizationPreReceiveHooks: String("opr"), 762 OrganizationProjects: String("op"), 763 OrganizationSecrets: String("os"), 764 OrganizationSelfHostedRunners: String("osh"), 765 OrganizationUserBlocking: String("oub"), 766 Packages: String("pkg"), 767 Pages: String("pg"), 768 PullRequests: String("pr"), 769 RepositoryHooks: String("rh"), 770 RepositoryProjects: String("rp"), 771 RepositoryPreReceiveHooks: String("rprh"), 772 Secrets: String("s"), 773 SecretScanningAlerts: String("ssa"), 774 SecurityEvents: String("se"), 775 SingleFile: String("sf"), 776 Statuses: String("s"), 777 TeamDiscussions: String("td"), 778 VulnerabilityAlerts: String("va"), 779 Workflows: String("w"), 780 }, 781 CreatedAt: &Timestamp{referenceTime}, 782 UpdatedAt: &Timestamp{referenceTime}, 783 HasMultipleSingleFiles: Bool(false), 784 SuspendedBy: &User{ 785 Login: String("l"), 786 ID: Int64(1), 787 URL: String("u"), 788 AvatarURL: String("a"), 789 GravatarID: String("g"), 790 Name: String("n"), 791 Company: String("c"), 792 Blog: String("b"), 793 Location: String("l"), 794 Email: String("e"), 795 Hireable: Bool(true), 796 Bio: String("b"), 797 TwitterUsername: String("t"), 798 PublicRepos: Int(1), 799 Followers: Int(1), 800 Following: Int(1), 801 CreatedAt: &Timestamp{referenceTime}, 802 SuspendedAt: &Timestamp{referenceTime}, 803 }, 804 SuspendedAt: &Timestamp{referenceTime}, 805 }, 806 } 807 808 want := `{ 809 "action": "a", 810 "team": { 811 "id": 1, 812 "node_id": "n", 813 "name": "n", 814 "description": "d", 815 "url": "u", 816 "slug": "s", 817 "permission": "p", 818 "privacy": "p", 819 "members_count": 1, 820 "repos_count": 1, 821 "organization": { 822 "login": "l", 823 "id": 1, 824 "node_id": "n", 825 "avatar_url": "a", 826 "html_url": "h", 827 "name": "n", 828 "company": "c", 829 "blog": "b", 830 "location": "l", 831 "email": "e" 832 }, 833 "members_url": "m", 834 "repositories_url": "r", 835 "parent": { 836 "id": 1, 837 "node_id": "n", 838 "name": "n", 839 "description": "d", 840 "url": "u", 841 "slug": "s", 842 "permission": "p", 843 "privacy": "p", 844 "members_count": 1, 845 "repos_count": 1 846 }, 847 "ldap_dn": "l" 848 }, 849 "changes": { 850 "description": { 851 "from": "from" 852 }, 853 "name": { 854 "from": "from" 855 }, 856 "privacy": { 857 "from": "from" 858 }, 859 "repository": { 860 "permissions": { 861 "from": { 862 "admin": true, 863 "pull": true, 864 "push": true 865 } 866 } 867 } 868 }, 869 "repository": { 870 "id": 1, 871 "name": "n", 872 "url": "s" 873 }, 874 "organization": { 875 "name": "n", 876 "company": "c", 877 "blog": "b", 878 "location": "loc", 879 "email": "e", 880 "twitter_username": "tu", 881 "description": "d", 882 "billing_email": "be", 883 "is_verified": true, 884 "has_organization_projects": true, 885 "has_repository_projects": true, 886 "default_repository_permission": "drp", 887 "members_can_create_repositories": true, 888 "members_can_create_public_repositories": false, 889 "members_can_create_private_repositories": true, 890 "members_can_create_internal_repositories": true, 891 "members_allowed_repository_creation_type": "marct", 892 "members_can_create_pages": true, 893 "members_can_create_public_pages": false, 894 "members_can_create_private_pages": true 895 }, 896 "sender": { 897 "login": "l", 898 "id": 1, 899 "node_id": "n", 900 "avatar_url": "a", 901 "url": "u", 902 "events_url": "e", 903 "repos_url": "r" 904 }, 905 "installation": { 906 "id": 1, 907 "node_id": "nid", 908 "app_id": 1, 909 "app_slug": "as", 910 "target_id": 1, 911 "account": { 912 "login": "l", 913 "id": 1, 914 "avatar_url": "a", 915 "gravatar_id": "g", 916 "name": "n", 917 "company": "c", 918 "blog": "b", 919 "location": "l", 920 "email": "e", 921 "hireable": true, 922 "bio": "b", 923 "twitter_username": "t", 924 "public_repos": 1, 925 "followers": 1, 926 "following": 1, 927 "created_at": ` + referenceTimeStr + `, 928 "suspended_at": ` + referenceTimeStr + `, 929 "url": "u" 930 }, 931 "access_tokens_url": "atu", 932 "repositories_url": "ru", 933 "html_url": "hu", 934 "target_type": "tt", 935 "single_file_name": "sfn", 936 "repository_selection": "rs", 937 "events": [ 938 "e" 939 ], 940 "single_file_paths": [ 941 "s" 942 ], 943 "permissions": { 944 "actions": "a", 945 "administration": "ad", 946 "checks": "c", 947 "contents": "co", 948 "content_references": "cr", 949 "deployments": "d", 950 "environments": "e", 951 "issues": "i", 952 "metadata": "md", 953 "members": "m", 954 "organization_administration": "oa", 955 "organization_hooks": "oh", 956 "organization_plan": "op", 957 "organization_pre_receive_hooks": "opr", 958 "organization_projects": "op", 959 "organization_secrets": "os", 960 "organization_self_hosted_runners": "osh", 961 "organization_user_blocking": "oub", 962 "packages": "pkg", 963 "pages": "pg", 964 "pull_requests": "pr", 965 "repository_hooks": "rh", 966 "repository_projects": "rp", 967 "repository_pre_receive_hooks": "rprh", 968 "secrets": "s", 969 "secret_scanning_alerts": "ssa", 970 "security_events": "se", 971 "single_file": "sf", 972 "statuses": "s", 973 "team_discussions": "td", 974 "vulnerability_alerts": "va", 975 "workflows": "w" 976 }, 977 "created_at": ` + referenceTimeStr + `, 978 "updated_at": ` + referenceTimeStr + `, 979 "has_multiple_single_files": false, 980 "suspended_by": { 981 "login": "l", 982 "id": 1, 983 "avatar_url": "a", 984 "gravatar_id": "g", 985 "name": "n", 986 "company": "c", 987 "blog": "b", 988 "location": "l", 989 "email": "e", 990 "hireable": true, 991 "bio": "b", 992 "twitter_username": "t", 993 "public_repos": 1, 994 "followers": 1, 995 "following": 1, 996 "created_at": ` + referenceTimeStr + `, 997 "suspended_at": ` + referenceTimeStr + `, 998 "url": "u" 999 }, 1000 "suspended_at": ` + referenceTimeStr + ` 1001 } 1002 }` 1003 1004 testJSONMarshal(t, u, want) 1005 } 1006 1007 func TestInstallationRepositoriesEvent_Marshal(t *testing.T) { 1008 testJSONMarshal(t, &InstallationRepositoriesEvent{}, "{}") 1009 1010 u := &InstallationRepositoriesEvent{ 1011 Action: String("a"), 1012 RepositoriesAdded: []*Repository{ 1013 { 1014 ID: Int64(1), 1015 URL: String("s"), 1016 Name: String("n"), 1017 }, 1018 }, 1019 RepositoriesRemoved: []*Repository{ 1020 { 1021 ID: Int64(1), 1022 URL: String("s"), 1023 Name: String("n"), 1024 }, 1025 }, 1026 RepositorySelection: String("rs"), 1027 Sender: &User{ 1028 Login: String("l"), 1029 ID: Int64(1), 1030 NodeID: String("n"), 1031 URL: String("u"), 1032 ReposURL: String("r"), 1033 EventsURL: String("e"), 1034 AvatarURL: String("a"), 1035 }, 1036 Installation: &Installation{ 1037 ID: Int64(1), 1038 NodeID: String("nid"), 1039 AppID: Int64(1), 1040 AppSlug: String("as"), 1041 TargetID: Int64(1), 1042 Account: &User{ 1043 Login: String("l"), 1044 ID: Int64(1), 1045 URL: String("u"), 1046 AvatarURL: String("a"), 1047 GravatarID: String("g"), 1048 Name: String("n"), 1049 Company: String("c"), 1050 Blog: String("b"), 1051 Location: String("l"), 1052 Email: String("e"), 1053 Hireable: Bool(true), 1054 Bio: String("b"), 1055 TwitterUsername: String("t"), 1056 PublicRepos: Int(1), 1057 Followers: Int(1), 1058 Following: Int(1), 1059 CreatedAt: &Timestamp{referenceTime}, 1060 SuspendedAt: &Timestamp{referenceTime}, 1061 }, 1062 AccessTokensURL: String("atu"), 1063 RepositoriesURL: String("ru"), 1064 HTMLURL: String("hu"), 1065 TargetType: String("tt"), 1066 SingleFileName: String("sfn"), 1067 RepositorySelection: String("rs"), 1068 Events: []string{"e"}, 1069 SingleFilePaths: []string{"s"}, 1070 Permissions: &InstallationPermissions{ 1071 Actions: String("a"), 1072 Administration: String("ad"), 1073 Checks: String("c"), 1074 Contents: String("co"), 1075 ContentReferences: String("cr"), 1076 Deployments: String("d"), 1077 Environments: String("e"), 1078 Issues: String("i"), 1079 Metadata: String("md"), 1080 Members: String("m"), 1081 OrganizationAdministration: String("oa"), 1082 OrganizationHooks: String("oh"), 1083 OrganizationPlan: String("op"), 1084 OrganizationPreReceiveHooks: String("opr"), 1085 OrganizationProjects: String("op"), 1086 OrganizationSecrets: String("os"), 1087 OrganizationSelfHostedRunners: String("osh"), 1088 OrganizationUserBlocking: String("oub"), 1089 Packages: String("pkg"), 1090 Pages: String("pg"), 1091 PullRequests: String("pr"), 1092 RepositoryHooks: String("rh"), 1093 RepositoryProjects: String("rp"), 1094 RepositoryPreReceiveHooks: String("rprh"), 1095 Secrets: String("s"), 1096 SecretScanningAlerts: String("ssa"), 1097 SecurityEvents: String("se"), 1098 SingleFile: String("sf"), 1099 Statuses: String("s"), 1100 TeamDiscussions: String("td"), 1101 VulnerabilityAlerts: String("va"), 1102 Workflows: String("w"), 1103 }, 1104 CreatedAt: &Timestamp{referenceTime}, 1105 UpdatedAt: &Timestamp{referenceTime}, 1106 HasMultipleSingleFiles: Bool(false), 1107 SuspendedBy: &User{ 1108 Login: String("l"), 1109 ID: Int64(1), 1110 URL: String("u"), 1111 AvatarURL: String("a"), 1112 GravatarID: String("g"), 1113 Name: String("n"), 1114 Company: String("c"), 1115 Blog: String("b"), 1116 Location: String("l"), 1117 Email: String("e"), 1118 Hireable: Bool(true), 1119 Bio: String("b"), 1120 TwitterUsername: String("t"), 1121 PublicRepos: Int(1), 1122 Followers: Int(1), 1123 Following: Int(1), 1124 CreatedAt: &Timestamp{referenceTime}, 1125 SuspendedAt: &Timestamp{referenceTime}, 1126 }, 1127 SuspendedAt: &Timestamp{referenceTime}, 1128 }, 1129 } 1130 1131 want := `{ 1132 "action": "a", 1133 "repositories_added": [ 1134 { 1135 "id": 1, 1136 "name": "n", 1137 "url": "s" 1138 } 1139 ], 1140 "repositories_removed": [ 1141 { 1142 "id": 1, 1143 "name": "n", 1144 "url": "s" 1145 } 1146 ], 1147 "repository_selection": "rs", 1148 "sender": { 1149 "login": "l", 1150 "id": 1, 1151 "node_id": "n", 1152 "avatar_url": "a", 1153 "url": "u", 1154 "events_url": "e", 1155 "repos_url": "r" 1156 }, 1157 "installation": { 1158 "id": 1, 1159 "node_id": "nid", 1160 "app_id": 1, 1161 "app_slug": "as", 1162 "target_id": 1, 1163 "account": { 1164 "login": "l", 1165 "id": 1, 1166 "avatar_url": "a", 1167 "gravatar_id": "g", 1168 "name": "n", 1169 "company": "c", 1170 "blog": "b", 1171 "location": "l", 1172 "email": "e", 1173 "hireable": true, 1174 "bio": "b", 1175 "twitter_username": "t", 1176 "public_repos": 1, 1177 "followers": 1, 1178 "following": 1, 1179 "created_at": ` + referenceTimeStr + `, 1180 "suspended_at": ` + referenceTimeStr + `, 1181 "url": "u" 1182 }, 1183 "access_tokens_url": "atu", 1184 "repositories_url": "ru", 1185 "html_url": "hu", 1186 "target_type": "tt", 1187 "single_file_name": "sfn", 1188 "repository_selection": "rs", 1189 "events": [ 1190 "e" 1191 ], 1192 "single_file_paths": [ 1193 "s" 1194 ], 1195 "permissions": { 1196 "actions": "a", 1197 "administration": "ad", 1198 "checks": "c", 1199 "contents": "co", 1200 "content_references": "cr", 1201 "deployments": "d", 1202 "environments": "e", 1203 "issues": "i", 1204 "metadata": "md", 1205 "members": "m", 1206 "organization_administration": "oa", 1207 "organization_hooks": "oh", 1208 "organization_plan": "op", 1209 "organization_pre_receive_hooks": "opr", 1210 "organization_projects": "op", 1211 "organization_secrets": "os", 1212 "organization_self_hosted_runners": "osh", 1213 "organization_user_blocking": "oub", 1214 "packages": "pkg", 1215 "pages": "pg", 1216 "pull_requests": "pr", 1217 "repository_hooks": "rh", 1218 "repository_projects": "rp", 1219 "repository_pre_receive_hooks": "rprh", 1220 "secrets": "s", 1221 "secret_scanning_alerts": "ssa", 1222 "security_events": "se", 1223 "single_file": "sf", 1224 "statuses": "s", 1225 "team_discussions": "td", 1226 "vulnerability_alerts": "va", 1227 "workflows": "w" 1228 }, 1229 "created_at": ` + referenceTimeStr + `, 1230 "updated_at": ` + referenceTimeStr + `, 1231 "has_multiple_single_files": false, 1232 "suspended_by": { 1233 "login": "l", 1234 "id": 1, 1235 "avatar_url": "a", 1236 "gravatar_id": "g", 1237 "name": "n", 1238 "company": "c", 1239 "blog": "b", 1240 "location": "l", 1241 "email": "e", 1242 "hireable": true, 1243 "bio": "b", 1244 "twitter_username": "t", 1245 "public_repos": 1, 1246 "followers": 1, 1247 "following": 1, 1248 "created_at": ` + referenceTimeStr + `, 1249 "suspended_at": ` + referenceTimeStr + `, 1250 "url": "u" 1251 }, 1252 "suspended_at": ` + referenceTimeStr + ` 1253 } 1254 }` 1255 1256 testJSONMarshal(t, u, want) 1257 } 1258 1259 func TestEditTitle_Marshal(t *testing.T) { 1260 testJSONMarshal(t, &EditTitle{}, "{}") 1261 1262 u := &EditTitle{ 1263 From: String("EditTitleFrom"), 1264 } 1265 1266 want := `{ 1267 "from": "EditTitleFrom" 1268 }` 1269 1270 testJSONMarshal(t, u, want) 1271 } 1272 1273 func TestEditBody_Marshal(t *testing.T) { 1274 testJSONMarshal(t, &EditBody{}, "{}") 1275 1276 u := &EditBody{ 1277 From: String("EditBodyFrom"), 1278 } 1279 1280 want := `{ 1281 "from": "EditBodyFrom" 1282 }` 1283 1284 testJSONMarshal(t, u, want) 1285 } 1286 1287 func TestEditBase_Marshal(t *testing.T) { 1288 testJSONMarshal(t, &EditBase{}, "{}") 1289 1290 u := &EditBase{ 1291 Ref: &EditRef{ 1292 From: String("EditRefFrom"), 1293 }, 1294 SHA: &EditSHA{ 1295 From: String("EditSHAFrom"), 1296 }, 1297 } 1298 1299 want := `{ 1300 "ref": { 1301 "from": "EditRefFrom" 1302 }, 1303 "sha": { 1304 "from": "EditSHAFrom" 1305 } 1306 }` 1307 1308 testJSONMarshal(t, u, want) 1309 } 1310 1311 func TestEditRef_Marshal(t *testing.T) { 1312 testJSONMarshal(t, &EditRef{}, "{}") 1313 1314 u := &EditRef{ 1315 From: String("EditRefFrom"), 1316 } 1317 1318 want := `{ 1319 "from": "EditRefFrom" 1320 }` 1321 1322 testJSONMarshal(t, u, want) 1323 } 1324 1325 func TestEditSHA_Marshal(t *testing.T) { 1326 testJSONMarshal(t, &EditSHA{}, "{}") 1327 1328 u := &EditSHA{ 1329 From: String("EditSHAFrom"), 1330 } 1331 1332 want := `{ 1333 "from": "EditSHAFrom" 1334 }` 1335 1336 testJSONMarshal(t, u, want) 1337 } 1338 1339 func TestProjectName_Marshal(t *testing.T) { 1340 testJSONMarshal(t, &ProjectName{}, "{}") 1341 1342 u := &ProjectName{ 1343 From: String("ProjectNameFrom"), 1344 } 1345 1346 want := `{ 1347 "from": "ProjectNameFrom" 1348 }` 1349 1350 testJSONMarshal(t, u, want) 1351 } 1352 1353 func TestProjectBody_Marshal(t *testing.T) { 1354 testJSONMarshal(t, &ProjectBody{}, "{}") 1355 1356 u := &ProjectBody{ 1357 From: String("ProjectBodyFrom"), 1358 } 1359 1360 want := `{ 1361 "from": "ProjectBodyFrom" 1362 }` 1363 1364 testJSONMarshal(t, u, want) 1365 } 1366 1367 func TestProjectCardNote_Marshal(t *testing.T) { 1368 testJSONMarshal(t, &ProjectCardNote{}, "{}") 1369 1370 u := &ProjectCardNote{ 1371 From: String("ProjectCardNoteFrom"), 1372 } 1373 1374 want := `{ 1375 "from": "ProjectCardNoteFrom" 1376 }` 1377 1378 testJSONMarshal(t, u, want) 1379 } 1380 1381 func TestProjectColumnName_Marshal(t *testing.T) { 1382 testJSONMarshal(t, &ProjectColumnName{}, "{}") 1383 1384 u := &ProjectColumnName{ 1385 From: String("ProjectColumnNameFrom"), 1386 } 1387 1388 want := `{ 1389 "from": "ProjectColumnNameFrom" 1390 }` 1391 1392 testJSONMarshal(t, u, want) 1393 } 1394 1395 func TestTeamDescription_Marshal(t *testing.T) { 1396 testJSONMarshal(t, &TeamDescription{}, "{}") 1397 1398 u := &TeamDescription{ 1399 From: String("TeamDescriptionFrom"), 1400 } 1401 1402 want := `{ 1403 "from": "TeamDescriptionFrom" 1404 }` 1405 1406 testJSONMarshal(t, u, want) 1407 } 1408 1409 func TestTeamName_Marshal(t *testing.T) { 1410 testJSONMarshal(t, &TeamName{}, "{}") 1411 1412 u := &TeamName{ 1413 From: String("TeamNameFrom"), 1414 } 1415 1416 want := `{ 1417 "from": "TeamNameFrom" 1418 }` 1419 1420 testJSONMarshal(t, u, want) 1421 } 1422 1423 func TestTeamPrivacy_Marshal(t *testing.T) { 1424 testJSONMarshal(t, &TeamPrivacy{}, "{}") 1425 1426 u := &TeamPrivacy{ 1427 From: String("TeamPrivacyFrom"), 1428 } 1429 1430 want := `{ 1431 "from": "TeamPrivacyFrom" 1432 }` 1433 1434 testJSONMarshal(t, u, want) 1435 } 1436 1437 func TestTeamRepository_Marshal(t *testing.T) { 1438 testJSONMarshal(t, &TeamRepository{}, "{}") 1439 1440 u := &TeamRepository{ 1441 Permissions: &TeamPermissions{ 1442 From: &TeamPermissionsFrom{ 1443 Admin: Bool(true), 1444 Pull: Bool(true), 1445 Push: Bool(true), 1446 }, 1447 }, 1448 } 1449 1450 want := `{ 1451 "permissions": { 1452 "from": { 1453 "admin": true, 1454 "pull": true, 1455 "push": true 1456 } 1457 } 1458 }` 1459 1460 testJSONMarshal(t, u, want) 1461 } 1462 1463 func TestTeamPermissions_Marshal(t *testing.T) { 1464 testJSONMarshal(t, &TeamPermissions{}, "{}") 1465 1466 u := &TeamPermissions{ 1467 From: &TeamPermissionsFrom{ 1468 Admin: Bool(true), 1469 Pull: Bool(true), 1470 Push: Bool(true), 1471 }, 1472 } 1473 1474 want := `{ 1475 "from": { 1476 "admin": true, 1477 "pull": true, 1478 "push": true 1479 } 1480 }` 1481 1482 testJSONMarshal(t, u, want) 1483 } 1484 1485 func TestTeamPermissionsFrom_Marshal(t *testing.T) { 1486 testJSONMarshal(t, &TeamPermissionsFrom{}, "{}") 1487 1488 u := &TeamPermissionsFrom{ 1489 Admin: Bool(true), 1490 Pull: Bool(true), 1491 Push: Bool(true), 1492 } 1493 1494 want := `{ 1495 "admin": true, 1496 "pull": true, 1497 "push": true 1498 }` 1499 1500 testJSONMarshal(t, u, want) 1501 } 1502 1503 func TestRepositoryVulnerabilityAlert_Marshal(t *testing.T) { 1504 testJSONMarshal(t, &RepositoryVulnerabilityAlert{}, "{}") 1505 1506 u := &RepositoryVulnerabilityAlert{ 1507 ID: Int64(1), 1508 AffectedRange: String("ar"), 1509 AffectedPackageName: String("apn"), 1510 ExternalReference: String("er"), 1511 ExternalIdentifier: String("ei"), 1512 FixedIn: String("fi"), 1513 Dismisser: &User{ 1514 Login: String("l"), 1515 ID: Int64(1), 1516 NodeID: String("n"), 1517 URL: String("u"), 1518 ReposURL: String("r"), 1519 EventsURL: String("e"), 1520 AvatarURL: String("a"), 1521 }, 1522 DismissReason: String("dr"), 1523 DismissedAt: &Timestamp{referenceTime}, 1524 } 1525 1526 want := `{ 1527 "id": 1, 1528 "affected_range": "ar", 1529 "affected_package_name": "apn", 1530 "external_reference": "er", 1531 "external_identifier": "ei", 1532 "fixed_in": "fi", 1533 "dismisser": { 1534 "login": "l", 1535 "id": 1, 1536 "node_id": "n", 1537 "avatar_url": "a", 1538 "url": "u", 1539 "events_url": "e", 1540 "repos_url": "r" 1541 }, 1542 "dismiss_reason": "dr", 1543 "dismissed_at": ` + referenceTimeStr + ` 1544 }` 1545 1546 testJSONMarshal(t, u, want) 1547 } 1548 1549 func TestPage_Marshal(t *testing.T) { 1550 testJSONMarshal(t, &Page{}, "{}") 1551 1552 u := &Page{ 1553 PageName: String("p"), 1554 Title: String("t"), 1555 Summary: String("s"), 1556 Action: String("a"), 1557 SHA: String("s"), 1558 HTMLURL: String("h"), 1559 } 1560 1561 want := `{ 1562 "page_name": "p", 1563 "title": "t", 1564 "summary": "s", 1565 "action": "a", 1566 "sha": "s", 1567 "html_url": "h" 1568 }` 1569 1570 testJSONMarshal(t, u, want) 1571 } 1572 1573 func TestTeamChange_Marshal(t *testing.T) { 1574 testJSONMarshal(t, &TeamChange{}, "{}") 1575 1576 u := &TeamChange{ 1577 Description: &TeamDescription{ 1578 From: String("DescriptionFrom"), 1579 }, 1580 Name: &TeamName{ 1581 From: String("NameFrom"), 1582 }, 1583 Privacy: &TeamPrivacy{ 1584 From: String("PrivacyFrom"), 1585 }, 1586 Repository: &TeamRepository{ 1587 Permissions: &TeamPermissions{ 1588 From: &TeamPermissionsFrom{ 1589 Admin: Bool(false), 1590 Pull: Bool(false), 1591 Push: Bool(false), 1592 }, 1593 }, 1594 }, 1595 } 1596 1597 want := `{ 1598 "description": { 1599 "from": "DescriptionFrom" 1600 }, 1601 "name": { 1602 "from": "NameFrom" 1603 }, 1604 "privacy": { 1605 "from": "PrivacyFrom" 1606 }, 1607 "repository": { 1608 "permissions": { 1609 "from": { 1610 "admin": false, 1611 "pull": false, 1612 "push": false 1613 } 1614 } 1615 } 1616 }` 1617 1618 testJSONMarshal(t, u, want) 1619 } 1620 1621 func TestIssueCommentEvent_Marshal(t *testing.T) { 1622 testJSONMarshal(t, &IssueCommentEvent{}, "{}") 1623 1624 u := &IssueCommentEvent{ 1625 Action: String("a"), 1626 Issue: &Issue{ID: Int64(1)}, 1627 Comment: &IssueComment{ID: Int64(1)}, 1628 Changes: &EditChange{ 1629 Title: &EditTitle{ 1630 From: String("TitleFrom"), 1631 }, 1632 Body: &EditBody{ 1633 From: String("BodyFrom"), 1634 }, 1635 Base: &EditBase{ 1636 Ref: &EditRef{ 1637 From: String("BaseRefFrom"), 1638 }, 1639 SHA: &EditSHA{ 1640 From: String("BaseSHAFrom"), 1641 }, 1642 }, 1643 }, 1644 Repo: &Repository{ 1645 ID: Int64(1), 1646 URL: String("s"), 1647 Name: String("n"), 1648 }, 1649 Sender: &User{ 1650 Login: String("l"), 1651 ID: Int64(1), 1652 NodeID: String("n"), 1653 URL: String("u"), 1654 ReposURL: String("r"), 1655 EventsURL: String("e"), 1656 AvatarURL: String("a"), 1657 }, 1658 Installation: &Installation{ 1659 ID: Int64(1), 1660 NodeID: String("nid"), 1661 AppID: Int64(1), 1662 AppSlug: String("as"), 1663 TargetID: Int64(1), 1664 Account: &User{ 1665 Login: String("l"), 1666 ID: Int64(1), 1667 URL: String("u"), 1668 AvatarURL: String("a"), 1669 GravatarID: String("g"), 1670 Name: String("n"), 1671 Company: String("c"), 1672 Blog: String("b"), 1673 Location: String("l"), 1674 Email: String("e"), 1675 Hireable: Bool(true), 1676 Bio: String("b"), 1677 TwitterUsername: String("t"), 1678 PublicRepos: Int(1), 1679 Followers: Int(1), 1680 Following: Int(1), 1681 CreatedAt: &Timestamp{referenceTime}, 1682 SuspendedAt: &Timestamp{referenceTime}, 1683 }, 1684 AccessTokensURL: String("atu"), 1685 RepositoriesURL: String("ru"), 1686 HTMLURL: String("hu"), 1687 TargetType: String("tt"), 1688 SingleFileName: String("sfn"), 1689 RepositorySelection: String("rs"), 1690 Events: []string{"e"}, 1691 SingleFilePaths: []string{"s"}, 1692 Permissions: &InstallationPermissions{ 1693 Actions: String("a"), 1694 Administration: String("ad"), 1695 Checks: String("c"), 1696 Contents: String("co"), 1697 ContentReferences: String("cr"), 1698 Deployments: String("d"), 1699 Environments: String("e"), 1700 Issues: String("i"), 1701 Metadata: String("md"), 1702 Members: String("m"), 1703 OrganizationAdministration: String("oa"), 1704 OrganizationHooks: String("oh"), 1705 OrganizationPlan: String("op"), 1706 OrganizationPreReceiveHooks: String("opr"), 1707 OrganizationProjects: String("op"), 1708 OrganizationSecrets: String("os"), 1709 OrganizationSelfHostedRunners: String("osh"), 1710 OrganizationUserBlocking: String("oub"), 1711 Packages: String("pkg"), 1712 Pages: String("pg"), 1713 PullRequests: String("pr"), 1714 RepositoryHooks: String("rh"), 1715 RepositoryProjects: String("rp"), 1716 RepositoryPreReceiveHooks: String("rprh"), 1717 Secrets: String("s"), 1718 SecretScanningAlerts: String("ssa"), 1719 SecurityEvents: String("se"), 1720 SingleFile: String("sf"), 1721 Statuses: String("s"), 1722 TeamDiscussions: String("td"), 1723 VulnerabilityAlerts: String("va"), 1724 Workflows: String("w"), 1725 }, 1726 CreatedAt: &Timestamp{referenceTime}, 1727 UpdatedAt: &Timestamp{referenceTime}, 1728 HasMultipleSingleFiles: Bool(false), 1729 SuspendedBy: &User{ 1730 Login: String("l"), 1731 ID: Int64(1), 1732 URL: String("u"), 1733 AvatarURL: String("a"), 1734 GravatarID: String("g"), 1735 Name: String("n"), 1736 Company: String("c"), 1737 Blog: String("b"), 1738 Location: String("l"), 1739 Email: String("e"), 1740 Hireable: Bool(true), 1741 Bio: String("b"), 1742 TwitterUsername: String("t"), 1743 PublicRepos: Int(1), 1744 Followers: Int(1), 1745 Following: Int(1), 1746 CreatedAt: &Timestamp{referenceTime}, 1747 SuspendedAt: &Timestamp{referenceTime}, 1748 }, 1749 SuspendedAt: &Timestamp{referenceTime}, 1750 }, 1751 Organization: &Organization{ 1752 BillingEmail: String("be"), 1753 Blog: String("b"), 1754 Company: String("c"), 1755 Email: String("e"), 1756 TwitterUsername: String("tu"), 1757 Location: String("loc"), 1758 Name: String("n"), 1759 Description: String("d"), 1760 IsVerified: Bool(true), 1761 HasOrganizationProjects: Bool(true), 1762 HasRepositoryProjects: Bool(true), 1763 DefaultRepoPermission: String("drp"), 1764 MembersCanCreateRepos: Bool(true), 1765 MembersCanCreateInternalRepos: Bool(true), 1766 MembersCanCreatePrivateRepos: Bool(true), 1767 MembersCanCreatePublicRepos: Bool(false), 1768 MembersAllowedRepositoryCreationType: String("marct"), 1769 MembersCanCreatePages: Bool(true), 1770 MembersCanCreatePublicPages: Bool(false), 1771 MembersCanCreatePrivatePages: Bool(true), 1772 }, 1773 } 1774 1775 want := `{ 1776 "action": "a", 1777 "issue": { 1778 "id": 1 1779 }, 1780 "comment": { 1781 "id": 1 1782 }, 1783 "changes": { 1784 "title": { 1785 "from": "TitleFrom" 1786 }, 1787 "body": { 1788 "from": "BodyFrom" 1789 }, 1790 "base": { 1791 "ref": { 1792 "from": "BaseRefFrom" 1793 }, 1794 "sha": { 1795 "from": "BaseSHAFrom" 1796 } 1797 } 1798 }, 1799 "repository": { 1800 "id": 1, 1801 "name": "n", 1802 "url": "s" 1803 }, 1804 "sender": { 1805 "login": "l", 1806 "id": 1, 1807 "node_id": "n", 1808 "avatar_url": "a", 1809 "url": "u", 1810 "events_url": "e", 1811 "repos_url": "r" 1812 }, 1813 "installation": { 1814 "id": 1, 1815 "node_id": "nid", 1816 "app_id": 1, 1817 "app_slug": "as", 1818 "target_id": 1, 1819 "account": { 1820 "login": "l", 1821 "id": 1, 1822 "avatar_url": "a", 1823 "gravatar_id": "g", 1824 "name": "n", 1825 "company": "c", 1826 "blog": "b", 1827 "location": "l", 1828 "email": "e", 1829 "hireable": true, 1830 "bio": "b", 1831 "twitter_username": "t", 1832 "public_repos": 1, 1833 "followers": 1, 1834 "following": 1, 1835 "created_at": ` + referenceTimeStr + `, 1836 "suspended_at": ` + referenceTimeStr + `, 1837 "url": "u" 1838 }, 1839 "access_tokens_url": "atu", 1840 "repositories_url": "ru", 1841 "html_url": "hu", 1842 "target_type": "tt", 1843 "single_file_name": "sfn", 1844 "repository_selection": "rs", 1845 "events": [ 1846 "e" 1847 ], 1848 "single_file_paths": [ 1849 "s" 1850 ], 1851 "permissions": { 1852 "actions": "a", 1853 "administration": "ad", 1854 "checks": "c", 1855 "contents": "co", 1856 "content_references": "cr", 1857 "deployments": "d", 1858 "environments": "e", 1859 "issues": "i", 1860 "metadata": "md", 1861 "members": "m", 1862 "organization_administration": "oa", 1863 "organization_hooks": "oh", 1864 "organization_plan": "op", 1865 "organization_pre_receive_hooks": "opr", 1866 "organization_projects": "op", 1867 "organization_secrets": "os", 1868 "organization_self_hosted_runners": "osh", 1869 "organization_user_blocking": "oub", 1870 "packages": "pkg", 1871 "pages": "pg", 1872 "pull_requests": "pr", 1873 "repository_hooks": "rh", 1874 "repository_projects": "rp", 1875 "repository_pre_receive_hooks": "rprh", 1876 "secrets": "s", 1877 "secret_scanning_alerts": "ssa", 1878 "security_events": "se", 1879 "single_file": "sf", 1880 "statuses": "s", 1881 "team_discussions": "td", 1882 "vulnerability_alerts": "va", 1883 "workflows": "w" 1884 }, 1885 "created_at": ` + referenceTimeStr + `, 1886 "updated_at": ` + referenceTimeStr + `, 1887 "has_multiple_single_files": false, 1888 "suspended_by": { 1889 "login": "l", 1890 "id": 1, 1891 "avatar_url": "a", 1892 "gravatar_id": "g", 1893 "name": "n", 1894 "company": "c", 1895 "blog": "b", 1896 "location": "l", 1897 "email": "e", 1898 "hireable": true, 1899 "bio": "b", 1900 "twitter_username": "t", 1901 "public_repos": 1, 1902 "followers": 1, 1903 "following": 1, 1904 "created_at": ` + referenceTimeStr + `, 1905 "suspended_at": ` + referenceTimeStr + `, 1906 "url": "u" 1907 }, 1908 "suspended_at": ` + referenceTimeStr + ` 1909 }, 1910 "organization": { 1911 "name": "n", 1912 "company": "c", 1913 "blog": "b", 1914 "location": "loc", 1915 "email": "e", 1916 "twitter_username": "tu", 1917 "description": "d", 1918 "billing_email": "be", 1919 "is_verified": true, 1920 "has_organization_projects": true, 1921 "has_repository_projects": true, 1922 "default_repository_permission": "drp", 1923 "members_can_create_repositories": true, 1924 "members_can_create_public_repositories": false, 1925 "members_can_create_private_repositories": true, 1926 "members_can_create_internal_repositories": true, 1927 "members_allowed_repository_creation_type": "marct", 1928 "members_can_create_pages": true, 1929 "members_can_create_public_pages": false, 1930 "members_can_create_private_pages": true 1931 } 1932 }` 1933 1934 testJSONMarshal(t, u, want) 1935 } 1936 1937 func TestIssuesEvent_Marshal(t *testing.T) { 1938 testJSONMarshal(t, &IssuesEvent{}, "{}") 1939 1940 u := &IssuesEvent{ 1941 Action: String("a"), 1942 Issue: &Issue{ID: Int64(1)}, 1943 Assignee: &User{ 1944 Login: String("l"), 1945 ID: Int64(1), 1946 NodeID: String("n"), 1947 URL: String("u"), 1948 ReposURL: String("r"), 1949 EventsURL: String("e"), 1950 AvatarURL: String("a"), 1951 }, 1952 Label: &Label{ID: Int64(1)}, 1953 Changes: &EditChange{ 1954 Title: &EditTitle{ 1955 From: String("TitleFrom"), 1956 }, 1957 Body: &EditBody{ 1958 From: String("BodyFrom"), 1959 }, 1960 Base: &EditBase{ 1961 Ref: &EditRef{ 1962 From: String("BaseRefFrom"), 1963 }, 1964 SHA: &EditSHA{ 1965 From: String("BaseSHAFrom"), 1966 }, 1967 }, 1968 }, 1969 Repo: &Repository{ 1970 ID: Int64(1), 1971 URL: String("s"), 1972 Name: String("n"), 1973 }, 1974 Sender: &User{ 1975 Login: String("l"), 1976 ID: Int64(1), 1977 NodeID: String("n"), 1978 URL: String("u"), 1979 ReposURL: String("r"), 1980 EventsURL: String("e"), 1981 AvatarURL: String("a"), 1982 }, 1983 Installation: &Installation{ 1984 ID: Int64(1), 1985 NodeID: String("nid"), 1986 AppID: Int64(1), 1987 AppSlug: String("as"), 1988 TargetID: Int64(1), 1989 Account: &User{ 1990 Login: String("l"), 1991 ID: Int64(1), 1992 URL: String("u"), 1993 AvatarURL: String("a"), 1994 GravatarID: String("g"), 1995 Name: String("n"), 1996 Company: String("c"), 1997 Blog: String("b"), 1998 Location: String("l"), 1999 Email: String("e"), 2000 Hireable: Bool(true), 2001 Bio: String("b"), 2002 TwitterUsername: String("t"), 2003 PublicRepos: Int(1), 2004 Followers: Int(1), 2005 Following: Int(1), 2006 CreatedAt: &Timestamp{referenceTime}, 2007 SuspendedAt: &Timestamp{referenceTime}, 2008 }, 2009 AccessTokensURL: String("atu"), 2010 RepositoriesURL: String("ru"), 2011 HTMLURL: String("hu"), 2012 TargetType: String("tt"), 2013 SingleFileName: String("sfn"), 2014 RepositorySelection: String("rs"), 2015 Events: []string{"e"}, 2016 SingleFilePaths: []string{"s"}, 2017 Permissions: &InstallationPermissions{ 2018 Actions: String("a"), 2019 Administration: String("ad"), 2020 Checks: String("c"), 2021 Contents: String("co"), 2022 ContentReferences: String("cr"), 2023 Deployments: String("d"), 2024 Environments: String("e"), 2025 Issues: String("i"), 2026 Metadata: String("md"), 2027 Members: String("m"), 2028 OrganizationAdministration: String("oa"), 2029 OrganizationHooks: String("oh"), 2030 OrganizationPlan: String("op"), 2031 OrganizationPreReceiveHooks: String("opr"), 2032 OrganizationProjects: String("op"), 2033 OrganizationSecrets: String("os"), 2034 OrganizationSelfHostedRunners: String("osh"), 2035 OrganizationUserBlocking: String("oub"), 2036 Packages: String("pkg"), 2037 Pages: String("pg"), 2038 PullRequests: String("pr"), 2039 RepositoryHooks: String("rh"), 2040 RepositoryProjects: String("rp"), 2041 RepositoryPreReceiveHooks: String("rprh"), 2042 Secrets: String("s"), 2043 SecretScanningAlerts: String("ssa"), 2044 SecurityEvents: String("se"), 2045 SingleFile: String("sf"), 2046 Statuses: String("s"), 2047 TeamDiscussions: String("td"), 2048 VulnerabilityAlerts: String("va"), 2049 Workflows: String("w"), 2050 }, 2051 CreatedAt: &Timestamp{referenceTime}, 2052 UpdatedAt: &Timestamp{referenceTime}, 2053 HasMultipleSingleFiles: Bool(false), 2054 SuspendedBy: &User{ 2055 Login: String("l"), 2056 ID: Int64(1), 2057 URL: String("u"), 2058 AvatarURL: String("a"), 2059 GravatarID: String("g"), 2060 Name: String("n"), 2061 Company: String("c"), 2062 Blog: String("b"), 2063 Location: String("l"), 2064 Email: String("e"), 2065 Hireable: Bool(true), 2066 Bio: String("b"), 2067 TwitterUsername: String("t"), 2068 PublicRepos: Int(1), 2069 Followers: Int(1), 2070 Following: Int(1), 2071 CreatedAt: &Timestamp{referenceTime}, 2072 SuspendedAt: &Timestamp{referenceTime}, 2073 }, 2074 SuspendedAt: &Timestamp{referenceTime}, 2075 }, 2076 } 2077 2078 want := `{ 2079 "action": "a", 2080 "issue": { 2081 "id": 1 2082 }, 2083 "assignee": { 2084 "login": "l", 2085 "id": 1, 2086 "node_id": "n", 2087 "avatar_url": "a", 2088 "url": "u", 2089 "events_url": "e", 2090 "repos_url": "r" 2091 }, 2092 "label": { 2093 "id": 1 2094 }, 2095 "changes": { 2096 "title": { 2097 "from": "TitleFrom" 2098 }, 2099 "body": { 2100 "from": "BodyFrom" 2101 }, 2102 "base": { 2103 "ref": { 2104 "from": "BaseRefFrom" 2105 }, 2106 "sha": { 2107 "from": "BaseSHAFrom" 2108 } 2109 } 2110 }, 2111 "repository": { 2112 "id": 1, 2113 "name": "n", 2114 "url": "s" 2115 }, 2116 "sender": { 2117 "login": "l", 2118 "id": 1, 2119 "node_id": "n", 2120 "avatar_url": "a", 2121 "url": "u", 2122 "events_url": "e", 2123 "repos_url": "r" 2124 }, 2125 "installation": { 2126 "id": 1, 2127 "node_id": "nid", 2128 "app_id": 1, 2129 "app_slug": "as", 2130 "target_id": 1, 2131 "account": { 2132 "login": "l", 2133 "id": 1, 2134 "avatar_url": "a", 2135 "gravatar_id": "g", 2136 "name": "n", 2137 "company": "c", 2138 "blog": "b", 2139 "location": "l", 2140 "email": "e", 2141 "hireable": true, 2142 "bio": "b", 2143 "twitter_username": "t", 2144 "public_repos": 1, 2145 "followers": 1, 2146 "following": 1, 2147 "created_at": ` + referenceTimeStr + `, 2148 "suspended_at": ` + referenceTimeStr + `, 2149 "url": "u" 2150 }, 2151 "access_tokens_url": "atu", 2152 "repositories_url": "ru", 2153 "html_url": "hu", 2154 "target_type": "tt", 2155 "single_file_name": "sfn", 2156 "repository_selection": "rs", 2157 "events": [ 2158 "e" 2159 ], 2160 "single_file_paths": [ 2161 "s" 2162 ], 2163 "permissions": { 2164 "actions": "a", 2165 "administration": "ad", 2166 "checks": "c", 2167 "contents": "co", 2168 "content_references": "cr", 2169 "deployments": "d", 2170 "environments": "e", 2171 "issues": "i", 2172 "metadata": "md", 2173 "members": "m", 2174 "organization_administration": "oa", 2175 "organization_hooks": "oh", 2176 "organization_plan": "op", 2177 "organization_pre_receive_hooks": "opr", 2178 "organization_projects": "op", 2179 "organization_secrets": "os", 2180 "organization_self_hosted_runners": "osh", 2181 "organization_user_blocking": "oub", 2182 "packages": "pkg", 2183 "pages": "pg", 2184 "pull_requests": "pr", 2185 "repository_hooks": "rh", 2186 "repository_projects": "rp", 2187 "repository_pre_receive_hooks": "rprh", 2188 "secrets": "s", 2189 "secret_scanning_alerts": "ssa", 2190 "security_events": "se", 2191 "single_file": "sf", 2192 "statuses": "s", 2193 "team_discussions": "td", 2194 "vulnerability_alerts": "va", 2195 "workflows": "w" 2196 }, 2197 "created_at": ` + referenceTimeStr + `, 2198 "updated_at": ` + referenceTimeStr + `, 2199 "has_multiple_single_files": false, 2200 "suspended_by": { 2201 "login": "l", 2202 "id": 1, 2203 "avatar_url": "a", 2204 "gravatar_id": "g", 2205 "name": "n", 2206 "company": "c", 2207 "blog": "b", 2208 "location": "l", 2209 "email": "e", 2210 "hireable": true, 2211 "bio": "b", 2212 "twitter_username": "t", 2213 "public_repos": 1, 2214 "followers": 1, 2215 "following": 1, 2216 "created_at": ` + referenceTimeStr + `, 2217 "suspended_at": ` + referenceTimeStr + `, 2218 "url": "u" 2219 }, 2220 "suspended_at": ` + referenceTimeStr + ` 2221 } 2222 }` 2223 2224 testJSONMarshal(t, u, want) 2225 } 2226 2227 func TestLabelEvent_Marshal(t *testing.T) { 2228 testJSONMarshal(t, &LabelEvent{}, "{}") 2229 2230 u := &LabelEvent{ 2231 Action: String("a"), 2232 Label: &Label{ID: Int64(1)}, 2233 Changes: &EditChange{ 2234 Title: &EditTitle{ 2235 From: String("TitleFrom"), 2236 }, 2237 Body: &EditBody{ 2238 From: String("BodyFrom"), 2239 }, 2240 Base: &EditBase{ 2241 Ref: &EditRef{ 2242 From: String("BaseRefFrom"), 2243 }, 2244 SHA: &EditSHA{ 2245 From: String("BaseSHAFrom"), 2246 }, 2247 }, 2248 }, 2249 Repo: &Repository{ 2250 ID: Int64(1), 2251 URL: String("s"), 2252 Name: String("n"), 2253 }, 2254 Org: &Organization{ 2255 BillingEmail: String("be"), 2256 Blog: String("b"), 2257 Company: String("c"), 2258 Email: String("e"), 2259 TwitterUsername: String("tu"), 2260 Location: String("loc"), 2261 Name: String("n"), 2262 Description: String("d"), 2263 IsVerified: Bool(true), 2264 HasOrganizationProjects: Bool(true), 2265 HasRepositoryProjects: Bool(true), 2266 DefaultRepoPermission: String("drp"), 2267 MembersCanCreateRepos: Bool(true), 2268 MembersCanCreateInternalRepos: Bool(true), 2269 MembersCanCreatePrivateRepos: Bool(true), 2270 MembersCanCreatePublicRepos: Bool(false), 2271 MembersAllowedRepositoryCreationType: String("marct"), 2272 MembersCanCreatePages: Bool(true), 2273 MembersCanCreatePublicPages: Bool(false), 2274 MembersCanCreatePrivatePages: Bool(true), 2275 }, 2276 Installation: &Installation{ 2277 ID: Int64(1), 2278 NodeID: String("nid"), 2279 AppID: Int64(1), 2280 AppSlug: String("as"), 2281 TargetID: Int64(1), 2282 Account: &User{ 2283 Login: String("l"), 2284 ID: Int64(1), 2285 URL: String("u"), 2286 AvatarURL: String("a"), 2287 GravatarID: String("g"), 2288 Name: String("n"), 2289 Company: String("c"), 2290 Blog: String("b"), 2291 Location: String("l"), 2292 Email: String("e"), 2293 Hireable: Bool(true), 2294 Bio: String("b"), 2295 TwitterUsername: String("t"), 2296 PublicRepos: Int(1), 2297 Followers: Int(1), 2298 Following: Int(1), 2299 CreatedAt: &Timestamp{referenceTime}, 2300 SuspendedAt: &Timestamp{referenceTime}, 2301 }, 2302 AccessTokensURL: String("atu"), 2303 RepositoriesURL: String("ru"), 2304 HTMLURL: String("hu"), 2305 TargetType: String("tt"), 2306 SingleFileName: String("sfn"), 2307 RepositorySelection: String("rs"), 2308 Events: []string{"e"}, 2309 SingleFilePaths: []string{"s"}, 2310 Permissions: &InstallationPermissions{ 2311 Actions: String("a"), 2312 Administration: String("ad"), 2313 Checks: String("c"), 2314 Contents: String("co"), 2315 ContentReferences: String("cr"), 2316 Deployments: String("d"), 2317 Environments: String("e"), 2318 Issues: String("i"), 2319 Metadata: String("md"), 2320 Members: String("m"), 2321 OrganizationAdministration: String("oa"), 2322 OrganizationHooks: String("oh"), 2323 OrganizationPlan: String("op"), 2324 OrganizationPreReceiveHooks: String("opr"), 2325 OrganizationProjects: String("op"), 2326 OrganizationSecrets: String("os"), 2327 OrganizationSelfHostedRunners: String("osh"), 2328 OrganizationUserBlocking: String("oub"), 2329 Packages: String("pkg"), 2330 Pages: String("pg"), 2331 PullRequests: String("pr"), 2332 RepositoryHooks: String("rh"), 2333 RepositoryProjects: String("rp"), 2334 RepositoryPreReceiveHooks: String("rprh"), 2335 Secrets: String("s"), 2336 SecretScanningAlerts: String("ssa"), 2337 SecurityEvents: String("se"), 2338 SingleFile: String("sf"), 2339 Statuses: String("s"), 2340 TeamDiscussions: String("td"), 2341 VulnerabilityAlerts: String("va"), 2342 Workflows: String("w"), 2343 }, 2344 CreatedAt: &Timestamp{referenceTime}, 2345 UpdatedAt: &Timestamp{referenceTime}, 2346 HasMultipleSingleFiles: Bool(false), 2347 SuspendedBy: &User{ 2348 Login: String("l"), 2349 ID: Int64(1), 2350 URL: String("u"), 2351 AvatarURL: String("a"), 2352 GravatarID: String("g"), 2353 Name: String("n"), 2354 Company: String("c"), 2355 Blog: String("b"), 2356 Location: String("l"), 2357 Email: String("e"), 2358 Hireable: Bool(true), 2359 Bio: String("b"), 2360 TwitterUsername: String("t"), 2361 PublicRepos: Int(1), 2362 Followers: Int(1), 2363 Following: Int(1), 2364 CreatedAt: &Timestamp{referenceTime}, 2365 SuspendedAt: &Timestamp{referenceTime}, 2366 }, 2367 SuspendedAt: &Timestamp{referenceTime}, 2368 }, 2369 } 2370 2371 want := `{ 2372 "action": "a", 2373 "label": { 2374 "id": 1 2375 }, 2376 "changes": { 2377 "title": { 2378 "from": "TitleFrom" 2379 }, 2380 "body": { 2381 "from": "BodyFrom" 2382 }, 2383 "base": { 2384 "ref": { 2385 "from": "BaseRefFrom" 2386 }, 2387 "sha": { 2388 "from": "BaseSHAFrom" 2389 } 2390 } 2391 }, 2392 "repository": { 2393 "id": 1, 2394 "name": "n", 2395 "url": "s" 2396 }, 2397 "organization": { 2398 "name": "n", 2399 "company": "c", 2400 "blog": "b", 2401 "location": "loc", 2402 "email": "e", 2403 "twitter_username": "tu", 2404 "description": "d", 2405 "billing_email": "be", 2406 "is_verified": true, 2407 "has_organization_projects": true, 2408 "has_repository_projects": true, 2409 "default_repository_permission": "drp", 2410 "members_can_create_repositories": true, 2411 "members_can_create_public_repositories": false, 2412 "members_can_create_private_repositories": true, 2413 "members_can_create_internal_repositories": true, 2414 "members_allowed_repository_creation_type": "marct", 2415 "members_can_create_pages": true, 2416 "members_can_create_public_pages": false, 2417 "members_can_create_private_pages": true 2418 }, 2419 "installation": { 2420 "id": 1, 2421 "node_id": "nid", 2422 "app_id": 1, 2423 "app_slug": "as", 2424 "target_id": 1, 2425 "account": { 2426 "login": "l", 2427 "id": 1, 2428 "avatar_url": "a", 2429 "gravatar_id": "g", 2430 "name": "n", 2431 "company": "c", 2432 "blog": "b", 2433 "location": "l", 2434 "email": "e", 2435 "hireable": true, 2436 "bio": "b", 2437 "twitter_username": "t", 2438 "public_repos": 1, 2439 "followers": 1, 2440 "following": 1, 2441 "created_at": ` + referenceTimeStr + `, 2442 "suspended_at": ` + referenceTimeStr + `, 2443 "url": "u" 2444 }, 2445 "access_tokens_url": "atu", 2446 "repositories_url": "ru", 2447 "html_url": "hu", 2448 "target_type": "tt", 2449 "single_file_name": "sfn", 2450 "repository_selection": "rs", 2451 "events": [ 2452 "e" 2453 ], 2454 "single_file_paths": [ 2455 "s" 2456 ], 2457 "permissions": { 2458 "actions": "a", 2459 "administration": "ad", 2460 "checks": "c", 2461 "contents": "co", 2462 "content_references": "cr", 2463 "deployments": "d", 2464 "environments": "e", 2465 "issues": "i", 2466 "metadata": "md", 2467 "members": "m", 2468 "organization_administration": "oa", 2469 "organization_hooks": "oh", 2470 "organization_plan": "op", 2471 "organization_pre_receive_hooks": "opr", 2472 "organization_projects": "op", 2473 "organization_secrets": "os", 2474 "organization_self_hosted_runners": "osh", 2475 "organization_user_blocking": "oub", 2476 "packages": "pkg", 2477 "pages": "pg", 2478 "pull_requests": "pr", 2479 "repository_hooks": "rh", 2480 "repository_projects": "rp", 2481 "repository_pre_receive_hooks": "rprh", 2482 "secrets": "s", 2483 "secret_scanning_alerts": "ssa", 2484 "security_events": "se", 2485 "single_file": "sf", 2486 "statuses": "s", 2487 "team_discussions": "td", 2488 "vulnerability_alerts": "va", 2489 "workflows": "w" 2490 }, 2491 "created_at": ` + referenceTimeStr + `, 2492 "updated_at": ` + referenceTimeStr + `, 2493 "has_multiple_single_files": false, 2494 "suspended_by": { 2495 "login": "l", 2496 "id": 1, 2497 "avatar_url": "a", 2498 "gravatar_id": "g", 2499 "name": "n", 2500 "company": "c", 2501 "blog": "b", 2502 "location": "l", 2503 "email": "e", 2504 "hireable": true, 2505 "bio": "b", 2506 "twitter_username": "t", 2507 "public_repos": 1, 2508 "followers": 1, 2509 "following": 1, 2510 "created_at": ` + referenceTimeStr + `, 2511 "suspended_at": ` + referenceTimeStr + `, 2512 "url": "u" 2513 }, 2514 "suspended_at": ` + referenceTimeStr + ` 2515 } 2516 }` 2517 2518 testJSONMarshal(t, u, want) 2519 } 2520 2521 func TestMilestoneEvent_Marshal(t *testing.T) { 2522 testJSONMarshal(t, &MilestoneEvent{}, "{}") 2523 2524 u := &MilestoneEvent{ 2525 Action: String("a"), 2526 Milestone: &Milestone{ID: Int64(1)}, 2527 Changes: &EditChange{ 2528 Title: &EditTitle{ 2529 From: String("TitleFrom"), 2530 }, 2531 Body: &EditBody{ 2532 From: String("BodyFrom"), 2533 }, 2534 Base: &EditBase{ 2535 Ref: &EditRef{ 2536 From: String("BaseRefFrom"), 2537 }, 2538 SHA: &EditSHA{ 2539 From: String("BaseSHAFrom"), 2540 }, 2541 }, 2542 }, 2543 Repo: &Repository{ 2544 ID: Int64(1), 2545 URL: String("s"), 2546 Name: String("n"), 2547 }, 2548 Sender: &User{ 2549 Login: String("l"), 2550 ID: Int64(1), 2551 NodeID: String("n"), 2552 URL: String("u"), 2553 ReposURL: String("r"), 2554 EventsURL: String("e"), 2555 AvatarURL: String("a"), 2556 }, 2557 Org: &Organization{ 2558 BillingEmail: String("be"), 2559 Blog: String("b"), 2560 Company: String("c"), 2561 Email: String("e"), 2562 TwitterUsername: String("tu"), 2563 Location: String("loc"), 2564 Name: String("n"), 2565 Description: String("d"), 2566 IsVerified: Bool(true), 2567 HasOrganizationProjects: Bool(true), 2568 HasRepositoryProjects: Bool(true), 2569 DefaultRepoPermission: String("drp"), 2570 MembersCanCreateRepos: Bool(true), 2571 MembersCanCreateInternalRepos: Bool(true), 2572 MembersCanCreatePrivateRepos: Bool(true), 2573 MembersCanCreatePublicRepos: Bool(false), 2574 MembersAllowedRepositoryCreationType: String("marct"), 2575 MembersCanCreatePages: Bool(true), 2576 MembersCanCreatePublicPages: Bool(false), 2577 MembersCanCreatePrivatePages: Bool(true), 2578 }, 2579 Installation: &Installation{ 2580 ID: Int64(1), 2581 NodeID: String("nid"), 2582 AppID: Int64(1), 2583 AppSlug: String("as"), 2584 TargetID: Int64(1), 2585 Account: &User{ 2586 Login: String("l"), 2587 ID: Int64(1), 2588 URL: String("u"), 2589 AvatarURL: String("a"), 2590 GravatarID: String("g"), 2591 Name: String("n"), 2592 Company: String("c"), 2593 Blog: String("b"), 2594 Location: String("l"), 2595 Email: String("e"), 2596 Hireable: Bool(true), 2597 Bio: String("b"), 2598 TwitterUsername: String("t"), 2599 PublicRepos: Int(1), 2600 Followers: Int(1), 2601 Following: Int(1), 2602 CreatedAt: &Timestamp{referenceTime}, 2603 SuspendedAt: &Timestamp{referenceTime}, 2604 }, 2605 AccessTokensURL: String("atu"), 2606 RepositoriesURL: String("ru"), 2607 HTMLURL: String("hu"), 2608 TargetType: String("tt"), 2609 SingleFileName: String("sfn"), 2610 RepositorySelection: String("rs"), 2611 Events: []string{"e"}, 2612 SingleFilePaths: []string{"s"}, 2613 Permissions: &InstallationPermissions{ 2614 Actions: String("a"), 2615 Administration: String("ad"), 2616 Checks: String("c"), 2617 Contents: String("co"), 2618 ContentReferences: String("cr"), 2619 Deployments: String("d"), 2620 Environments: String("e"), 2621 Issues: String("i"), 2622 Metadata: String("md"), 2623 Members: String("m"), 2624 OrganizationAdministration: String("oa"), 2625 OrganizationHooks: String("oh"), 2626 OrganizationPlan: String("op"), 2627 OrganizationPreReceiveHooks: String("opr"), 2628 OrganizationProjects: String("op"), 2629 OrganizationSecrets: String("os"), 2630 OrganizationSelfHostedRunners: String("osh"), 2631 OrganizationUserBlocking: String("oub"), 2632 Packages: String("pkg"), 2633 Pages: String("pg"), 2634 PullRequests: String("pr"), 2635 RepositoryHooks: String("rh"), 2636 RepositoryProjects: String("rp"), 2637 RepositoryPreReceiveHooks: String("rprh"), 2638 Secrets: String("s"), 2639 SecretScanningAlerts: String("ssa"), 2640 SecurityEvents: String("se"), 2641 SingleFile: String("sf"), 2642 Statuses: String("s"), 2643 TeamDiscussions: String("td"), 2644 VulnerabilityAlerts: String("va"), 2645 Workflows: String("w"), 2646 }, 2647 CreatedAt: &Timestamp{referenceTime}, 2648 UpdatedAt: &Timestamp{referenceTime}, 2649 HasMultipleSingleFiles: Bool(false), 2650 SuspendedBy: &User{ 2651 Login: String("l"), 2652 ID: Int64(1), 2653 URL: String("u"), 2654 AvatarURL: String("a"), 2655 GravatarID: String("g"), 2656 Name: String("n"), 2657 Company: String("c"), 2658 Blog: String("b"), 2659 Location: String("l"), 2660 Email: String("e"), 2661 Hireable: Bool(true), 2662 Bio: String("b"), 2663 TwitterUsername: String("t"), 2664 PublicRepos: Int(1), 2665 Followers: Int(1), 2666 Following: Int(1), 2667 CreatedAt: &Timestamp{referenceTime}, 2668 SuspendedAt: &Timestamp{referenceTime}, 2669 }, 2670 SuspendedAt: &Timestamp{referenceTime}, 2671 }, 2672 } 2673 2674 want := `{ 2675 "action": "a", 2676 "milestone": { 2677 "id": 1 2678 }, 2679 "changes": { 2680 "title": { 2681 "from": "TitleFrom" 2682 }, 2683 "body": { 2684 "from": "BodyFrom" 2685 }, 2686 "base": { 2687 "ref": { 2688 "from": "BaseRefFrom" 2689 }, 2690 "sha": { 2691 "from": "BaseSHAFrom" 2692 } 2693 } 2694 }, 2695 "repository": { 2696 "id": 1, 2697 "name": "n", 2698 "url": "s" 2699 }, 2700 "sender": { 2701 "login": "l", 2702 "id": 1, 2703 "node_id": "n", 2704 "avatar_url": "a", 2705 "url": "u", 2706 "events_url": "e", 2707 "repos_url": "r" 2708 }, 2709 "organization": { 2710 "name": "n", 2711 "company": "c", 2712 "blog": "b", 2713 "location": "loc", 2714 "email": "e", 2715 "twitter_username": "tu", 2716 "description": "d", 2717 "billing_email": "be", 2718 "is_verified": true, 2719 "has_organization_projects": true, 2720 "has_repository_projects": true, 2721 "default_repository_permission": "drp", 2722 "members_can_create_repositories": true, 2723 "members_can_create_public_repositories": false, 2724 "members_can_create_private_repositories": true, 2725 "members_can_create_internal_repositories": true, 2726 "members_allowed_repository_creation_type": "marct", 2727 "members_can_create_pages": true, 2728 "members_can_create_public_pages": false, 2729 "members_can_create_private_pages": true 2730 }, 2731 "installation": { 2732 "id": 1, 2733 "node_id": "nid", 2734 "app_id": 1, 2735 "app_slug": "as", 2736 "target_id": 1, 2737 "account": { 2738 "login": "l", 2739 "id": 1, 2740 "avatar_url": "a", 2741 "gravatar_id": "g", 2742 "name": "n", 2743 "company": "c", 2744 "blog": "b", 2745 "location": "l", 2746 "email": "e", 2747 "hireable": true, 2748 "bio": "b", 2749 "twitter_username": "t", 2750 "public_repos": 1, 2751 "followers": 1, 2752 "following": 1, 2753 "created_at": ` + referenceTimeStr + `, 2754 "suspended_at": ` + referenceTimeStr + `, 2755 "url": "u" 2756 }, 2757 "access_tokens_url": "atu", 2758 "repositories_url": "ru", 2759 "html_url": "hu", 2760 "target_type": "tt", 2761 "single_file_name": "sfn", 2762 "repository_selection": "rs", 2763 "events": [ 2764 "e" 2765 ], 2766 "single_file_paths": [ 2767 "s" 2768 ], 2769 "permissions": { 2770 "actions": "a", 2771 "administration": "ad", 2772 "checks": "c", 2773 "contents": "co", 2774 "content_references": "cr", 2775 "deployments": "d", 2776 "environments": "e", 2777 "issues": "i", 2778 "metadata": "md", 2779 "members": "m", 2780 "organization_administration": "oa", 2781 "organization_hooks": "oh", 2782 "organization_plan": "op", 2783 "organization_pre_receive_hooks": "opr", 2784 "organization_projects": "op", 2785 "organization_secrets": "os", 2786 "organization_self_hosted_runners": "osh", 2787 "organization_user_blocking": "oub", 2788 "packages": "pkg", 2789 "pages": "pg", 2790 "pull_requests": "pr", 2791 "repository_hooks": "rh", 2792 "repository_projects": "rp", 2793 "repository_pre_receive_hooks": "rprh", 2794 "secrets": "s", 2795 "secret_scanning_alerts": "ssa", 2796 "security_events": "se", 2797 "single_file": "sf", 2798 "statuses": "s", 2799 "team_discussions": "td", 2800 "vulnerability_alerts": "va", 2801 "workflows": "w" 2802 }, 2803 "created_at": ` + referenceTimeStr + `, 2804 "updated_at": ` + referenceTimeStr + `, 2805 "has_multiple_single_files": false, 2806 "suspended_by": { 2807 "login": "l", 2808 "id": 1, 2809 "avatar_url": "a", 2810 "gravatar_id": "g", 2811 "name": "n", 2812 "company": "c", 2813 "blog": "b", 2814 "location": "l", 2815 "email": "e", 2816 "hireable": true, 2817 "bio": "b", 2818 "twitter_username": "t", 2819 "public_repos": 1, 2820 "followers": 1, 2821 "following": 1, 2822 "created_at": ` + referenceTimeStr + `, 2823 "suspended_at": ` + referenceTimeStr + `, 2824 "url": "u" 2825 }, 2826 "suspended_at": ` + referenceTimeStr + ` 2827 } 2828 }` 2829 2830 testJSONMarshal(t, u, want) 2831 } 2832 2833 func TestPublicEvent_Marshal(t *testing.T) { 2834 testJSONMarshal(t, &PublicEvent{}, "{}") 2835 2836 u := &PublicEvent{ 2837 Repo: &Repository{ 2838 ID: Int64(1), 2839 URL: String("s"), 2840 Name: String("n"), 2841 }, 2842 Sender: &User{ 2843 Login: String("l"), 2844 ID: Int64(1), 2845 NodeID: String("n"), 2846 URL: String("u"), 2847 ReposURL: String("r"), 2848 EventsURL: String("e"), 2849 AvatarURL: String("a"), 2850 }, 2851 Installation: &Installation{ 2852 ID: Int64(1), 2853 NodeID: String("nid"), 2854 AppID: Int64(1), 2855 AppSlug: String("as"), 2856 TargetID: Int64(1), 2857 Account: &User{ 2858 Login: String("l"), 2859 ID: Int64(1), 2860 URL: String("u"), 2861 AvatarURL: String("a"), 2862 GravatarID: String("g"), 2863 Name: String("n"), 2864 Company: String("c"), 2865 Blog: String("b"), 2866 Location: String("l"), 2867 Email: String("e"), 2868 Hireable: Bool(true), 2869 Bio: String("b"), 2870 TwitterUsername: String("t"), 2871 PublicRepos: Int(1), 2872 Followers: Int(1), 2873 Following: Int(1), 2874 CreatedAt: &Timestamp{referenceTime}, 2875 SuspendedAt: &Timestamp{referenceTime}, 2876 }, 2877 AccessTokensURL: String("atu"), 2878 RepositoriesURL: String("ru"), 2879 HTMLURL: String("hu"), 2880 TargetType: String("tt"), 2881 SingleFileName: String("sfn"), 2882 RepositorySelection: String("rs"), 2883 Events: []string{"e"}, 2884 SingleFilePaths: []string{"s"}, 2885 Permissions: &InstallationPermissions{ 2886 Actions: String("a"), 2887 Administration: String("ad"), 2888 Checks: String("c"), 2889 Contents: String("co"), 2890 ContentReferences: String("cr"), 2891 Deployments: String("d"), 2892 Environments: String("e"), 2893 Issues: String("i"), 2894 Metadata: String("md"), 2895 Members: String("m"), 2896 OrganizationAdministration: String("oa"), 2897 OrganizationHooks: String("oh"), 2898 OrganizationPlan: String("op"), 2899 OrganizationPreReceiveHooks: String("opr"), 2900 OrganizationProjects: String("op"), 2901 OrganizationSecrets: String("os"), 2902 OrganizationSelfHostedRunners: String("osh"), 2903 OrganizationUserBlocking: String("oub"), 2904 Packages: String("pkg"), 2905 Pages: String("pg"), 2906 PullRequests: String("pr"), 2907 RepositoryHooks: String("rh"), 2908 RepositoryProjects: String("rp"), 2909 RepositoryPreReceiveHooks: String("rprh"), 2910 Secrets: String("s"), 2911 SecretScanningAlerts: String("ssa"), 2912 SecurityEvents: String("se"), 2913 SingleFile: String("sf"), 2914 Statuses: String("s"), 2915 TeamDiscussions: String("td"), 2916 VulnerabilityAlerts: String("va"), 2917 Workflows: String("w"), 2918 }, 2919 CreatedAt: &Timestamp{referenceTime}, 2920 UpdatedAt: &Timestamp{referenceTime}, 2921 HasMultipleSingleFiles: Bool(false), 2922 SuspendedBy: &User{ 2923 Login: String("l"), 2924 ID: Int64(1), 2925 URL: String("u"), 2926 AvatarURL: String("a"), 2927 GravatarID: String("g"), 2928 Name: String("n"), 2929 Company: String("c"), 2930 Blog: String("b"), 2931 Location: String("l"), 2932 Email: String("e"), 2933 Hireable: Bool(true), 2934 Bio: String("b"), 2935 TwitterUsername: String("t"), 2936 PublicRepos: Int(1), 2937 Followers: Int(1), 2938 Following: Int(1), 2939 CreatedAt: &Timestamp{referenceTime}, 2940 SuspendedAt: &Timestamp{referenceTime}, 2941 }, 2942 SuspendedAt: &Timestamp{referenceTime}, 2943 }, 2944 } 2945 2946 want := `{ 2947 "repository": { 2948 "id": 1, 2949 "name": "n", 2950 "url": "s" 2951 }, 2952 "sender": { 2953 "login": "l", 2954 "id": 1, 2955 "node_id": "n", 2956 "avatar_url": "a", 2957 "url": "u", 2958 "events_url": "e", 2959 "repos_url": "r" 2960 }, 2961 "installation": { 2962 "id": 1, 2963 "node_id": "nid", 2964 "app_id": 1, 2965 "app_slug": "as", 2966 "target_id": 1, 2967 "account": { 2968 "login": "l", 2969 "id": 1, 2970 "avatar_url": "a", 2971 "gravatar_id": "g", 2972 "name": "n", 2973 "company": "c", 2974 "blog": "b", 2975 "location": "l", 2976 "email": "e", 2977 "hireable": true, 2978 "bio": "b", 2979 "twitter_username": "t", 2980 "public_repos": 1, 2981 "followers": 1, 2982 "following": 1, 2983 "created_at": ` + referenceTimeStr + `, 2984 "suspended_at": ` + referenceTimeStr + `, 2985 "url": "u" 2986 }, 2987 "access_tokens_url": "atu", 2988 "repositories_url": "ru", 2989 "html_url": "hu", 2990 "target_type": "tt", 2991 "single_file_name": "sfn", 2992 "repository_selection": "rs", 2993 "events": [ 2994 "e" 2995 ], 2996 "single_file_paths": [ 2997 "s" 2998 ], 2999 "permissions": { 3000 "actions": "a", 3001 "administration": "ad", 3002 "checks": "c", 3003 "contents": "co", 3004 "content_references": "cr", 3005 "deployments": "d", 3006 "environments": "e", 3007 "issues": "i", 3008 "metadata": "md", 3009 "members": "m", 3010 "organization_administration": "oa", 3011 "organization_hooks": "oh", 3012 "organization_plan": "op", 3013 "organization_pre_receive_hooks": "opr", 3014 "organization_projects": "op", 3015 "organization_secrets": "os", 3016 "organization_self_hosted_runners": "osh", 3017 "organization_user_blocking": "oub", 3018 "packages": "pkg", 3019 "pages": "pg", 3020 "pull_requests": "pr", 3021 "repository_hooks": "rh", 3022 "repository_projects": "rp", 3023 "repository_pre_receive_hooks": "rprh", 3024 "secrets": "s", 3025 "secret_scanning_alerts": "ssa", 3026 "security_events": "se", 3027 "single_file": "sf", 3028 "statuses": "s", 3029 "team_discussions": "td", 3030 "vulnerability_alerts": "va", 3031 "workflows": "w" 3032 }, 3033 "created_at": ` + referenceTimeStr + `, 3034 "updated_at": ` + referenceTimeStr + `, 3035 "has_multiple_single_files": false, 3036 "suspended_by": { 3037 "login": "l", 3038 "id": 1, 3039 "avatar_url": "a", 3040 "gravatar_id": "g", 3041 "name": "n", 3042 "company": "c", 3043 "blog": "b", 3044 "location": "l", 3045 "email": "e", 3046 "hireable": true, 3047 "bio": "b", 3048 "twitter_username": "t", 3049 "public_repos": 1, 3050 "followers": 1, 3051 "following": 1, 3052 "created_at": ` + referenceTimeStr + `, 3053 "suspended_at": ` + referenceTimeStr + `, 3054 "url": "u" 3055 }, 3056 "suspended_at": ` + referenceTimeStr + ` 3057 } 3058 }` 3059 3060 testJSONMarshal(t, u, want) 3061 } 3062 3063 func TestPullRequestReviewEvent_Marshal(t *testing.T) { 3064 testJSONMarshal(t, &PullRequestReviewEvent{}, "{}") 3065 3066 u := &PullRequestReviewEvent{ 3067 Action: String("a"), 3068 Review: &PullRequestReview{ID: Int64(1)}, 3069 PullRequest: &PullRequest{ID: Int64(1)}, 3070 Repo: &Repository{ 3071 ID: Int64(1), 3072 URL: String("s"), 3073 Name: String("n"), 3074 }, 3075 Sender: &User{ 3076 Login: String("l"), 3077 ID: Int64(1), 3078 NodeID: String("n"), 3079 URL: String("u"), 3080 ReposURL: String("r"), 3081 EventsURL: String("e"), 3082 AvatarURL: String("a"), 3083 }, 3084 Installation: &Installation{ 3085 ID: Int64(1), 3086 NodeID: String("nid"), 3087 AppID: Int64(1), 3088 AppSlug: String("as"), 3089 TargetID: Int64(1), 3090 Account: &User{ 3091 Login: String("l"), 3092 ID: Int64(1), 3093 URL: String("u"), 3094 AvatarURL: String("a"), 3095 GravatarID: String("g"), 3096 Name: String("n"), 3097 Company: String("c"), 3098 Blog: String("b"), 3099 Location: String("l"), 3100 Email: String("e"), 3101 Hireable: Bool(true), 3102 Bio: String("b"), 3103 TwitterUsername: String("t"), 3104 PublicRepos: Int(1), 3105 Followers: Int(1), 3106 Following: Int(1), 3107 CreatedAt: &Timestamp{referenceTime}, 3108 SuspendedAt: &Timestamp{referenceTime}, 3109 }, 3110 AccessTokensURL: String("atu"), 3111 RepositoriesURL: String("ru"), 3112 HTMLURL: String("hu"), 3113 TargetType: String("tt"), 3114 SingleFileName: String("sfn"), 3115 RepositorySelection: String("rs"), 3116 Events: []string{"e"}, 3117 SingleFilePaths: []string{"s"}, 3118 Permissions: &InstallationPermissions{ 3119 Actions: String("a"), 3120 Administration: String("ad"), 3121 Checks: String("c"), 3122 Contents: String("co"), 3123 ContentReferences: String("cr"), 3124 Deployments: String("d"), 3125 Environments: String("e"), 3126 Issues: String("i"), 3127 Metadata: String("md"), 3128 Members: String("m"), 3129 OrganizationAdministration: String("oa"), 3130 OrganizationHooks: String("oh"), 3131 OrganizationPlan: String("op"), 3132 OrganizationPreReceiveHooks: String("opr"), 3133 OrganizationProjects: String("op"), 3134 OrganizationSecrets: String("os"), 3135 OrganizationSelfHostedRunners: String("osh"), 3136 OrganizationUserBlocking: String("oub"), 3137 Packages: String("pkg"), 3138 Pages: String("pg"), 3139 PullRequests: String("pr"), 3140 RepositoryHooks: String("rh"), 3141 RepositoryProjects: String("rp"), 3142 RepositoryPreReceiveHooks: String("rprh"), 3143 Secrets: String("s"), 3144 SecretScanningAlerts: String("ssa"), 3145 SecurityEvents: String("se"), 3146 SingleFile: String("sf"), 3147 Statuses: String("s"), 3148 TeamDiscussions: String("td"), 3149 VulnerabilityAlerts: String("va"), 3150 Workflows: String("w"), 3151 }, 3152 CreatedAt: &Timestamp{referenceTime}, 3153 UpdatedAt: &Timestamp{referenceTime}, 3154 HasMultipleSingleFiles: Bool(false), 3155 SuspendedBy: &User{ 3156 Login: String("l"), 3157 ID: Int64(1), 3158 URL: String("u"), 3159 AvatarURL: String("a"), 3160 GravatarID: String("g"), 3161 Name: String("n"), 3162 Company: String("c"), 3163 Blog: String("b"), 3164 Location: String("l"), 3165 Email: String("e"), 3166 Hireable: Bool(true), 3167 Bio: String("b"), 3168 TwitterUsername: String("t"), 3169 PublicRepos: Int(1), 3170 Followers: Int(1), 3171 Following: Int(1), 3172 CreatedAt: &Timestamp{referenceTime}, 3173 SuspendedAt: &Timestamp{referenceTime}, 3174 }, 3175 SuspendedAt: &Timestamp{referenceTime}, 3176 }, 3177 Organization: &Organization{ 3178 BillingEmail: String("be"), 3179 Blog: String("b"), 3180 Company: String("c"), 3181 Email: String("e"), 3182 TwitterUsername: String("tu"), 3183 Location: String("loc"), 3184 Name: String("n"), 3185 Description: String("d"), 3186 IsVerified: Bool(true), 3187 HasOrganizationProjects: Bool(true), 3188 HasRepositoryProjects: Bool(true), 3189 DefaultRepoPermission: String("drp"), 3190 MembersCanCreateRepos: Bool(true), 3191 MembersCanCreateInternalRepos: Bool(true), 3192 MembersCanCreatePrivateRepos: Bool(true), 3193 MembersCanCreatePublicRepos: Bool(false), 3194 MembersAllowedRepositoryCreationType: String("marct"), 3195 MembersCanCreatePages: Bool(true), 3196 MembersCanCreatePublicPages: Bool(false), 3197 MembersCanCreatePrivatePages: Bool(true), 3198 }, 3199 } 3200 3201 want := `{ 3202 "action": "a", 3203 "review": { 3204 "id": 1 3205 }, 3206 "pull_request": { 3207 "id": 1 3208 }, 3209 "repository": { 3210 "id": 1, 3211 "name": "n", 3212 "url": "s" 3213 }, 3214 "sender": { 3215 "login": "l", 3216 "id": 1, 3217 "node_id": "n", 3218 "avatar_url": "a", 3219 "url": "u", 3220 "events_url": "e", 3221 "repos_url": "r" 3222 }, 3223 "installation": { 3224 "id": 1, 3225 "node_id": "nid", 3226 "app_id": 1, 3227 "app_slug": "as", 3228 "target_id": 1, 3229 "account": { 3230 "login": "l", 3231 "id": 1, 3232 "avatar_url": "a", 3233 "gravatar_id": "g", 3234 "name": "n", 3235 "company": "c", 3236 "blog": "b", 3237 "location": "l", 3238 "email": "e", 3239 "hireable": true, 3240 "bio": "b", 3241 "twitter_username": "t", 3242 "public_repos": 1, 3243 "followers": 1, 3244 "following": 1, 3245 "created_at": ` + referenceTimeStr + `, 3246 "suspended_at": ` + referenceTimeStr + `, 3247 "url": "u" 3248 }, 3249 "access_tokens_url": "atu", 3250 "repositories_url": "ru", 3251 "html_url": "hu", 3252 "target_type": "tt", 3253 "single_file_name": "sfn", 3254 "repository_selection": "rs", 3255 "events": [ 3256 "e" 3257 ], 3258 "single_file_paths": [ 3259 "s" 3260 ], 3261 "permissions": { 3262 "actions": "a", 3263 "administration": "ad", 3264 "checks": "c", 3265 "contents": "co", 3266 "content_references": "cr", 3267 "deployments": "d", 3268 "environments": "e", 3269 "issues": "i", 3270 "metadata": "md", 3271 "members": "m", 3272 "organization_administration": "oa", 3273 "organization_hooks": "oh", 3274 "organization_plan": "op", 3275 "organization_pre_receive_hooks": "opr", 3276 "organization_projects": "op", 3277 "organization_secrets": "os", 3278 "organization_self_hosted_runners": "osh", 3279 "organization_user_blocking": "oub", 3280 "packages": "pkg", 3281 "pages": "pg", 3282 "pull_requests": "pr", 3283 "repository_hooks": "rh", 3284 "repository_projects": "rp", 3285 "repository_pre_receive_hooks": "rprh", 3286 "secrets": "s", 3287 "secret_scanning_alerts": "ssa", 3288 "security_events": "se", 3289 "single_file": "sf", 3290 "statuses": "s", 3291 "team_discussions": "td", 3292 "vulnerability_alerts": "va", 3293 "workflows": "w" 3294 }, 3295 "created_at": ` + referenceTimeStr + `, 3296 "updated_at": ` + referenceTimeStr + `, 3297 "has_multiple_single_files": false, 3298 "suspended_by": { 3299 "login": "l", 3300 "id": 1, 3301 "avatar_url": "a", 3302 "gravatar_id": "g", 3303 "name": "n", 3304 "company": "c", 3305 "blog": "b", 3306 "location": "l", 3307 "email": "e", 3308 "hireable": true, 3309 "bio": "b", 3310 "twitter_username": "t", 3311 "public_repos": 1, 3312 "followers": 1, 3313 "following": 1, 3314 "created_at": ` + referenceTimeStr + `, 3315 "suspended_at": ` + referenceTimeStr + `, 3316 "url": "u" 3317 }, 3318 "suspended_at": ` + referenceTimeStr + ` 3319 }, 3320 "organization": { 3321 "name": "n", 3322 "company": "c", 3323 "blog": "b", 3324 "location": "loc", 3325 "email": "e", 3326 "twitter_username": "tu", 3327 "description": "d", 3328 "billing_email": "be", 3329 "is_verified": true, 3330 "has_organization_projects": true, 3331 "has_repository_projects": true, 3332 "default_repository_permission": "drp", 3333 "members_can_create_repositories": true, 3334 "members_can_create_public_repositories": false, 3335 "members_can_create_private_repositories": true, 3336 "members_can_create_internal_repositories": true, 3337 "members_allowed_repository_creation_type": "marct", 3338 "members_can_create_pages": true, 3339 "members_can_create_public_pages": false, 3340 "members_can_create_private_pages": true 3341 } 3342 }` 3343 3344 testJSONMarshal(t, u, want) 3345 } 3346 3347 func TestPushEvent_Marshal(t *testing.T) { 3348 testJSONMarshal(t, &PushEvent{}, "{}") 3349 3350 u := &PushEvent{ 3351 PushID: Int64(1), 3352 Head: String("h"), 3353 Ref: String("ref"), 3354 Size: Int(1), 3355 Commits: []*HeadCommit{ 3356 {ID: String("id")}, 3357 }, 3358 Before: String("b"), 3359 DistinctSize: Int(1), 3360 After: String("a"), 3361 Created: Bool(true), 3362 Deleted: Bool(true), 3363 Forced: Bool(true), 3364 BaseRef: String("a"), 3365 Compare: String("a"), 3366 Repo: &PushEventRepository{ID: Int64(1)}, 3367 HeadCommit: &HeadCommit{ID: String("id")}, 3368 Pusher: &User{ 3369 Login: String("l"), 3370 ID: Int64(1), 3371 NodeID: String("n"), 3372 URL: String("u"), 3373 ReposURL: String("r"), 3374 EventsURL: String("e"), 3375 AvatarURL: String("a"), 3376 }, 3377 Sender: &User{ 3378 Login: String("l"), 3379 ID: Int64(1), 3380 NodeID: String("n"), 3381 URL: String("u"), 3382 ReposURL: String("r"), 3383 EventsURL: String("e"), 3384 AvatarURL: String("a"), 3385 }, 3386 Installation: &Installation{ 3387 ID: Int64(1), 3388 NodeID: String("nid"), 3389 AppID: Int64(1), 3390 AppSlug: String("as"), 3391 TargetID: Int64(1), 3392 Account: &User{ 3393 Login: String("l"), 3394 ID: Int64(1), 3395 URL: String("u"), 3396 AvatarURL: String("a"), 3397 GravatarID: String("g"), 3398 Name: String("n"), 3399 Company: String("c"), 3400 Blog: String("b"), 3401 Location: String("l"), 3402 Email: String("e"), 3403 Hireable: Bool(true), 3404 Bio: String("b"), 3405 TwitterUsername: String("t"), 3406 PublicRepos: Int(1), 3407 Followers: Int(1), 3408 Following: Int(1), 3409 CreatedAt: &Timestamp{referenceTime}, 3410 SuspendedAt: &Timestamp{referenceTime}, 3411 }, 3412 AccessTokensURL: String("atu"), 3413 RepositoriesURL: String("ru"), 3414 HTMLURL: String("hu"), 3415 TargetType: String("tt"), 3416 SingleFileName: String("sfn"), 3417 RepositorySelection: String("rs"), 3418 Events: []string{"e"}, 3419 SingleFilePaths: []string{"s"}, 3420 Permissions: &InstallationPermissions{ 3421 Actions: String("a"), 3422 Administration: String("ad"), 3423 Checks: String("c"), 3424 Contents: String("co"), 3425 ContentReferences: String("cr"), 3426 Deployments: String("d"), 3427 Environments: String("e"), 3428 Issues: String("i"), 3429 Metadata: String("md"), 3430 Members: String("m"), 3431 OrganizationAdministration: String("oa"), 3432 OrganizationHooks: String("oh"), 3433 OrganizationPlan: String("op"), 3434 OrganizationPreReceiveHooks: String("opr"), 3435 OrganizationProjects: String("op"), 3436 OrganizationSecrets: String("os"), 3437 OrganizationSelfHostedRunners: String("osh"), 3438 OrganizationUserBlocking: String("oub"), 3439 Packages: String("pkg"), 3440 Pages: String("pg"), 3441 PullRequests: String("pr"), 3442 RepositoryHooks: String("rh"), 3443 RepositoryProjects: String("rp"), 3444 RepositoryPreReceiveHooks: String("rprh"), 3445 Secrets: String("s"), 3446 SecretScanningAlerts: String("ssa"), 3447 SecurityEvents: String("se"), 3448 SingleFile: String("sf"), 3449 Statuses: String("s"), 3450 TeamDiscussions: String("td"), 3451 VulnerabilityAlerts: String("va"), 3452 Workflows: String("w"), 3453 }, 3454 CreatedAt: &Timestamp{referenceTime}, 3455 UpdatedAt: &Timestamp{referenceTime}, 3456 HasMultipleSingleFiles: Bool(false), 3457 SuspendedBy: &User{ 3458 Login: String("l"), 3459 ID: Int64(1), 3460 URL: String("u"), 3461 AvatarURL: String("a"), 3462 GravatarID: String("g"), 3463 Name: String("n"), 3464 Company: String("c"), 3465 Blog: String("b"), 3466 Location: String("l"), 3467 Email: String("e"), 3468 Hireable: Bool(true), 3469 Bio: String("b"), 3470 TwitterUsername: String("t"), 3471 PublicRepos: Int(1), 3472 Followers: Int(1), 3473 Following: Int(1), 3474 CreatedAt: &Timestamp{referenceTime}, 3475 SuspendedAt: &Timestamp{referenceTime}, 3476 }, 3477 SuspendedAt: &Timestamp{referenceTime}, 3478 }, 3479 Organization: &Organization{ 3480 BillingEmail: String("be"), 3481 Blog: String("b"), 3482 Company: String("c"), 3483 Email: String("e"), 3484 TwitterUsername: String("tu"), 3485 Location: String("loc"), 3486 Name: String("n"), 3487 Description: String("d"), 3488 IsVerified: Bool(true), 3489 HasOrganizationProjects: Bool(true), 3490 HasRepositoryProjects: Bool(true), 3491 DefaultRepoPermission: String("drp"), 3492 MembersCanCreateRepos: Bool(true), 3493 MembersCanCreateInternalRepos: Bool(true), 3494 MembersCanCreatePrivateRepos: Bool(true), 3495 MembersCanCreatePublicRepos: Bool(false), 3496 MembersAllowedRepositoryCreationType: String("marct"), 3497 MembersCanCreatePages: Bool(true), 3498 MembersCanCreatePublicPages: Bool(false), 3499 MembersCanCreatePrivatePages: Bool(true), 3500 }, 3501 } 3502 3503 want := `{ 3504 "push_id": 1, 3505 "head": "h", 3506 "ref": "ref", 3507 "size": 1, 3508 "commits": [ 3509 { 3510 "id": "id" 3511 } 3512 ], 3513 "before": "b", 3514 "distinct_size": 1, 3515 "after": "a", 3516 "created": true, 3517 "deleted": true, 3518 "forced": true, 3519 "base_ref": "a", 3520 "compare": "a", 3521 "repository": { 3522 "id": 1 3523 }, 3524 "head_commit": { 3525 "id": "id" 3526 }, 3527 "pusher": { 3528 "login": "l", 3529 "id": 1, 3530 "node_id": "n", 3531 "avatar_url": "a", 3532 "url": "u", 3533 "events_url": "e", 3534 "repos_url": "r" 3535 }, 3536 "sender": { 3537 "login": "l", 3538 "id": 1, 3539 "node_id": "n", 3540 "avatar_url": "a", 3541 "url": "u", 3542 "events_url": "e", 3543 "repos_url": "r" 3544 }, 3545 "installation": { 3546 "id": 1, 3547 "node_id": "nid", 3548 "app_id": 1, 3549 "app_slug": "as", 3550 "target_id": 1, 3551 "account": { 3552 "login": "l", 3553 "id": 1, 3554 "avatar_url": "a", 3555 "gravatar_id": "g", 3556 "name": "n", 3557 "company": "c", 3558 "blog": "b", 3559 "location": "l", 3560 "email": "e", 3561 "hireable": true, 3562 "bio": "b", 3563 "twitter_username": "t", 3564 "public_repos": 1, 3565 "followers": 1, 3566 "following": 1, 3567 "created_at": ` + referenceTimeStr + `, 3568 "suspended_at": ` + referenceTimeStr + `, 3569 "url": "u" 3570 }, 3571 "access_tokens_url": "atu", 3572 "repositories_url": "ru", 3573 "html_url": "hu", 3574 "target_type": "tt", 3575 "single_file_name": "sfn", 3576 "repository_selection": "rs", 3577 "events": [ 3578 "e" 3579 ], 3580 "single_file_paths": [ 3581 "s" 3582 ], 3583 "permissions": { 3584 "actions": "a", 3585 "administration": "ad", 3586 "checks": "c", 3587 "contents": "co", 3588 "content_references": "cr", 3589 "deployments": "d", 3590 "environments": "e", 3591 "issues": "i", 3592 "metadata": "md", 3593 "members": "m", 3594 "organization_administration": "oa", 3595 "organization_hooks": "oh", 3596 "organization_plan": "op", 3597 "organization_pre_receive_hooks": "opr", 3598 "organization_projects": "op", 3599 "organization_secrets": "os", 3600 "organization_self_hosted_runners": "osh", 3601 "organization_user_blocking": "oub", 3602 "packages": "pkg", 3603 "pages": "pg", 3604 "pull_requests": "pr", 3605 "repository_hooks": "rh", 3606 "repository_projects": "rp", 3607 "repository_pre_receive_hooks": "rprh", 3608 "secrets": "s", 3609 "secret_scanning_alerts": "ssa", 3610 "security_events": "se", 3611 "single_file": "sf", 3612 "statuses": "s", 3613 "team_discussions": "td", 3614 "vulnerability_alerts": "va", 3615 "workflows": "w" 3616 }, 3617 "created_at": ` + referenceTimeStr + `, 3618 "updated_at": ` + referenceTimeStr + `, 3619 "has_multiple_single_files": false, 3620 "suspended_by": { 3621 "login": "l", 3622 "id": 1, 3623 "avatar_url": "a", 3624 "gravatar_id": "g", 3625 "name": "n", 3626 "company": "c", 3627 "blog": "b", 3628 "location": "l", 3629 "email": "e", 3630 "hireable": true, 3631 "bio": "b", 3632 "twitter_username": "t", 3633 "public_repos": 1, 3634 "followers": 1, 3635 "following": 1, 3636 "created_at": ` + referenceTimeStr + `, 3637 "suspended_at": ` + referenceTimeStr + `, 3638 "url": "u" 3639 }, 3640 "suspended_at": ` + referenceTimeStr + ` 3641 }, 3642 "organization": { 3643 "name": "n", 3644 "company": "c", 3645 "blog": "b", 3646 "location": "loc", 3647 "email": "e", 3648 "twitter_username": "tu", 3649 "description": "d", 3650 "billing_email": "be", 3651 "is_verified": true, 3652 "has_organization_projects": true, 3653 "has_repository_projects": true, 3654 "default_repository_permission": "drp", 3655 "members_can_create_repositories": true, 3656 "members_can_create_public_repositories": false, 3657 "members_can_create_private_repositories": true, 3658 "members_can_create_internal_repositories": true, 3659 "members_allowed_repository_creation_type": "marct", 3660 "members_can_create_pages": true, 3661 "members_can_create_public_pages": false, 3662 "members_can_create_private_pages": true 3663 } 3664 }` 3665 3666 testJSONMarshal(t, u, want) 3667 } 3668 3669 func TestStatusEvent_Marshal(t *testing.T) { 3670 testJSONMarshal(t, &StatusEvent{}, "{}") 3671 3672 u := &StatusEvent{ 3673 SHA: String("sha"), 3674 State: String("s"), 3675 Description: String("d"), 3676 TargetURL: String("turl"), 3677 Branches: []*Branch{ 3678 { 3679 Name: String("n"), 3680 Commit: &RepositoryCommit{NodeID: String("nid")}, 3681 Protected: Bool(false), 3682 }, 3683 }, 3684 ID: Int64(1), 3685 Name: String("n"), 3686 Context: String("c"), 3687 Commit: &RepositoryCommit{NodeID: String("nid")}, 3688 CreatedAt: &Timestamp{referenceTime}, 3689 UpdatedAt: &Timestamp{referenceTime}, 3690 Sender: &User{ 3691 Login: String("l"), 3692 ID: Int64(1), 3693 NodeID: String("n"), 3694 URL: String("u"), 3695 ReposURL: String("r"), 3696 EventsURL: String("e"), 3697 AvatarURL: String("a"), 3698 }, 3699 Installation: &Installation{ 3700 ID: Int64(1), 3701 NodeID: String("nid"), 3702 AppID: Int64(1), 3703 AppSlug: String("as"), 3704 TargetID: Int64(1), 3705 Account: &User{ 3706 Login: String("l"), 3707 ID: Int64(1), 3708 URL: String("u"), 3709 AvatarURL: String("a"), 3710 GravatarID: String("g"), 3711 Name: String("n"), 3712 Company: String("c"), 3713 Blog: String("b"), 3714 Location: String("l"), 3715 Email: String("e"), 3716 Hireable: Bool(true), 3717 Bio: String("b"), 3718 TwitterUsername: String("t"), 3719 PublicRepos: Int(1), 3720 Followers: Int(1), 3721 Following: Int(1), 3722 CreatedAt: &Timestamp{referenceTime}, 3723 SuspendedAt: &Timestamp{referenceTime}, 3724 }, 3725 AccessTokensURL: String("atu"), 3726 RepositoriesURL: String("ru"), 3727 HTMLURL: String("hu"), 3728 TargetType: String("tt"), 3729 SingleFileName: String("sfn"), 3730 RepositorySelection: String("rs"), 3731 Events: []string{"e"}, 3732 SingleFilePaths: []string{"s"}, 3733 Permissions: &InstallationPermissions{ 3734 Actions: String("a"), 3735 Administration: String("ad"), 3736 Checks: String("c"), 3737 Contents: String("co"), 3738 ContentReferences: String("cr"), 3739 Deployments: String("d"), 3740 Environments: String("e"), 3741 Issues: String("i"), 3742 Metadata: String("md"), 3743 Members: String("m"), 3744 OrganizationAdministration: String("oa"), 3745 OrganizationHooks: String("oh"), 3746 OrganizationPlan: String("op"), 3747 OrganizationPreReceiveHooks: String("opr"), 3748 OrganizationProjects: String("op"), 3749 OrganizationSecrets: String("os"), 3750 OrganizationSelfHostedRunners: String("osh"), 3751 OrganizationUserBlocking: String("oub"), 3752 Packages: String("pkg"), 3753 Pages: String("pg"), 3754 PullRequests: String("pr"), 3755 RepositoryHooks: String("rh"), 3756 RepositoryProjects: String("rp"), 3757 RepositoryPreReceiveHooks: String("rprh"), 3758 Secrets: String("s"), 3759 SecretScanningAlerts: String("ssa"), 3760 SecurityEvents: String("se"), 3761 SingleFile: String("sf"), 3762 Statuses: String("s"), 3763 TeamDiscussions: String("td"), 3764 VulnerabilityAlerts: String("va"), 3765 Workflows: String("w"), 3766 }, 3767 CreatedAt: &Timestamp{referenceTime}, 3768 UpdatedAt: &Timestamp{referenceTime}, 3769 HasMultipleSingleFiles: Bool(false), 3770 SuspendedBy: &User{ 3771 Login: String("l"), 3772 ID: Int64(1), 3773 URL: String("u"), 3774 AvatarURL: String("a"), 3775 GravatarID: String("g"), 3776 Name: String("n"), 3777 Company: String("c"), 3778 Blog: String("b"), 3779 Location: String("l"), 3780 Email: String("e"), 3781 Hireable: Bool(true), 3782 Bio: String("b"), 3783 TwitterUsername: String("t"), 3784 PublicRepos: Int(1), 3785 Followers: Int(1), 3786 Following: Int(1), 3787 CreatedAt: &Timestamp{referenceTime}, 3788 SuspendedAt: &Timestamp{referenceTime}, 3789 }, 3790 SuspendedAt: &Timestamp{referenceTime}, 3791 }, 3792 } 3793 3794 want := `{ 3795 "sha": "sha", 3796 "state": "s", 3797 "description": "d", 3798 "target_url": "turl", 3799 "branches": [ 3800 { 3801 "name": "n", 3802 "commit": { 3803 "node_id": "nid" 3804 }, 3805 "protected": false 3806 } 3807 ], 3808 "id": 1, 3809 "name": "n", 3810 "context": "c", 3811 "commit": { 3812 "node_id": "nid" 3813 }, 3814 "created_at": ` + referenceTimeStr + `, 3815 "updated_at": ` + referenceTimeStr + `, 3816 "sender": { 3817 "login": "l", 3818 "id": 1, 3819 "node_id": "n", 3820 "avatar_url": "a", 3821 "url": "u", 3822 "events_url": "e", 3823 "repos_url": "r" 3824 }, 3825 "installation": { 3826 "id": 1, 3827 "node_id": "nid", 3828 "app_id": 1, 3829 "app_slug": "as", 3830 "target_id": 1, 3831 "account": { 3832 "login": "l", 3833 "id": 1, 3834 "avatar_url": "a", 3835 "gravatar_id": "g", 3836 "name": "n", 3837 "company": "c", 3838 "blog": "b", 3839 "location": "l", 3840 "email": "e", 3841 "hireable": true, 3842 "bio": "b", 3843 "twitter_username": "t", 3844 "public_repos": 1, 3845 "followers": 1, 3846 "following": 1, 3847 "created_at": ` + referenceTimeStr + `, 3848 "suspended_at": ` + referenceTimeStr + `, 3849 "url": "u" 3850 }, 3851 "access_tokens_url": "atu", 3852 "repositories_url": "ru", 3853 "html_url": "hu", 3854 "target_type": "tt", 3855 "single_file_name": "sfn", 3856 "repository_selection": "rs", 3857 "events": [ 3858 "e" 3859 ], 3860 "single_file_paths": [ 3861 "s" 3862 ], 3863 "permissions": { 3864 "actions": "a", 3865 "administration": "ad", 3866 "checks": "c", 3867 "contents": "co", 3868 "content_references": "cr", 3869 "deployments": "d", 3870 "environments": "e", 3871 "issues": "i", 3872 "metadata": "md", 3873 "members": "m", 3874 "organization_administration": "oa", 3875 "organization_hooks": "oh", 3876 "organization_plan": "op", 3877 "organization_pre_receive_hooks": "opr", 3878 "organization_projects": "op", 3879 "organization_secrets": "os", 3880 "organization_self_hosted_runners": "osh", 3881 "organization_user_blocking": "oub", 3882 "packages": "pkg", 3883 "pages": "pg", 3884 "pull_requests": "pr", 3885 "repository_hooks": "rh", 3886 "repository_projects": "rp", 3887 "repository_pre_receive_hooks": "rprh", 3888 "secrets": "s", 3889 "secret_scanning_alerts": "ssa", 3890 "security_events": "se", 3891 "single_file": "sf", 3892 "statuses": "s", 3893 "team_discussions": "td", 3894 "vulnerability_alerts": "va", 3895 "workflows": "w" 3896 }, 3897 "created_at": ` + referenceTimeStr + `, 3898 "updated_at": ` + referenceTimeStr + `, 3899 "has_multiple_single_files": false, 3900 "suspended_by": { 3901 "login": "l", 3902 "id": 1, 3903 "avatar_url": "a", 3904 "gravatar_id": "g", 3905 "name": "n", 3906 "company": "c", 3907 "blog": "b", 3908 "location": "l", 3909 "email": "e", 3910 "hireable": true, 3911 "bio": "b", 3912 "twitter_username": "t", 3913 "public_repos": 1, 3914 "followers": 1, 3915 "following": 1, 3916 "created_at": ` + referenceTimeStr + `, 3917 "suspended_at": ` + referenceTimeStr + `, 3918 "url": "u" 3919 }, 3920 "suspended_at": ` + referenceTimeStr + ` 3921 } 3922 }` 3923 3924 testJSONMarshal(t, u, want) 3925 } 3926 3927 func TestMarketplacePurchaseEvent_Marshal(t *testing.T) { 3928 testJSONMarshal(t, &MarketplacePurchaseEvent{}, "{}") 3929 3930 u := &MarketplacePurchaseEvent{ 3931 Action: String("a"), 3932 EffectiveDate: &Timestamp{referenceTime}, 3933 MarketplacePurchase: &MarketplacePurchase{ 3934 BillingCycle: String("bc"), 3935 NextBillingDate: &Timestamp{referenceTime}, 3936 UnitCount: Int(1), 3937 Plan: &MarketplacePlan{ 3938 URL: String("u"), 3939 AccountsURL: String("au"), 3940 ID: Int64(1), 3941 Number: Int(1), 3942 Name: String("n"), 3943 Description: String("d"), 3944 MonthlyPriceInCents: Int(1), 3945 YearlyPriceInCents: Int(1), 3946 PriceModel: String("pm"), 3947 UnitName: String("un"), 3948 Bullets: &[]string{"b"}, 3949 State: String("s"), 3950 HasFreeTrial: Bool(false), 3951 }, 3952 OnFreeTrial: Bool(false), 3953 FreeTrialEndsOn: &Timestamp{referenceTime}, 3954 UpdatedAt: &Timestamp{referenceTime}, 3955 }, 3956 PreviousMarketplacePurchase: &MarketplacePurchase{ 3957 BillingCycle: String("bc"), 3958 NextBillingDate: &Timestamp{referenceTime}, 3959 UnitCount: Int(1), 3960 Plan: &MarketplacePlan{ 3961 URL: String("u"), 3962 AccountsURL: String("au"), 3963 ID: Int64(1), 3964 Number: Int(1), 3965 Name: String("n"), 3966 Description: String("d"), 3967 MonthlyPriceInCents: Int(1), 3968 YearlyPriceInCents: Int(1), 3969 PriceModel: String("pm"), 3970 UnitName: String("un"), 3971 Bullets: &[]string{"b"}, 3972 State: String("s"), 3973 HasFreeTrial: Bool(false), 3974 }, 3975 OnFreeTrial: Bool(false), 3976 FreeTrialEndsOn: &Timestamp{referenceTime}, 3977 UpdatedAt: &Timestamp{referenceTime}, 3978 }, 3979 Sender: &User{ 3980 Login: String("l"), 3981 ID: Int64(1), 3982 NodeID: String("n"), 3983 URL: String("u"), 3984 ReposURL: String("r"), 3985 EventsURL: String("e"), 3986 AvatarURL: String("a"), 3987 }, 3988 Installation: &Installation{ 3989 ID: Int64(1), 3990 NodeID: String("nid"), 3991 AppID: Int64(1), 3992 AppSlug: String("as"), 3993 TargetID: Int64(1), 3994 Account: &User{ 3995 Login: String("l"), 3996 ID: Int64(1), 3997 URL: String("u"), 3998 AvatarURL: String("a"), 3999 GravatarID: String("g"), 4000 Name: String("n"), 4001 Company: String("c"), 4002 Blog: String("b"), 4003 Location: String("l"), 4004 Email: String("e"), 4005 Hireable: Bool(true), 4006 Bio: String("b"), 4007 TwitterUsername: String("t"), 4008 PublicRepos: Int(1), 4009 Followers: Int(1), 4010 Following: Int(1), 4011 CreatedAt: &Timestamp{referenceTime}, 4012 SuspendedAt: &Timestamp{referenceTime}, 4013 }, 4014 AccessTokensURL: String("atu"), 4015 RepositoriesURL: String("ru"), 4016 HTMLURL: String("hu"), 4017 TargetType: String("tt"), 4018 SingleFileName: String("sfn"), 4019 RepositorySelection: String("rs"), 4020 Events: []string{"e"}, 4021 SingleFilePaths: []string{"s"}, 4022 Permissions: &InstallationPermissions{ 4023 Actions: String("a"), 4024 Administration: String("ad"), 4025 Checks: String("c"), 4026 Contents: String("co"), 4027 ContentReferences: String("cr"), 4028 Deployments: String("d"), 4029 Environments: String("e"), 4030 Issues: String("i"), 4031 Metadata: String("md"), 4032 Members: String("m"), 4033 OrganizationAdministration: String("oa"), 4034 OrganizationHooks: String("oh"), 4035 OrganizationPlan: String("op"), 4036 OrganizationPreReceiveHooks: String("opr"), 4037 OrganizationProjects: String("op"), 4038 OrganizationSecrets: String("os"), 4039 OrganizationSelfHostedRunners: String("osh"), 4040 OrganizationUserBlocking: String("oub"), 4041 Packages: String("pkg"), 4042 Pages: String("pg"), 4043 PullRequests: String("pr"), 4044 RepositoryHooks: String("rh"), 4045 RepositoryProjects: String("rp"), 4046 RepositoryPreReceiveHooks: String("rprh"), 4047 Secrets: String("s"), 4048 SecretScanningAlerts: String("ssa"), 4049 SecurityEvents: String("se"), 4050 SingleFile: String("sf"), 4051 Statuses: String("s"), 4052 TeamDiscussions: String("td"), 4053 VulnerabilityAlerts: String("va"), 4054 Workflows: String("w"), 4055 }, 4056 CreatedAt: &Timestamp{referenceTime}, 4057 UpdatedAt: &Timestamp{referenceTime}, 4058 HasMultipleSingleFiles: Bool(false), 4059 SuspendedBy: &User{ 4060 Login: String("l"), 4061 ID: Int64(1), 4062 URL: String("u"), 4063 AvatarURL: String("a"), 4064 GravatarID: String("g"), 4065 Name: String("n"), 4066 Company: String("c"), 4067 Blog: String("b"), 4068 Location: String("l"), 4069 Email: String("e"), 4070 Hireable: Bool(true), 4071 Bio: String("b"), 4072 TwitterUsername: String("t"), 4073 PublicRepos: Int(1), 4074 Followers: Int(1), 4075 Following: Int(1), 4076 CreatedAt: &Timestamp{referenceTime}, 4077 SuspendedAt: &Timestamp{referenceTime}, 4078 }, 4079 SuspendedAt: &Timestamp{referenceTime}, 4080 }, 4081 } 4082 4083 want := `{ 4084 "action": "a", 4085 "effective_date": ` + referenceTimeStr + `, 4086 "marketplace_purchase": { 4087 "billing_cycle": "bc", 4088 "next_billing_date": ` + referenceTimeStr + `, 4089 "unit_count": 1, 4090 "plan": { 4091 "url": "u", 4092 "accounts_url": "au", 4093 "id": 1, 4094 "number": 1, 4095 "name": "n", 4096 "description": "d", 4097 "monthly_price_in_cents": 1, 4098 "yearly_price_in_cents": 1, 4099 "price_model": "pm", 4100 "unit_name": "un", 4101 "bullets": [ 4102 "b" 4103 ], 4104 "state": "s", 4105 "has_free_trial": false 4106 }, 4107 "on_free_trial": false, 4108 "free_trial_ends_on": ` + referenceTimeStr + `, 4109 "updated_at": ` + referenceTimeStr + ` 4110 }, 4111 "previous_marketplace_purchase": { 4112 "billing_cycle": "bc", 4113 "next_billing_date": ` + referenceTimeStr + `, 4114 "unit_count": 1, 4115 "plan": { 4116 "url": "u", 4117 "accounts_url": "au", 4118 "id": 1, 4119 "number": 1, 4120 "name": "n", 4121 "description": "d", 4122 "monthly_price_in_cents": 1, 4123 "yearly_price_in_cents": 1, 4124 "price_model": "pm", 4125 "unit_name": "un", 4126 "bullets": [ 4127 "b" 4128 ], 4129 "state": "s", 4130 "has_free_trial": false 4131 }, 4132 "on_free_trial": false, 4133 "free_trial_ends_on": ` + referenceTimeStr + `, 4134 "updated_at": ` + referenceTimeStr + ` 4135 }, 4136 "sender": { 4137 "login": "l", 4138 "id": 1, 4139 "node_id": "n", 4140 "avatar_url": "a", 4141 "url": "u", 4142 "events_url": "e", 4143 "repos_url": "r" 4144 }, 4145 "installation": { 4146 "id": 1, 4147 "node_id": "nid", 4148 "app_id": 1, 4149 "app_slug": "as", 4150 "target_id": 1, 4151 "account": { 4152 "login": "l", 4153 "id": 1, 4154 "avatar_url": "a", 4155 "gravatar_id": "g", 4156 "name": "n", 4157 "company": "c", 4158 "blog": "b", 4159 "location": "l", 4160 "email": "e", 4161 "hireable": true, 4162 "bio": "b", 4163 "twitter_username": "t", 4164 "public_repos": 1, 4165 "followers": 1, 4166 "following": 1, 4167 "created_at": ` + referenceTimeStr + `, 4168 "suspended_at": ` + referenceTimeStr + `, 4169 "url": "u" 4170 }, 4171 "access_tokens_url": "atu", 4172 "repositories_url": "ru", 4173 "html_url": "hu", 4174 "target_type": "tt", 4175 "single_file_name": "sfn", 4176 "repository_selection": "rs", 4177 "events": [ 4178 "e" 4179 ], 4180 "single_file_paths": [ 4181 "s" 4182 ], 4183 "permissions": { 4184 "actions": "a", 4185 "administration": "ad", 4186 "checks": "c", 4187 "contents": "co", 4188 "content_references": "cr", 4189 "deployments": "d", 4190 "environments": "e", 4191 "issues": "i", 4192 "metadata": "md", 4193 "members": "m", 4194 "organization_administration": "oa", 4195 "organization_hooks": "oh", 4196 "organization_plan": "op", 4197 "organization_pre_receive_hooks": "opr", 4198 "organization_projects": "op", 4199 "organization_secrets": "os", 4200 "organization_self_hosted_runners": "osh", 4201 "organization_user_blocking": "oub", 4202 "packages": "pkg", 4203 "pages": "pg", 4204 "pull_requests": "pr", 4205 "repository_hooks": "rh", 4206 "repository_projects": "rp", 4207 "repository_pre_receive_hooks": "rprh", 4208 "secrets": "s", 4209 "secret_scanning_alerts": "ssa", 4210 "security_events": "se", 4211 "single_file": "sf", 4212 "statuses": "s", 4213 "team_discussions": "td", 4214 "vulnerability_alerts": "va", 4215 "workflows": "w" 4216 }, 4217 "created_at": ` + referenceTimeStr + `, 4218 "updated_at": ` + referenceTimeStr + `, 4219 "has_multiple_single_files": false, 4220 "suspended_by": { 4221 "login": "l", 4222 "id": 1, 4223 "avatar_url": "a", 4224 "gravatar_id": "g", 4225 "name": "n", 4226 "company": "c", 4227 "blog": "b", 4228 "location": "l", 4229 "email": "e", 4230 "hireable": true, 4231 "bio": "b", 4232 "twitter_username": "t", 4233 "public_repos": 1, 4234 "followers": 1, 4235 "following": 1, 4236 "created_at": ` + referenceTimeStr + `, 4237 "suspended_at": ` + referenceTimeStr + `, 4238 "url": "u" 4239 }, 4240 "suspended_at": ` + referenceTimeStr + ` 4241 } 4242 }` 4243 4244 testJSONMarshal(t, u, want) 4245 } 4246 4247 func TestOrganizationEvent_Marshal(t *testing.T) { 4248 testJSONMarshal(t, &OrganizationEvent{}, "{}") 4249 4250 u := &OrganizationEvent{ 4251 Action: String("a"), 4252 Invitation: &Invitation{ID: Int64(1)}, 4253 Membership: &Membership{ 4254 URL: String("url"), 4255 State: String("s"), 4256 Role: String("r"), 4257 OrganizationURL: String("ou"), 4258 Organization: &Organization{ 4259 BillingEmail: String("be"), 4260 Blog: String("b"), 4261 Company: String("c"), 4262 Email: String("e"), 4263 TwitterUsername: String("tu"), 4264 Location: String("loc"), 4265 Name: String("n"), 4266 Description: String("d"), 4267 IsVerified: Bool(true), 4268 HasOrganizationProjects: Bool(true), 4269 HasRepositoryProjects: Bool(true), 4270 DefaultRepoPermission: String("drp"), 4271 MembersCanCreateRepos: Bool(true), 4272 MembersCanCreateInternalRepos: Bool(true), 4273 MembersCanCreatePrivateRepos: Bool(true), 4274 MembersCanCreatePublicRepos: Bool(false), 4275 MembersAllowedRepositoryCreationType: String("marct"), 4276 MembersCanCreatePages: Bool(true), 4277 MembersCanCreatePublicPages: Bool(false), 4278 MembersCanCreatePrivatePages: Bool(true), 4279 }, 4280 User: &User{ 4281 Login: String("l"), 4282 ID: Int64(1), 4283 NodeID: String("n"), 4284 URL: String("u"), 4285 ReposURL: String("r"), 4286 EventsURL: String("e"), 4287 AvatarURL: String("a"), 4288 }, 4289 }, 4290 Organization: &Organization{ 4291 BillingEmail: String("be"), 4292 Blog: String("b"), 4293 Company: String("c"), 4294 Email: String("e"), 4295 TwitterUsername: String("tu"), 4296 Location: String("loc"), 4297 Name: String("n"), 4298 Description: String("d"), 4299 IsVerified: Bool(true), 4300 HasOrganizationProjects: Bool(true), 4301 HasRepositoryProjects: Bool(true), 4302 DefaultRepoPermission: String("drp"), 4303 MembersCanCreateRepos: Bool(true), 4304 MembersCanCreateInternalRepos: Bool(true), 4305 MembersCanCreatePrivateRepos: Bool(true), 4306 MembersCanCreatePublicRepos: Bool(false), 4307 MembersAllowedRepositoryCreationType: String("marct"), 4308 MembersCanCreatePages: Bool(true), 4309 MembersCanCreatePublicPages: Bool(false), 4310 MembersCanCreatePrivatePages: Bool(true), 4311 }, 4312 Sender: &User{ 4313 Login: String("l"), 4314 ID: Int64(1), 4315 NodeID: String("n"), 4316 URL: String("u"), 4317 ReposURL: String("r"), 4318 EventsURL: String("e"), 4319 AvatarURL: String("a"), 4320 }, 4321 Installation: &Installation{ 4322 ID: Int64(1), 4323 NodeID: String("nid"), 4324 AppID: Int64(1), 4325 AppSlug: String("as"), 4326 TargetID: Int64(1), 4327 Account: &User{ 4328 Login: String("l"), 4329 ID: Int64(1), 4330 URL: String("u"), 4331 AvatarURL: String("a"), 4332 GravatarID: String("g"), 4333 Name: String("n"), 4334 Company: String("c"), 4335 Blog: String("b"), 4336 Location: String("l"), 4337 Email: String("e"), 4338 Hireable: Bool(true), 4339 Bio: String("b"), 4340 TwitterUsername: String("t"), 4341 PublicRepos: Int(1), 4342 Followers: Int(1), 4343 Following: Int(1), 4344 CreatedAt: &Timestamp{referenceTime}, 4345 SuspendedAt: &Timestamp{referenceTime}, 4346 }, 4347 AccessTokensURL: String("atu"), 4348 RepositoriesURL: String("ru"), 4349 HTMLURL: String("hu"), 4350 TargetType: String("tt"), 4351 SingleFileName: String("sfn"), 4352 RepositorySelection: String("rs"), 4353 Events: []string{"e"}, 4354 SingleFilePaths: []string{"s"}, 4355 Permissions: &InstallationPermissions{ 4356 Actions: String("a"), 4357 Administration: String("ad"), 4358 Checks: String("c"), 4359 Contents: String("co"), 4360 ContentReferences: String("cr"), 4361 Deployments: String("d"), 4362 Environments: String("e"), 4363 Issues: String("i"), 4364 Metadata: String("md"), 4365 Members: String("m"), 4366 OrganizationAdministration: String("oa"), 4367 OrganizationHooks: String("oh"), 4368 OrganizationPlan: String("op"), 4369 OrganizationPreReceiveHooks: String("opr"), 4370 OrganizationProjects: String("op"), 4371 OrganizationSecrets: String("os"), 4372 OrganizationSelfHostedRunners: String("osh"), 4373 OrganizationUserBlocking: String("oub"), 4374 Packages: String("pkg"), 4375 Pages: String("pg"), 4376 PullRequests: String("pr"), 4377 RepositoryHooks: String("rh"), 4378 RepositoryProjects: String("rp"), 4379 RepositoryPreReceiveHooks: String("rprh"), 4380 Secrets: String("s"), 4381 SecretScanningAlerts: String("ssa"), 4382 SecurityEvents: String("se"), 4383 SingleFile: String("sf"), 4384 Statuses: String("s"), 4385 TeamDiscussions: String("td"), 4386 VulnerabilityAlerts: String("va"), 4387 Workflows: String("w"), 4388 }, 4389 CreatedAt: &Timestamp{referenceTime}, 4390 UpdatedAt: &Timestamp{referenceTime}, 4391 HasMultipleSingleFiles: Bool(false), 4392 SuspendedBy: &User{ 4393 Login: String("l"), 4394 ID: Int64(1), 4395 URL: String("u"), 4396 AvatarURL: String("a"), 4397 GravatarID: String("g"), 4398 Name: String("n"), 4399 Company: String("c"), 4400 Blog: String("b"), 4401 Location: String("l"), 4402 Email: String("e"), 4403 Hireable: Bool(true), 4404 Bio: String("b"), 4405 TwitterUsername: String("t"), 4406 PublicRepos: Int(1), 4407 Followers: Int(1), 4408 Following: Int(1), 4409 CreatedAt: &Timestamp{referenceTime}, 4410 SuspendedAt: &Timestamp{referenceTime}, 4411 }, 4412 SuspendedAt: &Timestamp{referenceTime}, 4413 }, 4414 } 4415 4416 want := `{ 4417 "action": "a", 4418 "invitation": { 4419 "id": 1 4420 }, 4421 "membership": { 4422 "url": "url", 4423 "state": "s", 4424 "role": "r", 4425 "organization_url": "ou", 4426 "organization": { 4427 "name": "n", 4428 "company": "c", 4429 "blog": "b", 4430 "location": "loc", 4431 "email": "e", 4432 "twitter_username": "tu", 4433 "description": "d", 4434 "billing_email": "be", 4435 "is_verified": true, 4436 "has_organization_projects": true, 4437 "has_repository_projects": true, 4438 "default_repository_permission": "drp", 4439 "members_can_create_repositories": true, 4440 "members_can_create_public_repositories": false, 4441 "members_can_create_private_repositories": true, 4442 "members_can_create_internal_repositories": true, 4443 "members_allowed_repository_creation_type": "marct", 4444 "members_can_create_pages": true, 4445 "members_can_create_public_pages": false, 4446 "members_can_create_private_pages": true 4447 }, 4448 "user": { 4449 "login": "l", 4450 "id": 1, 4451 "node_id": "n", 4452 "avatar_url": "a", 4453 "url": "u", 4454 "events_url": "e", 4455 "repos_url": "r" 4456 } 4457 }, 4458 "organization": { 4459 "name": "n", 4460 "company": "c", 4461 "blog": "b", 4462 "location": "loc", 4463 "email": "e", 4464 "twitter_username": "tu", 4465 "description": "d", 4466 "billing_email": "be", 4467 "is_verified": true, 4468 "has_organization_projects": true, 4469 "has_repository_projects": true, 4470 "default_repository_permission": "drp", 4471 "members_can_create_repositories": true, 4472 "members_can_create_public_repositories": false, 4473 "members_can_create_private_repositories": true, 4474 "members_can_create_internal_repositories": true, 4475 "members_allowed_repository_creation_type": "marct", 4476 "members_can_create_pages": true, 4477 "members_can_create_public_pages": false, 4478 "members_can_create_private_pages": true 4479 }, 4480 "sender": { 4481 "login": "l", 4482 "id": 1, 4483 "node_id": "n", 4484 "avatar_url": "a", 4485 "url": "u", 4486 "events_url": "e", 4487 "repos_url": "r" 4488 }, 4489 "installation": { 4490 "id": 1, 4491 "node_id": "nid", 4492 "app_id": 1, 4493 "app_slug": "as", 4494 "target_id": 1, 4495 "account": { 4496 "login": "l", 4497 "id": 1, 4498 "avatar_url": "a", 4499 "gravatar_id": "g", 4500 "name": "n", 4501 "company": "c", 4502 "blog": "b", 4503 "location": "l", 4504 "email": "e", 4505 "hireable": true, 4506 "bio": "b", 4507 "twitter_username": "t", 4508 "public_repos": 1, 4509 "followers": 1, 4510 "following": 1, 4511 "created_at": ` + referenceTimeStr + `, 4512 "suspended_at": ` + referenceTimeStr + `, 4513 "url": "u" 4514 }, 4515 "access_tokens_url": "atu", 4516 "repositories_url": "ru", 4517 "html_url": "hu", 4518 "target_type": "tt", 4519 "single_file_name": "sfn", 4520 "repository_selection": "rs", 4521 "events": [ 4522 "e" 4523 ], 4524 "single_file_paths": [ 4525 "s" 4526 ], 4527 "permissions": { 4528 "actions": "a", 4529 "administration": "ad", 4530 "checks": "c", 4531 "contents": "co", 4532 "content_references": "cr", 4533 "deployments": "d", 4534 "environments": "e", 4535 "issues": "i", 4536 "metadata": "md", 4537 "members": "m", 4538 "organization_administration": "oa", 4539 "organization_hooks": "oh", 4540 "organization_plan": "op", 4541 "organization_pre_receive_hooks": "opr", 4542 "organization_projects": "op", 4543 "organization_secrets": "os", 4544 "organization_self_hosted_runners": "osh", 4545 "organization_user_blocking": "oub", 4546 "packages": "pkg", 4547 "pages": "pg", 4548 "pull_requests": "pr", 4549 "repository_hooks": "rh", 4550 "repository_projects": "rp", 4551 "repository_pre_receive_hooks": "rprh", 4552 "secrets": "s", 4553 "secret_scanning_alerts": "ssa", 4554 "security_events": "se", 4555 "single_file": "sf", 4556 "statuses": "s", 4557 "team_discussions": "td", 4558 "vulnerability_alerts": "va", 4559 "workflows": "w" 4560 }, 4561 "created_at": ` + referenceTimeStr + `, 4562 "updated_at": ` + referenceTimeStr + `, 4563 "has_multiple_single_files": false, 4564 "suspended_by": { 4565 "login": "l", 4566 "id": 1, 4567 "avatar_url": "a", 4568 "gravatar_id": "g", 4569 "name": "n", 4570 "company": "c", 4571 "blog": "b", 4572 "location": "l", 4573 "email": "e", 4574 "hireable": true, 4575 "bio": "b", 4576 "twitter_username": "t", 4577 "public_repos": 1, 4578 "followers": 1, 4579 "following": 1, 4580 "created_at": ` + referenceTimeStr + `, 4581 "suspended_at": ` + referenceTimeStr + `, 4582 "url": "u" 4583 }, 4584 "suspended_at": ` + referenceTimeStr + ` 4585 } 4586 }` 4587 4588 testJSONMarshal(t, u, want) 4589 } 4590 4591 func TestPageBuildEvent_Marshal(t *testing.T) { 4592 testJSONMarshal(t, &PageBuildEvent{}, "{}") 4593 4594 u := &PageBuildEvent{ 4595 Build: &PagesBuild{URL: String("url")}, 4596 ID: Int64(1), 4597 Repo: &Repository{ 4598 ID: Int64(1), 4599 URL: String("s"), 4600 Name: String("n"), 4601 }, 4602 Sender: &User{ 4603 Login: String("l"), 4604 ID: Int64(1), 4605 NodeID: String("n"), 4606 URL: String("u"), 4607 ReposURL: String("r"), 4608 EventsURL: String("e"), 4609 AvatarURL: String("a"), 4610 }, 4611 Installation: &Installation{ 4612 ID: Int64(1), 4613 NodeID: String("nid"), 4614 AppID: Int64(1), 4615 AppSlug: String("as"), 4616 TargetID: Int64(1), 4617 Account: &User{ 4618 Login: String("l"), 4619 ID: Int64(1), 4620 URL: String("u"), 4621 AvatarURL: String("a"), 4622 GravatarID: String("g"), 4623 Name: String("n"), 4624 Company: String("c"), 4625 Blog: String("b"), 4626 Location: String("l"), 4627 Email: String("e"), 4628 Hireable: Bool(true), 4629 Bio: String("b"), 4630 TwitterUsername: String("t"), 4631 PublicRepos: Int(1), 4632 Followers: Int(1), 4633 Following: Int(1), 4634 CreatedAt: &Timestamp{referenceTime}, 4635 SuspendedAt: &Timestamp{referenceTime}, 4636 }, 4637 AccessTokensURL: String("atu"), 4638 RepositoriesURL: String("ru"), 4639 HTMLURL: String("hu"), 4640 TargetType: String("tt"), 4641 SingleFileName: String("sfn"), 4642 RepositorySelection: String("rs"), 4643 Events: []string{"e"}, 4644 SingleFilePaths: []string{"s"}, 4645 Permissions: &InstallationPermissions{ 4646 Actions: String("a"), 4647 Administration: String("ad"), 4648 Checks: String("c"), 4649 Contents: String("co"), 4650 ContentReferences: String("cr"), 4651 Deployments: String("d"), 4652 Environments: String("e"), 4653 Issues: String("i"), 4654 Metadata: String("md"), 4655 Members: String("m"), 4656 OrganizationAdministration: String("oa"), 4657 OrganizationHooks: String("oh"), 4658 OrganizationPlan: String("op"), 4659 OrganizationPreReceiveHooks: String("opr"), 4660 OrganizationProjects: String("op"), 4661 OrganizationSecrets: String("os"), 4662 OrganizationSelfHostedRunners: String("osh"), 4663 OrganizationUserBlocking: String("oub"), 4664 Packages: String("pkg"), 4665 Pages: String("pg"), 4666 PullRequests: String("pr"), 4667 RepositoryHooks: String("rh"), 4668 RepositoryProjects: String("rp"), 4669 RepositoryPreReceiveHooks: String("rprh"), 4670 Secrets: String("s"), 4671 SecretScanningAlerts: String("ssa"), 4672 SecurityEvents: String("se"), 4673 SingleFile: String("sf"), 4674 Statuses: String("s"), 4675 TeamDiscussions: String("td"), 4676 VulnerabilityAlerts: String("va"), 4677 Workflows: String("w"), 4678 }, 4679 CreatedAt: &Timestamp{referenceTime}, 4680 UpdatedAt: &Timestamp{referenceTime}, 4681 HasMultipleSingleFiles: Bool(false), 4682 SuspendedBy: &User{ 4683 Login: String("l"), 4684 ID: Int64(1), 4685 URL: String("u"), 4686 AvatarURL: String("a"), 4687 GravatarID: String("g"), 4688 Name: String("n"), 4689 Company: String("c"), 4690 Blog: String("b"), 4691 Location: String("l"), 4692 Email: String("e"), 4693 Hireable: Bool(true), 4694 Bio: String("b"), 4695 TwitterUsername: String("t"), 4696 PublicRepos: Int(1), 4697 Followers: Int(1), 4698 Following: Int(1), 4699 CreatedAt: &Timestamp{referenceTime}, 4700 SuspendedAt: &Timestamp{referenceTime}, 4701 }, 4702 SuspendedAt: &Timestamp{referenceTime}, 4703 }, 4704 } 4705 4706 want := `{ 4707 "build": { 4708 "url": "url" 4709 }, 4710 "id": 1, 4711 "repository": { 4712 "id": 1, 4713 "name": "n", 4714 "url": "s" 4715 }, 4716 "sender": { 4717 "login": "l", 4718 "id": 1, 4719 "node_id": "n", 4720 "avatar_url": "a", 4721 "url": "u", 4722 "events_url": "e", 4723 "repos_url": "r" 4724 }, 4725 "installation": { 4726 "id": 1, 4727 "node_id": "nid", 4728 "app_id": 1, 4729 "app_slug": "as", 4730 "target_id": 1, 4731 "account": { 4732 "login": "l", 4733 "id": 1, 4734 "avatar_url": "a", 4735 "gravatar_id": "g", 4736 "name": "n", 4737 "company": "c", 4738 "blog": "b", 4739 "location": "l", 4740 "email": "e", 4741 "hireable": true, 4742 "bio": "b", 4743 "twitter_username": "t", 4744 "public_repos": 1, 4745 "followers": 1, 4746 "following": 1, 4747 "created_at": ` + referenceTimeStr + `, 4748 "suspended_at": ` + referenceTimeStr + `, 4749 "url": "u" 4750 }, 4751 "access_tokens_url": "atu", 4752 "repositories_url": "ru", 4753 "html_url": "hu", 4754 "target_type": "tt", 4755 "single_file_name": "sfn", 4756 "repository_selection": "rs", 4757 "events": [ 4758 "e" 4759 ], 4760 "single_file_paths": [ 4761 "s" 4762 ], 4763 "permissions": { 4764 "actions": "a", 4765 "administration": "ad", 4766 "checks": "c", 4767 "contents": "co", 4768 "content_references": "cr", 4769 "deployments": "d", 4770 "environments": "e", 4771 "issues": "i", 4772 "metadata": "md", 4773 "members": "m", 4774 "organization_administration": "oa", 4775 "organization_hooks": "oh", 4776 "organization_plan": "op", 4777 "organization_pre_receive_hooks": "opr", 4778 "organization_projects": "op", 4779 "organization_secrets": "os", 4780 "organization_self_hosted_runners": "osh", 4781 "organization_user_blocking": "oub", 4782 "packages": "pkg", 4783 "pages": "pg", 4784 "pull_requests": "pr", 4785 "repository_hooks": "rh", 4786 "repository_projects": "rp", 4787 "repository_pre_receive_hooks": "rprh", 4788 "secrets": "s", 4789 "secret_scanning_alerts": "ssa", 4790 "security_events": "se", 4791 "single_file": "sf", 4792 "statuses": "s", 4793 "team_discussions": "td", 4794 "vulnerability_alerts": "va", 4795 "workflows": "w" 4796 }, 4797 "created_at": ` + referenceTimeStr + `, 4798 "updated_at": ` + referenceTimeStr + `, 4799 "has_multiple_single_files": false, 4800 "suspended_by": { 4801 "login": "l", 4802 "id": 1, 4803 "avatar_url": "a", 4804 "gravatar_id": "g", 4805 "name": "n", 4806 "company": "c", 4807 "blog": "b", 4808 "location": "l", 4809 "email": "e", 4810 "hireable": true, 4811 "bio": "b", 4812 "twitter_username": "t", 4813 "public_repos": 1, 4814 "followers": 1, 4815 "following": 1, 4816 "created_at": ` + referenceTimeStr + `, 4817 "suspended_at": ` + referenceTimeStr + `, 4818 "url": "u" 4819 }, 4820 "suspended_at": ` + referenceTimeStr + ` 4821 } 4822 }` 4823 4824 testJSONMarshal(t, u, want) 4825 } 4826 4827 func TestCommitCommentEvent_Marshal(t *testing.T) { 4828 testJSONMarshal(t, &CommitCommentEvent{}, "{}") 4829 4830 u := &CommitCommentEvent{ 4831 Comment: &RepositoryComment{ 4832 HTMLURL: String("hurl"), 4833 URL: String("url"), 4834 ID: Int64(1), 4835 NodeID: String("nid"), 4836 CommitID: String("cid"), 4837 User: &User{ 4838 Login: String("l"), 4839 ID: Int64(1), 4840 NodeID: String("n"), 4841 URL: String("u"), 4842 ReposURL: String("r"), 4843 EventsURL: String("e"), 4844 AvatarURL: String("a"), 4845 }, 4846 Reactions: &Reactions{ 4847 TotalCount: Int(1), 4848 PlusOne: Int(1), 4849 MinusOne: Int(1), 4850 Laugh: Int(1), 4851 Confused: Int(1), 4852 Heart: Int(1), 4853 Hooray: Int(1), 4854 Rocket: Int(1), 4855 Eyes: Int(1), 4856 URL: String("url"), 4857 }, 4858 CreatedAt: &referenceTime, 4859 UpdatedAt: &referenceTime, 4860 Body: String("b"), 4861 Path: String("path"), 4862 Position: Int(1), 4863 }, 4864 Action: String("a"), 4865 Repo: &Repository{ 4866 ID: Int64(1), 4867 URL: String("s"), 4868 Name: String("n"), 4869 }, 4870 Sender: &User{ 4871 Login: String("l"), 4872 ID: Int64(1), 4873 NodeID: String("n"), 4874 URL: String("u"), 4875 ReposURL: String("r"), 4876 EventsURL: String("e"), 4877 AvatarURL: String("a"), 4878 }, 4879 Installation: &Installation{ 4880 ID: Int64(1), 4881 NodeID: String("nid"), 4882 AppID: Int64(1), 4883 AppSlug: String("as"), 4884 TargetID: Int64(1), 4885 Account: &User{ 4886 Login: String("l"), 4887 ID: Int64(1), 4888 URL: String("u"), 4889 AvatarURL: String("a"), 4890 GravatarID: String("g"), 4891 Name: String("n"), 4892 Company: String("c"), 4893 Blog: String("b"), 4894 Location: String("l"), 4895 Email: String("e"), 4896 Hireable: Bool(true), 4897 Bio: String("b"), 4898 TwitterUsername: String("t"), 4899 PublicRepos: Int(1), 4900 Followers: Int(1), 4901 Following: Int(1), 4902 CreatedAt: &Timestamp{referenceTime}, 4903 SuspendedAt: &Timestamp{referenceTime}, 4904 }, 4905 AccessTokensURL: String("atu"), 4906 RepositoriesURL: String("ru"), 4907 HTMLURL: String("hu"), 4908 TargetType: String("tt"), 4909 SingleFileName: String("sfn"), 4910 RepositorySelection: String("rs"), 4911 Events: []string{"e"}, 4912 SingleFilePaths: []string{"s"}, 4913 Permissions: &InstallationPermissions{ 4914 Actions: String("a"), 4915 Administration: String("ad"), 4916 Checks: String("c"), 4917 Contents: String("co"), 4918 ContentReferences: String("cr"), 4919 Deployments: String("d"), 4920 Environments: String("e"), 4921 Issues: String("i"), 4922 Metadata: String("md"), 4923 Members: String("m"), 4924 OrganizationAdministration: String("oa"), 4925 OrganizationHooks: String("oh"), 4926 OrganizationPlan: String("op"), 4927 OrganizationPreReceiveHooks: String("opr"), 4928 OrganizationProjects: String("op"), 4929 OrganizationSecrets: String("os"), 4930 OrganizationSelfHostedRunners: String("osh"), 4931 OrganizationUserBlocking: String("oub"), 4932 Packages: String("pkg"), 4933 Pages: String("pg"), 4934 PullRequests: String("pr"), 4935 RepositoryHooks: String("rh"), 4936 RepositoryProjects: String("rp"), 4937 RepositoryPreReceiveHooks: String("rprh"), 4938 Secrets: String("s"), 4939 SecretScanningAlerts: String("ssa"), 4940 SecurityEvents: String("se"), 4941 SingleFile: String("sf"), 4942 Statuses: String("s"), 4943 TeamDiscussions: String("td"), 4944 VulnerabilityAlerts: String("va"), 4945 Workflows: String("w"), 4946 }, 4947 CreatedAt: &Timestamp{referenceTime}, 4948 UpdatedAt: &Timestamp{referenceTime}, 4949 HasMultipleSingleFiles: Bool(false), 4950 SuspendedBy: &User{ 4951 Login: String("l"), 4952 ID: Int64(1), 4953 URL: String("u"), 4954 AvatarURL: String("a"), 4955 GravatarID: String("g"), 4956 Name: String("n"), 4957 Company: String("c"), 4958 Blog: String("b"), 4959 Location: String("l"), 4960 Email: String("e"), 4961 Hireable: Bool(true), 4962 Bio: String("b"), 4963 TwitterUsername: String("t"), 4964 PublicRepos: Int(1), 4965 Followers: Int(1), 4966 Following: Int(1), 4967 CreatedAt: &Timestamp{referenceTime}, 4968 SuspendedAt: &Timestamp{referenceTime}, 4969 }, 4970 SuspendedAt: &Timestamp{referenceTime}, 4971 }, 4972 } 4973 4974 want := `{ 4975 "comment": { 4976 "html_url": "hurl", 4977 "url": "url", 4978 "id": 1, 4979 "node_id": "nid", 4980 "commit_id": "cid", 4981 "user": { 4982 "login": "l", 4983 "id": 1, 4984 "node_id": "n", 4985 "avatar_url": "a", 4986 "url": "u", 4987 "events_url": "e", 4988 "repos_url": "r" 4989 }, 4990 "reactions": { 4991 "total_count": 1, 4992 "+1": 1, 4993 "-1": 1, 4994 "laugh": 1, 4995 "confused": 1, 4996 "heart": 1, 4997 "hooray": 1, 4998 "rocket": 1, 4999 "eyes": 1, 5000 "url": "url" 5001 }, 5002 "created_at": ` + referenceTimeStr + `, 5003 "updated_at": ` + referenceTimeStr + `, 5004 "body": "b", 5005 "path": "path", 5006 "position": 1 5007 }, 5008 "action": "a", 5009 "repository": { 5010 "id": 1, 5011 "name": "n", 5012 "url": "s" 5013 }, 5014 "sender": { 5015 "login": "l", 5016 "id": 1, 5017 "node_id": "n", 5018 "avatar_url": "a", 5019 "url": "u", 5020 "events_url": "e", 5021 "repos_url": "r" 5022 }, 5023 "installation": { 5024 "id": 1, 5025 "node_id": "nid", 5026 "app_id": 1, 5027 "app_slug": "as", 5028 "target_id": 1, 5029 "account": { 5030 "login": "l", 5031 "id": 1, 5032 "avatar_url": "a", 5033 "gravatar_id": "g", 5034 "name": "n", 5035 "company": "c", 5036 "blog": "b", 5037 "location": "l", 5038 "email": "e", 5039 "hireable": true, 5040 "bio": "b", 5041 "twitter_username": "t", 5042 "public_repos": 1, 5043 "followers": 1, 5044 "following": 1, 5045 "created_at": ` + referenceTimeStr + `, 5046 "suspended_at": ` + referenceTimeStr + `, 5047 "url": "u" 5048 }, 5049 "access_tokens_url": "atu", 5050 "repositories_url": "ru", 5051 "html_url": "hu", 5052 "target_type": "tt", 5053 "single_file_name": "sfn", 5054 "repository_selection": "rs", 5055 "events": [ 5056 "e" 5057 ], 5058 "single_file_paths": [ 5059 "s" 5060 ], 5061 "permissions": { 5062 "actions": "a", 5063 "administration": "ad", 5064 "checks": "c", 5065 "contents": "co", 5066 "content_references": "cr", 5067 "deployments": "d", 5068 "environments": "e", 5069 "issues": "i", 5070 "metadata": "md", 5071 "members": "m", 5072 "organization_administration": "oa", 5073 "organization_hooks": "oh", 5074 "organization_plan": "op", 5075 "organization_pre_receive_hooks": "opr", 5076 "organization_projects": "op", 5077 "organization_secrets": "os", 5078 "organization_self_hosted_runners": "osh", 5079 "organization_user_blocking": "oub", 5080 "packages": "pkg", 5081 "pages": "pg", 5082 "pull_requests": "pr", 5083 "repository_hooks": "rh", 5084 "repository_projects": "rp", 5085 "repository_pre_receive_hooks": "rprh", 5086 "secrets": "s", 5087 "secret_scanning_alerts": "ssa", 5088 "security_events": "se", 5089 "single_file": "sf", 5090 "statuses": "s", 5091 "team_discussions": "td", 5092 "vulnerability_alerts": "va", 5093 "workflows": "w" 5094 }, 5095 "created_at": ` + referenceTimeStr + `, 5096 "updated_at": ` + referenceTimeStr + `, 5097 "has_multiple_single_files": false, 5098 "suspended_by": { 5099 "login": "l", 5100 "id": 1, 5101 "avatar_url": "a", 5102 "gravatar_id": "g", 5103 "name": "n", 5104 "company": "c", 5105 "blog": "b", 5106 "location": "l", 5107 "email": "e", 5108 "hireable": true, 5109 "bio": "b", 5110 "twitter_username": "t", 5111 "public_repos": 1, 5112 "followers": 1, 5113 "following": 1, 5114 "created_at": ` + referenceTimeStr + `, 5115 "suspended_at": ` + referenceTimeStr + `, 5116 "url": "u" 5117 }, 5118 "suspended_at": ` + referenceTimeStr + ` 5119 } 5120 }` 5121 5122 testJSONMarshal(t, u, want) 5123 } 5124 5125 func TestDeploymentEvent_Marshal(t *testing.T) { 5126 testJSONMarshal(t, &DeploymentEvent{}, "{}") 5127 5128 l := make(map[string]interface{}) 5129 l["key"] = "value" 5130 5131 jsonMsg, _ := json.Marshal(&l) 5132 5133 u := &DeploymentEvent{ 5134 Deployment: &Deployment{ 5135 URL: String("url"), 5136 ID: Int64(1), 5137 SHA: String("sha"), 5138 Ref: String("ref"), 5139 Task: String("t"), 5140 Payload: jsonMsg, 5141 Environment: String("e"), 5142 Description: String("d"), 5143 Creator: &User{ 5144 Login: String("l"), 5145 ID: Int64(1), 5146 NodeID: String("n"), 5147 URL: String("u"), 5148 ReposURL: String("r"), 5149 EventsURL: String("e"), 5150 AvatarURL: String("a"), 5151 }, 5152 CreatedAt: &Timestamp{referenceTime}, 5153 UpdatedAt: &Timestamp{referenceTime}, 5154 StatusesURL: String("surl"), 5155 RepositoryURL: String("rurl"), 5156 NodeID: String("nid"), 5157 }, 5158 Repo: &Repository{ 5159 ID: Int64(1), 5160 URL: String("s"), 5161 Name: String("n"), 5162 }, 5163 Sender: &User{ 5164 Login: String("l"), 5165 ID: Int64(1), 5166 NodeID: String("n"), 5167 URL: String("u"), 5168 ReposURL: String("r"), 5169 EventsURL: String("e"), 5170 AvatarURL: String("a"), 5171 }, 5172 Installation: &Installation{ 5173 ID: Int64(1), 5174 NodeID: String("nid"), 5175 AppID: Int64(1), 5176 AppSlug: String("as"), 5177 TargetID: Int64(1), 5178 Account: &User{ 5179 Login: String("l"), 5180 ID: Int64(1), 5181 URL: String("u"), 5182 AvatarURL: String("a"), 5183 GravatarID: String("g"), 5184 Name: String("n"), 5185 Company: String("c"), 5186 Blog: String("b"), 5187 Location: String("l"), 5188 Email: String("e"), 5189 Hireable: Bool(true), 5190 Bio: String("b"), 5191 TwitterUsername: String("t"), 5192 PublicRepos: Int(1), 5193 Followers: Int(1), 5194 Following: Int(1), 5195 CreatedAt: &Timestamp{referenceTime}, 5196 SuspendedAt: &Timestamp{referenceTime}, 5197 }, 5198 AccessTokensURL: String("atu"), 5199 RepositoriesURL: String("ru"), 5200 HTMLURL: String("hu"), 5201 TargetType: String("tt"), 5202 SingleFileName: String("sfn"), 5203 RepositorySelection: String("rs"), 5204 Events: []string{"e"}, 5205 SingleFilePaths: []string{"s"}, 5206 Permissions: &InstallationPermissions{ 5207 Actions: String("a"), 5208 Administration: String("ad"), 5209 Checks: String("c"), 5210 Contents: String("co"), 5211 ContentReferences: String("cr"), 5212 Deployments: String("d"), 5213 Environments: String("e"), 5214 Issues: String("i"), 5215 Metadata: String("md"), 5216 Members: String("m"), 5217 OrganizationAdministration: String("oa"), 5218 OrganizationHooks: String("oh"), 5219 OrganizationPlan: String("op"), 5220 OrganizationPreReceiveHooks: String("opr"), 5221 OrganizationProjects: String("op"), 5222 OrganizationSecrets: String("os"), 5223 OrganizationSelfHostedRunners: String("osh"), 5224 OrganizationUserBlocking: String("oub"), 5225 Packages: String("pkg"), 5226 Pages: String("pg"), 5227 PullRequests: String("pr"), 5228 RepositoryHooks: String("rh"), 5229 RepositoryProjects: String("rp"), 5230 RepositoryPreReceiveHooks: String("rprh"), 5231 Secrets: String("s"), 5232 SecretScanningAlerts: String("ssa"), 5233 SecurityEvents: String("se"), 5234 SingleFile: String("sf"), 5235 Statuses: String("s"), 5236 TeamDiscussions: String("td"), 5237 VulnerabilityAlerts: String("va"), 5238 Workflows: String("w"), 5239 }, 5240 CreatedAt: &Timestamp{referenceTime}, 5241 UpdatedAt: &Timestamp{referenceTime}, 5242 HasMultipleSingleFiles: Bool(false), 5243 SuspendedBy: &User{ 5244 Login: String("l"), 5245 ID: Int64(1), 5246 URL: String("u"), 5247 AvatarURL: String("a"), 5248 GravatarID: String("g"), 5249 Name: String("n"), 5250 Company: String("c"), 5251 Blog: String("b"), 5252 Location: String("l"), 5253 Email: String("e"), 5254 Hireable: Bool(true), 5255 Bio: String("b"), 5256 TwitterUsername: String("t"), 5257 PublicRepos: Int(1), 5258 Followers: Int(1), 5259 Following: Int(1), 5260 CreatedAt: &Timestamp{referenceTime}, 5261 SuspendedAt: &Timestamp{referenceTime}, 5262 }, 5263 SuspendedAt: &Timestamp{referenceTime}, 5264 }, 5265 } 5266 5267 want := `{ 5268 "deployment": { 5269 "url": "url", 5270 "id": 1, 5271 "sha": "sha", 5272 "ref": "ref", 5273 "task": "t", 5274 "payload": { 5275 "key": "value" 5276 }, 5277 "environment": "e", 5278 "description": "d", 5279 "creator": { 5280 "login": "l", 5281 "id": 1, 5282 "node_id": "n", 5283 "avatar_url": "a", 5284 "url": "u", 5285 "events_url": "e", 5286 "repos_url": "r" 5287 }, 5288 "created_at": ` + referenceTimeStr + `, 5289 "updated_at": ` + referenceTimeStr + `, 5290 "statuses_url": "surl", 5291 "repository_url": "rurl", 5292 "node_id": "nid" 5293 }, 5294 "repository": { 5295 "id": 1, 5296 "name": "n", 5297 "url": "s" 5298 }, 5299 "sender": { 5300 "login": "l", 5301 "id": 1, 5302 "node_id": "n", 5303 "avatar_url": "a", 5304 "url": "u", 5305 "events_url": "e", 5306 "repos_url": "r" 5307 }, 5308 "installation": { 5309 "id": 1, 5310 "node_id": "nid", 5311 "app_id": 1, 5312 "app_slug": "as", 5313 "target_id": 1, 5314 "account": { 5315 "login": "l", 5316 "id": 1, 5317 "avatar_url": "a", 5318 "gravatar_id": "g", 5319 "name": "n", 5320 "company": "c", 5321 "blog": "b", 5322 "location": "l", 5323 "email": "e", 5324 "hireable": true, 5325 "bio": "b", 5326 "twitter_username": "t", 5327 "public_repos": 1, 5328 "followers": 1, 5329 "following": 1, 5330 "created_at": ` + referenceTimeStr + `, 5331 "suspended_at": ` + referenceTimeStr + `, 5332 "url": "u" 5333 }, 5334 "access_tokens_url": "atu", 5335 "repositories_url": "ru", 5336 "html_url": "hu", 5337 "target_type": "tt", 5338 "single_file_name": "sfn", 5339 "repository_selection": "rs", 5340 "events": [ 5341 "e" 5342 ], 5343 "single_file_paths": [ 5344 "s" 5345 ], 5346 "permissions": { 5347 "actions": "a", 5348 "administration": "ad", 5349 "checks": "c", 5350 "contents": "co", 5351 "content_references": "cr", 5352 "deployments": "d", 5353 "environments": "e", 5354 "issues": "i", 5355 "metadata": "md", 5356 "members": "m", 5357 "organization_administration": "oa", 5358 "organization_hooks": "oh", 5359 "organization_plan": "op", 5360 "organization_pre_receive_hooks": "opr", 5361 "organization_projects": "op", 5362 "organization_secrets": "os", 5363 "organization_self_hosted_runners": "osh", 5364 "organization_user_blocking": "oub", 5365 "packages": "pkg", 5366 "pages": "pg", 5367 "pull_requests": "pr", 5368 "repository_hooks": "rh", 5369 "repository_projects": "rp", 5370 "repository_pre_receive_hooks": "rprh", 5371 "secrets": "s", 5372 "secret_scanning_alerts": "ssa", 5373 "security_events": "se", 5374 "single_file": "sf", 5375 "statuses": "s", 5376 "team_discussions": "td", 5377 "vulnerability_alerts": "va", 5378 "workflows": "w" 5379 }, 5380 "created_at": ` + referenceTimeStr + `, 5381 "updated_at": ` + referenceTimeStr + `, 5382 "has_multiple_single_files": false, 5383 "suspended_by": { 5384 "login": "l", 5385 "id": 1, 5386 "avatar_url": "a", 5387 "gravatar_id": "g", 5388 "name": "n", 5389 "company": "c", 5390 "blog": "b", 5391 "location": "l", 5392 "email": "e", 5393 "hireable": true, 5394 "bio": "b", 5395 "twitter_username": "t", 5396 "public_repos": 1, 5397 "followers": 1, 5398 "following": 1, 5399 "created_at": ` + referenceTimeStr + `, 5400 "suspended_at": ` + referenceTimeStr + `, 5401 "url": "u" 5402 }, 5403 "suspended_at": ` + referenceTimeStr + ` 5404 } 5405 }` 5406 5407 testJSONMarshal(t, u, want) 5408 } 5409 5410 func TestDeploymentStatusEvent_Marshal(t *testing.T) { 5411 testJSONMarshal(t, &DeploymentStatusEvent{}, "{}") 5412 5413 l := make(map[string]interface{}) 5414 l["key"] = "value" 5415 5416 jsonMsg, _ := json.Marshal(&l) 5417 5418 u := &DeploymentStatusEvent{ 5419 Deployment: &Deployment{ 5420 URL: String("url"), 5421 ID: Int64(1), 5422 SHA: String("sha"), 5423 Ref: String("ref"), 5424 Task: String("t"), 5425 Payload: jsonMsg, 5426 Environment: String("e"), 5427 Description: String("d"), 5428 Creator: &User{ 5429 Login: String("l"), 5430 ID: Int64(1), 5431 NodeID: String("n"), 5432 URL: String("u"), 5433 ReposURL: String("r"), 5434 EventsURL: String("e"), 5435 AvatarURL: String("a"), 5436 }, 5437 CreatedAt: &Timestamp{referenceTime}, 5438 UpdatedAt: &Timestamp{referenceTime}, 5439 StatusesURL: String("surl"), 5440 RepositoryURL: String("rurl"), 5441 NodeID: String("nid"), 5442 }, 5443 DeploymentStatus: &DeploymentStatus{ 5444 ID: Int64(1), 5445 State: String("s"), 5446 Creator: &User{ 5447 Login: String("l"), 5448 ID: Int64(1), 5449 NodeID: String("n"), 5450 URL: String("u"), 5451 ReposURL: String("r"), 5452 EventsURL: String("e"), 5453 AvatarURL: String("a"), 5454 }, 5455 Description: String("s"), 5456 Environment: String("s"), 5457 NodeID: String("s"), 5458 CreatedAt: &Timestamp{referenceTime}, 5459 UpdatedAt: &Timestamp{referenceTime}, 5460 TargetURL: String("s"), 5461 DeploymentURL: String("s"), 5462 RepositoryURL: String("s"), 5463 EnvironmentURL: String("s"), 5464 LogURL: String("s"), 5465 URL: String("s"), 5466 }, 5467 Repo: &Repository{ 5468 ID: Int64(1), 5469 URL: String("s"), 5470 Name: String("n"), 5471 }, 5472 Sender: &User{ 5473 Login: String("l"), 5474 ID: Int64(1), 5475 NodeID: String("n"), 5476 URL: String("u"), 5477 ReposURL: String("r"), 5478 EventsURL: String("e"), 5479 AvatarURL: String("a"), 5480 }, 5481 Installation: &Installation{ 5482 ID: Int64(1), 5483 NodeID: String("nid"), 5484 AppID: Int64(1), 5485 AppSlug: String("as"), 5486 TargetID: Int64(1), 5487 Account: &User{ 5488 Login: String("l"), 5489 ID: Int64(1), 5490 URL: String("u"), 5491 AvatarURL: String("a"), 5492 GravatarID: String("g"), 5493 Name: String("n"), 5494 Company: String("c"), 5495 Blog: String("b"), 5496 Location: String("l"), 5497 Email: String("e"), 5498 Hireable: Bool(true), 5499 Bio: String("b"), 5500 TwitterUsername: String("t"), 5501 PublicRepos: Int(1), 5502 Followers: Int(1), 5503 Following: Int(1), 5504 CreatedAt: &Timestamp{referenceTime}, 5505 SuspendedAt: &Timestamp{referenceTime}, 5506 }, 5507 AccessTokensURL: String("atu"), 5508 RepositoriesURL: String("ru"), 5509 HTMLURL: String("hu"), 5510 TargetType: String("tt"), 5511 SingleFileName: String("sfn"), 5512 RepositorySelection: String("rs"), 5513 Events: []string{"e"}, 5514 SingleFilePaths: []string{"s"}, 5515 Permissions: &InstallationPermissions{ 5516 Actions: String("a"), 5517 Administration: String("ad"), 5518 Checks: String("c"), 5519 Contents: String("co"), 5520 ContentReferences: String("cr"), 5521 Deployments: String("d"), 5522 Environments: String("e"), 5523 Issues: String("i"), 5524 Metadata: String("md"), 5525 Members: String("m"), 5526 OrganizationAdministration: String("oa"), 5527 OrganizationHooks: String("oh"), 5528 OrganizationPlan: String("op"), 5529 OrganizationPreReceiveHooks: String("opr"), 5530 OrganizationProjects: String("op"), 5531 OrganizationSecrets: String("os"), 5532 OrganizationSelfHostedRunners: String("osh"), 5533 OrganizationUserBlocking: String("oub"), 5534 Packages: String("pkg"), 5535 Pages: String("pg"), 5536 PullRequests: String("pr"), 5537 RepositoryHooks: String("rh"), 5538 RepositoryProjects: String("rp"), 5539 RepositoryPreReceiveHooks: String("rprh"), 5540 Secrets: String("s"), 5541 SecretScanningAlerts: String("ssa"), 5542 SecurityEvents: String("se"), 5543 SingleFile: String("sf"), 5544 Statuses: String("s"), 5545 TeamDiscussions: String("td"), 5546 VulnerabilityAlerts: String("va"), 5547 Workflows: String("w"), 5548 }, 5549 CreatedAt: &Timestamp{referenceTime}, 5550 UpdatedAt: &Timestamp{referenceTime}, 5551 HasMultipleSingleFiles: Bool(false), 5552 SuspendedBy: &User{ 5553 Login: String("l"), 5554 ID: Int64(1), 5555 URL: String("u"), 5556 AvatarURL: String("a"), 5557 GravatarID: String("g"), 5558 Name: String("n"), 5559 Company: String("c"), 5560 Blog: String("b"), 5561 Location: String("l"), 5562 Email: String("e"), 5563 Hireable: Bool(true), 5564 Bio: String("b"), 5565 TwitterUsername: String("t"), 5566 PublicRepos: Int(1), 5567 Followers: Int(1), 5568 Following: Int(1), 5569 CreatedAt: &Timestamp{referenceTime}, 5570 SuspendedAt: &Timestamp{referenceTime}, 5571 }, 5572 SuspendedAt: &Timestamp{referenceTime}, 5573 }, 5574 } 5575 5576 want := `{ 5577 "deployment": { 5578 "url": "url", 5579 "id": 1, 5580 "sha": "sha", 5581 "ref": "ref", 5582 "task": "t", 5583 "payload": { 5584 "key": "value" 5585 }, 5586 "environment": "e", 5587 "description": "d", 5588 "creator": { 5589 "login": "l", 5590 "id": 1, 5591 "node_id": "n", 5592 "avatar_url": "a", 5593 "url": "u", 5594 "events_url": "e", 5595 "repos_url": "r" 5596 }, 5597 "created_at": ` + referenceTimeStr + `, 5598 "updated_at": ` + referenceTimeStr + `, 5599 "statuses_url": "surl", 5600 "repository_url": "rurl", 5601 "node_id": "nid" 5602 }, 5603 "deployment_status": { 5604 "id": 1, 5605 "state": "s", 5606 "creator": { 5607 "login": "l", 5608 "id": 1, 5609 "node_id": "n", 5610 "avatar_url": "a", 5611 "url": "u", 5612 "events_url": "e", 5613 "repos_url": "r" 5614 }, 5615 "description": "s", 5616 "environment": "s", 5617 "node_id": "s", 5618 "created_at": ` + referenceTimeStr + `, 5619 "updated_at": ` + referenceTimeStr + `, 5620 "target_url": "s", 5621 "deployment_url": "s", 5622 "repository_url": "s", 5623 "environment_url": "s", 5624 "log_url": "s", 5625 "url": "s" 5626 }, 5627 "repository": { 5628 "id": 1, 5629 "name": "n", 5630 "url": "s" 5631 }, 5632 "sender": { 5633 "login": "l", 5634 "id": 1, 5635 "node_id": "n", 5636 "avatar_url": "a", 5637 "url": "u", 5638 "events_url": "e", 5639 "repos_url": "r" 5640 }, 5641 "installation": { 5642 "id": 1, 5643 "node_id": "nid", 5644 "app_id": 1, 5645 "app_slug": "as", 5646 "target_id": 1, 5647 "account": { 5648 "login": "l", 5649 "id": 1, 5650 "avatar_url": "a", 5651 "gravatar_id": "g", 5652 "name": "n", 5653 "company": "c", 5654 "blog": "b", 5655 "location": "l", 5656 "email": "e", 5657 "hireable": true, 5658 "bio": "b", 5659 "twitter_username": "t", 5660 "public_repos": 1, 5661 "followers": 1, 5662 "following": 1, 5663 "created_at": ` + referenceTimeStr + `, 5664 "suspended_at": ` + referenceTimeStr + `, 5665 "url": "u" 5666 }, 5667 "access_tokens_url": "atu", 5668 "repositories_url": "ru", 5669 "html_url": "hu", 5670 "target_type": "tt", 5671 "single_file_name": "sfn", 5672 "repository_selection": "rs", 5673 "events": [ 5674 "e" 5675 ], 5676 "single_file_paths": [ 5677 "s" 5678 ], 5679 "permissions": { 5680 "actions": "a", 5681 "administration": "ad", 5682 "checks": "c", 5683 "contents": "co", 5684 "content_references": "cr", 5685 "deployments": "d", 5686 "environments": "e", 5687 "issues": "i", 5688 "metadata": "md", 5689 "members": "m", 5690 "organization_administration": "oa", 5691 "organization_hooks": "oh", 5692 "organization_plan": "op", 5693 "organization_pre_receive_hooks": "opr", 5694 "organization_projects": "op", 5695 "organization_secrets": "os", 5696 "organization_self_hosted_runners": "osh", 5697 "organization_user_blocking": "oub", 5698 "packages": "pkg", 5699 "pages": "pg", 5700 "pull_requests": "pr", 5701 "repository_hooks": "rh", 5702 "repository_projects": "rp", 5703 "repository_pre_receive_hooks": "rprh", 5704 "secrets": "s", 5705 "secret_scanning_alerts": "ssa", 5706 "security_events": "se", 5707 "single_file": "sf", 5708 "statuses": "s", 5709 "team_discussions": "td", 5710 "vulnerability_alerts": "va", 5711 "workflows": "w" 5712 }, 5713 "created_at": ` + referenceTimeStr + `, 5714 "updated_at": ` + referenceTimeStr + `, 5715 "has_multiple_single_files": false, 5716 "suspended_by": { 5717 "login": "l", 5718 "id": 1, 5719 "avatar_url": "a", 5720 "gravatar_id": "g", 5721 "name": "n", 5722 "company": "c", 5723 "blog": "b", 5724 "location": "l", 5725 "email": "e", 5726 "hireable": true, 5727 "bio": "b", 5728 "twitter_username": "t", 5729 "public_repos": 1, 5730 "followers": 1, 5731 "following": 1, 5732 "created_at": ` + referenceTimeStr + `, 5733 "suspended_at": ` + referenceTimeStr + `, 5734 "url": "u" 5735 }, 5736 "suspended_at": ` + referenceTimeStr + ` 5737 } 5738 }` 5739 5740 testJSONMarshal(t, u, want) 5741 } 5742 5743 func TestDiscussionEvent_Marshal(t *testing.T) { 5744 testJSONMarshal(t, &DiscussionEvent{}, "{}") 5745 5746 u := &DiscussionEvent{ 5747 Discussion: &Discussion{ 5748 RepositoryURL: String("rurl"), 5749 DiscussionCategory: &DiscussionCategory{ 5750 ID: Int64(1), 5751 NodeID: String("nid"), 5752 RepositoryID: Int64(1), 5753 Emoji: String("emoji"), 5754 Name: String("name"), 5755 Description: String("description"), 5756 CreatedAt: &Timestamp{referenceTime}, 5757 UpdatedAt: &Timestamp{referenceTime}, 5758 Slug: String("slug"), 5759 IsAnswerable: Bool(false), 5760 }, 5761 HTMLURL: String("hurl"), 5762 ID: Int64(1), 5763 NodeID: String("nurl"), 5764 Number: Int(1), 5765 Title: String("title"), 5766 User: &User{ 5767 Login: String("l"), 5768 ID: Int64(1), 5769 NodeID: String("n"), 5770 URL: String("u"), 5771 ReposURL: String("r"), 5772 EventsURL: String("e"), 5773 AvatarURL: String("a"), 5774 }, 5775 State: String("st"), 5776 Locked: Bool(false), 5777 Comments: Int(1), 5778 CreatedAt: &Timestamp{referenceTime}, 5779 UpdatedAt: &Timestamp{referenceTime}, 5780 AuthorAssociation: String("aa"), 5781 Body: String("bo"), 5782 }, 5783 Repo: &Repository{ 5784 ID: Int64(1), 5785 URL: String("s"), 5786 Name: String("n"), 5787 }, 5788 Org: &Organization{ 5789 BillingEmail: String("be"), 5790 Blog: String("b"), 5791 Company: String("c"), 5792 Email: String("e"), 5793 TwitterUsername: String("tu"), 5794 Location: String("loc"), 5795 Name: String("n"), 5796 Description: String("d"), 5797 IsVerified: Bool(true), 5798 HasOrganizationProjects: Bool(true), 5799 HasRepositoryProjects: Bool(true), 5800 DefaultRepoPermission: String("drp"), 5801 MembersCanCreateRepos: Bool(true), 5802 MembersCanCreateInternalRepos: Bool(true), 5803 MembersCanCreatePrivateRepos: Bool(true), 5804 MembersCanCreatePublicRepos: Bool(false), 5805 MembersAllowedRepositoryCreationType: String("marct"), 5806 MembersCanCreatePages: Bool(true), 5807 MembersCanCreatePublicPages: Bool(false), 5808 MembersCanCreatePrivatePages: Bool(true), 5809 }, 5810 Sender: &User{ 5811 Login: String("l"), 5812 ID: Int64(1), 5813 NodeID: String("n"), 5814 URL: String("u"), 5815 ReposURL: String("r"), 5816 EventsURL: String("e"), 5817 AvatarURL: String("a"), 5818 }, 5819 Installation: &Installation{ 5820 ID: Int64(1), 5821 NodeID: String("nid"), 5822 AppID: Int64(1), 5823 AppSlug: String("as"), 5824 TargetID: Int64(1), 5825 Account: &User{ 5826 Login: String("l"), 5827 ID: Int64(1), 5828 URL: String("u"), 5829 AvatarURL: String("a"), 5830 GravatarID: String("g"), 5831 Name: String("n"), 5832 Company: String("c"), 5833 Blog: String("b"), 5834 Location: String("l"), 5835 Email: String("e"), 5836 Hireable: Bool(true), 5837 Bio: String("b"), 5838 TwitterUsername: String("t"), 5839 PublicRepos: Int(1), 5840 Followers: Int(1), 5841 Following: Int(1), 5842 CreatedAt: &Timestamp{referenceTime}, 5843 SuspendedAt: &Timestamp{referenceTime}, 5844 }, 5845 AccessTokensURL: String("atu"), 5846 RepositoriesURL: String("ru"), 5847 HTMLURL: String("hu"), 5848 TargetType: String("tt"), 5849 SingleFileName: String("sfn"), 5850 RepositorySelection: String("rs"), 5851 Events: []string{"e"}, 5852 SingleFilePaths: []string{"s"}, 5853 Permissions: &InstallationPermissions{ 5854 Actions: String("a"), 5855 Administration: String("ad"), 5856 Checks: String("c"), 5857 Contents: String("co"), 5858 ContentReferences: String("cr"), 5859 Deployments: String("d"), 5860 Environments: String("e"), 5861 Issues: String("i"), 5862 Metadata: String("md"), 5863 Members: String("m"), 5864 OrganizationAdministration: String("oa"), 5865 OrganizationHooks: String("oh"), 5866 OrganizationPlan: String("op"), 5867 OrganizationPreReceiveHooks: String("opr"), 5868 OrganizationProjects: String("op"), 5869 OrganizationSecrets: String("os"), 5870 OrganizationSelfHostedRunners: String("osh"), 5871 OrganizationUserBlocking: String("oub"), 5872 Packages: String("pkg"), 5873 Pages: String("pg"), 5874 PullRequests: String("pr"), 5875 RepositoryHooks: String("rh"), 5876 RepositoryProjects: String("rp"), 5877 RepositoryPreReceiveHooks: String("rprh"), 5878 Secrets: String("s"), 5879 SecretScanningAlerts: String("ssa"), 5880 SecurityEvents: String("se"), 5881 SingleFile: String("sf"), 5882 Statuses: String("s"), 5883 TeamDiscussions: String("td"), 5884 VulnerabilityAlerts: String("va"), 5885 Workflows: String("w"), 5886 }, 5887 CreatedAt: &Timestamp{referenceTime}, 5888 UpdatedAt: &Timestamp{referenceTime}, 5889 HasMultipleSingleFiles: Bool(false), 5890 SuspendedBy: &User{ 5891 Login: String("l"), 5892 ID: Int64(1), 5893 URL: String("u"), 5894 AvatarURL: String("a"), 5895 GravatarID: String("g"), 5896 Name: String("n"), 5897 Company: String("c"), 5898 Blog: String("b"), 5899 Location: String("l"), 5900 Email: String("e"), 5901 Hireable: Bool(true), 5902 Bio: String("b"), 5903 TwitterUsername: String("t"), 5904 PublicRepos: Int(1), 5905 Followers: Int(1), 5906 Following: Int(1), 5907 CreatedAt: &Timestamp{referenceTime}, 5908 SuspendedAt: &Timestamp{referenceTime}, 5909 }, 5910 SuspendedAt: &Timestamp{referenceTime}, 5911 }, 5912 } 5913 5914 want := `{ 5915 "discussion": { 5916 "repository_url": "rurl", 5917 "category": { 5918 "id": 1, 5919 "node_id": "nid", 5920 "repository_id": 1, 5921 "emoji": "emoji", 5922 "name": "name", 5923 "description": "description", 5924 "created_at": ` + referenceTimeStr + `, 5925 "updated_at": ` + referenceTimeStr + `, 5926 "slug": "slug", 5927 "is_answerable": false 5928 }, 5929 "html_url": "hurl", 5930 "id": 1, 5931 "node_id": "nurl", 5932 "number": 1, 5933 "title": "title", 5934 "user": { 5935 "login": "l", 5936 "id": 1, 5937 "node_id": "n", 5938 "avatar_url": "a", 5939 "url": "u", 5940 "events_url": "e", 5941 "repos_url": "r" 5942 }, 5943 "state": "st", 5944 "locked": false, 5945 "comments": 1, 5946 "created_at": ` + referenceTimeStr + `, 5947 "updated_at": ` + referenceTimeStr + `, 5948 "author_association": "aa", 5949 "body": "bo" 5950 }, 5951 "repository": { 5952 "id": 1, 5953 "name": "n", 5954 "url": "s" 5955 }, 5956 "organization": { 5957 "name": "n", 5958 "company": "c", 5959 "blog": "b", 5960 "location": "loc", 5961 "email": "e", 5962 "twitter_username": "tu", 5963 "description": "d", 5964 "billing_email": "be", 5965 "is_verified": true, 5966 "has_organization_projects": true, 5967 "has_repository_projects": true, 5968 "default_repository_permission": "drp", 5969 "members_can_create_repositories": true, 5970 "members_can_create_public_repositories": false, 5971 "members_can_create_private_repositories": true, 5972 "members_can_create_internal_repositories": true, 5973 "members_allowed_repository_creation_type": "marct", 5974 "members_can_create_pages": true, 5975 "members_can_create_public_pages": false, 5976 "members_can_create_private_pages": true 5977 }, 5978 "sender": { 5979 "login": "l", 5980 "id": 1, 5981 "node_id": "n", 5982 "avatar_url": "a", 5983 "url": "u", 5984 "events_url": "e", 5985 "repos_url": "r" 5986 }, 5987 "installation": { 5988 "id": 1, 5989 "node_id": "nid", 5990 "app_id": 1, 5991 "app_slug": "as", 5992 "target_id": 1, 5993 "account": { 5994 "login": "l", 5995 "id": 1, 5996 "avatar_url": "a", 5997 "gravatar_id": "g", 5998 "name": "n", 5999 "company": "c", 6000 "blog": "b", 6001 "location": "l", 6002 "email": "e", 6003 "hireable": true, 6004 "bio": "b", 6005 "twitter_username": "t", 6006 "public_repos": 1, 6007 "followers": 1, 6008 "following": 1, 6009 "created_at": ` + referenceTimeStr + `, 6010 "suspended_at": ` + referenceTimeStr + `, 6011 "url": "u" 6012 }, 6013 "access_tokens_url": "atu", 6014 "repositories_url": "ru", 6015 "html_url": "hu", 6016 "target_type": "tt", 6017 "single_file_name": "sfn", 6018 "repository_selection": "rs", 6019 "events": [ 6020 "e" 6021 ], 6022 "single_file_paths": [ 6023 "s" 6024 ], 6025 "permissions": { 6026 "actions": "a", 6027 "administration": "ad", 6028 "checks": "c", 6029 "contents": "co", 6030 "content_references": "cr", 6031 "deployments": "d", 6032 "environments": "e", 6033 "issues": "i", 6034 "metadata": "md", 6035 "members": "m", 6036 "organization_administration": "oa", 6037 "organization_hooks": "oh", 6038 "organization_plan": "op", 6039 "organization_pre_receive_hooks": "opr", 6040 "organization_projects": "op", 6041 "organization_secrets": "os", 6042 "organization_self_hosted_runners": "osh", 6043 "organization_user_blocking": "oub", 6044 "packages": "pkg", 6045 "pages": "pg", 6046 "pull_requests": "pr", 6047 "repository_hooks": "rh", 6048 "repository_projects": "rp", 6049 "repository_pre_receive_hooks": "rprh", 6050 "secrets": "s", 6051 "secret_scanning_alerts": "ssa", 6052 "security_events": "se", 6053 "single_file": "sf", 6054 "statuses": "s", 6055 "team_discussions": "td", 6056 "vulnerability_alerts": "va", 6057 "workflows": "w" 6058 }, 6059 "created_at": ` + referenceTimeStr + `, 6060 "updated_at": ` + referenceTimeStr + `, 6061 "has_multiple_single_files": false, 6062 "suspended_by": { 6063 "login": "l", 6064 "id": 1, 6065 "avatar_url": "a", 6066 "gravatar_id": "g", 6067 "name": "n", 6068 "company": "c", 6069 "blog": "b", 6070 "location": "l", 6071 "email": "e", 6072 "hireable": true, 6073 "bio": "b", 6074 "twitter_username": "t", 6075 "public_repos": 1, 6076 "followers": 1, 6077 "following": 1, 6078 "created_at": ` + referenceTimeStr + `, 6079 "suspended_at": ` + referenceTimeStr + `, 6080 "url": "u" 6081 }, 6082 "suspended_at": ` + referenceTimeStr + ` 6083 } 6084 }` 6085 6086 testJSONMarshal(t, u, want) 6087 } 6088 6089 func TestPackageEvent_Marshal(t *testing.T) { 6090 testJSONMarshal(t, &PackageEvent{}, "{}") 6091 6092 u := &PackageEvent{ 6093 Action: String("a"), 6094 Package: &Package{ 6095 ID: Int64(1), 6096 Name: String("n"), 6097 PackageType: String("pt"), 6098 HTMLURL: String("hurl"), 6099 CreatedAt: &Timestamp{referenceTime}, 6100 UpdatedAt: &Timestamp{referenceTime}, 6101 Owner: &User{ 6102 Login: String("l"), 6103 ID: Int64(1), 6104 NodeID: String("n"), 6105 URL: String("u"), 6106 ReposURL: String("r"), 6107 EventsURL: String("e"), 6108 AvatarURL: String("a"), 6109 }, 6110 PackageVersion: &PackageVersion{ID: Int64(1)}, 6111 Registry: &PackageRegistry{Name: String("n")}, 6112 }, 6113 Repo: &Repository{ 6114 ID: Int64(1), 6115 URL: String("s"), 6116 Name: String("n"), 6117 }, 6118 Org: &Organization{ 6119 BillingEmail: String("be"), 6120 Blog: String("b"), 6121 Company: String("c"), 6122 Email: String("e"), 6123 TwitterUsername: String("tu"), 6124 Location: String("loc"), 6125 Name: String("n"), 6126 Description: String("d"), 6127 IsVerified: Bool(true), 6128 HasOrganizationProjects: Bool(true), 6129 HasRepositoryProjects: Bool(true), 6130 DefaultRepoPermission: String("drp"), 6131 MembersCanCreateRepos: Bool(true), 6132 MembersCanCreateInternalRepos: Bool(true), 6133 MembersCanCreatePrivateRepos: Bool(true), 6134 MembersCanCreatePublicRepos: Bool(false), 6135 MembersAllowedRepositoryCreationType: String("marct"), 6136 MembersCanCreatePages: Bool(true), 6137 MembersCanCreatePublicPages: Bool(false), 6138 MembersCanCreatePrivatePages: Bool(true), 6139 }, 6140 Sender: &User{ 6141 Login: String("l"), 6142 ID: Int64(1), 6143 NodeID: String("n"), 6144 URL: String("u"), 6145 ReposURL: String("r"), 6146 EventsURL: String("e"), 6147 AvatarURL: String("a"), 6148 }, 6149 } 6150 6151 want := `{ 6152 "action": "a", 6153 "package": { 6154 "id": 1, 6155 "name": "n", 6156 "package_type": "pt", 6157 "html_url": "hurl", 6158 "created_at": ` + referenceTimeStr + `, 6159 "updated_at": ` + referenceTimeStr + `, 6160 "owner": { 6161 "login": "l", 6162 "id": 1, 6163 "node_id": "n", 6164 "avatar_url": "a", 6165 "url": "u", 6166 "events_url": "e", 6167 "repos_url": "r" 6168 }, 6169 "package_version": { 6170 "id": 1 6171 }, 6172 "registry": { 6173 "name": "n" 6174 } 6175 }, 6176 "repository": { 6177 "id": 1, 6178 "name": "n", 6179 "url": "s" 6180 }, 6181 "organization": { 6182 "name": "n", 6183 "company": "c", 6184 "blog": "b", 6185 "location": "loc", 6186 "email": "e", 6187 "twitter_username": "tu", 6188 "description": "d", 6189 "billing_email": "be", 6190 "is_verified": true, 6191 "has_organization_projects": true, 6192 "has_repository_projects": true, 6193 "default_repository_permission": "drp", 6194 "members_can_create_repositories": true, 6195 "members_can_create_public_repositories": false, 6196 "members_can_create_private_repositories": true, 6197 "members_can_create_internal_repositories": true, 6198 "members_allowed_repository_creation_type": "marct", 6199 "members_can_create_pages": true, 6200 "members_can_create_public_pages": false, 6201 "members_can_create_private_pages": true 6202 }, 6203 "sender": { 6204 "login": "l", 6205 "id": 1, 6206 "node_id": "n", 6207 "avatar_url": "a", 6208 "url": "u", 6209 "events_url": "e", 6210 "repos_url": "r" 6211 } 6212 }` 6213 6214 testJSONMarshal(t, u, want) 6215 } 6216 6217 func TestPingEvent_Marshal(t *testing.T) { 6218 testJSONMarshal(t, &PingEvent{}, "{}") 6219 6220 l := make(map[string]interface{}) 6221 l["key"] = "value" 6222 6223 u := &PingEvent{ 6224 Zen: String("z"), 6225 HookID: Int64(1), 6226 Hook: &Hook{ 6227 CreatedAt: &referenceTime, 6228 UpdatedAt: &referenceTime, 6229 URL: String("url"), 6230 ID: Int64(1), 6231 Type: String("t"), 6232 Name: String("n"), 6233 TestURL: String("tu"), 6234 PingURL: String("pu"), 6235 LastResponse: l, 6236 Config: l, 6237 Events: []string{"a"}, 6238 Active: Bool(true), 6239 }, 6240 Installation: &Installation{ 6241 ID: Int64(1), 6242 NodeID: String("nid"), 6243 AppID: Int64(1), 6244 AppSlug: String("as"), 6245 TargetID: Int64(1), 6246 Account: &User{ 6247 Login: String("l"), 6248 ID: Int64(1), 6249 URL: String("u"), 6250 AvatarURL: String("a"), 6251 GravatarID: String("g"), 6252 Name: String("n"), 6253 Company: String("c"), 6254 Blog: String("b"), 6255 Location: String("l"), 6256 Email: String("e"), 6257 Hireable: Bool(true), 6258 Bio: String("b"), 6259 TwitterUsername: String("t"), 6260 PublicRepos: Int(1), 6261 Followers: Int(1), 6262 Following: Int(1), 6263 CreatedAt: &Timestamp{referenceTime}, 6264 SuspendedAt: &Timestamp{referenceTime}, 6265 }, 6266 AccessTokensURL: String("atu"), 6267 RepositoriesURL: String("ru"), 6268 HTMLURL: String("hu"), 6269 TargetType: String("tt"), 6270 SingleFileName: String("sfn"), 6271 RepositorySelection: String("rs"), 6272 Events: []string{"e"}, 6273 SingleFilePaths: []string{"s"}, 6274 Permissions: &InstallationPermissions{ 6275 Actions: String("a"), 6276 Administration: String("ad"), 6277 Checks: String("c"), 6278 Contents: String("co"), 6279 ContentReferences: String("cr"), 6280 Deployments: String("d"), 6281 Environments: String("e"), 6282 Issues: String("i"), 6283 Metadata: String("md"), 6284 Members: String("m"), 6285 OrganizationAdministration: String("oa"), 6286 OrganizationHooks: String("oh"), 6287 OrganizationPlan: String("op"), 6288 OrganizationPreReceiveHooks: String("opr"), 6289 OrganizationProjects: String("op"), 6290 OrganizationSecrets: String("os"), 6291 OrganizationSelfHostedRunners: String("osh"), 6292 OrganizationUserBlocking: String("oub"), 6293 Packages: String("pkg"), 6294 Pages: String("pg"), 6295 PullRequests: String("pr"), 6296 RepositoryHooks: String("rh"), 6297 RepositoryProjects: String("rp"), 6298 RepositoryPreReceiveHooks: String("rprh"), 6299 Secrets: String("s"), 6300 SecretScanningAlerts: String("ssa"), 6301 SecurityEvents: String("se"), 6302 SingleFile: String("sf"), 6303 Statuses: String("s"), 6304 TeamDiscussions: String("td"), 6305 VulnerabilityAlerts: String("va"), 6306 Workflows: String("w"), 6307 }, 6308 CreatedAt: &Timestamp{referenceTime}, 6309 UpdatedAt: &Timestamp{referenceTime}, 6310 HasMultipleSingleFiles: Bool(false), 6311 SuspendedBy: &User{ 6312 Login: String("l"), 6313 ID: Int64(1), 6314 URL: String("u"), 6315 AvatarURL: String("a"), 6316 GravatarID: String("g"), 6317 Name: String("n"), 6318 Company: String("c"), 6319 Blog: String("b"), 6320 Location: String("l"), 6321 Email: String("e"), 6322 Hireable: Bool(true), 6323 Bio: String("b"), 6324 TwitterUsername: String("t"), 6325 PublicRepos: Int(1), 6326 Followers: Int(1), 6327 Following: Int(1), 6328 CreatedAt: &Timestamp{referenceTime}, 6329 SuspendedAt: &Timestamp{referenceTime}, 6330 }, 6331 SuspendedAt: &Timestamp{referenceTime}, 6332 }, 6333 } 6334 6335 want := `{ 6336 "zen": "z", 6337 "hook_id": 1, 6338 "hook": { 6339 "created_at": ` + referenceTimeStr + `, 6340 "updated_at": ` + referenceTimeStr + `, 6341 "url": "url", 6342 "id": 1, 6343 "type": "t", 6344 "name": "n", 6345 "test_url": "tu", 6346 "ping_url": "pu", 6347 "last_response": { 6348 "key": "value" 6349 }, 6350 "config": { 6351 "key": "value" 6352 }, 6353 "events": [ 6354 "a" 6355 ], 6356 "active": true 6357 }, 6358 "installation": { 6359 "id": 1, 6360 "node_id": "nid", 6361 "app_id": 1, 6362 "app_slug": "as", 6363 "target_id": 1, 6364 "account": { 6365 "login": "l", 6366 "id": 1, 6367 "avatar_url": "a", 6368 "gravatar_id": "g", 6369 "name": "n", 6370 "company": "c", 6371 "blog": "b", 6372 "location": "l", 6373 "email": "e", 6374 "hireable": true, 6375 "bio": "b", 6376 "twitter_username": "t", 6377 "public_repos": 1, 6378 "followers": 1, 6379 "following": 1, 6380 "created_at": ` + referenceTimeStr + `, 6381 "suspended_at": ` + referenceTimeStr + `, 6382 "url": "u" 6383 }, 6384 "access_tokens_url": "atu", 6385 "repositories_url": "ru", 6386 "html_url": "hu", 6387 "target_type": "tt", 6388 "single_file_name": "sfn", 6389 "repository_selection": "rs", 6390 "events": [ 6391 "e" 6392 ], 6393 "single_file_paths": [ 6394 "s" 6395 ], 6396 "permissions": { 6397 "actions": "a", 6398 "administration": "ad", 6399 "checks": "c", 6400 "contents": "co", 6401 "content_references": "cr", 6402 "deployments": "d", 6403 "environments": "e", 6404 "issues": "i", 6405 "metadata": "md", 6406 "members": "m", 6407 "organization_administration": "oa", 6408 "organization_hooks": "oh", 6409 "organization_plan": "op", 6410 "organization_pre_receive_hooks": "opr", 6411 "organization_projects": "op", 6412 "organization_secrets": "os", 6413 "organization_self_hosted_runners": "osh", 6414 "organization_user_blocking": "oub", 6415 "packages": "pkg", 6416 "pages": "pg", 6417 "pull_requests": "pr", 6418 "repository_hooks": "rh", 6419 "repository_projects": "rp", 6420 "repository_pre_receive_hooks": "rprh", 6421 "secrets": "s", 6422 "secret_scanning_alerts": "ssa", 6423 "security_events": "se", 6424 "single_file": "sf", 6425 "statuses": "s", 6426 "team_discussions": "td", 6427 "vulnerability_alerts": "va", 6428 "workflows": "w" 6429 }, 6430 "created_at": ` + referenceTimeStr + `, 6431 "updated_at": ` + referenceTimeStr + `, 6432 "has_multiple_single_files": false, 6433 "suspended_by": { 6434 "login": "l", 6435 "id": 1, 6436 "avatar_url": "a", 6437 "gravatar_id": "g", 6438 "name": "n", 6439 "company": "c", 6440 "blog": "b", 6441 "location": "l", 6442 "email": "e", 6443 "hireable": true, 6444 "bio": "b", 6445 "twitter_username": "t", 6446 "public_repos": 1, 6447 "followers": 1, 6448 "following": 1, 6449 "created_at": ` + referenceTimeStr + `, 6450 "suspended_at": ` + referenceTimeStr + `, 6451 "url": "u" 6452 }, 6453 "suspended_at": ` + referenceTimeStr + ` 6454 } 6455 }` 6456 6457 testJSONMarshal(t, u, want) 6458 } 6459 6460 func TestRepositoryDispatchEvent_Marshal(t *testing.T) { 6461 testJSONMarshal(t, &RepositoryDispatchEvent{}, "{}") 6462 6463 l := make(map[string]interface{}) 6464 l["key"] = "value" 6465 6466 jsonMsg, _ := json.Marshal(&l) 6467 6468 u := &RepositoryDispatchEvent{ 6469 Action: String("a"), 6470 Branch: String("b"), 6471 ClientPayload: jsonMsg, 6472 Repo: &Repository{ 6473 6474 ID: Int64(1), 6475 URL: String("s"), 6476 Name: String("n"), 6477 }, 6478 Org: &Organization{ 6479 BillingEmail: String("be"), 6480 Blog: String("b"), 6481 Company: String("c"), 6482 Email: String("e"), 6483 TwitterUsername: String("tu"), 6484 Location: String("loc"), 6485 Name: String("n"), 6486 Description: String("d"), 6487 IsVerified: Bool(true), 6488 HasOrganizationProjects: Bool(true), 6489 HasRepositoryProjects: Bool(true), 6490 DefaultRepoPermission: String("drp"), 6491 MembersCanCreateRepos: Bool(true), 6492 MembersCanCreateInternalRepos: Bool(true), 6493 MembersCanCreatePrivateRepos: Bool(true), 6494 MembersCanCreatePublicRepos: Bool(false), 6495 MembersAllowedRepositoryCreationType: String("marct"), 6496 MembersCanCreatePages: Bool(true), 6497 MembersCanCreatePublicPages: Bool(false), 6498 MembersCanCreatePrivatePages: Bool(true), 6499 }, 6500 Sender: &User{ 6501 Login: String("l"), 6502 ID: Int64(1), 6503 NodeID: String("n"), 6504 URL: String("u"), 6505 ReposURL: String("r"), 6506 EventsURL: String("e"), 6507 AvatarURL: String("a"), 6508 }, 6509 Installation: &Installation{ 6510 ID: Int64(1), 6511 NodeID: String("nid"), 6512 AppID: Int64(1), 6513 AppSlug: String("as"), 6514 TargetID: Int64(1), 6515 Account: &User{ 6516 Login: String("l"), 6517 ID: Int64(1), 6518 URL: String("u"), 6519 AvatarURL: String("a"), 6520 GravatarID: String("g"), 6521 Name: String("n"), 6522 Company: String("c"), 6523 Blog: String("b"), 6524 Location: String("l"), 6525 Email: String("e"), 6526 Hireable: Bool(true), 6527 Bio: String("b"), 6528 TwitterUsername: String("t"), 6529 PublicRepos: Int(1), 6530 Followers: Int(1), 6531 Following: Int(1), 6532 CreatedAt: &Timestamp{referenceTime}, 6533 SuspendedAt: &Timestamp{referenceTime}, 6534 }, 6535 AccessTokensURL: String("atu"), 6536 RepositoriesURL: String("ru"), 6537 HTMLURL: String("hu"), 6538 TargetType: String("tt"), 6539 SingleFileName: String("sfn"), 6540 RepositorySelection: String("rs"), 6541 Events: []string{"e"}, 6542 SingleFilePaths: []string{"s"}, 6543 Permissions: &InstallationPermissions{ 6544 Actions: String("a"), 6545 Administration: String("ad"), 6546 Checks: String("c"), 6547 Contents: String("co"), 6548 ContentReferences: String("cr"), 6549 Deployments: String("d"), 6550 Environments: String("e"), 6551 Issues: String("i"), 6552 Metadata: String("md"), 6553 Members: String("m"), 6554 OrganizationAdministration: String("oa"), 6555 OrganizationHooks: String("oh"), 6556 OrganizationPlan: String("op"), 6557 OrganizationPreReceiveHooks: String("opr"), 6558 OrganizationProjects: String("op"), 6559 OrganizationSecrets: String("os"), 6560 OrganizationSelfHostedRunners: String("osh"), 6561 OrganizationUserBlocking: String("oub"), 6562 Packages: String("pkg"), 6563 Pages: String("pg"), 6564 PullRequests: String("pr"), 6565 RepositoryHooks: String("rh"), 6566 RepositoryProjects: String("rp"), 6567 RepositoryPreReceiveHooks: String("rprh"), 6568 Secrets: String("s"), 6569 SecretScanningAlerts: String("ssa"), 6570 SecurityEvents: String("se"), 6571 SingleFile: String("sf"), 6572 Statuses: String("s"), 6573 TeamDiscussions: String("td"), 6574 VulnerabilityAlerts: String("va"), 6575 Workflows: String("w"), 6576 }, 6577 CreatedAt: &Timestamp{referenceTime}, 6578 UpdatedAt: &Timestamp{referenceTime}, 6579 HasMultipleSingleFiles: Bool(false), 6580 SuspendedBy: &User{ 6581 Login: String("l"), 6582 ID: Int64(1), 6583 URL: String("u"), 6584 AvatarURL: String("a"), 6585 GravatarID: String("g"), 6586 Name: String("n"), 6587 Company: String("c"), 6588 Blog: String("b"), 6589 Location: String("l"), 6590 Email: String("e"), 6591 Hireable: Bool(true), 6592 Bio: String("b"), 6593 TwitterUsername: String("t"), 6594 PublicRepos: Int(1), 6595 Followers: Int(1), 6596 Following: Int(1), 6597 CreatedAt: &Timestamp{referenceTime}, 6598 SuspendedAt: &Timestamp{referenceTime}, 6599 }, 6600 SuspendedAt: &Timestamp{referenceTime}, 6601 }, 6602 } 6603 6604 want := `{ 6605 "action": "a", 6606 "branch": "b", 6607 "client_payload": { 6608 "key": "value" 6609 }, 6610 "repository": { 6611 "id": 1, 6612 "name": "n", 6613 "url": "s" 6614 }, 6615 "organization": { 6616 "name": "n", 6617 "company": "c", 6618 "blog": "b", 6619 "location": "loc", 6620 "email": "e", 6621 "twitter_username": "tu", 6622 "description": "d", 6623 "billing_email": "be", 6624 "is_verified": true, 6625 "has_organization_projects": true, 6626 "has_repository_projects": true, 6627 "default_repository_permission": "drp", 6628 "members_can_create_repositories": true, 6629 "members_can_create_public_repositories": false, 6630 "members_can_create_private_repositories": true, 6631 "members_can_create_internal_repositories": true, 6632 "members_allowed_repository_creation_type": "marct", 6633 "members_can_create_pages": true, 6634 "members_can_create_public_pages": false, 6635 "members_can_create_private_pages": true 6636 }, 6637 "sender": { 6638 "login": "l", 6639 "id": 1, 6640 "node_id": "n", 6641 "avatar_url": "a", 6642 "url": "u", 6643 "events_url": "e", 6644 "repos_url": "r" 6645 }, 6646 "installation": { 6647 "id": 1, 6648 "node_id": "nid", 6649 "app_id": 1, 6650 "app_slug": "as", 6651 "target_id": 1, 6652 "account": { 6653 "login": "l", 6654 "id": 1, 6655 "avatar_url": "a", 6656 "gravatar_id": "g", 6657 "name": "n", 6658 "company": "c", 6659 "blog": "b", 6660 "location": "l", 6661 "email": "e", 6662 "hireable": true, 6663 "bio": "b", 6664 "twitter_username": "t", 6665 "public_repos": 1, 6666 "followers": 1, 6667 "following": 1, 6668 "created_at": ` + referenceTimeStr + `, 6669 "suspended_at": ` + referenceTimeStr + `, 6670 "url": "u" 6671 }, 6672 "access_tokens_url": "atu", 6673 "repositories_url": "ru", 6674 "html_url": "hu", 6675 "target_type": "tt", 6676 "single_file_name": "sfn", 6677 "repository_selection": "rs", 6678 "events": [ 6679 "e" 6680 ], 6681 "single_file_paths": [ 6682 "s" 6683 ], 6684 "permissions": { 6685 "actions": "a", 6686 "administration": "ad", 6687 "checks": "c", 6688 "contents": "co", 6689 "content_references": "cr", 6690 "deployments": "d", 6691 "environments": "e", 6692 "issues": "i", 6693 "metadata": "md", 6694 "members": "m", 6695 "organization_administration": "oa", 6696 "organization_hooks": "oh", 6697 "organization_plan": "op", 6698 "organization_pre_receive_hooks": "opr", 6699 "organization_projects": "op", 6700 "organization_secrets": "os", 6701 "organization_self_hosted_runners": "osh", 6702 "organization_user_blocking": "oub", 6703 "packages": "pkg", 6704 "pages": "pg", 6705 "pull_requests": "pr", 6706 "repository_hooks": "rh", 6707 "repository_projects": "rp", 6708 "repository_pre_receive_hooks": "rprh", 6709 "secrets": "s", 6710 "secret_scanning_alerts": "ssa", 6711 "security_events": "se", 6712 "single_file": "sf", 6713 "statuses": "s", 6714 "team_discussions": "td", 6715 "vulnerability_alerts": "va", 6716 "workflows": "w" 6717 }, 6718 "created_at": ` + referenceTimeStr + `, 6719 "updated_at": ` + referenceTimeStr + `, 6720 "has_multiple_single_files": false, 6721 "suspended_by": { 6722 "login": "l", 6723 "id": 1, 6724 "avatar_url": "a", 6725 "gravatar_id": "g", 6726 "name": "n", 6727 "company": "c", 6728 "blog": "b", 6729 "location": "l", 6730 "email": "e", 6731 "hireable": true, 6732 "bio": "b", 6733 "twitter_username": "t", 6734 "public_repos": 1, 6735 "followers": 1, 6736 "following": 1, 6737 "created_at": ` + referenceTimeStr + `, 6738 "suspended_at": ` + referenceTimeStr + `, 6739 "url": "u" 6740 }, 6741 "suspended_at": ` + referenceTimeStr + ` 6742 } 6743 }` 6744 6745 testJSONMarshal(t, u, want) 6746 } 6747 6748 func TestRepositoryImportEvent_Marshal(t *testing.T) { 6749 testJSONMarshal(t, &RepositoryImportEvent{}, "{}") 6750 6751 u := &RepositoryImportEvent{ 6752 Status: String("success"), 6753 Repo: &Repository{ 6754 ID: Int64(1), 6755 URL: String("s"), 6756 Name: String("n"), 6757 }, 6758 Org: &Organization{ 6759 BillingEmail: String("be"), 6760 Blog: String("b"), 6761 Company: String("c"), 6762 Email: String("e"), 6763 TwitterUsername: String("tu"), 6764 Location: String("loc"), 6765 Name: String("n"), 6766 Description: String("d"), 6767 IsVerified: Bool(true), 6768 HasOrganizationProjects: Bool(true), 6769 HasRepositoryProjects: Bool(true), 6770 DefaultRepoPermission: String("drp"), 6771 MembersCanCreateRepos: Bool(true), 6772 MembersCanCreateInternalRepos: Bool(true), 6773 MembersCanCreatePrivateRepos: Bool(true), 6774 MembersCanCreatePublicRepos: Bool(false), 6775 MembersAllowedRepositoryCreationType: String("marct"), 6776 MembersCanCreatePages: Bool(true), 6777 MembersCanCreatePublicPages: Bool(false), 6778 MembersCanCreatePrivatePages: Bool(true), 6779 }, 6780 Sender: &User{ 6781 Login: String("l"), 6782 ID: Int64(1), 6783 NodeID: String("n"), 6784 URL: String("u"), 6785 ReposURL: String("r"), 6786 EventsURL: String("e"), 6787 AvatarURL: String("a"), 6788 }, 6789 } 6790 6791 want := `{ 6792 "status": "success", 6793 "repository": { 6794 "id": 1, 6795 "name": "n", 6796 "url": "s" 6797 }, 6798 "organization": { 6799 "name": "n", 6800 "company": "c", 6801 "blog": "b", 6802 "location": "loc", 6803 "email": "e", 6804 "twitter_username": "tu", 6805 "description": "d", 6806 "billing_email": "be", 6807 "is_verified": true, 6808 "has_organization_projects": true, 6809 "has_repository_projects": true, 6810 "default_repository_permission": "drp", 6811 "members_can_create_repositories": true, 6812 "members_can_create_public_repositories": false, 6813 "members_can_create_private_repositories": true, 6814 "members_can_create_internal_repositories": true, 6815 "members_allowed_repository_creation_type": "marct", 6816 "members_can_create_pages": true, 6817 "members_can_create_public_pages": false, 6818 "members_can_create_private_pages": true 6819 }, 6820 "sender": { 6821 "login": "l", 6822 "id": 1, 6823 "node_id": "n", 6824 "avatar_url": "a", 6825 "url": "u", 6826 "events_url": "e", 6827 "repos_url": "r" 6828 } 6829 }` 6830 6831 testJSONMarshal(t, u, want) 6832 } 6833 6834 func TestRepositoryEvent_Marshal(t *testing.T) { 6835 testJSONMarshal(t, &RepositoryEvent{}, "{}") 6836 6837 u := &RepositoryEvent{ 6838 Action: String("a"), 6839 Repo: &Repository{ 6840 ID: Int64(1), 6841 URL: String("s"), 6842 Name: String("n"), 6843 }, 6844 Org: &Organization{ 6845 BillingEmail: String("be"), 6846 Blog: String("b"), 6847 Company: String("c"), 6848 Email: String("e"), 6849 TwitterUsername: String("tu"), 6850 Location: String("loc"), 6851 Name: String("n"), 6852 Description: String("d"), 6853 IsVerified: Bool(true), 6854 HasOrganizationProjects: Bool(true), 6855 HasRepositoryProjects: Bool(true), 6856 DefaultRepoPermission: String("drp"), 6857 MembersCanCreateRepos: Bool(true), 6858 MembersCanCreateInternalRepos: Bool(true), 6859 MembersCanCreatePrivateRepos: Bool(true), 6860 MembersCanCreatePublicRepos: Bool(false), 6861 MembersAllowedRepositoryCreationType: String("marct"), 6862 MembersCanCreatePages: Bool(true), 6863 MembersCanCreatePublicPages: Bool(false), 6864 MembersCanCreatePrivatePages: Bool(true), 6865 }, 6866 Sender: &User{ 6867 Login: String("l"), 6868 ID: Int64(1), 6869 NodeID: String("n"), 6870 URL: String("u"), 6871 ReposURL: String("r"), 6872 EventsURL: String("e"), 6873 AvatarURL: String("a"), 6874 }, 6875 Installation: &Installation{ 6876 ID: Int64(1), 6877 NodeID: String("nid"), 6878 AppID: Int64(1), 6879 AppSlug: String("as"), 6880 TargetID: Int64(1), 6881 Account: &User{ 6882 Login: String("l"), 6883 ID: Int64(1), 6884 URL: String("u"), 6885 AvatarURL: String("a"), 6886 GravatarID: String("g"), 6887 Name: String("n"), 6888 Company: String("c"), 6889 Blog: String("b"), 6890 Location: String("l"), 6891 Email: String("e"), 6892 Hireable: Bool(true), 6893 Bio: String("b"), 6894 TwitterUsername: String("t"), 6895 PublicRepos: Int(1), 6896 Followers: Int(1), 6897 Following: Int(1), 6898 CreatedAt: &Timestamp{referenceTime}, 6899 SuspendedAt: &Timestamp{referenceTime}, 6900 }, 6901 AccessTokensURL: String("atu"), 6902 RepositoriesURL: String("ru"), 6903 HTMLURL: String("hu"), 6904 TargetType: String("tt"), 6905 SingleFileName: String("sfn"), 6906 RepositorySelection: String("rs"), 6907 Events: []string{"e"}, 6908 SingleFilePaths: []string{"s"}, 6909 Permissions: &InstallationPermissions{ 6910 Actions: String("a"), 6911 Administration: String("ad"), 6912 Checks: String("c"), 6913 Contents: String("co"), 6914 ContentReferences: String("cr"), 6915 Deployments: String("d"), 6916 Environments: String("e"), 6917 Issues: String("i"), 6918 Metadata: String("md"), 6919 Members: String("m"), 6920 OrganizationAdministration: String("oa"), 6921 OrganizationHooks: String("oh"), 6922 OrganizationPlan: String("op"), 6923 OrganizationPreReceiveHooks: String("opr"), 6924 OrganizationProjects: String("op"), 6925 OrganizationSecrets: String("os"), 6926 OrganizationSelfHostedRunners: String("osh"), 6927 OrganizationUserBlocking: String("oub"), 6928 Packages: String("pkg"), 6929 Pages: String("pg"), 6930 PullRequests: String("pr"), 6931 RepositoryHooks: String("rh"), 6932 RepositoryProjects: String("rp"), 6933 RepositoryPreReceiveHooks: String("rprh"), 6934 Secrets: String("s"), 6935 SecretScanningAlerts: String("ssa"), 6936 SecurityEvents: String("se"), 6937 SingleFile: String("sf"), 6938 Statuses: String("s"), 6939 TeamDiscussions: String("td"), 6940 VulnerabilityAlerts: String("va"), 6941 Workflows: String("w"), 6942 }, 6943 CreatedAt: &Timestamp{referenceTime}, 6944 UpdatedAt: &Timestamp{referenceTime}, 6945 HasMultipleSingleFiles: Bool(false), 6946 SuspendedBy: &User{ 6947 Login: String("l"), 6948 ID: Int64(1), 6949 URL: String("u"), 6950 AvatarURL: String("a"), 6951 GravatarID: String("g"), 6952 Name: String("n"), 6953 Company: String("c"), 6954 Blog: String("b"), 6955 Location: String("l"), 6956 Email: String("e"), 6957 Hireable: Bool(true), 6958 Bio: String("b"), 6959 TwitterUsername: String("t"), 6960 PublicRepos: Int(1), 6961 Followers: Int(1), 6962 Following: Int(1), 6963 CreatedAt: &Timestamp{referenceTime}, 6964 SuspendedAt: &Timestamp{referenceTime}, 6965 }, 6966 SuspendedAt: &Timestamp{referenceTime}, 6967 }, 6968 } 6969 6970 want := `{ 6971 "action": "a", 6972 "repository": { 6973 "id": 1, 6974 "name": "n", 6975 "url": "s" 6976 }, 6977 "organization": { 6978 "name": "n", 6979 "company": "c", 6980 "blog": "b", 6981 "location": "loc", 6982 "email": "e", 6983 "twitter_username": "tu", 6984 "description": "d", 6985 "billing_email": "be", 6986 "is_verified": true, 6987 "has_organization_projects": true, 6988 "has_repository_projects": true, 6989 "default_repository_permission": "drp", 6990 "members_can_create_repositories": true, 6991 "members_can_create_public_repositories": false, 6992 "members_can_create_private_repositories": true, 6993 "members_can_create_internal_repositories": true, 6994 "members_allowed_repository_creation_type": "marct", 6995 "members_can_create_pages": true, 6996 "members_can_create_public_pages": false, 6997 "members_can_create_private_pages": true 6998 }, 6999 "sender": { 7000 "login": "l", 7001 "id": 1, 7002 "node_id": "n", 7003 "avatar_url": "a", 7004 "url": "u", 7005 "events_url": "e", 7006 "repos_url": "r" 7007 }, 7008 "installation": { 7009 "id": 1, 7010 "node_id": "nid", 7011 "app_id": 1, 7012 "app_slug": "as", 7013 "target_id": 1, 7014 "account": { 7015 "login": "l", 7016 "id": 1, 7017 "avatar_url": "a", 7018 "gravatar_id": "g", 7019 "name": "n", 7020 "company": "c", 7021 "blog": "b", 7022 "location": "l", 7023 "email": "e", 7024 "hireable": true, 7025 "bio": "b", 7026 "twitter_username": "t", 7027 "public_repos": 1, 7028 "followers": 1, 7029 "following": 1, 7030 "created_at": ` + referenceTimeStr + `, 7031 "suspended_at": ` + referenceTimeStr + `, 7032 "url": "u" 7033 }, 7034 "access_tokens_url": "atu", 7035 "repositories_url": "ru", 7036 "html_url": "hu", 7037 "target_type": "tt", 7038 "single_file_name": "sfn", 7039 "repository_selection": "rs", 7040 "events": [ 7041 "e" 7042 ], 7043 "single_file_paths": [ 7044 "s" 7045 ], 7046 "permissions": { 7047 "actions": "a", 7048 "administration": "ad", 7049 "checks": "c", 7050 "contents": "co", 7051 "content_references": "cr", 7052 "deployments": "d", 7053 "environments": "e", 7054 "issues": "i", 7055 "metadata": "md", 7056 "members": "m", 7057 "organization_administration": "oa", 7058 "organization_hooks": "oh", 7059 "organization_plan": "op", 7060 "organization_pre_receive_hooks": "opr", 7061 "organization_projects": "op", 7062 "organization_secrets": "os", 7063 "organization_self_hosted_runners": "osh", 7064 "organization_user_blocking": "oub", 7065 "packages": "pkg", 7066 "pages": "pg", 7067 "pull_requests": "pr", 7068 "repository_hooks": "rh", 7069 "repository_projects": "rp", 7070 "repository_pre_receive_hooks": "rprh", 7071 "secrets": "s", 7072 "secret_scanning_alerts": "ssa", 7073 "security_events": "se", 7074 "single_file": "sf", 7075 "statuses": "s", 7076 "team_discussions": "td", 7077 "vulnerability_alerts": "va", 7078 "workflows": "w" 7079 }, 7080 "created_at": ` + referenceTimeStr + `, 7081 "updated_at": ` + referenceTimeStr + `, 7082 "has_multiple_single_files": false, 7083 "suspended_by": { 7084 "login": "l", 7085 "id": 1, 7086 "avatar_url": "a", 7087 "gravatar_id": "g", 7088 "name": "n", 7089 "company": "c", 7090 "blog": "b", 7091 "location": "l", 7092 "email": "e", 7093 "hireable": true, 7094 "bio": "b", 7095 "twitter_username": "t", 7096 "public_repos": 1, 7097 "followers": 1, 7098 "following": 1, 7099 "created_at": ` + referenceTimeStr + `, 7100 "suspended_at": ` + referenceTimeStr + `, 7101 "url": "u" 7102 }, 7103 "suspended_at": ` + referenceTimeStr + ` 7104 } 7105 }` 7106 7107 testJSONMarshal(t, u, want) 7108 } 7109 7110 func TestReleaseEvent_Marshal(t *testing.T) { 7111 testJSONMarshal(t, &ReleaseEvent{}, "{}") 7112 7113 u := &ReleaseEvent{ 7114 Action: String("a"), 7115 Release: &RepositoryRelease{ 7116 Name: String("n"), 7117 DiscussionCategoryName: String("dcn"), 7118 ID: Int64(2), 7119 CreatedAt: &Timestamp{referenceTime}, 7120 PublishedAt: &Timestamp{referenceTime}, 7121 URL: String("url"), 7122 HTMLURL: String("htmlurl"), 7123 AssetsURL: String("assetsurl"), 7124 Assets: []*ReleaseAsset{{ID: Int64(1)}}, 7125 UploadURL: String("uploadurl"), 7126 ZipballURL: String("zipballurl"), 7127 TarballURL: String("tarballurl"), 7128 Author: &User{Name: String("octocat")}, 7129 NodeID: String("nid"), 7130 }, 7131 Repo: &Repository{ 7132 ID: Int64(1), 7133 URL: String("s"), 7134 Name: String("n"), 7135 }, 7136 Sender: &User{ 7137 Login: String("l"), 7138 ID: Int64(1), 7139 NodeID: String("n"), 7140 URL: String("u"), 7141 ReposURL: String("r"), 7142 EventsURL: String("e"), 7143 AvatarURL: String("a"), 7144 }, 7145 Installation: &Installation{ 7146 ID: Int64(1), 7147 NodeID: String("nid"), 7148 AppID: Int64(1), 7149 AppSlug: String("as"), 7150 TargetID: Int64(1), 7151 Account: &User{ 7152 Login: String("l"), 7153 ID: Int64(1), 7154 URL: String("u"), 7155 AvatarURL: String("a"), 7156 GravatarID: String("g"), 7157 Name: String("n"), 7158 Company: String("c"), 7159 Blog: String("b"), 7160 Location: String("l"), 7161 Email: String("e"), 7162 Hireable: Bool(true), 7163 Bio: String("b"), 7164 TwitterUsername: String("t"), 7165 PublicRepos: Int(1), 7166 Followers: Int(1), 7167 Following: Int(1), 7168 CreatedAt: &Timestamp{referenceTime}, 7169 SuspendedAt: &Timestamp{referenceTime}, 7170 }, 7171 AccessTokensURL: String("atu"), 7172 RepositoriesURL: String("ru"), 7173 HTMLURL: String("hu"), 7174 TargetType: String("tt"), 7175 SingleFileName: String("sfn"), 7176 RepositorySelection: String("rs"), 7177 Events: []string{"e"}, 7178 SingleFilePaths: []string{"s"}, 7179 Permissions: &InstallationPermissions{ 7180 Actions: String("a"), 7181 Administration: String("ad"), 7182 Checks: String("c"), 7183 Contents: String("co"), 7184 ContentReferences: String("cr"), 7185 Deployments: String("d"), 7186 Environments: String("e"), 7187 Issues: String("i"), 7188 Metadata: String("md"), 7189 Members: String("m"), 7190 OrganizationAdministration: String("oa"), 7191 OrganizationHooks: String("oh"), 7192 OrganizationPlan: String("op"), 7193 OrganizationPreReceiveHooks: String("opr"), 7194 OrganizationProjects: String("op"), 7195 OrganizationSecrets: String("os"), 7196 OrganizationSelfHostedRunners: String("osh"), 7197 OrganizationUserBlocking: String("oub"), 7198 Packages: String("pkg"), 7199 Pages: String("pg"), 7200 PullRequests: String("pr"), 7201 RepositoryHooks: String("rh"), 7202 RepositoryProjects: String("rp"), 7203 RepositoryPreReceiveHooks: String("rprh"), 7204 Secrets: String("s"), 7205 SecretScanningAlerts: String("ssa"), 7206 SecurityEvents: String("se"), 7207 SingleFile: String("sf"), 7208 Statuses: String("s"), 7209 TeamDiscussions: String("td"), 7210 VulnerabilityAlerts: String("va"), 7211 Workflows: String("w"), 7212 }, 7213 CreatedAt: &Timestamp{referenceTime}, 7214 UpdatedAt: &Timestamp{referenceTime}, 7215 HasMultipleSingleFiles: Bool(false), 7216 SuspendedBy: &User{ 7217 Login: String("l"), 7218 ID: Int64(1), 7219 URL: String("u"), 7220 AvatarURL: String("a"), 7221 GravatarID: String("g"), 7222 Name: String("n"), 7223 Company: String("c"), 7224 Blog: String("b"), 7225 Location: String("l"), 7226 Email: String("e"), 7227 Hireable: Bool(true), 7228 Bio: String("b"), 7229 TwitterUsername: String("t"), 7230 PublicRepos: Int(1), 7231 Followers: Int(1), 7232 Following: Int(1), 7233 CreatedAt: &Timestamp{referenceTime}, 7234 SuspendedAt: &Timestamp{referenceTime}, 7235 }, 7236 SuspendedAt: &Timestamp{referenceTime}, 7237 }, 7238 } 7239 7240 want := `{ 7241 "action": "a", 7242 "release": { 7243 "name": "n", 7244 "discussion_category_name": "dcn", 7245 "id": 2, 7246 "created_at": ` + referenceTimeStr + `, 7247 "published_at": ` + referenceTimeStr + `, 7248 "url": "url", 7249 "html_url": "htmlurl", 7250 "assets_url": "assetsurl", 7251 "assets": [ 7252 { 7253 "id": 1 7254 } 7255 ], 7256 "upload_url": "uploadurl", 7257 "zipball_url": "zipballurl", 7258 "tarball_url": "tarballurl", 7259 "author": { 7260 "name": "octocat" 7261 }, 7262 "node_id": "nid" 7263 }, 7264 "repository": { 7265 "id": 1, 7266 "name": "n", 7267 "url": "s" 7268 }, 7269 "sender": { 7270 "login": "l", 7271 "id": 1, 7272 "node_id": "n", 7273 "avatar_url": "a", 7274 "url": "u", 7275 "events_url": "e", 7276 "repos_url": "r" 7277 }, 7278 "installation": { 7279 "id": 1, 7280 "node_id": "nid", 7281 "app_id": 1, 7282 "app_slug": "as", 7283 "target_id": 1, 7284 "account": { 7285 "login": "l", 7286 "id": 1, 7287 "avatar_url": "a", 7288 "gravatar_id": "g", 7289 "name": "n", 7290 "company": "c", 7291 "blog": "b", 7292 "location": "l", 7293 "email": "e", 7294 "hireable": true, 7295 "bio": "b", 7296 "twitter_username": "t", 7297 "public_repos": 1, 7298 "followers": 1, 7299 "following": 1, 7300 "created_at": ` + referenceTimeStr + `, 7301 "suspended_at": ` + referenceTimeStr + `, 7302 "url": "u" 7303 }, 7304 "access_tokens_url": "atu", 7305 "repositories_url": "ru", 7306 "html_url": "hu", 7307 "target_type": "tt", 7308 "single_file_name": "sfn", 7309 "repository_selection": "rs", 7310 "events": [ 7311 "e" 7312 ], 7313 "single_file_paths": [ 7314 "s" 7315 ], 7316 "permissions": { 7317 "actions": "a", 7318 "administration": "ad", 7319 "checks": "c", 7320 "contents": "co", 7321 "content_references": "cr", 7322 "deployments": "d", 7323 "environments": "e", 7324 "issues": "i", 7325 "metadata": "md", 7326 "members": "m", 7327 "organization_administration": "oa", 7328 "organization_hooks": "oh", 7329 "organization_plan": "op", 7330 "organization_pre_receive_hooks": "opr", 7331 "organization_projects": "op", 7332 "organization_secrets": "os", 7333 "organization_self_hosted_runners": "osh", 7334 "organization_user_blocking": "oub", 7335 "packages": "pkg", 7336 "pages": "pg", 7337 "pull_requests": "pr", 7338 "repository_hooks": "rh", 7339 "repository_projects": "rp", 7340 "repository_pre_receive_hooks": "rprh", 7341 "secrets": "s", 7342 "secret_scanning_alerts": "ssa", 7343 "security_events": "se", 7344 "single_file": "sf", 7345 "statuses": "s", 7346 "team_discussions": "td", 7347 "vulnerability_alerts": "va", 7348 "workflows": "w" 7349 }, 7350 "created_at": ` + referenceTimeStr + `, 7351 "updated_at": ` + referenceTimeStr + `, 7352 "has_multiple_single_files": false, 7353 "suspended_by": { 7354 "login": "l", 7355 "id": 1, 7356 "avatar_url": "a", 7357 "gravatar_id": "g", 7358 "name": "n", 7359 "company": "c", 7360 "blog": "b", 7361 "location": "l", 7362 "email": "e", 7363 "hireable": true, 7364 "bio": "b", 7365 "twitter_username": "t", 7366 "public_repos": 1, 7367 "followers": 1, 7368 "following": 1, 7369 "created_at": ` + referenceTimeStr + `, 7370 "suspended_at": ` + referenceTimeStr + `, 7371 "url": "u" 7372 }, 7373 "suspended_at": ` + referenceTimeStr + ` 7374 } 7375 }` 7376 7377 testJSONMarshal(t, u, want) 7378 } 7379 7380 func TestContentReferenceEvent_Marshal(t *testing.T) { 7381 testJSONMarshal(t, &ContentReferenceEvent{}, "{}") 7382 7383 u := &ContentReferenceEvent{ 7384 Action: String("a"), 7385 ContentReference: &ContentReference{ 7386 ID: Int64(1), 7387 NodeID: String("nid"), 7388 Reference: String("ref"), 7389 }, 7390 Repo: &Repository{ 7391 ID: Int64(1), 7392 URL: String("s"), 7393 Name: String("n"), 7394 }, 7395 Sender: &User{ 7396 Login: String("l"), 7397 ID: Int64(1), 7398 NodeID: String("n"), 7399 URL: String("u"), 7400 ReposURL: String("r"), 7401 EventsURL: String("e"), 7402 AvatarURL: String("a"), 7403 }, 7404 Installation: &Installation{ 7405 ID: Int64(1), 7406 NodeID: String("nid"), 7407 AppID: Int64(1), 7408 AppSlug: String("as"), 7409 TargetID: Int64(1), 7410 Account: &User{ 7411 Login: String("l"), 7412 ID: Int64(1), 7413 URL: String("u"), 7414 AvatarURL: String("a"), 7415 GravatarID: String("g"), 7416 Name: String("n"), 7417 Company: String("c"), 7418 Blog: String("b"), 7419 Location: String("l"), 7420 Email: String("e"), 7421 Hireable: Bool(true), 7422 Bio: String("b"), 7423 TwitterUsername: String("t"), 7424 PublicRepos: Int(1), 7425 Followers: Int(1), 7426 Following: Int(1), 7427 CreatedAt: &Timestamp{referenceTime}, 7428 SuspendedAt: &Timestamp{referenceTime}, 7429 }, 7430 AccessTokensURL: String("atu"), 7431 RepositoriesURL: String("ru"), 7432 HTMLURL: String("hu"), 7433 TargetType: String("tt"), 7434 SingleFileName: String("sfn"), 7435 RepositorySelection: String("rs"), 7436 Events: []string{"e"}, 7437 SingleFilePaths: []string{"s"}, 7438 Permissions: &InstallationPermissions{ 7439 Actions: String("a"), 7440 Administration: String("ad"), 7441 Checks: String("c"), 7442 Contents: String("co"), 7443 ContentReferences: String("cr"), 7444 Deployments: String("d"), 7445 Environments: String("e"), 7446 Issues: String("i"), 7447 Metadata: String("md"), 7448 Members: String("m"), 7449 OrganizationAdministration: String("oa"), 7450 OrganizationHooks: String("oh"), 7451 OrganizationPlan: String("op"), 7452 OrganizationPreReceiveHooks: String("opr"), 7453 OrganizationProjects: String("op"), 7454 OrganizationSecrets: String("os"), 7455 OrganizationSelfHostedRunners: String("osh"), 7456 OrganizationUserBlocking: String("oub"), 7457 Packages: String("pkg"), 7458 Pages: String("pg"), 7459 PullRequests: String("pr"), 7460 RepositoryHooks: String("rh"), 7461 RepositoryProjects: String("rp"), 7462 RepositoryPreReceiveHooks: String("rprh"), 7463 Secrets: String("s"), 7464 SecretScanningAlerts: String("ssa"), 7465 SecurityEvents: String("se"), 7466 SingleFile: String("sf"), 7467 Statuses: String("s"), 7468 TeamDiscussions: String("td"), 7469 VulnerabilityAlerts: String("va"), 7470 Workflows: String("w"), 7471 }, 7472 CreatedAt: &Timestamp{referenceTime}, 7473 UpdatedAt: &Timestamp{referenceTime}, 7474 HasMultipleSingleFiles: Bool(false), 7475 SuspendedBy: &User{ 7476 Login: String("l"), 7477 ID: Int64(1), 7478 URL: String("u"), 7479 AvatarURL: String("a"), 7480 GravatarID: String("g"), 7481 Name: String("n"), 7482 Company: String("c"), 7483 Blog: String("b"), 7484 Location: String("l"), 7485 Email: String("e"), 7486 Hireable: Bool(true), 7487 Bio: String("b"), 7488 TwitterUsername: String("t"), 7489 PublicRepos: Int(1), 7490 Followers: Int(1), 7491 Following: Int(1), 7492 CreatedAt: &Timestamp{referenceTime}, 7493 SuspendedAt: &Timestamp{referenceTime}, 7494 }, 7495 SuspendedAt: &Timestamp{referenceTime}, 7496 }, 7497 } 7498 7499 want := `{ 7500 "action": "a", 7501 "content_reference": { 7502 "id": 1, 7503 "node_id": "nid", 7504 "reference": "ref" 7505 }, 7506 "repository": { 7507 "id": 1, 7508 "name": "n", 7509 "url": "s" 7510 }, 7511 "sender": { 7512 "login": "l", 7513 "id": 1, 7514 "node_id": "n", 7515 "avatar_url": "a", 7516 "url": "u", 7517 "events_url": "e", 7518 "repos_url": "r" 7519 }, 7520 "installation": { 7521 "id": 1, 7522 "node_id": "nid", 7523 "app_id": 1, 7524 "app_slug": "as", 7525 "target_id": 1, 7526 "account": { 7527 "login": "l", 7528 "id": 1, 7529 "avatar_url": "a", 7530 "gravatar_id": "g", 7531 "name": "n", 7532 "company": "c", 7533 "blog": "b", 7534 "location": "l", 7535 "email": "e", 7536 "hireable": true, 7537 "bio": "b", 7538 "twitter_username": "t", 7539 "public_repos": 1, 7540 "followers": 1, 7541 "following": 1, 7542 "created_at": ` + referenceTimeStr + `, 7543 "suspended_at": ` + referenceTimeStr + `, 7544 "url": "u" 7545 }, 7546 "access_tokens_url": "atu", 7547 "repositories_url": "ru", 7548 "html_url": "hu", 7549 "target_type": "tt", 7550 "single_file_name": "sfn", 7551 "repository_selection": "rs", 7552 "events": [ 7553 "e" 7554 ], 7555 "single_file_paths": [ 7556 "s" 7557 ], 7558 "permissions": { 7559 "actions": "a", 7560 "administration": "ad", 7561 "checks": "c", 7562 "contents": "co", 7563 "content_references": "cr", 7564 "deployments": "d", 7565 "environments": "e", 7566 "issues": "i", 7567 "metadata": "md", 7568 "members": "m", 7569 "organization_administration": "oa", 7570 "organization_hooks": "oh", 7571 "organization_plan": "op", 7572 "organization_pre_receive_hooks": "opr", 7573 "organization_projects": "op", 7574 "organization_secrets": "os", 7575 "organization_self_hosted_runners": "osh", 7576 "organization_user_blocking": "oub", 7577 "packages": "pkg", 7578 "pages": "pg", 7579 "pull_requests": "pr", 7580 "repository_hooks": "rh", 7581 "repository_projects": "rp", 7582 "repository_pre_receive_hooks": "rprh", 7583 "secrets": "s", 7584 "secret_scanning_alerts": "ssa", 7585 "security_events": "se", 7586 "single_file": "sf", 7587 "statuses": "s", 7588 "team_discussions": "td", 7589 "vulnerability_alerts": "va", 7590 "workflows": "w" 7591 }, 7592 "created_at": ` + referenceTimeStr + `, 7593 "updated_at": ` + referenceTimeStr + `, 7594 "has_multiple_single_files": false, 7595 "suspended_by": { 7596 "login": "l", 7597 "id": 1, 7598 "avatar_url": "a", 7599 "gravatar_id": "g", 7600 "name": "n", 7601 "company": "c", 7602 "blog": "b", 7603 "location": "l", 7604 "email": "e", 7605 "hireable": true, 7606 "bio": "b", 7607 "twitter_username": "t", 7608 "public_repos": 1, 7609 "followers": 1, 7610 "following": 1, 7611 "created_at": ` + referenceTimeStr + `, 7612 "suspended_at": ` + referenceTimeStr + `, 7613 "url": "u" 7614 }, 7615 "suspended_at": ` + referenceTimeStr + ` 7616 } 7617 }` 7618 7619 testJSONMarshal(t, u, want) 7620 } 7621 7622 func TestMemberEvent_Marshal(t *testing.T) { 7623 testJSONMarshal(t, &MemberEvent{}, "{}") 7624 7625 u := &MemberEvent{ 7626 Action: String("a"), 7627 Member: &User{ 7628 Login: String("l"), 7629 ID: Int64(1), 7630 NodeID: String("n"), 7631 URL: String("u"), 7632 ReposURL: String("r"), 7633 EventsURL: String("e"), 7634 AvatarURL: String("a"), 7635 }, 7636 Repo: &Repository{ 7637 ID: Int64(1), 7638 URL: String("s"), 7639 Name: String("n"), 7640 }, 7641 Sender: &User{ 7642 Login: String("l"), 7643 ID: Int64(1), 7644 NodeID: String("n"), 7645 URL: String("u"), 7646 ReposURL: String("r"), 7647 EventsURL: String("e"), 7648 AvatarURL: String("a"), 7649 }, 7650 Installation: &Installation{ 7651 ID: Int64(1), 7652 NodeID: String("nid"), 7653 AppID: Int64(1), 7654 AppSlug: String("as"), 7655 TargetID: Int64(1), 7656 Account: &User{ 7657 Login: String("l"), 7658 ID: Int64(1), 7659 URL: String("u"), 7660 AvatarURL: String("a"), 7661 GravatarID: String("g"), 7662 Name: String("n"), 7663 Company: String("c"), 7664 Blog: String("b"), 7665 Location: String("l"), 7666 Email: String("e"), 7667 Hireable: Bool(true), 7668 Bio: String("b"), 7669 TwitterUsername: String("t"), 7670 PublicRepos: Int(1), 7671 Followers: Int(1), 7672 Following: Int(1), 7673 CreatedAt: &Timestamp{referenceTime}, 7674 SuspendedAt: &Timestamp{referenceTime}, 7675 }, 7676 AccessTokensURL: String("atu"), 7677 RepositoriesURL: String("ru"), 7678 HTMLURL: String("hu"), 7679 TargetType: String("tt"), 7680 SingleFileName: String("sfn"), 7681 RepositorySelection: String("rs"), 7682 Events: []string{"e"}, 7683 SingleFilePaths: []string{"s"}, 7684 Permissions: &InstallationPermissions{ 7685 Actions: String("a"), 7686 Administration: String("ad"), 7687 Checks: String("c"), 7688 Contents: String("co"), 7689 ContentReferences: String("cr"), 7690 Deployments: String("d"), 7691 Environments: String("e"), 7692 Issues: String("i"), 7693 Metadata: String("md"), 7694 Members: String("m"), 7695 OrganizationAdministration: String("oa"), 7696 OrganizationHooks: String("oh"), 7697 OrganizationPlan: String("op"), 7698 OrganizationPreReceiveHooks: String("opr"), 7699 OrganizationProjects: String("op"), 7700 OrganizationSecrets: String("os"), 7701 OrganizationSelfHostedRunners: String("osh"), 7702 OrganizationUserBlocking: String("oub"), 7703 Packages: String("pkg"), 7704 Pages: String("pg"), 7705 PullRequests: String("pr"), 7706 RepositoryHooks: String("rh"), 7707 RepositoryProjects: String("rp"), 7708 RepositoryPreReceiveHooks: String("rprh"), 7709 Secrets: String("s"), 7710 SecretScanningAlerts: String("ssa"), 7711 SecurityEvents: String("se"), 7712 SingleFile: String("sf"), 7713 Statuses: String("s"), 7714 TeamDiscussions: String("td"), 7715 VulnerabilityAlerts: String("va"), 7716 Workflows: String("w"), 7717 }, 7718 CreatedAt: &Timestamp{referenceTime}, 7719 UpdatedAt: &Timestamp{referenceTime}, 7720 HasMultipleSingleFiles: Bool(false), 7721 SuspendedBy: &User{ 7722 Login: String("l"), 7723 ID: Int64(1), 7724 URL: String("u"), 7725 AvatarURL: String("a"), 7726 GravatarID: String("g"), 7727 Name: String("n"), 7728 Company: String("c"), 7729 Blog: String("b"), 7730 Location: String("l"), 7731 Email: String("e"), 7732 Hireable: Bool(true), 7733 Bio: String("b"), 7734 TwitterUsername: String("t"), 7735 PublicRepos: Int(1), 7736 Followers: Int(1), 7737 Following: Int(1), 7738 CreatedAt: &Timestamp{referenceTime}, 7739 SuspendedAt: &Timestamp{referenceTime}, 7740 }, 7741 SuspendedAt: &Timestamp{referenceTime}, 7742 }, 7743 } 7744 7745 want := `{ 7746 "action": "a", 7747 "member": { 7748 "login": "l", 7749 "id": 1, 7750 "node_id": "n", 7751 "avatar_url": "a", 7752 "url": "u", 7753 "events_url": "e", 7754 "repos_url": "r" 7755 }, 7756 "repository": { 7757 "id": 1, 7758 "name": "n", 7759 "url": "s" 7760 }, 7761 "sender": { 7762 "login": "l", 7763 "id": 1, 7764 "node_id": "n", 7765 "avatar_url": "a", 7766 "url": "u", 7767 "events_url": "e", 7768 "repos_url": "r" 7769 }, 7770 "installation": { 7771 "id": 1, 7772 "node_id": "nid", 7773 "app_id": 1, 7774 "app_slug": "as", 7775 "target_id": 1, 7776 "account": { 7777 "login": "l", 7778 "id": 1, 7779 "avatar_url": "a", 7780 "gravatar_id": "g", 7781 "name": "n", 7782 "company": "c", 7783 "blog": "b", 7784 "location": "l", 7785 "email": "e", 7786 "hireable": true, 7787 "bio": "b", 7788 "twitter_username": "t", 7789 "public_repos": 1, 7790 "followers": 1, 7791 "following": 1, 7792 "created_at": ` + referenceTimeStr + `, 7793 "suspended_at": ` + referenceTimeStr + `, 7794 "url": "u" 7795 }, 7796 "access_tokens_url": "atu", 7797 "repositories_url": "ru", 7798 "html_url": "hu", 7799 "target_type": "tt", 7800 "single_file_name": "sfn", 7801 "repository_selection": "rs", 7802 "events": [ 7803 "e" 7804 ], 7805 "single_file_paths": [ 7806 "s" 7807 ], 7808 "permissions": { 7809 "actions": "a", 7810 "administration": "ad", 7811 "checks": "c", 7812 "contents": "co", 7813 "content_references": "cr", 7814 "deployments": "d", 7815 "environments": "e", 7816 "issues": "i", 7817 "metadata": "md", 7818 "members": "m", 7819 "organization_administration": "oa", 7820 "organization_hooks": "oh", 7821 "organization_plan": "op", 7822 "organization_pre_receive_hooks": "opr", 7823 "organization_projects": "op", 7824 "organization_secrets": "os", 7825 "organization_self_hosted_runners": "osh", 7826 "organization_user_blocking": "oub", 7827 "packages": "pkg", 7828 "pages": "pg", 7829 "pull_requests": "pr", 7830 "repository_hooks": "rh", 7831 "repository_projects": "rp", 7832 "repository_pre_receive_hooks": "rprh", 7833 "secrets": "s", 7834 "secret_scanning_alerts": "ssa", 7835 "security_events": "se", 7836 "single_file": "sf", 7837 "statuses": "s", 7838 "team_discussions": "td", 7839 "vulnerability_alerts": "va", 7840 "workflows": "w" 7841 }, 7842 "created_at": ` + referenceTimeStr + `, 7843 "updated_at": ` + referenceTimeStr + `, 7844 "has_multiple_single_files": false, 7845 "suspended_by": { 7846 "login": "l", 7847 "id": 1, 7848 "avatar_url": "a", 7849 "gravatar_id": "g", 7850 "name": "n", 7851 "company": "c", 7852 "blog": "b", 7853 "location": "l", 7854 "email": "e", 7855 "hireable": true, 7856 "bio": "b", 7857 "twitter_username": "t", 7858 "public_repos": 1, 7859 "followers": 1, 7860 "following": 1, 7861 "created_at": ` + referenceTimeStr + `, 7862 "suspended_at": ` + referenceTimeStr + `, 7863 "url": "u" 7864 }, 7865 "suspended_at": ` + referenceTimeStr + ` 7866 } 7867 }` 7868 7869 testJSONMarshal(t, u, want) 7870 } 7871 7872 func TestMembershipEvent_Marshal(t *testing.T) { 7873 testJSONMarshal(t, &MembershipEvent{}, "{}") 7874 7875 u := &MembershipEvent{ 7876 Action: String("a"), 7877 Scope: String("s"), 7878 Member: &User{ 7879 Login: String("l"), 7880 ID: Int64(1), 7881 NodeID: String("n"), 7882 URL: String("u"), 7883 ReposURL: String("r"), 7884 EventsURL: String("e"), 7885 AvatarURL: String("a"), 7886 }, 7887 Team: &Team{ 7888 ID: Int64(1), 7889 NodeID: String("n"), 7890 Name: String("n"), 7891 Description: String("d"), 7892 URL: String("u"), 7893 Slug: String("s"), 7894 Permission: String("p"), 7895 Privacy: String("p"), 7896 MembersCount: Int(1), 7897 ReposCount: Int(1), 7898 MembersURL: String("m"), 7899 RepositoriesURL: String("r"), 7900 Organization: &Organization{ 7901 Login: String("l"), 7902 ID: Int64(1), 7903 NodeID: String("n"), 7904 AvatarURL: String("a"), 7905 HTMLURL: String("h"), 7906 Name: String("n"), 7907 Company: String("c"), 7908 Blog: String("b"), 7909 Location: String("l"), 7910 Email: String("e"), 7911 }, 7912 Parent: &Team{ 7913 ID: Int64(1), 7914 NodeID: String("n"), 7915 Name: String("n"), 7916 Description: String("d"), 7917 URL: String("u"), 7918 Slug: String("s"), 7919 Permission: String("p"), 7920 Privacy: String("p"), 7921 MembersCount: Int(1), 7922 ReposCount: Int(1), 7923 }, 7924 LDAPDN: String("l"), 7925 }, 7926 Org: &Organization{ 7927 BillingEmail: String("be"), 7928 Blog: String("b"), 7929 Company: String("c"), 7930 Email: String("e"), 7931 TwitterUsername: String("tu"), 7932 Location: String("loc"), 7933 Name: String("n"), 7934 Description: String("d"), 7935 IsVerified: Bool(true), 7936 HasOrganizationProjects: Bool(true), 7937 HasRepositoryProjects: Bool(true), 7938 DefaultRepoPermission: String("drp"), 7939 MembersCanCreateRepos: Bool(true), 7940 MembersCanCreateInternalRepos: Bool(true), 7941 MembersCanCreatePrivateRepos: Bool(true), 7942 MembersCanCreatePublicRepos: Bool(false), 7943 MembersAllowedRepositoryCreationType: String("marct"), 7944 MembersCanCreatePages: Bool(true), 7945 MembersCanCreatePublicPages: Bool(false), 7946 MembersCanCreatePrivatePages: Bool(true), 7947 }, 7948 Sender: &User{ 7949 Login: String("l"), 7950 ID: Int64(1), 7951 NodeID: String("n"), 7952 URL: String("u"), 7953 ReposURL: String("r"), 7954 EventsURL: String("e"), 7955 AvatarURL: String("a"), 7956 }, 7957 Installation: &Installation{ 7958 ID: Int64(1), 7959 NodeID: String("nid"), 7960 AppID: Int64(1), 7961 AppSlug: String("as"), 7962 TargetID: Int64(1), 7963 Account: &User{ 7964 Login: String("l"), 7965 ID: Int64(1), 7966 URL: String("u"), 7967 AvatarURL: String("a"), 7968 GravatarID: String("g"), 7969 Name: String("n"), 7970 Company: String("c"), 7971 Blog: String("b"), 7972 Location: String("l"), 7973 Email: String("e"), 7974 Hireable: Bool(true), 7975 Bio: String("b"), 7976 TwitterUsername: String("t"), 7977 PublicRepos: Int(1), 7978 Followers: Int(1), 7979 Following: Int(1), 7980 CreatedAt: &Timestamp{referenceTime}, 7981 SuspendedAt: &Timestamp{referenceTime}, 7982 }, 7983 AccessTokensURL: String("atu"), 7984 RepositoriesURL: String("ru"), 7985 HTMLURL: String("hu"), 7986 TargetType: String("tt"), 7987 SingleFileName: String("sfn"), 7988 RepositorySelection: String("rs"), 7989 Events: []string{"e"}, 7990 SingleFilePaths: []string{"s"}, 7991 Permissions: &InstallationPermissions{ 7992 Actions: String("a"), 7993 Administration: String("ad"), 7994 Checks: String("c"), 7995 Contents: String("co"), 7996 ContentReferences: String("cr"), 7997 Deployments: String("d"), 7998 Environments: String("e"), 7999 Issues: String("i"), 8000 Metadata: String("md"), 8001 Members: String("m"), 8002 OrganizationAdministration: String("oa"), 8003 OrganizationHooks: String("oh"), 8004 OrganizationPlan: String("op"), 8005 OrganizationPreReceiveHooks: String("opr"), 8006 OrganizationProjects: String("op"), 8007 OrganizationSecrets: String("os"), 8008 OrganizationSelfHostedRunners: String("osh"), 8009 OrganizationUserBlocking: String("oub"), 8010 Packages: String("pkg"), 8011 Pages: String("pg"), 8012 PullRequests: String("pr"), 8013 RepositoryHooks: String("rh"), 8014 RepositoryProjects: String("rp"), 8015 RepositoryPreReceiveHooks: String("rprh"), 8016 Secrets: String("s"), 8017 SecretScanningAlerts: String("ssa"), 8018 SecurityEvents: String("se"), 8019 SingleFile: String("sf"), 8020 Statuses: String("s"), 8021 TeamDiscussions: String("td"), 8022 VulnerabilityAlerts: String("va"), 8023 Workflows: String("w"), 8024 }, 8025 CreatedAt: &Timestamp{referenceTime}, 8026 UpdatedAt: &Timestamp{referenceTime}, 8027 HasMultipleSingleFiles: Bool(false), 8028 SuspendedBy: &User{ 8029 Login: String("l"), 8030 ID: Int64(1), 8031 URL: String("u"), 8032 AvatarURL: String("a"), 8033 GravatarID: String("g"), 8034 Name: String("n"), 8035 Company: String("c"), 8036 Blog: String("b"), 8037 Location: String("l"), 8038 Email: String("e"), 8039 Hireable: Bool(true), 8040 Bio: String("b"), 8041 TwitterUsername: String("t"), 8042 PublicRepos: Int(1), 8043 Followers: Int(1), 8044 Following: Int(1), 8045 CreatedAt: &Timestamp{referenceTime}, 8046 SuspendedAt: &Timestamp{referenceTime}, 8047 }, 8048 SuspendedAt: &Timestamp{referenceTime}, 8049 }, 8050 } 8051 8052 want := `{ 8053 "action": "a", 8054 "scope": "s", 8055 "member": { 8056 "login": "l", 8057 "id": 1, 8058 "node_id": "n", 8059 "avatar_url": "a", 8060 "url": "u", 8061 "events_url": "e", 8062 "repos_url": "r" 8063 }, 8064 "team": { 8065 "id": 1, 8066 "node_id": "n", 8067 "name": "n", 8068 "description": "d", 8069 "url": "u", 8070 "slug": "s", 8071 "permission": "p", 8072 "privacy": "p", 8073 "members_count": 1, 8074 "repos_count": 1, 8075 "organization": { 8076 "login": "l", 8077 "id": 1, 8078 "node_id": "n", 8079 "avatar_url": "a", 8080 "html_url": "h", 8081 "name": "n", 8082 "company": "c", 8083 "blog": "b", 8084 "location": "l", 8085 "email": "e" 8086 }, 8087 "members_url": "m", 8088 "repositories_url": "r", 8089 "parent": { 8090 "id": 1, 8091 "node_id": "n", 8092 "name": "n", 8093 "description": "d", 8094 "url": "u", 8095 "slug": "s", 8096 "permission": "p", 8097 "privacy": "p", 8098 "members_count": 1, 8099 "repos_count": 1 8100 }, 8101 "ldap_dn": "l" 8102 }, 8103 "organization": { 8104 "name": "n", 8105 "company": "c", 8106 "blog": "b", 8107 "location": "loc", 8108 "email": "e", 8109 "twitter_username": "tu", 8110 "description": "d", 8111 "billing_email": "be", 8112 "is_verified": true, 8113 "has_organization_projects": true, 8114 "has_repository_projects": true, 8115 "default_repository_permission": "drp", 8116 "members_can_create_repositories": true, 8117 "members_can_create_public_repositories": false, 8118 "members_can_create_private_repositories": true, 8119 "members_can_create_internal_repositories": true, 8120 "members_allowed_repository_creation_type": "marct", 8121 "members_can_create_pages": true, 8122 "members_can_create_public_pages": false, 8123 "members_can_create_private_pages": true 8124 }, 8125 "sender": { 8126 "login": "l", 8127 "id": 1, 8128 "node_id": "n", 8129 "avatar_url": "a", 8130 "url": "u", 8131 "events_url": "e", 8132 "repos_url": "r" 8133 }, 8134 "installation": { 8135 "id": 1, 8136 "node_id": "nid", 8137 "app_id": 1, 8138 "app_slug": "as", 8139 "target_id": 1, 8140 "account": { 8141 "login": "l", 8142 "id": 1, 8143 "avatar_url": "a", 8144 "gravatar_id": "g", 8145 "name": "n", 8146 "company": "c", 8147 "blog": "b", 8148 "location": "l", 8149 "email": "e", 8150 "hireable": true, 8151 "bio": "b", 8152 "twitter_username": "t", 8153 "public_repos": 1, 8154 "followers": 1, 8155 "following": 1, 8156 "created_at": ` + referenceTimeStr + `, 8157 "suspended_at": ` + referenceTimeStr + `, 8158 "url": "u" 8159 }, 8160 "access_tokens_url": "atu", 8161 "repositories_url": "ru", 8162 "html_url": "hu", 8163 "target_type": "tt", 8164 "single_file_name": "sfn", 8165 "repository_selection": "rs", 8166 "events": [ 8167 "e" 8168 ], 8169 "single_file_paths": [ 8170 "s" 8171 ], 8172 "permissions": { 8173 "actions": "a", 8174 "administration": "ad", 8175 "checks": "c", 8176 "contents": "co", 8177 "content_references": "cr", 8178 "deployments": "d", 8179 "environments": "e", 8180 "issues": "i", 8181 "metadata": "md", 8182 "members": "m", 8183 "organization_administration": "oa", 8184 "organization_hooks": "oh", 8185 "organization_plan": "op", 8186 "organization_pre_receive_hooks": "opr", 8187 "organization_projects": "op", 8188 "organization_secrets": "os", 8189 "organization_self_hosted_runners": "osh", 8190 "organization_user_blocking": "oub", 8191 "packages": "pkg", 8192 "pages": "pg", 8193 "pull_requests": "pr", 8194 "repository_hooks": "rh", 8195 "repository_projects": "rp", 8196 "repository_pre_receive_hooks": "rprh", 8197 "secrets": "s", 8198 "secret_scanning_alerts": "ssa", 8199 "security_events": "se", 8200 "single_file": "sf", 8201 "statuses": "s", 8202 "team_discussions": "td", 8203 "vulnerability_alerts": "va", 8204 "workflows": "w" 8205 }, 8206 "created_at": ` + referenceTimeStr + `, 8207 "updated_at": ` + referenceTimeStr + `, 8208 "has_multiple_single_files": false, 8209 "suspended_by": { 8210 "login": "l", 8211 "id": 1, 8212 "avatar_url": "a", 8213 "gravatar_id": "g", 8214 "name": "n", 8215 "company": "c", 8216 "blog": "b", 8217 "location": "l", 8218 "email": "e", 8219 "hireable": true, 8220 "bio": "b", 8221 "twitter_username": "t", 8222 "public_repos": 1, 8223 "followers": 1, 8224 "following": 1, 8225 "created_at": ` + referenceTimeStr + `, 8226 "suspended_at": ` + referenceTimeStr + `, 8227 "url": "u" 8228 }, 8229 "suspended_at": ` + referenceTimeStr + ` 8230 } 8231 }` 8232 8233 testJSONMarshal(t, u, want) 8234 } 8235 8236 func TestMergeGroupEvent_Marshal(t *testing.T) { 8237 testJSONMarshal(t, &MergeGroupEvent{}, "{}") 8238 8239 u := &MergeGroupEvent{ 8240 Action: String("a"), 8241 MergeGroup: &MergeGroup{ 8242 HeadSHA: String("hs"), 8243 HeadRef: String("hr"), 8244 BaseSHA: String("bs"), 8245 BaseRef: String("br"), 8246 HeadCommit: &Commit{NodeID: String("nid")}, 8247 }, 8248 Repo: &Repository{ 8249 ID: Int64(1), 8250 URL: String("s"), 8251 Name: String("n"), 8252 }, 8253 Org: &Organization{ 8254 BillingEmail: String("be"), 8255 Blog: String("b"), 8256 Company: String("c"), 8257 Email: String("e"), 8258 TwitterUsername: String("tu"), 8259 Location: String("loc"), 8260 Name: String("n"), 8261 Description: String("d"), 8262 IsVerified: Bool(true), 8263 HasOrganizationProjects: Bool(true), 8264 HasRepositoryProjects: Bool(true), 8265 DefaultRepoPermission: String("drp"), 8266 MembersCanCreateRepos: Bool(true), 8267 MembersCanCreateInternalRepos: Bool(true), 8268 MembersCanCreatePrivateRepos: Bool(true), 8269 MembersCanCreatePublicRepos: Bool(false), 8270 MembersAllowedRepositoryCreationType: String("marct"), 8271 MembersCanCreatePages: Bool(true), 8272 MembersCanCreatePublicPages: Bool(false), 8273 MembersCanCreatePrivatePages: Bool(true), 8274 }, 8275 Sender: &User{ 8276 Login: String("l"), 8277 ID: Int64(1), 8278 NodeID: String("n"), 8279 URL: String("u"), 8280 ReposURL: String("r"), 8281 EventsURL: String("e"), 8282 AvatarURL: String("a"), 8283 }, 8284 Installation: &Installation{ 8285 ID: Int64(1), 8286 NodeID: String("nid"), 8287 AppID: Int64(1), 8288 AppSlug: String("as"), 8289 TargetID: Int64(1), 8290 Account: &User{ 8291 Login: String("l"), 8292 ID: Int64(1), 8293 URL: String("u"), 8294 AvatarURL: String("a"), 8295 GravatarID: String("g"), 8296 Name: String("n"), 8297 Company: String("c"), 8298 Blog: String("b"), 8299 Location: String("l"), 8300 Email: String("e"), 8301 Hireable: Bool(true), 8302 Bio: String("b"), 8303 TwitterUsername: String("t"), 8304 PublicRepos: Int(1), 8305 Followers: Int(1), 8306 Following: Int(1), 8307 CreatedAt: &Timestamp{referenceTime}, 8308 SuspendedAt: &Timestamp{referenceTime}, 8309 }, 8310 AccessTokensURL: String("atu"), 8311 RepositoriesURL: String("ru"), 8312 HTMLURL: String("hu"), 8313 TargetType: String("tt"), 8314 SingleFileName: String("sfn"), 8315 RepositorySelection: String("rs"), 8316 Events: []string{"e"}, 8317 SingleFilePaths: []string{"s"}, 8318 Permissions: &InstallationPermissions{ 8319 Actions: String("a"), 8320 Administration: String("ad"), 8321 Checks: String("c"), 8322 Contents: String("co"), 8323 ContentReferences: String("cr"), 8324 Deployments: String("d"), 8325 Environments: String("e"), 8326 Issues: String("i"), 8327 Metadata: String("md"), 8328 Members: String("m"), 8329 OrganizationAdministration: String("oa"), 8330 OrganizationHooks: String("oh"), 8331 OrganizationPlan: String("op"), 8332 OrganizationPreReceiveHooks: String("opr"), 8333 OrganizationProjects: String("op"), 8334 OrganizationSecrets: String("os"), 8335 OrganizationSelfHostedRunners: String("osh"), 8336 OrganizationUserBlocking: String("oub"), 8337 Packages: String("pkg"), 8338 Pages: String("pg"), 8339 PullRequests: String("pr"), 8340 RepositoryHooks: String("rh"), 8341 RepositoryProjects: String("rp"), 8342 RepositoryPreReceiveHooks: String("rprh"), 8343 Secrets: String("s"), 8344 SecretScanningAlerts: String("ssa"), 8345 SecurityEvents: String("se"), 8346 SingleFile: String("sf"), 8347 Statuses: String("s"), 8348 TeamDiscussions: String("td"), 8349 VulnerabilityAlerts: String("va"), 8350 Workflows: String("w"), 8351 }, 8352 CreatedAt: &Timestamp{referenceTime}, 8353 UpdatedAt: &Timestamp{referenceTime}, 8354 HasMultipleSingleFiles: Bool(false), 8355 SuspendedBy: &User{ 8356 Login: String("l"), 8357 ID: Int64(1), 8358 URL: String("u"), 8359 AvatarURL: String("a"), 8360 GravatarID: String("g"), 8361 Name: String("n"), 8362 Company: String("c"), 8363 Blog: String("b"), 8364 Location: String("l"), 8365 Email: String("e"), 8366 Hireable: Bool(true), 8367 Bio: String("b"), 8368 TwitterUsername: String("t"), 8369 PublicRepos: Int(1), 8370 Followers: Int(1), 8371 Following: Int(1), 8372 CreatedAt: &Timestamp{referenceTime}, 8373 SuspendedAt: &Timestamp{referenceTime}, 8374 }, 8375 SuspendedAt: &Timestamp{referenceTime}, 8376 }, 8377 } 8378 8379 want := `{ 8380 "action": "a", 8381 "merge_group": { 8382 "head_sha": "hs", 8383 "head_ref": "hr", 8384 "base_sha": "bs", 8385 "base_ref": "br", 8386 "head_commit": { 8387 "node_id": "nid" 8388 } 8389 }, 8390 "repository": { 8391 "id": 1, 8392 "name": "n", 8393 "url": "s" 8394 }, 8395 "organization": { 8396 "name": "n", 8397 "company": "c", 8398 "blog": "b", 8399 "location": "loc", 8400 "email": "e", 8401 "twitter_username": "tu", 8402 "description": "d", 8403 "billing_email": "be", 8404 "is_verified": true, 8405 "has_organization_projects": true, 8406 "has_repository_projects": true, 8407 "default_repository_permission": "drp", 8408 "members_can_create_repositories": true, 8409 "members_can_create_public_repositories": false, 8410 "members_can_create_private_repositories": true, 8411 "members_can_create_internal_repositories": true, 8412 "members_allowed_repository_creation_type": "marct", 8413 "members_can_create_pages": true, 8414 "members_can_create_public_pages": false, 8415 "members_can_create_private_pages": true 8416 }, 8417 "sender": { 8418 "login": "l", 8419 "id": 1, 8420 "node_id": "n", 8421 "avatar_url": "a", 8422 "url": "u", 8423 "events_url": "e", 8424 "repos_url": "r" 8425 }, 8426 "installation": { 8427 "id": 1, 8428 "node_id": "nid", 8429 "app_id": 1, 8430 "app_slug": "as", 8431 "target_id": 1, 8432 "account": { 8433 "login": "l", 8434 "id": 1, 8435 "avatar_url": "a", 8436 "gravatar_id": "g", 8437 "name": "n", 8438 "company": "c", 8439 "blog": "b", 8440 "location": "l", 8441 "email": "e", 8442 "hireable": true, 8443 "bio": "b", 8444 "twitter_username": "t", 8445 "public_repos": 1, 8446 "followers": 1, 8447 "following": 1, 8448 "created_at": ` + referenceTimeStr + `, 8449 "suspended_at": ` + referenceTimeStr + `, 8450 "url": "u" 8451 }, 8452 "access_tokens_url": "atu", 8453 "repositories_url": "ru", 8454 "html_url": "hu", 8455 "target_type": "tt", 8456 "single_file_name": "sfn", 8457 "repository_selection": "rs", 8458 "events": [ 8459 "e" 8460 ], 8461 "single_file_paths": [ 8462 "s" 8463 ], 8464 "permissions": { 8465 "actions": "a", 8466 "administration": "ad", 8467 "checks": "c", 8468 "contents": "co", 8469 "content_references": "cr", 8470 "deployments": "d", 8471 "environments": "e", 8472 "issues": "i", 8473 "metadata": "md", 8474 "members": "m", 8475 "organization_administration": "oa", 8476 "organization_hooks": "oh", 8477 "organization_plan": "op", 8478 "organization_pre_receive_hooks": "opr", 8479 "organization_projects": "op", 8480 "organization_secrets": "os", 8481 "organization_self_hosted_runners": "osh", 8482 "organization_user_blocking": "oub", 8483 "packages": "pkg", 8484 "pages": "pg", 8485 "pull_requests": "pr", 8486 "repository_hooks": "rh", 8487 "repository_projects": "rp", 8488 "repository_pre_receive_hooks": "rprh", 8489 "secrets": "s", 8490 "secret_scanning_alerts": "ssa", 8491 "security_events": "se", 8492 "single_file": "sf", 8493 "statuses": "s", 8494 "team_discussions": "td", 8495 "vulnerability_alerts": "va", 8496 "workflows": "w" 8497 }, 8498 "created_at": ` + referenceTimeStr + `, 8499 "updated_at": ` + referenceTimeStr + `, 8500 "has_multiple_single_files": false, 8501 "suspended_by": { 8502 "login": "l", 8503 "id": 1, 8504 "avatar_url": "a", 8505 "gravatar_id": "g", 8506 "name": "n", 8507 "company": "c", 8508 "blog": "b", 8509 "location": "l", 8510 "email": "e", 8511 "hireable": true, 8512 "bio": "b", 8513 "twitter_username": "t", 8514 "public_repos": 1, 8515 "followers": 1, 8516 "following": 1, 8517 "created_at": ` + referenceTimeStr + `, 8518 "suspended_at": ` + referenceTimeStr + `, 8519 "url": "u" 8520 }, 8521 "suspended_at": ` + referenceTimeStr + ` 8522 } 8523 }` 8524 8525 testJSONMarshal(t, u, want) 8526 } 8527 8528 func TestOrgBlockEvent_Marshal(t *testing.T) { 8529 testJSONMarshal(t, &OrgBlockEvent{}, "{}") 8530 8531 u := &OrgBlockEvent{ 8532 Action: String("a"), 8533 BlockedUser: &User{ 8534 Login: String("l"), 8535 ID: Int64(1), 8536 NodeID: String("n"), 8537 URL: String("u"), 8538 ReposURL: String("r"), 8539 EventsURL: String("e"), 8540 AvatarURL: String("a"), 8541 }, 8542 Organization: &Organization{ 8543 BillingEmail: String("be"), 8544 Blog: String("b"), 8545 Company: String("c"), 8546 Email: String("e"), 8547 TwitterUsername: String("tu"), 8548 Location: String("loc"), 8549 Name: String("n"), 8550 Description: String("d"), 8551 IsVerified: Bool(true), 8552 HasOrganizationProjects: Bool(true), 8553 HasRepositoryProjects: Bool(true), 8554 DefaultRepoPermission: String("drp"), 8555 MembersCanCreateRepos: Bool(true), 8556 MembersCanCreateInternalRepos: Bool(true), 8557 MembersCanCreatePrivateRepos: Bool(true), 8558 MembersCanCreatePublicRepos: Bool(false), 8559 MembersAllowedRepositoryCreationType: String("marct"), 8560 MembersCanCreatePages: Bool(true), 8561 MembersCanCreatePublicPages: Bool(false), 8562 MembersCanCreatePrivatePages: Bool(true), 8563 }, 8564 Sender: &User{ 8565 Login: String("l"), 8566 ID: Int64(1), 8567 NodeID: String("n"), 8568 URL: String("u"), 8569 ReposURL: String("r"), 8570 EventsURL: String("e"), 8571 AvatarURL: String("a"), 8572 }, 8573 Installation: &Installation{ 8574 ID: Int64(1), 8575 NodeID: String("nid"), 8576 AppID: Int64(1), 8577 AppSlug: String("as"), 8578 TargetID: Int64(1), 8579 Account: &User{ 8580 Login: String("l"), 8581 ID: Int64(1), 8582 URL: String("u"), 8583 AvatarURL: String("a"), 8584 GravatarID: String("g"), 8585 Name: String("n"), 8586 Company: String("c"), 8587 Blog: String("b"), 8588 Location: String("l"), 8589 Email: String("e"), 8590 Hireable: Bool(true), 8591 Bio: String("b"), 8592 TwitterUsername: String("t"), 8593 PublicRepos: Int(1), 8594 Followers: Int(1), 8595 Following: Int(1), 8596 CreatedAt: &Timestamp{referenceTime}, 8597 SuspendedAt: &Timestamp{referenceTime}, 8598 }, 8599 AccessTokensURL: String("atu"), 8600 RepositoriesURL: String("ru"), 8601 HTMLURL: String("hu"), 8602 TargetType: String("tt"), 8603 SingleFileName: String("sfn"), 8604 RepositorySelection: String("rs"), 8605 Events: []string{"e"}, 8606 SingleFilePaths: []string{"s"}, 8607 Permissions: &InstallationPermissions{ 8608 Actions: String("a"), 8609 Administration: String("ad"), 8610 Checks: String("c"), 8611 Contents: String("co"), 8612 ContentReferences: String("cr"), 8613 Deployments: String("d"), 8614 Environments: String("e"), 8615 Issues: String("i"), 8616 Metadata: String("md"), 8617 Members: String("m"), 8618 OrganizationAdministration: String("oa"), 8619 OrganizationHooks: String("oh"), 8620 OrganizationPlan: String("op"), 8621 OrganizationPreReceiveHooks: String("opr"), 8622 OrganizationProjects: String("op"), 8623 OrganizationSecrets: String("os"), 8624 OrganizationSelfHostedRunners: String("osh"), 8625 OrganizationUserBlocking: String("oub"), 8626 Packages: String("pkg"), 8627 Pages: String("pg"), 8628 PullRequests: String("pr"), 8629 RepositoryHooks: String("rh"), 8630 RepositoryProjects: String("rp"), 8631 RepositoryPreReceiveHooks: String("rprh"), 8632 Secrets: String("s"), 8633 SecretScanningAlerts: String("ssa"), 8634 SecurityEvents: String("se"), 8635 SingleFile: String("sf"), 8636 Statuses: String("s"), 8637 TeamDiscussions: String("td"), 8638 VulnerabilityAlerts: String("va"), 8639 Workflows: String("w"), 8640 }, 8641 CreatedAt: &Timestamp{referenceTime}, 8642 UpdatedAt: &Timestamp{referenceTime}, 8643 HasMultipleSingleFiles: Bool(false), 8644 SuspendedBy: &User{ 8645 Login: String("l"), 8646 ID: Int64(1), 8647 URL: String("u"), 8648 AvatarURL: String("a"), 8649 GravatarID: String("g"), 8650 Name: String("n"), 8651 Company: String("c"), 8652 Blog: String("b"), 8653 Location: String("l"), 8654 Email: String("e"), 8655 Hireable: Bool(true), 8656 Bio: String("b"), 8657 TwitterUsername: String("t"), 8658 PublicRepos: Int(1), 8659 Followers: Int(1), 8660 Following: Int(1), 8661 CreatedAt: &Timestamp{referenceTime}, 8662 SuspendedAt: &Timestamp{referenceTime}, 8663 }, 8664 SuspendedAt: &Timestamp{referenceTime}, 8665 }, 8666 } 8667 8668 want := `{ 8669 "action": "a", 8670 "blocked_user": { 8671 "login": "l", 8672 "id": 1, 8673 "node_id": "n", 8674 "avatar_url": "a", 8675 "url": "u", 8676 "events_url": "e", 8677 "repos_url": "r" 8678 }, 8679 "organization": { 8680 "name": "n", 8681 "company": "c", 8682 "blog": "b", 8683 "location": "loc", 8684 "email": "e", 8685 "twitter_username": "tu", 8686 "description": "d", 8687 "billing_email": "be", 8688 "is_verified": true, 8689 "has_organization_projects": true, 8690 "has_repository_projects": true, 8691 "default_repository_permission": "drp", 8692 "members_can_create_repositories": true, 8693 "members_can_create_public_repositories": false, 8694 "members_can_create_private_repositories": true, 8695 "members_can_create_internal_repositories": true, 8696 "members_allowed_repository_creation_type": "marct", 8697 "members_can_create_pages": true, 8698 "members_can_create_public_pages": false, 8699 "members_can_create_private_pages": true 8700 }, 8701 "sender": { 8702 "login": "l", 8703 "id": 1, 8704 "node_id": "n", 8705 "avatar_url": "a", 8706 "url": "u", 8707 "events_url": "e", 8708 "repos_url": "r" 8709 }, 8710 "installation": { 8711 "id": 1, 8712 "node_id": "nid", 8713 "app_id": 1, 8714 "app_slug": "as", 8715 "target_id": 1, 8716 "account": { 8717 "login": "l", 8718 "id": 1, 8719 "avatar_url": "a", 8720 "gravatar_id": "g", 8721 "name": "n", 8722 "company": "c", 8723 "blog": "b", 8724 "location": "l", 8725 "email": "e", 8726 "hireable": true, 8727 "bio": "b", 8728 "twitter_username": "t", 8729 "public_repos": 1, 8730 "followers": 1, 8731 "following": 1, 8732 "created_at": ` + referenceTimeStr + `, 8733 "suspended_at": ` + referenceTimeStr + `, 8734 "url": "u" 8735 }, 8736 "access_tokens_url": "atu", 8737 "repositories_url": "ru", 8738 "html_url": "hu", 8739 "target_type": "tt", 8740 "single_file_name": "sfn", 8741 "repository_selection": "rs", 8742 "events": [ 8743 "e" 8744 ], 8745 "single_file_paths": [ 8746 "s" 8747 ], 8748 "permissions": { 8749 "actions": "a", 8750 "administration": "ad", 8751 "checks": "c", 8752 "contents": "co", 8753 "content_references": "cr", 8754 "deployments": "d", 8755 "environments": "e", 8756 "issues": "i", 8757 "metadata": "md", 8758 "members": "m", 8759 "organization_administration": "oa", 8760 "organization_hooks": "oh", 8761 "organization_plan": "op", 8762 "organization_pre_receive_hooks": "opr", 8763 "organization_projects": "op", 8764 "organization_secrets": "os", 8765 "organization_self_hosted_runners": "osh", 8766 "organization_user_blocking": "oub", 8767 "packages": "pkg", 8768 "pages": "pg", 8769 "pull_requests": "pr", 8770 "repository_hooks": "rh", 8771 "repository_projects": "rp", 8772 "repository_pre_receive_hooks": "rprh", 8773 "secrets": "s", 8774 "secret_scanning_alerts": "ssa", 8775 "security_events": "se", 8776 "single_file": "sf", 8777 "statuses": "s", 8778 "team_discussions": "td", 8779 "vulnerability_alerts": "va", 8780 "workflows": "w" 8781 }, 8782 "created_at": ` + referenceTimeStr + `, 8783 "updated_at": ` + referenceTimeStr + `, 8784 "has_multiple_single_files": false, 8785 "suspended_by": { 8786 "login": "l", 8787 "id": 1, 8788 "avatar_url": "a", 8789 "gravatar_id": "g", 8790 "name": "n", 8791 "company": "c", 8792 "blog": "b", 8793 "location": "l", 8794 "email": "e", 8795 "hireable": true, 8796 "bio": "b", 8797 "twitter_username": "t", 8798 "public_repos": 1, 8799 "followers": 1, 8800 "following": 1, 8801 "created_at": ` + referenceTimeStr + `, 8802 "suspended_at": ` + referenceTimeStr + `, 8803 "url": "u" 8804 }, 8805 "suspended_at": ` + referenceTimeStr + ` 8806 } 8807 }` 8808 8809 testJSONMarshal(t, u, want) 8810 } 8811 8812 func TestGollumEvent_Marshal(t *testing.T) { 8813 testJSONMarshal(t, &GollumEvent{}, "{}") 8814 8815 u := &GollumEvent{ 8816 Pages: []*Page{ 8817 { 8818 PageName: String("pn"), 8819 Title: String("t"), 8820 Summary: String("s"), 8821 Action: String("a"), 8822 SHA: String("sha"), 8823 HTMLURL: String("hu"), 8824 }, 8825 }, 8826 Repo: &Repository{ 8827 ID: Int64(1), 8828 URL: String("s"), 8829 Name: String("n"), 8830 }, 8831 Sender: &User{ 8832 Login: String("l"), 8833 ID: Int64(1), 8834 NodeID: String("n"), 8835 URL: String("u"), 8836 ReposURL: String("r"), 8837 EventsURL: String("e"), 8838 AvatarURL: String("a"), 8839 }, 8840 Installation: &Installation{ 8841 ID: Int64(1), 8842 NodeID: String("nid"), 8843 AppID: Int64(1), 8844 AppSlug: String("as"), 8845 TargetID: Int64(1), 8846 Account: &User{ 8847 Login: String("l"), 8848 ID: Int64(1), 8849 URL: String("u"), 8850 AvatarURL: String("a"), 8851 GravatarID: String("g"), 8852 Name: String("n"), 8853 Company: String("c"), 8854 Blog: String("b"), 8855 Location: String("l"), 8856 Email: String("e"), 8857 Hireable: Bool(true), 8858 Bio: String("b"), 8859 TwitterUsername: String("t"), 8860 PublicRepos: Int(1), 8861 Followers: Int(1), 8862 Following: Int(1), 8863 CreatedAt: &Timestamp{referenceTime}, 8864 SuspendedAt: &Timestamp{referenceTime}, 8865 }, 8866 AccessTokensURL: String("atu"), 8867 RepositoriesURL: String("ru"), 8868 HTMLURL: String("hu"), 8869 TargetType: String("tt"), 8870 SingleFileName: String("sfn"), 8871 RepositorySelection: String("rs"), 8872 Events: []string{"e"}, 8873 SingleFilePaths: []string{"s"}, 8874 Permissions: &InstallationPermissions{ 8875 Actions: String("a"), 8876 Administration: String("ad"), 8877 Checks: String("c"), 8878 Contents: String("co"), 8879 ContentReferences: String("cr"), 8880 Deployments: String("d"), 8881 Environments: String("e"), 8882 Issues: String("i"), 8883 Metadata: String("md"), 8884 Members: String("m"), 8885 OrganizationAdministration: String("oa"), 8886 OrganizationHooks: String("oh"), 8887 OrganizationPlan: String("op"), 8888 OrganizationPreReceiveHooks: String("opr"), 8889 OrganizationProjects: String("op"), 8890 OrganizationSecrets: String("os"), 8891 OrganizationSelfHostedRunners: String("osh"), 8892 OrganizationUserBlocking: String("oub"), 8893 Packages: String("pkg"), 8894 Pages: String("pg"), 8895 PullRequests: String("pr"), 8896 RepositoryHooks: String("rh"), 8897 RepositoryProjects: String("rp"), 8898 RepositoryPreReceiveHooks: String("rprh"), 8899 Secrets: String("s"), 8900 SecretScanningAlerts: String("ssa"), 8901 SecurityEvents: String("se"), 8902 SingleFile: String("sf"), 8903 Statuses: String("s"), 8904 TeamDiscussions: String("td"), 8905 VulnerabilityAlerts: String("va"), 8906 Workflows: String("w"), 8907 }, 8908 CreatedAt: &Timestamp{referenceTime}, 8909 UpdatedAt: &Timestamp{referenceTime}, 8910 HasMultipleSingleFiles: Bool(false), 8911 SuspendedBy: &User{ 8912 Login: String("l"), 8913 ID: Int64(1), 8914 URL: String("u"), 8915 AvatarURL: String("a"), 8916 GravatarID: String("g"), 8917 Name: String("n"), 8918 Company: String("c"), 8919 Blog: String("b"), 8920 Location: String("l"), 8921 Email: String("e"), 8922 Hireable: Bool(true), 8923 Bio: String("b"), 8924 TwitterUsername: String("t"), 8925 PublicRepos: Int(1), 8926 Followers: Int(1), 8927 Following: Int(1), 8928 CreatedAt: &Timestamp{referenceTime}, 8929 SuspendedAt: &Timestamp{referenceTime}, 8930 }, 8931 SuspendedAt: &Timestamp{referenceTime}, 8932 }, 8933 } 8934 8935 want := `{ 8936 "pages": [ 8937 { 8938 "page_name": "pn", 8939 "title": "t", 8940 "summary": "s", 8941 "action": "a", 8942 "sha": "sha", 8943 "html_url": "hu" 8944 } 8945 ], 8946 "repository": { 8947 "id": 1, 8948 "name": "n", 8949 "url": "s" 8950 }, 8951 "sender": { 8952 "login": "l", 8953 "id": 1, 8954 "node_id": "n", 8955 "avatar_url": "a", 8956 "url": "u", 8957 "events_url": "e", 8958 "repos_url": "r" 8959 }, 8960 "installation": { 8961 "id": 1, 8962 "node_id": "nid", 8963 "app_id": 1, 8964 "app_slug": "as", 8965 "target_id": 1, 8966 "account": { 8967 "login": "l", 8968 "id": 1, 8969 "avatar_url": "a", 8970 "gravatar_id": "g", 8971 "name": "n", 8972 "company": "c", 8973 "blog": "b", 8974 "location": "l", 8975 "email": "e", 8976 "hireable": true, 8977 "bio": "b", 8978 "twitter_username": "t", 8979 "public_repos": 1, 8980 "followers": 1, 8981 "following": 1, 8982 "created_at": ` + referenceTimeStr + `, 8983 "suspended_at": ` + referenceTimeStr + `, 8984 "url": "u" 8985 }, 8986 "access_tokens_url": "atu", 8987 "repositories_url": "ru", 8988 "html_url": "hu", 8989 "target_type": "tt", 8990 "single_file_name": "sfn", 8991 "repository_selection": "rs", 8992 "events": [ 8993 "e" 8994 ], 8995 "single_file_paths": [ 8996 "s" 8997 ], 8998 "permissions": { 8999 "actions": "a", 9000 "administration": "ad", 9001 "checks": "c", 9002 "contents": "co", 9003 "content_references": "cr", 9004 "deployments": "d", 9005 "environments": "e", 9006 "issues": "i", 9007 "metadata": "md", 9008 "members": "m", 9009 "organization_administration": "oa", 9010 "organization_hooks": "oh", 9011 "organization_plan": "op", 9012 "organization_pre_receive_hooks": "opr", 9013 "organization_projects": "op", 9014 "organization_secrets": "os", 9015 "organization_self_hosted_runners": "osh", 9016 "organization_user_blocking": "oub", 9017 "packages": "pkg", 9018 "pages": "pg", 9019 "pull_requests": "pr", 9020 "repository_hooks": "rh", 9021 "repository_projects": "rp", 9022 "repository_pre_receive_hooks": "rprh", 9023 "secrets": "s", 9024 "secret_scanning_alerts": "ssa", 9025 "security_events": "se", 9026 "single_file": "sf", 9027 "statuses": "s", 9028 "team_discussions": "td", 9029 "vulnerability_alerts": "va", 9030 "workflows": "w" 9031 }, 9032 "created_at": ` + referenceTimeStr + `, 9033 "updated_at": ` + referenceTimeStr + `, 9034 "has_multiple_single_files": false, 9035 "suspended_by": { 9036 "login": "l", 9037 "id": 1, 9038 "avatar_url": "a", 9039 "gravatar_id": "g", 9040 "name": "n", 9041 "company": "c", 9042 "blog": "b", 9043 "location": "l", 9044 "email": "e", 9045 "hireable": true, 9046 "bio": "b", 9047 "twitter_username": "t", 9048 "public_repos": 1, 9049 "followers": 1, 9050 "following": 1, 9051 "created_at": ` + referenceTimeStr + `, 9052 "suspended_at": ` + referenceTimeStr + `, 9053 "url": "u" 9054 }, 9055 "suspended_at": ` + referenceTimeStr + ` 9056 } 9057 }` 9058 9059 testJSONMarshal(t, u, want) 9060 } 9061 9062 func TestWorkflowRunEvent_Marshal(t *testing.T) { 9063 testJSONMarshal(t, &WorkflowRunEvent{}, "{}") 9064 9065 u := &WorkflowRunEvent{ 9066 Action: String("a"), 9067 Workflow: &Workflow{ 9068 ID: Int64(1), 9069 NodeID: String("nid"), 9070 Name: String("n"), 9071 Path: String("p"), 9072 State: String("s"), 9073 CreatedAt: &Timestamp{referenceTime}, 9074 UpdatedAt: &Timestamp{referenceTime}, 9075 URL: String("u"), 9076 HTMLURL: String("h"), 9077 BadgeURL: String("b"), 9078 }, 9079 WorkflowRun: &WorkflowRun{ 9080 ID: Int64(1), 9081 Name: String("n"), 9082 NodeID: String("nid"), 9083 HeadBranch: String("hb"), 9084 HeadSHA: String("hs"), 9085 RunNumber: Int(1), 9086 RunAttempt: Int(1), 9087 Event: String("e"), 9088 Status: String("s"), 9089 Conclusion: String("c"), 9090 WorkflowID: Int64(1), 9091 URL: String("u"), 9092 HTMLURL: String("h"), 9093 PullRequests: []*PullRequest{ 9094 { 9095 URL: String("u"), 9096 ID: Int64(1), 9097 Number: Int(1), 9098 Head: &PullRequestBranch{ 9099 Ref: String("r"), 9100 SHA: String("s"), 9101 Repo: &Repository{ 9102 ID: Int64(1), 9103 URL: String("s"), 9104 Name: String("n"), 9105 }, 9106 }, 9107 Base: &PullRequestBranch{ 9108 Ref: String("r"), 9109 SHA: String("s"), 9110 Repo: &Repository{ 9111 ID: Int64(1), 9112 URL: String("u"), 9113 Name: String("n"), 9114 }, 9115 }, 9116 }, 9117 }, 9118 CreatedAt: &Timestamp{referenceTime}, 9119 UpdatedAt: &Timestamp{referenceTime}, 9120 RunStartedAt: &Timestamp{referenceTime}, 9121 JobsURL: String("j"), 9122 LogsURL: String("l"), 9123 CheckSuiteURL: String("c"), 9124 ArtifactsURL: String("a"), 9125 CancelURL: String("c"), 9126 RerunURL: String("r"), 9127 PreviousAttemptURL: String("p"), 9128 HeadCommit: &HeadCommit{ 9129 Message: String("m"), 9130 Author: &CommitAuthor{ 9131 Name: String("n"), 9132 Email: String("e"), 9133 Login: String("l"), 9134 }, 9135 URL: String("u"), 9136 Distinct: Bool(false), 9137 SHA: String("s"), 9138 ID: String("i"), 9139 TreeID: String("tid"), 9140 Timestamp: &Timestamp{referenceTime}, 9141 Committer: &CommitAuthor{ 9142 Name: String("n"), 9143 Email: String("e"), 9144 Login: String("l"), 9145 }, 9146 }, 9147 WorkflowURL: String("w"), 9148 Repository: &Repository{ 9149 ID: Int64(1), 9150 URL: String("u"), 9151 Name: String("n"), 9152 }, 9153 HeadRepository: &Repository{ 9154 ID: Int64(1), 9155 URL: String("u"), 9156 Name: String("n"), 9157 }, 9158 }, 9159 Org: &Organization{ 9160 BillingEmail: String("be"), 9161 Blog: String("b"), 9162 Company: String("c"), 9163 Email: String("e"), 9164 TwitterUsername: String("tu"), 9165 Location: String("loc"), 9166 Name: String("n"), 9167 Description: String("d"), 9168 IsVerified: Bool(true), 9169 HasOrganizationProjects: Bool(true), 9170 HasRepositoryProjects: Bool(true), 9171 DefaultRepoPermission: String("drp"), 9172 MembersCanCreateRepos: Bool(true), 9173 MembersCanCreateInternalRepos: Bool(true), 9174 MembersCanCreatePrivateRepos: Bool(true), 9175 MembersCanCreatePublicRepos: Bool(false), 9176 MembersAllowedRepositoryCreationType: String("marct"), 9177 MembersCanCreatePages: Bool(true), 9178 MembersCanCreatePublicPages: Bool(false), 9179 MembersCanCreatePrivatePages: Bool(true), 9180 }, 9181 Repo: &Repository{ 9182 ID: Int64(1), 9183 URL: String("s"), 9184 Name: String("n"), 9185 }, 9186 Sender: &User{ 9187 Login: String("l"), 9188 ID: Int64(1), 9189 NodeID: String("n"), 9190 URL: String("u"), 9191 ReposURL: String("r"), 9192 EventsURL: String("e"), 9193 AvatarURL: String("a"), 9194 }, 9195 } 9196 9197 want := `{ 9198 "action": "a", 9199 "workflow": { 9200 "id": 1, 9201 "node_id": "nid", 9202 "name": "n", 9203 "path": "p", 9204 "state": "s", 9205 "created_at": ` + referenceTimeStr + `, 9206 "updated_at": ` + referenceTimeStr + `, 9207 "url": "u", 9208 "html_url": "h", 9209 "badge_url": "b" 9210 }, 9211 "workflow_run": { 9212 "id": 1, 9213 "name": "n", 9214 "node_id": "nid", 9215 "head_branch": "hb", 9216 "head_sha": "hs", 9217 "run_number": 1, 9218 "run_attempt": 1, 9219 "event": "e", 9220 "status": "s", 9221 "conclusion": "c", 9222 "workflow_id": 1, 9223 "url": "u", 9224 "html_url": "h", 9225 "pull_requests": [ 9226 { 9227 "id": 1, 9228 "number": 1, 9229 "url": "u", 9230 "head": { 9231 "ref": "r", 9232 "sha": "s", 9233 "repo": { 9234 "id": 1, 9235 "name": "n", 9236 "url": "s" 9237 } 9238 }, 9239 "base": { 9240 "ref": "r", 9241 "sha": "s", 9242 "repo": { 9243 "id": 1, 9244 "name": "n", 9245 "url": "u" 9246 } 9247 } 9248 } 9249 ], 9250 "created_at": ` + referenceTimeStr + `, 9251 "updated_at": ` + referenceTimeStr + `, 9252 "run_started_at": ` + referenceTimeStr + `, 9253 "jobs_url": "j", 9254 "logs_url": "l", 9255 "check_suite_url": "c", 9256 "artifacts_url": "a", 9257 "cancel_url": "c", 9258 "rerun_url": "r", 9259 "previous_attempt_url": "p", 9260 "head_commit": { 9261 "message": "m", 9262 "author": { 9263 "name": "n", 9264 "email": "e", 9265 "username": "l" 9266 }, 9267 "url": "u", 9268 "distinct": false, 9269 "sha": "s", 9270 "id": "i", 9271 "tree_id": "tid", 9272 "timestamp": ` + referenceTimeStr + `, 9273 "committer": { 9274 "name": "n", 9275 "email": "e", 9276 "username": "l" 9277 } 9278 }, 9279 "workflow_url": "w", 9280 "repository": { 9281 "id": 1, 9282 "name": "n", 9283 "url": "u" 9284 }, 9285 "head_repository": { 9286 "id": 1, 9287 "name": "n", 9288 "url": "u" 9289 } 9290 }, 9291 "organization": { 9292 "name": "n", 9293 "company": "c", 9294 "blog": "b", 9295 "location": "loc", 9296 "email": "e", 9297 "twitter_username": "tu", 9298 "description": "d", 9299 "billing_email": "be", 9300 "is_verified": true, 9301 "has_organization_projects": true, 9302 "has_repository_projects": true, 9303 "default_repository_permission": "drp", 9304 "members_can_create_repositories": true, 9305 "members_can_create_public_repositories": false, 9306 "members_can_create_private_repositories": true, 9307 "members_can_create_internal_repositories": true, 9308 "members_allowed_repository_creation_type": "marct", 9309 "members_can_create_pages": true, 9310 "members_can_create_public_pages": false, 9311 "members_can_create_private_pages": true 9312 }, 9313 "repository": { 9314 "id": 1, 9315 "name": "n", 9316 "url": "s" 9317 }, 9318 "sender": { 9319 "login": "l", 9320 "id": 1, 9321 "node_id": "n", 9322 "avatar_url": "a", 9323 "url": "u", 9324 "events_url": "e", 9325 "repos_url": "r" 9326 } 9327 }` 9328 9329 testJSONMarshal(t, u, want) 9330 } 9331 9332 func TestWorkflowDispatchEvent_Marshal(t *testing.T) { 9333 testJSONMarshal(t, &WorkflowDispatchEvent{}, "{}") 9334 9335 i := make(map[string]interface{}) 9336 i["key"] = "value" 9337 9338 jsonMsg, _ := json.Marshal(i) 9339 u := &WorkflowDispatchEvent{ 9340 Inputs: jsonMsg, 9341 Ref: String("r"), 9342 Workflow: String("w"), 9343 Repo: &Repository{ 9344 ID: Int64(1), 9345 URL: String("s"), 9346 Name: String("n"), 9347 }, 9348 Org: &Organization{ 9349 BillingEmail: String("be"), 9350 Blog: String("b"), 9351 Company: String("c"), 9352 Email: String("e"), 9353 TwitterUsername: String("tu"), 9354 Location: String("loc"), 9355 Name: String("n"), 9356 Description: String("d"), 9357 IsVerified: Bool(true), 9358 HasOrganizationProjects: Bool(true), 9359 HasRepositoryProjects: Bool(true), 9360 DefaultRepoPermission: String("drp"), 9361 MembersCanCreateRepos: Bool(true), 9362 MembersCanCreateInternalRepos: Bool(true), 9363 MembersCanCreatePrivateRepos: Bool(true), 9364 MembersCanCreatePublicRepos: Bool(false), 9365 MembersAllowedRepositoryCreationType: String("marct"), 9366 MembersCanCreatePages: Bool(true), 9367 MembersCanCreatePublicPages: Bool(false), 9368 MembersCanCreatePrivatePages: Bool(true), 9369 }, 9370 Sender: &User{ 9371 Login: String("l"), 9372 ID: Int64(1), 9373 NodeID: String("n"), 9374 URL: String("u"), 9375 ReposURL: String("r"), 9376 EventsURL: String("e"), 9377 AvatarURL: String("a"), 9378 }, 9379 } 9380 9381 want := `{ 9382 "inputs": { 9383 "key": "value" 9384 }, 9385 "ref": "r", 9386 "workflow": "w", 9387 "repository": { 9388 "id": 1, 9389 "name": "n", 9390 "url": "s" 9391 }, 9392 "organization": { 9393 "name": "n", 9394 "company": "c", 9395 "blog": "b", 9396 "location": "loc", 9397 "email": "e", 9398 "twitter_username": "tu", 9399 "description": "d", 9400 "billing_email": "be", 9401 "is_verified": true, 9402 "has_organization_projects": true, 9403 "has_repository_projects": true, 9404 "default_repository_permission": "drp", 9405 "members_can_create_repositories": true, 9406 "members_can_create_public_repositories": false, 9407 "members_can_create_private_repositories": true, 9408 "members_can_create_internal_repositories": true, 9409 "members_allowed_repository_creation_type": "marct", 9410 "members_can_create_pages": true, 9411 "members_can_create_public_pages": false, 9412 "members_can_create_private_pages": true 9413 }, 9414 "sender": { 9415 "login": "l", 9416 "id": 1, 9417 "node_id": "n", 9418 "avatar_url": "a", 9419 "url": "u", 9420 "events_url": "e", 9421 "repos_url": "r" 9422 } 9423 }` 9424 9425 testJSONMarshal(t, u, want) 9426 } 9427 9428 func TestWatchEvent_Marshal(t *testing.T) { 9429 testJSONMarshal(t, &WatchEvent{}, "{}") 9430 9431 u := &WatchEvent{ 9432 Action: String("a"), 9433 Repo: &Repository{ 9434 ID: Int64(1), 9435 URL: String("s"), 9436 Name: String("n"), 9437 }, 9438 Sender: &User{ 9439 Login: String("l"), 9440 ID: Int64(1), 9441 NodeID: String("n"), 9442 URL: String("u"), 9443 ReposURL: String("r"), 9444 EventsURL: String("e"), 9445 AvatarURL: String("a"), 9446 }, 9447 Installation: &Installation{ 9448 ID: Int64(1), 9449 NodeID: String("nid"), 9450 AppID: Int64(1), 9451 AppSlug: String("as"), 9452 TargetID: Int64(1), 9453 Account: &User{ 9454 Login: String("l"), 9455 ID: Int64(1), 9456 URL: String("u"), 9457 AvatarURL: String("a"), 9458 GravatarID: String("g"), 9459 Name: String("n"), 9460 Company: String("c"), 9461 Blog: String("b"), 9462 Location: String("l"), 9463 Email: String("e"), 9464 Hireable: Bool(true), 9465 Bio: String("b"), 9466 TwitterUsername: String("t"), 9467 PublicRepos: Int(1), 9468 Followers: Int(1), 9469 Following: Int(1), 9470 CreatedAt: &Timestamp{referenceTime}, 9471 SuspendedAt: &Timestamp{referenceTime}, 9472 }, 9473 AccessTokensURL: String("atu"), 9474 RepositoriesURL: String("ru"), 9475 HTMLURL: String("hu"), 9476 TargetType: String("tt"), 9477 SingleFileName: String("sfn"), 9478 RepositorySelection: String("rs"), 9479 Events: []string{"e"}, 9480 SingleFilePaths: []string{"s"}, 9481 Permissions: &InstallationPermissions{ 9482 Actions: String("a"), 9483 Administration: String("ad"), 9484 Checks: String("c"), 9485 Contents: String("co"), 9486 ContentReferences: String("cr"), 9487 Deployments: String("d"), 9488 Environments: String("e"), 9489 Issues: String("i"), 9490 Metadata: String("md"), 9491 Members: String("m"), 9492 OrganizationAdministration: String("oa"), 9493 OrganizationHooks: String("oh"), 9494 OrganizationPlan: String("op"), 9495 OrganizationPreReceiveHooks: String("opr"), 9496 OrganizationProjects: String("op"), 9497 OrganizationSecrets: String("os"), 9498 OrganizationSelfHostedRunners: String("osh"), 9499 OrganizationUserBlocking: String("oub"), 9500 Packages: String("pkg"), 9501 Pages: String("pg"), 9502 PullRequests: String("pr"), 9503 RepositoryHooks: String("rh"), 9504 RepositoryProjects: String("rp"), 9505 RepositoryPreReceiveHooks: String("rprh"), 9506 Secrets: String("s"), 9507 SecretScanningAlerts: String("ssa"), 9508 SecurityEvents: String("se"), 9509 SingleFile: String("sf"), 9510 Statuses: String("s"), 9511 TeamDiscussions: String("td"), 9512 VulnerabilityAlerts: String("va"), 9513 Workflows: String("w"), 9514 }, 9515 CreatedAt: &Timestamp{referenceTime}, 9516 UpdatedAt: &Timestamp{referenceTime}, 9517 HasMultipleSingleFiles: Bool(false), 9518 SuspendedBy: &User{ 9519 Login: String("l"), 9520 ID: Int64(1), 9521 URL: String("u"), 9522 AvatarURL: String("a"), 9523 GravatarID: String("g"), 9524 Name: String("n"), 9525 Company: String("c"), 9526 Blog: String("b"), 9527 Location: String("l"), 9528 Email: String("e"), 9529 Hireable: Bool(true), 9530 Bio: String("b"), 9531 TwitterUsername: String("t"), 9532 PublicRepos: Int(1), 9533 Followers: Int(1), 9534 Following: Int(1), 9535 CreatedAt: &Timestamp{referenceTime}, 9536 SuspendedAt: &Timestamp{referenceTime}, 9537 }, 9538 SuspendedAt: &Timestamp{referenceTime}, 9539 }, 9540 } 9541 9542 want := `{ 9543 "action": "a", 9544 "repository": { 9545 "id": 1, 9546 "name": "n", 9547 "url": "s" 9548 }, 9549 "sender": { 9550 "login": "l", 9551 "id": 1, 9552 "node_id": "n", 9553 "avatar_url": "a", 9554 "url": "u", 9555 "events_url": "e", 9556 "repos_url": "r" 9557 }, 9558 "installation": { 9559 "id": 1, 9560 "node_id": "nid", 9561 "app_id": 1, 9562 "app_slug": "as", 9563 "target_id": 1, 9564 "account": { 9565 "login": "l", 9566 "id": 1, 9567 "avatar_url": "a", 9568 "gravatar_id": "g", 9569 "name": "n", 9570 "company": "c", 9571 "blog": "b", 9572 "location": "l", 9573 "email": "e", 9574 "hireable": true, 9575 "bio": "b", 9576 "twitter_username": "t", 9577 "public_repos": 1, 9578 "followers": 1, 9579 "following": 1, 9580 "created_at": ` + referenceTimeStr + `, 9581 "suspended_at": ` + referenceTimeStr + `, 9582 "url": "u" 9583 }, 9584 "access_tokens_url": "atu", 9585 "repositories_url": "ru", 9586 "html_url": "hu", 9587 "target_type": "tt", 9588 "single_file_name": "sfn", 9589 "repository_selection": "rs", 9590 "events": [ 9591 "e" 9592 ], 9593 "single_file_paths": [ 9594 "s" 9595 ], 9596 "permissions": { 9597 "actions": "a", 9598 "administration": "ad", 9599 "checks": "c", 9600 "contents": "co", 9601 "content_references": "cr", 9602 "deployments": "d", 9603 "environments": "e", 9604 "issues": "i", 9605 "metadata": "md", 9606 "members": "m", 9607 "organization_administration": "oa", 9608 "organization_hooks": "oh", 9609 "organization_plan": "op", 9610 "organization_pre_receive_hooks": "opr", 9611 "organization_projects": "op", 9612 "organization_secrets": "os", 9613 "organization_self_hosted_runners": "osh", 9614 "organization_user_blocking": "oub", 9615 "packages": "pkg", 9616 "pages": "pg", 9617 "pull_requests": "pr", 9618 "repository_hooks": "rh", 9619 "repository_projects": "rp", 9620 "repository_pre_receive_hooks": "rprh", 9621 "secrets": "s", 9622 "secret_scanning_alerts": "ssa", 9623 "security_events": "se", 9624 "single_file": "sf", 9625 "statuses": "s", 9626 "team_discussions": "td", 9627 "vulnerability_alerts": "va", 9628 "workflows": "w" 9629 }, 9630 "created_at": ` + referenceTimeStr + `, 9631 "updated_at": ` + referenceTimeStr + `, 9632 "has_multiple_single_files": false, 9633 "suspended_by": { 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 "suspended_at": ` + referenceTimeStr + ` 9654 } 9655 }` 9656 9657 testJSONMarshal(t, u, want) 9658 } 9659 9660 func TestUserEvent_Marshal(t *testing.T) { 9661 testJSONMarshal(t, &UserEvent{}, "{}") 9662 9663 u := &UserEvent{ 9664 User: &User{ 9665 Login: String("l"), 9666 ID: Int64(1), 9667 NodeID: String("n"), 9668 URL: String("u"), 9669 ReposURL: String("r"), 9670 EventsURL: String("e"), 9671 AvatarURL: String("a"), 9672 }, 9673 // The action performed. Possible values are: "created" or "deleted". 9674 Action: String("a"), 9675 Enterprise: &Enterprise{ 9676 ID: Int(1), 9677 Slug: String("s"), 9678 Name: String("n"), 9679 NodeID: String("nid"), 9680 AvatarURL: String("au"), 9681 Description: String("d"), 9682 WebsiteURL: String("wu"), 9683 HTMLURL: String("hu"), 9684 CreatedAt: &Timestamp{referenceTime}, 9685 UpdatedAt: &Timestamp{referenceTime}, 9686 }, 9687 Sender: &User{ 9688 Login: String("l"), 9689 ID: Int64(1), 9690 NodeID: String("n"), 9691 URL: String("u"), 9692 ReposURL: String("r"), 9693 EventsURL: String("e"), 9694 AvatarURL: String("a"), 9695 }, 9696 } 9697 9698 want := `{ 9699 "user": { 9700 "login": "l", 9701 "id": 1, 9702 "node_id": "n", 9703 "avatar_url": "a", 9704 "url": "u", 9705 "events_url": "e", 9706 "repos_url": "r" 9707 }, 9708 "action": "a", 9709 "enterprise": { 9710 "id": 1, 9711 "slug": "s", 9712 "name": "n", 9713 "node_id": "nid", 9714 "avatar_url": "au", 9715 "description": "d", 9716 "website_url": "wu", 9717 "html_url": "hu", 9718 "created_at": ` + referenceTimeStr + `, 9719 "updated_at": ` + referenceTimeStr + ` 9720 }, 9721 "sender": { 9722 "login": "l", 9723 "id": 1, 9724 "node_id": "n", 9725 "avatar_url": "a", 9726 "url": "u", 9727 "events_url": "e", 9728 "repos_url": "r" 9729 } 9730 }` 9731 9732 testJSONMarshal(t, u, want) 9733 } 9734 9735 func TestCheckRunEvent_Marshal(t *testing.T) { 9736 testJSONMarshal(t, &CheckRunEvent{}, "{}") 9737 9738 r := &CheckRunEvent{ 9739 CheckRun: &CheckRun{ 9740 ID: Int64(1), 9741 NodeID: String("n"), 9742 HeadSHA: String("h"), 9743 ExternalID: String("1"), 9744 URL: String("u"), 9745 HTMLURL: String("u"), 9746 DetailsURL: String("u"), 9747 Status: String("s"), 9748 Conclusion: String("c"), 9749 StartedAt: &Timestamp{referenceTime}, 9750 CompletedAt: &Timestamp{referenceTime}, 9751 Output: &CheckRunOutput{ 9752 Annotations: []*CheckRunAnnotation{ 9753 { 9754 AnnotationLevel: String("a"), 9755 EndLine: Int(1), 9756 Message: String("m"), 9757 Path: String("p"), 9758 RawDetails: String("r"), 9759 StartLine: Int(1), 9760 Title: String("t"), 9761 }, 9762 }, 9763 AnnotationsCount: Int(1), 9764 AnnotationsURL: String("a"), 9765 Images: []*CheckRunImage{ 9766 { 9767 Alt: String("a"), 9768 ImageURL: String("i"), 9769 Caption: String("c"), 9770 }, 9771 }, 9772 Title: String("t"), 9773 Summary: String("s"), 9774 Text: String("t"), 9775 }, 9776 Name: String("n"), 9777 CheckSuite: &CheckSuite{ 9778 ID: Int64(1), 9779 }, 9780 App: &App{ 9781 ID: Int64(1), 9782 NodeID: String("n"), 9783 Owner: &User{ 9784 Login: String("l"), 9785 ID: Int64(1), 9786 NodeID: String("n"), 9787 URL: String("u"), 9788 ReposURL: String("r"), 9789 EventsURL: String("e"), 9790 AvatarURL: String("a"), 9791 }, 9792 Name: String("n"), 9793 Description: String("d"), 9794 HTMLURL: String("h"), 9795 ExternalURL: String("u"), 9796 CreatedAt: &Timestamp{referenceTime}, 9797 UpdatedAt: &Timestamp{referenceTime}, 9798 }, 9799 PullRequests: []*PullRequest{ 9800 { 9801 URL: String("u"), 9802 ID: Int64(1), 9803 Number: Int(1), 9804 Head: &PullRequestBranch{ 9805 Ref: String("r"), 9806 SHA: String("s"), 9807 Repo: &Repository{ 9808 ID: Int64(1), 9809 URL: String("s"), 9810 Name: String("n"), 9811 }, 9812 }, 9813 Base: &PullRequestBranch{ 9814 Ref: String("r"), 9815 SHA: String("s"), 9816 Repo: &Repository{ 9817 ID: Int64(1), 9818 URL: String("u"), 9819 Name: String("n"), 9820 }, 9821 }, 9822 }, 9823 }, 9824 }, 9825 Action: String("a"), 9826 Repo: &Repository{ 9827 ID: Int64(1), 9828 URL: String("s"), 9829 Name: String("n"), 9830 }, 9831 Org: &Organization{ 9832 BillingEmail: String("be"), 9833 Blog: String("b"), 9834 Company: String("c"), 9835 Email: String("e"), 9836 TwitterUsername: String("tu"), 9837 Location: String("loc"), 9838 Name: String("n"), 9839 Description: String("d"), 9840 IsVerified: Bool(true), 9841 HasOrganizationProjects: Bool(true), 9842 HasRepositoryProjects: Bool(true), 9843 DefaultRepoPermission: String("drp"), 9844 MembersCanCreateRepos: Bool(true), 9845 MembersCanCreateInternalRepos: Bool(true), 9846 MembersCanCreatePrivateRepos: Bool(true), 9847 MembersCanCreatePublicRepos: Bool(false), 9848 MembersAllowedRepositoryCreationType: String("marct"), 9849 MembersCanCreatePages: Bool(true), 9850 MembersCanCreatePublicPages: Bool(false), 9851 MembersCanCreatePrivatePages: Bool(true), 9852 }, 9853 Sender: &User{ 9854 Login: String("l"), 9855 ID: Int64(1), 9856 NodeID: String("n"), 9857 URL: String("u"), 9858 ReposURL: String("r"), 9859 EventsURL: String("e"), 9860 AvatarURL: String("a"), 9861 }, 9862 Installation: &Installation{ 9863 ID: Int64(1), 9864 NodeID: String("nid"), 9865 AppID: Int64(1), 9866 AppSlug: String("as"), 9867 TargetID: Int64(1), 9868 Account: &User{ 9869 Login: String("l"), 9870 ID: Int64(1), 9871 URL: String("u"), 9872 AvatarURL: String("a"), 9873 GravatarID: String("g"), 9874 Name: String("n"), 9875 Company: String("c"), 9876 Blog: String("b"), 9877 Location: String("l"), 9878 Email: String("e"), 9879 Hireable: Bool(true), 9880 Bio: String("b"), 9881 TwitterUsername: String("t"), 9882 PublicRepos: Int(1), 9883 Followers: Int(1), 9884 Following: Int(1), 9885 CreatedAt: &Timestamp{referenceTime}, 9886 SuspendedAt: &Timestamp{referenceTime}, 9887 }, 9888 AccessTokensURL: String("atu"), 9889 RepositoriesURL: String("ru"), 9890 HTMLURL: String("hu"), 9891 TargetType: String("tt"), 9892 SingleFileName: String("sfn"), 9893 RepositorySelection: String("rs"), 9894 Events: []string{"e"}, 9895 SingleFilePaths: []string{"s"}, 9896 Permissions: &InstallationPermissions{ 9897 Actions: String("a"), 9898 Administration: String("ad"), 9899 Checks: String("c"), 9900 Contents: String("co"), 9901 ContentReferences: String("cr"), 9902 Deployments: String("d"), 9903 Environments: String("e"), 9904 Issues: String("i"), 9905 Metadata: String("md"), 9906 Members: String("m"), 9907 OrganizationAdministration: String("oa"), 9908 OrganizationHooks: String("oh"), 9909 OrganizationPlan: String("op"), 9910 OrganizationPreReceiveHooks: String("opr"), 9911 OrganizationProjects: String("op"), 9912 OrganizationSecrets: String("os"), 9913 OrganizationSelfHostedRunners: String("osh"), 9914 OrganizationUserBlocking: String("oub"), 9915 Packages: String("pkg"), 9916 Pages: String("pg"), 9917 PullRequests: String("pr"), 9918 RepositoryHooks: String("rh"), 9919 RepositoryProjects: String("rp"), 9920 RepositoryPreReceiveHooks: String("rprh"), 9921 Secrets: String("s"), 9922 SecretScanningAlerts: String("ssa"), 9923 SecurityEvents: String("se"), 9924 SingleFile: String("sf"), 9925 Statuses: String("s"), 9926 TeamDiscussions: String("td"), 9927 VulnerabilityAlerts: String("va"), 9928 Workflows: String("w"), 9929 }, 9930 CreatedAt: &Timestamp{referenceTime}, 9931 UpdatedAt: &Timestamp{referenceTime}, 9932 HasMultipleSingleFiles: Bool(false), 9933 SuspendedBy: &User{ 9934 Login: String("l"), 9935 ID: Int64(1), 9936 URL: String("u"), 9937 AvatarURL: String("a"), 9938 GravatarID: String("g"), 9939 Name: String("n"), 9940 Company: String("c"), 9941 Blog: String("b"), 9942 Location: String("l"), 9943 Email: String("e"), 9944 Hireable: Bool(true), 9945 Bio: String("b"), 9946 TwitterUsername: String("t"), 9947 PublicRepos: Int(1), 9948 Followers: Int(1), 9949 Following: Int(1), 9950 CreatedAt: &Timestamp{referenceTime}, 9951 SuspendedAt: &Timestamp{referenceTime}, 9952 }, 9953 SuspendedAt: &Timestamp{referenceTime}, 9954 }, 9955 RequestedAction: &RequestedAction{ 9956 Identifier: "i", 9957 }, 9958 } 9959 9960 want := `{ 9961 "check_run": { 9962 "id": 1, 9963 "node_id": "n", 9964 "head_sha": "h", 9965 "external_id": "1", 9966 "url": "u", 9967 "html_url": "u", 9968 "details_url": "u", 9969 "status": "s", 9970 "conclusion": "c", 9971 "started_at": ` + referenceTimeStr + `, 9972 "completed_at": ` + referenceTimeStr + `, 9973 "output": { 9974 "title": "t", 9975 "summary": "s", 9976 "text": "t", 9977 "annotations_count": 1, 9978 "annotations_url": "a", 9979 "annotations": [ 9980 { 9981 "path": "p", 9982 "start_line": 1, 9983 "end_line": 1, 9984 "annotation_level": "a", 9985 "message": "m", 9986 "title": "t", 9987 "raw_details": "r" 9988 } 9989 ], 9990 "images": [ 9991 { 9992 "alt": "a", 9993 "image_url": "i", 9994 "caption": "c" 9995 } 9996 ] 9997 }, 9998 "name": "n", 9999 "check_suite": { 10000 "id": 1 10001 }, 10002 "app": { 10003 "id": 1, 10004 "node_id": "n", 10005 "owner": { 10006 "login": "l", 10007 "id": 1, 10008 "node_id": "n", 10009 "avatar_url": "a", 10010 "url": "u", 10011 "events_url": "e", 10012 "repos_url": "r" 10013 }, 10014 "name": "n", 10015 "description": "d", 10016 "external_url": "u", 10017 "html_url": "h", 10018 "created_at": ` + referenceTimeStr + `, 10019 "updated_at": ` + referenceTimeStr + ` 10020 }, 10021 "pull_requests": [ 10022 { 10023 "id": 1, 10024 "number": 1, 10025 "url": "u", 10026 "head": { 10027 "ref": "r", 10028 "sha": "s", 10029 "repo": { 10030 "id": 1, 10031 "name": "n", 10032 "url": "s" 10033 } 10034 }, 10035 "base": { 10036 "ref": "r", 10037 "sha": "s", 10038 "repo": { 10039 "id": 1, 10040 "name": "n", 10041 "url": "u" 10042 } 10043 } 10044 } 10045 ] 10046 }, 10047 "action": "a", 10048 "repository": { 10049 "id": 1, 10050 "name": "n", 10051 "url": "s" 10052 }, 10053 "organization": { 10054 "name": "n", 10055 "company": "c", 10056 "blog": "b", 10057 "location": "loc", 10058 "email": "e", 10059 "twitter_username": "tu", 10060 "description": "d", 10061 "billing_email": "be", 10062 "is_verified": true, 10063 "has_organization_projects": true, 10064 "has_repository_projects": true, 10065 "default_repository_permission": "drp", 10066 "members_can_create_repositories": true, 10067 "members_can_create_public_repositories": false, 10068 "members_can_create_private_repositories": true, 10069 "members_can_create_internal_repositories": true, 10070 "members_allowed_repository_creation_type": "marct", 10071 "members_can_create_pages": true, 10072 "members_can_create_public_pages": false, 10073 "members_can_create_private_pages": true 10074 }, 10075 "sender": { 10076 "login": "l", 10077 "id": 1, 10078 "node_id": "n", 10079 "avatar_url": "a", 10080 "url": "u", 10081 "events_url": "e", 10082 "repos_url": "r" 10083 }, 10084 "installation": { 10085 "id": 1, 10086 "node_id": "nid", 10087 "app_id": 1, 10088 "app_slug": "as", 10089 "target_id": 1, 10090 "account": { 10091 "login": "l", 10092 "id": 1, 10093 "avatar_url": "a", 10094 "gravatar_id": "g", 10095 "name": "n", 10096 "company": "c", 10097 "blog": "b", 10098 "location": "l", 10099 "email": "e", 10100 "hireable": true, 10101 "bio": "b", 10102 "twitter_username": "t", 10103 "public_repos": 1, 10104 "followers": 1, 10105 "following": 1, 10106 "created_at": ` + referenceTimeStr + `, 10107 "suspended_at": ` + referenceTimeStr + `, 10108 "url": "u" 10109 }, 10110 "access_tokens_url": "atu", 10111 "repositories_url": "ru", 10112 "html_url": "hu", 10113 "target_type": "tt", 10114 "single_file_name": "sfn", 10115 "repository_selection": "rs", 10116 "events": [ 10117 "e" 10118 ], 10119 "single_file_paths": [ 10120 "s" 10121 ], 10122 "permissions": { 10123 "actions": "a", 10124 "administration": "ad", 10125 "checks": "c", 10126 "contents": "co", 10127 "content_references": "cr", 10128 "deployments": "d", 10129 "environments": "e", 10130 "issues": "i", 10131 "metadata": "md", 10132 "members": "m", 10133 "organization_administration": "oa", 10134 "organization_hooks": "oh", 10135 "organization_plan": "op", 10136 "organization_pre_receive_hooks": "opr", 10137 "organization_projects": "op", 10138 "organization_secrets": "os", 10139 "organization_self_hosted_runners": "osh", 10140 "organization_user_blocking": "oub", 10141 "packages": "pkg", 10142 "pages": "pg", 10143 "pull_requests": "pr", 10144 "repository_hooks": "rh", 10145 "repository_projects": "rp", 10146 "repository_pre_receive_hooks": "rprh", 10147 "secrets": "s", 10148 "secret_scanning_alerts": "ssa", 10149 "security_events": "se", 10150 "single_file": "sf", 10151 "statuses": "s", 10152 "team_discussions": "td", 10153 "vulnerability_alerts": "va", 10154 "workflows": "w" 10155 }, 10156 "created_at": ` + referenceTimeStr + `, 10157 "updated_at": ` + referenceTimeStr + `, 10158 "has_multiple_single_files": false, 10159 "suspended_by": { 10160 "login": "l", 10161 "id": 1, 10162 "avatar_url": "a", 10163 "gravatar_id": "g", 10164 "name": "n", 10165 "company": "c", 10166 "blog": "b", 10167 "location": "l", 10168 "email": "e", 10169 "hireable": true, 10170 "bio": "b", 10171 "twitter_username": "t", 10172 "public_repos": 1, 10173 "followers": 1, 10174 "following": 1, 10175 "created_at": ` + referenceTimeStr + `, 10176 "suspended_at": ` + referenceTimeStr + `, 10177 "url": "u" 10178 }, 10179 "suspended_at": ` + referenceTimeStr + ` 10180 }, 10181 "requested_action": { 10182 "identifier": "i" 10183 } 10184 }` 10185 10186 testJSONMarshal(t, r, want) 10187 } 10188 10189 func TestCheckSuiteEvent_Marshal(t *testing.T) { 10190 testJSONMarshal(t, &CheckSuiteEvent{}, "{}") 10191 10192 r := &CheckSuiteEvent{ 10193 CheckSuite: &CheckSuite{ 10194 ID: Int64(1), 10195 NodeID: String("n"), 10196 HeadBranch: String("h"), 10197 HeadSHA: String("h"), 10198 URL: String("u"), 10199 BeforeSHA: String("b"), 10200 AfterSHA: String("a"), 10201 Status: String("s"), 10202 Conclusion: String("c"), 10203 App: &App{ 10204 ID: Int64(1), 10205 NodeID: String("n"), 10206 Owner: &User{ 10207 Login: String("l"), 10208 ID: Int64(1), 10209 NodeID: String("n"), 10210 URL: String("u"), 10211 ReposURL: String("r"), 10212 EventsURL: String("e"), 10213 AvatarURL: String("a"), 10214 }, 10215 Name: String("n"), 10216 Description: String("d"), 10217 HTMLURL: String("h"), 10218 ExternalURL: String("u"), 10219 CreatedAt: &Timestamp{referenceTime}, 10220 UpdatedAt: &Timestamp{referenceTime}, 10221 }, 10222 Repository: &Repository{ 10223 ID: Int64(1), 10224 }, 10225 PullRequests: []*PullRequest{ 10226 { 10227 URL: String("u"), 10228 ID: Int64(1), 10229 Number: Int(1), 10230 Head: &PullRequestBranch{ 10231 Ref: String("r"), 10232 SHA: String("s"), 10233 Repo: &Repository{ 10234 ID: Int64(1), 10235 URL: String("s"), 10236 Name: String("n"), 10237 }, 10238 }, 10239 Base: &PullRequestBranch{ 10240 Ref: String("r"), 10241 SHA: String("s"), 10242 Repo: &Repository{ 10243 ID: Int64(1), 10244 URL: String("u"), 10245 Name: String("n"), 10246 }, 10247 }, 10248 }, 10249 }, 10250 HeadCommit: &Commit{ 10251 SHA: String("s"), 10252 }, 10253 }, 10254 Action: String("a"), 10255 Repo: &Repository{ 10256 ID: Int64(1), 10257 URL: String("s"), 10258 Name: String("n"), 10259 }, 10260 Org: &Organization{ 10261 BillingEmail: String("be"), 10262 Blog: String("b"), 10263 Company: String("c"), 10264 Email: String("e"), 10265 TwitterUsername: String("tu"), 10266 Location: String("loc"), 10267 Name: String("n"), 10268 Description: String("d"), 10269 IsVerified: Bool(true), 10270 HasOrganizationProjects: Bool(true), 10271 HasRepositoryProjects: Bool(true), 10272 DefaultRepoPermission: String("drp"), 10273 MembersCanCreateRepos: Bool(true), 10274 MembersCanCreateInternalRepos: Bool(true), 10275 MembersCanCreatePrivateRepos: Bool(true), 10276 MembersCanCreatePublicRepos: Bool(false), 10277 MembersAllowedRepositoryCreationType: String("marct"), 10278 MembersCanCreatePages: Bool(true), 10279 MembersCanCreatePublicPages: Bool(false), 10280 MembersCanCreatePrivatePages: Bool(true), 10281 }, 10282 Sender: &User{ 10283 Login: String("l"), 10284 ID: Int64(1), 10285 NodeID: String("n"), 10286 URL: String("u"), 10287 ReposURL: String("r"), 10288 EventsURL: String("e"), 10289 AvatarURL: String("a"), 10290 }, 10291 Installation: &Installation{ 10292 ID: Int64(1), 10293 NodeID: String("nid"), 10294 AppID: Int64(1), 10295 AppSlug: String("as"), 10296 TargetID: Int64(1), 10297 Account: &User{ 10298 Login: String("l"), 10299 ID: Int64(1), 10300 URL: String("u"), 10301 AvatarURL: String("a"), 10302 GravatarID: String("g"), 10303 Name: String("n"), 10304 Company: String("c"), 10305 Blog: String("b"), 10306 Location: String("l"), 10307 Email: String("e"), 10308 Hireable: Bool(true), 10309 Bio: String("b"), 10310 TwitterUsername: String("t"), 10311 PublicRepos: Int(1), 10312 Followers: Int(1), 10313 Following: Int(1), 10314 CreatedAt: &Timestamp{referenceTime}, 10315 SuspendedAt: &Timestamp{referenceTime}, 10316 }, 10317 AccessTokensURL: String("atu"), 10318 RepositoriesURL: String("ru"), 10319 HTMLURL: String("hu"), 10320 TargetType: String("tt"), 10321 SingleFileName: String("sfn"), 10322 RepositorySelection: String("rs"), 10323 Events: []string{"e"}, 10324 SingleFilePaths: []string{"s"}, 10325 Permissions: &InstallationPermissions{ 10326 Actions: String("a"), 10327 Administration: String("ad"), 10328 Checks: String("c"), 10329 Contents: String("co"), 10330 ContentReferences: String("cr"), 10331 Deployments: String("d"), 10332 Environments: String("e"), 10333 Issues: String("i"), 10334 Metadata: String("md"), 10335 Members: String("m"), 10336 OrganizationAdministration: String("oa"), 10337 OrganizationHooks: String("oh"), 10338 OrganizationPlan: String("op"), 10339 OrganizationPreReceiveHooks: String("opr"), 10340 OrganizationProjects: String("op"), 10341 OrganizationSecrets: String("os"), 10342 OrganizationSelfHostedRunners: String("osh"), 10343 OrganizationUserBlocking: String("oub"), 10344 Packages: String("pkg"), 10345 Pages: String("pg"), 10346 PullRequests: String("pr"), 10347 RepositoryHooks: String("rh"), 10348 RepositoryProjects: String("rp"), 10349 RepositoryPreReceiveHooks: String("rprh"), 10350 Secrets: String("s"), 10351 SecretScanningAlerts: String("ssa"), 10352 SecurityEvents: String("se"), 10353 SingleFile: String("sf"), 10354 Statuses: String("s"), 10355 TeamDiscussions: String("td"), 10356 VulnerabilityAlerts: String("va"), 10357 Workflows: String("w"), 10358 }, 10359 CreatedAt: &Timestamp{referenceTime}, 10360 UpdatedAt: &Timestamp{referenceTime}, 10361 HasMultipleSingleFiles: Bool(false), 10362 SuspendedBy: &User{ 10363 Login: String("l"), 10364 ID: Int64(1), 10365 URL: String("u"), 10366 AvatarURL: String("a"), 10367 GravatarID: String("g"), 10368 Name: String("n"), 10369 Company: String("c"), 10370 Blog: String("b"), 10371 Location: String("l"), 10372 Email: String("e"), 10373 Hireable: Bool(true), 10374 Bio: String("b"), 10375 TwitterUsername: String("t"), 10376 PublicRepos: Int(1), 10377 Followers: Int(1), 10378 Following: Int(1), 10379 CreatedAt: &Timestamp{referenceTime}, 10380 SuspendedAt: &Timestamp{referenceTime}, 10381 }, 10382 SuspendedAt: &Timestamp{referenceTime}, 10383 }, 10384 } 10385 10386 want := `{ 10387 "check_suite": { 10388 "id": 1, 10389 "node_id": "n", 10390 "head_branch": "h", 10391 "head_sha": "h", 10392 "url": "u", 10393 "before": "b", 10394 "after": "a", 10395 "status": "s", 10396 "conclusion": "c", 10397 "app": { 10398 "id": 1, 10399 "node_id": "n", 10400 "owner": { 10401 "login": "l", 10402 "id": 1, 10403 "node_id": "n", 10404 "avatar_url": "a", 10405 "url": "u", 10406 "events_url": "e", 10407 "repos_url": "r" 10408 }, 10409 "name": "n", 10410 "description": "d", 10411 "external_url": "u", 10412 "html_url": "h", 10413 "created_at": ` + referenceTimeStr + `, 10414 "updated_at": ` + referenceTimeStr + ` 10415 }, 10416 "repository": { 10417 "id": 1 10418 }, 10419 "pull_requests": [ 10420 { 10421 "id": 1, 10422 "number": 1, 10423 "url": "u", 10424 "head": { 10425 "ref": "r", 10426 "sha": "s", 10427 "repo": { 10428 "id": 1, 10429 "name": "n", 10430 "url": "s" 10431 } 10432 }, 10433 "base": { 10434 "ref": "r", 10435 "sha": "s", 10436 "repo": { 10437 "id": 1, 10438 "name": "n", 10439 "url": "u" 10440 } 10441 } 10442 } 10443 ], 10444 "head_commit": { 10445 "sha": "s" 10446 } 10447 }, 10448 "action": "a", 10449 "repository": { 10450 "id": 1, 10451 "name": "n", 10452 "url": "s" 10453 }, 10454 "organization": { 10455 "name": "n", 10456 "company": "c", 10457 "blog": "b", 10458 "location": "loc", 10459 "email": "e", 10460 "twitter_username": "tu", 10461 "description": "d", 10462 "billing_email": "be", 10463 "is_verified": true, 10464 "has_organization_projects": true, 10465 "has_repository_projects": true, 10466 "default_repository_permission": "drp", 10467 "members_can_create_repositories": true, 10468 "members_can_create_public_repositories": false, 10469 "members_can_create_private_repositories": true, 10470 "members_can_create_internal_repositories": true, 10471 "members_allowed_repository_creation_type": "marct", 10472 "members_can_create_pages": true, 10473 "members_can_create_public_pages": false, 10474 "members_can_create_private_pages": true 10475 }, 10476 "sender": { 10477 "login": "l", 10478 "id": 1, 10479 "node_id": "n", 10480 "avatar_url": "a", 10481 "url": "u", 10482 "events_url": "e", 10483 "repos_url": "r" 10484 }, 10485 "installation": { 10486 "id": 1, 10487 "node_id": "nid", 10488 "app_id": 1, 10489 "app_slug": "as", 10490 "target_id": 1, 10491 "account": { 10492 "login": "l", 10493 "id": 1, 10494 "avatar_url": "a", 10495 "gravatar_id": "g", 10496 "name": "n", 10497 "company": "c", 10498 "blog": "b", 10499 "location": "l", 10500 "email": "e", 10501 "hireable": true, 10502 "bio": "b", 10503 "twitter_username": "t", 10504 "public_repos": 1, 10505 "followers": 1, 10506 "following": 1, 10507 "created_at": ` + referenceTimeStr + `, 10508 "suspended_at": ` + referenceTimeStr + `, 10509 "url": "u" 10510 }, 10511 "access_tokens_url": "atu", 10512 "repositories_url": "ru", 10513 "html_url": "hu", 10514 "target_type": "tt", 10515 "single_file_name": "sfn", 10516 "repository_selection": "rs", 10517 "events": [ 10518 "e" 10519 ], 10520 "single_file_paths": [ 10521 "s" 10522 ], 10523 "permissions": { 10524 "actions": "a", 10525 "administration": "ad", 10526 "checks": "c", 10527 "contents": "co", 10528 "content_references": "cr", 10529 "deployments": "d", 10530 "environments": "e", 10531 "issues": "i", 10532 "metadata": "md", 10533 "members": "m", 10534 "organization_administration": "oa", 10535 "organization_hooks": "oh", 10536 "organization_plan": "op", 10537 "organization_pre_receive_hooks": "opr", 10538 "organization_projects": "op", 10539 "organization_secrets": "os", 10540 "organization_self_hosted_runners": "osh", 10541 "organization_user_blocking": "oub", 10542 "packages": "pkg", 10543 "pages": "pg", 10544 "pull_requests": "pr", 10545 "repository_hooks": "rh", 10546 "repository_projects": "rp", 10547 "repository_pre_receive_hooks": "rprh", 10548 "secrets": "s", 10549 "secret_scanning_alerts": "ssa", 10550 "security_events": "se", 10551 "single_file": "sf", 10552 "statuses": "s", 10553 "team_discussions": "td", 10554 "vulnerability_alerts": "va", 10555 "workflows": "w" 10556 }, 10557 "created_at": ` + referenceTimeStr + `, 10558 "updated_at": ` + referenceTimeStr + `, 10559 "has_multiple_single_files": false, 10560 "suspended_by": { 10561 "login": "l", 10562 "id": 1, 10563 "avatar_url": "a", 10564 "gravatar_id": "g", 10565 "name": "n", 10566 "company": "c", 10567 "blog": "b", 10568 "location": "l", 10569 "email": "e", 10570 "hireable": true, 10571 "bio": "b", 10572 "twitter_username": "t", 10573 "public_repos": 1, 10574 "followers": 1, 10575 "following": 1, 10576 "created_at": ` + referenceTimeStr + `, 10577 "suspended_at": ` + referenceTimeStr + `, 10578 "url": "u" 10579 }, 10580 "suspended_at": ` + referenceTimeStr + ` 10581 } 10582 }` 10583 10584 testJSONMarshal(t, r, want) 10585 } 10586 10587 func TestDeployKeyEvent_Marshal(t *testing.T) { 10588 testJSONMarshal(t, &DeployKeyEvent{}, "{}") 10589 10590 u := &DeployKeyEvent{ 10591 Action: String("a"), 10592 Key: &Key{ 10593 ID: Int64(1), 10594 Key: String("k"), 10595 URL: String("k"), 10596 Title: String("k"), 10597 ReadOnly: Bool(false), 10598 Verified: Bool(false), 10599 CreatedAt: &Timestamp{referenceTime}, 10600 }, 10601 Repo: &Repository{ 10602 ID: Int64(1), 10603 URL: String("s"), 10604 Name: String("n"), 10605 }, 10606 Organization: &Organization{ 10607 BillingEmail: String("be"), 10608 Blog: String("b"), 10609 Company: String("c"), 10610 Email: String("e"), 10611 TwitterUsername: String("tu"), 10612 Location: String("loc"), 10613 Name: String("n"), 10614 Description: String("d"), 10615 IsVerified: Bool(true), 10616 HasOrganizationProjects: Bool(true), 10617 HasRepositoryProjects: Bool(true), 10618 DefaultRepoPermission: String("drp"), 10619 MembersCanCreateRepos: Bool(true), 10620 MembersCanCreateInternalRepos: Bool(true), 10621 MembersCanCreatePrivateRepos: Bool(true), 10622 MembersCanCreatePublicRepos: Bool(false), 10623 MembersAllowedRepositoryCreationType: String("marct"), 10624 MembersCanCreatePages: Bool(true), 10625 MembersCanCreatePublicPages: Bool(false), 10626 MembersCanCreatePrivatePages: Bool(true), 10627 }, 10628 Sender: &User{ 10629 Login: String("l"), 10630 ID: Int64(1), 10631 NodeID: String("n"), 10632 AvatarURL: String("a"), 10633 URL: String("u"), 10634 EventsURL: String("e"), 10635 ReposURL: String("r"), 10636 }, 10637 } 10638 10639 want := `{ 10640 "action": "a", 10641 "key": { 10642 "id": 1, 10643 "key": "k", 10644 "url": "k", 10645 "title": "k", 10646 "read_only": false, 10647 "verified": false, 10648 "created_at": ` + referenceTimeStr + ` 10649 }, 10650 "repository": { 10651 "id": 1, 10652 "name": "n", 10653 "url": "s" 10654 }, 10655 "organization": { 10656 "name": "n", 10657 "company": "c", 10658 "blog": "b", 10659 "location": "loc", 10660 "email": "e", 10661 "twitter_username": "tu", 10662 "description": "d", 10663 "billing_email": "be", 10664 "is_verified": true, 10665 "has_organization_projects": true, 10666 "has_repository_projects": true, 10667 "default_repository_permission": "drp", 10668 "members_can_create_repositories": true, 10669 "members_can_create_public_repositories": false, 10670 "members_can_create_private_repositories": true, 10671 "members_can_create_internal_repositories": true, 10672 "members_allowed_repository_creation_type": "marct", 10673 "members_can_create_pages": true, 10674 "members_can_create_public_pages": false, 10675 "members_can_create_private_pages": true 10676 }, 10677 "sender": { 10678 "login": "l", 10679 "id": 1, 10680 "node_id": "n", 10681 "avatar_url": "a", 10682 "url": "u", 10683 "events_url": "e", 10684 "repos_url": "r" 10685 } 10686 }` 10687 10688 testJSONMarshal(t, u, want) 10689 } 10690 10691 func TestMetaEvent_Marshal(t *testing.T) { 10692 testJSONMarshal(t, &MetaEvent{}, "{}") 10693 10694 v := make(map[string]interface{}) 10695 v["a"] = "b" 10696 10697 u := &MetaEvent{ 10698 Action: String("a"), 10699 HookID: Int64(1), 10700 Hook: &Hook{ 10701 CreatedAt: &referenceTime, 10702 UpdatedAt: &referenceTime, 10703 URL: String("u"), 10704 ID: Int64(1), 10705 Type: String("t"), 10706 Name: String("n"), 10707 TestURL: String("tu"), 10708 PingURL: String("pu"), 10709 LastResponse: v, 10710 Config: v, 10711 Events: []string{"a"}, 10712 Active: Bool(true), 10713 }, 10714 } 10715 10716 want := `{ 10717 "action": "a", 10718 "hook_id": 1, 10719 "hook": { 10720 "created_at": ` + referenceTimeStr + `, 10721 "updated_at": ` + referenceTimeStr + `, 10722 "url": "u", 10723 "id": 1, 10724 "type": "t", 10725 "name": "n", 10726 "test_url": "tu", 10727 "ping_url": "pu", 10728 "last_response": { 10729 "a": "b" 10730 }, 10731 "config": { 10732 "a": "b" 10733 }, 10734 "events": [ 10735 "a" 10736 ], 10737 "active": true 10738 } 10739 }` 10740 10741 testJSONMarshal(t, u, want) 10742 } 10743 10744 func TestRequestedAction_Marshal(t *testing.T) { 10745 testJSONMarshal(t, &RequestedAction{}, "{}") 10746 10747 r := &RequestedAction{ 10748 Identifier: "i", 10749 } 10750 10751 want := `{ 10752 "identifier": "i" 10753 }` 10754 10755 testJSONMarshal(t, r, want) 10756 } 10757 10758 func TestCreateEvent_Marshal(t *testing.T) { 10759 testJSONMarshal(t, &CreateEvent{}, "{}") 10760 10761 r := &CreateEvent{ 10762 Ref: String("r"), 10763 RefType: String("rt"), 10764 MasterBranch: String("mb"), 10765 Description: String("d"), 10766 PusherType: String("pt"), 10767 Repo: &Repository{ 10768 ID: Int64(1), 10769 URL: String("s"), 10770 Name: String("n"), 10771 }, 10772 Sender: &User{ 10773 Login: String("l"), 10774 ID: Int64(1), 10775 NodeID: String("n"), 10776 URL: String("u"), 10777 ReposURL: String("r"), 10778 EventsURL: String("e"), 10779 AvatarURL: String("a"), 10780 }, 10781 Installation: &Installation{ 10782 ID: Int64(1), 10783 NodeID: String("nid"), 10784 AppID: Int64(1), 10785 AppSlug: String("as"), 10786 TargetID: Int64(1), 10787 Account: &User{ 10788 Login: String("l"), 10789 ID: Int64(1), 10790 URL: String("u"), 10791 AvatarURL: String("a"), 10792 GravatarID: String("g"), 10793 Name: String("n"), 10794 Company: String("c"), 10795 Blog: String("b"), 10796 Location: String("l"), 10797 Email: String("e"), 10798 Hireable: Bool(true), 10799 Bio: String("b"), 10800 TwitterUsername: String("t"), 10801 PublicRepos: Int(1), 10802 Followers: Int(1), 10803 Following: Int(1), 10804 CreatedAt: &Timestamp{referenceTime}, 10805 SuspendedAt: &Timestamp{referenceTime}, 10806 }, 10807 AccessTokensURL: String("atu"), 10808 RepositoriesURL: String("ru"), 10809 HTMLURL: String("hu"), 10810 TargetType: String("tt"), 10811 SingleFileName: String("sfn"), 10812 RepositorySelection: String("rs"), 10813 Events: []string{"e"}, 10814 SingleFilePaths: []string{"s"}, 10815 Permissions: &InstallationPermissions{ 10816 Actions: String("a"), 10817 Administration: String("ad"), 10818 Checks: String("c"), 10819 Contents: String("co"), 10820 ContentReferences: String("cr"), 10821 Deployments: String("d"), 10822 Environments: String("e"), 10823 Issues: String("i"), 10824 Metadata: String("md"), 10825 Members: String("m"), 10826 OrganizationAdministration: String("oa"), 10827 OrganizationHooks: String("oh"), 10828 OrganizationPlan: String("op"), 10829 OrganizationPreReceiveHooks: String("opr"), 10830 OrganizationProjects: String("op"), 10831 OrganizationSecrets: String("os"), 10832 OrganizationSelfHostedRunners: String("osh"), 10833 OrganizationUserBlocking: String("oub"), 10834 Packages: String("pkg"), 10835 Pages: String("pg"), 10836 PullRequests: String("pr"), 10837 RepositoryHooks: String("rh"), 10838 RepositoryProjects: String("rp"), 10839 RepositoryPreReceiveHooks: String("rprh"), 10840 Secrets: String("s"), 10841 SecretScanningAlerts: String("ssa"), 10842 SecurityEvents: String("se"), 10843 SingleFile: String("sf"), 10844 Statuses: String("s"), 10845 TeamDiscussions: String("td"), 10846 VulnerabilityAlerts: String("va"), 10847 Workflows: String("w"), 10848 }, 10849 CreatedAt: &Timestamp{referenceTime}, 10850 UpdatedAt: &Timestamp{referenceTime}, 10851 HasMultipleSingleFiles: Bool(false), 10852 SuspendedBy: &User{ 10853 Login: String("l"), 10854 ID: Int64(1), 10855 URL: String("u"), 10856 AvatarURL: String("a"), 10857 GravatarID: String("g"), 10858 Name: String("n"), 10859 Company: String("c"), 10860 Blog: String("b"), 10861 Location: String("l"), 10862 Email: String("e"), 10863 Hireable: Bool(true), 10864 Bio: String("b"), 10865 TwitterUsername: String("t"), 10866 PublicRepos: Int(1), 10867 Followers: Int(1), 10868 Following: Int(1), 10869 CreatedAt: &Timestamp{referenceTime}, 10870 SuspendedAt: &Timestamp{referenceTime}, 10871 }, 10872 SuspendedAt: &Timestamp{referenceTime}, 10873 }, 10874 } 10875 10876 want := `{ 10877 "ref": "r", 10878 "ref_type": "rt", 10879 "master_branch": "mb", 10880 "description": "d", 10881 "pusher_type": "pt", 10882 "repository": { 10883 "id": 1, 10884 "name": "n", 10885 "url": "s" 10886 }, 10887 "sender": { 10888 "login": "l", 10889 "id": 1, 10890 "node_id": "n", 10891 "avatar_url": "a", 10892 "url": "u", 10893 "events_url": "e", 10894 "repos_url": "r" 10895 }, 10896 "installation": { 10897 "id": 1, 10898 "node_id": "nid", 10899 "app_id": 1, 10900 "app_slug": "as", 10901 "target_id": 1, 10902 "account": { 10903 "login": "l", 10904 "id": 1, 10905 "avatar_url": "a", 10906 "gravatar_id": "g", 10907 "name": "n", 10908 "company": "c", 10909 "blog": "b", 10910 "location": "l", 10911 "email": "e", 10912 "hireable": true, 10913 "bio": "b", 10914 "twitter_username": "t", 10915 "public_repos": 1, 10916 "followers": 1, 10917 "following": 1, 10918 "created_at": ` + referenceTimeStr + `, 10919 "suspended_at": ` + referenceTimeStr + `, 10920 "url": "u" 10921 }, 10922 "access_tokens_url": "atu", 10923 "repositories_url": "ru", 10924 "html_url": "hu", 10925 "target_type": "tt", 10926 "single_file_name": "sfn", 10927 "repository_selection": "rs", 10928 "events": [ 10929 "e" 10930 ], 10931 "single_file_paths": [ 10932 "s" 10933 ], 10934 "permissions": { 10935 "actions": "a", 10936 "administration": "ad", 10937 "checks": "c", 10938 "contents": "co", 10939 "content_references": "cr", 10940 "deployments": "d", 10941 "environments": "e", 10942 "issues": "i", 10943 "metadata": "md", 10944 "members": "m", 10945 "organization_administration": "oa", 10946 "organization_hooks": "oh", 10947 "organization_plan": "op", 10948 "organization_pre_receive_hooks": "opr", 10949 "organization_projects": "op", 10950 "organization_secrets": "os", 10951 "organization_self_hosted_runners": "osh", 10952 "organization_user_blocking": "oub", 10953 "packages": "pkg", 10954 "pages": "pg", 10955 "pull_requests": "pr", 10956 "repository_hooks": "rh", 10957 "repository_projects": "rp", 10958 "repository_pre_receive_hooks": "rprh", 10959 "secrets": "s", 10960 "secret_scanning_alerts": "ssa", 10961 "security_events": "se", 10962 "single_file": "sf", 10963 "statuses": "s", 10964 "team_discussions": "td", 10965 "vulnerability_alerts": "va", 10966 "workflows": "w" 10967 }, 10968 "created_at": ` + referenceTimeStr + `, 10969 "updated_at": ` + referenceTimeStr + `, 10970 "has_multiple_single_files": false, 10971 "suspended_by": { 10972 "login": "l", 10973 "id": 1, 10974 "avatar_url": "a", 10975 "gravatar_id": "g", 10976 "name": "n", 10977 "company": "c", 10978 "blog": "b", 10979 "location": "l", 10980 "email": "e", 10981 "hireable": true, 10982 "bio": "b", 10983 "twitter_username": "t", 10984 "public_repos": 1, 10985 "followers": 1, 10986 "following": 1, 10987 "created_at": ` + referenceTimeStr + `, 10988 "suspended_at": ` + referenceTimeStr + `, 10989 "url": "u" 10990 }, 10991 "suspended_at": ` + referenceTimeStr + ` 10992 } 10993 }` 10994 10995 testJSONMarshal(t, r, want) 10996 } 10997 10998 func TestDeleteEvent_Marshal(t *testing.T) { 10999 testJSONMarshal(t, &DeleteEvent{}, "{}") 11000 11001 r := &DeleteEvent{ 11002 Ref: String("r"), 11003 RefType: String("rt"), 11004 PusherType: String("pt"), 11005 Repo: &Repository{ 11006 ID: Int64(1), 11007 URL: String("s"), 11008 Name: String("n"), 11009 }, 11010 Sender: &User{ 11011 Login: String("l"), 11012 ID: Int64(1), 11013 NodeID: String("n"), 11014 URL: String("u"), 11015 ReposURL: String("r"), 11016 EventsURL: String("e"), 11017 AvatarURL: String("a"), 11018 }, 11019 Installation: &Installation{ 11020 ID: Int64(1), 11021 NodeID: String("nid"), 11022 AppID: Int64(1), 11023 AppSlug: String("as"), 11024 TargetID: Int64(1), 11025 Account: &User{ 11026 Login: String("l"), 11027 ID: Int64(1), 11028 URL: String("u"), 11029 AvatarURL: String("a"), 11030 GravatarID: String("g"), 11031 Name: String("n"), 11032 Company: String("c"), 11033 Blog: String("b"), 11034 Location: String("l"), 11035 Email: String("e"), 11036 Hireable: Bool(true), 11037 Bio: String("b"), 11038 TwitterUsername: String("t"), 11039 PublicRepos: Int(1), 11040 Followers: Int(1), 11041 Following: Int(1), 11042 CreatedAt: &Timestamp{referenceTime}, 11043 SuspendedAt: &Timestamp{referenceTime}, 11044 }, 11045 AccessTokensURL: String("atu"), 11046 RepositoriesURL: String("ru"), 11047 HTMLURL: String("hu"), 11048 TargetType: String("tt"), 11049 SingleFileName: String("sfn"), 11050 RepositorySelection: String("rs"), 11051 Events: []string{"e"}, 11052 SingleFilePaths: []string{"s"}, 11053 Permissions: &InstallationPermissions{ 11054 Actions: String("a"), 11055 Administration: String("ad"), 11056 Checks: String("c"), 11057 Contents: String("co"), 11058 ContentReferences: String("cr"), 11059 Deployments: String("d"), 11060 Environments: String("e"), 11061 Issues: String("i"), 11062 Metadata: String("md"), 11063 Members: String("m"), 11064 OrganizationAdministration: String("oa"), 11065 OrganizationHooks: String("oh"), 11066 OrganizationPlan: String("op"), 11067 OrganizationPreReceiveHooks: String("opr"), 11068 OrganizationProjects: String("op"), 11069 OrganizationSecrets: String("os"), 11070 OrganizationSelfHostedRunners: String("osh"), 11071 OrganizationUserBlocking: String("oub"), 11072 Packages: String("pkg"), 11073 Pages: String("pg"), 11074 PullRequests: String("pr"), 11075 RepositoryHooks: String("rh"), 11076 RepositoryProjects: String("rp"), 11077 RepositoryPreReceiveHooks: String("rprh"), 11078 Secrets: String("s"), 11079 SecretScanningAlerts: String("ssa"), 11080 SecurityEvents: String("se"), 11081 SingleFile: String("sf"), 11082 Statuses: String("s"), 11083 TeamDiscussions: String("td"), 11084 VulnerabilityAlerts: String("va"), 11085 Workflows: String("w"), 11086 }, 11087 CreatedAt: &Timestamp{referenceTime}, 11088 UpdatedAt: &Timestamp{referenceTime}, 11089 HasMultipleSingleFiles: Bool(false), 11090 SuspendedBy: &User{ 11091 Login: String("l"), 11092 ID: Int64(1), 11093 URL: String("u"), 11094 AvatarURL: String("a"), 11095 GravatarID: String("g"), 11096 Name: String("n"), 11097 Company: String("c"), 11098 Blog: String("b"), 11099 Location: String("l"), 11100 Email: String("e"), 11101 Hireable: Bool(true), 11102 Bio: String("b"), 11103 TwitterUsername: String("t"), 11104 PublicRepos: Int(1), 11105 Followers: Int(1), 11106 Following: Int(1), 11107 CreatedAt: &Timestamp{referenceTime}, 11108 SuspendedAt: &Timestamp{referenceTime}, 11109 }, 11110 SuspendedAt: &Timestamp{referenceTime}, 11111 }, 11112 } 11113 11114 want := `{ 11115 "ref": "r", 11116 "ref_type": "rt", 11117 "pusher_type": "pt", 11118 "repository": { 11119 "id": 1, 11120 "name": "n", 11121 "url": "s" 11122 }, 11123 "sender": { 11124 "login": "l", 11125 "id": 1, 11126 "node_id": "n", 11127 "avatar_url": "a", 11128 "url": "u", 11129 "events_url": "e", 11130 "repos_url": "r" 11131 }, 11132 "installation": { 11133 "id": 1, 11134 "node_id": "nid", 11135 "app_id": 1, 11136 "app_slug": "as", 11137 "target_id": 1, 11138 "account": { 11139 "login": "l", 11140 "id": 1, 11141 "avatar_url": "a", 11142 "gravatar_id": "g", 11143 "name": "n", 11144 "company": "c", 11145 "blog": "b", 11146 "location": "l", 11147 "email": "e", 11148 "hireable": true, 11149 "bio": "b", 11150 "twitter_username": "t", 11151 "public_repos": 1, 11152 "followers": 1, 11153 "following": 1, 11154 "created_at": ` + referenceTimeStr + `, 11155 "suspended_at": ` + referenceTimeStr + `, 11156 "url": "u" 11157 }, 11158 "access_tokens_url": "atu", 11159 "repositories_url": "ru", 11160 "html_url": "hu", 11161 "target_type": "tt", 11162 "single_file_name": "sfn", 11163 "repository_selection": "rs", 11164 "events": [ 11165 "e" 11166 ], 11167 "single_file_paths": [ 11168 "s" 11169 ], 11170 "permissions": { 11171 "actions": "a", 11172 "administration": "ad", 11173 "checks": "c", 11174 "contents": "co", 11175 "content_references": "cr", 11176 "deployments": "d", 11177 "environments": "e", 11178 "issues": "i", 11179 "metadata": "md", 11180 "members": "m", 11181 "organization_administration": "oa", 11182 "organization_hooks": "oh", 11183 "organization_plan": "op", 11184 "organization_pre_receive_hooks": "opr", 11185 "organization_projects": "op", 11186 "organization_secrets": "os", 11187 "organization_self_hosted_runners": "osh", 11188 "organization_user_blocking": "oub", 11189 "packages": "pkg", 11190 "pages": "pg", 11191 "pull_requests": "pr", 11192 "repository_hooks": "rh", 11193 "repository_projects": "rp", 11194 "repository_pre_receive_hooks": "rprh", 11195 "secrets": "s", 11196 "secret_scanning_alerts": "ssa", 11197 "security_events": "se", 11198 "single_file": "sf", 11199 "statuses": "s", 11200 "team_discussions": "td", 11201 "vulnerability_alerts": "va", 11202 "workflows": "w" 11203 }, 11204 "created_at": ` + referenceTimeStr + `, 11205 "updated_at": ` + referenceTimeStr + `, 11206 "has_multiple_single_files": false, 11207 "suspended_by": { 11208 "login": "l", 11209 "id": 1, 11210 "avatar_url": "a", 11211 "gravatar_id": "g", 11212 "name": "n", 11213 "company": "c", 11214 "blog": "b", 11215 "location": "l", 11216 "email": "e", 11217 "hireable": true, 11218 "bio": "b", 11219 "twitter_username": "t", 11220 "public_repos": 1, 11221 "followers": 1, 11222 "following": 1, 11223 "created_at": ` + referenceTimeStr + `, 11224 "suspended_at": ` + referenceTimeStr + `, 11225 "url": "u" 11226 }, 11227 "suspended_at": ` + referenceTimeStr + ` 11228 } 11229 }` 11230 11231 testJSONMarshal(t, r, want) 11232 } 11233 11234 func TestForkEvent_Marshal(t *testing.T) { 11235 testJSONMarshal(t, &ForkEvent{}, "{}") 11236 11237 u := &ForkEvent{ 11238 Forkee: &Repository{ 11239 ID: Int64(1), 11240 URL: String("s"), 11241 Name: String("n"), 11242 }, 11243 Repo: &Repository{ 11244 ID: Int64(1), 11245 URL: String("s"), 11246 Name: String("n"), 11247 }, 11248 Sender: &User{ 11249 Login: String("l"), 11250 ID: Int64(1), 11251 NodeID: String("n"), 11252 URL: String("u"), 11253 ReposURL: String("r"), 11254 EventsURL: String("e"), 11255 AvatarURL: String("a"), 11256 }, 11257 Installation: &Installation{ 11258 ID: Int64(1), 11259 NodeID: String("nid"), 11260 AppID: Int64(1), 11261 AppSlug: String("as"), 11262 TargetID: Int64(1), 11263 Account: &User{ 11264 Login: String("l"), 11265 ID: Int64(1), 11266 URL: String("u"), 11267 AvatarURL: String("a"), 11268 GravatarID: String("g"), 11269 Name: String("n"), 11270 Company: String("c"), 11271 Blog: String("b"), 11272 Location: String("l"), 11273 Email: String("e"), 11274 Hireable: Bool(true), 11275 Bio: String("b"), 11276 TwitterUsername: String("t"), 11277 PublicRepos: Int(1), 11278 Followers: Int(1), 11279 Following: Int(1), 11280 CreatedAt: &Timestamp{referenceTime}, 11281 SuspendedAt: &Timestamp{referenceTime}, 11282 }, 11283 AccessTokensURL: String("atu"), 11284 RepositoriesURL: String("ru"), 11285 HTMLURL: String("hu"), 11286 TargetType: String("tt"), 11287 SingleFileName: String("sfn"), 11288 RepositorySelection: String("rs"), 11289 Events: []string{"e"}, 11290 SingleFilePaths: []string{"s"}, 11291 Permissions: &InstallationPermissions{ 11292 Actions: String("a"), 11293 Administration: String("ad"), 11294 Checks: String("c"), 11295 Contents: String("co"), 11296 ContentReferences: String("cr"), 11297 Deployments: String("d"), 11298 Environments: String("e"), 11299 Issues: String("i"), 11300 Metadata: String("md"), 11301 Members: String("m"), 11302 OrganizationAdministration: String("oa"), 11303 OrganizationHooks: String("oh"), 11304 OrganizationPlan: String("op"), 11305 OrganizationPreReceiveHooks: String("opr"), 11306 OrganizationProjects: String("op"), 11307 OrganizationSecrets: String("os"), 11308 OrganizationSelfHostedRunners: String("osh"), 11309 OrganizationUserBlocking: String("oub"), 11310 Packages: String("pkg"), 11311 Pages: String("pg"), 11312 PullRequests: String("pr"), 11313 RepositoryHooks: String("rh"), 11314 RepositoryProjects: String("rp"), 11315 RepositoryPreReceiveHooks: String("rprh"), 11316 Secrets: String("s"), 11317 SecretScanningAlerts: String("ssa"), 11318 SecurityEvents: String("se"), 11319 SingleFile: String("sf"), 11320 Statuses: String("s"), 11321 TeamDiscussions: String("td"), 11322 VulnerabilityAlerts: String("va"), 11323 Workflows: String("w"), 11324 }, 11325 CreatedAt: &Timestamp{referenceTime}, 11326 UpdatedAt: &Timestamp{referenceTime}, 11327 HasMultipleSingleFiles: Bool(false), 11328 SuspendedBy: &User{ 11329 Login: String("l"), 11330 ID: Int64(1), 11331 URL: String("u"), 11332 AvatarURL: String("a"), 11333 GravatarID: String("g"), 11334 Name: String("n"), 11335 Company: String("c"), 11336 Blog: String("b"), 11337 Location: String("l"), 11338 Email: String("e"), 11339 Hireable: Bool(true), 11340 Bio: String("b"), 11341 TwitterUsername: String("t"), 11342 PublicRepos: Int(1), 11343 Followers: Int(1), 11344 Following: Int(1), 11345 CreatedAt: &Timestamp{referenceTime}, 11346 SuspendedAt: &Timestamp{referenceTime}, 11347 }, 11348 SuspendedAt: &Timestamp{referenceTime}, 11349 }, 11350 } 11351 11352 want := `{ 11353 "forkee": { 11354 "id": 1, 11355 "name": "n", 11356 "url": "s" 11357 }, 11358 "repository": { 11359 "id": 1, 11360 "name": "n", 11361 "url": "s" 11362 }, 11363 "sender": { 11364 "login": "l", 11365 "id": 1, 11366 "node_id": "n", 11367 "avatar_url": "a", 11368 "url": "u", 11369 "events_url": "e", 11370 "repos_url": "r" 11371 }, 11372 "installation": { 11373 "id": 1, 11374 "node_id": "nid", 11375 "app_id": 1, 11376 "app_slug": "as", 11377 "target_id": 1, 11378 "account": { 11379 "login": "l", 11380 "id": 1, 11381 "avatar_url": "a", 11382 "gravatar_id": "g", 11383 "name": "n", 11384 "company": "c", 11385 "blog": "b", 11386 "location": "l", 11387 "email": "e", 11388 "hireable": true, 11389 "bio": "b", 11390 "twitter_username": "t", 11391 "public_repos": 1, 11392 "followers": 1, 11393 "following": 1, 11394 "created_at": ` + referenceTimeStr + `, 11395 "suspended_at": ` + referenceTimeStr + `, 11396 "url": "u" 11397 }, 11398 "access_tokens_url": "atu", 11399 "repositories_url": "ru", 11400 "html_url": "hu", 11401 "target_type": "tt", 11402 "single_file_name": "sfn", 11403 "repository_selection": "rs", 11404 "events": [ 11405 "e" 11406 ], 11407 "single_file_paths": [ 11408 "s" 11409 ], 11410 "permissions": { 11411 "actions": "a", 11412 "administration": "ad", 11413 "checks": "c", 11414 "contents": "co", 11415 "content_references": "cr", 11416 "deployments": "d", 11417 "environments": "e", 11418 "issues": "i", 11419 "metadata": "md", 11420 "members": "m", 11421 "organization_administration": "oa", 11422 "organization_hooks": "oh", 11423 "organization_plan": "op", 11424 "organization_pre_receive_hooks": "opr", 11425 "organization_projects": "op", 11426 "organization_secrets": "os", 11427 "organization_self_hosted_runners": "osh", 11428 "organization_user_blocking": "oub", 11429 "packages": "pkg", 11430 "pages": "pg", 11431 "pull_requests": "pr", 11432 "repository_hooks": "rh", 11433 "repository_projects": "rp", 11434 "repository_pre_receive_hooks": "rprh", 11435 "secrets": "s", 11436 "secret_scanning_alerts": "ssa", 11437 "security_events": "se", 11438 "single_file": "sf", 11439 "statuses": "s", 11440 "team_discussions": "td", 11441 "vulnerability_alerts": "va", 11442 "workflows": "w" 11443 }, 11444 "created_at": ` + referenceTimeStr + `, 11445 "updated_at": ` + referenceTimeStr + `, 11446 "has_multiple_single_files": false, 11447 "suspended_by": { 11448 "login": "l", 11449 "id": 1, 11450 "avatar_url": "a", 11451 "gravatar_id": "g", 11452 "name": "n", 11453 "company": "c", 11454 "blog": "b", 11455 "location": "l", 11456 "email": "e", 11457 "hireable": true, 11458 "bio": "b", 11459 "twitter_username": "t", 11460 "public_repos": 1, 11461 "followers": 1, 11462 "following": 1, 11463 "created_at": ` + referenceTimeStr + `, 11464 "suspended_at": ` + referenceTimeStr + `, 11465 "url": "u" 11466 }, 11467 "suspended_at": ` + referenceTimeStr + ` 11468 } 11469 }` 11470 11471 testJSONMarshal(t, u, want) 11472 } 11473 11474 func TestGitHubAppAuthorizationEvent_Marshal(t *testing.T) { 11475 testJSONMarshal(t, &GitHubAppAuthorizationEvent{}, "{}") 11476 11477 u := &GitHubAppAuthorizationEvent{ 11478 Action: String("a"), 11479 Sender: &User{ 11480 Login: String("l"), 11481 ID: Int64(1), 11482 NodeID: String("n"), 11483 URL: String("u"), 11484 ReposURL: String("r"), 11485 EventsURL: String("e"), 11486 AvatarURL: String("a"), 11487 }, 11488 } 11489 11490 want := `{ 11491 "action": "a", 11492 "sender": { 11493 "login": "l", 11494 "id": 1, 11495 "node_id": "n", 11496 "avatar_url": "a", 11497 "url": "u", 11498 "events_url": "e", 11499 "repos_url": "r" 11500 } 11501 }` 11502 11503 testJSONMarshal(t, u, want) 11504 } 11505 11506 func TestInstallationEvent_Marshal(t *testing.T) { 11507 testJSONMarshal(t, &InstallationEvent{}, "{}") 11508 11509 u := &InstallationEvent{ 11510 Action: String("a"), 11511 Repositories: []*Repository{ 11512 { 11513 ID: Int64(1), 11514 URL: String("u"), 11515 Name: String("n"), 11516 }, 11517 }, 11518 Sender: &User{ 11519 Login: String("l"), 11520 ID: Int64(1), 11521 NodeID: String("n"), 11522 URL: String("u"), 11523 ReposURL: String("r"), 11524 EventsURL: String("e"), 11525 AvatarURL: String("a"), 11526 }, 11527 Installation: &Installation{ 11528 ID: Int64(1), 11529 NodeID: String("nid"), 11530 AppID: Int64(1), 11531 AppSlug: String("as"), 11532 TargetID: Int64(1), 11533 Account: &User{ 11534 Login: String("l"), 11535 ID: Int64(1), 11536 URL: String("u"), 11537 AvatarURL: String("a"), 11538 GravatarID: String("g"), 11539 Name: String("n"), 11540 Company: String("c"), 11541 Blog: String("b"), 11542 Location: String("l"), 11543 Email: String("e"), 11544 Hireable: Bool(true), 11545 Bio: String("b"), 11546 TwitterUsername: String("t"), 11547 PublicRepos: Int(1), 11548 Followers: Int(1), 11549 Following: Int(1), 11550 CreatedAt: &Timestamp{referenceTime}, 11551 SuspendedAt: &Timestamp{referenceTime}, 11552 }, 11553 AccessTokensURL: String("atu"), 11554 RepositoriesURL: String("ru"), 11555 HTMLURL: String("hu"), 11556 TargetType: String("tt"), 11557 SingleFileName: String("sfn"), 11558 RepositorySelection: String("rs"), 11559 Events: []string{"e"}, 11560 SingleFilePaths: []string{"s"}, 11561 Permissions: &InstallationPermissions{ 11562 Actions: String("a"), 11563 Administration: String("ad"), 11564 Checks: String("c"), 11565 Contents: String("co"), 11566 ContentReferences: String("cr"), 11567 Deployments: String("d"), 11568 Environments: String("e"), 11569 Issues: String("i"), 11570 Metadata: String("md"), 11571 Members: String("m"), 11572 OrganizationAdministration: String("oa"), 11573 OrganizationHooks: String("oh"), 11574 OrganizationPlan: String("op"), 11575 OrganizationPreReceiveHooks: String("opr"), 11576 OrganizationProjects: String("op"), 11577 OrganizationSecrets: String("os"), 11578 OrganizationSelfHostedRunners: String("osh"), 11579 OrganizationUserBlocking: String("oub"), 11580 Packages: String("pkg"), 11581 Pages: String("pg"), 11582 PullRequests: String("pr"), 11583 RepositoryHooks: String("rh"), 11584 RepositoryProjects: String("rp"), 11585 RepositoryPreReceiveHooks: String("rprh"), 11586 Secrets: String("s"), 11587 SecretScanningAlerts: String("ssa"), 11588 SecurityEvents: String("se"), 11589 SingleFile: String("sf"), 11590 Statuses: String("s"), 11591 TeamDiscussions: String("td"), 11592 VulnerabilityAlerts: String("va"), 11593 Workflows: String("w"), 11594 }, 11595 CreatedAt: &Timestamp{referenceTime}, 11596 UpdatedAt: &Timestamp{referenceTime}, 11597 HasMultipleSingleFiles: Bool(false), 11598 SuspendedBy: &User{ 11599 Login: String("l"), 11600 ID: Int64(1), 11601 URL: String("u"), 11602 AvatarURL: String("a"), 11603 GravatarID: String("g"), 11604 Name: String("n"), 11605 Company: String("c"), 11606 Blog: String("b"), 11607 Location: String("l"), 11608 Email: String("e"), 11609 Hireable: Bool(true), 11610 Bio: String("b"), 11611 TwitterUsername: String("t"), 11612 PublicRepos: Int(1), 11613 Followers: Int(1), 11614 Following: Int(1), 11615 CreatedAt: &Timestamp{referenceTime}, 11616 SuspendedAt: &Timestamp{referenceTime}, 11617 }, 11618 SuspendedAt: &Timestamp{referenceTime}, 11619 }, 11620 } 11621 11622 want := `{ 11623 "action": "a", 11624 "repositories": [ 11625 { 11626 "id":1, 11627 "name":"n", 11628 "url":"u" 11629 } 11630 ], 11631 "sender": { 11632 "login": "l", 11633 "id": 1, 11634 "node_id": "n", 11635 "avatar_url": "a", 11636 "url": "u", 11637 "events_url": "e", 11638 "repos_url": "r" 11639 }, 11640 "installation": { 11641 "id": 1, 11642 "node_id": "nid", 11643 "app_id": 1, 11644 "app_slug": "as", 11645 "target_id": 1, 11646 "account": { 11647 "login": "l", 11648 "id": 1, 11649 "avatar_url": "a", 11650 "gravatar_id": "g", 11651 "name": "n", 11652 "company": "c", 11653 "blog": "b", 11654 "location": "l", 11655 "email": "e", 11656 "hireable": true, 11657 "bio": "b", 11658 "twitter_username": "t", 11659 "public_repos": 1, 11660 "followers": 1, 11661 "following": 1, 11662 "created_at": ` + referenceTimeStr + `, 11663 "suspended_at": ` + referenceTimeStr + `, 11664 "url": "u" 11665 }, 11666 "access_tokens_url": "atu", 11667 "repositories_url": "ru", 11668 "html_url": "hu", 11669 "target_type": "tt", 11670 "single_file_name": "sfn", 11671 "repository_selection": "rs", 11672 "events": [ 11673 "e" 11674 ], 11675 "single_file_paths": [ 11676 "s" 11677 ], 11678 "permissions": { 11679 "actions": "a", 11680 "administration": "ad", 11681 "checks": "c", 11682 "contents": "co", 11683 "content_references": "cr", 11684 "deployments": "d", 11685 "environments": "e", 11686 "issues": "i", 11687 "metadata": "md", 11688 "members": "m", 11689 "organization_administration": "oa", 11690 "organization_hooks": "oh", 11691 "organization_plan": "op", 11692 "organization_pre_receive_hooks": "opr", 11693 "organization_projects": "op", 11694 "organization_secrets": "os", 11695 "organization_self_hosted_runners": "osh", 11696 "organization_user_blocking": "oub", 11697 "packages": "pkg", 11698 "pages": "pg", 11699 "pull_requests": "pr", 11700 "repository_hooks": "rh", 11701 "repository_projects": "rp", 11702 "repository_pre_receive_hooks": "rprh", 11703 "secrets": "s", 11704 "secret_scanning_alerts": "ssa", 11705 "security_events": "se", 11706 "single_file": "sf", 11707 "statuses": "s", 11708 "team_discussions": "td", 11709 "vulnerability_alerts": "va", 11710 "workflows": "w" 11711 }, 11712 "created_at": ` + referenceTimeStr + `, 11713 "updated_at": ` + referenceTimeStr + `, 11714 "has_multiple_single_files": false, 11715 "suspended_by": { 11716 "login": "l", 11717 "id": 1, 11718 "avatar_url": "a", 11719 "gravatar_id": "g", 11720 "name": "n", 11721 "company": "c", 11722 "blog": "b", 11723 "location": "l", 11724 "email": "e", 11725 "hireable": true, 11726 "bio": "b", 11727 "twitter_username": "t", 11728 "public_repos": 1, 11729 "followers": 1, 11730 "following": 1, 11731 "created_at": ` + referenceTimeStr + `, 11732 "suspended_at": ` + referenceTimeStr + `, 11733 "url": "u" 11734 }, 11735 "suspended_at": ` + referenceTimeStr + ` 11736 } 11737 }` 11738 11739 testJSONMarshal(t, u, want) 11740 } 11741 11742 func TestHeadCommit_Marshal(t *testing.T) { 11743 testJSONMarshal(t, &HeadCommit{}, "{}") 11744 11745 u := &HeadCommit{ 11746 Message: String("m"), 11747 Author: &CommitAuthor{ 11748 Date: &referenceTime, 11749 Name: String("n"), 11750 Email: String("e"), 11751 Login: String("u"), 11752 }, 11753 URL: String("u"), 11754 Distinct: Bool(true), 11755 SHA: String("s"), 11756 ID: String("id"), 11757 TreeID: String("tid"), 11758 Timestamp: &Timestamp{referenceTime}, 11759 Committer: &CommitAuthor{ 11760 Date: &referenceTime, 11761 Name: String("n"), 11762 Email: String("e"), 11763 Login: String("u"), 11764 }, 11765 Added: []string{"a"}, 11766 Removed: []string{"r"}, 11767 Modified: []string{"m"}, 11768 } 11769 11770 want := `{ 11771 "message": "m", 11772 "author": { 11773 "date": ` + referenceTimeStr + `, 11774 "name": "n", 11775 "email": "e", 11776 "username": "u" 11777 }, 11778 "url": "u", 11779 "distinct": true, 11780 "sha": "s", 11781 "id": "id", 11782 "tree_id": "tid", 11783 "timestamp": ` + referenceTimeStr + `, 11784 "committer": { 11785 "date": ` + referenceTimeStr + `, 11786 "name": "n", 11787 "email": "e", 11788 "username": "u" 11789 }, 11790 "added": [ 11791 "a" 11792 ], 11793 "removed": [ 11794 "r" 11795 ], 11796 "modified": [ 11797 "m" 11798 ] 11799 }` 11800 11801 testJSONMarshal(t, u, want) 11802 } 11803 11804 func TestPushEventRepository_Marshal(t *testing.T) { 11805 testJSONMarshal(t, &PushEventRepository{}, "{}") 11806 11807 u := &PushEventRepository{ 11808 ID: Int64(1), 11809 NodeID: String("nid"), 11810 Name: String("n"), 11811 FullName: String("fn"), 11812 Owner: &User{ 11813 Login: String("l"), 11814 ID: Int64(1), 11815 AvatarURL: String("a"), 11816 GravatarID: String("g"), 11817 Name: String("n"), 11818 Company: String("c"), 11819 Blog: String("b"), 11820 Location: String("l"), 11821 Email: String("e"), 11822 Hireable: Bool(true), 11823 PublicRepos: Int(1), 11824 Followers: Int(1), 11825 Following: Int(1), 11826 CreatedAt: &Timestamp{referenceTime}, 11827 URL: String("u"), 11828 }, 11829 Private: Bool(true), 11830 Description: String("d"), 11831 Fork: Bool(true), 11832 CreatedAt: &Timestamp{referenceTime}, 11833 PushedAt: &Timestamp{referenceTime}, 11834 UpdatedAt: &Timestamp{referenceTime}, 11835 Homepage: String("h"), 11836 PullsURL: String("p"), 11837 Size: Int(1), 11838 StargazersCount: Int(1), 11839 WatchersCount: Int(1), 11840 Language: String("l"), 11841 HasIssues: Bool(true), 11842 HasDownloads: Bool(true), 11843 HasWiki: Bool(true), 11844 HasPages: Bool(true), 11845 ForksCount: Int(1), 11846 Archived: Bool(true), 11847 Disabled: Bool(true), 11848 OpenIssuesCount: Int(1), 11849 DefaultBranch: String("d"), 11850 MasterBranch: String("m"), 11851 Organization: String("o"), 11852 URL: String("u"), 11853 ArchiveURL: String("a"), 11854 HTMLURL: String("h"), 11855 StatusesURL: String("s"), 11856 GitURL: String("g"), 11857 SSHURL: String("s"), 11858 CloneURL: String("c"), 11859 SVNURL: String("s"), 11860 } 11861 11862 want := `{ 11863 "id": 1, 11864 "node_id": "nid", 11865 "name": "n", 11866 "full_name": "fn", 11867 "owner": { 11868 "login": "l", 11869 "id": 1, 11870 "avatar_url": "a", 11871 "gravatar_id": "g", 11872 "name": "n", 11873 "company": "c", 11874 "blog": "b", 11875 "location": "l", 11876 "email": "e", 11877 "hireable": true, 11878 "public_repos": 1, 11879 "followers": 1, 11880 "following": 1, 11881 "created_at": ` + referenceTimeStr + `, 11882 "url": "u" 11883 }, 11884 "private": true, 11885 "description": "d", 11886 "fork": true, 11887 "created_at": ` + referenceTimeStr + `, 11888 "pushed_at": ` + referenceTimeStr + `, 11889 "updated_at": ` + referenceTimeStr + `, 11890 "homepage": "h", 11891 "pulls_url": "p", 11892 "size": 1, 11893 "stargazers_count": 1, 11894 "watchers_count": 1, 11895 "language": "l", 11896 "has_issues": true, 11897 "has_downloads": true, 11898 "has_wiki": true, 11899 "has_pages": true, 11900 "forks_count": 1, 11901 "archived": true, 11902 "disabled": true, 11903 "open_issues_count": 1, 11904 "default_branch": "d", 11905 "master_branch": "m", 11906 "organization": "o", 11907 "url": "u", 11908 "archive_url": "a", 11909 "html_url": "h", 11910 "statuses_url": "s", 11911 "git_url": "g", 11912 "ssh_url": "s", 11913 "clone_url": "c", 11914 "svn_url": "s" 11915 }` 11916 11917 testJSONMarshal(t, u, want) 11918 } 11919 11920 func TestPushEventRepoOwner_Marshal(t *testing.T) { 11921 testJSONMarshal(t, &PushEventRepoOwner{}, "{}") 11922 11923 u := &PushEventRepoOwner{ 11924 Name: String("n"), 11925 Email: String("e"), 11926 } 11927 11928 want := `{ 11929 "name": "n", 11930 "email": "e" 11931 }` 11932 11933 testJSONMarshal(t, u, want) 11934 } 11935 11936 func TestProjectEvent_Marshal(t *testing.T) { 11937 testJSONMarshal(t, &ProjectEvent{}, "{}") 11938 11939 u := &ProjectEvent{ 11940 Project: &Project{ID: Int64(1)}, 11941 Action: String("a"), 11942 Changes: &ProjectChange{ 11943 Name: &ProjectName{From: String("NameFrom")}, 11944 Body: &ProjectBody{From: String("BodyFrom")}, 11945 }, 11946 Repo: &Repository{ 11947 ID: Int64(1), 11948 URL: String("s"), 11949 Name: String("n"), 11950 }, 11951 Org: &Organization{ 11952 BillingEmail: String("be"), 11953 Blog: String("b"), 11954 Company: String("c"), 11955 Email: String("e"), 11956 TwitterUsername: String("tu"), 11957 Location: String("loc"), 11958 Name: String("n"), 11959 Description: String("d"), 11960 IsVerified: Bool(true), 11961 HasOrganizationProjects: Bool(true), 11962 HasRepositoryProjects: Bool(true), 11963 DefaultRepoPermission: String("drp"), 11964 MembersCanCreateRepos: Bool(true), 11965 MembersCanCreateInternalRepos: Bool(true), 11966 MembersCanCreatePrivateRepos: Bool(true), 11967 MembersCanCreatePublicRepos: Bool(false), 11968 MembersAllowedRepositoryCreationType: String("marct"), 11969 MembersCanCreatePages: Bool(true), 11970 MembersCanCreatePublicPages: Bool(false), 11971 MembersCanCreatePrivatePages: Bool(true), 11972 }, 11973 Sender: &User{ 11974 Login: String("l"), 11975 ID: Int64(1), 11976 NodeID: String("n"), 11977 URL: String("u"), 11978 ReposURL: String("r"), 11979 EventsURL: String("e"), 11980 AvatarURL: String("a"), 11981 }, 11982 Installation: &Installation{ 11983 ID: Int64(1), 11984 NodeID: String("nid"), 11985 AppID: Int64(1), 11986 AppSlug: String("as"), 11987 TargetID: Int64(1), 11988 Account: &User{ 11989 Login: String("l"), 11990 ID: Int64(1), 11991 URL: String("u"), 11992 AvatarURL: String("a"), 11993 GravatarID: String("g"), 11994 Name: String("n"), 11995 Company: String("c"), 11996 Blog: String("b"), 11997 Location: String("l"), 11998 Email: String("e"), 11999 Hireable: Bool(true), 12000 Bio: String("b"), 12001 TwitterUsername: String("t"), 12002 PublicRepos: Int(1), 12003 Followers: Int(1), 12004 Following: Int(1), 12005 CreatedAt: &Timestamp{referenceTime}, 12006 SuspendedAt: &Timestamp{referenceTime}, 12007 }, 12008 AccessTokensURL: String("atu"), 12009 RepositoriesURL: String("ru"), 12010 HTMLURL: String("hu"), 12011 TargetType: String("tt"), 12012 SingleFileName: String("sfn"), 12013 RepositorySelection: String("rs"), 12014 Events: []string{"e"}, 12015 SingleFilePaths: []string{"s"}, 12016 Permissions: &InstallationPermissions{ 12017 Actions: String("a"), 12018 Administration: String("ad"), 12019 Checks: String("c"), 12020 Contents: String("co"), 12021 ContentReferences: String("cr"), 12022 Deployments: String("d"), 12023 Environments: String("e"), 12024 Issues: String("i"), 12025 Metadata: String("md"), 12026 Members: String("m"), 12027 OrganizationAdministration: String("oa"), 12028 OrganizationHooks: String("oh"), 12029 OrganizationPlan: String("op"), 12030 OrganizationPreReceiveHooks: String("opr"), 12031 OrganizationProjects: String("op"), 12032 OrganizationSecrets: String("os"), 12033 OrganizationSelfHostedRunners: String("osh"), 12034 OrganizationUserBlocking: String("oub"), 12035 Packages: String("pkg"), 12036 Pages: String("pg"), 12037 PullRequests: String("pr"), 12038 RepositoryHooks: String("rh"), 12039 RepositoryProjects: String("rp"), 12040 RepositoryPreReceiveHooks: String("rprh"), 12041 Secrets: String("s"), 12042 SecretScanningAlerts: String("ssa"), 12043 SecurityEvents: String("se"), 12044 SingleFile: String("sf"), 12045 Statuses: String("s"), 12046 TeamDiscussions: String("td"), 12047 VulnerabilityAlerts: String("va"), 12048 Workflows: String("w"), 12049 }, 12050 CreatedAt: &Timestamp{referenceTime}, 12051 UpdatedAt: &Timestamp{referenceTime}, 12052 HasMultipleSingleFiles: Bool(false), 12053 SuspendedBy: &User{ 12054 Login: String("l"), 12055 ID: Int64(1), 12056 URL: String("u"), 12057 AvatarURL: String("a"), 12058 GravatarID: String("g"), 12059 Name: String("n"), 12060 Company: String("c"), 12061 Blog: String("b"), 12062 Location: String("l"), 12063 Email: String("e"), 12064 Hireable: Bool(true), 12065 Bio: String("b"), 12066 TwitterUsername: String("t"), 12067 PublicRepos: Int(1), 12068 Followers: Int(1), 12069 Following: Int(1), 12070 CreatedAt: &Timestamp{referenceTime}, 12071 SuspendedAt: &Timestamp{referenceTime}, 12072 }, 12073 SuspendedAt: &Timestamp{referenceTime}, 12074 }, 12075 } 12076 12077 want := `{ 12078 "action": "a", 12079 "changes": { 12080 "name": { 12081 "from": "NameFrom" 12082 }, 12083 "body": { 12084 "from": "BodyFrom" 12085 } 12086 }, 12087 "project": { 12088 "id": 1 12089 }, 12090 "repository": { 12091 "id": 1, 12092 "name": "n", 12093 "url": "s" 12094 }, 12095 "organization": { 12096 "name": "n", 12097 "company": "c", 12098 "blog": "b", 12099 "location": "loc", 12100 "email": "e", 12101 "twitter_username": "tu", 12102 "description": "d", 12103 "billing_email": "be", 12104 "is_verified": true, 12105 "has_organization_projects": true, 12106 "has_repository_projects": true, 12107 "default_repository_permission": "drp", 12108 "members_can_create_repositories": true, 12109 "members_can_create_public_repositories": false, 12110 "members_can_create_private_repositories": true, 12111 "members_can_create_internal_repositories": true, 12112 "members_allowed_repository_creation_type": "marct", 12113 "members_can_create_pages": true, 12114 "members_can_create_public_pages": false, 12115 "members_can_create_private_pages": true 12116 }, 12117 "sender": { 12118 "login": "l", 12119 "id": 1, 12120 "node_id": "n", 12121 "avatar_url": "a", 12122 "url": "u", 12123 "events_url": "e", 12124 "repos_url": "r" 12125 }, 12126 "installation": { 12127 "id": 1, 12128 "node_id": "nid", 12129 "app_id": 1, 12130 "app_slug": "as", 12131 "target_id": 1, 12132 "account": { 12133 "login": "l", 12134 "id": 1, 12135 "avatar_url": "a", 12136 "gravatar_id": "g", 12137 "name": "n", 12138 "company": "c", 12139 "blog": "b", 12140 "location": "l", 12141 "email": "e", 12142 "hireable": true, 12143 "bio": "b", 12144 "twitter_username": "t", 12145 "public_repos": 1, 12146 "followers": 1, 12147 "following": 1, 12148 "created_at": ` + referenceTimeStr + `, 12149 "suspended_at": ` + referenceTimeStr + `, 12150 "url": "u" 12151 }, 12152 "access_tokens_url": "atu", 12153 "repositories_url": "ru", 12154 "html_url": "hu", 12155 "target_type": "tt", 12156 "single_file_name": "sfn", 12157 "repository_selection": "rs", 12158 "events": [ 12159 "e" 12160 ], 12161 "single_file_paths": [ 12162 "s" 12163 ], 12164 "permissions": { 12165 "actions": "a", 12166 "administration": "ad", 12167 "checks": "c", 12168 "contents": "co", 12169 "content_references": "cr", 12170 "deployments": "d", 12171 "environments": "e", 12172 "issues": "i", 12173 "metadata": "md", 12174 "members": "m", 12175 "organization_administration": "oa", 12176 "organization_hooks": "oh", 12177 "organization_plan": "op", 12178 "organization_pre_receive_hooks": "opr", 12179 "organization_projects": "op", 12180 "organization_secrets": "os", 12181 "organization_self_hosted_runners": "osh", 12182 "organization_user_blocking": "oub", 12183 "packages": "pkg", 12184 "pages": "pg", 12185 "pull_requests": "pr", 12186 "repository_hooks": "rh", 12187 "repository_projects": "rp", 12188 "repository_pre_receive_hooks": "rprh", 12189 "secrets": "s", 12190 "secret_scanning_alerts": "ssa", 12191 "security_events": "se", 12192 "single_file": "sf", 12193 "statuses": "s", 12194 "team_discussions": "td", 12195 "vulnerability_alerts": "va", 12196 "workflows": "w" 12197 }, 12198 "created_at": ` + referenceTimeStr + `, 12199 "updated_at": ` + referenceTimeStr + `, 12200 "has_multiple_single_files": false, 12201 "suspended_by": { 12202 "login": "l", 12203 "id": 1, 12204 "avatar_url": "a", 12205 "gravatar_id": "g", 12206 "name": "n", 12207 "company": "c", 12208 "blog": "b", 12209 "location": "l", 12210 "email": "e", 12211 "hireable": true, 12212 "bio": "b", 12213 "twitter_username": "t", 12214 "public_repos": 1, 12215 "followers": 1, 12216 "following": 1, 12217 "created_at": ` + referenceTimeStr + `, 12218 "suspended_at": ` + referenceTimeStr + `, 12219 "url": "u" 12220 }, 12221 "suspended_at": ` + referenceTimeStr + ` 12222 } 12223 }` 12224 12225 testJSONMarshal(t, u, want) 12226 } 12227 12228 func TestProjectCardEvent_Marshal(t *testing.T) { 12229 testJSONMarshal(t, &ProjectCardEvent{}, "{}") 12230 12231 u := &ProjectCardEvent{ 12232 Action: String("a"), 12233 Changes: &ProjectCardChange{ 12234 Note: &ProjectCardNote{From: String("NoteFrom")}, 12235 }, 12236 AfterID: Int64(1), 12237 ProjectCard: &ProjectCard{ID: Int64(1)}, 12238 Repo: &Repository{ 12239 ID: Int64(1), 12240 URL: String("s"), 12241 Name: String("n"), 12242 }, 12243 Org: &Organization{ 12244 BillingEmail: String("be"), 12245 Blog: String("b"), 12246 Company: String("c"), 12247 Email: String("e"), 12248 TwitterUsername: String("tu"), 12249 Location: String("loc"), 12250 Name: String("n"), 12251 Description: String("d"), 12252 IsVerified: Bool(true), 12253 HasOrganizationProjects: Bool(true), 12254 HasRepositoryProjects: Bool(true), 12255 DefaultRepoPermission: String("drp"), 12256 MembersCanCreateRepos: Bool(true), 12257 MembersCanCreateInternalRepos: Bool(true), 12258 MembersCanCreatePrivateRepos: Bool(true), 12259 MembersCanCreatePublicRepos: Bool(false), 12260 MembersAllowedRepositoryCreationType: String("marct"), 12261 MembersCanCreatePages: Bool(true), 12262 MembersCanCreatePublicPages: Bool(false), 12263 MembersCanCreatePrivatePages: Bool(true), 12264 }, 12265 Sender: &User{ 12266 Login: String("l"), 12267 ID: Int64(1), 12268 NodeID: String("n"), 12269 URL: String("u"), 12270 ReposURL: String("r"), 12271 EventsURL: String("e"), 12272 AvatarURL: String("a"), 12273 }, 12274 Installation: &Installation{ 12275 ID: Int64(1), 12276 NodeID: String("nid"), 12277 AppID: Int64(1), 12278 AppSlug: String("as"), 12279 TargetID: Int64(1), 12280 Account: &User{ 12281 Login: String("l"), 12282 ID: Int64(1), 12283 URL: String("u"), 12284 AvatarURL: String("a"), 12285 GravatarID: String("g"), 12286 Name: String("n"), 12287 Company: String("c"), 12288 Blog: String("b"), 12289 Location: String("l"), 12290 Email: String("e"), 12291 Hireable: Bool(true), 12292 Bio: String("b"), 12293 TwitterUsername: String("t"), 12294 PublicRepos: Int(1), 12295 Followers: Int(1), 12296 Following: Int(1), 12297 CreatedAt: &Timestamp{referenceTime}, 12298 SuspendedAt: &Timestamp{referenceTime}, 12299 }, 12300 AccessTokensURL: String("atu"), 12301 RepositoriesURL: String("ru"), 12302 HTMLURL: String("hu"), 12303 TargetType: String("tt"), 12304 SingleFileName: String("sfn"), 12305 RepositorySelection: String("rs"), 12306 Events: []string{"e"}, 12307 SingleFilePaths: []string{"s"}, 12308 Permissions: &InstallationPermissions{ 12309 Actions: String("a"), 12310 Administration: String("ad"), 12311 Checks: String("c"), 12312 Contents: String("co"), 12313 ContentReferences: String("cr"), 12314 Deployments: String("d"), 12315 Environments: String("e"), 12316 Issues: String("i"), 12317 Metadata: String("md"), 12318 Members: String("m"), 12319 OrganizationAdministration: String("oa"), 12320 OrganizationHooks: String("oh"), 12321 OrganizationPlan: String("op"), 12322 OrganizationPreReceiveHooks: String("opr"), 12323 OrganizationProjects: String("op"), 12324 OrganizationSecrets: String("os"), 12325 OrganizationSelfHostedRunners: String("osh"), 12326 OrganizationUserBlocking: String("oub"), 12327 Packages: String("pkg"), 12328 Pages: String("pg"), 12329 PullRequests: String("pr"), 12330 RepositoryHooks: String("rh"), 12331 RepositoryProjects: String("rp"), 12332 RepositoryPreReceiveHooks: String("rprh"), 12333 Secrets: String("s"), 12334 SecretScanningAlerts: String("ssa"), 12335 SecurityEvents: String("se"), 12336 SingleFile: String("sf"), 12337 Statuses: String("s"), 12338 TeamDiscussions: String("td"), 12339 VulnerabilityAlerts: String("va"), 12340 Workflows: String("w"), 12341 }, 12342 CreatedAt: &Timestamp{referenceTime}, 12343 UpdatedAt: &Timestamp{referenceTime}, 12344 HasMultipleSingleFiles: Bool(false), 12345 SuspendedBy: &User{ 12346 Login: String("l"), 12347 ID: Int64(1), 12348 URL: String("u"), 12349 AvatarURL: String("a"), 12350 GravatarID: String("g"), 12351 Name: String("n"), 12352 Company: String("c"), 12353 Blog: String("b"), 12354 Location: String("l"), 12355 Email: String("e"), 12356 Hireable: Bool(true), 12357 Bio: String("b"), 12358 TwitterUsername: String("t"), 12359 PublicRepos: Int(1), 12360 Followers: Int(1), 12361 Following: Int(1), 12362 CreatedAt: &Timestamp{referenceTime}, 12363 SuspendedAt: &Timestamp{referenceTime}, 12364 }, 12365 SuspendedAt: &Timestamp{referenceTime}, 12366 }, 12367 } 12368 12369 want := `{ 12370 "action": "a", 12371 "changes": { 12372 "note": { 12373 "from": "NoteFrom" 12374 } 12375 }, 12376 "after_id": 1, 12377 "project_card": { 12378 "id": 1 12379 }, 12380 "repository": { 12381 "id": 1, 12382 "name": "n", 12383 "url": "s" 12384 }, 12385 "organization": { 12386 "name": "n", 12387 "company": "c", 12388 "blog": "b", 12389 "location": "loc", 12390 "email": "e", 12391 "twitter_username": "tu", 12392 "description": "d", 12393 "billing_email": "be", 12394 "is_verified": true, 12395 "has_organization_projects": true, 12396 "has_repository_projects": true, 12397 "default_repository_permission": "drp", 12398 "members_can_create_repositories": true, 12399 "members_can_create_public_repositories": false, 12400 "members_can_create_private_repositories": true, 12401 "members_can_create_internal_repositories": true, 12402 "members_allowed_repository_creation_type": "marct", 12403 "members_can_create_pages": true, 12404 "members_can_create_public_pages": false, 12405 "members_can_create_private_pages": true 12406 }, 12407 "sender": { 12408 "login": "l", 12409 "id": 1, 12410 "node_id": "n", 12411 "avatar_url": "a", 12412 "url": "u", 12413 "events_url": "e", 12414 "repos_url": "r" 12415 }, 12416 "installation": { 12417 "id": 1, 12418 "node_id": "nid", 12419 "app_id": 1, 12420 "app_slug": "as", 12421 "target_id": 1, 12422 "account": { 12423 "login": "l", 12424 "id": 1, 12425 "avatar_url": "a", 12426 "gravatar_id": "g", 12427 "name": "n", 12428 "company": "c", 12429 "blog": "b", 12430 "location": "l", 12431 "email": "e", 12432 "hireable": true, 12433 "bio": "b", 12434 "twitter_username": "t", 12435 "public_repos": 1, 12436 "followers": 1, 12437 "following": 1, 12438 "created_at": ` + referenceTimeStr + `, 12439 "suspended_at": ` + referenceTimeStr + `, 12440 "url": "u" 12441 }, 12442 "access_tokens_url": "atu", 12443 "repositories_url": "ru", 12444 "html_url": "hu", 12445 "target_type": "tt", 12446 "single_file_name": "sfn", 12447 "repository_selection": "rs", 12448 "events": [ 12449 "e" 12450 ], 12451 "single_file_paths": [ 12452 "s" 12453 ], 12454 "permissions": { 12455 "actions": "a", 12456 "administration": "ad", 12457 "checks": "c", 12458 "contents": "co", 12459 "content_references": "cr", 12460 "deployments": "d", 12461 "environments": "e", 12462 "issues": "i", 12463 "metadata": "md", 12464 "members": "m", 12465 "organization_administration": "oa", 12466 "organization_hooks": "oh", 12467 "organization_plan": "op", 12468 "organization_pre_receive_hooks": "opr", 12469 "organization_projects": "op", 12470 "organization_secrets": "os", 12471 "organization_self_hosted_runners": "osh", 12472 "organization_user_blocking": "oub", 12473 "packages": "pkg", 12474 "pages": "pg", 12475 "pull_requests": "pr", 12476 "repository_hooks": "rh", 12477 "repository_projects": "rp", 12478 "repository_pre_receive_hooks": "rprh", 12479 "secrets": "s", 12480 "secret_scanning_alerts": "ssa", 12481 "security_events": "se", 12482 "single_file": "sf", 12483 "statuses": "s", 12484 "team_discussions": "td", 12485 "vulnerability_alerts": "va", 12486 "workflows": "w" 12487 }, 12488 "created_at": ` + referenceTimeStr + `, 12489 "updated_at": ` + referenceTimeStr + `, 12490 "has_multiple_single_files": false, 12491 "suspended_by": { 12492 "login": "l", 12493 "id": 1, 12494 "avatar_url": "a", 12495 "gravatar_id": "g", 12496 "name": "n", 12497 "company": "c", 12498 "blog": "b", 12499 "location": "l", 12500 "email": "e", 12501 "hireable": true, 12502 "bio": "b", 12503 "twitter_username": "t", 12504 "public_repos": 1, 12505 "followers": 1, 12506 "following": 1, 12507 "created_at": ` + referenceTimeStr + `, 12508 "suspended_at": ` + referenceTimeStr + `, 12509 "url": "u" 12510 }, 12511 "suspended_at": ` + referenceTimeStr + ` 12512 } 12513 }` 12514 12515 testJSONMarshal(t, u, want) 12516 } 12517 12518 func TestProjectColumnEvent_Marshal(t *testing.T) { 12519 testJSONMarshal(t, &ProjectColumnEvent{}, "{}") 12520 12521 u := &ProjectColumnEvent{ 12522 Action: String("a"), 12523 Changes: &ProjectColumnChange{ 12524 Name: &ProjectColumnName{From: String("NameFrom")}, 12525 }, 12526 AfterID: Int64(1), 12527 ProjectColumn: &ProjectColumn{ID: Int64(1)}, 12528 Repo: &Repository{ 12529 ID: Int64(1), 12530 URL: String("s"), 12531 Name: String("n"), 12532 }, 12533 Org: &Organization{ 12534 BillingEmail: String("be"), 12535 Blog: String("b"), 12536 Company: String("c"), 12537 Email: String("e"), 12538 TwitterUsername: String("tu"), 12539 Location: String("loc"), 12540 Name: String("n"), 12541 Description: String("d"), 12542 IsVerified: Bool(true), 12543 HasOrganizationProjects: Bool(true), 12544 HasRepositoryProjects: Bool(true), 12545 DefaultRepoPermission: String("drp"), 12546 MembersCanCreateRepos: Bool(true), 12547 MembersCanCreateInternalRepos: Bool(true), 12548 MembersCanCreatePrivateRepos: Bool(true), 12549 MembersCanCreatePublicRepos: Bool(false), 12550 MembersAllowedRepositoryCreationType: String("marct"), 12551 MembersCanCreatePages: Bool(true), 12552 MembersCanCreatePublicPages: Bool(false), 12553 MembersCanCreatePrivatePages: Bool(true), 12554 }, 12555 Sender: &User{ 12556 Login: String("l"), 12557 ID: Int64(1), 12558 NodeID: String("n"), 12559 URL: String("u"), 12560 ReposURL: String("r"), 12561 EventsURL: String("e"), 12562 AvatarURL: String("a"), 12563 }, 12564 Installation: &Installation{ 12565 ID: Int64(1), 12566 NodeID: String("nid"), 12567 AppID: Int64(1), 12568 AppSlug: String("as"), 12569 TargetID: Int64(1), 12570 Account: &User{ 12571 Login: String("l"), 12572 ID: Int64(1), 12573 URL: String("u"), 12574 AvatarURL: String("a"), 12575 GravatarID: String("g"), 12576 Name: String("n"), 12577 Company: String("c"), 12578 Blog: String("b"), 12579 Location: String("l"), 12580 Email: String("e"), 12581 Hireable: Bool(true), 12582 Bio: String("b"), 12583 TwitterUsername: String("t"), 12584 PublicRepos: Int(1), 12585 Followers: Int(1), 12586 Following: Int(1), 12587 CreatedAt: &Timestamp{referenceTime}, 12588 SuspendedAt: &Timestamp{referenceTime}, 12589 }, 12590 AccessTokensURL: String("atu"), 12591 RepositoriesURL: String("ru"), 12592 HTMLURL: String("hu"), 12593 TargetType: String("tt"), 12594 SingleFileName: String("sfn"), 12595 RepositorySelection: String("rs"), 12596 Events: []string{"e"}, 12597 SingleFilePaths: []string{"s"}, 12598 Permissions: &InstallationPermissions{ 12599 Actions: String("a"), 12600 Administration: String("ad"), 12601 Checks: String("c"), 12602 Contents: String("co"), 12603 ContentReferences: String("cr"), 12604 Deployments: String("d"), 12605 Environments: String("e"), 12606 Issues: String("i"), 12607 Metadata: String("md"), 12608 Members: String("m"), 12609 OrganizationAdministration: String("oa"), 12610 OrganizationHooks: String("oh"), 12611 OrganizationPlan: String("op"), 12612 OrganizationPreReceiveHooks: String("opr"), 12613 OrganizationProjects: String("op"), 12614 OrganizationSecrets: String("os"), 12615 OrganizationSelfHostedRunners: String("osh"), 12616 OrganizationUserBlocking: String("oub"), 12617 Packages: String("pkg"), 12618 Pages: String("pg"), 12619 PullRequests: String("pr"), 12620 RepositoryHooks: String("rh"), 12621 RepositoryProjects: String("rp"), 12622 RepositoryPreReceiveHooks: String("rprh"), 12623 Secrets: String("s"), 12624 SecretScanningAlerts: String("ssa"), 12625 SecurityEvents: String("se"), 12626 SingleFile: String("sf"), 12627 Statuses: String("s"), 12628 TeamDiscussions: String("td"), 12629 VulnerabilityAlerts: String("va"), 12630 Workflows: String("w"), 12631 }, 12632 CreatedAt: &Timestamp{referenceTime}, 12633 UpdatedAt: &Timestamp{referenceTime}, 12634 HasMultipleSingleFiles: Bool(false), 12635 SuspendedBy: &User{ 12636 Login: String("l"), 12637 ID: Int64(1), 12638 URL: String("u"), 12639 AvatarURL: String("a"), 12640 GravatarID: String("g"), 12641 Name: String("n"), 12642 Company: String("c"), 12643 Blog: String("b"), 12644 Location: String("l"), 12645 Email: String("e"), 12646 Hireable: Bool(true), 12647 Bio: String("b"), 12648 TwitterUsername: String("t"), 12649 PublicRepos: Int(1), 12650 Followers: Int(1), 12651 Following: Int(1), 12652 CreatedAt: &Timestamp{referenceTime}, 12653 SuspendedAt: &Timestamp{referenceTime}, 12654 }, 12655 SuspendedAt: &Timestamp{referenceTime}, 12656 }, 12657 } 12658 12659 want := `{ 12660 "action": "a", 12661 "changes": { 12662 "name": { 12663 "from": "NameFrom" 12664 } 12665 }, 12666 "after_id": 1, 12667 "project_column": { 12668 "id": 1 12669 }, 12670 "repository": { 12671 "id": 1, 12672 "name": "n", 12673 "url": "s" 12674 }, 12675 "organization": { 12676 "name": "n", 12677 "company": "c", 12678 "blog": "b", 12679 "location": "loc", 12680 "email": "e", 12681 "twitter_username": "tu", 12682 "description": "d", 12683 "billing_email": "be", 12684 "is_verified": true, 12685 "has_organization_projects": true, 12686 "has_repository_projects": true, 12687 "default_repository_permission": "drp", 12688 "members_can_create_repositories": true, 12689 "members_can_create_public_repositories": false, 12690 "members_can_create_private_repositories": true, 12691 "members_can_create_internal_repositories": true, 12692 "members_allowed_repository_creation_type": "marct", 12693 "members_can_create_pages": true, 12694 "members_can_create_public_pages": false, 12695 "members_can_create_private_pages": true 12696 }, 12697 "sender": { 12698 "login": "l", 12699 "id": 1, 12700 "node_id": "n", 12701 "avatar_url": "a", 12702 "url": "u", 12703 "events_url": "e", 12704 "repos_url": "r" 12705 }, 12706 "installation": { 12707 "id": 1, 12708 "node_id": "nid", 12709 "app_id": 1, 12710 "app_slug": "as", 12711 "target_id": 1, 12712 "account": { 12713 "login": "l", 12714 "id": 1, 12715 "avatar_url": "a", 12716 "gravatar_id": "g", 12717 "name": "n", 12718 "company": "c", 12719 "blog": "b", 12720 "location": "l", 12721 "email": "e", 12722 "hireable": true, 12723 "bio": "b", 12724 "twitter_username": "t", 12725 "public_repos": 1, 12726 "followers": 1, 12727 "following": 1, 12728 "created_at": ` + referenceTimeStr + `, 12729 "suspended_at": ` + referenceTimeStr + `, 12730 "url": "u" 12731 }, 12732 "access_tokens_url": "atu", 12733 "repositories_url": "ru", 12734 "html_url": "hu", 12735 "target_type": "tt", 12736 "single_file_name": "sfn", 12737 "repository_selection": "rs", 12738 "events": [ 12739 "e" 12740 ], 12741 "single_file_paths": [ 12742 "s" 12743 ], 12744 "permissions": { 12745 "actions": "a", 12746 "administration": "ad", 12747 "checks": "c", 12748 "contents": "co", 12749 "content_references": "cr", 12750 "deployments": "d", 12751 "environments": "e", 12752 "issues": "i", 12753 "metadata": "md", 12754 "members": "m", 12755 "organization_administration": "oa", 12756 "organization_hooks": "oh", 12757 "organization_plan": "op", 12758 "organization_pre_receive_hooks": "opr", 12759 "organization_projects": "op", 12760 "organization_secrets": "os", 12761 "organization_self_hosted_runners": "osh", 12762 "organization_user_blocking": "oub", 12763 "packages": "pkg", 12764 "pages": "pg", 12765 "pull_requests": "pr", 12766 "repository_hooks": "rh", 12767 "repository_projects": "rp", 12768 "repository_pre_receive_hooks": "rprh", 12769 "secrets": "s", 12770 "secret_scanning_alerts": "ssa", 12771 "security_events": "se", 12772 "single_file": "sf", 12773 "statuses": "s", 12774 "team_discussions": "td", 12775 "vulnerability_alerts": "va", 12776 "workflows": "w" 12777 }, 12778 "created_at": ` + referenceTimeStr + `, 12779 "updated_at": ` + referenceTimeStr + `, 12780 "has_multiple_single_files": false, 12781 "suspended_by": { 12782 "login": "l", 12783 "id": 1, 12784 "avatar_url": "a", 12785 "gravatar_id": "g", 12786 "name": "n", 12787 "company": "c", 12788 "blog": "b", 12789 "location": "l", 12790 "email": "e", 12791 "hireable": true, 12792 "bio": "b", 12793 "twitter_username": "t", 12794 "public_repos": 1, 12795 "followers": 1, 12796 "following": 1, 12797 "created_at": ` + referenceTimeStr + `, 12798 "suspended_at": ` + referenceTimeStr + `, 12799 "url": "u" 12800 }, 12801 "suspended_at": ` + referenceTimeStr + ` 12802 } 12803 }` 12804 12805 testJSONMarshal(t, u, want) 12806 } 12807 12808 func TestPullRequestEvent_Marshal(t *testing.T) { 12809 testJSONMarshal(t, &PullRequestEvent{}, "{}") 12810 12811 u := &PullRequestEvent{ 12812 Action: String("a"), 12813 Assignee: &User{ 12814 Login: String("l"), 12815 ID: Int64(1), 12816 NodeID: String("n"), 12817 URL: String("u"), 12818 ReposURL: String("r"), 12819 EventsURL: String("e"), 12820 AvatarURL: String("a"), 12821 }, 12822 Number: Int(1), 12823 PullRequest: &PullRequest{ID: Int64(1)}, 12824 Changes: &EditChange{ 12825 Title: &EditTitle{ 12826 From: String("TitleFrom"), 12827 }, 12828 Body: &EditBody{ 12829 From: String("BodyFrom"), 12830 }, 12831 Base: &EditBase{ 12832 Ref: &EditRef{ 12833 From: String("BaseRefFrom"), 12834 }, 12835 SHA: &EditSHA{ 12836 From: String("BaseSHAFrom"), 12837 }, 12838 }, 12839 }, 12840 RequestedReviewer: &User{ 12841 Login: String("l"), 12842 ID: Int64(1), 12843 NodeID: String("n"), 12844 URL: String("u"), 12845 ReposURL: String("r"), 12846 EventsURL: String("e"), 12847 AvatarURL: String("a"), 12848 }, 12849 RequestedTeam: &Team{ID: Int64(1)}, 12850 Label: &Label{ID: Int64(1)}, 12851 Before: String("before"), 12852 After: String("after"), 12853 Repo: &Repository{ 12854 ID: Int64(1), 12855 URL: String("s"), 12856 Name: String("n"), 12857 }, 12858 Organization: &Organization{ 12859 BillingEmail: String("be"), 12860 Blog: String("b"), 12861 Company: String("c"), 12862 Email: String("e"), 12863 TwitterUsername: String("tu"), 12864 Location: String("loc"), 12865 Name: String("n"), 12866 Description: String("d"), 12867 IsVerified: Bool(true), 12868 HasOrganizationProjects: Bool(true), 12869 HasRepositoryProjects: Bool(true), 12870 DefaultRepoPermission: String("drp"), 12871 MembersCanCreateRepos: Bool(true), 12872 MembersCanCreateInternalRepos: Bool(true), 12873 MembersCanCreatePrivateRepos: Bool(true), 12874 MembersCanCreatePublicRepos: Bool(false), 12875 MembersAllowedRepositoryCreationType: String("marct"), 12876 MembersCanCreatePages: Bool(true), 12877 MembersCanCreatePublicPages: Bool(false), 12878 MembersCanCreatePrivatePages: Bool(true), 12879 }, 12880 Sender: &User{ 12881 Login: String("l"), 12882 ID: Int64(1), 12883 NodeID: String("n"), 12884 URL: String("u"), 12885 ReposURL: String("r"), 12886 EventsURL: String("e"), 12887 AvatarURL: String("a"), 12888 }, 12889 Installation: &Installation{ 12890 ID: Int64(1), 12891 NodeID: String("nid"), 12892 AppID: Int64(1), 12893 AppSlug: String("as"), 12894 TargetID: Int64(1), 12895 Account: &User{ 12896 Login: String("l"), 12897 ID: Int64(1), 12898 URL: String("u"), 12899 AvatarURL: String("a"), 12900 GravatarID: String("g"), 12901 Name: String("n"), 12902 Company: String("c"), 12903 Blog: String("b"), 12904 Location: String("l"), 12905 Email: String("e"), 12906 Hireable: Bool(true), 12907 Bio: String("b"), 12908 TwitterUsername: String("t"), 12909 PublicRepos: Int(1), 12910 Followers: Int(1), 12911 Following: Int(1), 12912 CreatedAt: &Timestamp{referenceTime}, 12913 SuspendedAt: &Timestamp{referenceTime}, 12914 }, 12915 AccessTokensURL: String("atu"), 12916 RepositoriesURL: String("ru"), 12917 HTMLURL: String("hu"), 12918 TargetType: String("tt"), 12919 SingleFileName: String("sfn"), 12920 RepositorySelection: String("rs"), 12921 Events: []string{"e"}, 12922 SingleFilePaths: []string{"s"}, 12923 Permissions: &InstallationPermissions{ 12924 Actions: String("a"), 12925 Administration: String("ad"), 12926 Checks: String("c"), 12927 Contents: String("co"), 12928 ContentReferences: String("cr"), 12929 Deployments: String("d"), 12930 Environments: String("e"), 12931 Issues: String("i"), 12932 Metadata: String("md"), 12933 Members: String("m"), 12934 OrganizationAdministration: String("oa"), 12935 OrganizationHooks: String("oh"), 12936 OrganizationPlan: String("op"), 12937 OrganizationPreReceiveHooks: String("opr"), 12938 OrganizationProjects: String("op"), 12939 OrganizationSecrets: String("os"), 12940 OrganizationSelfHostedRunners: String("osh"), 12941 OrganizationUserBlocking: String("oub"), 12942 Packages: String("pkg"), 12943 Pages: String("pg"), 12944 PullRequests: String("pr"), 12945 RepositoryHooks: String("rh"), 12946 RepositoryProjects: String("rp"), 12947 RepositoryPreReceiveHooks: String("rprh"), 12948 Secrets: String("s"), 12949 SecretScanningAlerts: String("ssa"), 12950 SecurityEvents: String("se"), 12951 SingleFile: String("sf"), 12952 Statuses: String("s"), 12953 TeamDiscussions: String("td"), 12954 VulnerabilityAlerts: String("va"), 12955 Workflows: String("w"), 12956 }, 12957 CreatedAt: &Timestamp{referenceTime}, 12958 UpdatedAt: &Timestamp{referenceTime}, 12959 HasMultipleSingleFiles: Bool(false), 12960 SuspendedBy: &User{ 12961 Login: String("l"), 12962 ID: Int64(1), 12963 URL: String("u"), 12964 AvatarURL: String("a"), 12965 GravatarID: String("g"), 12966 Name: String("n"), 12967 Company: String("c"), 12968 Blog: String("b"), 12969 Location: String("l"), 12970 Email: String("e"), 12971 Hireable: Bool(true), 12972 Bio: String("b"), 12973 TwitterUsername: String("t"), 12974 PublicRepos: Int(1), 12975 Followers: Int(1), 12976 Following: Int(1), 12977 CreatedAt: &Timestamp{referenceTime}, 12978 SuspendedAt: &Timestamp{referenceTime}, 12979 }, 12980 SuspendedAt: &Timestamp{referenceTime}, 12981 }, 12982 } 12983 12984 want := `{ 12985 "action": "a", 12986 "assignee": { 12987 "login": "l", 12988 "id": 1, 12989 "node_id": "n", 12990 "avatar_url": "a", 12991 "url": "u", 12992 "events_url": "e", 12993 "repos_url": "r" 12994 }, 12995 "number": 1, 12996 "pull_request": { 12997 "id": 1 12998 }, 12999 "changes": { 13000 "title": { 13001 "from": "TitleFrom" 13002 }, 13003 "body": { 13004 "from": "BodyFrom" 13005 }, 13006 "base": { 13007 "ref": { 13008 "from": "BaseRefFrom" 13009 }, 13010 "sha": { 13011 "from": "BaseSHAFrom" 13012 } 13013 } 13014 }, 13015 "requested_reviewer": { 13016 "login": "l", 13017 "id": 1, 13018 "node_id": "n", 13019 "avatar_url": "a", 13020 "url": "u", 13021 "events_url": "e", 13022 "repos_url": "r" 13023 }, 13024 "requested_team": { 13025 "id": 1 13026 }, 13027 "repository": { 13028 "id": 1, 13029 "name": "n", 13030 "url": "s" 13031 }, 13032 "sender": { 13033 "login": "l", 13034 "id": 1, 13035 "node_id": "n", 13036 "avatar_url": "a", 13037 "url": "u", 13038 "events_url": "e", 13039 "repos_url": "r" 13040 }, 13041 "installation": { 13042 "id": 1, 13043 "node_id": "nid", 13044 "app_id": 1, 13045 "app_slug": "as", 13046 "target_id": 1, 13047 "account": { 13048 "login": "l", 13049 "id": 1, 13050 "avatar_url": "a", 13051 "gravatar_id": "g", 13052 "name": "n", 13053 "company": "c", 13054 "blog": "b", 13055 "location": "l", 13056 "email": "e", 13057 "hireable": true, 13058 "bio": "b", 13059 "twitter_username": "t", 13060 "public_repos": 1, 13061 "followers": 1, 13062 "following": 1, 13063 "created_at": ` + referenceTimeStr + `, 13064 "suspended_at": ` + referenceTimeStr + `, 13065 "url": "u" 13066 }, 13067 "access_tokens_url": "atu", 13068 "repositories_url": "ru", 13069 "html_url": "hu", 13070 "target_type": "tt", 13071 "single_file_name": "sfn", 13072 "repository_selection": "rs", 13073 "events": [ 13074 "e" 13075 ], 13076 "single_file_paths": [ 13077 "s" 13078 ], 13079 "permissions": { 13080 "actions": "a", 13081 "administration": "ad", 13082 "checks": "c", 13083 "contents": "co", 13084 "content_references": "cr", 13085 "deployments": "d", 13086 "environments": "e", 13087 "issues": "i", 13088 "metadata": "md", 13089 "members": "m", 13090 "organization_administration": "oa", 13091 "organization_hooks": "oh", 13092 "organization_plan": "op", 13093 "organization_pre_receive_hooks": "opr", 13094 "organization_projects": "op", 13095 "organization_secrets": "os", 13096 "organization_self_hosted_runners": "osh", 13097 "organization_user_blocking": "oub", 13098 "packages": "pkg", 13099 "pages": "pg", 13100 "pull_requests": "pr", 13101 "repository_hooks": "rh", 13102 "repository_projects": "rp", 13103 "repository_pre_receive_hooks": "rprh", 13104 "secrets": "s", 13105 "secret_scanning_alerts": "ssa", 13106 "security_events": "se", 13107 "single_file": "sf", 13108 "statuses": "s", 13109 "team_discussions": "td", 13110 "vulnerability_alerts": "va", 13111 "workflows": "w" 13112 }, 13113 "created_at": ` + referenceTimeStr + `, 13114 "updated_at": ` + referenceTimeStr + `, 13115 "has_multiple_single_files": false, 13116 "suspended_by": { 13117 "login": "l", 13118 "id": 1, 13119 "avatar_url": "a", 13120 "gravatar_id": "g", 13121 "name": "n", 13122 "company": "c", 13123 "blog": "b", 13124 "location": "l", 13125 "email": "e", 13126 "hireable": true, 13127 "bio": "b", 13128 "twitter_username": "t", 13129 "public_repos": 1, 13130 "followers": 1, 13131 "following": 1, 13132 "created_at": ` + referenceTimeStr + `, 13133 "suspended_at": ` + referenceTimeStr + `, 13134 "url": "u" 13135 }, 13136 "suspended_at": ` + referenceTimeStr + ` 13137 }, 13138 "label": { 13139 "id": 1 13140 }, 13141 "organization": { 13142 "name": "n", 13143 "company": "c", 13144 "blog": "b", 13145 "location": "loc", 13146 "email": "e", 13147 "twitter_username": "tu", 13148 "description": "d", 13149 "billing_email": "be", 13150 "is_verified": true, 13151 "has_organization_projects": true, 13152 "has_repository_projects": true, 13153 "default_repository_permission": "drp", 13154 "members_can_create_repositories": true, 13155 "members_can_create_public_repositories": false, 13156 "members_can_create_private_repositories": true, 13157 "members_can_create_internal_repositories": true, 13158 "members_allowed_repository_creation_type": "marct", 13159 "members_can_create_pages": true, 13160 "members_can_create_public_pages": false, 13161 "members_can_create_private_pages": true 13162 }, 13163 "before": "before", 13164 "after": "after" 13165 }` 13166 13167 testJSONMarshal(t, u, want) 13168 } 13169 13170 func TestPullRequestReviewCommentEvent_Marshal(t *testing.T) { 13171 testJSONMarshal(t, &PullRequestReviewCommentEvent{}, "{}") 13172 13173 u := &PullRequestReviewCommentEvent{ 13174 Action: String("a"), 13175 PullRequest: &PullRequest{ID: Int64(1)}, 13176 Comment: &PullRequestComment{ID: Int64(1)}, 13177 Changes: &EditChange{ 13178 Title: &EditTitle{ 13179 From: String("TitleFrom"), 13180 }, 13181 Body: &EditBody{ 13182 From: String("BodyFrom"), 13183 }, 13184 Base: &EditBase{ 13185 Ref: &EditRef{ 13186 From: String("BaseRefFrom"), 13187 }, 13188 SHA: &EditSHA{ 13189 From: String("BaseSHAFrom"), 13190 }, 13191 }, 13192 }, 13193 Repo: &Repository{ 13194 ID: Int64(1), 13195 URL: String("s"), 13196 Name: String("n"), 13197 }, 13198 Sender: &User{ 13199 Login: String("l"), 13200 ID: Int64(1), 13201 NodeID: String("n"), 13202 URL: String("u"), 13203 ReposURL: String("r"), 13204 EventsURL: String("e"), 13205 AvatarURL: String("a"), 13206 }, 13207 Installation: &Installation{ 13208 ID: Int64(1), 13209 NodeID: String("nid"), 13210 AppID: Int64(1), 13211 AppSlug: String("as"), 13212 TargetID: Int64(1), 13213 Account: &User{ 13214 Login: String("l"), 13215 ID: Int64(1), 13216 URL: String("u"), 13217 AvatarURL: String("a"), 13218 GravatarID: String("g"), 13219 Name: String("n"), 13220 Company: String("c"), 13221 Blog: String("b"), 13222 Location: String("l"), 13223 Email: String("e"), 13224 Hireable: Bool(true), 13225 Bio: String("b"), 13226 TwitterUsername: String("t"), 13227 PublicRepos: Int(1), 13228 Followers: Int(1), 13229 Following: Int(1), 13230 CreatedAt: &Timestamp{referenceTime}, 13231 SuspendedAt: &Timestamp{referenceTime}, 13232 }, 13233 AccessTokensURL: String("atu"), 13234 RepositoriesURL: String("ru"), 13235 HTMLURL: String("hu"), 13236 TargetType: String("tt"), 13237 SingleFileName: String("sfn"), 13238 RepositorySelection: String("rs"), 13239 Events: []string{"e"}, 13240 SingleFilePaths: []string{"s"}, 13241 Permissions: &InstallationPermissions{ 13242 Actions: String("a"), 13243 Administration: String("ad"), 13244 Checks: String("c"), 13245 Contents: String("co"), 13246 ContentReferences: String("cr"), 13247 Deployments: String("d"), 13248 Environments: String("e"), 13249 Issues: String("i"), 13250 Metadata: String("md"), 13251 Members: String("m"), 13252 OrganizationAdministration: String("oa"), 13253 OrganizationHooks: String("oh"), 13254 OrganizationPlan: String("op"), 13255 OrganizationPreReceiveHooks: String("opr"), 13256 OrganizationProjects: String("op"), 13257 OrganizationSecrets: String("os"), 13258 OrganizationSelfHostedRunners: String("osh"), 13259 OrganizationUserBlocking: String("oub"), 13260 Packages: String("pkg"), 13261 Pages: String("pg"), 13262 PullRequests: String("pr"), 13263 RepositoryHooks: String("rh"), 13264 RepositoryProjects: String("rp"), 13265 RepositoryPreReceiveHooks: String("rprh"), 13266 Secrets: String("s"), 13267 SecretScanningAlerts: String("ssa"), 13268 SecurityEvents: String("se"), 13269 SingleFile: String("sf"), 13270 Statuses: String("s"), 13271 TeamDiscussions: String("td"), 13272 VulnerabilityAlerts: String("va"), 13273 Workflows: String("w"), 13274 }, 13275 CreatedAt: &Timestamp{referenceTime}, 13276 UpdatedAt: &Timestamp{referenceTime}, 13277 HasMultipleSingleFiles: Bool(false), 13278 SuspendedBy: &User{ 13279 Login: String("l"), 13280 ID: Int64(1), 13281 URL: String("u"), 13282 AvatarURL: String("a"), 13283 GravatarID: String("g"), 13284 Name: String("n"), 13285 Company: String("c"), 13286 Blog: String("b"), 13287 Location: String("l"), 13288 Email: String("e"), 13289 Hireable: Bool(true), 13290 Bio: String("b"), 13291 TwitterUsername: String("t"), 13292 PublicRepos: Int(1), 13293 Followers: Int(1), 13294 Following: Int(1), 13295 CreatedAt: &Timestamp{referenceTime}, 13296 SuspendedAt: &Timestamp{referenceTime}, 13297 }, 13298 SuspendedAt: &Timestamp{referenceTime}, 13299 }, 13300 } 13301 13302 want := `{ 13303 "action": "a", 13304 "pull_request": { 13305 "id": 1 13306 }, 13307 "comment": { 13308 "id": 1 13309 }, 13310 "changes": { 13311 "title": { 13312 "from": "TitleFrom" 13313 }, 13314 "body": { 13315 "from": "BodyFrom" 13316 }, 13317 "base": { 13318 "ref": { 13319 "from": "BaseRefFrom" 13320 }, 13321 "sha": { 13322 "from": "BaseSHAFrom" 13323 } 13324 } 13325 }, 13326 "repository": { 13327 "id": 1, 13328 "name": "n", 13329 "url": "s" 13330 }, 13331 "sender": { 13332 "login": "l", 13333 "id": 1, 13334 "node_id": "n", 13335 "avatar_url": "a", 13336 "url": "u", 13337 "events_url": "e", 13338 "repos_url": "r" 13339 }, 13340 "installation": { 13341 "id": 1, 13342 "node_id": "nid", 13343 "app_id": 1, 13344 "app_slug": "as", 13345 "target_id": 1, 13346 "account": { 13347 "login": "l", 13348 "id": 1, 13349 "avatar_url": "a", 13350 "gravatar_id": "g", 13351 "name": "n", 13352 "company": "c", 13353 "blog": "b", 13354 "location": "l", 13355 "email": "e", 13356 "hireable": true, 13357 "bio": "b", 13358 "twitter_username": "t", 13359 "public_repos": 1, 13360 "followers": 1, 13361 "following": 1, 13362 "created_at": ` + referenceTimeStr + `, 13363 "suspended_at": ` + referenceTimeStr + `, 13364 "url": "u" 13365 }, 13366 "access_tokens_url": "atu", 13367 "repositories_url": "ru", 13368 "html_url": "hu", 13369 "target_type": "tt", 13370 "single_file_name": "sfn", 13371 "repository_selection": "rs", 13372 "events": [ 13373 "e" 13374 ], 13375 "single_file_paths": [ 13376 "s" 13377 ], 13378 "permissions": { 13379 "actions": "a", 13380 "administration": "ad", 13381 "checks": "c", 13382 "contents": "co", 13383 "content_references": "cr", 13384 "deployments": "d", 13385 "environments": "e", 13386 "issues": "i", 13387 "metadata": "md", 13388 "members": "m", 13389 "organization_administration": "oa", 13390 "organization_hooks": "oh", 13391 "organization_plan": "op", 13392 "organization_pre_receive_hooks": "opr", 13393 "organization_projects": "op", 13394 "organization_secrets": "os", 13395 "organization_self_hosted_runners": "osh", 13396 "organization_user_blocking": "oub", 13397 "packages": "pkg", 13398 "pages": "pg", 13399 "pull_requests": "pr", 13400 "repository_hooks": "rh", 13401 "repository_projects": "rp", 13402 "repository_pre_receive_hooks": "rprh", 13403 "secrets": "s", 13404 "secret_scanning_alerts": "ssa", 13405 "security_events": "se", 13406 "single_file": "sf", 13407 "statuses": "s", 13408 "team_discussions": "td", 13409 "vulnerability_alerts": "va", 13410 "workflows": "w" 13411 }, 13412 "created_at": ` + referenceTimeStr + `, 13413 "updated_at": ` + referenceTimeStr + `, 13414 "has_multiple_single_files": false, 13415 "suspended_by": { 13416 "login": "l", 13417 "id": 1, 13418 "avatar_url": "a", 13419 "gravatar_id": "g", 13420 "name": "n", 13421 "company": "c", 13422 "blog": "b", 13423 "location": "l", 13424 "email": "e", 13425 "hireable": true, 13426 "bio": "b", 13427 "twitter_username": "t", 13428 "public_repos": 1, 13429 "followers": 1, 13430 "following": 1, 13431 "created_at": ` + referenceTimeStr + `, 13432 "suspended_at": ` + referenceTimeStr + `, 13433 "url": "u" 13434 }, 13435 "suspended_at": ` + referenceTimeStr + ` 13436 } 13437 }` 13438 13439 testJSONMarshal(t, u, want) 13440 } 13441 13442 func TestPullRequestReviewThreadEvent_Marshal(t *testing.T) { 13443 testJSONMarshal(t, &PullRequestReviewThreadEvent{}, "{}") 13444 13445 u := &PullRequestReviewThreadEvent{ 13446 Action: String("a"), 13447 PullRequest: &PullRequest{ID: Int64(1)}, 13448 Thread: &PullRequestThread{ 13449 Comments: []*PullRequestComment{{ID: Int64(1)}, {ID: Int64(2)}}, 13450 }, 13451 Repo: &Repository{ 13452 ID: Int64(1), 13453 URL: String("s"), 13454 Name: String("n"), 13455 }, 13456 Sender: &User{ 13457 Login: String("l"), 13458 ID: Int64(1), 13459 NodeID: String("n"), 13460 URL: String("u"), 13461 ReposURL: String("r"), 13462 EventsURL: String("e"), 13463 AvatarURL: String("a"), 13464 }, 13465 Installation: &Installation{ 13466 ID: Int64(1), 13467 NodeID: String("nid"), 13468 AppID: Int64(1), 13469 AppSlug: String("as"), 13470 TargetID: Int64(1), 13471 Account: &User{ 13472 Login: String("l"), 13473 ID: Int64(1), 13474 URL: String("u"), 13475 AvatarURL: String("a"), 13476 GravatarID: String("g"), 13477 Name: String("n"), 13478 Company: String("c"), 13479 Blog: String("b"), 13480 Location: String("l"), 13481 Email: String("e"), 13482 Hireable: Bool(true), 13483 Bio: String("b"), 13484 TwitterUsername: String("t"), 13485 PublicRepos: Int(1), 13486 Followers: Int(1), 13487 Following: Int(1), 13488 CreatedAt: &Timestamp{referenceTime}, 13489 SuspendedAt: &Timestamp{referenceTime}, 13490 }, 13491 AccessTokensURL: String("atu"), 13492 RepositoriesURL: String("ru"), 13493 HTMLURL: String("hu"), 13494 TargetType: String("tt"), 13495 SingleFileName: String("sfn"), 13496 RepositorySelection: String("rs"), 13497 Events: []string{"e"}, 13498 SingleFilePaths: []string{"s"}, 13499 Permissions: &InstallationPermissions{ 13500 Actions: String("a"), 13501 Administration: String("ad"), 13502 Checks: String("c"), 13503 Contents: String("co"), 13504 ContentReferences: String("cr"), 13505 Deployments: String("d"), 13506 Environments: String("e"), 13507 Issues: String("i"), 13508 Metadata: String("md"), 13509 Members: String("m"), 13510 OrganizationAdministration: String("oa"), 13511 OrganizationHooks: String("oh"), 13512 OrganizationPlan: String("op"), 13513 OrganizationPreReceiveHooks: String("opr"), 13514 OrganizationProjects: String("op"), 13515 OrganizationSecrets: String("os"), 13516 OrganizationSelfHostedRunners: String("osh"), 13517 OrganizationUserBlocking: String("oub"), 13518 Packages: String("pkg"), 13519 Pages: String("pg"), 13520 PullRequests: String("pr"), 13521 RepositoryHooks: String("rh"), 13522 RepositoryProjects: String("rp"), 13523 RepositoryPreReceiveHooks: String("rprh"), 13524 Secrets: String("s"), 13525 SecretScanningAlerts: String("ssa"), 13526 SecurityEvents: String("se"), 13527 SingleFile: String("sf"), 13528 Statuses: String("s"), 13529 TeamDiscussions: String("td"), 13530 VulnerabilityAlerts: String("va"), 13531 Workflows: String("w"), 13532 }, 13533 CreatedAt: &Timestamp{referenceTime}, 13534 UpdatedAt: &Timestamp{referenceTime}, 13535 HasMultipleSingleFiles: Bool(false), 13536 SuspendedBy: &User{ 13537 Login: String("l"), 13538 ID: Int64(1), 13539 URL: String("u"), 13540 AvatarURL: String("a"), 13541 GravatarID: String("g"), 13542 Name: String("n"), 13543 Company: String("c"), 13544 Blog: String("b"), 13545 Location: String("l"), 13546 Email: String("e"), 13547 Hireable: Bool(true), 13548 Bio: String("b"), 13549 TwitterUsername: String("t"), 13550 PublicRepos: Int(1), 13551 Followers: Int(1), 13552 Following: Int(1), 13553 CreatedAt: &Timestamp{referenceTime}, 13554 SuspendedAt: &Timestamp{referenceTime}, 13555 }, 13556 SuspendedAt: &Timestamp{referenceTime}, 13557 }, 13558 } 13559 13560 want := `{ 13561 "action": "a", 13562 "pull_request": { 13563 "id": 1 13564 }, 13565 "thread": { 13566 "comments": [ 13567 { 13568 "id": 1 13569 }, 13570 { 13571 "id": 2 13572 } 13573 ] 13574 }, 13575 "repository": { 13576 "id": 1, 13577 "name": "n", 13578 "url": "s" 13579 }, 13580 "sender": { 13581 "login": "l", 13582 "id": 1, 13583 "node_id": "n", 13584 "avatar_url": "a", 13585 "url": "u", 13586 "events_url": "e", 13587 "repos_url": "r" 13588 }, 13589 "installation": { 13590 "id": 1, 13591 "node_id": "nid", 13592 "app_id": 1, 13593 "app_slug": "as", 13594 "target_id": 1, 13595 "account": { 13596 "login": "l", 13597 "id": 1, 13598 "avatar_url": "a", 13599 "gravatar_id": "g", 13600 "name": "n", 13601 "company": "c", 13602 "blog": "b", 13603 "location": "l", 13604 "email": "e", 13605 "hireable": true, 13606 "bio": "b", 13607 "twitter_username": "t", 13608 "public_repos": 1, 13609 "followers": 1, 13610 "following": 1, 13611 "created_at": ` + referenceTimeStr + `, 13612 "suspended_at": ` + referenceTimeStr + `, 13613 "url": "u" 13614 }, 13615 "access_tokens_url": "atu", 13616 "repositories_url": "ru", 13617 "html_url": "hu", 13618 "target_type": "tt", 13619 "single_file_name": "sfn", 13620 "repository_selection": "rs", 13621 "events": [ 13622 "e" 13623 ], 13624 "single_file_paths": [ 13625 "s" 13626 ], 13627 "permissions": { 13628 "actions": "a", 13629 "administration": "ad", 13630 "checks": "c", 13631 "contents": "co", 13632 "content_references": "cr", 13633 "deployments": "d", 13634 "environments": "e", 13635 "issues": "i", 13636 "metadata": "md", 13637 "members": "m", 13638 "organization_administration": "oa", 13639 "organization_hooks": "oh", 13640 "organization_plan": "op", 13641 "organization_pre_receive_hooks": "opr", 13642 "organization_projects": "op", 13643 "organization_secrets": "os", 13644 "organization_self_hosted_runners": "osh", 13645 "organization_user_blocking": "oub", 13646 "packages": "pkg", 13647 "pages": "pg", 13648 "pull_requests": "pr", 13649 "repository_hooks": "rh", 13650 "repository_projects": "rp", 13651 "repository_pre_receive_hooks": "rprh", 13652 "secrets": "s", 13653 "secret_scanning_alerts": "ssa", 13654 "security_events": "se", 13655 "single_file": "sf", 13656 "statuses": "s", 13657 "team_discussions": "td", 13658 "vulnerability_alerts": "va", 13659 "workflows": "w" 13660 }, 13661 "created_at": ` + referenceTimeStr + `, 13662 "updated_at": ` + referenceTimeStr + `, 13663 "has_multiple_single_files": false, 13664 "suspended_by": { 13665 "login": "l", 13666 "id": 1, 13667 "avatar_url": "a", 13668 "gravatar_id": "g", 13669 "name": "n", 13670 "company": "c", 13671 "blog": "b", 13672 "location": "l", 13673 "email": "e", 13674 "hireable": true, 13675 "bio": "b", 13676 "twitter_username": "t", 13677 "public_repos": 1, 13678 "followers": 1, 13679 "following": 1, 13680 "created_at": ` + referenceTimeStr + `, 13681 "suspended_at": ` + referenceTimeStr + `, 13682 "url": "u" 13683 }, 13684 "suspended_at": ` + referenceTimeStr + ` 13685 } 13686 }` 13687 13688 testJSONMarshal(t, u, want) 13689 } 13690 13691 func TestPullRequestTargetEvent_Marshal(t *testing.T) { 13692 testJSONMarshal(t, &PullRequestTargetEvent{}, "{}") 13693 13694 u := &PullRequestTargetEvent{ 13695 Action: String("a"), 13696 Assignee: &User{ 13697 Login: String("l"), 13698 ID: Int64(1), 13699 NodeID: String("n"), 13700 URL: String("u"), 13701 ReposURL: String("r"), 13702 EventsURL: String("e"), 13703 AvatarURL: String("a"), 13704 }, 13705 Number: Int(1), 13706 PullRequest: &PullRequest{ID: Int64(1)}, 13707 Changes: &EditChange{ 13708 Title: &EditTitle{ 13709 From: String("TitleFrom"), 13710 }, 13711 Body: &EditBody{ 13712 From: String("BodyFrom"), 13713 }, 13714 Base: &EditBase{ 13715 Ref: &EditRef{ 13716 From: String("BaseRefFrom"), 13717 }, 13718 SHA: &EditSHA{ 13719 From: String("BaseSHAFrom"), 13720 }, 13721 }, 13722 }, 13723 RequestedReviewer: &User{ 13724 Login: String("l"), 13725 ID: Int64(1), 13726 NodeID: String("n"), 13727 URL: String("u"), 13728 ReposURL: String("r"), 13729 EventsURL: String("e"), 13730 AvatarURL: String("a"), 13731 }, 13732 RequestedTeam: &Team{ID: Int64(1)}, 13733 Label: &Label{ID: Int64(1)}, 13734 Before: String("before"), 13735 After: String("after"), 13736 Repo: &Repository{ 13737 ID: Int64(1), 13738 URL: String("s"), 13739 Name: String("n"), 13740 }, 13741 Organization: &Organization{ 13742 BillingEmail: String("be"), 13743 Blog: String("b"), 13744 Company: String("c"), 13745 Email: String("e"), 13746 TwitterUsername: String("tu"), 13747 Location: String("loc"), 13748 Name: String("n"), 13749 Description: String("d"), 13750 IsVerified: Bool(true), 13751 HasOrganizationProjects: Bool(true), 13752 HasRepositoryProjects: Bool(true), 13753 DefaultRepoPermission: String("drp"), 13754 MembersCanCreateRepos: Bool(true), 13755 MembersCanCreateInternalRepos: Bool(true), 13756 MembersCanCreatePrivateRepos: Bool(true), 13757 MembersCanCreatePublicRepos: Bool(false), 13758 MembersAllowedRepositoryCreationType: String("marct"), 13759 MembersCanCreatePages: Bool(true), 13760 MembersCanCreatePublicPages: Bool(false), 13761 MembersCanCreatePrivatePages: Bool(true), 13762 }, 13763 Sender: &User{ 13764 Login: String("l"), 13765 ID: Int64(1), 13766 NodeID: String("n"), 13767 URL: String("u"), 13768 ReposURL: String("r"), 13769 EventsURL: String("e"), 13770 AvatarURL: String("a"), 13771 }, 13772 Installation: &Installation{ 13773 ID: Int64(1), 13774 NodeID: String("nid"), 13775 AppID: Int64(1), 13776 AppSlug: String("as"), 13777 TargetID: Int64(1), 13778 Account: &User{ 13779 Login: String("l"), 13780 ID: Int64(1), 13781 URL: String("u"), 13782 AvatarURL: String("a"), 13783 GravatarID: String("g"), 13784 Name: String("n"), 13785 Company: String("c"), 13786 Blog: String("b"), 13787 Location: String("l"), 13788 Email: String("e"), 13789 Hireable: Bool(true), 13790 Bio: String("b"), 13791 TwitterUsername: String("t"), 13792 PublicRepos: Int(1), 13793 Followers: Int(1), 13794 Following: Int(1), 13795 CreatedAt: &Timestamp{referenceTime}, 13796 SuspendedAt: &Timestamp{referenceTime}, 13797 }, 13798 AccessTokensURL: String("atu"), 13799 RepositoriesURL: String("ru"), 13800 HTMLURL: String("hu"), 13801 TargetType: String("tt"), 13802 SingleFileName: String("sfn"), 13803 RepositorySelection: String("rs"), 13804 Events: []string{"e"}, 13805 SingleFilePaths: []string{"s"}, 13806 Permissions: &InstallationPermissions{ 13807 Actions: String("a"), 13808 Administration: String("ad"), 13809 Checks: String("c"), 13810 Contents: String("co"), 13811 ContentReferences: String("cr"), 13812 Deployments: String("d"), 13813 Environments: String("e"), 13814 Issues: String("i"), 13815 Metadata: String("md"), 13816 Members: String("m"), 13817 OrganizationAdministration: String("oa"), 13818 OrganizationHooks: String("oh"), 13819 OrganizationPlan: String("op"), 13820 OrganizationPreReceiveHooks: String("opr"), 13821 OrganizationProjects: String("op"), 13822 OrganizationSecrets: String("os"), 13823 OrganizationSelfHostedRunners: String("osh"), 13824 OrganizationUserBlocking: String("oub"), 13825 Packages: String("pkg"), 13826 Pages: String("pg"), 13827 PullRequests: String("pr"), 13828 RepositoryHooks: String("rh"), 13829 RepositoryProjects: String("rp"), 13830 RepositoryPreReceiveHooks: String("rprh"), 13831 Secrets: String("s"), 13832 SecretScanningAlerts: String("ssa"), 13833 SecurityEvents: String("se"), 13834 SingleFile: String("sf"), 13835 Statuses: String("s"), 13836 TeamDiscussions: String("td"), 13837 VulnerabilityAlerts: String("va"), 13838 Workflows: String("w"), 13839 }, 13840 CreatedAt: &Timestamp{referenceTime}, 13841 UpdatedAt: &Timestamp{referenceTime}, 13842 HasMultipleSingleFiles: Bool(false), 13843 SuspendedBy: &User{ 13844 Login: String("l"), 13845 ID: Int64(1), 13846 URL: String("u"), 13847 AvatarURL: String("a"), 13848 GravatarID: String("g"), 13849 Name: String("n"), 13850 Company: String("c"), 13851 Blog: String("b"), 13852 Location: String("l"), 13853 Email: String("e"), 13854 Hireable: Bool(true), 13855 Bio: String("b"), 13856 TwitterUsername: String("t"), 13857 PublicRepos: Int(1), 13858 Followers: Int(1), 13859 Following: Int(1), 13860 CreatedAt: &Timestamp{referenceTime}, 13861 SuspendedAt: &Timestamp{referenceTime}, 13862 }, 13863 SuspendedAt: &Timestamp{referenceTime}, 13864 }, 13865 } 13866 13867 want := `{ 13868 "action": "a", 13869 "assignee": { 13870 "login": "l", 13871 "id": 1, 13872 "node_id": "n", 13873 "avatar_url": "a", 13874 "url": "u", 13875 "events_url": "e", 13876 "repos_url": "r" 13877 }, 13878 "number": 1, 13879 "pull_request": { 13880 "id": 1 13881 }, 13882 "changes": { 13883 "title": { 13884 "from": "TitleFrom" 13885 }, 13886 "body": { 13887 "from": "BodyFrom" 13888 }, 13889 "base": { 13890 "ref": { 13891 "from": "BaseRefFrom" 13892 }, 13893 "sha": { 13894 "from": "BaseSHAFrom" 13895 } 13896 } 13897 }, 13898 "requested_reviewer": { 13899 "login": "l", 13900 "id": 1, 13901 "node_id": "n", 13902 "avatar_url": "a", 13903 "url": "u", 13904 "events_url": "e", 13905 "repos_url": "r" 13906 }, 13907 "requested_team": { 13908 "id": 1 13909 }, 13910 "repository": { 13911 "id": 1, 13912 "name": "n", 13913 "url": "s" 13914 }, 13915 "sender": { 13916 "login": "l", 13917 "id": 1, 13918 "node_id": "n", 13919 "avatar_url": "a", 13920 "url": "u", 13921 "events_url": "e", 13922 "repos_url": "r" 13923 }, 13924 "installation": { 13925 "id": 1, 13926 "node_id": "nid", 13927 "app_id": 1, 13928 "app_slug": "as", 13929 "target_id": 1, 13930 "account": { 13931 "login": "l", 13932 "id": 1, 13933 "avatar_url": "a", 13934 "gravatar_id": "g", 13935 "name": "n", 13936 "company": "c", 13937 "blog": "b", 13938 "location": "l", 13939 "email": "e", 13940 "hireable": true, 13941 "bio": "b", 13942 "twitter_username": "t", 13943 "public_repos": 1, 13944 "followers": 1, 13945 "following": 1, 13946 "created_at": ` + referenceTimeStr + `, 13947 "suspended_at": ` + referenceTimeStr + `, 13948 "url": "u" 13949 }, 13950 "access_tokens_url": "atu", 13951 "repositories_url": "ru", 13952 "html_url": "hu", 13953 "target_type": "tt", 13954 "single_file_name": "sfn", 13955 "repository_selection": "rs", 13956 "events": [ 13957 "e" 13958 ], 13959 "single_file_paths": [ 13960 "s" 13961 ], 13962 "permissions": { 13963 "actions": "a", 13964 "administration": "ad", 13965 "checks": "c", 13966 "contents": "co", 13967 "content_references": "cr", 13968 "deployments": "d", 13969 "environments": "e", 13970 "issues": "i", 13971 "metadata": "md", 13972 "members": "m", 13973 "organization_administration": "oa", 13974 "organization_hooks": "oh", 13975 "organization_plan": "op", 13976 "organization_pre_receive_hooks": "opr", 13977 "organization_projects": "op", 13978 "organization_secrets": "os", 13979 "organization_self_hosted_runners": "osh", 13980 "organization_user_blocking": "oub", 13981 "packages": "pkg", 13982 "pages": "pg", 13983 "pull_requests": "pr", 13984 "repository_hooks": "rh", 13985 "repository_projects": "rp", 13986 "repository_pre_receive_hooks": "rprh", 13987 "secrets": "s", 13988 "secret_scanning_alerts": "ssa", 13989 "security_events": "se", 13990 "single_file": "sf", 13991 "statuses": "s", 13992 "team_discussions": "td", 13993 "vulnerability_alerts": "va", 13994 "workflows": "w" 13995 }, 13996 "created_at": ` + referenceTimeStr + `, 13997 "updated_at": ` + referenceTimeStr + `, 13998 "has_multiple_single_files": false, 13999 "suspended_by": { 14000 "login": "l", 14001 "id": 1, 14002 "avatar_url": "a", 14003 "gravatar_id": "g", 14004 "name": "n", 14005 "company": "c", 14006 "blog": "b", 14007 "location": "l", 14008 "email": "e", 14009 "hireable": true, 14010 "bio": "b", 14011 "twitter_username": "t", 14012 "public_repos": 1, 14013 "followers": 1, 14014 "following": 1, 14015 "created_at": ` + referenceTimeStr + `, 14016 "suspended_at": ` + referenceTimeStr + `, 14017 "url": "u" 14018 }, 14019 "suspended_at": ` + referenceTimeStr + ` 14020 }, 14021 "label": { 14022 "id": 1 14023 }, 14024 "organization": { 14025 "name": "n", 14026 "company": "c", 14027 "blog": "b", 14028 "location": "loc", 14029 "email": "e", 14030 "twitter_username": "tu", 14031 "description": "d", 14032 "billing_email": "be", 14033 "is_verified": true, 14034 "has_organization_projects": true, 14035 "has_repository_projects": true, 14036 "default_repository_permission": "drp", 14037 "members_can_create_repositories": true, 14038 "members_can_create_public_repositories": false, 14039 "members_can_create_private_repositories": true, 14040 "members_can_create_internal_repositories": true, 14041 "members_allowed_repository_creation_type": "marct", 14042 "members_can_create_pages": true, 14043 "members_can_create_public_pages": false, 14044 "members_can_create_private_pages": true 14045 }, 14046 "before": "before", 14047 "after": "after" 14048 }` 14049 14050 testJSONMarshal(t, u, want) 14051 } 14052 14053 func TestRepositoryVulnerabilityAlertEvent_Marshal(t *testing.T) { 14054 testJSONMarshal(t, &RepositoryVulnerabilityAlertEvent{}, "{}") 14055 14056 u := &RepositoryVulnerabilityAlertEvent{ 14057 Action: String("a"), 14058 Alert: &RepositoryVulnerabilityAlert{ 14059 ID: Int64(1), 14060 AffectedRange: String("ar"), 14061 AffectedPackageName: String("apn"), 14062 ExternalReference: String("er"), 14063 ExternalIdentifier: String("ei"), 14064 FixedIn: String("fi"), 14065 Dismisser: &User{ 14066 Login: String("l"), 14067 ID: Int64(1), 14068 NodeID: String("n"), 14069 URL: String("u"), 14070 ReposURL: String("r"), 14071 EventsURL: String("e"), 14072 AvatarURL: String("a"), 14073 }, 14074 DismissReason: String("dr"), 14075 DismissedAt: &Timestamp{referenceTime}, 14076 }, 14077 Repository: &Repository{ 14078 ID: Int64(1), 14079 URL: String("s"), 14080 Name: String("n"), 14081 }, 14082 } 14083 14084 want := `{ 14085 "action": "a", 14086 "alert": { 14087 "id": 1, 14088 "affected_range": "ar", 14089 "affected_package_name": "apn", 14090 "external_reference": "er", 14091 "external_identifier": "ei", 14092 "fixed_in": "fi", 14093 "dismisser": { 14094 "login": "l", 14095 "id": 1, 14096 "node_id": "n", 14097 "avatar_url": "a", 14098 "url": "u", 14099 "events_url": "e", 14100 "repos_url": "r" 14101 }, 14102 "dismiss_reason": "dr", 14103 "dismissed_at": ` + referenceTimeStr + ` 14104 }, 14105 "repository": { 14106 "id": 1, 14107 "name": "n", 14108 "url": "s" 14109 } 14110 }` 14111 14112 testJSONMarshal(t, u, want) 14113 } 14114 14115 func TestSecretScanningAlertEvent_Marshal(t *testing.T) { 14116 testJSONMarshal(t, &SecretScanningAlertEvent{}, "{}") 14117 14118 u := &SecretScanningAlertEvent{ 14119 Action: String("a"), 14120 Alert: &SecretScanningAlert{ 14121 Number: Int(1), 14122 SecretType: String("t"), 14123 Resolution: String("r"), 14124 ResolvedBy: &User{ 14125 Login: String("l"), 14126 ID: Int64(1), 14127 NodeID: String("n"), 14128 URL: String("u"), 14129 ReposURL: String("r"), 14130 EventsURL: String("e"), 14131 AvatarURL: String("a"), 14132 }, 14133 ResolvedAt: &Timestamp{referenceTime}, 14134 }, 14135 Repo: &Repository{ 14136 ID: Int64(1), 14137 URL: String("s"), 14138 Name: String("n"), 14139 }, 14140 Organization: &Organization{ 14141 BillingEmail: String("be"), 14142 Blog: String("b"), 14143 Company: String("c"), 14144 Email: String("e"), 14145 TwitterUsername: String("tu"), 14146 Location: String("loc"), 14147 Name: String("n"), 14148 Description: String("d"), 14149 IsVerified: Bool(true), 14150 HasOrganizationProjects: Bool(true), 14151 HasRepositoryProjects: Bool(true), 14152 DefaultRepoPermission: String("drp"), 14153 MembersCanCreateRepos: Bool(true), 14154 MembersCanCreateInternalRepos: Bool(true), 14155 MembersCanCreatePrivateRepos: Bool(true), 14156 MembersCanCreatePublicRepos: Bool(false), 14157 MembersAllowedRepositoryCreationType: String("marct"), 14158 MembersCanCreatePages: Bool(true), 14159 MembersCanCreatePublicPages: Bool(false), 14160 MembersCanCreatePrivatePages: Bool(true), 14161 }, 14162 Enterprise: &Enterprise{ 14163 ID: Int(1), 14164 Slug: String("s"), 14165 Name: String("n"), 14166 NodeID: String("nid"), 14167 AvatarURL: String("au"), 14168 Description: String("d"), 14169 WebsiteURL: String("wu"), 14170 HTMLURL: String("hu"), 14171 CreatedAt: &Timestamp{referenceTime}, 14172 UpdatedAt: &Timestamp{referenceTime}, 14173 }, 14174 Sender: &User{ 14175 Login: String("l"), 14176 ID: Int64(1), 14177 NodeID: String("n"), 14178 URL: String("u"), 14179 ReposURL: String("r"), 14180 EventsURL: String("e"), 14181 AvatarURL: String("a"), 14182 }, 14183 Installation: &Installation{ 14184 ID: Int64(1), 14185 NodeID: String("nid"), 14186 AppID: Int64(1), 14187 AppSlug: String("as"), 14188 TargetID: Int64(1), 14189 Account: &User{ 14190 Login: String("l"), 14191 ID: Int64(1), 14192 URL: String("u"), 14193 AvatarURL: String("a"), 14194 GravatarID: String("g"), 14195 Name: String("n"), 14196 Company: String("c"), 14197 Blog: String("b"), 14198 Location: String("l"), 14199 Email: String("e"), 14200 Hireable: Bool(true), 14201 Bio: String("b"), 14202 TwitterUsername: String("t"), 14203 PublicRepos: Int(1), 14204 Followers: Int(1), 14205 Following: Int(1), 14206 CreatedAt: &Timestamp{referenceTime}, 14207 SuspendedAt: &Timestamp{referenceTime}, 14208 }, 14209 AccessTokensURL: String("atu"), 14210 RepositoriesURL: String("ru"), 14211 HTMLURL: String("hu"), 14212 TargetType: String("tt"), 14213 SingleFileName: String("sfn"), 14214 RepositorySelection: String("rs"), 14215 Events: []string{"e"}, 14216 SingleFilePaths: []string{"s"}, 14217 Permissions: &InstallationPermissions{ 14218 Actions: String("a"), 14219 Administration: String("ad"), 14220 Checks: String("c"), 14221 Contents: String("co"), 14222 ContentReferences: String("cr"), 14223 Deployments: String("d"), 14224 Environments: String("e"), 14225 Issues: String("i"), 14226 Metadata: String("md"), 14227 Members: String("m"), 14228 OrganizationAdministration: String("oa"), 14229 OrganizationHooks: String("oh"), 14230 OrganizationPlan: String("op"), 14231 OrganizationPreReceiveHooks: String("opr"), 14232 OrganizationProjects: String("op"), 14233 OrganizationSecrets: String("os"), 14234 OrganizationSelfHostedRunners: String("osh"), 14235 OrganizationUserBlocking: String("oub"), 14236 Packages: String("pkg"), 14237 Pages: String("pg"), 14238 PullRequests: String("pr"), 14239 RepositoryHooks: String("rh"), 14240 RepositoryProjects: String("rp"), 14241 RepositoryPreReceiveHooks: String("rprh"), 14242 Secrets: String("s"), 14243 SecretScanningAlerts: String("ssa"), 14244 SecurityEvents: String("se"), 14245 SingleFile: String("sf"), 14246 Statuses: String("s"), 14247 TeamDiscussions: String("td"), 14248 VulnerabilityAlerts: String("va"), 14249 Workflows: String("w"), 14250 }, 14251 CreatedAt: &Timestamp{referenceTime}, 14252 UpdatedAt: &Timestamp{referenceTime}, 14253 HasMultipleSingleFiles: Bool(false), 14254 SuspendedBy: &User{ 14255 Login: String("l"), 14256 ID: Int64(1), 14257 URL: String("u"), 14258 AvatarURL: String("a"), 14259 GravatarID: String("g"), 14260 Name: String("n"), 14261 Company: String("c"), 14262 Blog: String("b"), 14263 Location: String("l"), 14264 Email: String("e"), 14265 Hireable: Bool(true), 14266 Bio: String("b"), 14267 TwitterUsername: String("t"), 14268 PublicRepos: Int(1), 14269 Followers: Int(1), 14270 Following: Int(1), 14271 CreatedAt: &Timestamp{referenceTime}, 14272 SuspendedAt: &Timestamp{referenceTime}, 14273 }, 14274 SuspendedAt: &Timestamp{referenceTime}, 14275 }, 14276 } 14277 14278 want := `{ 14279 "action": "a", 14280 "alert": { 14281 "number": 1, 14282 "secret_type": "t", 14283 "resolution": "r", 14284 "resolved_by": { 14285 "login": "l", 14286 "id": 1, 14287 "node_id": "n", 14288 "avatar_url": "a", 14289 "url": "u", 14290 "events_url": "e", 14291 "repos_url": "r" 14292 }, 14293 "resolved_at": ` + referenceTimeStr + ` 14294 }, 14295 "repository": { 14296 "id": 1, 14297 "name": "n", 14298 "url": "s" 14299 }, 14300 "organization": { 14301 "name": "n", 14302 "company": "c", 14303 "blog": "b", 14304 "location": "loc", 14305 "email": "e", 14306 "twitter_username": "tu", 14307 "description": "d", 14308 "billing_email": "be", 14309 "is_verified": true, 14310 "has_organization_projects": true, 14311 "has_repository_projects": true, 14312 "default_repository_permission": "drp", 14313 "members_can_create_repositories": true, 14314 "members_can_create_public_repositories": false, 14315 "members_can_create_private_repositories": true, 14316 "members_can_create_internal_repositories": true, 14317 "members_allowed_repository_creation_type": "marct", 14318 "members_can_create_pages": true, 14319 "members_can_create_public_pages": false, 14320 "members_can_create_private_pages": true 14321 }, 14322 "enterprise": { 14323 "id": 1, 14324 "slug": "s", 14325 "name": "n", 14326 "node_id": "nid", 14327 "avatar_url": "au", 14328 "description": "d", 14329 "website_url": "wu", 14330 "html_url": "hu", 14331 "created_at": ` + referenceTimeStr + `, 14332 "updated_at": ` + referenceTimeStr + ` 14333 }, 14334 "sender": { 14335 "login": "l", 14336 "id": 1, 14337 "node_id": "n", 14338 "avatar_url": "a", 14339 "url": "u", 14340 "events_url": "e", 14341 "repos_url": "r" 14342 }, 14343 "installation": { 14344 "id": 1, 14345 "node_id": "nid", 14346 "app_id": 1, 14347 "app_slug": "as", 14348 "target_id": 1, 14349 "account": { 14350 "login": "l", 14351 "id": 1, 14352 "avatar_url": "a", 14353 "gravatar_id": "g", 14354 "name": "n", 14355 "company": "c", 14356 "blog": "b", 14357 "location": "l", 14358 "email": "e", 14359 "hireable": true, 14360 "bio": "b", 14361 "twitter_username": "t", 14362 "public_repos": 1, 14363 "followers": 1, 14364 "following": 1, 14365 "created_at": ` + referenceTimeStr + `, 14366 "suspended_at": ` + referenceTimeStr + `, 14367 "url": "u" 14368 }, 14369 "access_tokens_url": "atu", 14370 "repositories_url": "ru", 14371 "html_url": "hu", 14372 "target_type": "tt", 14373 "single_file_name": "sfn", 14374 "repository_selection": "rs", 14375 "events": [ 14376 "e" 14377 ], 14378 "single_file_paths": [ 14379 "s" 14380 ], 14381 "permissions": { 14382 "actions": "a", 14383 "administration": "ad", 14384 "checks": "c", 14385 "contents": "co", 14386 "content_references": "cr", 14387 "deployments": "d", 14388 "environments": "e", 14389 "issues": "i", 14390 "metadata": "md", 14391 "members": "m", 14392 "organization_administration": "oa", 14393 "organization_hooks": "oh", 14394 "organization_plan": "op", 14395 "organization_pre_receive_hooks": "opr", 14396 "organization_projects": "op", 14397 "organization_secrets": "os", 14398 "organization_self_hosted_runners": "osh", 14399 "organization_user_blocking": "oub", 14400 "packages": "pkg", 14401 "pages": "pg", 14402 "pull_requests": "pr", 14403 "repository_hooks": "rh", 14404 "repository_projects": "rp", 14405 "repository_pre_receive_hooks": "rprh", 14406 "secrets": "s", 14407 "secret_scanning_alerts": "ssa", 14408 "security_events": "se", 14409 "single_file": "sf", 14410 "statuses": "s", 14411 "team_discussions": "td", 14412 "vulnerability_alerts": "va", 14413 "workflows": "w" 14414 }, 14415 "created_at": ` + referenceTimeStr + `, 14416 "updated_at": ` + referenceTimeStr + `, 14417 "has_multiple_single_files": false, 14418 "suspended_by": { 14419 "login": "l", 14420 "id": 1, 14421 "avatar_url": "a", 14422 "gravatar_id": "g", 14423 "name": "n", 14424 "company": "c", 14425 "blog": "b", 14426 "location": "l", 14427 "email": "e", 14428 "hireable": true, 14429 "bio": "b", 14430 "twitter_username": "t", 14431 "public_repos": 1, 14432 "followers": 1, 14433 "following": 1, 14434 "created_at": ` + referenceTimeStr + `, 14435 "suspended_at": ` + referenceTimeStr + `, 14436 "url": "u" 14437 }, 14438 "suspended_at": ` + referenceTimeStr + ` 14439 } 14440 }` 14441 14442 testJSONMarshal(t, u, want) 14443 } 14444 14445 func TestSecurityAdvisoryEvent_Marshal(t *testing.T) { 14446 testJSONMarshal(t, &SecurityAdvisoryEvent{}, "{}") 14447 u := &SecurityAdvisoryEvent{ 14448 Action: String("published"), 14449 SecurityAdvisory: &SecurityAdvisory{ 14450 GHSAID: String("GHSA-rf4j-j272-some"), 14451 Summary: String("Siuuuuuuuuu"), 14452 Description: String("desc"), 14453 Severity: String("moderate"), 14454 Identifiers: []*AdvisoryIdentifier{ 14455 { 14456 Value: String("GHSA-rf4j-j272-some"), 14457 Type: String("GHSA"), 14458 }, 14459 }, 14460 References: []*AdvisoryReference{ 14461 { 14462 URL: String("https://some-url"), 14463 }, 14464 }, 14465 PublishedAt: &Timestamp{referenceTime}, 14466 UpdatedAt: &Timestamp{referenceTime}, 14467 WithdrawnAt: nil, 14468 Vulnerabilities: []*AdvisoryVulnerability{ 14469 { 14470 Package: &VulnerabilityPackage{ 14471 Ecosystem: String("ucl"), 14472 Name: String("penaldo"), 14473 }, 14474 Severity: String("moderate"), 14475 VulnerableVersionRange: String(">= 2.0.0, < 2.0.2"), 14476 FirstPatchedVersion: &FirstPatchedVersion{ 14477 Identifier: String("2.0.2"), 14478 }, 14479 }, 14480 }, 14481 }, 14482 } 14483 14484 want := `{ 14485 "action": "published", 14486 "security_advisory": { 14487 "ghsa_id": "GHSA-rf4j-j272-some", 14488 "summary": "Siuuuuuuuuu", 14489 "description": "desc", 14490 "severity": "moderate", 14491 "identifiers": [ 14492 { 14493 "value": "GHSA-rf4j-j272-some", 14494 "type": "GHSA" 14495 } 14496 ], 14497 "references": [ 14498 { 14499 "url": "https://some-url" 14500 } 14501 ], 14502 "published_at": ` + referenceTimeStr + `, 14503 "updated_at": ` + referenceTimeStr + `, 14504 "withdrawn_at": null, 14505 "vulnerabilities": [ 14506 { 14507 "package": { 14508 "ecosystem": "ucl", 14509 "name": "penaldo" 14510 }, 14511 "severity": "moderate", 14512 "vulnerable_version_range": ">= 2.0.0, < 2.0.2", 14513 "first_patched_version": { 14514 "identifier": "2.0.2" 14515 } 14516 } 14517 ] 14518 } 14519 }` 14520 14521 testJSONMarshal(t, u, want) 14522 } 14523 14524 func TestCodeScanningAlertEvent_Marshal(t *testing.T) { 14525 testJSONMarshal(t, &CodeScanningAlertEvent{}, "{}") 14526 14527 u := &CodeScanningAlertEvent{ 14528 Action: String("reopened"), 14529 Alert: &Alert{ 14530 Number: Int(10), 14531 Rule: &Rule{ 14532 ID: String("Style/FrozenStringLiteralComment"), 14533 Severity: String("note"), 14534 Description: String("desc"), 14535 FullDescription: String("full desc"), 14536 Tags: []string{"style"}, 14537 Help: String("help"), 14538 }, 14539 Tool: &Tool{ 14540 Name: String("Rubocop"), 14541 Version: nil, 14542 }, 14543 CreatedAt: &Timestamp{referenceTime}, 14544 UpdatedAt: &Timestamp{referenceTime}, 14545 FixedAt: nil, 14546 State: String("open"), 14547 URL: String("a"), 14548 HTMLURL: String("a"), 14549 Instances: []*MostRecentInstance{ 14550 { 14551 Ref: String("refs/heads/main"), 14552 AnalysisKey: String(".github/workflows/workflow.yml:upload"), 14553 Environment: String("{}"), 14554 State: String("open"), 14555 }, 14556 }, 14557 DismissedBy: nil, 14558 DismissedAt: nil, 14559 DismissedReason: nil, 14560 }, 14561 Ref: String("refs/heads/main"), 14562 CommitOID: String("d6e4c75c141dbacecc279b721b8bsomeSHA"), 14563 Repo: &Repository{ 14564 ID: Int64(1234234535), 14565 NodeID: String("MDEwOlJlcG9zaXRvcnkxODY4NT=="), 14566 Owner: &User{ 14567 Login: String("Codertocat"), 14568 ID: Int64(21031067), 14569 NodeID: String("MDQ6VXNlcjIxMDMxMDY3"), 14570 AvatarURL: String("a"), 14571 GravatarID: String(""), 14572 URL: String("a"), 14573 HTMLURL: String("a"), 14574 Type: String("User"), 14575 SiteAdmin: Bool(false), 14576 FollowersURL: String("a"), 14577 FollowingURL: String("a"), 14578 EventsURL: String("a"), 14579 GistsURL: String("a"), 14580 OrganizationsURL: String("a"), 14581 ReceivedEventsURL: String("a"), 14582 ReposURL: String("a"), 14583 StarredURL: String("a"), 14584 SubscriptionsURL: String("a"), 14585 }, 14586 HTMLURL: String("a"), 14587 Name: String("Hello-World"), 14588 FullName: String("Codertocat/Hello-World"), 14589 Description: nil, 14590 Fork: Bool(false), 14591 Homepage: nil, 14592 DefaultBranch: String("main"), 14593 CreatedAt: &Timestamp{referenceTime}, 14594 PushedAt: &Timestamp{referenceTime}, 14595 UpdatedAt: &Timestamp{referenceTime}, 14596 CloneURL: String("a"), 14597 GitURL: String("a"), 14598 MirrorURL: nil, 14599 SSHURL: String("a"), 14600 SVNURL: String("a"), 14601 Language: nil, 14602 ForksCount: Int(0), 14603 OpenIssuesCount: Int(2), 14604 OpenIssues: Int(2), 14605 StargazersCount: Int(0), 14606 WatchersCount: Int(0), 14607 Watchers: Int(0), 14608 Size: Int(0), 14609 Archived: Bool(false), 14610 Disabled: Bool(false), 14611 License: nil, 14612 Private: Bool(false), 14613 HasIssues: Bool(true), 14614 HasWiki: Bool(true), 14615 HasPages: Bool(true), 14616 HasProjects: Bool(true), 14617 HasDownloads: Bool(true), 14618 URL: String("a"), 14619 ArchiveURL: String("a"), 14620 AssigneesURL: String("a"), 14621 BlobsURL: String("a"), 14622 BranchesURL: String("a"), 14623 CollaboratorsURL: String("a"), 14624 CommentsURL: String("a"), 14625 CommitsURL: String("a"), 14626 CompareURL: String("a"), 14627 ContentsURL: String("a"), 14628 ContributorsURL: String("a"), 14629 DeploymentsURL: String("a"), 14630 DownloadsURL: String("a"), 14631 EventsURL: String("a"), 14632 ForksURL: String("a"), 14633 GitCommitsURL: String("a"), 14634 GitRefsURL: String("a"), 14635 GitTagsURL: String("a"), 14636 HooksURL: String("a"), 14637 IssueCommentURL: String("a"), 14638 IssueEventsURL: String("a"), 14639 IssuesURL: String("a"), 14640 KeysURL: String("a"), 14641 LabelsURL: String("a"), 14642 LanguagesURL: String("a"), 14643 MergesURL: String("a"), 14644 MilestonesURL: String("a"), 14645 NotificationsURL: String("a"), 14646 PullsURL: String("a"), 14647 ReleasesURL: String("a"), 14648 StargazersURL: String("a"), 14649 StatusesURL: String("a"), 14650 SubscribersURL: String("a"), 14651 SubscriptionURL: String("a"), 14652 TagsURL: String("a"), 14653 TreesURL: String("a"), 14654 TeamsURL: String("a"), 14655 }, 14656 Org: &Organization{ 14657 Login: String("Octocoders"), 14658 ID: Int64(6), 14659 NodeID: String("MDEyOk9yZ2FuaXphdGlvbjY="), 14660 AvatarURL: String("a"), 14661 Description: String(""), 14662 URL: String("a"), 14663 EventsURL: String("a"), 14664 HooksURL: String("a"), 14665 IssuesURL: String("a"), 14666 MembersURL: String("a"), 14667 PublicMembersURL: String("a"), 14668 ReposURL: String("a"), 14669 }, 14670 Sender: &User{ 14671 Login: String("github"), 14672 ID: Int64(9919), 14673 NodeID: String("MDEyOk9yZ2FuaXphdGlvbjk5MTk="), 14674 AvatarURL: String("a"), 14675 HTMLURL: String("a"), 14676 GravatarID: String(""), 14677 Type: String("Organization"), 14678 SiteAdmin: Bool(false), 14679 URL: String("a"), 14680 EventsURL: String("a"), 14681 FollowingURL: String("a"), 14682 FollowersURL: String("a"), 14683 GistsURL: String("a"), 14684 OrganizationsURL: String("a"), 14685 ReceivedEventsURL: String("a"), 14686 ReposURL: String("a"), 14687 StarredURL: String("a"), 14688 SubscriptionsURL: String("a"), 14689 }, 14690 } 14691 14692 want := `{ 14693 "action": "reopened", 14694 "alert": { 14695 "number": 10, 14696 "created_at": ` + referenceTimeStr + `, 14697 "updated_at": ` + referenceTimeStr + `, 14698 "url": "a", 14699 "html_url": "a", 14700 "instances": [ 14701 { 14702 "ref": "refs/heads/main", 14703 "analysis_key": ".github/workflows/workflow.yml:upload", 14704 "environment": "{}", 14705 "state": "open" 14706 } 14707 ], 14708 "state": "open", 14709 "fixed_at": null, 14710 "dismissed_by": null, 14711 "dismissed_at": null, 14712 "dismissed_reason": null, 14713 "rule": { 14714 "id": "Style/FrozenStringLiteralComment", 14715 "severity": "note", 14716 "description": "desc", 14717 "full_description": "full desc", 14718 "tags": [ 14719 "style" 14720 ], 14721 "help": "help" 14722 }, 14723 "tool": { 14724 "name": "Rubocop", 14725 "version": null 14726 } 14727 }, 14728 "ref": "refs/heads/main", 14729 "commit_oid": "d6e4c75c141dbacecc279b721b8bsomeSHA", 14730 "repository": { 14731 "id": 1234234535, 14732 "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NT==", 14733 "name": "Hello-World", 14734 "full_name": "Codertocat/Hello-World", 14735 "private": false, 14736 "owner": { 14737 "login": "Codertocat", 14738 "id": 21031067, 14739 "node_id": "MDQ6VXNlcjIxMDMxMDY3", 14740 "avatar_url": "a", 14741 "gravatar_id": "", 14742 "url": "a", 14743 "html_url": "a", 14744 "followers_url": "a", 14745 "following_url": "a", 14746 "gists_url": "a", 14747 "starred_url": "a", 14748 "subscriptions_url": "a", 14749 "organizations_url": "a", 14750 "repos_url": "a", 14751 "events_url": "a", 14752 "received_events_url": "a", 14753 "type": "User", 14754 "site_admin": false 14755 }, 14756 "html_url": "a", 14757 "description": null, 14758 "fork": false, 14759 "url": "a", 14760 "forks_url": "a", 14761 "keys_url": "a", 14762 "collaborators_url": "a", 14763 "teams_url": "a", 14764 "hooks_url": "a", 14765 "issue_events_url": "a", 14766 "events_url": "a", 14767 "assignees_url": "a", 14768 "branches_url": "a", 14769 "tags_url": "a", 14770 "blobs_url": "a", 14771 "git_tags_url": "a", 14772 "git_refs_url": "a", 14773 "trees_url": "a", 14774 "statuses_url": "a", 14775 "languages_url": "a", 14776 "stargazers_url": "a", 14777 "contributors_url": "a", 14778 "subscribers_url": "a", 14779 "subscription_url": "a", 14780 "commits_url": "a", 14781 "git_commits_url": "a", 14782 "comments_url": "a", 14783 "issue_comment_url": "a", 14784 "contents_url": "a", 14785 "compare_url": "a", 14786 "merges_url": "a", 14787 "archive_url": "a", 14788 "downloads_url": "a", 14789 "issues_url": "a", 14790 "pulls_url": "a", 14791 "milestones_url": "a", 14792 "notifications_url": "a", 14793 "labels_url": "a", 14794 "releases_url": "a", 14795 "deployments_url": "a", 14796 "created_at": ` + referenceTimeStr + `, 14797 "updated_at": ` + referenceTimeStr + `, 14798 "pushed_at": ` + referenceTimeStr + `, 14799 "git_url": "a", 14800 "ssh_url": "a", 14801 "clone_url": "a", 14802 "svn_url": "a", 14803 "homepage": null, 14804 "size": 0, 14805 "stargazers_count": 0, 14806 "watchers_count": 0, 14807 "language": null, 14808 "has_issues": true, 14809 "has_projects": true, 14810 "has_downloads": true, 14811 "has_wiki": true, 14812 "has_pages": true, 14813 "forks_count": 0, 14814 "mirror_url": null, 14815 "archived": false, 14816 "disabled": false, 14817 "open_issues_count": 2, 14818 "license": null, 14819 "forks": 0, 14820 "open_issues": 2, 14821 "watchers": 0, 14822 "default_branch": "main" 14823 }, 14824 "organization": { 14825 "login": "Octocoders", 14826 "id": 6, 14827 "node_id": "MDEyOk9yZ2FuaXphdGlvbjY=", 14828 "url": "a", 14829 "repos_url": "a", 14830 "events_url": "a", 14831 "hooks_url": "a", 14832 "issues_url": "a", 14833 "members_url": "a", 14834 "public_members_url": "a", 14835 "avatar_url": "a", 14836 "description": "" 14837 }, 14838 "sender": { 14839 "login": "github", 14840 "id": 9919, 14841 "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", 14842 "avatar_url": "a", 14843 "gravatar_id": "", 14844 "url": "a", 14845 "html_url": "a", 14846 "followers_url": "a", 14847 "following_url": "a", 14848 "gists_url": "a", 14849 "starred_url": "a", 14850 "subscriptions_url": "a", 14851 "organizations_url": "a", 14852 "repos_url": "a", 14853 "events_url": "a", 14854 "received_events_url": "a", 14855 "type": "Organization", 14856 "site_admin": false 14857 } 14858 }` 14859 14860 testJSONMarshal(t, u, want) 14861 }