Files
EventHubBack/test/unit/handler_search_tests.erl
T
aleksey 0e4e886cd4
CI / test (push) Successful in 8m35s
CI / deploy-ift (push) Successful in 21m2s
CI / e2e-ift (push) Successful in 2m3s
CI / deploy-stage (push) Successful in 2m9s
CI / e2e-stage (push) Successful in 1m16s
feat(specialists): owner is non-deletable specialist on commercial create
Bootstrap calendar_specialist for owner (active); DELETE owner → 403;
toggle via status. Fixes solo assign-to-slot. Refs EventHub/EventHubBack#66
2026-08-01 12:18:36 +03:00

31 lines
951 B
Erlang

-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, {{_, Code, _}, _, Body0}} =
httpc:request(get, {"http://localhost:8080/v1/search?type=event", []}, [],
[{body_format, binary}]),
?assertEqual(401, Code),
Body = iolist_to_binary(Body0),
%% Dev proxy may return empty body; JSON error is preferred but not required.
case Body of
<<>> -> ok;
_ -> ?assertMatch(#{<<"error">> := _}, jsx:decode(Body, [return_maps]))
end.