MCPcopy Index your code
hub / github.com/coder/coder / TestExpRpty

Function TestExpRpty

cli/exp_rpty_test.go:22–141  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20)
21
22func TestExpRpty(t *testing.T) {
23 t.Parallel()
24
25 t.Run("DefaultCommand", func(t *testing.T) {
26 t.Parallel()
27
28 client, workspace, agentToken := setupWorkspaceForAgent(t)
29 inv, root := clitest.New(t, "exp", "rpty", workspace.Name)
30 clitest.SetupConfig(t, client, root)
31 pty := ptytest.New(t).Attach(inv)
32
33 ctx := testutil.Context(t, testutil.WaitLong)
34
35 _ = agenttest.New(t, client.URL, agentToken)
36 _ = coderdtest.NewWorkspaceAgentWaiter(t, client, workspace.ID).Wait()
37
38 cmdDone := tGo(t, func() {
39 err := inv.WithContext(ctx).Run()
40 assert.NoError(t, err)
41 })
42
43 pty.WriteLine("exit")
44 <-cmdDone
45 })
46
47 t.Run("Command", func(t *testing.T) {
48 t.Parallel()
49
50 client, workspace, agentToken := setupWorkspaceForAgent(t)
51 randStr := uuid.NewString()
52 inv, root := clitest.New(t, "exp", "rpty", workspace.Name, "echo", randStr)
53 clitest.SetupConfig(t, client, root)
54 pty := ptytest.New(t).Attach(inv)
55
56 ctx := testutil.Context(t, testutil.WaitLong)
57
58 _ = agenttest.New(t, client.URL, agentToken)
59 _ = coderdtest.NewWorkspaceAgentWaiter(t, client, workspace.ID).Wait()
60
61 cmdDone := tGo(t, func() {
62 err := inv.WithContext(ctx).Run()
63 assert.NoError(t, err)
64 })
65
66 pty.ExpectMatch(randStr)
67 <-cmdDone
68 })
69
70 t.Run("NotFound", func(t *testing.T) {
71 t.Parallel()
72
73 client, _, _ := setupWorkspaceForAgent(t)
74 inv, root := clitest.New(t, "exp", "rpty", "not-found")
75 clitest.SetupConfig(t, client, root)
76
77 ctx := testutil.Context(t, testutil.WaitShort)
78 err := inv.WithContext(ctx).Run()
79 require.ErrorContains(t, err, "not found")

Callers

nothing calls this directly

Calls 15

NewFunction · 0.92
SetupConfigFunction · 0.92
NewFunction · 0.92
ContextFunction · 0.92
NewFunction · 0.92
NewWorkspaceAgentWaiterFunction · 0.92
WithProjectDiscoveryFunction · 0.92
tGoFunction · 0.85
WithContextMethod · 0.80
WriteLineMethod · 0.80
SkipMethod · 0.80

Tested by

no test coverage detected