test domo: add capabilities
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:
@@ -25,7 +25,24 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
char *load_capabilities(devices_manager_t *dm)
|
||||
{
|
||||
int s;
|
||||
FILE *f;
|
||||
char buf[1024];
|
||||
char *capabilities;
|
||||
|
||||
f = fopen(dm->capabilities_path, "rb");
|
||||
if (f == NULL)
|
||||
return NULL;
|
||||
|
||||
s = fread(buf, 1, sizeof(buf), f);
|
||||
fclose(f);
|
||||
buf[s] = '\0';
|
||||
capabilities = strdup(buf);
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
@@ -46,8 +63,9 @@ TEST("Domo - Test API correct access\t")
|
||||
struct event_base *ev_base;
|
||||
restd_server_t *rest_server;
|
||||
devices_manager_t *dm;
|
||||
char *config_path;
|
||||
char *config_path, *capabilities_path;
|
||||
int ret;
|
||||
char *capabilities;
|
||||
|
||||
dm = devices_manager_new();
|
||||
ASSERT_NOT_NULL(dm);
|
||||
@@ -64,8 +82,26 @@ TEST("Domo - Test API correct access\t")
|
||||
config_path = get_config_path();
|
||||
ASSERT_NOT_NULL(config_path);
|
||||
|
||||
capabilities_path = qstrdupf("%s/capabilities.json", config_path);
|
||||
|
||||
devices_manager_set_capabilities_path(dm, capabilities_path);
|
||||
free(capabilities_path);
|
||||
|
||||
ret = setup_rest_server(rest_server, kserver_port, config_path, dm);
|
||||
ASSERT_EQUAL_INT(ret, 0);
|
||||
|
||||
restd_server_set_option(rest_server, "server.thread", "1");
|
||||
|
||||
ret = restd_server_start(rest_server);
|
||||
ASSERT_EQUAL_INT(ret, 0);
|
||||
|
||||
sleep(1);
|
||||
|
||||
capabilities = load_capabilities(dm);
|
||||
ASSERT_NOT_NULL(capabilities);
|
||||
ret = exec_request(kget_method, "http://localhost:" kserver_port "/api/v1/capabilities", 200, "", capabilities, false);
|
||||
ASSERT_EQUAL_INT(ret, 0);
|
||||
free(capabilities);
|
||||
|
||||
// TODO
|
||||
|
||||
@@ -73,3 +109,4 @@ TEST("Domo - Test API correct access\t")
|
||||
devices_manager_free(dm);
|
||||
free(config_path);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user