Make tests return Result

This commit is contained in:
gwenn
2020-11-05 22:14:00 +01:00
parent 65c38bf813
commit da94f8eba6
30 changed files with 1040 additions and 1179 deletions

View File

@@ -106,11 +106,11 @@ mod test {
use std::time;
#[test]
fn test_unlock_notify() {
fn test_unlock_notify() -> Result<()> {
let url = "file::memory:?cache=shared";
let flags = OpenFlags::SQLITE_OPEN_READ_WRITE | OpenFlags::SQLITE_OPEN_URI;
let db1 = Connection::open_with_flags(url, flags).unwrap();
db1.execute_batch("CREATE TABLE foo (x)").unwrap();
let db1 = Connection::open_with_flags(url, flags)?;
db1.execute_batch("CREATE TABLE foo (x)")?;
let (rx, tx) = sync_channel(0);
let child = thread::spawn(move || {
let mut db2 = Connection::open_with_flags(url, flags).unwrap();
@@ -123,7 +123,8 @@ mod test {
});
assert_eq!(tx.recv().unwrap(), 1);
let the_answer: Result<i64> = db1.query_row("SELECT x FROM foo", [], |r| r.get(0));
assert_eq!(42i64, the_answer.unwrap());
assert_eq!(42i64, the_answer?);
child.join().unwrap();
Ok(())
}
}