@@ -166,4 +166,25 @@ mod tests {
166166 // Test invalid method
167167 assert ! ( HttpMethod :: try_from( "INVALID" . to_string( ) ) . is_err( ) ) ;
168168 }
169+
170+ #[ test]
171+ fn test_http_method_try_from_http_handler_method ( ) {
172+ let test_cases = vec ! [
173+ ( http_handler:: Method :: GET , HttpMethod :: Get ) ,
174+ ( http_handler:: Method :: POST , HttpMethod :: Post ) ,
175+ ( http_handler:: Method :: PUT , HttpMethod :: Put ) ,
176+ ( http_handler:: Method :: DELETE , HttpMethod :: Delete ) ,
177+ ( http_handler:: Method :: PATCH , HttpMethod :: Patch ) ,
178+ ( http_handler:: Method :: HEAD , HttpMethod :: Head ) ,
179+ ( http_handler:: Method :: OPTIONS , HttpMethod :: Options ) ,
180+ ( http_handler:: Method :: TRACE , HttpMethod :: Trace ) ,
181+ ( http_handler:: Method :: CONNECT , HttpMethod :: Connect ) ,
182+ ] ;
183+
184+ for ( http_handler_method, expected_asgi_method) in test_cases {
185+ let result: Result < HttpMethod , String > = ( & http_handler_method) . try_into ( ) ;
186+ assert ! ( result. is_ok( ) , "Failed to convert {http_handler_method}" ) ;
187+ assert_eq ! ( result. unwrap( ) , expected_asgi_method) ;
188+ }
189+ }
169190}
0 commit comments