Skip to content

Commit

Permalink
Merge pull request #369 from untangle/MFW-4428
Browse files Browse the repository at this point in the history
MFW-4428: Backport reporting functionality for policy manager into EFT branch
  • Loading branch information
sumedha-game authored Feb 22, 2024
2 parents 34c1f53 + 9706d8c commit fdc9a26
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ func ContainsString(s []string, e string) bool {
return false
}

// StringArrayToDB converts a string array into a single string, using pipe as a delimiter
func StringArrayToDB(s []string) string {
return strings.Join(s, "|")
}

// WaitGroupDoneOrTimeout waits for the waitgroup for the specified max timeout.
// Returns true if waiting timed out.
func WaitGroupDoneOrTimeout(wg *sync.WaitGroup, timeout time.Duration) bool {
Expand Down
30 changes: 30 additions & 0 deletions util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,33 @@ func TestExtractSettingsFromTar(t *testing.T) {
assert.Error(t, err)

}

func TestStringArrayToDB(t *testing.T) {
tests := []struct {
name string
input []string
expected string
}{
{
name: "Empty input",
input: []string{},
expected: "",
},
{
name: "Single element",
input: []string{"test"},
expected: "test",
},
{
name: "Multiple elements",
input: []string{"test", "test2", "test3"},
expected: "test|test2|test3",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
actual := StringArrayToDB(test.input)
assert.Equal(t, test.expected, actual)
})
}
}

0 comments on commit fdc9a26

Please sign in to comment.