This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
#include <qlibc/qlibc.h>
|
||||
#include <json.h>
|
||||
|
||||
#include <restd.h>
|
||||
|
||||
#include "qunit.h"
|
||||
|
||||
#include "domo.h"
|
||||
@@ -51,6 +53,7 @@ TEST("devices_manager create and free\t")
|
||||
#include "test_sprinkler.c"
|
||||
#include "test_shutter.c"
|
||||
#include "test_outlet.c"
|
||||
#include "test_rest.c"
|
||||
|
||||
#if 0
|
||||
|
||||
|
||||
70
src/tests/test_rest.c
Normal file
70
src/tests/test_rest.c
Normal file
@@ -0,0 +1,70 @@
|
||||
/*!
|
||||
* test_rest.c
|
||||
*
|
||||
* Copyright (c) 2015-2020, NADAL Jean-Baptiste. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* @Author: NADAL Jean-Baptiste
|
||||
* @Date: 08/01/2020
|
||||
*
|
||||
*/
|
||||
|
||||
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
|
||||
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
int my_test_handler(short event, restd_conn_t *conn, void *userdata)
|
||||
{
|
||||
restd_http_response(conn, 200, "application/json", "{\"status\":\"error\"}", 18);
|
||||
return RESTD_CLOSE; // Close connection.
|
||||
}
|
||||
|
||||
|
||||
TEST("Rest - create free\t")
|
||||
{
|
||||
restd_server_t *rest_server;
|
||||
|
||||
rest_server = restd_server_new();
|
||||
ASSERT_NOT_NULL(rest_server);
|
||||
|
||||
restd_server_set_option(rest_server, "server.port", "7777");
|
||||
|
||||
restd_server_register_hook_on_path(rest_server, "POST", "/api/v1/test", my_test_handler, NULL);
|
||||
|
||||
|
||||
restd_server_free(rest_server);
|
||||
}
|
||||
|
||||
TEST("Rest - create free\t")
|
||||
{
|
||||
restd_server_t *rest_server;
|
||||
|
||||
rest_server = restd_server_new();
|
||||
ASSERT_NOT_NULL(rest_server);
|
||||
|
||||
restd_server_set_option(rest_server, "server.port", "7777");
|
||||
|
||||
restd_server_register_hook_on_path(rest_server, "POST", "/api/v1/test", my_test_handler, NULL);
|
||||
restd_server_register_hook_on_path(rest_server, "GET", "/api/v1/test", my_test_handler, NULL);
|
||||
restd_server_register_hook_on_path(rest_server, "GET", "/api/v1/test/:id", my_test_handler, NULL);
|
||||
restd_server_register_hook_on_path(rest_server, "PUT", "/api/v1/test/:id", my_test_handler, NULL);
|
||||
restd_server_register_hook_on_path(rest_server, "DELETE", "/api/v1/test/:id", my_test_handler, NULL);
|
||||
|
||||
|
||||
restd_server_free(rest_server);
|
||||
}
|
||||
Reference in New Issue
Block a user