filetest

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

README

filetest

Creation of tree of files for testing

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LowerCaseChars, ValidChars string

Functions

func CommitDirs

func CommitDirs(tree *Dir, root string) int

func CommitNewDefaultRandomTree

func CommitNewDefaultRandomTree(t *testing.T) (string, *Dir, DirStats)

func CommitNewRandomTree

func CommitNewRandomTree(t *testing.T, altRoot string, o TreeOptions, m Mixes) (string, *Dir, DirStats)

func CommitZonedFilesMixed

func CommitZonedFilesMixed(rnd1 *xrand.Xrand, rnd2 *xrand.Xrand, files []*File, z Zones, m Mixes, root string, stage2 bool) (DirStats, []*File)

Commits files from a tree returns the files which have not been committed (excluded)

func DirStatsTable

func DirStatsTable() *format.Table

func NewCloneFileOperation

func NewCloneFileOperation(sbase, dbase string) func(*File, *File)

func NewDirMakerFactory

func NewDirMakerFactory(base string) func(*Dir)

func NewFileFromStorageFactory

func NewFileFromStorageFactory(base string) func(Entry) *File

func NewLinkFileOperation

func NewLinkFileOperation(sbase, dbase string) func(*File, *File)

func NewRandomFileFactory

func NewRandomFileFactory(rnd *xrand.Xrand, base string, sizeFactory func() int) func(*File)

func NewRandomNameFactory

func NewRandomNameFactory(rnd *xrand.Xrand, sizeFactory func() int, charSet string) func() string

func ShuffleFiles

func ShuffleFiles(rnd *xrand.Xrand, f []*File)

func TempDir

func TempDir(t *testing.T, altName string) string

Types

type Dir

type Dir struct {
	Entry
	Files []*File
	Dirs  []*Dir
}

func NewDirFromStorage

func NewDirFromStorage(base string) *Dir

func NewDirFromStorageFiltered

func NewDirFromStorageFiltered(base string, fileFilter func(e Entry) bool) *Dir

func NewRandomTree

func NewRandomTree(rnd *xrand.Xrand, o TreeOptions) *Dir

func NewRandomTree2

func NewRandomTree2(rnd *xrand.Xrand, o TreeOptions) (*Dir, func() string)

returns also the name factory

func (*Dir) AllDirsMap

func (d *Dir) AllDirsMap() map[string]*Dir

func (*Dir) AllDirsSlice

func (d *Dir) AllDirsSlice() []*Dir

func (*Dir) AllFilesMap

func (d *Dir) AllFilesMap() map[string]*File

func (*Dir) AllFilesSlice

func (d *Dir) AllFilesSlice() []*File

func (*Dir) Compare

func (d *Dir) Compare(o *Dir) bool

func (*Dir) Dump

func (d *Dir) Dump(outFile string)

func (*Dir) EachDir

func (d *Dir) EachDir(cb func(*Dir))

func (*Dir) EachDirRecursive

func (d *Dir) EachDirRecursive(cb func(*Dir)) (count int)

func (*Dir) EachFile

func (d *Dir) EachFile(cb func(*File))

func (*Dir) EachFileRecursive

func (d *Dir) EachFileRecursive(cb func(*File))

func (*Dir) EachRecursive

func (d *Dir) EachRecursive(fcb func(*File), dcb func(*Dir))

func (*Dir) RemoveFiles

func (d *Dir) RemoveFiles(files []*File)

Remove files by pointer

func (*Dir) Sort

func (d *Dir) Sort()

type DirFactory

type DirFactory func(parent *Dir, depth int) *Dir

func NewDirFactory

func NewDirFactory(entryFactory EntryFactory, filesFactory FilesFactory, dirsFactory DirsFactory) DirFactory

type DirStats

type DirStats struct {
	TotalFiles   int
	ClonedFiles  int
	LinkedFiles  int
	UniqueHashes int
}

func CommitFilesMixed

func CommitFilesMixed(rnd *xrand.Xrand, files []*File, m Mixes, root string) DirStats

func CommitMixed

func CommitMixed(rnd *xrand.Xrand, tree *Dir, m Mixes, root string) DirStats

func (*DirStats) AppendToTable

func (ds *DirStats) AppendToTable(t *format.Table) *format.Table

func (*DirStats) Merge

func (ds *DirStats) Merge(o DirStats)

func (DirStats) String

func (ds DirStats) String() string

type DirsFactory

type DirsFactory func(parent *Dir, depth int) []*Dir

func NewDirsFactory

func NewDirsFactory(maxDepth int, countFactory func() int) (DirsFactory, func(DirFactory))

func NullDirsFactory

func NullDirsFactory() DirsFactory

type Entry

type Entry struct {
	Parent *Dir
	Name   string
}

func (*Entry) Path

func (e *Entry) Path() string

func (*Entry) PathFrom

func (e *Entry) PathFrom(base string) string

type EntryFactory

type EntryFactory func(parent *Dir) Entry

func NewEntryFactory

func NewEntryFactory(nameFactory func() string) EntryFactory

func NullEntryFactory

func NullEntryFactory() EntryFactory

type File

type File struct {
	Entry
	Hash []byte
}

func (*File) String

func (f *File) String() string

type FileFactory

type FileFactory func(parent *Dir) *File

func NewFileFactory

func NewFileFactory(entryFactory EntryFactory) FileFactory

type FilesFactory

type FilesFactory func(parent *Dir) []*File

func NewFilesFactory

func NewFilesFactory(fileFactory FileFactory, countFactory func() int) FilesFactory

func NullFilesFactory

func NullFilesFactory() FilesFactory

type MinMax

type MinMax struct {
	Min int
	Max int
}

type Mixes

type Mixes struct {
	MaxSize int
	// in % - what remains are unique files
	Created, Cloned, Linked int
}

func DefaultMixes

func DefaultMixes() Mixes

type TreeOptions

type TreeOptions struct {
	CharSet   string
	CharCount MinMax
	FileCount MinMax
	DirCount  MinMax
	Depth     int
}

func DefaultTreeOptions

func DefaultTreeOptions() TreeOptions

func FlatTreeOptions

func FlatTreeOptions(minFiles, maxFiles int) TreeOptions

type Zones

type Zones struct {
	// in % - what remains are not committed
	NoChange, Shuffle, Reseed int
}

func DefaultZones

func DefaultZones() Zones

Jump to

Keyboard shortcuts

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