benchttptest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package benchttptest proovides utilities for benchttp testing.

Index

Constants

This section is empty.

Variables

View Source
var RequestCmpOptions = cmp.Options{
	cmp.Transformer("Request", instantiateNilRequest),
	cmp.Transformer("Request.Header", instantiateNilHeader),
	cmp.Transformer("Request.URL", stringifyURL),
	cmpopts.IgnoreUnexported(http.Request{}, tls.ConnectionState{}),
	cmpopts.IgnoreFields(http.Request{}, unreliableRequestFields...),
}

RequestCmpOptions is the cmp.Options used to compare *http.Request. It behaves as follows:

  • Nil and empty values are considered equal

  • Fields that depend on how the request was created are ignored to avoid false negatives when comparing requests created in different ways (http.NewRequest vs httptest.NewRequest vs &http.Request{})

  • Function fields are ignored

  • Body is ignored: it is compared separately

RunnerCmpOptions is the cmp.Options used to compare benchttp.Runner. By default, it ignores unexported fields and includes RequestCmpOptions.

Functions

func AssertEqualRunners

func AssertEqualRunners(t *testing.T, x, y benchttp.Runner)

AssertEqualRunners fails t and shows a diff if a and b are not equal, as determined by RunnerCmpOptions.

func DiffRunner

func DiffRunner(x, y benchttp.Runner) string

DiffRunner returns a string showing the diff between x and y, as determined by RunnerCmpOptions.

func EqualRunners

func EqualRunners(x, y benchttp.Runner) bool

EqualRunners returns true if x and y are equal, as determined by RunnerCmpOptions.

Types

This section is empty.

Jump to

Keyboard shortcuts

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