Fork me on GitHub
#testing
<
2019-04-28
>
metame17:04:06

Wanted to see if anyone had good ideas on testing a webhook service. The service POSTs to urls provided by the user. Some ideas: 1. Add a new API endpoint to our current api service that is just used for integration testing webhooks that would then write to the db or a file or something that the integration test can then fetch and read. 2. Set up a temp server that I can read responses from ideally without any fs/db side effects. Found stub-http that might support this use case(?). This would seem to preclude any remote testing (but maybe not). 1 would be simpler to implement but I don't like the idea of changing our app api for an integration test. Would think there are others who have solved this problem.

metame04:05:28

For anyone interested, I ended up using stub-http to accomplish this (testing a webhook service) and found it quite nice to use and simple to get right. Setup routes, waited for request to be recorded and verified data was correct in just a few loc.

donaldball20:04:49

I always do (2) myself. Standing up a simple jetty instance with pedestal or ring isn’t much code and there’s really no better integration test. Specifically in your case, I’d build a handler that records activity in an atom and assert the things I expected to happen actually happened.

metame20:04:04

Thanks for the response @donaldball --- confirms what I thought I should do