Commit Graph

12 Commits

Author SHA1 Message Date
Niketh Murali
4665b0aa5a Fix clippy warnings
Fix linter warning from clippy about unnecessary borrows - "This expression borrows a reference ... that is immediately dereferenced by the compiler"
2021-08-13 09:26:04 +02:00
Martin Algesten
b42e9afd71 Fix clippy warnings 2021-03-24 20:29:43 +01:00
Joshua Nelson
f0245aad23 Fix some clippy lints (#292)
This commit can be replicated with `cargo +nightly clippy --fix -Z unstable-options`,
plus an edit to fix another `return` missed by clippy.
2021-01-03 20:10:43 -08:00
Joshua Nelson
498b7137c2 Make tests much easier to debug
- Don't panic on the mutex in all tests if a single test fails
- Give a more helpful message if a test handler wasn't registered
- Enable env_logger for tests
2021-01-03 20:26:17 -05:00
Jacob Hoffman-Andrews
b9e3d3e76c Fix test 2020-12-06 14:55:55 -08:00
Joshua Nelson
37f991fa50 Make sure the redirects doctest actually tests something for 301 redirects 2020-12-05 15:03:47 +01:00
Joshua Nelson
4a3d3c49a1 Note that 307 redirects aren't followed in the docs 2020-12-05 15:03:47 +01:00
Jacob Hoffman-Andrews
4cb856196e Rename some call sites for read_headers.
Fixes tests.
2020-11-15 22:35:42 +01:00
Martin Algesten
d4af920b53 Fix body send doc tests 2020-11-15 21:10:19 +01:00
Jacob Hoffman-Andrews
daa63d3bc6 Update some more doctests.
I missed these in my previous doctest PR.

The doctests all now run without accessing the network. Tested by
turning off networking and running them.

Request.call's doctest wouldn't run because it relied on making a custom
AgentBuilder and building it, which bypasses the test_agent. I concluded
that this doctest was mostly illustrating behavior of AgentBuilder, not
call(), and simplified it to be more like the other calling methods on
request.
2020-11-15 09:14:19 +01:00
Jacob Hoffman-Andrews
203573d27c Implement more realistic doctests. (#222)
Add is_test and fn main headers to various doctests, and use real
URLs along with the ? operator.
2020-11-14 09:53:15 -08:00
Jacob Hoffman-Andrews
acc36ac370 Add support for using testserver in doctests. (#218)
Doctests run against a normally-built copy of the crate, i.e. one
without #[cfg(test)] set, so we can't use the conditional compilation
feature.

Instead, define a static var that indicates whether the library is
running in test mode or not. For each doctest, insert a hidden call that
sets this var to true. Then, when ureq::agent() is called, it returns a
test_agent instead.

This required moving testserver out of the test mod and into src/, so
that it can be included unconditionally (i.e. when cfg(test) is false).

This PR converts one doctest as an example. If we land this PR, I'll
send a followup to convert the rest.
2020-11-13 10:40:16 -08:00