A test that reads every manifest in a catalogue checkout and parses it with the control plane's own parser, rather than asserting against a fixture: whether the manifests as written are accepted is the question, and a copy of one proves nothing about the other seventy-one. Skipped unless MESH_CATALOGUE names a checkout, so it costs nothing in ordinary runs and is there when the catalogue changes shape. It also refuses to pass if no endpoint is named, because a run that validated nothing would otherwise read as success.
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package catalogue
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
// TestEveryCatalogueManifestParses runs the real catalogue through the real gate.
|
|
//
|
|
// Not a fixture: the point is whether the manifests as written are accepted by the control plane that
|
|
// will read them, and a copy of one manifest proves nothing about the other seventy-one.
|
|
func TestEveryCatalogueManifestParses(t *testing.T) {
|
|
root := os.Getenv("MESH_CATALOGUE")
|
|
if root == "" {
|
|
t.Skip("set MESH_CATALOGUE to a catalogue checkout to run this")
|
|
}
|
|
found, err := filepath.Glob(filepath.Join(root, "modules", "*", "module.json"))
|
|
if err != nil || len(found) == 0 {
|
|
t.Fatalf("no manifests under %s: %v", root, err)
|
|
}
|
|
named, routed := 0, 0
|
|
for _, p := range found {
|
|
raw, err := os.ReadFile(p)
|
|
if err != nil {
|
|
t.Fatalf("%s: %v", p, err)
|
|
}
|
|
m, err := ParseManifest(raw)
|
|
if err != nil {
|
|
t.Errorf("%s: %v", filepath.Base(filepath.Dir(p)), err)
|
|
continue
|
|
}
|
|
for _, l := range m.Listens {
|
|
if l.Name != "" {
|
|
named++
|
|
}
|
|
}
|
|
for port := range RoutedPorts(m) {
|
|
_ = port
|
|
routed++
|
|
}
|
|
}
|
|
t.Logf("%d manifests, %d named endpoints, %d routed endpoints resolved", len(found), named, routed)
|
|
if named == 0 {
|
|
t.Fatal("no endpoint in the catalogue is named, so this proved nothing")
|
|
}
|
|
}
|