summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/spf13/cobra/doc/yaml_docs_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/spf13/cobra/doc/yaml_docs_test.go')
-rw-r--r--vendor/github.com/spf13/cobra/doc/yaml_docs_test.go28
1 files changed, 24 insertions, 4 deletions
diff --git a/vendor/github.com/spf13/cobra/doc/yaml_docs_test.go b/vendor/github.com/spf13/cobra/doc/yaml_docs_test.go
index a41499e1f..fb969da22 100644
--- a/vendor/github.com/spf13/cobra/doc/yaml_docs_test.go
+++ b/vendor/github.com/spf13/cobra/doc/yaml_docs_test.go
@@ -2,14 +2,14 @@ package doc
import (
"bytes"
- "fmt"
+ "io/ioutil"
"os"
+ "path/filepath"
"strings"
"testing"
-)
-var _ = fmt.Println
-var _ = os.Stderr
+ "github.com/spf13/cobra"
+)
func TestGenYamlDoc(t *testing.T) {
c := initializeWithRootCmd()
@@ -86,3 +86,23 @@ func TestGenYamlNoTag(t *testing.T) {
checkStringOmits(t, found, unexpected)
}
+
+func TestGenYamlTree(t *testing.T) {
+ cmd := &cobra.Command{
+ Use: "do [OPTIONS] arg1 arg2",
+ }
+
+ tmpdir, err := ioutil.TempDir("", "test-gen-yaml-tree")
+ if err != nil {
+ t.Fatalf("Failed to create tmpdir: %s", err.Error())
+ }
+ defer os.RemoveAll(tmpdir)
+
+ if err := GenYamlTree(cmd, tmpdir); err != nil {
+ t.Fatalf("GenYamlTree failed: %s", err.Error())
+ }
+
+ if _, err := os.Stat(filepath.Join(tmpdir, "do.yaml")); err != nil {
+ t.Fatalf("Expected file 'do.yaml' to exist")
+ }
+}