Add test for DispatchEvent with error handling
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:
Rene Nochebuena 2025-04-13 01:33:25 -06:00
parent 5bea19ecf1
commit 0c1694c947
Signed by: Rene Nochebuena
GPG Key ID: A9FD83117EA538D8

View File

@ -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) {
d := NewDispatcher()
d.RegisterCommandHandler(testCommand{}, &testErrorHandler{})