add godotenv.Read() which returns a map rather than calling os.Setenv

This commit is contained in:
John Barton (joho)
2013-09-04 12:40:17 +10:00
parent 38f18b8248
commit 6e333bd708
3 changed files with 82 additions and 5 deletions

View File

@ -44,6 +44,32 @@ func TestLoadFileNotFound(t *testing.T) {
}
}
func TestReadPlainEnv(t *testing.T) {
envFileName := "fixtures/plain.env"
expectedValues := map[string]string{
"OPTION_A": "1",
"OPTION_B": "2",
"OPTION_C": "3",
"OPTION_D": "4",
"OPTION_E": "5",
}
envMap, err := Read(envFileName)
if err != nil {
t.Error("Error reading file")
}
if len(envMap) != len(expectedValues) {
t.Error("Didn't get the right size map back")
}
for key, value := range expectedValues {
if envMap[key] != value {
t.Error("Read got one of the keys wrong")
}
}
}
func TestLoadPlainEnv(t *testing.T) {
envFileName := "fixtures/plain.env"
expectedValues := map[string]string{