test: batch 03 of refactoring CLI tests not to use PTY (#25935)

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

Batch of refactored CLI tests to avoid creating PTYs.
This commit is contained in:
Spike Curtis
2026-06-02 08:05:26 -04:00
committed by GitHub
parent bfa6ce32a6
commit 93b067f5f2
7 changed files with 184 additions and 141 deletions
+8 -6
View File
@@ -21,7 +21,8 @@ import (
"github.com/coder/coder/v2/provisioner/echo"
"github.com/coder/coder/v2/provisionersdk"
"github.com/coder/coder/v2/provisionersdk/proto"
"github.com/coder/coder/v2/pty/ptytest"
"github.com/coder/coder/v2/testutil"
"github.com/coder/coder/v2/testutil/expecter"
)
// dirSum calculates a checksum of the files in a directory.
@@ -320,8 +321,6 @@ func TestTemplatePull_ToDir(t *testing.T) {
inv, root := clitest.New(t, "templates", "pull", template.Name, actualDest)
clitest.SetupConfig(t, templateAdmin, root)
ptytest.New(t).Attach(inv)
require.NoError(t, inv.Run())
// Validate behavior of choosing template name in the absence of an output path argument.
@@ -343,6 +342,8 @@ func TestTemplatePull_ToDir(t *testing.T) {
func TestTemplatePull_FolderConflict(t *testing.T) {
t.Parallel()
logger := testutil.Logger(t)
ctx := testutil.Context(t, testutil.WaitMedium)
client := coderdtest.New(t, &coderdtest.Options{
IncludeProvisionerDaemon: true,
})
@@ -389,12 +390,13 @@ func TestTemplatePull_FolderConflict(t *testing.T) {
inv, root := clitest.New(t, "templates", "pull", template.Name, conflictDest)
clitest.SetupConfig(t, templateAdmin, root)
pty := ptytest.New(t).Attach(inv)
stdout := expecter.NewAttachedToInvocation(t, inv)
stdin := testutil.NewWriterAttachedToInvocation(t, logger.Named("stdin"), inv)
waiter := clitest.StartWithWaiter(t, inv)
pty.ExpectMatch("not empty")
pty.WriteLine("no")
stdout.ExpectMatchContext(ctx, "not empty")
stdin.WriteLine("no")
waiter.RequireError()