Skip to content

Commit

Permalink
Uncomment threads tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lipanski committed Mar 11, 2023
1 parent 6e2064d commit ed338fa
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1482,22 +1482,28 @@ fn test_request_from_thread() {
}

#[test]
#[ignore]
fn test_mock_from_inside_thread_does_not_lock_forever() {
let mut s = Server::new();
let host = s.host_with_port();
let _mock_outside_thread = s.mock("GET", "/").with_body("outside").create();
let server = Arc::new(Mutex::new(Server::new()));
let host;
let _mock_outside_thread;

{
let s1_mutex = server.clone();
let mut s1 = s1_mutex.lock().unwrap();
host = s1.host_with_port();
_mock_outside_thread = s1.mock("GET", "/").with_body("outside").create();
}

let server_mutex = Arc::new(Mutex::new(s));
let server_clone = server_mutex;
let s2_mutex = server.clone();
let process = thread::spawn(move || {
let mut s = server_clone.lock().unwrap();
let _mock_inside_thread = s.mock("GET", "/").with_body("inside").create();
let mut s2 = s2_mutex.lock().unwrap();
let _mock_inside_thread = s2.mock("GET", "/").with_body("inside").create();
});

process.join().unwrap();

let (_, _, body) = request(&host, "GET /", "");
let (status_line, _, body) = request(&host, "GET /", "");
assert!(status_line.starts_with("HTTP/1.1 200 "));
assert_eq!("outside", body);
}

Expand Down

0 comments on commit ed338fa

Please sign in to comment.