Sloppy update.
This commit is contained in:
10
src/main.rs
10
src/main.rs
@@ -13,14 +13,14 @@ use settings::Settings;
|
||||
#[async_std::main]
|
||||
async fn main() -> tide::Result<()> {
|
||||
let sett = Settings::new().unwrap();
|
||||
let app = app_setup().await;
|
||||
let app = app_setup(sett.data_dir.as_str()).await;
|
||||
app.listen(format!("{}:{}", sett.address, sett.port))
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn app_setup() -> tide::Server<MoreThanText> {
|
||||
let db = MoreThanText::new().await;
|
||||
async fn app_setup(data_dir: &str) -> tide::Server<MoreThanText> {
|
||||
let db = MoreThanText::new(data_dir).await.unwrap();
|
||||
let mut app = tide::with_state(db);
|
||||
app.at("/").get(home);
|
||||
app.with(
|
||||
@@ -48,11 +48,13 @@ async fn home(_req: Request<MoreThanText>) -> tide::Result {
|
||||
#[cfg(test)]
|
||||
mod server_app {
|
||||
use super::*;
|
||||
use tempfile::tempdir;
|
||||
use tide_testing::TideTestingExt;
|
||||
|
||||
#[async_std::test]
|
||||
async fn home_page_available() {
|
||||
let app = app_setup().await;
|
||||
let dir = tempdir().unwrap();
|
||||
let app = app_setup(dir.path().to_str().unwrap()).await;
|
||||
let response = app.get("/").await.unwrap();
|
||||
assert_eq!(response.status(), StatusCode::Ok);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user