2017-10-04 16:32:03 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ClusterEntity do
|
2017-10-30 12:03:58 -04:00
|
|
|
describe '#as_json' do
|
|
|
|
subject { described_class.new(cluster).as_json }
|
2017-10-04 16:32:03 -04:00
|
|
|
|
2017-10-30 12:03:58 -04:00
|
|
|
context 'when provider type is gcp' do
|
|
|
|
let(:cluster) { create(:cluster, provider_type: :gcp, provider_gcp: provider) }
|
2017-10-04 16:32:03 -04:00
|
|
|
|
2017-10-30 12:03:58 -04:00
|
|
|
context 'when status is creating' do
|
2017-11-06 09:06:10 -05:00
|
|
|
let(:provider) { create(:cluster_provider_gcp, :creating) }
|
2017-10-04 16:32:03 -04:00
|
|
|
|
2017-10-30 12:03:58 -04:00
|
|
|
it 'has corresponded data' do
|
|
|
|
expect(subject[:status]).to eq(:creating)
|
|
|
|
expect(subject[:status_reason]).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when status is errored' do
|
2017-11-06 09:06:10 -05:00
|
|
|
let(:provider) { create(:cluster_provider_gcp, :errored) }
|
2017-10-30 12:03:58 -04:00
|
|
|
|
|
|
|
it 'has corresponded data' do
|
|
|
|
expect(subject[:status]).to eq(:errored)
|
|
|
|
expect(subject[:status_reason]).to eq(provider.status_reason)
|
|
|
|
end
|
|
|
|
end
|
2017-10-04 16:32:03 -04:00
|
|
|
end
|
|
|
|
|
2017-10-30 12:03:58 -04:00
|
|
|
context 'when provider type is user' do
|
|
|
|
let(:cluster) { create(:cluster, provider_type: :user) }
|
|
|
|
|
2017-11-07 03:02:50 -05:00
|
|
|
it 'has corresponded data' do
|
|
|
|
expect(subject[:status]).to eq(:created)
|
2017-10-30 12:03:58 -04:00
|
|
|
expect(subject[:status_reason]).to be_nil
|
|
|
|
end
|
2017-10-04 16:32:03 -04:00
|
|
|
end
|
2017-10-31 06:29:56 -04:00
|
|
|
|
2017-11-06 11:02:28 -05:00
|
|
|
context 'when no application has been installed' do
|
|
|
|
let(:cluster) { create(:cluster) }
|
|
|
|
subject { described_class.new(cluster).as_json[:applications]}
|
|
|
|
|
2017-11-07 11:32:12 -05:00
|
|
|
it 'contains helm as not_installable' do
|
2017-11-06 11:02:28 -05:00
|
|
|
expect(subject).not_to be_empty
|
|
|
|
|
|
|
|
helm = subject[0]
|
|
|
|
expect(helm[:name]).to eq('helm')
|
2017-11-07 11:32:12 -05:00
|
|
|
expect(helm[:status]).to eq(:not_installable)
|
2017-11-06 11:02:28 -05:00
|
|
|
end
|
2017-10-31 06:29:56 -04:00
|
|
|
end
|
2017-10-04 16:32:03 -04:00
|
|
|
end
|
|
|
|
end
|