67 lines
2 KiB
Rust
67 lines
2 KiB
Rust
mod fixtures;
|
|
mod utils;
|
|
|
|
use fixtures::{server, Error, TestServer, DIR_NO_FOUND, DIR_NO_INDEX};
|
|
use rstest::rstest;
|
|
|
|
#[rstest]
|
|
fn render_index(#[with(&["--render-index"])] server: TestServer) -> Result<(), Error> {
|
|
let resp = reqwest::blocking::get(server.url())?;
|
|
let text = resp.text()?;
|
|
assert_eq!(text, "This is index.html");
|
|
Ok(())
|
|
}
|
|
|
|
#[rstest]
|
|
fn render_index2(#[with(&["--render-index"])] server: TestServer) -> Result<(), Error> {
|
|
let resp = reqwest::blocking::get(format!("{}{}", server.url(), DIR_NO_INDEX))?;
|
|
assert_eq!(resp.status(), 404);
|
|
Ok(())
|
|
}
|
|
|
|
#[rstest]
|
|
fn render_try_index(#[with(&["--render-try-index"])] server: TestServer) -> Result<(), Error> {
|
|
let resp = reqwest::blocking::get(server.url())?;
|
|
let text = resp.text()?;
|
|
assert_eq!(text, "This is index.html");
|
|
Ok(())
|
|
}
|
|
|
|
#[rstest]
|
|
fn render_try_index2(#[with(&["--render-try-index"])] server: TestServer) -> Result<(), Error> {
|
|
let resp = reqwest::blocking::get(format!("{}{}", server.url(), DIR_NO_INDEX))?;
|
|
let files: Vec<&str> = self::fixtures::FILES
|
|
.iter()
|
|
.filter(|v| **v != "index.html")
|
|
.cloned()
|
|
.collect();
|
|
assert_index_resp!(resp, files);
|
|
Ok(())
|
|
}
|
|
|
|
#[rstest]
|
|
fn render_try_index3(#[with(&["--render-try-index"])] server: TestServer) -> Result<(), Error> {
|
|
let resp = reqwest::blocking::get(format!("{}{}?zip", server.url(), DIR_NO_INDEX))?;
|
|
assert_eq!(resp.status(), 200);
|
|
assert_eq!(
|
|
resp.headers().get("content-type").unwrap(),
|
|
"application/zip"
|
|
);
|
|
Ok(())
|
|
}
|
|
|
|
#[rstest]
|
|
fn render_spa(#[with(&["--render-spa"])] server: TestServer) -> Result<(), Error> {
|
|
let resp = reqwest::blocking::get(server.url())?;
|
|
let text = resp.text()?;
|
|
assert_eq!(text, "This is index.html");
|
|
Ok(())
|
|
}
|
|
|
|
#[rstest]
|
|
fn render_spa2(#[with(&["--render-spa"])] server: TestServer) -> Result<(), Error> {
|
|
let resp = reqwest::blocking::get(format!("{}{}", server.url(), DIR_NO_FOUND))?;
|
|
let text = resp.text()?;
|
|
assert_eq!(text, "This is index.html");
|
|
Ok(())
|
|
}
|