Skip to content

Commit

Permalink
Print expected and received texts in sm_helper:assert_messages
Browse files Browse the repository at this point in the history
  • Loading branch information
arcusfelis committed Dec 16, 2021
1 parent c6e2cc7 commit 9a15e27
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions big_tests/tests/sm_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,19 @@ wait_for_messages(Alice, Texts) ->
assert_messages(Stanzas, Texts).

assert_messages(Stanzas, Texts) ->
assert_same_length(Stanzas, Texts),
Checks = [escalus_pred:is_chat_message(Text, Stanza)
|| {Text, Stanza} <- lists:zip(Texts, Stanzas)],
case lists:usort(Checks) of
[true] ->
Bodies = lists:map(fun get_body/1, Stanzas),
case Bodies of
Texts ->
ok;
_ ->
ct:fail({assert_messages_failed, Checks, Stanzas, Texts})
ct:fail({assert_messages_failed, Stanzas,
{expected, Texts},
{received, Bodies}})
end.

get_body(Stanza) ->
exml_query:path(Stanza, [{element, <<"body">>}, cdata]).

assert_same_length(List1, List2) when length(List1) =:= length(List2) -> ok.

get_ack(Client) ->
Expand Down

0 comments on commit 9a15e27

Please sign in to comment.