Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Weaver committed Oct 6, 2010
1 parent 44358ae commit f1f42a2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Original file line Diff line number Diff line change
@@ -1 +1 @@
0.5.3 0.5.4
2 changes: 1 addition & 1 deletion lib/kestrel/client/transactional.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get(key, opts = {})


queue = (rand < @error_rate) ? key + "_errors" : key queue = (rand < @error_rate) ? key + "_errors" : key


if job = get(queue, opts.merge(:open => true)) if job = client.get(queue, opts.merge(:open => true))
@current_queue = key @current_queue = key
@job = job.is_a?(RetryableJob) ? job : RetryableJob.new(0, job) @job = job.is_a?(RetryableJob) ? job : RetryableJob.new(0, job)
@job.job @job.job
Expand Down
21 changes: 7 additions & 14 deletions spec/kestrel/client/transactional_spec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
describe "#get" do describe "#get" do


it "asks for a transaction" do it "asks for a transaction" do
mock(@raw_kestrel_client).get(@queue, :open => true, :close => true) { :mcguffin } mock(@raw_kestrel_client).get(@queue, :open => true) { :mcguffin }
@kestrel.get(@queue).should == :mcguffin @kestrel.get(@queue).should == :mcguffin
end end


Expand All @@ -23,30 +23,23 @@
@kestrel.get(@queue).should == :mcguffin @kestrel.get(@queue).should == :mcguffin
end end


it "falls through to the normal queue when error queue is empty" do
mock(@kestrel).rand { Kestrel::Client::Transactional::ERROR_PROCESSING_RATE - 0.05 }
mock(@raw_kestrel_client).get(@queue + "_errors", anything) { nil }
mock(@raw_kestrel_client).get(@queue, anything) { :mcguffin }
@kestrel.get(@queue).should == :mcguffin
end

it "gets from the normal queue most of the time" do it "gets from the normal queue most of the time" do
mock(@kestrel).rand { Kestrel::Client::Transactional::ERROR_PROCESSING_RATE + 0.05 } mock(@kestrel).rand { Kestrel::Client::Transactional::ERROR_PROCESSING_RATE + 0.05 }
mock(@raw_kestrel_client).get(@queue, anything) { :mcguffin } mock(@raw_kestrel_client).get(@queue, anything) { :mcguffin }
mock(@raw_kestrel_client).get(@queue + "_errors", anything).never mock(@raw_kestrel_client).get(@queue + "_errors", anything).never
@kestrel.get(@queue).should == :mcguffin @kestrel.get(@queue).should == :mcguffin
end end


it "falls through to the error queue when normal queue is empty" do it "is nil when the primary queue is empty and selected" do
mock(@kestrel).rand { Kestrel::Client::Transactional::ERROR_PROCESSING_RATE + 0.05 } mock(@kestrel).rand { Kestrel::Client::Transactional::ERROR_PROCESSING_RATE + 0.05 }
mock(@raw_kestrel_client).get(@queue, anything) { nil } mock(@raw_kestrel_client).get(@queue, anything) { nil }
mock(@raw_kestrel_client).get(@queue + "_errors", anything) { :mcguffin } mock(@raw_kestrel_client).get(@queue + "_errors", anything).never
@kestrel.get(@queue).should == :mcguffin @kestrel.get(@queue).should be_nil
end end


it "is nil when both queues are empty" do it "is nil when the error queue is empty and selected" do
mock(@kestrel).rand { Kestrel::Client::Transactional::ERROR_PROCESSING_RATE + 0.05 } mock(@kestrel).rand { Kestrel::Client::Transactional::ERROR_PROCESSING_RATE - 0.05 }
mock(@raw_kestrel_client).get(@queue, anything) { nil } mock(@raw_kestrel_client).get(@queue, anything).never
mock(@raw_kestrel_client).get(@queue + "_errors", anything) { nil } mock(@raw_kestrel_client).get(@queue + "_errors", anything) { nil }
@kestrel.get(@queue).should be_nil @kestrel.get(@queue).should be_nil
end end
Expand Down

0 comments on commit f1f42a2

Please sign in to comment.