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