This commit is contained in:
2024-12-26 09:18:30 -06:00
parent 4260aa9d9b
commit f402f2ef9a
2 changed files with 19 additions and 2 deletions

View File

@ -64,6 +64,8 @@ public:
[[nodiscard]] virtual auto is_directory() const -> bool = 0;
[[nodiscard]] virtual auto is_write_supported() const -> bool = 0;
[[nodiscard]] virtual auto has_handle(std::uint64_t handle) const -> bool = 0;
[[nodiscard]] virtual auto
@ -109,8 +111,6 @@ public:
[[nodiscard]] virtual auto is_modified() const -> bool = 0;
[[nodiscard]] virtual auto is_write_supported() const -> bool = 0;
virtual void remove(std::uint64_t handle) = 0;
virtual void remove_all() = 0;

View File

@ -475,6 +475,10 @@ TEST_F(file_manager_test,
});
EXPECT_CALL(mp, upload_file).Times(0u);
if (not open_file->is_write_supported()) {
EXPECT_EQ(api_error::success, mgr.get_open_file(handle, true, open_file));
}
std::size_t bytes_written{};
data_buffer data = {0, 1, 2};
EXPECT_EQ(api_error::success, open_file->write(0u, data, bytes_written));
@ -614,6 +618,11 @@ TEST_F(file_manager_test, upload_occurs_after_write_if_fully_downloaded) {
EXPECT_NO_THROW(EXPECT_FALSE(meta2.at(META_WRITTEN).empty()));
return api_error::success;
});
if (not open_file->is_write_supported()) {
EXPECT_EQ(api_error::success, mgr.get_open_file(handle, true, open_file));
}
std::size_t bytes_written{};
data_buffer data = {0, 1, 2};
EXPECT_EQ(api_error::success, open_file->write(0u, data, bytes_written));
@ -697,6 +706,10 @@ TEST_F(file_manager_test, can_evict_file) {
.WillRepeatedly(Return(api_error::success));
EXPECT_CALL(mp, upload_file(_, _, _)).WillOnce(Return(api_error::success));
if (not open_file->is_write_supported()) {
EXPECT_EQ(api_error::success, mgr.get_open_file(handle, true, open_file));
}
data_buffer data{{0, 1, 1}};
std::size_t bytes_written{};
auto res = open_file->write(0U, data, bytes_written);
@ -908,6 +921,10 @@ TEST_F(file_manager_test, evict_file_fails_if_file_is_uploading) {
return api_error::success;
});
if (not open_file->is_write_supported()) {
EXPECT_EQ(api_error::success, mgr.get_open_file(handle, true, open_file));
}
data_buffer data{{0, 1, 1}};
std::size_t bytes_written{};
EXPECT_EQ(api_error::success, open_file->write(0U, data, bytes_written));