diff options
Diffstat (limited to 'spec/models/concerns/prometheus_adapter_spec.rb')
-rw-r--r-- | spec/models/concerns/prometheus_adapter_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/models/concerns/prometheus_adapter_spec.rb b/spec/models/concerns/prometheus_adapter_spec.rb index bc58df7e7c2..fdc98ba74b8 100644 --- a/spec/models/concerns/prometheus_adapter_spec.rb +++ b/spec/models/concerns/prometheus_adapter_spec.rb @@ -18,6 +18,29 @@ describe PrometheusAdapter, :use_clean_rails_memory_store_caching do let(:environment_query) { Gitlab::Prometheus::Queries::EnvironmentQuery } describe '#query' do + describe 'validate_query' do + let(:environment) { build_stubbed(:environment, slug: 'env-slug') } + let(:validation_query) { Gitlab::Prometheus::Queries::ValidateQuery.name } + let(:query) { 'avg(response)' } + let(:validation_respone) { { data: { valid: true } } } + + around do |example| + Timecop.freeze { example.run } + end + + context 'with valid data' do + subject { service.query(:validate, query) } + + before do + stub_reactive_cache(service, validation_respone, validation_query, query) + end + + it 'returns query data' do + is_expected.to eq(query: { valid: true }) + end + end + end + describe 'environment' do let(:environment) { build_stubbed(:environment, slug: 'env-slug') } |