mirror of
https://github.com/mikefarah/yq.git
synced 2026-08-31 04:54:44 +08:00
Merged envsubst into env operators
This commit is contained in:
@@ -62,6 +62,39 @@ var envOperatorScenarios = []expressionScenario{
|
||||
"D0, P[cat], (!!str)::meow\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "Replace strings with envsubst",
|
||||
environmentVariable: "cat",
|
||||
expression: `"the ${myenv} meows" | envsubst`,
|
||||
expected: []string{
|
||||
"D0, P[], (!!str)::the cat meows\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "Replace strings with envsubst, missing variables",
|
||||
environmentVariable: "cat",
|
||||
expression: `"the ${myenvnonexisting} meows" | envsubst`,
|
||||
expected: []string{
|
||||
"D0, P[], (!!str)::the meows\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "Replace strings with envsubst, missing variables with defaults",
|
||||
environmentVariable: "cat",
|
||||
expression: `"the ${myenvnonexisting-dog} meows" | envsubst`,
|
||||
expected: []string{
|
||||
"D0, P[], (!!str)::the dog meows\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "Replace string environment variable in document",
|
||||
environmentVariable: "cat meow",
|
||||
document: "{v: \"${myenv}\"}",
|
||||
expression: `.v |= envsubst`,
|
||||
expected: []string{
|
||||
"D0, P[], (doc)::{v: \"cat meow\"}\n",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func TestEnvOperatorScenarios(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user