FakeDir implements a Directory that is not backed on the filesystem. This is useful for testing since the created "files" are simple bytes.Buffer that can be inspected.
type FakeDir struct { Files map[string]*FakeFile Deleted bool }
func (d *FakeDir) Delete() error
Delete doesn't remove anything, but records that the directory has been deleted.
func (d *FakeDir) NewFile(name string) (io.WriteCloser, error)
NewFile returns a new FakeFile if the filename doesn't exist already. This function will fail if the directory has already been deleted.
FakeFile is an implementation of a WriteCloser, that records what has been written in the file (in a bytes.Buffer) and if the file has been closed.
type FakeFile struct { Buffer bytes.Buffer Closed bool }
func (f *FakeFile) Close() error
Close records that the file has been closed. If the file has already been closed, an error is returned.
func (f *FakeFile) Write(p []byte) (n int, err error)
Write appends the contents of p to the Buffer. If the file has already been closed, an error is returned.