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
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:
@@ -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 = { version = "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
3
src/lib.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
pub mod callers;
|
||||
pub mod config;
|
||||
pub mod models;
|
@@ -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
42
tests/auth_tests.rs
Normal 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!");
|
||||
}
|
Reference in New Issue
Block a user