Help us shape the future of Go! Take the 2026 Go Developer Survey

xfs

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirEntry added in v0.0.2

type DirEntry = fs.DirEntry

type DirEntryMock added in v0.0.2

type DirEntryMock struct {
	// InfoFunc mocks the Info method.
	InfoFunc func() (fs.FileInfo, error)

	// IsDirFunc mocks the IsDir method.
	IsDirFunc func() bool

	// NameFunc mocks the Name method.
	NameFunc func() string

	// TypeFunc mocks the Type method.
	TypeFunc func() fs.FileMode
	// contains filtered or unexported fields
}

DirEntryMock is a mock implementation of DirEntry.

func TestSomethingThatUsesDirEntry(t *testing.T) {

	// make and configure a mocked DirEntry
	mockedDirEntry := &DirEntryMock{
		InfoFunc: func() (fs.FileInfo, error) {
			panic("mock out the Info method")
		},
		IsDirFunc: func() bool {
			panic("mock out the IsDir method")
		},
		NameFunc: func() string {
			panic("mock out the Name method")
		},
		TypeFunc: func() fs.FileMode {
			panic("mock out the Type method")
		},
	}

	// use mockedDirEntry in code that requires DirEntry
	// and then make assertions.

}

func (*DirEntryMock) Info added in v0.0.2

func (mock *DirEntryMock) Info() (fs.FileInfo, error)

Info calls InfoFunc.

func (*DirEntryMock) InfoCalls added in v0.0.2

func (mock *DirEntryMock) InfoCalls() []struct {
}

InfoCalls gets all the calls that were made to Info. Check the length with:

len(mockedDirEntry.InfoCalls())

func (*DirEntryMock) IsDir added in v0.0.2

func (mock *DirEntryMock) IsDir() bool

IsDir calls IsDirFunc.

func (*DirEntryMock) IsDirCalls added in v0.0.2

func (mock *DirEntryMock) IsDirCalls() []struct {
}

IsDirCalls gets all the calls that were made to IsDir. Check the length with:

len(mockedDirEntry.IsDirCalls())

func (*DirEntryMock) Name added in v0.0.2

func (mock *DirEntryMock) Name() string

Name calls NameFunc.

func (*DirEntryMock) NameCalls added in v0.0.2

func (mock *DirEntryMock) NameCalls() []struct {
}

NameCalls gets all the calls that were made to Name. Check the length with:

len(mockedDirEntry.NameCalls())

func (*DirEntryMock) Type added in v0.0.2

func (mock *DirEntryMock) Type() fs.FileMode

Type calls TypeFunc.

func (*DirEntryMock) TypeCalls added in v0.0.2

func (mock *DirEntryMock) TypeCalls() []struct {
}

TypeCalls gets all the calls that were made to Type. Check the length with:

len(mockedDirEntry.TypeCalls())

type FS

type FS interface {

	// DirName returns the name used to create the rooted xfs.FS
	DirName() string
	// contains filtered or unexported methods
}

func Dir added in v0.0.2

func Dir(name string) FS

type FSMock

type FSMock struct {
	// DirNameFunc mocks the DirName method.
	DirNameFunc func() string

	// OpenFunc mocks the Open method.
	OpenFunc func(name string) (fs.File, error)

	// ReadDirFunc mocks the ReadDir method.
	ReadDirFunc func(name string) ([]fs.DirEntry, error)

	// ReadFileFunc mocks the ReadFile method.
	ReadFileFunc func(name string) ([]byte, error)

	// StatFunc mocks the Stat method.
	StatFunc func(name string) (fs.FileInfo, error)
	// contains filtered or unexported fields
}

FSMock is a mock implementation of FS.

