wip to remove device
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2020-01-09 00:20:00 +01:00
parent 5912d1421e
commit 142c804939
6 changed files with 239 additions and 32 deletions

View File

@@ -74,8 +74,58 @@ void device_create_set_state_free(const char *capability, const char *test_name_
/*--------------------------------------------------------------------------*/
void device_create_three_devices_remove_second(const char *capability)
void device_create_three_devices_remove_second(const char *capability, const char *test_array)
{
struct json_object *root_node;
devices_manager_t *dm;
int ret;
char *device_serialized;
dm = devices_manager_new();
ASSERT_NOT_NULL(dm);
// Create a New Entry 1.
root_node = json_object_new_object();
json_object_object_add(root_node, k_entry_name, json_object_new_string("test1"));
ret = devices_manager_create(dm, capability, root_node);
/* Clean the json object. */
json_object_put(root_node);
ASSERT_EQUAL_INT(ret, 0);
// Create a New Entry 2.
root_node = json_object_new_object();
json_object_object_add(root_node, k_entry_name, json_object_new_string("test2"));
ret = devices_manager_create(dm, capability, root_node);
/* Clean the json object. */
json_object_put(root_node);
ASSERT_EQUAL_INT(ret, 0);
// Create a New Entry 3.
root_node = json_object_new_object();
json_object_object_add(root_node, k_entry_name, json_object_new_string("test3"));
ret = devices_manager_create(dm, capability, root_node);
/* Clean the json object. */
json_object_put(root_node);
ASSERT_EQUAL_INT(ret, 0);
// Remove ID 1.
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);
json_object_put(root_node);
ASSERT_EQUAL_INT(ret, 0);
device_serialized = devices_manager_get(dm, capability);
// printf ("device: %s\n", device_serialized);
ASSERT_EQUAL_STR(device_serialized, test_array);
free(device_serialized);
// Free the Object.
devices_manager_free(dm);
}