test

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package test implements a test suite available to all file systems.

Index

Constants

View Source
const (
	UsrTest = "UsrTest" // UsrTest is used to test user access rights.
	UsrGrp  = "UsrGrp"  // UsrGrp is a member of the group GrpTest used to test default group access rights.
	UsrOth  = "UsrOth"  // UsrOth is a member of the group GrpOth used to test non-members access rights.
)
View Source
const (
	LinkError   errType = "LinkError"
	PathError   errType = "PathError"
	StringError errType = "StringError"
)

Variables

This section is empty.

Functions

func AssertInvalid added in v0.3.2

func AssertInvalid(tb testing.TB, err error, msgAndArgs ...any) bool

AssertInvalid asserts that the error is fs.ErrInvalid.

func AssertLinkError added in v0.3.2

func AssertLinkError(tb testing.TB, err error) *assertLinkError

AssertLinkError checks if err is a os.LinkError.

func AssertNoError added in v0.3.2

func AssertNoError(tb testing.TB, err error, msgAndArgs ...any) bool

AssertNoError asserts that there is no error (err == nil).

func AssertPanic added in v0.3.2

func AssertPanic(tb testing.TB, funcName string, f func())

AssertPanic checks that function f panics.

func AssertPathError added in v0.3.2

func AssertPathError(tb testing.TB, err error) *assertPathError

AssertPathError checks if err is a fs.PathError.

func FileNilPtr added in v0.3.2

func FileNilPtr(t *testing.T, f avfs.File)

FileNilPtr test calls to File methods when f is a nil File.

func RequireNoError added in v0.3.2

func RequireNoError(tb testing.TB, err error, msgAndArgs ...any)

RequireNoError require that a function returned no error.

Types

type GroupInfo added in v0.3.2

type GroupInfo struct {
	Name string
}

GroupInfo contains information to create a test group.

func GroupInfos added in v0.3.2

func GroupInfos() []*GroupInfo

GroupInfos returns a GroupInfo slice describing the test groups.

type PermFunc added in v0.3.2

type PermFunc func(path string) error

PermFunc returns an error depending on the permissions of the user and the file mode on the path.

type PermOptions added in v0.3.2

type PermOptions struct {
	IgnoreOp    bool // IgnoreOp ignores the Op field comparison of fs.PathError or os.LinkError structs.
	IgnorePath  bool // IgnorePath ignores the Path, Old or New field comparison of fs.PathError or os.LinkError errors.
	CreateFiles bool // CreateFiles creates files instead of directories.
}

PermOptions are options for running the tests.

type PermTests added in v0.3.2

type PermTests struct {
	// contains filtered or unexported fields
}

PermTests regroups all tests for a specific function.

func (*PermTests) Test added in v0.3.2

func (pts *PermTests) Test(t *testing.T, permFunc PermFunc)

Test generates or tests the golden file of the permissions for a specific function.

type RaceResult added in v0.3.0

type RaceResult uint8

RaceResult defines the type of result expected from a race test.

const (
	// RaceNoneOk expects that all the results will return an error.
	RaceNoneOk RaceResult = iota + 1

	// RaceOneOk expects that only one result will be without error.
	RaceOneOk

	// RaceAllOk expects that all results will be without error.
	RaceAllOk

	// RaceUndefined does not expect anything (unpredictable results).
	RaceUndefined
)

type Suite added in v0.3.2

type Suite struct {
	// contains filtered or unexported fields
}

Suite is a test suite for virtual file systems and identity managers.

func NewSuiteFS added in v0.3.2

func NewSuiteFS(tb testing.TB, vfsSetup, vfsTest avfs.VFSBase) *Suite

NewSuiteFS creates a new test suite for a file system.

func NewSuiteIdm added in v0.3.2

func NewSuiteIdm(tb testing.TB, idm avfs.IdentityMgr) *Suite

NewSuiteIdm creates a new test suite for an identity manager.

func (*Suite) BenchAll added in v0.3.2

func (ts *Suite) BenchAll(b *testing.B)

BenchAll runs all benchmarks.

func (*Suite) BenchCreate added in v0.3.2

func (ts *Suite) BenchCreate(b *testing.B, testDir string)

