From ca32ac310fa5f140e230f2eb5fb9db57382fd888 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Wed, 20 Jan 2021 12:31:51 +0100 Subject: [PATCH] chore(style): make elvis happy --- scripts/elvis-check.sh | 2 +- test/emqx_shared_sub_SUITE.erl | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/scripts/elvis-check.sh b/scripts/elvis-check.sh index 9e6fb7320..7ba8b72eb 100755 --- a/scripts/elvis-check.sh +++ b/scripts/elvis-check.sh @@ -4,7 +4,7 @@ set -euo pipefail ELVIS_VERSION='1.0.0-emqx-1' -base=${GITHUB_BASE_REF:-$1} +base="${GITHUB_BASE_REF:-$1}" elvis_version="${2:-$ELVIS_VERSION}" echo "elvis -v: $elvis_version" diff --git a/test/emqx_shared_sub_SUITE.erl b/test/emqx_shared_sub_SUITE.erl index c2d7468d9..2e8e624c6 100644 --- a/test/emqx_shared_sub_SUITE.erl +++ b/test/emqx_shared_sub_SUITE.erl @@ -47,16 +47,21 @@ t_is_ack_required(_) -> t_maybe_nack_dropped(_) -> ?assertEqual(ok, emqx_shared_sub:maybe_nack_dropped(#message{headers = #{}})), - ?assertEqual(ok, emqx_shared_sub:maybe_nack_dropped(#message{headers = #{shared_dispatch_ack => {self(), for_test}}})), + Msg = #message{headers = #{shared_dispatch_ack => {self(), for_test}}}, + ?assertEqual(ok, emqx_shared_sub:maybe_nack_dropped(Msg)), ?assertEqual(ok,receive {for_test, {shared_sub_nack, dropped}} -> ok after 100 -> timeout end). t_nack_no_connection(_) -> - ?assertEqual(ok, emqx_shared_sub:nack_no_connection(#message{headers = #{shared_dispatch_ack => {self(), for_test}}})), - ?assertEqual(ok,receive {for_test, {shared_sub_nack, no_connection}} -> ok after 100 -> timeout end). + Msg = #message{headers = #{shared_dispatch_ack => {self(), for_test}}}, + ?assertEqual(ok, emqx_shared_sub:nack_no_connection(Msg)), + ?assertEqual(ok,receive {for_test, {shared_sub_nack, no_connection}} -> ok + after 100 -> timeout end). t_maybe_ack(_) -> ?assertEqual(#message{headers = #{}}, emqx_shared_sub:maybe_ack(#message{headers = #{}})), - ?assertEqual(#message{headers = #{shared_dispatch_ack => ?no_ack}}, emqx_shared_sub:maybe_ack(#message{headers = #{shared_dispatch_ack => {self(), for_test}}})), + Msg = #message{headers = #{shared_dispatch_ack => {self(), for_test}}}, + ?assertEqual(#message{headers = #{shared_dispatch_ack => ?no_ack}}, + emqx_shared_sub:maybe_ack(Msg)), ?assertEqual(ok,receive {for_test, ?ack} -> ok after 100 -> timeout end). % t_subscribers(_) -> @@ -124,7 +129,8 @@ t_no_connection_nack(_) -> %% This is the connection which was picked by broker to dispatch (sticky) for 1st message ?assertMatch([#{packet_id := 1}], recv_msgs(1)), - %% Now kill the connection, expect all following messages to be delivered to the other subscriber. + %% Now kill the connection, expect all following messages to be delivered to the other + %% subscriber. %emqx_mock_client:stop(ConnPid), %% sleep then make synced calls to session processes to ensure that %% the connection pid's 'EXIT' message is propagated to the session process @@ -291,9 +297,11 @@ last_message(ExpectedPayload, Pids) -> t_dispatch(_) -> ok = ensure_config(random), Topic = <<"foo">>, - ?assertEqual({error, no_subscribers}, emqx_shared_sub:dispatch(<<"group1">>, Topic, #delivery{message = #message{}})), + ?assertEqual({error, no_subscribers}, + emqx_shared_sub:dispatch(<<"group1">>, Topic, #delivery{message = #message{}})), emqx:subscribe(Topic, #{qos => 2, share => <<"group1">>}), - ?assertEqual({ok, 1}, emqx_shared_sub:dispatch(<<"group1">>, Topic, #delivery{message = #message{}})). + ?assertEqual({ok, 1}, + emqx_shared_sub:dispatch(<<"group1">>, Topic, #delivery{message = #message{}})). % t_unsubscribe(_) -> % error('TODO').