mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-13 22:38:04 +00:00
48 lines
926 B
Go
48 lines
926 B
Go
package yqlib
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
var fileOperatorScenarios = []expressionScenario{
|
|
{
|
|
description: "Get filename",
|
|
document: `{a: cat}`,
|
|
expression: `filename`,
|
|
expected: []string{
|
|
"D0, P[], (!!str)::sample.yml\n",
|
|
},
|
|
},
|
|
{
|
|
description: "Get file index",
|
|
document: `{a: cat}`,
|
|
expression: `fileIndex`,
|
|
expected: []string{
|
|
"D0, P[], (!!int)::0\n",
|
|
},
|
|
},
|
|
{
|
|
description: "Get file index alias",
|
|
document: `{a: cat}`,
|
|
expression: `fi`,
|
|
expected: []string{
|
|
"D0, P[], (!!int)::0\n",
|
|
},
|
|
},
|
|
{
|
|
skipDoc: true,
|
|
document: "a: cat\nb: dog",
|
|
expression: `.. lineComment |= filename`,
|
|
expected: []string{
|
|
"D0, P[], (!!map)::a: cat # sample.yml\nb: dog # sample.yml\n",
|
|
},
|
|
},
|
|
}
|
|
|
|
func TestFileOperatorsScenarios(t *testing.T) {
|
|
for _, tt := range fileOperatorScenarios {
|
|
testScenario(t, &tt)
|
|
}
|
|
documentScenarios(t, "File Operators", fileOperatorScenarios)
|
|
}
|