forked from coop-cloud-mirrors/godotenv
Start porting over parser tests.
This commit is contained in:
parent
d8dfdb69b3
commit
919c161945
@ -5,6 +5,13 @@ import (
|
|||||||
"testing"
|
"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) {
|
func loadEnvAndCompareValues(t *testing.T, envFileName string, expectedValues map[string]string) {
|
||||||
err := Load(envFileName)
|
err := Load(envFileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -39,3 +46,8 @@ func TestLoadPlainEnv(t *testing.T) {
|
|||||||
|
|
||||||
loadEnvAndCompareValues(t, envFileName, plainValues)
|
loadEnvAndCompareValues(t, envFileName, plainValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParsing(t *testing.T) {
|
||||||
|
// unquoted values
|
||||||
|
parseAndCompare(t, "FOO=bar", "FOO", "bar")
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user