aboutsummaryrefslogtreecommitdiff
path: root/internal/cli/cli_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-24 15:38:13 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-24 15:38:13 +0200
commit573aa8bf4677793c6d7da4ef08c79af241aca70e (patch)
tree92846c2852ccdb1e60b1a13ae21b01f6cfc075eb /internal/cli/cli_test.go
parented7717fef53db3b3aa5593fbb2649313e75a0f31 (diff)
downloadlectio-573aa8bf4677793c6d7da4ef08c79af241aca70e.tar.gz
lectio-573aa8bf4677793c6d7da4ef08c79af241aca70e.zip
cli: --rand -b accepts any version incl. bt (bt falls back to a corpus version instead of erroring); v0.16.1
Diffstat (limited to 'internal/cli/cli_test.go')
-rw-r--r--internal/cli/cli_test.go18
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())
}
}