Update outlet and shutter tests.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
|
||||
#define kOutletTestNameTrue "{ \"id\": 1, \"name\": \"test_name\", \"state\": true, \"zone\": \"\", \"sender\": 0, \"switch\": 0 }"
|
||||
#define kOutletTestNameFalse "{ \"id\": 1, \"name\": \"test_name\", \"state\": false, \"zone\": \"\", \"sender\": 0, \"switch\": 0 }"
|
||||
#define kOutletTestNameFullFalse "{ \"id\": 1, \"name\": \"test_name\", \"speech_name\": \"speech_name\", \"state\": false, \"zone\": \"zone\", \"sender\": 123456, \"switch\": 77 }"
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
@@ -56,3 +57,45 @@ TEST("Outlet - update - Error case\t")
|
||||
{
|
||||
device_get_by_id_error_case(kOutletEntry);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
TEST("Outlet - update - Error case\t")
|
||||
{
|
||||
device_get_by_id_error_case(kOutletEntry);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
TEST("Outlet - create - with all field\t")
|
||||
{
|
||||
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.
|
||||
root_node = json_object_new_object();
|
||||
json_object_object_add(root_node, k_entry_name, json_object_new_string("test_name"));
|
||||
json_object_object_add(root_node, k_entry_speech_name, json_object_new_string("speech_name"));
|
||||
|
||||
json_object_object_add(root_node, k_entry_zone, json_object_new_string("zone"));
|
||||
json_object_object_add(root_node, k_entry_sender, json_object_new_int(123456));
|
||||
json_object_object_add(root_node, k_entry_switch, json_object_new_int(77));
|
||||
|
||||
ret = devices_manager_create(dm, kOutletEntry, root_node);
|
||||
ASSERT_EQUAL_INT(ret, 0);
|
||||
|
||||
// Check Objets.
|
||||
device_serialized = devices_manager_get_by_id(dm, kOutletEntry, 1);
|
||||
// printf ("device: %s\n", device_serialized);
|
||||
ASSERT_EQUAL_STR(device_serialized, kOutletTestNameFullFalse);
|
||||
free(device_serialized);
|
||||
|
||||
json_object_put(root_node);
|
||||
|
||||
// Free the Object.
|
||||
devices_manager_free(dm);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#define kShutterTestNameTrue "{ \"id\": 1, \"name\": \"test_name\", \"state\": true, \"zone\": \"\", \"sender\": 0, \"switch\": 0, \"speed_up\": 0, \"speed_down\": 0 }"
|
||||
#define kShutterTestNameFalse "{ \"id\": 1, \"name\": \"test_name\", \"state\": false, \"zone\": \"\", \"sender\": 0, \"switch\": 0, \"speed_up\": 0, \"speed_down\": 0 }"
|
||||
#define kShutterTestNameFullFalse "{ \"id\": 1, \"name\": \"test_name\", \"state\": false, \"zone\": \"zone\", \"sender\": 123456, \"switch\": 77, \"speed_up\": 50, \"speed_down\": 60 }"
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
@@ -56,3 +57,38 @@ TEST("Shutter - update - Error case\t")
|
||||
{
|
||||
device_get_by_id_error_case(kShutterEntry);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
TEST("Shutter - create - with all field\t")
|
||||
{
|
||||
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.
|
||||
root_node = json_object_new_object();
|
||||
json_object_object_add(root_node, k_entry_name, json_object_new_string("test_name"));
|
||||
json_object_object_add(root_node, k_entry_zone, json_object_new_string("zone"));
|
||||
json_object_object_add(root_node, k_entry_sender, json_object_new_int(123456));
|
||||
json_object_object_add(root_node, k_entry_switch, json_object_new_int(77));
|
||||
json_object_object_add(root_node, k_entry_speed_up, json_object_new_int(50));
|
||||
json_object_object_add(root_node, k_entry_speed_down, json_object_new_int(60));
|
||||
|
||||
ret = devices_manager_create(dm, kShutterEntry, root_node);
|
||||
ASSERT_EQUAL_INT(ret, 0);
|
||||
|
||||
// Check Objets.
|
||||
device_serialized = devices_manager_get_by_id(dm, kShutterEntry, 1);
|
||||
// printf ("device: %s\n", device_serialized);
|
||||
ASSERT_EQUAL_STR(device_serialized, kShutterTestNameFullFalse);
|
||||
free(device_serialized);
|
||||
|
||||
json_object_put(root_node);
|
||||
|
||||
// Free the Object.
|
||||
devices_manager_free(dm);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user