本文整理匯總了Golang中github.com/juju/juju/state.Service.Relations方法的典型用法代碼示例。如果您正苦於以下問題:Golang Service.Relations方法的具體用法?Golang Service.Relations怎麽用?Golang Service.Relations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/juju/state.Service
的用法示例。
在下文中一共展示了Service.Relations方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: assertServiceRelations
func (s *ServiceSuite) assertServiceRelations(c *gc.C, svc *state.Service, expectedKeys ...string) []*state.Relation {
rels, err := svc.Relations()
c.Assert(err, gc.IsNil)
if len(rels) == 0 {
return nil
}
relKeys := make([]string, len(expectedKeys))
for i, rel := range rels {
relKeys[i] = rel.String()
}
sort.Strings(relKeys)
c.Assert(relKeys, gc.DeepEquals, expectedKeys)
return rels
}
示例2: assertOneRelation
func assertOneRelation(c *gc.C, srv *state.Service, relId int, endpoints ...state.Endpoint) *state.Relation {
rels, err := srv.Relations()
c.Assert(err, gc.IsNil)
c.Assert(rels, gc.HasLen, 1)
rel := rels[0]
c.Assert(rel.Id(), gc.Equals, relId)
c.Assert(rel.Endpoints(), jc.SameContents, endpoints)
name := srv.Name()
expectEp := endpoints[0]
ep, err := rel.Endpoint(name)
c.Assert(err, gc.IsNil)
c.Assert(ep, gc.DeepEquals, expectEp)
if len(endpoints) == 2 {
expectEp = endpoints[1]
}
eps, err := rel.RelatedEndpoints(name)
c.Assert(err, gc.IsNil)
c.Assert(eps, gc.DeepEquals, []state.Endpoint{expectEp})
return rel
}
示例3: assertNoRelations
func assertNoRelations(c *gc.C, srv *state.Service) {
rels, err := srv.Relations()
c.Assert(err, gc.IsNil)
c.Assert(rels, gc.HasLen, 0)
}