forked from kenkoooo/AtCoderProblems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_contest_problem.rs
More file actions
35 lines (30 loc) · 958 Bytes
/
test_contest_problem.rs
File metadata and controls
35 lines (30 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use sql_client::contest_problem::ContestProblemClient;
use sql_client::models::ContestProblem;
use sql_client::PgPool;
mod utils;
fn create_problem(id: i32) -> ContestProblem {
ContestProblem {
contest_id: format!("contest{}", id),
problem_id: format!("problem{}", id),
problem_index: format!("{}", id),
}
}
#[sqlx::test]
async fn test_contest_problem(pool: PgPool) {
utils::initialize(&pool).await;
assert!(pool.load_contest_problem().await.unwrap().is_empty());
pool.insert_contest_problem(&[create_problem(1), create_problem(2)])
.await
.unwrap();
assert_eq!(
pool.load_contest_problem().await.unwrap(),
vec![create_problem(1), create_problem(2)]
);
pool.insert_contest_problem(&[create_problem(1)])
.await
.unwrap();
assert_eq!(
pool.load_contest_problem().await.unwrap(),
vec![create_problem(1), create_problem(2)]
);
}