From 48ff8c2d488a2e556055bc3c47c6c312392d7a35 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Wed, 15 Nov 2023 13:39:11 +0100 Subject: [PATCH] File format upgrade might trigger migration --- test/object-store/foo.realm | Bin 0 -> 16384 bytes test/object-store/migrations.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 test/object-store/foo.realm diff --git a/test/object-store/foo.realm b/test/object-store/foo.realm new file mode 100644 index 0000000000000000000000000000000000000000..64a8088a07b99be04b3f05d9ae9a87f542340b61 GIT binary patch literal 16384 zcmeIwze+cNRfE!3aDe&l?!^T;Re=_jsc zb#oYp!{M`KY~NIfu{3R61f+Y>!Lg9$s7KTH`|9;ZS?O<8xM8dXK`G&doZt} z`+HC~_a%d{D%1Y0+5VVMR4Su&98}By=eId`(YnE zI{u}xZecYPwiq4-2*AP{cn@38p5!-Lj5_W;`Aqt#WHH|ED%#XbTp8mczI%5w#MtKM z$KD?uUXjoa5;(VjUPi}nGdNfd^XPyn8wDsp0SZun0u-PC1t>rP3Q&Lo6rcbFC_n)U zP=Epypa2CZKmiI+fC3bt00k&O0SZun0u-PC1t>rP3Q&Lo6rcbFC_n)UP=Epypa2CZ JK!HC6z5%w#c5wgz literal 0 HcmV?d00001 diff --git a/test/object-store/migrations.cpp b/test/object-store/migrations.cpp index e6c34a7747a..f12fb671bff 100644 --- a/test/object-store/migrations.cpp +++ b/test/object-store/migrations.cpp @@ -18,9 +18,11 @@ #include #include +#include "../util/test_path.hpp" #include #include +#include #include #include @@ -2022,6 +2024,32 @@ TEST_CASE("migration: ReadOnly", "[migration]") { } } +TEST_CASE("file format upgrade + migration: SoftResetFile", "[migration]") { + TestFile config; + config.schema_mode = SchemaMode::ReadOnly; + config.disable_format_upgrade = false; + + std::string path = test_util::get_test_resource_path() + "foo.realm"; + std::string temp_copy1 = test_util::get_test_resource_path() + "foo_copy1.realm"; + config.path = temp_copy1; + + realm::util::File::copy(path, temp_copy1); + + auto realm1 = Realm::get_shared_realm(config); + REQUIRE(realm1->schema().size() == 1); + REQUIRE(!realm1->is_empty()); + + config.schema_mode = SchemaMode::SoftResetFile; + std::string temp_copy2 = test_util::get_test_resource_path() + "foo_copy2.realm"; + config.path = temp_copy2; + + realm::util::File::copy(path, temp_copy2); + auto realm2 = Realm::get_shared_realm(config); + REQUIRE(realm2->schema().size() == 1); + REQUIRE(!realm2->is_empty()); +} + + TEST_CASE("migration: SoftResetFile", "[migration]") { TestFile config; config.schema_mode = SchemaMode::SoftResetFile;