updating github.com/jonboulle/clockwork to v0.1.0
This commit is contained in:
5
vendor/github.com/jonboulle/clockwork/.travis.yml
generated
vendored
Normal file
5
vendor/github.com/jonboulle/clockwork/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
language: go
|
||||
go:
|
||||
- 1.3
|
||||
|
||||
sudo: false
|
5
vendor/github.com/jonboulle/clockwork/README.md
generated
vendored
5
vendor/github.com/jonboulle/clockwork/README.md
generated
vendored
@@ -1,6 +1,9 @@
|
||||
clockwork
|
||||
=========
|
||||
|
||||
[](https://travis-ci.org/jonboulle/clockwork)
|
||||
[](http://godoc.org/github.com/jonboulle/clockwork)
|
||||
|
||||
a simple fake clock for golang
|
||||
|
||||
# Usage
|
||||
@@ -55,4 +58,4 @@ See [example_test.go](example_test.go) for a full example.
|
||||
|
||||
# Credits
|
||||
|
||||
Inspired by @wickman's [threaded fake clock](https://gist.github.com/wickman/3840816), and the [Golang playground](http://blog.golang.org/playground#Faking time)
|
||||
clockwork is inspired by @wickman's [threaded fake clock](https://gist.github.com/wickman/3840816), and the [Golang playground](http://blog.golang.org/playground#Faking time)
|
||||
|
18
vendor/github.com/jonboulle/clockwork/clockwork.go
generated
vendored
18
vendor/github.com/jonboulle/clockwork/clockwork.go
generated
vendored
@@ -32,10 +32,17 @@ func NewRealClock() Clock {
|
||||
}
|
||||
|
||||
// NewFakeClock returns a FakeClock implementation which can be
|
||||
// manually advanced through time for testing.
|
||||
// manually advanced through time for testing. The initial time of the
|
||||
// FakeClock will be an arbitrary non-zero time.
|
||||
func NewFakeClock() FakeClock {
|
||||
// use a fixture that does not fulfill Time.IsZero()
|
||||
return NewFakeClockAt(time.Date(1984, time.April, 4, 0, 0, 0, 0, time.UTC))
|
||||
}
|
||||
|
||||
// NewFakeClockAt returns a FakeClock initialised at the given time.Time.
|
||||
func NewFakeClockAt(t time.Time) FakeClock {
|
||||
return &fakeClock{
|
||||
l: sync.RWMutex{},
|
||||
time: t,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,9 +124,10 @@ func (fc *fakeClock) Sleep(d time.Duration) {
|
||||
|
||||
// Time returns the current time of the fakeClock
|
||||
func (fc *fakeClock) Now() time.Time {
|
||||
fc.l.Lock()
|
||||
defer fc.l.Unlock()
|
||||
return fc.time
|
||||
fc.l.RLock()
|
||||
t := fc.time
|
||||
fc.l.RUnlock()
|
||||
return t
|
||||
}
|
||||
|
||||
// Advance advances fakeClock to a new point in time, ensuring channels from any
|
||||
|
Reference in New Issue
Block a user