-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1420 from fluent/json-formatter-without-nl
formatter: Add add_newline parameter to remove '\n' from the result
- Loading branch information
Showing
8 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require_relative '../helper' | ||
require 'fluent/test/driver/formatter' | ||
require 'fluent/plugin/formatter_hash' | ||
|
||
class HashFormatterTest < ::Test::Unit::TestCase | ||
def setup | ||
@time = event_time | ||
end | ||
|
||
def create_driver(conf = "") | ||
Fluent::Test::Driver::Formatter.new(Fluent::Plugin::HashFormatter).configure(conf) | ||
end | ||
|
||
def tag | ||
"tag" | ||
end | ||
|
||
def record | ||
{'message' => 'awesome', 'greeting' => 'hello'} | ||
end | ||
|
||
def test_format | ||
d = create_driver({}) | ||
formatted = d.instance.format(tag, @time, record) | ||
|
||
assert_equal(%Q!{"message"=>"awesome", "greeting"=>"hello"}\n!, formatted.encode(Encoding::UTF_8)) | ||
end | ||
|
||
def test_format_without_newline | ||
d = create_driver('add_newline' => false) | ||
formatted = d.instance.format(tag, @time, record) | ||
|
||
assert_equal(%Q!{"message"=>"awesome", "greeting"=>"hello"}!, formatted.encode(Encoding::UTF_8)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters