2017-10-04 10:26:56 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ClusterProvisionWorker do
|
|
|
|
describe '#perform' do
|
2017-10-30 11:18:15 -04:00
|
|
|
context 'when provider type is gcp' do
|
|
|
|
let(:cluster) { create(:cluster, provider_type: :gcp, provider_gcp: provider) }
|
2017-11-06 09:06:10 -05:00
|
|
|
let(:provider) { create(:cluster_provider_gcp, :scheduled) }
|
2017-10-04 10:26:56 -04:00
|
|
|
|
|
|
|
it 'provision a cluster' do
|
2017-10-30 11:18:15 -04:00
|
|
|
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-11-02 11:46:15 -04:00
|
|
|
let(:cluster) { create(:cluster, :provided_by_user) }
|
2017-10-30 11:18:15 -04:00
|
|
|
|
|
|
|
it 'does not provision a cluster' do
|
|
|
|
expect_any_instance_of(Clusters::Gcp::ProvisionService).not_to receive(:execute)
|
2017-10-04 10:26:56 -04:00
|
|
|
|
|
|
|
described_class.new.perform(cluster.id)
|
|
|
|
end
|
2018-11-02 11:46:15 -04:00
|
|
|
|
|
|
|
it 'configures kubernetes platform' do
|
2018-12-21 08:17:13 -05:00
|
|
|
expect(ClusterConfigureWorker).to receive(:perform_async).with(cluster.id)
|
2018-11-02 11:46:15 -04:00
|
|
|
|
|
|
|
described_class.new.perform(cluster.id)
|
|
|
|
end
|
2017-10-04 10:26:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when cluster does not exist' do
|
|
|
|
it 'does not provision a cluster' do
|
2017-10-30 11:18:15 -04:00
|
|
|
expect_any_instance_of(Clusters::Gcp::ProvisionService).not_to receive(:execute)
|
2018-12-21 08:17:13 -05:00
|
|
|
expect(ClusterConfigureWorker).not_to receive(:perform_async)
|
2017-10-04 10:26:56 -04:00
|
|
|
|
|
|
|
described_class.new.perform(123)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|