testutil

package
v0.0.0-...-87e9d67 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package testutil wraps helpers for testing.

Index

Constants

View Source
const Race = false

Race reports if the race detector is enabled.

Variables

This section is empty.

Functions

func Date

func Date() time.Time

Date return date for testing.

func ErrWriter

func ErrWriter(err error) io.Writer

ErrWriter returns an io.Writer that returns 0, err from all Write calls.

func MaxAlloc

func MaxAlloc(t *testing.T, n int, f func())

MaxAlloc checks that f does not allocate more than n.

func Payloads

func Payloads() []int

Payloads returns a payload sizes list. Helpful for benchmarks.

func RSAPrivateKey

func RSAPrivateKey() *rsa.PrivateKey

RSAPrivateKey returns pre-generated test RSA private key.

func Rand

func Rand(seed []byte) *rand.Rand

Rand returns a new rand.Rand with source deterministically initialized from seed byte slice.

Zero length seed (or nil) is valid input.

func RunPayloads

func RunPayloads(b *testing.B, runner func(size int) func(b *testing.B))

RunPayloads runs given benchmark runner for every payload.

func SetEnv

func SetEnv(t *testing.T, k, v string)

SetEnv sets environment variable and sets delete callback to unset variable after test.

func SkipExternal

func SkipExternal(tb testing.TB)

SkipExternal skips current test if GOTD_TEST_EXTERNAL is not 1.

Caller should be high-level test function with TestExternalE2E prefix, like TestExternalE2EConnect.

Run all tests with following command in module root:

GOTD_TEST_EXTERNAL=1 go test -v -run ^TestExternalE2E ./...

func TestError

func TestError() error

TestError returns error for testing error pass.

func ZeroAlloc

func ZeroAlloc(t *testing.T, f func())

ZeroAlloc checks that f does not allocate.

Types

type ZeroRand

type ZeroRand struct{}

ZeroRand is zero random source.

func (ZeroRand) Read

func (ZeroRand) Read(p []byte) (n int, err error)

Read implements io.Reader.

Jump to

Keyboard shortcuts

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