Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
Signed-off-by: SANSKARJAIN2 <[email protected]>
  • Loading branch information
SANSKARJAIN2 committed Nov 7, 2022
1 parent b8f2457 commit 585985a
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions pkg/webhooks/resource/generation/generation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,30 +483,24 @@ func Test_handleUpdateGenerateTargetResource(t *testing.T) {
}
}


func newFakeGenerateHandler(ctx *context.Context, logger logr.Logger, objects []runtime.Object, clientObjs []clientObject) (GenerationHandler, *fakekyvernov1.Clientset, error) {

kyvernoClient := fakekyvernov1.NewSimpleClientset(objects[0])
kyvernoClient := fakekyvernov1.NewSimpleClientset(objects...)
kyvernoInformers := kyvernoinformers.NewSharedInformerFactory(kyvernoClient, 0)
kyvernoInformers.Start((*ctx).Done())
kyvernoInformers.WaitForCacheSync((*ctx).Done())

clientUr := fakekyvernov1.NewSimpleClientset(objects[1])
kyvernoInformersUr := kyvernoinformers.NewSharedInformerFactory(clientUr, 0)
kyvernoInformersUr.Start((*ctx).Done())
kyvernoInformersUr.WaitForCacheSync((*ctx).Done())

client := fake.NewSimpleClientset()
informers := informers.NewSharedInformerFactory(client, 0)
informers.Start((*ctx).Done())

urLister := kyvernoInformersUr.Kyverno().V1beta1().UpdateRequests().Lister().UpdateRequests(config.KyvernoNamespace())
kyvernoInformersUr.Start((*ctx).Done())
kyvernoInformersUr.WaitForCacheSync((*ctx).Done())
urLister := kyvernoInformers.Kyverno().V1beta1().UpdateRequests().Lister().UpdateRequests(config.KyvernoNamespace())
kyvernoInformers.Start((*ctx).Done())
kyvernoInformers.WaitForCacheSync((*ctx).Done())

nsLister := informers.Core().V1().Namespaces().Lister()
urGenerator := updaterequest.NewFake()
urUpdater := webhookutils.NewUpdateRequestUpdater(clientUr, urLister)
urUpdater := webhookutils.NewUpdateRequestUpdater(kyvernoClient, urLister)
eventGen := event.NewFake()

gvrToListKind := map[schema.GroupVersionResource]string{}
Expand All @@ -530,5 +524,5 @@ func newFakeGenerateHandler(ctx *context.Context, logger logr.Logger, objects []

fakeGh := NewGenerationHandler(logger, dclientVar, kyvernoClient, nsLister, urLister, urGenerator, urUpdater, eventGen)

return fakeGh, clientUr, nil
return fakeGh, kyvernoClient, nil
}

0 comments on commit 585985a

Please sign in to comment.