util

package
v0.0.0-...-4559cbb Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertDirEqual

func AssertDirEqual(t *testing.T, root string, options ...AssertOption)

AssertDirEqual asserts that each file located under root is byte-for-byte identical with it's corresponding golden file. It also asserts on the directory structure itself.

To update files under test, use:

go test ./... -update

WARNING: Multiple AssertDirEqual should not run in the same go test. If you need to call AssertDirEqual more then once in a test, place each in a subtest:

t.Run("docs", func(t *testing.T) { util.AssertDirEqual(t, baseDocsOutDir) })
t.Run("tree", func(t *testing.T) { util.AssertDirEqual(t, basePackageTreeJSONOutDir) })

func AssertDirsEqual

func AssertDirsEqual(t *testing.T, expected, actual string, options ...AssertOption)

AssertDirsEqual asserts that the file-tree at actual matches the file-tree at expected.

If you just want to assert that a directory structure is unchanged or show updates, see AssertDirEqual. AssertDirsEqual is about showing that two already written out directories are equivalent.

func ReadFile

func ReadFile(t *testing.T, path string) string

func WriteFile

func WriteFile(t *testing.T, path, contents string)

Types

type AssertOption

type AssertOption func(*assertOptions)

func AssertOptionsPreCompareTransform

func AssertOptionsPreCompareTransform(regex, with string) AssertOption

Apply a regexp based transformation to all files before they are used in comparison..

Jump to

Keyboard shortcuts

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