Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ludydoo committed Jun 28, 2023
1 parent 0b0af54 commit 0b344af
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions pkg/reconciler/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,72 @@ var _ = Describe("Reconciler", func() {
Expect(WithPostRenderer(withAnnotatingPostRenderer)(r)).To(Succeed())
Expect(r.postRendererFn).NotTo(BeNil())
})
It("should unset the reconciler if nil", func() {
Expect(WithPostRenderer(nil)(r)).To(Succeed())
Expect(r.postRendererFn).To(BeNil())
})
When("No PostRenderer function is configured", func() {
BeforeEach(func() {
Expect(WithPostRenderer(nil)(r)).To(Succeed())
Expect(r.postRendererFn).To(BeNil())
})
It("should not append the post renderer to the upgrade options", func() {
var opts []helmclient.UpgradeOption
var obj = &unstructured.Unstructured{}
newOptions, err := r.appendUpgradePostRendererOption(context.Background(), obj, opts, map[string]interface{}{})
Expect(err).NotTo(HaveOccurred())
Expect(newOptions).To(HaveLen(0))
})
It("should not append the post renderer to the install options", func() {
var opts []helmclient.InstallOption
var obj = &unstructured.Unstructured{}
newOptions, err := r.appendInstallPostRendererOption(context.Background(), obj, opts, map[string]interface{}{})
Expect(err).NotTo(HaveOccurred())
Expect(newOptions).To(HaveLen(0))
})
})
When("A PostRenderer function is configured", func() {
BeforeEach(func() {
Expect(WithPostRenderer(withAnnotatingPostRenderer)(r)).To(Succeed())
Expect(r.postRendererFn).NotTo(BeNil())
})
It("Should return the InstallOptions with the PostRenderer", func() {
var opts []helmclient.InstallOption
var obj = &unstructured.Unstructured{}
newOptions, err := r.appendInstallPostRendererOption(context.Background(), obj, opts, map[string]interface{}{})
Expect(err).NotTo(HaveOccurred())
Expect(newOptions).To(HaveLen(1))
})
It("Should return the UpgradeOptions with the PostRenderer", func() {
var opts []helmclient.UpgradeOption
var obj = &unstructured.Unstructured{}
newOptions, err := r.appendUpgradePostRendererOption(context.Background(), obj, opts, map[string]interface{}{})
Expect(err).NotTo(HaveOccurred())
Expect(newOptions).To(HaveLen(1))
})
})
When("A PostRenderer function is configured but returns nil", func() {
BeforeEach(func() {
Expect(WithPostRenderer(func(_ context.Context, _ PostRendererContext) (postrender.PostRenderer, error) {
return nil, nil
})(r)).To(Succeed())
Expect(r.postRendererFn).NotTo(BeNil())
})
It("Should return the InstallOptions with the PostRenderer", func() {
var opts []helmclient.InstallOption
var obj = &unstructured.Unstructured{}
newOptions, err := r.appendInstallPostRendererOption(context.Background(), obj, opts, map[string]interface{}{})
Expect(err).NotTo(HaveOccurred())
Expect(newOptions).To(HaveLen(0))
})
It("Should return the UpgradeOptions with the PostRenderer", func() {
var opts []helmclient.UpgradeOption
var obj = &unstructured.Unstructured{}
newOptions, err := r.appendUpgradePostRendererOption(context.Background(), obj, opts, map[string]interface{}{})
Expect(err).NotTo(HaveOccurred())
Expect(newOptions).To(HaveLen(0))
})
})
})
})

Expand Down

0 comments on commit 0b344af

Please sign in to comment.