本文整理汇总了Golang中github.com/juju/testing.Clock.Now方法的典型用法代码示例。如果您正苦于以下问题:Golang Clock.Now方法的具体用法?Golang Clock.Now怎么用?Golang Clock.Now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/testing.Clock
的用法示例。
在下文中一共展示了Clock.Now方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: PrimeUnitStatusHistory
// PrimeUnitStatusHistory will add count history elements, advancing the test clock by
// one second for each entry.
func PrimeUnitStatusHistory(
c *gc.C, clock *testing.Clock,
unit *Unit, statusVal status.Status,
count, batchSize int,
nextData func(int) map[string]interface{},
) {
globalKey := unit.globalKey()
history, closer := unit.st.getCollection(statusesHistoryC)
defer closer()
historyW := history.Writeable()
var data map[string]interface{}
for i := 0; i < count; {
var docs []interface{}
for j := 0; j < batchSize && i < count; j++ {
clock.Advance(time.Second)
if nextData != nil {
data = utils.EscapeKeys(nextData(i))
}
docs = append(docs, &historicalStatusDoc{
Status: statusVal,
StatusData: data,
Updated: clock.Now().UnixNano(),
GlobalKey: globalKey,
})
// Seems like you can't increment two values in one loop
i++
}
err := historyW.Insert(docs...)
c.Assert(err, jc.ErrorIsNil)
}
// Set the status for the unit itself.
doc := statusDoc{
Status: statusVal,
StatusData: data,
Updated: clock.Now().UnixNano(),
}
buildTxn := updateStatusSource(unit.st, globalKey, doc)
err := unit.st.run(buildTxn)
c.Assert(err, jc.ErrorIsNil)
}
示例2: assertReady
func assertReady(c *gc.C, s *schedule.Schedule, clock *jujutesting.Clock, expect ...interface{}) {
ready := s.Ready(clock.Now())
c.Assert(ready, jc.DeepEquals, expect)
}