Documentation ¶
Index ¶
- func IsCloseFileError(err error) bool
- func IsCreateDirectoryError(err error) bool
- func IsCreateFileError(err error) bool
- func IsFileExistsError(err error) bool
- func IsOpenFileError(err error) bool
- func IsReadFileError(err error) bool
- func IsWriteFileError(err error) bool
- type FileSystem
- type MockOptions
- func MockCloseFileError(err error) MockOptions
- func MockCreateDirError(err error) MockOptions
- func MockCreateFileError(err error) MockOptions
- func MockExists(exists func(path string) bool) MockOptions
- func MockExistsError(err error) MockOptions
- func MockInput(input *bytes.Buffer) MockOptions
- func MockOpenFileError(err error) MockOptions
- func MockOutput(output *bytes.Buffer) MockOptions
- func MockPath(path string) MockOptions
- func MockReadFileError(err error) MockOptions
- func MockWriteFileError(err error) MockOptions
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCloseFileError ¶
IsCloseFileError checks if the returned error is because the file could not be closed
func IsCreateDirectoryError ¶
IsCreateDirectoryError checks if the returned error is because the directory could not be created
func IsCreateFileError ¶
IsCreateFileError checks if the returned error is because the file could not be created
func IsFileExistsError ¶
IsFileExistsError checks if the returned error is because the file could not be checked for existence
func IsOpenFileError ¶
IsOpenFileError checks if the returned error is because the file could not be opened
func IsReadFileError ¶
IsReadFileError checks if the returned error is because the file could not be read
func IsWriteFileError ¶
IsWriteFileError checks if the returned error is because the file could not be written to
Types ¶
type FileSystem ¶
type FileSystem interface { // Exists checks if the file exists Exists(path string) (bool, error) // Open opens the file and returns a self-closing io.Reader. Open(path string) (io.ReadCloser, error) // Create creates the directory and file and returns a self-closing // io.Writer pointing to that file. If the file exists, it truncates it. Create(path string) (io.Writer, error) }
FileSystem is an IO wrapper to create files
type MockOptions ¶
type MockOptions func(system *mockFileSystem)
MockOptions configure FileSystem
func MockCloseFileError ¶
func MockCloseFileError(err error) MockOptions
MockCloseFileError makes the Write method (of the io.Writer returned by FileSystem.Create) return err
func MockCreateDirError ¶
func MockCreateDirError(err error) MockOptions
MockCreateDirError makes FileSystem.Create return err
func MockCreateFileError ¶
func MockCreateFileError(err error) MockOptions
MockCreateFileError makes FileSystem.Create return err
func MockExists ¶
func MockExists(exists func(path string) bool) MockOptions
MockExists makes FileSystem.Exists use the provided function to check if the file exists
func MockExistsError ¶
func MockExistsError(err error) MockOptions
MockExistsError makes FileSystem.Exists return err
func MockInput ¶
func MockInput(input *bytes.Buffer) MockOptions
MockInput provides a buffer where the content will be read from
func MockOpenFileError ¶
func MockOpenFileError(err error) MockOptions
MockOpenFileError makes FileSystem.Open return err
func MockOutput ¶
func MockOutput(output *bytes.Buffer) MockOptions
MockOutput provides a buffer where the content will be written
func MockPath ¶
func MockPath(path string) MockOptions
MockPath ensures that the file created with this scaffold is at path
func MockReadFileError ¶
func MockReadFileError(err error) MockOptions
MockReadFileError makes the Read method (of the io.Reader returned by FileSystem.Open) return err
func MockWriteFileError ¶
func MockWriteFileError(err error) MockOptions
MockWriteFileError makes the Write method (of the io.Writer returned by FileSystem.Create) return err
type Options ¶
type Options func(system *fileSystem)
Options configure FileSystem
func DirectoryPermissions ¶
DirectoryPermissions makes FileSystem.Create use the provided directory permissions
func FilePermissions ¶
FilePermissions makes FileSystem.Create use the provided file permissions