Refactor pool tests
Also actually build + compile types tests <_<
This commit is contained in:
34
src/test/pool.rs
Normal file
34
src/test/pool.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use std::comm;
|
||||
use std::sync::Future;
|
||||
|
||||
use postgres::NoSsl;
|
||||
use postgres::pool::PostgresConnectionPool;
|
||||
|
||||
#[test]
|
||||
// Make sure we can take both connections at once and can still get one after
|
||||
fn test_pool() {
|
||||
let pool = or_fail!(PostgresConnectionPool::new("postgres://postgres@localhost",
|
||||
NoSsl, 2));
|
||||
|
||||
let (s1, r1) = comm::channel();
|
||||
let (s2, r2) = comm::channel();
|
||||
|
||||
let pool1 = pool.clone();
|
||||
let mut fut1 = Future::spawn(proc() {
|
||||
let _conn = pool1.get_connection();
|
||||
s1.send(());
|
||||
r2.recv();
|
||||
});
|
||||
|
||||
let pool2 = pool.clone();
|
||||
let mut fut2 = Future::spawn(proc() {
|
||||
let _conn = pool2.get_connection();
|
||||
s2.send(());
|
||||
r1.recv();
|
||||
});
|
||||
|
||||
fut1.get();
|
||||
fut2.get();
|
||||
|
||||
pool.get_connection();
|
||||
}
|
||||
@@ -9,8 +9,6 @@ extern crate uuid;
|
||||
extern crate openssl;
|
||||
|
||||
use serialize::json;
|
||||
use std::comm;
|
||||
use std::sync::Future;
|
||||
use time::Timespec;
|
||||
use uuid::Uuid;
|
||||
use openssl::ssl::{SslContext, Sslv3};
|
||||
@@ -45,7 +43,6 @@ use postgres::error::{PgConnectDbError,
|
||||
use postgres::types::{ToSql, FromSql, PgInt4, PgVarchar};
|
||||
use postgres::types::array::{ArrayBase};
|
||||
use postgres::types::range::{Range, Inclusive, Exclusive, RangeBound};
|
||||
use postgres::pool::PostgresConnectionPool;
|
||||
|
||||
macro_rules! or_fail(
|
||||
($e:expr) => (
|
||||
@@ -56,34 +53,8 @@ macro_rules! or_fail(
|
||||
)
|
||||
)
|
||||
|
||||
#[test]
|
||||
// Make sure we can take both connections at once and can still get one after
|
||||
fn test_pool() {
|
||||
let pool = or_fail!(PostgresConnectionPool::new("postgres://postgres@localhost",
|
||||
NoSsl, 2));
|
||||
|
||||
let (s1, r1) = comm::channel();
|
||||
let (s2, r2) = comm::channel();
|
||||
|
||||
let pool1 = pool.clone();
|
||||
let mut fut1 = Future::spawn(proc() {
|
||||
let _conn = pool1.get_connection();
|
||||
s1.send(());
|
||||
r2.recv();
|
||||
});
|
||||
|
||||
let pool2 = pool.clone();
|
||||
let mut fut2 = Future::spawn(proc() {
|
||||
let _conn = pool2.get_connection();
|
||||
s2.send(());
|
||||
r1.recv();
|
||||
});
|
||||
|
||||
fut1.get();
|
||||
fut2.get();
|
||||
|
||||
pool.get_connection();
|
||||
}
|
||||
mod types;
|
||||
mod pool;
|
||||
|
||||
#[test]
|
||||
fn test_non_default_database() {
|
||||
|
||||
Reference in New Issue
Block a user