mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Issue #1901: Don't crash if provided config file is empty.
Don't return result of YAML.load if false added tests around empty config file update changelog
This commit is contained in:
parent
587520d0ba
commit
381e4ea429
3 changed files with 31 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
|||
-----------
|
||||
|
||||
- Add queues list for each process to the Busy page. [davetoxa, #1897]
|
||||
- Fix for crash caused by empty config file. [jordan0day, #1901]
|
||||
|
||||
3.2.2
|
||||
-----------
|
||||
|
|
|
@ -353,7 +353,7 @@ module Sidekiq
|
|||
def parse_config(cfile)
|
||||
opts = {}
|
||||
if File.exist?(cfile)
|
||||
opts = YAML.load(ERB.new(IO.read(cfile)).result)
|
||||
opts = YAML.load(ERB.new(IO.read(cfile)).result) || opts
|
||||
opts = opts.merge(opts.delete(environment) || {})
|
||||
parse_queues(opts, opts.delete(:queues) || [])
|
||||
else
|
||||
|
|
|
@ -241,6 +241,35 @@ class TestCli < Sidekiq::Test
|
|||
end
|
||||
end
|
||||
|
||||
describe 'with an empty config file' do
|
||||
before do
|
||||
@tmp_file = Tempfile.new('sidekiq-test')
|
||||
@tmp_path = @tmp_file.path
|
||||
@tmp_file.close!
|
||||
end
|
||||
|
||||
after do
|
||||
File.unlink @tmp_path if File.exist? @tmp_path
|
||||
end
|
||||
|
||||
it 'takes a path' do
|
||||
@cli.parse(['sidekiq', '-C', @tmp_path])
|
||||
assert_equal @tmp_path, Sidekiq.options[:config_file]
|
||||
end
|
||||
|
||||
it 'should have an identical options hash, except for config_file' do
|
||||
@cli.parse(['sidekiq'])
|
||||
old_options = Sidekiq.options.clone
|
||||
|
||||
@cli.parse(['sidekiq', '-C', @tmp_path])
|
||||
new_options = Sidekiq.options.clone
|
||||
refute_equal old_options, new_options
|
||||
|
||||
new_options.delete(:config_file)
|
||||
assert_equal old_options, new_options
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with config file and flags' do
|
||||
before do
|
||||
# We need an actual file here.
|
||||
|
|
Loading…
Reference in a new issue