Skip to content

Commit

Permalink
convert remaining tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ironage committed Feb 12, 2024
1 parent 9208c23 commit 6e8a96c
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 205 deletions.
3 changes: 2 additions & 1 deletion src/realm/object-store/sync/app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ class App : public std::enable_shared_from_this<App>,
// The default value is `<rootDir>/<appId>/<userId>/<partitionValue>.realm`.
// If the file cannot be created at this location, for example due to path length restrictions,
// this function may pass back `<rootDir>/<hashedFileName>.realm`
std::string path_for_realm(const SyncConfig& config, std::optional<std::string> custom_file_name) const;
std::string path_for_realm(const SyncConfig& config,
std::optional<std::string> custom_file_name = std::nullopt) const;

// Attempt to perform all pending file actions for the given path. Returns
// true if any were performed.
Expand Down
12 changes: 12 additions & 0 deletions src/realm/object-store/sync/impl/app_metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,13 @@ struct PersistedSyncMetadataManager : public app::MetadataStore {
return did_run;
}

size_t num_pending_actions() override
{
auto realm = get_realm();
TableRef table = realm->read_group().get_table(m_file_action_schema.table_key);
return table->size();
}

bool has_logged_in_user(std::string_view user_id) override
{
auto realm = get_realm();
Expand Down Expand Up @@ -874,6 +881,11 @@ class InMemoryMetadataStorage : public app::MetadataStore {
{
std::lock_guard lock(m_mutex);
}

size_t num_pending_actions() override
{
return 0;
}
};

} // anonymous namespace
Expand Down
1 change: 1 addition & 0 deletions src/realm/object-store/sync/impl/app_metadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class MetadataStore {
virtual void create_file_action(SyncFileAction action, std::string_view original_path,
std::string_view recovery_path, std::string_view partition_value,
std::string_view user_id) = 0;
virtual size_t num_pending_actions() = 0;

virtual bool has_logged_in_user(std::string_view user_id) = 0;
virtual std::optional<UserData> get_user(std::string_view user_id) = 0;
Expand Down
6 changes: 2 additions & 4 deletions src/realm/object-store/sync/impl/sync_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,8 @@ SyncFileManager::SyncFileManager(const app::AppConfig& config)
, m_app_path(util::file_path_by_appending_component(m_base_path, util::validate_and_clean_path(config.app_id),
util::FilePathType::Directory))
{
if (config.metadata_mode != app::AppConfig::MetadataMode::InMemory) {
util::try_make_dir(m_base_path);
util::try_make_dir(m_app_path);
}
util::try_make_dir(m_base_path);
util::try_make_dir(m_app_path);
}

std::string SyncFileManager::get_special_directory(std::string directory_name) const
Expand Down
6 changes: 3 additions & 3 deletions test/object-store/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ if(REALM_ENABLE_SYNC)
sync/migration_store_test.cpp
sync/remote_mongo_tests.cpp
sync/session/connection_change_notifications.cpp
# sync/session/progress_notifications.cpp
# sync/session/session.cpp
sync/session/progress_notifications.cpp
sync/session/session.cpp
sync/session/wait_for_completion.cpp
# sync/sync_manager.cpp
sync/sync_manager.cpp
util/sync/sync_test_utils.cpp
util/unit_test_transport.cpp
)
Expand Down
3 changes: 3 additions & 0 deletions test/object-store/sync/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "util/sync/baas_admin_api.hpp"
#include "util/sync/sync_test_utils.hpp"
#include "util/unit_test_transport.hpp"
#include "util/test_path.hpp"

#include <realm/object-store/impl/object_accessor_impl.hpp>
#include <realm/object-store/sync/app_credentials.hpp>
Expand Down Expand Up @@ -6019,9 +6020,11 @@ TEST_CASE("app: user logs out while profile is fetched", "[sync][app][user]") {
}

TEST_CASE("app: shared instances", "[sync][app]") {
realm::test_util::TestDirGuard test_dir(util::make_temp_dir(), false);
AppConfig base_config;
set_app_config_defaults(base_config, instance_of<UnitTestTransport>);
base_config.metadata_mode = AppConfig::MetadataMode::InMemory;
base_config.base_file_path = test_dir;

auto config1 = base_config;
config1.app_id = "app1";
Expand Down
Loading

0 comments on commit 6e8a96c

Please sign in to comment.