-
Notifications
You must be signed in to change notification settings - Fork 928
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
Expose api errors for service broker commands #465
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,6 +135,27 @@ var _ = Describe("Service Brokers Repo", func() { | |
Expect(apiErr).To(HaveOccurred()) | ||
Expect(apiErr.Error()).To(Equal("Service Broker my-broker not found")) | ||
}) | ||
|
||
It("returns an error when listing service brokers returns an api error", func() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This description reads odd... |
||
req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{ | ||
Method: "GET", | ||
Path: "/v2/service_brokers?q=name%3Amy-broker", | ||
Response: testnet.TestResponse{Status: http.StatusForbidden, Body: `{ | ||
"code": 10003, | ||
"description": "You are not authorized to perform the requested action", | ||
"error_code": "CF-NotAuthorized" | ||
}`}, | ||
}) | ||
|
||
ts, handler, repo := createServiceBrokerRepo(req) | ||
defer ts.Close() | ||
|
||
_, apiErr := repo.FindByName("my-broker") | ||
|
||
Expect(handler).To(HaveAllRequestsCalled()) | ||
Expect(apiErr).To(HaveOccurred()) | ||
Expect(apiErr.Error()).To(Equal("Server error, status code: 403, error code: 10003, message: You are not authorized to perform the requested action")) | ||
}) | ||
}) | ||
|
||
Describe("FindByGuid", func() { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Also, since you have now added another variable to the conditional, I expected at least two more tests or really four totals:
foundBroker and apiErr nil
,foundBroker and apiErr not nil
,!foundBroker and apiErr nil
, and!foundBroker and apiErr not nil
.Are you compacting the tests or am I missing something?
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 think the test coverage is sufficient; there's no case where we'd have a list of service brokers to search as well as an apiErr from CC. If we get a CC error, we return from ListPaginatedResources before ever searching for a potential service broker. foundBroker will always remain false if there's a CC error.
This block covers a weird case: the CC may return 200 with an empty list, so we make our own error in this if-block. The additional check is a bug fix; the previous behavior was ignoring existing CC errors and would overwrite them with the ModelNotFoundError.
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.
Hmm, OK. I guess I'd then simplify the conditional into two. However, we are splitting hair here so if others are OK then I am happy to be cool with it. Cheers.