(t *testing.T, pty *ptytest.PTY)
| 167 | } |
| 168 | |
| 169 | func login(t *testing.T, pty *ptytest.PTY) config.Root { |
| 170 | t.Helper() |
| 171 | |
| 172 | client := coderdtest.New(t, nil) |
| 173 | coderdtest.CreateFirstUser(t, client) |
| 174 | |
| 175 | doneChan := make(chan struct{}) |
| 176 | root, cfg := clitest.New(t, "login", "--force-tty", client.URL.String(), "--no-open") |
| 177 | root.Stdin = pty.Input() |
| 178 | root.Stdout = pty.Output() |
| 179 | go func() { |
| 180 | defer close(doneChan) |
| 181 | err := root.Run() |
| 182 | assert.NoError(t, err) |
| 183 | }() |
| 184 | |
| 185 | pty.ExpectMatch("Paste your token here:") |
| 186 | pty.WriteLine(client.SessionToken()) |
| 187 | pty.ExpectMatch("Welcome to Coder") |
| 188 | <-doneChan |
| 189 | |
| 190 | return cfg |
| 191 | } |
no test coverage detected