diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-28 12:50:31 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-28 12:50:31 +0200 |
| commit | 7b220084cf3951c8cde0582efdfcf628afc64336 (patch) | |
| tree | e74bae03c61b62479ef4f68b046e3345618933c8 /internal/liturgy/store_test.go | |
| parent | feede51697be870ae183a95b513ef64f031dbd0f (diff) | |
| download | lectio-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/store_test.go')
| -rw-r--r-- | internal/liturgy/store_test.go | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/internal/liturgy/store_test.go b/internal/liturgy/store_test.go deleted file mode 100644 index 1bf8343..0000000 --- a/internal/liturgy/store_test.go +++ /dev/null @@ -1,100 +0,0 @@ -package liturgy - -import ( - "net/http" - "net/http/httptest" - "os" - "strings" - "testing" - "time" -) - -func TestHarvestAndOffline(t *testing.T) { - html, _ := os.ReadFile("testdata/2026-07-22.html") - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if strings.Contains(r.URL.Path, "2026-07-22") { - w.Write(html) - } else { - w.Write([]byte("<html>Przykro nam</html>")) // horizon - } - })) - defer srv.Close() - t.Setenv("XDG_CACHE_HOME", t.TempDir()) - t.Setenv("XDG_DATA_HOME", t.TempDir()) - baseURL = srv.URL + "/liturgia/%s/Ewangelia" - - added, _, err := Harvest("2026-07-22", 3) - if err != nil || added < 1 { - t.Fatalf("harvest: added=%d err=%v", added, err) - } - secs, err := LoadOffline("2026-07-22") - if err != nil { - t.Fatal(err) - } - var haveGospel bool - var haveFirstCzytanie bool - for _, s := range secs { - if s.Citation == "J 20, 1. 11-18" && s.PartID == "ewangelia" { - haveGospel = true - } - if strings.HasPrefix(s.Heading, "1. czytanie") && s.PartID == "pierwsze_czytanie" { - haveFirstCzytanie = true - } - } - if !haveGospel { - t.Error("offline gospel citation or PartID missing") - } - if !haveFirstCzytanie { - t.Error("offline first czytanie PartID missing") - } -} - -// TestHarvestFetchErrorSavesPartialProgress exercises the transient-error -// path: a genuine network/transport failure on a date must NOT be mistaken -// for the unpublished horizon (that is Parse's job, on a "Przykro nam" page -// -- see TestHarvestAndOffline above, which stays nil-error). It must -// instead surface as a returned error, after writeSigla has still saved -// whatever was harvested before the failing date. -func TestHarvestFetchErrorSavesPartialProgress(t *testing.T) { - html, _ := os.ReadFile("testdata/2026-07-22.html") - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if strings.Contains(r.URL.Path, "2026-07-22") { - w.Write(html) - return - } - // Simulate a network/transport error (not a "Przykro nam" horizon - // page) by hijacking the connection and closing it without a - // response, so the client sees a read/EOF error. - hj, ok := w.(http.Hijacker) - if !ok { - t.Fatal("test server ResponseWriter does not support hijacking") - } - conn, _, err := hj.Hijack() - if err != nil { - t.Fatal(err) - } - conn.Close() - })) - defer srv.Close() - t.Setenv("XDG_CACHE_HOME", t.TempDir()) - t.Setenv("XDG_DATA_HOME", t.TempDir()) - baseURL = srv.URL + "/liturgia/%s/Ewangelia" - - origRetries, origDelay := harvestRetries, harvestRetryDelay - harvestRetries, harvestRetryDelay = 2, time.Millisecond - defer func() { harvestRetries, harvestRetryDelay = origRetries, origDelay }() - - added, furthest, err := Harvest("2026-07-22", 0) - if err == nil { - t.Fatal("harvest: want error on a fetch failure, got nil") - } - if added != 1 || furthest != "2026-07-22" { - t.Errorf("harvest: added=%d furthest=%q, want added=1 furthest=2026-07-22 (only the one date fetched before the network error)", added, furthest) - } - - // Progress made before the failing date must still be on disk. - secs, offErr := LoadOffline("2026-07-22") - if offErr != nil || len(secs) == 0 { - t.Errorf("harvest: partial progress not saved: offErr=%v secs=%v", offErr, secs) - } -} |
