test/test_god.rb in god-0.5.0 vs test/test_god.rb in god-0.6.0

- old
+ new

@@ -10,10 +10,17 @@ def teardown Timer.get.timer.kill end + # applog + + def test_applog + LOG.expects(:log).with(nil, :debug, 'foo') + applog(nil, :debug, 'foo') + end + # internal_init def test_init_should_initialize_watches_to_empty_array God.internal_init { } assert_equal Hash.new, God.watches @@ -295,10 +302,19 @@ w.state = :up w.expects(:unmonitor).returns(w) God.control('foo', 'unmonitor') end + def test_control_should_unwatch_on_remove + God.watch { |w| w.name = 'foo'; w.start = 'bar' } + + w = God.watches['foo'] + w.state = :up + God.expects(:unwatch) + God.control('foo', 'remove') + end + def test_control_should_raise_on_invalid_command God.watch { |w| w.name = 'foo'; w.start = 'bar' } assert_raise InvalidCommandError do God.control('foo', 'invalid') @@ -327,14 +343,23 @@ # stop_all # terminate def test_terminate_should_exit + God.pid = nil + FileUtils.expects(:rm_f).never God.expects(:exit!) God.terminate end + def test_terminate_should_delete_pid + God.pid = '/foo/bar' + FileUtils.expects(:rm_f).with("/foo/bar") + God.expects(:exit!) + God.terminate + end + # status def test_status_should_show_state God.watch { |w| w.name = 'foo'; w.start = 'bar' } @@ -501,9 +526,20 @@ # at_exit def test_at_exit_should_call_start God.expects(:start).once God.at_exit + end + + # pattern_match + + def test_pattern_match + list = %w{ mongrel-3000 mongrel-3001 fuzed fuzed2 apache mysql} + + assert_equal %w{ mongrel-3000 }, God.pattern_match('m3000', list) + assert_equal %w{ mongrel-3001 }, God.pattern_match('m31', list) + assert_equal %w{ fuzed fuzed2 }, God.pattern_match('fu', list) + assert_equal %w{ mysql }, God.pattern_match('sql', list) end end class TestGodOther < Test::Unit::TestCase \ No newline at end of file