From 828862a20df3d974c543ea7b57544faaad6553a8 Mon Sep 17 00:00:00 2001 From: Eito Katagiri Date: Wed, 2 Oct 2019 17:45:35 +0900 Subject: [PATCH] warn if both pool and identifier options are specified --- lib/delayed/command.rb | 1 + spec/delayed/command_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/delayed/command.rb b/lib/delayed/command.rb index 281078242..fa3c08f50 100644 --- a/lib/delayed/command.rb +++ b/lib/delayed/command.rb @@ -72,6 +72,7 @@ def initialize(args) # rubocop:disable MethodLength @options[:queues] = queue.split(',') end opt.on('--pool=queue1[,queue2][:worker_count]', 'Specify queues and number of workers for a worker pool') do |pool| + warn '--identifier is ignored because --pool is specified and used.' if @options[:identifier] parse_worker_pool(pool) end opt.on('--exit-on-complete', 'Exit when no more jobs are available to run. This will exit if all jobs are scheduled to run in the future.') do diff --git a/spec/delayed/command_spec.rb b/spec/delayed/command_spec.rb index b57cd6efa..2f1bd2c78 100644 --- a/spec/delayed/command_spec.rb +++ b/spec/delayed/command_spec.rb @@ -176,4 +176,16 @@ command.daemonize end end + + describe 'when both --pool and --identifier are specified' do + it 'should ignore --identifier and display warning' do + command = nil + expect { command = Delayed::Command.new(['--identifier=42', '--pool=mailers']) } + .to output(/--identifier is ignored/).to_stderr + + expect(command.worker_pools).to eq [ + [['mailers'], 1], + ] + end + end end