testutils

package
v0.0.0-...-25a6cea Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CharsetUtf8 = map[string]string{"charset": "utf-8"}

Functions

func AssertAwsStringEqual

func AssertAwsStringEqual(t *testing.T, expected string, actual *string)

func AssertContentType

func AssertContentType(
	t *testing.T,
	headers textproto.MIMEHeader,
	expectedMediaType string,
	expectedParams map[string]string,
)

func AssertContentTypeAndGetParams

func AssertContentTypeAndGetParams(
	t *testing.T, headers textproto.MIMEHeader, expectedMediaType string,
) (params map[string]string)

func AssertDecodedContent

func AssertDecodedContent(t *testing.T, content io.Reader, expected string)

func AssertNextPart

func AssertNextPart(
	t *testing.T, reader *multipart.Reader, mediaType, decoded string,
)

func AssertValue

func AssertValue(t *testing.T, name, expected, actual string)

func AwsServerError

func AwsServerError(msg string) error

func CheckDockerIsRunning

func CheckDockerIsRunning() (err error)

func CleanupDockerContainer

func CleanupDockerContainer(service, containerId string) (errResult error)

func ErrorIs

func ErrorIs(err, expectedErr error) cmp.Comparison

func ErrorIsNot

func ErrorIsNot(err, unexpectedErr error) cmp.Comparison

func ExpectPanic

func ExpectPanic(t *testing.T, expectedMsg string)

func GetDecodedContent

func GetDecodedContent(t *testing.T, content io.Reader) string

func GetNextPart

func GetNextPart(
	t *testing.T, reader *multipart.Reader, mediaType string,
) io.Reader

func GetNextPartContent

func GetNextPartContent(
	t *testing.T, reader *multipart.Reader, mediaType string,
) string

func LaunchDockerContainer

func LaunchDockerContainer(
	service, localHostPort string, containerPort int, dbImage string,
) (cleanup func() error, err error)

func ParseMessage

func ParseMessage(t *testing.T, content string) (msg *mail.Message)

func ParseMultipartMessageAndBoundary

func ParseMultipartMessageAndBoundary(
	t *testing.T, content string,
) (msg *mail.Message, boundary string, partReader *multipart.Reader)

func ParseTextMessage

func ParseTextMessage(
	t *testing.T, content string,
) (msg *mail.Message, qpReader *quotedprintable.Reader)

func PickUnusedHostPort

func PickUnusedHostPort() (string, error)

func PullDockerImage

func PullDockerImage(dbImage string) error

func RandomEmail

func RandomEmail(n int, domain string) string

func TimesEqual

func TimesEqual(expectedTime, actualTime time.Time) cmp.Comparison

Types

type EndpointResolver

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

func (*EndpointResolver) AddEndpoint

func (r *EndpointResolver) AddEndpoint(service, localHostPort string)

func (*EndpointResolver) CreateEndpoint

func (r *EndpointResolver) CreateEndpoint(service string) (string, error)

func (*EndpointResolver) ResolveEndpoint

func (r *EndpointResolver) ResolveEndpoint(
	service, region string, options ...interface{},
) (endpoint aws.Endpoint, err error)

type ErrWriter

type ErrWriter struct {
	Buf     io.Writer
	ErrorOn string
	Err     error
}

func (*ErrWriter) Write

func (ew *ErrWriter) Write(b []byte) (int, error)

type Logs

type Logs struct {
	Builder strings.Builder
}

func NewLogs

func NewLogs() (*Logs, *log.Logger)

func (*Logs) AssertContains

func (tl *Logs) AssertContains(t *testing.T, message string)

func (*Logs) Logs

func (tl *Logs) Logs() string

func (*Logs) NewLogger

func (tl *Logs) NewLogger() *log.Logger

func (*Logs) Reset

func (tl *Logs) Reset()

type TestHeader

type TestHeader struct {
	mail.Header
}

func (*TestHeader) Assert

func (th *TestHeader) Assert(t *testing.T, name string, expected string)

Jump to

Keyboard shortcuts

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