summaryrefslogtreecommitdiff
path: root/internal/cli/corpus_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-27 20:29:31 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-27 20:29:31 +0200
commit0bcddd4ed0aff66452397dc0973337c535c0d2ed (patch)
treefffae4df5ba0efe80c0f7c2501ebf0396e438fdd /internal/cli/corpus_test.go
parent399f0d428050ee104f16e8d4a289b65a4a68eb13 (diff)
downloadlectio-0bcddd4ed0aff66452397dc0973337c535c0d2ed.tar.gz
lectio-0bcddd4ed0aff66452397dc0973337c535c0d2ed.zip
feat(cli): lectio --corpus-check validator
Diffstat (limited to 'internal/cli/corpus_test.go')
-rw-r--r--internal/cli/corpus_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/internal/cli/corpus_test.go b/internal/cli/corpus_test.go
new file mode 100644
index 0000000..0ed17bc
--- /dev/null
+++ b/internal/cli/corpus_test.go
@@ -0,0 +1,41 @@
+package cli
+
+import (
+ "bytes"
+ "strings"
+ "testing"
+
+ "github.com/lukaszkasprzak/lectio/internal/bible"
+)
+
+func TestRunCorpusCheckPathArg(t *testing.T) {
+ t.Cleanup(func() { bible.SetUserCorporaDir("") })
+
+ var buf bytes.Buffer
+ if code := runCorpusCheck("../bible/testdata/corpora/badbook.tsv", false, &buf, &buf); code != 1 {
+ t.Fatalf("badbook: exit %d, want 1 (out=%s)", code, buf.String())
+ }
+ if !strings.Contains(buf.String(), "ERROR:") {
+ t.Errorf("expected an ERROR: line, got %s", buf.String())
+ }
+
+ buf.Reset()
+ if code := runCorpusCheck("../bible/testdata/corpora/good.tsv", false, &buf, &buf); code != 0 {
+ t.Fatalf("good: exit %d, want 0 (out=%s)", code, buf.String())
+ }
+ if !strings.Contains(buf.String(), "ok:") {
+ t.Errorf("expected an ok: summary, got %s", buf.String())
+ }
+}
+
+func TestRunCorpusCheckJSON(t *testing.T) {
+ t.Cleanup(func() { bible.SetUserCorporaDir("") })
+
+ var buf bytes.Buffer
+ if code := runCorpusCheck("../bible/testdata/corpora/badbook.tsv", true, &buf, &buf); code != 1 {
+ t.Fatalf("badbook --json: exit %d, want 1 (out=%s)", code, buf.String())
+ }
+ if !strings.Contains(buf.String(), `"Errors"`) {
+ t.Errorf("expected a JSON report, got %s", buf.String())
+ }
+}