mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 20:00:07 +00:00
Don't look at same type multiple times in recursive test
This commit is contained in:
committed by
Antoine Pelisse
parent
3cff3355b0
commit
7a5063e14c
@@ -93,6 +93,10 @@ func ensureNoTags(t *testing.T, gvk schema.GroupVersionKind, tp reflect.Type, pa
|
||||
return
|
||||
}
|
||||
|
||||
// Don't look at the same type multiple times
|
||||
if containsType(parents, tp) {
|
||||
return
|
||||
}
|
||||
parents = append(parents, tp)
|
||||
|
||||
switch tp.Kind() {
|
||||
@@ -145,6 +149,10 @@ func ensureTags(t *testing.T, gvk schema.GroupVersionKind, tp reflect.Type, pare
|
||||
return
|
||||
}
|
||||
|
||||
// Don't look at the same type multiple times
|
||||
if containsType(parents, tp) {
|
||||
return
|
||||
}
|
||||
parents = append(parents, tp)
|
||||
|
||||
switch tp.Kind() {
|
||||
@@ -185,3 +193,13 @@ func ensureTags(t *testing.T, gvk schema.GroupVersionKind, tp reflect.Type, pare
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// containsType returns true if s contains t, false otherwise
|
||||
func containsType(s []reflect.Type, t reflect.Type) bool {
|
||||
for _, u := range s {
|
||||
if t == u {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user