debian-mirror-gitlab/spec/models/concerns/deployment_platform_spec.rb

86 lines
2.6 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'rails_helper'
describe DeploymentPlatform do
let(:project) { create(:project) }
describe '#deployment_platform' do
subject { project.deployment_platform }
2019-09-30 21:07:59 +05:30
context 'with no Kubernetes configuration on CI/CD, no Kubernetes Service' do
2018-03-17 18:26:18 +05:30
it { is_expected.to be_nil }
end
2019-02-15 15:39:39 +05:30
context 'when project has configured kubernetes from CI/CD > Clusters' do
2018-03-17 18:26:18 +05:30
let!(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let(:platform_kubernetes) { cluster.platform_kubernetes }
it 'returns the Kubernetes platform' do
expect(subject).to eq(platform_kubernetes)
end
2019-02-15 15:39:39 +05:30
context 'with a group level kubernetes cluster' do
let(:group_cluster) { create(:cluster, :provided_by_gcp, :group) }
before do
project.update!(group: group_cluster.group)
end
it 'returns the Kubernetes platform from the project cluster' do
expect(subject).to eq(platform_kubernetes)
end
end
end
context 'when group has configured kubernetes cluster' do
let!(:group_cluster) { create(:cluster, :provided_by_gcp, :group) }
let(:group) { group_cluster.group }
before do
project.update!(group: group)
end
it 'returns the Kubernetes platform' do
is_expected.to eq(group_cluster.platform_kubernetes)
end
2019-10-12 21:52:04 +05:30
context 'when child group has configured kubernetes cluster' do
let(:child_group1) { create(:group, parent: group) }
let!(:child_group1_cluster) { create(:cluster_for_group, groups: [child_group1]) }
2019-02-15 15:39:39 +05:30
before do
project.update!(group: child_group1)
end
it 'returns the Kubernetes platform for the child group' do
is_expected.to eq(child_group1_cluster.platform_kubernetes)
end
context 'deeply nested group' do
2019-10-12 21:52:04 +05:30
let(:child_group2) { create(:group, parent: child_group1) }
let!(:child_group2_cluster) { create(:cluster_for_group, groups: [child_group2]) }
2019-02-15 15:39:39 +05:30
before do
project.update!(group: child_group2)
end
it 'returns most nested group cluster Kubernetes platform' do
is_expected.to eq(child_group2_cluster.platform_kubernetes)
end
context 'cluster in the middle of hierarchy is disabled' do
before do
child_group2_cluster.update!(enabled: false)
end
it 'returns closest enabled Kubenetes platform' do
is_expected.to eq(child_group1_cluster.platform_kubernetes)
end
end
end
end
2018-03-17 18:26:18 +05:30
end
end
end