@@ -161,6 +161,8 @@ mod tests {
161161 use super :: * ;
162162 use crate :: test_helpers:: * ;
163163 use axum:: { routing:: post, Router } ;
164+ use http:: header:: CONTENT_TYPE ;
165+ use http:: StatusCode ;
164166
165167 #[ tokio:: test]
166168 async fn decode_body ( ) {
@@ -182,9 +184,11 @@ mod tests {
182184 let client = TestClient :: new ( app) ;
183185 let res = client. post ( "/" ) . body ( input. encode_to_vec ( ) ) . await ;
184186
187+ let status = res. status ( ) ;
185188 let body = res. text ( ) . await ;
186189
187- assert_eq ! ( body, "bar" ) ;
190+ assert_eq ! ( status, StatusCode :: OK ) ;
191+ assert_eq ! ( body, input. foo) ;
188192 }
189193
190194 #[ tokio:: test]
@@ -211,6 +215,7 @@ mod tests {
211215 let res = client. post ( "/" ) . body ( input. encode_to_vec ( ) ) . await ;
212216
213217 assert_eq ! ( res. status( ) , StatusCode :: UNPROCESSABLE_ENTITY ) ;
218+ assert ! ( res. text( ) . await . starts_with( "Failed to decode the body" ) ) ;
214219 }
215220
216221 #[ tokio:: test]
@@ -243,15 +248,20 @@ mod tests {
243248 let client = TestClient :: new ( app) ;
244249 let res = client. post ( "/" ) . body ( input. encode_to_vec ( ) ) . await ;
245250
251+ let content_type_header_value = res
252+ . headers ( )
253+ . get ( CONTENT_TYPE )
254+ . expect ( "missing expected header" ) ;
255+
246256 assert_eq ! (
247- res . headers ( ) [ "content-type" ] ,
257+ content_type_header_value ,
248258 mime:: APPLICATION_OCTET_STREAM . as_ref( )
249259 ) ;
250260
251261 let body = res. bytes ( ) . await ;
252262
253263 let output = Output :: decode ( body) . unwrap ( ) ;
254264
255- assert_eq ! ( output. result, "bar" ) ;
265+ assert_eq ! ( output. result, input . foo ) ;
256266 }
257267}
0 commit comments