Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/project_services/prometheus_service_spec.rb')
-rw-r--r--spec/models/project_services/prometheus_service_spec.rb23
1 files changed, 19 insertions, 4 deletions
diff --git a/spec/models/project_services/prometheus_service_spec.rb b/spec/models/project_services/prometheus_service_spec.rb
index f3126bc1e57..82a3e2698c1 100644
--- a/spec/models/project_services/prometheus_service_spec.rb
+++ b/spec/models/project_services/prometheus_service_spec.rb
@@ -47,15 +47,30 @@ describe PrometheusService, models: true, caching: true do
describe '#metrics' do
let(:environment) { build_stubbed(:environment, slug: 'env-slug') }
- subject { service.metrics(environment) }
around do |example|
Timecop.freeze { example.run }
end
- context 'with valid data' do
+ context 'with valid data without time range' do
+ subject { service.metrics(environment) }
+
+ before do
+ stub_reactive_cache(service, prometheus_data, 'env-slug', nil, nil)
+ end
+
+ it 'returns reactive data' do
+ is_expected.to eq(prometheus_data)
+ end
+ end
+
+ context 'with valid data with time range' do
+ let(:t_start) { 1.hour.ago.utc }
+ let(:t_end) { Time.now.utc }
+ subject { service.metrics(environment, timeframe_start: t_start, timeframe_end: t_end) }
+
before do
- stub_reactive_cache(service, prometheus_data, 'env-slug')
+ stub_reactive_cache(service, prometheus_data, 'env-slug', t_start, t_end)
end
it 'returns reactive data' do
@@ -72,7 +87,7 @@ describe PrometheusService, models: true, caching: true do
end
subject do
- service.calculate_reactive_cache(environment.slug)
+ service.calculate_reactive_cache(environment.slug, nil, nil)
end
context 'when service is inactive' do