@@ -71,8 +71,8 @@ func setupTestSchedule(t *testing.T, sched *cron.Schedule) (ownerClient, memberC
71
71
// Ensure same order as in CLI output
72
72
ws = resp .Workspaces
73
73
sort .Slice (ws , func (i , j int ) bool {
74
- a := ws [i ].OwnerName + "/" + ws [i ].Name
75
- b := ws [j ].OwnerName + "/" + ws [j ].Name
74
+ a := ws [i ].OwnerUsername + "/" + ws [i ].Name
75
+ b := ws [j ].OwnerUsername + "/" + ws [j ].Name
76
76
return a < b
77
77
})
78
78
@@ -102,13 +102,13 @@ func TestScheduleShow(t *testing.T) {
102
102
103
103
// Then: they should see their own workspaces.
104
104
// 1st workspace: a-owner-ws1 has both autostart and autostop enabled.
105
- pty .ExpectMatch (ws [0 ].OwnerName + "/" + ws [0 ].Name )
105
+ pty .ExpectMatch (ws [0 ].OwnerUsername + "/" + ws [0 ].Name )
106
106
pty .ExpectMatch (sched .Humanize ())
107
107
pty .ExpectMatch (sched .Next (now ).In (loc ).Format (time .RFC3339 ))
108
108
pty .ExpectMatch ("8h" )
109
109
pty .ExpectMatch (ws [0 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ))
110
110
// 2nd workspace: b-owner-ws2 has only autostart enabled.
111
- pty .ExpectMatch (ws [1 ].OwnerName + "/" + ws [1 ].Name )
111
+ pty .ExpectMatch (ws [1 ].OwnerUsername + "/" + ws [1 ].Name )
112
112
pty .ExpectMatch (sched .Humanize ())
113
113
pty .ExpectMatch (sched .Next (now ).In (loc ).Format (time .RFC3339 ))
114
114
})
@@ -123,21 +123,21 @@ func TestScheduleShow(t *testing.T) {
123
123
124
124
// Then: they should see all workspaces
125
125
// 1st workspace: a-owner-ws1 has both autostart and autostop enabled.
126
- pty .ExpectMatch (ws [0 ].OwnerName + "/" + ws [0 ].Name )
126
+ pty .ExpectMatch (ws [0 ].OwnerUsername + "/" + ws [0 ].Name )
127
127
pty .ExpectMatch (sched .Humanize ())
128
128
pty .ExpectMatch (sched .Next (now ).In (loc ).Format (time .RFC3339 ))
129
129
pty .ExpectMatch ("8h" )
130
130
pty .ExpectMatch (ws [0 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ))
131
131
// 2nd workspace: b-owner-ws2 has only autostart enabled.
132
- pty .ExpectMatch (ws [1 ].OwnerName + "/" + ws [1 ].Name )
132
+ pty .ExpectMatch (ws [1 ].OwnerUsername + "/" + ws [1 ].Name )
133
133
pty .ExpectMatch (sched .Humanize ())
134
134
pty .ExpectMatch (sched .Next (now ).In (loc ).Format (time .RFC3339 ))
135
135
// 3rd workspace: c-member-ws3 has only autostop enabled.
136
- pty .ExpectMatch (ws [2 ].OwnerName + "/" + ws [2 ].Name )
136
+ pty .ExpectMatch (ws [2 ].OwnerUsername + "/" + ws [2 ].Name )
137
137
pty .ExpectMatch ("8h" )
138
138
pty .ExpectMatch (ws [2 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ))
139
139
// 4th workspace: d-member-ws4 has neither autostart nor autostop enabled.
140
- pty .ExpectMatch (ws [3 ].OwnerName + "/" + ws [3 ].Name )
140
+ pty .ExpectMatch (ws [3 ].OwnerUsername + "/" + ws [3 ].Name )
141
141
})
142
142
143
143
t .Run ("OwnerSearchByName" , func (t * testing.T ) {
@@ -150,22 +150,22 @@ func TestScheduleShow(t *testing.T) {
150
150
151
151
// Then: they should see workspaces matching that query
152
152
// 2nd workspace: b-owner-ws2 has only autostart enabled.
153
- pty .ExpectMatch (ws [1 ].OwnerName + "/" + ws [1 ].Name )
153
+ pty .ExpectMatch (ws [1 ].OwnerUsername + "/" + ws [1 ].Name )
154
154
pty .ExpectMatch (sched .Humanize ())
155
155
pty .ExpectMatch (sched .Next (now ).In (loc ).Format (time .RFC3339 ))
156
156
})
157
157
158
158
t .Run ("OwnerOneArg" , func (t * testing.T ) {
159
159
// When: owner asks for a specific workspace by name
160
- inv , root := clitest .New (t , "schedule" , "show" , ws [2 ].OwnerName + "/" + ws [2 ].Name )
160
+ inv , root := clitest .New (t , "schedule" , "show" , ws [2 ].OwnerUsername + "/" + ws [2 ].Name )
161
161
//nolint:gocritic // Testing that owner user sees all
162
162
clitest .SetupConfig (t , ownerClient , root )
163
163
pty := ptytest .New (t ).Attach (inv )
164
164
require .NoError (t , inv .Run ())
165
165
166
166
// Then: they should see that workspace
167
167
// 3rd workspace: c-member-ws3 has only autostop enabled.
168
- pty .ExpectMatch (ws [2 ].OwnerName + "/" + ws [2 ].Name )
168
+ pty .ExpectMatch (ws [2 ].OwnerUsername + "/" + ws [2 ].Name )
169
169
pty .ExpectMatch ("8h" )
170
170
pty .ExpectMatch (ws [2 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ))
171
171
})
@@ -179,11 +179,11 @@ func TestScheduleShow(t *testing.T) {
179
179
180
180
// Then: they should see their own workspaces
181
181
// 1st workspace: c-member-ws3 has only autostop enabled.
182
- pty .ExpectMatch (ws [2 ].OwnerName + "/" + ws [2 ].Name )
182
+ pty .ExpectMatch (ws [2 ].OwnerUsername + "/" + ws [2 ].Name )
183
183
pty .ExpectMatch ("8h" )
184
184
pty .ExpectMatch (ws [2 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ))
185
185
// 2nd workspace: d-member-ws4 has neither autostart nor autostop enabled.
186
- pty .ExpectMatch (ws [3 ].OwnerName + "/" + ws [3 ].Name )
186
+ pty .ExpectMatch (ws [3 ].OwnerUsername + "/" + ws [3 ].Name )
187
187
})
188
188
189
189
t .Run ("MemberAll" , func (t * testing.T ) {
@@ -200,11 +200,11 @@ func TestScheduleShow(t *testing.T) {
200
200
201
201
// Then: they should only see their own
202
202
// 1st workspace: c-member-ws3 has only autostop enabled.
203
- pty .ExpectMatch (ws [2 ].OwnerName + "/" + ws [2 ].Name )
203
+ pty .ExpectMatch (ws [2 ].OwnerUsername + "/" + ws [2 ].Name )
204
204
pty .ExpectMatch ("8h" )
205
205
pty .ExpectMatch (ws [2 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ))
206
206
// 2nd workspace: d-member-ws4 has neither autostart nor autostop enabled.
207
- pty .ExpectMatch (ws [3 ].OwnerName + "/" + ws [3 ].Name )
207
+ pty .ExpectMatch (ws [3 ].OwnerUsername + "/" + ws [3 ].Name )
208
208
})
209
209
210
210
t .Run ("JSON" , func (t * testing.T ) {
@@ -231,25 +231,25 @@ func TestScheduleShow(t *testing.T) {
231
231
return a < b
232
232
})
233
233
// 1st workspace: a-owner-ws1 has both autostart and autostop enabled.
234
- assert .Equal (t , ws [0 ].OwnerName + "/" + ws [0 ].Name , parsed [0 ]["workspace" ])
234
+ assert .Equal (t , ws [0 ].OwnerUsername + "/" + ws [0 ].Name , parsed [0 ]["workspace" ])
235
235
assert .Equal (t , sched .Humanize (), parsed [0 ]["starts_at" ])
236
236
assert .Equal (t , sched .Next (now ).In (loc ).Format (time .RFC3339 ), parsed [0 ]["starts_next" ])
237
237
assert .Equal (t , "8h" , parsed [0 ]["stops_after" ])
238
238
assert .Equal (t , ws [0 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ), parsed [0 ]["stops_next" ])
239
239
// 2nd workspace: b-owner-ws2 has only autostart enabled.
240
- assert .Equal (t , ws [1 ].OwnerName + "/" + ws [1 ].Name , parsed [1 ]["workspace" ])
240
+ assert .Equal (t , ws [1 ].OwnerUsername + "/" + ws [1 ].Name , parsed [1 ]["workspace" ])
241
241
assert .Equal (t , sched .Humanize (), parsed [1 ]["starts_at" ])
242
242
assert .Equal (t , sched .Next (now ).In (loc ).Format (time .RFC3339 ), parsed [1 ]["starts_next" ])
243
243
assert .Empty (t , parsed [1 ]["stops_after" ])
244
244
assert .Empty (t , parsed [1 ]["stops_next" ])
245
245
// 3rd workspace: c-member-ws3 has only autostop enabled.
246
- assert .Equal (t , ws [2 ].OwnerName + "/" + ws [2 ].Name , parsed [2 ]["workspace" ])
246
+ assert .Equal (t , ws [2 ].OwnerUsername + "/" + ws [2 ].Name , parsed [2 ]["workspace" ])
247
247
assert .Empty (t , parsed [2 ]["starts_at" ])
248
248
assert .Empty (t , parsed [2 ]["starts_next" ])
249
249
assert .Equal (t , "8h" , parsed [2 ]["stops_after" ])
250
250
assert .Equal (t , ws [2 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ), parsed [2 ]["stops_next" ])
251
251
// 4th workspace: d-member-ws4 has neither autostart nor autostop enabled.
252
- assert .Equal (t , ws [3 ].OwnerName + "/" + ws [3 ].Name , parsed [3 ]["workspace" ])
252
+ assert .Equal (t , ws [3 ].OwnerUsername + "/" + ws [3 ].Name , parsed [3 ]["workspace" ])
253
253
assert .Empty (t , parsed [3 ]["starts_at" ])
254
254
assert .Empty (t , parsed [3 ]["starts_next" ])
255
255
assert .Empty (t , parsed [3 ]["stops_after" ])
@@ -272,61 +272,61 @@ func TestScheduleModify(t *testing.T) {
272
272
t .Run ("SetStart" , func (t * testing.T ) {
273
273
// When: we set the start schedule
274
274
inv , root := clitest .New (t ,
275
- "schedule" , "start" , ws [3 ].OwnerName + "/" + ws [3 ].Name , "7:30AM" , "Mon-Fri" , "Europe/Dublin" ,
275
+ "schedule" , "start" , ws [3 ].OwnerUsername + "/" + ws [3 ].Name , "7:30AM" , "Mon-Fri" , "Europe/Dublin" ,
276
276
)
277
277
//nolint:gocritic // this workspace is not owned by the same user
278
278
clitest .SetupConfig (t , ownerClient , root )
279
279
pty := ptytest .New (t ).Attach (inv )
280
280
require .NoError (t , inv .Run ())
281
281
282
282
// Then: the updated schedule should be shown
283
- pty .ExpectMatch (ws [3 ].OwnerName + "/" + ws [3 ].Name )
283
+ pty .ExpectMatch (ws [3 ].OwnerUsername + "/" + ws [3 ].Name )
284
284
pty .ExpectMatch (sched .Humanize ())
285
285
pty .ExpectMatch (sched .Next (now ).In (loc ).Format (time .RFC3339 ))
286
286
})
287
287
288
288
t .Run ("SetStop" , func (t * testing.T ) {
289
289
// When: we set the stop schedule
290
290
inv , root := clitest .New (t ,
291
- "schedule" , "stop" , ws [2 ].OwnerName + "/" + ws [2 ].Name , "8h30m" ,
291
+ "schedule" , "stop" , ws [2 ].OwnerUsername + "/" + ws [2 ].Name , "8h30m" ,
292
292
)
293
293
//nolint:gocritic // this workspace is not owned by the same user
294
294
clitest .SetupConfig (t , ownerClient , root )
295
295
pty := ptytest .New (t ).Attach (inv )
296
296
require .NoError (t , inv .Run ())
297
297
298
298
// Then: the updated schedule should be shown
299
- pty .ExpectMatch (ws [2 ].OwnerName + "/" + ws [2 ].Name )
299
+ pty .ExpectMatch (ws [2 ].OwnerUsername + "/" + ws [2 ].Name )
300
300
pty .ExpectMatch ("8h30m" )
301
301
pty .ExpectMatch (ws [2 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ))
302
302
})
303
303
304
304
t .Run ("UnsetStart" , func (t * testing.T ) {
305
305
// When: we unset the start schedule
306
306
inv , root := clitest .New (t ,
307
- "schedule" , "start" , ws [1 ].OwnerName + "/" + ws [1 ].Name , "manual" ,
307
+ "schedule" , "start" , ws [1 ].OwnerUsername + "/" + ws [1 ].Name , "manual" ,
308
308
)
309
309
//nolint:gocritic // this workspace is owned by owner
310
310
clitest .SetupConfig (t , ownerClient , root )
311
311
pty := ptytest .New (t ).Attach (inv )
312
312
require .NoError (t , inv .Run ())
313
313
314
314
// Then: the updated schedule should be shown
315
- pty .ExpectMatch (ws [1 ].OwnerName + "/" + ws [1 ].Name )
315
+ pty .ExpectMatch (ws [1 ].OwnerUsername + "/" + ws [1 ].Name )
316
316
})
317
317
318
318
t .Run ("UnsetStop" , func (t * testing.T ) {
319
319
// When: we unset the stop schedule
320
320
inv , root := clitest .New (t ,
321
- "schedule" , "stop" , ws [0 ].OwnerName + "/" + ws [0 ].Name , "manual" ,
321
+ "schedule" , "stop" , ws [0 ].OwnerUsername + "/" + ws [0 ].Name , "manual" ,
322
322
)
323
323
//nolint:gocritic // this workspace is owned by owner
324
324
clitest .SetupConfig (t , ownerClient , root )
325
325
pty := ptytest .New (t ).Attach (inv )
326
326
require .NoError (t , inv .Run ())
327
327
328
328
// Then: the updated schedule should be shown
329
- pty .ExpectMatch (ws [0 ].OwnerName + "/" + ws [0 ].Name )
329
+ pty .ExpectMatch (ws [0 ].OwnerUsername + "/" + ws [0 ].Name )
330
330
})
331
331
}
332
332
@@ -359,15 +359,15 @@ func TestScheduleOverride(t *testing.T) {
359
359
360
360
// When: we override the stop schedule
361
361
inv , root := clitest .New (t ,
362
- "schedule" , tt .command , ws [0 ].OwnerName + "/" + ws [0 ].Name , "10h" ,
362
+ "schedule" , tt .command , ws [0 ].OwnerUsername + "/" + ws [0 ].Name , "10h" ,
363
363
)
364
364
365
365
clitest .SetupConfig (t , ownerClient , root )
366
366
pty := ptytest .New (t ).Attach (inv )
367
367
require .NoError (t , inv .Run ())
368
368
369
369
// Then: the updated schedule should be shown
370
- pty .ExpectMatch (ws [0 ].OwnerName + "/" + ws [0 ].Name )
370
+ pty .ExpectMatch (ws [0 ].OwnerUsername + "/" + ws [0 ].Name )
371
371
pty .ExpectMatch (sched .Humanize ())
372
372
pty .ExpectMatch (sched .Next (now ).In (loc ).Format (time .RFC3339 ))
373
373
pty .ExpectMatch ("8h" )
0 commit comments