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 17, 2021
1 parent 27e5068 commit 7bb63ff
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 @@ -280,16 +280,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]).

get_ack(Client) ->
escalus:assert(is_sm_ack_request, escalus_connection:get_stanza(Client, ack)).

Expand Down

0 comments on commit 7bb63ff

Please sign in to comment.