98 lines
2.3 KiB
Erlang
98 lines
2.3 KiB
Erlang
-module(api_SUITE).
|
|
-include_lib("common_test/include/ct.hrl").
|
|
|
|
-export([all/0, init_per_suite/1, end_per_suite/1]).
|
|
-export([auth_test/1, calendar_test/1, event_test/1, booking_test/1]).
|
|
-export([search_test/1, reviews_test/1, moderation_test/1]).
|
|
-export([tickets_test/1, subscription_test/1, admin_test/1]).
|
|
-export([websocket_test/1]).
|
|
|
|
all() -> [
|
|
auth_test,
|
|
calendar_test,
|
|
event_test,
|
|
booking_test,
|
|
search_test,
|
|
reviews_test,
|
|
moderation_test,
|
|
tickets_test,
|
|
subscription_test,
|
|
admin_test,
|
|
websocket_test
|
|
].
|
|
|
|
init_per_suite(Config) ->
|
|
% Очищаем Mnesia перед тестами
|
|
io:format("~n=== Cleaning Mnesia for fresh test run ===~n"),
|
|
os:cmd("rm -rf Mnesia.* 2>/dev/null || true"),
|
|
timer:sleep(2000),
|
|
% Запускаем сервер
|
|
io:format("Starting server...~n"),
|
|
{ok, _Apps} = application:ensure_all_started(eventhub),
|
|
|
|
% Компилируем модули из test/api/
|
|
code:add_patha("_build/test/lib/eventhub/ebin"),
|
|
code:add_patha("test/api"),
|
|
|
|
% Компилируем все файлы в test/api/
|
|
compile_api_modules(),
|
|
|
|
inets:start(),
|
|
ssl:start(),
|
|
|
|
%% Perform healthcheck (simplified)
|
|
Url = "http://localhost:8080",
|
|
case httpc:request(get, {Url ++ "/health", []}, [], []) of
|
|
{ok, {{_Version, 200, _Reason}, _Headers, _Body}} ->
|
|
ok; %% Healthcheck passed
|
|
_Error ->
|
|
ct:log("Healthcheck failed for: ~p", [Url]),
|
|
error(healthcheck_failed)
|
|
end,
|
|
Config.
|
|
|
|
end_per_suite(_Config) ->
|
|
application:stop(eventhub),
|
|
ok.
|
|
|
|
compile_api_modules() ->
|
|
Files = filelib:wildcard("test/api/*.erl"),
|
|
lists:foreach(fun(File) ->
|
|
compile:file(File, [report, {outdir, "test/api"}])
|
|
end, Files),
|
|
code:add_patha("test/api").
|
|
|
|
%% ============ ТЕСТЫ-ПРОКСИ ============
|
|
|
|
auth_test(_Config) ->
|
|
api_auth_tests:test().
|
|
|
|
calendar_test(_Config) ->
|
|
api_calendar_tests:test().
|
|
|
|
event_test(_Config) ->
|
|
api_event_tests:test().
|
|
|
|
booking_test(_Config) ->
|
|
api_booking_tests:test().
|
|
|
|
search_test(_Config) ->
|
|
api_search_tests:test().
|
|
|
|
reviews_test(_Config) ->
|
|
api_reviews_tests:test().
|
|
|
|
moderation_test(_Config) ->
|
|
api_moderation_tests:test().
|
|
|
|
tickets_test(_Config) ->
|
|
api_tickets_tests:test().
|
|
|
|
subscription_test(_Config) ->
|
|
api_subscription_tests:test().
|
|
|
|
admin_test(_Config) ->
|
|
api_admin_tests:test().
|
|
|
|
websocket_test(_Config) ->
|
|
api_websocket_tests:test(). |