From bff0d0204c0749aa0d8345071b38ab4cf477bbbf Mon Sep 17 00:00:00 2001 From: Dimitar Draganov Date: Tue, 14 Jan 2025 09:19:04 +0200 Subject: [PATCH] Fixed some tests after the merge conflicts --- api/payloads/service_binding.go | 4 ++-- api/payloads/service_binding_test.go | 2 +- .../service_binding_repository_test.go | 23 +++++++++---------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/api/payloads/service_binding.go b/api/payloads/service_binding.go index 0e1901e4c..58b07c00a 100644 --- a/api/payloads/service_binding.go +++ b/api/payloads/service_binding.go @@ -42,12 +42,12 @@ func (p ServiceBindingCreate) Validate() error { jellidation.Field(&p.Relationships, jellidation.By(func(value any) error { relationships, ok := value.(*ServiceBindingRelationships) if !ok || relationships == nil { - return errors.New("relationships cannot be blank") + return errors.New("relationships is required") } if p.Type == "app" { if relationships.App == nil { - return jellidation.NewError("validation_required", "relationships.app cannot be blank") + return jellidation.NewError("validation_required", "relationships.app is required") } if relationships.App.Data.GUID == "" { return jellidation.NewError("validation_required", "relationships.app.data.guid cannot be blank") diff --git a/api/payloads/service_binding_test.go b/api/payloads/service_binding_test.go index 8c1326f06..c233d08fd 100644 --- a/api/payloads/service_binding_test.go +++ b/api/payloads/service_binding_test.go @@ -149,7 +149,6 @@ var _ = Describe("ServiceBindingCreate", func() { Expect(apiError.Detail()).To(ContainSubstring("name cannot be blank")) }) }) - }) When("all relationships are missing", func() { @@ -243,6 +242,7 @@ var _ = Describe("ServiceBindingCreate", func() { ServiceInstanceGUID: createPayload.Relationships.ServiceInstance.Data.GUID, AppGUID: createPayload.Relationships.App.Data.GUID, SpaceGUID: "space-guid", + Type: "app", Parameters: map[string]any{ "p1": "p1-value", }, diff --git a/api/repositories/service_binding_repository_test.go b/api/repositories/service_binding_repository_test.go index 4b1c5c1d5..82c3c24ff 100644 --- a/api/repositories/service_binding_repository_test.go +++ b/api/repositories/service_binding_repository_test.go @@ -271,10 +271,10 @@ var _ = Describe("ServiceBindingRepo", func() { JustBeforeEach(func() { serviceBindingRecord, createErr = repo.CreateServiceBinding(ctx, authInfo, repositories.CreateServiceBindingMessage{ Type: korifiv1alpha1.CFServiceBindingTypeApp, - Name: bindingName, ServiceInstanceGUID: cfServiceInstance.Name, AppGUID: appGUID, SpaceGUID: space.Name, + Name: bindingName, }) }) @@ -524,7 +524,7 @@ var _ = Describe("ServiceBindingRepo", func() { createMsg = repositories.CreateServiceBindingMessage{ Type: korifiv1alpha1.CFServiceBindingTypeApp, - Name: &serviceBindingName, + Name: nil, ServiceInstanceGUID: cfServiceInstance.Name, AppGUID: appGUID, SpaceGUID: space.Name, @@ -577,7 +577,7 @@ var _ = Describe("ServiceBindingRepo", func() { }), "Spec": MatchFields(IgnoreExtras, Fields{ "Type": Equal(korifiv1alpha1.CFServiceBindingTypeApp), - "DisplayName": PointTo(Equal(serviceBindingName)), + "DisplayName": BeNil(), "Service": Equal(corev1.ObjectReference{ Kind: "CFServiceInstance", APIVersion: korifiv1alpha1.SchemeGroupVersion.Identifier(), @@ -621,7 +621,7 @@ var _ = Describe("ServiceBindingRepo", func() { When("the app does not exist", func() { BeforeEach(func() { - appGUID = "i-do-not-exits" + createMsg.AppGUID = "i-do-not-exits" }) It("returns an UnprocessableEntity error", func() { @@ -629,14 +629,13 @@ var _ = Describe("ServiceBindingRepo", func() { }) }) - When("The service binding has a name", func() { + When("the service binding has a name", func() { BeforeEach(func() { - tempName := "some-name-for-a-binding" - bindingName = &tempName + createMsg.Name = tools.PtrTo("some-name-for-a-binding") }) It("creates the binding with the specified name", func() { - Expect(serviceBindingRecord.Name).To(Equal(bindingName)) + Expect(serviceBindingRecord.Name).To(Equal(tools.PtrTo("some-name-for-a-binding"))) }) }) @@ -644,6 +643,7 @@ var _ = Describe("ServiceBindingRepo", func() { BeforeEach(func() { createMsg.Type = korifiv1alpha1.CFServiceBindingTypeKey createMsg.AppGUID = "" + createMsg.Name = tools.PtrTo(serviceBindingName) createRoleBinding(ctx, userName, spaceDeveloperRole.Name, space.Name) }) @@ -680,9 +680,9 @@ var _ = Describe("ServiceBindingRepo", func() { APIVersion: korifiv1alpha1.SchemeGroupVersion.Identifier(), Name: cfServiceInstance.Name, }), - }), - "Parameters": MatchAllFields(Fields{ - "Name": Not(BeEmpty()), + "Parameters": MatchAllFields(Fields{ + "Name": Not(BeEmpty()), + }), }), })) }) @@ -1238,5 +1238,4 @@ var _ = Describe("ServiceBindingRepo", func() { }) }) }) - })