unit-test: add unit test for pkg/ingress/kube/annotations (#156)

Signed-off-by: charlie <qianglin98@qq.com>
This commit is contained in:
charlie
2023-02-02 15:22:11 +08:00
committed by GitHub
parent 1092402516
commit 7ceec94a87
6 changed files with 479 additions and 1 deletions

View File

@@ -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)
}
}
}