@@ -49,13 +49,12 @@ func TestWorkspaceAgent(t *testing.T) {
49
49
cmd , _ := clitest .New (t , "agent" , "--auth" , "azure-instance-identity" , "--agent-url" , client .URL .String ())
50
50
ctx , cancelFunc := context .WithCancel (context .Background ())
51
51
defer cancelFunc ()
52
+ errC := make (chan error )
52
53
go func () {
53
- // A linting error occurs for weakly typing the context value here,
54
- // but it seems reasonable for a one-off test.
55
- // nolint
56
- ctx = context .WithValue (ctx , "azure-client" , metadataClient )
57
- err := cmd .ExecuteContext (ctx )
58
- require .NoError (t , err )
54
+ // A linting error occurs for weakly typing the context value here.
55
+ //nolint // The above seems reasonable for a one-off test.
56
+ ctx := context .WithValue (ctx , "azure-client" , metadataClient )
57
+ errC <- cmd .ExecuteContext (ctx )
59
58
}()
60
59
coderdtest .AwaitWorkspaceAgents (t , client , workspace .LatestBuild .ID )
61
60
resources , err := client .WorkspaceResourcesByBuild (ctx , workspace .LatestBuild .ID )
@@ -66,6 +65,8 @@ func TestWorkspaceAgent(t *testing.T) {
66
65
_ , err = dialer .Ping ()
67
66
require .NoError (t , err )
68
67
cancelFunc ()
68
+ err = <- errC
69
+ require .NoError (t , err )
69
70
})
70
71
71
72
t .Run ("AWS" , func (t * testing.T ) {
@@ -103,13 +104,12 @@ func TestWorkspaceAgent(t *testing.T) {
103
104
cmd , _ := clitest .New (t , "agent" , "--auth" , "aws-instance-identity" , "--agent-url" , client .URL .String ())
104
105
ctx , cancelFunc := context .WithCancel (context .Background ())
105
106
defer cancelFunc ()
107
+ errC := make (chan error )
106
108
go func () {
107
- // A linting error occurs for weakly typing the context value here,
108
- // but it seems reasonable for a one-off test.
109
- // nolint
110
- ctx = context .WithValue (ctx , "aws-client" , metadataClient )
111
- err := cmd .ExecuteContext (ctx )
112
- require .NoError (t , err )
109
+ // A linting error occurs for weakly typing the context value here.
110
+ //nolint // The above seems reasonable for a one-off test.
111
+ ctx := context .WithValue (ctx , "aws-client" , metadataClient )
112
+ errC <- cmd .ExecuteContext (ctx )
113
113
}()
114
114
coderdtest .AwaitWorkspaceAgents (t , client , workspace .LatestBuild .ID )
115
115
resources , err := client .WorkspaceResourcesByBuild (ctx , workspace .LatestBuild .ID )
@@ -120,6 +120,8 @@ func TestWorkspaceAgent(t *testing.T) {
120
120
_ , err = dialer .Ping ()
121
121
require .NoError (t , err )
122
122
cancelFunc ()
123
+ err = <- errC
124
+ require .NoError (t , err )
123
125
})
124
126
125
127
t .Run ("GoogleCloud" , func (t * testing.T ) {
@@ -157,13 +159,12 @@ func TestWorkspaceAgent(t *testing.T) {
157
159
cmd , _ := clitest .New (t , "agent" , "--auth" , "google-instance-identity" , "--agent-url" , client .URL .String ())
158
160
ctx , cancelFunc := context .WithCancel (context .Background ())
159
161
defer cancelFunc ()
162
+ errC := make (chan error )
160
163
go func () {
161
- // A linting error occurs for weakly typing the context value here,
162
- // but it seems reasonable for a one-off test.
163
- // nolint
164
- ctx = context .WithValue (ctx , "gcp-client" , metadata )
165
- err := cmd .ExecuteContext (ctx )
166
- require .NoError (t , err )
164
+ // A linting error occurs for weakly typing the context value here.
165
+ //nolint // The above seems reasonable for a one-off test.
166
+ ctx := context .WithValue (ctx , "gcp-client" , metadata )
167
+ errC <- cmd .ExecuteContext (ctx )
167
168
}()
168
169
coderdtest .AwaitWorkspaceAgents (t , client , workspace .LatestBuild .ID )
169
170
resources , err := client .WorkspaceResourcesByBuild (ctx , workspace .LatestBuild .ID )
@@ -174,5 +175,7 @@ func TestWorkspaceAgent(t *testing.T) {
174
175
_ , err = dialer .Ping ()
175
176
require .NoError (t , err )
176
177
cancelFunc ()
178
+ err = <- errC
179
+ require .NoError (t , err )
177
180
})
178
181
}
0 commit comments