Skip to content
This repository was archived by the owner on Jan 12, 2022. It is now read-only.

Commit 33977c2

Browse files
author
Takumasa Sakao
committed
Add test for substitutions
1 parent 9be76b3 commit 33977c2

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

fixtures/substitutions.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
OPTION_A=1
2+
OPTION_B=${OPTION_A}
3+
OPTION_C=$OPTION_B
4+
OPTION_D=${OPTION_A}${OPTION_B}
5+
OPTION_E=${OPTION_NOT_DEFINED}

godotenv_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,19 @@ func TestLoadQuotedEnv(t *testing.T) {
193193
loadEnvAndCompareValues(t, Load, envFileName, expectedValues, noopPresets)
194194
}
195195

196+
func TestSubstituitions(t *testing.T) {
197+
envFileName := "fixtures/substitutions.env"
198+
expectedValues := map[string]string{
199+
"OPTION_A": "1",
200+
"OPTION_B": "1",
201+
"OPTION_C": "1",
202+
"OPTION_D": "11",
203+
"OPTION_E": "",
204+
}
205+
206+
loadEnvAndCompareValues(t, Load, envFileName, expectedValues, noopPresets)
207+
}
208+
196209
func TestActualEnvVarsAreLeftAlone(t *testing.T) {
197210
os.Clearenv()
198211
os.Setenv("OPTION_A", "actualenv")

0 commit comments

Comments
 (0)