rowt/src/tera/misc.rs
philipp 82aa94c024
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m54s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
rename planned_event to event
2024-05-28 09:08:48 +02:00

39 lines
977 B
Rust

use rocket::{get, http::ContentType, routes, Route, State};
use sqlx::SqlitePool;
use crate::model::event::Event;
#[get("/cal")]
async fn cal(db: &State<SqlitePool>) -> (ContentType, String) {
//TODO: add unit test once proper functionality is there
(ContentType::Calendar, Event::get_ics_feed(db).await)
}
pub fn routes() -> Vec<Route> {
routes![cal]
}
#[cfg(test)]
mod test {
use rocket::{http::Status, local::asynchronous::Client};
use sqlx::SqlitePool;
use crate::testdb;
#[sqlx::test]
fn test_without_login() {
let db = testdb!();
let rocket = rocket::build().manage(db.clone());
let rocket = crate::tera::config(rocket);
let client = Client::tracked(rocket).await.unwrap();
let req = client.get("/");
let response = req.dispatch().await;
assert_eq!(response.status(), Status::SeeOther);
assert_eq!(response.headers().get("Location").next(), Some("/auth"));
}
}