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

Function TestPrebuildsResume

enterprise/cli/prebuilds_test.go:139–252  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

137}
138
139func TestPrebuildsResume(t *testing.T) {
140 t.Parallel()
141
142 t.Run("Success", func(t *testing.T) {
143 t.Parallel()
144
145 client, _ := coderdenttest.New(t, &coderdenttest.Options{
146 LicenseOptions: &coderdenttest.LicenseOptions{
147 Features: license.Features{
148 codersdk.FeatureWorkspacePrebuilds: 1,
149 },
150 },
151 })
152
153 // First pause prebuilds
154 inv1, conf := newCLI(t, "prebuilds", "pause")
155 //nolint:gocritic // Only owners can change deployment settings
156 clitest.SetupConfig(t, client, conf)
157 err := inv1.Run()
158 require.NoError(t, err)
159
160 // Then resume
161 inv2, conf2 := newCLI(t, "prebuilds", "resume")
162 var buf bytes.Buffer
163 inv2.Stderr = &buf
164 clitest.SetupConfig(t, client, conf2)
165
166 err = inv2.Run()
167 require.NoError(t, err)
168
169 // Verify the output message
170 assert.Contains(t, buf.String(), "Prebuilds are now resumed.")
171
172 // Verify the settings were actually updated
173 //nolint:gocritic // Only owners can change deployment settings
174 settings, err := client.GetPrebuildsSettings(inv2.Context())
175 require.NoError(t, err)
176 assert.False(t, settings.ReconciliationPaused)
177 })
178
179 t.Run("ResumeWhenNotPaused", func(t *testing.T) {
180 t.Parallel()
181
182 client, _ := coderdenttest.New(t, &coderdenttest.Options{
183 LicenseOptions: &coderdenttest.LicenseOptions{
184 Features: license.Features{
185 codersdk.FeatureWorkspacePrebuilds: 1,
186 },
187 },
188 })
189
190 // Resume without first pausing
191 inv, conf := newCLI(t, "prebuilds", "resume")
192 var buf bytes.Buffer
193 inv.Stderr = &buf
194 //nolint:gocritic // Only owners can change deployment settings
195 clitest.SetupConfig(t, client, conf)
196

Callers

nothing calls this directly

Calls 12

StatusCodeMethod · 0.95
NewFunction · 0.92
SetupConfigFunction · 0.92
CreateAnotherUserFunction · 0.92
newCLIFunction · 0.85
RunMethod · 0.65
GetPrebuildsSettingsMethod · 0.65
ContextMethod · 0.65
ContainsMethod · 0.45
StringMethod · 0.45
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected