@@ -790,16 +790,15 @@ var _ = Describe("ServiceBindingRepo", func() {
790790
791791 Describe ("DeleteServiceBinding" , func () {
792792 var (
793- deleteErr error
794- serviceBindingGUID string
793+ deleteErr error
794+ binding * korifiv1alpha1.CFServiceBinding
795+ bindingGUID string
795796 )
796797
797798 BeforeEach (func () {
798- serviceBindingGUID = uuid .NewString ()
799-
800- serviceBinding := & korifiv1alpha1.CFServiceBinding {
799+ binding = & korifiv1alpha1.CFServiceBinding {
801800 ObjectMeta : metav1.ObjectMeta {
802- Name : serviceBindingGUID ,
801+ Name : uuid . NewString () ,
803802 Namespace : space .Name ,
804803 Annotations : map [string ]string {
805804 korifiv1alpha1 .ServiceInstanceTypeAnnotation : korifiv1alpha1 .UserProvidedType ,
@@ -819,17 +818,19 @@ var _ = Describe("ServiceBindingRepo", func() {
819818 },
820819 }
821820 Expect (
822- k8sClient .Create (ctx , serviceBinding ),
821+ k8sClient .Create (ctx , binding ),
823822 ).To (Succeed ())
824823
824+ bindingGUID = binding .Name
825+
825826 appConditionAwaiter .AwaitStateStub = func (ctx context.Context , _ repositories.Klient , object client.Object , checkState func (a * korifiv1alpha1.CFApp ) error ) (* korifiv1alpha1.CFApp , error ) {
826827 cfApp , ok := object .(* korifiv1alpha1.CFApp )
827828 Expect (ok ).To (BeTrue ())
828829
829830 Expect (k8s .Patch (ctx , k8sClient , cfApp , func () {
830831 cfApp .Status .ObservedGeneration = cfApp .Generation
831832 cfApp .Status .ServiceBindings = slices .Collect (it .Exclude (slices .Values (cfApp .Status .ServiceBindings ), func (b korifiv1alpha1.ServiceBinding ) bool {
832- return b .GUID == serviceBindingGUID
833+ return b .GUID == bindingGUID
833834 }))
834835 })).To (Succeed ())
835836
@@ -839,7 +840,7 @@ var _ = Describe("ServiceBindingRepo", func() {
839840 })
840841
841842 JustBeforeEach (func () {
842- deleteErr = repo .DeleteServiceBinding (ctx , authInfo , serviceBindingGUID )
843+ deleteErr = repo .DeleteServiceBinding (ctx , authInfo , bindingGUID )
843844 })
844845
845846 It ("returns a not-found error for users with no role in the space" , func () {
@@ -863,11 +864,19 @@ var _ = Describe("ServiceBindingRepo", func() {
863864
864865 It ("deletes the binding" , func () {
865866 Expect (deleteErr ).NotTo (HaveOccurred ())
867+ actualBinding := & korifiv1alpha1.CFServiceBinding {
868+ ObjectMeta : metav1.ObjectMeta {
869+ Name : binding .Name ,
870+ Namespace : binding .Namespace ,
871+ },
872+ }
873+ Expect (k8sClient .Get (ctx , client .ObjectKeyFromObject (actualBinding ), actualBinding )).To (Succeed ())
874+ Expect (actualBinding .DeletionTimestamp ).NotTo (BeNil ())
866875 })
867876
868877 When ("the binding doesn't exist" , func () {
869878 BeforeEach (func () {
870- serviceBindingGUID = "something-that-does-not-match"
879+ bindingGUID = "something-that-does-not-match"
871880 })
872881
873882 It ("returns a not-found error" , func () {
@@ -903,7 +912,7 @@ var _ = Describe("ServiceBindingRepo", func() {
903912
904913 Expect (k8s .Patch (ctx , k8sClient , cfApp , func () {
905914 cfApp .Status .ServiceBindings = slices .Collect (it .Exclude (slices .Values (cfApp .Status .ServiceBindings ), func (b korifiv1alpha1.ServiceBinding ) bool {
906- return b .GUID == serviceBindingGUID
915+ return b .GUID == bindingGUID
907916 }))
908917 })).To (Succeed ())
909918
@@ -916,6 +925,52 @@ var _ = Describe("ServiceBindingRepo", func() {
916925 Expect (deleteErr ).To (MatchError (ContainSubstring ("outdated" )))
917926 })
918927 })
928+
929+ When ("the binding is of type key" , func () {
930+ BeforeEach (func () {
931+ binding = & korifiv1alpha1.CFServiceBinding {
932+ ObjectMeta : metav1.ObjectMeta {
933+ Name : uuid .NewString (),
934+ Namespace : space .Name ,
935+ Annotations : map [string ]string {
936+ korifiv1alpha1 .ServiceInstanceTypeAnnotation : korifiv1alpha1 .ManagedType ,
937+ },
938+ Finalizers : []string {korifiv1alpha1 .CFServiceBindingFinalizerName },
939+ },
940+ Spec : korifiv1alpha1.CFServiceBindingSpec {
941+ Service : corev1.ObjectReference {
942+ Kind : "CFServiceInstance" ,
943+ APIVersion : korifiv1alpha1 .SchemeGroupVersion .Identifier (),
944+ Name : uuid .NewString (),
945+ },
946+ Type : korifiv1alpha1 .CFServiceBindingTypeKey ,
947+ },
948+ }
949+ Expect (
950+ k8sClient .Create (ctx , binding ),
951+ ).To (Succeed ())
952+
953+ bindingGUID = binding .Name
954+ })
955+
956+ It ("deletes the binding" , func () {
957+ Expect (deleteErr ).NotTo (HaveOccurred ())
958+ actualBinding := & korifiv1alpha1.CFServiceBinding {
959+ ObjectMeta : metav1.ObjectMeta {
960+ Name : binding .Name ,
961+ Namespace : binding .Namespace ,
962+ },
963+ }
964+ Expect (k8sClient .Get (ctx , client .ObjectKeyFromObject (actualBinding ), actualBinding )).To (Succeed ())
965+ Expect (actualBinding .DeletionTimestamp ).NotTo (BeNil ())
966+ })
967+
968+ It ("does not await app state" , func () {
969+ Expect (deleteErr ).NotTo (HaveOccurred ())
970+
971+ Expect (appConditionAwaiter .AwaitStateCallCount ()).To (Equal (0 ))
972+ })
973+ })
919974 })
920975 })
921976
0 commit comments