@@ -164,6 +164,15 @@ func TestWorkspaceProxies(t *testing.T) {
164
164
expectedSeverity : health .SeverityWarning ,
165
165
expectedWarningCode : health .CodeProxyUpdate ,
166
166
},
167
+ {
168
+ name : "Enabled/OneUnhealthyAndDeleted" ,
169
+ fetchWorkspaceProxies : fakeFetchWorkspaceProxies (fakeWorkspaceProxy ("alpha" , false , currentVersion , func (wp * codersdk.WorkspaceProxy ) {
170
+ wp .Deleted = true
171
+ })),
172
+ updateProxyHealth : fakeUpdateProxyHealth (nil ),
173
+ expectedHealthy : true ,
174
+ expectedSeverity : health .SeverityOK ,
175
+ },
167
176
} {
168
177
tt := tt
169
178
t .Run (tt .name , func (t * testing.T ) {
@@ -236,7 +245,7 @@ func (u *fakeWorkspaceProxyFetchUpdater) Update(ctx context.Context) error {
236
245
}
237
246
238
247
//nolint:revive // yes, this is a control flag, and that is OK in a unit test.
239
- func fakeWorkspaceProxy (name string , healthy bool , version string ) codersdk.WorkspaceProxy {
248
+ func fakeWorkspaceProxy (name string , healthy bool , version string , mutators ... func ( * codersdk. WorkspaceProxy ) ) codersdk.WorkspaceProxy {
240
249
var status codersdk.WorkspaceProxyStatus
241
250
if ! healthy {
242
251
status = codersdk.WorkspaceProxyStatus {
@@ -246,14 +255,18 @@ func fakeWorkspaceProxy(name string, healthy bool, version string) codersdk.Work
246
255
},
247
256
}
248
257
}
249
- return codersdk.WorkspaceProxy {
258
+ wsp := codersdk.WorkspaceProxy {
250
259
Region : codersdk.Region {
251
260
Name : name ,
252
261
Healthy : healthy ,
253
262
},
254
263
Version : version ,
255
264
Status : status ,
256
265
}
266
+ for _ , f := range mutators {
267
+ f (& wsp )
268
+ }
269
+ return wsp
257
270
}
258
271
259
272
func fakeFetchWorkspaceProxies (ps ... codersdk.WorkspaceProxy ) func (context.Context ) (codersdk.RegionsResponse [codersdk.WorkspaceProxy ], error ) {
0 commit comments