diff --git a/CHANGELOG.md b/CHANGELOG.md index dc098c07..087eb851 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ ### Changes from v2.0.3-rc * Continue documentation updates +* Refactored app_config unit tests * Refactored polling to be more accurate on scheduling tasks ## v2.0.3-rc diff --git a/repertory/librepertory/include/types/repertory.hpp b/repertory/librepertory/include/types/repertory.hpp index 676e0d69..c04580f8 100644 --- a/repertory/librepertory/include/types/repertory.hpp +++ b/repertory/librepertory/include/types/repertory.hpp @@ -24,7 +24,7 @@ namespace repertory { constexpr const auto default_api_auth_size{48U}; -constexpr const auto default_download_timeout_ces{30U}; +constexpr const auto default_download_timeout_secs{30U}; constexpr const auto default_eviction_delay_mins{1U}; constexpr const auto default_high_freq_interval_secs{30U}; constexpr const auto default_low_freq_interval_secs{std::uint16_t(60U * 60U)}; diff --git a/repertory/librepertory/src/app_config.cpp b/repertory/librepertory/src/app_config.cpp index 6c79dda0..bb9d71b4 100644 --- a/repertory/librepertory/src/app_config.cpp +++ b/repertory/librepertory/src/app_config.cpp @@ -70,7 +70,7 @@ app_config::app_config(const provider_type &prov, api_port_(default_rpc_port(prov)), api_user_(std::string{REPERTORY}), config_changed_(false), - download_timeout_secs_(default_download_timeout_ces), + download_timeout_secs_(default_download_timeout_secs), enable_download_timeout_(true), enable_drive_events_(false), #if defined(_WIN32) diff --git a/repertory/repertory_test/src/app_config_test.cpp b/repertory/repertory_test/src/app_config_test.cpp index bcd7568b..b5086f5b 100644 --- a/repertory/repertory_test/src/app_config_test.cpp +++ b/repertory/repertory_test/src/app_config_test.cpp @@ -34,10 +34,18 @@ public: static std::atomic idx; + std::string encrypt_directory; std::string s3_directory; std::string sia_directory; void SetUp() override { + encrypt_directory = utils::path::combine(test::get_test_output_dir(), + { + "app_config_test", + "encrypt", + std::to_string(++idx), + }); + s3_directory = utils::path::combine(test::get_test_output_dir(), { "app_config_test", @@ -59,641 +67,144 @@ public: std::atomic app_config_test::idx{0U}; -TEST_F(app_config_test, api_path) { - std::string original_value; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_api_auth(); - EXPECT_EQ(48U, original_value.size()); - } -} - -TEST_F(app_config_test, api_auth) { - std::string original_value; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_api_auth(); - config.set_api_auth(original_value.substr(0, 20)); - EXPECT_EQ(original_value.substr(0, 20), config.get_api_auth()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(original_value.substr(0, 20), config.get_api_auth()); - } -} - -TEST_F(app_config_test, api_port) { - std::uint16_t original_value{}; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_api_port(); - config.set_api_port(original_value + 5); - EXPECT_EQ(original_value + 5, config.get_api_port()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(original_value + 5, config.get_api_port()); - } -} - -TEST_F(app_config_test, api_user) { - std::string original_value; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_api_user(); - config.set_api_user(original_value.substr(0, 2)); - EXPECT_EQ(original_value.substr(0, 2), config.get_api_user()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(original_value.substr(0, 2), config.get_api_user()); - } -} - -TEST_F(app_config_test, download_timeout_secs) { - std::uint8_t original_value{}; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_download_timeout_secs(); - config.set_download_timeout_secs(original_value + 5); - EXPECT_EQ(original_value + 5, config.get_download_timeout_secs()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(original_value + 5, config.get_download_timeout_secs()); - } -} - -TEST_F(app_config_test, enable_download_timeout) { - bool original_value{}; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_enable_download_timeout(); - config.set_enable_download_timeout(not original_value); - EXPECT_EQ(not original_value, config.get_enable_download_timeout()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(not original_value, config.get_enable_download_timeout()); - } -} - -TEST_F(app_config_test, enable_drive_events) { - bool original_value{}; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_enable_drive_events(); - config.set_enable_drive_events(not original_value); - EXPECT_EQ(not original_value, config.get_enable_drive_events()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(not original_value, config.get_enable_drive_events()); - } -} - +static void defaults_tests(const json &json_data, provider_type prov) { + json json_defaults = { + {JSON_API_PORT, app_config::default_rpc_port(prov)}, + {JSON_API_USER, std::string{REPERTORY}}, + {JSON_DOWNLOAD_TIMEOUT_SECS, default_download_timeout_secs}, + {JSON_DATABASE_TYPE, database_type::rocksdb}, + {JSON_ENABLE_DOWNLOAD_TIMEOUT, true}, + {JSON_ENABLE_DRIVE_EVENTS, false}, #if defined(_WIN32) -TEST_F(app_config_test, enable_mount_manager) { - bool original_value; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_enable_mount_manager(); - config.set_enable_mount_manager(not original_value); - EXPECT_EQ(not original_value, config.get_enable_mount_manager()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(not original_value, config.get_enable_mount_manager()); - } -} -#endif -TEST_F(app_config_test, event_level) { - { - app_config config(provider_type::sia, sia_directory); - config.set_event_level(event_level::debug); - EXPECT_EQ(event_level::debug, config.get_event_level()); - config.set_event_level(event_level::warn); - EXPECT_EQ(event_level::warn, config.get_event_level()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(event_level::warn, config.get_event_level()); - } -} - -TEST_F(app_config_test, eviction_delay_mins) { - std::uint32_t original_value{}; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_eviction_delay_mins(); - config.set_eviction_delay_mins(original_value + 5); - EXPECT_EQ(original_value + 5, config.get_eviction_delay_mins()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(original_value + 5, config.get_eviction_delay_mins()); - } -} - -TEST_F(app_config_test, eviction_uses_accessed_time) { - bool original_value{}; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_eviction_uses_accessed_time(); - config.set_eviction_uses_accessed_time(not original_value); - EXPECT_EQ(not original_value, config.get_eviction_uses_accessed_time()); - } - - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(not original_value, config.get_eviction_uses_accessed_time()); - } -} - -TEST_F(app_config_test, high_frequency_interval_secs) { - std::uint16_t original_value{}; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_high_frequency_interval_secs(); - config.set_high_frequency_interval_secs(original_value + 5U); - EXPECT_EQ(original_value + 5U, config.get_high_frequency_interval_secs()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(original_value + 5U, config.get_high_frequency_interval_secs()); - } -} - -TEST_F(app_config_test, low_frequency_interval_secs) { - std::uint16_t original_value{}; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_low_frequency_interval_secs(); - config.set_low_frequency_interval_secs(original_value + 5U); - EXPECT_EQ(original_value + 5U, config.get_low_frequency_interval_secs()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(original_value + 5U, config.get_low_frequency_interval_secs()); - } -} - -TEST_F(app_config_test, med_frequency_interval_secs) { - std::uint16_t original_value{}; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_med_frequency_interval_secs(); - config.set_med_frequency_interval_secs(original_value + 5U); - EXPECT_EQ(original_value + 5U, config.get_med_frequency_interval_secs()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(original_value + 5U, config.get_med_frequency_interval_secs()); - } -} - -TEST_F(app_config_test, max_cache_size_bytes) { - { - app_config config(provider_type::sia, sia_directory); - config.get_max_cache_size_bytes(); - EXPECT_EQ(default_max_cache_size_bytes, config.get_max_cache_size_bytes()); - } - { - app_config config(provider_type::sia, sia_directory); - config.set_max_cache_size_bytes(100U * 1024U * 1024U); - EXPECT_EQ(100U * 1024 * 1024, config.get_max_cache_size_bytes()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(100U * 1024 * 1024, config.get_max_cache_size_bytes()); - } -} - -TEST_F(app_config_test, max_upload_count) { - { - app_config config(provider_type::sia, sia_directory); - config.set_max_upload_count(8U); - EXPECT_EQ(std::uint8_t(8U), config.get_max_upload_count()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(std::uint8_t(8U), config.get_max_upload_count()); - } - { - app_config config(provider_type::sia, sia_directory); - config.set_max_upload_count(0U); - EXPECT_EQ(std::uint8_t(1U), config.get_max_upload_count()); - } -} - -TEST_F(app_config_test, online_check_retry_secs) { - std::uint16_t original_value{}; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_online_check_retry_secs(); - config.set_online_check_retry_secs(original_value + 1); - EXPECT_EQ(original_value + 1, config.get_online_check_retry_secs()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(original_value + 1, config.get_online_check_retry_secs()); - } -} - -TEST_F(app_config_test, online_check_retry_secs_minimum_value) { - { - app_config config(provider_type::sia, sia_directory); - config.set_online_check_retry_secs(14); - EXPECT_EQ(15, config.get_online_check_retry_secs()); - } -} - -TEST_F(app_config_test, orphaned_file_retention_days) { - std::uint16_t original_value{}; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_orphaned_file_retention_days(); - config.set_orphaned_file_retention_days(original_value + 1); - EXPECT_EQ(original_value + 1, config.get_orphaned_file_retention_days()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(original_value + 1, config.get_orphaned_file_retention_days()); - } -} - -TEST_F(app_config_test, orphaned_file_retention_days_minimum_value) { - { - app_config config(provider_type::sia, sia_directory); - config.set_orphaned_file_retention_days(0); - EXPECT_EQ(1, config.get_orphaned_file_retention_days()); - } -} - -TEST_F(app_config_test, orphaned_file_retention_days_maximum_value) { - { - app_config config(provider_type::sia, sia_directory); - config.set_orphaned_file_retention_days(32); - EXPECT_EQ(31, config.get_orphaned_file_retention_days()); - } -} - -TEST_F(app_config_test, get_cache_directory) { - { - app_config config(provider_type::sia, sia_directory); - EXPECT_STREQ(utils::path::combine(sia_directory, {"cache"}).c_str(), - config.get_cache_directory().c_str()); - } -} - -TEST_F(app_config_test, get_config_file_path) { - { - const auto config_file = utils::path::absolute( - utils::path::combine(sia_directory, {"config.json"})); - - app_config config(provider_type::sia, sia_directory); - EXPECT_STREQ(config_file.c_str(), config.get_config_file_path().c_str()); - } -} - -TEST_F(app_config_test, get_data_directory) { - { - app_config config(provider_type::sia, sia_directory); - EXPECT_STREQ(sia_directory.c_str(), config.get_data_directory().c_str()); - } -} - -TEST_F(app_config_test, get_log_directory) { - { - app_config config(provider_type::sia, sia_directory); - EXPECT_STREQ(utils::path::combine(sia_directory, {"logs"}).c_str(), - config.get_log_directory().c_str()); - } -} - -TEST_F(app_config_test, ring_buffer_file_size) { - std::uint16_t original_value; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_ring_buffer_file_size(); - config.set_ring_buffer_file_size(original_value + 5u); - EXPECT_EQ(original_value + 5u, config.get_ring_buffer_file_size()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(original_value + 5u, config.get_ring_buffer_file_size()); - } -} - -TEST_F(app_config_test, ring_buffer_file_size_minimum_size) { - { - app_config config(provider_type::sia, sia_directory); - config.set_ring_buffer_file_size(63u); - EXPECT_EQ(64u, config.get_ring_buffer_file_size()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(64u, config.get_ring_buffer_file_size()); - } -} - -TEST_F(app_config_test, ring_buffer_file_size_maximum_size) { - { - app_config config(provider_type::sia, sia_directory); - config.set_ring_buffer_file_size(1025u); - EXPECT_EQ(1024u, config.get_ring_buffer_file_size()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(1024u, config.get_ring_buffer_file_size()); - } -} - -TEST_F(app_config_test, preferred_download_type) { - download_type original_value; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_preferred_download_type(); - config.set_preferred_download_type(download_type::ring_buffer); - EXPECT_NE(original_value, config.get_preferred_download_type()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_NE(original_value, config.get_preferred_download_type()); - } -} - -TEST_F(app_config_test, default_agent_name) { - EXPECT_STREQ("Sia-Agent", - app_config::default_agent_name(provider_type::sia).c_str()); -} - -TEST_F(app_config_test, default_api_port) { - EXPECT_EQ(9980U, app_config::default_api_port(provider_type::sia)); -} - -TEST_F(app_config_test, default_data_directory) { - const std::array data_directory = { - app_config::default_data_directory(provider_type::sia), + {JSON_ENABLE_MOUNT_MANAGER, false}, +#endif // defined(_WIN32) + {JSON_ENCRYPT_CONFIG, encrypt_config{}}, + {JSON_EVENT_LEVEL, event_level::info}, + {JSON_EVICTION_DELAY_MINS, default_eviction_delay_mins}, + {JSON_EVICTION_USE_ACCESS_TIME, false}, + {JSON_HIGH_FREQ_INTERVAL_SECS, default_high_freq_interval_secs}, + {JSON_HOST_CONFIG, host_config{}}, + {JSON_LOW_FREQ_INTERVAL_SECS, default_low_freq_interval_secs}, + {JSON_MAX_CACHE_SIZE_BYTES, default_max_cache_size_bytes}, + {JSON_MAX_UPLOAD_COUNT, default_max_upload_count}, + {JSON_MED_FREQ_INTERVAL_SECS, default_med_freq_interval_secs}, + {JSON_ONLINE_CHECK_RETRY_SECS, default_online_check_retry_secs}, + {JSON_ORPHANED_FILE_RETENTION_DAYS, default_orphaned_file_retention_days}, + {JSON_PREFERRED_DOWNLOAD_TYPE, download_type::default_}, + {JSON_REMOTE_CONFIG, remote::remote_config{}}, + {JSON_REMOTE_MOUNT, remote::remote_mount{}}, + {JSON_RETRY_READ_COUNT, default_retry_read_count}, + {JSON_RING_BUFFER_FILE_SIZE, default_ring_buffer_file_size}, + {JSON_S3_CONFIG, s3_config{}}, + {JSON_SIA_CONFIG, sia_config{}}, + {JSON_TASK_WAIT_MS, default_task_wait_ms}, + {JSON_VERSION, REPERTORY_CONFIG_VERSION}, }; -#if defined(_WIN32) - const auto local_app_data = utils::get_environment_variable("localappdata"); -#endif -#if defined(__linux__) - const auto local_app_data = - utils::path::combine(utils::get_environment_variable("HOME"), {".local"}); -#endif -#if defined(__APPLE__) - const auto local_app_data = utils::path::combine( - utils::get_environment_variable("HOME"), {"Library/Application Support"}); -#endif - auto expected_directory = - utils::path::combine(local_app_data, {"/repertory2/sia"}); - EXPECT_STREQ(expected_directory.c_str(), data_directory[0].c_str()); -} + switch (prov) { + case provider_type::encrypt: + json_defaults.erase(JSON_DOWNLOAD_TIMEOUT_SECS); + json_defaults.erase(JSON_ENABLE_DOWNLOAD_TIMEOUT); + json_defaults.erase(JSON_EVICTION_DELAY_MINS); + json_defaults.erase(JSON_EVICTION_USE_ACCESS_TIME); + json_defaults.erase(JSON_HOST_CONFIG); + json_defaults.erase(JSON_MAX_CACHE_SIZE_BYTES); + json_defaults.erase(JSON_MAX_UPLOAD_COUNT); + json_defaults.erase(JSON_ONLINE_CHECK_RETRY_SECS); + json_defaults.erase(JSON_ORPHANED_FILE_RETENTION_DAYS); + json_defaults.erase(JSON_PREFERRED_DOWNLOAD_TYPE); + json_defaults.erase(JSON_REMOTE_CONFIG); + json_defaults.erase(JSON_RETRY_READ_COUNT); + json_defaults.erase(JSON_RING_BUFFER_FILE_SIZE); + json_defaults.erase(JSON_S3_CONFIG); + json_defaults.erase(JSON_SIA_CONFIG); + break; -TEST_F(app_config_test, default_rpc_port) { - EXPECT_EQ(10000U, app_config::default_rpc_port(provider_type::sia)); -} + case provider_type::remote: + json_defaults.erase(JSON_DATABASE_TYPE); + json_defaults.erase(JSON_DOWNLOAD_TIMEOUT_SECS); + json_defaults.erase(JSON_ENABLE_DOWNLOAD_TIMEOUT); + json_defaults.erase(JSON_ENCRYPT_CONFIG); + json_defaults.erase(JSON_EVICTION_DELAY_MINS); + json_defaults.erase(JSON_EVICTION_USE_ACCESS_TIME); + json_defaults.erase(JSON_HIGH_FREQ_INTERVAL_SECS); + json_defaults.erase(JSON_HOST_CONFIG); + json_defaults.erase(JSON_LOW_FREQ_INTERVAL_SECS); + json_defaults.erase(JSON_MAX_CACHE_SIZE_BYTES); + json_defaults.erase(JSON_MAX_UPLOAD_COUNT); + json_defaults.erase(JSON_MED_FREQ_INTERVAL_SECS); + json_defaults.erase(JSON_ONLINE_CHECK_RETRY_SECS); + json_defaults.erase(JSON_ORPHANED_FILE_RETENTION_DAYS); + json_defaults.erase(JSON_PREFERRED_DOWNLOAD_TYPE); + json_defaults.erase(JSON_REMOTE_MOUNT); + json_defaults.erase(JSON_RETRY_READ_COUNT); + json_defaults.erase(JSON_RING_BUFFER_FILE_SIZE); + json_defaults.erase(JSON_S3_CONFIG); + json_defaults.erase(JSON_SIA_CONFIG); + break; -TEST_F(app_config_test, get_provider_display_name) { - EXPECT_STREQ( - "Sia", app_config::get_provider_display_name(provider_type::sia).c_str()); -} + case provider_type::s3: + json_defaults.erase(JSON_ENCRYPT_CONFIG); + json_defaults.erase(JSON_HOST_CONFIG); + json_defaults.erase(JSON_REMOTE_CONFIG); + json_defaults.erase(JSON_SIA_CONFIG); + break; -TEST_F(app_config_test, get_provider_name) { - EXPECT_STREQ("sia", - app_config::get_provider_name(provider_type::sia).c_str()); -} + case provider_type::sia: + json_defaults.erase(JSON_ENCRYPT_CONFIG); + json_defaults.erase(JSON_REMOTE_CONFIG); + json_defaults.erase(JSON_S3_CONFIG); + break; -TEST_F(app_config_test, get_version) { - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(REPERTORY_CONFIG_VERSION, config.get_version()); + default: + return; + } + + ASSERT_EQ(std::size_t(default_api_auth_size), + json_data.at(JSON_API_AUTH).get().size()); + for (const auto &element : json_defaults) { + fmt::println("testing default|{}-{}", app_config::get_provider_name(prov), + element.key()); + EXPECT_EQ(json_defaults.value(), json_data.at(element.key())); } } -// TEST_F(config_test, enable_remote_mount) { -// bool original_value{}; -// { -// app_config config(provider_type::sia, sia_directory); -// original_value = config.get_enable_remote_mount(); -// config.set_enable_remote_mount(not original_value); -// EXPECT_EQ(not original_value, config.get_enable_remote_mount()); -// } -// { -// app_config config(provider_type::sia, sia_directory); -// EXPECT_EQ(not original_value, config.get_enable_remote_mount()); -// } -// } +static void common_tests(app_config &config, provider_type prov) { + ASSERT_EQ(config.get_provider_type(), prov); -// TEST_F(config_test, is_remote_mount) { -// bool original_value{}; -// { -// app_config config(provider_type::sia, sia_directory); -// original_value = config.get_is_remote_mount(); -// config.set_is_remote_mount(not original_value); -// EXPECT_EQ(not original_value, config.get_is_remote_mount()); -// } -// { -// app_config config(provider_type::sia, sia_directory); -// EXPECT_EQ(not original_value, config.get_is_remote_mount()); -// } -// } + switch (config.get_provider_type()) { + case provider_type::encrypt: + break; -// TEST_F(config_test, enable_remote_mount_fails_if_remote_mount_is_true) { -// app_config config(provider_type::sia, sia_directory); -// config.set_is_remote_mount(true); -// config.set_enable_remote_mount(true); -// EXPECT_FALSE(config.get_enable_remote_mount()); -// EXPECT_TRUE(config.get_is_remote_mount()); -// } + case provider_type::remote: + break; -// TEST_F(config_test, set_is_remote_mount_fails_if_enable_remote_mount_is_true) -// { -// app_config config(provider_type::sia, sia_directory); -// config.set_enable_remote_mount(true); -// config.set_is_remote_mount(true); -// EXPECT_FALSE(config.get_is_remote_mount()); -// EXPECT_TRUE(config.get_enable_remote_mount()); -// } + case provider_type::s3: + break; -// TEST_F(config_test, remote_host_name_or_ip) { -// { -// app_config config(provider_type::sia, sia_directory); -// config.set_remote_host_name_or_ip("my.host.name"); -// EXPECT_STREQ("my.host.name", -// config.get_remote_host_name_or_ip().c_str()); -// } -// { -// app_config config(provider_type::sia, sia_directory); -// EXPECT_STREQ("my.host.name", -// config.get_remote_host_name_or_ip().c_str()); -// } -// } + case provider_type::sia: + break; -// TEST_F(config_test, remote_api_port) { -// std::uint16_t original_value{}; -// { -// app_config config(provider_type::sia, sia_directory); -// original_value = config.get_remote_api_port(); -// config.set_remote_api_port(original_value + 5); -// EXPECT_EQ(original_value + 5, config.get_remote_api_port()); -// } -// { -// app_config config(provider_type::sia, sia_directory); -// EXPECT_EQ(original_value + 5, config.get_remote_api_port()); -// } -// } - -// TEST_F(config_test, remote_receive_timeout_secs) { -// std::uint16_t original_value{}; -// { -// app_config config(provider_type::sia, sia_directory); -// original_value = config.get_remote_receive_timeout_secs(); -// config.set_remote_receive_timeout_secs(original_value + 5); -// EXPECT_EQ(original_value + 5, config.get_remote_receive_timeout_secs()); -// } -// { -// app_config config(provider_type::sia, sia_directory); -// EXPECT_EQ(original_value + 5, config.get_remote_receive_timeout_secs()); -// } -// } - -// TEST_F(config_test, remote_send_timeout_secs) { -// std::uint16_t original_value{}; -// { -// app_config config(provider_type::sia, sia_directory); -// original_value = config.get_remote_send_timeout_secs(); -// config.set_remote_send_timeout_secs(original_value + 5); -// EXPECT_EQ(original_value + 5, config.get_remote_send_timeout_secs()); -// } -// { -// app_config config(provider_type::sia, sia_directory); -// EXPECT_EQ(original_value + 5, config.get_remote_send_timeout_secs()); -// } -// } - -// TEST_F(config_test, remote_encryption_token) { -// { -// app_config config(provider_type::sia, sia_directory); -// config.set_remote_encryption_token("myToken"); -// EXPECT_STREQ("myToken", config.get_remote_encryption_token().c_str()); -// } -// { -// app_config config(provider_type::sia, sia_directory); -// EXPECT_STREQ("myToken", config.get_remote_encryption_token().c_str()); -// } -// } -// -// TEST_F(config_test, remote_client_pool_size) { -// std::uint8_t original_value{}; -// { -// app_config config(provider_type::sia, sia_directory); -// original_value = config.get_remote_client_pool_size(); -// config.set_remote_client_pool_size(original_value + 5); -// EXPECT_EQ(original_value + 5, config.get_remote_client_pool_size()); -// } -// { -// app_config config(provider_type::sia, sia_directory); -// EXPECT_EQ(original_value + 5, config.get_remote_client_pool_size()); -// } -// } -// -// TEST_F(config_test, remote_client_pool_size_minimum_value) { -// { -// app_config config(provider_type::sia, sia_directory); -// config.set_remote_client_pool_size(0); -// EXPECT_EQ(5, config.get_remote_client_pool_size()); -// } -// { -// app_config config(provider_type::sia, sia_directory); -// EXPECT_EQ(5, config.get_remote_client_pool_size()); -// } -// } - -// TEST_F(config_test, remote_max_connections) { -// std::uint8_t original_value{}; -// { -// app_config config(provider_type::sia, sia_directory); -// original_value = config.get_remote_max_connections(); -// config.set_remote_max_connections(original_value + 5); -// EXPECT_EQ(original_value + 5, config.get_remote_max_connections()); -// } -// { -// app_config config(provider_type::sia, sia_directory); -// EXPECT_EQ(original_value + 5, config.get_remote_max_connections()); -// } -// } - -// TEST_F(config_test, remote_max_connections_minimum_value) { -// { -// app_config config(provider_type::sia, sia_directory); -// config.set_remote_max_connections(0); -// EXPECT_EQ(1, config.get_remote_max_connections()); -// } -// { -// app_config config(provider_type::sia, sia_directory); -// EXPECT_EQ(1, config.get_remote_max_connections()); -// } -// } - -TEST_F(app_config_test, retry_read_count) { - std::uint16_t original_value{}; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_retry_read_count(); - config.set_retry_read_count(original_value + 1); - EXPECT_EQ(original_value + 1, config.get_retry_read_count()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(original_value + 1, config.get_retry_read_count()); + default: + return; } } -TEST_F(app_config_test, retry_read_count_minimum_value) { - { - app_config config(provider_type::sia, sia_directory); - config.set_retry_read_count(1); - EXPECT_EQ(2, config.get_retry_read_count()); - } +TEST_F(app_config_test, encrypt_config) { + app_config config(provider_type::encrypt, encrypt_directory); + defaults_tests(config.get_json(), provider_type::encrypt); + common_tests(config, provider_type::encrypt); } -TEST_F(app_config_test, task_wait_ms) { - std::uint16_t original_value{}; - { - app_config config(provider_type::sia, sia_directory); - original_value = config.get_task_wait_ms(); - config.set_task_wait_ms(original_value + 1U); - EXPECT_EQ(original_value + 1U, config.get_task_wait_ms()); - } - { - app_config config(provider_type::sia, sia_directory); - EXPECT_EQ(original_value + 1U, config.get_task_wait_ms()); - } +TEST_F(app_config_test, s3_config) { + app_config config(provider_type::s3, s3_directory); + defaults_tests(config.get_json(), provider_type::s3); + common_tests(config, provider_type::s3); } -TEST_F(app_config_test, task_wait_ms_minimum_value) { - { - app_config config(provider_type::sia, sia_directory); - config.set_task_wait_ms(1U); - EXPECT_EQ(50U, config.get_task_wait_ms()); - } -} - -TEST_F(app_config_test, can_set_database_type) { - { - app_config config(provider_type::sia, sia_directory); - config.set_database_type(database_type::rocksdb); - EXPECT_EQ(database_type::rocksdb, config.get_database_type()); - - config.set_database_type(database_type::sqlite); - EXPECT_EQ(database_type::sqlite, config.get_database_type()); - - config.set_database_type(database_type::rocksdb); - EXPECT_EQ(database_type::rocksdb, config.get_database_type()); - } +TEST_F(app_config_test, sia_config) { + app_config config(provider_type::sia, sia_directory); + defaults_tests(config.get_json(), provider_type::sia); + common_tests(config, provider_type::sia); } } // namespace repertory