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

Function TestHelperIsOurs

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

Source from the content-addressed store, hash-verified

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

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