Nicer error message when trying to use merge anchor tags other than maps #1184

This commit is contained in:
Mike Farah
2022-04-27 14:46:52 +10:00
parent 70ad7a35a8
commit 26529fae94
2 changed files with 18 additions and 0 deletions
+15
View File
@@ -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) {