Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File format upgrade might trigger migration #7139

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added test/object-store/foo.realm
Binary file not shown.
28 changes: 28 additions & 0 deletions test/object-store/migrations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@

#include <util/test_file.hpp>
#include <util/test_utils.hpp>
#include "../util/test_path.hpp"

#include <realm/group.hpp>
#include <realm/table.hpp>
#include <realm/util/file.hpp>

#include <realm/object-store/object_schema.hpp>
#include <realm/object-store/object_store.hpp>
Expand Down Expand Up @@ -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;
Expand Down
Loading