Skip to content

Commit

Permalink
test fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
hatoo committed May 13, 2024
1 parent 013586a commit 2fbf749
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,14 +722,14 @@ async fn test_json_schema() {
tokio::spawn(async { axum::serve(listener, app).await });

const SCHEMA: &str = include_str!("../schema.json");
let schema: serde_json::Value = serde_json::from_str(SCHEMA).unwrap();
let schema = jsonschema::JSONSchema::compile(&schema).unwrap();
let schema_value: serde_json::Value = serde_json::from_str(SCHEMA).unwrap();
let schema = jsonschema::JSONSchema::compile(&schema_value).unwrap();

let output_json: String = String::from_utf8(
tokio::task::spawn_blocking(move || {
Command::cargo_bin("oha")
.unwrap()
.args(["-n", "100", "--no-tui", "-j"])
.args(["-n", "10", "--no-tui", "-j"])
.arg(format!("http://127.0.0.1:{port}/"))
.assert()
.get_output()
Expand All @@ -745,7 +745,7 @@ async fn test_json_schema() {
tokio::task::spawn_blocking(move || {
Command::cargo_bin("oha")
.unwrap()
.args(["-n", "100", "--no-tui", "-j", "--stats-success-breakdown"])
.args(["-n", "10", "--no-tui", "-j", "--stats-success-breakdown"])
.arg(format!("http://127.0.0.1:{port}/"))
.assert()
.get_output()
Expand All @@ -761,6 +761,17 @@ async fn test_json_schema() {
let value_stats_success_breakdown: serde_json::Value =
serde_json::from_str(&output_json_stats_success_breakdown).unwrap();

assert!(schema.is_valid(&value));
assert!(schema.is_valid(&value_stats_success_breakdown));
if let Err(errors) = schema.validate(&value) {
for error in errors {
eprintln!("{}", error);
}
panic!("JSON schema validation failed");
}

if let Err(errors) = schema.validate(&value_stats_success_breakdown) {
for error in errors {
eprintln!("{}", error);
}
panic!("JSON schema validation failed");
}/* ?? */;
}

0 comments on commit 2fbf749

Please sign in to comment.