Skip to content

Commit e5bee0b

Browse files
committed
cleanup test
1 parent df574a8 commit e5bee0b

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

cli/ssh_test.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -168,37 +168,27 @@ func TestSSH(t *testing.T) {
168168
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
169169
defer cancel()
170170

171-
type proc struct {
172-
stdout bytes.Buffer
173-
pty *ptytest.PTY
174-
err chan error
175-
}
176-
procs := make([]proc, 3)
177-
for i := range procs {
171+
ptys := make([]*ptytest.PTY, 3)
172+
for i := range ptys {
178173
// SSH to the workspace which should autostart it
179174
inv, root := clitest.New(t, "ssh", workspace.Name)
180175

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)
176+
ptys[i] = ptytest.New(t).Attach(inv)
187177
clitest.SetupConfig(t, client, root)
188178
clitest.StartWithAssert(t, inv, func(*testing.T, error) {
189179
// Noop.
190180
})
191181
}
192182

193183
var foundConflict int
194-
for _, proc := range procs {
184+
for _, pty := range ptys {
195185
// Either allow the command to start the workspace or fail
196186
// 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...)")
187+
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...)")
198188
if strings.Contains(match, "Unable to start the workspace due to conflict, the workspace may be starting, retrying without autostart...") {
199189
foundConflict++
200190
// It should retry without autostart.
201-
proc.pty.ExpectMatchContext(ctx, "Waiting for the workspace agent to connect")
191+
pty.ExpectMatchContext(ctx, "Waiting for the workspace agent to connect")
202192
}
203193
}
204194
// TODO(mafredri): Remove this if it's racy.

0 commit comments

Comments
 (0)