summaryrefslogtreecommitdiff
path: root/spec/integration
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-05-14 21:38:46 -0600
committermo khan <mo.khan@gmail.com>2020-05-14 21:38:46 -0600
commitf1a6736ed78c9fb48645f45505b57b61cc71c822 (patch)
tree28356bce86a8d591be6838ac9ab141aec8b24cb1 /spec/integration
parentee021d5bdb9b35e19eb386e17e81f054a00397e9 (diff)
Write inflated index
Diffstat (limited to 'spec/integration')
-rw-r--r--spec/integration/core/cache_spec.rb28
1 files changed, 20 insertions, 8 deletions
diff --git a/spec/integration/core/cache_spec.rb b/spec/integration/core/cache_spec.rb
index abc7880..ced4604 100644
--- a/spec/integration/core/cache_spec.rb
+++ b/spec/integration/core/cache_spec.rb
@@ -94,10 +94,19 @@ RSpec.describe Spandx::Core::Cache do
end
context 'when new items are added to the catalogue' do
+ let(:items) do
+ [
+ ['spandx', '0.0.0', ['MIT']],
+ ['bolt', '0.2.0', ['Apache-2.0']],
+ ['spandx', '0.1.0', ['MIT']]
+ ]
+ end
+ let(:sorted_items) { items.sort }
+
before do
- subject.insert('spandx', '0.0.0', ['MIT'])
- subject.insert('bolt', '0.2.0', ['Apache-2.0'])
- subject.insert('spandx', '0.1.0', ['MIT'])
+ items.each do |item|
+ subject.insert(item[0], item[1], item[2])
+ end
subject.rebuild_index
end
@@ -111,16 +120,19 @@ RSpec.describe Spandx::Core::Cache do
it 'builds an index that contains the seek position for the start of each line' do
data_file = subject.datafile_for('spandx')
data_file.open_file do |io|
+ i = 0
data_file.index.each do |position|
- unless position.zero?
- io.seek(position - 1)
- expect(io.readchar).to eql("\n")
- end
- expect(io.readchar).not_to eql("\n")
+ io.seek(position)
+ expect(io.gets).to eql("\"#{sorted_items[i].flatten.join('","')}\"\n")
+ i += 1
end
end
end
# rubocop:enable RSpec/MultipleExpectations
+
+ specify { expect(subject.licenses_for('bolt', '0.2.0')).to match_array(['Apache-2.0']) }
+ specify { expect(subject.licenses_for('spandx', '0.0.0')).to match_array(['MIT']) }
+ specify { expect(subject.licenses_for('spandx', '0.1.0')).to match_array(['MIT']) }
end
end