Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lapin Sandbox #13

Open
lswith opened this issue Nov 22, 2017 · 6 comments
Open

Lapin Sandbox #13

lswith opened this issue Nov 22, 2017 · 6 comments
Milestone

Comments

@lswith
Copy link
Contributor

lswith commented Nov 22, 2017

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:

  • doesn't require an amqp server
  • allows the control of messages through test harnesses (I can determine when I wish to send a message)
  • allows messages to be prepopulated on the queue
@lucacorti
Copy link
Owner

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
Copy link
Contributor Author

lswith commented Nov 22, 2017

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

@lucacorti
Copy link
Owner

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?

@lucacorti lucacorti added this to the 1.0 milestone Nov 22, 2017
@lswith
Copy link
Contributor Author

lswith commented Nov 22, 2017

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
Copy link

jhchabran commented Dec 20, 2017

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants