1
0
Fork 0

fix tests

This commit is contained in:
Andrey Abramov 2018-03-27 14:44:10 +03:00
parent b641cf9b13
commit a7760cb3b7
10 changed files with 292 additions and 104 deletions

View File

@ -1797,10 +1797,16 @@ arangodb::Result IResearchView::link(
new IResearchView(&vocbase, info, std::move(dataPath))
);
auto& json = info.isNone() ? emptyObjectSlice() : info; // if no 'info' then assume defaults
auto props = info.get("properties");
if (props.isNone()) {
// if no 'properties' then assume defaults
props = emptyObjectSlice();
}
std::string error;
if (!ptr->_meta.init(json, error)) {
if (!ptr->_meta.init(props, error)) {
LOG_TOPIC(WARN, iresearch::IResearchFeature::IRESEARCH)
<< "failed to initialize iResearch view from definition, error: " << error;

View File

@ -365,11 +365,15 @@ TEST_CASE("IResearchQueryTestJoinDuplicateDataSource", "[iresearch][iresearch-qu
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
auto tmpSlice = slice.get("links");
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
auto tmpSlice = slice.get("properties").get("links");
CHECK((true == tmpSlice.isObject() && 2 == tmpSlice.length()));
}
@ -565,11 +569,15 @@ TEST_CASE("IResearchQueryTestJoin", "[iresearch][iresearch-query]") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
auto tmpSlice = slice.get("links");
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
auto tmpSlice = slice.get("properties").get("links");
CHECK((true == tmpSlice.isObject() && 2 == tmpSlice.length()));
}

View File

@ -228,11 +228,15 @@ TEST_CASE("IResearchQueryTestNumericTerm", "[iresearch][iresearch-query]") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
auto tmpSlice = slice.get("links");
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
auto tmpSlice = slice.get("properties").get("links");
CHECK((true == tmpSlice.isObject() && 2 == tmpSlice.length()));
}

View File

@ -219,11 +219,15 @@ TEST_CASE("IResearchQueryTestOr", "[iresearch][iresearch-query]") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
auto tmpSlice = slice.get("links");
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
auto tmpSlice = slice.get("properties").get("links");
CHECK((true == tmpSlice.isObject() && 2 == tmpSlice.length()));
}

View File

@ -219,11 +219,15 @@ TEST_CASE("IResearchQueryTestSelectAll", "[iresearch][iresearch-query]") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
auto tmpSlice = slice.get("links");
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
auto tmpSlice = slice.get("properties").get("links");
CHECK((true == tmpSlice.isObject() && 2 == tmpSlice.length()));
}

View File

@ -219,11 +219,15 @@ TEST_CASE("IResearchQueryTestStartsWith", "[iresearch][iresearch-query]") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
auto tmpSlice = slice.get("links");
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
auto tmpSlice = slice.get("properties").get("links");
CHECK((true == tmpSlice.isObject() && 2 == tmpSlice.length()));
}

View File

@ -256,11 +256,15 @@ TEST_CASE("IResearchQueryTestStringTerm", "[iresearch][iresearch-query]") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
auto tmpSlice = slice.get("links");
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
auto tmpSlice = slice.get("properties").get("links");
CHECK((true == tmpSlice.isObject() && 2 == tmpSlice.length()));
}

View File

