Skip to content

Commit f3595c3

Browse files
committed
fixup! feat(agent/reconnectingpty): allow selecting backend type
1 parent dea368b commit f3595c3

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

cli/exp_rpty_test.go

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package cli_test
22

33
import (
4-
"fmt"
54
"runtime"
65
"testing"
76

7+
"github.com/google/uuid"
88
"github.com/ory/dockertest/v3"
99
"github.com/ory/dockertest/v3/docker"
1010

@@ -23,7 +23,7 @@ import (
2323
func TestExpRpty(t *testing.T) {
2424
t.Parallel()
2525

26-
t.Run("OK", func(t *testing.T) {
26+
t.Run("DefaultCommand", func(t *testing.T) {
2727
t.Parallel()
2828

2929
client, workspace, agentToken := setupWorkspaceForAgent(t)
@@ -41,11 +41,33 @@ func TestExpRpty(t *testing.T) {
4141
_ = agenttest.New(t, client.URL, agentToken)
4242
_ = coderdtest.NewWorkspaceAgentWaiter(t, client, workspace.ID).Wait()
4343

44-
pty.ExpectMatch(fmt.Sprintf("Connected to %s", workspace.Name))
4544
pty.WriteLine("exit")
4645
<-cmdDone
4746
})
4847

48+
t.Run("Command", func(t *testing.T) {
49+
t.Parallel()
50+
51+
client, workspace, agentToken := setupWorkspaceForAgent(t)
52+
randStr := uuid.NewString()
53+
inv, root := clitest.New(t, "exp", "rpty", workspace.Name, "echo", randStr)
54+
clitest.SetupConfig(t, client, root)
55+
pty := ptytest.New(t).Attach(inv)
56+
57+
ctx := testutil.Context(t, testutil.WaitLong)
58+
59+
cmdDone := tGo(t, func() {
60+
err := inv.WithContext(ctx).Run()
61+
assert.NoError(t, err)
62+
})
63+
64+
_ = agenttest.New(t, client.URL, agentToken)
65+
_ = coderdtest.NewWorkspaceAgentWaiter(t, client, workspace.ID).Wait()
66+
67+
pty.ExpectMatch(randStr)
68+
<-cmdDone
69+
})
70+
4971
t.Run("NotFound", func(t *testing.T) {
5072
t.Parallel()
5173

@@ -103,8 +125,6 @@ func TestExpRpty(t *testing.T) {
103125
assert.NoError(t, err)
104126
})
105127

106-
pty.ExpectMatch(fmt.Sprintf("Connected to %s", workspace.Name))
107-
pty.ExpectMatch("Reconnect ID: ")
108128
pty.ExpectMatch(" #")
109129
pty.WriteLine("hostname")
110130
pty.ExpectMatch(ct.Container.Config.Hostname)

0 commit comments

Comments
 (0)