Documentation ¶
Index ¶
- func Attach(tr *erltest.TestReceiver, e erltest.Expectation) erltest.Expectation
- func Fail(ea erltest.ExpectArg, reason string) *erltest.ExpectationFailure
- type ExpectOpt
- type Expectation
- func AttachDeepEqual(tr *erltest.TestReceiver, expected any, cmpOpts []cmp.Option, ...) *Expectation
- func AttachEquals(tr *erltest.TestReceiver, expected any, opts ...ExpectOpt) *Expectation
- func Called(opts ...ExpectOpt) *Expectation
- func DeepEqual(t *testing.T, expected any, cmpOpts []cmp.Option, opts ...ExpectOpt) *Expectation
- func Equals(t *testing.T, expected any, opts ...ExpectOpt) *Expectation
- func Expect(f func(arg erltest.ExpectArg) bool, opts ...ExpectOpt) *Expectation
- func New(te Handle, opts ...ExpectOpt) *Expectation
- func (ex *Expectation) And(exs ...*Expectation)
- func (ex *Expectation) Check(arg erltest.ExpectArg) (next erltest.Expectation, failure *erltest.ExpectationFailure)
- func (ex *Expectation) ID() string
- func (ex *Expectation) Name() string
- func (ex *Expectation) Satisfied(testEnded bool) bool
- func (ex *Expectation) String() string
- type Handle
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Attach ¶
func Attach(tr *erltest.TestReceiver, e erltest.Expectation) erltest.Expectation
Attach an expectation to a receiver. If the expectation is not satisfied, the receiver will not Pass.
Types ¶
type ExpectOpt ¶
type ExpectOpt func(o expectOpts) expectOpts
func AnyTimes ¶
func AnyTimes() ExpectOpt
Expectation is satisifed if it is executed zero or more times. Ensure that you are sleeping the test or have other expectations so [TestReciever.Wait] does not exit immediately
func AtMost ¶
Expectation is satisifed if it is executed up to [n] times. Zero executions will also pass WARNING: this expectation will cause your test to run until [WaitTimeout] is exceeded
func Never ¶
func Never() ExpectOpt
expectation will pass only if never matched. Alias for `Times(0)` WARNING: this expectation will cause your test to run until [WaitTimeout] is exceeded
func Receiver ¶
func Receiver(tr *erltest.TestReceiver) ExpectOpt
Set the TestReceiver that the expectation will add itself to. Useful when you are registering [Simple] sub-expectations
type Expectation ¶
type Expectation struct {
// contains filtered or unexported fields
}
func AttachDeepEqual ¶
func AttachDeepEqual(tr *erltest.TestReceiver, expected any, cmpOpts []cmp.Option, opts ...ExpectOpt) *Expectation
func AttachEquals ¶
func AttachEquals(tr *erltest.TestReceiver, expected any, opts ...ExpectOpt) *Expectation
Create an Equals expectation and attach it to [tr]
func Called ¶
func Called(opts ...ExpectOpt) *Expectation
Set an expectation that will pass if it is matched (or not matched, depending on opts). Useful if we don't care about a message's contents
func Equals ¶
func Equals(t *testing.T, expected any, opts ...ExpectOpt) *Expectation
assert a message equals exactly
func Expect ¶
func Expect(f func(arg erltest.ExpectArg) bool, opts ...ExpectOpt) *Expectation
a simple terminal expectation that works well with check.Chain
func New ¶
func New(te Handle, opts ...ExpectOpt) *Expectation
Create a custom expectation that can branch to other expectations
IMPORTANT: Any expectation used in a handler needs to be [Attach]ed to a test receiver. If there are multiple possible expectations that can be returned here, they all need to be attached to make sure the [TestReceiver] does not pass without checking them.
func (*Expectation) And ¶
func (ex *Expectation) And(exs ...*Expectation)
Joins [ex] with the [exs], so that all [exs] must succeed in order for [ex.Satisfied] to pass. WARNING: any *Expectation returned from an[exs] is ignored. This prevents branching, which can be accomplished by composing exceptions inside a Handle.
func (*Expectation) Check ¶
func (ex *Expectation) Check(arg erltest.ExpectArg) (next erltest.Expectation, failure *erltest.ExpectationFailure)
[Check] should be executed after a "match" has been made to the expectation. It will return an error if it has been clearly executed too many times. If you want to evaluate if an Expectation has "passed", you should call [Satisified].
func (*Expectation) ID ¶
func (ex *Expectation) ID() string
func (*Expectation) Name ¶
func (ex *Expectation) Name() string
func (*Expectation) Satisfied ¶
func (ex *Expectation) Satisfied(testEnded bool) bool
Returns true if this and all joined exceptions are satisifed, and immediately if it encounters a failure.
If [testEnded] is true, checks that should never be executed (ie: Times(0)) will be evaluated.
func (*Expectation) String ¶
func (ex *Expectation) String() string
type Handle ¶
type Handle func(erltest.ExpectArg) (erltest.Expectation, *erltest.ExpectationFailure)