Skip to content

[#272] Resolve "add integration test for dispatch logic"

aguestuser requested to merge 272-add-integration-tests-for-dispatch-logic into master

Closes #272 (closed)

context

  • the unit tests for the dispatch module currently rely on a live socket. (ie: the require invoking run and then listening on a socket, when they could simply plass messages into the pure function dispatch.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

changes

  • refactor the dispatch unit tests so they mock everything at the module level and don't invoke app.run
    • instead, expose dispatcher.dispatch and test it as a pure function
  • 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 a sock resource that receives messages from a testing EventEmitter and writes messages to a stubbed out socket.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 the socketPool that will soon be initialized in app.run
Edited by aguestuser

Merge request reports

Loading