util

package
v2.6.20 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteCountDecimal added in v2.4.0

func ByteCountDecimal(b int64) string

func GenerateRandomBytes

func GenerateRandomBytes(n int) []byte

func MakeToken

func MakeToken(n int) string

func MustParseAddr

func MustParseAddr(str string) ma.Multiaddr

func NewClonedContext

func NewClonedContext(ctx context.Context) context.Context

NewClonedContext returns a context with the same Values but not inherited cancelation.

func NewResolvedPath

func NewResolvedPath(s string) (path.Resolved, error)

func ParsePath

func ParsePath(p path.Path) (resolved path.Resolved, fpath string, err error)

func RunFlaky

func RunFlaky(t *testing.T, f func(ft *FlakyT))

RunFlaky runs a flaky test with retries.

func ToValidName

func ToValidName(str string) (name string, ok bool)

Types

type FlakyT

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

FlakyT provides retry mechanisms to test.

func NewFlakyT

func NewFlakyT(t *testing.T) *FlakyT

NewFlakyT creates a new FlakyT.

func (*FlakyT) Cleanup

func (ft *FlakyT) Cleanup(cls func())

Cleanup registers a cleanup function.

func (*FlakyT) Errorf

func (ft *FlakyT) Errorf(format string, args ...interface{})

Errorf registers an error message.

func (*FlakyT) FailNow

func (ft *FlakyT) FailNow()

FailNow indicates to fail the test.

func (*FlakyT) TempDir added in v2.3.0

func (ft *FlakyT) TempDir() string

TempDir returns a temporary directory for the test to use. The directory is automatically removed by Cleanup when the test and all its subtests complete.

type TestingTWithCleanup

type TestingTWithCleanup interface {
	require.TestingT
	TempDir() string
	Cleanup(func())
}

TestingTWithCleanup is an augmented require.TestingT with a Cleanup function.

Jump to

Keyboard shortcuts

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