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/nuget | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/finders/packages/nuget')
-rw-r--r-- | spec/finders/packages/nuget/package_finder_spec.rb | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/spec/finders/packages/nuget/package_finder_spec.rb b/spec/finders/packages/nuget/package_finder_spec.rb new file mode 100644 index 00000000000..9295d0c7a2f --- /dev/null +++ b/spec/finders/packages/nuget/package_finder_spec.rb @@ -0,0 +1,75 @@ +# frozen_string_literal: true +require 'spec_helper' + +RSpec.describe Packages::Nuget::PackageFinder do + let_it_be(:package1) { create(:nuget_package) } + let_it_be(:project) { package1.project } + let_it_be(:package2) { create(:nuget_package, name: package1.name, version: '2.0.0', project: project) } + let_it_be(:package3) { create(:nuget_package, name: 'Another.Dummy.Package', project: project) } + let(:package_name) { package1.name } + let(:package_version) { nil } + let(:limit) { 50 } + + describe '#execute!' do + subject { described_class.new(project, package_name: package_name, package_version: package_version, limit: limit).execute } + + it { is_expected.to match_array([package1, package2]) } + + context 'with lower case package name' do + let(:package_name) { package1.name.downcase } + + it { is_expected.to match_array([package1, package2]) } + end + + context 'with unknown package name' do + let(:package_name) { 'foobar' } + + it { is_expected.to be_empty } + end + + context 'with valid version' do + let(:package_version) { '2.0.0' } + + it { is_expected.to match_array([package2]) } + end + + context 'with unknown version' do + let(:package_version) { 'foobar' } + + it { is_expected.to be_empty } + end + + context 'with limit hit' do + let_it_be(:package4) { create(:nuget_package, name: package1.name, project: project) } + let_it_be(:package5) { create(:nuget_package, name: package1.name, project: project) } + let_it_be(:package6) { create(:nuget_package, name: package1.name, project: project) } + let(:limit) { 2 } + + it { is_expected.to match_array([package5, package6]) } + end + + context 'with downcase package name' do + let(:package_name) { package1.name.downcase } + + it { is_expected.to match_array([package1, package2]) } + end + + context 'with prefix wildcard' do + let(:package_name) { "%#{package1.name[3..-1]}" } + + it { is_expected.to match_array([package1, package2]) } + end + + context 'with suffix wildcard' do + let(:package_name) { "#{package1.name[0..-3]}%" } + + it { is_expected.to match_array([package1, package2]) } + end + + context 'with surrounding wildcards' do + let(:package_name) { "%#{package1.name[3..-3]}%" } + + it { is_expected.to match_array([package1, package2]) } + end + end +end |