summaryrefslogtreecommitdiff
path: root/internal/imgw
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-25 15:58:38 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-25 15:58:38 +0200
commita7941bb92df67686b018fbb601cbf413ea909d14 (patch)
tree322d0ad4b5fef2f27a143d7ec64d5849a4502371 /internal/imgw
parent391fc97fca932a50557d8e0f07ea2dfa8135900a (diff)
downloadprognosis-a7941bb92df67686b018fbb601cbf413ea909d14.tar.gz
prognosis-a7941bb92df67686b018fbb601cbf413ea909d14.zip
privacy: use Krakow in examples, tests and fixturesv0.1.2
A recorded GUGiK fixture was a reverse address lookup for the author's home: it carried a house number, a postal code and coordinates to about a metre, and it was published. The place name in the README was the lesser half of the problem. Fixtures are re-recorded against Rynek Glowny in Krakow, a public square, and the tests, spec example and README follow. The README example is regenerated from the binary. warnings.json is left as recorded: it is a verbatim national bulletin whose teryt array lists roughly two hundred powiats, so no single entry says anything about anyone. NOTE: this removes the address from the tip, not from history. Commit e14a7db and its successors still contain it, and remain reachable on any clone or mirror.
Diffstat (limited to 'internal/imgw')
-rw-r--r--internal/imgw/imgw_test.go26
-rw-r--r--internal/imgw/testdata/gugik_krakow.json1
2 files changed, 14 insertions, 13 deletions
diff --git a/internal/imgw/imgw_test.go b/internal/imgw/imgw_test.go
index ffc678e..fb1bf21 100644
--- a/internal/imgw/imgw_test.go
+++ b/internal/imgw/imgw_test.go
@@ -53,8 +53,8 @@ func TestPowiatTruncatesTerytToFourDigits(t *testing.T) {
if status != StatusOK {
t.Fatalf("status = %v, want StatusOK", status)
}
- if code != "1815" {
- t.Fatalf("code = %q, want 1815 (first four digits of 126101)", code)
+ if code != "1261" {
+ t.Fatalf("code = %q, want 1261 (first four digits of 126101)", code)
}
}
@@ -108,32 +108,32 @@ func TestPowiatAsksForAWideRadius(t *testing.T) {
func TestWarningsKeepOnlyThisPowiat(t *testing.T) {
pinClock(t, time.Date(2000, 1, 1, 0, 0, 0, 0, time.Local)) // nothing expired
body := `[
- {"nazwa_zdarzenia":"Upal","stopien":"1","obowiazuje_do":"2030-01-01 00:00:00","teryt":["1815","1234"]},
+ {"nazwa_zdarzenia":"Upal","stopien":"1","obowiazuje_do":"2030-01-01 00:00:00","teryt":["1261","1234"]},
{"nazwa_zdarzenia":"Burze","stopien":"2","obowiazuje_do":"2030-01-01 00:00:00","teryt":["2207"]}
]`
srv := serveText(t, body)
warningsURL = srv.URL
- live, err := Warnings("1815")
+ live, err := Warnings("1261")
if err != nil {
t.Fatal(err)
}
if len(live) != 1 || live[0].Event != "Upal" {
- t.Fatalf("got %+v, want only the warning covering 1815", live)
+ t.Fatalf("got %+v, want only the warning covering 1261", live)
}
}
func TestWarningsDropExpiredButKeepUnparseableDates(t *testing.T) {
pinClock(t, time.Date(2026, 8, 10, 12, 0, 0, 0, time.Local))
body := `[
- {"nazwa_zdarzenia":"Wczorajsze","stopien":"1","obowiazuje_do":"2026-08-09 23:00:00","teryt":["1815"]},
- {"nazwa_zdarzenia":"Trwajace","stopien":"1","obowiazuje_do":"2026-08-10 20:00:00","teryt":["1815"]},
- {"nazwa_zdarzenia":"Bezdaty","stopien":"1","obowiazuje_do":"","teryt":["1815"]}
+ {"nazwa_zdarzenia":"Wczorajsze","stopien":"1","obowiazuje_do":"2026-08-09 23:00:00","teryt":["1261"]},
+ {"nazwa_zdarzenia":"Trwajace","stopien":"1","obowiazuje_do":"2026-08-10 20:00:00","teryt":["1261"]},
+ {"nazwa_zdarzenia":"Bezdaty","stopien":"1","obowiazuje_do":"","teryt":["1261"]}
]`
srv := serveText(t, body)
warningsURL = srv.URL
- live, err := Warnings("1815")
+ live, err := Warnings("1261")
if err != nil {
t.Fatal(err)
}
@@ -151,9 +151,9 @@ func TestWarningsDropExpiredButKeepUnparseableDates(t *testing.T) {
// IMGW has been seen to encode TERYT codes as numbers as well as strings.
func TestWarningsMatchNumericTerytCodes(t *testing.T) {
pinClock(t, time.Date(2000, 1, 1, 0, 0, 0, 0, time.Local))
- srv := serveText(t, `[{"nazwa_zdarzenia":"X","obowiazuje_do":"2030-01-01 00:00:00","teryt":[1815]}]`)
+ srv := serveText(t, `[{"nazwa_zdarzenia":"X","obowiazuje_do":"2030-01-01 00:00:00","teryt":[1261]}]`)
warningsURL = srv.URL
- live, err := Warnings("1815")
+ live, err := Warnings("1261")
if err != nil {
t.Fatal(err)
}
@@ -166,7 +166,7 @@ func TestWarningsUnreachableIsAnError(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
srv.Close()
warningsURL = srv.URL
- if _, err := Warnings("1815"); err == nil {
+ if _, err := Warnings("1261"); err == nil {
t.Fatal("expected an error: the caller must be able to say 'could not check'")
}
}
@@ -177,7 +177,7 @@ func TestWarningsParseTheRecordedFeed(t *testing.T) {
srv := serve(t, "warnings.json", nil)
warningsURL = srv.URL
- if _, err := Warnings("1815"); err != nil {
+ if _, err := Warnings("1261"); err != nil {
t.Fatalf("the recorded feed must parse: %v", err)
}
none, err := Warnings("9999")
diff --git a/internal/imgw/testdata/gugik_krakow.json b/internal/imgw/testdata/gugik_krakow.json
new file mode 100644
index 0000000..9bee9a1
--- /dev/null
+++ b/internal/imgw/testdata/gugik_krakow.json
@@ -0,0 +1 @@
+{"type":"address","max results limit":1,"radius":5000,"max polygon area":null,"returned objects":1,"results":{"1":{"city":"Krak\u00f3w","citypart":null,"street":"Rynek G\u0142\u00f3wny","number":"3","teryt":"126101","simc":"0950463","ulic":"38504","code":"31-042","jednostka":"{Polska,ma\u0142opolskie,Krak\u00f3w,Krak\u00f3w}","x":"19.9375622203567","y":"50.0617125271123","geometry_wkt":"POINT(19.9375622203567 50.0617125271123)","distance":"18.8155055148824","id":1}},"request time":0.0011776526769002279} \ No newline at end of file