|
1 | 1 | require "test_helper" |
2 | 2 |
|
3 | 3 | describe "Resque::MultiQueue" do |
4 | | - let(:redis) { Resque.redis } |
5 | 4 | let(:pool) { Resque.pool } |
6 | 5 | let(:coder) { Resque::JsonCoder.new } |
7 | 6 |
|
8 | 7 | it "poll times out and returns nil" do |
9 | 8 | foo = Resque::Queue.new 'foo', pool |
10 | 9 | bar = Resque::Queue.new 'bar', pool |
11 | | - queue = Resque::MultiQueue.new([foo, bar], redis, pool) |
| 10 | + queue = Resque::MultiQueue.new([foo, bar], pool) |
12 | 11 | assert_nil queue.poll(1) |
13 | 12 | end |
14 | 13 |
|
15 | 14 | it "poll is a no-op when queues are empty" do |
16 | | - queue = Resque::MultiQueue.new([], redis) |
| 15 | + queue = Resque::MultiQueue.new([]) |
17 | 16 | assert_nil queue.poll(1) |
18 | 17 | end |
19 | 18 |
|
20 | 19 | it "blocks on pop" do |
21 | 20 | foo = Resque::Queue.new 'foo', pool, coder |
22 | 21 | bar = Resque::Queue.new 'bar', pool, coder |
23 | | - queue = Resque::MultiQueue.new([foo, bar], redis, pool) |
| 22 | + queue = Resque::MultiQueue.new([foo, bar], pool) |
24 | 23 | t = Thread.new { queue.pop } |
25 | 24 |
|
26 | 25 | job = { 'class' => 'GoodJob', 'args' => [35, 'tar'] } |
|
32 | 31 | it "nonblocking pop works" do |
33 | 32 | foo = Resque::Queue.new 'foo', pool, coder |
34 | 33 | bar = Resque::Queue.new 'bar', pool, coder |
35 | | - queue = Resque::MultiQueue.new([foo, bar], redis, pool) |
| 34 | + queue = Resque::MultiQueue.new([foo, bar], pool) |
36 | 35 |
|
37 | 36 | job = { 'class' => 'GoodJob', 'args' => [35, 'tar'] } |
38 | 37 | bar << job |
|
43 | 42 | it "nonblocking pop doesn't block" do |
44 | 43 | foo = Resque::Queue.new 'foo', pool, coder |
45 | 44 | bar = Resque::Queue.new 'bar', pool, coder |
46 | | - queue = Resque::MultiQueue.new([foo, bar], redis, pool) |
| 45 | + queue = Resque::MultiQueue.new([foo, bar], pool) |
47 | 46 |
|
48 | 47 | assert_raises ThreadError do |
49 | 48 | queue.pop(true) |
|
53 | 52 | it "blocks forever on pop" do |
54 | 53 | foo = Resque::Queue.new 'foo', pool, coder |
55 | 54 | bar = Resque::Queue.new 'bar', pool, coder |
56 | | - queue = Resque::MultiQueue.new([foo, bar], redis, pool) |
| 55 | + queue = Resque::MultiQueue.new([foo, bar], pool) |
57 | 56 | assert_raises Timeout::Error do |
58 | 57 | Timeout::timeout(2) { queue.pop } |
59 | 58 | end |
|
64 | 63 | bar = Resque::Queue.new 'bar', pool, coder |
65 | 64 | baz = Resque::Queue.new 'baz', pool, coder |
66 | 65 | queues = [foo, bar, baz] |
67 | | - queue = Resque::MultiQueue.new(queues, redis, pool) |
| 66 | + queue = Resque::MultiQueue.new(queues, pool) |
68 | 67 | job = { 'class' => 'GoodJob', 'args' => [35, 'tar'] } |
69 | 68 |
|
70 | 69 | queues.each {|q| q << job } |
|
82 | 81 | bar = Resque::Queue.new 'bar', pool, coder |
83 | 82 | baz = Resque::Queue.new 'baz', pool, coder |
84 | 83 | queues = [foo, bar, baz] |
85 | | - queue = Resque::MultiQueue.new(queues, redis, pool) |
| 84 | + queue = Resque::MultiQueue.new(queues, pool) |
86 | 85 | job = { 'class' => 'GoodJob', 'args' => [35, 'tar'] } |
87 | 86 |
|
88 | 87 | queues.each {|q| q << job } |
|
96 | 95 | end |
97 | 96 |
|
98 | 97 | it "blocking pop is a no-op if queues are empty" do |
99 | | - queue = Resque::MultiQueue.new([], redis) |
| 98 | + queue = Resque::MultiQueue.new([]) |
100 | 99 | assert_raises Timeout::Error do |
101 | 100 | Timeout.timeout(2) { queue.pop } |
102 | 101 | end |
|
0 commit comments