Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
fix: update bool app envs (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
hycdong authored and acelyc111 committed Jun 3, 2021
1 parent 7f06320 commit e17ef89
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/replica/replica_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,11 +567,12 @@ void replica::update_bool_envs(const std::map<std::string, std::string> &envs,
const std::string &name,
bool &value)
{
bool new_value = value;
bool new_value = false;
auto iter = envs.find(name);
if (iter != envs.end()) {
if (!buf2bool(iter->second, new_value)) {
dwarn_replica("invalid value of env {}: \"{}\"", name, iter->second);
return;
}
}
if (new_value != value) {
Expand Down
20 changes: 9 additions & 11 deletions src/replica/test/replica_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,18 @@ TEST_F(replica_test, update_validate_partition_hash_test)
{
struct update_validate_partition_hash_test
{
bool old_value;
bool set_in_map;
bool old_value;
std::string new_value;
bool expected_value;
} tests[]{
{false, false, "false", false},
{false, true, "false", false},
{false, false, "true", false},
{false, true, "true", true},
{false, true, "ture", false},
{true, true, "false", false},
{true, true, "true", true},
{true, true, "flase", true},
};
} tests[]{{true, false, "false", false},
{true, false, "true", true},
{true, true, "true", true},
{true, true, "false", false},
{false, false, "", false},
{false, true, "", false},
{true, true, "flase", true},
{true, false, "ture", false}};
for (const auto &test : tests) {
update_validate_partition_hash(test.old_value, test.set_in_map, test.new_value);
ASSERT_EQ(get_validate_partition_hash(), test.expected_value);
Expand Down

0 comments on commit e17ef89

Please sign in to comment.