Skip to content

Commit cb6ccff

Browse files
committed
add tests
1 parent e93bdfe commit cb6ccff

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/go/pt-mongodb-index-check/main_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"os/exec"
55
"regexp"
6+
"strings"
67
"testing"
78
)
89

@@ -20,3 +21,16 @@ func TestVersionOption(t *testing.T) {
2021
t.Errorf("%s --version returns wrong result:\n%s", toolname, out)
2122
}
2223
}
24+
25+
func TestNoCommand(t *testing.T) {
26+
mockMongo := "mongodb://127.0.0.1:27017"
27+
out, err := exec.Command("../../../bin/"+toolname, "--mongodb.uri", mockMongo).Output()
28+
if err != nil {
29+
t.Errorf("error executing %s with no command: %s", toolname, err.Error())
30+
}
31+
32+
want := "Usage: pt-mongodb-index-check show-help"
33+
if !strings.Contains(string(out), want) {
34+
t.Errorf("Output missmatch. Output %q should contain %q", string(out), want)
35+
}
36+
}

0 commit comments

Comments
 (0)