@@ -71,8 +71,8 @@ func setupTestSchedule(t *testing.T, sched *cron.Schedule) (ownerClient, memberC
7171// Ensure same order as in CLI output
7272ws = resp .Workspaces
7373sort .Slice (ws ,func (i ,j int )bool {
74- a := ws [i ].OwnerUsername + "/" + ws [i ].Name
75- b := ws [j ].OwnerUsername + "/" + ws [j ].Name
74+ a := ws [i ].OwnerName + "/" + ws [i ].Name
75+ b := ws [j ].OwnerName + "/" + ws [j ].Name
7676return a < b
7777})
7878
@@ -102,13 +102,13 @@ func TestScheduleShow(t *testing.T) {
102102
103103// Then: they should see their own workspaces.
104104// 1st workspace: a-owner-ws1 has both autostart and autostop enabled.
105- pty .ExpectMatch (ws [0 ].OwnerUsername + "/" + ws [0 ].Name )
105+ pty .ExpectMatch (ws [0 ].OwnerName + "/" + ws [0 ].Name )
106106pty .ExpectMatch (sched .Humanize ())
107107pty .ExpectMatch (sched .Next (now ).In (loc ).Format (time .RFC3339 ))
108108pty .ExpectMatch ("8h" )
109109pty .ExpectMatch (ws [0 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ))
110110// 2nd workspace: b-owner-ws2 has only autostart enabled.
111- pty .ExpectMatch (ws [1 ].OwnerUsername + "/" + ws [1 ].Name )
111+ pty .ExpectMatch (ws [1 ].OwnerName + "/" + ws [1 ].Name )
112112pty .ExpectMatch (sched .Humanize ())
113113pty .ExpectMatch (sched .Next (now ).In (loc ).Format (time .RFC3339 ))
114114})
@@ -123,21 +123,21 @@ func TestScheduleShow(t *testing.T) {
123123
124124// Then: they should see all workspaces
125125// 1st workspace: a-owner-ws1 has both autostart and autostop enabled.
126- pty .ExpectMatch (ws [0 ].OwnerUsername + "/" + ws [0 ].Name )
126+ pty .ExpectMatch (ws [0 ].OwnerName + "/" + ws [0 ].Name )
127127pty .ExpectMatch (sched .Humanize ())
128128pty .ExpectMatch (sched .Next (now ).In (loc ).Format (time .RFC3339 ))
129129pty .ExpectMatch ("8h" )
130130pty .ExpectMatch (ws [0 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ))
131131// 2nd workspace: b-owner-ws2 has only autostart enabled.
132- pty .ExpectMatch (ws [1 ].OwnerUsername + "/" + ws [1 ].Name )
132+ pty .ExpectMatch (ws [1 ].OwnerName + "/" + ws [1 ].Name )
133133pty .ExpectMatch (sched .Humanize ())
134134pty .ExpectMatch (sched .Next (now ).In (loc ).Format (time .RFC3339 ))
135135// 3rd workspace: c-member-ws3 has only autostop enabled.
136- pty .ExpectMatch (ws [2 ].OwnerUsername + "/" + ws [2 ].Name )
136+ pty .ExpectMatch (ws [2 ].OwnerName + "/" + ws [2 ].Name )
137137pty .ExpectMatch ("8h" )
138138pty .ExpectMatch (ws [2 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ))
139139// 4th workspace: d-member-ws4 has neither autostart nor autostop enabled.
140- pty .ExpectMatch (ws [3 ].OwnerUsername + "/" + ws [3 ].Name )
140+ pty .ExpectMatch (ws [3 ].OwnerName + "/" + ws [3 ].Name )
141141})
142142
143143t .Run ("OwnerSearchByName" ,func (t * testing.T ) {
@@ -150,22 +150,22 @@ func TestScheduleShow(t *testing.T) {
150150
151151// Then: they should see workspaces matching that query
152152// 2nd workspace: b-owner-ws2 has only autostart enabled.
153- pty .ExpectMatch (ws [1 ].OwnerUsername + "/" + ws [1 ].Name )
153+ pty .ExpectMatch (ws [1 ].OwnerName + "/" + ws [1 ].Name )
154154pty .ExpectMatch (sched .Humanize ())
155155pty .ExpectMatch (sched .Next (now ).In (loc ).Format (time .RFC3339 ))
156156})
157157
158158t .Run ("OwnerOneArg" ,func (t * testing.T ) {
159159// When: owner asks for a specific workspace by name
160- inv ,root := clitest .New (t ,"schedule" ,"show" ,ws [2 ].OwnerUsername + "/" + ws [2 ].Name )
160+ inv ,root := clitest .New (t ,"schedule" ,"show" ,ws [2 ].OwnerName + "/" + ws [2 ].Name )
161161//nolint:gocritic // Testing that owner user sees all
162162clitest .SetupConfig (t ,ownerClient ,root )
163163pty := ptytest .New (t ).Attach (inv )
164164require .NoError (t ,inv .Run ())
165165
166166// Then: they should see that workspace
167167// 3rd workspace: c-member-ws3 has only autostop enabled.
168- pty .ExpectMatch (ws [2 ].OwnerUsername + "/" + ws [2 ].Name )
168+ pty .ExpectMatch (ws [2 ].OwnerName + "/" + ws [2 ].Name )
169169pty .ExpectMatch ("8h" )
170170pty .ExpectMatch (ws [2 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ))
171171})
@@ -179,11 +179,11 @@ func TestScheduleShow(t *testing.T) {
179179
180180// Then: they should see their own workspaces
181181// 1st workspace: c-member-ws3 has only autostop enabled.
182- pty .ExpectMatch (ws [2 ].OwnerUsername + "/" + ws [2 ].Name )
182+ pty .ExpectMatch (ws [2 ].OwnerName + "/" + ws [2 ].Name )
183183pty .ExpectMatch ("8h" )
184184pty .ExpectMatch (ws [2 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ))
185185// 2nd workspace: d-member-ws4 has neither autostart nor autostop enabled.
186- pty .ExpectMatch (ws [3 ].OwnerUsername + "/" + ws [3 ].Name )
186+ pty .ExpectMatch (ws [3 ].OwnerName + "/" + ws [3 ].Name )
187187})
188188
189189t .Run ("MemberAll" ,func (t * testing.T ) {
@@ -200,11 +200,11 @@ func TestScheduleShow(t *testing.T) {
200200
201201// Then: they should only see their own
202202// 1st workspace: c-member-ws3 has only autostop enabled.
203- pty .ExpectMatch (ws [2 ].OwnerUsername + "/" + ws [2 ].Name )
203+ pty .ExpectMatch (ws [2 ].OwnerName + "/" + ws [2 ].Name )
204204pty .ExpectMatch ("8h" )
205205pty .ExpectMatch (ws [2 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ))
206206// 2nd workspace: d-member-ws4 has neither autostart nor autostop enabled.
207- pty .ExpectMatch (ws [3 ].OwnerUsername + "/" + ws [3 ].Name )
207+ pty .ExpectMatch (ws [3 ].OwnerName + "/" + ws [3 ].Name )
208208})
209209
210210t .Run ("JSON" ,func (t * testing.T ) {
@@ -231,25 +231,25 @@ func TestScheduleShow(t *testing.T) {
231231return a < b
232232})
233233// 1st workspace: a-owner-ws1 has both autostart and autostop enabled.
234- assert .Equal (t ,ws [0 ].OwnerUsername + "/" + ws [0 ].Name ,parsed [0 ]["workspace" ])
234+ assert .Equal (t ,ws [0 ].OwnerName + "/" + ws [0 ].Name ,parsed [0 ]["workspace" ])
235235assert .Equal (t ,sched .Humanize (),parsed [0 ]["starts_at" ])
236236assert .Equal (t ,sched .Next (now ).In (loc ).Format (time .RFC3339 ),parsed [0 ]["starts_next" ])
237237assert .Equal (t ,"8h" ,parsed [0 ]["stops_after" ])
238238assert .Equal (t ,ws [0 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ),parsed [0 ]["stops_next" ])
239239// 2nd workspace: b-owner-ws2 has only autostart enabled.
240- assert .Equal (t ,ws [1 ].OwnerUsername + "/" + ws [1 ].Name ,parsed [1 ]["workspace" ])
240+ assert .Equal (t ,ws [1 ].OwnerName + "/" + ws [1 ].Name ,parsed [1 ]["workspace" ])
241241assert .Equal (t ,sched .Humanize (),parsed [1 ]["starts_at" ])
242242assert .Equal (t ,sched .Next (now ).In (loc ).Format (time .RFC3339 ),parsed [1 ]["starts_next" ])
243243assert .Empty (t ,parsed [1 ]["stops_after" ])
244244assert .Empty (t ,parsed [1 ]["stops_next" ])
245245// 3rd workspace: c-member-ws3 has only autostop enabled.
246- assert .Equal (t ,ws [2 ].OwnerUsername + "/" + ws [2 ].Name ,parsed [2 ]["workspace" ])
246+ assert .Equal (t ,ws [2 ].OwnerName + "/" + ws [2 ].Name ,parsed [2 ]["workspace" ])
247247assert .Empty (t ,parsed [2 ]["starts_at" ])
248248assert .Empty (t ,parsed [2 ]["starts_next" ])
249249assert .Equal (t ,"8h" ,parsed [2 ]["stops_after" ])
250250assert .Equal (t ,ws [2 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ),parsed [2 ]["stops_next" ])
251251// 4th workspace: d-member-ws4 has neither autostart nor autostop enabled.
252- assert .Equal (t ,ws [3 ].OwnerUsername + "/" + ws [3 ].Name ,parsed [3 ]["workspace" ])
252+ assert .Equal (t ,ws [3 ].OwnerName + "/" + ws [3 ].Name ,parsed [3 ]["workspace" ])
253253assert .Empty (t ,parsed [3 ]["starts_at" ])
254254assert .Empty (t ,parsed [3 ]["starts_next" ])
255255assert .Empty (t ,parsed [3 ]["stops_after" ])
@@ -272,61 +272,61 @@ func TestScheduleModify(t *testing.T) {
272272t .Run ("SetStart" ,func (t * testing.T ) {
273273// When: we set the start schedule
274274inv ,root := clitest .New (t ,
275- "schedule" ,"start" ,ws [3 ].OwnerUsername + "/" + ws [3 ].Name ,"7:30AM" ,"Mon-Fri" ,"Europe/Dublin" ,
275+ "schedule" ,"start" ,ws [3 ].OwnerName + "/" + ws [3 ].Name ,"7:30AM" ,"Mon-Fri" ,"Europe/Dublin" ,
276276)
277277//nolint:gocritic // this workspace is not owned by the same user
278278clitest .SetupConfig (t ,ownerClient ,root )
279279pty := ptytest .New (t ).Attach (inv )
280280require .NoError (t ,inv .Run ())
281281
282282// Then: the updated schedule should be shown
283- pty .ExpectMatch (ws [3 ].OwnerUsername + "/" + ws [3 ].Name )
283+ pty .ExpectMatch (ws [3 ].OwnerName + "/" + ws [3 ].Name )
284284pty .ExpectMatch (sched .Humanize ())
285285pty .ExpectMatch (sched .Next (now ).In (loc ).Format (time .RFC3339 ))
286286})
287287
288288t .Run ("SetStop" ,func (t * testing.T ) {
289289// When: we set the stop schedule
290290inv ,root := clitest .New (t ,
291- "schedule" ,"stop" ,ws [2 ].OwnerUsername + "/" + ws [2 ].Name ,"8h30m" ,
291+ "schedule" ,"stop" ,ws [2 ].OwnerName + "/" + ws [2 ].Name ,"8h30m" ,
292292)
293293//nolint:gocritic // this workspace is not owned by the same user
294294clitest .SetupConfig (t ,ownerClient ,root )
295295pty := ptytest .New (t ).Attach (inv )
296296require .NoError (t ,inv .Run ())
297297
298298// Then: the updated schedule should be shown
299- pty .ExpectMatch (ws [2 ].OwnerUsername + "/" + ws [2 ].Name )
299+ pty .ExpectMatch (ws [2 ].OwnerName + "/" + ws [2 ].Name )
300300pty .ExpectMatch ("8h30m" )
301301pty .ExpectMatch (ws [2 ].LatestBuild .Deadline .Time .In (loc ).Format (time .RFC3339 ))
302302})
303303
304304t .Run ("UnsetStart" ,func (t * testing.T ) {
305305// When: we unset the start schedule
306306inv ,root := clitest .New (t ,
307- "schedule" ,"start" ,ws [1 ].OwnerUsername + "/" + ws [1 ].Name ,"manual" ,
307+ "schedule" ,"start" ,ws [1 ].OwnerName + "/" + ws [1 ].Name ,"manual" ,
308308)
309309//nolint:gocritic // this workspace is owned by owner
310310clitest .SetupConfig (t ,ownerClient ,root )
311311pty := ptytest .New (t ).Attach (inv )
312312require .NoError (t ,inv .Run ())
313313
314314// Then: the updated schedule should be shown
315- pty .ExpectMatch (ws [1 ].OwnerUsername + "/" + ws [1 ].Name )
315+ pty .ExpectMatch (ws [1 ].OwnerName + "/" + ws [1 ].Name )
316316})
317317
318318t .Run ("UnsetStop" ,func (t * testing.T ) {
319319// When: we unset the stop schedule
320320inv ,root := clitest .New (t ,
321- "schedule" ,"stop" ,ws [0 ].OwnerUsername + "/" + ws [0 ].Name ,"manual" ,
321+ "schedule" ,"stop" ,ws [0 ].OwnerName + "/" + ws [0 ].Name ,"manual" ,
322322)
323323//nolint:gocritic // this workspace is owned by owner
324324clitest .SetupConfig (t ,ownerClient ,root )
325325pty := ptytest .New (t ).Attach (inv )
326326require .NoError (t ,inv .Run ())
327327
328328// Then: the updated schedule should be shown
329- pty .ExpectMatch (ws [0 ].OwnerUsername + "/" + ws [0 ].Name )
329+ pty .ExpectMatch (ws [0 ].OwnerName + "/" + ws [0 ].Name )
330330})
331331}
332332
@@ -359,15 +359,15 @@ func TestScheduleOverride(t *testing.T) {
359359
360360// When: we override the stop schedule
361361inv ,root := clitest .New (t ,
362- "schedule" ,tt .command ,ws [0 ].OwnerUsername + "/" + ws [0 ].Name ,"10h" ,
362+ "schedule" ,tt .command ,ws [0 ].OwnerName + "/" + ws [0 ].Name ,"10h" ,
363363)
364364
365365clitest .SetupConfig (t ,ownerClient ,root )
366366pty := ptytest .New (t ).Attach (inv )
367367require .NoError (t ,inv .Run ())
368368
369369// Then: the updated schedule should be shown
370- pty .ExpectMatch (ws [0 ].OwnerUsername + "/" + ws [0 ].Name )
370+ pty .ExpectMatch (ws [0 ].OwnerName + "/" + ws [0 ].Name )
371371pty .ExpectMatch (sched .Humanize ())
372372pty .ExpectMatch (sched .Next (now ).In (loc ).Format (time .RFC3339 ))
373373pty .ExpectMatch ("8h" )