package resolution import ( "testing" mcat "git.novox.be/novox/mesh-sdk/go/catalogue" ) func TestTheMeshsPlaceForDockerIsAccepted(t *testing.T) { // The fix #205 needed: the mesh's own directory for the module, /mesh/docker. m, err := decodeForTest([]byte(`{"module": "docker", "version": "1", "resources": [ {"id": "state", "type": "directory", "place": "mesh"}, {"id": "marker", "type": "file", "path": "${dir:state}/applied", "content": "x"}]}`)) if err != nil { t.Fatalf("place %q is in the mesh's tree, where the mesh writes for every module: %v", "mesh", err) } if got := dirsFor(m, mcat.Rendering{}); got["state"] != "/var/lib/mesh/docker" { t.Fatalf("got %v", got) } } func TestComposingAMachineIsNeverStoppedByOneModulesPath(t *testing.T) { // A module registered from outside the catalogue never passes the gate. Refusing its path while a machine's // declaration is composed would fail the whole declaration and freeze every module on that machine; the // node-engine fails only the one resource. So composition leaves it to the engine. m := mcat.Manifest{Module: "docker", Version: "1", Resources: []map[string]any{ {"id": "state", "type": "directory", "place": "."}, }} if _, err := Declaration((mcat.Resolution{Node: "anchor", Modules: []mcat.Manifest{m}}), mcat.Rendering{}); err != nil { t.Fatalf("the machine's declaration failed for one module's path: %v", err) } }