clock

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: BSD-3-Clause Imports: 2 Imported by: 3

Documentation

Overview

Package clock provides a simple abstraction around the standard time package.

  • Set and "freeze" the wall clock in test code, with provided wrappers for
  • time.Now
  • time.Since
  • Skip sleeps in test code, with provided wrappers for
  • time.Sleep

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Now

func Now() time.Time

Now returns the current time or the time to which it's been set.

func ResumeSleeps

func ResumeSleeps(t *testing.T)

ResumeSleeps causes time.Sleep to resume default behavior. This should only be called by test code.

func SetAndFreezeClock

func SetAndFreezeClock(t *testing.T, ti time.Time)

SetAndFreezeClock will set the value to be returned by Now. This should only be called by test code.

func Since

func Since(t time.Time) time.Duration

Since returns the time elapsed since t, where the current time may have been frozen.

func SkipSleeps

func SkipSleeps(t *testing.T)

SkipSleeps causes time.Sleep to sleep for only a small, negligible duration. This should only be called by test code.

func Sleep

func Sleep(d time.Duration)

Sleep either the specified duration or a small, negligible duration.

func UnfreezeClock

func UnfreezeClock(t *testing.T)

UnfreezeClock will revert clock.Now's behavior to delegating to time.Now. This should only be called by test code.

Types

This section is empty.

Jump to

Keyboard shortcuts

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