testutils

package
v0.0.0-...-760d8ea Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSTDCapture

func CreateSTDCapture(t *testing.T) (writer *os.File, capture func() string, err error)

CreateSTDCapture creates a new os.File writer that can be used in place of default system values (such as os.Stdout). The content written into the file can then be retrieved using the returned capture function.

Calling the capture function closes the original writer, so make sure you captured everything you need before calling it.

func RequireGRPCCodesEqual

func RequireGRPCCodesEqual(t *testing.T, err error, code codes.Code)

RequireGRPCCodesEqual checks if an error is nil or if it is a gRPC error with the expected code.

If the code is codes.OK, it will instead check if the error is nil.

func RunCMD

func RunCMD(t *testing.T, config *CMDConfig)

RunCMD setups a pattern to run test in controlled environments. https://stackoverflow.com/a/33404435/9021186

IMPORTANT: this must be run only once per test.

func WaitConn

func WaitConn(t *testing.T, conn *grpc.ClientConn)

WaitConn expects a conn to enter ready state. It returns when conn is available, otherwise it fails the test.

Types

type CMDConfig

type CMDConfig struct {
	CmdFn  func(t *testing.T)
	MainFn func(t *testing.T, res *CMDResult)
	Env    []string
}

type CMDResult

type CMDResult struct {
	Err     error
	Success bool

	STDOut string
	STDErr string
}

Jump to

Keyboard shortcuts

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