test_utils

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultSnapshotOptions = SnapshotOption{
	UpdateSnapshots: lo.Contains([]string{"true", "1"}, os.Getenv("UPDATE_SNAPSHOTS")),
	ReadFunc: func(f io.ReadCloser) (any, error) {
		data, err := io.ReadAll(f)
		return data, err
	},
	CompareFunc: func(expected, actual any) bool {
		return cmp.Equal(expected, actual)
	},
	DiffFunc: func(expected, actual any) string {
		return cmp.Diff(expected, actual)
	},
}
View Source
var (
	MatchAnyContext = mock.MatchedBy(func(ctx context.Context) bool {
		return true
	})
)

Functions

func ParseMultiYaml

func ParseMultiYaml(data []byte) ([]map[string]interface{}, error)

func ReadMultiYaml

func ReadMultiYaml(filename string) ([]map[string]interface{}, error)

func ReadMultiYamlIO

func ReadMultiYamlIO(f io.ReadCloser) ([]map[string]interface{}, error)

func RequireEqualCmp

func RequireEqualCmp(t *testing.T, expected, actual interface{}, opts ...cmp.Option)

func SnapshotT

func SnapshotT(t *testing.T, snapshotFilePath string, actualBytes []byte, options ...zoptions.MustOption[SnapshotOption])

Types

type SnapshotOption

type SnapshotOption struct {
	UpdateSnapshots bool
	ReadFunc        func(io.ReadCloser) (any, error)
	CompareFunc     func(expected, actual any) bool
	DiffFunc        func(expected, actual any) string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