From 78ba83b776f06f652fb3f1ee7d1044199d3c5f86 Mon Sep 17 00:00:00 2001 From: "John Barton (joho)" Date: Tue, 30 Jul 2013 11:46:52 +1000 Subject: [PATCH] First failing tests extracted from dotenv --- fixtures/exported.env | 2 ++ fixtures/plain.env | 5 +++++ fixtures/quoted.env | 8 ++++++++ godotenv.go | 5 +++++ godotenv_test.go | 30 ++++++++++++++++++++++++++++++ 5 files changed, 50 insertions(+) create mode 100644 fixtures/exported.env create mode 100644 fixtures/plain.env create mode 100644 fixtures/quoted.env create mode 100644 godotenv.go create mode 100644 godotenv_test.go diff --git a/fixtures/exported.env b/fixtures/exported.env new file mode 100644 index 0000000..5821377 --- /dev/null +++ b/fixtures/exported.env @@ -0,0 +1,2 @@ +export OPTION_A=2 +export OPTION_B='\n' diff --git a/fixtures/plain.env b/fixtures/plain.env new file mode 100644 index 0000000..c983b06 --- /dev/null +++ b/fixtures/plain.env @@ -0,0 +1,5 @@ +OPTION_A=1 +OPTION_B=2 +OPTION_C= 3 +OPTION_D =4 +OPTION_E = 5 diff --git a/fixtures/quoted.env b/fixtures/quoted.env new file mode 100644 index 0000000..a03ce24 --- /dev/null +++ b/fixtures/quoted.env @@ -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" diff --git a/godotenv.go b/godotenv.go new file mode 100644 index 0000000..d667e7f --- /dev/null +++ b/godotenv.go @@ -0,0 +1,5 @@ +package godotenv + +func Load(filenames ...string) (err error) { + return +} diff --git a/godotenv_test.go b/godotenv_test.go new file mode 100644 index 0000000..d698b9a --- /dev/null +++ b/godotenv_test.go @@ -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) + } + } +}