filesystemtest

package
v1.16.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileContentMap

type FileContentMap map[string]string

FileContentMap specifies files that should be created as part of a parser test.

Keys are slash-delimited paths.

type TestDir

type TestDir struct {
	// contains filtered or unexported fields
}

TestDir is a temporary directory for use in testing.

func NewTestDir

func NewTestDir(t *testing.T, opts ...TestDirOpt) *TestDir

NewTestDir constructs a new temporary test directory.

The test directory is automatically cleaned at the end of the test.

func (TestDir) FilePaths

func (d TestDir) FilePaths(filePaths ...string) reader.FilePaths

FilePaths returns a collection of absolute file paths along with the absolute and relative paths of the root directory of the TestDir.

filePaths is a list of slash-delimited paths relative to the test directory root.

func (TestDir) Root

func (d TestDir) Root() cmpath.Absolute

Root returns the absolute path to the root directory of the TestDir.

type TestDirOpt

type TestDirOpt func(t *testing.T, testDir cmpath.Absolute)

TestDirOpt performs setup on the test directory in question.

func Chmod

func Chmod(file string, perm os.FileMode) TestDirOpt

Chmod changes the permissions of the passed path to perm.

file is a slash-delimited path relative to the test directory root.

func Dir

func Dir(dir string) TestDirOpt

Dir creates a directory inside the test directory if it does not exist.

dir is a slash-delimited relative path.

func DirContents

func DirContents(contentMap FileContentMap) TestDirOpt

DirContents is a convenience method for writing many files inside the test directory.

func FileContents

func FileContents(file string, contents string) TestDirOpt

FileContents writes a file called subPath with contents inside the test directory.

file is a slash-delimited path relative to the test directory root.

Jump to

Keyboard shortcuts

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