Tests for bugfix: Override subcharts with null values #12879

- Add consistency for null test in given values, parent chart, subchart, and
  sub-sub-chart
- Remove bar null test to keep consistent with boat=null at top level

Signed-off-by: Scott Rigby <scott@r6by.com>
pull/12879/head
Scott Rigby 9 months ago committed by Ryan Hockstad
parent 5a58751a05
commit 60fcce18d1

@ -44,6 +44,7 @@ global:
boat: true boat: true
pequod: pequod:
boat: null
global: global:
name: Stinky name: Stinky
harpooner: Tashtego harpooner: Tashtego
@ -55,7 +56,7 @@ pequod:
boat: null boat: null
nested: nested:
foo: true foo: true
bar: null boat: null
`) `)
func withDeps(c *chart.Chart, deps ...*chart.Chart) *chart.Chart { func withDeps(c *chart.Chart, deps ...*chart.Chart) *chart.Chart {
@ -82,6 +83,13 @@ func TestCoalesceValues(t *testing.T) {
"global": map[string]interface{}{ "global": map[string]interface{}{
"nested2": map[string]interface{}{"l0": "moby"}, "nested2": map[string]interface{}{"l0": "moby"},
}, },
"pequod": map[string]interface{}{
"boat": "maybe",
"ahab": map[string]interface{}{
"boat": "maybe",
"nested": map[string]interface{}{"boat": "maybe"},
},
},
}, },
}, },
withDeps(&chart.Chart{ withDeps(&chart.Chart{
@ -92,6 +100,11 @@ func TestCoalesceValues(t *testing.T) {
"global": map[string]interface{}{ "global": map[string]interface{}{
"nested2": map[string]interface{}{"l1": "pequod"}, "nested2": map[string]interface{}{"l1": "pequod"},
}, },
"boat": false,
"ahab": map[string]interface{}{
"boat": false,
"nested": map[string]interface{}{"boat": false},
},
}, },
}, },
&chart.Chart{ &chart.Chart{
@ -104,7 +117,7 @@ func TestCoalesceValues(t *testing.T) {
"scope": "ahab", "scope": "ahab",
"name": "ahab", "name": "ahab",
"boat": true, "boat": true,
"nested": map[string]interface{}{"foo": false, "bar": true}, "nested": map[string]interface{}{"foo": false, "boat": true},
}, },
}, },
), ),
@ -200,13 +213,18 @@ func TestCoalesceValues(t *testing.T) {
t.Error("Expected nested boat key to be removed, still present") t.Error("Expected nested boat key to be removed, still present")
} }
subchart := v["pequod"].(map[string]interface{})["ahab"].(map[string]interface{}) subchart := v["pequod"].(map[string]interface{})
if _, ok := subchart["boat"]; ok { if _, ok := subchart["boat"]; ok {
t.Error("Expected subchart boat key to be removed, still present") t.Error("Expected subchart boat key to be removed, still present")
} }
if _, ok := subchart["nested"].(map[string]interface{})["bar"]; ok { subsubchart := subchart["ahab"].(map[string]interface{})
t.Error("Expected subchart nested bar key to be removed, still present") if _, ok := subsubchart["boat"]; ok {
t.Error("Expected sub-subchart ahab boat key to be removed, still present")
}
if _, ok := subsubchart["nested"].(map[string]interface{})["boat"]; ok {
t.Error("Expected sub-subchart nested boat key to be removed, still present")
} }
// CoalesceValues should not mutate the passed arguments // CoalesceValues should not mutate the passed arguments

Loading…
Cancel
Save