Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in #80 update crate #81

Merged
merged 20 commits into from
Aug 19, 2023
Merged
Prev Previous commit
Next Next commit
test example
  • Loading branch information
Jzow committed Aug 18, 2023
commit 545a2c0949da18a03bd20903a8a97cf47ad6c80a
2 changes: 1 addition & 1 deletion example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -18,4 +18,4 @@ schemars = "0.8.8"
tokio = { version = "1.19.2", features = ["full"] }

#summer
summer-boot = { version = "1.0.0"}
summer-boot = { version = "1.0.1", path = "../summer-boot" }
4 changes: 2 additions & 2 deletions example/src/http_method.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::Deserialize;
use summer_boot::{Request, Result};

#[derive(Debug, Deserialize)]
#[derive(Debug, Deserialize)]
struct User {
name: String,
age: u16,
@@ -16,4 +16,4 @@ pub async fn hello(mut _req: Request<()>) -> Result {
pub async fn test_api(mut req: Request<()>) -> Result {
let User { name, age } = req.body_json().await?;
Ok(format!("Hello, {}! {} years old", name, age).into())
}
}
3 changes: 1 addition & 2 deletions example/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
mod read_yml;
mod log;

2 changes: 1 addition & 1 deletion example/src/log.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

use summer_boot::log;

#[cfg(test)]
mod test {
4 changes: 3 additions & 1 deletion example/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use serde::Deserialize;
use summer_boot::{Request, Result};

mod http_method;
mod test;

#[derive(Debug, Deserialize)]
struct User {
@@ -18,4 +20,4 @@ async fn main() {
async fn test_api(mut req: Request<()>) -> Result {
let User { name, age } = req.body_json().await?;
Ok(format!("Hello, {}! {} years old", name, age).into())
}
}
25 changes: 25 additions & 0 deletions example/src/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use std::{
fs::{self, File},
io::{BufReader, Read},
};

#[test]
fn test() {
// let file = File::open("example/src/resources").expect("找不到文件");

let file = File::open("example/src/resources/").is_ok();

let file_name = "application.yml";
let directories = vec!["src/resources", "spring-boot/src/resources", "dir3"];

for directory in directories {
let path = format!("{}/{}", directory, file_name);
let file_exists = fs::metadata(&path).is_ok();

if file_exists {
println!("文件 {} 存在于目录 {}", file_name, directory);
} else {
println!("文件 {} 不存在于目录 {}", file_name, directory);
}
}
}