@ -1217,8 +1217,24 @@ SECTION("test_register_link") {
auto view = std::dynamic_pointer_cast<arangodb::iresearch::IResearchView>(
vocbase.createView(viewJson0->slice(), 0)
);
REQUIRE((false == !view));
{
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("id").copyString() == "101");
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
CHECK(3 == slice.length());
}
{
std::set<TRI_voc_cid_t> cids;
view->visitCollections([&cids](TRI_voc_cid_t cid)->bool { cids.emplace(cid); return true; });
@ -1244,6 +1260,22 @@ SECTION("test_register_link") {
);
REQUIRE((false == !view));
{
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("id").copyString() == "101");
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
CHECK(3 == slice.length());
}
{
std::unordered_set<TRI_voc_cid_t> cids;
view->sync();
@ -2204,17 +2236,24 @@ SECTION("test_update_overwrite") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
CHECK(4 == slice.length());
arangodb::iresearch::IResearchViewMeta meta;
std::string error;
CHECK((6U == slice.length()));
CHECK((meta.init(slice, error) && expectedMeta == meta));
auto propSlice = slice.get("properties");
CHECK(propSlice.isObject());
CHECK((6U == propSlice.length()));
CHECK((meta.init(propSlice, error) && expectedMeta == meta));
auto tmpSlice = slice.get("links");
auto tmpSlice = propSlice.get("links");
CHECK((true == tmpSlice.isObject() && 0 == tmpSlice.length()));
}
@ -2231,17 +2270,23 @@ SECTION("test_update_overwrite") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
arangodb::iresearch::IResearchViewMeta meta;
std::string error;
CHECK((6U == slice.length()));
CHECK((meta.init(slice, error) && expectedMeta == meta));
auto propSlice = slice.get("properties");
CHECK(propSlice.isObject());
CHECK((6U == propSlice.length()));
CHECK((meta.init(propSlice, error) && expectedMeta == meta));
auto tmpSlice = slice.get("links");
auto tmpSlice = propSlice.get("links");
CHECK((true == tmpSlice.isObject() && 0 == tmpSlice.length()));
}
}
@ -2276,17 +2321,23 @@ SECTION("test_update_overwrite") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
arangodb::iresearch::IResearchViewMeta meta;
std::string error;
CHECK((6U == slice.length()));
CHECK((meta.init(slice, error) && expectedMeta == meta));
auto propSlice = slice.get("properties");
CHECK(propSlice.isObject());
CHECK((6U == propSlice.length()));
CHECK((meta.init(propSlice, error) && expectedMeta == meta));
auto tmpSlice = slice.get("links");
auto tmpSlice = propSlice.get("links");
CHECK((true == tmpSlice.isObject() && 1 == tmpSlice.length()));
for (arangodb::velocypack::ObjectIterator itr(tmpSlice); itr.valid(); ++itr) {
@ -2323,17 +2374,23 @@ SECTION("test_update_overwrite") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
arangodb::iresearch::IResearchViewMeta meta;
std::string error;
CHECK((6U == slice.length()));
CHECK((meta.init(slice, error) && expectedMeta == meta));
auto propSlice = slice.get("properties");
CHECK(propSlice.isObject());
CHECK((6U == propSlice.length()));
CHECK((meta.init(propSlice, error) && expectedMeta == meta));
auto tmpSlice = slice.get("links");
auto tmpSlice = propSlice.get("links");
CHECK((true == tmpSlice.isObject() && 1 == tmpSlice.length()));
for (arangodb::velocypack::ObjectIterator itr(tmpSlice); itr.valid(); ++itr) {
@ -2380,13 +2437,18 @@ SECTION("test_update_overwrite") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
auto tmpSlice = slice.get("collections");
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
auto tmpSlice = slice.get("properties").get("collections");
CHECK((true == tmpSlice.isArray() && 1 == tmpSlice.length()));
tmpSlice = slice.get("links");
tmpSlice = slice.get("properties").get("links");
CHECK((true == tmpSlice.isObject() && 1 == tmpSlice.length()));
tmpSlice = tmpSlice.get("testCollection");
CHECK((true == tmpSlice.isObject()));
@ -2404,11 +2466,14 @@ SECTION("test_update_overwrite") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
auto tmpSlice = slice.get("links");
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
auto tmpSlice = slice.get("properties").get("links");
CHECK((true == tmpSlice.isObject() && 1 == tmpSlice.length()));
tmpSlice = tmpSlice.get("testCollection");
CHECK((true == tmpSlice.isObject()));
@ -2448,17 +2513,23 @@ SECTION("test_update_partial") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
arangodb::iresearch::IResearchViewMeta meta;
std::string error;
CHECK((6U == slice.length()));
CHECK((meta.init(slice, error) && expectedMeta == meta));
auto propSlice = slice.get("properties");
CHECK(propSlice.isObject());
CHECK((6U == propSlice.length()));
CHECK((meta.init(propSlice, error) && expectedMeta == meta));
auto tmpSlice = slice.get("links");
auto tmpSlice = propSlice.get("links");
CHECK((true == tmpSlice.isObject() && 0 == tmpSlice.length()));
}
@ -2483,17 +2554,23 @@ SECTION("test_update_partial") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
arangodb::iresearch::IResearchViewMeta meta;
std::string error;
CHECK((6U == slice.length()));
CHECK((meta.init(slice, error) && expectedMeta == meta));
auto propSlice = slice.get("properties");
CHECK(propSlice.isObject());
CHECK((6U == propSlice.length()));
CHECK((meta.init(propSlice, error) && expectedMeta == meta));
auto tmpSlice = slice.get("links");
auto tmpSlice = propSlice.get("links");
CHECK((true == tmpSlice.isObject() && 0 == tmpSlice.length()));
}
@ -2521,14 +2598,21 @@ SECTION("test_update_partial") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
auto propSlice = slice.get("properties");
CHECK(propSlice.isObject());
CHECK((
true == slice.hasKey("links")
&& slice.get("links").isObject()
&& 1 == slice.get("links").length()
true == propSlice.hasKey("links")
&& propSlice.get("links").isObject()
&& 1 == propSlice.get("links").length()
));
}
@ -2558,17 +2642,23 @@ SECTION("test_update_partial") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
arangodb::iresearch::IResearchViewMeta meta;
std::string error;
CHECK((6U == slice.length()));
CHECK((meta.init(slice, error) && expectedMeta == meta));
auto propSlice = slice.get("properties");
CHECK(propSlice.isObject());
CHECK((6U == propSlice.length()));
CHECK((meta.init(propSlice, error) && expectedMeta == meta));
auto tmpSlice = slice.get("links");
auto tmpSlice = propSlice.get("links");
CHECK((true == tmpSlice.isObject() && 1 == tmpSlice.length()));
for (arangodb::velocypack::ObjectIterator itr(tmpSlice); itr.valid(); ++itr) {
@ -2629,17 +2719,22 @@ SECTION("test_update_partial") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
arangodb::iresearch::IResearchViewMeta meta;
std::string error;
CHECK((6U == slice.length()));
CHECK((meta.init(slice, error) && expectedMeta == meta));
auto propSlice = slice.get("properties");
CHECK((6U == propSlice.length()));
CHECK((meta.init(propSlice, error) && expectedMeta == meta));
auto tmpSlice = slice.get("links");
auto tmpSlice = propSlice.get("links");
CHECK((true == tmpSlice.isObject() && 1 == tmpSlice.length()));
for (arangodb::velocypack::ObjectIterator itr(tmpSlice); itr.valid(); ++itr) {
@ -2681,17 +2776,22 @@ SECTION("test_update_partial") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
arangodb::iresearch::IResearchViewMeta meta;
std::string error;
CHECK((6U == slice.length()));
CHECK((meta.init(slice, error) && expectedMeta == meta));
auto propSlice = slice.get("properties");
CHECK((6U == propSlice.length()));
CHECK((meta.init(propSlice, error) && expectedMeta == meta));
auto tmpSlice = slice.get("links");
auto tmpSlice = propSlice.get("links");
CHECK((true == tmpSlice.isObject() && 0 == tmpSlice.length()));
}
@ -2716,14 +2816,20 @@ SECTION("test_update_partial") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
auto propSlice = slice.get("properties");
CHECK((
true == slice.hasKey("links")
&& slice.get("links").isObject()
&& 1 == slice.get("links").length()
true == propSlice.hasKey("links")
&& propSlice.get("links").isObject()
&& 1 == propSlice.get("links").length()
));
}
@ -2740,14 +2846,20 @@ SECTION("test_update_partial") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
auto propSlice = slice.get("properties");
CHECK((
true == slice.hasKey("links")
&& slice.get("links").isObject()
&& 0 == slice.get("links").length()
true == propSlice.hasKey("links")
&& propSlice.get("links").isObject()
&& 0 == propSlice.get("links").length()
));
}
}
@ -2776,17 +2888,23 @@ SECTION("test_update_partial") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
arangodb::iresearch::IResearchViewMeta meta;
std::string error;
CHECK((6U == slice.length()));
CHECK((meta.init(slice, error) && expectedMeta == meta));
auto propSlice = slice.get("properties");
CHECK(propSlice.isObject());
CHECK((6U == propSlice.length()));
CHECK((meta.init(propSlice, error) && expectedMeta == meta));
auto tmpSlice = slice.get("links");
auto tmpSlice = propSlice.get("links");
CHECK((true == tmpSlice.isObject() && 1 == tmpSlice.length()));
}
@ -2802,17 +2920,23 @@ SECTION("test_update_partial") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
arangodb::iresearch::IResearchViewMeta meta;
std::string error;
CHECK((6U == slice.length()));
CHECK((meta.init(slice, error) && expectedMeta == meta));
auto propSlice = slice.get("properties");
CHECK(propSlice.isObject());
CHECK((6U == propSlice.length()));
CHECK((meta.init(propSlice, error) && expectedMeta == meta));
auto tmpSlice = slice.get("links");
auto tmpSlice = propSlice.get("links");
CHECK((true == tmpSlice.isObject() && 0 == tmpSlice.length()));
}
}
@ -2834,17 +2958,23 @@ SECTION("test_update_partial") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
arangodb::iresearch::IResearchViewMeta meta;
std::string error;
CHECK((6U == slice.length()));
CHECK((meta.init(slice, error) && expectedMeta == meta));
auto propSlice = slice.get("properties");
CHECK(propSlice.isObject());
CHECK((6U == propSlice.length()));
CHECK((meta.init(propSlice, error) && expectedMeta == meta));
auto tmpSlice = slice.get("links");
auto tmpSlice = propSlice.get("links");
CHECK((true == tmpSlice.isObject() && 0 == tmpSlice.length()));
}
@ -2868,17 +2998,23 @@ SECTION("test_update_partial") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
arangodb::iresearch::IResearchViewMeta meta;
std::string error;
CHECK((6U == slice.length()));
CHECK((meta.init(slice, error) && expectedMeta == meta));
auto propSlice = slice.get("properties");
CHECK(propSlice.isObject());
CHECK((6U == propSlice.length()));
CHECK((meta.init(propSlice, error) && expectedMeta == meta));
auto tmpSlice = slice.get("links");
auto tmpSlice = propSlice.get("links");
CHECK((true == tmpSlice.isObject() && 0 == tmpSlice.length()));
}
@ -2901,11 +3037,15 @@ SECTION("test_update_partial") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
auto tmpSlice = slice.get("links");
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
auto tmpSlice = slice.get("properties").get("links");
CHECK((true == tmpSlice.isObject() && 1 == tmpSlice.length()));
}
@ -2925,11 +3065,15 @@ SECTION("test_update_partial") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
auto tmpSlice = slice.get("links");
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
auto tmpSlice = slice.get("properties").get("links");
CHECK((true == tmpSlice.isObject() && 1 == tmpSlice.length()));
std::unordered_set<TRI_idx_iid_t> actual;
@ -2961,13 +3105,17 @@ SECTION("test_update_partial") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
auto tmpSlice = slice.get("collections");
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
auto tmpSlice = slice.get("properties").get("collections");
CHECK((true == tmpSlice.isArray() && 1 == tmpSlice.length()));
tmpSlice = slice.get("links");
tmpSlice = slice.get("properties").get("links");
CHECK((true == tmpSlice.isObject() && 1 == tmpSlice.length()));
tmpSlice = tmpSlice.get("testCollection");
CHECK((true == tmpSlice.isObject()));
@ -2985,11 +3133,15 @@ SECTION("test_update_partial") {
arangodb::velocypack::Builder builder;
builder.openObject();
view->toVelocyPack(builder, false, false);
view->toVelocyPack(builder, true, false);
builder.close();
auto slice = builder.slice();
auto tmpSlice = slice.get("links");
CHECK(slice.isObject());
CHECK(slice.get("name").copyString() == "testView");
CHECK(slice.get("type").copyString() == arangodb::iresearch::IResearchView::type().name());
CHECK(slice.get("deleted").isNone()); // no system properties
auto tmpSlice = slice.get("properties").get("links");
CHECK((true == tmpSlice.isObject() && 1 == tmpSlice.length()));
tmpSlice = tmpSlice.get("testCollection");
CHECK((true == tmpSlice.isObject()));
@ -2999,10 +3151,6 @@ SECTION("test_update_partial") {
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief generate tests
////////////////////////////////////////////////////////////////////////////////
}
// -----------------------------------------------------------------------------

View File

@ -42,9 +42,12 @@ std::unique_ptr<arangodb::LogicalView> makeTestView(
bool isNew
) {
struct Impl: public arangodb::LogicalView{
Impl(): arangodb::LogicalView(nullptr, arangodb::velocypack::Slice::emptyObjectSlice()) {
Impl(TRI_vocbase_t& vocbase, arangodb::velocypack::Slice const& info)
: arangodb::LogicalView(&vocbase, info) {
}
virtual void drop() override {
deleted(true);
}
virtual void drop() override {}
virtual void toVelocyPack(
arangodb::velocypack::Builder&, bool, bool
) const override {
@ -65,7 +68,7 @@ std::unique_ptr<arangodb::LogicalView> makeTestView(
}
};
return std::make_unique<Impl>();
return std::make_unique<Impl>(vocbase, info);
}
}

View File

@ -43,9 +43,12 @@ std::unique_ptr<arangodb::LogicalView> makeTestView(
bool isNew
) {
struct Impl: public arangodb::LogicalView{
Impl(): LogicalView(nullptr, arangodb::velocypack::Slice::emptyObjectSlice()) {
Impl(TRI_vocbase_t& vocbase, arangodb::velocypack::Slice const& info)
: LogicalView(&vocbase, info) {
}
virtual void drop() override {
deleted(true);
}
virtual void drop() override {}
virtual void toVelocyPack(
arangodb::velocypack::Builder&, bool, bool
) const override {
@ -66,7 +69,7 @@ std::unique_ptr<arangodb::LogicalView> makeTestView(
}
};
return std::make_unique<Impl>();
return std::make_unique<Impl>(vocbase, info);
}
}