Skip to content

Commit b2e76e3

Browse files
committed
first test for pool
1 parent ca4bc01 commit b2e76e3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/storage/sqlite_pool.rs

+23
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,26 @@ impl SqliteConnectionPool {
7777
f(&conn)
7878
}
7979
}
80+
81+
#[cfg(test)]
82+
mod tests {
83+
use super::*;
84+
85+
#[test]
86+
fn test_simple_connection() {
87+
let filename = tempfile::NamedTempFile::new().unwrap().into_temp_path();
88+
rusqlite::Connection::open(&filename).unwrap();
89+
90+
let pool = SqliteConnectionPool::new(NonZeroU64::new(1).unwrap());
91+
92+
pool.with_connection(&filename, |conn| {
93+
conn.query_row("SELECT 1", [], |row| {
94+
assert_eq!(row.get::<_, i32>(0).unwrap(), 1);
95+
Ok(())
96+
})
97+
.unwrap();
98+
Ok(())
99+
})
100+
.unwrap();
101+
}
102+
}

0 commit comments

Comments
 (0)