testutil

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPBinHostname = "myhttpbin"
	MySQLHostname   = "mydb"
	SSHdHostname    = "mysshd"
)
View Source
const MultipartBoundary = "123456789012345678901234567890abcdefghijklmnopqrstuvwxyz"

Variables

View Source
var Cacert = func() []byte {
	b, err := os.ReadFile(filepath.Join(Testdata(), "cacert.pem"))
	if err != nil {
		panic(err)
	}
	return b
}()
View Source
var Cert = func() []byte {
	b, err := os.ReadFile(filepath.Join(Testdata(), "cert.pem"))
	if err != nil {
		panic(err)
	}
	return b
}()
View Source
var Key = func() []byte {
	b, err := os.ReadFile(filepath.Join(Testdata(), "key.pem"))
	if err != nil {
		panic(err)
	}
	return b
}()

Functions

func BenchmarkSet added in v0.93.0

func BenchmarkSet(t testing.TB, bookCount, stepCount int, body string) (*httptest.Server, string)

BenchmarkSet returns a server and a path pattern for benchmarking.

func BenchmarkSetWithOpenAPI3 added in v0.103.2

func BenchmarkSetWithOpenAPI3(t testing.TB, bookCount, stepCount int) (*httptest.Server, string)

BenchmarkSetWithOpenAPI3 returns a server and a path pattern for benchmarking.

func CreateHTTPBinContainer added in v0.52.0

func CreateHTTPBinContainer(t *testing.T) string

func CreateMySQLContainer added in v0.52.0

func CreateMySQLContainer(t *testing.T) (*sql.DB, string)

func CreateSSHdContainer added in v0.52.0

func CreateSSHdContainer(t *testing.T) (*ssh.Client, string, string, string, int)

func GRPCServer

func GRPCServer(t *testing.T, useTLS bool, disableReflection bool) *grpcstub.Server

func HTTPSServer added in v0.57.2

func HTTPSServer(t testing.TB) *httptest.Server

HTTPSServer creates and returns an HTTPS test server with TLS and predefined routes. The server is automatically closed when the test completes.

func HTTPSServerAndRouter added in v0.57.2

func HTTPSServerAndRouter(t testing.TB) (*httptest.Server, *httpstub.Router)

HTTPSServerAndRouter creates and returns both an HTTPS test server with TLS and its router. This allows for additional route configuration after creation. The server is automatically closed when the test completes.

func HTTPServer

func HTTPServer(t testing.TB) *httptest.Server

HTTPServer creates and returns an HTTP test server with predefined routes. The server is automatically closed when the test completes.

func HTTPServerAndRouter added in v0.47.0

func HTTPServerAndRouter(t testing.TB) (*httptest.Server, *httpstub.Router)

HTTPServerAndRouter creates and returns both an HTTP test server and its router. This allows for additional route configuration after creation. The server is automatically closed when the test completes.

func NewNullSSHClient added in v0.52.0

func NewNullSSHClient() *ssh.Client

func NewPort added in v0.89.0

func NewPort(t testing.TB) int

func Root

func Root() string

func SQLite

func SQLite(t *testing.T) (*sql.DB, string)

func SSHServer added in v0.96.0

func SSHServer(t testing.TB) string

func SkipCDPTest added in v0.47.0

func SkipCDPTest(t *testing.T) bool

func Testdata

func Testdata() string

Types

type NullChannel added in v0.52.0

type NullChannel struct{}

func (*NullChannel) Close added in v0.52.0

func (*NullChannel) Close() error

func (*NullChannel) CloseWrite added in v0.52.0

func (*NullChannel) CloseWrite() error

func (*NullChannel) Read added in v0.52.0

func (*NullChannel) Read(data []byte) (int, error)

func (*NullChannel) SendRequest added in v0.52.0

func (*NullChannel) SendRequest(name string, wantReply bool, payload []byte) (bool, error)

func (*NullChannel) Stderr added in v0.52.0

func (*NullChannel) Stderr() io.ReadWriter

func (*NullChannel) Write added in v0.52.0

func (*NullChannel) Write(data []byte) (int, error)

type NullConn added in v0.52.0

type NullConn struct{}

func (*NullConn) ClientVersion added in v0.52.0

func (*NullConn) ClientVersion() []byte

func (*NullConn) Close added in v0.52.0

func (*NullConn) Close() error

func (*NullConn) LocalAddr added in v0.52.0

func (*NullConn) LocalAddr() net.Addr

func (*NullConn) OpenChannel added in v0.52.0

func (*NullConn) OpenChannel(name string, data []byte) (ssh.Channel, <-chan *ssh.Request, error)

func (*NullConn) RemoteAddr added in v0.52.0

func (*NullConn) RemoteAddr() net.Addr

func (*NullConn) SendRequest added in v0.52.0

func (*NullConn) SendRequest(name string, wantReply bool, payload []byte) (bool, []byte, error)

func (*NullConn) ServerVersion added in v0.52.0

func (*NullConn) ServerVersion() []byte

func (*NullConn) SessionID added in v0.52.0

func (*NullConn) SessionID() []byte

func (*NullConn) User added in v0.52.0

func (*NullConn) User() string

func (*NullConn) Wait added in v0.52.0

func (*NullConn) Wait() error

type NullReadWriter added in v0.52.0

type NullReadWriter struct{}

func (*NullReadWriter) Read added in v0.52.0

func (*NullReadWriter) Read(data []byte) (int, error)

func (*NullReadWriter) Write added in v0.52.0

func (*NullReadWriter) Write(data []byte) (int, error)

Jump to

Keyboard shortcuts

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