@@ -2,9 +2,11 @@ package coderd_test
2
2
3
3
import (
4
4
"context"
5
+ "sync"
5
6
"testing"
6
7
7
8
"github.com/google/uuid"
9
+ "github.com/stretchr/testify/assert"
8
10
"github.com/stretchr/testify/require"
9
11
10
12
"github.com/coder/coder/coderd/coderdtest"
@@ -37,12 +39,12 @@ func TestWorkspaceQuota(t *testing.T) {
37
39
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
38
40
defer cancel ()
39
41
max := 1
40
- client := coderdenttest .New (t , & coderdenttest.Options {
42
+ client , _ , api := coderdenttest .NewWithAPI (t , & coderdenttest.Options {
41
43
UserWorkspaceQuota : max ,
42
- Options : & coderdtest.Options {
43
- IncludeProvisionerDaemon : true ,
44
- },
45
44
})
45
+ coderdtest .NewProvisionerDaemon (t , api .AGPL )
46
+ coderdtest .NewProvisionerDaemon (t , api .AGPL )
47
+ coderdtest .NewProvisionerDaemon (t , api .AGPL )
46
48
47
49
user := coderdtest .CreateFirstUser (t , client )
48
50
coderdenttest .AddLicense (t , client , coderdenttest.LicenseOptions {
@@ -104,12 +106,18 @@ func TestWorkspaceQuota(t *testing.T) {
104
106
template := coderdtest .CreateTemplate (t , client , user .OrganizationID , version .ID )
105
107
106
108
// Spin up three workspaces fine
109
+ var wg sync.WaitGroup
107
110
for i := 0 ; i < 3 ; i ++ {
108
- workspace := coderdtest .CreateWorkspace (t , client , user .OrganizationID , template .ID )
109
- build := coderdtest .AwaitWorkspaceBuildJob (t , client , workspace .LatestBuild .ID )
110
- verifyQuota (ctx , t , client , i + 1 , 3 )
111
- require .Equal (t , codersdk .WorkspaceStatusRunning , build .Status )
111
+ wg .Add (1 )
112
+ go func () {
113
+ defer wg .Done ()
114
+ workspace := coderdtest .CreateWorkspace (t , client , user .OrganizationID , template .ID )
115
+ build := coderdtest .AwaitWorkspaceBuildJob (t , client , workspace .LatestBuild .ID )
116
+ assert .Equal (t , codersdk .WorkspaceStatusRunning , build .Status )
117
+ }()
112
118
}
119
+ wg .Wait ()
120
+ verifyQuota (ctx , t , client , 3 , 3 )
113
121
114
122
// Next one must fail
115
123
workspace := coderdtest .CreateWorkspace (t , client , user .OrganizationID , template .ID )
0 commit comments