Skip to content

Commit

Permalink
Check for we're not getting errors on the Patch calls and remove the …
Browse files Browse the repository at this point in the history
…eventually as not needed here

Signed-off-by: Luke Mallon (Nalum) <[email protected]>
  • Loading branch information
Nalum committed Nov 27, 2023
1 parent 9896a51 commit 15d2a0d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions internal/controller/kustomization_disallowed_managers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,14 @@ data:
Namespace: id,
},
}
_ = k8sClient.Patch(context.Background(), &configMap, client.RawPatch(types.MergePatchType, []byte(`{"data":{"bad-key":"overridden field manager"}}`)), &client.PatchOptions{FieldManager: overrideManagerName})
_ = k8sClient.Patch(context.Background(), &configMap, client.RawPatch(types.MergePatchType, []byte(`{"data":{"key2":"not overridden field manager"}}`)), &client.PatchOptions{FieldManager: "good-name"})

g.Eventually(func() bool {
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(initialConfigMap), badConfigMap)
return g.Expect(badConfigMap.Data).Should(HaveKey("bad-key")) && g.Expect(badConfigMap.Data).Should(HaveKey("key2"))
}, timeout, time.Second).Should(BeTrue())
err = k8sClient.Patch(context.Background(), &configMap, client.RawPatch(types.MergePatchType, []byte(`{"data":{"bad-key":"overridden field manager"}}`)), &client.PatchOptions{FieldManager: overrideManagerName})
g.Expect(err).NotTo(HaveOccurred())
err = k8sClient.Patch(context.Background(), &configMap, client.RawPatch(types.MergePatchType, []byte(`{"data":{"key2":"not overridden field manager"}}`)), &client.PatchOptions{FieldManager: "good-name"})
g.Expect(err).NotTo(HaveOccurred())
err = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(initialConfigMap), badConfigMap)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(badConfigMap.Data).Should(HaveKey("bad-key"))
g.Expect(badConfigMap.Data).Should(HaveKey("key2"))
})

t.Run("bad-key should be removed from the configmap", func(t *testing.T) {
Expand Down

0 comments on commit 15d2a0d

Please sign in to comment.