package catalogue import ( "testing" ) // Defends novox/hq ADR 0477 ยง4 (issue 1573): the go and nodejs modules own the toolchain packages and provide // them with the machine's reach, so a node without one refuses the module that needs it at resolution, naming // the provision, and does not find out at its first build. The manifests are the catalogue's, as they are. func toolchainShelf(t *testing.T) map[string]Manifest { t.Helper() m := map[string]Manifest{ "forge": {Module: "forge", Version: "1", Provides: []Offer{{Name: "forge-account"}, {Name: "npm-package-registry"}, {Name: "artifact-store"}, {Name: "node-tools"}}}, } for _, name := range []string{"go", "nodejs", "mesh-build-go", "mesh-build-node", "dev-tools"} { m[name] = catalogueManifest(t, name) } return m } // Only the owners declare the packages: a build module that declared go again would compose without the // owner's provision being met by anything, which is the gap the provision closes. func TestOnlyTheToolchainModulesDeclareTheToolchainPackages(t *testing.T) { owner := map[string]string{"go": "go", "nodejs": "nodejs", "npm": "nodejs"} for name, m := range toolchainShelf(t) { for _, r := range m.Resources { if r["type"] != "package" { continue } pkg, _ := r["package"].(string) if o, ok := owner[pkg]; ok && o != name { t.Errorf("%s declares the package %s, which only %s may", name, pkg, o) } } } }