summaryrefslogtreecommitdiff
path: root/spec/integration/core
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-05-10 10:37:24 -0600
committermo khan <mo.khan@gmail.com>2020-05-10 10:37:24 -0600
commitb2ea3e84a6ec775ceda0e64b1045085444755f06 (patch)
treeb9c9ebcc3e89f3b7fe949316e2473bf3c54b8d51 /spec/integration/core
parent7099bcdb3f3b140495e8a742fa90da3bd04ffb4f (diff)
Identify and resolve bottleneck with csv parsing
Diffstat (limited to 'spec/integration/core')
-rw-r--r--spec/integration/core/cache_spec.rb30
1 files changed, 22 insertions, 8 deletions
diff --git a/spec/integration/core/cache_spec.rb b/spec/integration/core/cache_spec.rb
index 06cdfa3..3f947b2 100644
--- a/spec/integration/core/cache_spec.rb
+++ b/spec/integration/core/cache_spec.rb
@@ -132,20 +132,20 @@ RSpec.describe Spandx::Core::Cache do
end
describe '#each' do
- subject { described_class.new('rubygems', root: root_dir) }
+ context 'when a single item is present in the cache' do
+ subject { described_class.new('rubygems', root: root_dir) }
- let(:root_dir) { Dir.mktmpdir }
+ let(:root_dir) { Dir.mktmpdir }
- after do
- FileUtils.remove_entry(root_dir)
- end
-
- context 'when a single item is present in the cache' do
before do
subject.insert('spandx', '0.0.0', ['MIT'])
end
- it 'yields each item in the index' do
+ after do
+ FileUtils.remove_entry(root_dir)
+ end
+
+ it 'yields each item in the cache' do
collect = []
subject.each do |item|
@@ -155,5 +155,19 @@ RSpec.describe Spandx::Core::Cache do
expect(collect).to match_array([['spandx', '0.0.0', 'MIT']])
end
end
+
+ context 'when multiple items are in multiple datafiles' do
+ subject { described_class.new('rubygems', root: root_dir) }
+
+ let(:root_dir) { "#{Spandx.git[:rubygems].root}/.index" }
+
+ it 'yields each item in the cache' do
+ expect(subject.count).to be > 800_000
+ end
+
+ it 'yields each item quickly' do
+ expect { subject.take(100_000).count }.to perform_under(0.1).sample(10)
+ end
+ end
end
end