@@ -480,16 +480,27 @@ func TestWorkspacesSortOrder(t *testing.T) {
480
480
t .Parallel ()
481
481
482
482
client , db := coderdtest .NewWithDatabase (t , nil )
483
- firstUser := coderdtest .CreateFirstUser (t , client )
483
+ firstUser := coderdtest .CreateFirstUser (t , client , func (r * codersdk.CreateFirstUserRequest ) {
484
+ r .Username = "aaa"
485
+ })
486
+ _ , secondUser := coderdtest .CreateAnotherUserMutators (t , client , firstUser .OrganizationID , []string {"owner" }, func (r * codersdk.CreateUserRequest ) {
487
+ r .Username = "zzz"
488
+ })
484
489
485
490
// c-workspace should be running
486
- wsb1 := dbfake .WorkspaceBuild (t , db , database.Workspace {Name : "c-workspace" , OwnerID : firstUser .UserID , OrganizationID : firstUser .OrganizationID }).Do ()
491
+ wsbC := dbfake .WorkspaceBuild (t , db , database.Workspace {Name : "c-workspace" , OwnerID : firstUser .UserID , OrganizationID : firstUser .OrganizationID }).Do ()
487
492
488
493
// b-workspace should be stopped
489
- wsb2 := dbfake .WorkspaceBuild (t , db , database.Workspace {Name : "b-workspace" , OwnerID : firstUser .UserID , OrganizationID : firstUser .OrganizationID }).Seed (database.WorkspaceBuild {Transition : database .WorkspaceTransitionStop }).Do ()
494
+ wsbB := dbfake .WorkspaceBuild (t , db , database.Workspace {Name : "b-workspace" , OwnerID : firstUser .UserID , OrganizationID : firstUser .OrganizationID }).Seed (database.WorkspaceBuild {Transition : database .WorkspaceTransitionStop }).Do ()
490
495
491
496
// a-workspace should be running
492
- wsb3 := dbfake .WorkspaceBuild (t , db , database.Workspace {Name : "a-workspace" , OwnerID : firstUser .UserID , OrganizationID : firstUser .OrganizationID }).Do ()
497
+ wsbA := dbfake .WorkspaceBuild (t , db , database.Workspace {Name : "a-workspace" , OwnerID : firstUser .UserID , OrganizationID : firstUser .OrganizationID }).Do ()
498
+
499
+ // d-workspace should be stopped
500
+ wsbD := dbfake .WorkspaceBuild (t , db , database.Workspace {Name : "d-workspace" , OwnerID : secondUser .ID , OrganizationID : firstUser .OrganizationID }).Seed (database.WorkspaceBuild {Transition : database .WorkspaceTransitionStop }).Do ()
501
+
502
+ // e-workspace should also be stopped
503
+ wsbE := dbfake .WorkspaceBuild (t , db , database.Workspace {Name : "e-workspace" , OwnerID : secondUser .ID , OrganizationID : firstUser .OrganizationID }).Seed (database.WorkspaceBuild {Transition : database .WorkspaceTransitionStop }).Do ()
493
504
494
505
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
495
506
defer cancel ()
@@ -498,15 +509,19 @@ func TestWorkspacesSortOrder(t *testing.T) {
498
509
workspaces := workspacesResponse .Workspaces
499
510
500
511
expectedNames := []string {
501
- wsb3 .Workspace .Name ,
502
- wsb1 .Workspace .Name ,
503
- wsb2 .Workspace .Name ,
512
+ wsbA .Workspace .Name , // running
513
+ wsbC .Workspace .Name , // running
514
+ wsbB .Workspace .Name , // stopped, aaa < zzz
515
+ wsbD .Workspace .Name , // stopped, zzz > aaa
516
+ wsbE .Workspace .Name , // stopped, zzz > aaa
504
517
}
505
518
506
519
expectedStatus := []codersdk.WorkspaceStatus {
507
520
codersdk .WorkspaceStatusRunning ,
508
521
codersdk .WorkspaceStatusRunning ,
509
522
codersdk .WorkspaceStatusStopped ,
523
+ codersdk .WorkspaceStatusStopped ,
524
+ codersdk .WorkspaceStatusStopped ,
510
525
}
511
526
512
527
var actualNames []string
0 commit comments