mirror of
https://github.com/alibaba/higress.git
synced 2026-04-21 20:17:29 +08:00
unit-test: add unit test for pkg/ingress/kube/annotations (#156)
Signed-off-by: charlie <qianglin98@qq.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"istio.io/istio/pilot/pkg/model"
|
||||
)
|
||||
|
||||
@@ -51,3 +52,35 @@ func TestExtraSecret(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSplitBySeparator(t *testing.T) {
|
||||
testCases := []struct {
|
||||
input string
|
||||
sep string
|
||||
expect []string
|
||||
}{
|
||||
{
|
||||
input: "a b c d",
|
||||
sep: " ",
|
||||
expect: []string{"a", "b", "c", "d"},
|
||||
},
|
||||
{
|
||||
input: ".1.2.3.4.",
|
||||
sep: ".",
|
||||
expect: []string{"1", "2", "3", "4"},
|
||||
},
|
||||
{
|
||||
input: "1....2....3....4",
|
||||
sep: ".",
|
||||
expect: []string{"1", "2", "3", "4"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range testCases {
|
||||
got := splitBySeparator(tt.input, tt.sep)
|
||||
if diff := cmp.Diff(tt.expect, got); diff != "" {
|
||||
t.Errorf("TestSplitBySeparator() mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user