testclock

package
v0.0.0-...-0da26dc Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package testclock provides a convenient Clock implementation for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock struct {
	// contains filtered or unexported fields
}

Clock is a clock used for testing.

func New

func New(now time.Time) *Clock

New creates a new Clock for testing with a tick of 0. For this clock, Now() always returns the value the clock was created with.

func WithTick

func WithTick(now time.Time, tick time.Duration) *Clock

WithTick creates a new Clock for testing with the time and tick specified.

func (*Clock) Advance

func (c *Clock) Advance(d time.Duration)

Advance advances the clock the specified duration.

func (*Clock) Now

func (c *Clock) Now() time.Time

Now returns the current time as seen by the Clock and advances the time the duration of the tick.

Jump to

Keyboard shortcuts

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