assert

package
v2.26.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 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 MinDuration added in v2.23.0

func MinDuration(t *testing.T, got time.Duration, wantMin time.Duration)

MinDuration asserts that got >= min.

func NilError

func NilError(t *testing.T, err error)

NilError asserts that an error is nil.

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