@@ -20,7 +20,7 @@ import (
20
20
"github.com/coder/coder/v2/coderd/database/dbfake"
21
21
"github.com/coder/coder/v2/codersdk"
22
22
"github.com/coder/coder/v2/provisionersdk/proto"
23
- "github.com/coder/coder/v2/pty/ptytest "
23
+ "github.com/coder/coder/v2/testutil "
24
24
)
25
25
26
26
func TestWorkspaceAgent (t * testing.T ) {
@@ -44,17 +44,17 @@ func TestWorkspaceAgent(t *testing.T) {
44
44
"--log-dir" , logDir ,
45
45
)
46
46
47
- pty := ptytest .New (t ).Attach (inv )
48
-
49
47
clitest .Start (t , inv )
50
- ctx := inv .Context ()
51
- pty .ExpectMatchContext (ctx , "agent is starting now" )
52
48
53
49
coderdtest .AwaitWorkspaceAgents (t , client , ws .ID )
54
50
55
- info , err := os .Stat (filepath .Join (logDir , "coder-agent.log" ))
56
- require .NoError (t , err )
57
- require .Greater (t , info .Size (), int64 (0 ))
51
+ require .Eventually (t , func () bool {
52
+ info , err := os .Stat (filepath .Join (logDir , "coder-agent.log" ))
53
+ if err != nil {
54
+ return false
55
+ }
56
+ return info .Size () > 0
57
+ }, testutil .WaitLong , testutil .IntervalMedium )
58
58
})
59
59
60
60
t .Run ("Azure" , func (t * testing.T ) {
@@ -84,6 +84,7 @@ func TestWorkspaceAgent(t *testing.T) {
84
84
//nolint:revive,staticcheck
85
85
context .WithValue (inv .Context (), "azure-client" , metadataClient ),
86
86
)
87
+
87
88
ctx := inv .Context ()
88
89
clitest .Start (t , inv )
89
90
coderdtest .AwaitWorkspaceAgents (t , client , ws .ID )
@@ -126,6 +127,7 @@ func TestWorkspaceAgent(t *testing.T) {
126
127
//nolint:revive,staticcheck
127
128
context .WithValue (inv .Context (), "aws-client" , metadataClient ),
128
129
)
130
+
129
131
clitest .Start (t , inv )
130
132
ctx := inv .Context ()
131
133
coderdtest .AwaitWorkspaceAgents (t , client , ws .ID )
@@ -164,8 +166,8 @@ func TestWorkspaceAgent(t *testing.T) {
164
166
}},
165
167
})
166
168
inv , cfg := clitest .New (t , "agent" , "--auth" , "google-instance-identity" , "--agent-url" , client .URL .String ())
167
- ptytest .New (t ).Attach (inv )
168
169
clitest .SetupConfig (t , member , cfg )
170
+
169
171
clitest .Start (t ,
170
172
inv .WithContext (
171
173
//nolint:revive,staticcheck
@@ -223,10 +225,7 @@ func TestWorkspaceAgent(t *testing.T) {
223
225
// Set the subsystems for the agent.
224
226
inv .Environ .Set (agent .EnvAgentSubsystem , fmt .Sprintf ("%s,%s" , codersdk .AgentSubsystemExectrace , codersdk .AgentSubsystemEnvbox ))
225
227
226
- pty := ptytest .New (t ).Attach (inv )
227
-
228
228
clitest .Start (t , inv )
229
- pty .ExpectMatchContext (inv .Context (), "agent is starting now" )
230
229
231
230
resources := coderdtest .AwaitWorkspaceAgents (t , client , ws .ID )
232
231
require .Len (t , resources , 1 )
0 commit comments