add test helpers

This commit is contained in:
vilmibm 2022-08-15 13:53:43 -05:00
parent 8bba7f9624
commit 2d093c1741
4 changed files with 51 additions and 26 deletions

View file

@ -48,14 +48,14 @@ func TestLogin_ssh(t *testing.T) {
httpmock.StringResponse(`{}`))
pm := &prompter.PrompterMock{}
pm.SelectFunc = func(prompt, _ string, _ []string) (int, error) {
pm.SelectFunc = func(prompt, _ string, opts []string) (int, error) {
switch prompt {
case "What is your preferred protocol for Git operations?":
return 1, nil
return prompter.IndexFor(opts, "SSH")
case "How would you like to authenticate GitHub CLI?":
return 1, nil
return prompter.IndexFor(opts, "Paste an authentication token")
}
return -1, nil
return -1, prompter.NoSuchPromptErr(prompt)
}
pm.PasswordFunc = func(_ string) (string, error) {
return "monkey", nil