From 919c16194535565aefd874e2e64307d87b9a9f1d Mon Sep 17 00:00:00 2001 From: "John Barton (joho)" Date: Tue, 30 Jul 2013 18:15:58 +1000 Subject: [PATCH] Start porting over parser tests. --- godotenv_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/godotenv_test.go b/godotenv_test.go index d51b382..454a54a 100644 --- a/godotenv_test.go +++ b/godotenv_test.go @@ -5,6 +5,13 @@ import ( "testing" ) +func parseAndCompare(t *testing.T, rawEnvLine string, expectedKey string, expectedValue string) { + key, value, _ := parseLine(rawEnvLine) + if key != expectedKey || value != expectedValue { + t.Errorf("Expected '%v' to parse as '%v' => '%v', got '%v' => '%v' instead", rawEnvLine, expectedKey, expectedValue, key, value) + } +} + func loadEnvAndCompareValues(t *testing.T, envFileName string, expectedValues map[string]string) { err := Load(envFileName) if err != nil { @@ -39,3 +46,8 @@ func TestLoadPlainEnv(t *testing.T) { loadEnvAndCompareValues(t, envFileName, plainValues) } + +func TestParsing(t *testing.T) { + // unquoted values + parseAndCompare(t, "FOO=bar", "FOO", "bar") +}