Commit 1382e6b9 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '241832-follow-up-from-add-basic-redis-hll-module-add-tests' into 'master'

Add tests for events_for_category

Closes #241832

See merge request gitlab-org/gitlab!40702
parents 7617b7ea 6c290834
......@@ -53,8 +53,10 @@ module Gitlab
Gitlab::Redis::HLL.count(keys: keys)
end
# @param category [String] the category name
# @return [Array<String>] list of event names for given category
def events_for_category(category)
known_events.select { |event| event[:category] == category }.map { |event| event[:name] }
known_events.select { |event| event[:category] == category.to_s }.map { |event| event[:name] }
end
private
......
......@@ -43,6 +43,12 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
Timecop.freeze(reference_time) { example.run }
end
describe '.events_for_category' do
it 'gets the event names for given category' do
expect(described_class.events_for_category(:analytics)).to contain_exactly(weekly_event, daily_event)
end
end
describe '.track_event' do
it "raise error if metrics don't have same aggregation" do
expect { described_class.track_event(entity1, different_aggregation, Date.current) } .to raise_error(Gitlab::UsageDataCounters::HLLRedisCounter::UnknownAggregation)
......
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