blob: 51912347a8927b82123eddce4d2afab1d7a7d636 [file] [log] [blame]
Patrick Venture9efef5d2019-06-19 08:45:44 -07001#include "cleanup.hpp"
2#include "filesystem_mock.hpp"
3#include "util.hpp"
4
5#include <string>
6#include <vector>
7
8#include <gtest/gtest.h>
9
10namespace ipmi_flash
11{
12namespace
13{
14
15using ::testing::Return;
16using ::testing::UnorderedElementsAreArray;
17
18class CleanupHandlerTest : public ::testing::Test
19{
20 protected:
21 std::vector<std::string> blobs = {"abcd", "efgh"};
22 FileSystemMock mock;
23 FileCleanupHandler handler{cleanupBlobId, blobs, &mock};
24};
25
26TEST_F(CleanupHandlerTest, GetBlobListReturnsExpectedList)
27{
28 EXPECT_TRUE(handler.canHandleBlob(cleanupBlobId));
29 EXPECT_THAT(handler.getBlobIds(),
30 UnorderedElementsAreArray({cleanupBlobId}));
31}
32
33TEST_F(CleanupHandlerTest, CommitShouldDeleteFiles)
34{
35 EXPECT_CALL(mock, remove("abcd")).WillOnce(Return());
36 EXPECT_CALL(mock, remove("efgh")).WillOnce(Return());
37
38 EXPECT_TRUE(handler.commit(1, {}));
39}
40
41} // namespace
42} // namespace ipmi_flash