diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/lib/gitlab/prometheus | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/lib/gitlab/prometheus')
3 files changed, 27 insertions, 7 deletions
diff --git a/spec/lib/gitlab/prometheus/internal_spec.rb b/spec/lib/gitlab/prometheus/internal_spec.rb index 1254610fe32..7771d85222a 100644 --- a/spec/lib/gitlab/prometheus/internal_spec.rb +++ b/spec/lib/gitlab/prometheus/internal_spec.rb @@ -48,7 +48,7 @@ RSpec.describe Gitlab::Prometheus::Internal do let(:listen_address) { nil } it 'does not fail' do - expect(described_class.uri).to eq(nil) + expect(described_class.uri).to be_nil end end @@ -56,12 +56,32 @@ RSpec.describe Gitlab::Prometheus::Internal do let(:listen_address) { '' } it 'does not configure prometheus' do - expect(described_class.uri).to eq(nil) + expect(described_class.uri).to be_nil end end end - describe 'prometheus_enabled?' do + describe '.server_address' do + context 'self.uri returns valid uri' do + ['http://localhost:9090', 'https://localhost:9090 '].each do |valid_uri| + it 'returns correct server address' do + expect(described_class).to receive(:uri).and_return(valid_uri) + + expect(described_class.server_address).to eq('localhost:9090') + end + end + end + + context 'self.uri returns nil' do + it 'returns nil' do + expect(described_class).to receive(:uri).and_return(nil) + + expect(described_class.server_address).to be_nil + end + end + end + + describe '.prometheus_enabled?' do it 'returns correct value' do expect(described_class.prometheus_enabled?).to eq(true) end @@ -101,7 +121,7 @@ RSpec.describe Gitlab::Prometheus::Internal do end it 'does not fail' do - expect(described_class.listen_address).to eq(nil) + expect(described_class.listen_address).to be_nil end end end diff --git a/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb b/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb index f5911963108..d0dee2ad366 100644 --- a/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb +++ b/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery do around do |example| - Timecop.freeze { example.run } + freeze_time { example.run } end include_examples 'additional metrics query' do diff --git a/spec/lib/gitlab/prometheus/queries/validate_query_spec.rb b/spec/lib/gitlab/prometheus/queries/validate_query_spec.rb index 045c063ab34..e3706a4b106 100644 --- a/spec/lib/gitlab/prometheus/queries/validate_query_spec.rb +++ b/spec/lib/gitlab/prometheus/queries/validate_query_spec.rb @@ -28,7 +28,7 @@ RSpec.describe Gitlab::Prometheus::Queries::ValidateQuery do let(:error_message) { "invalid parameter 'query': 1:9: parse error: unexpected identifier \"query\"" } it 'returns invalid' do - Timecop.freeze do + freeze_time do stub_prometheus_query_error( prometheus_query_with_time_url(query, Time.now), error_message @@ -53,7 +53,7 @@ RSpec.describe Gitlab::Prometheus::Queries::ValidateQuery do end it 'catches exception and returns invalid' do - Timecop.freeze do + freeze_time do expect(subject.query(query)).to eq(valid: false, error: message) end end |