mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-22 07:09: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::time::Duration;
|
||||
|
||||
use crate::{Connection, Error, ErrorCode, Result, TransactionBehavior};
|
||||
use crate::{Connection, ErrorCode, Result, TransactionBehavior};
|
||||
|
||||
#[test]
|
||||
fn test_default_busy() -> Result<()> {
|
||||
@ -101,12 +101,10 @@ mod test {
|
||||
let tx1 = db1.transaction_with_behavior(TransactionBehavior::Exclusive)?;
|
||||
let db2 = Connection::open(&path)?;
|
||||
let r: Result<()> = db2.query_row("PRAGMA schema_version", [], |_| unreachable!());
|
||||
match r.unwrap_err() {
|
||||
Error::SqliteFailure(err, _) => {
|
||||
assert_eq!(err.code, ErrorCode::DatabaseBusy);
|
||||
}
|
||||
err => panic!("Unexpected error {}", err),
|
||||
}
|
||||
assert_eq!(
|
||||
r.unwrap_err().sqlite_error_code(),
|
||||
Some(ErrorCode::DatabaseBusy)
|
||||
);
|
||||
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();
|
||||
|
||||
match result.unwrap_err() {
|
||||
Error::SqliteFailure(err, _) => {
|
||||
assert_eq!(err.code, ErrorCode::OperationInterrupted);
|
||||
}
|
||||
err => {
|
||||
panic!("Unexpected error {}", err);
|
||||
}
|
||||
}
|
||||
assert_eq!(
|
||||
result.unwrap_err().sqlite_error_code(),
|
||||
Some(ErrorCode::OperationInterrupted)
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user