summaryrefslogtreecommitdiff
path: root/spec/factories/alert_management
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-21 07:08:36 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-21 07:08:36 +0000
commit48aff82709769b098321c738f3444b9bdaa694c6 (patch)
treee00c7c43e2d9b603a5a6af576b1685e400410dee /spec/factories/alert_management
parent879f5329ee916a948223f8f43d77fba4da6cd028 (diff)
downloadgitlab-ce-13.5.0-rc42.tar.gz
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'spec/factories/alert_management')
-rw-r--r--spec/factories/alert_management/alerts.rb22
-rw-r--r--spec/factories/alert_management/http_integrations.rb14
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