Skip to content

Commit

Permalink
Version 0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-pickin-epi committed Sep 25, 2024
1 parent 9c10ac3 commit d9c3992
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.2
0.0.3
6 changes: 5 additions & 1 deletion lib/fluent/plugin/filter_flatten.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def configure(conf)

def filter(tag, time, record)
begin
flatten(record) if @enabled
if @enabled
flatten(record)
else
record
end
rescue => e
router.emit_error_event(tag, time, record, e)
end
Expand Down
21 changes: 16 additions & 5 deletions spec/filter_flatten_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ def create_filter
expect(@filter.flatten({})).to eq Hash.new
end

it "no error with disabled" do
@filter.enabled = false
test_hash = {}
test_hash["key"] = "value"
test_hash["key.dot"] = "value.dot"
expect_hash = {}
expect_hash["key"] = "value"
expect_hash["key.dot"] = "value.dot"
expect(@filter.filter("tag", "time", test_hash)).to eq expect_hash
end

it "no error with non recursive hash" do
@filter.recurse = false
test_hash = {}
Expand All @@ -41,7 +52,7 @@ def create_filter
expect_hash = {}
expect_hash["key"] = test_hash["key"]
expect_hash["key_dot"] = test_hash["key.dot"]
expect(@filter.flatten(test_hash)).to eq expect_hash
expect(@filter.filter("tag", "time", test_hash)).to eq expect_hash
end

it "no error with recursive hash with de_dot_nested = false" do
Expand All @@ -59,7 +70,7 @@ def create_filter
expect_hash = {}
expect_hash["key"] = "value"
expect_hash["child_dot"] = expect_child_hash
expect(@filter.flatten(test_hash)).to eq expect_hash
expect(@filter.filter("tag", "time", test_hash)).to eq expect_hash
end

it "no error with recursive hash with de_dot_nested = true" do
Expand All @@ -77,7 +88,7 @@ def create_filter
expect_hash = {}
expect_hash["key"] = "value"
expect_hash["child_dot"] = expect_child_hash
expect(@filter.flatten(test_hash)).to eq expect_hash
expect(@filter.filter("tag", "time", test_hash)).to eq expect_hash
end

it "no error with recursive array with de_dot_nested = false" do
Expand All @@ -103,7 +114,7 @@ def create_filter
expect_hash = {}
expect_hash["key"] = "value"
expect_hash["child_dot"] = expect_child_array
expect(@filter.flatten(test_hash)).to eq expect_hash
expect(@filter.filter("tag", "time", test_hash)).to eq expect_hash
end

it "no error with recursive array with de_dot_nested = true" do
Expand All @@ -129,7 +140,7 @@ def create_filter
expect_hash = {}
expect_hash["key"] = "value"
expect_hash["child_dot"] = expect_child_array
expect(@filter.flatten(test_hash)).to eq expect_hash
expect(@filter.filter("tag", "time", test_hash)).to eq expect_hash
end

end
Expand Down

0 comments on commit d9c3992

Please sign in to comment.