First failing tests extracted from dotenv

pull/1/head
John Barton (joho) 2013-07-30 11:46:52 +10:00
parent ccd8bf5602
commit 78ba83b776
5 changed files with 50 additions and 0 deletions

2
fixtures/exported.env Normal file
View File

@ -0,0 +1,2 @@
export OPTION_A=2
export OPTION_B='\n'

5
fixtures/plain.env Normal file
View File

@ -0,0 +1,5 @@
OPTION_A=1
OPTION_B=2
OPTION_C= 3
OPTION_D =4
OPTION_E = 5

8
fixtures/quoted.env Normal file
View File

@ -0,0 +1,8 @@
OPTION_A='1'
OPTION_B='2'
OPTION_C=''
OPTION_D='\n'
OPTION_E="1"
OPTION_F="2"
OPTION_G=""
OPTION_H="\n"

5
godotenv.go Normal file
View File

@ -0,0 +1,5 @@
package godotenv
func Load(filenames ...string) (err error) {
return
}

30
godotenv_test.go Normal file
View File

@ -0,0 +1,30 @@
package godotenv
import (
"os"
"testing"
)
func TestLoadPlainEnv(t *testing.T) {
envFileName := "fixtures/plain.env"
err := Load(envFileName)
if err != nil {
t.Fatalf("Error loading %v", envFileName)
}
plainValues := map[string]string{
"OPTION_A": "1",
"OPTION_B": "2",
"OPTION_C": "3",
"OPTION_D": "4",
"OPTION_E": "5",
}
for k := range plainValues {
envValue := os.Getenv(k)
v := plainValues[k]
if envValue != v {
t.Errorf("Mismatch for key '%v': expected '%v' got '%v'", k, v, envValue)
}
}
}