test: consolidate blob lists
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Id0a8b64ccaacd787eef799d46d9523307fafb422
diff --git a/test/firmware_state_notyetstarted_tarball_unittest.cpp b/test/firmware_state_notyetstarted_tarball_unittest.cpp
index b0e631c..5aa2baa 100644
--- a/test/firmware_state_notyetstarted_tarball_unittest.cpp
+++ b/test/firmware_state_notyetstarted_tarball_unittest.cpp
@@ -70,12 +70,13 @@
{
expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
- std::vector<std::string> expected = {hashBlobId, ubiTarballBlobId};
- EXPECT_THAT(handler->getBlobIds(), UnorderedElementsAreArray(expected));
+ EXPECT_THAT(handler->getBlobIds(),
+ UnorderedElementsAreArray({hashBlobId, ubiTarballBlobId}));
openToInProgress(ubiTarballBlobId);
- expected = {hashBlobId, ubiTarballBlobId, activeImageBlobId};
- EXPECT_THAT(handler->getBlobIds(), UnorderedElementsAreArray(expected));
+ EXPECT_THAT(handler->getBlobIds(),
+ UnorderedElementsAreArray(
+ {hashBlobId, ubiTarballBlobId, activeImageBlobId}));
}
} // namespace
diff --git a/test/firmware_state_notyetstarted_unittest.cpp b/test/firmware_state_notyetstarted_unittest.cpp
index 80e0911..528e47f 100644
--- a/test/firmware_state_notyetstarted_unittest.cpp
+++ b/test/firmware_state_notyetstarted_unittest.cpp
@@ -59,13 +59,11 @@
/* By only checking that the hash and static blob ids are present to start
* with, we're also verifying others aren't.
*/
- std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId};
-
EXPECT_THAT(handler->getBlobIds(),
- UnorderedElementsAreArray(expectedBlobs));
+ UnorderedElementsAreArray(startingBlobs));
/* Verify canHandleBlob is reading from the same list (basically) */
- for (const auto& blob : expectedBlobs)
+ for (const auto& blob : startingBlobs)
{
EXPECT_TRUE(handler->canHandleBlob(blob));
}
diff --git a/test/firmware_state_updatecompleted_unittest.cpp b/test/firmware_state_updatecompleted_unittest.cpp
index 923b6d0..9e43edb 100644
--- a/test/firmware_state_updatecompleted_unittest.cpp
+++ b/test/firmware_state_updatecompleted_unittest.cpp
@@ -196,9 +196,10 @@
{
getToUpdateCompleted(ActionStatus::success);
- std::vector<std::string> expected = {updateBlobId, hashBlobId,
- activeImageBlobId, staticLayoutBlobId};
- EXPECT_THAT(handler->getBlobIds(), UnorderedElementsAreArray(expected));
+ EXPECT_THAT(
+ handler->getBlobIds(),
+ UnorderedElementsAreArray(
+ {updateBlobId, hashBlobId, activeImageBlobId, staticLayoutBlobId}));
}
/*
@@ -215,8 +216,8 @@
handler->close(session);
expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
- std::vector<std::string> expected = {hashBlobId, staticLayoutBlobId};
- EXPECT_THAT(handler->getBlobIds(), UnorderedElementsAreArray(expected));
+ EXPECT_THAT(handler->getBlobIds(),
+ UnorderedElementsAreArray(startingBlobs));
}
TEST_F(FirmwareHandlerUpdateCompletedTest,
@@ -227,8 +228,8 @@
handler->close(session);
expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
- std::vector<std::string> expected = {hashBlobId, staticLayoutBlobId};
- EXPECT_THAT(handler->getBlobIds(), UnorderedElementsAreArray(expected));
+ EXPECT_THAT(handler->getBlobIds(),
+ UnorderedElementsAreArray(startingBlobs));
}
/*
diff --git a/test/firmware_state_updatepending_unittest.cpp b/test/firmware_state_updatepending_unittest.cpp
index 884852c..d09c820 100644
--- a/test/firmware_state_updatepending_unittest.cpp
+++ b/test/firmware_state_updatepending_unittest.cpp
@@ -53,9 +53,9 @@
{
getToUpdatePending();
- std::vector<std::string> expected = {updateBlobId, activeImageBlobId,
- hashBlobId, staticLayoutBlobId};
- EXPECT_THAT(handler->getBlobIds(), UnorderedElementsAreArray(expected));
+ EXPECT_THAT(handler->getBlobIds(),
+ UnorderedElementsAreArray({updateBlobId, activeImageBlobId,
+ hashBlobId, staticLayoutBlobId}));
}
/*
@@ -167,8 +167,7 @@
expected.blobState = FirmwareBlobHandler::UpdateFlags::ipmi;
expected.size = 0;
- std::vector<std::string> testBlobs = {staticLayoutBlobId, hashBlobId};
- for (const auto& blob : testBlobs)
+ for (const auto& blob : startingBlobs)
{
ASSERT_TRUE(handler->canHandleBlob(blob));
@@ -249,9 +248,8 @@
ASSERT_TRUE(handler->canHandleBlob(updateBlobId));
EXPECT_TRUE(handler->deleteBlob(updateBlobId));
- std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId};
EXPECT_THAT(handler->getBlobIds(),
- UnorderedElementsAreArray(expectedBlobs));
+ UnorderedElementsAreArray(startingBlobs));
expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
}
@@ -264,9 +262,8 @@
ASSERT_TRUE(handler->canHandleBlob(activeImageBlobId));
EXPECT_TRUE(handler->deleteBlob(activeImageBlobId));
- std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId};
EXPECT_THAT(handler->getBlobIds(),
- UnorderedElementsAreArray(expectedBlobs));
+ UnorderedElementsAreArray(startingBlobs));
expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
}
@@ -279,9 +276,8 @@
ASSERT_TRUE(handler->canHandleBlob(staticLayoutBlobId));
EXPECT_TRUE(handler->deleteBlob(staticLayoutBlobId));
- std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId};
EXPECT_THAT(handler->getBlobIds(),
- UnorderedElementsAreArray(expectedBlobs));
+ UnorderedElementsAreArray(startingBlobs));
expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
}
@@ -294,9 +290,8 @@
ASSERT_TRUE(handler->canHandleBlob(hashBlobId));
EXPECT_TRUE(handler->deleteBlob(hashBlobId));
- std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId};
EXPECT_THAT(handler->getBlobIds(),
- UnorderedElementsAreArray(expectedBlobs));
+ UnorderedElementsAreArray(startingBlobs));
expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
}
diff --git a/test/firmware_state_updatestarted_unittest.cpp b/test/firmware_state_updatestarted_unittest.cpp
index e8bd103..237e0e9 100644
--- a/test/firmware_state_updatestarted_unittest.cpp
+++ b/test/firmware_state_updatestarted_unittest.cpp
@@ -63,9 +63,10 @@
{
getToUpdateStarted();
- std::vector<std::string> expected = {updateBlobId, hashBlobId,
- activeImageBlobId, staticLayoutBlobId};
- EXPECT_THAT(handler->getBlobIds(), UnorderedElementsAreArray(expected));
+ EXPECT_THAT(
+ handler->getBlobIds(),
+ UnorderedElementsAreArray(
+ {updateBlobId, hashBlobId, activeImageBlobId, staticLayoutBlobId}));
}
/*
@@ -234,10 +235,8 @@
EXPECT_TRUE(handler->close(session));
- std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId};
-
EXPECT_THAT(handler->getBlobIds(),
- UnorderedElementsAreArray(expectedBlobs));
+ UnorderedElementsAreArray(startingBlobs));
expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
}
diff --git a/test/firmware_state_uploadinprogress_unittest.cpp b/test/firmware_state_uploadinprogress_unittest.cpp
index 6c3b607..005ca3f 100644
--- a/test/firmware_state_uploadinprogress_unittest.cpp
+++ b/test/firmware_state_uploadinprogress_unittest.cpp
@@ -48,10 +48,9 @@
/* Opening the image file will add the active image blob id */
openToInProgress(staticLayoutBlobId);
- std::vector<std::string> expectedAfterImage = {
- staticLayoutBlobId, hashBlobId, activeImageBlobId};
EXPECT_THAT(handler->getBlobIds(),
- UnorderedElementsAreArray(expectedAfterImage));
+ UnorderedElementsAreArray(
+ {staticLayoutBlobId, hashBlobId, activeImageBlobId}));
}
TEST_F(FirmwareHandlerUploadInProgressTest, GetBlobIdsVerifyOutputActiveHash)
@@ -59,10 +58,9 @@
/* Opening the image file will add the active image blob id */
openToInProgress(hashBlobId);
- std::vector<std::string> expectedAfterImage = {
- staticLayoutBlobId, hashBlobId, activeHashBlobId};
EXPECT_THAT(handler->getBlobIds(),
- UnorderedElementsAreArray(expectedAfterImage));
+ UnorderedElementsAreArray(
+ {staticLayoutBlobId, hashBlobId, activeHashBlobId}));
}
/*
diff --git a/test/firmware_state_verificationcompleted_unittest.cpp b/test/firmware_state_verificationcompleted_unittest.cpp
index 0f02cf3..8754e15 100644
--- a/test/firmware_state_verificationcompleted_unittest.cpp
+++ b/test/firmware_state_verificationcompleted_unittest.cpp
@@ -91,9 +91,10 @@
TEST_F(FirmwareHandlerVerificationCompletedTest, GetBlobIdsReturnsExpectedList)
{
getToVerificationCompleted(ActionStatus::success);
- std::vector<std::string> expected = {verifyBlobId, hashBlobId,
- activeImageBlobId, staticLayoutBlobId};
- EXPECT_THAT(handler->getBlobIds(), UnorderedElementsAreArray(expected));
+ EXPECT_THAT(
+ handler->getBlobIds(),
+ UnorderedElementsAreArray(
+ {verifyBlobId, hashBlobId, activeImageBlobId, staticLayoutBlobId}));
}
/*
@@ -307,8 +308,8 @@
handler->close(session);
ASSERT_FALSE(handler->canHandleBlob(updateBlobId));
expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
- std::vector<std::string> expected = {staticLayoutBlobId, hashBlobId};
- EXPECT_THAT(handler->getBlobIds(), UnorderedElementsAreArray(expected));
+ EXPECT_THAT(handler->getBlobIds(),
+ UnorderedElementsAreArray(startingBlobs));
}
} // namespace
diff --git a/test/firmware_state_verificationstarted_unittest.cpp b/test/firmware_state_verificationstarted_unittest.cpp
index 165ef0e..74e24b2 100644
--- a/test/firmware_state_verificationstarted_unittest.cpp
+++ b/test/firmware_state_verificationstarted_unittest.cpp
@@ -52,12 +52,12 @@
{
getToVerificationStarted(staticLayoutBlobId);
- std::vector<std::string> expectedList = {
- activeImageBlobId, staticLayoutBlobId, hashBlobId, verifyBlobId};
+ auto blobs = handler->getBlobIds();
+ EXPECT_THAT(
+ blobs, UnorderedElementsAreArray({activeImageBlobId, staticLayoutBlobId,
+ hashBlobId, verifyBlobId}));
- EXPECT_THAT(handler->getBlobIds(), UnorderedElementsAreArray(expectedList));
-
- for (const auto& blob : expectedList)
+ for (const auto& blob : blobs)
{
EXPECT_TRUE(handler->canHandleBlob(blob));
}
@@ -283,10 +283,8 @@
EXPECT_TRUE(handler->close(session));
- std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId};
-
EXPECT_THAT(handler->getBlobIds(),
- UnorderedElementsAreArray(expectedBlobs));
+ UnorderedElementsAreArray(startingBlobs));
expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
}
diff --git a/test/firmware_unittest.hpp b/test/firmware_unittest.hpp
index a79cd4f..e36081d 100644
--- a/test/firmware_unittest.hpp
+++ b/test/firmware_unittest.hpp
@@ -6,6 +6,7 @@
#include "triggerable_mock.hpp"
#include <memory>
+#include <string>
#include <vector>
#include <gmock/gmock.h>
@@ -122,6 +123,8 @@
std::uint16_t session = 1;
std::uint16_t flags =
blobs::OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi;
+
+ std::vector<std::string> startingBlobs = {staticLayoutBlobId, hashBlobId};
};
class IpmiOnlyFirmwareTest : public ::testing::Test