diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/lib/gitlab/usage/metrics/aggregates/sources/redis_hll_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/lib/gitlab/usage/metrics/aggregates/sources/redis_hll_spec.rb')
-rw-r--r-- | spec/lib/gitlab/usage/metrics/aggregates/sources/redis_hll_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/lib/gitlab/usage/metrics/aggregates/sources/redis_hll_spec.rb b/spec/lib/gitlab/usage/metrics/aggregates/sources/redis_hll_spec.rb new file mode 100644 index 00000000000..af2de5ea343 --- /dev/null +++ b/spec/lib/gitlab/usage/metrics/aggregates/sources/redis_hll_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Usage::Metrics::Aggregates::Sources::RedisHll do + describe '.calculate_events_union' do + let(:event_names) { %w[event_a event_b] } + let(:start_date) { 7.days.ago } + let(:end_date) { Date.current } + + subject(:calculate_metrics_union) do + described_class.calculate_metrics_union(metric_names: event_names, start_date: start_date, end_date: end_date, recorded_at: nil) + end + + it 'calls Gitlab::UsageDataCounters::HLLRedisCounter.calculate_events_union' do + expect(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:calculate_events_union) + .with(event_names: event_names, start_date: start_date, end_date: end_date) + .and_return(5) + + calculate_metrics_union + end + + it 'prevents from using fallback value as valid union result' do + allow(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:calculate_events_union).and_return(-1) + + expect { calculate_metrics_union }.to raise_error Gitlab::Usage::Metrics::Aggregates::Sources::UnionNotAvailable + end + end +end |