Documentation
¶
Overview ¶
this package contains the TestReceiver which is a process that can have message expectations set on them. These expectations match messages sent to the process inbox and execute a TestExpectation function. The function returns true to pass and false to fail the test.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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
type ExpectationFailure ¶
type TestReceiver ¶
type TestReceiver struct {
// contains filtered or unexported fields
}
func NewReceiver ¶
func NewReceiver(t *testing.T) (erl.PID, *TestReceiver)
Creates a new TestReceiver, which is a process that you can set message matching expectations on.
func (*TestReceiver) Expect ¶
func (tr *TestReceiver) Expect(expected any, handler TestExpectation, opts ...ExpectOpt)
Set an expectation that will be matched whenever an [expected] msg type is received.
func (*TestReceiver) Pass ¶
func (tr *TestReceiver) Pass() (int, bool)
returns the number of failed expectations and whether all expectations have been satisifed. An expectation is not satisfied unless it is invoked in the correct time and order
func (*TestReceiver) Receive ¶
func (tr *TestReceiver) Receive(self erl.PID, inbox <-chan any) error
func (*TestReceiver) Wait ¶
func (tr *TestReceiver) Wait()
same as [WaitFor], but uses default test timeout
func (*TestReceiver) WaitFor ¶
func (tr *TestReceiver) WaitFor(tout time.Duration)
Returns when the [tout] expires or an expectation fails. If at the end of the timeout not all expectations are satisifed, the test is failed. Call this after you have sent your messages and want fail if your expecations don't pass