MCPcopy Create free account
hub / github.com/coder/envbuilder / TestCLIOutput

Function TestCLIOutput

options/options_test.go:153–181  ·  view source on GitHub ↗

TestCLIOutput tests that the default CLI output is as expected.

(t *testing.T)

Source from the content-addressed store, hash-verified

151
152// TestCLIOutput tests that the default CLI output is as expected.
153func TestCLIOutput(t *testing.T) {
154 var o options.Options
155 cmd := serpent.Command{
156 Use: "envbuilder",
157 Options: o.CLI(),
158 Handler: func(inv *serpent.Invocation) error {
159 return nil
160 },
161 }
162
163 var b ioBufs
164 i := cmd.Invoke("--help")
165 i.Stdout = &b.Stdout
166 i.Stderr = &b.Stderr
167 i.Stdin = &b.Stdin
168
169 err := i.Run()
170 require.NoError(t, err)
171
172 if *updateCLIOutputGoldenFiles {
173 err = os.WriteFile("testdata/options.golden", b.Stdout.Bytes(), 0o644)
174 require.NoError(t, err)
175 t.Logf("updated golden file: testdata/options.golden")
176 } else {
177 golden, err := os.ReadFile("testdata/options.golden")
178 require.NoError(t, err)
179 require.Equal(t, string(golden), b.Stdout.String())
180 }
181}
182
183func runCLI() options.Options {
184 var o options.Options

Callers

nothing calls this directly

Calls 1

CLIMethod · 0.95

Tested by

no test coverage detected