#[macro_use] extern crate nickel; extern crate diesel; extern crate nickel_diesel; extern crate r2d2; extern crate r2d2_diesel; use r2d2::{Config, NopErrorHandler, Pool}; use r2d2_diesel::ConnectionManager; #[cfg(feature = "sqlite")] use diesel::sqlite::SqliteConnection; use nickel::Nickel; use nickel_diesel::DieselMiddleware; #[cfg(feature = "sqlite")] #[test] fn test_sqlite_middleware_new() { let mut server = Nickel::new(); let database_url = ":memory:"; let dbpool: DieselMiddleware = DieselMiddleware::new(&*database_url, 5, Box::new(NopErrorHandler)).unwrap(); server.utilize(dbpool); } #[cfg(feature = "sqlite")] #[test] fn test_sqlite_middleware_from_pool() { let mut server = Nickel::new(); let database_url = ":memory:"; let manager = ConnectionManager::::new(database_url); let config = Config::builder() .pool_size(5) .error_handler(Box::new(NopErrorHandler)) .build(); let pool = Pool::new(config, manager).unwrap(); let diesel_mw = DieselMiddleware::from_pool(pool); server.utilize(diesel_mw); }