aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-09-08 14:28:13 +0200
committerDan Engelbrecht <[email protected]>2025-09-08 14:28:13 +0200
commitb159b3fec828edc5b413ba0084921050d159c9ed (patch)
tree111dd20350b87be85da713a50c9970baeab37192 /src
parentfaster oplog entries with referenceset (#488) (diff)
downloadzen-de/json-to-cbobject-test.tar.xz
zen-de/json-to-cbobject-test.zip
add cloud query test casede/json-to-cbobject-test
Diffstat (limited to 'src')
-rw-r--r--src/zencore/compactbinaryjson.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/zencore/compactbinaryjson.cpp b/src/zencore/compactbinaryjson.cpp
index 02f22ba4d..911e6a3db 100644
--- a/src/zencore/compactbinaryjson.cpp
+++ b/src/zencore/compactbinaryjson.cpp
@@ -877,6 +877,40 @@ TEST_CASE("json.uson")
CHECK(Cb["value"sv].IsHash());
CHECK(Cb["value"sv].AsHash() == Hash);
}
+
+ SUBCASE("cloudquery")
+ {
+ std::string_view QueryJson =
+ "{\"bucketRegex\": \"fortnitegame.staged-build.*\", \"query\": {\"commit\": {\"$lte\": 45375501}, \"type\": {\"$eq\": "
+ "\"staged-build\"}, \"branch\": {\"$eq\": \"fortnite-main\"}, \"platform\": {\"$in\": [\"windows-server\", \"windows\", "
+ "\"windows-client\", \"windows-server\"]}}}";
+ CbObject Cb = LoadCompactBinaryFromJson(QueryJson).AsObject();
+ CHECK_EQ(Cb["bucketRegex"sv].AsString(), "fortnitegame.staged-build.*");
+ CbObjectView Query = Cb["query"sv].AsObjectView();
+ CHECK(Query);
+ CbObjectView Commit = Query["commit"sv].AsObjectView();
+ CHECK(Commit);
+ CHECK_EQ(Commit["$lte"sv].AsDouble(), 45375501.0);
+ CbObjectView Type = Query["type"sv].AsObjectView();
+ CHECK(Type);
+ CHECK_EQ(Type["$eq"sv].AsString(), "staged-build");
+ CbObjectView Branch = Query["branch"sv].AsObjectView();
+ CHECK(Branch);
+ CHECK_EQ(Branch["$eq"sv].AsString(), "fortnite-main");
+ CbObjectView Platform = Query["platform"sv].AsObjectView();
+ CHECK(Platform);
+ CbArrayView In = Platform["$in"sv].AsArrayView();
+ CHECK(In);
+ CHECK_EQ(In.Num(), 4);
+ auto ArrayIt = In.CreateViewIterator();
+ CHECK_EQ(ArrayIt.AsString(), "windows-server");
+ ArrayIt++;
+ CHECK_EQ(ArrayIt.AsString(), "windows");
+ ArrayIt++;
+ CHECK_EQ(ArrayIt.AsString(), "windows-client");
+ ArrayIt++;
+ CHECK_EQ(ArrayIt.AsString(), "windows-server");
+ }
}
#endif // ZEN_WITH_TESTS