Skip to content

Commit

Permalink
feat: temporary fix for tests before the implementation of server config
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-cne committed Apr 19, 2024
1 parent 4804c30 commit 3147695
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ infrastructure = { path = "../infrastructure" }
shared = { path = "../shared" }

[dev-dependencies]
dotenvy.workspace = true
serde.workspace = true

http-body-util = "0.1.0"
27 changes: 25 additions & 2 deletions crates/api/src/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use axum::Router;
use http_body_util::BodyExt;
use tower::Service; // for `collect`

use crate::PurpleSector;
use crate::handlers;
use shared::prelude::{Pagination, Response, Series};

pub mod macros;
Expand Down Expand Up @@ -57,7 +57,30 @@ where
}

pub fn setup() -> Router {
PurpleSector::new(30).router
use axum::routing::get;

let pool = infrastructure::ConnectionPool::try_new().unwrap();

let api_routes = Router::new()
.route("/circuits", get(handlers::circuits::circuits))
.route(
"/constructors/standings",
get(handlers::constructor_standings::constructor_standings),
)
.route("/constructors", get(handlers::constructors::constructors))
.route(
"/drivers/standings",
get(handlers::driver_standings::driver_standings),
)
.route("/drivers", get(handlers::drivers::drivers))
.route("/laps", get(handlers::laps::laps))
.route("/races", get(handlers::races::races))
.route("/pit-stops", get(handlers::pit_stops::pit_stops))
.route("/seasons", get(handlers::seasons::seasons))
.route("/status", get(handlers::status::status))
.with_state(pool);

Router::new().nest("/api/:series", api_routes)
}

pub async fn get(mut router: Router, uri: &str) -> Result<axum::http::Response<Body>, Infallible> {
Expand Down

0 comments on commit 3147695

Please sign in to comment.