1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

Fixed empty merge problem

This commit is contained in:
Mike Farah
2020-02-13 18:08:13 +11:00
parent 69fae2d9cb
commit 9864afc4e7
3 changed files with 45 additions and 7 deletions

View File

@@ -1581,7 +1581,7 @@ func TestWriteCmd_SplatMapEmpty(t *testing.T) {
t.Error(result.Error)
}
expectedOutput := `b:
c: thing
c: {}
d: another thing
`
test.AssertResult(t, expectedOutput, result.Output)
@@ -2009,6 +2009,25 @@ apples: red
test.AssertResult(t, expectedOutput, result.Output)
}
func TestMergeYamlNullMapCmd(t *testing.T) {
content := `b:`
filename := test.WriteTempYamlFile(content)
defer test.RemoveTempYamlFile(filename)
mergeContent := `b:
thing: a frog
`
mergeFilename := test.WriteTempYamlFile(mergeContent)
defer test.RemoveTempYamlFile(mergeFilename)
cmd := getRootCommand()
result := test.RunCmd(cmd, fmt.Sprintf("merge %s %s", filename, mergeFilename))
if result.Error != nil {
t.Error(result.Error)
}
test.AssertResult(t, mergeContent, result.Output)
}
func TestMergeCmd_Error(t *testing.T) {
cmd := getRootCommand()
result := test.RunCmd(cmd, "merge")