Skip to content

Commit 03bdeae

Browse files
committed
ステータスコードを見るように
1 parent 3485f7a commit 03bdeae

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

atcoder-problems-backend/tests/test_server_e2e_problem_list.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,17 @@ async fn test_list() {
5959

6060
assert_eq!(response, json!([]));
6161

62-
let request = test::TestRequest::post()
62+
let response = test::TestRequest::post()
6363
.uri("/internal-api/list/create")
6464
.insert_header(("Cookie", format!("token={}", token)))
6565
.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());
6869

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();
7073

7174
let request = test::TestRequest::get()
7275
.uri("/internal-api/list/my")
@@ -215,12 +218,16 @@ async fn test_list_item() {
215218

216219
let cookie_header = format!("token={}", VALID_TOKEN);
217220

218-
let request = test::TestRequest::post()
221+
let response = test::TestRequest::post()
219222
.uri("/internal-api/list/create")
220223
.insert_header(("Cookie", cookie_header.as_str()))
221224
.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;
224231

225232
let internal_list_id = response["internal_list_id"].as_str().unwrap();
226233

@@ -345,12 +352,16 @@ async fn test_list_delete() {
345352

346353
let cookie_header = format!("token={}", VALID_TOKEN);
347354

348-
let request = test::TestRequest::post()
355+
let response = test::TestRequest::post()
349356
.uri("/internal-api/list/create")
350357
.insert_header(("Cookie", cookie_header.as_str()))
351358
.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;
354365

355366
let internal_list_id = value["internal_list_id"].as_str().unwrap();
356367

0 commit comments

Comments
 (0)