本文整理汇总了Golang中github.com/juju/testing.MgoInstance.MustDialDirect方法的典型用法代码示例。如果您正苦于以下问题:Golang MgoInstance.MustDialDirect方法的具体用法?Golang MgoInstance.MustDialDirect怎么用?Golang MgoInstance.MustDialDirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/testing.MgoInstance
的用法示例。
在下文中一共展示了MgoInstance.MustDialDirect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: dialAndTestInitiate
func (s *MongoSuite) dialAndTestInitiate(c *gc.C, inst *gitjujutesting.MgoInstance, addr string) {
session := inst.MustDialDirect()
defer session.Close()
mode := session.Mode()
err := Initiate(session, addr, rsName, initialTags)
c.Assert(err, gc.IsNil)
// make sure we haven't messed with the session's mode
c.Assert(session.Mode(), gc.Equals, mode)
// Ids start at 1 for us, so we can differentiate between set and unset
expectedMembers := []Member{Member{Id: 1, Address: addr, Tags: initialTags}}
// need to set mode to strong so that we wait for the write to succeed
// before reading and thus ensure that we're getting consistent reads.
session.SetMode(mgo.Strong, false)
mems, err := CurrentMembers(session)
c.Assert(err, gc.IsNil)
c.Assert(mems, jc.DeepEquals, expectedMembers)
// now add some data so we get a more real-life test
loadData(session, c)
}