MCPcopy
hub / github.com/cli/cli / TestHelperIsOurs

Function TestHelperIsOurs

pkg/cmd/auth/shared/gitcredentials/helper_config_test.go:74–125  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

72}
73
74func TestHelperIsOurs(t *testing.T) {
75 tests := []struct {
76 name string
77 cmd string
78 want bool
79 windowsOnly bool
80 }{
81 {
82 name: "blank",
83 cmd: "",
84 want: false,
85 },
86 {
87 name: "invalid",
88 cmd: "!",
89 want: false,
90 },
91 {
92 name: "osxkeychain",
93 cmd: "osxkeychain",
94 want: false,
95 },
96 {
97 name: "looks like gh but isn't",
98 cmd: "gh auth",
99 want: false,
100 },
101 {
102 name: "ours",
103 cmd: "!/path/to/gh auth",
104 want: true,
105 },
106 {
107 name: "ours - Windows edition",
108 cmd: `!'C:\Program Files\GitHub CLI\gh.exe' auth git-credential`,
109 want: true,
110 windowsOnly: true,
111 },
112 }
113 for _, tt := range tests {
114 t.Run(tt.name, func(t *testing.T) {
115 if tt.windowsOnly && runtime.GOOS != "windows" {
116 t.Skip("skipping test on non-Windows platform")
117 }
118
119 h := gitcredentials.Helper{Cmd: tt.cmd}
120 if got := h.IsOurs(); got != tt.want {
121 t.Errorf("IsOurs() = %v, want %v", got, tt.want)
122 }
123 })
124 }
125}

Callers

nothing calls this directly

Calls 4

IsOursMethod · 0.95
SkipMethod · 0.80
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected