diff options
Diffstat (limited to 'spec/factories/alert_management')
-rw-r--r-- | spec/factories/alert_management/alerts.rb | 22 | ||||
-rw-r--r-- | spec/factories/alert_management/http_integrations.rb | 14 |
2 files changed, 31 insertions, 5 deletions
diff --git a/spec/factories/alert_management/alerts.rb b/spec/factories/alert_management/alerts.rb index d931947fff1..e36e4c38013 100644 --- a/spec/factories/alert_management/alerts.rb +++ b/spec/factories/alert_management/alerts.rb @@ -56,22 +56,22 @@ FactoryBot.define do end trait :triggered do - status { AlertManagement::Alert::STATUSES[:triggered] } + status { AlertManagement::Alert.status_value(:triggered) } without_ended_at end trait :acknowledged do - status { AlertManagement::Alert::STATUSES[:acknowledged] } + status { AlertManagement::Alert.status_value(:acknowledged) } without_ended_at end trait :resolved do - status { AlertManagement::Alert::STATUSES[:resolved] } + status { AlertManagement::Alert.status_value(:resolved) } with_ended_at end trait :ignored do - status { AlertManagement::Alert::STATUSES[:ignored] } + status { AlertManagement::Alert.status_value(:ignored) } without_ended_at end @@ -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 |