Added test #8

Merged
phoenix merged 3 commits from add_test into devel 2025-04-01 00:29:09 +00:00
5 changed files with 51 additions and 4 deletions
Showing only changes of commit 14787b01b9 - Show all commits

View File

@@ -8,5 +8,7 @@ axum = { version = "0.8.3" }
serde = { version = "1.0.218", features = ["derive"] }
serde_json = { version = "1.0.139" }
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 = "1.6.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},
};
pub mod callers;
pub mod config;
pub mod models;
use icarus_auth::callers;
use icarus_auth::config;
#[tokio::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!");
}

1
tests/mod.rs Normal file
View File

@@ -0,0 +1 @@