updating github.com/jonboulle/clockwork to v0.1.0

This commit is contained in:
Davanum Srinivas
2019-06-14 11:02:22 -04:00
parent d04014a208
commit db35f59e27
11 changed files with 36 additions and 20 deletions

5
vendor/github.com/jonboulle/clockwork/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,5 @@
language: go
go:
- 1.3
sudo: false

View File

@@ -1,6 +1,9 @@
clockwork
=========
[![Build Status](https://travis-ci.org/jonboulle/clockwork.png?branch=master)](https://travis-ci.org/jonboulle/clockwork)
[![godoc](https://godoc.org/github.com/jonboulle/clockwork?status.svg)](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)

View File

@@ -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