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 776ae08
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 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
6 changes: 4 additions & 2 deletions tests/e2e/service_plans_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ var _ = Describe("Service Plans", func() {
})

Describe("Delete Visibility", func() {
JustBeforeEach(func() {
var err error
var err error

BeforeEach(func() {
resp, err = adminClient.R().
SetBody(planVisibilityResource{
Type: "organization",
Expand All @@ -142,7 +142,9 @@ var _ = Describe("Service Plans", func() {
Expect(resp).To(SatisfyAll(
HaveRestyStatusCode(http.StatusOK),
))
})

JustBeforeEach(func() {
resp, err = adminClient.R().
SetResult(&result).
Delete(fmt.Sprintf("/v3/service_plans/%s/visibility/%s", planGUID, "org-guid"))
Expand Down

0 comments on commit 776ae08

Please sign in to comment.