BenchCreate benchmarks Create function.

func (*Suite) BenchFileRead added in v0.3.2

func (ts *Suite) BenchFileRead(b *testing.B, testDir string)

func (*Suite) BenchFileWrite added in v0.3.2

func (ts *Suite) BenchFileWrite(b *testing.B, testDir string)

func (*Suite) BenchMkdir added in v0.3.2

func (ts *Suite) BenchMkdir(b *testing.B, testDir string)

BenchMkdir benchmarks Mkdir function.

func (*Suite) BenchOpenFile added in v0.3.2

func (ts *Suite) BenchOpenFile(b *testing.B, testDir string)

BenchOpenFile benchmarks OpenFile function.

func (*Suite) BenchRemove added in v0.3.2

func (ts *Suite) BenchRemove(b *testing.B, testDir string)

BenchRemove benchmarks Remove function.

func (*Suite) CreateGroups added in v0.3.2

func (ts *Suite) CreateGroups(tb testing.TB, suffix string) (groups []avfs.GroupReader)

CreateGroups creates and returns test groups with a suffix appended to each group. Errors are ignored if the group already exists.

func (*Suite) CreateUsers added in v0.3.2

func (ts *Suite) CreateUsers(tb testing.TB, suffix string) (users []avfs.UserReader)

CreateUsers creates and returns test users with a suffix appended to each user. Errors are ignored if the user or his home directory already exists.

func (*Suite) NewPermTests added in v0.3.2

func (ts *Suite) NewPermTests(t *testing.T, testDir, funcName string) *PermTests

NewPermTests creates and returns a new environment for permissions test.

func (*Suite) NewPermTestsWithOptions added in v0.3.2

func (ts *Suite) NewPermTestsWithOptions(t *testing.T, testDir, funcName string, options *PermOptions) *PermTests

NewPermTestsWithOptions creates and returns a new environment for permissions test with options.

func (*Suite) RaceCreate added in v0.3.2

func (ts *Suite) RaceCreate(t *testing.T, testDir string)

RaceCreate tests data race conditions for Create.

func (*Suite) RaceCreateTemp added in v0.3.2

func (ts *Suite) RaceCreateTemp(t *testing.T, testDir string)

RaceCreateTemp tests data race conditions for CreateTemp.

func (*Suite) RaceFileClose added in v0.3.2

func (ts *Suite) RaceFileClose(t *testing.T, testDir string)

RaceFileClose tests data race conditions for File.Close.

func (*Suite) RaceMkdir added in v0.3.2

func (ts *Suite) RaceMkdir(t *testing.T, testDir string)

RaceMkdir tests data race conditions for Mkdir.

func (*Suite) RaceMkdirAll added in v0.3.2

func (ts *Suite) RaceMkdirAll(t *testing.T, testDir string)

RaceMkdirAll tests data race conditions for MkdirAll.

func (*Suite) RaceMkdirRemoveAll added in v0.3.2

func (ts *Suite) RaceMkdirRemoveAll(t *testing.T, testDir string)

RaceMkdirRemoveAll test data race conditions for MkdirAll and RemoveAll.

func (*Suite) RaceMkdirTemp added in v0.3.2

func (ts *Suite) RaceMkdirTemp(t *testing.T, testDir string)

RaceMkdirTemp tests data race conditions for MkdirTemp.

func (*Suite) RaceOpen added in v0.3.2

func (ts *Suite) RaceOpen(t *testing.T, testDir string)

RaceOpen tests data race conditions for Open.

func (*Suite) RaceOpenFile added in v0.3.2

func (ts *Suite) RaceOpenFile(t *testing.T, testDir string)

RaceOpenFile tests data race conditions for OpenFile.

func (*Suite) RaceOpenFileExcl added in v0.3.2

func (ts *Suite) RaceOpenFileExcl(t *testing.T, testDir string)

RaceOpenFileExcl tests data race conditions for OpenFile with O_EXCL flag.

func (*Suite) RaceRemove added in v0.3.2

func (ts *Suite) RaceRemove(t *testing.T, testDir string)

RaceRemove tests data race conditions for Remove.

func (*Suite) RaceRemoveAll added in v0.3.2

