lucacorti / lapin

Elixir RabbitMQ Client
MIT License
25 stars 11 forks source link

Lapin Sandbox #13

Open lswith opened 7 years ago

lswith commented 7 years ago

I've started to work a lot with elixir and I've noticed the best frameworks are the ones that provide some sort of sandbox for a developer to substitute in when they write test cases. Currently, to test against lapin, I need to have an actual rabbitmq host running. It would be nice to have an in-memory sandbox that I could substitute in to test against.

The scope would look something like this:

lucacorti commented 7 years ago

I've just added Travis CI integration to the master branch. Travis automatically runs tests and provides RabbitMQ in the test sandbox, so tests are automatically executed against a real broker with no setup overhead on our part.

AMQP allows you to declare configuration as part of the protocol, setting up exchanges and queues. Lapin does this automatically by default. I think this is more practical than setting up a custom test environment for now.

lswith commented 7 years ago

Ah I think the sandbox is more for people integrating with your library rather than testing internally.

lucacorti commented 7 years ago

Ok, so I guess some kind of mock simulating the broker interaction. I guess this is interesting. Do you have a pointer to an existing library which does this for tests for reference?

lswith commented 7 years ago

I wrote one on this open source repo here: https://github.com/lswith/analytics-elixir

The sandbox can be swapped out for the actual Genserver. This allows our tests to make sure that the lib is being called without actually making the http requests.

jhchabran commented 6 years ago

See also https://github.com/jcabotc/hare/blob/master/lib/hare/adapter/sandbox.ex for a concrete rabbitmq example.

I haven't used this rabbitmq lib directly though (I used the previous attempt at Rabbitmq by the same author, jcabotc/channels).

lucacorti commented 6 years ago

Thanks guys, I'll look into the examples. As my time is currently limited I'm going to be prioritizing other features though.

Also, the current travis setup already allows for easy instantiation of a real rabbitmq broker in the sandbox and at least on mac running rabbit locally is a no brainer.