debian-mirror-gitlab/spec/finders/packages/helm/package_files_finder_spec.rb

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

57 lines
1.5 KiB
Ruby
Raw Normal View History

2021-09-04 01:27:46 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::Packages::Helm::PackageFilesFinder do
let_it_be(:project1) { create(:project) }
let_it_be(:project2) { create(:project) }
let_it_be(:helm_package) { create(:helm_package, project: project1) }
2021-11-11 11:23:49 +05:30
let_it_be(:helm_package_file1) { helm_package.package_files.first }
let_it_be(:helm_package_file2) { create(:helm_package_file, package: helm_package) }
2021-09-04 01:27:46 +05:30
let_it_be(:debian_package) { create(:debian_package, project: project1) }
2021-11-11 11:23:49 +05:30
let(:project) { project1 }
let(:channel) { 'stable' }
let(:params) { {} }
let(:service) { described_class.new(project, channel, params) }
2021-09-04 01:27:46 +05:30
2021-11-11 11:23:49 +05:30
describe '#execute' do
subject { service.execute }
2021-09-04 01:27:46 +05:30
context 'with empty params' do
2021-11-11 11:23:49 +05:30
it { is_expected.to eq([helm_package_file2, helm_package_file1]) }
2021-09-04 01:27:46 +05:30
end
context 'with another project' do
let(:project) { project2 }
2021-11-11 11:23:49 +05:30
it { is_expected.to eq([]) }
2021-09-04 01:27:46 +05:30
end
context 'with another channel' do
let(:channel) { 'staging' }
2021-11-11 11:23:49 +05:30
it { is_expected.to eq([]) }
2021-09-04 01:27:46 +05:30
end
2021-11-11 11:23:49 +05:30
context 'with matching file_name' do
let(:params) { { file_name: helm_package_file1.file_name } }
2021-09-04 01:27:46 +05:30
2021-11-11 11:23:49 +05:30
it { is_expected.to eq([helm_package_file2, helm_package_file1]) }
2021-09-04 01:27:46 +05:30
end
context 'with another file_name' do
let(:params) { { file_name: 'foobar.tgz' } }
2021-11-11 11:23:49 +05:30
it { is_expected.to eq([]) }
2021-09-04 01:27:46 +05:30
end
end
2021-11-11 11:23:49 +05:30
describe '#most_recent!' do
subject { service.most_recent! }
it { is_expected.to eq(helm_package_file2) }
end
2021-09-04 01:27:46 +05:30
end