diff options
Diffstat (limited to 'spec/lib/gitlab/alert_management')
-rw-r--r-- | spec/lib/gitlab/alert_management/payload/base_spec.rb | 22 | ||||
-rw-r--r-- | spec/lib/gitlab/alert_management/payload/generic_spec.rb | 36 |
2 files changed, 58 insertions, 0 deletions
diff --git a/spec/lib/gitlab/alert_management/payload/base_spec.rb b/spec/lib/gitlab/alert_management/payload/base_spec.rb index ad2a3c7b462..3e8d71ac673 100644 --- a/spec/lib/gitlab/alert_management/payload/base_spec.rb +++ b/spec/lib/gitlab/alert_management/payload/base_spec.rb @@ -347,4 +347,26 @@ RSpec.describe Gitlab::AlertManagement::Payload::Base do it { is_expected.to be(true) } end + + describe '#source' do + subject { parsed_payload.source } + + it { is_expected.to be_nil } + + context 'with alerting integration provided' do + before do + parsed_payload.integration = instance_double('::AlertManagement::HttpIntegration', name: 'INTEGRATION') + end + + it { is_expected.to eq('INTEGRATION') } + end + + context 'with monitoring tool defined in the raw payload' do + before do + allow(parsed_payload).to receive(:monitoring_tool).and_return('TOOL') + end + + it { is_expected.to eq('TOOL') } + end + end end diff --git a/spec/lib/gitlab/alert_management/payload/generic_spec.rb b/spec/lib/gitlab/alert_management/payload/generic_spec.rb index 59933f7459d..bc3b6edc638 100644 --- a/spec/lib/gitlab/alert_management/payload/generic_spec.rb +++ b/spec/lib/gitlab/alert_management/payload/generic_spec.rb @@ -144,4 +144,40 @@ RSpec.describe Gitlab::AlertManagement::Payload::Generic do it { is_expected.to eq(value) } end end + + describe '#resolved?' do + subject { parsed_payload.resolved? } + + context 'without end time' do + it { is_expected.to eq(false) } + end + + context 'with end time' do + let(:raw_payload) { { 'end_time' => Time.current.to_s } } + + it { is_expected.to eq(true) } + end + end + + describe '#source' do + subject { parsed_payload.source } + + it { is_expected.to eq('Generic Alert Endpoint') } + + context 'with alerting integration provided' do + before do + parsed_payload.integration = instance_double('::AlertManagement::HttpIntegration', name: 'INTEGRATION') + end + + it { is_expected.to eq('INTEGRATION') } + end + + context 'with monitoring tool defined in the raw payload' do + before do + allow(parsed_payload).to receive(:monitoring_tool).and_return('TOOL') + end + + it { is_expected.to eq('TOOL') } + end + end end |