summaryrefslogtreecommitdiff
path: root/internal/liturgy/fetch_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-28 12:50:31 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-28 12:50:31 +0200
commit7b220084cf3951c8cde0582efdfcf628afc64336 (patch)
treee74bae03c61b62479ef4f68b046e3345618933c8 /internal/liturgy/fetch_test.go
parentfeede51697be870ae183a95b513ef64f031dbd0f (diff)
downloadlectio-7b220084cf3951c8cde0582efdfcf628afc64336.tar.gz
lectio-7b220084cf3951c8cde0582efdfcf628afc64336.zip
refactor: remove the niedziela/missalemeum scrapers, bt, traditional_lang
The daily view now computes entirely offline (previous commit), so retire the network path and everything that served it: - Delete internal/tradlit (missalemeum) and the niedziela scraper from internal/liturgy (fetch/store/parse + fixtures); keep Section, DayInfo and ExtractCitation. - Remove the "bt" version everywhere (render gatherBT + branches, config, i18n, web form, TUI) and bible.ToEnglishRef (Polish citation converter). A legacy config carrying "bt" migrates to "wuj" on load (config.migrateBT). - Remove the traditional_lang config field and the -g/--lang flag from all three binaries. - Drop the now-dead flags -R/--refresh, -o/--offline, -u/--update, -C/--clean and the harvest/clean commands. - New defaults: versions = wuj,vul,grb,drb; default_version = vul. Update the README (offline-by-design, no harvest/update), help text, and stale niedziela/bt doc comments. Tests updated for the offline reality; go test ./... and go vet ./... are clean, all three binaries build and run offline (OF + EF, compare, web).
Diffstat (limited to 'internal/liturgy/fetch_test.go')
-rw-r--r--internal/liturgy/fetch_test.go68
1 files changed, 0 insertions, 68 deletions
diff --git a/internal/liturgy/fetch_test.go b/internal/liturgy/fetch_test.go
deleted file mode 100644
index c06f0f8..0000000
--- a/internal/liturgy/fetch_test.go
+++ /dev/null
@@ -1,68 +0,0 @@
-package liturgy
-
-import (
- "net/http"
- "net/http/httptest"
- "os"
- "path/filepath"
- "testing"
-)
-
-func TestLoadCaches(t *testing.T) {
- html, _ := os.ReadFile("testdata/2026-06-22.html")
- hits := 0
- srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- hits++
- w.Write(html)
- }))
- defer srv.Close()
- t.Setenv("XDG_CACHE_HOME", t.TempDir())
- baseURL = srv.URL + "/liturgia/%s/Ewangelia" // test hook
-
- secs1, info1, err := Load(Options{Date: "2026-06-22"})
- if err != nil || len(secs1) == 0 {
- t.Fatalf("load1: %v", err)
- }
- 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
-// the ?date= path-traversal finding: Load must reject a non-YYYY-MM-DD date
-// before it ever builds a filesystem path from it, so every caller (web,
-// cli, tui) is protected even if a future caller forgets to validate.
-//
-// 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, loadCache would read it back and return its section instead
-// of an error.
-func TestLoadRejectsInvalidDate(t *testing.T) {
- dir := t.TempDir()
- t.Setenv("XDG_CACHE_HOME", dir)
-
- evilPath := filepath.Join(dir, "passwd.json")
- if err := os.WriteFile(evilPath, []byte(`[{"Heading":"SHOULD-NEVER-BE-READ"}]`), 0o644); err != nil {
- t.Fatal(err)
- }
-
- secs, _, err := Load(Options{Date: "../passwd"})
- if err == nil {
- t.Fatalf("Load(Date=%q) = (%v, nil), want a non-nil error", "../passwd", secs)
- }
- if secs != nil {
- t.Errorf("Load(Date=%q) sections = %v, want nil", "../passwd", secs)
- }
-}