added lib_test.go

This commit is contained in:
Mikhail Katychev 2021-01-12 13:29:05 -06:00 committed by Mike Farah
parent 9ae03e0a1c
commit e6336bcb85

39
pkg/yqlib/lib_test.go Normal file
View File

@ -0,0 +1,39 @@
package yqlib
import (
"testing"
"github.com/mikefarah/yq/v4/test"
)
var evaluateNodesScenario = []expressionScenario{
{
document: `a: hello`,
expression: `.a`,
expected: []string{
"D0, P[a], (!!str)::hello\n",
},
},
{
document: `a: hello`,
expression: `.`,
expected: []string{
"D0, P[], (doc)::a: hello\n",
},
},
{
document: `- a: "yes"`,
expression: `.[] | has("a")`,
expected: []string{
"D0, P[0], (!!bool)::true\n",
},
},
}
func TestEvaluateNodesScenarios(t *testing.T) {
for _, tt := range evaluateNodesScenario {
node := test.ParseData(tt.document)
list, _ := EvaluateNodes(tt.expression, &node)
test.AssertResultComplex(t, tt.expected, resultsToString(list))
}
}