2021-01-14 03:25:31 +00:00
|
|
|
package yqlib
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
var splitDocOperatorScenarios = []expressionScenario{
|
|
|
|
{
|
|
|
|
description: "Split empty",
|
|
|
|
document: ``,
|
2022-02-10 22:05:17 +00:00
|
|
|
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}]`,
|
2022-02-10 22:05:17 +00:00
|
|
|
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
|
|
|
}
|