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. // Partial-proper memorials keep ONLY the strictly-proper part (the resolver // fills the rest from the ferial): the Guardian Angels a proper gospel, St // Barnabas a proper first reading, Our Lady of Sorrows a proper gospel. want := map[string][2]string{ // slug -> {reading.first substr, reading.gospel substr; "" = absent} "assumption-of-the-blessed-virgin-mary": {"Revelation 11", "Luke 1:39-56"}, "all-saints": {"Revelation 7", "Matthew 5:1-12"}, "barnabas-the-apostle": {"Acts 11", ""}, "guardian-angels": {"", "Matthew 18:1-5"}, "our-lady-of-sorrows": {"", "John 19:25-27"}, } for slug, w := range want { rc, ok := l.Cels[slug] if !ok { t.Errorf("missing %q", slug) continue } for i, part := range []string{"reading.first", "reading.gospel"} { got := rc.Fields[part] if w[i] == "" { if got != "" { t.Errorf("%s: %s = %q, want absent (ferial)", slug, part, got) } } else if !strings.Contains(got, w[i]) { t.Errorf("%s: %s = %q, want containing %q", slug, part, got, w[i]) } } } } 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"]) } } }