From f707236a37fab52d9b0427d9f68257ac3f95ba1e Mon Sep 17 00:00:00 2001 From: armirveliaj Date: Tue, 11 Jun 2024 11:01:30 -0400 Subject: [PATCH] Add unit test on utils --- utils/coreutils_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/utils/coreutils_test.go b/utils/coreutils_test.go index 4ee2b315c..c699b5da9 100644 --- a/utils/coreutils_test.go +++ b/utils/coreutils_test.go @@ -1854,3 +1854,33 @@ func TestCoreUtilsMapStringSlicePointer(t *testing.T) { }) } } + +func TestCoreutilsParseHierarchyPath(t *testing.T) { + tests := []struct { + path string + sep string + expected HierarchyPath + }{ + { + path: "", + sep: "/", + expected: nil, + }, + { + path: "parent/child/grandchild", + sep: "", + expected: HierarchyPath{"parent", "child", "grandchild"}, + }, + { + path: "root-section-subsection", + sep: "-", + expected: HierarchyPath{"root", "section", "subsection"}, + }, + } + for _, test := range tests { + result := ParseHierarchyPath(test.path, test.sep) + if !reflect.DeepEqual(result, test.expected) { + t.Errorf("For path: %s and sep: %s, expected: %v, but got: %v", test.path, test.sep, test.expected, result) + } + } +}