Extend the cursor_workflow test

This commit is contained in:
Ivan Ukhov 2015-11-22 20:26:47 +01:00
parent 96554c391d
commit 12816e86f2

View File

@ -99,19 +99,29 @@ fn cursor_wildcard_without_binding() {
#[test] #[test]
fn cursor_workflow() { fn cursor_workflow() {
let connection = setup_users(":memory:"); let connection = setup_users(":memory:");
let statement = "SELECT id, name FROM users WHERE id = ?";
let mut cursor = ok!(connection.prepare(statement)).cursor();
ok!(cursor.bind(&[Value::Integer(1)])); let select = "SELECT id, name FROM users WHERE id = ?";
assert_eq!(ok!(ok!(cursor.next())), &[Value::Integer(1), Value::String("Alice".to_string())]); let mut select = ok!(connection.prepare(select)).cursor();
assert_eq!(ok!(cursor.next()), None);
ok!(cursor.bind(&[Value::Integer(1)])); let insert = "INSERT INTO users (id, name) VALUES (?, ?)";
assert_eq!(ok!(ok!(cursor.next())), &[Value::Integer(1), Value::String("Alice".to_string())]); let mut insert = ok!(connection.prepare(insert)).cursor();
assert_eq!(ok!(cursor.next()), None);
ok!(cursor.bind(&[Value::Integer(42)])); for _ in 0..10 {
assert_eq!(ok!(cursor.next()), None); ok!(select.bind(&[Value::Integer(1)]));
assert_eq!(ok!(ok!(select.next())), &[Value::Integer(1),
Value::String("Alice".to_string())]);
assert_eq!(ok!(select.next()), None);
}
ok!(select.bind(&[Value::Integer(42)]));
assert_eq!(ok!(select.next()), None);
ok!(insert.bind(&[Value::Integer(42), Value::String("Bob".to_string())]));
assert_eq!(ok!(insert.next()), None);
ok!(select.bind(&[Value::Integer(42)]));
assert_eq!(ok!(ok!(select.next())), &[Value::Integer(42), Value::String("Bob".to_string())]);
assert_eq!(ok!(select.next()), None);
} }
#[test] #[test]