Documentation

Overview

    Package mockfs mocks interactions with the filesystem.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    type File

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

      File provides a mock implementation of the sys.File interface.

      func (*File) Close

      func (f *File) Close() error

        Close implements the interface for sys.File.

        func (*File) Read

        func (f *File) Read(p []byte) (n int, err error)

          Read implements the interface for sys.File.

          type FileInfo

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

            FileInfo provides a mock implementation of the os.FileInfo interface.

            func (*FileInfo) FailClose

            func (f *FileInfo) FailClose() *FileInfo

              FailClose will mark a file to fail when its Close method is called.

              func (*FileInfo) FailOpen

              func (f *FileInfo) FailOpen() *FileInfo

                FailOpen will return an error for Open calls at the current path.

                func (*FileInfo) FailRead

                func (f *FileInfo) FailRead() *FileInfo

                  FailRead will mark a file to fail when its Read method is called.

                  func (*FileInfo) FailStat

                  func (f *FileInfo) FailStat() *FileInfo

                    FailStat will return an error for Lstat/Stat calls at the current path.

                    func (*FileInfo) IsDir

                    func (f *FileInfo) IsDir() bool

                      IsDir implements the interface for os.FileInfo.

                      func (*FileInfo) ModTime

                      func (f *FileInfo) ModTime() time.Time

                        ModTime implements the interface for os.FileInfo.

                        func (*FileInfo) Mode

                        func (f *FileInfo) Mode() os.FileMode

                          Mode implements the interface for os.FileInfo.

                          func (*FileInfo) Name

                          func (f *FileInfo) Name() string

                            Name implements the interface for os.FileInfo.

                            func (*FileInfo) Size

                            func (f *FileInfo) Size() int64

                              Size implements the interface for os.FileInfo.

                              func (*FileInfo) Sys

                              func (f *FileInfo) Sys() interface{}

                                Sys implements the interface for os.FileInfo.

                                type FileSystem

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

                                  FileSystem provides a configurable mock implementation of the sys.FileSystem interface.

                                  func New

                                  func New() *FileSystem

                                    New returns a mockable filesystem for testing purposes.

                                    func (*FileSystem) Lstat

                                    func (f *FileSystem) Lstat(path string) (os.FileInfo, error)

                                      Lstat implements the interface for sys.Filesystem.

                                      func (*FileSystem) Mkdir

                                      func (f *FileSystem) Mkdir(path string) *FileInfo

                                        Mkdir creates a directory at the given path, along with any necessary parent directories. If a directory already exists, then the method will exit early.

                                        WriteFile implicitly creates directories, so this method is only really useful for creating empty directories.

                                        func (*FileSystem) Open

                                        func (f *FileSystem) Open(path string) (sys.File, error)

                                          Open implements the interface for sys.Filesystem.

                                          func (*FileSystem) Stat

                                          func (f *FileSystem) Stat(path string) (os.FileInfo, error)

                                            Stat implements the interface for sys.Filesystem.

                                            func (*FileSystem) Walk

                                            func (f *FileSystem) Walk(root string, walkFn filepath.WalkFunc) error

                                              Walk implements the interface for sys.Filesystem.

                                              func (*FileSystem) WriteFile

                                              func (f *FileSystem) WriteFile(path string, data string) *FileInfo

                                                WriteFile creates a file with the given data at the specified path. It will implicitly create any parent directories as necessary.

                                                Source Files