package caldata import ( "strings" "testing" "github.com/lukaszkasprzak/lectio/internal/calendar" ) func TestUniversalLoads(t *testing.T) { l := Universal() if l.ID != "universal" { t.Fatalf("layer id = %q", l.ID) } // the Assumption (08-15, solemnity) must be present under some slug. assumption := false for _, rc := range l.Cels { if rc.Fields["date"] == "08-15" && rc.Fields["rank"] == "solemnity" { assumption = true } } if !assumption { t.Fatal("no 08-15 solemnity (Assumption) in the universal calendar") } // every entry must build into a typed Celebration whose rank parsed. for slug, rc := range l.Cels { c := calendar.BuildCelebrationForTest(slug, rc) if c.Rank == calendar.RankFerial && rc.Fields["rank"] != "" { t.Errorf("%s: rank did not parse (%q)", slug, rc.Fields["rank"]) } } } func TestUniversalSanctoralReadings(t *testing.T) { l := Universal() // A feast/solemnity or a PROPER-reading memorial carries its own inline Mass // (imported from catholic-resources.org) rather than falling back to the ferial. want := map[string][2]string{ // slug -> {reading.first substr, reading.gospel substr} "barnabas-the-apostle": {"Acts 11", "Matthew 10:7-13"}, "assumption-of-the-blessed-virgin-mary": {"Revelation 11", "Luke 1:39-56"}, "our-lady-of-sorrows": {"Hebrews 5", "John 19:25-27"}, "all-saints": {"Revelation 7", "Matthew 5:1-12"}, } for slug, w := range want { rc, ok := l.Cels[slug] if !ok { t.Errorf("missing %q", slug) continue } if got := rc.Fields["reading.first"]; !strings.Contains(got, w[0]) { t.Errorf("%s: reading.first = %q, want containing %q", slug, got, w[0]) } if got := rc.Fields["reading.gospel"]; !strings.Contains(got, w[1]) { t.Errorf("%s: reading.gospel = %q, want containing %q", slug, got, w[1]) } } } func TestTridentineLoads(t *testing.T) { l := Tridentine() if l.ID != "tridentine" { t.Fatalf("layer id = %q", l.ID) } // The full 1962 sanctoral is populated (generated from missalemeum), not the // 16-entry bootstrap. if len(l.Cels) < 250 { t.Fatalf("EF sanctoral has only %d entries; expected the full calendar", len(l.Cels)) } // Landmark feasts must be present with the right rank/class: Sts Peter & Paul // (I class, 06-29), the Purification/Presentation (a II class feast of the // Lord, 02-02, which must displace a Sunday), the Immaculate Conception // (I class, 12-08). want := map[string]struct{ date, rank, class string }{ "sts-peter-paul": {"06-29", "class-1", ""}, "purification-of-the-blessed-virgin-mary": {"02-02", "class-2", "lord"}, "immaculate-conception-of-the-blessed-virgin-mary": {"12-08", "class-1", ""}, } for slug, w := range want { rc, ok := l.Cels[slug] if !ok { t.Errorf("missing landmark feast %q", slug) continue } if rc.Fields["date"] != w.date || rc.Fields["rank"] != w.rank { t.Errorf("%s: date/rank = %q/%q, want %q/%q", slug, rc.Fields["date"], rc.Fields["rank"], w.date, w.rank) } if w.class != "" && rc.Fields["class"] != w.class { t.Errorf("%s: class = %q, want %q", slug, rc.Fields["class"], w.class) } } // every entry must build into a typed Celebration whose rank parsed. for slug, rc := range l.Cels { c := calendar.BuildCelebrationForTest(slug, rc) if c.Rank == calendar.RankFerial && rc.Fields["rank"] != "" { t.Errorf("%s: rank did not parse (%q)", slug, rc.Fields["rank"]) } } }