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 Jan 8, 2025
1 parent f161ec2 commit c771132
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
1 change: 1 addition & 0 deletions api/handlers/service_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"
"strings"

apierrors "code.cloudfoundry.org/korifi/api/errors"
. "code.cloudfoundry.org/korifi/api/handlers"
"code.cloudfoundry.org/korifi/api/handlers/fake"
"code.cloudfoundry.org/korifi/api/payloads"
Expand Down
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 @@ -608,6 +608,8 @@ var _ = Describe("ServicePlanRepo", func() {
})

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

BeforeEach(func() {
cfServicePlan := &korifiv1alpha1.CFServicePlan{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -619,13 +621,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 @@ -655,11 +659,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 @@ -668,11 +669,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 @@ -685,7 +683,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: 3 additions & 3 deletions tests/e2e/service_plans_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ var _ = Describe("Service Plans", func() {
})

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

BeforeEach(func() {
resp, err = adminClient.R().
SetBody(planVisibilityResource{
Type: "organization",
Expand All @@ -139,7 +137,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 c771132

Please sign in to comment.