diff options
author | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-05-02 11:16:59 -0500 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-05-04 13:56:26 -0500 |
commit | 63a5d98a7c921289e9b43f4b54c03614427f7eda (patch) | |
tree | 8ceed0baac1b2ede87074cf88991c201ac035102 /spec/lib | |
parent | ad6ac17c5434f7eb87005dc3603b4ae9409c333f (diff) | |
download | gitlab-ce-63a5d98a7c921289e9b43f4b54c03614427f7eda.tar.gz |
Added specs
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/prometheus_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/lib/gitlab/prometheus_spec.rb b/spec/lib/gitlab/prometheus_spec.rb index 280264188e2..d8683669518 100644 --- a/spec/lib/gitlab/prometheus_spec.rb +++ b/spec/lib/gitlab/prometheus_spec.rb @@ -49,6 +49,24 @@ describe Gitlab::Prometheus, lib: true do end end + describe 'failure to reach a prometheus url' do + prometheus_invalid_url = 'https://prometheus.invalid.example.com' + + it 'raises a Gitlab::PrometheusError error when a SocketError is rescued' do + req_stub = stub_prometheus_request_with_socket_exception(prometheus_invalid_url) + + expect { subject.send(:get, prometheus_invalid_url) }.to raise_error(Gitlab::PrometheusError, "Can't connect to #{prometheus_invalid_url}") + expect(req_stub).to have_been_requested + end + + it 'raises a Gitlab::PrometheusError error when a SSLError is rescued' do + req_stub = stub_prometheus_request_with_ssl_exception(prometheus_invalid_url) + + expect { subject.send(:get, prometheus_invalid_url) }.to raise_error(Gitlab::PrometheusError, "#{prometheus_invalid_url} contains invalid SSL data") + expect(req_stub).to have_been_requested + end + end + describe '#query' do let(:prometheus_query) { prometheus_cpu_query('env-slug') } let(:query_url) { prometheus_query_url(prometheus_query) } |