summaryrefslogtreecommitdiff
path: root/internal/cli/cli_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-24 10:47:48 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-24 10:47:48 +0200
commite50b003d84b091b60c8028468edc633f04e39731 (patch)
treef68b4efc14b133bacd571550d86869aa450cf97d /internal/cli/cli_test.go
parentc9f3bf46f0de09edb796e35f3dcff349febf75c9 (diff)
downloadlectio-e50b003d84b091b60c8028468edc633f04e39731.tar.gz
lectio-e50b003d84b091b60c8028468edc633f04e39731.zip
bible-lookup: add --ref passage lookup + --list-pl/--list-en book lists; v0.6.0
Diffstat (limited to 'internal/cli/cli_test.go')
-rw-r--r--internal/cli/cli_test.go62
1 files changed, 62 insertions, 0 deletions
diff --git a/internal/cli/cli_test.go b/internal/cli/cli_test.go
index 6fc5e0e..c76d61c 100644
--- a/internal/cli/cli_test.go
+++ b/internal/cli/cli_test.go
@@ -267,3 +267,65 @@ func TestExtractDateDefaultsToday(t *testing.T) {
t.Errorf("extractDate rest = %v, want [-a -r]", rest)
}
}
+
+func TestListEN(t *testing.T) {
+ var out, errb bytes.Buffer
+ if code := Run([]string{"--list-en"}, nil, &out, &errb); code != 0 {
+ t.Fatalf("--list-en code=%d stderr=%q", code, errb.String())
+ }
+ s := out.String()
+ if !strings.Contains(s, "John") || !strings.Contains(s, "Genesis") {
+ t.Errorf("--list-en missing expected books:\n%s", s)
+ }
+ // abbrev-then-name, one book per line; expect a J -> John line.
+ if !strings.Contains(s, "J") {
+ t.Errorf("--list-en missing John abbrev")
+ }
+}
+
+func TestListPL(t *testing.T) {
+ var out, errb bytes.Buffer
+ if code := Run([]string{"--list-pl"}, nil, &out, &errb); code != 0 {
+ t.Fatalf("--list-pl code=%d stderr=%q", code, errb.String())
+ }
+ if s := out.String(); !strings.Contains(s, "Jan") || !strings.Contains(s, "Rodzaju") {
+ t.Errorf("--list-pl missing Polish names:\n%s", s)
+ }
+}
+
+func TestRefSingle(t *testing.T) {
+ var out, errb bytes.Buffer
+ code := Run([]string{"-p", "J 3:16", "-b", "vul"}, nil, &out, &errb)
+ if code != 0 {
+ t.Fatalf("ref code=%d stderr=%q", code, errb.String())
+ }
+ if s := out.String(); !strings.Contains(s, "3:16") {
+ t.Errorf("ref output missing verse 3:16:\n%s", s)
+ }
+}
+
+func TestRefRejectsBT(t *testing.T) {
+ var out, errb bytes.Buffer
+ if code := Run([]string{"-p", "J 3:16", "-b", "bt"}, nil, &out, &errb); code != 2 {
+ t.Errorf("ref -b bt code=%d want 2 (stderr=%q)", code, errb.String())
+ }
+}
+
+func TestRefCompare(t *testing.T) {
+ var out, errb bytes.Buffer
+ code := Run([]string{"-p", "J 3:16", "-c", "vul,drb"}, nil, &out, &errb)
+ if code != 0 {
+ t.Fatalf("ref compare code=%d stderr=%q", code, errb.String())
+ }
+ if s := out.String(); !strings.Contains(s, "3:16") {
+ t.Errorf("ref compare missing verse:\n%s", s)
+ }
+}
+
+func TestRefNotFound(t *testing.T) {
+ var out, errb bytes.Buffer
+ // A book/verse the corpus won't have text for -> exit 1.
+ if code := Run([]string{"-p", "Zzz 9:9", "-b", "vul"}, nil, &out, &errb); code != 1 {
+ t.Errorf("ref not-found code=%d want 1 (stderr=%q)", code, errb.String())
+ }
+}