-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DELETE for org in a Service Plan Visibility #3650
Add DELETE for org in a Service Plan Visibility #3650
Conversation
804fba2
to
2922cb8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments inline
api/handlers/service_plan_test.go
Outdated
@@ -350,4 +351,46 @@ var _ = Describe("ServicePlan", func() { | |||
}) | |||
}) | |||
}) | |||
|
|||
Describe("DELETE /v3/service_plans/{guid}/visibility/{org-guid}", func() { | |||
BeforeEach(func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This BeforeEach
is unnecessary as the service plan repository fake will return nil by default
api/handlers/service_plan.go
Outdated
ServicePlanVisivilityPath = "/v3/service_plans/{guid}/visibility" | ||
ServicePlansPath = "/v3/service_plans" | ||
ServicePlanVisibilityPath = "/v3/service_plans/{guid}/visibility" | ||
ServicePlanVisibilityOrgPath = ServicePlanVisibilityPath + "/{org-guid}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion it would be more readable if the path is a plain single string:
ServicePlanVisibilityOrgPath = "/v3/service_plans/{guid}/visibility/{org-guid}"
Having it plain makes it easier to get what endpoints are implemented with a single glance. It also makes it easier to extract this information with a script
api/handlers/service_plan_test.go
Outdated
Expect(rr).To(HaveHTTPStatus(http.StatusNoContent)) | ||
}) | ||
|
||
When("deleting the visibility fails with not found", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The handler does not process not found any differently than a generic error, so this test does not add more value then the one below.
|
||
When("the user is not authorized", func() { | ||
BeforeEach(func() { | ||
visibilityErr = repo.DeletePlanVisibility(ctx, authInfo, repositories.DeleteServicePlanVisibilityMessage{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could go to a Describe-global JustBeforeEach
as it is invoking the code under test. This will also reduce duplication
}, | ||
} | ||
Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(servicePlan), servicePlan)).To(Succeed()) | ||
Expect(servicePlan.Spec.Visibility.Organizations).To(Equal([]string{cfOrg.Name})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we could conveniently use gomega's ConsistOf
matcher
Expect(servicePlan.Spec.Visibility.Organizations).To(ConsistOf(cfOrg.Name))
}, | ||
} | ||
Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(servicePlan), servicePlan)).To(Succeed()) | ||
Expect(servicePlan.Spec.Visibility.Organizations).To(Equal([]string{cfOrg.Name, anotherOrg.Name})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above comment about usingConsistsOf
In addition to @georgethebeatle's comments, as this is a new endpoint, I would also like to have an e2e test that excercises deleting orgs from plan visibility PS: In the spirit of e2e tests, the new test should cover the very basic happy path, i.e. don't bother testing error cases (not authorised, or org not found) |
a31e6c6
to
f5df5f7
Compare
@danail-branekov @georgethebeatle Did some changes, let me know if all is good so I can fix the conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added some comments on the tests sctrucuture, looks all right otherwise.
}) | ||
|
||
When("the plan does not exist", func() { | ||
JustBeforeEach(func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you create a variable for the delete message and default it to the value you use in the describe's JustBeforeEach
in the BeforeEach
, then in each context's BeforeEach
you could just override the message and not invoke the method under test (DeleteServicePlanVisibility
) over and over again.
I.e.
Describe("DeletePlanVisibility", func() {
var deleteMessage repositories.DeleteServicePlanVisibilityMessage
BeforeEach(func(){
deleteMessage = repositories.DeleteServicePlanVisibilityMessage{
PlanGUID: planGUID,
OrgGUID: anotherOrg.Name,
}
})
JustBeforeEach(func(){
visibilityErr = repo.DeletePlanVisibility(ctx, authInfo, deleteMessage)
})
.........
When("the plan does not exist", func() {
BeforeEach(func(){
deleteMessage.PlanGUID = "i-do-not-exist"
})
It(......)
})
When("the org does not exist", func() {
BeforeEach(func(){
deleteMessage.OrgGUID = "i-do-not-exist"
})
It(......)
})
})
ff64585
to
776ae08
Compare
@danail-branekov Done with the changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good, you would unfortunately have to resolve the conflicts
6fba7f0
to
55cdc5e
Compare
55cdc5e
to
c771132
Compare
Is there a related GitHub Issue?
#3645
What is this change about?
Here we add the ability to remove an organization from a service plan visibility
Does this PR introduce a breaking change?
No
Acceptance Steps
Tag your pair, your PM, and/or team