2019-09-30 09:06:31 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-11-06 16:02:28 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 06:09:01 +00:00
|
|
|
RSpec.describe ClusterApplicationEntity do
|
2017-11-06 16:02:28 +00:00
|
|
|
describe '#as_json' do
|
2019-01-30 09:26:52 +00:00
|
|
|
let(:application) { build(:clusters_applications_helm, version: '0.1.1') }
|
2019-12-17 18:07:48 +00:00
|
|
|
|
2017-11-06 16:02:28 +00:00
|
|
|
subject { described_class.new(application).as_json }
|
|
|
|
|
|
|
|
it 'has name' do
|
|
|
|
expect(subject[:name]).to eq(application.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has status' do
|
2017-11-07 16:32:12 +00:00
|
|
|
expect(subject[:status]).to eq(:not_installable)
|
2017-11-06 16:02:28 +00:00
|
|
|
end
|
|
|
|
|
2019-01-30 09:26:52 +00:00
|
|
|
it 'has version' do
|
|
|
|
expect(subject[:version]).to eq('0.1.1')
|
|
|
|
end
|
|
|
|
|
2017-11-06 16:02:28 +00:00
|
|
|
it 'has no status_reason' do
|
|
|
|
expect(subject[:status_reason]).to be_nil
|
|
|
|
end
|
|
|
|
|
2019-04-12 05:42:48 +00:00
|
|
|
it 'has can_uninstall' do
|
2019-08-02 19:02:57 +00:00
|
|
|
expect(subject[:can_uninstall]).to be_truthy
|
2019-04-12 05:42:48 +00:00
|
|
|
end
|
|
|
|
|
2019-02-07 21:40:55 +00:00
|
|
|
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
|
|
|
|
|
2017-11-06 16:02:28 +00:00
|
|
|
context 'when application is errored' do
|
2017-12-22 17:23:43 +00:00
|
|
|
let(:application) { build(:clusters_applications_helm, :errored) }
|
2017-11-06 16:02:28 +00:00
|
|
|
|
|
|
|
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-02-12 03:22:15 +00:00
|
|
|
|
|
|
|
context 'for ingress application' do
|
|
|
|
let(:application) do
|
|
|
|
build(
|
|
|
|
:clusters_applications_ingress,
|
|
|
|
:installed,
|
2018-02-16 00:47:42 +00:00
|
|
|
external_ip: '111.222.111.222'
|
2018-02-12 03:22:15 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'includes external_ip' do
|
|
|
|
expect(subject[:external_ip]).to eq('111.222.111.222')
|
|
|
|
end
|
|
|
|
end
|
2020-02-27 15:09:24 +00:00
|
|
|
|
|
|
|
context 'for knative application' do
|
|
|
|
let(:pages_domain) { create(:pages_domain, :instance_serverless) }
|
|
|
|
let(:application) { build(:clusters_applications_knative, :installed) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
create(:serverless_domain_cluster, knative: application, pages_domain: pages_domain)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'includes available domains' do
|
|
|
|
expect(subject[:available_domains].length).to eq(1)
|
|
|
|
expect(subject[:available_domains].first).to eq(id: pages_domain.id, domain: pages_domain.domain)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'includes pages_domain' do
|
|
|
|
expect(subject[:pages_domain]).to eq(id: pages_domain.id, domain: pages_domain.domain)
|
|
|
|
end
|
|
|
|
end
|
2020-04-23 00:09:41 +00:00
|
|
|
|
|
|
|
context 'for fluentd application' do
|
|
|
|
let(:application) { build(:clusters_applications_fluentd, :installed) }
|
|
|
|
|
|
|
|
it 'includes host, port, protocol and log fields' do
|
|
|
|
expect(subject[:port]).to eq(514)
|
|
|
|
expect(subject[:host]).to eq("example.com")
|
|
|
|
expect(subject[:protocol]).to eq("tcp")
|
|
|
|
expect(subject[:waf_log_enabled]).to be true
|
|
|
|
expect(subject[:cilium_log_enabled]).to be true
|
|
|
|
end
|
|
|
|
end
|
2017-11-06 16:02:28 +00:00
|
|
|
end
|
|
|
|
end
|