http: Add a more expressive but still nowhere near regex URL pattern matcher.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 14m57s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 14m57s
This commit is contained in:
22
src/tests.c
22
src/tests.c
@ -4,8 +4,8 @@
|
||||
#include "http.h"
|
||||
#include "log.h"
|
||||
#include "mem.h"
|
||||
#include "ssb.h"
|
||||
#include "ssb.db.h"
|
||||
#include "ssb.h"
|
||||
#include "ssb.tests.h"
|
||||
#include "util.js.h"
|
||||
|
||||
@ -850,16 +850,14 @@ static void _test_httpd(const tf_test_options_t* options)
|
||||
char command[256];
|
||||
snprintf(command, sizeof(command), "%s run -b 0 --db-path=out/test_db0.sqlite" TEST_ARGS, options->exe_path);
|
||||
|
||||
uv_stdio_container_t stdio[] =
|
||||
{
|
||||
uv_stdio_container_t stdio[] = {
|
||||
[STDIN_FILENO] = { .flags = UV_IGNORE },
|
||||
[STDOUT_FILENO] = { .flags = UV_INHERIT_FD },
|
||||
[STDERR_FILENO] = { .flags = UV_INHERIT_FD },
|
||||
};
|
||||
uv_process_t process = { 0 };
|
||||
uv_spawn(&loop, &process,
|
||||
&(uv_process_options_t)
|
||||
{
|
||||
&(uv_process_options_t) {
|
||||
.file = options->exe_path,
|
||||
.args = (char*[]) { (char*)options->exe_path, "run", "-b0", "--db-path=out/test_db0.sqlite", "--http-port=8080", "--https-port=0", NULL },
|
||||
.stdio_count = sizeof(stdio) / sizeof(*stdio),
|
||||
@ -906,6 +904,19 @@ static void _test_httpd(const tf_test_options_t* options)
|
||||
uv_loop_close(&loop);
|
||||
}
|
||||
|
||||
static void _test_pattern(const tf_test_options_t* options)
|
||||
{
|
||||
assert(tf_http_pattern_matches("/~core/test/", "/~core/test/"));
|
||||
assert(tf_http_pattern_matches("/~core/test/*", "/~core/test/"));
|
||||
assert(tf_http_pattern_matches("/~core/test/*", "/~core/test/blah"));
|
||||
assert(tf_http_pattern_matches("*/~core/test/", "/~core/test/"));
|
||||
assert(tf_http_pattern_matches("*/~core/test/", "blah/~core/test/"));
|
||||
assert(tf_http_pattern_matches("/~*/*/", "/~core/test/"));
|
||||
assert(tf_http_pattern_matches("/~{word}/*", "/~core/test"));
|
||||
assert(tf_http_pattern_matches("/~{word}/{word}/", "/~core/test/"));
|
||||
assert(tf_http_pattern_matches("/~{word}/{word}", "/~core/test"));
|
||||
}
|
||||
|
||||
static void _test_auto_process_exit(uv_process_t* process, int64_t status, int termination_signal)
|
||||
{
|
||||
tf_printf("Process exit %d signal=%d.\n", (int)WEXITSTATUS(status), termination_signal);
|
||||
@ -1012,6 +1023,7 @@ void tf_tests(const tf_test_options_t* options)
|
||||
_tf_test_run(options, "bip39", _test_bip39, false);
|
||||
_tf_test_run(options, "http", _test_http, false);
|
||||
_tf_test_run(options, "httpd", _test_httpd, false);
|
||||
_tf_test_run(options, "pattern", _test_pattern, false);
|
||||
_tf_test_run(options, "ssb", tf_ssb_test_ssb, false);
|
||||
_tf_test_run(options, "ssb_id", tf_ssb_test_id_conversion, false);
|
||||
_tf_test_run(options, "ssb_following", tf_ssb_test_following, false);
|
||||
|
Reference in New Issue
Block a user