mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-26 19:41:37 +08:00
Expose query progress information
Add unit tests
This commit is contained in:
parent
f5c83af863
commit
49325296a9
29
src/hooks.rs
29
src/hooks.rs
@ -364,4 +364,33 @@ mod test {
|
|||||||
db.execute_batch("INSERT INTO foo VALUES ('lisa')").unwrap();
|
db.execute_batch("INSERT INTO foo VALUES ('lisa')").unwrap();
|
||||||
assert!(CALLED.load(Ordering::Relaxed));
|
assert!(CALLED.load(Ordering::Relaxed));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_progress_handler() {
|
||||||
|
let db = Connection::open_in_memory().unwrap();
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref CALLED: AtomicBool = AtomicBool::new(false);
|
||||||
|
}
|
||||||
|
db.progress_handler(1, Some(|| {
|
||||||
|
CALLED.store(true, Ordering::Relaxed);
|
||||||
|
false
|
||||||
|
}));
|
||||||
|
db.execute_batch("BEGIN; CREATE TABLE foo (t TEXT); COMMIT;")
|
||||||
|
.unwrap();
|
||||||
|
assert!(CALLED.load(Ordering::Relaxed));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_progress_handler_interrupt() {
|
||||||
|
let db = Connection::open_in_memory().unwrap();
|
||||||
|
|
||||||
|
fn handler() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
db.progress_handler(1, Some(handler));
|
||||||
|
db.execute_batch("BEGIN; CREATE TABLE foo (t TEXT); COMMIT;")
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user