Skip to content

Commit

Permalink
skeleton of sidekiq logging test
Browse files Browse the repository at this point in the history
  • Loading branch information
akostadinov committed May 30, 2023
1 parent 79e97d6 commit b5615a3
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions test/unit/sidekiq_initializer_test.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# frozen_string_literal: true

require 'test_helper'
require 'sidekiq/manager'
require 'sidekiq/testing'

class SidekiqInitializerTest < ActiveSupport::TestCase

test 'log job arguments' do
options = {:queues => ['default']}

logger = Sidekiq.logger = Sidekiq::Logging.initialize_logger

mgr = Sidekiq::Manager.new(options)
processor = ::Sidekiq::Processor.new(mgr)

invoice = FactoryBot.create(:invoice)

msg = Sidekiq.dump_json({ 'class' => InvoiceFriendlyIdWorker.to_s, 'args' => [invoice.id] })
job = Sidekiq::BasicFetch::UnitOfWork.new('queue:default', msg)
processor.send(:process, job)

# Sidekiq.logger.expects(:info) #.with { |message| message.match("ARGS-[#{invoice.id}]") }

logger.expects(:info)
logged = false
ActiveRecord::Base.transaction
SphinxIndexationWorker.stubs(:perform_later)
Rails.logger.stubs(:info).with do |msg|
next(true) if msg.start_with?("[EventBroker] ")

logged = msg =~ /^Failed to reprocess invoice logo for.*/
end

buyer = FactoryBot.create(:buyer_account)
assert logged
Testing.inline! do
BillingWorker.enqueue_for_buyer(buyer, Time.zone.now)
end
end
end

0 comments on commit b5615a3

Please sign in to comment.