package catalogue_test import ( "encoding/json" "testing" "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/overlay" ) // The manifests the control plane actually ships, resolved. // // Written because the earlier tests built their own manifests and passed while the real one was // missing a claim — a whole mechanism could have been absent from what ships and every test would // still have been green. func provided(t *testing.T) map[string]catalogue.Manifest { t.Helper() out := map[string]catalogue.Manifest{} for _, raw := range []map[string]any{ overlay.Manifest(), } { b, err := json.Marshal(raw) if err != nil { t.Fatal(err) } m, err := catalogue.Decode(b) if err != nil { t.Fatalf("a manifest this control plane ships is not valid: %v", err) } out[m.Module] = m } return out } func TestTheControlPlaneShipsNoNetworkingBundle(t *testing.T) { // ADR 0226: one module for the one private network. A bundle shipped beside it again would be // a second name every machine carries for the same thing. shipped := provided(t) if len(shipped) != 1 { t.Fatalf("the control plane ships %d modules, want only %s", len(shipped), overlay.Name) } if _, ok := shipped["networking"]; ok { t.Fatal("the retired networking bundle is shipped again") } } // The names-need-addressing test went with the names module: names are a fact now, and a machine // the mesh cannot place is simply left out of the file (facts_test.go) — which is the same // protection, enforced where the file is written rather than by a provision refusing. func withTailscale(shelf map[string]catalogue.Manifest) map[string]catalogue.Manifest { out := map[string]catalogue.Manifest{} for k, v := range shelf { out[k] = v } // Deliberately without name-resolution of its own, which is the case that used to install // both VPNs: the names then needed the mesh's addressing, and only WireGuard has it. out["tailscale"] = catalogue.Manifest{ Module: "tailscale", Version: "1", Provides: catalogue.Offers(overlay.Requirement), Claims: []catalogue.Claim{{Name: overlay.TheNetwork, Scope: catalogue.ScopeNode}}, } return out }