Commit 4ef61a71 authored by Adnan Abdulhussein's avatar Adnan Abdulhussein

fix(chartutil): Ensure ReadValues doesn't return a nil map

parent da2f7e96
......@@ -110,9 +110,9 @@ func tableLookup(v Values, simple string) (Values, error) {
// ReadValues will parse YAML byte data into a Values.
func ReadValues(data []byte) (vals Values, err error) {
vals = make(map[string]interface{})
if len(data) > 0 {
err = yaml.Unmarshal(data, &vals)
err = yaml.Unmarshal(data, &vals)
if len(vals) == 0 {
vals = Values{}
}
return
}
......
......@@ -53,6 +53,18 @@ water:
t.Fatalf("Error parsing bytes: %s", err)
}
matchValues(t, data)
tests := []string{`poet: "Coleridge"`, "# Just a comment", ""}
for _, tt := range tests {
data, err = ReadValues([]byte(tt))
if err != nil {
t.Fatalf("Error parsing bytes: %s", err)
}
if data == nil {
t.Errorf(`YAML string "%s" gave a nil map`, tt)
}
}
}
func TestReadValuesFile(t *testing.T) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment