Fixed incorrect assignable types order in invocation
This commit is contained in:
parent
e7cb026708
commit
dbce4f6dce
18
bus_test.go
18
bus_test.go
|
@ -1,6 +1,7 @@
|
|||
package events
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
@ -34,6 +35,23 @@ func TestNew_Lifecycle(t *testing.T) {
|
|||
}, receives)
|
||||
}
|
||||
|
||||
func TestFire(t *testing.T) {
|
||||
t.Run("should preserve context.Context", func(t *testing.T) {
|
||||
var wasFired bool
|
||||
|
||||
d := New()
|
||||
|
||||
d.On("event", func(ctx context.Context) {
|
||||
assert.NotNil(t, ctx)
|
||||
wasFired = true
|
||||
})
|
||||
|
||||
d.Fire("event", context.Background())
|
||||
|
||||
assert.True(t, wasFired)
|
||||
})
|
||||
}
|
||||
|
||||
func TestTryFire(t *testing.T) {
|
||||
errVal := errors.New("bang")
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ func (rh *receiptHandler) invoke(values preparedArgs) error {
|
|||
for i := range args {
|
||||
args[i] = reflect.Zero(rh.funcType.In(i))
|
||||
if i < len(values) {
|
||||
if rh.funcType.In(i).AssignableTo(values[i].Type()) {
|
||||
if values[i].Type().AssignableTo(rh.funcType.In(i)) {
|
||||
args[i] = values[i]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue