prevent the same path load multiple times

Kubernetes-commit: 973e610787db8a9cee5da098e2f72672be817aa9
This commit is contained in:
wackxu
2017-10-12 10:19:28 +08:00
committed by Kubernetes Publisher
parent fff8c3d73e
commit 1ae3aba19b
3 changed files with 47 additions and 2 deletions

View File

@@ -592,3 +592,30 @@ func Example_mergingEverythingNoConflicts() {
// user:
// token: red-token
}
func TestDeduplicate(t *testing.T) {
testCases := []struct {
src []string
expect []string
}{
{
src: []string{"a", "b", "c", "d", "e", "f"},
expect: []string{"a", "b", "c", "d", "e", "f"},
},
{
src: []string{"a", "b", "c", "b", "e", "f"},
expect: []string{"a", "b", "c", "e", "f"},
},
{
src: []string{"a", "a", "b", "b", "c", "b"},
expect: []string{"a", "b", "c"},
},
}
for _, testCase := range testCases {
get := deduplicate(testCase.src)
if !reflect.DeepEqual(get, testCase.expect) {
t.Errorf("expect: %v, get: %v", testCase.expect, get)
}
}
}