mirror of
https://github.com/lammertb/libhttp.git
synced 2026-01-03 16:02:30 +03:00
Add some CI tests
This commit is contained in:
@@ -93,7 +93,8 @@ macro(civetweb_add_test suite test_case)
|
||||
endmacro(civetweb_add_test)
|
||||
|
||||
# Public API tests
|
||||
civetweb_add_test(Public Cookies)
|
||||
civetweb_add_test(Public "Cookies")
|
||||
civetweb_add_test(Public "Start Stop Server")
|
||||
|
||||
# Private API tests
|
||||
civetweb_add_test(Private "HTTP Message")
|
||||
|
||||
@@ -82,6 +82,7 @@ START_TEST (test_parse_http_message)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (test_match_prefix)
|
||||
{
|
||||
ck_assert_int_eq(4, match_prefix("/api", 4, "/api"));
|
||||
@@ -115,6 +116,7 @@ START_TEST (test_match_prefix)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (test_remove_double_dots_and_double_slashes)
|
||||
{
|
||||
struct {
|
||||
@@ -140,16 +142,29 @@ START_TEST (test_remove_double_dots_and_double_slashes)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
Suite * make_private_suite (void) {
|
||||
Suite * const suite = suite_create("Private");
|
||||
|
||||
START_TEST (test_is_valid_uri)
|
||||
{
|
||||
ck_assert_int_eq(1, is_valid_uri("/api"));
|
||||
ck_assert_int_eq(0, is_valid_uri("api"));
|
||||
ck_assert_int_eq(1, is_valid_uri("*"));
|
||||
ck_assert_int_eq(0, is_valid_uri("*xy"));
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
Suite * make_private_suite (void) {
|
||||
|
||||
Suite * const suite = suite_create("Private");
|
||||
TCase * const http_message = tcase_create("HTTP Message");
|
||||
TCase * const url_parsing = tcase_create("URL Parsing");
|
||||
|
||||
tcase_add_test(http_message, test_parse_http_message);
|
||||
suite_add_tcase(suite, http_message);
|
||||
|
||||
TCase * const url_parsing = tcase_create("URL Parsing");
|
||||
tcase_add_test(url_parsing, test_match_prefix);
|
||||
tcase_add_test(url_parsing, test_remove_double_dots_and_double_slashes);
|
||||
tcase_add_test(url_parsing, test_is_valid_uri);
|
||||
suite_add_tcase(suite, url_parsing);
|
||||
|
||||
return suite;
|
||||
|
||||
@@ -57,7 +57,7 @@ START_TEST (test_mg_get_cookie)
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (test_mg_start_stop_server)
|
||||
START_TEST (test_mg_start_stop_http_server)
|
||||
{
|
||||
struct mg_context *ctx;
|
||||
const char *OPTIONS[] = {
|
||||
@@ -73,18 +73,36 @@ START_TEST (test_mg_start_stop_server)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_mg_start_stop_https_server)
|
||||
{
|
||||
struct mg_context *ctx;
|
||||
const char *OPTIONS[] = {
|
||||
"document_root", ".",
|
||||
"listening_ports", "8080",
|
||||
"ssl_certificate", "../resources/ssl_cert.pem",
|
||||
NULL,
|
||||
};
|
||||
|
||||
ctx = mg_start(NULL, NULL, OPTIONS);
|
||||
ck_assert(ctx != NULL);
|
||||
mg_Sleep(2);
|
||||
mg_stop(ctx);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
Suite * make_public_suite (void) {
|
||||
|
||||
Suite * const suite = suite_create("Public");
|
||||
TCase * const cookies = tcase_create("Cookies");
|
||||
TCase * const startserver = tcase_create("StartServer");
|
||||
TCase * const startstop = tcase_create("Start Stop Server");
|
||||
|
||||
tcase_add_test(cookies, test_mg_get_cookie);
|
||||
suite_add_tcase(suite, cookies);
|
||||
|
||||
tcase_add_test(startserver, test_mg_start_stop_server);
|
||||
suite_add_tcase(suite, startserver);
|
||||
tcase_add_test(startstop, test_mg_start_stop_http_server);
|
||||
tcase_add_test(startstop, test_mg_start_stop_https_server);
|
||||
suite_add_tcase(suite, startstop);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user