version-handler: Refactor handler construction

Instead of requiring callers to build maps and info blobs, take the
minimal required amount of information about the blob configuration and
build required datastructures internally.

This reduces the amount of code, and nearly eliminates all of the
untested code in main.cpp.

Change-Id: Iaa398eb404814e9263e6707b71b38a9831d96697
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/bmc/version-handler/test/version_open_unittest.cpp b/bmc/version-handler/test/version_open_unittest.cpp
index 7e287e5..7c7e5d2 100644
--- a/bmc/version-handler/test/version_open_unittest.cpp
+++ b/bmc/version-handler/test/version_open_unittest.cpp
@@ -1,16 +1,16 @@
-#include "flags.hpp"
-#include "image_mock.hpp"
-#include "triggerable_mock.hpp"
-#include "util.hpp"
 #include "version_handler.hpp"
+#include "version_mock.hpp"
 
-#include <array>
+#include <memory>
 #include <string>
+#include <unordered_map>
 #include <vector>
 
 #include <gtest/gtest.h>
+
 using ::testing::_;
 using ::testing::Return;
+
 namespace ipmi_flash
 {
 
@@ -19,32 +19,15 @@
   protected:
     void SetUp() override
     {
-        VersionInfoMap vim;
-        for (const auto& blobName : blobNames)
+        h = std::make_unique<VersionBlobHandler>(
+            createMockVersionConfigs(blobNames, &im, &tm));
+        for (const auto& blob : blobNames)
         {
-            auto t = CreateTriggerMock();
-            auto i = CreateImageMock();
-            tm[blobName] = reinterpret_cast<TriggerMock*>(t.get());
-            im[blobName] = reinterpret_cast<ImageHandlerMock*>(i.get());
-            vim.try_emplace(
-                blobName,
-                VersionInfoPack(
-                    blobName, std::make_unique<VersionActionPack>(std::move(t)),
-                    std::move(i)));
-        }
-        h = VersionBlobHandler::create(std::move(vim));
-        ASSERT_NE(h, nullptr);
-        for (const auto& [key, val] : tm)
-        {
-            /* by default no action triggers expected to be called */
-            EXPECT_CALL(*val, trigger()).Times(0);
-        }
-        for (const auto& [key, val] : im)
-        {
-            /* by default no image handler open is expected to be called */
-            EXPECT_CALL(*val, open(_, _)).Times(0);
+            EXPECT_CALL(*tm.at(blob), status())
+                .WillRepeatedly(Return(ActionStatus::unknown));
         }
     }
+
     std::unique_ptr<blobs::GenericBlobInterface> h;
     std::vector<std::string> blobNames{"blob0", "blob1", "blob2", "blob3"};
     std::unordered_map<std::string, TriggerMock*> tm;