testutils

package
v5.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: GPL-3.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTestFileReadInterrupted = errors.New("test file read interrupted")
)

Functions

This section is empty.

Types

type CountingFS

type CountingFS struct {
	afero.Fs
	// contains filtered or unexported fields
}

CountingFS wraps an afero filesystem and counts the files opened and closed through it

func NewCountingFS

func NewCountingFS(fs afero.Fs) *CountingFS

func (*CountingFS) Create

func (fs *CountingFS) Create(name string) (afero.File, error)

Create creates a file and counts it

func (*CountingFS) GetCounts

func (fs *CountingFS) GetCounts() (opened, closed int)

GetCounts returns how many files were opened and closed. A file closed more than once counts once, so equal counts mean every file was closed

func (*CountingFS) Open

func (fs *CountingFS) Open(name string) (afero.File, error)

Open opens a file and counts it

func (*CountingFS) OpenFile

func (fs *CountingFS) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)

OpenFile opens a file with the given flags and counts it

func (*CountingFS) Unclosed

func (fs *CountingFS) Unclosed() int

Unclosed returns how many files are still open

type FailingFS

type FailingFS struct {
	afero.Fs
	FailPath  string
	FailAfter int64
}

FailingFS is an afero.Fs that returns ErrTestFileReadInterrupted when the file at failPath is read, after failAfter bytes have been read from that file. Reads all other files normally.

func (*FailingFS) Open

func (fs *FailingFS) Open(name string) (afero.File, error)

type FailingFile

type FailingFile struct {
	afero.File
	// contains filtered or unexported fields
}

func (*FailingFile) Read

func (f *FailingFile) Read(p []byte) (int, error)

Jump to

Keyboard shortcuts

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