diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-05-30 16:25:05 +0300 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-05-30 16:27:51 +0300 |
commit | 9ccda901271eb755cf37f37831f6beef83ed7037 (patch) | |
tree | 3e04dfb61d38494e8652029caf94544960e5372a /spec/lib/gitlab/prometheus_client_spec.rb | |
parent | aaeda829ddb5e150be41c9dff374b2be0beab336 (diff) |
Add Prometheus client tests
Diffstat (limited to 'spec/lib/gitlab/prometheus_client_spec.rb')
-rw-r--r-- | spec/lib/gitlab/prometheus_client_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/lib/gitlab/prometheus_client_spec.rb b/spec/lib/gitlab/prometheus_client_spec.rb index 2d8bd2f6b97..46eaadae206 100644 --- a/spec/lib/gitlab/prometheus_client_spec.rb +++ b/spec/lib/gitlab/prometheus_client_spec.rb @@ -119,6 +119,36 @@ describe Gitlab::PrometheusClient, lib: true do end end + describe '#series' do + let(:query_url) { prometheus_series_url('series_name', 'other_service') } + + around do |example| + Timecop.freeze { example.run } + end + + it 'calls endpoint and returns list of series' do + req_stub = stub_prometheus_request(query_url, body: prometheus_series('series_name')) + expected = prometheus_series('series_name').deep_stringify_keys['data'] + + expect(subject.series('series_name', 'other_service')).to eq(expected) + + expect(req_stub).to have_been_requested + end + end + + describe '#label_values' do + let(:query_url) { prometheus_label_values_url('__name__') } + + it 'calls endpoint and returns label values' do + req_stub = stub_prometheus_request(query_url, body: prometheus_label_values) + expected = prometheus_label_values.deep_stringify_keys['data'] + + expect(subject.label_values('__name__')).to eq(expected) + + expect(req_stub).to have_been_requested + end + end + describe '#query_range' do let(:prometheus_query) { prometheus_memory_query('env-slug') } let(:query_url) { prometheus_query_range_url(prometheus_query) } |