Documentation
¶
Index ¶
- func ReadDir(dirname string) ([]os.DirEntry, error)
- func ReadFile(filename string) ([]byte, error)
- func Stat(name string) (os.FileInfo, error)
- type FileSystemInterface
- type MockDirEntry
- type MockFileSystem
- func (m *MockFileSystem) AllowReadDir(path string, dirs []os.DirEntry, err error)
- func (m *MockFileSystem) AllowReadFile(path string, data []byte, err error)
- func (m *MockFileSystem) AllowStat(path string, info os.FileInfo, err error)
- func (m *MockFileSystem) ExpectReadDir(path string, dirs []os.DirEntry, err error)
- func (m *MockFileSystem) ExpectReadFile(path string, data []byte, err error)
- func (m *MockFileSystem) ExpectStat(path string, info os.FileInfo, err error)
- func (m *MockFileSystem) ReadDir(dirname string) ([]os.DirEntry, error)
- func (m *MockFileSystem) ReadFile(filename string) ([]byte, error)
- func (m *MockFileSystem) Stat(name string) (os.FileInfo, error)
- func (m *MockFileSystem) VerifyAllCalls(t *testing.T)
- type ReadDirCall
- type ReadFileCall
- type RealFileSystem
- type StatCall
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FileSystemInterface ¶
type FileSystemInterface interface {
Stat(name string) (os.FileInfo, error)
ReadDir(dirname string) ([]os.DirEntry, error)
ReadFile(filename string) ([]byte, error)
}
FileSystemInterface defines the interface for filesystem operations to enable mocking. Modeled after linuxptp-daemon's addons/intel/common.go FileSystemInterface.
type MockDirEntry ¶
MockDirEntry implements os.DirEntry for testing
func (MockDirEntry) IsDir ¶
func (m MockDirEntry) IsDir() bool
func (MockDirEntry) Name ¶
func (m MockDirEntry) Name() string
func (MockDirEntry) Type ¶
func (m MockDirEntry) Type() os.FileMode
type MockFileSystem ¶
type MockFileSystem struct {
// contains filtered or unexported fields
}
MockFileSystem is a mock implementation of FileSystemInterface for testing. Modeled after linuxptp-daemon's addons/intel/mock_test.go MockFileSystem.
func SetupMockFS ¶
func SetupMockFS() (*MockFileSystem, func())
SetupMockFS swaps the global filesystem implementation with a mock and returns a cleanup function.
func (*MockFileSystem) AllowReadDir ¶
func (m *MockFileSystem) AllowReadDir(path string, dirs []os.DirEntry, err error)
func (*MockFileSystem) AllowReadFile ¶
func (m *MockFileSystem) AllowReadFile(path string, data []byte, err error)
func (*MockFileSystem) AllowStat ¶
func (m *MockFileSystem) AllowStat(path string, info os.FileInfo, err error)
func (*MockFileSystem) ExpectReadDir ¶
func (m *MockFileSystem) ExpectReadDir(path string, dirs []os.DirEntry, err error)
func (*MockFileSystem) ExpectReadFile ¶
func (m *MockFileSystem) ExpectReadFile(path string, data []byte, err error)
func (*MockFileSystem) ExpectStat ¶
func (m *MockFileSystem) ExpectStat(path string, info os.FileInfo, err error)
func (*MockFileSystem) ReadDir ¶
func (m *MockFileSystem) ReadDir(dirname string) ([]os.DirEntry, error)
func (*MockFileSystem) ReadFile ¶
func (m *MockFileSystem) ReadFile(filename string) ([]byte, error)
func (*MockFileSystem) VerifyAllCalls ¶
func (m *MockFileSystem) VerifyAllCalls(t *testing.T)
VerifyAllCalls asserts that all expected calls were made
type ReadDirCall ¶
ReadDirCall represents an expected or allowed ReadDir call
type ReadFileCall ¶
ReadFileCall represents an expected or allowed ReadFile call
type RealFileSystem ¶
type RealFileSystem struct{}
RealFileSystem implements FileSystemInterface using real OS operations
func (*RealFileSystem) ReadDir ¶
func (fs *RealFileSystem) ReadDir(dirname string) ([]os.DirEntry, error)