func TestSomethingThatUsesFS(t *testing.T) {

	// make and configure a mocked FS
	mockedFS := &FSMock{
		DirNameFunc: func() string {
			panic("mock out the DirName method")
		},
		OpenFunc: func(name string) (fs.File, error) {
			panic("mock out the Open method")
		},
		ReadDirFunc: func(name string) ([]fs.DirEntry, error) {
			panic("mock out the ReadDir method")
		},
		ReadFileFunc: func(name string) ([]byte, error) {
			panic("mock out the ReadFile method")
		},
		StatFunc: func(name string) (fs.FileInfo, error) {
			panic("mock out the Stat method")
		},
	}

	// use mockedFS in code that requires FS
	// and then make assertions.

}

func (*FSMock) DirName added in v0.0.3

func (mock *FSMock) DirName() string

DirName calls DirNameFunc.

func (*FSMock) DirNameCalls added in v0.0.3

func (mock *FSMock) DirNameCalls() []struct {
}

DirNameCalls gets all the calls that were made to DirName. Check the length with:

len(mockedFS.DirNameCalls())

func (*FSMock) Open

func (mock *FSMock) Open(name string) (fs.File, error)

Open calls OpenFunc.

func (*FSMock) OpenCalls

func (mock *FSMock) OpenCalls() []struct {
	Name string
}

OpenCalls gets all the calls that were made to Open. Check the length with:

len(mockedFS.OpenCalls())

func (*FSMock) ReadDir added in v0.0.2

func (mock *FSMock) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir calls ReadDirFunc.

func (*FSMock) ReadDirCalls added in v0.0.2

func (mock *FSMock) ReadDirCalls() []struct {
	Name string
}

ReadDirCalls gets all the calls that were made to ReadDir. Check the length with:

len(mockedFS.ReadDirCalls())

func (*FSMock) ReadFile added in v0.0.2

func (mock *FSMock) ReadFile(name string) ([]byte, error)

ReadFile calls ReadFileFunc.

func (*FSMock) ReadFileCalls added in v0.0.2

func (mock *FSMock) ReadFileCalls() []struct {
	Name string
}

ReadFileCalls gets all the calls that were made to ReadFile. Check the length with:

len(mockedFS.ReadFileCalls())

func (*FSMock) Stat added in v0.0.2

func (mock *FSMock) Stat(name string) (fs.FileInfo, error)

Stat calls StatFunc.

func (*FSMock) StatCalls added in v0.0.2

func (mock *FSMock) StatCalls() []struct {
	Name string
}

StatCalls gets all the calls that were made to Stat. Check the length with:

len(mockedFS.StatCalls())

type File

type File = fs.File

type FileInfo

type FileInfo = fs.FileInfo

type FileInfoMock

type FileInfoMock struct {
	// IsDirFunc mocks the IsDir method.
	IsDirFunc func() bool

	// ModTimeFunc mocks the ModTime method.
	ModTimeFunc func() time.Time

	// ModeFunc mocks the Mode method.
	ModeFunc func() fs.FileMode

	// NameFunc mocks the Name method.
	NameFunc func() string

	// SizeFunc mocks the Size method.
	SizeFunc func() int64

	// SysFunc mocks the Sys method.
	SysFunc func() any
	// contains filtered or unexported fields
}

FileInfoMock is a mock implementation of FileInfo.

func TestSomethingThatUsesFileInfo(t *testing.T) {

	// make and configure a mocked FileInfo
	mockedFileInfo := &FileInfoMock{
		IsDirFunc: func() bool {
			panic("mock out the IsDir method")
		},
		ModTimeFunc: func() time.Time {
			panic("mock out the ModTime method")
		},
		ModeFunc: func() fs.FileMode {
			panic("mock out the Mode method")
		},
		NameFunc: func() string {
			panic("mock out the Name method")
		},
		SizeFunc: func() int64 {
			panic("mock out the Size method")
		},
		SysFunc: func() any {
			panic("mock out the Sys method")
		},
	}

	// use mockedFileInfo in code that requires FileInfo
	// and then make assertions.

}

func (*FileInfoMock) IsDir

func (mock *FileInfoMock) IsDir() bool

