mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-13 22:38:04 +00:00
40 lines
779 B
Go
40 lines
779 B
Go
package yqlib
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
var deleteOperatorScenarios = []expressionScenario{
|
|
{
|
|
description: "Delete entry in map",
|
|
document: `{a: cat, b: dog}`,
|
|
expression: `del(.b)`,
|
|
expected: []string{
|
|
"D0, P[], (doc)::{a: cat}\n",
|
|
},
|
|
},
|
|
{
|
|
description: "Delete entry in array",
|
|
document: `[1,2,3]`,
|
|
expression: `del(.[1])`,
|
|
expected: []string{
|
|
"D0, P[], (doc)::[1, 3]\n",
|
|
},
|
|
},
|
|
{
|
|
description: "Delete no matches",
|
|
document: `{a: cat, b: dog}`,
|
|
expression: `del(.c)`,
|
|
expected: []string{
|
|
"D0, P[], (doc)::{a: cat, b: dog}\n",
|
|
},
|
|
},
|
|
}
|
|
|
|
func TestDeleteOperatorScenarios(t *testing.T) {
|
|
for _, tt := range deleteOperatorScenarios {
|
|
testScenario(t, &tt)
|
|
}
|
|
documentScenarios(t, "Delete Operator", deleteOperatorScenarios)
|
|
}
|