add basic inspect test

This commit is contained in:
Matt Jaffee 2017-03-15 21:41:25 -05:00
parent 241649fc22
commit e92203a466
2 changed files with 19 additions and 3 deletions

View file

@ -11,8 +11,10 @@ import (
"github.com/pilosa/pilosa/ctl"
)
var Inspector *ctl.InspectCommand
func NewInspectCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command {
inspecter := ctl.NewInspectCommand(os.Stdin, os.Stdout, os.Stderr)
Inspector = ctl.NewInspectCommand(os.Stdin, os.Stdout, os.Stderr)
inspectCmd := &cobra.Command{
Use: "inspect",
@ -28,8 +30,8 @@ Inspects a data file and provides stats.
fmt.Println("only one path allowed")
return
}
inspecter.Path = args[0]
if err := inspecter.Run(context.Background()); err != nil {
Inspector.Path = args[0]
if err := Inspector.Run(context.Background()); err != nil {
fmt.Println(err)
}
},

14
cmd/inspect_test.go Normal file
View file

@ -0,0 +1,14 @@
package cmd_test
import (
"strings"
"testing"
)
func TestInspectHelp(t *testing.T) {
output := ExecNewRootCommand(t, "inspect", "--help")
if !strings.Contains(output, "Usage:") ||
!strings.Contains(output, "pilosa inspect") {
t.Fatalf("Command 'inspect --help' not working, got: %s", output)
}
}