[#272] Resolve "add integration test for dispatch logic"
Closes #272 (closed)
context
- the unit tests for the
dispatch
module currently rely on a live socket. (ie: the require invokingrun
and then listening on a socket, when they could simply plass messages into the pure functiondispatch.dispatch
) - we want to introduce:
- an integration ("big bracket") test layer that (1) uses stateful resources initialized in
app.run
and (2) avoids mocking anything inside the boundaries of our application code - a convention that module-level unit ("small bracket") tests draw strict boundaries at the module layer and avoid calling out to stateful application components
- a convention that service-level integration ("big bracket") tests do not mock module interfaces, but draw a mock boundary at the interface with the signald socket
- an integration ("big bracket") test layer that (1) uses stateful resources initialized in
changes
- refactor the
dispatch
unit tests so they mock everything at the module level and don't invokeapp.run
- instead, expose
dispatcher.dispatch
and test it as a pure function
- instead, expose
- add a "big bracket" (integration) test for the
dispatch
module that:- tests dispatching a broadcast message and a
HELLO
command - doesn't mock out the command execution or database layer
- invokes
run
, and attempts to test the full execution path for handling a message from coming off the socket from signald to putting messages back on the socket for signald- accomplish this by using the new
app
module to inject asock
resource that receives messages from a testingEventEmitter
and writes messages to a stubbed outsocket.writeWithPool
- note that we are punting on stuffing
pool
into app just yet, but when we do, will move the stub one layer down the call stack to thesocketPool
that will soon be initialized inapp.run
- accomplish this by using the new
- tests dispatching a broadcast message and a
Edited by aguestuser