Sha256: a26e3ab7c38bc01aca3252e847e58fdbccf79d83f4d2d781d0b67c4c11642690

Contents?: true

Size: 1.29 KB

Versions: 17

Compression:

Stored size: 1.29 KB

Contents

require 'test_helper'

class EnvironmentTest < Minitest::Test

  def setup
    ENV['STATSD_ADDR'] = nil
    ENV['IMPLEMENTATION'] = nil
  end

  def test_uses_logger_in_development_environment
    StatsD::Instrument::Environment.stubs(:environment).returns('development')
    assert_instance_of StatsD::Instrument::Backends::LoggerBackend, StatsD::Instrument::Environment.default_backend
  end

  def test_uses_null_backend_in_test_environment
    StatsD::Instrument::Environment.stubs(:environment).returns('test')
    assert_instance_of StatsD::Instrument::Backends::NullBackend, StatsD::Instrument::Environment.default_backend
  end

  def test_uses_udp_backend_in_production_environment
    StatsD::Instrument::Environment.stubs(:environment).returns('production')
    assert_instance_of StatsD::Instrument::Backends::UDPBackend, StatsD::Instrument::Environment.default_backend
  end

  def test_uses_environment_variables_in_production_environment
    StatsD::Instrument::Environment.stubs(:environment).returns('production')
    ENV['STATSD_ADDR'] = '127.0.0.1:1234'
    ENV['STATSD_IMPLEMENTATION'] = 'datadog'

    backend = StatsD::Instrument::Environment.default_backend
    assert_equal '127.0.0.1', backend.host
    assert_equal 1234, backend.port
    assert_equal :datadog, backend.implementation
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
statsd-instrument-2.1.1 test/environment_test.rb
statsd-instrument-2.1.0 test/environment_test.rb
statsd-instrument-2.0.12 test/environment_test.rb
statsd-instrument-2.0.11 test/environment_test.rb
statsd-instrument-2.0.10 test/environment_test.rb
statsd-instrument-2.0.9 test/environment_test.rb
statsd-instrument-2.0.8 test/environment_test.rb
statsd-instrument-2.0.7 test/environment_test.rb
statsd-instrument-2.0.6 test/environment_test.rb
statsd-instrument-2.0.5 test/environment_test.rb
statsd-instrument-2.0.4 test/environment_test.rb
statsd-instrument-2.0.3 test/environment_test.rb
statsd-instrument-2.0.2 test/environment_test.rb
statsd-instrument-2.0.1 test/environment_test.rb
statsd-instrument-2.0.0 test/environment_test.rb
statsd-instrument-2.0.0beta2 test/environment_test.rb
statsd-instrument-2.0.0beta test/environment_test.rb