package process import ( "strings" "testing" "git.novox.be/novox/mesh-sdk/go/announce" ) // After Keeps a process binds only the states it announced (novox/hq ADR 0495 clause 5): any other of its module's // states is refused at the call, naming it, before the bus is asked; before Keeps nothing is refused. func TestAProcessBindsOnlyTheStatesItAnnounced(t *testing.T) { c := &Conn{account: Account{Module: "mesh-mail", Node: "novox"}} if err := c.remember([]announce.State{{Name: "accounts", Readable: true}}); err != nil { t.Fatal(err) } _, err := c.State("drafts").Get("k") if err == nil || !strings.Contains(err.Error(), `"drafts"`) || !strings.Contains(err.Error(), "Keeps") { t.Fatalf("an unannounced state was bound: %v", err) } if err := c.remember([]announce.State{{Name: "a_b"}}); err == nil { t.Fatal("an announcement no bucket could be named by was accepted") } got, err := announce.Decode(c.announced) if err != nil || got.Module != "mesh-mail" || got.Node != "novox" || !got.Readable("accounts") { t.Fatalf("the announcement is %s (%v)", c.announced, err) } }