From 7b220084cf3951c8cde0582efdfcf628afc64336 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 28 Jul 2026 12:50:31 +0200 Subject: 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). --- internal/liturgy/clean_test.go | 75 ------------------------------------------ 1 file changed, 75 deletions(-) delete mode 100644 internal/liturgy/clean_test.go (limited to 'internal/liturgy/clean_test.go') diff --git a/internal/liturgy/clean_test.go b/internal/liturgy/clean_test.go deleted file mode 100644 index d9ab4fc..0000000 --- a/internal/liturgy/clean_test.go +++ /dev/null @@ -1,75 +0,0 @@ -package liturgy - -import ( - "os" - "path/filepath" - "testing" - "time" -) - -// TestCleanCache exercises CleanCache's file-selection rules: date-prefixed -// cache files (modern ".html"/".json" and traditional ".trad..json") -// older than the cutoff are removed; recent files and a non-matching file -// are left untouched. The cutoff is a fixed literal (not time.Now-derived) -// so the test is deterministic; only the "recent" fixtures are anchored to -// today, and only to make sure they land safely on the "keep" side of that -// fixed cutoff. -func TestCleanCache(t *testing.T) { - dir := t.TempDir() - t.Setenv("XDG_CACHE_HOME", dir) - cacheDir := filepath.Join(dir, "lectio") - if err := os.MkdirAll(cacheDir, 0o755); err != nil { - t.Fatal(err) - } - - recent := time.Now().Format("2006-01-02") - files := map[string]string{ - "2020-01-01.html": "old", - "2020-01-01.json": `[{"Heading":"old"}]`, - "2020-01-01.trad.pl.json": `[{"info":{},"sections":[]}]`, - recent + ".html": "recent", - recent + ".trad.pl.json": `[{"info":{},"sections":[]}]`, - "notes.txt": "not a cache file", - } - for name, content := range files { - if err := os.WriteFile(filepath.Join(cacheDir, name), []byte(content), 0o644); err != nil { - t.Fatal(err) - } - } - - cutoff := time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC) - removed, freed, err := CleanCache(cutoff) - if err != nil { - t.Fatalf("CleanCache: %v", err) - } - if removed != 3 { - t.Errorf("removed = %d, want 3", removed) - } - if freed <= 0 { - t.Errorf("freed = %d, want > 0", freed) - } - - for _, gone := range []string{"2020-01-01.html", "2020-01-01.json", "2020-01-01.trad.pl.json"} { - if _, err := os.Stat(filepath.Join(cacheDir, gone)); !os.IsNotExist(err) { - t.Errorf("%s still exists after CleanCache, want removed", gone) - } - } - for _, kept := range []string{recent + ".html", recent + ".trad.pl.json", "notes.txt"} { - if _, err := os.Stat(filepath.Join(cacheDir, kept)); err != nil { - t.Errorf("%s missing after CleanCache, want kept: %v", kept, err) - } - } -} - -// TestCleanCacheMissingDir checks the documented no-op: a cache dir that -// does not exist yet is not an error. -func TestCleanCacheMissingDir(t *testing.T) { - t.Setenv("XDG_CACHE_HOME", t.TempDir()) - removed, freed, err := CleanCache(time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC)) - if err != nil { - t.Fatalf("CleanCache on missing dir: %v", err) - } - if removed != 0 || freed != 0 { - t.Errorf("CleanCache on missing dir = (%d, %d), want (0, 0)", removed, freed) - } -} -- cgit v1.3