Don't look at same type multiple times in recursive test

This commit is contained in:
jennybuckley
2018-10-23 09:18:20 -07:00
committed by Antoine Pelisse
parent 3cff3355b0
commit 7a5063e14c

View File

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