Documentation
¶
Index ¶
- func CaptureStderr(fn func() error) ([]byte, error)
- func CaptureStdout(fn func() error) ([]byte, error)
- func CompareFS(a, b file.FS) error
- func CompareFileInfo(a, b file.InfoList) error
- func Contents(fs file.FS) map[string][]byte
- func FeedStdin(input string, fn func() error) error
- func NewFile(rd io.ReadCloser, info fs.FileInfo) fs.File
- func NewMockFS(opts ...FSOption) file.FS
- func WrapEmbedFS(fs embed.FS) file.FS
- type BufferCloser
- type FSOption
- type WriteFS
- func (wfs *WriteFS) Create(_ context.Context, name string, filemode fs.FileMode) (io.WriteCloser, error)
- func (wfs *WriteFS) Open(name string) (fs.File, error)
- func (wfs *WriteFS) OpenCtx(_ context.Context, name string) (fs.File, error)
- func (wfs *WriteFS) ReadFile(name string) ([]byte, error)
- func (wfs *WriteFS) ReadFileCtx(_ context.Context, name string) ([]byte, error)
- func (mfs *WriteFS) Scheme() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureStderr ¶
CaptureStderr redirects os.Stderr to a pipe, runs fn, and returns any output written to os.Stderr along with any error returned by fn. NOTE: CaptureStderr temporarily replaces os.Stderr and is not safe for concurrent use.
func CaptureStdout ¶
CaptureStdout redirects os.Stdout to a pipe, runs fn, and returns any output written to os.Stdout along with any error returned by fn. NOTE: CaptureStdout temporarily replaces os.Stdout and is not safe for concurrent use.
func CompareFS ¶
CompareFS returns nil if the two instances of fs.FS contain exactly the same files and file contents.
func CompareFileInfo ¶
func FeedStdin ¶
FeedStdin redirects os.Stdin to read from a pipe populated with input, runs fn, and restores os.Stdin. NOTE: FeedStdin temporarily replaces os.Stdin and is not safe for concurrent use.
Types ¶
type BufferCloser ¶
BufferCloser adds an io.Closer to bytes.Buffer.
func (*BufferCloser) Close ¶
func (bc *BufferCloser) Close() error
type FSOption ¶
type FSOption func(o *fsOptions)
FSOption represents an option to configure a new mock instance of fs.FS.
func FSErrorOnly ¶
FSErrorOnly requests a mock FS that always returns err.
func FSWithConstantContents ¶
FSWithConstantContents requests a mock FS that will return files of a random size (up to maxSize) with random contents.
func FSWithRandomContents ¶
FSWithRandomContents requests a mock FS that will return files of a random size (up to maxSize) with random contents.