mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-23 09:44:22 +03:00
Update Hurl sample for 4.0.0
This commit is contained in:
parent
7793c769bc
commit
3185167183
33
contrib/sample/Cargo.lock
generated
33
contrib/sample/Cargo.lock
generated
@ -187,22 +187,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.3.2"
|
||||
version = "4.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "401a4694d2bf92537b6867d94de48c4842089645fdcdf6c71865b175d836e9c2"
|
||||
checksum = "384e169cc618c613d5e3ca6404dda77a8685a63e08660dcc64abaf7da7cb0c7a"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.3.1"
|
||||
version = "4.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980"
|
||||
checksum = "ef137bbe35aab78bdb468ccfba75a5f4d8321ae011d34063770780545176af2d"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"bitflags",
|
||||
"clap_lex",
|
||||
"once_cell",
|
||||
"strsim",
|
||||
@ -471,9 +470,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46"
|
||||
|
||||
[[package]]
|
||||
name = "hurl"
|
||||
version = "3.0.1"
|
||||
version = "4.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11f6eeeefa981e4856287e7746ddf39c0fa34efbf2e9c114f288b7b3d8b8923e"
|
||||
checksum = "3e7f951480e4ede1b4b58021323250ec164c458c688d212ae89439d5dcf5ce02"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"base64",
|
||||
@ -517,9 +516,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hurl_core"
|
||||
version = "3.0.1"
|
||||
version = "4.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b648f93bfb7afde564936d76889011f0edbe59478133f2333f00a4ef56871c9b"
|
||||
checksum = "ecad8169425267fc3dbb8528420f9948d504acc7bde7430db3948d195ae57c50"
|
||||
dependencies = [
|
||||
"float-cmp",
|
||||
"regex",
|
||||
@ -869,15 +868,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.163"
|
||||
version = "1.0.165"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2"
|
||||
checksum = "c939f902bb7d0ccc5bce4f03297e161543c2dcb30914faf032c2bd0b7a0d48fc"
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.96"
|
||||
version = "1.0.99"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1"
|
||||
checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
@ -886,9 +885,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.10.6"
|
||||
version = "0.10.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0"
|
||||
checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
@ -1030,9 +1029,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.3.3"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2"
|
||||
checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"rand",
|
||||
|
@ -6,6 +6,6 @@ edition = "2021"
|
||||
[workspace]
|
||||
|
||||
[dependencies]
|
||||
hurl = "3.0.0"
|
||||
hurl_core = "3.0.0"
|
||||
hurl = "4.0.0"
|
||||
hurl_core = "4.0.0"
|
||||
|
||||
|
@ -16,16 +16,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use std::{env, fs};
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Debug;
|
||||
use std::process::exit;
|
||||
use std::time::Duration;
|
||||
use std::{env, fs};
|
||||
|
||||
use hurl::runner;
|
||||
use hurl::runner::{AssertResult, CaptureResult, EntryResult, Error, HurlResult, Verbosity};
|
||||
use hurl::util::logger::LoggerBuilder;
|
||||
use hurl::runner::{AssertResult, CaptureResult, EntryResult, Error, HurlResult};
|
||||
use hurl::util::logger::{ErrorFormat, LoggerOptionsBuilder, Verbosity};
|
||||
use hurl::util::path::ContextDir;
|
||||
use hurl_core::ast::Retry;
|
||||
use runner::RunnerOptionsBuilder;
|
||||
|
||||
/// Run a Hurl file and dumps results.
|
||||
/// This sample is used to detect public APIs change for Hurl crates.
|
||||
@ -40,14 +42,16 @@ fn main() {
|
||||
let filename = &args[1];
|
||||
let content = fs::read_to_string(filename).expect("Should have been able to read the file");
|
||||
|
||||
let logger = LoggerBuilder::new()
|
||||
let logger_opts = LoggerOptionsBuilder::new()
|
||||
.color(false)
|
||||
.verbose(false)
|
||||
.error_format(ErrorFormat::Short)
|
||||
.filename(filename)
|
||||
.progress_bar(false)
|
||||
.verbosity(Some(Verbosity::Verbose))
|
||||
.build();
|
||||
|
||||
// Define runner options
|
||||
let runner_options = runner::RunnerOptionsBuilder::new()
|
||||
let runner_opts = RunnerOptionsBuilder::new()
|
||||
.cacert_file(None)
|
||||
.compressed(false)
|
||||
.connect_timeout(Duration::from_secs(300))
|
||||
@ -62,26 +66,19 @@ fn main() {
|
||||
.post_entry(None)
|
||||
.pre_entry(None)
|
||||
.proxy(None)
|
||||
.retry(false)
|
||||
.retry(Retry::None)
|
||||
.retry_interval(Duration::from_secs(1))
|
||||
.retry_max_count(Some(10))
|
||||
.timeout(Duration::from_secs(300))
|
||||
.to_entry(None)
|
||||
.user(None)
|
||||
.user_agent(None)
|
||||
.verbosity(Some(Verbosity::VeryVerbose))
|
||||
.build();
|
||||
|
||||
// Set variables
|
||||
let variables = HashMap::default();
|
||||
|
||||
// Run the hurl file
|
||||
let result = runner::run(
|
||||
&content,
|
||||
&runner_options,
|
||||
&variables,
|
||||
&logger,
|
||||
).unwrap();
|
||||
let result = runner::run(&content, &runner_opts, &variables, &logger_opts).unwrap();
|
||||
|
||||
print_result(&result, filename);
|
||||
}
|
||||
@ -89,7 +86,7 @@ fn main() {
|
||||
/// Prints a Hurl result
|
||||
fn print_result(results: &HurlResult, filename: &str) {
|
||||
let level = 0;
|
||||
print(level, "file", &filename);
|
||||
print(level, "file", filename);
|
||||
print(level, "success", &results.success.to_string());
|
||||
print(level, "duration", &results.time_in_ms.to_string());
|
||||
if results.entries.is_empty() {
|
||||
@ -209,7 +206,6 @@ fn print_error(error: &Error) {
|
||||
// print(level, "value", &header.value);
|
||||
// }
|
||||
|
||||
|
||||
fn print(level: usize, key: &str, value: &str) {
|
||||
let prefix = " ".repeat(level * 2);
|
||||
let len = 20 - key.len() - prefix.len();
|
||||
|
Loading…
Reference in New Issue
Block a user