Improve MetricGroup test
This commit is contained in:
parent
c54494e22a
commit
db467ad66d
1 changed files with 19 additions and 7 deletions
|
@ -4,10 +4,10 @@ require 'rails_helper'
|
|||
|
||||
describe Gitlab::Prometheus::MetricGroup do
|
||||
describe '.common_metrics' do
|
||||
set(:project_metric) { create(:prometheus_metric) }
|
||||
set(:common_metric_group_a) { create(:prometheus_metric, :common, group: :aws_elb) }
|
||||
set(:common_metric_group_b_q1) { create(:prometheus_metric, :common, group: :kubernetes) }
|
||||
set(:common_metric_group_b_q2) { create(:prometheus_metric, :common, group: :kubernetes) }
|
||||
let!(:project_metric) { create(:prometheus_metric) }
|
||||
let!(:common_metric_group_a) { create(:prometheus_metric, :common, group: :aws_elb) }
|
||||
let!(:common_metric_group_b_q1) { create(:prometheus_metric, :common, group: :kubernetes) }
|
||||
let!(:common_metric_group_b_q2) { create(:prometheus_metric, :common, group: :kubernetes) }
|
||||
|
||||
subject { described_class.common_metrics }
|
||||
|
||||
|
@ -16,9 +16,21 @@ describe Gitlab::Prometheus::MetricGroup do
|
|||
end
|
||||
|
||||
it 'returns exactly three metric queries' do
|
||||
expect(subject.map(&:metrics).flatten.map(&:queries)).to contain_exactly(
|
||||
common_metric_group_a.queries, common_metric_group_b_q1.queries,
|
||||
common_metric_group_b_q2.queries)
|
||||
expect(subject.map(&:metrics).flatten.map(&:id)).to contain_exactly(
|
||||
common_metric_group_a.id, common_metric_group_b_q1.id,
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue