Commit 6216e032 authored by Etienne Baqué's avatar Etienne Baqué

Added rspec tests

Added tests for changes made on Prometheus class.
Added tests for changes made on Environments class.
parent 45d212da
...@@ -289,4 +289,28 @@ describe Clusters::Applications::Prometheus do ...@@ -289,4 +289,28 @@ describe Clusters::Applications::Prometheus do
end end
end end
end end
describe '#configured?' do
let(:prometheus) { create(:clusters_applications_prometheus, :installed, cluster: cluster) }
subject { prometheus.configured? }
context 'when a kubenetes client is present' do
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
it { is_expected.to be_truthy }
context 'when it is not availalble' do
let(:prometheus) { create(:clusters_applications_prometheus, cluster: cluster) }
it { is_expected.to be_falsey }
end
end
context 'when a kubenetes client is not present' do
let(:cluster) { create(:cluster) }
it { is_expected.to be_falsy }
end
end
end end
...@@ -824,6 +824,14 @@ describe Environment, :use_clean_rails_memory_store_caching do ...@@ -824,6 +824,14 @@ describe Environment, :use_clean_rails_memory_store_caching do
context 'and no deployments' do context 'and no deployments' do
it { is_expected.to be_truthy } it { is_expected.to be_truthy }
end end
context 'and the prometheus adapter is not configured' do
before do
allow(environment.prometheus_adapter).to receive(:configured?).and_return(false)
end
it { is_expected.to be_falsy }
end
end end
context 'without a monitoring service' do context 'without a monitoring service' do
...@@ -858,6 +866,14 @@ describe Environment, :use_clean_rails_memory_store_caching do ...@@ -858,6 +866,14 @@ describe Environment, :use_clean_rails_memory_store_caching do
is_expected.to eq(:fake_metrics) is_expected.to eq(:fake_metrics)
end end
context 'and the prometheus client is not present' do
before do
allow(environment.prometheus_adapter).to receive(:promethus_client).and_return(nil)
end
it { is_expected.to be_nil }
end
end end
context 'when the environment does not have metrics' do context 'when the environment does not have metrics' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment