status code on failure

This commit is contained in:
Robin Appelman 2020-11-30 01:51:56 +01:00
commit ac115dedbf
2 changed files with 14 additions and 6 deletions

View file

@ -31,7 +31,9 @@ async fn main() -> Result<()> {
let edit_key = dotenv::var("EDIT_KEY")?;
let edit_key = &edit_key;
Test::run(
let mut success = true;
success &= Test::run(
"Upload with invalid credentials",
&harness,
|test| async move {
@ -61,7 +63,7 @@ async fn main() -> Result<()> {
)
.await;
Test::run(
success &= Test::run(
"Upload demo, then retrieve info",
&harness,
|test| async move {
@ -157,7 +159,7 @@ async fn main() -> Result<()> {
)
.await;
Test::run("Listings", &harness, |test| async move {
success &= Test::run("Listings", &harness, |test| async move {
test.step("upload", |client| async move {
client
.upload_demo(
@ -334,7 +336,7 @@ async fn main() -> Result<()> {
})
.await;
Test::run("Set url", &harness, |test| async move {
success &= Test::run("Set url", &harness, |test| async move {
let id = test
.step("upload", |client| async move {
Ok(client
@ -452,6 +454,10 @@ async fn main() -> Result<()> {
})
.await;
if !success {
std::process::exit(1);
}
Ok(())
}

View file

@ -15,13 +15,13 @@ impl Test {
name: &str,
harness: &'a Harness,
f: F,
) {
) -> bool {
println!(" - {}", name);
if let Err(e) = harness.reset().await {
println!(" {}: {:#}", "Reset api server".red(), e);
println!(" {}", "".red());
return;
return false;
} else {
println!(" - {}", "Reset api server".green());
}
@ -33,9 +33,11 @@ impl Test {
match f(test).await {
Ok(_) => {
println!(" {}", "".green());
true
}
Err(e) => {
println!(" {}: {:#}", "".red(), e);
false
}
}
}