MCPcopy
hub / github.com/spf13/cobra / TestGenYamlDoc

Function TestGenYamlDoc

doc/yaml_docs_test.go:27–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestGenYamlDoc(t *testing.T) {
28 // We generate on s subcommand so we have both subcommands and parents
29 buf := new(bytes.Buffer)
30 if err := GenYaml(echoCmd, buf); err != nil {
31 t.Fatal(err)
32 }
33 output := buf.String()
34
35 checkStringContains(t, output, echoCmd.Long)
36 checkStringContains(t, output, echoCmd.Example)
37 checkStringContains(t, output, "boolone")
38 checkStringContains(t, output, "rootflag")
39 checkStringContains(t, output, rootCmd.Short)
40 checkStringContains(t, output, echoSubCmd.Short)
41 checkStringContains(t, output, fmt.Sprintf("- %s - %s", echoSubCmd.CommandPath(), echoSubCmd.Short))
42}
43
44func TestGenYamlNoTag(t *testing.T) {
45 rootCmd.DisableAutoGenTag = true

Callers

nothing calls this directly

Calls 4

GenYamlFunction · 0.85
StringMethod · 0.80
CommandPathMethod · 0.80
checkStringContainsFunction · 0.70

Tested by

no test coverage detected