Update Rust sample with hurl/hurl_core 2.0.0

This commit is contained in:
jcamiel 2023-01-31 12:00:29 +01:00
parent 98f5db346f
commit ffa798be0c
No known key found for this signature in database
GPG Key ID: 07FF11CFD55356CC
3 changed files with 61 additions and 53 deletions

View File

@ -60,9 +60,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "base64"
version = "0.13.1"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a"
[[package]]
name = "bitflags"
@ -108,9 +108,9 @@ checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
[[package]]
name = "cc"
version = "1.0.77"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4"
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
[[package]]
name = "cfg-if"
@ -132,9 +132,9 @@ dependencies = [
[[package]]
name = "clap"
version = "4.0.27"
version = "4.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0acbd8d28a0a60d7108d7ae850af6ba34cf2d1257fc646980e5f97ce14275966"
checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76"
dependencies = [
"bitflags",
"clap_lex",
@ -408,9 +408,9 @@ dependencies = [
[[package]]
name = "glob"
version = "0.3.0"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "hashbrown"
@ -450,9 +450,9 @@ checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0"
[[package]]
name = "hurl"
version = "1.8.0"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b14f1900d325fc06675fbc164a2d294c3c2fe427d03b110db887429d6ce6d65"
checksum = "47d609e0605874eaec24a3e8de1f92c1af791d8c500255e57391b85303c109aa"
dependencies = [
"atty",
"base64",
@ -469,6 +469,7 @@ dependencies = [
"hex-literal",
"hurl_core",
"indexmap",
"lazy_static",
"libflate",
"libxml",
"md5",
@ -493,9 +494,9 @@ dependencies = [
[[package]]
name = "hurl_core"
version = "1.8.0"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "379e6a221e817e2ad11051bac3613d5a50a7ab124413fade46bd10292fd9f13a"
checksum = "da6e3dc1647f062ba6c059963dd6b027511360edf3a44a94a855997fa4b91865"
dependencies = [
"float-cmp",
"regex",
@ -564,13 +565,13 @@ dependencies = [
[[package]]
name = "is-terminal"
version = "0.4.0"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aae5bc6e2eb41c9def29a3e0f1306382807764b9b53112030eff57435667352d"
checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189"
dependencies = [
"hermit-abi 0.2.6",
"io-lifetimes 1.0.1",
"rustix 0.36.3",
"rustix 0.36.7",
"windows-sys 0.42.0",
]
@ -798,9 +799,9 @@ dependencies = [
[[package]]
name = "regex"
version = "1.7.0"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a"
checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733"
dependencies = [
"aho-corasick",
"memchr",
@ -835,9 +836,9 @@ dependencies = [
[[package]]
name = "rustix"
version = "0.36.3"
version = "0.36.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b1fbb4dfc4eb1d390c02df47760bb19a84bb80b301ecc947ab5406394d8223e"
checksum = "d4fdebc4b395b7fbb9ab11e462e20ed9051e7b16e42d24042c776eca0ac81b03"
dependencies = [
"bitflags",
"errno",
@ -871,15 +872,15 @@ checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898"
[[package]]
name = "serde"
version = "1.0.147"
version = "1.0.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb"
[[package]]
name = "serde_json"
version = "1.0.89"
version = "1.0.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db"
checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883"
dependencies = [
"itoa",
"ryu",

View File

@ -6,6 +6,6 @@ edition = "2021"
[workspace]
[dependencies]
hurl = "1.8.0"
hurl_core = "1.8.0"
hurl = "2.0.0"
hurl_core = "2.0.0"

View File

@ -16,9 +16,9 @@
*
*/
use hurl::cli::Logger;
use hurl::http::{ContextDir, Header, Request, Response};
use hurl::runner::{AssertResult, Call, CaptureResult, EntryResult, Error, HurlResult};
use hurl::runner::{AssertResult, Call, CaptureResult, EntryResult, Error, HurlResult, Verbosity};
use hurl::util::logger::LoggerBuilder;
use hurl::{http, runner};
use hurl_core::parser;
use std::collections::HashMap;
@ -45,34 +45,41 @@ fn main() {
// Create an HTTP client
let mut client = http::Client::new(None);
let logger = Logger::new(false, false, file_path, &contents);
let mut logger_builder = LoggerBuilder::new();
let logger = logger_builder
.color(false)
.verbose(false)
.filename(file_path)
.content(&contents)
.build()
.unwrap();
// Define runner options
let runner_options = runner::RunnerOptions {
cacert_file: None,
compressed: false,
connect_timeout: Duration::from_secs(300),
context_dir: ContextDir::default(),
cookie_input_file: None,
fail_fast: false,
follow_location: false,
ignore_asserts: false,
insecure: false,
max_redirect: None,
no_proxy: None,
post_entry: None,
pre_entry: None,
proxy: None,
retry: false,
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: None,
very_verbose: true,
};
let runner_options = runner::RunnerOptionsBuilder::new()
.cacert_file(None)
.compressed(false)
.connect_timeout(Duration::from_secs(300))
.context_dir(&ContextDir::default())
.cookie_input_file(None)
.fail_fast(false)
.follow_location(false)
.ignore_asserts(false)
.insecure(false)
.max_redirect(None)
.no_proxy(None)
.post_entry(None)
.pre_entry(None)
.proxy(None)
.retry(false)
.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();