mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-22 16:29:20 +08:00
Use sqlite_error_code where possible
This commit is contained in:
parent
f54e550b2b
commit
fedf6b41ae
12
src/busy.rs
12
src/busy.rs
@ -90,7 +90,7 @@ mod test {
|
|||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use crate::{Connection, Error, ErrorCode, Result, TransactionBehavior};
|
use crate::{Connection, ErrorCode, Result, TransactionBehavior};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_default_busy() -> Result<()> {
|
fn test_default_busy() -> Result<()> {
|
||||||
@ -101,12 +101,10 @@ mod test {
|
|||||||
let tx1 = db1.transaction_with_behavior(TransactionBehavior::Exclusive)?;
|
let tx1 = db1.transaction_with_behavior(TransactionBehavior::Exclusive)?;
|
||||||
let db2 = Connection::open(&path)?;
|
let db2 = Connection::open(&path)?;
|
||||||
let r: Result<()> = db2.query_row("PRAGMA schema_version", [], |_| unreachable!());
|
let r: Result<()> = db2.query_row("PRAGMA schema_version", [], |_| unreachable!());
|
||||||
match r.unwrap_err() {
|
assert_eq!(
|
||||||
Error::SqliteFailure(err, _) => {
|
r.unwrap_err().sqlite_error_code(),
|
||||||
assert_eq!(err.code, ErrorCode::DatabaseBusy);
|
Some(ErrorCode::DatabaseBusy)
|
||||||
}
|
);
|
||||||
err => panic!("Unexpected error {}", err),
|
|
||||||
}
|
|
||||||
tx1.rollback()
|
tx1.rollback()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
src/lib.rs
12
src/lib.rs
@ -1742,14 +1742,10 @@ mod test {
|
|||||||
|
|
||||||
let result: Result<Vec<i32>> = stmt.query([])?.map(|r| r.get(0)).collect();
|
let result: Result<Vec<i32>> = stmt.query([])?.map(|r| r.get(0)).collect();
|
||||||
|
|
||||||
match result.unwrap_err() {
|
assert_eq!(
|
||||||
Error::SqliteFailure(err, _) => {
|
result.unwrap_err().sqlite_error_code(),
|
||||||
assert_eq!(err.code, ErrorCode::OperationInterrupted);
|
Some(ErrorCode::OperationInterrupted)
|
||||||
}
|
);
|
||||||
err => {
|
|
||||||
panic!("Unexpected error {}", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user