2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05: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
|
|
|
|
context 'when user configured kubernetes from CI/CD > Clusters' do
|
|
|
|
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
|
|
|
|
let(:project) { cluster.project }
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
it 'is satisfied by a kubernetes pipeline' do
|
|
|
|
expect(described_class.new('active'))
|
|
|
|
.to be_satisfied_by(pipeline)
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when kubernetes service is inactive' do
|
2020-04-08 14:13:33 +05:30
|
|
|
let_it_be(:project) { create(:project) }
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
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
|