From 7feb17572089e04e73f944de1c2079e1def6aa5b Mon Sep 17 00:00:00 2001 From: Sargun Dhillon Date: Mon, 15 Feb 2021 15:14:01 -0800 Subject: [PATCH] Split up lifecycle test wireUpSystem function This splits up the wireUpSystem function into a chunk that makes it "client agnostic". It also removes the requirement that the client is faked. --- node/lifecycle_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/node/lifecycle_test.go b/node/lifecycle_test.go index 3adc2f8b3..2c8a951ed 100644 --- a/node/lifecycle_test.go +++ b/node/lifecycle_test.go @@ -21,6 +21,7 @@ import ( "k8s.io/apimachinery/pkg/util/uuid" "k8s.io/apimachinery/pkg/watch" kubeinformers "k8s.io/client-go/informers" + "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/fake" corev1client "k8s.io/client-go/kubernetes/typed/core/v1" ktesting "k8s.io/client-go/testing" @@ -226,7 +227,7 @@ func TestPodLifecycle(t *testing.T) { type testFunction func(ctx context.Context, s *system) type system struct { pc *PodController - client *fake.Clientset + client kubernetes.Interface podControllerConfig PodControllerConfig } @@ -262,6 +263,13 @@ func wireUpSystem(ctx context.Context, provider PodLifecycleHandler, f testFunct return false, nil, nil }) + return wireUpSystemWithClient(ctx, provider, client, f) +} + +func wireUpSystemWithClient(ctx context.Context, provider PodLifecycleHandler, client kubernetes.Interface, f testFunction) error { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + // This is largely copy and pasted code from the root command sharedInformerFactory := kubeinformers.NewSharedInformerFactoryWithOptions( client,