httpd: Update `/git` test to use `test` helper fns
Update `axum` to 0.6.7 to be able to use fix in: https://github.com/tokio-rs/axum/pull/1767 Signed-off-by: xphoniex <dj.2dixx@gmail.com>
This commit is contained in:
parent
f290f6b4a5
commit
6ca1c89610
|
|
@ -121,9 +121,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "axum"
|
name = "axum"
|
||||||
version = "0.6.4"
|
version = "0.6.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e5694b64066a2459918d8074c2ce0d5a88f409431994c2356617c8ae0c4721fc"
|
checksum = "2fb79c228270dcf2426e74864cabc94babb5dbab01a4314e702d2f16540e1591"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"axum-core",
|
"axum-core",
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ logfmt = [
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = { version = "1" }
|
anyhow = { version = "1" }
|
||||||
axum = { version = "0.6.2", default-features = false, features = ["headers", "json", "query", "tokio"] }
|
axum = { version = "0.6.7", default-features = false, features = ["headers", "json", "query", "tokio"] }
|
||||||
axum-auth = { version= "0.4.0", default-features = false, features = ["auth-bearer"] }
|
axum-auth = { version= "0.4.0", default-features = false, features = ["auth-bearer"] }
|
||||||
axum-server = { version = "0.4.4", default-features = false }
|
axum-server = { version = "0.4.4", default-features = false }
|
||||||
chrono = { version = "0.4.22" }
|
chrono = { version = "0.4.22" }
|
||||||
|
|
|
||||||
|
|
@ -197,29 +197,19 @@ async fn git_http_backend(
|
||||||
mod routes {
|
mod routes {
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
use axum::body::Body;
|
use axum::extract::connect_info::MockConnectInfo;
|
||||||
use axum::extract::ConnectInfo;
|
use axum::http::StatusCode;
|
||||||
use axum::http::Request;
|
|
||||||
use axum::http::{Method, StatusCode};
|
|
||||||
use tower::ServiceExt;
|
|
||||||
|
|
||||||
use crate::test;
|
use crate::test::{self, get};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_invalid_route_returns_404() {
|
async fn test_invalid_route_returns_404() {
|
||||||
let tmp = tempfile::tempdir().unwrap();
|
let tmp = tempfile::tempdir().unwrap();
|
||||||
let ctx = test::seed(tmp.path());
|
let ctx = test::seed(tmp.path());
|
||||||
let app = super::router(ctx.profile().to_owned());
|
let app = super::router(ctx.profile().to_owned())
|
||||||
|
.layer(MockConnectInfo(SocketAddr::from(([0, 0, 0, 0], 8080))));
|
||||||
|
|
||||||
let request = Request::builder()
|
let response = get(&app, "/aa/a").await;
|
||||||
.method(Method::GET)
|
|
||||||
.uri("/aa/a".to_string());
|
|
||||||
|
|
||||||
let mut request = request.body(Body::empty()).unwrap();
|
|
||||||
let socket_addr: SocketAddr = "127.0.0.1:8080".parse().unwrap();
|
|
||||||
request.extensions_mut().insert(ConnectInfo(socket_addr));
|
|
||||||
|
|
||||||
let response = app.oneshot(request).await.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue