Avoid rewriting the file if nothing changed
This avoids changing the indentation or number of blank lines etc unnecessarily if nothing has changed.
This commit is contained in:
@@ -64,6 +64,14 @@ func TestUpdateYamlValue(t *testing.T) {
|
||||
expectedOut: "foo:\n bar:\n baz: qux\n",
|
||||
expectedErr: "",
|
||||
},
|
||||
{
|
||||
name: "don't rewrite file if value didn't change",
|
||||
in: "foo:\n bar: baz\n",
|
||||
path: []string{"foo", "bar"},
|
||||
value: "baz",
|
||||
expectedOut: "foo:\n bar: baz\n",
|
||||
expectedErr: "",
|
||||
},
|
||||
|
||||
// Error cases
|
||||
{
|
||||
@@ -142,6 +150,14 @@ func TestRenameYamlKey(t *testing.T) {
|
||||
expectedOut: "qux:\n bar: 5\n",
|
||||
expectedErr: "",
|
||||
},
|
||||
{
|
||||
name: "don't rewrite file if value didn't change",
|
||||
in: "foo:\n bar: 5\n",
|
||||
path: []string{"nonExistingKey"},
|
||||
newKey: "qux",
|
||||
expectedOut: "foo:\n bar: 5\n",
|
||||
expectedErr: "",
|
||||
},
|
||||
|
||||
// Error cases
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user