-
Notifications
You must be signed in to change notification settings - Fork 0
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 api module with download_to
method
#3
Conversation
f006986
to
7434659
Compare
.join("pair-0.1.7.zip"); | ||
|
||
// Start a lightweight mock server. | ||
let server = MockServer::start(); |
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.
Cool! Didn't know about this one. I used to use mockito
a while back
src/error/mod.rs
Outdated
@@ -11,4 +12,30 @@ pub enum BuildError { | |||
/// Unknown pipeline error. | |||
#[error("unknown build pipeline `{0}`")] | |||
UnknownPipeline(String), | |||
|
|||
/// IO rror. |
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.
e
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.
Bah, fixed in b0f261a, thanks.
Use the `ureq` crate for simple synchronous requests, but keep it encapsulated so we can replace it later if need be. Create an agent that supports proxies and require HTTPS for all requests. Use it in the `download_to` method, but if the API base URL has a `file` schema, skip the ureq agent and copy the file directly. This will be useful for working with `rsync`d mirrors. Add variants to the BuildError enum for IO, URL parsing and formatting, and HTTP request errors from ureq. Box ureq errors because otherwise they're far to big, and [clippy complains] about the error size. Make a custom File error to improve IO errors to include the action attempted and relevant file name or names. Use `httpmock` to test the handling of `http:` URLs, and `sha2` & `tempfile` to test `file:` URLs. While at it, exclude `Cargo.lock` from `git diff`; it's just too verbose and distracting. Also use string comparison for some error tests in `src/tests.rs`. [clippy complains]: https://rust-lang.github.io/rust-clippy/master/index.html#result_large_errclippyClick
Use the
ureq
crate for simple synchronous requests, but keep it encapsulated so we can replace it later if need be. Create an agent that supports proxies and require HTTPS for all requests. Use it in thedownload_to
method, but if the API base URL has afile
schema, skip the ureq agent and copy the file directly. This will be useful for working withrsync
d mirrors.Add variants to the BuildError enum for IO, URL parsing and formatting, and HTTP request errors from ureq. Box ureq errors because otherwise they're far to big, and clippy complains about the error size. Make a custom File error to improve IO errors to include the action attempted and relevant file name or names.
Use
httpmock
to test the handling ofhttp:
URLs, andsha2
&tempfile
to testfile:
URLs.While at it, exclude
Cargo.lock
fromgit diff
; it's just too verbose and distracting. Also use string comparison for some error tests insrc/tests.rs
.