diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-24 10:32:28 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-24 10:32:28 +0200 |
| commit | c9f3bf46f0de09edb796e35f3dcff349febf75c9 (patch) | |
| tree | c1a0b98b484e4da557c1ab205dfff0d92ce8ac36 /internal/liturgy/fetch_test.go | |
| parent | a865374755480a4aef2a6156afccdf08a91422ea (diff) | |
| download | lectio-c9f3bf46f0de09edb796e35f3dcff349febf75c9.tar.gz lectio-c9f3bf46f0de09edb796e35f3dcff349febf75c9.zip | |
dayinfo: show feast/day name + colour (modern niedziela + traditional missalemeum) in cli/tui/web; v0.5.0
Diffstat (limited to 'internal/liturgy/fetch_test.go')
| -rw-r--r-- | internal/liturgy/fetch_test.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/internal/liturgy/fetch_test.go b/internal/liturgy/fetch_test.go index 738126d..c06f0f8 100644 --- a/internal/liturgy/fetch_test.go +++ b/internal/liturgy/fetch_test.go @@ -19,17 +19,25 @@ func TestLoadCaches(t *testing.T) { t.Setenv("XDG_CACHE_HOME", t.TempDir()) baseURL = srv.URL + "/liturgia/%s/Ewangelia" // test hook - secs1, err := Load(Options{Date: "2026-06-22"}) + secs1, info1, err := Load(Options{Date: "2026-06-22"}) if err != nil || len(secs1) == 0 { t.Fatalf("load1: %v", err) } - secs2, _ := Load(Options{Date: "2026-06-22"}) // should hit JSON cache + if info1.Name == "" { + t.Error("load1: DayInfo.Name empty, want it populated from the freshly-parsed HTML") + } + secs2, info2, _ := Load(Options{Date: "2026-06-22"}) // should hit JSON cache if hits != 1 { t.Errorf("server hit %d times, want 1 (cache miss on repeat)", hits) } if len(secs2) != len(secs1) { t.Error("cache returned different section count") } + // The JSON cache round-trips DayInfo (see cachedDay/loadCache), so a + // cache-hit repeat load must not lose it. + if info2 != info1 { + t.Errorf("cache-hit DayInfo = %+v, want it to match the first load's %+v", info2, info1) + } } // TestLoadRejectsInvalidDate is the liturgy-layer defense-in-depth check for @@ -39,7 +47,7 @@ func TestLoadCaches(t *testing.T) { // // The planted "passwd.json" sits one level *above* CacheDir() -- reachable // only via a "../" date -- so if Load ever built jsonPath from the raw date -// unchecked, loadJSONCache would read it back and return its section instead +// unchecked, loadCache would read it back and return its section instead // of an error. func TestLoadRejectsInvalidDate(t *testing.T) { dir := t.TempDir() @@ -50,7 +58,7 @@ func TestLoadRejectsInvalidDate(t *testing.T) { t.Fatal(err) } - secs, err := Load(Options{Date: "../passwd"}) + secs, _, err := Load(Options{Date: "../passwd"}) if err == nil { t.Fatalf("Load(Date=%q) = (%v, nil), want a non-nil error", "../passwd", secs) } |
