webtest

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package webtest import some useful method to perfome assertion for testing package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Body

func Body(t *testing.T, expected string, resp *http.Response, msg ...any)

Body fetch and assert that the body of the http.Response is the same than expected

func BodyContains added in v1.2.2

func BodyContains(t *testing.T, expected string, resp *http.Response, msg ...any)

func BodyContainsStr added in v1.3.1

func BodyContainsStr(t *testing.T, expected string, body []byte, msg ...any)

func BodyDiffere

func BodyDiffere(t *testing.T, expected string, resp *http.Response)

BodyDiffere fetch and assert that the body of the http.Response differ than expected

func BodyStr added in v1.3.1

func BodyStr(t *testing.T, expected string, body []byte, msg ...any)

Body fetch and assert that the body of the http.Response is the same than expected

func DeleteAndTestAPI

func DeleteAndTestAPI(t *testing.T, url string, handler HandlerForTest)

DeleteAndTestAPI run a DELETE request before running the test handler.

func FetchBody added in v1.2.2

func FetchBody(t *testing.T, resp *http.Response) string

FetchBody return the response body.

func Header(t *testing.T, key, val string, resp *http.Response) bool

Header assert value of the given header key:vak in the htt.Response param.

func Headers

func Headers(t *testing.T, resp *http.Response, kv ...[2]string) bool

Headers assert value of the given header key:vak in the htt.Response param.

func HeadersExact added in v1.3.1

func HeadersExact(t *testing.T, resp *http.Response, kv ...[2]string) bool

Headers assert value of the given header key:vak in the htt.Response param.

func PushAndTestAPI

func PushAndTestAPI(t *testing.T, path string, content []byte, handler HandlerForTest, headers ...[2]string)

PushAndTestAPI post to an API then run the test handler. The sub method try to send an `application/json` encoded content

func RequestAndTestAPI

func RequestAndTestAPI(t *testing.T, url string, handler HandlerForTest)

RequestAndTestAPI request an API then run the test handler.

func StatusCode

func StatusCode(t *testing.T, expected int, resp *http.Response, msg ...any)

StatusCode assert the status code of the response.

Types

type HandlerForTest

type HandlerForTest = func(t *testing.T, resp *http.Response)

HandlerForTest implement the function signature used to check the req/resp

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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