Documentation ¶
Overview ¶
Package lysclient contains types and functions to help test a REST API which was created using lys functions.
Index ¶
- func DoToValue[T any](client http.Client, method string, targetUrl string) (val T, err error)
- func DoToValueTester[T any](h http.Handler, method string, targetUrl string) (val T, err error)
- func GetArray[T any](client http.Client, targetUrl string) (arr []T, err error)
- func GetArrayTester[T any](h http.Handler, targetUrl string) (arr []T, err error)
- func GetItems(client http.Client, targetUrl string) (items []map[string]any, err error)
- func GetItemsTester(h http.Handler, targetUrl string) (items []map[string]any, err error)
- func MustDoToValue[T any](t testing.TB, h http.Handler, method string, targetUrl string) (val T)
- func MustGetArray[T any](t testing.TB, h http.Handler, targetUrl string) (arr []T)
- func MustGetFile(t testing.TB, h http.Handler, targetUrl string)
- func MustGetItems(t testing.TB, h http.Handler, targetUrl string) (items []map[string]any)
- func MustPostToValue[inT, outT any](t testing.TB, h http.Handler, method string, targetUrl string, item inT) (val outT)
- func PostToValue[inT, outT any](client http.Client, method string, targetUrl string, item inT) (val outT, err error)
- func PostToValueTester[inT, outT any](h http.Handler, method string, targetUrl string, item inT) (val outT, err error)
- type ArrayResp
- type ItemAResp
- type ValueResp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoToValueTester ¶
DoToValueTester sends a request without a body to targetUrl using a test handler. It expects a T in response
func GetArrayTester ¶
GetArrayTester GETs the target Url using a test handler. It expects an array of T in response
func GetItemsTester ¶
GetItemsTester GETs the target Url using a test handler. It expects an array of items in response
func MustDoToValue ¶
MustDoToValue sends a request without a body to targetUrl using a test handler. It expects a T in response and will fail on any error
func MustGetArray ¶
MustGetArray GETs the target Url using a test handler. It expects an array of T in response and will fail on any error
func MustGetFile ¶ added in v0.1.5
MustGetFile GETs the target Url using a test handler. It expects a response with file output headers and will fail on any error
func MustGetItems ¶
MustGetItems GETs the target Url using a test handler. It expects an array of items in response and will fail on any error
func MustPostToValue ¶
func MustPostToValue[inT, outT any](t testing.TB, h http.Handler, method string, targetUrl string, item inT) (val outT)
MustPostToValue sends a POST/PUT/PATCH request to targetUrl using a test handler with an inT as the body. It expects an outT in response and will fail on any error
Types ¶
type ArrayResp ¶
type ArrayResp[T any] struct { Status string `json:"status"` Data []T `json:"data"` ErrDescription string `json:"err_description"` }
ArrayResp is expected when StdResponse returns an array of T