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

Function TestProjectFeatures

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

Source from the content-addressed store, hash-verified

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

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