Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
devbro1 committed Dec 16, 2023
1 parent 07f443d commit d094cfa
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ default-run = "main"
[dependencies]
axum = "0.7.2"
lambda_http = "0.8.3"
pretty_assertions = "1.4.0"
tokio = { version = "1.35.0", features = ["full"] }
tokio-test = "0.4.3"

[[bin]]
name = "commander"
path = "src/commander.rs"

[[bin]]
name = "main"
path = "src/main.rs"
path = "src/main.rs"
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pub fn func1() -> &'static str {
"Hello, World!"
}


pub async fn root() -> &'static str {
"Hello, World!"
}
5 changes: 1 addition & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use axum::{
#[tokio::main]
async fn main() {
let routes = Router::new()
.route("/", get(root));
.route("/", get(web_framework::root));

let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, routes).await.unwrap();
Expand All @@ -15,6 +15,3 @@ async fn main() {
return;
}

async fn root() -> &'static str {
"Hello, World!"
}
19 changes: 19 additions & 0 deletions tests/test2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use web_framework::func1;
use web_framework::root;
use pretty_assertions::assert_eq;


macro_rules! aw {
($e:expr) => {
tokio_test::block_on($e)
};
}

#[test]
fn test_add() {
func1();
let a = aw!(root());

assert_eq!(a,"Hello, World!");
assert_eq!(2,2);
}

0 comments on commit d094cfa

Please sign in to comment.