testutil

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package testutil contains helpers for tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertErrorContains added in v0.3.1

func AssertErrorContains(t *testing.T, err error, expected error)

AssertErrorContains checks that the error contains a given sub-error.

func AssertWrappedErrorEqual added in v0.3.1

func AssertWrappedErrorEqual(t *testing.T, err error, expected error)

AssertWrappedErrorEqual checks that the innermost error equals the given expected error.

func ContainsString

func ContainsString(a []string, s string) bool

ContainsString checks if an array contains a string.

func CreateTempFile added in v0.3.1

func CreateTempFile(t *testing.T, data string) string

CreateTempFile creates a temporary file for tests with data as content.

func KillContainer added in v0.3.1

func KillContainer(containerName string) error

KillContainer stops and removes specified container.

func PaginatedSegmentsEqual added in v0.3.1

func PaginatedSegmentsEqual(t *testing.T, s1, s2 *types.PaginatedSegments)

PaginatedSegmentsEqual verifies that two paginated segment lists are equal.

func PullImage added in v0.3.1

func PullImage(imageName string) error

PullImage pulls an image from docker hub if image is not available or not up to date.

func RandomKey

func RandomKey() []byte

RandomKey returns a random byte array (with max 64 bytes)

func RandomValue

func RandomValue() []byte

RandomValue returns a random byte array (with max 1024 bytes)

func RequestJSON

func RequestJSON(h http.HandlerFunc, method, target string, payload, dst interface{}) (*httptest.ResponseRecorder, error)

RequestJSON does a request expecting a JSON response.

func RunContainer added in v0.3.1

func RunContainer(containerName string, imageName string, exposedPorts nat.PortSet, portBindings nat.PortMap) error

RunContainer reproduces docker run command.

func RunContainerWithEnv added in v0.3.1

func RunContainerWithEnv(containerName string, imageName string, envVariables []string, exposedPorts nat.PortSet, portBindings nat.PortMap) error

RunContainerWithEnv reproduces docker run command.

Types

This section is empty.

Jump to

Keyboard shortcuts

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