Kill off Makefile
Due to mozilla/rust#9602, the connection pool test had to be pulled into the main test file.
This commit is contained in:
24
Makefile
24
Makefile
@@ -1,24 +0,0 @@
|
||||
RUSTC ?= rustc
|
||||
RUSTFLAGS += -L. -Z debug-info
|
||||
|
||||
.PHONY: all
|
||||
all: postgres.dummy
|
||||
|
||||
postgres.dummy: src/lib.rs src/message.rs src/types.rs src/error.rs src/pool/mod.rs
|
||||
$(RUSTC) $(RUSTFLAGS) --lib src/lib.rs --out-dir .
|
||||
touch $@
|
||||
|
||||
.PHONY: check
|
||||
check: check-postgres check-pool
|
||||
|
||||
check-postgres: postgres.dummy src/test.rs
|
||||
$(RUSTC) $(RUSTFLAGS) --test src/test.rs -o $@
|
||||
./$@
|
||||
|
||||
check-pool: postgres.dummy src/pool/test.rs
|
||||
$(RUSTC) $(RUSTFLAGS) --test src/pool/test.rs -o $@
|
||||
./$@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
git clean -dfx
|
||||
@@ -1,32 +0,0 @@
|
||||
extern mod extra;
|
||||
extern mod postgres;
|
||||
|
||||
use extra::comm::DuplexStream;
|
||||
use extra::future::Future;
|
||||
|
||||
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 = PostgresConnectionPool::new("postgres://postgres@localhost", 2);
|
||||
|
||||
let (stream1, stream2) = DuplexStream::<(), ()>();
|
||||
|
||||
let mut fut1 = do Future::spawn_with(pool.clone()) |pool| {
|
||||
let _conn = pool.get_connection();
|
||||
stream1.send(());
|
||||
stream1.recv();
|
||||
};
|
||||
|
||||
let mut fut2 = do Future::spawn_with(pool.clone()) |pool| {
|
||||
let _conn = pool.get_connection();
|
||||
stream2.send(());
|
||||
stream2.recv();
|
||||
};
|
||||
|
||||
fut1.get();
|
||||
fut2.get();
|
||||
|
||||
pool.get_connection();
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
extern mod extra;
|
||||
extern mod postgres;
|
||||
|
||||
use extra::comm::DuplexStream;
|
||||
use extra::future::Future;
|
||||
use extra::time;
|
||||
use extra::time::Timespec;
|
||||
use extra::json;
|
||||
@@ -19,6 +21,34 @@ use postgres::{PostgresNoticeHandler,
|
||||
ResultDescription};
|
||||
use postgres::error::hack::{SyntaxError, InvalidPassword};
|
||||
use postgres::types::{ToSql, FromSql, PgInt4, PgVarchar};
|
||||
use postgres::pool::PostgresConnectionPool;
|
||||
|
||||
|
||||
#[test]
|
||||
// TODO move back to pool/test.rs once mozilla/rust#9602 is fixed
|
||||
// Make sure we can take both connections at once and can still get one after
|
||||
fn test_pool() {
|
||||
let pool = PostgresConnectionPool::new("postgres://postgres@localhost", 2);
|
||||
|
||||
let (stream1, stream2) = DuplexStream::<(), ()>();
|
||||
|
||||
let mut fut1 = do Future::spawn_with(pool.clone()) |pool| {
|
||||
let _conn = pool.get_connection();
|
||||
stream1.send(());
|
||||
stream1.recv();
|
||||
};
|
||||
|
||||
let mut fut2 = do Future::spawn_with(pool.clone()) |pool| {
|
||||
let _conn = pool.get_connection();
|
||||
stream2.send(());
|
||||
stream2.recv();
|
||||
};
|
||||
|
||||
fut1.get();
|
||||
fut2.get();
|
||||
|
||||
pool.get_connection();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_prepare_err() {
|
||||
|
||||
Reference in New Issue
Block a user