testutil

package
v1.8.9 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package testutil provides testing utilities and helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertContains

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

AssertContains fails the test if s does not contain substr.

func AssertEqual

func AssertEqual(t *testing.T, expected, actual interface{}, msg string)

AssertEqual compares two values and fails the test if they're not equal.

func AssertError

func AssertError(t *testing.T, err error, msg string)

AssertError fails the test if err is nil.

func AssertFalse

func AssertFalse(t *testing.T, value bool, msg string)

AssertFalse fails the test if the value is not false.

func AssertJSONContains

func AssertJSONContains(t *testing.T, body []byte, key string, expected interface{})

AssertJSONContains checks if the JSON response contains expected key-value pairs.

func AssertNil

func AssertNil(t *testing.T, value interface{}, msg string)

AssertNil fails the test if the value is not nil.

func AssertNoError

func AssertNoError(t *testing.T, err error, msg string)

AssertNoError fails the test if err is not nil.

func AssertNotEqual

func AssertNotEqual(t *testing.T, notExpected, actual interface{}, msg string)

AssertNotEqual compares two values and fails the test if they're equal.

func AssertNotNil

func AssertNotNil(t *testing.T, value interface{}, msg string)

AssertNotNil fails the test if the value is nil.

func AssertStatusCode

func AssertStatusCode(t *testing.T, rr *httptest.ResponseRecorder, expected int)

AssertStatusCode checks if the response has the expected status code.

func AssertTrue

func AssertTrue(t *testing.T, value bool, msg string)

AssertTrue fails the test if the value is not true.

func NewTestRequest

func NewTestRequest(method, path string, body io.Reader) *http.Request

NewTestRequest creates a new HTTP request for testing.

func NewTestRequestWithJSON

func NewTestRequestWithJSON(t *testing.T, method, path string, data interface{}) *http.Request

NewTestRequestWithJSON creates a new HTTP request with JSON body.

func ParseJSONResponse

func ParseJSONResponse(t *testing.T, body []byte) map[string]interface{}

ParseJSONResponse parses a JSON response body into a map.

func RandomEmail

func RandomEmail() string

RandomEmail generates a random email for testing.

func RandomUUID

func RandomUUID() uuid.UUID

RandomUUID generates a random UUID for testing.

Types

This section is empty.

Jump to

Keyboard shortcuts

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