testutility

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcceptanceTests added in v1.4.3

func AcceptanceTests(t *testing.T, reason string)

AcceptanceTests marks this test function as a extended that require additional dependencies automatically skipped unless running in a CI environment

func CleanSnapshots added in v1.6.2

func CleanSnapshots(m *testing.M)

CleanSnapshots ensures that snapshots are relevant and sorted for consistency

func LoadJSONFixture

func LoadJSONFixture[V any](t *testing.T, path string) V

LoadJSONFixture returns the contents of the fixture file parsed as JSON

func LoadJSONFixtureWithWindowsReplacements added in v1.6.2

func LoadJSONFixtureWithWindowsReplacements[V any](
	t *testing.T,
	path string,
	replacements map[string]string,
) V

LoadJSONFixtureWithWindowsReplacements returns the contents of the fixture file parsed as JSON after applying any replacements if running on Windows

func Skip added in v1.6.2

func Skip(t *testing.T, args ...any)

Skip is equivalent to t.Log followed by t.SkipNow, but allows tracking of what snapshots are skipped so that they're not marked as obsolete

func ValueIfOnWindows added in v1.5.0

func ValueIfOnWindows(win, or string) string

Types

type Snapshot added in v1.6.2

type Snapshot struct {
	// contains filtered or unexported fields
}

func NewSnapshot added in v1.6.2

func NewSnapshot() Snapshot

NewSnapshot creates a snapshot that can be passed around within tests

func (Snapshot) MatchJSON added in v1.6.2

func (s Snapshot) MatchJSON(t *testing.T, got any)

MatchJSON asserts the existing snapshot matches what was gotten in the test, after being marshalled as JSON

func (Snapshot) MatchText added in v1.6.2

func (s Snapshot) MatchText(t *testing.T, got string)

MatchText asserts the existing snapshot matches what was gotten in the test

func (Snapshot) WithWindowsReplacements added in v1.6.2

func (s Snapshot) WithWindowsReplacements(replacements map[string]string) Snapshot

WithWindowsReplacements adds a map of strings with values that they should be replaced within before comparing the snapshot when running on Windows

Jump to

Keyboard shortcuts

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