summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/kubernetes/helm/base_command_spec.rb
blob: 3cfdae794f611e139987e48edf961841192eee2d (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
require 'spec_helper'

describe Gitlab::Kubernetes::Helm::BaseCommand do
  let(:application) { create(:clusters_applications_helm) }
  let(:base_command) { described_class.new(application.name) }

  describe '#generate_script' do
    let(:helm_version) { Gitlab::Kubernetes::Helm::HELM_VERSION }
    let(:command) do
      <<~HEREDOC
         set -eo pipefail
         apk add -U ca-certificates openssl >/dev/null
         wget -q -O - https://kubernetes-helm.storage.googleapis.com/helm-v#{helm_version}-linux-amd64.tar.gz | tar zxC /tmp >/dev/null
         mv /tmp/linux-amd64/helm /usr/bin/
      HEREDOC
    end

    subject { base_command.generate_script }

    it 'should return a command that prepares the environment for helm-cli' do
      expect(subject).to eq(command)
    end
  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
  end

  describe '#config_map?' do
    subject { base_command.config_map? }

    it { is_expected.to be_falsy }
  end

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

    it { is_expected.to eq('install-helm') }
  end
end