test: add test case for error when bridge name is too long

This commit is contained in:
Kjell Winblad 2023-06-05 17:02:08 +02:00
parent c2c87d276f
commit 375661c6a1
1 changed files with 20 additions and 0 deletions

View File

@ -415,6 +415,26 @@ t_http_crud_apis(Config) ->
),
%% Test bad updates
%% ================
%% Add bridge with a name that is too long
%% We only support bridge names up to 255 characters
LongName = list_to_binary(lists:duplicate(256, $a)),
NameTooLongRequestResult = request_json(
post,
uri(["bridges"]),
?HTTP_BRIDGE(URL1, LongName),
Config
),
?assertMatch(
{ok, 400, _},
NameTooLongRequestResult
),
{ok, 400, #{<<"message">> := NameTooLongMessage}} = NameTooLongRequestResult,
%% Use regex to check that the message contains the name
Match = re:run(NameTooLongMessage, LongName),
?assertMatch({match, _}, Match),
%% Add bridge without the URL field
{ok, 400, PutFail1} = request_json(
put,
uri(["bridges", BridgeID]),