From 02a6516148dd6f7bba61583ba4421a5870419729 Mon Sep 17 00:00:00 2001 From: John Barton Date: Fri, 27 Jan 2023 13:00:16 +1100 Subject: [PATCH] Add a full fixture for comments for extra piece of mind --- fixtures/comments.env | 4 ++++ godotenv_test.go | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 fixtures/comments.env 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)