-
Notifications
You must be signed in to change notification settings - Fork 1.4k
test_yaml_parser: add tests for YAML parser #5224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
6b2ede6 to
7575ad1
Compare
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
7575ad1 to
6399577
Compare
| File.open(path, "w:#{encoding}:utf-8") {|f| f.write data } | ||
| end | ||
|
|
||
| def test_special_yaml_elements_dollar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to group with sub_test-case
| assert_equal("match", config.elements[2].name) | ||
| assert_equal("worker", config.elements[3].name) | ||
| assert_equal("label", config.elements[4].name) | ||
| assert_equal("filter", config.elements[5].name) # included section |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be simplified with:
assert_equal(%w(source filter match worker label filter), config.elements.map(&:name))
| config = Fluent::Config::YamlParser.parse("#{TMP_DIR}/test_merge_common_parameter_using_include.yaml") | ||
| assert_equal(2, config.elements.size) | ||
| assert_equal('foobarbaz', config.elements[0].elements[0]['common_param']) | ||
| assert_equal('foobarbaz', config.elements[1].elements[0]['common_param']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elements[X].elements[Y]で参照するのはおそらく意図したものではなさそう。
現状パースエラーになるけど、以下をincludeするものとしたテストコードであるべきじゃないだろうか。
https://docs.fluentd.org/configuration/config-file-yaml#share-the-same-parameters
write_config "#{TMP_DIR}/fluent-common.yaml", <<~EOS
common_param: foobarbaz
EOS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
たとえば、テストケースのconfig.elements[0]は以下のように現状ではパースされる。
<name:match, arg:dummy_tag_1, attrs:{...}, elements:[<name:<<, arg:, attrs:{"common_param" => "foobarbaz"}, elements:[]>]>
config.elements[0].elements[0].name == '<<'になってしまっている。
Which issue(s) this PR fixes:
Fixes #
What this PR does / why we need it:
This PR will add missing yaml parser tests.
Docs Changes:
Release Note: