Skip to content

Commit 2d307fa

Browse files
committed
move 404 test
1 parent 5e34f29 commit 2d307fa

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

tests/basic/mod.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,6 @@ async fn test_404() {
4343
}
4444
}
4545

46-
#[actix_web::test]
47-
async fn test_404_fallback() {
48-
for f in [
49-
"/tests/does_not_exist.sql",
50-
"/tests/does_not_exist.html",
51-
"/tests/does_not_exist/",
52-
] {
53-
let resp_result = req_path(f).await;
54-
let resp = resp_result.unwrap();
55-
assert_eq!(resp.status(), http::StatusCode::OK, "{f} isnt 200");
56-
57-
let body = test::read_body(resp).await;
58-
assert!(body.starts_with(b"<!DOCTYPE html>"));
59-
let body = String::from_utf8(body.to_vec()).unwrap();
60-
assert!(body.contains("But the "));
61-
assert!(body.contains("404.sql"));
62-
assert!(body.contains("file saved the day!"));
63-
assert!(!body.contains("error"));
64-
}
65-
}
66-
6746
#[actix_web::test]
6847
async fn test_static_files() {
6948
let resp = req_path("/tests/it_works.txt").await.unwrap();

tests/core/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use actix_web::{
2-
http::StatusCode,
3-
test,
4-
};
1+
use actix_web::{http::StatusCode, test};
52
use sqlpage::{webserver, AppState};
63
use sqlx::Executor as _;
74

File renamed without changes.

tests/errors/mod.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use actix_web::{http::StatusCode, test};
1+
use actix_web::{
2+
http::{self, StatusCode},
3+
test,
4+
};
25

36
use crate::common::req_path;
47

@@ -17,3 +20,24 @@ async fn test_privileged_paths_are_not_accessible() {
1720
.to_lowercase()
1821
.contains("forbidden"),);
1922
}
23+
24+
#[actix_web::test]
25+
async fn test_404_fallback() {
26+
for f in [
27+
"/tests/errors/does_not_exist.sql",
28+
"/tests/errors/does_not_exist.html",
29+
"/tests/errors/does_not_exist/",
30+
] {
31+
let resp_result = req_path(f).await;
32+
let resp = resp_result.unwrap();
33+
assert_eq!(resp.status(), http::StatusCode::OK, "{f} isnt 200");
34+
35+
let body = test::read_body(resp).await;
36+
assert!(body.starts_with(b"<!DOCTYPE html>"));
37+
let body = String::from_utf8(body.to_vec()).unwrap();
38+
assert!(body.contains("But the "));
39+
assert!(body.contains("404.sql"));
40+
assert!(body.contains("file saved the day!"));
41+
assert!(!body.contains("error"));
42+
}
43+
}

0 commit comments

Comments
 (0)