clock

package
v1.8.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 4 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock clock.Clock

Clock is a clock

type Mock

type Mock struct {
	*clock.Mock
	// contains filtered or unexported fields
}

Mock is a mock clock that can be precisely controlled

func NewMock

func NewMock(t testing.TB) *Mock

NewMock creates a mock clock which can be precisely controlled

func NewMockAt added in v1.6.0

func NewMockAt(t testing.TB, now time.Time) *Mock

NewMockAt creates a mock clock which can be precisely controlled at a specific time.

func (*Mock) After

func (m *Mock) After(d time.Duration) <-chan time.Time

After waits for the duration to elapse and then sends the current time on the returned channel.

func (*Mock) SetAfterHook added in v1.8.3

func (m *Mock) SetAfterHook(h func(time.Duration) <-chan time.Time)

func (*Mock) Sleep

func (m *Mock) Sleep(d time.Duration)

Sleep pauses the current goroutine for at least the duration d

func (*Mock) Ticker

func (m *Mock) Ticker(d time.Duration) *clock.Ticker

Ticker returns a new Ticker containing a channel that will send the time with a period specified by the duration argument.

func (*Mock) Timer

func (m *Mock) Timer(d time.Duration) *clock.Timer

Timer creates a new Timer containing a channel that will send the time with a period specified by the duration argument.

func (*Mock) TimerCh

func (m *Mock) TimerCh() <-chan time.Duration

func (*Mock) WaitForAfter

func (m *Mock) WaitForAfter(timeout time.Duration, format string, args ...any)

WaitForAfter waits up to the specified timeout for After to be called on the clock.

func (*Mock) WaitForAfterCh added in v1.4.2

func (m *Mock) WaitForAfterCh() <-chan time.Duration

func (*Mock) WaitForSleep

func (m *Mock) WaitForSleep(timeout time.Duration, format string, args ...any)

WaitForSleep waits up to the specified timeout for a sleep to begin using the clock.

func (*Mock) WaitForTicker

func (m *Mock) WaitForTicker(timeout time.Duration, format string, args ...any)

WaitForTicker waits up to the specified timeout for a Ticker to be created from the clock.

func (*Mock) WaitForTickerMulti

func (m *Mock) WaitForTickerMulti(timeout time.Duration, count int, format string, args ...any)

func (*Mock) WaitForTimer

func (m *Mock) WaitForTimer(timeout time.Duration, format string, args ...any)

WaitForTimer waits up to the specified timeout for Timer to be called on the clock.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL