Skip to content

Commit 57703df

Browse files
committed
completion_test: remove printing of stdout
1 parent 73cef37 commit 57703df

6 files changed

Lines changed: 25 additions & 10 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ cookies.txt
1010
gitlabctl
1111
bin/
1212

13-
# Test binary, build with `go test -c`
13+
# Test outputs, build with `go test -c`
1414
*.test
15+
testdocs
1516

1617
# Output of the go coverage tool, specifically when used with LiteIDE
1718
*.out

cmd/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
test_gencode*
2+
testdocs

cmd/completion_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ func TestCompletion(t *testing.T) {
6565
noParent: true,
6666
}
6767
stdout, execResult := execT.executeCommand()
68-
tInfo(stdout)
6968
require.Equal(t, tc.expect, execResult,
7069
printFlagsTable(tc.flagsMap, stdout))
7170
})
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,7 @@ func TestGenCodeCmd(t *testing.T) {
5656
if err := os.Remove("cmd/test_gencode_test.go"); err != nil {
5757
glog.Fatal(err)
5858
}
59+
60+
// ensure to go back
61+
os.Chdir("cmd")
5962
}

cmd/gendoc.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ var gendocCmd = &cobra.Command{
3434
Use: "gendoc",
3535
Aliases: []string{"gendocs", "docs"},
3636
Short: "Generate markdown documentation",
37-
Run: func(cmd *cobra.Command, args []string) {
38-
err := doc.GenMarkdownTree(rootCmd, docsDir)
39-
if err != nil {
40-
er(err)
37+
RunE: func(cmd *cobra.Command, args []string) error {
38+
if err := doc.GenMarkdownTree(rootCmd, docsDir); err != nil {
39+
return err
4140
}
4241
f, err := os.Create(docsDir + "/index.md")
4342
if err != nil {
44-
er(err)
43+
return err
4544
}
4645
if err = doc.GenMarkdown(rootCmd, f); err != nil {
47-
er(err)
46+
return err
4847
}
4948
fmt.Printf("The documentations have been created in %s directory.\n", docsDir)
49+
return nil
5050
},
5151
}
5252

cmd/gendoc_test.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
package cmd
22

3-
import "testing"
3+
import (
4+
"os"
5+
"testing"
6+
7+
"github.com/golang/glog"
8+
)
49

510
func TestGenDoc(t *testing.T) {
6-
if _, err := executeCommand(rootCmd, "gendoc", "--dir=../docs"); err != nil {
11+
cwd, err := os.Getwd()
12+
if err != nil {
13+
glog.Fatal(err)
14+
}
15+
docs := cwd + "/testdocs"
16+
os.Mkdir(docs, 0755)
17+
if _, err := executeCommand(rootCmd, "gendoc", "--dir="+docs); err != nil {
718
t.Fatal(err)
819
}
920
}

0 commit comments

Comments
 (0)