func (ts *Suite) RaceRemoveAll(t *testing.T, testDir string)

RaceRemoveAll tests data race conditions for RemoveAll.

func (*Suite) RunBenchmarks added in v0.3.2

func (ts *Suite) RunBenchmarks(b *testing.B, userName string, BenchFuncs ...func(b *testing.B, testDir string))

RunBenchmarks runs all benchmark functions specified as user userName.

func (*Suite) RunTests added in v0.3.2

func (ts *Suite) RunTests(t *testing.T, userName string, testFuncs ...func(t *testing.T, testDir string))

RunTests runs all test functions specified as user userName.

func (*Suite) TestAbs added in v0.3.2

func (ts *Suite) TestAbs(t *testing.T, testDir string)

TestAbs test Abs function.

func (*Suite) TestAdminGroupUser added in v0.3.2

func (ts *Suite) TestAdminGroupUser(t *testing.T)

TestAdminGroupUser tests AdminGroup and AdminUser.

func (*Suite) TestBase added in v0.3.2

func (ts *Suite) TestBase(t *testing.T, _ string)

TestBase tests Base function.

func (*Suite) TestChdir added in v0.3.2

func (ts *Suite) TestChdir(t *testing.T, testDir string)

TestChdir tests Chdir and Getwd functions.

func (*Suite) TestChmod added in v0.3.2

func (ts *Suite) TestChmod(t *testing.T, testDir string)

TestChmod tests Chmod function.

func (*Suite) TestChown added in v0.3.2

func (ts *Suite) TestChown(t *testing.T, testDir string)

TestChown tests Chown function.

func (*Suite) TestChroot added in v0.3.2

func (ts *Suite) TestChroot(t *testing.T, testDir string)

TestChroot tests Chroot function.

func (*Suite) TestChtimes added in v0.3.2

func (ts *Suite) TestChtimes(t *testing.T, testDir string)

TestChtimes tests Chtimes function.

func (*Suite) TestClean added in v0.3.2

func (ts *Suite) TestClean(t *testing.T, _ string)

TestClean tests Clean function.

func (*Suite) TestClone added in v0.3.2

func (ts *Suite) TestClone(t *testing.T, _ string)

TestClone tests Clone function.

func (*Suite) TestCopyFile added in v0.3.2

func (ts *Suite) TestCopyFile(t *testing.T, testDir string)

TestCopyFile tests avfs.CopyFile function.

func (*Suite) TestCreate added in v0.3.2

func (ts *Suite) TestCreate(t *testing.T, testDir string)

TestCreate tests Create function.

func (*Suite) TestCreateHomeDir added in v0.3.2

func (ts *Suite) TestCreateHomeDir(t *testing.T, _ string)

TestCreateHomeDir tests that the user home directory exists and has the correct permissions.

func (*Suite) TestCreateSystemDirs added in v0.3.2

func (ts *Suite) TestCreateSystemDirs(t *testing.T, testDir string)

TestCreateSystemDirs tests CreateSystemDirs function.

func (*Suite) TestCreateTemp added in v0.3.2

func (ts *Suite) TestCreateTemp(t *testing.T, testDir string)

TestCreateTemp tests CreateTemp function.

func (*Suite) TestDir added in v0.3.2

func (ts *Suite) TestDir(t *testing.T, _ string)

TestDir tests Dir function.

func (*Suite) TestDirExists added in v0.3.2

func (ts *Suite) TestDirExists(t *testing.T, testDir string)

TestDirExists tests avfs.DirExists function.

func (ts *Suite) TestEvalSymlink(t *testing.T, testDir string)

TestEvalSymlink tests EvalSymlink function.

func (*Suite) TestExists added in v0.3.2

func (ts *Suite) TestExists(t *testing.T, testDir string)

TestExists tests avfs.Exists function.

func (*Suite) TestFile added in v0.3.2

func (ts *Suite) TestFile(t *testing.T)

func (*Suite) TestFileChdir added in v0.3.2

func (ts *Suite) TestFileChdir(t *testing.T, testDir string)

TestFileChdir tests File.Chdir function.

func (*Suite) TestFileChmod added in v0.3.2

