test/plugin/test_out_http.rb in fluent-plugin-out-http-1.1.4 vs test/plugin/test_out_http.rb in fluent-plugin-out-http-1.1.5
- old
+ new
@@ -102,10 +102,12 @@
if req.content_type == 'application/json'
record[:json] = Yajl.load(req.body)
elsif req.content_type == 'text/plain'
puts req
record[:data] = req.body
+ elsif req.content_type == 'application/octet-stream'
+ record[:data] = req.body
else
record[:form] = Hash[*(req.body.split('&').map{|kv|kv.split('=')}.flatten)]
end
instance_variable_get("@#{req.request_method.downcase}s").push(record)
@@ -217,10 +219,15 @@
CONFIG_TEXT = %[
endpoint_url http://127.0.0.1:#{port}/api/
serializer text
]
+ CONFIG_RAW = %[
+ endpoint_url http://127.0.0.1:#{port}/api/
+ serializer raw
+ ]
+
CONFIG_PUT = %[
endpoint_url http://127.0.0.1:#{port}/api/
http_method put
]
@@ -465,9 +472,21 @@
d.feed({ "message" => "hello" })
end
assert_equal 1, @posts.size
record = @posts[0]
assert_equal 'hello', record[:data]
+ assert_nil record[:auth]
+ end
+
+ def test_emit_raw
+ binary_string = "\xe3\x81\x82"
+ d = create_driver CONFIG_RAW + %[format msgpack]
+ d.run(default_tag: 'test.metrics') do
+ d.feed({ "message" => "hello" })
+ end
+ assert_equal 1, @posts.size
+ record = @posts[0]
+ assert_equal ({ "message" => "hello" }).to_msgpack, record[:data]
assert_nil record[:auth]
end
def test_http_error_is_raised
d = create_driver CONFIG_HTTP_ERROR