diff options
Diffstat (limited to 'mobile')
| -rw-r--r-- | mobile/mobile_test.go | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/mobile/mobile_test.go b/mobile/mobile_test.go index cf75b7f..85de500 100644 --- a/mobile/mobile_test.go +++ b/mobile/mobile_test.go @@ -152,23 +152,50 @@ func TestPartLabelsMatchesWhatTheEngineEmits(t *testing.T) { t.Errorf("ef[1] = %v, want evangelium/Ewangelia", ef[1]) } + // OF: derive the expected set from what Days actually emits over a full + // year (2026 -- a full Sunday cycle, so second readings appear too), + // rather than hand-copying the production list, which asserts a + // declaration against itself and can never fail for this class of bug + // (that is exactly how the app came to render a checkbox -- aklamacja -- + // that filters an ID the engine never emits). + observed := map[string]bool{} + s := Days("2026-01-01", 365, "of", "pl") + var days []map[string]any + if err := json.Unmarshal([]byte(s), &days); err != nil { + t.Fatalf("Days returned invalid JSON: %v", err) + } + for _, d := range days { + parts, _ := d["parts"].([]any) + for _, p := range parts { + part, _ := p.(map[string]any) + if id, ok := part["part"].(string); ok { + observed[id] = true + } + } + } + if len(observed) == 0 { + t.Fatal("swept zero part IDs from Days over 2026 -- the sweep is broken, not necessarily the engine") + } + var of []map[string]any if err := json.Unmarshal([]byte(PartLabels("of", "pl")), &of); err != nil { t.Fatalf("invalid JSON: %v", err) } - if len(of) != 5 { - t.Fatalf("of: got %d labels, want 5: %v", len(of), of) - } - // aklamacja was missing from the app's hardcoded list. - var seen []string + got := map[string]bool{} for _, e := range of { - seen = append(seen, e["part"].(string)) + got[e["part"].(string)] = true + } + if len(got) != len(of) { + t.Fatalf("PartLabels(of) lists a part ID more than once: %v", of) + } + for id := range observed { + if !got[id] { + t.Errorf("Days emits part %q somewhere in 2026 but PartLabels(of) does not list it: %v", id, of) + } } - want := []string{"pierwsze_czytanie", "psalm", "drugie_czytanie", "aklamacja", "ewangelia"} - for i := range want { - if seen[i] != want[i] { - t.Errorf("of order = %v, want %v", seen, want) - break + for id := range got { + if !observed[id] { + t.Errorf("PartLabels(of) lists part %q but Days never emits it anywhere in 2026: %v", id, of) } } } |
