1#include "rpc.h"
2
3#define CTEST_MAIN
4#include "ctest.h"
5
6#include "common.h"
7
8cstr content = "content";
9cstr uri = "wss://gem.vrtql.com:2020";
10
11CTEST_DATA(test)
12{
13 vws_cnx* c;
14 vrtql_rpc* rpc;
15};
16
17CTEST_SETUP(test)
18{
19 data->c = vws_cnx_new();
20 ASSERT_TRUE(data->c != NULL);
21 ASSERT_TRUE(vws_connect(data->c, uri));
22
23 data->rpc = vrtql_rpc_new(data->c);
24
25 // Enable tracing
26 vws.tracelevel = VT_PROTOCOL;
27}
28
29CTEST_TEARDOWN(test)
30{
31 vws_cnx_free(data->c);
32 vrtql_rpc_free(data->rpc);
33}
34
35CTEST2(test, basic)
36{
37 // Create request message
38 vrtql_msg* req = vrtql_msg_new();
39 vrtql_msg_set_header(req, "id", "vql");
40
41 // Headers for authentication
42 vrtql_msg_set_header(req, "username", "vrtql");
43 vrtql_msg_set_header(req, "password", "vrtql");
44 vrtql_msg_set_header(req, "domain", "global");
45
46 // VQL command to execute
47 vrtql_msg_set_content(req, "sql select * from solari");
48
49 vrtql_msg* reply = vrtql_rpc_exec(data->rpc, req);
50 ASSERT_TRUE(reply != NULL);
51 vrtql_msg_dump(reply);
52
53 vrtql_msg_free(req);
54 vrtql_msg_free(reply);
55}
56
57int main(int argc, const char* argv[])
58{
59 return ctest_main(argc, argv);
60}
61