Application consist of 3 servers:
- Queue, for fetching/deleting messages from the queue
- Token, for fetching access token required for other service
- Cron, for republishing messages from queue to 3rd party service by using access token authentication
Each of the HTTPoison calls are supposed to be replaced by proper Endpoints which could have used @behaviour
and have an Http implementation, that could be set via application configuration and tested with mox.
We assume that other servers/apis are tested, how do we now test the server that manages all other servers/apis?
- We could define here in test module dummy module mocks for each service and each case and pass them along. Issues:
- dummy modules can get out of sync easily
- dummy module per mock result
- We could specify for each server client a set of
@callbacksand then usemoxfor creating mocks. Issues:- Many useless behaviours which will be there only for test purposes
- We could pass in
functionsinstead of modules, i.e.cron(fetch: &state.queue.fetch_message/0, delete: &state.queue.delete_message/1, etc..), then in the test we can just pass in different functions, instead of whole modules. Issues:- isn't it too verbose?
- Any other ways?
so far so good, 4th iteration looks more reasonable, still wondering how to test functions setup