add tests

This commit is contained in:
Vladyslav Yurchenko
2026-01-21 21:53:28 +02:00
parent e93bdfed6c
commit cb6ccffe3b

View File

@@ -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)
}
}