diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-09-05 17:52:32 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-09-05 18:26:55 +0300 |
commit | db467ad66d61be87533ddd2bfbac4d3577da5d38 (patch) | |
tree | 62fc6cc5a77c46baffd6026c60f32e36517550da /spec/lib/gitlab/prometheus | |
parent | c54494e22adf6d157e05933aa37d182d2f3c1ce6 (diff) |
Improve MetricGroup test
Diffstat (limited to 'spec/lib/gitlab/prometheus')
-rw-r--r-- | spec/lib/gitlab/prometheus/metric_group_spec.rb | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/spec/lib/gitlab/prometheus/metric_group_spec.rb b/spec/lib/gitlab/prometheus/metric_group_spec.rb index 1c7a4a5d1d6..ec61f500902 100644 --- a/spec/lib/gitlab/prometheus/metric_group_spec.rb +++ b/spec/lib/gitlab/prometheus/metric_group_spec.rb @@ -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 |