1
0
Fork 0

add test for routes

This commit is contained in:
Adrian Hedqvist 2023-03-29 18:31:20 +02:00
parent 0808fc8099
commit f9cdffcd24
2 changed files with 20 additions and 1 deletions

View file

@ -5,7 +5,8 @@ title = 'Status update: 2020-05-16'
tags = ["hugo", "zola", "roguelike", "spork"] tags = ["hugo", "zola", "roguelike", "spork"]
+++ +++
Oh boy, it's been a while since I wrote anything on this website, over two years ago! Oh boy, it's been a while since I wrote anything on this website,
over two years ago!
But I've been thinking of starting to write posts more often, try this But I've been thinking of starting to write posts more often, try this
proggramming-blogging thing out that seems to have had some sort of resurgance. proggramming-blogging thing out that seems to have had some sort of resurgance.

View file

@ -98,10 +98,28 @@ impl IntoResponse for WebsiteError {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::sync::Arc;
use crate::AppState;
#[test] #[test]
fn render_index() { fn render_index() {
let tera = tera::Tera::new("templates/**/*").unwrap(); let tera = tera::Tera::new("templates/**/*").unwrap();
let ctx = tera::Context::new(); let ctx = tera::Context::new();
let _res = tera.render("index.html", &ctx).unwrap(); let _res = tera.render("index.html", &ctx).unwrap();
} }
#[tokio::test]
async fn setup_routes() {
// Load the actual posts, just to make this test fail if
// aliases overlap with themselves or other routes
let state = Arc::new(AppState {
tera: tera::Tera::new("templates/**/*").unwrap(),
posts: crate::post::load_all().await.unwrap(),
});
super::routes(&state)
.with_state(state)
.into_make_service();
}
} }