2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ClusterApplicationEntity do
|
|
|
|
describe '#as_json' do
|
2019-03-02 22:35:43 +05:30
|
|
|
let(:application) { build(:clusters_applications_helm, version: '0.1.1') }
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
subject { described_class.new(application).as_json }
|
|
|
|
|
|
|
|
it 'has name' do
|
|
|
|
expect(subject[:name]).to eq(application.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has status' do
|
|
|
|
expect(subject[:status]).to eq(:not_installable)
|
|
|
|
end
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
it 'has version' do
|
|
|
|
expect(subject[:version]).to eq('0.1.1')
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it 'has no status_reason' do
|
|
|
|
expect(subject[:status_reason]).to be_nil
|
|
|
|
end
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
it 'has can_uninstall' do
|
2019-10-12 21:52:04 +05:30
|
|
|
expect(subject[:can_uninstall]).to be_truthy
|
2019-07-31 22:56:46 +05:30
|
|
|
end
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
context 'non-helm application' do
|
|
|
|
let(:application) { build(:clusters_applications_runner, version: '0.0.0') }
|
|
|
|
|
|
|
|
it 'has update_available' do
|
|
|
|
expect(subject[:update_available]).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
context 'when application is errored' do
|
|
|
|
let(:application) { build(:clusters_applications_helm, :errored) }
|
|
|
|
|
|
|
|
it 'has corresponded data' do
|
|
|
|
expect(subject[:status]).to eq(:errored)
|
|
|
|
expect(subject[:status_reason]).not_to be_nil
|
|
|
|
expect(subject[:status_reason]).to eq(application.status_reason)
|
|
|
|
end
|
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
|
|
|
|
context 'for ingress application' do
|
|
|
|
let(:application) do
|
|
|
|
build(
|
|
|
|
:clusters_applications_ingress,
|
|
|
|
:installed,
|
|
|
|
external_ip: '111.222.111.222'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'includes external_ip' do
|
|
|
|
expect(subject[:external_ip]).to eq('111.222.111.222')
|
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|