diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-05-31 20:36:07 +0300 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-05 12:36:56 +0300 |
commit | e74896df0c7d0d88958a3d35b3144361cfdd0594 (patch) | |
tree | 2680ad5f449c9b58c2fec935d51216ddd20d2884 /spec | |
parent | 7e17d763ac2669dd4fe10075d8ba07eb7e119aea (diff) |
Matched Metrics tests
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/prometheus/queries/matched_metrics_query_spec.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/lib/gitlab/prometheus/queries/matched_metrics_query_spec.rb b/spec/lib/gitlab/prometheus/queries/matched_metrics_query_spec.rb new file mode 100644 index 00000000000..0aee9d37889 --- /dev/null +++ b/spec/lib/gitlab/prometheus/queries/matched_metrics_query_spec.rb @@ -0,0 +1,50 @@ +require 'spec_helper' + +describe Gitlab::Prometheus::Queries::MatchedMetricsQuery, lib: true do + let(:environment) { create(:environment, slug: 'environment-slug') } + let(:deployment) { create(:deployment, environment: environment) } + + let(:client) { double('prometheus_client') } + subject { described_class.new(client) } + + around do |example| + time_without_subsecond_values = Time.local(2008, 9, 1, 12, 0, 0) + Timecop.freeze(time_without_subsecond_values) { example.run } + end + + let(:metric_group_class) { Gitlab::Prometheus::MetricGroup } + let(:metric_class) { Gitlab::Prometheus::Metric } + + let(:simple_metrics) do + [ + metric_class.new('title', ['metrica', 'metricb'], '1', 'y_label', [{ :query_range => 'avg' }]) + ] + end + + let(:simple_metric_group) do + metric_group_class.new('name', 1, simple_metrics) + end + + let(:xx) do + [{ + '__name__': 'metrica', + 'environment': 'mattermost' + }, + { + '__name__': 'metricb', + 'environment': 'mattermost' + }] + end + + before do + allow(metric_group_class).to receive(:all).and_return([simple_metric_group]) + + allow(client).to receive(:label_values).and_return(['metrica', 'metricb']) + allow(client).to receive(:series).and_return(xx) + end + + it "something something" do + + expect(subject.query).to eq("asf") + end +end |