Skip to content

Commit 42803da

Browse files
committed
Simplify tests
1 parent 58223a2 commit 42803da

File tree

2 files changed

+21
-44
lines changed

2 files changed

+21
-44
lines changed

deps/rabbitmq_mqtt/test/mc_mqtt_SUITE.erl

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -162,31 +162,15 @@ roundtrip_amqpl(_Config) ->
162162
?assertMatch(#{'User-Property' := ExpectedUserProperty}, Props).
163163

164164
amqpl_to_mqtt_gh_12707(_Config) ->
165-
Props = #'P_basic'{content_type = <<"text/plain">>,
166-
content_encoding = <<"gzip">>,
167-
headers = [],
168-
delivery_mode = 1,
169-
priority = 7,
170-
correlation_id = <<"gh_12707-corr">> ,
171-
reply_to = <<"reply-to">>,
172-
expiration = <<"12707">>,
173-
message_id = <<"msg-id">>,
174-
timestamp = 99,
175-
type = <<"45">>,
176-
user_id = <<"gh_12707">>,
177-
app_id = <<"rmq">>
178-
},
165+
Props = #'P_basic'{expiration = <<"12707">>},
179166
Payload = [<<"gh_12707">>],
180167
Content = #content{properties = Props,
181168
payload_fragments_rev = Payload},
182-
Content = #content{properties = Props,
183-
payload_fragments_rev = Payload},
184-
Anns = #{
185-
?ANN_EXCHANGE => <<"amq.topic">>,
186-
?ANN_ROUTING_KEYS => [<<"dummy">>]
187-
},
169+
Anns = #{?ANN_EXCHANGE => <<"amq.topic">>,
170+
?ANN_ROUTING_KEYS => [<<"dummy">>]},
188171
OriginalMsg = mc:init(mc_amqpl, Content, Anns),
189172
Converted = mc:convert(mc_mqtt, OriginalMsg),
173+
?assertMatch(#mqtt_msg{}, mc:protocol_state(Converted)),
190174
?assertEqual(12707, mc:get_annotation(ttl, Converted)).
191175

192176
%% Non-UTF-8 Correlation Data should also be converted (via AMQP 0.9.1 header x-correlation-id).

deps/rabbitmq_mqtt/test/protocol_interop_SUITE.erl

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -170,36 +170,29 @@ mqtt_amqpl_mqtt(Config) ->
170170
ok = emqtt:disconnect(C).
171171

172172
amqpl_mqtt_gh_12707(Config) ->
173-
Q = ClientId = atom_to_binary(?FUNCTION_NAME),
174-
Ch = rabbit_ct_client_helpers:open_channel(Config),
175-
#'queue.declare_ok'{} = amqp_channel:call(Ch, #'queue.declare'{queue = Q, durable = true}),
176-
#'queue.bind_ok'{} = amqp_channel:call(Ch, #'queue.bind'{queue = Q,
177-
exchange = <<"amq.topic">>,
178-
routing_key = <<"gh12707">>}),
173+
ClientId = atom_to_binary(?FUNCTION_NAME),
174+
Topic = Payload = <<"gh_12707">>,
179175
C = connect(ClientId, Config),
176+
{ok, _, [1]} = emqtt:subscribe(C, Topic, qos1),
180177

181-
Topic = <<"gh12707">>,
182-
Payload = <<"gh_12707">>,
183-
184-
{ok, _, [1]} = emqtt:subscribe(C, #{'Subscription-Identifier' => 676}, [{Topic, [{qos, 1}]}]),
185-
amqp_channel:call(Ch, #'basic.publish'{exchange = <<"amq.topic">>,
186-
routing_key = Topic},
187-
#amqp_msg{payload = Payload,
188-
props = #'P_basic'{content_type = <<"application/json">>,
189-
expiration = <<"12707">>,
190-
headers = []}}),
178+
Ch = rabbit_ct_client_helpers:open_channel(Config),
179+
amqp_channel:call(Ch,
180+
#'basic.publish'{exchange = <<"amq.topic">>,
181+
routing_key = Topic},
182+
#amqp_msg{payload = Payload,
183+
props = #'P_basic'{expiration = <<"12707">>,
184+
headers = []}}),
191185

192186
receive {publish,
193-
#{topic := MqttTopic,
194-
payload := MqttPayload}} ->
195-
?assertEqual(MqttTopic, Topic),
196-
?assertEqual(Payload, MqttPayload)
197-
after 1000 ->
198-
ct:fail("did not receive a delivery")
187+
#{topic := MqttTopic,
188+
payload := MqttPayload}} ->
189+
?assertEqual(Topic, MqttTopic),
190+
?assertEqual(Payload, MqttPayload)
191+
after 5000 ->
192+
ct:fail("did not receive a delivery")
199193
end,
200194

201-
amqp_channel:call(Ch, #'queue.delete'{queue = Q}),
202-
rabbit_ct_client_helpers:close_channel(Ch),
195+
ok = rabbit_ct_client_helpers:close_channel(Ch),
203196
ok = emqtt:disconnect(C).
204197

205198
mqtt_amqp_mqtt(Config) ->

0 commit comments

Comments
 (0)