lipanski / mockito

HTTP mocking for Rust!
MIT License
695 stars 59 forks source link

Always fail with reqwest blocking #144

Closed kinosang closed 1 year ago

kinosang commented 3 years ago
use core::time::Duration;
use reqwest::header::USER_AGENT;

let _m = mock("GET", "/hello")
    .with_status(200)
    .with_header("content-type", "text/plain")
    .with_body("Hello World")
    .create();

let host = mockito::server_url();

let timeout = Duration::from_millis(3_000);

let client = reqwest::blocking::Client::new();

let req = client
    .get(format!("{}/hello", host))
    .header(USER_AGENT, "ParamiLinker/1.0")
    .timeout(timeout);

let res = req.send().unwrap();

assert_eq!(res.bytes().unwrap().to_vec(), b"Hello World".to_vec());

fail to assert or got 503 error

left: `[]`,
right: `[72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]`
lipanski commented 1 year ago

This should be fixed in https://github.com/lipanski/mockito/releases/tag/0.32.0