-
Notifications
You must be signed in to change notification settings - Fork 69
Coerce default_user, default_pass, exchange and vhost to binaries #32
Conversation
No, I don't think we need integration tests, this is a fairly trivial change. |
While we are at it, can be do the same for |
|
||
%% coerce in case of string | ||
coerce_exchange_test() -> | ||
<<"amq.direct">> = rabbit_mqtt_util:coerce(exchange, "amq.direct"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps you could use assertEqual?
from eunit instead of just relying on erlang's pattern matching, since according to the docs it can provide more informative error messages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I will. While we are discussing tests, I want to share my thoughts about this task. Here I'm writing unit tests for a function that is (at least, so far) private (used only by the rabbit_mqtt_util:env/1 function). What I would have preferred is to call rabbit_mqtt_util:env/1 from my tests and check the return value using assertEqual. This is not simple, because env call application:get_env/2 and this would require an instance of rabbitmq running (I guess). My question is: can we use some stub/mock erlang library for this? Are we already using it in other repos?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your tests are similar to these. To use application:get_env/2
the app needs to be loaded, but not necessarily running. See application:load/1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, looking into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
found this one: https://github.com/eproxus/meck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, there are mocking tools in Erlang, but without erlang.mk we are not going to be using them, since integrating them would be duplicated work.
Right now you can have an application config file with your mqtt settings, load that with the application module, and then run your tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michaelklishin jeez, you are a contributor!
@priviterag is this ready for QA? |
@michaelklishin yep, it's ready |
@priviterag if a pull request doesn't get any attention in more than 2 days it may be a good idea to explicitly state that it is ready. |
Coerce default_user, default_pass, exchange and vhost to binaries
fix #25
do we need integration tests?