test/worker_pool_test.rb in larva-0.9.0 vs test/worker_pool_test.rb in larva-0.9.1

- old
+ new

@@ -20,21 +20,33 @@ end Propono.config.logger.expects(:error).with('Listener for qux was dead') Propono.config.logger.expects(:error).with('Some threads have died:') pool = WorkerPool.new({'qux' => nil}) pool.stubs(:sleep) - pool.start + err = assert_raises(StandardError) { pool.start } + assert_equal 'Some threads have died', err.message end def test_listen_is_called_correctly Propono.config.logger.stubs(:info) Propono.config.logger.expects(:info).with("All threads are alive.") topic_name = "Foo" processor = mock Larva::Listener.expects(:listen).with(topic_name, processor) pool = WorkerPool.new({topic_name => processor}) + pool.expects(:sleep).with(60).at_least_once + + Thread.any_instance.stubs(alive?: true) + + Thread.new do + while true + sleep(1) + pool.stop + end + end + pool.start end end end