Commit 5c2844cd authored by Pawel Chojnacki's avatar Pawel Chojnacki

Align implementation after merge

parent 3c822c7a
......@@ -26,7 +26,13 @@ module PrometheusAdapter
query_class = Gitlab::Prometheus::Queries.const_get("#{query_name.to_s.classify}Query")
args.map!(&:id)
args.map! do |arg|
if arg.respond_to?(:id)
arg.id
else
arg
end
end
with_reactive_cache(query_class.name, *args, &query_class.method(:transform_reactive_result))
end
......
......@@ -8,6 +8,11 @@ module Gitlab
rescue Gitlab::PrometheusClient::QueryError => ex
{ valid: false, error: ex.message }
end
def self.transform_reactive_result(result)
result[:query] = result.delete :data
result
end
end
end
end
......
......@@ -4,11 +4,11 @@ describe Projects::Prometheus::MetricsController do
let(:user) { create(:user) }
let(:project) { create(:prometheus_project) }
let(:prometheus_service) { project.prometheus_service }
let(:prometheus_adapter) { double('prometheus_adapter', can_query?: true) }
before do
allow(controller).to receive(:project).and_return(project)
allow(controller).to receive(:prometheus_service).and_return(prometheus_service)
allow(controller).to receive(:prometheus_adapter).and_return(prometheus_adapter)
project.add_master(user)
sign_in(user)
......@@ -16,7 +16,7 @@ describe Projects::Prometheus::MetricsController do
describe 'POST #validate_query' do
before do
allow(prometheus_service).to receive(:query).with(:validate, query) { validation_result }
allow(prometheus_adapter).to receive(:query).with(:validate, query) { validation_result }
end
let(:query) { 'avg(metric)' }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment