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()) } }