assert

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package assert implements common assertions used in go-httbin's unit tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BodyContains

func BodyContains(t testing.TB, resp *http.Response, needle string)

BodyContains asserts that a response body contains a specific substring.

func BodyEquals

func BodyEquals(t testing.TB, resp *http.Response, want string)

BodyEquals asserts that a response body is equal to a specific string.

func BodySize

func BodySize(t testing.TB, resp *http.Response, want int)

BodySize asserts that a response body is a specific size.

func Contains

func Contains(t testing.TB, s string, needle string, description string)

Contains asserts that needle is found in the given string.

func ContentType

func ContentType(t testing.TB, resp *http.Response, contentType string)

ContentType asserts that a response has a specific Content-Type header value.

func DeepEqual

func DeepEqual[T any](t testing.TB, got, want T, msg string, arg ...any)

DeepEqual asserts that two values are deeply equal.

func DurationRange

func DurationRange(t testing.TB, got, minVal, maxVal time.Duration)

DurationRange asserts that a duration is within a specific range.

func Equal

func Equal[T comparable](t testing.TB, got, want T, msg string, arg ...any)

Equal asserts that two values are equal.

func Error

func Error(t testing.TB, got, expected error, alternates ...error)

Error asserts that an error matches an expected error or any one of a list of expected errors.

func Header(t testing.TB, resp *http.Response, key, want string)

Header asserts that a header key has a specific value in a response.

func NilError

func NilError(t testing.TB, err error)

NilError asserts that an error is nil.

func RoughlyEqual

func RoughlyEqual[T number](t testing.TB, got, want T, epsilon T)

RoughlyEqual asserts that a numeric value is within a certain tolerance.

func StatusCode

func StatusCode(t testing.TB, resp *http.Response, code int)

StatusCode asserts that a response has a specific status code.

Types

This section is empty.

Jump to

Keyboard shortcuts

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