From 4861299549efb956cc56afe993f162b0c6e744ee Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 20 Nov 2024 22:45:37 +0000 Subject: [PATCH] fix(deps): update rust crate kxio to v3 --- Cargo.toml | 2 +- src/issues/fetch.rs | 16 ++++++---------- src/issues/tests.rs | 19 ++++++------------- src/tests/run.rs | 36 +++++++++++------------------------- 4 files changed, 24 insertions(+), 49 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 126f843..9fce0af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ ignore = "0.4" file-format = { version = "0.26", features = ["reader-txt"] } -kxio = "2.1" +kxio = "3.1" regex = "1.10" serde = { version = "1.0", features = ["derive"] } diff --git a/src/issues/fetch.rs b/src/issues/fetch.rs index 1734f3c..fed3fc4 100644 --- a/src/issues/fetch.rs +++ b/src/issues/fetch.rs @@ -12,16 +12,12 @@ pub async fn fetch_open_issues<'net, 'fs>(config: &Config<'net, 'fs>) -> Result< let repo = config.repo(); let url = format!("{server_url}/api/v1/repos/{repo}/issues?state=open"); let net = config.net(); - let client = net.client(); - let request = client.get(url); - let request = if let Some(auth_token) = config.auth_token() { - request.header("Authorization", auth_token) - } else { - request - }; - // .build(); - - let response = net.send(request).await?; + let response = net + .get(url) + .with_option(config.auth_token()) + .some(|request, auth_token| request.header("Authorization", auth_token)) + .send() + .await?; let issues: HashSet = response.json().await?; Ok(issues) diff --git a/src/issues/tests.rs b/src/issues/tests.rs index 21780fb..7b563bc 100644 --- a/src/issues/tests.rs +++ b/src/issues/tests.rs @@ -5,25 +5,18 @@ use std::collections::HashSet; use crate::tests::a_config; -use kxio::net::{Method, Net, Url}; +use kxio::net::{Net, StatusCode}; #[tokio::test] async fn fetch_lists_issues() { //given let mock_net = kxio::net::mock(); mock_net - .on(Method::GET) - .url( - Url::parse("https://git.kemitix.net/api/v1/repos/kemitix/test/issues?state=open") - .expect("parse url"), - ) - .respond( - mock_net - .response() - .status(200) - .body(r#"[{"number":13},{"number":64}]"#) - .expect("response body"), - ); + .on() + .get("https://git.kemitix.net/api/v1/repos/kemitix/test/issues?state=open") + .respond(StatusCode::OK) + .body(r#"[{"number":13},{"number":64}]"#) + .expect("response body"); let fs = kxio::fs::temp().expect("temp fs"); let net = Net::from(mock_net); let config = a_config(&net, &fs).expect("config"); diff --git a/src/tests/run.rs b/src/tests/run.rs index 1d8060e..08363d7 100644 --- a/src/tests/run.rs +++ b/src/tests/run.rs @@ -1,7 +1,7 @@ // use super::*; -use kxio::net::{Method, Net, Url}; +use kxio::net::{Net, StatusCode}; use printer::TestPrinter; #[tokio::test] @@ -10,18 +10,11 @@ async fn run_with_some_invalids() /* -> Result<()> */ //given let mock_net = kxio::net::mock(); mock_net - .on(Method::GET) - .url( - Url::parse("https://git.kemitix.net/api/v1/repos/kemitix/test/issues?state=open") - .expect("parse url"), - ) - .respond( - mock_net - .response() - .status(200) - .body(r#"[{"number": 13}]"#) - .expect("response body"), - ); + .on() + .get("https://git.kemitix.net/api/v1/repos/kemitix/test/issues?state=open") + .respond(StatusCode::OK) + .body(r#"[{"number": 13}]"#) + .expect("response body"); let net = Net::from(mock_net); let fs = kxio::fs::temp().expect("temp fs"); @@ -49,18 +42,11 @@ async fn run_with_no_invalids() { //given let mock_net = kxio::net::mock(); mock_net - .on(Method::GET) - .url( - Url::parse("https://git.kemitix.net/api/v1/repos/kemitix/test/issues?state=open") - .expect("parse url"), - ) - .respond( - mock_net - .response() - .status(200) - .body(r#"[{"number":23},{"number":43}]"#) - .expect("response body"), - ); + .on() + .get("https://git.kemitix.net/api/v1/repos/kemitix/test/issues?state=open") + .respond(StatusCode::OK) + .body(r#"[{"number":23},{"number":43}]"#) + .expect("response body"); let net = Net::from(mock_net); let fs = kxio::fs::temp().expect("temp fs");