testutils

package
v0.0.0-...-e652847 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LastUUID api.UUID

LastUUID contains the last UUID returned by NewUUID()

Functions

func NewUUID

func NewUUID() api.UUID

NewUUID returns a new UUID or panics

Types

type ExpectedError

type ExpectedError struct {
	MatchMessage MatchMessage
	Name         string
}

ExpectedError is the definition of an expected error

func ExpectsContains

func ExpectsContains(value string) ExpectedError

ExpectsContains returns a ExpectedError matching a partial message

func ExpectsEqual

func ExpectsEqual(value string) ExpectedError

ExpectsEqual returns a ExpectedError matching a message exactly

type MatchMessage

type MatchMessage func(string) bool

MatchMessage is a function that match a log message

type NatsTestServer

type NatsTestServer struct {
	ConnOptions nats.Options
	// contains filtered or unexported fields
}

NatsTestServer wraps a gnatsd server.Server

func InitNatsTestServer

func InitNatsTestServer(
	t *testing.T, logger xbus.Logger,
	accountStorage storage.AccountStorage,
	passwordStorage storage.PasswordStorage,
	actorStorage storage.ActorStorage,
	sessionStorage storage.SessionStorage,
	ServerCert *tls.Certificate,
) NatsTestServer

InitNatsTestServer returns a gnatsd test server

func (NatsTestServer) AuthToken

func (s NatsTestServer) AuthToken() string

AuthToken returns the auth token

func (NatsTestServer) Connect

func (s NatsTestServer) Connect(t *testing.T) *nats.Conn

Connect returns a new client connection to the server

func (NatsTestServer) IsReady

func (s NatsTestServer) IsReady() bool

IsReady returns true if the server is ready

func (NatsTestServer) Shutdown

func (s NatsTestServer) Shutdown()

Shutdown stops the server

type PortLock

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

PortLock is a locker which locks by binding to a port on the loopback IPv4 interface

func NewPortLock

func NewPortLock(port int) *PortLock

NewPortLock returns a lock for port

func (*PortLock) Lock

func (p *PortLock) Lock() error

Lock locks on port

func (*PortLock) TryLock

func (p *PortLock) TryLock() (bool, error)

TryLock acquires the lock, non-blocking

func (*PortLock) Unlock

func (p *PortLock) Unlock() error

Unlock unlocks the port lock

type TestLogger

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

TestLogger is a BusLogger for tests

func GetTestLogger

func GetTestLogger(t testing.TB) *TestLogger

GetTestLogger returns a new BusLogger for the passed testing.T

func (TestLogger) Debugf

func (m TestLogger) Debugf(format string, v ...interface{})

Debugf passes the message to T.Logf

func (*TestLogger) Errorf

func (m *TestLogger) Errorf(format string, v ...interface{})

Errorf passes the message to T.Errorf

func (*TestLogger) ExpectsError

func (m *TestLogger) ExpectsError(expectedError interface{})

ExpectsError anticipate an error and make it non-fatal to the test

func (TestLogger) Fatalf

func (m TestLogger) Fatalf(format string, v ...interface{})

Fatalf passes the message to T.Fatalf

func (TestLogger) Noticef

func (m TestLogger) Noticef(format string, v ...interface{})

Noticef passes the message to T.Logf

func (*TestLogger) SetTest

func (m *TestLogger) SetTest(t testing.TB) func()

SetTest changes the current test, and return a function to cancel the change

func (TestLogger) Tracef

func (m TestLogger) Tracef(format string, v ...interface{})

Tracef passes the message to T.Logf

func (TestLogger) VerifyExpectations

func (m TestLogger) VerifyExpectations()

VerifyExpectations enforce error expectations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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