mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
better cgr_rpc and more tests
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"cmd/cgrates/utils"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
@@ -113,3 +114,27 @@ func TestStructFromMapStringInterface(t *testing.T) {
|
||||
t.Error("Error converting map to struct: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStructFromMapStringInterfaceValue(t *testing.T) {
|
||||
type T struct {
|
||||
Name string
|
||||
Disabled *bool
|
||||
Members []string
|
||||
}
|
||||
ts := &T{}
|
||||
vts := reflect.ValueOf(ts)
|
||||
x, err := FromMapStringInterfaceValue(map[string]interface{}{
|
||||
"Name": "test",
|
||||
"Disabled": true,
|
||||
"Members": []string{"1", "2", "3"},
|
||||
}, vts)
|
||||
rt := x.(T)
|
||||
if err != nil {
|
||||
t.Fatalf("error converting structure value: %v", err)
|
||||
}
|
||||
if rt.Name != "test" ||
|
||||
*rt.Disabled != true ||
|
||||
!reflect.DeepEqual(rt.Members, []string{"1", "2", "3"}) {
|
||||
t.Errorf("error converting structure value: %s", utils.ToIJSON(rt))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user