2022-06-12 03:43:50 +03:00
|
|
|
mod fixtures;
|
2022-06-17 03:41:01 +03:00
|
|
|
mod utils;
|
2022-06-12 03:43:50 +03:00
|
|
|
|
2023-02-20 17:50:24 +03:00
|
|
|
use fixtures::{server, Error, TestServer, BIN_FILE, DIR_NO_FOUND, DIR_NO_INDEX, FILES};
|
2022-06-12 03:43:50 +03:00
|
|
|
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]
|
2022-06-17 03:41:01 +03:00
|
|
|
fn render_index2(#[with(&["--render-index"])] server: TestServer) -> Result<(), Error> {
|
|
|
|
let resp = reqwest::blocking::get(format!("{}{}", server.url(), DIR_NO_INDEX))?;
|
2022-06-12 03:43:50 +03:00
|
|
|
assert_eq!(resp.status(), 404);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2022-06-17 03:41:01 +03:00
|
|
|
#[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))?;
|
2022-06-25 03:15:16 +03:00
|
|
|
let files: Vec<&str> = FILES
|
2022-06-17 03:41:01 +03:00
|
|
|
.iter()
|
|
|
|
.filter(|v| **v != "index.html")
|
|
|
|
.cloned()
|
|
|
|
.collect();
|
2022-06-25 03:15:16 +03:00
|
|
|
assert_resp_paths!(resp, files);
|
2022-06-17 03:41:01 +03:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2022-06-17 14:02:13 +03:00
|
|
|
#[rstest]
|
2022-12-10 06:09:42 +03:00
|
|
|
fn render_try_index3(
|
|
|
|
#[with(&["--render-try-index", "--allow-archive"])] server: TestServer,
|
|
|
|
) -> Result<(), Error> {
|
2022-06-17 14:02:13 +03:00
|
|
|
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(())
|
|
|
|
}
|
|
|
|
|
2022-07-02 18:25:57 +03:00
|
|
|
#[rstest]
|
|
|
|
#[case(server(&["--render-try-index"] as &[&str]), false)]
|
|
|
|
#[case(server(&["--render-try-index", "--allow-search"] as &[&str]), true)]
|
|
|
|
fn render_try_index4(#[case] server: TestServer, #[case] searched: bool) -> Result<(), Error> {
|
2023-02-20 17:50:24 +03:00
|
|
|
let resp = reqwest::blocking::get(format!("{}{}?q={}", server.url(), DIR_NO_INDEX, BIN_FILE))?;
|
2022-07-02 18:25:57 +03:00
|
|
|
assert_eq!(resp.status(), 200);
|
2022-08-03 03:51:12 +03:00
|
|
|
let paths = utils::retrieve_index_paths(&resp.text()?);
|
2023-02-20 17:50:24 +03:00
|
|
|
assert_eq!(paths.iter().all(|v| v.contains(BIN_FILE)), searched);
|
2022-07-02 18:25:57 +03:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2022-06-12 03:43:50 +03:00
|
|
|
#[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]
|
2022-06-17 03:41:01 +03:00
|
|
|
fn render_spa2(#[with(&["--render-spa"])] server: TestServer) -> Result<(), Error> {
|
|
|
|
let resp = reqwest::blocking::get(format!("{}{}", server.url(), DIR_NO_FOUND))?;
|
2022-06-12 03:43:50 +03:00
|
|
|
let text = resp.text()?;
|
|
|
|
assert_eq!(text, "This is index.html");
|
|
|
|
Ok(())
|
|
|
|
}
|