Add unit tests on utils

This commit is contained in:
armirveliaj
2024-06-03 10:06:59 -04:00
committed by Dan Christian Bogos
parent 044e56a6a4
commit b4f889247f

View File

@@ -29,6 +29,7 @@ import (
"golang.org/x/crypto/bcrypt"
"github.com/cgrates/rpcclient"
"github.com/google/go-cmp/cmp"
)
func TestGetStartTime(t *testing.T) {
@@ -1820,3 +1821,36 @@ func TestCoreUtilsFibDurationSeqNrOverflow(t *testing.T) {
t.Errorf("expected: <%+v>, \nreceived: <%+v>", math.MaxInt, rcv)
}
}
func TestCoreUtilsMapStringSlicePointer(t *testing.T) {
tests := []struct {
name string
input map[string][]string
expected *map[string][]string
}{
{
name: "Empty map",
input: map[string][]string{},
expected: &map[string][]string{},
},
{
name: "Non-empty map",
input: map[string][]string{
"key1": {"value1", "value2"},
"key2": {"value3"},
},
expected: &map[string][]string{
"key1": {"value1", "value2"},
"key2": {"value3"},
},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
result := MapStringSlicePointer(test.input)
if diff := cmp.Diff(result, test.expected); diff != "" {
t.Errorf("Test case %q failed: (-got +want)\n%s", test.name, diff)
}
})
}
}