testutil

package
v0.0.0-...-3bc0b6d Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertValidJSON

func AssertValidJSON(tb testing.TB, s string)

AssertValidJSON checks the given string is valid JSON.

func AssertValidJSONBytes

func AssertValidJSONBytes(tb testing.TB, b []byte)

AssertValidJSONBytes checks the given buffer is valid JSON.

func DiffBytes

func DiffBytes(tb testing.TB, got, want []byte, gotlabel, wantLabel string)

DiffBytes is a test helper that compares 2 bytes slices. If they differ, the test is failed and DiffBytes shows an hexadecimal diff (à la hexdump).

labels[0] and labels[1] can be used to personalize the title diff, instead of 'got' and 'want', respectively.

func DiffBytesWithGolden

func DiffBytesWithGolden(tb testing.TB, buf []byte, goldenFile string)

DiffBytesWithGolden is a test helper that compares some bytes with a file content whose path is provided in the 'goldenFile' argument. If -update flag is given to go test, the golden file is updated with the new content, provided by 'buf'.

func ValidJSON

func ValidJSON(s string) error

ValidJSON checks s is valid JSON.

func ValidJSONBytes

func ValidJSONBytes(b []byte) error

ValidJSONBytes checks b is valid JSON.

Types

This section is empty.

Jump to

Keyboard shortcuts

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