aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/apitests.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/tests/apitests.rs b/tests/apitests.rs
index e0803a8..94240ed 100644
--- a/tests/apitests.rs
+++ b/tests/apitests.rs
@@ -17,8 +17,9 @@
*/
use ramaskrik;
-use ramaskrik::models::{Film, NewFilm, Room, Screening};
+use ramaskrik::models::{Film, NewFilm, Room, AggregatedScreening};
+use chrono::{Utc, TimeZone};
use lazy_static::lazy_static;
use rocket::http::ContentType;
use rocket_contrib::databases::diesel::prelude::*;
@@ -34,10 +35,7 @@ pub fn server_with_db<TestFn>(f: TestFn)
{
let _lock = MUTEX.lock();
- let db_url = dotenv::var("TEST_DATABASE_URL")
- .map_err(|_| "No database! Set TEST_DATABASE_URL env var and try again.").unwrap();
-
- let server = ramaskrik::build_rocket(&db_url).unwrap();
+ let server = ramaskrik::build_rocket().unwrap();
let db = ramaskrik::db::Connection::get_one(&server).expect("Could not get db connection");
load_fixtures(&db);
@@ -123,16 +121,15 @@ fn getting_screenings_from_api() {
let r = db.get_room_by_name("Main room").unwrap();
let f = db.get_film_by_title("Hellraiser").unwrap();
- db.create_screening(&r, &f,
- chrono::NaiveDate::from_ymd(2019, 10, 21),
- chrono::NaiveTime::from_hms(18, 00, 00),
- chrono::NaiveTime::from_hms(19, 34, 00)).unwrap();
+ db.create_screening_from_aggregate(&r, &f,
+ Utc.ymd(2019, 10, 21).and_hms(18, 00, 00),
+ Utc.ymd(2019, 10, 21).and_hms(19, 34, 00)).unwrap();
let client = rocket::local::Client::new(server).unwrap();
let mut response = client.get("/screenings").dispatch();
assert_eq!(response.content_type(), Some(ContentType::JSON));
- let fetched_screenings: Vec<Screening> =
+ let fetched_screenings: Vec<AggregatedScreening> =
serde_json::from_str(&response.body_string().unwrap()).unwrap();
assert_eq!(fetched_screenings.len(), 1);