package replays import ( "regexp" "slices" "testing" ) // Every replay says what happened, what it asserts, where its fix is, and how it is run. func TestEveryReplayIsWhole(t *testing.T) { seen := map[string]bool{} for _, r := range Register { if seen[r.ID] { t.Errorf("%s is registered twice", r.ID) } seen[r.ID] = true if r.Issue == 0 || r.What == "" || r.Asserts == "" || r.Repository == "" || r.Fix == "" || r.Test == "" { t.Errorf("%s does not say its incident, its outcome, its fix and its test: %+v", r.ID, r) } // By its issue, or — for a replay that is not one core incident's — by a name of its own. if !regexp.MustCompile(`^R(\d+|-[a-z][a-z0-9-]*)$`).MatchString(r.ID) { t.Errorf("%q is not a replay's id", r.ID) } switch r.Kind { case InRepository, Gate: if len(r.Files) == 0 || r.Package == "" { t.Errorf("%s runs in its repository and lays no files over the commit", r.ID) } case Liveness: if len(r.Files) == 0 || len(r.With) == 0 { t.Errorf("%s runs two repositories and lays the controller's half over its commit: %+v", r.ID, r) } case Bed: if !regexp.MustCompile(`^test/integration/[a-z0-9-]+\.test\.ts$`).MatchString(r.Test) { t.Errorf("%s is a bed and names no bed of the lab to raise: %q", r.ID, r.Test) } if !slices.ContainsFunc(r.With, func(a Also) bool { return a.Repository == "mesh-controller" }) || !slices.ContainsFunc(r.With, func(a Also) bool { return a.Repository == "mesh-catalog" }) { t.Errorf("%s is a bed and does not pin the controller and the catalogue it raises: %+v", r.ID, r) } case Bus, Resolver: default: t.Errorf("%s is of no kind the prover runs: %q", r.ID, r.Kind) } } for _, issue := range []string{"236", "262", "263", "266"} { if _, ok := Find(issue); !ok { t.Errorf("to-be 45 Phase 5 is done when the replay of %s fails before its fix and passes after; it has none", issue) } } }