forked from TabbyML/tabby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(webserver): add unit test to cover query all users for anual act… (
TabbyML#1838) * test(webserver): add unit test to cover query all users for anual activites * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
9520ec4
commit 6472fe4
Showing
1 changed file
with
19 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,16 +115,6 @@ mod tests { | |
.await | ||
.unwrap(); | ||
|
||
let svc = new_analytic_service(db.clone()); | ||
let activity = svc | ||
.daily_stats_in_past_year(vec![user_id.as_id()]) | ||
.await | ||
.unwrap(); | ||
|
||
assert_eq!(1, activity.len()); | ||
assert_eq!(1, activity[0].completions); | ||
assert_eq!(1, activity[0].selects); | ||
|
||
let user_id2 = db | ||
.create_user("[email protected]".into(), Some("pass".into()), false) | ||
.await | ||
|
@@ -139,6 +129,18 @@ mod tests { | |
.await | ||
.unwrap(); | ||
|
||
// Query user 1 should return 1 completion and 1 select. | ||
let svc = new_analytic_service(db.clone()); | ||
let activity = svc | ||
.daily_stats_in_past_year(vec![user_id.as_id()]) | ||
.await | ||
.unwrap(); | ||
|
||
assert_eq!(1, activity.len()); | ||
assert_eq!(1, activity[0].completions); | ||
assert_eq!(1, activity[0].selects); | ||
|
||
// Query user 1 + user 2 should return 2 completions and 1 select. | ||
let activity2 = svc | ||
.daily_stats_in_past_year(vec![user_id.as_id(), user_id2.as_id()]) | ||
.await | ||
|
@@ -147,6 +149,13 @@ mod tests { | |
assert_eq!(1, activity2.len()); | ||
assert_eq!(2, activity2[0].completions); | ||
assert_eq!(1, activity2[0].selects); | ||
|
||
// Query all users should return 2 completions and 1 select. | ||
let activity3 = svc.daily_stats_in_past_year(vec![]).await.unwrap(); | ||
|
||
assert_eq!(1, activity3.len()); | ||
assert_eq!(2, activity3[0].completions); | ||
assert_eq!(1, activity3[0].selects); | ||
} | ||
|
||
#[tokio::test] | ||
|