Test that the composition marks a need its provider's helper answers, so the consumer's plan keys it (issue 774)
mesh/delivery merged: source.main moved to novox/mesh-sdk@125bb9177189
mesh/delivery-group group fix/one-rule-for-provisions merged: every member is merged
mesh/check being carried to 6c5a8ef893b4 on 125bb9177189 | from b74e23f973ab | novox/mesh-sdk#143 in group fix/one-rule-for-provisions

The review found answeredByHelper untested: forced false, every test passed. This row fails then.
This commit is contained in:
2026-10-30 22:29:12 +01:00
parent 91aa7b78fc
commit 6c5a8ef893
+28
View File
@@ -358,3 +358,31 @@ func TestALicenceKeyTheInputDoesNotCarryIsAStandInAndNamedForeseen(t *testing.T)
t.Errorf("a key the mesh holds none of: %q %v", n.Sealed, got.Foreseen) t.Errorf("a key the mesh holds none of: %q %v", n.Sealed, got.Foreseen)
} }
} }
// A consumer not handed of a provision whose provider's offer says the helper answers it has that provision in a plan of
// its own (issue 774: grafana's route): the composition marks the need answered by the helper, and the plan keys it.
func TestANeedAnsweredByTheHelperIsInTheConsumersPlan(t *testing.T) {
in := theStoreMesh(t)
store := in.Catalogue["store"]
store.Provides = []catalogue.Offer{{Name: "postgres-database", Scope: catalogue.ScopeMesh, AnsweredBy: catalogue.AnsweredByHelper}}
in.Catalogue["store"] = store
got, err := Resolve(in, "laptop")
if err != nil {
t.Fatal(err)
}
if n := need(t, got.Plan, "board", "postgres-database"); !n.AnsweredByHelper {
t.Fatalf("the need is not marked answered by the helper: %+v", n)
}
with := rendered(t, in, "laptop", Foreseeing).Rendering
with.Hands, with.Provisioner = true, "mesh-provisioner-client"
if with.Generators, err = newComposer(in).generators(); err != nil {
t.Fatal(err)
}
c, err := got.Plan.Compose(with)
if err != nil {
t.Fatal(err)
}
if p := c.Plans["board"].Provisions; len(p) != 1 || p[0].Provision != "postgres-database" || p[0].ProviderModule != "store" {
t.Fatalf("board's plan is %+v", c.Plans["board"])
}
}