add: init unit test
This commit is contained in:
parent
636fdf8df1
commit
320201bb5b
5 changed files with 40 additions and 63 deletions
55
config.json
55
config.json
|
@ -6,58 +6,7 @@
|
|||
"https": false
|
||||
}
|
||||
],
|
||||
"app": {
|
||||
"threads_num": 1,
|
||||
"enable_session": false,
|
||||
"session_timeout": 0,
|
||||
"document_root": "./static/",
|
||||
"home_page": "index.html",
|
||||
"upload_path": "uploads",
|
||||
"file_types": [
|
||||
"gif",
|
||||
"png",
|
||||
"jpg",
|
||||
"js",
|
||||
"css",
|
||||
"html",
|
||||
"ico",
|
||||
"swf",
|
||||
"xap",
|
||||
"apk",
|
||||
"cur",
|
||||
"xml"
|
||||
],
|
||||
"max_connections": 100000,
|
||||
"max_connections_per_ip": 0,
|
||||
"load_dynamic_views": false,
|
||||
"dynamic_views_path": [
|
||||
"./views"
|
||||
],
|
||||
"log": {
|
||||
"logfile_base_name": "",
|
||||
"log_size_limit": 100000000,
|
||||
"log_level": "DEBUG"
|
||||
},
|
||||
"run_as_daemon": false,
|
||||
"relaunch_on_error": false,
|
||||
"use_sendfile": true,
|
||||
"use_gzip": true,
|
||||
"static_files_cache_time": 5,
|
||||
"idle_connection_timeout": 60,
|
||||
"server_header_field": "",
|
||||
"keepalive_requests": 0,
|
||||
"pipelining_requests": 0,
|
||||
"gzip_static": true,
|
||||
"client_max_body_size": "1M",
|
||||
"client_max_memory_body_size": "64K",
|
||||
"client_max_websocket_message_size": "128K"
|
||||
},
|
||||
"plugins": [{
|
||||
"dependencies": [],
|
||||
"config": {
|
||||
"heartbeat_interval": 2
|
||||
"custom_config": {
|
||||
"db_name": "core.sqlite"
|
||||
}
|
||||
|
||||
}],
|
||||
"custom_config": {}
|
||||
}
|
||||
|
|
12
config.testing.json
Normal file
12
config.testing.json
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"listeners": [
|
||||
{
|
||||
"address": "0.0.0.0",
|
||||
"port": 5000,
|
||||
"https": false
|
||||
}
|
||||
],
|
||||
"custom_config": {
|
||||
"db_name": "core.testing.sqlite"
|
||||
}
|
||||
}
|
|
@ -70,5 +70,5 @@ helpers::migrate_sql()
|
|||
LOG_FATAL << "Couldn't write new Schema Version";
|
||||
}
|
||||
|
||||
return rc == SQLITE_DONE;
|
||||
return rc != SQLITE_DONE;
|
||||
}
|
||||
|
|
23
main.cc
23
main.cc
|
@ -29,31 +29,38 @@ terminate(int signum)
|
|||
}*/
|
||||
|
||||
int
|
||||
main()
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
signal(SIGINT, terminate);
|
||||
signal(SIGABRT, terminate);
|
||||
signal(SIGTERM, terminate);
|
||||
signal(SIGKILL, terminate);
|
||||
|
||||
int rc;
|
||||
const char* config_file_name = "config.json";
|
||||
|
||||
if(argc == 2)
|
||||
{
|
||||
config_file_name = argv[1];
|
||||
}
|
||||
|
||||
//Load config file
|
||||
drogon::app().loadConfigFile(config_file_name);
|
||||
|
||||
const char* db_name = drogon::app().instance().getCustomConfig()["db_name"].asCString();
|
||||
|
||||
/* Open database */
|
||||
rc = sqlite3_open("core.sqlite", &globals::db);
|
||||
int rc = sqlite3_open(db_name, &globals::db);
|
||||
|
||||
if( rc ) {
|
||||
if(rc) {
|
||||
LOG_FATAL << "Can't open database: " << sqlite3_errmsg(globals::db);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!helpers::migrate_sql())
|
||||
if(helpers::migrate_sql())
|
||||
{
|
||||
terminate(1);
|
||||
}
|
||||
|
||||
//Load config file
|
||||
drogon::app().loadConfigFile("config.json");
|
||||
|
||||
drogon::app().registerPostHandlingAdvice(add_cors_headers);
|
||||
drogon::app().instance().setCustom404Page(drogon::HttpResponse::newFileResponse("./static/index.html", "", drogon::CT_TEXT_HTML));
|
||||
|
||||
|
|
9
tavern_tests/test_minimal.tavern.yaml
Normal file
9
tavern_tests/test_minimal.tavern.yaml
Normal file
|
@ -0,0 +1,9 @@
|
|||
test_name: Test basic requests
|
||||
|
||||
stages:
|
||||
- name: Make sure we get any response
|
||||
request:
|
||||
url: http://localhost:5000/api/v1/schedules/
|
||||
method: GET
|
||||
response:
|
||||
status_code: 200
|
Loading…
Reference in a new issue