Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/graphql/types/alert_management/prometheus_integration_type_spec.rb')
-rw-r--r--spec/graphql/types/alert_management/prometheus_integration_type_spec.rb60
1 files changed, 60 insertions, 0 deletions
diff --git a/spec/graphql/types/alert_management/prometheus_integration_type_spec.rb b/spec/graphql/types/alert_management/prometheus_integration_type_spec.rb
new file mode 100644
index 00000000000..0e9994035d8
--- /dev/null
+++ b/spec/graphql/types/alert_management/prometheus_integration_type_spec.rb
@@ -0,0 +1,60 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['AlertManagementPrometheusIntegration'] do
+ include GraphqlHelpers
+
+ specify { expect(described_class.graphql_name).to eq('AlertManagementPrometheusIntegration') }
+ specify { expect(described_class).to require_graphql_authorizations(:admin_project) }
+
+ describe 'resolvers' do
+ shared_examples_for 'has field with value' do |field_name|
+ it 'correctly renders the field' do
+ expect(resolve_field(field_name, integration)).to eq(value)
+ end
+ end
+
+ let_it_be_with_reload(:integration) { create(:prometheus_service) }
+
+ it_behaves_like 'has field with value', 'name' do
+ let(:value) { integration.title }
+ end
+
+ it_behaves_like 'has field with value', 'type' do
+ let(:value) { :prometheus }
+ end
+
+ it_behaves_like 'has field with value', 'token' do
+ let(:value) { nil }
+ end
+
+ it_behaves_like 'has field with value', 'url' do
+ let(:value) { "http://localhost/#{integration.project.full_path}/prometheus/alerts/notify.json" }
+ end
+
+ it_behaves_like 'has field with value', 'active' do
+ let(:value) { integration.manual_configuration? }
+ end
+
+ context 'with alerting setting' do
+ let_it_be(:alerting_setting) { create(:project_alerting_setting, project: integration.project) }
+
+ it_behaves_like 'has field with value', 'token' do
+ let(:value) { alerting_setting.token }
+ end
+ end
+
+ context 'without project' do
+ let_it_be(:integration) { create(:prometheus_service, project: nil, group: create(:group)) }
+
+ it_behaves_like 'has field with value', 'token' do
+ let(:value) { nil }
+ end
+
+ it_behaves_like 'has field with value', 'url' do
+ let(:value) { nil }
+ end
+ end
+ end
+end