Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Coerce default_user, default_pass, exchange and vhost to binaries #32

Merged
merged 12 commits into from
Sep 22, 2015

Conversation

priviterag
Copy link
Contributor

fix #25

do we need integration tests?

@michaelklishin
Copy link
Contributor

No, I don't think we need integration tests, this is a fairly trivial change.

@michaelklishin
Copy link
Contributor

While we are at it, can be do the same for default_user and default_password? Those must be binaries as well.

@priviterag priviterag changed the title Coerce exchange and vhost to binaries [DO NOT MERGE] Coerce default_user, default_pass, exchange and vhost to binaries [DO NOT MERGE] Sep 17, 2015
@priviterag priviterag changed the title Coerce default_user, default_pass, exchange and vhost to binaries [DO NOT MERGE] Coerce default_user, default_pass, exchange and vhost to binaries Sep 17, 2015

%% coerce in case of string
coerce_exchange_test() ->
<<"amq.direct">> = rabbit_mqtt_util:coerce(exchange, "amq.direct").

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

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, looking into it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

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!

@michaelklishin
Copy link
Contributor

@priviterag is this ready for QA?

@michaelklishin michaelklishin added this to the n/a milestone Sep 22, 2015
@priviterag
Copy link
Contributor Author

@michaelklishin yep, it's ready

@michaelklishin
Copy link
Contributor

@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.

michaelklishin added a commit that referenced this pull request Sep 22, 2015
Coerce default_user, default_pass, exchange and vhost to binaries
@michaelklishin michaelklishin merged commit f6ca02c into stable Sep 22, 2015
@dumbbell dumbbell deleted the rabbitmq-mqtt-25 branch January 2, 2018 16:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants