summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2018-02-07 02:25:54 +0100
committerPawel Chojnacki <pawel@chojnacki.ws>2018-02-07 02:25:54 +0100
commit0e90284c11815f84c804e7e922e709b31ca6d029 (patch)
tree73c04b5accf3f317b36a9c1ca2f00b5454547d5a /spec/lib/gitlab
parent5209689d956c727f784481c86fe61355385371f5 (diff)
downloadgitlab-ce-0e90284c11815f84c804e7e922e709b31ca6d029.tar.gz
Catch json parsing error as PrometheusErrorpawel/connect_to_prometheus_through_proxy-30480
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/prometheus_client_spec.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/lib/gitlab/prometheus_client_spec.rb b/spec/lib/gitlab/prometheus_client_spec.rb
index 575b7805e33..5d86007f71f 100644
--- a/spec/lib/gitlab/prometheus_client_spec.rb
+++ b/spec/lib/gitlab/prometheus_client_spec.rb
@@ -47,6 +47,16 @@ describe Gitlab::PrometheusClient do
expect(req_stub).to have_been_requested
end
end
+
+ context 'when request returns non json data' do
+ it 'raises a Gitlab::PrometheusError error' do
+ req_stub = stub_prometheus_request(query_url, status: 200, body: 'not json')
+
+ expect { execute_query }
+ .to raise_error(Gitlab::PrometheusError, 'Parsing response failed')
+ expect(req_stub).to have_been_requested
+ end
+ end
end
describe 'failure to reach a provided prometheus url' do