package resolution import ( "testing" mcat "git.novox.be/novox/mesh-sdk/go/catalogue" ) func aChannel(module, kind string) mcat.Manifest { return mcat.Manifest{Module: module, Claims: []mcat.Claim{ {Name: "channel", Scope: mcat.ScopeMesh, Kind: kind}, {Name: "intake", Scope: mcat.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 := []mcat.Manifest{aChannel("telegram", "telegram"), aChannel("desk-channel", "desktop")} held, problems := checkClaims(modules, mcat.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([]mcat.Manifest{aChannel("telegram", "telegram")}, mcat.Node{Name: "home"}, held, nil) if len(problems) == 0 { t.Fatal("one kind held on two machines was not refused") } }