Help us shape the future of Go! Take the 2026 Go Developer Survey

testhelpers

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConsulHealthCheckTimeout is the timeout for Consul health checks
	ConsulHealthCheckTimeout = 2 * time.Second
)

Variables

This section is empty.

Functions

func ConsulClient

func ConsulClient() (*api.Client, error)

ConsulClient creates a new Consul API client

func ConsulURL

func ConsulURL() string

ConsulURL returns the Consul URL from environment or default

func IsConsulAvailable

func IsConsulAvailable() bool

IsConsulAvailable checks if Consul is running and accessible with timeout handling

Types

type Forwarder added in v0.35.0

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

Forwarder is a TCP forwarder a test can switch: it stands between a host and its relay, so a test can cut the tunnel, silence it, or send the next connection somewhere else, the way a network does.

func NewForwarder added in v0.35.0

func NewForwarder(t TB, target string) *Forwarder

NewForwarder forwards every connection to its address on to target, until the test ends.

func (*Forwarder) Addr added in v0.35.0

func (f *Forwarder) Addr() string

Addr is the address to dial in place of the target.

func (*Forwarder) Blackhole added in v0.35.0

func (f *Forwarder) Blackhole()

Blackhole makes every connection forwarded so far pass nothing more, in either direction, while staying open at both ends, as a link that went silent without either end hearing so. Connections accepted afterwards pass normally, so a host can redial past a blackholed one.

func (*Forwarder) Cut added in v0.35.0

func (f *Forwarder) Cut()

Cut closes every forwarded connection, both halves, as a dropped link would be seen by an end that notices. Later connections pass.

func (*Forwarder) Redirect added in v0.35.0

func (f *Forwarder) Redirect(target string)

Redirect sends the connections accepted from now on to target. Those already forwarded keep the target they were dialled to.

type TB added in v0.35.0

type TB interface {
	Helper()
	Cleanup(func())
	Fatalf(format string, args ...any)
}

TB is the part of *testing.T this package uses. Depending on an interface keeps the testing package, and the flags it registers, out of a non-test import graph.

Directories

Path Synopsis
Package fakerelay is an SSH server standing in for uptermd, for tests that need a relay to answer as the real one doesn't: with a random ID to a proven registration, as a relay without proofs does, with a scripted refusal, or by refusing a key at authentication.
Package fakerelay is an SSH server standing in for uptermd, for tests that need a relay to answer as the real one doesn't: with a random ID to a proven registration, as a relay without proofs does, with a scripted refusal, or by refusing a key at authentication.

Jump to

Keyboard shortcuts

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