meta db unit tests and fixes
This commit is contained in:
parent
5f51a9384e
commit
c6b895ced2
@ -119,6 +119,8 @@ auto rdb_meta_db::get_item_meta_json(const std::string &api_path,
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
auto found{false};
|
||||
|
||||
{
|
||||
std::string value;
|
||||
auto res = perform_action(__FUNCTION__, [&]() -> rocksdb::Status {
|
||||
@ -129,11 +131,10 @@ auto rdb_meta_db::get_item_meta_json(const std::string &api_path,
|
||||
return res;
|
||||
}
|
||||
|
||||
if (value.empty()) {
|
||||
return api_error::item_not_found;
|
||||
found = not value.empty();
|
||||
if (found) {
|
||||
json_data = json::parse(value);
|
||||
}
|
||||
|
||||
json_data = json::parse(value);
|
||||
}
|
||||
|
||||
{
|
||||
@ -146,6 +147,7 @@ auto rdb_meta_db::get_item_meta_json(const std::string &api_path,
|
||||
return res;
|
||||
}
|
||||
json_data[META_DIRECTORY] = value;
|
||||
found = found || not value.empty();
|
||||
}
|
||||
|
||||
{
|
||||
@ -157,6 +159,7 @@ auto rdb_meta_db::get_item_meta_json(const std::string &api_path,
|
||||
return res;
|
||||
}
|
||||
json_data[META_KEY] = value;
|
||||
found = found || not value.empty();
|
||||
}
|
||||
|
||||
{
|
||||
@ -169,6 +172,7 @@ auto rdb_meta_db::get_item_meta_json(const std::string &api_path,
|
||||
return res;
|
||||
}
|
||||
json_data[META_PINNED] = value;
|
||||
found = found || not value.empty();
|
||||
}
|
||||
|
||||
{
|
||||
@ -180,6 +184,7 @@ auto rdb_meta_db::get_item_meta_json(const std::string &api_path,
|
||||
return res;
|
||||
}
|
||||
json_data[META_SIZE] = value;
|
||||
found = found || not value.empty();
|
||||
}
|
||||
|
||||
{
|
||||
@ -192,9 +197,10 @@ auto rdb_meta_db::get_item_meta_json(const std::string &api_path,
|
||||
return res;
|
||||
}
|
||||
json_data[META_SOURCE] = value;
|
||||
found = found || not value.empty();
|
||||
}
|
||||
|
||||
return api_error::success;
|
||||
return found ? api_error::success : api_error::item_not_found;
|
||||
} catch (const std::exception &e) {
|
||||
utils::error::raise_api_path_error(function_name, api_path, e,
|
||||
"failed to get item meta");
|
||||
|
Loading…
x
Reference in New Issue
Block a user