Skip to content

Commit fa6aa54

Browse files
committed
test watch gvk
Signed-off-by: Tim Ramlot <[email protected]>
1 parent 690e280 commit fa6aa54

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

pkg/client/watch_test.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ var _ = Describe("ClientWithWatch", func() {
7272
Expect(cl).NotTo(BeNil())
7373
})
7474

75-
watchSuite := func(through client.ObjectList, expectedType client.Object) {
75+
watchSuite := func(through client.ObjectList, expectedType client.Object, checkGvk bool) {
7676
cl, err := client.NewWithWatch(cfg, client.Options{})
7777
Expect(err).NotTo(HaveOccurred())
7878
Expect(cl).NotTo(BeNil())
@@ -99,10 +99,19 @@ var _ = Describe("ClientWithWatch", func() {
9999
Expect(metaObject.GetName()).To(Equal(dep.Name))
100100
Expect(metaObject.GetUID()).To(Equal(dep.UID))
101101

102+
if checkGvk {
103+
runtimeObject := event.Object
104+
gvk := runtimeObject.GetObjectKind().GroupVersionKind()
105+
Expect(gvk).To(Equal(schema.GroupVersionKind{
106+
Group: "apps",
107+
Kind: "Deployment",
108+
Version: "v1",
109+
}))
110+
}
102111
}
103112

104113
It("should receive a create event when watching the typed object", func() {
105-
watchSuite(&appsv1.DeploymentList{}, &appsv1.Deployment{})
114+
watchSuite(&appsv1.DeploymentList{}, &appsv1.Deployment{}, false)
106115
})
107116

108117
It("should receive a create event when watching the unstructured object", func() {
@@ -112,12 +121,12 @@ var _ = Describe("ClientWithWatch", func() {
112121
Kind: "Deployment",
113122
Version: "v1",
114123
})
115-
watchSuite(u, &unstructured.Unstructured{})
124+
watchSuite(u, &unstructured.Unstructured{}, true)
116125
})
117126

118127
It("should receive a create event when watching the metadata object", func() {
119128
m := &metav1.PartialObjectMetadataList{TypeMeta: metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1"}}
120-
watchSuite(m, &metav1.PartialObjectMetadata{})
129+
watchSuite(m, &metav1.PartialObjectMetadata{}, false)
121130
})
122131
})
123132

0 commit comments

Comments
 (0)