Parse(io.Reader) => map[string]string

This commit is contained in:
Paul Annesley
2017-08-06 17:23:28 +10:00
parent 3ddb2792f3
commit ebf1036af6
2 changed files with 48 additions and 24 deletions

View File

@ -1,6 +1,7 @@
package godotenv
import (
"bytes"
"os"
"testing"
)
@ -94,6 +95,23 @@ func TestReadPlainEnv(t *testing.T) {
}
}
func TestParse(t *testing.T) {
envMap, err := Parse(bytes.NewReader([]byte("ONE=1\nTWO='2'\nTHREE = \"3\"")))
expectedValues := map[string]string{
"ONE": "1",
"TWO": "2",
"THREE": "3",
}
if err != nil {
t.Fatalf("error parsing env: %v", err)
}
for key, value := range expectedValues {
if envMap[key] != value {
t.Errorf("expected %s to be %s, got %s", key, value, envMap[key])
}
}
}
func TestLoadDoesNotOverride(t *testing.T) {
envFileName := "fixtures/plain.env"