func (s *EndpointSuite) TestImplementedBy(c *C) { for i, t := range implementedByTests { c.Logf("test %d", i) ep := state.Endpoint{"x", t.ifce, t.name, t.role, t.scope} c.Assert(ep.ImplementedBy(&dummyCharm{}), Equals, t.match) c.Assert(ep.IsImplicit(), Equals, t.implicit) } }
func (s *EndpointSuite) TestImplementedBy(c *C) { for i, t := range implementedByTests { c.Logf("test %d", i) ep := state.Endpoint{ ServiceName: "x", Relation: charm.Relation{ Interface: t.ifce, Name: t.name, Role: t.role, Scope: t.scope, }, } c.Assert(ep.ImplementedBy(&dummyCharm{}), Equals, t.match) c.Assert(ep.IsImplicit(), Equals, t.implicit) } }
func (s *EndpointSuite) TestCanRelate(c *C) { for i, t := range canRelateTests { c.Logf("test %d", i) ep1 := state.Endpoint{ ServiceName: "one-service", Relation: charm.Relation{ Interface: "ifce", Name: "foo", Role: t.role1, Scope: charm.ScopeGlobal, }, } ep2 := state.Endpoint{ ServiceName: "another-service", Relation: charm.Relation{ Interface: "ifce", Name: "bar", Role: t.role2, Scope: charm.ScopeGlobal, }, } if t.success { c.Assert(ep1.CanRelateTo(ep2), Equals, true) c.Assert(ep2.CanRelateTo(ep1), Equals, true) ep1.Interface = "different" } c.Assert(ep1.CanRelateTo(ep2), Equals, false) c.Assert(ep2.CanRelateTo(ep1), Equals, false) } ep1 := state.Endpoint{ ServiceName: "same-service", Relation: charm.Relation{ Interface: "ifce", Name: "foo", Role: charm.RoleProvider, Scope: charm.ScopeGlobal, }, } ep2 := state.Endpoint{ ServiceName: "same-service", Relation: charm.Relation{ Interface: "ifce", Name: "bar", Role: charm.RoleRequirer, Scope: charm.ScopeGlobal, }, } c.Assert(ep1.CanRelateTo(ep2), Equals, false) c.Assert(ep2.CanRelateTo(ep1), Equals, false) }
func (s *EndpointSuite) TestCanRelate(c *C) { for i, t := range canRelateTests { c.Logf("test %d", i) ep1 := state.Endpoint{"one-service", "ifce", "foo", t.role1, charm.ScopeGlobal} ep2 := state.Endpoint{"another-service", "ifce", "bar", t.role2, charm.ScopeGlobal} if t.success { c.Assert(ep1.CanRelateTo(ep2), Equals, true) c.Assert(ep2.CanRelateTo(ep1), Equals, true) ep1.Interface = "different" } c.Assert(ep1.CanRelateTo(ep2), Equals, false) c.Assert(ep2.CanRelateTo(ep1), Equals, false) } ep1 := state.Endpoint{"same-service", "ifce", "foo", state.RoleProvider, charm.ScopeGlobal} ep2 := state.Endpoint{"same-service", "ifce", "bar", state.RoleRequirer, charm.ScopeGlobal} c.Assert(ep1.CanRelateTo(ep2), Equals, false) c.Assert(ep2.CanRelateTo(ep1), Equals, false) }