blob: 979b09163d8f268985f9742a627f5cec240fa42d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package liturgy
import (
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"
)
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
for _, s := range secs {
if s.Citation == "J 20, 1. 11-18" {
haveGospel = true
}
}
if !haveGospel {
t.Error("offline gospel citation missing")
}
}
|