Documentation
¶
Overview ¶
Package filesystem provides a filesystem interface and implementations
Index ¶
- type FileSystem
- type MockFileSystem
- func (m *MockFileSystem) Exists(path string) (bool, error)
- func (m *MockFileSystem) Open(name string) (io.ReadCloser, error)
- func (m *MockFileSystem) ReadFile(name string) ([]byte, error)
- func (m *MockFileSystem) Remove(name string) error
- func (m *MockFileSystem) Rename(oldpath, newpath string) error
- func (m *MockFileSystem) Stat(name string) (fs.FileInfo, error)
- func (m *MockFileSystem) WriteFile(name string, data []byte, perm fs.FileMode) error
- type OS
- func (OS) Exists(path string) (bool, error)
- func (OS) Open(name string) (io.ReadCloser, error)
- func (OS) ReadFile(name string) ([]byte, error)
- func (OS) Remove(name string) error
- func (OS) Rename(oldpath, newpath string) error
- func (OS) Stat(name string) (fs.FileInfo, error)
- func (OS) WriteFile(name string, data []byte, perm fs.FileMode) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileSystem ¶
type FileSystem interface {
Stat(name string) (fs.FileInfo, error)
ReadFile(name string) ([]byte, error)
WriteFile(name string, data []byte, perm fs.FileMode) error
Remove(name string) error
Rename(oldpath, newpath string) error
Open(name string) (io.ReadCloser, error)
Exists(path string) (bool, error)
}
FileSystem defines the interface for filesystem operations used by the artifact manager.
type MockFileSystem ¶
type MockFileSystem struct {
Files map[string][]byte
StatErr error
ReadErr error
WriteErr error
RemoveErr error
RenameErr error
OpenErr error
WriteCalls []writeCall
RemoveCalls []string
RenameCalls []renameCall
// contains filtered or unexported fields
}
MockFileSystem implements FileSystem for testing.
func NewMockFileSystem ¶
func NewMockFileSystem() *MockFileSystem
NewMockFileSystem creates a new mock filesystem.
func (*MockFileSystem) Exists ¶
func (m *MockFileSystem) Exists(path string) (bool, error)
Exists checks if a file exists in the mock filesystem.
func (*MockFileSystem) Open ¶
func (m *MockFileSystem) Open(name string) (io.ReadCloser, error)
Open opens the named file for reading and returns an io.ReadCloser.
func (*MockFileSystem) ReadFile ¶
func (m *MockFileSystem) ReadFile(name string) ([]byte, error)
ReadFile reads and returns the contents of the named file.
func (*MockFileSystem) Remove ¶
func (m *MockFileSystem) Remove(name string) error
Remove deletes the named file from the mock filesystem.
func (*MockFileSystem) Rename ¶
func (m *MockFileSystem) Rename(oldpath, newpath string) error
Rename renames (moves) oldpath to newpath in the mock filesystem.
type OS ¶
type OS struct{}
OS implements FileSystem using the real os package.
func (OS) Open ¶
func (OS) Open(name string) (io.ReadCloser, error)
Open opens the file at the given path.