Skip to content

Commit

Permalink
Add test for sealed stream option
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelattwood committed Jan 7, 2025
1 parent 169c1f2 commit 6fa2f62
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/controller/stream_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,19 @@ var _ = Describe("Stream Controller", func() {
Expect(streamInfo.Created).To(BeTemporally("~", time.Now(), time.Second))
})

When("sealed is true", func() {
BeforeEach(func(ctx SpecContext) {
By("setting sealed to true")
stream.Spec.Name = "sealed"
stream.Spec.Sealed = true
Expect(k8sClient.Update(ctx, stream)).To(Succeed())
})
It("should not create the stream", func(ctx SpecContext) {
_, err := controller.Reconcile(ctx, ctrl.Request{NamespacedName: typeNamespacedName})
Expect(err.Error()).To(HaveSuffix("can not be sealed"))
})
})

When("PreventUpdate is set", func() {
BeforeEach(func(ctx SpecContext) {
By("setting preventDelete on the resource")
Expand Down Expand Up @@ -324,6 +337,7 @@ var _ = Describe("Stream Controller", func() {

By("updating the resource")
stream.Spec.Description = "new description"
stream.Spec.Sealed = true
Expect(k8sClient.Update(ctx, stream)).To(Succeed())

By("reconciling the updated resource")
Expand All @@ -348,6 +362,7 @@ var _ = Describe("Stream Controller", func() {
streamInfo, err := natsStream.Info(ctx)
Expect(err).NotTo(HaveOccurred())
Expect(streamInfo.Config.Description).To(Equal("new description"))
Expect(streamInfo.Config.Sealed).To(BeTrue())
// Other fields unchanged
Expect(streamInfo.Config.Subjects).To(Equal([]string{"tests.*"}))
})
Expand Down

0 comments on commit 6fa2f62

Please sign in to comment.