Complete ring buffer and direct download support #26

This commit is contained in:
Scott E. Graves 2024-12-23 09:27:17 -06:00
parent 1a84e507fc
commit 2d5508eb7c
3 changed files with 47 additions and 43 deletions

View File

@ -29,12 +29,22 @@ constexpr const std::size_t test_chunk_size{1024U};
} // namespace
namespace repertory {
TEST(direct_open_file, read_full_file) {
class direct_open_file_test : public ::testing::Test {
public:
console_consumer con_consumer;
mock_provider provider;
protected:
void SetUp() override { event_system::instance().start(); }
void TearDown() override { event_system::instance().stop(); }
};
TEST_F(direct_open_file_test, read_full_file) {
auto &source_file = test::create_random_file(test_chunk_size * 32U);
auto dest_path = test::generate_test_file_name("direct_open_file");
mock_provider provider;
EXPECT_CALL(provider, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi;
@ -89,12 +99,11 @@ TEST(direct_open_file, read_full_file) {
}
}
TEST(direct_open_file, read_full_file_in_reverse) {
TEST_F(direct_open_file_test, read_full_file_in_reverse) {
auto &source_file = test::create_random_file(test_chunk_size * 32U);
auto dest_path = test::generate_test_file_name("direct_open_file");
mock_provider provider;
EXPECT_CALL(provider, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi;
@ -149,12 +158,11 @@ TEST(direct_open_file, read_full_file_in_reverse) {
}
}
TEST(direct_open_file, read_full_file_in_partial_chunks) {
TEST_F(direct_open_file_test, read_full_file_in_partial_chunks) {
auto &source_file = test::create_random_file(test_chunk_size * 32U);
auto dest_path = test::generate_test_file_name("test");
mock_provider provider;
EXPECT_CALL(provider, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi;
@ -206,12 +214,11 @@ TEST(direct_open_file, read_full_file_in_partial_chunks) {
}
}
TEST(direct_open_file, read_full_file_in_partial_chunks_in_reverse) {
TEST_F(direct_open_file_test, read_full_file_in_partial_chunks_in_reverse) {
auto &source_file = test::create_random_file(test_chunk_size * 32U);
auto dest_path = test::generate_test_file_name("direct_open_file");
mock_provider provider;
EXPECT_CALL(provider, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi;

View File

@ -30,9 +30,11 @@
#include "utils/event_capture.hpp"
#include "utils/path.hpp"
namespace repertory {
static constexpr const std::size_t test_chunk_size{1024U};
namespace {
constexpr const std::size_t test_chunk_size{1024U};
}
namespace repertory {
class open_file_test : public ::testing::Test {
public:
console_consumer con_consumer;

View File

@ -37,11 +37,20 @@ std::string ring_buffer_dir = repertory::utils::path::combine(
} // namespace
namespace repertory {
TEST(ring_buffer_open_file, can_forward_to_last_chunk) {
auto source_path = test::generate_test_file_name("ring_buffer_open_file");
class ring_buffer_open_file_test : public ::testing::Test {
public:
console_consumer con_consumer;
mock_provider prov;
protected:
void SetUp() override { event_system::instance().start(); }
void TearDown() override { event_system::instance().stop(); }
};
TEST_F(ring_buffer_open_file_test, can_forward_to_last_chunk) {
auto source_path = test::generate_test_file_name("ring_buffer_open_file");
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi;
@ -67,12 +76,10 @@ TEST(ring_buffer_open_file, can_forward_to_last_chunk) {
EXPECT_TRUE(utils::file::directory(ring_buffer_dir).remove_recursively());
}
TEST(ring_buffer_open_file,
can_forward_to_last_chunk_if_count_is_greater_than_remaining) {
TEST_F(ring_buffer_open_file_test,
can_forward_to_last_chunk_if_count_is_greater_than_remaining) {
auto source_path = test::generate_test_file_name("ring_buffer_open_file");
mock_provider prov;
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi;
@ -98,11 +105,9 @@ TEST(ring_buffer_open_file,
EXPECT_TRUE(utils::file::directory(ring_buffer_dir).remove_recursively());
}
TEST(ring_buffer_open_file, can_forward_after_last_chunk) {
TEST_F(ring_buffer_open_file_test, can_forward_after_last_chunk) {
auto source_path = test::generate_test_file_name("ring_buffer_open_file");
mock_provider prov;
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi;
@ -129,11 +134,9 @@ TEST(ring_buffer_open_file, can_forward_after_last_chunk) {
EXPECT_TRUE(utils::file::directory(ring_buffer_dir).remove_recursively());
}
TEST(ring_buffer_open_file, can_forward_and_rollover_after_last_chunk) {
TEST_F(ring_buffer_open_file_test, can_forward_and_rollover_after_last_chunk) {
auto source_path = test::generate_test_file_name("ring_buffer_open_file");
mock_provider prov;
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi;
@ -156,11 +159,9 @@ TEST(ring_buffer_open_file, can_forward_and_rollover_after_last_chunk) {
EXPECT_TRUE(utils::file::directory(ring_buffer_dir).remove_recursively());
}
TEST(ring_buffer_open_file, can_reverse_to_first_chunk) {
TEST_F(ring_buffer_open_file_test, can_reverse_to_first_chunk) {
auto source_path = test::generate_test_file_name("ring_buffer_open_file");
mock_provider prov;
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi;
@ -186,12 +187,10 @@ TEST(ring_buffer_open_file, can_reverse_to_first_chunk) {
EXPECT_TRUE(utils::file::directory(ring_buffer_dir).remove_recursively());
}
TEST(ring_buffer_open_file,
can_reverse_to_first_chunk_if_count_is_greater_than_remaining) {
TEST_F(ring_buffer_open_file_test,
can_reverse_to_first_chunk_if_count_is_greater_than_remaining) {
auto source_path = test::generate_test_file_name("ring_buffer_open_file");
mock_provider prov;
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi;
@ -217,11 +216,9 @@ TEST(ring_buffer_open_file,
EXPECT_TRUE(utils::file::directory(ring_buffer_dir).remove_recursively());
}
TEST(ring_buffer_open_file, can_reverse_before_first_chunk) {
TEST_F(ring_buffer_open_file_test, can_reverse_before_first_chunk) {
auto source_path = test::generate_test_file_name("ring_buffer_open_file");
mock_provider prov;
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi;
@ -248,11 +245,10 @@ TEST(ring_buffer_open_file, can_reverse_before_first_chunk) {
EXPECT_TRUE(utils::file::directory(ring_buffer_dir).remove_recursively());
}
TEST(ring_buffer_open_file, can_reverse_and_rollover_before_first_chunk) {
TEST_F(ring_buffer_open_file_test,
can_reverse_and_rollover_before_first_chunk) {
auto source_path = test::generate_test_file_name("ring_buffer_open_file");
mock_provider prov;
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi;
@ -283,11 +279,9 @@ TEST(ring_buffer_open_file, can_reverse_and_rollover_before_first_chunk) {
EXPECT_TRUE(utils::file::directory(ring_buffer_dir).remove_recursively());
}
TEST(ring_buffer_open_file, can_reverse_full_ring) {
TEST_F(ring_buffer_open_file_test, can_reverse_full_ring) {
auto source_path = test::generate_test_file_name("ring_buffer_open_file");
mock_provider prov;
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi;
@ -314,7 +308,7 @@ TEST(ring_buffer_open_file, can_reverse_full_ring) {
EXPECT_TRUE(utils::file::directory(ring_buffer_dir).remove_recursively());
}
TEST(ring_buffer_open_file, read_full_file) {
TEST_F(ring_buffer_open_file_test, read_full_file) {
auto &nf = test::create_random_file(test_chunk_size * 33u + 11u);
auto download_source_path = nf.get_path();
@ -379,7 +373,7 @@ TEST(ring_buffer_open_file, read_full_file) {
EXPECT_TRUE(utils::file::directory(ring_buffer_dir).remove_recursively());
}
TEST(ring_buffer_open_file, read_full_file_in_reverse) {
TEST_F(ring_buffer_open_file_test, read_full_file_in_reverse) {
auto &nf = test::create_random_file(test_chunk_size * 32u);
auto download_source_path = nf.get_path();
@ -444,7 +438,7 @@ TEST(ring_buffer_open_file, read_full_file_in_reverse) {
EXPECT_TRUE(utils::file::directory(ring_buffer_dir).remove_recursively());
}
TEST(ring_buffer_open_file, read_full_file_in_partial_chunks) {
TEST_F(ring_buffer_open_file_test, read_full_file_in_partial_chunks) {
auto &nf = test::create_random_file(test_chunk_size * 32u);
auto download_source_path = nf.get_path();
@ -510,7 +504,8 @@ TEST(ring_buffer_open_file, read_full_file_in_partial_chunks) {
EXPECT_TRUE(utils::file::directory(ring_buffer_dir).remove_recursively());
}
TEST(ring_buffer_open_file, read_full_file_in_partial_chunks_in_reverse) {
TEST_F(ring_buffer_open_file_test,
read_full_file_in_partial_chunks_in_reverse) {
auto &nf = test::create_random_file(test_chunk_size * 32u);
auto download_source_path = nf.get_path();