Welcome to mirror list, hosted at ThFree Co, Russian Federation.

destroy_service_spec.rb « metrics « prometheus « projects « services « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 81fce82cf4693da711987885f224fd9330a1861d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

require 'spec_helper'

describe Projects::Prometheus::Metrics::DestroyService do
  let(:metric) { create(:prometheus_metric) }

  subject { described_class.new(metric) }

  it 'destroys metric' do
    subject.execute

    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