Documentation ¶
Overview ¶
Package testutil provides utilities for testing the network package.
Index ¶
Constants ¶
const ( // DefaultTimeout is the default timeout for running a server. DefaultTimeout = time.Minute )
Variables ¶
This section is empty.
Functions ¶
func GetDockerPID ¶
GetDockerPID returns the PID of a docker container.
func RunDockerServer ¶
func RunDockerServer(t testing.TB, serverName, dockerPath string, env []string, serverStartRegex *regexp.Regexp, timeout time.Duration, retryCount int) error
RunDockerServer is a template for running a protocols server in a docker. - serverName is a friendly name of the server we are setting (AMQP, mongo, etc.). - dockerPath is the path for the docker-compose. - env is any environment variable required for running the server. - serverStartRegex is a regex to be matched on the server logs to ensure it started correctly.
func RunHostServer ¶
func RunHostServer(t *testing.T, command []string, env []string, serverStartRegex *regexp.Regexp) bool
RunHostServer is a template for running a command on the Host. - command is the path for the command to execute. - env is any environment variable required for running the server. - serverStartRegex is a regex to be matched on the server logs to ensure it started correctly. return true on success
Types ¶
type PatternScanner ¶
type PatternScanner struct { // Once we've found the correct log, we should notify the caller. DoneChan chan struct{} // contains filtered or unexported fields }
PatternScanner is a helper to scan logs for a given pattern.
func NewScanner ¶
func NewScanner(pattern *regexp.Regexp, doneChan chan struct{}) *PatternScanner
NewScanner returns a new instance of PatternScanner.
func (*PatternScanner) PrintLogs ¶
func (ps *PatternScanner) PrintLogs(t testing.TB)
PrintLogs writes the captured logs into the test logger.