diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/lib/gitlab/alerting | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/lib/gitlab/alerting')
-rw-r--r-- | spec/lib/gitlab/alerting/alert_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/alerting/notification_payload_parser_spec.rb | 35 |
2 files changed, 36 insertions, 3 deletions
diff --git a/spec/lib/gitlab/alerting/alert_spec.rb b/spec/lib/gitlab/alerting/alert_spec.rb index a0582515f3d..d582ff6f32a 100644 --- a/spec/lib/gitlab/alerting/alert_spec.rb +++ b/spec/lib/gitlab/alerting/alert_spec.rb @@ -253,7 +253,7 @@ describe Gitlab::Alerting::Alert do include_context 'gitlab alert' it 'returns a fingerprint' do - plain_fingerprint = [alert.metric_id, alert.starts_at].join('/') + plain_fingerprint = [alert.metric_id, alert.starts_at_raw].join('/') is_expected.to eq(Digest::SHA1.hexdigest(plain_fingerprint)) end @@ -263,7 +263,7 @@ describe Gitlab::Alerting::Alert do include_context 'full query' it 'returns a fingerprint' do - plain_fingerprint = [alert.starts_at, alert.title, alert.full_query].join('/') + plain_fingerprint = [alert.starts_at_raw, alert.title, alert.full_query].join('/') is_expected.to eq(Digest::SHA1.hexdigest(plain_fingerprint)) end diff --git a/spec/lib/gitlab/alerting/notification_payload_parser_spec.rb b/spec/lib/gitlab/alerting/notification_payload_parser_spec.rb index f32095b3c86..889efae9585 100644 --- a/spec/lib/gitlab/alerting/notification_payload_parser_spec.rb +++ b/spec/lib/gitlab/alerting/notification_payload_parser_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'spec_helper' describe Gitlab::Alerting::NotificationPayloadParser do describe '.call' do @@ -89,6 +89,39 @@ describe Gitlab::Alerting::NotificationPayloadParser do end end + context 'with fingerprint' do + before do + payload[:fingerprint] = data + end + + shared_examples 'fingerprint generation' do + it 'generates the fingerprint correctly' do + expect(result).to eq(Gitlab::AlertManagement::Fingerprint.generate(data)) + end + end + + context 'with blank fingerprint' do + it_behaves_like 'fingerprint generation' do + let(:data) { ' ' } + let(:result) { subject.dig('annotations', 'fingerprint') } + end + end + + context 'with fingerprint given' do + it_behaves_like 'fingerprint generation' do + let(:data) { 'fingerprint' } + let(:result) { subject.dig('annotations', 'fingerprint') } + end + end + + context 'with array fingerprint given' do + it_behaves_like 'fingerprint generation' do + let(:data) { [1, 'fingerprint', 'given'] } + let(:result) { subject.dig('annotations', 'fingerprint') } + end + end + end + context 'when payload attributes have blank lines' do let(:payload) do { |