iomock

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 7 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 ErrContextProbe = errors.New("iomock: context probe refuses opens")

ErrContextProbe is the error ContextProbe returns from Open.

Functions

This section is empty.

Types

type ContextProbe

type ContextProbe struct {
	Ctx context.Context
}

ContextProbe is an IO that records the context passed to Open and then fails with ErrContextProbe, so tests can check which context reaches it.

func (*ContextProbe) Open

func (p *ContextProbe) Open(ctx context.Context, _ string) (io.File, error)

func (*ContextProbe) Remove

func (p *ContextProbe) Remove(context.Context, string) error

type MockFS

type MockFS struct {
	mock.Mock
}

func (*MockFS) Create

func (m *MockFS) Create(ctx context.Context, name string) (io.FileWriter, error)

func (*MockFS) Open

func (m *MockFS) Open(_ context.Context, name string) (io.File, error)

func (*MockFS) Remove

func (m *MockFS) Remove(_ context.Context, name string) error

func (*MockFS) WriteFile

func (m *MockFS) WriteFile(ctx context.Context, name string, content []byte) error

type MockFSReadFile

type MockFSReadFile struct {
	MockFS
	ErrOnClose  bool
	ReadFileCtx context.Context
}

func (*MockFSReadFile) ReadFile

func (m *MockFSReadFile) ReadFile(ctx context.Context, name string) ([]byte, error)

type MockFile

type MockFile struct {
	Contents   *bytes.Reader
	ErrOnClose bool
	// contains filtered or unexported fields
}

func (*MockFile) Close

func (m *MockFile) Close() error

func (*MockFile) Read

func (m *MockFile) Read(p []byte) (int, error)

func (*MockFile) ReadAt

func (m *MockFile) ReadAt(p []byte, off int64) (n int, err error)

func (*MockFile) ReadFrom

func (m *MockFile) ReadFrom(r sio.Reader) (n int64, err error)

func (*MockFile) Seek

func (m *MockFile) Seek(offset int64, whence int) (n int64, err error)

func (*MockFile) Stat

func (m *MockFile) Stat() (fs.FileInfo, error)

func (*MockFile) Write

func (m *MockFile) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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