yq/pkg/yqlib/operator_split_document_test.go

33 lines
651 B
Go
Raw Permalink Normal View History

2021-01-14 03:25:31 +00:00
package yqlib
import (
"testing"
)
var splitDocOperatorScenarios = []expressionScenario{
{
description: "Split empty",
document: ``,
expression: `split_doc`,
2021-01-14 03:25:31 +00:00
expected: []string{
"D0, P[], (!!null)::\n",
},
},
{
description: "Split array",
document: `[{a: cat}, {b: dog}]`,
expression: `.[] | split_doc`,
2021-01-14 03:25:31 +00:00
expected: []string{
"D0, P[0], (!!map)::{a: cat}\n",
"D1, P[1], (!!map)::{b: dog}\n",
},
},
}
func TestSplitDocOperatorScenarios(t *testing.T) {
for _, tt := range splitDocOperatorScenarios {
testScenario(t, &tt)
}
2021-12-21 04:02:07 +00:00
documentOperatorScenarios(t, "split-into-documents", splitDocOperatorScenarios)
2021-01-14 03:25:31 +00:00
}