1
1
package cli_test
2
2
3
3
import (
4
- "fmt"
5
4
"runtime"
6
5
"testing"
7
6
7
+ "github.com/google/uuid"
8
8
"github.com/ory/dockertest/v3"
9
9
"github.com/ory/dockertest/v3/docker"
10
10
@@ -23,7 +23,7 @@ import (
23
23
func TestExpRpty (t * testing.T ) {
24
24
t .Parallel ()
25
25
26
- t .Run ("OK " , func (t * testing.T ) {
26
+ t .Run ("DefaultCommand " , func (t * testing.T ) {
27
27
t .Parallel ()
28
28
29
29
client , workspace , agentToken := setupWorkspaceForAgent (t )
@@ -41,11 +41,33 @@ func TestExpRpty(t *testing.T) {
41
41
_ = agenttest .New (t , client .URL , agentToken )
42
42
_ = coderdtest .NewWorkspaceAgentWaiter (t , client , workspace .ID ).Wait ()
43
43
44
- pty .ExpectMatch (fmt .Sprintf ("Connected to %s" , workspace .Name ))
45
44
pty .WriteLine ("exit" )
46
45
<- cmdDone
47
46
})
48
47
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
+
49
71
t .Run ("NotFound" , func (t * testing.T ) {
50
72
t .Parallel ()
51
73
@@ -103,8 +125,6 @@ func TestExpRpty(t *testing.T) {
103
125
assert .NoError (t , err )
104
126
})
105
127
106
- pty .ExpectMatch (fmt .Sprintf ("Connected to %s" , workspace .Name ))
107
- pty .ExpectMatch ("Reconnect ID: " )
108
128
pty .ExpectMatch (" #" )
109
129
pty .WriteLine ("hostname" )
110
130
pty .ExpectMatch (ct .Container .Config .Hostname )
0 commit comments