mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
test: batch 02 of refactoring CLI tests not to use PTY (#25931)
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:
@@ -20,8 +20,8 @@ import (
|
||||
"github.com/coder/coder/v2/coderd/database/dbfake"
|
||||
"github.com/coder/coder/v2/coderd/util/slice"
|
||||
"github.com/coder/coder/v2/codersdk"
|
||||
"github.com/coder/coder/v2/pty/ptytest"
|
||||
"github.com/coder/coder/v2/testutil"
|
||||
"github.com/coder/coder/v2/testutil/expecter"
|
||||
)
|
||||
|
||||
// makeAITask creates an AI-task workspace.
|
||||
@@ -71,13 +71,13 @@ func TestExpTaskList(t *testing.T) {
|
||||
inv, root := clitest.New(t, "task", "list")
|
||||
clitest.SetupConfig(t, memberClient, root)
|
||||
|
||||
pty := ptytest.New(t).Attach(inv)
|
||||
stdout := expecter.NewAttachedToInvocation(t, inv)
|
||||
ctx := testutil.Context(t, testutil.WaitShort)
|
||||
|
||||
err := inv.WithContext(ctx).Run()
|
||||
require.NoError(t, err)
|
||||
|
||||
pty.ExpectMatch("No tasks found.")
|
||||
stdout.ExpectMatchContext(ctx, "No tasks found.")
|
||||
})
|
||||
|
||||
t.Run("Single_Table", func(t *testing.T) {
|
||||
@@ -95,16 +95,16 @@ func TestExpTaskList(t *testing.T) {
|
||||
inv, root := clitest.New(t, "task", "list", "--column", "id,name,status,initial prompt")
|
||||
clitest.SetupConfig(t, memberClient, root)
|
||||
|
||||
pty := ptytest.New(t).Attach(inv)
|
||||
stdout := expecter.NewAttachedToInvocation(t, inv)
|
||||
ctx := testutil.Context(t, testutil.WaitShort)
|
||||
|
||||
err := inv.WithContext(ctx).Run()
|
||||
require.NoError(t, err)
|
||||
|
||||
// Validate the table includes the task and status.
|
||||
pty.ExpectMatch(task.Name)
|
||||
pty.ExpectMatch("initializing")
|
||||
pty.ExpectMatch(wantPrompt)
|
||||
stdout.ExpectMatchContext(ctx, task.Name)
|
||||
stdout.ExpectMatchContext(ctx, "initializing")
|
||||
stdout.ExpectMatchContext(ctx, wantPrompt)
|
||||
})
|
||||
|
||||
t.Run("StatusFilter_JSON", func(t *testing.T) {
|
||||
@@ -156,13 +156,13 @@ func TestExpTaskList(t *testing.T) {
|
||||
//nolint:gocritic // Owner client is intended here smoke test the member task not showing up.
|
||||
clitest.SetupConfig(t, client, root)
|
||||
|
||||
pty := ptytest.New(t).Attach(inv)
|
||||
stdout := expecter.NewAttachedToInvocation(t, inv)
|
||||
ctx := testutil.Context(t, testutil.WaitShort)
|
||||
|
||||
err := inv.WithContext(ctx).Run()
|
||||
require.NoError(t, err)
|
||||
|
||||
pty.ExpectMatch(task.Name)
|
||||
stdout.ExpectMatchContext(ctx, task.Name)
|
||||
})
|
||||
|
||||
t.Run("Quiet", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user