Add Sprinkler Test.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
NADAL Jean-Baptiste
2020-02-25 18:44:00 +01:00
parent dfed6f6478
commit 5a5df0969f
4 changed files with 202 additions and 69 deletions

View File

@@ -139,8 +139,6 @@ TEST("Domo - Test API /api/v1/outlets - correct access\t")
sleep(1);
// Outlets
// Get All Devices. Should be empty.
ret = exec_request(kget_method, "http://localhost:" kserver_port "/api/v1/outlets", 200, "", k_outlet_list_empty, false);
ASSERT_EQUAL_INT(ret, 0);
@@ -180,3 +178,59 @@ TEST("Domo - Test API /api/v1/outlets - correct access\t")
restd_server_free(rest_server);
devices_manager_free(dm);
}
/*--------------------------------------------------------------------------*/
TEST("Domo - Test API /api/v1/sprinklers - correct access\t")
{
restd_server_t *rest_server;
devices_manager_t *dm;
int ret;
dm = devices_manager_new();
ASSERT_NOT_NULL(dm);
rest_server = setup_server(dm);
ASSERT_NOT_NULL(rest_server);
sleep(1);
// Get All Devices. Should be empty.
ret = exec_request(kget_method, "http://localhost:" kserver_port "/api/v1/sprinklers", 200, "", k_sprinkler_list_empty, false);
ASSERT_EQUAL_INT(ret, 0);
// Create An Outlet. Should be empty.
ret = exec_request(kpost_method, "http://localhost:" kserver_port "/api/v1/sprinklers", 204, k_create_sprinkler_1, "", false);
ASSERT_EQUAL_INT(ret, 0);
// Get All Devices. Should Contain One Device.
ret = exec_request(kget_method, "http://localhost:" kserver_port "/api/v1/sprinklers", 200, "", k_sprinkler_list_one_elem, false);
ASSERT_EQUAL_INT(ret, 0);
// Create A second Outlet. Should Contain two Device.
ret = exec_request(kpost_method, "http://localhost:" kserver_port "/api/v1/sprinklers", 204, k_create_sprinkler_2, "", false);
ASSERT_EQUAL_INT(ret, 0);
// Get All Devices. Should Contain two Devices.
ret = exec_request(kget_method, "http://localhost:" kserver_port "/api/v1/sprinklers", 200, "", k_sprinkler_list_two_elem, false);
ASSERT_EQUAL_INT(ret, 0);
// Update the second Outlet. Device should contain.
ret = exec_request(kput_method, "http://localhost:" kserver_port "/api/v1/sprinklers/2", 204, k_update_outlet_2, "", false);
ASSERT_EQUAL_INT(ret, 0);
// Get Device 2 only. Should Contain Device two updated.
ret = exec_request(kget_method, "http://localhost:" kserver_port "/api/v1/sprinklers/2", 200, "", k_sprinkler_list_elem_2, false);
ASSERT_EQUAL_INT(ret, 0);
// Delete Device 2.
ret = exec_request(kdelete_method, "http://localhost:" kserver_port "/api/v1/sprinklers/2", 204, "", "", false);
ASSERT_EQUAL_INT(ret, 0);
// Get All Devices. Should Contain One Device.
ret = exec_request(kget_method, "http://localhost:" kserver_port "/api/v1/sprinklers", 200, "", k_sprinkler_list_one_elem, false);
ASSERT_EQUAL_INT(ret, 0);
restd_server_free(rest_server);
devices_manager_free(dm);
}