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

deduplication_logger_spec.rb « sidekiq_logging « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3cc5c0bed1ba4760c78a071f08e69a33cb296751 (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
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::SidekiqLogging::DeduplicationLogger do
  describe '#log_deduplication' do
    let(:job) do
      {
        'class' => 'TestWorker',
        'args' => [1234, 'hello', { 'key' => 'value' }],
        'jid' => 'da883554ee4fe414012f5f42',
        'correlation_id' => 'cid',
        'duplicate-of' => 'other_jid'
      }
    end

    it 'logs a deduplication message to the sidekiq logger' do
      expected_payload = {
        'job_status' => 'deduplicated',
        'message' => "#{job['class']} JID-#{job['jid']}: deduplicated: a fancy strategy",
        'deduplication_type' => 'a fancy strategy'
      }
      expect(Sidekiq.logger).to receive(:info).with(a_hash_including(expected_payload)).and_call_original

      described_class.instance.log(job, "a fancy strategy")
    end

    it "does not modify the job" do
      expect { described_class.instance.log(job, "a fancy strategy") }
        .not_to change { job }
    end
  end
end