Testing setup
Closed this issue · 1 comments
bounoable commented
Command Bus testing
This is tedious:
package foo_test
func TestSomethingWithCommandBus(t *testing.T) {
ereg := event.NewRegistry()
ebus := eventstore.WithBus(chanbus.New(), ebus)
estore := memstore.New()
creg := command.NewRegistry()
cbus := cmdbus.New(creg, ereg, ebus, estore)
err := cbus.Dispatch(...)
}
Something like this should be possible:
package foo_test
func TestSomethingWithCommandBus(t *testing.T) {
setup := test.Setup(t)
cbus := setup.CommandBus()
err := cbus.Dispatch(...)
}
Command dispatches should be synchronous by default when using test.Setup
:
package foo_test
func TestAsyncDispatch(t *testing.T) {
setup := test.Setup(t)
cbus := setup.CommandBus(dispatch.Asynchronous) // pass default dispatch options
err := cbus.Dispatch(...)
}
bounoable commented
Not well thought out. Need more data