summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb
blob: 15eb01eb4722e7ebbe637c50ed583ab5e403a804 (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
require 'spec_helper'

describe Gitlab::Ci::Build::Policy::Kubernetes do
  let(:pipeline) { create(:ci_pipeline, project: project) }

  context 'when kubernetes service is active' do
    set(:project) { create(:kubernetes_project) }

    it 'is satisfied by a kubernetes pipeline' do
      expect(described_class.new('active'))
        .to be_satisfied_by(pipeline)
    end
  end

  context 'when kubernetes service is inactive' do
    set(:project) { create(:project) }

    it 'is not satisfied by a pipeline without kubernetes available' do
      expect(described_class.new('active'))
        .not_to be_satisfied_by(pipeline)
    end
  end

  context 'when kubernetes policy is invalid' do
    it 'raises an error' do
      expect { described_class.new('unknown') }
        .to raise_error(described_class::UnknownPolicyError)
    end
  end
end