test/unit/process_tests.rb in qs-0.4.0 vs test/unit/process_tests.rb in qs-0.5.0

- old
+ new

@@ -20,13 +20,11 @@ end class InitTests < UnitTests desc "when init" setup do - @current_env_process_label = ENV['QS_PROCESS_LABEL'] @current_env_skip_daemonize = ENV['QS_SKIP_DAEMONIZE'] - ENV.delete('QS_PROCESS_LABEL') ENV.delete('QS_SKIP_DAEMONIZE') @daemon_spy = DaemonSpy.new @pid_file_spy = PIDFileSpy.new(Factory.integer) @@ -39,11 +37,10 @@ @process = @process_class.new(@daemon_spy) end teardown do ENV['QS_SKIP_DAEMONIZE'] = @current_env_skip_daemonize - ENV['QS_PROCESS_LABEL'] = @current_env_process_label end subject{ @process } should have_readers :daemon, :name should have_readers :pid_file, :signal_io, :restart_cmd @@ -52,28 +49,16 @@ should "know its daemon" do assert_equal @daemon_spy, subject.daemon end should "know its name, pid file, signal io and restart cmd" do - assert_equal "qs: #{@daemon_spy.name}", subject.name + assert_equal "qs: #{@daemon_spy.process_label}", subject.name assert_equal @pid_file_spy, subject.pid_file assert_instance_of Qs::IOPipe, subject.signal_io assert_equal @restart_cmd_spy, subject.restart_cmd end - should "set its name using env vars" do - ENV['QS_PROCESS_LABEL'] = Factory.string - process = @process_class.new(@daemon_spy) - assert_equal "qs: #{ENV['QS_PROCESS_LABEL']}", process.name - end - - should "ignore blank env values for its name" do - ENV['QS_PROCESS_LABEL'] = '' - process = @process_class.new(@daemon_spy) - assert_equal "qs: #{@daemon_spy.name}", process.name - end - should "not daemonize by default" do process = @process_class.new(@daemon_spy) assert_false process.daemonize? end @@ -413,14 +398,18 @@ name Factory.string pid_file Factory.file_path queue Qs::Queue.new{ name Factory.string } + attr_accessor :process_label attr_accessor :start_called, :stop_called, :halt_called attr_reader :start_args, :stop_args, :halt_args def initialize(*args) super + + @process_label = Factory.string + @start_args = nil @start_called = false @stop_args = nil @stop_called = false @halt_args = nil