Skip to content

Commit 258470c

Browse files
committed
✨ Add the unit tests for HasWebhook
1 parent bba9577 commit 258470c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

pkg/model/config/config_test.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,15 @@ var _ = Describe("ResourceData Version Compatibility", func() {
249249

250250
var _ = Describe("Config", func() {
251251
var (
252-
c *Config
253-
gvk1, gvk2 ResourceData
252+
c *Config
253+
gvk1, gvk2, gvk3 ResourceData
254254
)
255255

256256
BeforeEach(func() {
257257
c = &Config{}
258258
gvk1 = ResourceData{Group: "example", Version: "v1", Kind: "TestKind"}
259259
gvk2 = ResourceData{Group: "example", Version: "v1", Kind: "TestKind2"}
260+
gvk3 = ResourceData{Group: "example", Version: "v1", Kind: "TestKind", Webhooks: &Webhooks{WebhookVersion: v1beta1}}
260261
})
261262

262263
Context("UpdateResource", func() {
@@ -295,4 +296,17 @@ var _ = Describe("Config", func() {
295296
})
296297

297298
})
299+
300+
Context("HasWebhook", func() {
301+
It("should return true when config has a webhook for the GVK", func() {
302+
c.UpdateResources(gvk3)
303+
Expect(c.Resources).To(Equal([]ResourceData{gvk3}))
304+
Expect(c.HasWebhook(gvk3)).To(BeTrue())
305+
})
306+
It("should return false when config does not have a webhook for the GVK", func() {
307+
c.UpdateResources(gvk1)
308+
Expect(c.Resources).To(Equal([]ResourceData{gvk1}))
309+
Expect(c.HasWebhook(gvk1)).To(BeFalse())
310+
})
311+
})
298312
})

0 commit comments

Comments
 (0)