diff options
Diffstat (limited to 'internal/render/render_test.go')
| -rw-r--r-- | internal/render/render_test.go | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/internal/render/render_test.go b/internal/render/render_test.go index dd177bb..e3bdc5d 100644 --- a/internal/render/render_test.go +++ b/internal/render/render_test.go @@ -4,20 +4,39 @@ import ( "strings" "testing" + "github.com/lukaszkasprzak/lectio/internal/bible" "github.com/lukaszkasprzak/lectio/internal/liturgy" ) +// requireCorpus skips the test when corpus `code` is not embedded in this +// build. The optional corpora (wuj, drb, grb) compile in only with +// `-tags fullbible` (or when dropped into the user corpora dir); mirrors the +// helper in internal/bible so these tests run under fullbible and skip -- not +// fail -- on the default vul-only build. +func requireCorpus(t *testing.T, code string) { + t.Helper() + if _, ok := bible.Meta(code); !ok { + t.Skipf("corpus %q not embedded; build with -tags fullbible", code) + } +} + func TestGatherBible(t *testing.T) { // Offline sections carry the English-canonical lookup reference in Ref; the // display citation stays in the reader's sigla dialect. sec := liturgy.Section{Heading: "Ewangelia", Citation: "J 20, 1. 11-18", Ref: "John 20:1,11-18"} label, blocks := GatherVersion("wuj", sec, "new", "pl") + // The label is an i18n chrome string, independent of whether the corpus is + // embedded, so it must resolve on either build. if !strings.Contains(label, "Wujek") { t.Errorf("label = %q", label) } - if len(blocks) == 0 || !strings.HasPrefix(blocks[0], "20:1") { - t.Errorf("first block = %q", blocks) - } + // The verse blocks come from the wuj corpus text itself. + t.Run("verses", func(t *testing.T) { + requireCorpus(t, "wuj") + if len(blocks) == 0 || !strings.HasPrefix(blocks[0], "20:1") { + t.Errorf("first block = %q", blocks) + } + }) } func TestGatherTraditional(t *testing.T) { @@ -106,18 +125,23 @@ func TestOfflineVersions(t *testing.T) { func TestGatherVersesBible(t *testing.T) { sec := liturgy.Section{Heading: "Ewangelia", Citation: "J 20, 1. 11-18", Ref: "John 20:1,11-18"} label, verses, versified := GatherVerses("wuj", sec, "new", "pl") + // The label is an i18n chrome string, independent of the corpus. if !strings.Contains(label, "Wujek") { t.Errorf("label = %q", label) } - if !versified { - t.Error("versified = false, want true for wuj with a resolvable citation") - } - if len(verses) == 0 { - t.Fatal("verses empty") - } - if verses[0].Chapter != 20 || verses[0].Verse != 1 || verses[0].Text == "" { - t.Errorf("verses[0] = %+v", verses[0]) - } + // Versified extraction requires the wuj corpus text. + t.Run("verses", func(t *testing.T) { + requireCorpus(t, "wuj") + if !versified { + t.Error("versified = false, want true for wuj with a resolvable citation") + } + if len(verses) == 0 { + t.Fatal("verses empty") + } + if verses[0].Chapter != 20 || verses[0].Verse != 1 || verses[0].Text == "" { + t.Errorf("verses[0] = %+v", verses[0]) + } + }) } func TestGatherVersesBT(t *testing.T) { |
