diff options
Diffstat (limited to 'spec/lib/gitlab/metrics/dashboard')
-rw-r--r-- | spec/lib/gitlab/metrics/dashboard/finder_spec.rb | 24 | ||||
-rw-r--r-- | spec/lib/gitlab/metrics/dashboard/processor_spec.rb | 23 |
2 files changed, 34 insertions, 13 deletions
diff --git a/spec/lib/gitlab/metrics/dashboard/finder_spec.rb b/spec/lib/gitlab/metrics/dashboard/finder_spec.rb index ce1bb49f5c9..af5df1fab43 100644 --- a/spec/lib/gitlab/metrics/dashboard/finder_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/finder_spec.rb @@ -15,7 +15,7 @@ describe Gitlab::Metrics::Dashboard::Finder, :use_clean_rails_memory_store_cachi describe '.find' do let(:dashboard_path) { '.gitlab/dashboards/test.yml' } - let(:service_call) { described_class.find(project, user, environment, dashboard_path: dashboard_path) } + let(:service_call) { described_class.find(project, user, environment: environment, dashboard_path: dashboard_path) } it_behaves_like 'misconfigured dashboard service response', :not_found @@ -45,19 +45,19 @@ describe Gitlab::Metrics::Dashboard::Finder, :use_clean_rails_memory_store_cachi end context 'when no dashboard is specified' do - let(:service_call) { described_class.find(project, user, environment) } + let(:service_call) { described_class.find(project, user, environment: environment) } it_behaves_like 'valid dashboard service response' end context 'when the dashboard is expected to be embedded' do - let(:service_call) { described_class.find(project, user, environment, **params) } - let(:params) { { embedded: true } } + let(:service_call) { described_class.find(project, user, **params) } + let(:params) { { environment: environment, embedded: true } } it_behaves_like 'valid embedded dashboard service response' context 'when params are incomplete' do - let(:params) { { embedded: true, dashboard_path: system_dashboard_path } } + let(:params) { { environment: environment, embedded: true, dashboard_path: system_dashboard_path } } it_behaves_like 'valid embedded dashboard service response' end @@ -65,11 +65,14 @@ describe Gitlab::Metrics::Dashboard::Finder, :use_clean_rails_memory_store_cachi context 'when the panel is specified' do context 'as a custom metric' do let(:params) do - { embedded: true, + { + environment: environment, + embedded: true, dashboard_path: system_dashboard_path, group: business_metric_title, title: 'title', - y_label: 'y_label' } + y_label: 'y_label' + } end it_behaves_like 'misconfigured dashboard service response', :not_found @@ -86,11 +89,14 @@ describe Gitlab::Metrics::Dashboard::Finder, :use_clean_rails_memory_store_cachi context 'as a project-defined panel' do let(:dashboard_path) { '.gitlab/dashboard/test.yml' } let(:params) do - { embedded: true, + { + environment: environment, + embedded: true, dashboard_path: dashboard_path, group: 'Group A', title: 'Super Chart A1', - y_label: 'y_label' } + y_label: 'y_label' + } end it_behaves_like 'misconfigured dashboard service response', :not_found diff --git a/spec/lib/gitlab/metrics/dashboard/processor_spec.rb b/spec/lib/gitlab/metrics/dashboard/processor_spec.rb index d7891e69dd0..e2ce1869810 100644 --- a/spec/lib/gitlab/metrics/dashboard/processor_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/processor_spec.rb @@ -8,8 +8,16 @@ describe Gitlab::Metrics::Dashboard::Processor do let(:dashboard_yml) { YAML.load_file('spec/fixtures/lib/gitlab/metrics/dashboard/sample_dashboard.yml') } describe 'process' do - let(:process_params) { [project, environment, dashboard_yml] } - let(:dashboard) { described_class.new(*process_params).process(insert_project_metrics: true) } + let(:sequence) do + [ + Gitlab::Metrics::Dashboard::Stages::CommonMetricsInserter, + Gitlab::Metrics::Dashboard::Stages::ProjectMetricsInserter, + Gitlab::Metrics::Dashboard::Stages::EndpointInserter, + Gitlab::Metrics::Dashboard::Stages::Sorter + ] + end + let(:process_params) { [project, dashboard_yml, sequence, { environment: environment }] } + let(:dashboard) { described_class.new(*process_params).process } it 'includes a path for the prometheus endpoint with each metric' do expect(all_metrics).to satisfy_all do |metric| @@ -54,7 +62,14 @@ describe Gitlab::Metrics::Dashboard::Processor do end context 'when the dashboard should not include project metrics' do - let(:dashboard) { described_class.new(*process_params).process(insert_project_metrics: false) } + let(:sequence) do + [ + Gitlab::Metrics::Dashboard::Stages::CommonMetricsInserter, + Gitlab::Metrics::Dashboard::Stages::EndpointInserter, + Gitlab::Metrics::Dashboard::Stages::Sorter + ] + end + let(:dashboard) { described_class.new(*process_params).process } it 'includes only dashboard metrics' do metrics = all_metrics.map { |m| m[:id] } @@ -67,7 +82,7 @@ describe Gitlab::Metrics::Dashboard::Processor do shared_examples_for 'errors with message' do |expected_message| it 'raises a DashboardLayoutError' do - error_class = Gitlab::Metrics::Dashboard::Stages::BaseStage::DashboardProcessingError + error_class = Gitlab::Metrics::Dashboard::Errors::DashboardProcessingError expect { dashboard }.to raise_error(error_class, expected_message) end |