Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs generation command #1572

Merged
merged 9 commits into from
Jun 4, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve tests
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
  • Loading branch information
pavolloffay committed Jun 4, 2019
commit 2ef07a58df4a6e7e19da4f0216ae486782b0a7b3
19 changes: 13 additions & 6 deletions cmd/docs/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package docs

import (
"github.com/spf13/cobra"
"io/ioutil"
"strings"
"testing"
Expand All @@ -24,7 +25,7 @@ import (
"github.com/stretchr/testify/require"
)

func TestCommand(t *testing.T) {
func TestOutputFormats(t *testing.T) {
tests := []struct{
file string
flag string
Expand All @@ -51,11 +52,17 @@ func TestCommand(t *testing.T) {
}
}

func Test(t *testing.T) {
func TestDocsForParent(t *testing.T) {
parent := &cobra.Command{
Use: "root_command",
Short: "some description",
}
v := viper.New()
cmd := Command(v)
cmd.RunE(cmd, []string{})
f, err := ioutil.ReadFile("docs.md")
docs := Command(v)
parent.AddCommand(docs)
err := docs.RunE(docs, []string{})
require.NoError(t, err)
f, err := ioutil.ReadFile("root_command.md")
require.NoError(t, err)
assert.True(t, strings.Contains(string(f), "documentation"))
assert.True(t, strings.Contains(string(f), "some description"))
}