diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-05-29 23:23:19 +0200 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-02 19:45:58 +0200 |
commit | ae8f7666e597493ab404f8524c1216a924338291 (patch) | |
tree | 1e7684337782584f90b8b8a9d3e5980393e633c7 /spec/lib/gitlab/health_checks | |
parent | c134a72cdb7e6de8b70dc60de99cf4edc68a9227 (diff) | |
download | gitlab-ce-ae8f7666e597493ab404f8524c1216a924338291.tar.gz |
Add prometheus text formatter
+ rename controler method to #index from #metrics
+ remove assertion from nullMetric
Diffstat (limited to 'spec/lib/gitlab/health_checks')
-rw-r--r-- | spec/lib/gitlab/health_checks/prometheus_text_format_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/lib/gitlab/health_checks/prometheus_text_format_spec.rb b/spec/lib/gitlab/health_checks/prometheus_text_format_spec.rb new file mode 100644 index 00000000000..a9feab8ff78 --- /dev/null +++ b/spec/lib/gitlab/health_checks/prometheus_text_format_spec.rb @@ -0,0 +1,44 @@ +describe Gitlab::HealthChecks::PrometheusTextFormat do + let(:metric_class) { Gitlab::HealthChecks::Metric } + subject { described_class.new } + + describe '#marshal' do + let(:sample_metrics) do + [ + metric_class.new('metric1', 1), + metric_class.new('metric2', 2) + ] + end + + it 'marshal to text with non repeating type definition' do + expected = <<-EXPECTED +# TYPE metric1 gauge +metric1 1 +# TYPE metric2 gauge +metric2 2 +EXPECTED + expect(subject.marshal(sample_metrics)).to eq(expected.chomp) + end + + context 'metrics where name repeats' do + let(:sample_metrics) do + [ + metric_class.new('metric1', 1), + metric_class.new('metric1', 2), + metric_class.new('metric2', 3) + ] + end + + it 'marshal to text with non repeating type definition' do + expected = <<-EXPECTED +# TYPE metric1 gauge +metric1 1 +metric1 2 +# TYPE metric2 gauge +metric2 3 + EXPECTED + expect(subject.marshal(sample_metrics)).to eq(expected.chomp) + end + end + end +end |