summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2019-03-28 10:18:53 -0500
committertom barrett <spalf0@gmail.com>2019-03-29 07:42:22 -0500
commit50d92d677d6d53a83df15188c1b820b2b163e720 (patch)
tree4aa31171a8a00e8967c17b5eaf99afdf49e66724 /tests
parentf8c446ce74329fc5844e0fc1fd82e618242196f4 (diff)
unified entires, now use main serde lib, added another postgres test assert, simplified
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.rs18
1 files changed, 13 insertions, 5 deletions
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::<MassEntry>(&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::<MassEntry>(&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");