blob: 44b55e228c582a34dacc552777b5d5fb86793e3c (
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::AlertManagement::Payload do
describe '#parse' do
let_it_be(:project) { build_stubbed(:project) }
let(:payload) { {} }
context 'without a monitoring_tool specified by caller' do
subject { described_class.parse(project, payload) }
context 'without a monitoring tool in the payload' do
it { is_expected.to be_a Gitlab::AlertManagement::Payload::Generic }
end
context 'with the payload specifying Prometheus' do
let(:payload) { { 'monitoring_tool' => 'Prometheus' } }
it { is_expected.to be_a Gitlab::AlertManagement::Payload::Prometheus }
context 'with gitlab-managed attributes' do
let(:payload) { { 'monitoring_tool' => 'Prometheus', 'labels' => { 'gitlab_alert_id' => '12' } } }
it { is_expected.to be_a Gitlab::AlertManagement::Payload::ManagedPrometheus }
end
end
context 'with the payload specifying an unknown tool' do
let(:payload) { { 'monitoring_tool' => 'Custom Tool' } }
it { is_expected.to be_a Gitlab::AlertManagement::Payload::Generic }
end
end
context 'with monitoring_tool specified by caller' do
subject { described_class.parse(project, payload, monitoring_tool: monitoring_tool) }
context 'as Prometheus' do
let(:monitoring_tool) { 'Prometheus' }
context 'with an externally managed prometheus payload' do
it { is_expected.to be_a Gitlab::AlertManagement::Payload::Prometheus }
end
context 'with a self-managed prometheus payload' do
let(:payload) { { 'labels' => { 'gitlab_alert_id' => '14' } } }
it { is_expected.to be_a Gitlab::AlertManagement::Payload::ManagedPrometheus }
end
end
context 'as an unknown tool' do
let(:monitoring_tool) { 'Custom Tool' }
it { is_expected.to be_a Gitlab::AlertManagement::Payload::Generic }
end
end
end
end
|