mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-23 16:18:44 +05:00
use indented json in ONM.String()
to be consistent with the logged request/CGREvent. only used by logs
This commit is contained in:
committed by
Dan Christian Bogos
parent
4bde2fc07c
commit
af6e29362e
@@ -2017,6 +2017,27 @@ func TestGetEndOfMonth(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// go test ./utils/ -bench BenchmarkToJSON -benchtime=1s -benchmem
|
||||
func BenchmarkToJSON(b *testing.B) {
|
||||
v := map[string]any{
|
||||
"Result-Code": "2001",
|
||||
"Granted-Service-Unit": map[string]any{
|
||||
"CC-Time": 300,
|
||||
},
|
||||
"Session-Id": "cgrates;1052943642;938",
|
||||
}
|
||||
b.Run("ToJSON", func(b *testing.B) {
|
||||
for b.Loop() {
|
||||
ToJSON(v)
|
||||
}
|
||||
})
|
||||
b.Run("ToIJSON", func(b *testing.B) {
|
||||
for b.Loop() {
|
||||
ToIJSON(v)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestParseBinarySize(t *testing.T) {
|
||||
type args struct {
|
||||
size string
|
||||
|
||||
@@ -42,7 +42,7 @@ type OrderedNavigableMap struct {
|
||||
|
||||
// String returns the map as json string
|
||||
func (onm *OrderedNavigableMap) String() string {
|
||||
return ToJSON(onm.nm)
|
||||
return ToIJSON(onm.nm)
|
||||
}
|
||||
|
||||
// GetFirstElement returns the first element from the order
|
||||
|
||||
@@ -892,7 +892,15 @@ func TestOrderedNavigableMapString(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
onmExpect := `{"Map":{"test1":{"Value":{"Data":"data!"}}}}`
|
||||
onmExpect := `{
|
||||
"Map": {
|
||||
"test1": {
|
||||
"Value": {
|
||||
"Data": "data!"
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
if onm.String() != onmExpect {
|
||||
t.Errorf("Expected %s but received %s", onmExpect, onm.String())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user