Skip to content

Commit

Permalink
Integration and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danieltabacaru committed Sep 14, 2022
1 parent fe80e2a commit 491a8ac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/object-store/schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ TEST_CASE("Schema") {
ObjectSchema::ObjectType::TopLevelAsymmetric,
{{"_id", PropertyType::Int, Property::IsPrimary{true}}, {"street", PropertyType::String}}},
};
REQUIRE_NOTHROW(schema.validate(SchemaValidationMode::Sync));
REQUIRE_NOTHROW(schema.validate(SchemaValidationMode::SyncFLX));
REQUIRE_THROWS(schema.validate(SchemaValidationMode::SyncPBS));
}

SECTION("asymmetric tables not allowed in local realm") {
Expand All @@ -392,7 +393,7 @@ TEST_CASE("Schema") {
{{"_id", PropertyType::Int, Property::IsPrimary{true}}}},
};
REQUIRE_THROWS_CONTAINING(
schema.validate(SchemaValidationMode::Sync),
schema.validate(SchemaValidationMode::SyncFLX),
"Property 'object.link' of type 'object' cannot be a link to an asymmetric object.");
}

Expand All @@ -403,7 +404,7 @@ TEST_CASE("Schema") {
{{"link", PropertyType::Object | PropertyType::Nullable, "link target"}}},
{"link target", {{"value", PropertyType::Int}}},
};
REQUIRE_THROWS_CONTAINING(schema.validate(SchemaValidationMode::Sync),
REQUIRE_THROWS_CONTAINING(schema.validate(SchemaValidationMode::SyncFLX),
"Asymmetric table with property 'object.link' of type 'object' cannot have a "
"non-embedded object type.");
}
Expand All @@ -416,7 +417,7 @@ TEST_CASE("Schema") {
{"link", PropertyType::Object | PropertyType::Nullable, "link target"}}},
{"link target", ObjectSchema::ObjectType::Embedded, {{"value", PropertyType::Int}}},
};
schema.validate(SchemaValidationMode::Sync);
schema.validate(SchemaValidationMode::SyncFLX);
}

SECTION("rejects array properties with no target object") {
Expand Down
15 changes: 15 additions & 0 deletions test/object-store/sync/flx_sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,21 @@ TEST_CASE("flx: asymmetric sync", "[sync][flx][app]") {
});
}

SECTION("asymmetric table not allowed in PBS") {
Schema schema{
{"Asymmetric2",
ObjectSchema::ObjectType::TopLevelAsymmetric,
{
{"_id", PropertyType::Int, Property::IsPrimary{true}},
{"location", PropertyType::Int},
{"reading", PropertyType::Int},
}},
};

SyncTestFile config(harness->app(), bson::Bson{}, schema);
REQUIRE_THROWS(Realm::get_shared_realm(config));
}

// Add any new test sections above this point

SECTION("teardown") {
Expand Down

0 comments on commit 491a8ac

Please sign in to comment.