From cd5715cfc62a9354911ab8be5a83f01d41bda8ab Mon Sep 17 00:00:00 2001 From: Adam Eijdenberg Date: Fri, 16 Aug 2019 12:47:36 +1000 Subject: [PATCH] Add test for subchart with null value Signed-off-by: Adam Eijdenberg --- pkg/chartutil/values_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pkg/chartutil/values_test.go b/pkg/chartutil/values_test.go index dfb38387e..04b507fbc 100644 --- a/pkg/chartutil/values_test.go +++ b/pkg/chartutil/values_test.go @@ -643,3 +643,35 @@ func TestOverriteTableItemWithNonTableValue(t *testing.T) { t.Errorf("Expected %v, but got %v", expected, result) } } + +func TestSubchartCoaleseWithNullValue(t *testing.T) { + v, err := CoalesceValues(&chart.Chart{ + Metadata: &chart.Metadata{Name: "demo"}, + Dependencies: []*chart.Chart{ + { + Metadata: &chart.Metadata{Name: "logstash"}, + Values: &chart.Config{ + Raw: `livenessProbe: {httpGet: {path: "/", port: monitor}}`, + }, + }, + }, + Values: &chart.Config{ + Raw: `logstash: {livenessProbe: {httpGet: null, exec: "/bin/true"}}`, + }, + }, &chart.Config{}) + if err != nil { + t.Errorf("Failed with %s", err) + } + result := v.AsMap() + expected := map[string]interface{}{ + "logstash": map[string]interface{}{ + "global": map[string]interface{}{}, + "livenessProbe": map[string]interface{}{ + "exec": "/bin/true", + }, + }, + } + if !reflect.DeepEqual(result, expected) { + t.Errorf("got %+v, expected %+v", result, expected) + } +}