Skip to content

Commit 380d03f

Browse files
committed
Kill off Makefile
Due to rust-lang/rust#9602, the connection pool test had to be pulled into the main test file.
1 parent 324809f commit 380d03f

3 files changed

Lines changed: 30 additions & 56 deletions

File tree

Makefile

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/postgres/pool/test.rs

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/postgres/test.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
extern mod extra;
22
extern mod postgres;
33

4+
use extra::comm::DuplexStream;
5+
use extra::future::Future;
46
use extra::time;
57
use extra::time::Timespec;
68
use extra::json;
@@ -19,6 +21,34 @@ use postgres::{PostgresNoticeHandler,
1921
ResultDescription};
2022
use postgres::error::hack::{SyntaxError, InvalidPassword};
2123
use postgres::types::{ToSql, FromSql, PgInt4, PgVarchar};
24+
use postgres::pool::PostgresConnectionPool;
25+
26+
27+
#[test]
28+
// TODO move back to pool/test.rs once mozilla/rust#9602 is fixed
29+
// Make sure we can take both connections at once and can still get one after
30+
fn test_pool() {
31+
let pool = PostgresConnectionPool::new("postgres://postgres@localhost", 2);
32+
33+
let (stream1, stream2) = DuplexStream::<(), ()>();
34+
35+
let mut fut1 = do Future::spawn_with(pool.clone()) |pool| {
36+
let _conn = pool.get_connection();
37+
stream1.send(());
38+
stream1.recv();
39+
};
40+
41+
let mut fut2 = do Future::spawn_with(pool.clone()) |pool| {
42+
let _conn = pool.get_connection();
43+
stream2.send(());
44+
stream2.recv();
45+
};
46+
47+
fut1.get();
48+
fut2.get();
49+
50+
pool.get_connection();
51+
}
2252

2353
#[test]
2454
fn test_prepare_err() {

0 commit comments

Comments
 (0)