From f5c3beb15981712ff7c60c40b2ddba1e4fbc6599 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Tue, 18 Feb 2020 20:02:09 +1100 Subject: [PATCH] Added test for https://github.com/mikefarah/yq/issues/361 --- cmd/commands_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cmd/commands_test.go b/cmd/commands_test.go index d66ef87b..8f4f8b62 100644 --- a/cmd/commands_test.go +++ b/cmd/commands_test.go @@ -1279,6 +1279,26 @@ func TestWriteEmptyCmd(t *testing.T) { test.AssertResult(t, expectedOutput, result.Output) } +func TestWriteAutoCreateCmd(t *testing.T) { + content := `applications: + - name: app + env:` + filename := test.WriteTempYamlFile(content) + defer test.RemoveTempYamlFile(filename) + + cmd := getRootCommand() + result := test.RunCmd(cmd, fmt.Sprintf("write %s applications[0].env.hello world", filename)) + if result.Error != nil { + t.Error(result.Error) + } + expectedOutput := `applications: +- name: app + env: + hello: world +` + test.AssertResult(t, expectedOutput, result.Output) +} + func TestWriteCmdScript(t *testing.T) { content := `b: c: 3