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

Function TestPrompt_expiring_configure

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

Source from the content-addressed store, hash-verified

198}
199
200func TestPrompt_expiring_configure(t *testing.T) {
201 var gotMessage string
202 ios, _, _, stderr := iostreams.Test()
203 hc := &stubHelperConfig{helper: gitcredentials.Helper{Cmd: "osxkeychain"}}
204 f := GitCredentialFlow{
205 IO: ios,
206 Prompter: &prompter.PrompterMock{
207 SelectFunc: func(message, _ string, options []string) (int, error) {
208 gotMessage = message
209 return slices.Index(options, "Set up gh as your Git credential helper (recommended)"), nil
210 },
211 },
212 HelperConfig: hc,
213 }
214
215 err := f.Prompt("github.com", true)
216 if err != nil {
217 t.Fatalf("Prompt() error = %v", err)
218 }
219 if !f.ShouldSetup() {
220 t.Error("ShouldSetup() = false, want true after choosing to configure gh")
221 }
222 if !slices.Contains(f.Scopes(), "workflow") {
223 t.Errorf("Scopes() = %v, want it to include workflow", f.Scopes())
224 }
225 if !strings.Contains(gotMessage, "How would you like to proceed?") {
226 t.Errorf("prompt message = %q, want the short decision prompt", gotMessage)
227 }
228 if !strings.Contains(stderr.String(), "expiring token") {
229 t.Errorf("warning = %q, want it to explain the expiring token consequence", stderr.String())
230 }
231}
232
233func TestPrompt_expiring_decline(t *testing.T) {
234 ios, _, _, _ := iostreams.Test()

Callers

nothing calls this directly

Calls 8

PromptMethod · 0.95
ShouldSetupMethod · 0.95
ScopesMethod · 0.95
TestFunction · 0.92
ContainsMethod · 0.80
ErrorfMethod · 0.65
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected