We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am aware of #106 but what I am interested is a way to run tests without running a server.
Rocket has something like this:
#[cfg(test)] mod test { use rocket::http::Status; use rocket::local::blocking::Client; #[test] fn hello_world() { let client = Client::tracked(super::rocket()).unwrap(); let response = client.get("/").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.into_string(), Some("Hello, world!".into())); } }
I have not seen if this possible with Rouille.
I tried to write something and got this:
#[macro_use] extern crate rouille; use rouille::{Server, Request, Response}; fn handle(req: &Request) -> Response { router!(req, (GET) (/) => { rouille::Response::html("Hello <b>world!</b>") }, _ => rouille::Response::html("This page does <b>not</b> exist.").with_status_code(404) ) } fn main() { let host = "localhost"; let port = "8000"; println!("Now listening on {host}:{port}"); let server = Server::new(format!("{host}:{port}"), move |req| { handle(req) }).expect("Err"); server.run() } #[test] fn hello_world() { let server = Server::new(format!("localhost:8000"), move |req| { handle(req) }).expect("Err"); let req = Request::fake_http( "GET", "/", vec![("Content-Type".to_owned(), "text/plain".to_owned())], b"test".to_vec()); //server.server.incoming_requests(req); }
but I still don't have the response....
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am aware of #106 but what I am interested is a way to run tests without running a server.
Rocket has something like this:
I have not seen if this possible with Rouille.
I tried to write something and got this:
but I still don't have the response....
The text was updated successfully, but these errors were encountered: