mirror of https://github.com/databricks/cli.git
Loading an empty file yields a nil (#906)
## Changes Empty YAML files are valid and should return a nil-equivalent when loaded. ## Tests Tests pass.
This commit is contained in:
parent
5018059444
commit
3411b8aa37
|
@ -12,6 +12,9 @@ func LoadYAML(path string, r io.Reader) (config.Value, error) {
|
|||
dec := yaml.NewDecoder(r)
|
||||
err := dec.Decode(&node)
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
return config.NilValue, nil
|
||||
}
|
||||
return config.NilValue, err
|
||||
}
|
||||
|
||||
|
|
|
@ -28,3 +28,8 @@ func loadYAML(t *testing.T, path string) config.Value {
|
|||
assert.EqualValues(t, ref, self.AsAny())
|
||||
return self
|
||||
}
|
||||
|
||||
func TestYAMLEmpty(t *testing.T) {
|
||||
self := loadYAML(t, "testdata/empty.yml")
|
||||
assert.Equal(t, config.NilValue, self)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue