test

package
v4.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertHTTPStatus added in v4.2.0

func AssertHTTPStatus(t *testing.T, r *httptest.ResponseRecorder, expectedStatus ...int)

AssertHTTPStatus verifies that the HTTP response status is correct

func DecodeError

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

func DecodeResponse added in v4.2.0

func DecodeResponse(t *testing.T, r *httptest.ResponseRecorder, target interface{})

DecodeResponse decodes an HTTP response into a target struct.

func LoadTestFile added in v4.2.0

func LoadTestFile(t *testing.T, filePath string) (*bytes.Buffer, map[string]string)

LoadTestFile loads a test file from the testdata directory

File contents are returned as a buffer and a map for the HTTP request headers

func Request

func Request(t *testing.T, method, reqURL string, body any, headers ...map[string]string) httptest.ResponseRecorder

Request is a helper method to simplify making a HTTP request for tests.

func TmpFile added in v4.2.0

func TmpFile(t *testing.T) string

TmpFile returns the path to a unique file to be used in tests

Types

type APIResponse

type APIResponse struct {
	Links map[string]string
	Error string
}

Jump to

Keyboard shortcuts

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