From 7a5063e14cb00170914fc0a993262483298dd06e Mon Sep 17 00:00:00 2001 From: jennybuckley Date: Tue, 23 Oct 2018 09:18:20 -0700 Subject: [PATCH] Don't look at same type multiple times in recursive test --- pkg/master/import_known_versions_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkg/master/import_known_versions_test.go b/pkg/master/import_known_versions_test.go index c2aba14015f..0d19a47b29a 100644 --- a/pkg/master/import_known_versions_test.go +++ b/pkg/master/import_known_versions_test.go @@ -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 +}