diff options
Diffstat (limited to 'spec/factories/alert_management')
-rw-r--r-- | spec/factories/alert_management/alerts.rb | 14 | ||||
-rw-r--r-- | spec/factories/alert_management/http_integrations.rb | 14 |
2 files changed, 27 insertions, 1 deletions
diff --git a/spec/factories/alert_management/alerts.rb b/spec/factories/alert_management/alerts.rb index d931947fff1..d0546657ccf 100644 --- a/spec/factories/alert_management/alerts.rb +++ b/spec/factories/alert_management/alerts.rb @@ -100,7 +100,7 @@ FactoryBot.define do end trait :prometheus do - monitoring_tool { Gitlab::AlertManagement::AlertParams::MONITORING_TOOLS[:prometheus] } + monitoring_tool { Gitlab::AlertManagement::Payload::MONITORING_TOOLS[:prometheus] } payload do { annotations: { @@ -123,5 +123,17 @@ FactoryBot.define do with_description low end + + trait :from_payload do + after(:build) do |alert| + alert_params = ::Gitlab::AlertManagement::Payload.parse( + alert.project, + alert.payload, + monitoring_tool: alert.monitoring_tool + ).alert_params + + alert.assign_attributes(alert_params) + end + end end end diff --git a/spec/factories/alert_management/http_integrations.rb b/spec/factories/alert_management/http_integrations.rb new file mode 100644 index 00000000000..9311cb3e114 --- /dev/null +++ b/spec/factories/alert_management/http_integrations.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :alert_management_http_integration, class: 'AlertManagement::HttpIntegration' do + project + active { true } + name { 'DataDog' } + endpoint_identifier { SecureRandom.hex(4) } + + trait :inactive do + active { false } + end + end +end |