Skip to content

Commit cc90df3

Browse files
committed
Test Apply in interceptor
1 parent b6d3b23 commit cc90df3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pkg/client/interceptor/intercept_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,29 @@ var _ = Describe("NewClient", func() {
6363
_ = client2.List(ctx, nil)
6464
Expect(called).To(BeTrue())
6565
})
66+
It("should call the provided Apply function", func() {
67+
var called bool
68+
client := NewClient(wrappedClient, Funcs{
69+
Apply: func(ctx context.Context, client client.WithWatch, obj runtime.ApplyConfiguration, opts ...client.ApplyOption) error {
70+
called = true
71+
return nil
72+
},
73+
})
74+
_ = client.Apply(ctx, nil)
75+
Expect(called).To(BeTrue())
76+
})
77+
It("should call the underlying client if the provided Apply function is nil", func() {
78+
var called bool
79+
client1 := NewClient(wrappedClient, Funcs{
80+
Apply: func(ctx context.Context, client client.WithWatch, obj runtime.ApplyConfiguration, opts ...client.ApplyOption) error {
81+
called = true
82+
return nil
83+
},
84+
})
85+
client2 := NewClient(client1, Funcs{})
86+
_ = client2.Apply(ctx, nil)
87+
Expect(called).To(BeTrue())
88+
})
6689
It("should call the provided Create function", func() {
6790
var called bool
6891
client := NewClient(wrappedClient, Funcs{

0 commit comments

Comments
 (0)