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

Add smoke test in examples. #85

Merged
merged 2 commits into from
Jun 24, 2020
Merged

Add smoke test in examples. #85

merged 2 commits into from
Jun 24, 2020

Conversation

jsha
Copy link
Collaborator

@jsha jsha commented Jun 23, 2020

This loads a list of top domain names (e.g. from
https://tranco-list.eu/) and tries to fetch them all, in parallel. This
can be used to exercise ureq and find panics.

This loads a list of top domain names (e.g. from
https://tranco-list.eu/) and tries to fetch them all, in parallel. This
can be used to exercise ureq and find panics.
Copy link
Contributor

@lolgesten lolgesten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! And very useful!

let hostnames = bufreader
.lines()
.map(|line| Ok(line?.rsplit(",").next().unwrap().to_string()))
.collect::<io::Result<Vec<String>>>()?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you don't need to collect, cause for var in iter { ... } works over iterator. But I guess you'd push the error handling into the for loop instead, so maybe it's cleaner this way.

type Bytes = Vec<u8>;
type Result<T> = result::Result<T, Oops>;

fn get(agent: &ureq::Agent, url: &String) -> Result<Bytes> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For someone just scanning the code, Bytes often means this crate https://docs.rs/bytes/0.5.5/bytes/#bytes

Doesn't matter much though.

@jsha jsha merged commit a6e99c8 into algesten:master Jun 24, 2020
@jsha jsha deleted the smoke-test branch June 24, 2020 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants