testdirtree

package
v0.12.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package testdirtree provides utilities for creating test directory trees for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDirectoryTree

func CreateDirectoryTree(dirname string, options DirectoryTreeOptions, counters *DirectoryTreeCounters) error

CreateDirectoryTree creates a directory tree of a given depth with random files.

func CreateRandomFile

func CreateRandomFile(filePath string, options DirectoryTreeOptions, counters *DirectoryTreeCounters) error

CreateRandomFile creates a new file at the provided path with randomized contents.

func MustCreateDirectoryTree

func MustCreateDirectoryTree(t *testing.T, dirname string, options DirectoryTreeOptions)

MustCreateDirectoryTree creates a directory tree of a given depth with random files.

func MustCreateRandomFile

func MustCreateRandomFile(t *testing.T, filePath string, options DirectoryTreeOptions, counters *DirectoryTreeCounters)

MustCreateRandomFile creates a new file at the provided path with randomized contents. It will fail with a test error if the creation does not succeed.

Types

type DirectoryTreeCounters

type DirectoryTreeCounters struct {
	Files         int
	Directories   int
	Symlinks      int
	TotalFileSize int64
	MaxFileSize   int64
}

DirectoryTreeCounters stores stats about files and directories created by CreateDirectoryTree.

type DirectoryTreeOptions

type DirectoryTreeOptions struct {
	Depth                              int
	MaxSubdirsPerDirectory             int
	MaxFilesPerDirectory               int
	MaxSymlinksPerDirectory            int
	MaxFileSize                        int
	MinFileSize                        int
	MinNameLength                      int
	MaxNameLength                      int
	NonExistingSymlinkTargetPercentage int // 0..100
}

DirectoryTreeOptions lists options for CreateDirectoryTree.

func MaybeSimplifyFilesystem

func MaybeSimplifyFilesystem(o DirectoryTreeOptions) DirectoryTreeOptions

MaybeSimplifyFilesystem applies caps to the provided DirectoryTreeOptions to reduce test time on ARM.

Jump to

Keyboard shortcuts

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