Documentation
¶
Overview ¶
Package fstest runs test suites against a target FS. See fstest.FS() to get started.
Index ¶
- func FS(tb testing.TB, options FSOptions)
- func File(tb testing.TB, options FSOptions)
- func TestBaseChmod(tb testing.TB, o FSOptions)
- func TestBaseChtimes(tb testing.TB, o FSOptions)
- func TestBaseCreate(tb testing.TB, o FSOptions)
- func TestBaseMkdir(tb testing.TB, o FSOptions)
- func TestChmod(tb testing.TB, o FSOptions)
- func TestChtimes(tb testing.TB, o FSOptions)
- func TestConcurrentCreate(tb testing.TB, o FSOptions)
- func TestConcurrentFileRead(tb testing.TB, o FSOptions)
- func TestConcurrentFileStat(tb testing.TB, o FSOptions)
- func TestConcurrentFileWrite(tb testing.TB, o FSOptions)
- func TestConcurrentMkdir(tb testing.TB, o FSOptions)
- func TestConcurrentMkdirAll(tb testing.TB, o FSOptions)
- func TestConcurrentOpenFileCreate(tb testing.TB, o FSOptions)
- func TestConcurrentRemove(tb testing.TB, o FSOptions)
- func TestCreate(tb testing.TB, o FSOptions)
- func TestFileClose(tb testing.TB, o FSOptions)
- func TestFileRead(tb testing.TB, o FSOptions)
- func TestFileReadAt(tb testing.TB, o FSOptions)
- func TestFileReadDir(tb testing.TB, o FSOptions)
- func TestFileSeek(tb testing.TB, o FSOptions)
- func TestFileStat(tb testing.TB, o FSOptions)
- func TestFileSync(tb testing.TB, o FSOptions)
- func TestFileTruncate(tb testing.TB, o FSOptions)
- func TestFileWrite(tb testing.TB, o FSOptions)
- func TestFileWriteAt(tb testing.TB, o FSOptions)
- func TestMkdir(tb testing.TB, o FSOptions)
- func TestMkdirAll(tb testing.TB, o FSOptions)
- func TestOpen(tb testing.TB, o FSOptions)
- func TestOpenFile(tb testing.TB, o FSOptions)
- func TestReadFile(tb testing.TB, o FSOptions)
- func TestRemove(tb testing.TB, o FSOptions)
- func TestRemoveAll(tb testing.TB, o FSOptions)
- func TestRename(tb testing.TB, o FSOptions)
- func TestStat(tb testing.TB, o FSOptions)
- type Constraints
- type FSOptions
- type Facets
- type SetupFS
- type TestSetup
- type TestSetupFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestBaseChmod ¶
func TestBaseChtimes ¶
func TestBaseCreate ¶
func TestBaseMkdir ¶
func TestChmod ¶
Chmod changes the mode of the named file to mode. If the file is a symbolic link, it changes the mode of the link's target. If there is an error, it will be of type *PathError.
A different subset of the mode bits are used, depending on the operating system.
fstest will only check permission bits
func TestChtimes ¶
Chtimes changes the access and modification times of the named file, similar to the Unix utime() or utimes() functions.
The underlying filesystem may truncate or round the values to a less precise time unit. If there is an error, it will be of type *PathError.
func TestConcurrentCreate ¶
func TestConcurrentFileRead ¶
func TestConcurrentFileStat ¶
func TestConcurrentFileWrite ¶
func TestConcurrentMkdir ¶
func TestConcurrentMkdirAll ¶
func TestConcurrentRemove ¶
func TestCreate ¶
TestCreate verifies fs.Create().
Create creates or truncates the named file. If the file already exists, it is truncated. If the file does not exist, it is created with mode 0666 (before umask). If successful, methods on the returned File can be used for I/O; the associated file descriptor has mode O_RDWR. If there is an error, it will be of type *PathError.
func TestFileClose ¶
func TestFileRead ¶
func TestFileReadAt ¶
func TestFileReadDir ¶
func TestFileSeek ¶
func TestFileStat ¶
func TestFileSync ¶
func TestFileTruncate ¶
func TestFileWrite ¶
func TestFileWriteAt ¶
func TestMkdir ¶
TestMkdir verifies fs.Mkdir().
Mkdir creates a new directory with the specified name and permission bits (before umask). If there is an error, it will be of type *PathError.
func TestMkdirAll ¶
MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm (before umask) are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil.
func TestOpen ¶
Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. If there is an error, it will be of type *PathError.
func TestOpenFile ¶
OpenFile is the generalized open call; most users will use Open or Create instead. It opens the named file with specified flag (O_RDONLY etc.). If the file does not exist, and the O_CREATE flag is passed, it is created with mode perm (before umask). If successful, methods on the returned File can be used for I/O. If there is an error, it will be of type *PathError.
func TestReadFile ¶
func TestRemove ¶
Remove removes the named file or (empty) directory. If there is an error, it will be of type *PathError.
func TestRemoveAll ¶
RemoveAll removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error). If there is an error, it will be of type *PathError.
func TestRename ¶
TestRename verifies fs.Rename().
Rename renames (moves) oldpath to newpath. If newpath already exists and is not a directory, Rename replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories. If there is an error, it will be of type *LinkError.
Types ¶
type Constraints ¶ added in v0.1.3
type Constraints struct {
// FileModeMask disables mode checks on the specified bits. Defaults to checking all bits (0).
FileModeMask hackpadfs.FileMode
}
Constraints limits tests to a reduced set of assertions due to non-standard behavior. Avoid setting any of these.
type FSOptions ¶
type FSOptions struct {
// Name of this test run. Required.
Name string
// TestFS sets up the current sub-test and returns an FS. Required if SetupFS is not set.
// Must support running in parallel with other tests. For a global FS like 'osfs', return a sub-FS rooted in a temporary directory for each call to TestFS.
// Cleanup should be run via tb.Cleanup() tasks.
TestFS func(tb testing.TB) SetupFS
// Setup returns an FS that can prepare files and a commit function. Required of TestFS is not set.
// When commit is called, SetupFS's changes must be copied into a new test FS (like TestFS does) and return it.
//
// In many cases, this is not needed and all preparation can be done with only the TestFS() option.
// However, in more niche file systems like a read-only FS, it is necessary to commit files to a normal FS, then copy them into a read-only store.
Setup TestSetup
// Contraints limits tests to a reduced set of assertions. Avoid setting any of these options.
// For example, setting FileModeMask limits FileMode assertions on a file's Stat() result.
//
// NOTE: This MUST NOT be used lightly. Any custom constraints severely impairs the quality of a standardized file system.
Constraints Constraints
// ShouldSkip determines if the current test with features defined by 'facets' should be skipped.
// ShouldSkip() is intended for handling undefined behavior in existing systems outside one's control.
//
// NOTE: This MUST NOT be used lightly. Any custom skips severely impairs the quality of a standardized file system.
ShouldSkip func(facets Facets) bool
}
FSOptions contains required and optional settings for running fstest against your FS.
type Facets ¶ added in v0.1.3
type Facets struct {
// Name is the full name of the current test
Name string
}
Facets contains details for the current test. Used in FSOptions.ShouldSkip() to inspect and skip tests that should not apply to this FS.
type SetupFS ¶
type SetupFS interface {
hackpadfs.FS
hackpadfs.OpenFileFS
hackpadfs.MkdirFS
hackpadfs.ChmodFS
hackpadfs.ChtimesFS
}
SetupFS is an FS that supports the baseline interfaces for creating files/directories and changing their metadata. This FS is used to initialize a test's environment.