Skip to content

Commit 8e9690a

Browse files
committed
cleanup test
1 parent df574a8 commit 8e9690a

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

cli/ssh_test.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,32 +173,27 @@ func TestSSH(t *testing.T) {
173173
pty *ptytest.PTY
174174
err chan error
175175
}
176-
procs := make([]proc, 3)
177-
for i := range procs {
176+
ptys := make([]*ptytest.PTY, 3)
177+
for i := range ptys {
178178
// SSH to the workspace which should autostart it
179179
inv, root := clitest.New(t, "ssh", workspace.Name)
180180

181-
proc := proc{
182-
pty: ptytest.New(t).Attach(inv),
183-
err: make(chan error, 1),
184-
}
185-
procs[i] = proc
186-
inv.Stdout = io.MultiWriter(proc.pty.Output(), &proc.stdout)
181+
ptys[i] = ptytest.New(t).Attach(inv)
187182
clitest.SetupConfig(t, client, root)
188183
clitest.StartWithAssert(t, inv, func(*testing.T, error) {
189184
// Noop.
190185
})
191186
}
192187

193188
var foundConflict int
194-
for _, proc := range procs {
189+
for _, pty := range ptys {
195190
// Either allow the command to start the workspace or fail
196191
// due to conflict (race), in which case it retries.
197-
match := proc.pty.ExpectRegexMatchContext(ctx, "(Waiting for the workspace agent to connect|Unable to start the workspace due to conflict, the workspace may be starting, retrying without autostart...)")
192+
match := pty.ExpectRegexMatchContext(ctx, "(Waiting for the workspace agent to connect|Unable to start the workspace due to conflict, the workspace may be starting, retrying without autostart...)")
198193
if strings.Contains(match, "Unable to start the workspace due to conflict, the workspace may be starting, retrying without autostart...") {
199194
foundConflict++
200195
// It should retry without autostart.
201-
proc.pty.ExpectMatchContext(ctx, "Waiting for the workspace agent to connect")
196+
pty.ExpectMatchContext(ctx, "Waiting for the workspace agent to connect")
202197
}
203198
}
204199
// TODO(mafredri): Remove this if it's racy.

0 commit comments

Comments
 (0)