debian-mirror-gitlab/spec/finders/packages/conan/package_finder_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

55 lines
1.8 KiB
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::Packages::Conan::PackageFinder do
2022-07-01 11:34:44 +05:30
using RSpec::Parameterized::TableSyntax
let_it_be_with_reload(:project) { create(:project) }
2020-07-28 23:09:34 +05:30
let_it_be(:user) { create(:user) }
2022-07-01 11:34:44 +05:30
let_it_be(:private_project) { create(:project, :private) }
let_it_be(:conan_package) { create(:conan_package, project: project) }
let_it_be(:conan_package2) { create(:conan_package, project: project) }
let_it_be(:errored_package) { create(:conan_package, :error, project: project) }
let_it_be(:private_package) { create(:conan_package, project: private_project) }
2020-07-28 23:09:34 +05:30
describe '#execute' do
2022-07-01 11:34:44 +05:30
let(:query) { "#{conan_package.name.split('/').first[0, 3]}%" }
let(:finder) { described_class.new(user, query: query) }
subject { finder.execute }
where(:visibility, :role, :packages_visible) do
:private | :maintainer | true
:private | :developer | true
:private | :reporter | true
:private | :guest | false
:private | :anonymous | false
:internal | :maintainer | true
:internal | :developer | true
:internal | :reporter | true
:internal | :guest | true
:internal | :anonymous | false
:public | :maintainer | true
:public | :developer | true
:public | :reporter | true
:public | :guest | true
:public | :anonymous | true
end
2020-07-28 23:09:34 +05:30
2022-07-01 11:34:44 +05:30
with_them do
let(:expected_packages) { packages_visible ? [conan_package, conan_package2] : [] }
let(:user) { role == :anonymous ? nil : super() }
2020-07-28 23:09:34 +05:30
2022-07-01 11:34:44 +05:30
before do
project.update_column(:visibility_level, Gitlab::VisibilityLevel.string_options[visibility.to_s])
project.add_user(user, role) unless role == :anonymous
end
2020-07-28 23:09:34 +05:30
2022-07-01 11:34:44 +05:30
it { is_expected.to eq(expected_packages) }
2020-07-28 23:09:34 +05:30
end
end
end