diff options
Diffstat (limited to 'vendor/github.com/spf13/cobra/doc/md_docs_test.go')
-rw-r--r-- | vendor/github.com/spf13/cobra/doc/md_docs_test.go | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/vendor/github.com/spf13/cobra/doc/md_docs_test.go b/vendor/github.com/spf13/cobra/doc/md_docs_test.go index 86ee02930..f4f3bc149 100644 --- a/vendor/github.com/spf13/cobra/doc/md_docs_test.go +++ b/vendor/github.com/spf13/cobra/doc/md_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 TestGenMdDoc(t *testing.T) { c := initializeWithRootCmd() @@ -86,3 +86,22 @@ func TestGenMdNoTag(t *testing.T) { checkStringOmits(t, found, unexpected) } + +func TestGenMdTree(t *testing.T) { + cmd := &cobra.Command{ + Use: "do [OPTIONS] arg1 arg2", + } + tmpdir, err := ioutil.TempDir("", "test-gen-md-tree") + if err != nil { + t.Fatalf("Failed to create tmpdir: %s", err.Error()) + } + defer os.RemoveAll(tmpdir) + + if err := GenMarkdownTree(cmd, tmpdir); err != nil { + t.Fatalf("GenMarkdownTree failed: %s", err.Error()) + } + + if _, err := os.Stat(filepath.Join(tmpdir, "do.md")); err != nil { + t.Fatalf("Expected file 'do.md' to exist") + } +} |