File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ SELECT ' alert' AS component,
2
+ ' We almost got an oopsie' AS title,
3
+ ' But the `404.sql` file saved the day!' AS description_md;
Original file line number Diff line number Diff line change @@ -51,6 +51,28 @@ async fn test_404() {
51
51
}
52
52
}
53
53
54
+ #[ actix_web:: test]
55
+ async fn test_404_fallback ( ) {
56
+ for f in [
57
+ "/tests/does_not_exist.sql" ,
58
+ "/tests/does_not_exist.html" ,
59
+ "/tests/does_not_exist/" ,
60
+ ] {
61
+ let resp_result = req_path ( f) . await ;
62
+ let resp = resp_result. unwrap ( ) ;
63
+ assert_eq ! ( resp. status( ) , http:: StatusCode :: OK , "{f} isnt 200" ) ;
64
+
65
+ let body = test:: read_body ( resp) . await ;
66
+ assert ! ( body. starts_with( b"<!DOCTYPE html>" ) ) ;
67
+ // the body should contain our happy string, but not the string "error"
68
+ let body = String :: from_utf8 ( body. to_vec ( ) ) . unwrap ( ) ;
69
+ assert ! ( body. contains( "But the " ) ) ;
70
+ assert ! ( body. contains( "404.sql" ) ) ;
71
+ assert ! ( body. contains( "file saved the day!" ) ) ;
72
+ assert ! ( !body. contains( "error" ) ) ;
73
+ }
74
+ }
75
+
54
76
#[ actix_web:: test]
55
77
async fn test_concurrent_requests ( ) {
56
78
// send 32 requests (less than the default postgres pool size)
You can’t perform that action at this time.
0 commit comments