diff options
Diffstat (limited to 'spec/services/projects/prometheus')
5 files changed, 0 insertions, 183 deletions
diff --git a/spec/services/projects/prometheus/alerts/create_service_spec.rb b/spec/services/projects/prometheus/alerts/create_service_spec.rb deleted file mode 100644 index 6b9d43e4e81..00000000000 --- a/spec/services/projects/prometheus/alerts/create_service_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Projects::Prometheus::Alerts::CreateService do - let_it_be(:project) { create(:project) } - let_it_be(:user) { create(:user) } - - let(:service) { described_class.new(project: project, current_user: user, params: params) } - - subject { service.execute } - - describe '#execute' do - context 'with params' do - let_it_be(:environment) { create(:environment, project: project) } - - let_it_be(:metric) do - create(:prometheus_metric, project: project) - end - - let(:params) do - { - environment_id: environment.id, - prometheus_metric_id: metric.id, - operator: '<', - threshold: 1.0 - } - end - - it 'creates an alert' do - expect(subject).to be_persisted - - expect(subject).to have_attributes( - project: project, - environment: environment, - prometheus_metric: metric, - operator: 'lt', - threshold: 1.0 - ) - end - end - - context 'without params' do - let(:params) { {} } - - it 'fails to create' do - expect(subject).to be_new_record - expect(subject).to be_invalid - end - end - end -end diff --git a/spec/services/projects/prometheus/alerts/destroy_service_spec.rb b/spec/services/projects/prometheus/alerts/destroy_service_spec.rb deleted file mode 100644 index a3e9c3516c2..00000000000 --- a/spec/services/projects/prometheus/alerts/destroy_service_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Projects::Prometheus::Alerts::DestroyService do - let_it_be(:project) { create(:project) } - let_it_be(:user) { create(:user) } - let_it_be(:alert) { create(:prometheus_alert, project: project) } - - let(:service) { described_class.new(project: project, current_user: user, params: nil) } - - describe '#execute' do - subject { service.execute(alert) } - - it 'deletes the alert' do - expect(subject).to be_truthy - - expect(alert).to be_destroyed - end - end -end diff --git a/spec/services/projects/prometheus/alerts/update_service_spec.rb b/spec/services/projects/prometheus/alerts/update_service_spec.rb deleted file mode 100644 index ec6766221f6..00000000000 --- a/spec/services/projects/prometheus/alerts/update_service_spec.rb +++ /dev/null @@ -1,53 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Projects::Prometheus::Alerts::UpdateService do - let_it_be(:project) { create(:project) } - let_it_be(:user) { create(:user) } - let_it_be(:environment) { create(:environment, project: project) } - - let_it_be(:alert) do - create(:prometheus_alert, project: project, environment: environment) - end - - let(:service) { described_class.new(project: project, current_user: user, params: params) } - - let(:params) do - { - environment_id: alert.environment_id, - prometheus_metric_id: alert.prometheus_metric_id, - operator: '==', - threshold: 2.0 - } - end - - describe '#execute' do - subject { service.execute(alert) } - - context 'with valid params' do - it 'updates the alert' do - expect(subject).to be_truthy - - expect(alert.reload).to have_attributes( - operator: 'eq', - threshold: 2.0 - ) - end - end - - context 'with invalid params' do - let(:other_environment) { create(:environment) } - - before do - params[:environment_id] = other_environment.id - end - - it 'fails to update' do - expect(subject).to be_falsey - - expect(alert).to be_invalid - end - end - end -end diff --git a/spec/services/projects/prometheus/metrics/destroy_service_spec.rb b/spec/services/projects/prometheus/metrics/destroy_service_spec.rb index 17cc88b27b6..b4af81f2c87 100644 --- a/spec/services/projects/prometheus/metrics/destroy_service_spec.rb +++ b/spec/services/projects/prometheus/metrics/destroy_service_spec.rb @@ -12,17 +12,4 @@ RSpec.describe Projects::Prometheus::Metrics::DestroyService do expect(PrometheusMetric.find_by(id: metric.id)).to be_nil end - - context 'when metric has a prometheus alert associated' do - it 'schedules a prometheus alert update' do - create(:prometheus_alert, project: metric.project, prometheus_metric: metric) - - schedule_update_service = spy - allow(::Clusters::Applications::ScheduleUpdateService).to receive(:new).and_return(schedule_update_service) - - subject.execute - - expect(schedule_update_service).to have_received(:execute) - end - end end diff --git a/spec/services/projects/prometheus/metrics/update_service_spec.rb b/spec/services/projects/prometheus/metrics/update_service_spec.rb deleted file mode 100644 index bf87093150c..00000000000 --- a/spec/services/projects/prometheus/metrics/update_service_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Projects::Prometheus::Metrics::UpdateService do - let(:metric) { create(:prometheus_metric) } - - it 'updates the prometheus metric' do - expect do - described_class.new(metric, { title: "bar" }).execute - end.to change { metric.reload.title }.to("bar") - end - - context 'when metric has a prometheus alert associated' do - let(:schedule_update_service) { spy } - - before do - create(:prometheus_alert, project: metric.project, prometheus_metric: metric) - allow(::Clusters::Applications::ScheduleUpdateService).to receive(:new).and_return(schedule_update_service) - end - - context 'when updating title' do - it 'schedules a prometheus alert update' do - described_class.new(metric, { title: "bar" }).execute - - expect(schedule_update_service).to have_received(:execute) - end - end - - context 'when updating query' do - it 'schedules a prometheus alert update' do - described_class.new(metric, { query: "sum(bar)" }).execute - - expect(schedule_update_service).to have_received(:execute) - end - end - - it 'does not schedule a prometheus alert update without title nor query being changed' do - described_class.new(metric, { y_label: "bar" }).execute - - expect(schedule_update_service).not_to have_received(:execute) - end - end -end |