testsupport

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 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 testsupport holds small helpers shared by test files across packages. It is not itself a _test.go file (Go doesn't let those be imported), but nothing outside test code should import it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteCredFile

func WriteCredFile(t *testing.T, dir, name, body, def string) string

WriteCredFile writes body (or def, if body is empty) to name inside dir at 0600, and returns the file's path. Extracted from four near-identical copies across the migration command test suites (execute, init, lagcheck, executetbm) that each wrote a credentials file into a manifest fixture.

Types

type CutListener

type CutListener struct {
	net.Listener
	// contains filtered or unexported fields
}

CutListener is a TCP listener for a test server that can reset every connection it has accepted at once, the way a cluster drops its clients in a connection storm. It keeps accepting new connections afterwards. Hand it to sarama.NewMockBrokerListener to put a mock broker behind it.

func NewCutListener

func NewCutListener(t testing.TB) *CutListener

NewCutListener listens on a free loopback port.

func (*CutListener) Accept

func (l *CutListener) Accept() (net.Conn, error)

Accept accepts a connection and remembers it for Cut.

func (*CutListener) Cut

func (l *CutListener) Cut()

Cut closes every connection accepted so far with a TCP reset.

Jump to

Keyboard shortcuts

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