test

package
v0.0.0-...-a1758a3 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package test provides test helpers for unit and integration tests. This code is not meant to be used outside of tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Body

func Body(t *testing.T, rr *httptest.ResponseRecorder, body string)

Body tests if a HTTP response body matches the expected values and fails t if it does not

func BoolEquals

func BoolEquals(t *testing.T, expected bool, actual bool)

BoolEquals tests if two bools match and fails t if they are not equal

func BytesEquals

func BytesEquals(t *testing.T, expected []byte, actual []byte)

BytesEquals tests if two byte arrays match and fails t if they are not equal

func DurationEquals

func DurationEquals(t *testing.T, expected time.Duration, actual time.Duration)

DurationEquals tests if two durations match and fails t if they are not equal

func FileExist

func FileExist(t *testing.T, filename string)

FileExist asserts that a file exists and fails t if it does not

func FileNotExist

func FileNotExist(t *testing.T, filename string)

FileNotExist asserts that a file does not exist and fails t if it does

func FromBase64

func FromBase64(t *testing.T, s string) []byte

FromBase64 converts a base64 string to a byte array and fails t if that fails

func Int64Equals

func Int64Equals(t *testing.T, expected int64, actual int64)

Int64Equals tests if two int64s match and fails t if they are not equal

func Response

func Response(t *testing.T, rr *httptest.ResponseRecorder, status int, body string)

Response tests if a HTTP response status code and body match the expected values and fails t if they do not

func Status

func Status(t *testing.T, rr *httptest.ResponseRecorder, status int)

Status tests if a HTTP response status code matches the expected values and fails t if it does not

func StrContains

func StrContains(t *testing.T, s string, substr string)

StrContains tests if substr is contained in s and fails t if it is not

func StrEquals

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

StrEquals tests two strings for equality and fails t if they are not equal

func WaitForOutput

func WaitForOutput(t *testing.T, rc io.ReadCloser, waitFirstLine time.Duration, waitRest time.Duration) string

WaitForOutput reads rc line by line and returns the entire contents or fails t if that fails. The function waits a period of time for the first line and then for the rest of the stream.

func WaitForPortDown

func WaitForPortDown(t *testing.T, port string)

WaitForPortDown waits up to 5s for a port to come down and fails t if that fails

func WaitForPortUp

func WaitForPortUp(t *testing.T, port string)

WaitForPortUp waits up to 7s for a port to come up and fails t if that fails

Types

This section is empty.

Jump to

Keyboard shortcuts

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