From e92203a466ac6b99ad3b3571d1b2fdf104f12912 Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Wed, 15 Mar 2017 21:41:25 -0500 Subject: [PATCH] add basic inspect test --- cmd/inspect.go | 8 +++++--- cmd/inspect_test.go | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 cmd/inspect_test.go diff --git a/cmd/inspect.go b/cmd/inspect.go index fea61f1a7..f1bbd41dc 100644 --- a/cmd/inspect.go +++ b/cmd/inspect.go @@ -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) } }, diff --git a/cmd/inspect_test.go b/cmd/inspect_test.go new file mode 100644 index 000000000..b81078a8a --- /dev/null +++ b/cmd/inspect_test.go @@ -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) + } +}