Sha256: 2725b4405eba81afcb4c682faa6b07baf0ebd023a2bcc2a46f590a941672c59a
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
# frozen_string_literal: true require 'test_helper' require 'statsd/instrument/client' class CaptureSinktest < Minitest::Test def test_capture_sink_captures_datagram_instances capture_sink = StatsD::Instrument::CaptureSink.new(parent: []) capture_sink << 'foo:1|c' assert_equal 1, capture_sink.datagrams.length assert_kind_of StatsD::Instrument::Datagram, capture_sink.datagrams.first assert_equal 'foo:1|c', capture_sink.datagrams.first.source end def test_capture_sink_sends_datagrams_to_parent parent = [] capture_sink = StatsD::Instrument::CaptureSink.new(parent: parent) capture_sink << 'foo:1|c' << 'bar:1|c' assert_equal ['foo:1|c', 'bar:1|c'], parent end def test_nesting_capture_sink_instances null_sink = StatsD::Instrument::NullSink.new outer_capture_sink = StatsD::Instrument::CaptureSink.new(parent: null_sink) inner_capture_sink = StatsD::Instrument::CaptureSink.new(parent: outer_capture_sink) outer_capture_sink << 'foo:1|c' inner_capture_sink << 'bar:1|c' assert_equal ['foo:1|c', 'bar:1|c'], outer_capture_sink.datagrams.map(&:source) assert_equal ['bar:1|c'], inner_capture_sink.datagrams.map(&:source) end def test_using_a_different_datagram_class sink = StatsD::Instrument::CaptureSink.new(parent: [], datagram_class: String) sink << 'foo:1|c' assert sink.datagrams.all? { |datagram| datagram.is_a?(String) } assert_equal ['foo:1|c'], sink.datagrams end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
statsd-instrument-2.6.0 | test/capture_sink_test.rb |