Add test for DispatchEvent with error handling
All checks were successful
Go CI/CD / go-ci (push) Successful in 19m8s
All checks were successful
Go CI/CD / go-ci (push) Successful in 19m8s
This commit introduces a new test, Test_DispatchEventWithError, to verify error handling when dispatching events. It ensures that the dispatcher properly returns an error when an event handler triggers one.
This commit is contained in:
parent
5bea19ecf1
commit
0c1694c947
@ -136,6 +136,17 @@ func Test_UnknownEvent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_DispatchEventWithError(t *testing.T) {
|
||||||
|
d := NewDispatcher()
|
||||||
|
d.RegisterCommandHandler(testCommand{}, &testCommandHandler{})
|
||||||
|
d.RegisterEventHandler(testEvent{}, &testErrorEventHandler{})
|
||||||
|
|
||||||
|
err := d.DispatchEvent(context.Background(), testEvent{})
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("expected error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func Test_Error(t *testing.T) {
|
func Test_Error(t *testing.T) {
|
||||||
d := NewDispatcher()
|
d := NewDispatcher()
|
||||||
d.RegisterCommandHandler(testCommand{}, &testErrorHandler{})
|
d.RegisterCommandHandler(testCommand{}, &testErrorHandler{})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user