Added positive test case for If-Modified-Since

This commit is contained in:
William 2019-02-08 18:31:33 +01:00
parent dfff2fd634
commit 9ab2d35e6b
1 changed files with 19 additions and 1 deletions

View File

@ -968,7 +968,25 @@ mod tests {
} }
#[test] #[test]
fn test_if_modified_since_ignored() { fn test_if_modified_since_without_if_none_match() {
let mut file = NamedFile::open("Cargo.toml")
.unwrap()
.set_cpu_pool(CpuPool::new(1));
let since = header::HttpDate::from(
SystemTime::now().add(Duration::from_secs(60)));
let req = TestRequest::default()
.header(header::IF_MODIFIED_SINCE, since)
.finish();
let resp = file.respond_to(&req).unwrap();
assert_eq!(
resp.status(),
StatusCode::NOT_MODIFIED
);
}
#[test]
fn test_if_modified_since_with_if_none_match() {
let mut file = NamedFile::open("Cargo.toml") let mut file = NamedFile::open("Cargo.toml")
.unwrap() .unwrap()
.set_cpu_pool(CpuPool::new(1)); .set_cpu_pool(CpuPool::new(1));