OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 package cipd | |
6 | |
7 // No tests in this file, just a mockClock function used from other tests. | |
8 | |
9 import ( | |
10 "time" | |
11 | |
12 . "github.com/smartystreets/goconvey/convey" | |
13 ) | |
14 | |
15 type mockedClocked struct { | |
16 now time.Time | |
17 } | |
18 | |
19 func (c *mockedClocked) Now() time.Time { return c.now } | |
20 func (c *mockedClocked) Sleep(d time.Duration) { c.now = c.now.Add(d) } | |
21 | |
22 func mockClock(now time.Time) { | |
23 prev := clock | |
24 clock = &mockedClocked{now: now} | |
25 Reset(func() { clock = prev }) | |
26 } | |
OLD | NEW |