MCPcopy Index your code
hub / github.com/coder/coder / TestEntitlements_Prebuilds

Function TestEntitlements_Prebuilds

enterprise/coderd/coderd_test.go:300–361  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

298}
299
300func TestEntitlements_Prebuilds(t *testing.T) {
301 t.Parallel()
302
303 cases := []struct {
304 name string
305 featureEnabled bool
306 expectedEnabled bool
307 }{
308 {
309 name: "Feature enabled",
310 featureEnabled: true,
311 expectedEnabled: true,
312 },
313 {
314 name: "Feature disabled",
315 featureEnabled: false,
316 expectedEnabled: false,
317 },
318 }
319
320 for _, tc := range cases {
321 t.Run(tc.name, func(t *testing.T) {
322 t.Parallel()
323
324 var prebuildsEntitled int64
325 if tc.featureEnabled {
326 prebuildsEntitled = 1
327 }
328
329 _, _, api, _ := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
330 Options: &coderdtest.Options{
331 DeploymentValues: coderdtest.DeploymentValues(t),
332 },
333
334 EntitlementsUpdateInterval: time.Second,
335 LicenseOptions: &coderdenttest.LicenseOptions{
336 Features: license.Features{
337 codersdk.FeatureWorkspacePrebuilds: prebuildsEntitled,
338 },
339 },
340 })
341
342 // The entitlements will need to refresh before the reconciler is set.
343 require.Eventually(t, func() bool {
344 return api.AGPL.PrebuildsReconciler.Load() != nil
345 }, testutil.WaitSuperLong, testutil.IntervalFast)
346
347 reconciler := api.AGPL.PrebuildsReconciler.Load()
348 claimer := api.AGPL.PrebuildsClaimer.Load()
349 require.NotNil(t, reconciler)
350 require.NotNil(t, claimer)
351
352 if tc.expectedEnabled {
353 require.IsType(t, &prebuilds.StoreReconciler{}, *reconciler)
354 require.IsType(t, &prebuilds.EnterpriseClaimer{}, *claimer)
355 } else {
356 require.Equal(t, &agplprebuilds.DefaultReconciler, reconciler)
357 require.Equal(t, &agplprebuilds.DefaultClaimer, claimer)

Callers

nothing calls this directly

Calls 5

NewWithAPIFunction · 0.92
DeploymentValuesFunction · 0.92
RunMethod · 0.65
LoadMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected