diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-22 00:10:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-22 00:10:16 +0300 |
commit | 6333a892f50d882f007497fd5512a740ba1020e5 (patch) | |
tree | d24e3699301fb3ee362bd3eeb6eb740067365a51 /spec/services | |
parent | 779672e43b60e1b853d4581493c4838b775de83f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/metrics/dashboard/panel_preview_service_spec.rb | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/spec/services/metrics/dashboard/panel_preview_service_spec.rb b/spec/services/metrics/dashboard/panel_preview_service_spec.rb deleted file mode 100644 index 584be717d7c..00000000000 --- a/spec/services/metrics/dashboard/panel_preview_service_spec.rb +++ /dev/null @@ -1,85 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Metrics::Dashboard::PanelPreviewService, feature_category: :metrics do - let_it_be(:project) { create(:project) } - let_it_be(:environment) { create(:environment, project: project) } - let_it_be(:panel_yml) do - <<~YML - --- - title: test panel - YML - end - - let_it_be(:dashboard) do - { - panel_groups: [ - { - panels: [{ 'title' => 'test panel' }] - } - ] - } - end - - describe '#execute' do - subject(:service_response) { described_class.new(project, panel_yml, environment).execute } - - context "valid panel's yaml" do - before do - allow_next_instance_of(::Gitlab::Metrics::Dashboard::Processor) do |processor| - allow(processor).to receive(:process).and_return(dashboard) - end - end - - it 'returns success service response' do - expect(service_response.success?).to be_truthy - end - - it 'returns processed panel' do - expect(service_response.payload).to eq('title' => 'test panel') - end - - it 'uses dashboard processor' do - sequence = [ - ::Gitlab::Metrics::Dashboard::Stages::CommonMetricsInserter, - ::Gitlab::Metrics::Dashboard::Stages::MetricEndpointInserter, - ::Gitlab::Metrics::Dashboard::Stages::PanelIdsInserter, - ::Gitlab::Metrics::Dashboard::Stages::UrlValidator - ] - processor_params = [project, dashboard, sequence, environment: environment] - - expect_next_instance_of(::Gitlab::Metrics::Dashboard::Processor, *processor_params) do |processor| - expect(processor).to receive(:process).and_return(dashboard) - end - - service_response - end - end - - context "invalid panel's yaml" do - [ - Gitlab::Metrics::Dashboard::Errors::DashboardProcessingError, - Gitlab::Config::Loader::Yaml::NotHashError, - Gitlab::Config::Loader::Yaml::DataTooLargeError, - Gitlab::Config::Loader::FormatError - ].each do |error_class| - context "with #{error_class}" do - before do - allow_next_instance_of(::Gitlab::Metrics::Dashboard::Processor) do |processor| - allow(processor).to receive(:process).and_raise(error_class.new('error')) - end - end - - it 'returns error service response' do - expect(service_response.error?).to be_truthy - end - - it 'returns error message' do - expect(service_response.message).to eq('error') - end - end - end - end - end -end |