Skip to content

Commit

Permalink
Check config file existence
Browse files Browse the repository at this point in the history
  • Loading branch information
Tensho committed Dec 11, 2018
1 parent 6a7bf2d commit f013178
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/sidekiq/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ def validate!
die(1)
end

if options[:config_file] && !File.exist?(options[:config_file])
raise ArgumentError, "No such file #{options[:config_file]}"
end

[:concurrency, :timeout].each do |opt|
raise ArgumentError, "#{opt}: #{options[opt]} is not a valid value" if options.has_key?(opt) && options[opt].to_i <= 0
end
Expand Down
8 changes: 8 additions & 0 deletions test/test_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ class TestCLI < Minitest::Test
exit = assert_raises(SystemExit) { @cli.parse(%w[sidekiq -r ./test/fixtures]) }
assert_equal 1, exit.status
end

describe 'when config file path does not exist' do
it 'raises argument error' do
assert_raises(ArgumentError) do
@cli.parse(%w[sidekiq -r ./test/fake_env.rb -C /non/existent/path])
end
end
end
end
end
end
Expand Down

0 comments on commit f013178

Please sign in to comment.