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

Function TestPrompt_expiring_alreadyOurs

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

Source from the content-addressed store, hash-verified

273}
274
275func TestPrompt_expiring_alreadyOurs(t *testing.T) {
276 selectCalled := false
277 f := GitCredentialFlow{
278 Prompter: &prompter.PrompterMock{
279 SelectFunc: func(_, _ string, options []string) (int, error) {
280 selectCalled = true
281 return slices.Index(options, "Set up gh as your Git credential helper (recommended)"), nil
282 },
283 },
284 HelperConfig: &stubHelperConfig{helper: gitcredentials.Helper{Cmd: "!/path/to/gh auth git-credential"}},
285 }
286
287 err := f.Prompt("github.com", true)
288 if err != nil {
289 t.Fatalf("Prompt() error = %v", err)
290 }
291 if selectCalled {
292 t.Error("Select was called even though gh is already the credential helper")
293 }
294 if f.ShouldSetup() {
295 t.Error("ShouldSetup() = true, want false when gh is already the credential helper")
296 }
297 if !slices.Contains(f.Scopes(), "workflow") {
298 t.Errorf("Scopes() = %v, want it to include workflow", f.Scopes())
299 }
300}
301
302func TestSetup_expiring_externalHelper_configuresOurs(t *testing.T) {
303 cs, restoreRun := run.Stub()

Callers

nothing calls this directly

Calls 6

PromptMethod · 0.95
ShouldSetupMethod · 0.95
ScopesMethod · 0.95
ContainsMethod · 0.80
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected