forked from coop-cloud-mirrors/godotenv
First failing tests extracted from dotenv
This commit is contained in:
2
fixtures/exported.env
Normal file
2
fixtures/exported.env
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export OPTION_A=2
|
||||||
|
export OPTION_B='\n'
|
5
fixtures/plain.env
Normal file
5
fixtures/plain.env
Normal 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
8
fixtures/quoted.env
Normal 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
5
godotenv.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package godotenv
|
||||||
|
|
||||||
|
func Load(filenames ...string) (err error) {
|
||||||
|
return
|
||||||
|
}
|
30
godotenv_test.go
Normal file
30
godotenv_test.go
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user