Complete ring buffer and direct download support #26

This commit is contained in:
Scott E. Graves 2024-12-23 09:28:01 -06:00
parent 2d5508eb7c
commit b3f7a9b659

View File

@ -40,7 +40,7 @@ namespace repertory {
class ring_buffer_open_file_test : public ::testing::Test { class ring_buffer_open_file_test : public ::testing::Test {
public: public:
console_consumer con_consumer; console_consumer con_consumer;
mock_provider prov; mock_provider provider;
protected: protected:
void SetUp() override { event_system::instance().start(); } void SetUp() override { event_system::instance().start(); }
@ -51,7 +51,7 @@ protected:
TEST_F(ring_buffer_open_file_test, can_forward_to_last_chunk) { TEST_F(ring_buffer_open_file_test, can_forward_to_last_chunk) {
auto source_path = test::generate_test_file_name("ring_buffer_open_file"); auto source_path = test::generate_test_file_name("ring_buffer_open_file");
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false)); EXPECT_CALL(provider, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi; filesystem_item fsi;
fsi.directory = false; fsi.directory = false;
@ -60,8 +60,8 @@ TEST_F(ring_buffer_open_file_test, can_forward_to_last_chunk) {
fsi.source_path = source_path; fsi.source_path = source_path;
{ {
ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi, prov, ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi,
8U); provider, 8U);
file.set(0U, 3U); file.set(0U, 3U);
file.forward(4U); file.forward(4U);
@ -80,7 +80,7 @@ TEST_F(ring_buffer_open_file_test,
can_forward_to_last_chunk_if_count_is_greater_than_remaining) { can_forward_to_last_chunk_if_count_is_greater_than_remaining) {
auto source_path = test::generate_test_file_name("ring_buffer_open_file"); auto source_path = test::generate_test_file_name("ring_buffer_open_file");
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false)); EXPECT_CALL(provider, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi; filesystem_item fsi;
fsi.directory = false; fsi.directory = false;
@ -89,8 +89,8 @@ TEST_F(ring_buffer_open_file_test,
fsi.source_path = source_path; fsi.source_path = source_path;
{ {
ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi, prov, ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi,
8U); provider, 8U);
file.set(0U, 3U); file.set(0U, 3U);
file.forward(100U); file.forward(100U);
@ -108,7 +108,7 @@ TEST_F(ring_buffer_open_file_test,
TEST_F(ring_buffer_open_file_test, 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"); auto source_path = test::generate_test_file_name("ring_buffer_open_file");
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false)); EXPECT_CALL(provider, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi; filesystem_item fsi;
fsi.directory = false; fsi.directory = false;
@ -117,8 +117,8 @@ TEST_F(ring_buffer_open_file_test, can_forward_after_last_chunk) {
fsi.source_path = source_path; fsi.source_path = source_path;
{ {
ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi, prov, ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi,
8U); provider, 8U);
file.set(0U, 3U); file.set(0U, 3U);
file.forward(5U); file.forward(5U);
@ -137,7 +137,7 @@ TEST_F(ring_buffer_open_file_test, can_forward_after_last_chunk) {
TEST_F(ring_buffer_open_file_test, 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"); auto source_path = test::generate_test_file_name("ring_buffer_open_file");
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false)); EXPECT_CALL(provider, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi; filesystem_item fsi;
fsi.directory = false; fsi.directory = false;
@ -146,8 +146,8 @@ TEST_F(ring_buffer_open_file_test, can_forward_and_rollover_after_last_chunk) {
fsi.source_path = source_path; fsi.source_path = source_path;
{ {
ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi, prov, ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi,
8U); provider, 8U);
file.set(16U, 20U); file.set(16U, 20U);
file.forward(8U); file.forward(8U);
@ -162,7 +162,7 @@ TEST_F(ring_buffer_open_file_test, can_forward_and_rollover_after_last_chunk) {
TEST_F(ring_buffer_open_file_test, 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"); auto source_path = test::generate_test_file_name("ring_buffer_open_file");
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false)); EXPECT_CALL(provider, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi; filesystem_item fsi;
fsi.directory = false; fsi.directory = false;
@ -171,8 +171,8 @@ TEST_F(ring_buffer_open_file_test, can_reverse_to_first_chunk) {
fsi.source_path = source_path; fsi.source_path = source_path;
{ {
ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi, prov, ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi,
8U); provider, 8U);
file.set(0U, 3U); file.set(0U, 3U);
file.reverse(3U); file.reverse(3U);
@ -191,7 +191,7 @@ TEST_F(ring_buffer_open_file_test,
can_reverse_to_first_chunk_if_count_is_greater_than_remaining) { can_reverse_to_first_chunk_if_count_is_greater_than_remaining) {
auto source_path = test::generate_test_file_name("ring_buffer_open_file"); auto source_path = test::generate_test_file_name("ring_buffer_open_file");
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false)); EXPECT_CALL(provider, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi; filesystem_item fsi;
fsi.directory = false; fsi.directory = false;
@ -200,8 +200,8 @@ TEST_F(ring_buffer_open_file_test,
fsi.source_path = source_path; fsi.source_path = source_path;
{ {
ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi, prov, ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi,
8U); provider, 8U);
file.set(0U, 3U); file.set(0U, 3U);
file.reverse(13U); file.reverse(13U);
@ -219,7 +219,7 @@ TEST_F(ring_buffer_open_file_test,
TEST_F(ring_buffer_open_file_test, 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"); auto source_path = test::generate_test_file_name("ring_buffer_open_file");
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false)); EXPECT_CALL(provider, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi; filesystem_item fsi;
fsi.directory = false; fsi.directory = false;
@ -228,8 +228,8 @@ TEST_F(ring_buffer_open_file_test, can_reverse_before_first_chunk) {
fsi.source_path = source_path; fsi.source_path = source_path;
{ {
ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi, prov, ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi,
8U); provider, 8U);
file.set(1U, 3U); file.set(1U, 3U);
file.reverse(3U); file.reverse(3U);
@ -249,7 +249,7 @@ TEST_F(ring_buffer_open_file_test,
can_reverse_and_rollover_before_first_chunk) { can_reverse_and_rollover_before_first_chunk) {
auto source_path = test::generate_test_file_name("ring_buffer_open_file"); auto source_path = test::generate_test_file_name("ring_buffer_open_file");
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false)); EXPECT_CALL(provider, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi; filesystem_item fsi;
fsi.directory = false; fsi.directory = false;
@ -258,8 +258,8 @@ TEST_F(ring_buffer_open_file_test,
fsi.source_path = source_path; fsi.source_path = source_path;
{ {
ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi, prov, ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi,
8U); provider, 8U);
file.set(16U, 20U); file.set(16U, 20U);
file.reverse(8U); file.reverse(8U);
@ -282,7 +282,7 @@ TEST_F(ring_buffer_open_file_test,
TEST_F(ring_buffer_open_file_test, 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"); auto source_path = test::generate_test_file_name("ring_buffer_open_file");
EXPECT_CALL(prov, is_read_only()).WillRepeatedly(Return(false)); EXPECT_CALL(provider, is_read_only()).WillRepeatedly(Return(false));
filesystem_item fsi; filesystem_item fsi;
fsi.directory = false; fsi.directory = false;
@ -291,8 +291,8 @@ TEST_F(ring_buffer_open_file_test, can_reverse_full_ring) {
fsi.source_path = source_path; fsi.source_path = source_path;
{ {
ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi, prov, ring_buffer_open_file file(ring_buffer_dir, test_chunk_size, 30U, fsi,
8U); provider, 8U);
file.set(8U, 15U); file.set(8U, 15U);
file.reverse(16U); file.reverse(16U);