nop

package
v0.32.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EOFChan = make(chan interface{})

EOFChan can be closed to simulate reading the end of a file. The MockLine value will be returned with simulated end-of-file behavior.

View Source
var MockLine = []byte("mock line\n")

MockLine can be used for setting the return value of a call to Read() or ReadLine(). The set value will be returned unless Reader is initialized with a MockReader value that indicates returning an error.

View Source
var MsgChan = make(chan []byte)

MsgChan can be used to set a read message value. The call to Read or ReadLine will block until a mock message is send on MsgChan. This way both the value and timing of a read call can be controlled. This can be useful when testing.

The reader only listens on MsgChan if len(MockLine) is 0.

If EOFChan is closed then and a message is written to MsgChan the reader may behave as if it reached an end-of-file or it may return the MsgChan message. If it is desired to return a message with end-of-file behavior then make sure MockLine is set with the desired return value.

Functions

func ListFiles

func ListFiles(pth string) ([]stat.Stats, error)

ListFiles will return a single stat.Stats record whose path is the same as pth.

if pth has 'err' in the first part of the path then no stats will be returned along with an instance of error.

func Stat added in v0.5.0

func Stat(pth string) (stat.Stats, error)

Stat can be used as a mock stat for testing. The following are supported mocks error, err, stat_error or stat_err - return an error when called stat_dir - identifies the path as a directory

Types

type Reader

type Reader struct {
	MockReadMode string
	// contains filtered or unexported fields
}

func NewReader

func NewReader(pth string) (*Reader, error)

func (*Reader) Close

func (r *Reader) Close() (err error)

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Read will return n as len(MockLine) or length of MsgChan bytes.

func (*Reader) ReadLine

func (r *Reader) ReadLine() (ln []byte, err error)

func (*Reader) Stats

func (r *Reader) Stats() stat.Stats

type Writer

type Writer struct {
	MockWriteMode string
	// contains filtered or unexported fields
}

Writer is a no-operation writer useful for testing.

func NewWriter

func NewWriter(pth string) (*Writer, error)

func (*Writer) Abort

func (w *Writer) Abort() error

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Stats

func (w *Writer) Stats() stat.Stats

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

func (*Writer) WriteLine

func (w *Writer) WriteLine(ln []byte) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL