Refactor Version::getValue()
Rename the function to getValues() and change the parameter and return
value types, and add a test case for it.
It will be used in future commits.
Tested: Verify the unit test case passes.
Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I57ccf857737ef13f4e2f27c5f2fb7400a2170e91
diff --git a/src/item_updater.cpp b/src/item_updater.cpp
index e100381..d9a502f 100644
--- a/src/item_updater.cpp
+++ b/src/item_updater.cpp
@@ -9,6 +9,11 @@
#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+namespace
+{
+constexpr auto EXTENDED_VERSION = "extended_version";
+}
+
namespace phosphor
{
namespace software
@@ -98,12 +103,14 @@
fs::path manifestPath(filePath);
manifestPath /= MANIFEST_FILE;
- std::string extendedVersion =
- (Version::getValue(
- manifestPath.string(),
- std::map<std::string, std::string>{{"extended_version", ""}}))
- .begin()
- ->second;
+ std::string extendedVersion;
+ auto values =
+ Version::getValues(manifestPath.string(), {EXTENDED_VERSION});
+ const auto it = values.find(EXTENDED_VERSION);
+ if (it != values.end())
+ {
+ extendedVersion = it->second;
+ }
auto activation = createActivationObject(
path, versionId, extendedVersion, activationState, associations);