diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /spec/lib/gitlab/redis | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'spec/lib/gitlab/redis')
-rw-r--r-- | spec/lib/gitlab/redis/hll_spec.rb | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/spec/lib/gitlab/redis/hll_spec.rb b/spec/lib/gitlab/redis/hll_spec.rb index cbf78f23036..e452e5b2f52 100644 --- a/spec/lib/gitlab/redis/hll_spec.rb +++ b/spec/lib/gitlab/redis/hll_spec.rb @@ -39,6 +39,24 @@ RSpec.describe Gitlab::Redis::HLL, :clean_gitlab_redis_shared_state do end end end + + context 'when adding entries' do + let(:metric) { 'test-{metric}' } + + it 'supports single value' do + track_event(metric, 1) + + expect(count_unique_events([metric])).to eq(1) + end + + it 'supports multiple values' do + stub_const("#{described_class.name}::HLL_BATCH_SIZE", 2) + + track_event(metric, [1, 2, 3, 4, 5]) + + expect(count_unique_events([metric])).to eq(5) + end + end end describe '.count' do @@ -94,13 +112,13 @@ RSpec.describe Gitlab::Redis::HLL, :clean_gitlab_redis_shared_state do expect(unique_counts).to eq(4) end + end - def track_event(key, value, expiry = 1.day) - described_class.add(key: key, value: value, expiry: expiry) - end + def track_event(key, value, expiry = 1.day) + described_class.add(key: key, value: value, expiry: expiry) + end - def count_unique_events(keys) - described_class.count(keys: keys) - end + def count_unique_events(keys) + described_class.count(keys: keys) end end |