| 273 | } |
| 274 | |
| 275 | func 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 | |
| 302 | func TestSetup_expiring_externalHelper_configuresOurs(t *testing.T) { |
| 303 | cs, restoreRun := run.Stub() |