summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/luaquerymapper.cc29
1 files changed, 28 insertions, 1 deletions
diff --git a/server/src/luaquerymapper.cc b/server/src/luaquerymapper.cc
index f593c28..56b7c1b 100644
--- a/server/src/luaquerymapper.cc
+++ b/server/src/luaquerymapper.cc
@@ -228,6 +228,8 @@ TEST_BEGIN;
time_t now = time(NULL);
{
+ LUAQueryMapper mapper;
+
QueryResult res;
res.groups["test"].timestamp = now;
res.groups["test"].source = "test app";
@@ -240,9 +242,18 @@ time_t now = time(NULL);
res.groups["test"].groups["subtest"].groups["subsubtest"].timestamp = now + 2;
res.groups["test"].groups["subtest"].groups["subsubtest"].values["somevalue"] = "hello world!!";
- LUAQueryMapper mapper;
mapper.addQueryResult(res);
+ QueryResult res2;
+ res2.groups["test"].groups["subtest"].source = "src";
+ res2.groups["test"].groups["subtest"].timestamp = now + 3;
+ res2.groups["test"].groups["subtest"].values["val"] = "gnaf";
+ res2.groups["test"].groups["subgrp"].source = "src2";
+ res2.groups["test"].groups["subgrp"].timestamp = now + 4;
+ res2.groups["test"].groups["subgrp"].values["val2"] = "gnaf2";
+
+ mapper.addQueryResult(res2);
+
// Test simple value forwarding with nesting
std::string luamap = "return test.subtest.subsubtest.somevalue.value, test.subtest.subsubtest.somevalue.timestamp, test.subtest.subsubtest.somevalue.source";
@@ -275,6 +286,22 @@ time_t now = time(NULL);
TEST_EQUAL_STR(value.value, "3.14", "Test value");
TEST_EQUAL_INT(value.timestamp, now, "Test timestamp");
TEST_EQUAL_STR(value.source, "test app", "Test source");
+
+ luamap = "return test.subtest.val.value, test.subtest.val.timestamp, test.subtest.val.source";
+
+ value = mapper.map(luamap);
+
+ TEST_EQUAL_STR(value.value, "gnaf", "Test value");
+ TEST_EQUAL_INT(value.timestamp, now + 3, "Test timestamp");
+ TEST_EQUAL_STR(value.source, "src", "Test source");
+
+ luamap = "return test.subgrp.val2.value, test.subgrp.val2.timestamp, test.subgrp.val2.source";
+
+ value = mapper.map(luamap);
+
+ TEST_EQUAL_STR(value.value, "gnaf2", "Test value");
+ TEST_EQUAL_INT(value.timestamp, now + 4, "Test timestamp");
+ TEST_EQUAL_STR(value.source, "src2", "Test source");
}
QueryResult res;