Documentation
¶
Index ¶
- func CleanSnapshots(m *testing.M)
- func IsAcceptanceTest() bool
- func LoadJSONFixture[V any](t *testing.T, path string) V
- func LoadJSONFixtureWithWindowsReplacements[V any](t *testing.T, path string, replacements map[string]string) V
- func NormalizeJSON(t *testing.T, data any) string
- func NormalizeStdStream(t *testing.T, std *bytes.Buffer) string
- func Skip(t *testing.T, args ...any)
- func SkipIfNotAcceptanceTesting(t *testing.T, reason string)
- func ValueIfOnWindows(win, or string) string
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanSnapshots ¶
CleanSnapshots ensures that snapshots are relevant and sorted for consistency
func IsAcceptanceTest ¶
func IsAcceptanceTest() bool
Access to environment variable that toggles acceptance testing execution paths Acceptance testing is "On" only when var set to "true"
func LoadJSONFixture ¶
LoadJSONFixture returns the contents of the fixture file parsed as JSON
func LoadJSONFixtureWithWindowsReplacements ¶
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 NormalizeJSON ¶
NormalizeJSON applies a series of normalizes to a buffer after being marshalled as JSON
func NormalizeStdStream ¶
NormalizeStdStream applies a series of normalizes to the buffer from a std stream like stdout and stderr
func Skip ¶
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 SkipIfNotAcceptanceTesting ¶
AcceptanceTests marks this test function as a extended that require additional dependencies automatically skipped unless running in a CI environment
func ValueIfOnWindows ¶
Types ¶
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
func NewSnapshot ¶
func NewSnapshot() Snapshot
NewSnapshot creates a snapshot that can be passed around within tests
func (Snapshot) MatchJSON ¶
MatchJSON asserts the existing snapshot matches what was gotten in the test, after being marshalled as JSON
func (Snapshot) MatchText ¶
MatchText asserts the existing snapshot matches what was gotten in the test
func (Snapshot) WithCRLFReplacement ¶
WithCRLFReplacement adds a Windows replacement for "\r\n" to "\n".
func (Snapshot) WithJSONNormalization ¶
WithJSONNormalization applies JSON normalization to the snapshot to errors and paths