Updated console help regex

This commit is contained in:
Trial97
2020-08-12 15:50:30 +03:00
committed by Dan Christian Bogos
parent a9f0a9429b
commit 89f85341a2
2 changed files with 17 additions and 1 deletions

View File

@@ -33,7 +33,7 @@ import (
var (
lineR = regexp.MustCompile(`(\w+)\s*=\s*(\[.*?\]|\".*?\"|\{.*?\}|.+?)(?:\s+|$)`)
jsonR = regexp.MustCompile(`"(\w+)":(\[.+?\]|.+?)[,|}]`)
jsonR = regexp.MustCompile(`"(\w+)":(\[.+?\]|.+?)(?:,|}$)`)
)
// Commander implementation

View File

@@ -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)
}
}