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

Function TestPrebuildsCommand

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

Source from the content-addressed store, hash-verified

252}
253
254func TestPrebuildsCommand(t *testing.T) {
255 t.Parallel()
256
257 t.Run("Help", func(t *testing.T) {
258 t.Parallel()
259
260 client, _ := coderdenttest.New(t, &coderdenttest.Options{
261 LicenseOptions: &coderdenttest.LicenseOptions{
262 Features: license.Features{
263 codersdk.FeatureWorkspacePrebuilds: 1,
264 },
265 },
266 })
267
268 inv, conf := newCLI(t, "prebuilds", "--help")
269 var buf bytes.Buffer
270 inv.Stdout = &buf
271 //nolint:gocritic // Only owners can change deployment settings
272 clitest.SetupConfig(t, client, conf)
273
274 err := inv.Run()
275 require.NoError(t, err)
276
277 // Verify help output contains expected information
278 output := buf.String()
279 assert.Contains(t, output, "Manage Coder prebuilds")
280 assert.Contains(t, output, "pause")
281 assert.Contains(t, output, "resume")
282 assert.Contains(t, output, "Administrators can use these commands")
283 })
284
285 t.Run("NoSubcommand", func(t *testing.T) {
286 t.Parallel()
287
288 client, _ := coderdenttest.New(t, &coderdenttest.Options{
289 LicenseOptions: &coderdenttest.LicenseOptions{
290 Features: license.Features{
291 codersdk.FeatureWorkspacePrebuilds: 1,
292 },
293 },
294 })
295
296 inv, conf := newCLI(t, "prebuilds")
297 var buf bytes.Buffer
298 inv.Stdout = &buf
299 //nolint:gocritic // Only owners can change deployment settings
300 clitest.SetupConfig(t, client, conf)
301
302 err := inv.Run()
303 require.NoError(t, err)
304
305 // Should show help when no subcommand is provided
306 output := buf.String()
307 assert.Contains(t, output, "Manage Coder prebuilds")
308 assert.Contains(t, output, "pause")
309 assert.Contains(t, output, "resume")
310 })
311}

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
SetupConfigFunction · 0.92
newCLIFunction · 0.85
RunMethod · 0.65
StringMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected