test

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockFS

type MockFS struct {
	// OpenFunc allows for customizing the behavior of the Open method.
	OpenFunc func(name string) (fs.File, error)
}

MockFS provides a mock implementation of the fs.FS interface.

func (*MockFS) Open

func (m *MockFS) Open(name string) (fs.File, error)

Open calls the OpenFunc field of the MockFS struct.

type MockFile

type MockFile struct {
	// Content simulates the content of the file. Read operations will return data from this slice.
	Content []byte

	// CloseFunc is an optional function that simulates closing the file. It allows users to
	// specify custom behavior for the Close method, including simulating errors.
	CloseFunc func() error
	// contains filtered or unexported fields
}

MockFile is a mock implementation of the fs.File interface.

func (*MockFile) Close

func (mf *MockFile) Close() error

Close simulates closing the file.

func (*MockFile) Read

func (mf *MockFile) Read(b []byte) (int, error)

Read attempts to read bytes from the MockFile into b. It simulates reading by copying bytes from mf.Content into b, starting from the current read position. Returns the number of bytes read and an error, if any. Once all content has been read, subsequent calls will return io.EOF.

func (*MockFile) Stat

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

Jump to

Keyboard shortcuts

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