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

Function TestReleaseFeatures

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

Source from the content-addressed store, hash-verified

664}
665
666func 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),

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