forked from kenkoooo/AtCoderProblems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_progress_reset_manager.rs
More file actions
77 lines (70 loc) · 2.06 KB
/
test_progress_reset_manager.rs
File metadata and controls
77 lines (70 loc) · 2.06 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use sql_client::{
internal::progress_reset_manager::{
ProgressResetItem, ProgressResetList, ProgressResetManager,
},
PgPool,
};
mod utils;
#[sqlx::test]
async fn test_progress_reset_manager(pool: PgPool) {
let internal_user_id = "user_id";
let atcoder_user_id = "atcoder_id";
let problem_id = "problem_id";
let reset_epoch_second = 42;
utils::initialize(&pool).await;
utils::setup_internal_user(&pool, internal_user_id, atcoder_user_id).await;
let list = pool
.get_progress_reset_list(internal_user_id)
.await
.unwrap();
assert!(
list.items.is_empty(),
"`get_progress_reset_list` here should return an empty list, but got not empty."
);
pool.add_item(internal_user_id, problem_id, reset_epoch_second)
.await
.unwrap();
let list = pool
.get_progress_reset_list(internal_user_id)
.await
.unwrap();
assert_eq!(
list,
ProgressResetList {
items: vec![ProgressResetItem {
problem_id: problem_id.to_string(),
reset_epoch_second,
}],
},
"The item that has been added to the list is not found."
);
let updated_reset_epoch_second = 334;
pool.add_item(internal_user_id, problem_id, updated_reset_epoch_second)
.await
.unwrap();
let list = pool
.get_progress_reset_list(internal_user_id)
.await
.unwrap();
assert_eq!(
list,
ProgressResetList {
items: vec![ProgressResetItem {
problem_id: problem_id.to_string(),
reset_epoch_second: updated_reset_epoch_second,
}],
},
"`reset_epoch_second` should be updated, but not."
);
pool.remove_item(internal_user_id, problem_id)
.await
.unwrap();
let list = pool
.get_progress_reset_list(internal_user_id)
.await
.unwrap();
assert!(
list.items.is_empty(),
"The list should not have any items, but still has."
);
}