(t *testing.T)
| 29 | } |
| 30 | |
| 31 | func TestProcessOutput(t *testing.T) { |
| 32 | defaultPromptUserForCredential := func(ct CredentialType) string { |
| 33 | switch ct { |
| 34 | case Password: |
| 35 | return "password" |
| 36 | case Username: |
| 37 | return "username" |
| 38 | case Passphrase: |
| 39 | return "passphrase" |
| 40 | case PIN: |
| 41 | return "pin" |
| 42 | case Token: |
| 43 | return "token" |
| 44 | default: |
| 45 | panic("unexpected credential type") |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | scenarios := []struct { |
| 50 | name string |
| 51 | promptUserForCredential func(CredentialType) string |
| 52 | output string |
| 53 | expectedToWrite string |
| 54 | }{ |
| 55 | { |
| 56 | name: "no output", |
| 57 | promptUserForCredential: defaultPromptUserForCredential, |
| 58 | output: "", |
| 59 | expectedToWrite: "", |
| 60 | }, |
| 61 | { |
| 62 | name: "password prompt", |
| 63 | promptUserForCredential: defaultPromptUserForCredential, |
| 64 | output: "Password:", |
| 65 | expectedToWrite: "password", |
| 66 | }, |
| 67 | { |
| 68 | name: "password prompt 2", |
| 69 | promptUserForCredential: defaultPromptUserForCredential, |
| 70 | output: "Bill's password:", |
| 71 | expectedToWrite: "password", |
| 72 | }, |
| 73 | { |
| 74 | name: "password prompt 3", |
| 75 | promptUserForCredential: defaultPromptUserForCredential, |
| 76 | output: "Password for 'Bill':", |
| 77 | expectedToWrite: "password", |
| 78 | }, |
| 79 | { |
| 80 | name: "username prompt", |
| 81 | promptUserForCredential: defaultPromptUserForCredential, |
| 82 | output: "Username for 'Bill':", |
| 83 | expectedToWrite: "username", |
| 84 | }, |
| 85 | { |
| 86 | name: "passphrase prompt", |
| 87 | promptUserForCredential: defaultPromptUserForCredential, |
| 88 | output: "Enter passphrase for key '123':", |
nothing calls this directly
no test coverage detected