Skip to content

Commit

Permalink
Some more test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
klapkov committed Dec 12, 2024
1 parent f5df5f7 commit ff64585
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions api/repositories/service_plan_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,8 @@ var _ = Describe("ServicePlanRepo", func() {
})

Describe("DeletePlanVisibility", func() {
var deleteMessage repositories.DeleteServicePlanVisibilityMessage

BeforeEach(func() {
cfServicePlan := &korifiv1alpha1.CFServicePlan{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -615,13 +617,15 @@ var _ = Describe("ServicePlanRepo", func() {
cfServicePlan.Spec.Visibility.Type = visibilityType
cfServicePlan.Spec.Visibility.Organizations = []string{cfOrg.Name, anotherOrg.Name}
})).To(Succeed())
})

JustBeforeEach(func() {
visibilityErr = repo.DeletePlanVisibility(ctx, authInfo, repositories.DeleteServicePlanVisibilityMessage{
deleteMessage = repositories.DeleteServicePlanVisibilityMessage{
PlanGUID: planGUID,
OrgGUID: anotherOrg.Name,
})
}
})

JustBeforeEach(func() {
visibilityErr = repo.DeletePlanVisibility(ctx, authInfo, deleteMessage)
})

When("the user is not authorized", func() {
Expand Down Expand Up @@ -651,11 +655,8 @@ var _ = Describe("ServicePlanRepo", func() {
})

When("the plan does not exist", func() {
JustBeforeEach(func() {
visibilityErr = repo.DeletePlanVisibility(ctx, authInfo, repositories.DeleteServicePlanVisibilityMessage{
PlanGUID: "does-not-exist",
OrgGUID: anotherOrg.Name,
})
BeforeEach(func() {
deleteMessage.PlanGUID = "does-not-exist"
})

It("returns an NotFoundError", func() {
Expand All @@ -664,11 +665,8 @@ var _ = Describe("ServicePlanRepo", func() {
})

When("the org does not exist", func() {
JustBeforeEach(func() {
visibilityErr = repo.DeletePlanVisibility(ctx, authInfo, repositories.DeleteServicePlanVisibilityMessage{
PlanGUID: planGUID,
OrgGUID: "does-not-exist",
})
BeforeEach(func() {
deleteMessage.OrgGUID = "does-not-exist"
})

It("does not change the visibility orgs", func() {
Expand All @@ -681,7 +679,7 @@ var _ = Describe("ServicePlanRepo", func() {
},
}
Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(servicePlan), servicePlan)).To(Succeed())
Expect(servicePlan.Spec.Visibility.Organizations).To(ConsistOf(cfOrg.Name))
Expect(servicePlan.Spec.Visibility.Organizations).To(ConsistOf(cfOrg.Name, anotherOrg.Name))
})
})
})
Expand Down

0 comments on commit ff64585

Please sign in to comment.