This commit is contained in:
2026-04-20 21:04:16 +03:00
parent b24cbc97f3
commit 19f82768e4
18 changed files with 1851 additions and 131 deletions

View File

@@ -0,0 +1,23 @@
-module(handler_search_tests).
-include_lib("eunit/include/eunit.hrl").
handler_search_test_() ->
case is_server_running() of
true ->
[
{"Search API requires authentication", fun test_search_requires_auth/0}
];
false ->
io:format("Skipping handler tests: server not running~n"),
[]
end.
is_server_running() ->
case httpc:request(get, {"http://localhost:8080/health", []}, [], [{timeout, 1000}]) of
{ok, {{_, 200, _}, _, _}} -> true;
_ -> false
end.
test_search_requires_auth() ->
{ok, {{_, 401, _}, _, Body}} = httpc:request(get, {"http://localhost:8080/v1/search?type=event", []}, [], []),
?assertMatch(#{<<"error">> := _}, jsx:decode(Body, [return_maps])).