mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
godep: update clockwork dependency
This commit is contained in:
4
Godeps/_workspace/src/github.com/jonboulle/clockwork/README.md
generated
vendored
4
Godeps/_workspace/src/github.com/jonboulle/clockwork/README.md
generated
vendored
@@ -39,8 +39,8 @@ func TestMyFunc(t *testing.T) {
|
||||
|
||||
assert_state()
|
||||
|
||||
// Tick the FakeClock forward in time
|
||||
c.Tick(3)
|
||||
// Advance the FakeClock forward in time
|
||||
c.Advance(3)
|
||||
|
||||
assert_state()
|
||||
}
|
||||
|
||||
14
Godeps/_workspace/src/github.com/jonboulle/clockwork/clockwork.go
generated
vendored
14
Godeps/_workspace/src/github.com/jonboulle/clockwork/clockwork.go
generated
vendored
@@ -14,12 +14,12 @@ type Clock interface {
|
||||
}
|
||||
|
||||
// FakeClock provides an interface for a clock which can be
|
||||
// manually ticked through time
|
||||
// manually advanced through time
|
||||
type FakeClock interface {
|
||||
Clock
|
||||
// Tick advances the FakeClock to a new point in time, ensuring any existing
|
||||
// Advance advances the FakeClock to a new point in time, ensuring any existing
|
||||
// sleepers are notified appropriately before returning
|
||||
Tick(d time.Duration)
|
||||
Advance(d time.Duration)
|
||||
// BlockUntil will block until the FakeClock has the given number of
|
||||
// sleepers (callers of Sleep or After)
|
||||
BlockUntil(n int)
|
||||
@@ -32,7 +32,7 @@ func NewRealClock() Clock {
|
||||
}
|
||||
|
||||
// NewFakeClock returns a FakeClock implementation which can be
|
||||
// manually ticked through time for testing.
|
||||
// manually advanced through time for testing.
|
||||
func NewFakeClock() FakeClock {
|
||||
return &fakeClock{
|
||||
l: sync.RWMutex{},
|
||||
@@ -122,10 +122,11 @@ func (fc *fakeClock) Now() time.Time {
|
||||
return fc.time
|
||||
}
|
||||
|
||||
// Tick advances fakeClock to a new point in time, ensuring channels from any
|
||||
// Advance advances fakeClock to a new point in time, ensuring channels from any
|
||||
// previous invocations of After are notified appropriately before returning
|
||||
func (fc *fakeClock) Tick(d time.Duration) {
|
||||
func (fc *fakeClock) Advance(d time.Duration) {
|
||||
fc.l.Lock()
|
||||
defer fc.l.Unlock()
|
||||
end := fc.time.Add(d)
|
||||
var newSleepers []*sleeper
|
||||
for _, s := range fc.sleepers {
|
||||
@@ -138,7 +139,6 @@ func (fc *fakeClock) Tick(d time.Duration) {
|
||||
fc.sleepers = newSleepers
|
||||
fc.blockers = notifyBlockers(fc.blockers, len(fc.sleepers))
|
||||
fc.time = end
|
||||
fc.l.Unlock()
|
||||
}
|
||||
|
||||
// BlockUntil will block until the fakeClock has the given number of sleepers
|
||||
|
||||
10
Godeps/_workspace/src/github.com/jonboulle/clockwork/clockwork_test.go
generated
vendored
10
Godeps/_workspace/src/github.com/jonboulle/clockwork/clockwork_test.go
generated
vendored
@@ -18,7 +18,7 @@ func TestFakeClockAfter(t *testing.T) {
|
||||
two := fc.After(2)
|
||||
six := fc.After(6)
|
||||
ten := fc.After(10)
|
||||
fc.Tick(1)
|
||||
fc.Advance(1)
|
||||
select {
|
||||
case <-one:
|
||||
default:
|
||||
@@ -33,7 +33,7 @@ func TestFakeClockAfter(t *testing.T) {
|
||||
t.Errorf("ten returned prematurely!")
|
||||
default:
|
||||
}
|
||||
fc.Tick(1)
|
||||
fc.Advance(1)
|
||||
select {
|
||||
case <-two:
|
||||
default:
|
||||
@@ -46,7 +46,7 @@ func TestFakeClockAfter(t *testing.T) {
|
||||
t.Errorf("ten returned prematurely!")
|
||||
default:
|
||||
}
|
||||
fc.Tick(1)
|
||||
fc.Advance(1)
|
||||
select {
|
||||
case <-six:
|
||||
t.Errorf("six returned prematurely!")
|
||||
@@ -54,7 +54,7 @@ func TestFakeClockAfter(t *testing.T) {
|
||||
t.Errorf("ten returned prematurely!")
|
||||
default:
|
||||
}
|
||||
fc.Tick(3)
|
||||
fc.Advance(3)
|
||||
select {
|
||||
case <-six:
|
||||
default:
|
||||
@@ -65,7 +65,7 @@ func TestFakeClockAfter(t *testing.T) {
|
||||
t.Errorf("ten returned prematurely!")
|
||||
default:
|
||||
}
|
||||
fc.Tick(100)
|
||||
fc.Advance(100)
|
||||
select {
|
||||
case <-ten:
|
||||
default:
|
||||
|
||||
4
Godeps/_workspace/src/github.com/jonboulle/clockwork/example_test.go
generated
vendored
4
Godeps/_workspace/src/github.com/jonboulle/clockwork/example_test.go
generated
vendored
@@ -38,8 +38,8 @@ func TestMyFunc(t *testing.T) {
|
||||
// Assert the initial state
|
||||
assert_state(t, i, 0)
|
||||
|
||||
// Now tick the clock forward in time
|
||||
c.Tick(1 * time.Hour)
|
||||
// Now advance the clock forward in time
|
||||
c.Advance(1 * time.Hour)
|
||||
|
||||
// Wait until the function completes
|
||||
wg.Wait()
|
||||
|
||||
Reference in New Issue
Block a user