Sha256: 300cf792320f60d18d16cc4ec9e7f56da1bfa90e060b84eae6925ce25a4fbf5f
Contents?: true
Size: 1.53 KB
Versions: 4
Compression:
Stored size: 1.53 KB
Contents
ENV['SKIP_RAILS'] = 'true' require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper')) class NewRelic::Agent::WorkerLoopTest < Test::Unit::TestCase def setup @log = "" @logger = Logger.new(StringIO.new(@log)) @worker_loop = NewRelic::Agent::WorkerLoop.new @worker_loop.stubs(:log).returns(@logger) @test_start_time = Time.now end def test_add_task @x = false @worker_loop.run(0) do @worker_loop.stop @x = true end assert @x end def test_density # This shows how the tasks stay aligned with the period and don't drift. count = 0 start = Time.now @worker_loop.run(0.2) do count +=1 if count == 10 @worker_loop.stop next end end elapsed = Time.now - start assert_in_delta 1.9, elapsed, 0.2 end def test_task_error__standard @logger.expects(:debug) @logger.expects(:error) # This loop task will run twice done = false @worker_loop.run(0) do @worker_loop.stop done = true raise "Standard Error Test" end assert done end class BadBoy < Exception; end def test_task_error__exception @logger.expects(:error).once @logger.expects(:debug).once @worker_loop.run(0) do @worker_loop.stop raise BadBoy, "oops" end end def test_task_error__server @logger.expects(:error).never @logger.expects(:debug).once @worker_loop.run(0) do @worker_loop.stop raise NewRelic::Agent::ServerError, "Runtime Error Test" end end end
Version data entries
4 entries across 4 versions & 1 rubygems