Start porting over parser tests.

This commit is contained in:
John Barton (joho) 2013-07-30 18:15:58 +10:00
parent d8dfdb69b3
commit 919c161945

View File

@ -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")
}