From b4f889247f765bf25e7850ff3d8c81a04c96013a Mon Sep 17 00:00:00 2001 From: armirveliaj Date: Mon, 3 Jun 2024 10:06:59 -0400 Subject: [PATCH] Add unit tests on utils --- utils/coreutils_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/utils/coreutils_test.go b/utils/coreutils_test.go index ee46d5dea..4ee2b315c 100644 --- a/utils/coreutils_test.go +++ b/utils/coreutils_test.go @@ -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) + } + }) + } +}