mesh/delivery-group group feat/sdk1 rejected: composed together: the checker's verdict at the members' heads (428d048dd50a): unit: git.novox.be/novox/mesh-sdk/…
mesh/delivery closed: a newer head of the same pull request
mesh/check failed: unit: git.novox.be/novox/mesh-sdk/go/process.TestStatePutWritesAKeyWhole: a Put through a short blackout: 0, mesh-mail's state send…
Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
47 lines
1.9 KiB
Go
47 lines
1.9 KiB
Go
package catalogue
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// A consumer of a provision that keeps its data stays bound where its data is (novox/hq ADR 0232,
|
|
// issue 273).
|
|
//
|
|
// The incident, exactly: a machine runs its own store and five consumers of it; the mesh's store seat
|
|
// is held by the store on another machine. Issue 258's rule — the seat's holder elsewhere answers
|
|
// before this machine's own provider — re-bound all five to the holder, each was made a fresh, empty
|
|
// database there, and nothing said so.
|
|
|
|
func TestAnOfferSaysWhetherItKeepsConsumerData(t *testing.T) {
|
|
var o Offer
|
|
if err := json.Unmarshal([]byte(`{"name":"wildcard-resolution","scope":"mesh","keeps-consumer-data":false}`), &o); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if o.KeepsConsumerData == nil || *o.KeepsConsumerData {
|
|
t.Fatalf("read %+v", o)
|
|
}
|
|
out, err := json.Marshal(o)
|
|
if err != nil || !strings.Contains(string(out), `"keeps-consumer-data":false`) {
|
|
t.Fatalf("wrote %s, %v", out, err)
|
|
}
|
|
yes, no := true, false
|
|
granting := Manifest{Module: "g", Provides: []Offer{{Name: "p", Scope: ScopeMesh}}, Grants: map[string]string{"p": "/g"}}
|
|
if !granting.KeepsConsumerData("p") {
|
|
t.Error("a provider granting each consumer a credential keeps what it writes, unsaid")
|
|
}
|
|
if (Manifest{Module: "r", Provides: []Offer{{Name: "p", Scope: ScopeMesh}}}).KeepsConsumerData("p") {
|
|
t.Error("a provider granting nothing keeps nothing, unsaid")
|
|
}
|
|
granting.Provides[0].KeepsConsumerData = &no
|
|
if granting.KeepsConsumerData("p") {
|
|
t.Error("what an offer says, it gets")
|
|
}
|
|
said := Manifest{Module: "s", Provides: []Offer{{Name: "p", Scope: ScopeMesh, KeepsConsumerData: &yes}}}
|
|
if !said.KeepsConsumerData("p") || !KeepsConsumerData(map[string]Manifest{"s": said, "r": {Module: "r",
|
|
Provides: []Offer{{Name: "p", Scope: ScopeMesh, KeepsConsumerData: &no}}}}, "p") {
|
|
t.Error("a name any provider says keeps data keeps data")
|
|
}
|
|
}
|