IsDir calls IsDirFunc.

func (*FileInfoMock) IsDirCalls

func (mock *FileInfoMock) IsDirCalls() []struct {
}

IsDirCalls gets all the calls that were made to IsDir. Check the length with:

len(mockedFileInfo.IsDirCalls())

func (*FileInfoMock) ModTime

func (mock *FileInfoMock) ModTime() time.Time

ModTime calls ModTimeFunc.

func (*FileInfoMock) ModTimeCalls

func (mock *FileInfoMock) ModTimeCalls() []struct {
}

ModTimeCalls gets all the calls that were made to ModTime. Check the length with:

len(mockedFileInfo.ModTimeCalls())

func (*FileInfoMock) Mode

func (mock *FileInfoMock) Mode() fs.FileMode

Mode calls ModeFunc.

func (*FileInfoMock) ModeCalls

func (mock *FileInfoMock) ModeCalls() []struct {
}

ModeCalls gets all the calls that were made to Mode. Check the length with:

len(mockedFileInfo.ModeCalls())

func (*FileInfoMock) Name

func (mock *FileInfoMock) Name() string

Name calls NameFunc.

func (*FileInfoMock) NameCalls

func (mock *FileInfoMock) NameCalls() []struct {
}

NameCalls gets all the calls that were made to Name. Check the length with:

len(mockedFileInfo.NameCalls())

func (*FileInfoMock) Size

func (mock *FileInfoMock) Size() int64

Size calls SizeFunc.

func (*FileInfoMock) SizeCalls

func (mock *FileInfoMock) SizeCalls() []struct {
}

SizeCalls gets all the calls that were made to Size. Check the length with:

len(mockedFileInfo.SizeCalls())

func (*FileInfoMock) Sys

func (mock *FileInfoMock) Sys() any

Sys calls SysFunc.

func (*FileInfoMock) SysCalls

func (mock *FileInfoMock) SysCalls() []struct {
}

SysCalls gets all the calls that were made to Sys. Check the length with:

len(mockedFileInfo.SysCalls())

type FileMock

type FileMock struct {
	// CloseFunc mocks the Close method.
	CloseFunc func() error

	// ReadFunc mocks the Read method.
	ReadFunc func(bytes []byte) (int, error)

	// StatFunc mocks the Stat method.
	StatFunc func() (fs.FileInfo, error)
	// contains filtered or unexported fields
}

FileMock is a mock implementation of File.

func TestSomethingThatUsesFile(t *testing.T) {

	// make and configure a mocked File
	mockedFile := &FileMock{
		CloseFunc: func() error {
			panic("mock out the Close method")
		},
		ReadFunc: func(bytes []byte) (int, error) {
			panic("mock out the Read method")
		},
		StatFunc: func() (fs.FileInfo, error) {
			panic("mock out the Stat method")
		},
	}

	// use mockedFile in code that requires File
	// and then make assertions.

}

func (*FileMock) Close

func (mock *FileMock) Close() error

Close calls CloseFunc.

func (*FileMock) CloseCalls

func (mock *FileMock) CloseCalls() []struct {
}

CloseCalls gets all the calls that were made to Close. Check the length with:

len(mockedFile.CloseCalls())

func (*FileMock) Read

func (mock *FileMock) Read(bytes []byte) (int, error)

Read calls ReadFunc.

func (*FileMock) ReadCalls

func (mock *FileMock) ReadCalls() []struct {
	Bytes []byte
}

ReadCalls gets all the calls that were made to Read. Check the length with:

len(mockedFile.ReadCalls())

func (*FileMock) Stat

func (mock *FileMock) Stat() (fs.FileInfo, error)

Stat calls StatFunc.

func (*FileMock) StatCalls

func (mock *FileMock) StatCalls() []struct {
}

StatCalls gets all the calls that were made to Stat. Check the length with:

len(mockedFile.StatCalls())

Jump to

Keyboard shortcuts

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