cobra parsed flags for `sww healthcheck`, so `--x` exited 2 with cobra's error and `-h` printed help and exited 0, where the issue keeps HealthCheck's own message and status 1 for any argument. The command now passes every argument to HealthCheck. Model: opus-5-5
This commit is contained in:
1 parent
504515c1d1
commit
d17f72d1ef
2 files changed
+14
-5
No files matched your search
@@ -218,12 +218,19 @@ func wantTheCommands(t *testing.T, where, text string) {
|
||||
func TestMainHealthCheckRefusesAnArgument(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
code, stdout, stderr := runMain(t, "healthcheck now")
|
||||
for _, argument := range []string{"now", "--x", "-h"} {
|
||||
t.Run("argument "+argument, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
want := "sww healthcheck: unexpected argument \"now\"\n"
|
||||
if code != 1 || stderr != want || stdout != "" {
|
||||
t.Errorf("exit status %d, stdout %q and stderr %q, "+
|
||||
"want 1, nothing and %q", code, stdout, stderr, want)
|
||||
code, stdout, stderr := runMain(t, "healthcheck "+argument)
|
||||
|
||||
want := "sww healthcheck: unexpected argument \"" +
|
||||
argument + "\"\n"
|
||||
if code != 1 || stderr != want || stdout != "" {
|
||||
t.Errorf("exit status %d, stdout %q and stderr %q, "+
|
||||
"want 1, nothing and %q", code, stdout, stderr, want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user