diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-29 11:46:17 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-29 11:46:17 +0200 |
| commit | 8ddd910dd545c45a7227da87ca125758b4a0e2cb (patch) | |
| tree | b652bb239c622e2f8806a443db21a0b0bf8c8962 /internal/render/render_test.go | |
| parent | 79f9ae051c1e8f179e2e7c17f590c105eb18bef1 (diff) | |
| download | lectio-8ddd910dd545c45a7227da87ca125758b4a0e2cb.tar.gz lectio-8ddd910dd545c45a7227da87ca125758b4a0e2cb.zip | |
test(bible): skip corpus-dependent tests when optional corpora aren't embedded
Since 51c0f4e split the corpora (only vul embedded by default; wuj/drb/grb
behind -tags fullbible), `go test ./...` on the default build was red across six
packages -- every failure was a test assuming an optional corpus is present.
Guard those assertions with a skip keyed on bible.Meta(code), so they run under
-tags fullbible and skip -- not fail -- on the default vul-only build. Mixed
tests are split into subtests so the always-embedded vul assertions and pure
logic (pl->vul fallback, explicit passthrough, bt-rejection, i18n labels) keep
running on both builds. Test-only change; no product code or corpora touched.
- internal/bible: TestVerses, TestLookup, TestCorpusBooks, TestChapters,
TestGrbNoApparatusMarkers, TestCrossChapterRange* (requireCorpus helper).
- internal/cli, config, render, tui, web: the same pattern for their
corpus-dependent tests.
- Fixes an index-out-of-range panic in internal/tui's reader tests that was
aborting the package binary and masking 3 further corpus-absence failures
(TestReaderBookmarkFlow, TestReaderChapterJump, TestReaderRemembersPlace).
Verified: `go test ./...` and `go test -tags fullbible ./...` both green (0 FAIL);
guards active only on the default build (29 skips vs 1 unrelated pre-existing);
gofmt and go vet clean.
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) { |
