mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
parent
df67763f43
commit
1a095fccb9
2 changed files with 9 additions and 2 deletions
|
@ -46,7 +46,7 @@ module LogStash::Util
|
|||
|
||||
def del(accessor)
|
||||
target, key = lookup(accessor)
|
||||
target.delete(key)
|
||||
target.is_a?(Array) ? target.delete_at(key.to_i) : target.delete(key)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -161,7 +161,14 @@ describe LogStash::Util::Accessors, :if => true do
|
|||
insist { accessors.get("[hello][world][0][a]") } == data["hello"]["world"][0]["a"]
|
||||
insist { accessors.get("[hello][world][1][b]") } == data["hello"]["world"][1]["b"]
|
||||
end
|
||||
end
|
||||
|
||||
it "should handle delete of array element" do
|
||||
str = "[geocoords][0]"
|
||||
data = { "geocoords" => [4, 2] }
|
||||
accessors = LogStash::Util::Accessors.new(data)
|
||||
insist { accessors.del(str) } == 4
|
||||
insist { data } == { "geocoords" => [2] }
|
||||
end end
|
||||
|
||||
context "using invalid encoding" do
|
||||
it "strinct_set should raise on non UTF-8 string encoding" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue