diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/finders/packages/packages_finder_spec.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/finders/packages/packages_finder_spec.rb')
-rw-r--r-- | spec/finders/packages/packages_finder_spec.rb | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/spec/finders/packages/packages_finder_spec.rb b/spec/finders/packages/packages_finder_spec.rb new file mode 100644 index 00000000000..925b003bb8e --- /dev/null +++ b/spec/finders/packages/packages_finder_spec.rb @@ -0,0 +1,90 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::Packages::PackagesFinder do + let_it_be(:project) { create(:project) } + let_it_be(:maven_package) { create(:maven_package, project: project, created_at: 2.days.ago, name: 'maven', version: '2.0.0') } + let_it_be(:conan_package) { create(:conan_package, project: project, created_at: 1.day.ago, name: 'conan', version: '1.0.0') } + + describe '#execute' do + let(:params) { {} } + + subject { described_class.new(project, params).execute } + + context 'with package_type' do + let_it_be(:npm_package1) { create(:npm_package, project: project) } + let_it_be(:npm_package2) { create(:npm_package, project: project) } + + context 'conan packages' do + let(:params) { { package_type: 'conan' } } + + it { is_expected.to eq([conan_package]) } + end + + context 'npm packages' do + let(:params) { { package_type: 'npm' } } + + it { is_expected.to match_array([npm_package1, npm_package2]) } + end + end + + context 'with order_by' do + context 'by default is created_at' do + it { is_expected.to eq([maven_package, conan_package]) } + end + + context 'order by name' do + let(:params) { { order_by: 'name' } } + + it { is_expected.to eq([conan_package, maven_package]) } + end + + context 'order by version' do + let(:params) { { order_by: 'version' } } + + it { is_expected.to eq([conan_package, maven_package]) } + end + + context 'order by type' do + let(:params) { { order_by: 'type' } } + + it { is_expected.to eq([maven_package, conan_package]) } + end + end + + context 'with sort' do + context 'by default is ascending' do + it { is_expected.to eq([maven_package, conan_package]) } + end + + context 'can sort descended' do + let(:params) { { sort: 'desc' } } + + it { is_expected.to eq([conan_package, maven_package]) } + end + end + + context 'with package_name' do + let(:params) { { package_name: 'maven' } } + + it { is_expected.to eq([maven_package]) } + end + + context 'with nil params' do + it { is_expected.to match_array([conan_package, maven_package]) } + end + + context 'with processing packages' do + let_it_be(:nuget_package) { create(:nuget_package, project: project, name: Packages::Nuget::CreatePackageService::TEMPORARY_PACKAGE_NAME) } + + it { is_expected.to match_array([conan_package, maven_package]) } + end + + context 'does not include packages without version number' do + let_it_be(:package_without_version) { create(:maven_package, project: project, version: nil) } + + it { is_expected.not_to include(package_without_version) } + end + end +end |