MCPcopy
hub / github.com/cli/cli / TestReleaseFeatures

Function TestReleaseFeatures

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

Source from the content-addressed store, hash-verified

674}
675
676func 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),

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