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