diff options
author | syasonik <syasonik@gitlab.com> | 2019-04-01 16:28:28 +0800 |
---|---|---|
committer | syasonik <syasonik@gitlab.com> | 2019-04-01 17:16:16 +0800 |
commit | 1a99261fb09586719a1b4902939cfa7589a3f5dc (patch) | |
tree | ac8b07a3f954fd3dc5ffa81f5438e6e9b667bdee | |
parent | cc59414eac08ef8be59b58057f540cc288f1e781 (diff) | |
download | gitlab-ce-move-timeframe-args-default.tar.gz |
Add unit test for proper query formationmove-timeframe-args-default
-rw-r--r-- | spec/support/prometheus/additional_metrics_shared_examples.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/support/prometheus/additional_metrics_shared_examples.rb b/spec/support/prometheus/additional_metrics_shared_examples.rb index 0fd67531c3b..7a3e5a49a1c 100644 --- a/spec/support/prometheus/additional_metrics_shared_examples.rb +++ b/spec/support/prometheus/additional_metrics_shared_examples.rb @@ -166,4 +166,18 @@ RSpec.shared_examples 'additional metrics query' do end end end + + context 'when a query contains values for interpolation' do + let(:expected_query) { "query_range_#{environment.slug}" } + let(:metrics) { [simple_metric(queries: [simple_query('%{ci_environment_slug}')])] } + + before do + allow(metric_group_class).to receive(:common_metrics).and_return([simple_metric_group(metrics: metrics)]) + end + + it 'interpolates values from the query context' do + expect(client).to receive(:query_range).with(expected_query, any_args).and_return(query_range_result) + query_result + end + end end |