diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/lib/gitlab/prometheus/query_variables_spec.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/lib/gitlab/prometheus/query_variables_spec.rb')
-rw-r--r-- | spec/lib/gitlab/prometheus/query_variables_spec.rb | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/spec/lib/gitlab/prometheus/query_variables_spec.rb b/spec/lib/gitlab/prometheus/query_variables_spec.rb index d8f8a2b7e7c..7dfa4de35d6 100644 --- a/spec/lib/gitlab/prometheus/query_variables_spec.rb +++ b/spec/lib/gitlab/prometheus/query_variables_spec.rb @@ -7,8 +7,9 @@ describe Gitlab::Prometheus::QueryVariables do let(:project) { environment.project } let(:environment) { create(:environment) } let(:slug) { environment.slug } + let(:params) { {} } - subject { described_class.call(environment) } + subject { described_class.call(environment, params) } it { is_expected.to include(ci_environment_slug: slug) } it { is_expected.to include(ci_project_name: project.name) } @@ -53,5 +54,42 @@ describe Gitlab::Prometheus::QueryVariables do it { is_expected.to include(kube_namespace: kube_namespace) } end end + + context '__range' do + context 'when start_time and end_time are present' do + let(:params) do + { + start_time: Time.rfc3339('2020-05-29T07:23:05.008Z'), + end_time: Time.rfc3339('2020-05-29T15:23:05.008Z') + } + end + + it { is_expected.to include(__range: "#{8.hours.to_i}s") } + end + + context 'when start_time and end_time are not present' do + it { is_expected.to include(__range: nil) } + end + + context 'when end_time is not present' do + let(:params) do + { + start_time: Time.rfc3339('2020-05-29T07:23:05.008Z') + } + end + + it { is_expected.to include(__range: nil) } + end + + context 'when start_time is not present' do + let(:params) do + { + end_time: Time.rfc3339('2020-05-29T07:23:05.008Z') + } + end + + it { is_expected.to include(__range: nil) } + end + end end end |