Merged envsubst into env operators

This commit is contained in:
Mike Farah
2022-01-27 09:20:53 +11:00
parent 8195ff8b9b
commit a9e7f669d0
8 changed files with 134 additions and 147 deletions
+33
View File
@@ -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) {