Added test (#8)
All checks were successful
Release Tagging / release (push) Successful in 30s
Rust Build / Check (push) Successful in 32s
Rust Build / Test Suite (push) Successful in 40s
Rust Build / Rustfmt (push) Successful in 27s
Rust Build / Clippy (push) Successful in 32s
Rust Build / build (push) Successful in 40s

Reviewed-on: #8
Co-authored-by: phoenix <kundeng94@gmail.com>
Co-committed-by: phoenix <kundeng94@gmail.com>
This commit is contained in:
2025-04-01 00:29:09 +00:00
committed by phoenix
parent f105de7c80
commit c9873d95d7
4 changed files with 50 additions and 4 deletions

View File

@@ -8,5 +8,7 @@ axum = { version = "0.8.3" }
serde = { version = "1.0.218", features = ["derive"] } serde = { version = "1.0.218", features = ["derive"] }
serde_json = { version = "1.0.139" } serde_json = { version = "1.0.139" }
tokio = { version = "1.44.1", features = ["rt-multi-thread"] } tokio = { version = "1.44.1", features = ["rt-multi-thread"] }
tracing-subscriber = "0.3.19" tracing-subscriber = { version = "0.3.19" }
tower = { version = "0.5.2" }
hyper = { version = "1.6.0" }
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.2.0" } icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.2.0" }

3
src/lib.rs Normal file
View File

@@ -0,0 +1,3 @@
pub mod callers;
pub mod config;
pub mod models;

View File

@@ -3,9 +3,8 @@ use axum::{
routing::{get, post}, routing::{get, post},
}; };
pub mod callers; use icarus_auth::callers;
pub mod config; use icarus_auth::config;
pub mod models;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {

42
tests/auth_tests.rs Normal file
View File

@@ -0,0 +1,42 @@
extern crate icarus_auth;
use axum::body::Body;
// use axum::response::Response;
use axum::{
Router,
http::{Request, StatusCode},
routing::get,
};
// use http::{Request, StatusCode};
// use serde_json::json;
// use tower::ServiceExt; // for `.oneshot()`
use tower::util::ServiceExt;
use crate::icarus_auth::callers;
#[tokio::test]
async fn test_hello_world() {
let app = Router::new().route(callers::endpoints::ROOT, get(callers::common::root)); // Replace with your handler
let response = app
.oneshot(
Request::builder()
.uri(callers::endpoints::ROOT)
.body(Body::empty())
.unwrap(),
)
.await
.unwrap();
assert_eq!(response.status(), StatusCode::OK);
let body = String::from_utf8(
axum::body::to_bytes(response.into_body(), usize::MAX)
.await
.unwrap()
.to_vec(),
)
.unwrap();
assert_eq!(body, "Hello, World!");
}