Commit db467ad6 authored by Kamil Trzciński's avatar Kamil Trzciński

Improve MetricGroup test

parent c54494e2
...@@ -4,10 +4,10 @@ require 'rails_helper' ...@@ -4,10 +4,10 @@ require 'rails_helper'
describe Gitlab::Prometheus::MetricGroup do describe Gitlab::Prometheus::MetricGroup do
describe '.common_metrics' do describe '.common_metrics' do
set(:project_metric) { create(:prometheus_metric) } let!(:project_metric) { create(:prometheus_metric) }
set(:common_metric_group_a) { create(:prometheus_metric, :common, group: :aws_elb) } let!(:common_metric_group_a) { create(:prometheus_metric, :common, group: :aws_elb) }
set(:common_metric_group_b_q1) { create(:prometheus_metric, :common, group: :kubernetes) } let!(:common_metric_group_b_q1) { create(:prometheus_metric, :common, group: :kubernetes) }
set(:common_metric_group_b_q2) { create(:prometheus_metric, :common, group: :kubernetes) } let!(:common_metric_group_b_q2) { create(:prometheus_metric, :common, group: :kubernetes) }
subject { described_class.common_metrics } subject { described_class.common_metrics }
...@@ -16,9 +16,21 @@ describe Gitlab::Prometheus::MetricGroup do ...@@ -16,9 +16,21 @@ describe Gitlab::Prometheus::MetricGroup do
end end
it 'returns exactly three metric queries' do it 'returns exactly three metric queries' do
expect(subject.map(&:metrics).flatten.map(&:queries)).to contain_exactly( expect(subject.map(&:metrics).flatten.map(&:id)).to contain_exactly(
common_metric_group_a.queries, common_metric_group_b_q1.queries, common_metric_group_a.id, common_metric_group_b_q1.id,
common_metric_group_b_q2.queries) common_metric_group_b_q2.id)
end
end
describe '.for_project' do
let!(:other_project) { create(:project) }
let!(:project_metric) { create(:prometheus_metric) }
let!(:common_metric) { create(:prometheus_metric, :common, group: :aws_elb) }
subject { described_class.for_project(other_project) }
it 'returns exactly one common metric' do
expect(subject.map(&:metrics).flatten.map(&:id)).to contain_exactly(common_metric.id)
end end
end end
end end
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