fix(emqx_utils): use deep_merge in unindent

This commit is contained in:
Stefan Strigler 2023-12-11 14:40:24 +01:00
parent 6143b3a2be
commit be31486983
2 changed files with 5 additions and 1 deletions

View File

@ -345,7 +345,7 @@ indent(IndentKey, PickKeys, Map) ->
-spec unindent(term(), map()) -> map().
unindent(Key, Map) ->
maps:merge(
deep_merge(
maps:remove(Key, Map),
maps:get(Key, Map, #{})
).

View File

@ -170,5 +170,9 @@ map_indent_unindent_test_() ->
?_assertEqual(
#{a => 1, b => 2},
unindent(c, M)
),
?_assertEqual(
#{a => #{c => 3, d => 4}},
unindent(b, #{a => #{c => 3}, b => #{a => #{d => 4}}})
)
].