summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/usage_data_counters/package_event_counter_spec.rb
blob: c484595ee714659d41a87dbcd774b7a788d67dc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::UsageDataCounters::PackageEventCounter, :clean_gitlab_redis_shared_state do
  shared_examples_for 'usage counter with totals' do |counter|
    it 'increments counter and returns total count' do
      expect(described_class.read(counter)).to eq(0)

      2.times { described_class.count(counter) }

      expect(described_class.read(counter)).to eq(2)
    end
  end

  it 'includes the right events' do
    expect(described_class::KNOWN_EVENTS.size).to eq 51
  end

  described_class::KNOWN_EVENTS.each do |event|
    it_behaves_like 'usage counter with totals', event
  end

  describe '.fetch_supported_event' do
    subject { described_class.fetch_supported_event(event_name) }

    let(:event_name) { 'package_events_i_package_composer_push_package' }

    it { is_expected.to eq 'i_package_composer_push_package' }
  end
end