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
This commit is contained in:
Joshua Nelson
2021-01-03 20:20:19 -05:00
parent 6da035b669
commit 498b7137c2
3 changed files with 22 additions and 6 deletions

View File

@@ -13,6 +13,9 @@ use crate::{Agent, AgentBuilder};
// An agent to be installed by default for tests and doctests, such
// that all hostnames resolve to a TestServer on localhost.
pub(crate) fn test_agent() -> Agent {
#[cfg(test)]
let _ = env_logger::try_init();
let testserver = TestServer::new(|mut stream: TcpStream| -> io::Result<()> {
let headers = read_request(&stream);
if headers.0.is_empty() {