summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/kubernetes/helm/base_command_spec.rb
blob: aacae78be4395b1c18be80e484ab97154cd6b411 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require 'spec_helper'

describe Gitlab::Kubernetes::Helm::BaseCommand do
  let(:application) { create(:clusters_applications_helm) }
  let(:rbac) { false }

  let(:test_class) do
    Class.new do
      include Gitlab::Kubernetes::Helm::BaseCommand

      def initialize(rbac)
        @rbac = rbac
      end

      def name
        "test-class-name"
      end

      def rbac?
        @rbac
      end

      def files
        {
          some: 'value'
        }
      end
    end
  end

  let(:base_command) do
    test_class.new(rbac)
  end

  subject { base_command }

  it_behaves_like 'helm commands' do
    let(:commands) { '' }
  end

  describe '#pod_resource' do
    subject { base_command.pod_resource }

    it 'should returns a kubeclient resoure with pod content for application' do
      is_expected.to be_an_instance_of ::Kubeclient::Resource
    end

    context 'when rbac is true' do
      let(:rbac) { true }

      it 'also returns a kubeclient resource' do
        is_expected.to be_an_instance_of ::Kubeclient::Resource
      end
    end
  end

  describe '#pod_name' do
    subject { base_command.pod_name }

    it { is_expected.to eq('install-test-class-name') }
  end
end