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

Improve mod_pubsub test coverage #1241

Merged
merged 6 commits into from
Mar 30, 2017

Conversation

fenek
Copy link
Member

@fenek fenek commented Mar 24, 2017

New PR for rebased+squashed branch

case Affiliation of
owner ->
NewOwner = jid:to_bare(JID),
NewOwners = [NewOwner | Owners],

Choose a reason for hiding this comment

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

According to Elvis:

Line 2721 is too long: NewOwners = [NewOwner | Owners],.

NewOwners = Owners -- [OldOwner],
tree_call(Host,
set_node,
[N#pubsub_node{owners = NewOwners}]);

Choose a reason for hiding this comment

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

According to Elvis:

Line 2732 is too long: [N#pubsub_node{owners = NewOwners}]);.

attrs = [{<<"jid">>, jid:to_binary(Unchanged)}, {<<"affiliation">>, <<"owner">>}] }
|| Unchanged <- Owners ],
AffiliationsPayload = #xmlel{ name = <<"affiliations">>, attrs = [{<<"node">>, NodeId}],
children = OwnersPayload },

Choose a reason for hiding this comment

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

According to Elvis:

Line 2711 is too long: children = OwnersPayload },.

AffiliationsPayload = #xmlel{ name = <<"affiliations">>, attrs = [{<<"node">>, NodeId}],
children = OwnersPayload },
NewPubSubPayload = #xmlel{ name = <<"pubsub">>, attrs = [{<<"xmlns">>, ?NS_PUBSUB_OWNER}],
children = [AffiliationsPayload] },

Choose a reason for hiding this comment

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

According to Elvis:

Line 2713 is too long: children = [AffiliationsPayload] },.

