Sha256: 287336f5473a653dfb1b858b77828aea0e40f8a69b80872e00ab9047145fff5d

Contents?: true

Size: 930 Bytes

Versions: 1

Compression:

Stored size: 930 Bytes

Contents

require File.expand_path('../../test_helper', __FILE__)

module Filum

  class Worker
    def self.process
      Filum.logger.info "Processing"
    end
  end

  class LoggerTest < IntegrationTest
    def test_one_logline
      test_thread = Thread.new do
        Filum.logger.context_id = " [12345]"
        Worker.process
      end
      test_thread.join
      assert_logged(/\[12345\] Processing/)
    end

    def test_multiple_threads
      test_thread1 = Thread.new do
        Filum.logger.context_id = " [23456]"
        Worker.process
      end
      test_thread2 = Thread.new do
        Filum.logger.context_id = " [34567]"
        Worker.process
      end
      test_thread1.join
      test_thread2.join
      assert_logged(/\[23456\] Processing/)
      assert_logged(/\[34567\] Processing/)
    end


    def assert_logged(regex)
      assert File.readlines(Filum.config.logfile).grep(regex).size == 1
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
filum-0.0.1 test/integration/logger_test.rb