util

package
v0.0.0-...-d0bd53c Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 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)

AssertDirEqual asserts that each file located under root is byte-for-byte identical with it's test representation.

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 ...OptionAssertDirsEqual)

AssertDirsEqual asserts that each file located under root is byte-for-byte identical with another directory, and that the directory structures match.

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 OptionAssertDirsEqual

type OptionAssertDirsEqual func(*optionAssertDirsEqual)

func OptionAssertDirsEqualReplace

func OptionAssertDirsEqualReplace(regex, with string) OptionAssertDirsEqual

Apply a regexp based transformation to both the expected and actual content of each file.

Jump to

Keyboard shortcuts

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