From ae8f7666e597493ab404f8524c1216a924338291 Mon Sep 17 00:00:00 2001 From: Pawel Chojnacki Date: Mon, 29 May 2017 23:23:19 +0200 Subject: Add prometheus text formatter + rename controler method to #index from #metrics + remove assertion from nullMetric --- .../health_checks/prometheus_text_format_spec.rb | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 spec/lib/gitlab/health_checks/prometheus_text_format_spec.rb (limited to 'spec/lib/gitlab/health_checks') 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 -- cgit v1.2.3