package catalogue import ( "testing" ) // The router of novox/hq ADR 0259: it declares the operator's seat and the two kinded benches. func router() Manifest { return Manifest{Module: "messenger", Tools: []string{"open", "history", "notify"}, State: []StateDeclaration{{Name: "asks"}}, RunsAs: "messenger", SecretsOwner: "messenger", DefinesSeats: []SeatDeclaration{ {Name: "operator-channel", Scope: ScopeMesh, Accepts: []string{"ask", "cancel"}, Emits: []string{"decided"}, ByCaller: []string{"ask", "cancel", "decided"}, Records: []string{"asks"}, Serves: []Verb{{Name: "open"}, {Name: "history"}, {Name: "notify"}}}, {Name: "channel", Scope: ScopeMesh, Kinded: true, Accepts: []string{"show", "edit", "send"}}, {Name: "intake", Scope: ScopeMesh, Kinded: true, Emits: []string{"choice", "link"}, Proofs: []string{"code"}}, }, Claims: []Claim{{Name: "operator-channel", Scope: ScopeMesh}}, Uses: []string{"channel"}} } func aChannel(module, kind string) Manifest { return Manifest{Module: module, Claims: []Claim{ {Name: "channel", Scope: ScopeMesh, Kind: kind}, {Name: "intake", Scope: ScopeMesh, Kind: kind}}} } // Two kinds on one machine are two holders, and one kind on two machines is a second claimant. func TestEachKindIsItsOwnHolderWhenResolved(t *testing.T) { modules := []Manifest{aChannel("telegram", "telegram"), aChannel("desk-channel", "desktop")} held, problems := checkClaims(modules, Node{Name: "anchor"}, nil, nil) if len(problems) > 0 || len(held) != 4 { t.Fatalf("two kinds on one machine: held %v, problems %v", held, problems) } _, problems = checkClaims([]Manifest{aChannel("telegram", "telegram")}, Node{Name: "home"}, held, nil) if len(problems) == 0 { t.Fatal("one kind held on two machines was not refused") } }