MCPcopy Create free account
hub / github.com/cli/cli / TestReleaseFeatures

Function TestReleaseFeatures

internal/featuredetection/feature_detection_test.go:668–777  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

666}
667
668func 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),

Callers

nothing calls this directly

Calls 8

RegisterMethod · 0.95
ReleaseFeaturesMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
ReplaceTripperFunction · 0.92
NewDetectorFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected