mirror of
https://codeberg.org/demostf/api-test.git
synced 2026-06-03 17:44:07 +02:00
status code on failure
This commit is contained in:
parent
bcd2169ff0
commit
ac115dedbf
2 changed files with 14 additions and 6 deletions
14
src/main.rs
14
src/main.rs
|
|
@ -31,7 +31,9 @@ async fn main() -> Result<()> {
|
||||||
let edit_key = dotenv::var("EDIT_KEY")?;
|
let edit_key = dotenv::var("EDIT_KEY")?;
|
||||||
let edit_key = &edit_key;
|
let edit_key = &edit_key;
|
||||||
|
|
||||||
Test::run(
|
let mut success = true;
|
||||||
|
|
||||||
|
success &= Test::run(
|
||||||
"Upload with invalid credentials",
|
"Upload with invalid credentials",
|
||||||
&harness,
|
&harness,
|
||||||
|test| async move {
|
|test| async move {
|
||||||
|
|
@ -61,7 +63,7 @@ async fn main() -> Result<()> {
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Test::run(
|
success &= Test::run(
|
||||||
"Upload demo, then retrieve info",
|
"Upload demo, then retrieve info",
|
||||||
&harness,
|
&harness,
|
||||||
|test| async move {
|
|test| async move {
|
||||||
|
|
@ -157,7 +159,7 @@ async fn main() -> Result<()> {
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Test::run("Listings", &harness, |test| async move {
|
success &= Test::run("Listings", &harness, |test| async move {
|
||||||
test.step("upload", |client| async move {
|
test.step("upload", |client| async move {
|
||||||
client
|
client
|
||||||
.upload_demo(
|
.upload_demo(
|
||||||
|
|
@ -334,7 +336,7 @@ async fn main() -> Result<()> {
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Test::run("Set url", &harness, |test| async move {
|
success &= Test::run("Set url", &harness, |test| async move {
|
||||||
let id = test
|
let id = test
|
||||||
.step("upload", |client| async move {
|
.step("upload", |client| async move {
|
||||||
Ok(client
|
Ok(client
|
||||||
|
|
@ -452,6 +454,10 @@ async fn main() -> Result<()> {
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
if !success {
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,13 @@ impl Test {
|
||||||
name: &str,
|
name: &str,
|
||||||
harness: &'a Harness,
|
harness: &'a Harness,
|
||||||
f: F,
|
f: F,
|
||||||
) {
|
) -> bool {
|
||||||
println!(" - {}", name);
|
println!(" - {}", name);
|
||||||
|
|
||||||
if let Err(e) = harness.reset().await {
|
if let Err(e) = harness.reset().await {
|
||||||
println!(" {}: {:#}", "Reset api server".red(), e);
|
println!(" {}: {:#}", "Reset api server".red(), e);
|
||||||
println!(" {}", "❌".red());
|
println!(" {}", "❌".red());
|
||||||
return;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
println!(" - {}", "Reset api server".green());
|
println!(" - {}", "Reset api server".green());
|
||||||
}
|
}
|
||||||
|
|
@ -33,9 +33,11 @@ impl Test {
|
||||||
match f(test).await {
|
match f(test).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
println!(" {}", "✓".green());
|
println!(" {}", "✓".green());
|
||||||
|
true
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!(" {}: {:#}", "❌".red(), e);
|
println!(" {}: {:#}", "❌".red(), e);
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue