diff options
| author | mo khan <mo.khan@gmail.com> | 2020-05-15 12:13:34 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-05-15 12:13:34 -0600 |
| commit | 81f8960379e2eb05f63275ca3d2caa9986d426cf (patch) | |
| tree | db0f6bed740e0ea4fed68ea2f598fdd13f9e3dc2 /spec | |
| parent | 1d7e7d741cd6e7487bffc23d810a9616d5c3e599 (diff) | |
Load entries in index on demand
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/integration/core/cache_spec.rb | 24 | ||||
| -rw-r--r-- | spec/integration/core/git_spec.rb | 2 | ||||
| -rw-r--r-- | spec/unit/core/index_file_spec.rb | 4 |
3 files changed, 13 insertions, 17 deletions
diff --git a/spec/integration/core/cache_spec.rb b/spec/integration/core/cache_spec.rb index a021418..943fd94 100644 --- a/spec/integration/core/cache_spec.rb +++ b/spec/integration/core/cache_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Spandx::Core::Cache do include_examples 'each data file', 'rubygems', :rubygems include_examples 'each data file', 'nuget', :cache - describe '#insert' do + describe '#insert!' do subject { described_class.new('rubygems', root: root_dir) } let(:root_dir) { Dir.mktmpdir } @@ -45,7 +45,7 @@ RSpec.describe Spandx::Core::Cache do let(:version) { "#{rand(10)}.#{rand(10)}.#{rand(10)}" } before do - subject.insert(dependency_name, version, ['MIT']) + subject.insert!(dependency_name, version, ['MIT']) end specify { expect(subject.licenses_for(dependency_name, version)).to match_array(['MIT']) } @@ -53,32 +53,32 @@ RSpec.describe Spandx::Core::Cache do context 'when attempting to insert invalid entries' do specify do - subject.insert(nil, '1.1.1', ['MIT']) + subject.insert!(nil, '1.1.1', ['MIT']) expect(subject.licenses_for(nil, '1.1.1')).to be_empty end specify do - subject.insert('', '1.1.1', ['MIT']) + subject.insert!('', '1.1.1', ['MIT']) expect(subject.licenses_for('', '1.1.1')).to be_empty end specify do - subject.insert('spandx', nil, ['MIT']) + subject.insert!('spandx', nil, ['MIT']) expect(subject.licenses_for('spandx', nil)).to be_empty end specify do - subject.insert('spandx', nil, ['MIT']) + subject.insert!('spandx', nil, ['MIT']) expect(File.exist?(File.join(root_dir, 'cf', subject.package_manager))).to be(false) end specify do - subject.insert('spandx', '', ['MIT']) + subject.insert!('spandx', '', ['MIT']) expect(subject.licenses_for('spandx', '')).to be_empty end specify do - subject.insert('spandx', '', ['MIT']) + subject.insert!('spandx', '', ['MIT']) expect(File.exist?(File.join(root_dir, 'cf', subject.package_manager))).to be(false) end end @@ -141,7 +141,7 @@ RSpec.describe Spandx::Core::Cache do let(:root_dir) { Dir.mktmpdir } before do - subject.insert('spandx', '0.0.0', ['MIT']) + subject.insert!('spandx', '0.0.0', ['MIT']) end after do @@ -172,12 +172,6 @@ RSpec.describe Spandx::Core::Cache do expect { subject.take(100_000).count }.to perform_under(0.1).sample(10) end - xit 'profiles each' do - with_profiler do - subject.take(100_000).count - end - end - xit 'profiles each option' do require 'fastest-csv' diff --git a/spec/integration/core/git_spec.rb b/spec/integration/core/git_spec.rb index 19307af..12d4a42 100644 --- a/spec/integration/core/git_spec.rb +++ b/spec/integration/core/git_spec.rb @@ -30,7 +30,7 @@ RSpec.describe Spandx::Core::Git do subject.update! end - specify { expect(shell).to have_received(:system).with('git', 'clone', '--quiet', url, expected_path) } + specify { expect(shell).to have_received(:system).with('git', 'clone', '--quiet', '--depth=1', '--single-branch', '--branch', 'master', url, expected_path) } end context 'when the repository has already been cloned' do diff --git a/spec/unit/core/index_file_spec.rb b/spec/unit/core/index_file_spec.rb index 51aef24..d3bf9a5 100644 --- a/spec/unit/core/index_file_spec.rb +++ b/spec/unit/core/index_file_spec.rb @@ -40,7 +40,7 @@ RSpec.describe Spandx::Core::IndexFile do describe '#update!' do let(:data_file) { Spandx::Core::DataFile.new(path) } - let(:path) { File.expand_path(File.join(Dir.home, '.local', 'share', 'spandx-rubygems', '.index', '00', 'rubygems')) } + let(:path) { File.expand_path(File.join(Dir.home, '.local', 'share', 'spandx', 'cache', '.index', '00', 'nuget')) } before do subject.update! @@ -51,5 +51,7 @@ RSpec.describe Spandx::Core::IndexFile do expect(item).not_to be_nil end end + + specify { expect(data_file.count).to be > 1_000 } end end |
