mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-19 15:53:15 +02:00
fix(maputil): prevent nil value overwrite (#1755)
Signed-off-by: zhengbayi <ban11111@qq.com> Co-authored-by: zhengbayi <zhengbaiyi@sensetime.com>
This commit is contained in:
@@ -215,6 +215,10 @@ func TestMapUtil_MergeMaps(t *testing.T) {
|
||||
"app1": 3,
|
||||
},
|
||||
}
|
||||
map5 := map[string]interface{}{
|
||||
"logLevel": "error",
|
||||
"replicaCount": nil,
|
||||
}
|
||||
|
||||
testMap := MergeMaps(map2, map4)
|
||||
equal := reflect.DeepEqual(testMap, map4)
|
||||
@@ -247,4 +251,17 @@ func TestMapUtil_MergeMaps(t *testing.T) {
|
||||
if !equal {
|
||||
t.Errorf("Expected a map with different keys to merge properly with another map. Expected: %v, got %v", expectedMap, testMap)
|
||||
}
|
||||
|
||||
testMap = MergeMaps(map3, map5)
|
||||
expectedMap = map[string]interface{}{
|
||||
"logLevel": "error",
|
||||
"replicaCount": map[string]any{
|
||||
"app1": 3,
|
||||
"awesome": 4,
|
||||
},
|
||||
}
|
||||
equal = reflect.DeepEqual(testMap, expectedMap)
|
||||
if !equal {
|
||||
t.Errorf("Expected a map with empty value not to overwrite another map's value. Expected: %v, got %v", expectedMap, testMap)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user