Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Err = errors.New("test error")
Functions ¶
func MaybeFail ¶
func MaybeFail[T any](ct *Calltracker, f func() (T, error)) (T, error)
MaybeFail fails the call if the next value in Fails is true.
func MaybeFailErrFunc ¶
func MaybeFailErrFunc(ct *Calltracker, f func() error) error
MaybeFailErrFunc fails the call if the next value in Fails is true.
Types ¶
type Calltracker ¶
type Calltracker struct { CallIndex int ShouldFail bool Err error FailAllAfterIndex bool FailAtIndex int }
Calltracker is a helper struct to track calls to a dependency. It can be used to simulate failing dependencies. The zero value is ready to use and will never fail.
func NewFailingDeps ¶
func NewFailingDeps(err error, expectCalls int) []Calltracker
NewFailingDeps will create failing calltrackers that will fail at different points in the call sequence.
Dependencies will fail in two ways: - A single failure, then all calls after succesful. - All calls will fail after a number of succesful calls.
Click to show internal directories.
Click to hide internal directories.