testutils

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CIDWelcomeDocs = "QmQPeNsJPyVWPFDVHb77w8G42Fvo15z4bG2X8D2GhfbSXc"
	CIDEmptyDir    = "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn"
)

Variables

View Source
var (
	AlphabetEasy = []rune("abcdefghijklmnopqrstuvwxyz01234567890-_")
	AlphabetHard = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890!@#$%^&*()-_+= ;.,<>'\"[]{}() ")
)

Functions

func AssertStringContainsOneOf added in v0.24.0

func AssertStringContainsOneOf(t *testing.T, str string, ss ...string)

func FindUp

func FindUp(name, dir string) string

Searches for a file in a dir, then the parent dir, etc. If the file is not found, an empty string is returned.

func FloatTruncate added in v0.24.0

func FloatTruncate(value float64, decimalPlaces int) float64

func ForEachPar added in v0.24.0

func ForEachPar[T any](s []T, f func(T))

ForEachPar invokes f in a new goroutine for each element of s and waits for all to complete.

func MustOpen

func MustOpen(name string) *os.File

func PreviewStr

func PreviewStr(s string) string

PreviewStr returns a preview of s, which is a prefix for logging that avoids dumping a huge string to logs.

func RandomBytes

func RandomBytes(n int) []byte

func RandomStr added in v0.24.0

func RandomStr(n int) string

func RequiresDocker

func RequiresDocker(t *testing.T)

func RequiresExpensive

func RequiresExpensive(t *testing.T)

func RequiresFUSE

func RequiresFUSE(t *testing.T)

func RequiresLinux

func RequiresLinux(t *testing.T)

func RequiresPlugins

func RequiresPlugins(t *testing.T)

func SplitLines

func SplitLines(s string) []string

func StrCat

func StrCat(args ...interface{}) []string

StrCat takes a bunch of strings or string slices and concats them all together into one string slice. If an arg is not one of those types, this panics. If an arg is an empty string, it is dropped.

func ToJSONStr

func ToJSONStr(m JSONObj) string

func URLStrToMultiaddr

func URLStrToMultiaddr(u string) multiaddr.Multiaddr

URLStrToMultiaddr converts a URL string like http://localhost:80 to a multiaddr.

Types

type JSONObj

type JSONObj map[string]interface{}

type RandFiles added in v0.24.0

type RandFiles struct {
	Rand         *rand.Rand
	FileSize     int // the size per file.
	FilenameSize int
	Alphabet     []rune // for filenames

	FanoutDepth int // how deep the hierarchy goes
	FanoutFiles int // how many files per dir
	FanoutDirs  int // how many dirs per dir

	RandomSize   bool // randomize file sizes
	RandomFanout bool // randomize fanout numbers
}

func NewRandFiles added in v0.24.0

func NewRandFiles() *RandFiles

func (*RandFiles) RandomFilename added in v0.24.0

func (r *RandFiles) RandomFilename(length int) string

func (*RandFiles) WriteRandomDir added in v0.24.0

func (r *RandFiles) WriteRandomDir(root string, depth int) error

func (*RandFiles) WriteRandomFile added in v0.24.0

func (r *RandFiles) WriteRandomFile(root string) error

func (*RandFiles) WriteRandomFiles added in v0.24.0

func (r *RandFiles) WriteRandomFiles(root string, depth int) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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