Skip to content

Commit

Permalink
[SAPBTPCFS-7876] Optimize handling of non-transient errors
Browse files Browse the repository at this point in the history
  • Loading branch information
I065450 committed Dec 11, 2023
1 parent 635aa5f commit 2753508
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions api/v1/serviceinstance_validating_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/SAP/sap-btp-service-operator/api"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"time"
)

var _ = Describe("Service Instance Webhook Test", func() {
Expand All @@ -24,6 +25,25 @@ var _ = Describe("Service Instance Webhook Test", func() {
Expect(err.Error()).To(ContainSubstring("changing the btpAccessCredentialsSecret for an existing instance is not allowed"))
})
})
When("service instance IgnoreNonTransientErrorTimestampAnnotation annotation is not set with not a date", func() {
It("should not return error from webhook", func() {
instance.Annotations = map[string]string{
api.IgnoreNonTransientErrorTimestampAnnotation: "true",
}
_, err := instance.ValidateUpdate(instance)
Expect(err).To(HaveOccurred())

})
})
When("service instance IgnoreNonTransientErrorTimestampAnnotation annotation is not set with future date", func() {
It("should not return error from webhook", func() {
instance.Annotations = map[string]string{
api.IgnoreNonTransientErrorTimestampAnnotation: time.Now().Add(48 * time.Hour).Format(time.RFC3339),
}
_, err := instance.ValidateUpdate(instance)
Expect(err).To(HaveOccurred())
})
})
})

Context("Validate Delete", func() {
Expand Down Expand Up @@ -53,5 +73,26 @@ var _ = Describe("Service Instance Webhook Test", func() {
Expect(err).ToNot(HaveOccurred())
})
})
Context("Validate Create", func() {
When("service instance IgnoreNonTransientErrorTimestampAnnotation annotation is not set with not a date", func() {
It("should not return error from webhook", func() {
instance.Annotations = map[string]string{
api.IgnoreNonTransientErrorTimestampAnnotation: "true",
}
_, err := instance.ValidateCreate()
Expect(err).To(HaveOccurred())

})
})
When("service instance IgnoreNonTransientErrorTimestampAnnotation annotation is not set with future date", func() {
It("should not return error from webhook", func() {
instance.Annotations = map[string]string{
api.IgnoreNonTransientErrorTimestampAnnotation: time.Now().Add(48 * time.Hour).Format(time.RFC3339),
}
_, err := instance.ValidateCreate()
Expect(err).To(HaveOccurred())
})
})
})
})
})

0 comments on commit 2753508

Please sign in to comment.