diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/finders/packages/helm/packages_finder_spec.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/finders/packages/helm/packages_finder_spec.rb')
-rw-r--r-- | spec/finders/packages/helm/packages_finder_spec.rb | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/spec/finders/packages/helm/packages_finder_spec.rb b/spec/finders/packages/helm/packages_finder_spec.rb new file mode 100644 index 00000000000..5037a9e6205 --- /dev/null +++ b/spec/finders/packages/helm/packages_finder_spec.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::Packages::Helm::PackagesFinder do + let_it_be(:project1) { create(:project) } + let_it_be(:project2) { create(:project) } + let_it_be(:helm_package) { create(:helm_package, project: project1) } + let_it_be(:npm_package) { create(:npm_package, project: project1) } + let_it_be(:npm_package) { create(:npm_package, project: project2) } + + let(:project) { project1 } + let(:channel) { 'stable' } + let(:finder) { described_class.new(project, channel) } + + describe '#execute' do + subject { finder.execute } + + context 'with project' do + context 'with channel' do + it { is_expected.to eq([helm_package]) } + + context 'ignores duplicate package files' do + let_it_be(:package_file1) { create(:helm_package_file, package: helm_package) } + let_it_be(:package_file2) { create(:helm_package_file, package: helm_package) } + + it { is_expected.to eq([helm_package]) } + + context 'let clients use select id' do + subject { finder.execute.pluck_primary_key } + + it { is_expected.to eq([helm_package.id]) } + end + end + end + + context 'with not existing channel' do + let(:channel) { 'alpha' } + + it { is_expected.to be_empty } + end + + context 'with no channel' do + let(:channel) { nil } + + it { is_expected.to be_empty } + end + + context 'with no helm packages' do + let(:project) { project2 } + + it { is_expected.to be_empty } + end + end + + context 'with no project' do + let(:project) { nil } + + it { is_expected.to be_empty } + end + + context 'when the limit is hit' do + let_it_be(:helm_package2) { create(:helm_package, project: project1) } + let_it_be(:helm_package3) { create(:helm_package, project: project1) } + let_it_be(:helm_package4) { create(:helm_package, project: project1) } + + before do + stub_const("#{described_class}::MAX_PACKAGES_COUNT", 2) + end + + it { is_expected.to eq([helm_package4, helm_package3]) } + end + end +end |