mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-01-29 03:07:54 +08:00
add tests
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -20,3 +21,16 @@ func TestVersionOption(t *testing.T) {
|
||||
t.Errorf("%s --version returns wrong result:\n%s", toolname, out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoCommand(t *testing.T) {
|
||||
mockMongo := "mongodb://127.0.0.1:27017"
|
||||
out, err := exec.Command("../../../bin/"+toolname, "--mongodb.uri", mockMongo).Output()
|
||||
if err != nil {
|
||||
t.Errorf("error executing %s with no command: %s", toolname, err.Error())
|
||||
}
|
||||
|
||||
want := "Usage: pt-mongodb-index-check show-help"
|
||||
if !strings.Contains(string(out), want) {
|
||||
t.Errorf("Output missmatch. Output %q should contain %q", string(out), want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user