xtest

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package xtest contains test helpers for Chronoctl.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertDirEqual

func AssertDirEqual(t testing.TB, expectedDir, actualDir string)

AssertDirEqual verifies the contents of files in the specified directories match. Note: It does not support recursing into subdirectoreis, and assumes a flat list of files.

func GoldenFilePath

func GoldenFilePath(t *testing.T, root, id string) string

GoldenFilePath constructs the file path for a golden test file based on the test name, test file, and id.

func JSONMarshalIndentedString

func JSONMarshalIndentedString(t *testing.T, str string) string

JSONMarshalIndentedString returns an indentend JSON string.

func JSONMarshalIndentedValue

func JSONMarshalIndentedValue(t *testing.T, value interface{}) string

JSONMarshalIndentedValue returns an indentend JSON string.

func JSONProtoMarshal

func JSONProtoMarshal(t *testing.T, message proto.Message) string

JSONProtoMarshal will JSONPB marshal a proto message.

func MustEqualFile

func MustEqualFile(t *testing.T, expectedFilePath, data string)

MustEqualFile compares pass in data to a recorded file. If updateGoldenFiles flag is enabled, the recorded json is updated before the comparison. Ex: go test ./src/to/tests/... -update-golden-files or Ex: UPDATE_GOLDEN_FILES=1 go test ./src/to/tests/...

func MustReadFile

func MustReadFile(t testing.TB, fileName string, msgAndArgs ...any) string

MustReadFile reads and returns the file contents as string or fails the test if an error occurs.

func MustUnmarshalJSON

func MustUnmarshalJSON(t testing.TB, filename string, obj interface{})

MustUnmarshalJSON unmarshals a json file into obj, failing the test if an error occurs.

func RegexpEscapedPatternWithTypes

func RegexpEscapedPatternWithTypes(t *testing.T, input string) *regexp.Regexp

RegexpEscapedPatternWithTypes returns a regexp pattern with specific type aliases replaced with their regexp patterns and all other characters escaped. The supported types are:

  • string: $uuid pattern: "?[a-zA-Z0-9-]{32,36}"?

func StructMustEqualJSONFile

func StructMustEqualJSONFile(t *testing.T, expectedFilePath string, data any)

StructMustEqualJSONFile compares passed in data to recorded json. If updateGoldenFiles flag is enabled, the recorded json is updated before the comparison. Ex: go test ./src/to/tests/... --update-golden-files

Types

This section is empty.

Jump to

Keyboard shortcuts

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