func (ts *Suite) TestFileChmod(t *testing.T, testDir string)

TestFileChmod tests File.Chmod function.

func (*Suite) TestFileChown added in v0.3.2

func (ts *Suite) TestFileChown(t *testing.T, testDir string)

TestFileChown tests File.Chown function.

func (*Suite) TestFileCloseRead added in v0.3.2

func (ts *Suite) TestFileCloseRead(t *testing.T, testDir string)

TestFileCloseRead tests File.Close function for read only files.

func (*Suite) TestFileCloseWrite added in v0.3.2

func (ts *Suite) TestFileCloseWrite(t *testing.T, testDir string)

TestFileCloseWrite tests File.Close function for read/write files.

func (*Suite) TestFileFd added in v0.3.2

func (ts *Suite) TestFileFd(t *testing.T, testDir string)

TestFileFd tests File.Fd function.

func (*Suite) TestFileName added in v0.3.2

func (ts *Suite) TestFileName(t *testing.T, testDir string)

TestFileName tests File.Name function.

func (*Suite) TestFileRead added in v0.3.2

func (ts *Suite) TestFileRead(t *testing.T, testDir string)

TestFileRead tests File.Read function.

func (*Suite) TestFileReadAt added in v0.3.2

func (ts *Suite) TestFileReadAt(t *testing.T, testDir string)

TestFileReadAt tests File.ReadAt function.

func (*Suite) TestFileReadDir added in v0.3.2

func (ts *Suite) TestFileReadDir(t *testing.T, testDir string)

TestFileReadDir tests File.ReadDir function.

func (*Suite) TestFileReaddirnames added in v0.3.2

func (ts *Suite) TestFileReaddirnames(t *testing.T, testDir string)

TestFileReaddirnames tests File.Readdirnames function.

func (*Suite) TestFileSeek added in v0.3.2

func (ts *Suite) TestFileSeek(t *testing.T, testDir string)

TestFileSeek tests File.Seek function.

func (*Suite) TestFileStat added in v0.3.2

func (ts *Suite) TestFileStat(t *testing.T, testDir string)

TestFileStat tests File.Stat function.

func (*Suite) TestFileSync added in v0.3.2

func (ts *Suite) TestFileSync(t *testing.T, testDir string)

TestFileSync tests File.Sync function.

func (*Suite) TestFileTruncate added in v0.3.2

func (ts *Suite) TestFileTruncate(t *testing.T, testDir string)

TestFileTruncate tests File.Truncate function.

func (*Suite) TestFileWrite added in v0.3.2

func (ts *Suite) TestFileWrite(t *testing.T, testDir string)

TestFileWrite tests File.Write function.

func (*Suite) TestFileWriteAt added in v0.3.2

func (ts *Suite) TestFileWriteAt(t *testing.T, testDir string)

TestFileWriteAt tests File.WriteAt function.

func (*Suite) TestFileWriteString added in v0.3.2

func (ts *Suite) TestFileWriteString(t *testing.T, testDir string)

TestFileWriteString tests File.WriteString function.

func (*Suite) TestFileWriteTime added in v0.3.2

func (ts *Suite) TestFileWriteTime(t *testing.T, testDir string)

TestFileWriteTime checks that modification time is updated on write operations.

func (*Suite) TestFromToSlash added in v0.3.2

func (ts *Suite) TestFromToSlash(t *testing.T, _ string)

TestFromToSlash tests FromSlash and ToSlash functions.

func (*Suite) TestGlob added in v0.3.2

func (ts *Suite) TestGlob(t *testing.T, testDir string)

TestGlob tests Glob function.

func (*Suite) TestGroupAddDel added in v0.3.2

func (ts *Suite) TestGroupAddDel(t *testing.T)

TestGroupAddDel tests GroupAdd and GroupDel functions.

func (*Suite) TestHashFile added in v0.3.2

func (ts *Suite) TestHashFile(t *testing.T, testDir string)

TestHashFile tests avfs.HashFile function.

func (*Suite) TestIdmAll added in v0.3.2

func (ts *Suite) TestIdmAll(t *testing.T)

TestIdmAll runs all identity manager tests.

