1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

Splat array is now the fallback instead of parsing int

This commit is contained in:
Mike Farah
2020-01-30 15:11:47 +11:00
parent 4a5bd0ff5b
commit 4dbe3636c2
3 changed files with 22 additions and 21 deletions

View File

@@ -438,21 +438,21 @@ true`
func TestReadCmd_ArrayYaml_ErrorBadPath(t *testing.T) {
cmd := getRootCommand()
result := test.RunCmd(cmd, "read ../examples/array.yaml [x].gather_facts")
if result.Error == nil {
t.Error("Expected command to fail due to missing arg")
if result.Error != nil {
t.Error(result.Error)
}
expectedOutput := `Error reading path in document index 0: Error parsing array index 'x' for '': strconv.ParseInt: parsing "x": invalid syntax`
test.AssertResult(t, expectedOutput, result.Error.Error())
expectedOutput := ``
test.AssertResult(t, expectedOutput, result.Output)
}
func TestReadCmd_ArrayYaml_Splat_ErrorBadPath(t *testing.T) {
cmd := getRootCommand()
result := test.RunCmd(cmd, "read ../examples/array.yaml [*].roles[x]")
if result.Error == nil {
t.Error("Expected command to fail due to missing arg")
if result.Error != nil {
t.Error(result.Error)
}
expectedOutput := `Error reading path in document index 0: Error parsing array index 'x' for '[0].roles': strconv.ParseInt: parsing "x": invalid syntax`
test.AssertResult(t, expectedOutput, result.Error.Error())
expectedOutput := ``
test.AssertResult(t, expectedOutput, result.Output)
}
func TestReadCmd_Error(t *testing.T) {
@@ -505,8 +505,11 @@ func TestReadCmd_ErrorBadPath(t *testing.T) {
cmd := getRootCommand()
result := test.RunCmd(cmd, fmt.Sprintf("read %s b.d.*.[x]", filename))
expectedOutput := `Error reading path in document index 0: Error parsing array index 'x' for 'b.d.e': strconv.ParseInt: parsing "x": invalid syntax`
test.AssertResult(t, expectedOutput, result.Error.Error())
if result.Error != nil {
t.Error(result.Error)
}
expectedOutput := ``
test.AssertResult(t, expectedOutput, result.Output)
}
func TestReadCmd_Verbose(t *testing.T) {