assert

package
v2.18.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: MIT Imports: 7 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.T, resp *http.Response, needle string)

BodyContains asserts that a response body contains a specific substring.

func BodyEquals

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

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

func BodySize

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

BodySize asserts that a response body is a specific size.

func Contains added in v2.13.0

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

Contains asserts that needle is found in the given string.

func ContentType

func ContentType(t *testing.T, 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.T, got, want T, msg string, arg ...any)

DeepEqual asserts that two values are deeply equal.

func DurationRange

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

DurationRange asserts that a duration is within a specific range.

func Equal

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

Equal asserts that two values are equal.

func Error

func Error(t *testing.T, got, expected error)

Error asserts that an error is not nil.

func Header(t *testing.T, 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.T, err error)

NilError asserts that an error is nil.

func RoughlyEqual added in v2.13.2

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

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

func StatusCode

func StatusCode(t *testing.T, 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