Add function test and feature to remove sprinkler
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
NADAL Jean-Baptiste
2020-01-09 10:58:37 +01:00
parent ca029ca190
commit 0291ee9c4d
3 changed files with 35 additions and 12 deletions

View File

@@ -74,7 +74,7 @@ void device_create_set_state_free(const char *capability, const char *test_name_
/*--------------------------------------------------------------------------*/
void device_create_three_devices_remove_second(const char *capability, const char *test_array)
void device_create_three_devices_remove_second(const char *capability, const char *test_array_full, const char *test_array_removed)
{
struct json_object *root_node;
devices_manager_t *dm;
@@ -111,7 +111,12 @@ void device_create_three_devices_remove_second(const char *capability, const cha
json_object_put(root_node);
ASSERT_EQUAL_INT(ret, 0);
// Remove ID 1.
device_serialized = devices_manager_get(dm, capability);
// printf ("device: %s\n", device_serialized);
ASSERT_EQUAL_STR(device_serialized, test_array_full);
free(device_serialized);
// Remove ID 2.
root_node = json_object_new_object();
json_object_object_add(root_node, k_entry_id, json_object_new_int(2));
ret = devices_manager_delete(dm, capability, root_node);
@@ -120,7 +125,7 @@ void device_create_three_devices_remove_second(const char *capability, const cha
device_serialized = devices_manager_get(dm, capability);
// printf ("device: %s\n", device_serialized);
ASSERT_EQUAL_STR(device_serialized, test_array);
ASSERT_EQUAL_STR(device_serialized, test_array_removed);
free(device_serialized);
// Free the Object.

View File

@@ -29,7 +29,8 @@
#define kSprinklerTestNameTrue "{ \"id\": 1, \"name\": \"test_name\", \"state\": true }"
#define kSprinklerTestNameFalse "{ \"id\": 1, \"name\": \"test_name\", \"state\": false }"
#define kSprinklerTestRemove "[ { \"id\": 1, \"name\": \"test1\", \"state\": false }, { \"id\": 3, \"name\": \"test3\", \"state\": false } ]"
#define kSprinklerTestNameFull "[ { \"id\": 1, \"name\": \"test1\", \"state\": false }, { \"id\": 2, \"name\": \"test2\", \"state\": false }, { \"id\": 3, \"name\": \"test3\", \"state\": false } ]"
#define kSprinklerTestRemoved "[ { \"id\": 1, \"name\": \"test1\", \"state\": false }, { \"id\": 3, \"name\": \"test3\", \"state\": false } ]"
/*--------------------------------------------------------------------------*/
@@ -42,7 +43,7 @@ TEST("Sprinkler - create set_state free\t")
TEST("Sprinkler - create 3 device remove 2\t")
{
device_create_three_devices_remove_second(kSprinklerEntry, kSprinklerTestRemove);
device_create_three_devices_remove_second(kSprinklerEntry, kSprinklerTestNameFull, kSprinklerTestRemoved);
}
/*--------------------------------------------------------------------------*/