yq/pkg/yqlib/operator_shuffle_test.go
Mike Farah 13d1bbb45f
Generic ast (#1829)
Remove dependency on yaml.Node for internal AST representation. Yaml decoder is now just another decoder.
2023-10-18 12:11:53 +11:00

31 lines
650 B
Go

package yqlib
import "testing"
var shuffleOperatorScenarios = []expressionScenario{
{
description: "Shuffle array",
document: "[1, 2, 3, 4, 5]",
expression: `shuffle`,
expected: []string{
"D0, P[], (!!seq)::[5, 2, 4, 1, 3]\n",
},
},
{
description: "Shuffle array in place",
document: "cool: [1, 2, 3, 4, 5]",
expression: `.cool |= shuffle`,
expected: []string{
"D0, P[], (!!map)::cool: [5, 2, 4, 1, 3]\n",
},
},
}
func TestShuffleByOperatorScenarios(t *testing.T) {
for _, tt := range shuffleOperatorScenarios {
testScenario(t, &tt)
}
documentOperatorScenarios(t, "shuffle", shuffleOperatorScenarios)
}