bmc: move data handler to owned object

To handle the case where one cannot have complex static or global
objects, the object must be owned.  In this case, it is reasonable to
pass ownership to the only object that will use the data handler.

Alternatively, singletons can be used to get around this, but just using
ownership is more appropriate.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I47b291d1cd01af9d4b7287c1411ed9ba37aa7a4c
diff --git a/bmc/test/firmware_handler_unittest.cpp b/bmc/test/firmware_handler_unittest.cpp
index bbbd15a..b886a01 100644
--- a/bmc/test/firmware_handler_unittest.cpp
+++ b/bmc/test/firmware_handler_unittest.cpp
@@ -19,9 +19,8 @@
 
 TEST(FirmwareHandlerTest, CreateEmptyHandlerListVerifyFails)
 {
-    std::vector<DataHandlerPack> data = {
-        {FirmwareFlags::UpdateFlags::ipmi, nullptr},
-    };
+    std::vector<DataHandlerPack> data;
+    data.emplace_back(FirmwareFlags::UpdateFlags::ipmi, nullptr);
 
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
         {}, std::move(data), std::move(CreateActionMap("abcd")));
@@ -47,9 +46,8 @@
     /* The ActionPack map corresponds to the firmware list passed in, but
      * they're not checked against each other yet.
      */
-    std::vector<DataHandlerPack> data = {
-        {FirmwareFlags::UpdateFlags::ipmi, nullptr},
-    };
+    std::vector<DataHandlerPack> data;
+    data.emplace_back(FirmwareFlags::UpdateFlags::ipmi, nullptr);
 
     std::vector<HandlerPack> blobs;
     blobs.push_back(
@@ -68,9 +66,8 @@
     /* The hashblob handler must be one of the entries, but it cannot be the
      * only entry.
      */
-    std::vector<DataHandlerPack> data = {
-        {FirmwareFlags::UpdateFlags::ipmi, nullptr},
-    };
+    std::vector<DataHandlerPack> data;
+    data.emplace_back(FirmwareFlags::UpdateFlags::ipmi, nullptr);
 
     /* Provide a firmware list that has the hash blob, which is the required one
      * -- tested in a different test.
@@ -90,11 +87,12 @@
     blobs2.push_back(
         std::move(HandlerPack("asdf", std::make_unique<ImageHandlerMock>())));
 
-    data = {
-        {FirmwareFlags::UpdateFlags::ipmi, nullptr},
-    };
+    std::vector<DataHandlerPack> data2;
+    data2.emplace_back(FirmwareFlags::UpdateFlags::ipmi, nullptr);
+
     handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        std::move(blobs2), std::move(data), std::move(CreateActionMap("asdf")));
+        std::move(blobs2), std::move(data2),
+        std::move(CreateActionMap("asdf")));
 
     auto result = handler->getBlobIds();
     std::vector<std::string> expectedBlobs = {"asdf", hashBlobId};
@@ -102,9 +100,8 @@
 }
 TEST(FirmwareHandlerTest, VerifyHashRequiredForHappiness)
 {
-    std::vector<DataHandlerPack> data = {
-        {FirmwareFlags::UpdateFlags::ipmi, nullptr},
-    };
+    std::vector<DataHandlerPack> data;
+    data.emplace_back(FirmwareFlags::UpdateFlags::ipmi, nullptr);
 
     /* This works fine only if you also pass in the hash handler. */
     std::vector<HandlerPack> blobs;
@@ -121,11 +118,12 @@
     blobs2.push_back(std::move(
         HandlerPack(hashBlobId, std::make_unique<ImageHandlerMock>())));
 
-    data = {
-        {FirmwareFlags::UpdateFlags::ipmi, nullptr},
-    };
+    std::vector<DataHandlerPack> data2;
+    data2.emplace_back(FirmwareFlags::UpdateFlags::ipmi, nullptr);
+
     handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        std::move(blobs2), std::move(data), std::move(CreateActionMap("asdf")));
+        std::move(blobs2), std::move(data2),
+        std::move(CreateActionMap("asdf")));
 
     auto result = handler->getBlobIds();
     std::vector<std::string> expectedBlobs = {"asdf", hashBlobId};