diff --git a/api/v1/serviceinstance_types_test.go b/api/v1/serviceinstance_types_test.go index ab4b1f04..79935d74 100644 --- a/api/v1/serviceinstance_types_test.go +++ b/api/v1/serviceinstance_types_test.go @@ -153,4 +153,14 @@ var _ = Describe("Service Instance Type Test", func() { Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("cannot be a future timestamp")) }) + It("validate annotation exist and valid", func() { + + annotation := map[string]string{ + api.IgnoreNonTransientErrorAnnotation: "true", + api.IgnoreNonTransientErrorTimestampAnnotation: time.Now().Format(time.RFC3339), + } + instance.SetAnnotations(annotation) + exist := instance.IsIgnoreNonTransientAnnotationExistAndValid(serviceinstancelog, time.Hour) + Expect(exist).To(BeTrue()) + }) }) diff --git a/api/v1alpha1/serviceinstance_types_test.go b/api/v1alpha1/serviceinstance_types_test.go index 41ac8e59..917bfed6 100644 --- a/api/v1alpha1/serviceinstance_types_test.go +++ b/api/v1alpha1/serviceinstance_types_test.go @@ -7,10 +7,14 @@ import ( "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + logf "sigs.k8s.io/controller-runtime/pkg/log" + "time" ) var _ = Describe("Service Instance Type Test", func() { var instance *ServiceInstance + var serviceinstancelog = logf.Log.WithName("serviceinstance-resource") + BeforeEach(func() { instance = getInstance() conditions := instance.GetConditions() @@ -121,4 +125,33 @@ var _ = Describe("Service Instance Type Test", func() { instance.SetStatus(status) Expect(instance.GetStatus()).To(Equal(status)) }) + + It("should update annotation", func() { + annotation := map[string]string{ + api.IgnoreNonTransientErrorAnnotation: "true", + } + instance.SetAnnotations(annotation) + Expect(instance.GetAnnotations()).To(Equal(annotation)) + }) + + It("validate timestamp annotation- not date", func() { + + annotation := map[string]string{ + api.IgnoreNonTransientErrorAnnotation: "true", + api.IgnoreNonTransientErrorTimestampAnnotation: "true", + } + instance.SetAnnotations(annotation) + exist := instance.IsIgnoreNonTransientAnnotationExistAndValid(serviceinstancelog, time.Hour) + Expect(exist).To(BeFalse()) + }) + It("validate annotation exist and valid", func() { + + annotation := map[string]string{ + api.IgnoreNonTransientErrorAnnotation: "true", + api.IgnoreNonTransientErrorTimestampAnnotation: time.Now().Format(time.RFC3339), + } + instance.SetAnnotations(annotation) + exist := instance.IsIgnoreNonTransientAnnotationExistAndValid(serviceinstancelog, time.Hour) + Expect(exist).To(BeTrue()) + }) })