2020-11-20 11:57:32 +00:00
|
|
|
package yqlib
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
var fileOperatorScenarios = []expressionScenario{
|
|
|
|
{
|
|
|
|
description: "Get filename",
|
2020-11-20 12:08:12 +00:00
|
|
|
document: `{a: cat}`,
|
2020-11-20 11:57:32 +00:00
|
|
|
expression: `filename`,
|
|
|
|
expected: []string{
|
|
|
|
"D0, P[], (!!str)::sample.yml\n",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
description: "Get file index",
|
2020-11-20 12:08:12 +00:00
|
|
|
document: `{a: cat}`,
|
2020-11-20 11:57:32 +00:00
|
|
|
expression: `fileIndex`,
|
|
|
|
expected: []string{
|
|
|
|
"D0, P[], (!!int)::0\n",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFileOperatorsScenarios(t *testing.T) {
|
|
|
|
for _, tt := range fileOperatorScenarios {
|
|
|
|
testScenario(t, &tt)
|
|
|
|
}
|
|
|
|
documentScenarios(t, "File Operators", fileOperatorScenarios)
|
|
|
|
}
|