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

View File

@ -846,10 +846,10 @@ unsafe fn db_filename(_: *mut ffi::sqlite3) -> Option<PathBuf> {
#[cfg(test)]
mod test {
use fallible_iterator::FallibleIterator;
use self::tempdir::TempDir;
pub use super::*;
use crate::ffi;
use fallible_iterator::FallibleIterator;
pub use std::error::Error as StdError;
pub use std::fmt;
use tempdir;
@ -1133,7 +1133,9 @@ mod test {
let mut query = db.prepare("SELECT x, y FROM foo ORDER BY x DESC").unwrap();
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();
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)]
mod test {
use std::sync::atomic::{AtomicBool, Ordering};
use fallible_streaming_iterator::FallibleStreamingIterator;
use std::sync::atomic::{AtomicBool, Ordering};
use super::{Changeset, ChangesetIter, ConflictAction, ConflictType, Session};
use crate::hooks::Action;

View File

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

View File

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