package resolution import ( "strings" "testing" mcat "git.novox.be/novox/mesh-sdk/go/catalogue" ) // The artifact store's seat is one per mesh, read from the catalogue beside this checkout. // // **A second store anywhere is refused by name, not discovered as a consumer failure.** The seat // was node-scoped, so a second `distribution` on another machine resolved cleanly there — and a // node-scoped requirement with one candidate installs that candidate on the node, so anything that // required the store's presence beside it would have raised a fresh, empty store on the wrong // machine. Only afterwards did the mesh notice: `artifact-store` offered by two nodes, and every // consumer elsewhere refusing to choose. The claim says it first, where the second store is // assigned. func TestASecondArtifactStoreAnywhereIsRefusedByName(t *testing.T) { store := catalogueManifest(t, "distribution") // The first store resolves as it always has. if _, err := Resolve(shelf(store), []string{"distribution"}, workstation(), mcat.World{}); err != nil { t.Fatalf("the store alone does not resolve: %v", err) } // A second one, on any other machine, is refused — and the refusal names the seat. elsewhere := mcat.World{Held: []mcat.Held{{Claim: "mesh-artifact-store", Scope: mcat.ScopeMesh, Node: "anchor", Module: "distribution"}}} other := workstation() other.Name = "laptop" _, err := Resolve(shelf(store), []string{"distribution"}, other, elsewhere) if err == nil { t.Fatal("a second store was accepted on another machine; it would offer artifact-store a " + "second time and every consumer elsewhere would refuse to choose") } if !strings.Contains(err.Error(), "mesh-artifact-store") || !strings.Contains(err.Error(), "one per mesh") { t.Fatalf("refused without naming the seat: %v", err) } }