mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-14 07:08:06 +00:00
48 lines
832 B
Go
48 lines
832 B
Go
|
package yqlib
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
var keysOperatorScenarios = []expressionScenario{
|
||
|
{
|
||
|
description: "Map keys",
|
||
|
document: `{dog: woof, cat: meow}`,
|
||
|
expression: `keys`,
|
||
|
expected: []string{
|
||
|
"D0, P[], (!!seq)::- dog\n- cat\n",
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
skipDoc: true,
|
||
|
document: `{}`,
|
||
|
expression: `keys`,
|
||
|
expected: []string{
|
||
|
"D0, P[], (!!seq)::[]\n",
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
description: "Array keys",
|
||
|
document: `[apple, banana]`,
|
||
|
expression: `keys`,
|
||
|
expected: []string{
|
||
|
"D0, P[], (!!seq)::- 0\n- 1\n",
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
skipDoc: true,
|
||
|
document: `[]`,
|
||
|
expression: `keys`,
|
||
|
expected: []string{
|
||
|
"D0, P[], (!!seq)::[]\n",
|
||
|
},
|
||
|
},
|
||
|
}
|
||
|
|
||
|
func TestKeysOperatorScenarios(t *testing.T) {
|
||
|
for _, tt := range keysOperatorScenarios {
|
||
|
testScenario(t, &tt)
|
||
|
}
|
||
|
documentScenarios(t, "Keys", keysOperatorScenarios)
|
||
|
}
|