1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Raise error for duplicate queue names in config, fixes #3911 (#3936)

* Raise error for duplicate queue names in config, fixes #3911

* Add note to change log
This commit is contained in:
Chad Schroeder 2018-08-24 13:35:07 -05:00 committed by Mike Perham
parent 6386c6596e
commit e8227186bb
3 changed files with 13 additions and 3 deletions

View file

@ -2,6 +2,11 @@
[Sidekiq Changes](https://github.com/mperham/sidekiq/blob/master/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/master/Ent-Changes.md)
HEAD
---------
- Raise error for duplicate queue names in config to avoid unexpected fetch algorithm change [#3911]
5.2.1
-----------

View file

@ -436,9 +436,9 @@ module Sidekiq
end
def parse_queue(opts, q, weight=nil)
[weight.to_i, 1].max.times do
(opts[:queues] ||= []) << q
end
opts[:queues] ||= []
raise ArgumentError, "queues: #{q} cannot be defined twice" if opts[:queues].include?(q)
[weight.to_i, 1].max.times { opts[:queues] << q }
opts[:strict] = false if weight.to_i > 0
end
end

View file

@ -104,6 +104,11 @@ class TestCli < Sidekiq::Test
assert_equal ['foo.bar'], Sidekiq.options[:queues]
end
it 'raises an error for duplicate queue names' do
assert_raises(ArgumentError) { @cli.parse(['sidekiq', '-q', 'foo', '-q', 'foo', '-r', './test/fake_env.rb']) }
assert_raises(ArgumentError) { @cli.parse(['sidekiq', '-q', 'foo,3', '-q', 'foo,1', '-r', './test/fake_env.rb']) }
end
it 'sets verbose' do
old = Sidekiq.logger.level
@cli.parse(['sidekiq', '-v', '-r', './test/fake_env.rb'])