Skip to content
Snippets Groups Projects
Commit ad6ac17c authored by Jose Ivan Vargas Lopez's avatar Jose Ivan Vargas Lopez
Browse files

Added rescue block for the test method for the prometheus service

parent 91e8f770
No related branches found
No related tags found
1 merge request!10994Added rescue block for the test method for the prometheus service
---
title: Added rescue block for the test method
merge_request: 10994
author:
Loading
Loading
@@ -49,7 +49,11 @@ module Gitlab
end
 
def get(url)
handle_response(HTTParty.get(url))
begin
handle_response(HTTParty.get(url))
rescue SocketError
raise PrometheusError, "Can't connect to #{url}"
end
end
 
def handle_response(response)
Loading
Loading
Loading
Loading
@@ -93,11 +93,12 @@ describe PrometheusService, models: true, caching: true do
 
[404, 500].each do |status|
context "when Prometheus responds with #{status}" do
body_response = 'QUERY_FAILED'
before do
stub_all_prometheus_requests(environment.slug, status: status, body: 'QUERY FAILED!')
stub_all_prometheus_requests(environment.slug, status: status, body: body_response)
end
 
it { is_expected.to eq(success: false, result: %(#{status} - "QUERY FAILED!")) }
it { is_expected.to eq(success: false, result: %(#{status} - \"#{body_response}\")) }
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment