mirror of
https://github.com/joho/godotenv.git
synced 2025-06-25 20:34:02 +00:00
Parse(io.Reader) => map[string]string
This commit is contained in:
@ -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"
|
||||
|
||||
|
Reference in New Issue
Block a user