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

fix: fix bug when update bool app envs #781

Merged
merged 2 commits into from
Mar 12, 2021
Merged
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
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 @@ -167,20 +167,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