diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-26 03:07:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-26 03:07:58 +0300 |
commit | 101c30f4dffc624af3cbe3f12edc2cfee570a5f3 (patch) | |
tree | ce7c63b2d73a42ad41d004020410871968974537 /spec/lib/gitlab/prometheus_client_spec.rb | |
parent | e1549c75843d235607aebac9ed64f2fd10e549ed (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/prometheus_client_spec.rb')
-rw-r--r-- | spec/lib/gitlab/prometheus_client_spec.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/lib/gitlab/prometheus_client_spec.rb b/spec/lib/gitlab/prometheus_client_spec.rb index 5eb133a5bf4..e869a384b29 100644 --- a/spec/lib/gitlab/prometheus_client_spec.rb +++ b/spec/lib/gitlab/prometheus_client_spec.rb @@ -16,6 +16,26 @@ describe Gitlab::PrometheusClient do end end + describe '#healthy?' do + it 'returns true when status code is 200 and healthy response body' do + stub_request(:get, subject.health_url).to_return(status: 200, body: described_class::HEALTHY_RESPONSE) + + expect(subject.healthy?).to eq(true) + end + + it 'returns false when status code is 200 and unhealthy response body' do + stub_request(:get, subject.health_url).to_return(status: 200, body: '') + + expect(subject.healthy?).to eq(false) + end + + it 'raises error when status code not 200' do + stub_request(:get, subject.health_url).to_return(status: 500, body: '') + + expect { subject.healthy? }.to raise_error(Gitlab::PrometheusClient::Error) + end + end + # This shared examples expect: # - query_url: A query URL # - execute_query: A query call |