OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package memory | 5 package memory |
6 | 6 |
7 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 "infra/gae/libs/wrapper" | 9 "infra/gae/libs/wrapper" |
10 "math/rand" | 10 "math/rand" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 Convey("TaskQueue", t, func() { | 24 Convey("TaskQueue", t, func() { |
25 now := time.Date(2000, time.January, 1, 1, 1, 1, 1, time.UTC) | 25 now := time.Date(2000, time.January, 1, 1, 1, 1, 1, time.UTC) |
26 timeNow := func(context.Context) time.Time { | 26 timeNow := func(context.Context) time.Time { |
27 ret := now | 27 ret := now |
28 now = now.Add(time.Second) | 28 now = now.Add(time.Second) |
29 return ret | 29 return ret |
30 } | 30 } |
31 c := wrapper.SetTimeNowFactory(context.Background(), timeNow) | 31 c := wrapper.SetTimeNowFactory(context.Background(), timeNow) |
32 c = wrapper.SetMathRand(c, rand.New(rand.NewSource(wrapper.GetTi
meNow(c).UnixNano()))) | 32 c = wrapper.SetMathRand(c, rand.New(rand.NewSource(wrapper.GetTi
meNow(c).UnixNano()))) |
33 » » c = Use(Enable(c)) | 33 » » c = Use(c) |
34 | 34 |
35 tq := wrapper.GetTQ(c).(interface { | 35 tq := wrapper.GetTQ(c).(interface { |
36 wrapper.TQMultiReadWriter | 36 wrapper.TQMultiReadWriter |
37 wrapper.TQTestable | 37 wrapper.TQTestable |
38 }) | 38 }) |
39 | 39 |
40 So(tq, ShouldNotBeNil) | 40 So(tq, ShouldNotBeNil) |
41 | 41 |
42 Convey("implements TQMultiReadWriter", func() { | 42 Convey("implements TQMultiReadWriter", func() { |
43 Convey("Add", func() { | 43 Convey("Add", func() { |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 }() | 463 }() |
464 | 464 |
465 So(tq.GetScheduledTasks()["default"][tEnQ.Name],
ShouldResemble, tEnQ) | 465 So(tq.GetScheduledTasks()["default"][tEnQ.Name],
ShouldResemble, tEnQ) |
466 So(tq.GetTombstonedTasks()["default"][tEnQ2.Name
], ShouldResemble, tEnQ2) | 466 So(tq.GetTombstonedTasks()["default"][tEnQ2.Name
], ShouldResemble, tEnQ2) |
467 So(tq.GetTransactionTasks()["default"], ShouldBe
Nil) | 467 So(tq.GetTransactionTasks()["default"], ShouldBe
Nil) |
468 }) | 468 }) |
469 | 469 |
470 }) | 470 }) |
471 }) | 471 }) |
472 } | 472 } |
OLD | NEW |