From 07743cd8a50a757326aa5dbc1d3e52cb52778623 Mon Sep 17 00:00:00 2001 From: Chris AtLee Date: Mon, 4 Mar 2024 21:02:27 +0000 Subject: [PATCH] Clean up some test noise --- test/environment_test.rb | 3 +++ test/udp_sink_test.rb | 3 +++ 2 files changed, 6 insertions(+) diff --git a/test/environment_test.rb b/test/environment_test.rb index f6ff7568..d49bcbf6 100644 --- a/test/environment_test.rb +++ b/test/environment_test.rb @@ -57,6 +57,9 @@ def test_client_from_env_uses_batched_udp_sink_in_production_environment end def test_client_from_env_uses_regular_udp_sink_when_flush_interval_is_0 + StatsD::Instrument::Environment.any_instance.expects(:warn).with( + "STATSD_FLUSH_INTERVAL=0.0 is deprecated, please set STATSD_BUFFER_CAPACITY=0 instead.", + ).once env = StatsD::Instrument::Environment.new( "STATSD_USE_NEW_CLIENT" => "1", "STATSD_ENV" => "staging", diff --git a/test/udp_sink_test.rb b/test/udp_sink_test.rb index 6993540c..e860210e 100644 --- a/test/udp_sink_test.rb +++ b/test/udp_sink_test.rb @@ -152,6 +152,7 @@ def test_socket_error_should_invalidate_socket socket.expects(:close).in_sequence(seq) socket.expects(:connect).with("localhost", 8125).in_sequence(seq) socket.expects(:send).twice.returns(1).in_sequence(seq) + socket.expects(:close).in_sequence(seq) udp_sink = build_sink("localhost", 8125) udp_sink << "foo:1|c" @@ -164,6 +165,8 @@ def test_socket_error_should_invalidate_socket ) ensure StatsD.logger = previous_logger + # Make sure our fake socket is closed so that it doesn't interfere with other tests + udp_sink&.send(:invalidate_socket) end end end