From 70b88fa778ededa9fbe7f2f6e118459b0fd138fb Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Mon, 3 Feb 2020 16:40:17 +1100 Subject: [PATCH] Pretty print everything test --- cmd/commands_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/cmd/commands_test.go b/cmd/commands_test.go index 97a770dd..e21d8c22 100644 --- a/cmd/commands_test.go +++ b/cmd/commands_test.go @@ -1224,6 +1224,38 @@ func TestWriteCmd_Append(t *testing.T) { test.AssertResult(t, expectedOutput, result.Output) } +func TestWriteCmd_AppendInline(t *testing.T) { + content := `b: [foo]` + filename := test.WriteTempYamlFile(content) + defer test.RemoveTempYamlFile(filename) + + cmd := getRootCommand() + result := test.RunCmd(cmd, fmt.Sprintf("write %s b[+] 7", filename)) + if result.Error != nil { + t.Error(result.Error) + } + expectedOutput := `b: [foo, 7] +` + test.AssertResult(t, expectedOutput, result.Output) +} + +func TestWriteCmd_AppendInlinePretty(t *testing.T) { + content := `b: [foo]` + filename := test.WriteTempYamlFile(content) + defer test.RemoveTempYamlFile(filename) + + cmd := getRootCommand() + result := test.RunCmd(cmd, fmt.Sprintf("write %s -P b[+] 7", filename)) + if result.Error != nil { + t.Error(result.Error) + } + expectedOutput := `b: +- foo +- 7 +` + test.AssertResult(t, expectedOutput, result.Output) +} + func TestWriteCmd_AppendEmptyArray(t *testing.T) { content := `a: 2 `