Skip to content

Commit

Permalink
fix factory default configuration store tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielsantosphilips committed Nov 12, 2024
1 parent 3a944af commit 15d563d
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions services/util/test/TestConfigurationStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ class FactoryDefaultConfigurationStoreTest
public:
infra::Function<void(bool success)> onRecoverDone;
infra::Function<void()> onEraseDone;
infra::Function<void(bool success)> onEraseCheckDone;
testing::StrictMock<ConfigurationBlobMock> configurationBlobFactoryDefault;
testing::StrictMock<ConfigurationBlobMock> configurationBlob1;
testing::StrictMock<ConfigurationBlobMock> configurationBlob2;
Expand All @@ -592,6 +593,7 @@ TEST_F(FactoryDefaultConfigurationStoreTest, failed_factory_default_results_in_O
{
configurationStore.Configuration().data = 5;
}));

EXPECT_CALL(configurationBlobFactoryDefault, Erase(testing::_)).WillOnce(testing::SaveArg<0>(&onEraseDone));
onRecoverDone(false);

Expand All @@ -609,9 +611,12 @@ TEST_F(FactoryDefaultConfigurationStoreTest, failed_factory_default_results_in_O
EXPECT_CALL(configurationBlob2, Recover(testing::_)).WillOnce(testing::SaveArg<0>(&onRecoverDone));
onRecoverDone(false);

EXPECT_CALL(configurationBlob1, Erase(testing::_)).WillOnce(testing::SaveArg<0>(&onEraseDone));
EXPECT_CALL(configurationBlob1, IsErased(testing::_)).WillOnce(testing::SaveArg<0>(&onEraseCheckDone));
onRecoverDone(false);

EXPECT_CALL(configurationBlob1, Erase(testing::_)).WillOnce(testing::SaveArg<0>(&onEraseDone));
onEraseCheckDone(false);

EXPECT_CALL(configurationBlob2, Erase(testing::_)).WillOnce(testing::SaveArg<0>(&onEraseDone));
onEraseDone();

Expand Down Expand Up @@ -657,9 +662,12 @@ TEST_F(FactoryDefaultConfigurationStoreTest, failed_factory_default_but_successf

blob = 0;

EXPECT_CALL(configurationBlob2, Erase(testing::_)).WillOnce(testing::SaveArg<0>(&onEraseDone));
EXPECT_CALL(configurationBlob2, IsErased(testing::_)).WillOnce(testing::SaveArg<0>(&onEraseCheckDone));
onRecoverDone(true);

EXPECT_CALL(configurationBlob2, Erase(testing::_)).WillOnce(testing::SaveArg<0>(&onEraseDone));
onEraseCheckDone(false);

blob = 15;
EXPECT_CALL(configurationBlob1, CurrentBlob()).WillOnce(testing::Return(infra::MakeByteRange(blob)));
EXPECT_CALL(*this, OnRecovered(false));
Expand Down Expand Up @@ -691,8 +699,11 @@ TEST_F(FactoryDefaultConfigurationStoreTest, successful_factory_default_results_

blob = 0;

EXPECT_CALL(configurationBlob2, IsErased(testing::_)).WillOnce(testing::SaveArg<0>(&onEraseCheckDone));
onRecoverDone(true);

EXPECT_CALL(configurationBlob2, Erase(testing::_)).WillOnce(testing::SaveArg<0>(&onEraseDone));
onRecoverDone(true); // Blob 1 is recovered
onEraseCheckDone(false); // Blob 1 is recovered

blob = 5;
EXPECT_CALL(configurationBlob1, CurrentBlob()).WillOnce(testing::Return(infra::MakeByteRange(blob)));
Expand Down Expand Up @@ -726,8 +737,11 @@ TEST_F(FactoryDefaultConfigurationStoreTest, when_ConfigurationStore_Recover_fai
EXPECT_CALL(configurationBlob2, Recover(testing::_)).WillOnce(testing::SaveArg<0>(&onRecoverDone));
onRecoverDone(false); // Blob 1 is not recovered

EXPECT_CALL(configurationBlob1, IsErased(testing::_)).WillOnce(testing::SaveArg<0>(&onEraseCheckDone));
onRecoverDone(false);

EXPECT_CALL(configurationBlob1, Erase(testing::_)).WillOnce(testing::SaveArg<0>(&onEraseDone));
onRecoverDone(false); // Blob 2 is not recovered
onEraseCheckDone(false); // Blob 2 is not recovered

EXPECT_CALL(*this, OnRecovered(true));
onEraseDone();
Expand Down

0 comments on commit 15d563d

Please sign in to comment.