(t *testing.T)
| 666 | } |
| 667 | |
| 668 | func TestReleaseFeatures(t *testing.T) { |
| 669 | withImmutableReleaseSupport := `{"data":{"Release":{"fields":[{"name":"author"},{"name":"name"},{"name":"immutable"}]}}}` |
| 670 | withoutImmutableReleaseSupport := `{"data":{"Release":{"fields":[{"name":"author"},{"name":"name"}]}}}` |
| 671 | |
| 672 | tests := []struct { |
| 673 | name string |
| 674 | hostname string |
| 675 | httpStubs func(*httpmock.Registry) |
| 676 | wantFeatures ReleaseFeatures |
| 677 | }{ |
| 678 | { |
| 679 | // This is not a real case as `github.com` supports immutable releases. |
| 680 | name: "github.com, immutable releases unsupported", |
| 681 | hostname: "github.com", |
| 682 | httpStubs: func(reg *httpmock.Registry) { |
| 683 | reg.Register( |
| 684 | httpmock.GraphQL(`query Release_fields\b`), |
| 685 | httpmock.StringResponse(withoutImmutableReleaseSupport), |
| 686 | ) |
| 687 | }, |
| 688 | wantFeatures: ReleaseFeatures{ |
| 689 | ImmutableReleases: false, |
| 690 | }, |
| 691 | }, |
| 692 | { |
| 693 | name: "github.com, immutable releases supported", |
| 694 | hostname: "github.com", |
| 695 | httpStubs: func(reg *httpmock.Registry) { |
| 696 | reg.Register( |
| 697 | httpmock.GraphQL(`query Release_fields\b`), |
| 698 | httpmock.StringResponse(withImmutableReleaseSupport), |
| 699 | ) |
| 700 | }, |
| 701 | wantFeatures: ReleaseFeatures{ |
| 702 | ImmutableReleases: true, |
| 703 | }, |
| 704 | }, |
| 705 | { |
| 706 | // This is not a real case as `github.com` supports immutable releases. |
| 707 | name: "ghec data residency (ghe.com), immutable releases unsupported", |
| 708 | hostname: "stampname.ghe.com", |
| 709 | httpStubs: func(reg *httpmock.Registry) { |
| 710 | reg.Register( |
| 711 | httpmock.GraphQL(`query Release_fields\b`), |
| 712 | httpmock.StringResponse(withoutImmutableReleaseSupport), |
| 713 | ) |
| 714 | }, |
| 715 | wantFeatures: ReleaseFeatures{ |
| 716 | ImmutableReleases: false, |
| 717 | }, |
| 718 | }, |
| 719 | { |
| 720 | name: "ghec data residency (ghe.com), immutable releases supported", |
| 721 | hostname: "stampname.ghe.com", |
| 722 | httpStubs: func(reg *httpmock.Registry) { |
| 723 | reg.Register( |
| 724 | httpmock.GraphQL(`query Release_fields\b`), |
| 725 | httpmock.StringResponse(withImmutableReleaseSupport), |
nothing calls this directly
no test coverage detected