testtools

package
v0.22.3 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFiles

func CheckFiles(t *testing.T, dir string, files []FileSpec)

CheckFiles checks that files in "dir" exist and have the content specified in "files". Files not listed in "files" are not tested, so extra files are allowed.

func CreateFiles

func CreateFiles(t *testing.T, files []FileSpec) (dir string, cleanup func())

CreateFiles creates a directory of test files. This is a more compact alternative to testdata directories. CreateFiles returns a canonical path to the directory and a function to call to clean up the directory after the test.

func NewTestConfig

func NewTestConfig(t *testing.T, cexts []config.Configurer, langs []language.Language, args []string) *config.Config

NewTestConfig returns a Config used for tests in any language extension. cexts is a list of configuration extensions to use. langs is a list of language extensions to use (languages are also configuration extensions, but it may be convenient to keep them separate). args is a list of command line arguments to apply. NewTestConfig calls t.Fatal if any error is encountered while processing flags.

Types

type FileSpec

type FileSpec struct {
	// Path is a slash-separated path relative to the test directory. If Path
	// ends with a slash, it indicates a directory should be created
	// instead of a file.
	Path string

	// Symlink is a slash-separated path relative to the test directory. If set,
	// it indicates a symbolic link should be created with this path instead of a
	// file.
	Symlink string

	// Content is the content of the test file.
	Content string

	// NotExist asserts that no file at this path exists.
	// It is only valid in CheckFiles.
	NotExist bool
}

FileSpec specifies the content of a test file.

Jump to

Keyboard shortcuts

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