From 0a91515ceeb2726af8bd31fef7df97c906e760fa Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Thu, 11 Apr 2019 08:41:40 +0430 Subject: [PATCH] test(job_start_log): new tests for job_start_log configuration --- spec/sidekiq/logstash_spec.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/spec/sidekiq/logstash_spec.rb b/spec/sidekiq/logstash_spec.rb index 111d942..083a6ff 100644 --- a/spec/sidekiq/logstash_spec.rb +++ b/spec/sidekiq/logstash_spec.rb @@ -51,4 +51,33 @@ expect(log_job['args'][2]).to include('[ENCRYPTED]') end end + + context 'enable job_start_log' do + it 'generates log with job_status=started' do + buffer = StringIO.new + Sidekiq.logger = Logger.new(buffer) + + Sidekiq::Logstash.configure do |config| + config.job_start_log = true + end + + log_job = Sidekiq::LogstashJobLogger.new.log_job(job, Time.now.utc, exc = nil, start = true) + + expect(log_job['job_status']).to eq('started') + end + + it 'logs both the starting and finished logs' do + buffer = StringIO.new + Sidekiq.logger = Logger.new(buffer) + + Sidekiq::Logstash.configure do |config| + config.job_start_log = true + end + + log_job = Sidekiq::LogstashJobLogger.new.call(job, :default) {} + + expect(buffer.string).to include('"job_status"=>"started"') + expect(buffer.string).to include('"job_status"=>"done"') + end + end end