Closed Richard1ybb closed 3 years ago
hi @Richard1ybb
My tests are all working :)
const Event2FurcasTicketCreate = "kapal.furcas.ticket.create"
event.On("*", handler)
event.On("kapal.furcas.ticket.*", handler)
event.On(Event2FurcasTicketCreate, handler)
https://github.com/gookit/event/blob/aa601afd98bf802feab84ad1643d086d90f5182c/all_test.go#L272-L304
这是最小可复现代码
type test_notify struct {}
var is_Run = false
func (notify *test_notify) Handle(e event.Event) error {
is_Run = true
return nil
}
func TestTicketCreate_Handle_1(t *testing.T) {
TestNotify := test_notify{}
event.On("*", &TestNotify)
err, _ := event.Fire("test_notify", event.M{})
assert.Nil(t, err)
assert.NotEqual(t, is_Run, true)
event.On("test_notify", &TestNotify)
err, _ = event.Fire("test_notify", event.M{})
assert.Nil(t, err)
assert.Equal(t, is_Run, true)
}
refer #8