add test for routes
This commit is contained in:
parent
0808fc8099
commit
f9cdffcd24
2 changed files with 20 additions and 1 deletions
|
@ -5,7 +5,8 @@ title = 'Status update: 2020-05-16'
|
|||
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
|
||||
proggramming-blogging thing out that seems to have had some sort of resurgance.
|
||||
|
|
|
@ -98,10 +98,28 @@ impl IntoResponse for WebsiteError {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::AppState;
|
||||
|
||||
#[test]
|
||||
fn render_index() {
|
||||
let tera = tera::Tera::new("templates/**/*").unwrap();
|
||||
let ctx = tera::Context::new();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue