sigoden
3 years ago
committed by
GitHub
4 changed files with 113 additions and 55 deletions
@ -0,0 +1,61 @@
@@ -0,0 +1,61 @@
|
||||
mod fixtures; |
||||
mod utils; |
||||
|
||||
use fixtures::{server, Error, TestServer}; |
||||
use rstest::rstest; |
||||
|
||||
#[rstest] |
||||
fn assets(server: TestServer) -> Result<(), Error> { |
||||
let ver = env!("CARGO_PKG_VERSION"); |
||||
let resp = reqwest::blocking::get(server.url())?; |
||||
let index_js = format!("/__dufs_v{}_index.js", ver); |
||||
let index_css = format!("/__dufs_v{}_index.css", ver); |
||||
let favicon_ico = format!("/__dufs_v{}_favicon.ico", ver); |
||||
let text = resp.text()?; |
||||
assert!(text.contains(&format!(r#"href="{}""#, index_css))); |
||||
assert!(text.contains(&format!(r#"href="{}""#, favicon_ico))); |
||||
assert!(text.contains(&format!(r#"src="{}""#, index_js))); |
||||
Ok(()) |
||||
} |
||||
|
||||
#[rstest] |
||||
fn asset_js(server: TestServer) -> Result<(), Error> { |
||||
let url = format!( |
||||
"{}__dufs_v{}_index.js", |
||||
server.url(), |
||||
env!("CARGO_PKG_VERSION") |
||||
); |
||||
let resp = reqwest::blocking::get(url)?; |
||||
assert_eq!(resp.status(), 200); |
||||
assert_eq!( |
||||
resp.headers().get("content-type").unwrap(), |
||||
"application/javascript" |
||||
); |
||||
Ok(()) |
||||
} |
||||
|
||||
#[rstest] |
||||
fn asset_css(server: TestServer) -> Result<(), Error> { |
||||
let url = format!( |
||||
"{}__dufs_v{}_index.css", |
||||
server.url(), |
||||
env!("CARGO_PKG_VERSION") |
||||
); |
||||
let resp = reqwest::blocking::get(url)?; |
||||
assert_eq!(resp.status(), 200); |
||||
assert_eq!(resp.headers().get("content-type").unwrap(), "text/css"); |
||||
Ok(()) |
||||
} |
||||
|
||||
#[rstest] |
||||
fn asset_ico(server: TestServer) -> Result<(), Error> { |
||||
let url = format!( |
||||
"{}__dufs_v{}_favicon.ico", |
||||
server.url(), |
||||
env!("CARGO_PKG_VERSION") |
||||
); |
||||
let resp = reqwest::blocking::get(url)?; |
||||
assert_eq!(resp.status(), 200); |
||||
assert_eq!(resp.headers().get("content-type").unwrap(), "image/x-icon"); |
||||
Ok(()) |
||||
} |
@ -1,25 +0,0 @@
@@ -1,25 +0,0 @@
|
||||
mod fixtures; |
||||
mod utils; |
||||
|
||||
use fixtures::{server, Error, TestServer}; |
||||
use rstest::rstest; |
||||
|
||||
#[rstest] |
||||
fn default_favicon(server: TestServer) -> Result<(), Error> { |
||||
let resp = reqwest::blocking::get(format!("{}favicon.ico", server.url()))?; |
||||
assert_eq!(resp.status(), 200); |
||||
assert_eq!(resp.headers().get("content-type").unwrap(), "image/x-icon"); |
||||
Ok(()) |
||||
} |
||||
|
||||
#[rstest] |
||||
fn exist_favicon(#[with(&["-A"])] server: TestServer) -> Result<(), Error> { |
||||
let url = format!("{}favicon.ico", server.url()); |
||||
let data = b"abc"; |
||||
let resp = fetch!(b"PUT", &url).body(data.to_vec()).send()?; |
||||
assert_eq!(resp.status(), 201); |
||||
let resp = reqwest::blocking::get(url)?; |
||||
assert_eq!(resp.status(), 200); |
||||
assert_eq!(resp.bytes()?, data.to_vec()); |
||||
Ok(()) |
||||
} |
Loading…
Reference in new issue