iotest
v1.0.0
github.com/redforks/testing/iotest
Documentation
pkg.go.dev ↗Variables
ErrWriter
var (
// Error object returned by ErrorWriter
ErrWriter = errors.New("ErrorWrite: no more writes")
)
Functions
ErrorWriter
func ErrorWriter(n int) byteWriterWriter
Returns a writer that would error after writes n bytes
NewSlowWriter
func NewSlowWriter(w io.Writer, delay time.Duration) io.Writer
Create a slow writer. Slow writer wrap a exist writer, each write operation will delay a while.
Types
TempTestDir
type TempTestDir string
Create a temporary directory used for testing, the directory deleted automatically in spork/testing/reset.
NewTempTestDir
func NewTempTestDir() TempTestDir
Create a new TempTestDir.
TempTestDir.Close
func (ttd TempTestDir) Close()
Close() delete the whole temp directory, including the files and sub directories in it. Ignore any IO error. Normally do not need call .Close(), it automatically called in spork/testing/reset.
TempTestDir.Dir
func (ttd TempTestDir) Dir() string
The absolute path of temp directory.