-
Notifications
You must be signed in to change notification settings - Fork 309
api: Write tests for ApiConnection.get, post, postFileFromStream #112
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
Merged
Conversation
This file contains hidden or 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 includes a "TODO(checks)" comment, indicating a question that should go upstream for the `package:checks` beta.
This will make things a bit cleaner later, when we accept more parameters.
Also unpack a TODO comment into a softer invitation to expand the API, and a list of suggestions. (This wasn't really an actionable TODO in the first place; its real function was always more to just disclaim any belief that the API was sufficient, as an invitation to go ahead and expand it when needed.)
Seems most logical, given that the account contains the auth. And this will enable us to test that the auth information gets appropriately included in the HTTP request. (The API key should of course be a fake one; the tests shouldn't have any other kind of API key in the first place. And the fake connection won't generate any real network requests in any case, because it uses a FakeHttpClient.)
Caught this when I wrote tests for this method and its peers. Those tests are coming in the next commit.
LGTM, thanks! Merging. |
(Nice!) |
This was referenced May 24, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The main ingredient here is that we have FakeHttpClient log the last
http.Request
object it was passed, and we add somepackage:checks
extensions so that tests can conveniently inspect that request.We also fix a small bug in
ApiConnection.postFileFromStream
, which writing these tests uncovered: it was doubling the slash at the start of the URL path.This makes another step toward #37.