(t *testing.T)
| 34 | } |
| 35 | |
| 36 | func Test_NewCmdLogin(t *testing.T) { |
| 37 | tests := []struct { |
| 38 | name string |
| 39 | cli string |
| 40 | stdin string |
| 41 | stdinTTY bool |
| 42 | defaultHost string |
| 43 | wants LoginOptions |
| 44 | wantsErr bool |
| 45 | }{ |
| 46 | { |
| 47 | name: "nontty, with-token", |
| 48 | stdin: "abc123\n", |
| 49 | cli: "--with-token", |
| 50 | wants: LoginOptions{ |
| 51 | Hostname: "github.com", |
| 52 | Token: "abc123", |
| 53 | }, |
| 54 | }, |
| 55 | { |
| 56 | name: "nontty, with-token, enterprise default host", |
| 57 | stdin: "abc123\n", |
| 58 | cli: "--with-token", |
| 59 | defaultHost: "git.example.com", |
| 60 | wants: LoginOptions{ |
| 61 | Hostname: "git.example.com", |
| 62 | Token: "abc123", |
| 63 | }, |
| 64 | }, |
| 65 | { |
| 66 | name: "tty, with-token", |
| 67 | stdinTTY: true, |
| 68 | stdin: "def456", |
| 69 | cli: "--with-token", |
| 70 | wants: LoginOptions{ |
| 71 | Hostname: "github.com", |
| 72 | Token: "def456", |
| 73 | }, |
| 74 | }, |
| 75 | { |
| 76 | name: "nontty, hostname", |
| 77 | stdinTTY: false, |
| 78 | cli: "--hostname claire.redfield", |
| 79 | wants: LoginOptions{ |
| 80 | Hostname: "claire.redfield", |
| 81 | Token: "", |
| 82 | }, |
| 83 | }, |
| 84 | { |
| 85 | name: "nontty", |
| 86 | stdinTTY: false, |
| 87 | cli: "", |
| 88 | wants: LoginOptions{ |
| 89 | Hostname: "github.com", |
| 90 | Token: "", |
| 91 | }, |
| 92 | }, |
| 93 | { |
nothing calls this directly
no test coverage detected