diff --git a/cmd/commands_test.go b/cmd/commands_test.go index 1fe3692..d3bb9d5 100644 --- a/cmd/commands_test.go +++ b/cmd/commands_test.go @@ -1405,6 +1405,22 @@ b: test.AssertResult(t, expectedOutput, result.Output) } +func TestDeleteDeepDoesNotExistCmd(t *testing.T) { + content := `a: 2` + filename := test.WriteTempYamlFile(content) + defer test.RemoveTempYamlFile(filename) + + cmd := getRootCommand() + result := test.RunCmd(cmd, fmt.Sprintf("delete %s b.c", filename)) + if result.Error != nil { + t.Error(result.Error) + } + + expectedOutput := `a: 2 +` + test.AssertResult(t, expectedOutput, result.Output) +} + func TestDeleteSplatYaml(t *testing.T) { content := `a: other b: [3, 4] diff --git a/pkg/yqlib/delete_navigation_strategy.go b/pkg/yqlib/delete_navigation_strategy.go index de51e30..cff9a42 100644 --- a/pkg/yqlib/delete_navigation_strategy.go +++ b/pkg/yqlib/delete_navigation_strategy.go @@ -15,7 +15,7 @@ func DeleteNavigationStrategy(pathElementToDelete string) NavigationStrategy { return false }, autoCreateMap: func(nodeContext NodeContext) bool { - return true + return false }, visit: func(nodeContext NodeContext) error { node := nodeContext.Node