@@ -2660,41 +2690,56 @@ set_affiliations(Host, Node, From, EntitiesEls) ->
error ->
{error, ?ERR_BAD_REQUEST};
_ ->
Action = fun (#pubsub_node{type = Type, id = Nidx, owners = O} = N) ->
Action = fun (#pubsub_node{type = Type, id = Nidx, owners = O, nodeid = {_, NodeId}} = N) ->

Choose a reason for hiding this comment

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

According to Elvis:

Line 2693 is too long: Action = fun (#pubsub_node{type = Type, id = Nidx, owners = O, nodeid = {_, NodeId}} = N) ->.

tree_call(Host,
set_node,
[N#pubsub_node{owners = NewOwners}]);
none ->
OldOwner = jid:to_bare(JID),

Choose a reason for hiding this comment

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

According to Elvis:

Line 2726 is too long: OldOwner = jid:to_bare(JID),.

{error, {?ERR_NOT_ACCEPTABLE, [NewPubSubPayload]}};
_ ->
lists:foreach(fun ({JID, Affiliation}) ->
node_call(Host, Type, set_affiliation, [Nidx, JID, Affiliation]),

Choose a reason for hiding this comment

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

According to Elvis:

Line 2717 is too long: node_call(Host, Type, set_affiliation, [Nidx, JID, Affiliation]),.

% other invalid affiliation transitions
OwnersDryRun = lists:foldl(
fun({JID, owner}, Acc) ->
sets:add_element(jid:to_bare(JID), Acc);

Choose a reason for hiding this comment

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

According to Elvis:

Line 2701 is too long: sets:add_element(jid:to_bare(JID), Acc);.

tree_call(Host,
set_node,
[N#pubsub_node{owners = NewOwners}]);
none ->
OldOwner = jid:to_bare(JID),
case lists:member(OldOwner, Owners) of

Choose a reason for hiding this comment

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

According to Elvis:

Line 2727 is too long: case lists:member(OldOwner, Owners) of.

@@ -2876,6 +2924,7 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) ->
_ ->
[]
end;
%% used by node_flat (therefore by dag, hometree and push as well)

Choose a reason for hiding this comment

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

According to Elvis:

Line 2927 is too long: %% used by node_flat (therefore by dag, hometree and push as well).

case sets:size(OwnersDryRun) of
0 ->
OwnersPayload = [ #xmlel{ name = <<"affiliation">>,
attrs = [{<<"jid">>, jid:to_binary(Unchanged)}, {<<"affiliation">>, <<"owner">>}] }

Choose a reason for hiding this comment

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

According to Elvis:

Line 2708 is too long: attrs = [{<<"jid">>, jid:to_binary(Unchanged)}, {<<"affiliation">>, <<"owner">>}] }.

|| Unchanged <- Owners ],
AffiliationsPayload = #xmlel{ name = <<"affiliations">>, attrs = [{<<"node">>, NodeId}],
children = OwnersPayload },
NewPubSubPayload = #xmlel{ name = <<"pubsub">>, attrs = [{<<"xmlns">>, ?NS_PUBSUB_OWNER}],

Choose a reason for hiding this comment

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

According to Elvis:

Line 2712 is too long: NewPubSubPayload = #xmlel{ name = <<"pubsub">>, attrs = [{<<"xmlns">>, ?NS_PUBSUB_OWNER}],.

OwnersPayload = [ #xmlel{ name = <<"affiliation">>,
attrs = [{<<"jid">>, jid:to_binary(Unchanged)}, {<<"affiliation">>, <<"owner">>}] }
|| Unchanged <- Owners ],
AffiliationsPayload = #xmlel{ name = <<"affiliations">>, attrs = [{<<"node">>, NodeId}],

Choose a reason for hiding this comment

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

According to Elvis:

Line 2710 is too long: AffiliationsPayload = #xmlel{ name = <<"affiliations">>, attrs = [{<<"node">>, NodeId}],.

({_, none, _}) ->
[];
%% sometimes used by node_pep
({#pubsub_node{nodeid = {_, SubsNode}}, Sub, SubId, SubJID}) ->

Choose a reason for hiding this comment

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

According to Elvis:

Line 2909 is too long: ({#pubsub_node{nodeid = {_, SubsNode}}, Sub, SubId, SubJID}) ->.

node_call(Host, Type, set_affiliation, [Nidx, JID, Affiliation]),
case Affiliation of
owner ->
NewOwner = jid:to_bare(JID),

Choose a reason for hiding this comment

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

According to Elvis:

Line 2720 is too long: NewOwner = jid:to_bare(JID),.

@@ -1526,7 +1556,7 @@ send_pending_auth_events(Request, Host, Node, Owner) ->
send_authorization_request(#pubsub_node{nodeid = {Host, Node}, type = Type, id = Nidx, owners = O},
Subscriber) ->
Lang = <<"en">>,
Stanza = #xmlel{name = <<"message">>, attrs = [],
Stanza = #xmlel{name = <<"message">>, attrs = [{<<"id">>, list_to_binary(randoms:get_string())}],

Choose a reason for hiding this comment

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

According to Elvis:

Line 1559 is too long: Stanza = #xmlel{name = <<"message">>, attrs = [{<<"id">>, list_to_binary(randoms:get_string())}],.

@@ -1005,6 +1034,8 @@ do_route(ServerHost, Access, Plugins, Host, From, To, Packet) ->
of
{result, IQRes} ->
jlib:iq_to_xml(IQ#iq{type = result, sub_el = IQRes});
{error, {Error, NewPayload}} ->
jlib:make_error_reply(Packet#xmlel{ children = NewPayload }, Error);

Choose a reason for hiding this comment

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

According to Elvis:

Line 1038 is too long: jlib:make_error_reply(Packet#xmlel{ children = NewPayload }, Error);.

@@ -2876,6 +2924,7 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) ->
_ ->
[]
end;
%% used by node_flat (therefore by dag, hometree and push as well)
({#pubsub_node{nodeid = {_, SubsNode}}, Sub, SubJID}) ->
case Node of

Choose a reason for hiding this comment

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

According to Elvis:

The expression on line 2929 and column 45 is nested beyond the maximum level of 3.

case Affiliation of
owner ->
NewOwner = jid:to_bare(JID),
NewOwners = [NewOwner | Owners],
tree_call(Host,
set_node,
[N#pubsub_node{owners = NewOwners}]);

Choose a reason for hiding this comment

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

According to Elvis:

Line 2724 is too long: [N#pubsub_node{owners = NewOwners}]);.

@@ -2660,41 +2690,56 @@ set_affiliations(Host, Node, From, EntitiesEls) ->
error ->
{error, ?ERR_BAD_REQUEST};
_ ->
Action = fun (#pubsub_node{type = Type, id = Nidx, owners = O} = N) ->
Action = fun (#pubsub_node{type = Type, id = Nidx, owners = O, nodeid = {_, NodeId}} = N) ->
Owners = node_owners_call(Host, Type, Nidx, O),
case lists:member(Owner, Owners) of

Choose a reason for hiding this comment

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

According to Elvis:

The expression on line 2695 and column 30 is nested beyond the maximum level of 3.

({_, none, _}) ->
[];
%% sometimes used by node_pep
({#pubsub_node{nodeid = {_, SubsNode}}, Sub, SubId, SubJID}) ->
case Node of

Choose a reason for hiding this comment

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

According to Elvis:

The expression on line 2910 and column 45 is nested beyond the maximum level of 3.

true ->
NewOwners = Owners -- [OldOwner],
tree_call(Host,
set_node,

Choose a reason for hiding this comment

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

According to Elvis:

Line 2731 is too long: set_node,.

fun({JID, owner}, Acc) ->
sets:add_element(jid:to_bare(JID), Acc);
({JID, _}, Acc) ->
sets:del_element(jid:to_bare(JID), Acc)

Choose a reason for hiding this comment

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

According to Elvis:

Line 2703 is too long: sets:del_element(jid:to_bare(JID), Acc).

OldOwner = jid:to_bare(JID),
case lists:member(OldOwner, Owners) of
true ->
NewOwners = Owners -- [OldOwner],

Choose a reason for hiding this comment

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

According to Elvis:

Line 2729 is too long: NewOwners = Owners -- [OldOwner],.

@@ -3742,11 +3793,12 @@ set_configure(Host, Node, From, Els, Lang) ->
end,
case set_xoption(Host, XData, OldOpts) of
NewOpts when is_list(NewOpts) ->
NewNode = N#pubsub_node{options = NewOpts},

Choose a reason for hiding this comment

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

According to Elvis:

Line 3796 is too long: NewNode = N#pubsub_node{options = NewOpts},.

@@ -3758,7 +3810,7 @@ set_configure(Host, Node, From, Els, Lang) ->
end
end,
case transaction(Host, Node, Action, transaction) of

Choose a reason for hiding this comment

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

According to Elvis:

The expression on line 3812 and column 21 is nested beyond the maximum level of 3.

@fenek fenek force-pushed the pubsub_SUITE-to-cover-refactor_rebase branch from d1a225a to 135ef8e Compare March 28, 2017 14:11
@fenek fenek force-pushed the pubsub_SUITE-to-cover-refactor_rebase branch from 135ef8e to b46491d Compare March 29, 2017 10:39
@@ -3742,11 +3778,12 @@ set_configure(Host, Node, From, Els, Lang) ->
end,
case set_xoption(Host, XData, OldOpts) of
NewOpts when is_list(NewOpts) ->
NewNode = N#pubsub_node{options = NewOpts},

Choose a reason for hiding this comment

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

According to Elvis:

Line 3781 is too long: NewNode = N#pubsub_node{options = NewOpts},.

@@ -3758,7 +3795,7 @@ set_configure(Host, Node, From, Els, Lang) ->
end
end,
case transaction(Host, Node, Action, transaction) of

Choose a reason for hiding this comment

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

According to Elvis:

The expression on line 3797 and column 21 is nested beyond the maximum level of 3.

@michalwski michalwski merged commit 6fc47a8 into master Mar 30, 2017
@michalwski michalwski deleted the pubsub_SUITE-to-cover-refactor_rebase branch March 30, 2017 12:58
@michalwski
Copy link
Contributor

This is massive coverage improvement! Thanks a lot!

@fenek fenek mentioned this pull request Jul 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants