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

Function TestGitCredentialsSetup_setOurs_GH

pkg/cmd/auth/shared/git_credential_test.go:117–165  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

115}
116
117func TestGitCredentialsSetup_setOurs_GH(t *testing.T) {
118 cs, restoreRun := run.Stub()
119 defer restoreRun(t)
120 cs.Register(`git config --global --replace-all credential\.`, 0, "", func(args []string) {
121 if key := args[len(args)-2]; key != "credential.https://github.com.helper" {
122 t.Errorf("git config key was %q", key)
123 }
124 if val := args[len(args)-1]; val != "" {
125 t.Errorf("global credential helper configured to %q", val)
126 }
127 })
128 cs.Register(`git config --global --add credential\.`, 0, "", func(args []string) {
129 if key := args[len(args)-2]; key != "credential.https://github.com.helper" {
130 t.Errorf("git config key was %q", key)
131 }
132 if val := args[len(args)-1]; val != "!/path/to/gh auth git-credential" {
133 t.Errorf("global credential helper configured to %q", val)
134 }
135 })
136 cs.Register(`git config --global --replace-all credential\.`, 0, "", func(args []string) {
137 if key := args[len(args)-2]; key != "credential.https://gist.github.com.helper" {
138 t.Errorf("git config key was %q", key)
139 }
140 if val := args[len(args)-1]; val != "" {
141 t.Errorf("global credential helper configured to %q", val)
142 }
143 })
144 cs.Register(`git config --global --add credential\.`, 0, "", func(args []string) {
145 if key := args[len(args)-2]; key != "credential.https://gist.github.com.helper" {
146 t.Errorf("git config key was %q", key)
147 }
148 if val := args[len(args)-1]; val != "!/path/to/gh auth git-credential" {
149 t.Errorf("global credential helper configured to %q", val)
150 }
151 })
152
153 f := GitCredentialFlow{
154 helper: gitcredentials.Helper{},
155 HelperConfig: &gitcredentials.HelperConfig{
156 SelfExecutablePath: "/path/to/gh",
157 GitClient: &git.Client{GitPath: "some/path/git"},
158 },
159 }
160
161 if _, err := f.Setup("github.com", "monalisa", "PASSWD", false); err != nil {
162 t.Errorf("Setup() error = %v", err)
163 }
164
165}
166
167func TestSetup_setOurs_nonGH(t *testing.T) {
168 cs, restoreRun := run.Stub()

Callers

nothing calls this directly

Calls 4

SetupMethod · 0.95
StubFunction · 0.92
ErrorfMethod · 0.65
RegisterMethod · 0.45

Tested by

no test coverage detected