Skip to content

Commit becd729

Browse files
committed
rework(tests): allow ? usage in integration tests so errors are output
1 parent fd08d9b commit becd729

4 files changed

Lines changed: 30 additions & 33 deletions

File tree

‎crates/cli/tests/bugzilla/attachment/create.rs‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,18 @@ use crate::command::cmd;
99
use super::SERVICE;
1010

1111
#[tokio::test]
12-
async fn single_attachment_to_single_bug() {
12+
async fn single_attachment_to_single_bug() -> anyhow::Result<()> {
1313
let id = SERVICE
1414
.create()
1515
.summary("summary")
1616
.component("TestComponent")
1717
.product("TestProduct")
1818
.description("description")
1919
.send()
20-
.await
21-
.unwrap();
20+
.await?;
2221

23-
let file = NamedUtf8TempFile::new().unwrap();
24-
fs::write(&file, "test").unwrap();
22+
let file = NamedUtf8TempFile::new()?;
23+
fs::write(&file, "test")?;
2524
let path = file.path();
2625

2726
cmd!("bite bugzilla attachment create {id} -v")
@@ -32,4 +31,6 @@ async fn single_attachment_to_single_bug() {
3231
)))
3332
.stderr("")
3433
.success();
34+
35+
Ok(())
3536
}

‎crates/cli/tests/bugzilla/create.rs‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,35 @@ use crate::command::cmd;
66
use super::SERVICE;
77

88
#[tokio::test]
9-
async fn from_bug() {
9+
async fn from_bug() -> anyhow::Result<()> {
1010
let id = SERVICE
1111
.create()
1212
.summary("summary")
1313
.component("TestComponent")
1414
.product("TestProduct")
1515
.description("description")
1616
.send()
17-
.await
18-
.unwrap();
17+
.await?;
1918

2019
cmd!("bite bugzilla create --from-bug {id} -S summary -D description")
2120
.assert()
2221
.success();
22+
23+
Ok(())
2324
}
2425

2526
#[tokio::test]
26-
async fn from_template() {
27+
async fn from_template() -> anyhow::Result<()> {
2728
let id = SERVICE
2829
.create()
2930
.summary("summary")
3031
.component("TestComponent")
3132
.product("TestProduct")
3233
.description("description")
3334
.send()
34-
.await
35-
.unwrap();
35+
.await?;
3636

37-
let dir = tempdir().unwrap();
37+
let dir = tempdir()?;
3838
let path = dir.path().join("template");
3939

4040
// create template from bug
@@ -48,4 +48,6 @@ async fn from_template() {
4848
cmd!("bite bugzilla create --from {path} -S summary -D description")
4949
.assert()
5050
.success();
51+
52+
Ok(())
5153
}

‎crates/cli/tests/bugzilla/search.rs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,21 @@ use crate::command::cmd;
66
use super::SERVICE;
77

88
#[tokio::test]
9-
async fn id() {
9+
async fn id() -> anyhow::Result<()> {
1010
let id = SERVICE
1111
.create()
1212
.summary("summary")
1313
.component("TestComponent")
1414
.product("TestProduct")
1515
.description("description")
1616
.send()
17-
.await
18-
.unwrap();
17+
.await?;
1918

2019
cmd!("bite bugzilla search --id {id} --fields id")
2120
.assert()
2221
.stdout(predicate::eq(id.to_string()).trim())
2322
.stderr("")
2423
.success();
24+
25+
Ok(())
2526
}

‎crates/cli/tests/bugzilla/update.rs‎

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ use crate::command::cmd;
77
use super::SERVICE;
88

99
#[tokio::test]
10-
async fn from_template() {
10+
async fn from_template() -> anyhow::Result<()> {
1111
let id = SERVICE
1212
.create()
1313
.summary("summary")
1414
.component("TestComponent")
1515
.product("TestProduct")
1616
.description("description")
1717
.send()
18-
.await
19-
.unwrap();
18+
.await?;
2019

2120
let dir = tempdir().unwrap();
2221
let path = dir.path().join("template");
@@ -33,29 +32,23 @@ async fn from_template() {
3332
.assert()
3433
.success();
3534

36-
let bug = SERVICE
37-
.get([id])
38-
.send()
39-
.await
40-
.unwrap()
41-
.into_iter()
42-
.next()
43-
.unwrap();
35+
let bug = SERVICE.get([id]).send().await?.into_iter().next().unwrap();
4436

4537
assert_eq!(bug.summary.unwrap(), "new-summary");
38+
39+
Ok(())
4640
}
4741

4842
#[tokio::test]
49-
async fn multiple_bugs() {
43+
async fn multiple_bugs() -> anyhow::Result<()> {
5044
let id1 = SERVICE
5145
.create()
5246
.summary("summary")
5347
.component("TestComponent")
5448
.product("TestProduct")
5549
.description("description")
5650
.send()
57-
.await
58-
.unwrap();
51+
.await?;
5952

6053
let id2 = SERVICE
6154
.create()
@@ -64,8 +57,7 @@ async fn multiple_bugs() {
6457
.product("TestProduct")
6558
.description("description")
6659
.send()
67-
.await
68-
.unwrap();
60+
.await?;
6961

7062
cmd!("bite bugzilla update {id1} {id2} -S new-summary")
7163
.assert()
@@ -74,12 +66,13 @@ async fn multiple_bugs() {
7466
let (bug1, bug2) = SERVICE
7567
.get([id1, id2])
7668
.send()
77-
.await
78-
.unwrap()
69+
.await?
7970
.into_iter()
8071
.collect_tuple()
8172
.unwrap();
8273

8374
assert_eq!(bug1.summary.unwrap(), "new-summary");
8475
assert_eq!(bug2.summary.unwrap(), "new-summary");
76+
77+
Ok(())
8578
}

0 commit comments

Comments
 (0)