Skip to content

Commit d7d1e4a

Browse files
committed
async fn内のでファイル読み込みを非同期にした
1 parent 41ffc2c commit d7d1e4a

File tree

1 file changed

+2
-5
lines changed
  • atcoder-problems-backend/sql-client/tests/utils

1 file changed

+2
-5
lines changed

atcoder-problems-backend/sql-client/tests/utils/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use sql_client::PgPool;
22
use sqlx::Executor;
3-
use std::fs::File;
4-
use std::io::prelude::*;
3+
use tokio::fs;
54

65
const SQL_FILE: &str = "../../config/database-definition.sql";
76
const SQL_URL_ENV_KEY: &str = "SQL_URL";
@@ -30,9 +29,7 @@ pub async fn initialize_and_connect_to_test_sql() -> PgPool {
3029
}
3130

3231
async fn initialize(pool: &PgPool) {
33-
let mut file = File::open(SQL_FILE).unwrap();
34-
let mut sql = String::new();
35-
file.read_to_string(&mut sql).unwrap();
32+
let sql = fs::read_to_string(SQL_FILE).await.unwrap();
3633
let mut conn = pool.acquire().await.unwrap();
3734
conn.execute(sql.as_str()).await.unwrap();
3835
}

0 commit comments

Comments
 (0)