debian-mirror-gitlab/spec/workers/cluster_provision_worker_spec.rb

42 lines
1.2 KiB
Ruby
Raw Normal View History

2018-03-17 18:26:18 +05:30
require 'spec_helper'
describe ClusterProvisionWorker do
describe '#perform' do
context 'when provider type is gcp' do
let(:cluster) { create(:cluster, provider_type: :gcp, provider_gcp: provider) }
let(:provider) { create(:cluster_provider_gcp, :scheduled) }
it 'provision a cluster' do
expect_any_instance_of(Clusters::Gcp::ProvisionService).to receive(:execute)
described_class.new.perform(cluster.id)
end
end
context 'when provider type is user' do
2018-12-13 13:39:08 +05:30
let(:cluster) { create(:cluster, :provided_by_user) }
2018-03-17 18:26:18 +05:30
it 'does not provision a cluster' do
expect_any_instance_of(Clusters::Gcp::ProvisionService).not_to receive(:execute)
described_class.new.perform(cluster.id)
end
2018-12-13 13:39:08 +05:30
it 'configures kubernetes platform' do
2019-02-13 22:33:31 +05:30
expect(ClusterConfigureWorker).to receive(:perform_async).with(cluster.id)
2018-12-13 13:39:08 +05:30
described_class.new.perform(cluster.id)
end
2018-03-17 18:26:18 +05:30
end
context 'when cluster does not exist' do
it 'does not provision a cluster' do
expect_any_instance_of(Clusters::Gcp::ProvisionService).not_to receive(:execute)
2019-02-13 22:33:31 +05:30
expect(ClusterConfigureWorker).not_to receive(:perform_async)
2018-03-17 18:26:18 +05:30
described_class.new.perform(123)
end
end
end
end