Refactored app_config unit tests

This commit is contained in:
Scott E. Graves 2025-02-14 09:29:30 -06:00
parent 0398696e54
commit a244781b8d
4 changed files with 128 additions and 616 deletions

View File

@ -13,6 +13,7 @@
### Changes from v2.0.3-rc ### Changes from v2.0.3-rc
* Continue documentation updates * Continue documentation updates
* Refactored app_config unit tests
* Refactored polling to be more accurate on scheduling tasks * Refactored polling to be more accurate on scheduling tasks
## v2.0.3-rc ## v2.0.3-rc

View File

@ -24,7 +24,7 @@
namespace repertory { namespace repertory {
constexpr const auto default_api_auth_size{48U}; 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_eviction_delay_mins{1U};
constexpr const auto default_high_freq_interval_secs{30U}; constexpr const auto default_high_freq_interval_secs{30U};
constexpr const auto default_low_freq_interval_secs{std::uint16_t(60U * 60U)}; constexpr const auto default_low_freq_interval_secs{std::uint16_t(60U * 60U)};

View File

@ -70,7 +70,7 @@ app_config::app_config(const provider_type &prov,
api_port_(default_rpc_port(prov)), api_port_(default_rpc_port(prov)),
api_user_(std::string{REPERTORY}), api_user_(std::string{REPERTORY}),
config_changed_(false), config_changed_(false),
download_timeout_secs_(default_download_timeout_ces), download_timeout_secs_(default_download_timeout_secs),
enable_download_timeout_(true), enable_download_timeout_(true),
enable_drive_events_(false), enable_drive_events_(false),
#if defined(_WIN32) #if defined(_WIN32)

View File

@ -34,10 +34,18 @@ public:
static std::atomic<std::uint64_t> idx; static std::atomic<std::uint64_t> idx;
std::string encrypt_directory;
std::string s3_directory; std::string s3_directory;
std::string sia_directory; std::string sia_directory;
void SetUp() override { 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(), s3_directory = utils::path::combine(test::get_test_output_dir(),
{ {
"app_config_test", "app_config_test",
@ -59,641 +67,144 @@ public:
std::atomic<std::uint64_t> app_config_test::idx{0U}; std::atomic<std::uint64_t> app_config_test::idx{0U};
TEST_F(app_config_test, api_path) { static void defaults_tests(const json &json_data, provider_type prov) {
std::string original_value; json json_defaults = {
{ {JSON_API_PORT, app_config::default_rpc_port(prov)},
app_config config(provider_type::sia, sia_directory); {JSON_API_USER, std::string{REPERTORY}},
original_value = config.get_api_auth(); {JSON_DOWNLOAD_TIMEOUT_SECS, default_download_timeout_secs},
EXPECT_EQ(48U, original_value.size()); {JSON_DATABASE_TYPE, database_type::rocksdb},
} {JSON_ENABLE_DOWNLOAD_TIMEOUT, true},
} {JSON_ENABLE_DRIVE_EVENTS, false},
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());
}
}
#if defined(_WIN32) #if defined(_WIN32)
TEST_F(app_config_test, enable_mount_manager) { {JSON_ENABLE_MOUNT_MANAGER, false},
bool original_value; #endif // defined(_WIN32)
{ {JSON_ENCRYPT_CONFIG, encrypt_config{}},
app_config config(provider_type::sia, sia_directory); {JSON_EVENT_LEVEL, event_level::info},
original_value = config.get_enable_mount_manager(); {JSON_EVICTION_DELAY_MINS, default_eviction_delay_mins},
config.set_enable_mount_manager(not original_value); {JSON_EVICTION_USE_ACCESS_TIME, false},
EXPECT_EQ(not original_value, config.get_enable_mount_manager()); {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},
app_config config(provider_type::sia, sia_directory); {JSON_MAX_CACHE_SIZE_BYTES, default_max_cache_size_bytes},
EXPECT_EQ(not original_value, config.get_enable_mount_manager()); {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},
#endif {JSON_ORPHANED_FILE_RETENTION_DAYS, default_orphaned_file_retention_days},
TEST_F(app_config_test, event_level) { {JSON_PREFERRED_DOWNLOAD_TYPE, download_type::default_},
{ {JSON_REMOTE_CONFIG, remote::remote_config{}},
app_config config(provider_type::sia, sia_directory); {JSON_REMOTE_MOUNT, remote::remote_mount{}},
config.set_event_level(event_level::debug); {JSON_RETRY_READ_COUNT, default_retry_read_count},
EXPECT_EQ(event_level::debug, config.get_event_level()); {JSON_RING_BUFFER_FILE_SIZE, default_ring_buffer_file_size},
config.set_event_level(event_level::warn); {JSON_S3_CONFIG, s3_config{}},
EXPECT_EQ(event_level::warn, config.get_event_level()); {JSON_SIA_CONFIG, sia_config{}},
} {JSON_TASK_WAIT_MS, default_task_wait_ms},
{ {JSON_VERSION, REPERTORY_CONFIG_VERSION},
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<std::string, 1U> data_directory = {
app_config::default_data_directory(provider_type::sia),
}; };
#if defined(_WIN32) switch (prov) {
const auto local_app_data = utils::get_environment_variable("localappdata"); case provider_type::encrypt:
#endif json_defaults.erase(JSON_DOWNLOAD_TIMEOUT_SECS);
#if defined(__linux__) json_defaults.erase(JSON_ENABLE_DOWNLOAD_TIMEOUT);
const auto local_app_data = json_defaults.erase(JSON_EVICTION_DELAY_MINS);
utils::path::combine(utils::get_environment_variable("HOME"), {".local"}); json_defaults.erase(JSON_EVICTION_USE_ACCESS_TIME);
#endif json_defaults.erase(JSON_HOST_CONFIG);
#if defined(__APPLE__) json_defaults.erase(JSON_MAX_CACHE_SIZE_BYTES);
const auto local_app_data = utils::path::combine( json_defaults.erase(JSON_MAX_UPLOAD_COUNT);
utils::get_environment_variable("HOME"), {"Library/Application Support"}); json_defaults.erase(JSON_ONLINE_CHECK_RETRY_SECS);
#endif json_defaults.erase(JSON_ORPHANED_FILE_RETENTION_DAYS);
auto expected_directory = json_defaults.erase(JSON_PREFERRED_DOWNLOAD_TYPE);
utils::path::combine(local_app_data, {"/repertory2/sia"}); json_defaults.erase(JSON_REMOTE_CONFIG);
EXPECT_STREQ(expected_directory.c_str(), data_directory[0].c_str()); 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;
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;
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;
case provider_type::sia:
json_defaults.erase(JSON_ENCRYPT_CONFIG);
json_defaults.erase(JSON_REMOTE_CONFIG);
json_defaults.erase(JSON_S3_CONFIG);
break;
default:
return;
} }
TEST_F(app_config_test, default_rpc_port) { ASSERT_EQ(std::size_t(default_api_auth_size),
EXPECT_EQ(10000U, app_config::default_rpc_port(provider_type::sia)); json_data.at(JSON_API_AUTH).get<std::string>().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(app_config_test, get_provider_display_name) { static void common_tests(app_config &config, provider_type prov) {
EXPECT_STREQ( ASSERT_EQ(config.get_provider_type(), prov);
"Sia", app_config::get_provider_display_name(provider_type::sia).c_str());
switch (config.get_provider_type()) {
case provider_type::encrypt:
break;
case provider_type::remote:
break;
case provider_type::s3:
break;
case provider_type::sia:
break;
default:
return;
}
} }
TEST_F(app_config_test, get_provider_name) { TEST_F(app_config_test, encrypt_config) {
EXPECT_STREQ("sia", app_config config(provider_type::encrypt, encrypt_directory);
app_config::get_provider_name(provider_type::sia).c_str()); defaults_tests(config.get_json(), provider_type::encrypt);
common_tests(config, provider_type::encrypt);
} }
TEST_F(app_config_test, get_version) { 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, sia_config) {
app_config config(provider_type::sia, sia_directory); app_config config(provider_type::sia, sia_directory);
EXPECT_EQ(REPERTORY_CONFIG_VERSION, config.get_version()); defaults_tests(config.get_json(), provider_type::sia);
} common_tests(config, provider_type::sia);
}
// 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());
// }
// }
// 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());
// }
// }
// 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());
// }
// 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());
// }
// 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());
// }
// }
// 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());
}
}
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, 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, 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());
}
} }
} // namespace repertory } // namespace repertory