Skip to content

Commit

Permalink
Fixed some tests after the merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ddraganovv committed Jan 14, 2025
1 parent f3da3cf commit bff0d02
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions api/payloads/service_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion api/payloads/service_binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ var _ = Describe("ServiceBindingCreate", func() {
Expect(apiError.Detail()).To(ContainSubstring("name cannot be blank"))
})
})

})

When("all relationships are missing", func() {
Expand Down Expand Up @@ -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",
},
Expand Down
23 changes: 11 additions & 12 deletions api/repositories/service_binding_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
})

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -621,29 +621,29 @@ 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() {
Expect(createErr).To(BeAssignableToTypeOf(apierrors.UnprocessableEntityError{}))
})
})

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")))
})
})

When("binding type is key", func() {
BeforeEach(func() {
createMsg.Type = korifiv1alpha1.CFServiceBindingTypeKey
createMsg.AppGUID = ""
createMsg.Name = tools.PtrTo(serviceBindingName)
createRoleBinding(ctx, userName, spaceDeveloperRole.Name, space.Name)
})

Expand Down Expand Up @@ -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()),
}),
}),
}))
})
Expand Down Expand Up @@ -1238,5 +1238,4 @@ var _ = Describe("ServiceBindingRepo", func() {
})
})
})

})

0 comments on commit bff0d02

Please sign in to comment.