This commit is contained in:
gwenn 2019-03-19 20:45:04 +01:00
parent 4703358866
commit ceb1ce4a55
5 changed files with 19 additions and 18 deletions

View File

@ -151,9 +151,9 @@ impl StatementCache {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use fallible_iterator::FallibleIterator;
use super::StatementCache; use super::StatementCache;
use crate::{Connection, NO_PARAMS}; use crate::{Connection, NO_PARAMS};
use fallible_iterator::FallibleIterator;
impl StatementCache { impl StatementCache {
fn clear(&self) { fn clear(&self) {
@ -279,8 +279,7 @@ mod test {
let mut stmt = db.prepare_cached(sql).unwrap(); let mut stmt = db.prepare_cached(sql).unwrap();
assert_eq!( assert_eq!(
Ok(Some(1i32)), Ok(Some(1i32)),
stmt.query(NO_PARAMS).unwrap().map(|r| r.get(0)) stmt.query(NO_PARAMS).unwrap().map(|r| r.get(0)).next()
.next()
); );
} }
@ -296,7 +295,9 @@ mod test {
let mut stmt = db.prepare_cached(sql).unwrap(); let mut stmt = db.prepare_cached(sql).unwrap();
assert_eq!( assert_eq!(
Ok(Some((1i32, 2i32))), Ok(Some((1i32, 2i32))),
stmt.query(NO_PARAMS).unwrap().map(|r| Ok((r.get(0)?, r.get(1)?))) stmt.query(NO_PARAMS)
.unwrap()
.map(|r| Ok((r.get(0)?, r.get(1)?)))
.next() .next()
); );
} }

View File

@ -846,10 +846,10 @@ unsafe fn db_filename(_: *mut ffi::sqlite3) -> Option<PathBuf> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use fallible_iterator::FallibleIterator;
use self::tempdir::TempDir; use self::tempdir::TempDir;
pub use super::*; pub use super::*;
use crate::ffi; use crate::ffi;
use fallible_iterator::FallibleIterator;
pub use std::error::Error as StdError; pub use std::error::Error as StdError;
pub use std::fmt; pub use std::fmt;
use tempdir; use tempdir;
@ -1133,7 +1133,9 @@ mod test {
let mut query = db.prepare("SELECT x, y FROM foo ORDER BY x DESC").unwrap(); let mut query = db.prepare("SELECT x, y FROM foo ORDER BY x DESC").unwrap();
let results: Result<Vec<String>> = query let results: Result<Vec<String>> = query
.query(NO_PARAMS).unwrap().map(|row| row.get(1)) .query(NO_PARAMS)
.unwrap()
.map(|row| row.get(1))
.collect(); .collect();
assert_eq!(results.unwrap().concat(), "hello, world!"); assert_eq!(results.unwrap().concat(), "hello, world!");

View File

@ -719,8 +719,8 @@ unsafe extern "C" fn x_output(p_out: *mut c_void, data: *const c_void, len: c_in
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use std::sync::atomic::{AtomicBool, Ordering};
use fallible_streaming_iterator::FallibleStreamingIterator; use fallible_streaming_iterator::FallibleStreamingIterator;
use std::sync::atomic::{AtomicBool, Ordering};
use super::{Changeset, ChangesetIter, ConflictAction, ConflictType, Session}; use super::{Changeset, ChangesetIter, ConflictAction, ConflictType, Session};
use crate::hooks::Action; use crate::hooks::Action;

View File

@ -1,7 +1,7 @@
//! `ToSql` and `FromSql` implementation for [`url::Url`]. //! `ToSql` and `FromSql` implementation for [`url::Url`].
use url::Url;
use crate::Result;
use crate::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef}; use crate::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
use crate::Result;
use url::Url;
/// Serialize `Url` to text. /// Serialize `Url` to text.
impl ToSql for Url { impl ToSql for Url {
@ -23,8 +23,8 @@ impl FromSql for Url {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use url::{Url, ParseError}; use crate::{params, Connection, Error, Result};
use crate::{Connection, params, Error, Result}; use url::{ParseError, Url};
fn checked_memory_handle() -> Connection { fn checked_memory_handle() -> Connection {
let db = Connection::open_in_memory().unwrap(); let db = Connection::open_in_memory().unwrap();
@ -34,11 +34,7 @@ mod test {
} }
fn get_url(db: &Connection, id: i64) -> Result<Url> { fn get_url(db: &Connection, id: i64) -> Result<Url> {
db.query_row( db.query_row("SELECT v FROM urls WHERE i = ?", params![id], |r| r.get(0))
"SELECT v FROM urls WHERE i = ?",
params![id],
|r| r.get(0),
)
} }
#[test] #[test]

View File

@ -345,9 +345,9 @@ impl From<csv::Error> for Error {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use fallible_iterator::FallibleIterator;
use crate::vtab::csvtab; use crate::vtab::csvtab;
use crate::{Connection, Result, NO_PARAMS}; use crate::{Connection, Result, NO_PARAMS};
use fallible_iterator::FallibleIterator;
#[test] #[test]
fn test_csv_module() { fn test_csv_module() {
@ -364,7 +364,9 @@ mod test {
} }
let ids: Result<Vec<i32>> = s let ids: Result<Vec<i32>> = s
.query(NO_PARAMS).unwrap().map(|row| row.get::<_, i32>(0)) .query(NO_PARAMS)
.unwrap()
.map(|row| row.get::<_, i32>(0))
.collect(); .collect();
let sum = ids.unwrap().iter().sum::<i32>(); let sum = ids.unwrap().iter().sum::<i32>();
assert_eq!(sum, 15); assert_eq!(sum, 15);