diff options
| author | mo khan <mo.khan@gmail.com> | 2020-07-13 09:57:29 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-08-21 16:31:57 -0600 |
| commit | cbc4d1e328fd0e578f038d57fbd6b9354dafa79e (patch) | |
| tree | 99b53a90cd7c0996a2d0993b41eb56a695bcc996 /spec/integration/python/pip_spec.rb | |
| parent | eb11eeb1018c4d32e8dbaf3f734e588205f0671f (diff) | |
Install tools from .deb package
Diffstat (limited to 'spec/integration/python/pip_spec.rb')
| -rw-r--r-- | spec/integration/python/pip_spec.rb | 59 |
1 files changed, 12 insertions, 47 deletions
diff --git a/spec/integration/python/pip_spec.rb b/spec/integration/python/pip_spec.rb index 9911dc5..8b7d43b 100644 --- a/spec/integration/python/pip_spec.rb +++ b/spec/integration/python/pip_spec.rb @@ -3,6 +3,10 @@ require 'spec_helper' RSpec.describe "pip" do + before do + system('rm -fr /opt/asdf/installs/python') + end + context "when a project depends on the latest version of pip" do let(:requirements) { "sentry-sdk>=0.7.7" } @@ -65,18 +69,21 @@ RSpec.describe "pip" do [{ version: '2', commit: '04dce91b' }, { version: '3', commit: '48e250a1' }].each do |python| ['1.0', '1.1', '2.0', '2.1'].each do |report_version| context "when generating a `#{report_version}` report using Python `#{python[:version]}`" do + subject { runner.scan(env: environment) } + let(:url) { "https://gitlab.com/gitlab-org/security-products/tests/#{language}-#{package_manager}.git" } let(:language) { 'python' } let(:package_manager) { 'pip' } let(:environment) { { 'LM_REPORT_VERSION' => report_version, 'LM_PYTHON_VERSION' => python[:version] } } let(:expected_content) { fixture_file_content("expected/#{language}/#{python[:version]}/#{package_manager}/v#{report_version}.json").chomp } - it 'matches the expected report' do + before do runner.clone(url, branch: python[:commit]) - report = runner.scan(env: environment) + end - expect(JSON.pretty_generate(report.to_h)).to eq(expected_content) - expect(report).to match_schema(version: report_version) + it 'matches the expected report' do + expect(JSON.pretty_generate(subject.to_h)).to eq(expected_content) + expect(subject).to match_schema(version: report_version) end end end @@ -134,8 +141,8 @@ RSpec.describe "pip" do report = runner.scan(env: { 'SETUP_CMD' => 'bash custom.sh' }) expect(report).to match_schema(version: '2.0') - expect(report.licenses_for('six')).to match_array(["MIT"]) expect(report.dependency_names).to contain_exactly('six') + expect(report.licenses_for('six')).to match_array(["MIT"]) end end @@ -187,46 +194,4 @@ RSpec.describe "pip" do expect(report.licenses_for('requests')).to match_array(['Apache-2.0']) end end - - context "when specifying the version of Python using environment variables" do - let(:output_file) { Pathname.new(runner.project_path.join('output.txt')) } - - before do - runner.add_file('custom.sh') do - <<~SCRIPT - #!/bin/bash -l - - python --version &> '#{output_file}' - SCRIPT - end - end - - it 'prioritizes `LM_PYTHON_VERSION` over the `ASDF_PYTHON_VERSION`' do - runner.scan(env: { - 'ASDF_PYTHON_VERSION' => '3.8.2', - 'LM_PYTHON_VERSION' => '2.7.18', - 'SETUP_CMD' => 'bash custom.sh' - }) - - expect(output_file).to exist - expect(output_file.read).to include('2.7.18') - end - - it 'reads the ASDF_PYTHON_VERSION' do - runner.scan(env: { - 'ASDF_PYTHON_VERSION' => '3.8.2', - 'SETUP_CMD' => 'bash custom.sh' - }) - - expect(output_file).to exist - expect(output_file.read).to include('3.8.2') - end - - it 'defaults to Python 3' do - runner.scan(env: { 'SETUP_CMD' => 'bash custom.sh' }) - - expect(output_file).to exist - expect(output_file.read).to include('3.8.2') - end - end end |
