Skip to content

Commit 99e103e

Browse files
authored
feat(coderd/coderdtest): allow mutating deployment values (coder#14414)
1 parent 4cc26be commit 99e103e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

coderd/coderdtest/coderdtest.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,10 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
268268
if options.DeploymentValues == nil {
269269
options.DeploymentValues = DeploymentValues(t)
270270
}
271-
// This value is not safe to run in parallel. Force it to be false.
272-
options.DeploymentValues.DisableOwnerWorkspaceExec = false
271+
// This value is not safe to run in parallel.
272+
if options.DeploymentValues.DisableOwnerWorkspaceExec {
273+
t.Logf("WARNING: DisableOwnerWorkspaceExec is set, this is not safe in parallel tests!")
274+
}
273275

274276
// If no ratelimits are set, disable all rate limiting for tests.
275277
if options.APIRateLimit == 0 {
@@ -1385,10 +1387,13 @@ func SDKError(t testing.TB, err error) *codersdk.Error {
13851387
return cerr
13861388
}
13871389

1388-
func DeploymentValues(t testing.TB) *codersdk.DeploymentValues {
1389-
var cfg codersdk.DeploymentValues
1390+
func DeploymentValues(t testing.TB, mut ...func(*codersdk.DeploymentValues)) *codersdk.DeploymentValues {
1391+
cfg := &codersdk.DeploymentValues{}
13901392
opts := cfg.Options()
13911393
err := opts.SetDefaults()
13921394
require.NoError(t, err)
1393-
return &cfg
1395+
for _, fn := range mut {
1396+
fn(cfg)
1397+
}
1398+
return cfg
13941399
}

0 commit comments

Comments
 (0)