Create missing path elements

This fixes a serious error: trying to change a value on gui.someOption would add
a someOption key at root if gui doesn't exist.
This commit is contained in:
Stefan Haller
2023-06-08 09:22:42 +02:00
parent 6acabba417
commit 4461dc68b7
2 changed files with 27 additions and 5 deletions

View File

@@ -56,6 +56,14 @@ func TestUpdateYamlValue(t *testing.T) {
expectedOut: "foo:\n bar: qux\n",
expectedErr: "",
},
{
name: "nested where parents doesn't exist yet",
in: "",
path: []string{"foo", "bar", "baz"},
value: "qux",
expectedOut: "foo:\n bar:\n baz: qux\n",
expectedErr: "",
},
// Error cases
{