diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-09 21:07:59 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-09 21:07:59 +0300 |
commit | 7ebcead8cfd2edb810dd0cbda816b6cfbd170fe3 (patch) | |
tree | 11880c4059c89149cf997e9b958fb6d32c7dbdad /spec/lib/gitlab/sidekiq_logging | |
parent | f1a40d0db939dfe8ff95d385e652ff72566be765 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/sidekiq_logging')
-rw-r--r-- | spec/lib/gitlab/sidekiq_logging/deduplication_logger_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/lib/gitlab/sidekiq_logging/deduplication_logger_spec.rb b/spec/lib/gitlab/sidekiq_logging/deduplication_logger_spec.rb new file mode 100644 index 00000000000..3cc5c0bed1b --- /dev/null +++ b/spec/lib/gitlab/sidekiq_logging/deduplication_logger_spec.rb @@ -0,0 +1,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 |