test

package
v5.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertHTTPStatus

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

AssertHTTPStatus verifies that the HTTP response status is correct

func DecodeResponse

func DecodeResponse(t *testing.T, r *httptest.ResponseRecorder, target any)

DecodeResponse decodes an HTTP response into a target struct.

func LoadTestFile

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

func TmpFile(t *testing.T) string

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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