diff options
Diffstat (limited to 'spec/finders/packages')
6 files changed, 60 insertions, 6 deletions
diff --git a/spec/finders/packages/conan/package_file_finder_spec.rb b/spec/finders/packages/conan/package_file_finder_spec.rb index c2f445c58f7..3da7da456c2 100644 --- a/spec/finders/packages/conan/package_file_finder_spec.rb +++ b/spec/finders/packages/conan/package_file_finder_spec.rb @@ -8,7 +8,7 @@ RSpec.describe ::Packages::Conan::PackageFileFinder do let(:package_file_name) { package_file.file_name } let(:params) { {} } - RSpec.shared_examples 'package file finder examples' do + shared_examples 'package file finder examples' do it { is_expected.to eq(package_file) } context 'with conan_file_type' do @@ -39,11 +39,37 @@ RSpec.describe ::Packages::Conan::PackageFileFinder do end end + shared_examples 'not returning pending_destruction package files' do + let_it_be(:recent_package_file_pending_destruction) do + create(:package_file, :pending_destruction, package: package, file_name: package_file.file_name) + end + + it 'returns the correct package file' do + expect(package.package_files.last).to eq(recent_package_file_pending_destruction) + + expect(subject).to eq(package_file) + end + + context 'with packages_installable_package_files disabled' do + before do + stub_feature_flags(packages_installable_package_files: false) + end + + it 'returns the correct package file' do + expect(package.package_files.last).to eq(recent_package_file_pending_destruction) + + expect(subject).to eq(recent_package_file_pending_destruction) + end + end + end + describe '#execute' do subject { described_class.new(package, package_file_name, params).execute } it_behaves_like 'package file finder examples' + it_behaves_like 'not returning pending_destruction package files' + context 'with unknown file_name' do let(:package_file_name) { 'unknown.jpg' } @@ -56,6 +82,8 @@ RSpec.describe ::Packages::Conan::PackageFileFinder do it_behaves_like 'package file finder examples' + it_behaves_like 'not returning pending_destruction package files' + context 'with unknown file_name' do let(:package_file_name) { 'unknown.jpg' } diff --git a/spec/finders/packages/go/package_finder_spec.rb b/spec/finders/packages/go/package_finder_spec.rb index dbcb8255d47..b928336f958 100644 --- a/spec/finders/packages/go/package_finder_spec.rb +++ b/spec/finders/packages/go/package_finder_spec.rb @@ -59,7 +59,7 @@ RSpec.describe Packages::Go::PackageFinder do let(:version_name) { version.name } before do - package.update_column(:status, 1) + package.update_column(:status, :error) end it { is_expected.to eq(nil) } diff --git a/spec/finders/packages/maven/package_finder_spec.rb b/spec/finders/packages/maven/package_finder_spec.rb index 38fc3b7cce4..8b45dbdad51 100644 --- a/spec/finders/packages/maven/package_finder_spec.rb +++ b/spec/finders/packages/maven/package_finder_spec.rb @@ -39,7 +39,7 @@ RSpec.describe ::Packages::Maven::PackageFinder do let(:param_path) { package.maven_metadatum.path } before do - package.update_column(:status, 1) + package.update_column(:status, :error) end it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) } diff --git a/spec/finders/packages/npm/package_finder_spec.rb b/spec/finders/packages/npm/package_finder_spec.rb index 230d267e508..7fabb3eed86 100644 --- a/spec/finders/packages/npm/package_finder_spec.rb +++ b/spec/finders/packages/npm/package_finder_spec.rb @@ -52,7 +52,7 @@ RSpec.describe ::Packages::Npm::PackageFinder do context 'with an uninstallable package' do before do - package.update_column(:status, 1) + package.update_column(:status, :error) end it { is_expected.to be_empty } diff --git a/spec/finders/packages/nuget/package_finder_spec.rb b/spec/finders/packages/nuget/package_finder_spec.rb index 045dba295ac..415bf796a72 100644 --- a/spec/finders/packages/nuget/package_finder_spec.rb +++ b/spec/finders/packages/nuget/package_finder_spec.rb @@ -36,7 +36,7 @@ RSpec.describe Packages::Nuget::PackageFinder do context 'with an uninstallable package' do before do - package1.update_column(:status, 1) + package1.update_column(:status, :error) end it { is_expected.to contain_exactly(package2) } diff --git a/spec/finders/packages/package_file_finder_spec.rb b/spec/finders/packages/package_file_finder_spec.rb index 8014f04d917..8b21c9cd3ec 100644 --- a/spec/finders/packages/package_file_finder_spec.rb +++ b/spec/finders/packages/package_file_finder_spec.rb @@ -8,7 +8,7 @@ RSpec.describe Packages::PackageFileFinder do let(:package_file_name) { package_file.file_name } let(:params) { {} } - RSpec.shared_examples 'package file finder examples' do + shared_examples 'package file finder examples' do it { is_expected.to eq(package_file) } context 'with file_name_like' do @@ -19,11 +19,35 @@ RSpec.describe Packages::PackageFileFinder do end end + shared_examples 'not returning pending_destruction package files' do + let_it_be(:recent_package_file_pending_destruction) do + create(:package_file, :pending_destruction, package: package, file_name: package_file.file_name) + end + + it 'returns the correct package file' do + expect(package.package_files.last).to eq(recent_package_file_pending_destruction) + + expect(subject).to eq(package_file) + end + + context 'with packages_installable_package_files disabled' do + before do + stub_feature_flags(packages_installable_package_files: false) + end + + it 'returns them' do + expect(subject).to eq(recent_package_file_pending_destruction) + end + end + end + describe '#execute' do subject { described_class.new(package, package_file_name, params).execute } it_behaves_like 'package file finder examples' + it_behaves_like 'not returning pending_destruction package files' + context 'with unknown file_name' do let(:package_file_name) { 'unknown.jpg' } @@ -36,6 +60,8 @@ RSpec.describe Packages::PackageFileFinder do it_behaves_like 'package file finder examples' + it_behaves_like 'not returning pending_destruction package files' + context 'with unknown file_name' do let(:package_file_name) { 'unknown.jpg' } |