This commit is contained in:
2025-10-04 14:31:29 -05:00
parent b0e790c5aa
commit b5116732d4
2 changed files with 9 additions and 30 deletions

View File

@@ -27,8 +27,6 @@
#include "events/types/service_stop_begin.hpp" #include "events/types/service_stop_begin.hpp"
#include "events/types/service_stop_end.hpp" #include "events/types/service_stop_end.hpp"
#include "utils/error.hpp" #include "utils/error.hpp"
#include <chrono>
#include <thread>
namespace repertory { namespace repertory {
client_pool::pool::work_queue::work_queue() { client_pool::pool::work_queue::work_queue() {

View File

@@ -493,42 +493,23 @@ TEST_F(direct_open_file_test, provider_error_is_propagated) {
auto test_buffer = build_test_buffer(source_file); auto test_buffer = build_test_buffer(source_file);
bool fail_once{true};
EXPECT_CALL(provider, read_file_bytes) EXPECT_CALL(provider, read_file_bytes)
.WillRepeatedly( .WillRepeatedly([test_buffer](std::string_view, std::size_t /* size */,
[test_buffer, &fail_once](std::string_view, std::size_t size, std::uint64_t /* offset */,
std::uint64_t offset, data_buffer &data, data_buffer & /* data */,
stop_type &stop_requested) -> api_error { stop_type &stop_requested) -> api_error {
if (stop_requested) { if (stop_requested) {
return api_error::download_stopped; return api_error::download_stopped;
} }
if (fail_once) {
fail_once = false; return api_error::os_error;
return api_error::os_error; });
}
std::size_t avail =
(offset < test_buffer.size())
? (test_buffer.size() - static_cast<std::size_t>(offset))
: 0U;
std::size_t to_copy = std::min(size, avail);
data.resize(to_copy);
if (to_copy != 0U) {
std::memcpy(data.data(),
test_buffer.data() + static_cast<std::size_t>(offset),
to_copy);
}
return api_error::success;
});
{ {
direct_open_file file(test_chunk_size, 30U, fsi, provider); direct_open_file file(test_chunk_size, 30U, fsi, provider);
data_buffer data{}; data_buffer data{};
EXPECT_EQ(api_error::os_error, file.read(17U, 0U, data)); EXPECT_EQ(api_error::os_error, file.read(17U, 0U, data));
data_buffer data2{};
EXPECT_EQ(api_error::success, file.read(17U, 0U, data2));
EXPECT_EQ(std::size_t(17U), data2.size());
} }
source_file.close(); source_file.close();