diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2019-04-08 15:55:14 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2019-04-08 15:55:14 +0200 |
commit | ad0e585abed7a189b6117e9187c9afff809d1414 (patch) | |
tree | d1e80624e0f87882e90c0fe87a99a817e7edc61d /tests | |
parent | 5ab5f490bc7199709fbc03d51bf6131e92269fdc (diff) | |
download | ramaskrik-social-ad0e585abed7a189b6117e9187c9afff809d1414.tar.gz ramaskrik-social-ad0e585abed7a189b6117e9187c9afff809d1414.tar.bz2 ramaskrik-social-ad0e585abed7a189b6117e9187c9afff809d1414.zip |
Move functions to query/modify db to connection object.
Makes tha API a bit nicer by asking the database rather than
passing the database on to each model. Reserve models for
method/functions that work on the model structs themselves.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/apitests.rs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/tests/apitests.rs b/tests/apitests.rs index 58be302..54b7961 100644 --- a/tests/apitests.rs +++ b/tests/apitests.rs @@ -18,7 +18,6 @@ use ramaskrik; use ramaskrik::models::{ - self, film::{ Film, NewFilm }, room::Room, screening, @@ -125,25 +124,25 @@ fn getting_films_from_api() { #[test] fn getting_screenings_from_api() { server_with_db(|server, db| { - let r = models::room::by_name("Main room", &db).unwrap(); - let f = models::film::by_title("Hellraiser", &db).unwrap(); - screening::create(&r, &f, + 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), - &db).unwrap(); + chrono::NaiveTime::from_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::Screening, Option<Film>, Option<Room>)> = + let fetched_screenings: Vec<(screening::Screening, Film, Room)> = serde_json::from_str(&response.body_string().unwrap()).unwrap(); assert_eq!(fetched_screenings.len(), 1); - let (scr, ff, rr) = &fetched_screenings[0]; - assert_eq!(ff.as_ref().unwrap().title, "Hellraiser"); - assert_eq!(rr.as_ref().unwrap().name, "Main room"); + let (_scr, ff, rr) = &fetched_screenings[0]; + assert_eq!(ff.title, "Hellraiser"); + assert_eq!(rr.name, "Main room"); }); } |