本文整理汇总了Golang中testing.T.After方法的典型用法代码示例。如果您正苦于以下问题:Golang T.After方法的具体用法?Golang T.After怎么用?Golang T.After使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testing.T
的用法示例。
在下文中一共展示了T.After方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestHackthing
func TestHackthing(t *testing.T) {
fa := Flightaware{APIKey: TestAPIKey, APIUsername: TestAPIUsername}
fa.Init()
ret, err := fa.CallArrived("KSFO")
if err != nil {
t.Errorf("init call: %v", err)
}
for _, f := range ret {
results, err := fa.CallFlightInfoEx(f.Ident)
if err != nil {
t.Errorf("CallFlightInfoEx failed: %v", err)
}
for _, v := range results {
t := time.Unix(int64(v.Fileddeparturetime), 0)
// Use v.actualdeparturetime to compare against arrived.actualdeparturetime
if t.After(time.Now()) {
continue
}
atoms := strings.Split(v.Route, " ")
fmt.Printf("%s, %s-%s, %s, %s, %s\n", v.Ident, v.Origin, v.Destination, t,
atoms[len(atoms)-1], v.Route)
break
}
}
}
示例2: Test_MessageEntry_MessagesIsStored_And_GetsCorrectParameters
func Test_MessageEntry_MessagesIsStored_And_GetsCorrectParameters(t *testing.T) {
defer initCtrl(t)()
a := assert.New(t)
startTime := time.Now()
msg := &guble.Message{Path: guble.Path("/topic1")}
var storedMsg []byte
var routedMsg *guble.Message
routerMock := NewMockMessageSink(ctrl)
messageEntry := NewMessageEntry(routerMock)
messageStoreMock := NewMockMessageStore(ctrl)
messageEntry.SetMessageStore(messageStoreMock)
messageStoreMock.EXPECT().StoreTx("topic1", gomock.Any()).
Do(func(topic string, callback func(msgId uint64) []byte) {
storedMsg = callback(uint64(42))
})
routerMock.EXPECT().HandleMessage(gomock.Any()).Do(func(msg *guble.Message) {
routedMsg = msg
a.Equal(uint64(42), msg.Id)
t, e := time.Parse(time.RFC3339, msg.PublishingTime) // publishing time
a.NoError(e)
a.True(t.After(startTime.Add(-1 * time.Second)))
a.True(t.Before(time.Now().Add(time.Second)))
})
messageEntry.HandleMessage(msg)
a.Equal(routedMsg.Bytes(), storedMsg)
}
示例3: TestTimes
// TestDimes tests the generation of durations and times.
func TestTimes(t *testing.T) {
assert := audit.NewTestingAssertion(t, true)
gen := audit.NewGenerator(audit.SimpleRand())
for i := 0; i < 10000; i++ {
// Test durations.
lo := gen.Duration(time.Second, time.Minute)
hi := gen.Duration(time.Second, time.Minute)
d := gen.Duration(lo, hi)
if hi < lo {
lo, hi = hi, lo
}
assert.True(lo <= d && d <= hi)
// Test times.
loc := time.Local
now := time.Now()
dur := gen.Duration(24*time.Hour, 30*24*time.Hour)
t := gen.Time(loc, now, dur)
assert.True(t.Equal(now) || t.After(now))
assert.True(t.Before(now.Add(dur)) || t.Equal(now.Add(dur)))
}
}