helper

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src, dst string) error

Copy files around

func ExpectFailure

func ExpectFailure(t *testing.T, f func(tt testing.TB))

func NewAfInstance

func NewAfInstance(t testing.TB, name, cfg string) *afInstance

If you need to create instance without starting it up right away

func NewAquariumFish

func NewAquariumFish(t testing.TB, name, cfg string, args ...string) *afInstance

Simple creates and run the fish node

func Retry

func Retry(r Retryer, t Failer, f func(r *R))

Types

type Counter

type Counter struct {
	Count int
	Wait  time.Duration
	// contains filtered or unexported fields
}

Counter repeats an operation a given number of times and waits between subsequent operations.

func (*Counter) Continue

func (r *Counter) Continue() bool

type Failer

type Failer interface {
	Helper()

	// Log is called for the final test output
	Log(args ...any)

	// FailNow is called when the retrying is abandoned.
	FailNow()
}

Failer is an interface compatible with testing.T.

type MockT

type MockT struct {
	testing.T

	FailNowCalled bool
	// contains filtered or unexported fields
}

Useful to capture the failed test

func (*MockT) FailNow

func (m *MockT) FailNow()

func (*MockT) Fatal

func (m *MockT) Fatal(args ...any)

func (*MockT) Fatalf

func (m *MockT) Fatalf(format string, args ...any)

func (*MockT) Log

func (m *MockT) Log(args ...any)

func (*MockT) Logf

func (m *MockT) Logf(format string, args ...any)

type R

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

R provides context for the retryer.

func (*R) Check

func (r *R) Check(err error)

func (*R) Error

func (r *R) Error(args ...any)

func (*R) Errorf

func (r *R) Errorf(format string, args ...any)

func (*R) FailNow

func (r *R) FailNow()

func (*R) Fatal

func (r *R) Fatal(args ...any)

func (*R) Fatalf

func (r *R) Fatalf(format string, args ...any)

func (*R) Helper

func (r *R) Helper()

func (*R) Stop

func (r *R) Stop(err error)

Stop retrying, and fail the test with the specified error.

type Retryer

type Retryer interface {
	// Continue returns true if the operation should be repeated, otherwise it
	// returns false to indicate retrying should stop.
	Continue() bool
}

Retryer provides an interface for repeating operations until they succeed or an exit condition is met.

type Timer

type Timer struct {
	Timeout time.Duration
	Wait    time.Duration
	// contains filtered or unexported fields
}

Timer repeats an operation for a given amount of time and waits between subsequent operations.

func (*Timer) Continue

func (r *Timer) Continue() bool

Jump to

Keyboard shortcuts

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