Skip to content

Commit

Permalink
Add JID for inline testing, fixes #1454
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Jan 30, 2014
1 parent 3a6cadc commit b0107b5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Changes.md
@@ -1,3 +1,11 @@
HEAD
-----------

- Fix JID support in inline testing, #1454
- Polish worker arguments display in UI, #1453
- Marshal arguments fully to avoid worker mutation, #1452


2.17.3
-----------

Expand Down
7 changes: 6 additions & 1 deletion lib/sidekiq/testing.rb
@@ -1,3 +1,5 @@
require 'securerandom'

module Sidekiq

class Testing
Expand Down Expand Up @@ -64,8 +66,11 @@ def raw_push(payloads)
true
elsif Sidekiq::Testing.inline?
payloads.each do |item|
jid = item['jid'] || SecureRandom.hex(12)
marshalled = Sidekiq.load_json(Sidekiq.dump_json(item))
marshalled['class'].constantize.new.perform(*marshalled['args'])
worker = marshalled['class'].constantize.new
worker.jid = jid
worker.perform(*marshalled['args'])
end
true
else
Expand Down
1 change: 1 addition & 0 deletions test/test_testing_inline.rb
Expand Up @@ -17,6 +17,7 @@ class ParameterIsNotString < RuntimeError; end
class InlineWorker
include Sidekiq::Worker
def perform(pass)
raise ArgumentError, "no jid" unless jid
raise InlineError unless pass
end
end
Expand Down

0 comments on commit b0107b5

Please sign in to comment.