mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-01 14:14:52 +08:00
Nicer error message when trying to use merge anchor tags other than maps #1184
This commit is contained in:
@@ -26,6 +26,15 @@ foobar:
|
||||
thing: foobar_thing
|
||||
`
|
||||
|
||||
// cannot use merge anchors with arrays
|
||||
var badAliasSample = `
|
||||
_common: &common-docker-file
|
||||
- FROM ubuntu:18.04
|
||||
|
||||
steps:
|
||||
<<: *common-docker-file
|
||||
`
|
||||
|
||||
var traversePathOperatorScenarios = []expressionScenario{
|
||||
{
|
||||
skipDoc: true,
|
||||
@@ -529,6 +538,12 @@ var traversePathOperatorScenarios = []expressionScenario{
|
||||
"D0, P[a 2], (!!str)::c\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
skipDoc: true,
|
||||
document: badAliasSample,
|
||||
expression: ".steps[]",
|
||||
expectedError: "can only use merge anchors with maps (!!map), but got !!seq",
|
||||
},
|
||||
}
|
||||
|
||||
func TestTraversePathOperatorScenarios(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user