Documentation ¶
Overview ¶
Package xtest contains test helpers for Chronoctl.
Index ¶
- func AssertDirEqual(t testing.TB, expectedDir, actualDir string)
- func GoldenFilePath(t *testing.T, root, id string) string
- func JSONMarshalIndentedString(t *testing.T, str string) string
- func JSONMarshalIndentedValue(t *testing.T, value interface{}) string
- func JSONProtoMarshal(t *testing.T, message proto.Message) string
- func MustEqualFile(t *testing.T, expectedFilePath, data string)
- func MustReadFile(t testing.TB, fileName string, msgAndArgs ...any) string
- func MustUnmarshalJSON(t testing.TB, filename string, obj interface{})
- func RegexpEscapedPatternWithTypes(t *testing.T, input string) *regexp.Regexp
- func StructMustEqualJSONFile(t *testing.T, expectedFilePath string, data any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertDirEqual ¶
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 ¶
GoldenFilePath constructs the file path for a golden test file based on the test name, test file, and id.
func JSONMarshalIndentedString ¶
JSONMarshalIndentedString returns an indentend JSON string.
func JSONMarshalIndentedValue ¶
JSONMarshalIndentedValue returns an indentend JSON string.
func JSONProtoMarshal ¶
JSONProtoMarshal will JSONPB marshal a proto message.
func MustEqualFile ¶
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 ¶
MustReadFile reads and returns the file contents as string or fails the test if an error occurs.
func MustUnmarshalJSON ¶
MustUnmarshalJSON unmarshals a json file into obj, failing the test if an error occurs.
func RegexpEscapedPatternWithTypes ¶
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 ¶
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.