lipanski / mockito

HTTP mocking for Rust!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Always fail with reqwest blocking

kinosang opened this issue · comments

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]`