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

Function TestNetNew

coderd/prebuilds/preset_snapshot_test.go:100–126  ·  view source on GitHub ↗

A new template version with a preset with prebuilds configured should result in a new prebuild being created.

(t *testing.T)

Source from the content-addressed store, hash-verified

98
99// A new template version with a preset with prebuilds configured should result in a new prebuild being created.
100func TestNetNew(t *testing.T) {
101 t.Parallel()
102 current := opts[optionSet0]
103 clock := quartz.NewMock(t)
104
105 presets := []database.GetTemplatePresetsWithPrebuildsRow{
106 preset(true, 1, current),
107 }
108
109 snapshot := prebuilds.NewGlobalSnapshot(presets, nil, nil, nil, nil, nil, nil, clock, testutil.Logger(t))
110 ps, err := snapshot.FilterByPreset(current.presetID)
111 require.NoError(t, err)
112
113 state := ps.CalculateState()
114 actions, err := ps.CalculateActions(backoffInterval)
115 require.NoError(t, err)
116
117 validateState(t, prebuilds.ReconciliationState{
118 Desired: 1,
119 }, *state)
120 validateActions(t, []*prebuilds.ReconciliationActions{
121 {
122 ActionType: prebuilds.ActionTypeCreate,
123 Create: 1,
124 },
125 }, actions)
126}
127
128// A new template version is created with a preset with prebuilds configured; this outdates the older version and
129// requires the old prebuilds to be destroyed and new prebuilds to be created.

Callers

nothing calls this directly

Calls 8

FilterByPresetMethod · 0.95
NewGlobalSnapshotFunction · 0.92
LoggerFunction · 0.92
presetFunction · 0.85
validateStateFunction · 0.85
validateActionsFunction · 0.85
CalculateStateMethod · 0.80
CalculateActionsMethod · 0.45

Tested by

no test coverage detected