fix(delayed): fix http 500 error
This commit is contained in:
parent
b16920e796
commit
eea0ec135f
|
@ -329,6 +329,12 @@ generate_http_code_map(message_not_found, Topic) ->
|
||||||
message =>
|
message =>
|
||||||
iolist_to_binary(io_lib:format("Not found messages for ~s", [Topic]))
|
iolist_to_binary(io_lib:format("Not found messages for ~s", [Topic]))
|
||||||
};
|
};
|
||||||
|
generate_http_code_map(invalid_topic_name, Topic) ->
|
||||||
|
#{
|
||||||
|
code => ?INVALID_TOPIC,
|
||||||
|
message =>
|
||||||
|
iolist_to_binary(io_lib:format("The topic name ~s is invalid", [Topic]))
|
||||||
|
};
|
||||||
generate_http_code_map(invalid_node, Node) ->
|
generate_http_code_map(invalid_node, Node) ->
|
||||||
#{
|
#{
|
||||||
code => ?INVALID_NODE,
|
code => ?INVALID_NODE,
|
||||||
|
|
|
@ -211,6 +211,25 @@ t_delete_messages_via_topic(_) ->
|
||||||
|
|
||||||
%% assert: messages are deleted
|
%% assert: messages are deleted
|
||||||
?assertEqual([], get_messages(0)),
|
?assertEqual([], get_messages(0)),
|
||||||
|
|
||||||
|
%% assert: return 400 if the topic parameter is invalid
|
||||||
|
TopicFilter = uri_string:quote(<<"t/#">>),
|
||||||
|
?assertMatch(
|
||||||
|
{ok, 400, _},
|
||||||
|
request(
|
||||||
|
delete,
|
||||||
|
uri(["mqtt", "delayed", "messages", TopicFilter])
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
%% assert: return 404 if no messages found for the topic
|
||||||
|
?assertMatch(
|
||||||
|
{ok, 404, _},
|
||||||
|
request(
|
||||||
|
delete,
|
||||||
|
uri(["mqtt", "delayed", "messages", TopicInUrl])
|
||||||
|
)
|
||||||
|
),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
t_large_payload(_) ->
|
t_large_payload(_) ->
|
||||||
|
|
Loading…
Reference in New Issue