1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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())
}
}
|