mirror of
https://github.com/fluencelabs/sqlite-wasm-connector
synced 2025-04-22 23:52:13 +00:00
Clean up the unit tests
This commit is contained in:
parent
02f8c79c9f
commit
b433054c82
@ -154,12 +154,10 @@ extern fn process_callback<F>(callback: *mut c_void, count: c_int, values: *mut
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::Connection;
|
use super::Connection;
|
||||||
use tests::setup;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute() {
|
fn execute() {
|
||||||
let (path, _directory) = setup();
|
let connection = Connection::open(":memory:").unwrap();
|
||||||
let connection = Connection::open(&path).unwrap();
|
|
||||||
match connection.execute(":)") {
|
match connection.execute(":)") {
|
||||||
Err(error) => assert_eq!(error.message,
|
Err(error) => assert_eq!(error.message,
|
||||||
Some(String::from(r#"unrecognized token: ":""#))),
|
Some(String::from(r#"unrecognized token: ":""#))),
|
||||||
@ -169,8 +167,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn set_busy_handler() {
|
fn set_busy_handler() {
|
||||||
let (path, _directory) = setup();
|
let mut connection = Connection::open(":memory:").unwrap();
|
||||||
let mut connection = Connection::open(&path).unwrap();
|
|
||||||
connection.set_busy_handler(|_| true).unwrap();
|
connection.set_busy_handler(|_| true).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
src/lib.rs
14
src/lib.rs
@ -48,9 +48,6 @@
|
|||||||
extern crate libc;
|
extern crate libc;
|
||||||
extern crate sqlite3_sys as ffi;
|
extern crate sqlite3_sys as ffi;
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
extern crate temporary;
|
|
||||||
|
|
||||||
macro_rules! raise(
|
macro_rules! raise(
|
||||||
($message:expr) => (return Err(::Error::from($message)));
|
($message:expr) => (return Err(::Error::from($message)));
|
||||||
);
|
);
|
||||||
@ -117,14 +114,3 @@ pub type Result<T> = std::result::Result<T, Error>;
|
|||||||
pub fn open<'l, T: AsRef<std::path::Path>>(path: T) -> Result<Connection<'l>> {
|
pub fn open<'l, T: AsRef<std::path::Path>>(path: T) -> Result<Connection<'l>> {
|
||||||
Connection::open(path)
|
Connection::open(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use temporary::Directory;
|
|
||||||
|
|
||||||
pub fn setup() -> (PathBuf, Directory) {
|
|
||||||
let directory = Directory::new("sqlite").unwrap();
|
|
||||||
(directory.path().join("database.sqlite3"), directory)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user