本文整理汇总了Golang中github.com/juju/juju/state.AddTestingService函数的典型用法代码示例。如果您正苦于以下问题:Golang AddTestingService函数的具体用法?Golang AddTestingService怎么用?Golang AddTestingService使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AddTestingService函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: NewPeerRelation
func NewPeerRelation(c *gc.C, st *state.State, owner names.UserTag) *PeerRelation {
svc := state.AddTestingService(c, st, "riak", state.AddTestingCharm(c, st, "riak"), owner)
ep, err := svc.Endpoint("ring")
c.Assert(err, jc.ErrorIsNil)
rel, err := st.EndpointsRelation(ep)
c.Assert(err, jc.ErrorIsNil)
pr := &PeerRelation{rel: rel, svc: svc}
pr.u0, pr.ru0 = addRU(c, svc, rel, nil)
pr.u1, pr.ru1 = addRU(c, svc, rel, nil)
pr.u2, pr.ru2 = addRU(c, svc, rel, nil)
pr.u3, pr.ru3 = addRU(c, svc, rel, nil)
return pr
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:13,代码来源:relationunit_test.go
示例2: TestRelations
func (s *MigrationImportSuite) TestRelations(c *gc.C) {
// Need to remove owner from service.
ignored := s.Owner
wordpress := state.AddTestingService(c, s.State, "wordpress", state.AddTestingCharm(c, s.State, "wordpress"), ignored)
state.AddTestingService(c, s.State, "mysql", state.AddTestingCharm(c, s.State, "mysql"), ignored)
eps, err := s.State.InferEndpoints("mysql", "wordpress")
c.Assert(err, jc.ErrorIsNil)
rel, err := s.State.AddRelation(eps...)
c.Assert(err, jc.ErrorIsNil)
wordpress_0 := s.Factory.MakeUnit(c, &factory.UnitParams{Service: wordpress})
ru, err := rel.Unit(wordpress_0)
c.Assert(err, jc.ErrorIsNil)
relSettings := map[string]interface{}{
"name": "wordpress/0",
}
err = ru.EnterScope(relSettings)
c.Assert(err, jc.ErrorIsNil)
_, newSt := s.importModel(c)
defer newSt.Close()
newWordpress, err := newSt.Service("wordpress")
c.Assert(err, jc.ErrorIsNil)
c.Assert(state.RelationCount(newWordpress), gc.Equals, 1)
rels, err := newWordpress.Relations()
c.Assert(err, jc.ErrorIsNil)
c.Assert(rels, gc.HasLen, 1)
units, err := newWordpress.AllUnits()
c.Assert(err, jc.ErrorIsNil)
c.Assert(units, gc.HasLen, 1)
ru, err = rels[0].Unit(units[0])
c.Assert(err, jc.ErrorIsNil)
settings, err := ru.Settings()
c.Assert(err, jc.ErrorIsNil)
c.Assert(settings.Map(), gc.DeepEquals, relSettings)
}
开发者ID:makyo,项目名称:juju,代码行数:39,代码来源:migration_import_test.go
示例3: AddTestingService
func (s *ConnSuite) AddTestingService(c *gc.C, name string, ch *state.Charm) *state.Service {
return state.AddTestingService(c, s.State, name, ch)
}
开发者ID:jiasir,项目名称:juju,代码行数:3,代码来源:conn_test.go
示例4: TestRelations
func (s *MigrationExportSuite) TestRelations(c *gc.C) {
wordpress := state.AddTestingService(c, s.State, "wordpress", state.AddTestingCharm(c, s.State, "wordpress"))
mysql := state.AddTestingService(c, s.State, "mysql", state.AddTestingCharm(c, s.State, "mysql"))
// InferEndpoints will always return provider, requirer
eps, err := s.State.InferEndpoints("mysql", "wordpress")
c.Assert(err, jc.ErrorIsNil)
rel, err := s.State.AddRelation(eps...)
msEp, wpEp := eps[0], eps[1]
c.Assert(err, jc.ErrorIsNil)
wordpress_0 := s.Factory.MakeUnit(c, &factory.UnitParams{Application: wordpress})
mysql_0 := s.Factory.MakeUnit(c, &factory.UnitParams{Application: mysql})
ru, err := rel.Unit(wordpress_0)
c.Assert(err, jc.ErrorIsNil)
wordpressSettings := map[string]interface{}{
"name": "wordpress/0",
}
err = ru.EnterScope(wordpressSettings)
c.Assert(err, jc.ErrorIsNil)
ru, err = rel.Unit(mysql_0)
c.Assert(err, jc.ErrorIsNil)
mysqlSettings := map[string]interface{}{
"name": "mysql/0",
}
err = ru.EnterScope(mysqlSettings)
c.Assert(err, jc.ErrorIsNil)
model, err := s.State.Export()
c.Assert(err, jc.ErrorIsNil)
rels := model.Relations()
c.Assert(rels, gc.HasLen, 1)
exRel := rels[0]
c.Assert(exRel.Id(), gc.Equals, rel.Id())
c.Assert(exRel.Key(), gc.Equals, rel.String())
exEps := exRel.Endpoints()
c.Assert(exEps, gc.HasLen, 2)
checkEndpoint := func(
exEndpoint description.Endpoint,
unitName string,
ep state.Endpoint,
settings map[string]interface{},
) {
c.Logf("%#v", exEndpoint)
c.Check(exEndpoint.ApplicationName(), gc.Equals, ep.ApplicationName)
c.Check(exEndpoint.Name(), gc.Equals, ep.Name)
c.Check(exEndpoint.UnitCount(), gc.Equals, 1)
c.Check(exEndpoint.Settings(unitName), jc.DeepEquals, settings)
c.Check(exEndpoint.Role(), gc.Equals, string(ep.Role))
c.Check(exEndpoint.Interface(), gc.Equals, ep.Interface)
c.Check(exEndpoint.Optional(), gc.Equals, ep.Optional)
c.Check(exEndpoint.Limit(), gc.Equals, ep.Limit)
c.Check(exEndpoint.Scope(), gc.Equals, string(ep.Scope))
}
checkEndpoint(exEps[0], mysql_0.Name(), msEp, mysqlSettings)
checkEndpoint(exEps[1], wordpress_0.Name(), wpEp, wordpressSettings)
}
开发者ID:kat-co,项目名称:juju,代码行数:61,代码来源:migration_export_test.go
示例5: AddTestingService
func (s *ConnWithWallClockSuite) AddTestingService(c *gc.C, name string, ch *state.Charm) *state.Application {
return state.AddTestingService(c, s.State, name, ch)
}
开发者ID:bac,项目名称:juju,代码行数:3,代码来源:conn_wallclock_test.go
注:本文中的github.com/juju/juju/state.AddTestingService函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论