Files
kubescape/cautils/strutils_test.go
Ben Hirschberg 70955537c8 initial commit
2021-08-12 16:01:26 +03:00

30 lines
712 B
Go

package cautils
import (
"fmt"
"strings"
"testing"
)
func TestConvertLabelsToString(t *testing.T) {
str := "a=b;c=d"
strMap := map[string]string{"a": "b", "c": "d"}
rsrt := ConvertLabelsToString(strMap)
spilltedA := strings.Split(rsrt, ";")
spilltedB := strings.Split(str, ";")
for i := range spilltedA {
if spilltedA[i] != spilltedB[i] {
t.Errorf("%s != %s", spilltedA[i], spilltedB[i])
}
}
}
func TestConvertStringToLabels(t *testing.T) {
str := "a=b;c=d"
strMap := map[string]string{"a": "b", "c": "d"}
rstrMap := ConvertStringToLabels(str)
if fmt.Sprintf("%v", rstrMap) != fmt.Sprintf("%v", strMap) {
t.Errorf("%s != %s", fmt.Sprintf("%v", rstrMap), fmt.Sprintf("%v", strMap))
}
}