Skip to content

Commit da3b9b1

Browse files
committed
feat(coderd/coderdtest): allow mutating deployment values
1 parent 70a694e commit da3b9b1

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
@@ -264,8 +264,10 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
264264
if options.DeploymentValues == nil {
265265
options.DeploymentValues = DeploymentValues(t)
266266
}
267-
// This value is not safe to run in parallel. Force it to be false.
268-
options.DeploymentValues.DisableOwnerWorkspaceExec = false
267+
// This value is not safe to run in parallel.
268+
if options.DeploymentValues.DisableOwnerWorkspaceExec {
269+
t.Logf("WARNING: DisableOwnerWorkspaceExec is set, this is not safe in parallel tests!")
270+
}
269271

270272
// If no ratelimits are set, disable all rate limiting for tests.
271273
if options.APIRateLimit == 0 {
@@ -1380,10 +1382,13 @@ func SDKError(t testing.TB, err error) *codersdk.Error {
13801382
return cerr
13811383
}
13821384

1383-
func DeploymentValues(t testing.TB) *codersdk.DeploymentValues {
1384-
var cfg codersdk.DeploymentValues
1385+
func DeploymentValues(t testing.TB, mut ...func(*codersdk.DeploymentValues)) *codersdk.DeploymentValues {
1386+
cfg := &codersdk.DeploymentValues{}
13851387
opts := cfg.Options()
13861388
err := opts.SetDefaults()
13871389
require.NoError(t, err)
1388-
return &cfg
1390+
for _, fn := range mut {
1391+
fn(cfg)
1392+
}
1393+
return cfg
13891394
}

0 commit comments

Comments
 (0)