package testing
import "k8s.io/klog/v2/internal/clock/testing"
Index ¶
- type FakeClock
- func NewFakeClock(t time.Time) *FakeClock
- func (f *FakeClock) After(d time.Duration) <-chan time.Time
- func (f *FakeClock) AfterFunc(d time.Duration, cb func()) clock.Timer
- func (f *FakeClock) HasWaiters() bool
- func (f *FakeClock) NewTicker(d time.Duration) clock.Ticker
- func (f *FakeClock) NewTimer(d time.Duration) clock.Timer
- func (f *FakeClock) SetTime(t time.Time)
- func (f *FakeClock) Sleep(d time.Duration)
- func (f *FakeClock) Step(d time.Duration)
- func (f *FakeClock) Tick(d time.Duration) <-chan time.Time
- type FakePassiveClock
- func NewFakePassiveClock(t time.Time) *FakePassiveClock
- func (f *FakePassiveClock) Now() time.Time
- func (f *FakePassiveClock) SetTime(t time.Time)
- func (f *FakePassiveClock) Since(ts time.Time) time.Duration
- type IntervalClock
- func (*IntervalClock) After(time.Duration) <-chan time.Time
- func (*IntervalClock) AfterFunc(time.Duration, func()) clock.Timer
- func (*IntervalClock) NewTicker(time.Duration) clock.Ticker
- func (*IntervalClock) NewTimer(time.Duration) clock.Timer
- func (i *IntervalClock) Now() time.Time
- func (i *IntervalClock) Since(ts time.Time) time.Duration
- func (*IntervalClock) Sleep(time.Duration)
- type SimpleIntervalClock
Types ¶
type FakeClock ¶
type FakeClock struct { FakePassiveClock // contains filtered or unexported fields }
FakeClock implements clock.Clock, but returns an arbitrary time.
func NewFakeClock ¶
NewFakeClock constructs a fake clock set to the provided time.
func (*FakeClock) After ¶
After is the fake version of time.After(d).
func (*FakeClock) AfterFunc ¶
AfterFunc is the Fake version of time.AfterFunc(d, cb).
func (*FakeClock) HasWaiters ¶
HasWaiters returns true if After or AfterFunc has been called on f but not yet satisfied (so you can write race-free tests).
func (*FakeClock) NewTicker ¶
NewTicker returns a new Ticker.
func (*FakeClock) NewTimer ¶
NewTimer constructs a fake timer, akin to time.NewTimer(d).
func (*FakeClock) SetTime ¶
SetTime sets the time.
func (*FakeClock) Sleep ¶
Sleep is akin to time.Sleep
func (*FakeClock) Step ¶
Step moves the clock by Duration and notifies anyone that's called After, Tick, or NewTimer.
func (*FakeClock) Tick ¶
Tick constructs a fake ticker, akin to time.Tick
type FakePassiveClock ¶
type FakePassiveClock struct {
// contains filtered or unexported fields
}
FakePassiveClock implements PassiveClock, but returns an arbitrary time.
func NewFakePassiveClock ¶
func NewFakePassiveClock(t time.Time) *FakePassiveClock
NewFakePassiveClock returns a new FakePassiveClock.
func (*FakePassiveClock) Now ¶
func (f *FakePassiveClock) Now() time.Time
Now returns f's time.
func (*FakePassiveClock) SetTime ¶
func (f *FakePassiveClock) SetTime(t time.Time)
SetTime sets the time on the FakePassiveClock.
func (*FakePassiveClock) Since ¶
func (f *FakePassiveClock) Since(ts time.Time) time.Duration
Since returns time since the time in f.
type IntervalClock ¶
IntervalClock implements clock.PassiveClock, but each invocation of Now steps the clock forward the specified duration. IntervalClock technically implements the other methods of clock.Clock, but each implementation is just a panic.
Deprecated: See SimpleIntervalClock for an alternative that only has the methods of PassiveClock.
func (*IntervalClock) After ¶
func (*IntervalClock) After(time.Duration) <-chan time.Time
After is unimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) AfterFunc ¶
func (*IntervalClock) AfterFunc(time.Duration, func()) clock.Timer
AfterFunc is unimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) NewTicker ¶
func (*IntervalClock) NewTicker(time.Duration) clock.Ticker
NewTicker has no implementation yet and is omitted. TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) NewTimer ¶
func (*IntervalClock) NewTimer(time.Duration) clock.Timer
NewTimer is unimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) Now ¶
func (i *IntervalClock) Now() time.Time
Now returns i's time.
func (*IntervalClock) Since ¶
func (i *IntervalClock) Since(ts time.Time) time.Duration
Since returns time since the time in i.
func (*IntervalClock) Sleep ¶
func (*IntervalClock) Sleep(time.Duration)
Sleep is unimplemented, will panic.
type SimpleIntervalClock ¶
SimpleIntervalClock implements clock.PassiveClock, but each invocation of Now steps the clock forward the specified duration
func (*SimpleIntervalClock) Now ¶
func (i *SimpleIntervalClock) Now() time.Time
Now returns i's time.
func (*SimpleIntervalClock) Since ¶
func (i *SimpleIntervalClock) Since(ts time.Time) time.Duration
Since returns time since the time in i.
Source Files ¶
fake_clock.go simple_interval_clock.go
- Version
- v2.130.0
- Published
- Jun 15, 2024
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 3 hours ago –
Tools for package owners.