@@ -59,14 +59,17 @@ async fn test_list() {
59
59
60
60
assert_eq ! ( response, json!( [ ] ) ) ;
61
61
62
- let request = test:: TestRequest :: post ( )
62
+ let response = test:: TestRequest :: post ( )
63
63
. uri ( "/internal-api/list/create" )
64
64
. insert_header ( ( "Cookie" , format ! ( "token={}" , token) ) )
65
65
. set_json ( json ! ( { "list_name" : "a" } ) )
66
- . to_request ( ) ;
67
- let value: Value = test:: call_and_read_body_json ( & app, request) . await ;
66
+ . send_request ( & app)
67
+ . await ;
68
+ assert ! ( response. status( ) . is_success( ) ) ;
68
69
69
- let internal_list_id = value. get ( "internal_list_id" ) . unwrap ( ) . as_str ( ) . unwrap ( ) ;
70
+ let value: Value = test:: read_body_json ( response) . await ;
71
+
72
+ let internal_list_id = value[ "internal_list_id" ] . as_str ( ) . unwrap ( ) ;
70
73
71
74
let request = test:: TestRequest :: get ( )
72
75
. uri ( "/internal-api/list/my" )
@@ -215,12 +218,16 @@ async fn test_list_item() {
215
218
216
219
let cookie_header = format ! ( "token={}" , VALID_TOKEN ) ;
217
220
218
- let request = test:: TestRequest :: post ( )
221
+ let response = test:: TestRequest :: post ( )
219
222
. uri ( "/internal-api/list/create" )
220
223
. insert_header ( ( "Cookie" , cookie_header. as_str ( ) ) )
221
224
. set_json ( json ! ( { "list_name" : "a" } ) )
222
- . to_request ( ) ;
223
- let response: Value = test:: call_and_read_body_json ( & app, request) . await ;
225
+ . send_request ( & app)
226
+ . await ;
227
+
228
+ assert ! ( response. status( ) . is_success( ) ) ;
229
+
230
+ let response: Value = test:: read_body_json ( response) . await ;
224
231
225
232
let internal_list_id = response[ "internal_list_id" ] . as_str ( ) . unwrap ( ) ;
226
233
@@ -345,12 +352,16 @@ async fn test_list_delete() {
345
352
346
353
let cookie_header = format ! ( "token={}" , VALID_TOKEN ) ;
347
354
348
- let request = test:: TestRequest :: post ( )
355
+ let response = test:: TestRequest :: post ( )
349
356
. uri ( "/internal-api/list/create" )
350
357
. insert_header ( ( "Cookie" , cookie_header. as_str ( ) ) )
351
358
. set_json ( json ! ( { "list_name" : "a" } ) )
352
- . to_request ( ) ;
353
- let value: Value = test:: call_and_read_body_json ( & app, request) . await ;
359
+ . send_request ( & app)
360
+ . await ;
361
+
362
+ assert ! ( response. status( ) . is_success( ) ) ;
363
+
364
+ let value: Value = test:: read_body_json ( response) . await ;
354
365
355
366
let internal_list_id = value[ "internal_list_id" ] . as_str ( ) . unwrap ( ) ;
356
367
0 commit comments