Add more backend unit tests

This commit is contained in:
Jamie Curnow
2023-07-27 21:17:08 +10:00
parent d94e304f31
commit 7f9a1f5a98
10 changed files with 836 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package util
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
@ -90,3 +91,21 @@ func TestConvertIntSliceToString(t *testing.T) {
str := ConvertIntSliceToString(items)
assert.Equal(t, expectedStr, str)
}
func TestConvertStringSliceToInterface(t *testing.T) {
testCases := []struct {
input []string
expected []interface{}
}{
{[]string{"hello", "world"}, []interface{}{"hello", "world"}},
{[]string{"apple", "banana", "cherry"}, []interface{}{"apple", "banana", "cherry"}},
{[]string{}, []interface{}{}}, // Empty slice should return an empty slice
}
for _, tc := range testCases {
result := ConvertStringSliceToInterface(tc.input)
if !reflect.DeepEqual(result, tc.expected) {
t.Errorf("Expected: %v, Got: %v", tc.expected, result)
}
}
}