summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2017-06-16 14:23:33 +0200
committerPawel Chojnacki <pawel@chojnacki.ws>2017-06-16 14:34:23 +0200
commitb97d5b65dd40fb5d8753c0677534e82cb5636f2d (patch)
tree4e6fbc43e10ddbb2d1be735df5ea2224aa12d42e /spec
parent0e7e7c2f2bd0e9c913cda438826a60e761130271 (diff)
downloadgitlab-ce-b97d5b65dd40fb5d8753c0677534e82cb5636f2d.tar.gz
Use include ActiveModel::Model to hold metrics data parsed from yaml.
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb23
-rw-r--r--spec/support/prometheus/metric_builders.rb4
2 files changed, 14 insertions, 13 deletions
diff --git a/spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb b/spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb
index 97280de173e..f8b2746b43d 100644
--- a/spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb
+++ b/spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb
@@ -26,7 +26,7 @@ describe Gitlab::Prometheus::AdditionalMetricsParser, lib: true do
priority: 1
metrics:
- title: title
- required_metrics: []
+ required_metrics: ['metric_a']
weight: 1
queries: [{query_range: query_range_a}]
EOF
@@ -54,7 +54,7 @@ describe Gitlab::Prometheus::AdditionalMetricsParser, lib: true do
expect(metrics.count).to eq(3)
expect(metrics[0]).to have_attributes(title: 'title', required_metrics: %w(metric_a metric_b), weight: 1)
expect(metrics[1]).to have_attributes(title: 'title', required_metrics: %w(metric_a), weight: 1)
- expect(metrics[2]).to have_attributes(title: 'title', required_metrics: [], weight: 1)
+ expect(metrics[2]).to have_attributes(title: 'title', required_metrics: %w{metric_a}, weight: 1)
end
it 'provides query data' do
@@ -78,7 +78,7 @@ describe Gitlab::Prometheus::AdditionalMetricsParser, lib: true do
end
it 'throws parsing error' do
- expect { subject }.to raise_error(parser_error_class, /missing.*#{field_name}/)
+ expect { subject }.to raise_error(parser_error_class, /#{field_name} can't be blank/i)
end
end
@@ -88,13 +88,13 @@ describe Gitlab::Prometheus::AdditionalMetricsParser, lib: true do
end
it 'throws parsing error' do
- expect { subject }.to raise_error(parser_error_class, /missing.*#{field_name}/)
+ expect { subject }.to raise_error(parser_error_class, /#{field_name} can't be blank/i)
end
end
end
describe 'group required fields' do
- it_behaves_like 'required field', :metrics do
+ it_behaves_like 'required field', 'metrics' do
let(:field_nil) do
<<-EOF.strip_heredoc
- group: group_a
@@ -111,10 +111,11 @@ describe Gitlab::Prometheus::AdditionalMetricsParser, lib: true do
end
end
- it_behaves_like 'required field', :group do
+ it_behaves_like 'required field', 'name' do
let(:field_nil) do
<<-EOF.strip_heredoc
- - priority: 1
+ - group:
+ priority: 1
metrics: []
EOF
end
@@ -127,7 +128,7 @@ describe Gitlab::Prometheus::AdditionalMetricsParser, lib: true do
end
end
- it_behaves_like 'required field', :priority do
+ it_behaves_like 'required field', 'priority' do
let(:field_nil) do
<<-EOF.strip_heredoc
- group: group_a
@@ -146,7 +147,7 @@ describe Gitlab::Prometheus::AdditionalMetricsParser, lib: true do
end
describe 'metrics fields parsing' do
- it_behaves_like 'required field', :title do
+ it_behaves_like 'required field', 'title' do
let(:field_nil) do
<<-EOF.strip_heredoc
- group: group_a
@@ -171,7 +172,7 @@ describe Gitlab::Prometheus::AdditionalMetricsParser, lib: true do
end
end
- it_behaves_like 'required field', :required_metrics do
+ it_behaves_like 'required field', 'required metrics' do
let(:field_nil) do
<<-EOF.strip_heredoc
- group: group_a
@@ -196,7 +197,7 @@ describe Gitlab::Prometheus::AdditionalMetricsParser, lib: true do
end
end
- it_behaves_like 'required field', :weight do
+ it_behaves_like 'required field', 'weight' do
let(:field_nil) do
<<-EOF.strip_heredoc
- group: group_a
diff --git a/spec/support/prometheus/metric_builders.rb b/spec/support/prometheus/metric_builders.rb
index e4b55c22acd..c8d056d3fc8 100644
--- a/spec/support/prometheus/metric_builders.rb
+++ b/spec/support/prometheus/metric_builders.rb
@@ -9,7 +9,7 @@ module Prometheus
end
def simple_metric(title: 'title', required_metrics: [], queries: [simple_query])
- Gitlab::Prometheus::Metric.new(title, required_metrics, 1, nil, queries)
+ Gitlab::Prometheus::Metric.new(title: title, required_metrics: required_metrics, weight: 1, queries: queries)
end
def simple_metrics(added_metric_name: 'metric_a')
@@ -21,7 +21,7 @@ module Prometheus
end
def simple_metric_group(name: 'name', metrics: simple_metrics)
- Gitlab::Prometheus::MetricGroup.new( name, 1, metrics)
+ Gitlab::Prometheus::MetricGroup.new(name: name, priority: 1, metrics: metrics)
end
end
end