tstest

package
v0.100.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package tstest provides utilities for use in unit tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FixLogs

func FixLogs(t *testing.T)

func PanicOnLog

func PanicOnLog()

PanicOnLog modifies the standard library log package's default output to an io.Writer that panics, to root out code that's not plumbing their logging through explicit tailscale.com/logger.Logf paths.

func UnfixLogs

func UnfixLogs(t *testing.T)

Types

type Clock

type Clock struct {
	// Start is the first value returned by Now.
	Start time.Time
	// Step is how much to advance with each Now call.
	Step time.Duration
	// Present is the time that the next Now call will receive.
	Present time.Time

	sync.Mutex
}

Clock is a testing clock that advances every time its Now method is called, beginning at Start.

The zero value starts virtual time at an arbitrary value recorded in Start on the first call to Now, and time never advances.

func (*Clock) Now

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

Now returns the virtual clock's current time, and avances it according to its step configuration.

func (*Clock) Reset

func (c *Clock) Reset()

Reset rewinds the virtual clock to its start time.

type ResourceCheck

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

func NewResourceCheck

func NewResourceCheck() *ResourceCheck

func (*ResourceCheck) Assert

func (r *ResourceCheck) Assert(t *testing.T)

Directories

Path Synopsis
Package natlab lets us simulate different types of networks all in-memory without running VMs or requiring root, etc.
Package natlab lets us simulate different types of networks all in-memory without running VMs or requiring root, etc.

Jump to

Keyboard shortcuts

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