Sha256: be4eb70919e64f5bbc909d81d8576104c9ad74bb1d938defeb93bc810a61fcf9

Contents?: true

Size: 910 Bytes

Versions: 9

Compression:

Stored size: 910 Bytes

Contents

require_relative '../test_helper'
require 'logster/defer_logger'
require 'logster/logger'

class TestDeferLogger < Minitest::Test
  def setup
    @store = TestStore.new
    @defer_logger = Logster::DeferLogger.new(@store)
  end

  def test_defer_logger_inherits_logger
    assert(Logster::Logger === @defer_logger)
  end

  def test_work_is_done_async
    queue = Logster::Scheduler.queue
    assert_equal(0, queue.size)

    @defer_logger.add(4, "hi this a test", "prog")

    assert_equal(1, queue.size)
    queue << :terminate
    Logster::Scheduler.thread.join
    assert_equal(1, @store.calls.size)

    # we need to make sure the backtrace is passed from the main thread.
    # Otherwise we'd only get a partial backtrace from
    # the point the new thread was spawned
    backtrace = @store.calls.first[3][:backtrace]
    assert_instance_of(Array, backtrace)

    assert_equal(0, queue.size)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
logster-2.4.2 test/logster/test_defer_logger.rb
logster-2.4.1 test/logster/test_defer_logger.rb
logster-2.4.0 test/logster/test_defer_logger.rb
logster-2.3.3 test/logster/test_defer_logger.rb
logster-2.3.2 test/logster/test_defer_logger.rb
logster-2.3.1 test/logster/test_defer_logger.rb
logster-2.3.0 test/logster/test_defer_logger.rb
logster-2.2.0 test/logster/test_defer_logger.rb
logster-2.1.1 test/logster/test_defer_logger.rb