Skip to content

Commit

Permalink
skip integration-usage tests on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
auguwu committed Jun 6, 2024
1 parent 9303fd9 commit 8977794
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
4 changes: 4 additions & 0 deletions crates/macros/tests/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ fn router() -> axum::Router {
}

#[test(setup)]
#[cfg_attr(
windows,
ignore = "fails on Windows: hyper_util::client::legacy::Error(Connect, ConnectError(\"tcp connect error\", Os { code: 10049, kind: AddrNotAvailable, message: \"The requested address is not valid in its context.\" })))"
)]
async fn usage(ctx: &TestContext) {
let res = ctx
.request("/", Method::GET, None::<axum::body::Bytes>, |_| {})
Expand Down
25 changes: 9 additions & 16 deletions crates/testkit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,9 @@ pub use charted_testkit_macros::*;

mod macros;

use axum::{
body::Bytes,
extract::Request,
http::uri::{Parts, PathAndQuery, Scheme},
Router,
};
use axum::{body::Bytes, extract::Request, Router};
use http_body_util::Full;
use hyper::{body::Incoming, Method, Uri};
use hyper::{body::Incoming, Method};
use hyper_util::{
client::legacy::{connect::HttpConnector, Client, ResponseFuture},
rt::{TokioExecutor, TokioIo},
Expand Down Expand Up @@ -166,15 +161,9 @@ impl TestContext {

let mut req = Request::<Full<Bytes>>::new(Full::new(body.map(Into::into).unwrap_or_default()));
*req.method_mut() = method;
*req.uri_mut() = {
let mut parts = Parts::default();
parts.scheme = Some(Scheme::HTTP);
parts.authority = Some(addr.to_string().parse().expect("unable to parse into `Authority`"));
parts.path_and_query =
Some(PathAndQuery::try_from(uri.as_ref()).expect("unable to transform into `PathAndQuery`"));

Uri::from_parts(parts).expect("failed to construct `hyper::Uri`")
};
*req.uri_mut() = format!("http://{addr}{}", uri.as_ref())
.parse()
.expect("failed to parse into `hyper::Uri`");

build(&mut req);
self.client.request(req)
Expand Down Expand Up @@ -280,6 +269,10 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(
windows,
ignore = "fails on Windows: hyper_util::client::legacy::Error(Connect, ConnectError(\"tcp connect error\", Os { code: 10049, kind: AddrNotAvailable, message: \"The requested address is not valid in its context.\" })))"
)]
async fn test_usage() {
let mut ctx = TestContext::default();
ctx.serve(router()).await;
Expand Down

0 comments on commit 8977794

Please sign in to comment.