From e0866d8f9b7b9cabcc1af018de45d02b680dd469 Mon Sep 17 00:00:00 2001 From: Ivan Giuliani Date: Wed, 12 Apr 2023 10:14:35 +0100 Subject: [PATCH] Add tests for small chunk downloads via the streaming interface This also tests that it's possible to customise the chunk size on individual adapters. --- spec/bucket_store_integration_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/bucket_store_integration_spec.rb b/spec/bucket_store_integration_spec.rb index 7448abc..db9c18c 100644 --- a/spec/bucket_store_integration_spec.rb +++ b/spec/bucket_store_integration_spec.rb @@ -99,6 +99,22 @@ expect(rebuilt_large_file.size).to eq(large_file_content.size) expect(rebuilt_large_file).to eq(large_file_content) end + + it "allows downloads of individual small chunks" do + described_class. + for("#{base_bucket_uri}/large.txt"). + upload!("1234567890") + + chunks = described_class.for("#{base_bucket_uri}/large.txt"). + stream. + download(chunk_size: 1). + to_a + + expect(chunks.size).to eq(10) + expect(chunks.map { |_meta, chunk| chunk }).to match_array( + %w[1 2 3 4 5 6 7 8 9 0], + ) + end end end