From d8a2804f88aaadeb2498d903470d770e0670598a Mon Sep 17 00:00:00 2001 From: Ulysses Souza Date: Sat, 23 Mar 2024 21:42:35 +0100 Subject: [PATCH] Add new test cases Signed-off-by: Ulysses Souza --- envlang_test.go | 15 +++++++++++++++ handlers/filehandler.go | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/envlang_test.go b/envlang_test.go index 0cd2f7f..a9805d2 100644 --- a/envlang_test.go +++ b/envlang_test.go @@ -246,6 +246,7 @@ A = "aaa ${B} ccc " } } +//nolint:funlen func TestFull(t *testing.T) { log.SetLevel(log.DebugLevel) is := ` @@ -300,6 +301,14 @@ SPECIAL4 = "{{{ $ $ $}}}" SPECIAL5 = "{{{ $$ }}}" SPECIAL6 = "{{{ $$$ }}}" +SPECIAL_CHAR_A=unquoted phrase special ã char +SPECIAL_CHAR_C=unquoted phrase special ç char +SPECIAL_CHAR_E=unquoted phrase special è char + +VAR-WITH-DASHES="dashes" +VAR.WITH.DOTS="dots" +VAR_WITH_UNDERSCORES="underscores" + EMPTY_VAR="" VAR_DEFAULT_UNSET = "${UNSET_VAR-uuu}" @@ -341,6 +350,12 @@ export EQUALS='postgres://localhost:5432/database?sslmode=disable' "OPTION_B": strPtr("\\n"), "EQUALS": strPtr("postgres://localhost:5432/database?sslmode=disable"), "VAR_TO_BE_LOADED_FROM_OS_ENV": strPtr("loaded_from_os_env"), + "VAR-WITH-DASHES": strPtr("dashes"), + "VAR.WITH.DOTS": strPtr("dots"), + "VAR_WITH_UNDERSCORES": strPtr("underscores"), + "SPECIAL_CHAR_A": strPtr("unquoted phrase special ã char"), + "SPECIAL_CHAR_C": strPtr("unquoted phrase special ç char"), + "SPECIAL_CHAR_E": strPtr("unquoted phrase special è char"), } d := dao.NewDefaultDaoFromMap(map[string]*string{ diff --git a/handlers/filehandler.go b/handlers/filehandler.go index 03d544e..62a7776 100644 --- a/handlers/filehandler.go +++ b/handlers/filehandler.go @@ -41,7 +41,7 @@ func (l *EnvLangFileListener) ExitEntry(c *fileparser.EntryContext) { if strings.HasPrefix(id, "#") { return } - re := regexp.MustCompile(`^[0-9a-zA-Z_]+$`) + re := regexp.MustCompile(`^[0-9a-zA-Z_\-.]+$`) if !re.MatchString(id) { return }