func (*Suite) TestIsAbs added in v0.3.2

func (ts *Suite) TestIsAbs(t *testing.T, _ string)

TestIsAbs tests IsAbs function.

func (*Suite) TestIsDir added in v0.3.2

func (ts *Suite) TestIsDir(t *testing.T, testDir string)

TestIsDir tests avfs.IsDir function.

func (*Suite) TestIsEmpty added in v0.3.2

func (ts *Suite) TestIsEmpty(t *testing.T, testDir string)

TestIsEmpty tests avfs.IsEmpty function.

func (*Suite) TestIsPathSeparator added in v0.3.2

func (ts *Suite) TestIsPathSeparator(t *testing.T, _ string)

TestIsPathSeparator tests IsPathSeparator function.

func (*Suite) TestJoin added in v0.3.2

func (ts *Suite) TestJoin(t *testing.T, _ string)

TestJoin tests Join function.

func (*Suite) TestLchown added in v0.3.2

func (ts *Suite) TestLchown(t *testing.T, testDir string)

TestLchown tests Lchown function.

func (ts *Suite) TestLink(t *testing.T, testDir string)

TestLink tests Link function.

func (*Suite) TestLookup added in v0.3.2

func (ts *Suite) TestLookup(t *testing.T)

TestLookup tests Lookup* functions.

func (*Suite) TestLstat added in v0.3.2

func (ts *Suite) TestLstat(t *testing.T, testDir string)

TestLstat tests Lstat function.

func (*Suite) TestMatch added in v0.3.2

func (ts *Suite) TestMatch(t *testing.T, _ string)

func (*Suite) TestMkdir added in v0.3.2

func (ts *Suite) TestMkdir(t *testing.T, testDir string)

TestMkdir tests Mkdir function.

func (*Suite) TestMkdirAll added in v0.3.2

func (ts *Suite) TestMkdirAll(t *testing.T, testDir string)

TestMkdirAll tests MkdirAll function.

func (*Suite) TestMkdirTemp added in v0.3.2

func (ts *Suite) TestMkdirTemp(t *testing.T, testDir string)

TestMkdirTemp tests MkdirTemp function.

func (*Suite) TestName added in v0.3.2

func (ts *Suite) TestName(t *testing.T, _ string)

TestName tests Name function.

func (*Suite) TestOpen added in v0.3.2

func (ts *Suite) TestOpen(t *testing.T, testDir string)

TestOpen tests Open function.

func (*Suite) TestOpenFileWrite added in v0.3.2

func (ts *Suite) TestOpenFileWrite(t *testing.T, testDir string)

TestOpenFileWrite tests OpenFile function for write.

func (*Suite) TestPathSeparator added in v0.3.2

func (ts *Suite) TestPathSeparator(t *testing.T, _ string)

TestPathSeparator tests PathSeparator function.

func (*Suite) TestRace added in v0.3.2

func (ts *Suite) TestRace(t *testing.T)

TestRace tests data race conditions.

func (*Suite) TestReadDir added in v0.3.2

func (ts *Suite) TestReadDir(t *testing.T, testDir string)

TestReadDir tests ReadDir function.

func (*Suite) TestReadFile added in v0.3.2

func (ts *Suite) TestReadFile(t *testing.T, testDir string)

TestReadFile tests ReadFile function.

func (ts *Suite) TestReadlink(t *testing.T, testDir string)

TestReadlink tests Readlink function.

func (*Suite) TestRel added in v0.3.2

func (ts *Suite) TestRel(t *testing.T, _ string)

TestRel tests Rel function.

func (*Suite) TestRemove added in v0.3.2

func (ts *Suite) TestRemove(t *testing.T, testDir string)

TestRemove tests Remove function.

func (*Suite) TestRemoveAll added in v0.3.2

func (ts *Suite) TestRemoveAll(t *testing.T, testDir string)

TestRemoveAll tests RemoveAll function.

func (*Suite) TestRename added in v0.3.2

func (ts *Suite) TestRename(t *testing.T, testDir string)

TestRename tests Rename function.

func (*Suite) TestRndTree added in v0.3.2

func (ts *Suite) TestRndTree(t *testing.T, testDir string)

