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

Function TestProjectFeatures

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

Source from the content-addressed store, hash-verified

580}
581
582func TestProjectFeatures(t *testing.T) {
583 tests := []struct {
584 name string
585 hostname string
586 queryResponse map[string]string
587 wantFeatures ProjectFeatures
588 wantErr bool
589 }{
590 {
591 name: "github.com",
592 hostname: "github.com",
593 wantFeatures: ProjectFeatures{
594 ProjectItemQuery: true,
595 },
596 },
597 {
598 name: "ghec data residency (ghe.com)",
599 hostname: "stampname.ghe.com",
600 wantFeatures: ProjectFeatures{
601 ProjectItemQuery: true,
602 },
603 },
604 {
605 name: "GHE empty response",
606 hostname: "git.my.org",
607 queryResponse: map[string]string{
608 `query ProjectV2_fields\b`: `{"data": {}}`,
609 },
610 wantFeatures: ProjectFeatures{},
611 },
612 {
613 name: "GHE items field without query arg",
614 hostname: "git.my.org",
615 queryResponse: map[string]string{
616 `query ProjectV2_fields\b`: heredoc.Doc(`
617 { "data": { "ProjectV2": { "fields": [
618 {"name": "items", "args": [
619 {"name": "after"},
620 {"name": "first"}
621 ]}
622 ] } } }
623 `),
624 },
625 wantFeatures: ProjectFeatures{},
626 },
627 {
628 name: "GHE items field with query arg",
629 hostname: "git.my.org",
630 queryResponse: map[string]string{
631 `query ProjectV2_fields\b`: heredoc.Doc(`
632 { "data": { "ProjectV2": { "fields": [
633 {"name": "items", "args": [
634 {"name": "after"},
635 {"name": "first"},
636 {"name": "query"}
637 ]}
638 ] } } }
639 `),

Callers

nothing calls this directly

Calls 9

VerifyMethod · 0.95
RegisterMethod · 0.95
ProjectFeaturesMethod · 0.95
ReplaceTripperFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected