Sha256: a004037de9dee796d2de3ba9e45cef0503e4284ed853f0b25cda217535358172

Contents?: true

Size: 1.67 KB

Versions: 24

Compression:

Stored size: 1.67 KB

Contents

require 'test_helper'

class TestCLogger < Minitest::Test
  def setup
    Prefab::LoggerClient.send(:public, :get_path)
    Prefab::LoggerClient.send(:public, :level_of)
    @logger = Prefab::LoggerClient.new($stdout)
  end

  def test_get_path
    assert_equal "test_l.foo_warn",
                 @logger.get_path("/Users/jdwyah/Documents/workspace/RateLimitInc/prefab-cloud-ruby/lib/test_l.rb",
                                  "foo_warn")

    assert_equal "active_support.log_subscriber.info",
                 @logger.get_path("/Users/jdwyah/.rvm/gems/ruby-2.3.3@forcerank/gems/activesupport-4.1.16/lib/active_support/log_subscriber.rb",
                                  "info")
  end

  def test_level_of
    assert_equal Logger::INFO,
                 @logger.level_of("app.models.user"), "PREFAB_LOG_CLIENT_BOOTSTRAP_LOG_LEVEL is info"

    @logger.set_config_client(MockConfigClient.new({}))
    assert_equal Logger::WARN,
                 @logger.level_of("app.models.user"), "default is warn"

    @logger.set_config_client(MockConfigClient.new("log_level.app" => "info"))
    assert_equal Logger::INFO,
                 @logger.level_of("app.models.user")

    @logger.set_config_client(MockConfigClient.new("log_level.app" => "debug"))
    assert_equal Logger::DEBUG,
                 @logger.level_of("app.models.user")

    @logger.set_config_client(MockConfigClient.new("log_level.app" => "debug",
                                                   "log_level.app.models" => "warn"))
    assert_equal Logger::WARN,
                 @logger.level_of("app.models.user")
  end
end

class MockConfigClient
  def initialize(hash)
    @hash = hash
  end

  def get(key)
    @hash[key]
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
prefab-cloud-ruby-0.13.1 test/test_logger.rb
prefab-cloud-ruby-0.9.0 test/test_logger.rb
prefab-cloud-ruby-0.8.0 test/test_logger.rb
prefab-cloud-ruby-0.7.0 test/test_logger.rb
prefab-cloud-ruby-0.6.0 test/test_logger.rb
prefab-cloud-ruby-0.5.1 test/test_logger.rb
prefab-cloud-ruby-0.5.0 test/test_logger.rb
prefab-cloud-ruby-0.4.0 test/test_logger.rb
prefab-cloud-ruby-0.3.0 test/test_logger.rb
prefab-cloud-ruby-0.2.0 test/test_logger.rb
prefab-cloud-ruby-0.1.1 test/test_logger.rb
prefab-cloud-ruby-0.1.0 test/test_logger.rb
prefab-cloud-ruby-0.1.0.alpha.1 test/test_logger.rb
prefab-cloud-ruby-0.0.28 test/test_logger.rb
prefab-cloud-ruby-0.0.27 test/test_logger.rb
prefab-cloud-ruby-0.0.26 test/test_logger.rb
prefab-cloud-ruby-0.0.25 test/test_logger.rb
prefab-cloud-ruby-0.0.24 test/test_logger.rb
prefab-cloud-ruby-0.0.23 test/test_logger.rb
prefab-cloud-ruby-0.0.22 test/test_logger.rb