From 0bcddd4ed0aff66452397dc0973337c535c0d2ed Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 27 Jul 2026 20:29:31 +0200 Subject: feat(cli): lectio --corpus-check validator --- internal/cli/corpus_test.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 internal/cli/corpus_test.go (limited to 'internal/cli/corpus_test.go') 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()) + } +} -- cgit v1.3