Documentation
¶
Overview ¶
Package fakeobj provides a fake object for testing. such as fake fs.File, fs.FileInfo, fs.DirEntry etc.
Index ¶
- type Clock
- type DirEntry
- type FileInfo
- func (f *FileInfo) Close() error
- func (f *FileInfo) IsDir() bool
- func (f *FileInfo) ModTime() time.Time
- func (f *FileInfo) Mode() fs.FileMode
- func (f *FileInfo) Name() string
- func (f *FileInfo) Read(p []byte) (int, error)
- func (f *FileInfo) Reset() *FileInfo
- func (f *FileInfo) Size() int64
- func (f *FileInfo) Stat() (fs.FileInfo, error)
- func (f *FileInfo) Sys() any
- func (f *FileInfo) WithBody(s string) *FileInfo
- func (f *FileInfo) WithMtime(mt time.Time) *FileInfo
- type IOWriter
- type Reader
- type Writer
- func (w *Writer) Close() error
- func (w *Writer) Flush() error
- func (w *Writer) ResetGet() string
- func (w *Writer) SetErrOnClose() *Writer
- func (w *Writer) SetErrOnFlush() *Writer
- func (w *Writer) SetErrOnSync() *Writer
- func (w *Writer) SetErrOnWrite() *Writer
- func (w *Writer) Sync() error
- func (w *Writer) Write(p []byte) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶ added in v0.7.3
type Clock struct {
// contains filtered or unexported fields
}
Clock mock time clock for test
func NewClock ¶ added in v0.7.3
NewClock create a mock clock instance from layout "2006-01-02 15:04:05"
Example:
tc := NewClock("2023-01-01 12:00:00")
tc.Add(time.Second * 15)
ds := tc.Datetime() // "2023-01-01 12:00:15"
type DirEntry ¶
type DirEntry struct {
Dir bool
Nam string // basename
Mod fs.FileMode
Fi fs.FileInfo
Err error // for test info error
}
DirEntry implements the fs.DirEntry
func NewDirEntry ¶
NewDirEntry create a fs.DirEntry
type FileInfo ¶
type FileInfo struct {
Dir bool
Nam string // basename
Mod fs.FileMode
Mt time.Time
// Path full path
Path string
Contents string
CloseErr error
// contains filtered or unexported fields
}
FileInfo implements the fs.FileInfo, fs.File
func (*FileInfo) Size ¶
Size returns the length in bytes for regular files; system-dependent for others.
type IOWriter ¶
type IOWriter struct {
Buf []byte
// ErrOnWrite return error on write, useful for testing
ErrOnWrite bool
}
IOWriter only implements the io.Writer
type Reader ¶
type Reader struct {
byteutil.Buffer
// ErrOnRead return error on read, useful for testing
ErrOnRead bool
}
Reader implements the io.Reader, io.Closer
type Writer ¶
type Writer struct {
byteutil.Buffer
// ErrOnWrite return error on write, useful for testing
ErrOnWrite bool
// ErrOnFlush return error on flush, useful for testing
ErrOnFlush bool
// ErrOnSync return error on flush, useful for testing
ErrOnSync bool
// ErrOnClose return error on close, useful for testing
ErrOnClose bool
}
Writer implements the io.Writer, stdio.Flusher, io.Closer.
Click to show internal directories.
Click to hide internal directories.