Documentation ¶
Index ¶
- Variables
- func AssertDuration(t *testing.T, expectedDuration int, actualDuration time.Duration)
- func ErrorNTimesThenError[R any](err error, errorTimes int, finalError error) func(exec failsafe.Execution[R]) (R, error)
- func ErrorNTimesThenPanic[R any](err error, errorTimes int, panicValue any) func(exec failsafe.Execution[R]) (R, error)
- func ErrorNTimesThenReturn[R any](err error, errorTimes int, results ...R) (fn func(exec failsafe.Execution[R]) (R, error), resetFn func())
- func GetFn[R any](result R, err error) func() (R, error)
- func GetType(myvar interface{}) string
- func GetWithExecutionFn[R any](result R, err error) func(exec failsafe.Execution[R]) (R, error)
- func MillisToNanos(millis int) int64
- func RunFn(err error) func() error
- func SetupWithContextSleep(sleepTime time.Duration) func() context.Context
- func TestGetFailure[R any](t *testing.T, given Given, executor failsafe.Executor[R], when WhenGet[R], ...)
- func TestGetSuccess[R any](t *testing.T, given Given, executor failsafe.Executor[R], when WhenGet[R], ...)
- func TestRunFailure[R any](t *testing.T, given Given, executor failsafe.Executor[R], when WhenRun[R], ...)
- func TestRunSuccess[R any](t *testing.T, given Given, executor failsafe.Executor[R], when WhenRun[R], ...)
- func Timed(fn func()) time.Duration
- func WaitAndAssertCanceled[R any](t *testing.T, waitDuration time.Duration, exec failsafe.Execution[R])
- type CompositeError
- type Given
- type TestClock
- type TestExecution
- func (s TestExecution[R]) AttemptStartTime() time.Time
- func (s TestExecution[R]) Attempts() int
- func (s TestExecution[R]) Canceled() <-chan any
- func (s TestExecution[R]) Context() context.Context
- func (s TestExecution[R]) ElapsedAttemptTime() time.Duration
- func (s TestExecution[R]) ElapsedTime() time.Duration
- func (s TestExecution[R]) Executions() int
- func (s TestExecution[R]) IsCanceled() bool
- func (s TestExecution[R]) IsFirstAttempt() bool
- func (s TestExecution[R]) IsRetry() bool
- func (s TestExecution[R]) LastError() error
- func (s TestExecution[R]) LastResult() R
- func (s TestExecution[R]) StartTime() time.Time
- type TestStopwatch
- type Waiter
- type WhenGet
- type WhenRun
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrConnecting = errors.New("connection error")
View Source
var ErrInvalidArgument = errors.New("invalid argument")
View Source
var ErrInvalidState = errors.New("invalid state")
View Source
var ErrTimeout = errors.New("timeout error")
View Source
var GetFalseFn = func() (bool, error) { return false, nil }
View Source
var GetTrueFn = func() (bool, error) { return true, nil }
View Source
var NoopFn = func() error { return nil }
Functions ¶
func AssertDuration ¶
func ErrorNTimesThenError ¶
func ErrorNTimesThenError[R any](err error, errorTimes int, finalError error) func(exec failsafe.Execution[R]) (R, error)
ErrorNTimesThenError returns a stub function that returns the err errorTimes and then returns the finalError. Can be used with failsafe.GetWithExecution.
func ErrorNTimesThenPanic ¶
func ErrorNTimesThenPanic[R any](err error, errorTimes int, panicValue any) func(exec failsafe.Execution[R]) (R, error)
ErrorNTimesThenPanic returns a stub function that returns the err errorTimes and then panics with the panicValue. Can be used with failsafe.GetWithExecution.
func ErrorNTimesThenReturn ¶
func ErrorNTimesThenReturn[R any](err error, errorTimes int, results ...R) (fn func(exec failsafe.Execution[R]) (R, error), resetFn func())
ErrorNTimesThenReturn returns a stub function that returns the err errorTimes and then returns the results. Can be used with failsafe.GetWithExecution.
func GetWithExecutionFn ¶
func MillisToNanos ¶
func SetupWithContextSleep ¶
SetupWithContextSleep returns a setup function that provides a context that is canceled after the sleepTime.
func TestGetFailure ¶
func TestGetSuccess ¶
func TestRunFailure ¶
func TestRunSuccess ¶
Types ¶
type CompositeError ¶
type CompositeError struct {
Cause error
}
func (*CompositeError) Error ¶
func (ce *CompositeError) Error() string
func (*CompositeError) Is ¶
func (ce *CompositeError) Is(err error) bool
func (*CompositeError) Unwrap ¶
func (ce *CompositeError) Unwrap() error
type TestExecution ¶
type TestExecution[R any] struct { TheLastResult R }
func (TestExecution[R]) AttemptStartTime ¶
func (s TestExecution[R]) AttemptStartTime() time.Time
func (TestExecution[R]) Attempts ¶
func (s TestExecution[R]) Attempts() int
func (TestExecution[R]) Canceled ¶
func (s TestExecution[R]) Canceled() <-chan any
func (TestExecution[R]) Context ¶
func (s TestExecution[R]) Context() context.Context
func (TestExecution[R]) ElapsedAttemptTime ¶
func (s TestExecution[R]) ElapsedAttemptTime() time.Duration
func (TestExecution[R]) ElapsedTime ¶
func (s TestExecution[R]) ElapsedTime() time.Duration
func (TestExecution[R]) Executions ¶
func (s TestExecution[R]) Executions() int
func (TestExecution[R]) IsCanceled ¶
func (s TestExecution[R]) IsCanceled() bool
func (TestExecution[R]) IsFirstAttempt ¶
func (s TestExecution[R]) IsFirstAttempt() bool
func (TestExecution[R]) IsRetry ¶
func (s TestExecution[R]) IsRetry() bool
func (TestExecution[R]) LastError ¶
func (s TestExecution[R]) LastError() error
func (TestExecution[R]) LastResult ¶
func (s TestExecution[R]) LastResult() R
func (TestExecution[R]) StartTime ¶
func (s TestExecution[R]) StartTime() time.Time
type TestStopwatch ¶
type TestStopwatch struct {
CurrentTime int64
}
func (*TestStopwatch) ElapsedTime ¶
func (t *TestStopwatch) ElapsedTime() time.Duration
func (*TestStopwatch) Reset ¶
func (t *TestStopwatch) Reset()
type Waiter ¶
type Waiter struct {
// contains filtered or unexported fields
}
func (*Waiter) AssertEqual ¶
func (*Waiter) AwaitWithTimeout ¶
Click to show internal directories.
Click to hide internal directories.