Added another scenario for find by value

This commit is contained in:
Mike Farah 2020-02-28 15:28:37 +11:00
parent 67fb924e0e
commit 69caccd2d3

View File

@ -2019,7 +2019,7 @@ func TestReadExpression(t *testing.T) {
test.AssertResult(t, expectedOutput, result.Output) test.AssertResult(t, expectedOutput, result.Output)
} }
func TestReadFindValueCmd(t *testing.T) { func TestReadFindValueArrayCmd(t *testing.T) {
content := `- cat content := `- cat
- dog - dog
- rat - rat
@ -2037,7 +2037,7 @@ func TestReadFindValueCmd(t *testing.T) {
test.AssertResult(t, expectedOutput, result.Output) test.AssertResult(t, expectedOutput, result.Output)
} }
func TestReadFindValueDeepCmd(t *testing.T) { func TestReadFindValueDeepArrayCmd(t *testing.T) {
content := `animals: content := `animals:
- cat - cat
- dog - dog
@ -2056,6 +2056,24 @@ func TestReadFindValueDeepCmd(t *testing.T) {
test.AssertResult(t, expectedOutput, result.Output) 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) { func TestDeleteYamlArrayExpressionCmd(t *testing.T) {
content := `- name: fred content := `- name: fred
- name: cat - name: cat