test: batch 07 of refactoring CLI tests not to use PTY (#25997)

Closes [coder/internal#1400](https://github.com/coder/internal/issues/1400)

Final batch of refactored CLI tests to avoid creating PTYs.
This commit is contained in:
Spike Curtis
2026-06-03 15:16:42 -04:00
committed by GitHub
parent 88d9ce57e1
commit 7d7cc27581
22 changed files with 216 additions and 334 deletions
+3 -6
View File
@@ -22,8 +22,8 @@ import (
"github.com/coder/coder/v2/coderd/coderdtest"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/agentsdk"
"github.com/coder/coder/v2/pty/ptytest"
"github.com/coder/coder/v2/testutil"
"github.com/coder/coder/v2/testutil/expecter"
"github.com/coder/serpent"
)
@@ -275,10 +275,7 @@ func TestDERPHeaders(t *testing.T) {
}
inv, root := clitest.New(t, args...)
clitest.SetupConfig(t, member, root)
pty := ptytest.New(t)
inv.Stdin = pty.Input()
inv.Stderr = pty.Output()
inv.Stdout = pty.Output()
stdout := expecter.NewAttachedToInvocation(t, inv)
ctx := testutil.Context(t, testutil.WaitLong)
cmdDone := tGo(t, func() {
@@ -286,7 +283,7 @@ func TestDERPHeaders(t *testing.T) {
assert.NoError(t, err)
})
pty.ExpectMatch("pong from " + workspace.Name)
stdout.ExpectMatchContext(ctx, "pong from "+workspace.Name)
<-cmdDone
require.Greater(t, derpCalled.Load(), int64(0), "expected /derp to be called at least once")