Skip to content

Commit

Permalink
add micro test to cover the scernario where the flash region is alrea…
Browse files Browse the repository at this point in the history
…dy erased
  • Loading branch information
gabrielsantosphilips committed Nov 14, 2024
1 parent 199b2a8 commit 1fa092c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions services/util/test/TestConfigurationStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "hal/interfaces/test_doubles/FlashStub.hpp"
#include "infra/event/test_helper/EventDispatcherFixture.hpp"
#include "infra/stream/ByteOutputStream.hpp"
#include "infra/util/ByteRange.hpp"
#include "infra/util/test_helper/MockCallback.hpp"
#include "infra/util/test_helper/MockHelpers.hpp"
#include "services/util/ConfigurationStore.hpp"
Expand Down Expand Up @@ -295,6 +296,24 @@ class ConfigurationStoreTest
testing::StrictMock<ConfigurationStoreObserverMock> observer{ configurationStore };
};

TEST_F(ConfigurationStoreTest, do_not_erase_blob_if_is_already_erased)
{
EXPECT_CALL(configurationBlob1, Recover(testing::_)).WillOnce(testing::SaveArg<0>(&onRecoverDone));
configurationStore.Recover([this](bool success)
{
OnLoaded(success);
});

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

EXPECT_CALL(configurationBlob1, CurrentBlob()).WillOnce(testing::Return(infra::ConstByteRange()));
EXPECT_CALL(dataInstance, Deserialize(testing::_));

EXPECT_CALL(*this, OnLoaded(true));
onEraseCheckDone(true);
}

TEST_F(ConfigurationStoreTest, failed_blob_load_is_propagated)
{
EXPECT_CALL(configurationBlob1, Recover(testing::_)).WillOnce(testing::SaveArg<0>(&onRecoverDone));
Expand Down

0 comments on commit 1fa092c

Please sign in to comment.