summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/usage/metrics/instrumentations/redis_metric_spec.rb
blob: fb3bd1ba8341dfa0b6adf4dc4b6390cc41d7e33e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Usage::Metrics::Instrumentations::RedisMetric, :clean_gitlab_redis_shared_state do
  before do
    4.times do
      Gitlab::UsageDataCounters::SourceCodeCounter.count(:pushes)
    end
  end

  let(:expected_value) { 4 }

  it_behaves_like 'a correct instrumented metric value', { options: { event: 'pushes', counter_class: 'SourceCodeCounter' } }

  it 'raises an exception if event option is not present' do
    expect { described_class.new(counter_class: 'SourceCodeCounter') }.to raise_error(ArgumentError)
  end

  it 'raises an exception if counter_class option is not present' do
    expect { described_class.new(event: 'pushes') }.to raise_error(ArgumentError)
  end
end