diff options
Diffstat (limited to 'spec/lib/gitlab/prometheus_spec.rb')
-rw-r--r-- | spec/lib/gitlab/prometheus_spec.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/spec/lib/gitlab/prometheus_spec.rb b/spec/lib/gitlab/prometheus_spec.rb index fc453a2704b..9d67e3d2f37 100644 --- a/spec/lib/gitlab/prometheus_spec.rb +++ b/spec/lib/gitlab/prometheus_spec.rb @@ -81,7 +81,11 @@ describe Gitlab::Prometheus, lib: true do describe '#query' do let(:prometheus_query) { prometheus_cpu_query('env-slug') } - let(:query_url) { prometheus_query_url(prometheus_query) } + let(:query_url) { prometheus_query_with_time_url(prometheus_query, Time.now.utc) } + + around do |example| + Timecop.freeze { example.run } + end context 'when request returns vector results' do it 'returns data from the API call' do @@ -123,6 +127,20 @@ describe Gitlab::Prometheus, lib: true do Timecop.freeze { example.run } end + context 'when non utc time is passed' do + let(:time_stop) { Time.now.in_time_zone("Warsaw") } + let(:time_start) { time_stop - 8.hours } + + let(:query_url) { prometheus_query_range_url(prometheus_query, start: time_start.utc.to_f, stop: time_stop.utc.to_f) } + + it 'passed dates are properly converted to utc' do + req_stub = stub_prometheus_request(query_url, body: prometheus_values_body('vector')) + + subject.query_range(prometheus_query, start: time_start, stop: time_stop) + expect(req_stub).to have_been_requested + end + end + context 'when a start time is passed' do let(:query_url) { prometheus_query_range_url(prometheus_query, start: 2.hours.ago) } |