From 89f85341a2696acff6aabc3e4d9123a9f179cb51 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Wed, 12 Aug 2020 15:50:30 +0300 Subject: [PATCH] Updated console help regex --- console/command_executer.go | 2 +- console/command_executer_test.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/console/command_executer.go b/console/command_executer.go index ca2e5ded3..c3b10adb4 100644 --- a/console/command_executer.go +++ b/console/command_executer.go @@ -33,7 +33,7 @@ import ( var ( lineR = regexp.MustCompile(`(\w+)\s*=\s*(\[.*?\]|\".*?\"|\{.*?\}|.+?)(?:\s+|$)`) - jsonR = regexp.MustCompile(`"(\w+)":(\[.+?\]|.+?)[,|}]`) + jsonR = regexp.MustCompile(`"(\w+)":(\[.+?\]|.+?)(?:,|}$)`) ) // Commander implementation diff --git a/console/command_executer_test.go b/console/command_executer_test.go index 1dc2e61b1..ce66fed5d 100644 --- a/console/command_executer_test.go +++ b/console/command_executer_test.go @@ -21,6 +21,8 @@ import ( "encoding/json" "testing" "time" + + "github.com/cgrates/cgrates/utils" ) func TestToJSON(t *testing.T) { @@ -237,3 +239,17 @@ func TestGetFormatedSliceResult(t *testing.T) { t.Errorf("Expecting: %s , received: %s", expected, rply) } } + +func TestFromJSONInterestingFields2(t *testing.T) { + jsn := utils.ToJSON(&utils.TenantIDWithOpts{ + TenantID: new(utils.TenantID), + Opts: make(map[string]interface{}), + }) + + line := FromJSON([]byte(jsn), []string{"Tenant", "ID", "Opts"}) + expected := `Tenant="" ID="" Opts={}` + if line != expected { + t.Log(jsn) + t.Errorf("Expected: %s got: '%s'", expected, line) + } +}