test/plugin/test_expander.rb in fluent-plugin-config-expander-0.1.0 vs test/plugin/test_expander.rb in fluent-plugin-config-expander-0.1.1

- old
+ new

@@ -11,10 +11,11 @@ assert_equal "", @m.replace("", {'foo' => 'bar'}) assert_equal "barbar", @m.replace("foobar", {'foo' => 'bar'}) assert_equal "foofoo", @m.replace("foobar", {'bar' => 'foo'}) assert_equal "foobar", @m.replace("foobar", {'hoge' => 'moge'}) assert_equal "xxbar", @m.replace("foofoobar", {'foo' => 'x'}) + assert_equal "xxy", @m.replace("foofoobar", {'foo' => 'x', 'bar' => 'y'}) end def test_expand e1 = Fluent::Config::Element.new('config', '', {'attr_first'=>'value_first', 'attr_second'=>'__NUM__'}, [], []) assert_equal "<config>\n attr_first value_first\n attr_second __NUM__\n</config>\n", e1.to_s @@ -126,7 +127,71 @@ port 24224 </server> </config> EOL assert_equal exconf3, @m.expand(conf3, {}).to_s + + nonexconf4 = <<EOL +<config> + type forward + flush_interval 1s + <for nodenum in 01> + <for portnum in 24221 24222 24223 24224> + <server> + host node__nodenum__.local + port ${portnum} + </server> + </for> + </for> + <for nodenum in 02> + <for portnum in 24221 24222 24223 24224> + <server> + host node${nodenum}.local + port __portnum__ + </server> + </for> + </for> +</config> +EOL + conf4 = Fluent::Config.parse(nonexconf4, 'hoge').elements.first + assert_equal nonexconf4, conf4.to_s + exconf4 = <<EOL +<config> + type forward + flush_interval 1s + <server> + host node01.local + port 24221 + </server> + <server> + host node01.local + port 24222 + </server> + <server> + host node01.local + port 24223 + </server> + <server> + host node01.local + port 24224 + </server> + <server> + host node02.local + port 24221 + </server> + <server> + host node02.local + port 24222 + </server> + <server> + host node02.local + port 24223 + </server> + <server> + host node02.local + port 24224 + </server> +</config> +EOL + assert_equal exconf4, @m.expand(conf4, {}).to_s end end