Documentation ¶
Overview ¶
Package test provides test helpers for unit and integration tests. This code is not meant to be used outside of tests.
Index ¶
- func Body(t *testing.T, rr *httptest.ResponseRecorder, body string)
- func BoolEquals(t *testing.T, expected bool, actual bool)
- func BytesEquals(t *testing.T, expected []byte, actual []byte)
- func DurationEquals(t *testing.T, expected time.Duration, actual time.Duration)
- func FileExist(t *testing.T, filename string)
- func FileNotExist(t *testing.T, filename string)
- func FromBase64(t *testing.T, s string) []byte
- func Int64Equals(t *testing.T, expected int64, actual int64)
- func Response(t *testing.T, rr *httptest.ResponseRecorder, status int, body string)
- func Status(t *testing.T, rr *httptest.ResponseRecorder, status int)
- func StrContains(t *testing.T, s string, substr string)
- func StrEquals(t *testing.T, expected string, actual string)
- func WaitForOutput(t *testing.T, rc io.ReadCloser, waitFirstLine time.Duration, ...) string
- func WaitForPortDown(t *testing.T, port string)
- func WaitForPortUp(t *testing.T, port string)
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 ¶
BoolEquals tests if two bools match and fails t if they are not equal
func BytesEquals ¶
BytesEquals tests if two byte arrays match and fails t if they are not equal
func DurationEquals ¶
DurationEquals tests if two durations match and fails t if they are not equal
func FileNotExist ¶
FileNotExist asserts that a file does not exist and fails t if it does
func FromBase64 ¶
FromBase64 converts a base64 string to a byte array and fails t if that fails
func Int64Equals ¶
Int64Equals tests if two int64s match and fails t if they are not equal
func Response ¶
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 ¶
StrContains tests if substr is contained in s and fails t if it is not
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 ¶
WaitForPortDown waits up to 5s for a port to come down and fails t if that fails
func WaitForPortUp ¶
WaitForPortUp waits up to 7s for a port to come up and fails t if that fails
Types ¶
This section is empty.