syntactic changes: replace unwrap() with ? in functions that return Result<...>

This commit is contained in:
Jorge López
2025-01-18 18:33:43 +01:00
parent 86a4714711
commit f160206cdd
7 changed files with 36 additions and 32 deletions

View File

@@ -332,7 +332,7 @@ mod tests {
for i in 0..iterations {
let insert_query = format!("INSERT INTO test VALUES ({})", i);
do_flush(&conn, &tmp_db)?;
conn.checkpoint().unwrap();
conn.checkpoint()?;
match conn.query(insert_query) {
Ok(Some(ref mut rows)) => loop {
match rows.next_row()? {
@@ -351,7 +351,7 @@ mod tests {
}
do_flush(&conn, &tmp_db)?;
conn.clear_page_cache().unwrap();
conn.clear_page_cache()?;
let list_query = "SELECT * FROM test LIMIT 1";
let mut current_index = 0;
match conn.query(list_query) {
@@ -417,7 +417,7 @@ mod tests {
debug!("counting");
let list_query = "SELECT count(x) FROM test";
loop {
if let Some(ref mut rows) = conn.query(list_query).unwrap() {
if let Some(ref mut rows) = conn.query(list_query)? {
loop {
match rows.next_row()? {
StepResult::Row(row) => {
@@ -445,12 +445,13 @@ mod tests {
let conn = tmp_db.connect_limbo();
insert(1, &conn, &tmp_db).unwrap();
assert_eq!(count(&conn, &tmp_db).unwrap(), 1);
insert(1, &conn, &tmp_db)?;
conn.close()?;
}
{
let conn = tmp_db.connect_limbo();
assert_eq!(
count(&conn, &tmp_db).unwrap(),
count(&conn, &tmp_db)?,
1,
"failed to read from wal from another connection"
);
@@ -619,7 +620,7 @@ mod tests {
let mut stmt = conn.prepare("select ?")?;
stmt.bind_at(1.try_into().unwrap(), Value::Integer(1));
stmt.bind_at(1.try_into()?, Value::Integer(1));
loop {
match stmt.step()? {
@@ -633,7 +634,7 @@ mod tests {
stmt.reset();
stmt.bind_at(1.try_into().unwrap(), Value::Integer(2));
stmt.bind_at(1.try_into()?, Value::Integer(2));
loop {
match stmt.step()? {
@@ -656,14 +657,14 @@ mod tests {
let mut stmt = conn.prepare("select ?, ?1, :named, ?3, ?4")?;
stmt.bind_at(1.try_into().unwrap(), Value::Text(&"hello".to_string()));
stmt.bind_at(1.try_into()?, Value::Text(&"hello".to_string()));
let i = stmt.parameters().index(":named").unwrap();
stmt.bind_at(i, Value::Integer(42));
stmt.bind_at(3.try_into().unwrap(), Value::Blob(&vec![0x1, 0x2, 0x3]));
stmt.bind_at(3.try_into()?, Value::Blob(&vec![0x1, 0x2, 0x3]));
stmt.bind_at(4.try_into().unwrap(), Value::Float(0.5));
stmt.bind_at(4.try_into()?, Value::Float(0.5));
assert_eq!(stmt.parameters().count(), 4);