Skip to content

Commit

Permalink
test(job_start_log): new tests for job_start_log configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahdi Dibaiee committed Apr 11, 2019
1 parent a3f68bc commit 0a91515
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions spec/sidekiq/logstash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0a91515

Please sign in to comment.