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.
This commit is contained in:
Jacob Hoffman-Andrews
2020-11-14 16:35:11 -08:00
committed by Martin Algesten
parent 203573d27c
commit daa63d3bc6
2 changed files with 27 additions and 18 deletions

View File

@@ -22,6 +22,10 @@ pub(crate) fn test_agent() -> Agent {
stream.write_all(b"Content-Length: 100\r\n")?;
stream.write_all(b"\r\n")?;
stream.write_all(&[0; 100])?;
} else if headers.path() == "/hello_world.json" {
stream.write_all(b"HTTP/1.1 200 OK\r\n")?;
stream.write_all(b"\r\n")?;
stream.write_all(br#"{"hello": "world"}"#)?;
} else if headers.path() == "/redirect/3" {
stream.write_all(b"HTTP/1.1 302 Found\r\n")?;
stream.write_all(b"Location: /redirect/3\r\n")?;