MCPcopy Create free account
hub / github.com/coder/coder / TestCanSkipReconciliation

Function TestCanSkipReconciliation

coderd/prebuilds/preset_snapshot_test.go:1530–1782  ·  view source on GitHub ↗

TestCanSkipReconciliation ensures that CanSkipReconciliation only returns true when CalculateActions would return no actions.

(t *testing.T)

Source from the content-addressed store, hash-verified

1528// TestCanSkipReconciliation ensures that CanSkipReconciliation only returns true
1529// when CalculateActions would return no actions.
1530func TestCanSkipReconciliation(t *testing.T) {
1531 t.Parallel()
1532
1533 clock := quartz.NewMock(t)
1534 logger := testutil.Logger(t)
1535 backoffInterval := 5 * time.Minute
1536
1537 tests := []struct {
1538 name string
1539 preset database.GetTemplatePresetsWithPrebuildsRow
1540 running []database.GetRunningPrebuiltWorkspacesRow
1541 expired []database.GetRunningPrebuiltWorkspacesRow
1542 inProgress []database.CountInProgressPrebuildsRow
1543 pendingCount int
1544 backoff *database.GetPresetsBackoffRow
1545 isHardLimited bool
1546 expectedCanSkip bool
1547 expectedActionNoOp bool
1548 }{
1549 {
1550 name: "inactive_with_nothing_to_cleanup",
1551 preset: database.GetTemplatePresetsWithPrebuildsRow{
1552 UsingActiveVersion: false,
1553 Deleted: false,
1554 Deprecated: false,
1555 DesiredInstances: sql.NullInt32{Int32: 5, Valid: true},
1556 },
1557 running: []database.GetRunningPrebuiltWorkspacesRow{},
1558 expired: []database.GetRunningPrebuiltWorkspacesRow{},
1559 inProgress: []database.CountInProgressPrebuildsRow{},
1560 pendingCount: 0,
1561 backoff: nil,
1562 isHardLimited: false,
1563 expectedCanSkip: true, // Inactive with nothing to clean up
1564 expectedActionNoOp: true, // No actions needed
1565 },
1566 {
1567 name: "inactive_with_running_workspaces",
1568 preset: database.GetTemplatePresetsWithPrebuildsRow{
1569 UsingActiveVersion: false,
1570 Deleted: false,
1571 Deprecated: false,
1572 },
1573 running: []database.GetRunningPrebuiltWorkspacesRow{
1574 {ID: uuid.New()},
1575 },
1576 expired: []database.GetRunningPrebuiltWorkspacesRow{},
1577 inProgress: []database.CountInProgressPrebuildsRow{},
1578 pendingCount: 0,
1579 backoff: nil,
1580 isHardLimited: false,
1581 expectedCanSkip: false, // Has running prebuilds to delete
1582 expectedActionNoOp: false, // Returns ActionTypeDelete
1583 },
1584 {
1585 name: "inactive_with_pending_jobs",
1586 preset: database.GetTemplatePresetsWithPrebuildsRow{
1587 UsingActiveVersion: false,

Callers

nothing calls this directly

Calls 9

CanSkipReconciliationMethod · 0.95
CalculateActionsMethod · 0.95
LoggerFunction · 0.92
NewPresetSnapshotFunction · 0.92
IsNoopMethod · 0.80
NewMethod · 0.65
AddMethod · 0.65
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected