@@ -3,7 +3,9 @@ package interceptor
3
3
import (
4
4
"context"
5
5
6
- "sigs.k8s.io/controller-runtime/pkg/client/fake"
6
+ "k8s.io/apimachinery/pkg/api/meta"
7
+ "k8s.io/apimachinery/pkg/runtime"
8
+ "k8s.io/apimachinery/pkg/runtime/schema"
7
9
8
10
. "github.com/onsi/ginkgo/v2"
9
11
. "github.com/onsi/gomega"
@@ -13,7 +15,7 @@ import (
13
15
)
14
16
15
17
var _ = Describe ("NewClient" , func () {
16
- wrappedClient := fake . NewClientBuilder (). Build ()
18
+ wrappedClient := dummyClient {}
17
19
ctx := context .Background ()
18
20
It ("should call the provided Get function" , func () {
19
21
var called bool
@@ -252,8 +254,7 @@ var _ = Describe("NewClient", func() {
252
254
})
253
255
254
256
var _ = Describe ("NewSubResourceClient" , func () {
255
- wrappedClient := fake .NewClientBuilder ().Build ()
256
- srClient := wrappedClient .SubResource ("test" )
257
+ srClient := dummySubResourceClient {}
257
258
ctx := context .Background ()
258
259
It ("should call the provided Get function" , func () {
259
260
var called bool
@@ -348,3 +349,83 @@ var _ = Describe("NewSubResourceClient", func() {
348
349
Expect (called ).To (BeTrue ())
349
350
})
350
351
})
352
+
353
+ type dummyClient struct {}
354
+
355
+ var _ client.WithWatch = & dummyClient {}
356
+
357
+ func (d dummyClient ) Get (ctx context.Context , key client.ObjectKey , obj client.Object , opts ... client.GetOption ) error {
358
+ return nil
359
+ }
360
+
361
+ func (d dummyClient ) List (ctx context.Context , list client.ObjectList , opts ... client.ListOption ) error {
362
+ return nil
363
+ }
364
+
365
+ func (d dummyClient ) Create (ctx context.Context , obj client.Object , opts ... client.CreateOption ) error {
366
+ return nil
367
+ }
368
+
369
+ func (d dummyClient ) Delete (ctx context.Context , obj client.Object , opts ... client.DeleteOption ) error {
370
+ return nil
371
+ }
372
+
373
+ func (d dummyClient ) Update (ctx context.Context , obj client.Object , opts ... client.UpdateOption ) error {
374
+ return nil
375
+ }
376
+
377
+ func (d dummyClient ) Patch (ctx context.Context , obj client.Object , patch client.Patch , opts ... client.PatchOption ) error {
378
+ return nil
379
+ }
380
+
381
+ func (d dummyClient ) DeleteAllOf (ctx context.Context , obj client.Object , opts ... client.DeleteAllOfOption ) error {
382
+ return nil
383
+ }
384
+
385
+ func (d dummyClient ) Status () client.SubResourceWriter {
386
+ return d .SubResource ("status" )
387
+ }
388
+
389
+ func (d dummyClient ) SubResource (subResource string ) client.SubResourceClient {
390
+ return nil
391
+ }
392
+
393
+ func (d dummyClient ) Scheme () * runtime.Scheme {
394
+ return nil
395
+ }
396
+
397
+ func (d dummyClient ) RESTMapper () meta.RESTMapper {
398
+ return nil
399
+ }
400
+
401
+ func (d dummyClient ) GroupVersionKindFor (obj runtime.Object ) (schema.GroupVersionKind , error ) {
402
+ return schema.GroupVersionKind {}, nil
403
+ }
404
+
405
+ func (d dummyClient ) IsObjectNamespaced (obj runtime.Object ) (bool , error ) {
406
+ return false , nil
407
+ }
408
+
409
+ func (d dummyClient ) Watch (ctx context.Context , obj client.ObjectList , opts ... client.ListOption ) (watch.Interface , error ) {
410
+ return nil , nil
411
+ }
412
+
413
+ type dummySubResourceClient struct {}
414
+
415
+ var _ client.SubResourceClient = & dummySubResourceClient {}
416
+
417
+ func (d dummySubResourceClient ) Get (ctx context.Context , obj client.Object , subResource client.Object , opts ... client.SubResourceGetOption ) error {
418
+ return nil
419
+ }
420
+
421
+ func (d dummySubResourceClient ) Create (ctx context.Context , obj client.Object , subResource client.Object , opts ... client.SubResourceCreateOption ) error {
422
+ return nil
423
+ }
424
+
425
+ func (d dummySubResourceClient ) Update (ctx context.Context , obj client.Object , opts ... client.SubResourceUpdateOption ) error {
426
+ return nil
427
+ }
428
+
429
+ func (d dummySubResourceClient ) Patch (ctx context.Context , obj client.Object , patch client.Patch , opts ... client.SubResourcePatchOption ) error {
430
+ return nil
431
+ }
0 commit comments