TestRndTree tests RndTree methods.

func (*Suite) TestSameFile added in v0.3.2

func (ts *Suite) TestSameFile(t *testing.T, testDir string)

TestSameFile tests SameFile function.

func (*Suite) TestSetUserFS added in v0.3.2

func (ts *Suite) TestSetUserFS(t *testing.T, _ string)

func (*Suite) TestSetUserIdm added in v0.3.2

func (ts *Suite) TestSetUserIdm(t *testing.T)

func (*Suite) TestSplit added in v0.3.2

func (ts *Suite) TestSplit(t *testing.T, _ string)

TestSplit tests Split function.

func (*Suite) TestSplitAbs added in v0.3.2

func (ts *Suite) TestSplitAbs(t *testing.T, _ string)

TestSplitAbs tests SplitAbs function.

func (*Suite) TestStat added in v0.3.2

func (ts *Suite) TestStat(t *testing.T, testDir string)

TestStat tests Stat function.

func (*Suite) TestSub added in v0.3.2

func (ts *Suite) TestSub(t *testing.T, testDir string)

TestSub tests Sub function.

func (ts *Suite) TestSymlink(t *testing.T, testDir string)

TestSymlink tests Symlink function.

func (*Suite) TestTempDir added in v0.3.2

func (ts *Suite) TestTempDir(t *testing.T, _ string)

TestTempDir tests TempDir function.

func (*Suite) TestToSysStat added in v0.3.2

func (ts *Suite) TestToSysStat(t *testing.T, testDir string)

TestToSysStat tests ToSysStat function.

func (*Suite) TestTruncate added in v0.3.2

func (ts *Suite) TestTruncate(t *testing.T, testDir string)

TestTruncate tests Truncate function.

func (*Suite) TestUMask added in v0.3.2

func (ts *Suite) TestUMask(t *testing.T, _ string)

TestUMask tests SetUMask and UMask functions.

func (*Suite) TestUser added in v0.3.2

func (ts *Suite) TestUser(t *testing.T, _ string)

TestUser tests User function.

func (*Suite) TestUserAddDel added in v0.3.2

func (ts *Suite) TestUserAddDel(t *testing.T)

TestUserAddDel tests UserAdd and UserDel functions.

func (*Suite) TestUtils added in v0.3.2

func (ts *Suite) TestUtils(t *testing.T)

func (*Suite) TestVFS added in v0.3.2

func (ts *Suite) TestVFS(t *testing.T)

func (*Suite) TestVFSAll added in v0.3.2

func (ts *Suite) TestVFSAll(t *testing.T)

TestVFSAll runs all file system tests.

func (*Suite) TestVolume added in v0.3.2

func (ts *Suite) TestVolume(t *testing.T, _ string)

TestVolume tests VolumeAdd, VolumeDelete and VolumeList functions.

func (*Suite) TestWalkDir added in v0.3.2

func (ts *Suite) TestWalkDir(t *testing.T, testDir string)

TestWalkDir tests WalkDir function.

func (*Suite) TestWriteFile added in v0.3.2

func (ts *Suite) TestWriteFile(t *testing.T, testDir string)

TestWriteFile tests WriteFile function.

func (*Suite) TestWriteOnReadOnlyFS added in v0.3.2

func (ts *Suite) TestWriteOnReadOnlyFS(t *testing.T, testDir string)

TestWriteOnReadOnlyFS tests all write functions of a read only file system.

func (*Suite) TestWriteString added in v0.3.2

func (ts *Suite) TestWriteString(t *testing.T, testDir string)

TestWriteString tests WriteString function.

func (*Suite) VFSSetup added in v0.3.2

func (ts *Suite) VFSSetup() avfs.VFSBase

VFSSetup returns the file system used to set up the tests.

func (*Suite) VFSTest added in v0.3.2

func (ts *Suite) VFSTest() avfs.VFSBase

VFSTest returns the file system used to run the tests.

type UserInfo added in v0.3.2

type UserInfo struct {
	Name      string
	GroupName string
}

UserInfo contains information to create a test user.

func UserInfos added in v0.3.2

func UserInfos() []*UserInfo

UserInfos returns a UserInfo slice describing the test users.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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