From e8e6be0ce9bc82441a47f8b8b3e946c7b10f825d Mon Sep 17 00:00:00 2001 From: Ivan Ukhov Date: Wed, 10 Jun 2020 20:22:16 +0200 Subject: [PATCH] Move a test --- tests/lib.rs | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/tests/lib.rs b/tests/lib.rs index d334702..3d8f636 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -6,6 +6,25 @@ use std::path::Path; macro_rules! ok(($result:expr) => ($result.unwrap())); +#[test] +fn connection_changes() { + let connection = setup_users(":memory:"); + assert_eq!(connection.changes(), 1); + assert_eq!(connection.total_changes(), 1); + + ok!(connection.execute("UPDATE users SET name = 'Bob' WHERE id = 1")); + assert_eq!(connection.changes(), 1); + assert_eq!(connection.total_changes(), 2); + + ok!(connection.execute("INSERT INTO users VALUES (2, 'Bob', NULL, NULL)")); + assert_eq!(connection.changes(), 1); + assert_eq!(connection.total_changes(), 3); + + ok!(connection.execute("DELETE FROM users")); + assert_eq!(connection.changes(), 2); + assert_eq!(connection.total_changes(), 5); +} + #[test] fn connection_error() { let connection = setup_users(":memory:"); @@ -41,27 +60,6 @@ fn connection_iterate() { assert!(done); } -#[test] -fn connection_changes() { - let connection = setup_users(":memory:"); - - // The insert in setup_users() counts as a change - assert_eq!(connection.changes(), 1); - assert_eq!(connection.total_changes(), 1); - - ok!(connection.execute("UPDATE users SET name = 'Bob' WHERE id = 1")); - assert_eq!(connection.changes(), 1); - assert_eq!(connection.total_changes(), 2); - - ok!(connection.execute("INSERT INTO users VALUES (2, 'Bob', NULL, NULL)")); - assert_eq!(connection.changes(), 1); - assert_eq!(connection.total_changes(), 3); - - ok!(connection.execute("DELETE FROM users")); - assert_eq!(connection.changes(), 2); - assert_eq!(connection.total_changes(), 5); -} - #[test] fn connection_open_with_flags() { use temporary::Directory;