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.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user