Skip to content
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

Stub include=space.organization filter when listing plan #3430

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/payloads/params/include.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type IncludeResourceRule struct {

func (r IncludeResourceRule) Validate() error {
return jellidation.ValidateStruct(&r,
jellidation.Field(&r.RelationshipPath, jellidation.Each(validation.OneOf("service_offering", "service_broker"))),
jellidation.Field(&r.RelationshipPath, jellidation.Each(validation.OneOf("service_offering", "service_broker", "space", "organization"))),
jellidation.Field(&r.Fields, jellidation.Each(validation.OneOf("guid", "name"))),
)
}
Expand Down
8 changes: 7 additions & 1 deletion api/payloads/service_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ var _ = Describe("ServicePlan", func() {
Entry("names", "names=b1,b2", payloads.ServicePlanList{Names: "b1,b2"}),
Entry("available", "available=true", payloads.ServicePlanList{Available: tools.PtrTo(true)}),
Entry("not available", "available=false", payloads.ServicePlanList{Available: tools.PtrTo(false)}),
Entry("include", "include=service_offering", payloads.ServicePlanList{
Entry("include service offering", "include=service_offering", payloads.ServicePlanList{
IncludeResourceRules: []params.IncludeResourceRule{{
RelationshipPath: []string{"service_offering"},
Fields: []string{},
}},
}),
Entry("include space organization", "include=space.organization", payloads.ServicePlanList{
IncludeResourceRules: []params.IncludeResourceRule{{
RelationshipPath: []string{"space", "organization"},
Fields: []string{},
}},
}),
Entry("service broker fields", "fields[service_offering.service_broker]=guid,name", payloads.ServicePlanList{
IncludeResourceRules: []params.IncludeResourceRule{{
RelationshipPath: []string{"service_offering", "service_broker"},
Expand Down
2 changes: 2 additions & 0 deletions api/repositories/relationships/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func (r *ResourceRelationshipsRepo) ListRelatedResources(ctx context.Context, au
authInfo,
repositories.ListServiceBrokerMessage{GUIDs: relatedResourceGUIDs},
))
case "space", "organization":
return nil, nil
}

return nil, fmt.Errorf("no repository for type %q", relatedResourceType)
Expand Down
26 changes: 24 additions & 2 deletions api/repositories/relationships/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var _ = Describe("ResourceRelationshipsRepository", func() {
Expect(listError).To(MatchError(ContainSubstring(`no repository for type "foo"`)))
})

Describe("resorce type service_offering", func() {
Describe("resource type service_offering", func() {
BeforeEach(func() {
resourceType = "service_offering"

Expand Down Expand Up @@ -91,7 +91,7 @@ var _ = Describe("ResourceRelationshipsRepository", func() {
})
})

Describe("resorce type service_broker", func() {
Describe("resource type service_broker", func() {
BeforeEach(func() {
resourceType = "service_broker"

Expand Down Expand Up @@ -139,4 +139,26 @@ var _ = Describe("ResourceRelationshipsRepository", func() {
})
})
})

Describe("resource type space", func() {
BeforeEach(func() {
resourceType = "space"
})

It("does not fail and returns an empty result", func() {
Expect(listError).NotTo(HaveOccurred())
Expect(result).To(BeEmpty())
})
})

Describe("resource type organization", func() {
BeforeEach(func() {
resourceType = "organization"
})

It("does not fail and returns an empty result", func() {
Expect(listError).NotTo(HaveOccurred())
Expect(result).To(BeEmpty())
})
})
})
Loading