rocdev-foundation / medera

Is a chat bot the new "Hello, World"?
GNU General Public License v3.0
1 stars 2 forks source link

Allow testing without connecting to Slack #5

Closed dantswain closed 7 years ago

dantswain commented 7 years ago

mix test now passes without needing to connect to Slack.

The Slack client code is not very test-friendly :/

I changed the job of Connector slightly so that it now acts as an abstraction on top of sending/receiving data from/to Slack and does not actually handle the messages. Then I added a TestConnector module that plays the same role during tests. The TestConnector module also collects sent messages, which allows us to test (for example) that receiving a particular message results in sending a reply.

It's a little weird that the Printer module handles the messages, but effectively it was doing that before these changes - the messages were relayed from Connector to MessageProducer to Printer and then back to Connector. I think that should get cleaned up but I don't think it's in the scope of this PR.