From 69caccd2d3f5263a3f781dddd849d3cec9505f58 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Fri, 28 Feb 2020 15:28:37 +1100 Subject: [PATCH] Added another scenario for find by value --- cmd/commands_test.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/cmd/commands_test.go b/cmd/commands_test.go index 10e85ad..e26b974 100644 --- a/cmd/commands_test.go +++ b/cmd/commands_test.go @@ -2019,7 +2019,7 @@ func TestReadExpression(t *testing.T) { test.AssertResult(t, expectedOutput, result.Output) } -func TestReadFindValueCmd(t *testing.T) { +func TestReadFindValueArrayCmd(t *testing.T) { content := `- cat - dog - rat @@ -2037,7 +2037,7 @@ func TestReadFindValueCmd(t *testing.T) { test.AssertResult(t, expectedOutput, result.Output) } -func TestReadFindValueDeepCmd(t *testing.T) { +func TestReadFindValueDeepArrayCmd(t *testing.T) { content := `animals: - cat - dog @@ -2056,6 +2056,24 @@ func TestReadFindValueDeepCmd(t *testing.T) { test.AssertResult(t, expectedOutput, result.Output) } +func TestReadFindValueDeepObjectCmd(t *testing.T) { + content := `animals: + great: yes + small: sometimes +` + filename := test.WriteTempYamlFile(content) + defer test.RemoveTempYamlFile(filename) + cmd := getRootCommand() + result := test.RunCmd(cmd, fmt.Sprintf("r %s animals(.==yes) -ppv", filename)) + if result.Error != nil { + t.Error(result.Error) + } + + expectedOutput := `animals.great: yes +` + test.AssertResult(t, expectedOutput, result.Output) +} + func TestDeleteYamlArrayExpressionCmd(t *testing.T) { content := `- name: fred - name: cat