Skip to content

Commit

Permalink
Initial eunit test for riaknostic_check_ring using meck
Browse files Browse the repository at this point in the history
  • Loading branch information
Tryn Mirell committed Apr 2, 2012
1 parent 55eca41 commit 115b766
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/riaknostic_check_ring_membership.erl
Expand Up @@ -31,6 +31,8 @@
check/0,
format/1]).

-include_lib("eunit/include/eunit.hrl").

-spec description() -> string().
description() ->
"Cluster membership validity".
Expand All @@ -51,6 +53,14 @@ check() ->
[{warning, {not_ring_member, NodeName}}]
end.

check_test() ->
meck:new(riaknostic_node, [passthrough]),
meck:expect(riaknostic_node, stats, fun() -> [{ring_members, ["riak@127.0.0.1"]}, {nodename, ["notmember@127.0.0.1"]}] end),
?assert(meck:validate(riaknostic_node)),
?assertEqual([{warning, {not_ring_member, ["notmember@127.0.0.1"]}}], check()),
?assertNotEqual([{warning, {not_ring_member, ["notequal@127.0.0.1"]}}], check()),
meck:unload(riaknostic_node).

-spec format(term()) -> {io:format(), [term()]}.
format({not_ring_member, Nodename}) ->
{"Local node ~w is not a member of the ring. Please check that the -name setting in vm.args is correct.", [Nodename]}.

0 comments on commit 115b766

Please sign in to comment.