Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sidekiq_middleware_spec.rb « metrics « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 05214efc56593ce335979bc09db5a356c270fd53 (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
32
33
34
require 'spec_helper'

describe Gitlab::Metrics::SidekiqMiddleware do
  let(:middleware) { described_class.new }

  describe '#call' do
    it 'tracks the transaction' do
      worker = Class.new.new

      expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:finish)

      middleware.call(worker, 'test', :test) { nil }
    end

    it 'does not track jobs of the MetricsWorker' do
      worker = MetricsWorker.new

      expect(Gitlab::Metrics::Transaction).to_not receive(:new)

      middleware.call(worker, 'test', :test) { nil }
    end
  end

  describe '#tag_worker' do
    it 'adds the worker class and action to the transaction' do
      trans  = Gitlab::Metrics::Transaction.new
      worker = double(:worker, class: double(:class, name: 'TestWorker'))

      expect(trans).to receive(:add_tag).with(:action, 'TestWorker#perform')

      middleware.tag_worker(trans, worker)
    end
  end
end