package broker import ( "slices" "testing" "git.novox.be/novox/mesh-sdk/go/catalogue" ) // The catalogue's list of the mesh's own stream names, which a module's stream may not take, is the broker's // own list (novox/hq ADR 0363 ยง1): read from MeshStreams, so a stream added there cannot be forgotten there. // // **The names of streams the mesh no longer asserts stay reserved** (R4g, ADR 0525 clause 6): the pull requests' two check // queues are left on the bus until a cleanup removes them, and no module may take their names meanwhile. So the catalogue // reserves every name of the broker's own, and may reserve these retired ones beside them. func TestTheCataloguesReservedStreamNamesAreTheMeshsOwn(t *testing.T) { retired := []string{"CHECKS_OTHER", "CHECKS_READY"} var own []string for _, s := range MeshStreams() { own = append(own, s.Name) } reserved := append([]string(nil), catalogue.MeshStreamNames...) slices.Sort(own) slices.Sort(reserved) var extra []string for _, name := range reserved { if !slices.Contains(own, name) { extra = append(extra, name) } } var missing []string for _, name := range own { if !slices.Contains(reserved, name) { missing = append(missing, name) } } for _, name := range extra { if !slices.Contains(retired, name) { t.Errorf("the catalogue reserves %s, which the broker neither asserts nor names retired", name) } } if len(missing) > 0 { t.Fatalf("the broker's own streams %v are not reserved by the catalogue (it reserves %v)", missing, reserved) } }