Documentation
¶
Overview ¶
Package testutil contains common testing helpers.
Index ¶
- func AssertContains[S ~[]V, V comparable](t *testing.T, s S, v V)
- func AssertEqual(t *testing.T, got, want any)
- func AssertErrorType(t *testing.T, got, want error)
- func AssertNotContains[S ~[]V, V comparable](t *testing.T, s S, v V)
- func BuildTxtar(t *testing.T, dir string) []byte
- func ExtractTxtar(t *testing.T, ar *txtar.Archive, dir string)
- func MockHTTPClient(h http.Handler) *http.Client
- func Run(t *testing.T, glob string, f func(t *testing.T, match string))
- func RunGolden(t *testing.T, glob string, f func(t *testing.T, match string) []byte, ...)
- func UnmarshalJSON[V any](t *testing.T, b []byte) V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertContains ¶
func AssertContains[S ~[]V, V comparable](t *testing.T, s S, v V)
AssertContains fails the test if v is not present in s.
func AssertEqual ¶
AssertEqual compares two values and if they differ, fails the test and prints the difference between them.
func AssertErrorType ¶ added in v0.1.4
AssertErrorType asserts that the got error is of the same type as the want error. It does not compare error messages or values, only the types.
func AssertNotContains ¶
func AssertNotContains[S ~[]V, V comparable](t *testing.T, s S, v V)
AssertNotContains fails the test if v is present in s.
func BuildTxtar ¶
BuildTxtar constructs a txtar archive from contents of dir.
func ExtractTxtar ¶
ExtractTxtar extracts a txtar archive to dir.
func MockHTTPClient ¶
MockHTTPClient returns a http.Client that serves all requests made through it from handler h.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.