forked from kenkoooo/AtCoderProblems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_simple_client.rs
More file actions
63 lines (54 loc) · 1.57 KB
/
test_simple_client.rs
File metadata and controls
63 lines (54 loc) · 1.57 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use sql_client::models::{Contest, Problem};
use sql_client::simple_client::SimpleClient;
use sql_client::PgPool;
mod utils;
#[sqlx::test]
async fn test_insert_contests(pool: PgPool) {
utils::initialize(&pool).await;
assert!(pool.load_contests().await.unwrap().is_empty());
pool.insert_contests(&[Contest {
id: "contest1".to_string(),
start_epoch_second: 0,
duration_second: 0,
title: "".to_string(),
rate_change: "".to_string(),
}])
.await
.unwrap();
let contests = pool.load_contests().await.unwrap();
assert_eq!(contests[0].id, "contest1");
pool.insert_contests(&[Contest {
id: "contest1".to_string(),
start_epoch_second: 0,
duration_second: 0,
title: "".to_string(),
rate_change: "".to_string(),
}])
.await
.unwrap();
}
#[sqlx::test]
async fn test_insert_problems(pool: PgPool) {
utils::initialize(&pool).await;
assert!(pool.load_problems().await.unwrap().is_empty());
pool.insert_problems(&[Problem {
id: "problem1".to_string(),
contest_id: "".to_string(),
problem_index: "".to_string(),
name: "".to_string(),
title: "".to_string(),
}])
.await
.unwrap();
let problems = pool.load_problems().await.unwrap();
assert_eq!(problems[0].id, "problem1");
pool.insert_problems(&[Problem {
id: "problem1".to_string(),
contest_id: "".to_string(),
problem_index: "".to_string(),
name: "".to_string(),
title: "".to_string(),
}])
.await
.unwrap();
}