testing

package
v0.19.8 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testing provides testing helpers for state machines using testify.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertErr

func AssertErr(t *stdtest.T, mach am.Api)

AssertErr asserts that the machine is in the Exception state.

func AssertIs

func AssertIs(t *stdtest.T, mach am.Api, states am.S, msgAndArgs ...any)

AssertIs asserts that the machine is in the given states.

func AssertIs1

func AssertIs1(t *stdtest.T, mach am.Api, state string, msgAndArgs ...any)

AssertIs1 asserts that the machine is in the given state.

func AssertNoErrEver

func AssertNoErrEver(t *stdtest.T, mach am.Api)

AssertNoErrEver asserts that the machine never was in the Exception state.

func AssertNoErrNow

func AssertNoErrNow(t *stdtest.T, mach am.Api)

AssertNoErrNow asserts that the machine is not in the Exception state.

func AssertNoErrQueued added in v0.19.0

func AssertNoErrQueued(t *stdtest.T, mach *am.Machine)

func AssertNot

func AssertNot(t *stdtest.T, mach am.Api, states am.S, msgAndArgs ...any)

AssertNot asserts that the machine is not in the given states.

func AssertNot1

func AssertNot1(t *stdtest.T, mach am.Api, state string, msgAndArgs ...any)

AssertNot1 asserts that the machine is not in the given state.

func AssertString added in v0.19.3

func AssertString(
	t *stdtest.T, m am.Api, expected string, states am.S,
)

func AssertTime added in v0.19.3

func AssertTime(t *stdtest.T, m am.Api, states am.S, time am.Time,
	msgAndArgs ...any,
)

func GroupWhen1

func GroupWhen1(
	t *stdtest.T, mach []am.Api, state string, ctx context.Context,
) []<-chan struct{}

GroupWhen1 is a test version of amhelp.GroupWhen1, which errors instead of returning an error.

func LogToTestLog added in v0.18.9

func LogToTestLog(t *stdtest.T, mach am.Api, maxLvl am.LogLevel)

LogToTestLog will fwd machine's log to `go test` log.

func MachDebug

func MachDebug(t *stdtest.T, mach am.Api, amDbgAddr string,
	logLvl am.LogLevel, stdout bool,
)

MachDebug sets up a machine for debugging in tests, based on the AM_DEBUG env var, passed am-dbg address, log level and stdout flag.

func MachDebugEnv

func MachDebugEnv(t *stdtest.T, mach am.Api)

MachDebugEnv sets up a machine for debugging in tests, based on env vars only: AM_DBG_ADDR, AM_LOG, and AM_DEBUG.

func Wait

func Wait(
	t *stdtest.T, errMsg string, ctx context.Context, length time.Duration,
)

Wait is a test version of amhelp.Wait, which errors instead of returning false.

func WaitForAll

func WaitForAll(
	t *stdtest.T, source string, ctx context.Context, timeout time.Duration,
	chans ...<-chan struct{},
)

WaitForAll is a test version of amhelp.WaitForAll, which errors instead of returning an error.

func WaitForAny

func WaitForAny(
	t *stdtest.T, source string, ctx context.Context, timeout time.Duration,
	chans ...<-chan struct{},
)

WaitForAny is a test version of amhelp.WaitForAny, which errors instead of returning an error.

func WaitForErrAll

func WaitForErrAll(
	t *stdtest.T, source string, ctx context.Context, mach am.Api,
	timeout time.Duration, chans ...<-chan struct{},
)

WaitForErrAll is a test version of amhelp.WaitForErrAll, which errors instead of returning an error.

Types

type MeteredUDP added in v0.19.3

type MeteredUDP struct {
	net.PacketConn
	// contains filtered or unexported fields
}

MeteredUDP wraps a net.PacketConn to track bytes and packet counts.

func WrapUDP added in v0.19.3

func WrapUDP(conn net.PacketConn) *MeteredUDP

func (*MeteredUDP) BytesIn added in v0.19.3

func (m *MeteredUDP) BytesIn() uint64

Stats getters

func (*MeteredUDP) BytesOut added in v0.19.3

func (m *MeteredUDP) BytesOut() uint64

func (*MeteredUDP) PacketsIn added in v0.19.3

func (m *MeteredUDP) PacketsIn() uint64

func (*MeteredUDP) PacketsOut added in v0.19.3

func (m *MeteredUDP) PacketsOut() uint64

func (*MeteredUDP) ReadFrom added in v0.19.3

func (m *MeteredUDP) ReadFrom(p []byte) (int, net.Addr, error)

func (*MeteredUDP) WriteTo added in v0.19.3

func (m *MeteredUDP) WriteTo(p []byte, addr net.Addr) (int, error)

Jump to

Keyboard shortcuts

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