summaryrefslogtreecommitdiff
path: root/spec/finders/packages/helm/package_files_finder_spec.rb
blob: 2b84fd2b2d258c9318343355ce2b65f130675d1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 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) }
  let_it_be(:helm_package_file) { helm_package.package_files.first }
  let_it_be(:debian_package) { create(:debian_package, project: project1) }

  describe '#execute' do
    let(:project) { project1 }
    let(:channel) { 'stable' }
    let(:params) { {} }

    subject { described_class.new(project, channel, params).execute }

    context 'with empty params' do
      it { is_expected.to match_array([helm_package_file]) }
    end

    context 'with another project' do
      let(:project) { project2 }

      it { is_expected.to match_array([]) }
    end

    context 'with another channel' do
      let(:channel) { 'staging' }

      it { is_expected.to match_array([]) }
    end

    context 'with file_name' do
      let(:params) { { file_name: helm_package_file.file_name } }

      it { is_expected.to match_array([helm_package_file]) }
    end

    context 'with another file_name' do
      let(:params) { { file_name: 'foobar.tgz' } }

      it { is_expected.to match_array([]) }
    end
  end
end