File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -807,3 +807,26 @@ impl ResponseHeaders for http::response::Builder {
807807 self
808808 }
809809}
810+
811+ #[ cfg( test) ]
812+ mod tests {
813+ use super :: * ;
814+ #[ tokio:: test]
815+ async fn handle_fs_path_html ( ) {
816+ // Test case 1: Path is ""
817+ let req = Request :: default ( ) ;
818+ let path = "" ;
819+ let use_compression = false ;
820+ let response = handle_fs_path ( & req, path, use_compression) . await . unwrap ( ) ;
821+ // "", "/", "/index.html", "/graphs.html" map to "graphs.html"
822+ let expected_body = TEMPLATES . get_template ( "graphs.html" ) . await . unwrap ( ) ;
823+ let expected_response = http:: Response :: builder ( )
824+ . header_typed ( ETag :: from_str ( & format ! ( r#""{}""# , * VERSION_UUID ) ) . unwrap ( ) )
825+ . header ( CACHE_CONTROL , "max-age=60, stale-while-revalidate=86400" )
826+ . header_typed ( ContentType :: html ( ) )
827+ . body ( hyper:: Body :: from ( expected_body) )
828+ . unwrap ( ) ;
829+ assert_eq ! ( response. headers( ) , expected_response. headers( ) ) ;
830+ assert_eq ! ( hyper:: body:: to_bytes( response. into_body( ) ) . await . unwrap( ) , hyper:: body:: to_bytes( expected_response. into_body( ) ) . await . unwrap( ) ) ;
831+ }
832+ }
You can’t perform that action at this time.
0 commit comments