diff --git a/fixtures/substitutions.env b/fixtures/substitutions.env new file mode 100644 index 0000000..44337a9 --- /dev/null +++ b/fixtures/substitutions.env @@ -0,0 +1,5 @@ +OPTION_A=1 +OPTION_B=${OPTION_A} +OPTION_C=$OPTION_B +OPTION_D=${OPTION_A}${OPTION_B} +OPTION_E=${OPTION_NOT_DEFINED} diff --git a/godotenv_test.go b/godotenv_test.go index 475f4ec..8e75092 100644 --- a/godotenv_test.go +++ b/godotenv_test.go @@ -193,6 +193,19 @@ func TestLoadQuotedEnv(t *testing.T) { loadEnvAndCompareValues(t, Load, envFileName, expectedValues, noopPresets) } +func TestSubstituitions(t *testing.T) { + envFileName := "fixtures/substitutions.env" + expectedValues := map[string]string{ + "OPTION_A": "1", + "OPTION_B": "1", + "OPTION_C": "1", + "OPTION_D": "11", + "OPTION_E": "", + } + + loadEnvAndCompareValues(t, Load, envFileName, expectedValues, noopPresets) +} + func TestActualEnvVarsAreLeftAlone(t *testing.T) { os.Clearenv() os.Setenv("OPTION_A", "actualenv")