Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
racinmat committed Mar 31, 2020
1 parent d33c9e3 commit 70108de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/schema.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ end
function suggestextractor(node::ArrayEntry, settings = NamedTuple())
if isempty(node)
@error "empty array, can not suggest extractor"
return nothing
end
e = suggestextractor(node.items, settings)
isnothing(e) ? e : ExtractArray(e)
Expand Down Expand Up @@ -182,6 +183,9 @@ function suggestextractor(e::DictEntry, settings = NamedTuple())
ks = filter(k -> updated(e.childs[k]) > mincount, keys(e.childs))
# to omit empty lists by default
ks = filter(k->!isempty(e.childs[k]), keys(e.childs))
for k in filter(k->isempty(e.childs[k]), keys(e.childs))
@warn "key $k contains empty array, skipping"
end
isempty(ks) && return nothing
c = [(k,suggestextractor(e.childs[k], settings)) for k in ks]
c = filter(s -> s[2] != nothing, c)
Expand Down
2 changes: 1 addition & 1 deletion test/schema.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ end

@testset "Fail empty bag extractor" begin
ex = JsonGrinder.newentry([])
@test_throws ArgumentError suggestextractor(ex)
@test isnothing(suggestextractor(ex))
end

@testset "delete in path" begin
Expand Down

0 comments on commit 70108de

Please sign in to comment.