correct and simplify noisy test

This commit is contained in:
Sam Saffron 2021-08-04 15:58:46 +10:00
parent 4e23da64ca
commit ac2084b074
No known key found for this signature in database
GPG Key ID: B9606168D2FFD9F5
1 changed files with 6 additions and 5 deletions

View File

@ -53,14 +53,15 @@ class PrometheusExporterTest < Minitest::Test
end
def test_overriding_logger
mock_logger = Minitest::Mock.new
mock_logger.expect :level=, nil, [Logger::WARN]
mock_logger.expect :warn, nil, ["Prometheus Exporter client is dropping message cause queue is full"]
client = PrometheusExporter::Client.new(logger: mock_logger, max_queue_size: 1)
logs = StringIO.new
logger = Logger.new(logs)
logger.level = :warn
client = PrometheusExporter::Client.new(logger: logger, max_queue_size: 1)
client.send("put a message in the queue")
client.send("put a second message in the queue to trigger the logger")
mock_logger.verify
assert_includes(logs.string, "dropping message cause queue is full")
end
end