From 50d92d677d6d53a83df15188c1b820b2b163e720 Mon Sep 17 00:00:00 2001 From: tom barrett Date: Thu, 28 Mar 2019 10:18:53 -0500 Subject: unified entires, now use main serde lib, added another postgres test assert, simplified --- tests/tests.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/tests.rs b/tests/tests.rs index fd8349d..781e365 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -529,14 +529,15 @@ mod tests { fn test_postgres() { let connection = PgConnection::establish(&get_db_url()).expect("Cannot connect"); - let masses = db_masses + let size = db_masses .load::(&connection) - .expect("Cannot query, probably no migrations, run 'cargo run --bin migrate'"); - let size = masses.len(); - let name = String::from("test"); + .expect("Cannot query, probably no migrations, run 'cargo run --bin migrate'") + .len(); + let name = String::from("test"); + let mass = Mass::new_astroid(); diesel::insert_into(db_masses) - .values(&Mass::new_astroid().to_new_mass_entry(name.clone())) + .values(&mass.to_mass_entry(name.clone())) .execute(&connection) .expect("Cannot insert"); @@ -547,6 +548,13 @@ mod tests { assert!(len == size + 1); + let db_mass = db_masses + .filter(dsl::name.eq(name.clone())) + .load::(&connection) + .expect("Cannot filter"); + + assert!(mass.position.x == db_mass[0].pos_x); + diesel::delete(db_masses.filter(dsl::name.eq(name))) .execute(&connection) .expect("Cannot delete"); -- cgit v1.2.3