本文整理匯總了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)
}