Skip to content

Commit 442df2b

Browse files
committed
test: add more assert
1 parent 219fab5 commit 442df2b

File tree

5 files changed

+27
-29
lines changed

5 files changed

+27
-29
lines changed

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
name: Test
3636
runs-on: ${{ matrix.os }}
3737
strategy:
38-
fail-fast: true
38+
fail-fast: false
3939
matrix:
4040
os: [ubuntu-latest, windows-latest, macos-latest]
4141
rust: [nightly]
@@ -111,4 +111,4 @@ jobs:
111111
- name: Run Test
112112
run: |
113113
cargo nextest run get_all_pbs_works new_get_index # generate database
114-
cargo nextest run --all-features
114+
cargo nextest run

crates/leetcode-api/tests/get_img_work.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ async fn get_img_url() {
1010

1111
let question = glob_leetcode()
1212
.await
13-
.get_qs_detail(IdSlug::Id(1008), true)
13+
.get_qs_detail(IdSlug::Id(1008), false)
1414
.await
1515
.unwrap();
1616

crates/leetcode-api/tests/leetcode_work.rs

+13-14
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use leetcode_api::{glob_leetcode, leetcode::IdSlug};
2-
use miette::Result;
32
use pretty_assertions::assert_eq;
43

54
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
6-
async fn get_qs_detail_work() -> Result<()> {
5+
async fn get_qs_detail_work() {
76
// tracing_subscriber::fmt()
87
// .with_max_level(tracing::Level::DEBUG)
98
// .with_test_writer()
@@ -13,7 +12,7 @@ async fn get_qs_detail_work() -> Result<()> {
1312
let question = lcode
1413
.get_qs_detail(
1514
IdSlug::Slug("find-smallest-common-element-in-all-rows".to_owned()),
16-
true,
15+
false,
1716
)
1817
.await
1918
.unwrap();
@@ -37,41 +36,41 @@ async fn get_qs_detail_work() -> Result<()> {
3736
assert_eq!(&question.title, "Find Smallest Common Element in All Rows");
3837

3938
let question = lcode
40-
.get_qs_detail(IdSlug::Slug("two-sum".to_owned()), true)
41-
.await?;
39+
.get_qs_detail(IdSlug::Slug("two-sum".to_owned()), false)
40+
.await
41+
.unwrap();
4242
assert_eq!(&question.question_id, "1");
4343
assert_eq!(&question.title, "Two Sum");
4444
assert_eq!(&question.qs_slug.unwrap(), "two-sum");
4545
assert_eq!(&question.question_title.unwrap(), "Two Sum");
4646

4747
let question = lcode
48-
.get_qs_detail(IdSlug::Id(195), true)
49-
.await?;
48+
.get_qs_detail(IdSlug::Id(195), false)
49+
.await
50+
.unwrap();
5051
assert_eq!(&question.qs_slug.unwrap(), "tenth-line");
5152
assert_eq!(&question.question_id, "195");
5253
assert_eq!(&question.question_title.unwrap(), "Tenth Line");
5354
assert_eq!(&question.title, "Tenth Line");
54-
55-
Ok(())
5655
}
5756

5857
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
59-
async fn get_user_code_work() -> Result<()> {
58+
async fn get_user_code_work() {
6059
let id = IdSlug::Id(108);
6160
glob_leetcode()
6261
.await
6362
.get_qs_detail(id.clone(), false)
64-
.await?;
63+
.await
64+
.unwrap();
6565

6666
let a = glob_leetcode()
6767
.await
6868
.get_user_code(id)
69-
.await?;
69+
.await
70+
.unwrap();
7071

7172
assert!(!a.0.is_empty());
7273
assert_eq!(&a.1, "[-10,-3,0,5,9]\n[1,3]");
73-
74-
Ok(())
7574
}
7675

7776
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]

crates/leetcode-api/tests/query_work.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ async fn query_base() -> Result<()> {
1515
"hash-table".to_owned(),
1616
]);
1717
let res = Query::query_by_topic(&tags, None).await?;
18-
for ele in &res {
19-
eprintln!("{}", &ele.title_slug);
20-
}
18+
// for ele in &res {
19+
// eprintln!("{}", &ele.title_slug);
20+
// }
21+
22+
let mut iter = res.iter();
23+
assert!(iter.next().unwrap().title_slug == "3sum-with-multiplicity");
24+
assert!(iter.next().unwrap().title_slug == "4sum-ii");
25+
assert!(iter.next().unwrap().title_slug == "accounts-merge");
2126

22-
assert!(res.first().unwrap().title_slug == "3sum-with-multiplicity");
2327
assert!(res
2428
.iter()
2529
.any(|v| { v.title_slug == "two-sum" }));

crates/leetcode-api/tests/render_work.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ async fn content_img() -> Result<()> {
77
let id = 1008;
88
let qs = glob_leetcode()
99
.await
10-
.get_qs_detail(IdSlug::Id(id), true)
10+
.get_qs_detail(IdSlug::Id(id), false)
1111
.await?;
1212
println!("{}", qs.content.as_deref().unwrap());
1313
qs.render_with_mdcat();
@@ -16,21 +16,16 @@ async fn content_img() -> Result<()> {
1616

1717
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
1818
async fn render_md_terminal() -> Result<()> {
19-
// tracing_subscriber::fmt()
20-
// .with_max_level(tracing::Level::DEBUG)
21-
// .with_test_writer()
22-
// .init();
23-
2419
let id = 108;
2520
let qs = glob_leetcode()
2621
.await
27-
.get_qs_detail(IdSlug::Id(id), true)
22+
.get_qs_detail(IdSlug::Id(id), false)
2823
.await?;
2924
let slug = "two-sum".to_owned();
3025
qs.render_with_mdcat();
3126
let qs = glob_leetcode()
3227
.await
33-
.get_qs_detail(IdSlug::Slug(slug), true)
28+
.get_qs_detail(IdSlug::Slug(slug), false)
3429
.await?;
3530
qs.render_with_mdcat();
3631

0 commit comments

Comments
 (0)