Sha256: 3da50867e166365165d678638f25daf9c468c841082c36906b9d0e1a39b6ba50
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
require 'helper' class StringScrubFilterTest < Test::Unit::TestCase include Fluent def setup Fluent::Test.setup @time = Fluent::Engine.now end CONFIG = %[ replace_char ? ] CONFIG_UNICODE_1 = %[ replace_char \uFFFD ] CONFIG_UNICODE_2 = %[ replace_char \u{FFFD} ] def create_driver(conf=CONFIG) Fluent::Test::Driver::Filter.new(Fluent::Plugin::StringScrubFilter).configure(conf) end def filter(config, msgs) d = create_driver(config) d.run(default_tag: 'test.filter') { msgs.each {|msg| d.feed(@time, msg) } } filtered = d.filtered filtered.map {|m| m[1] } end def test_filter1 orig_message = 'testtesttest' invalid_utf8 = "\xff".force_encoding('UTF-8') msg = {"message" => orig_message + invalid_utf8} filtered = filter(CONFIG, [msg]) assert_equal([{"message" => orig_message + '?'}], filtered) end def test_filter2_frozen_string orig_message = 'testtesttest' invalid_utf8 = "\xff".force_encoding('UTF-8') msg = {"message" => (orig_message + invalid_utf8).freeze} filtered = filter(CONFIG, [msg]) assert_equal([{"message" => orig_message + '?'}], filtered) def test_filter_integer orig_message = 123456789 msg = {"message" => orig_message} filtered = filter(CONFIG, [msg]) assert_equal([{"message" => orig_message}], filtered) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fluent-plugin-string-scrub-1.0.1 | test/plugin/test_filter_string-scrub.rb |