diff --git a/fixtures/comments.env b/fixtures/comments.env new file mode 100644 index 0000000..af9781f --- /dev/null +++ b/fixtures/comments.env @@ -0,0 +1,4 @@ +# Full line comment +foo=bar # baz +bar=foo#baz +baz="foo"#bar diff --git a/godotenv_test.go b/godotenv_test.go index 05aaca8..017d6b6 100644 --- a/godotenv_test.go +++ b/godotenv_test.go @@ -461,6 +461,17 @@ func TestErrorParsing(t *testing.T) { } } +func TestComments(t *testing.T) { + envFileName := "fixtures/comments.env" + expectedValues := map[string]string{ + "foo": "bar", + "bar": "foo#baz", + "baz": "foo", + } + + loadEnvAndCompareValues(t, Load, envFileName, expectedValues, noopPresets) +} + func TestWrite(t *testing.T) { writeAndCompare := func(env string, expected string) { envMap, _ := Unmarshal(env)