提交 ad6ac17c 编写于 作者: J Jose Ivan Vargas

Added rescue block for the test method for the prometheus service

上级 91e8f770
---
title: Added rescue block for the test method
merge_request: 10994
author:
......@@ -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)
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册