Compare commits
2 Commits
934d400cb4
...
633e7376f7
Author | SHA1 | Date | |
---|---|---|---|
633e7376f7 | |||
567756916b |
@ -748,6 +748,17 @@ TEST_F(file_manager_test, evict_file_fails_if_file_is_pinned) {
|
||||
EXPECT_CALL(mp, is_read_only()).WillRepeatedly(Return(false));
|
||||
file_manager mgr(*cfg, mp);
|
||||
|
||||
EXPECT_CALL(mp, get_filesystem_item)
|
||||
.WillRepeatedly([](const std::string &api_path, bool directory,
|
||||
filesystem_item &fsi) -> api_error {
|
||||
fsi.api_path = api_path;
|
||||
fsi.api_parent = utils::path::get_parent_api_path(api_path);
|
||||
fsi.directory = directory;
|
||||
fsi.size = 2U;
|
||||
fsi.source_path = "/test/test_open.src";
|
||||
return api_error::success;
|
||||
});
|
||||
|
||||
EXPECT_CALL(mp, get_item_meta(_, META_PINNED, _))
|
||||
.WillOnce([](const std::string &api_path, const std::string &key,
|
||||
std::string &value) -> api_error {
|
||||
@ -811,9 +822,11 @@ TEST_F(file_manager_test, evict_file_fails_if_unable_to_get_filesystem_item) {
|
||||
file_manager mgr(*cfg, mp);
|
||||
|
||||
EXPECT_CALL(mp, get_filesystem_item)
|
||||
.WillRepeatedly(
|
||||
[](const std::string &api_path, bool directory,
|
||||
filesystem_item &fsi) -> api_error { return api_error::error; });
|
||||
.WillRepeatedly([](const std::string & /* api_path */,
|
||||
bool /* directory */,
|
||||
filesystem_item & /* fsi */) -> api_error {
|
||||
return api_error::error;
|
||||
});
|
||||
|
||||
EXPECT_FALSE(mgr.evict_file("/test_open.txt"));
|
||||
}
|
||||
@ -943,6 +956,7 @@ TEST_F(file_manager_test, evict_file_fails_if_file_is_modified) {
|
||||
EXPECT_CALL(mp, is_read_only()).WillRepeatedly(Return(false));
|
||||
|
||||
file_manager mgr(*cfg, mp);
|
||||
|
||||
EXPECT_CALL(mp, get_filesystem_item)
|
||||
.WillOnce([](const std::string &api_path, bool directory,
|
||||
filesystem_item &fsi) -> api_error {
|
||||
@ -957,11 +971,12 @@ TEST_F(file_manager_test, evict_file_fails_if_file_is_modified) {
|
||||
});
|
||||
|
||||
auto file = std::make_shared<mock_open_file>();
|
||||
EXPECT_CALL(*file, is_directory).WillOnce(Return(false));
|
||||
EXPECT_CALL(*file, add).WillOnce(Return());
|
||||
EXPECT_CALL(*file, get_api_path).WillRepeatedly(Return("/test_evict.txt"));
|
||||
EXPECT_CALL(*file, get_source_path).WillRepeatedly(Return("/test_evict.src"));
|
||||
EXPECT_CALL(*file, is_modified).Times(2).WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(*file, is_directory).WillOnce(Return(false));
|
||||
EXPECT_CALL(*file, is_modified).WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(*file, is_write_supported).WillRepeatedly(Return(true));
|
||||
|
||||
std::uint64_t handle{};
|
||||
std::shared_ptr<i_open_file> open_file;
|
||||
@ -984,20 +999,21 @@ TEST_F(file_manager_test, evict_file_fails_if_file_is_not_complete) {
|
||||
filesystem_item &fsi) -> api_error {
|
||||
EXPECT_STREQ("/test_evict.txt", api_path.c_str());
|
||||
EXPECT_FALSE(directory);
|
||||
fsi.api_path = api_path;
|
||||
fsi.api_parent = utils::path::get_parent_api_path(api_path);
|
||||
fsi.api_path = api_path;
|
||||
fsi.directory = directory;
|
||||
fsi.size = 1U;
|
||||
return api_error::success;
|
||||
});
|
||||
|
||||
auto file = std::make_shared<mock_open_file>();
|
||||
EXPECT_CALL(*file, is_directory).WillOnce(Return(false));
|
||||
EXPECT_CALL(*file, add).WillOnce(Return());
|
||||
EXPECT_CALL(*file, get_api_path).WillRepeatedly(Return("/test_evict.txt"));
|
||||
EXPECT_CALL(*file, get_source_path).WillRepeatedly(Return("/test_evict.src"));
|
||||
EXPECT_CALL(*file, is_modified).Times(2).WillRepeatedly(Return(false));
|
||||
EXPECT_CALL(*file, is_complete).Times(2).WillRepeatedly(Return(false));
|
||||
EXPECT_CALL(*file, is_complete).WillRepeatedly(Return(false));
|
||||
EXPECT_CALL(*file, is_directory).WillOnce(Return(false));
|
||||
EXPECT_CALL(*file, is_modified).WillRepeatedly(Return(false));
|
||||
EXPECT_CALL(*file, is_write_supported).WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(mp, set_item_meta("/test_evict.txt", META_SOURCE, _))
|
||||
.WillOnce(Return(api_error::success));
|
||||
|
||||
|
Reference in New Issue
Block a user