Skip to content

Commit 7ba8622

Browse files
committed
updating leader test to fix issue with breaking change in Fakeclient, where it now clears typemeta
Signed-off-by: Adam D. Cornett <[email protected]>
1 parent 4d9d19f commit 7ba8622

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

leader/leader_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ var _ = Describe("Leader election", func() {
165165
interceptor.Funcs{
166166
// Mock garbage collection of the ConfigMap when the Pod is deleted.
167167
Delete: func(ctx context.Context, client crclient.WithWatch, obj crclient.Object, _ ...crclient.DeleteOption) error {
168-
if obj.GetObjectKind() != nil && obj.GetObjectKind().GroupVersionKind().Kind == "Pod" && obj.GetName() == "leader-test" {
168+
if pod, ok := obj.(*corev1.Pod); ok && pod.GetName() == "leader-test" {
169169
cm := &corev1.ConfigMap{
170170
ObjectMeta: metav1.ObjectMeta{
171171
Name: "leader-test",
@@ -260,7 +260,7 @@ var _ = Describe("Leader election", func() {
260260
interceptor.Funcs{
261261
// Mock garbage collection of the ConfigMap when the Pod is deleted.
262262
Delete: func(ctx context.Context, client crclient.WithWatch, obj crclient.Object, _ ...crclient.DeleteOption) error {
263-
if obj.GetObjectKind() != nil && obj.GetObjectKind().GroupVersionKind().Kind == "Pod" && obj.GetName() == "leader-test" {
263+
if pod, ok := obj.(*corev1.Pod); ok && pod.GetName() == "leader-test" {
264264
cm := &corev1.ConfigMap{
265265
ObjectMeta: metav1.ObjectMeta{
266266
Name: "leader-test",
@@ -404,8 +404,7 @@ var _ = Describe("Leader election", func() {
404404
pod, err := getPod(context.TODO(), client, "testns")
405405
Expect(err).ShouldNot(HaveOccurred())
406406
Expect(pod).ShouldNot(BeNil())
407-
Expect(pod.TypeMeta.APIVersion).To(Equal("v1"))
408-
Expect(pod.TypeMeta.Kind).To(Equal("Pod"))
407+
Expect(pod.Name).To(Equal("mypod"))
409408
})
410409
})
411410

@@ -434,8 +433,7 @@ var _ = Describe("Leader election", func() {
434433
It("should return the node with the given name", func() {
435434
node := corev1.Node{}
436435
Expect(getNode(context.TODO(), client, "mynode", &node)).Should(Succeed())
437-
Expect(node.TypeMeta.APIVersion).To(Equal("v1"))
438-
Expect(node.TypeMeta.Kind).To(Equal("Node"))
436+
Expect(node.Name).To(Equal("mynode"))
439437
})
440438
})
441439

0 commit comments

Comments
 (0)