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