diff options
Diffstat (limited to 'internal/cli/cli_test.go')
| -rw-r--r-- | internal/cli/cli_test.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/internal/cli/cli_test.go b/internal/cli/cli_test.go index 58b2d00..3b99562 100644 --- a/internal/cli/cli_test.go +++ b/internal/cli/cli_test.go @@ -375,10 +375,22 @@ func TestRandChapter(t *testing.T) { } } -func TestRandRejectsBT(t *testing.T) { +func TestRandBTFallsBack(t *testing.T) { + // bt has no corpus but is accepted: --rand falls back to a corpus version + // and still prints a passage (exit 0), rather than erroring. var out, errb bytes.Buffer - if code := Run([]string{"--rand-v", "-b", "bt"}, nil, &out, &errb); code != 2 { - t.Errorf("rand -b bt code=%d want 2 (stderr=%q)", code, errb.String()) + if code := Run([]string{"--rand-v", "-b", "bt"}, nil, &out, &errb); code != 0 { + t.Errorf("rand -b bt code=%d want 0 (stderr=%q)", code, errb.String()) + } + if strings.TrimSpace(out.String()) == "" { + t.Errorf("rand -b bt produced no output") + } +} + +func TestRandRejectsUnknownVersion(t *testing.T) { + var out, errb bytes.Buffer + if code := Run([]string{"--rand-v", "-b", "xyz"}, nil, &out, &errb); code != 2 { + t.Errorf("rand -b xyz code=%d want 2 (stderr=%q)", code, errb.String()) } } |
