@@ -6,7 +6,8 @@ use std::time::Duration;
66use tokio_core:: reactor:: { Core , Interval } ;
77
88use super :: * ;
9- use error:: { Error , ConnectError , INVALID_PASSWORD , INVALID_AUTHORIZATION_SPECIFICATION , QUERY_CANCELED } ;
9+ use error:: { Error , ConnectError , INVALID_PASSWORD , INVALID_AUTHORIZATION_SPECIFICATION ,
10+ QUERY_CANCELED } ;
1011use params:: { ConnectParams , Host } ;
1112use types:: { ToSql , FromSql , Type , IsNull , Kind } ;
1213
@@ -101,25 +102,31 @@ fn pass_user_wrong_pass() {
101102#[ test]
102103fn batch_execute_ok ( ) {
103104 let mut l = Core :: new ( ) . unwrap ( ) ;
104- let done = Connection :: connect ( "postgres://postgres@localhost:5433" , TlsMode :: None , & l. handle ( ) )
105- . then ( |c| {
106- c. unwrap ( ) . batch_execute (
107- "CREATE TEMPORARY TABLE foo (id SERIAL);" ,
108- )
109- } ) ;
105+ let done = Connection :: connect (
106+ "postgres://postgres@localhost:5433" ,
107+ TlsMode :: None ,
108+ & l. handle ( ) ,
109+ ) . then ( |c| {
110+ c. unwrap ( ) . batch_execute (
111+ "CREATE TEMPORARY TABLE foo (id SERIAL);" ,
112+ )
113+ } ) ;
110114 l. run ( done) . unwrap ( ) ;
111115}
112116
113117#[ test]
114118fn batch_execute_err ( ) {
115119 let mut l = Core :: new ( ) . unwrap ( ) ;
116- let done = Connection :: connect ( "postgres://postgres@localhost:5433" , TlsMode :: None , & l. handle ( ) )
117- . then ( |r| {
118- r. unwrap ( ) . batch_execute (
119- "CREATE TEMPORARY TABLE foo (id SERIAL); INSERT INTO foo DEFAULT \
120+ let done = Connection :: connect (
121+ "postgres://postgres@localhost:5433" ,
122+ TlsMode :: None ,
123+ & l. handle ( ) ,
124+ ) . then ( |r| {
125+ r. unwrap ( ) . batch_execute (
126+ "CREATE TEMPORARY TABLE foo (id SERIAL); INSERT INTO foo DEFAULT \
120127 VALUES;",
121- )
122- } )
128+ )
129+ } )
123130 . and_then ( |c| c. batch_execute ( "SELECT * FROM bogo" ) )
124131 . then ( |r| match r {
125132 Err ( Error :: Db ( e, s) ) => {
@@ -135,12 +142,15 @@ fn batch_execute_err() {
135142#[ test]
136143fn prepare_execute ( ) {
137144 let mut l = Core :: new ( ) . unwrap ( ) ;
138- let done = Connection :: connect ( "postgres://postgres@localhost:5433" , TlsMode :: None , & l. handle ( ) )
139- . then ( |c| {
140- c. unwrap ( ) . prepare (
141- "CREATE TEMPORARY TABLE foo (id SERIAL PRIMARY KEY, name VARCHAR)" ,
142- )
143- } )
145+ let done = Connection :: connect (
146+ "postgres://postgres@localhost:5433" ,
147+ TlsMode :: None ,
148+ & l. handle ( ) ,
149+ ) . then ( |c| {
150+ c. unwrap ( ) . prepare (
151+ "CREATE TEMPORARY TABLE foo (id SERIAL PRIMARY KEY, name VARCHAR)" ,
152+ )
153+ } )
144154 . and_then ( |( s, c) | c. execute ( & s, & [ ] ) )
145155 . and_then ( |( n, c) | {
146156 assert_eq ! ( 0 , n) ;
@@ -154,22 +164,28 @@ fn prepare_execute() {
154164#[ test]
155165fn prepare_execute_rows ( ) {
156166 let mut l = Core :: new ( ) . unwrap ( ) ;
157- let done = Connection :: connect ( "postgres://postgres@localhost:5433" , TlsMode :: None , & l. handle ( ) )
158- . then ( |c| c. unwrap ( ) . prepare ( "SELECT 1" ) )
167+ let done = Connection :: connect (
168+ "postgres://postgres@localhost:5433" ,
169+ TlsMode :: None ,
170+ & l. handle ( ) ,
171+ ) . then ( |c| c. unwrap ( ) . prepare ( "SELECT 1" ) )
159172 . and_then ( |( s, c) | c. execute ( & s, & [ ] ) ) ;
160173 l. run ( done) . unwrap ( ) ;
161174}
162175
163176#[ test]
164177fn query ( ) {
165178 let mut l = Core :: new ( ) . unwrap ( ) ;
166- let done = Connection :: connect ( "postgres://postgres@localhost:5433" , TlsMode :: None , & l. handle ( ) )
167- . then ( |c| {
168- c. unwrap ( ) . batch_execute (
169- "CREATE TEMPORARY TABLE foo (id SERIAL, name VARCHAR);
179+ let done = Connection :: connect (
180+ "postgres://postgres@localhost:5433" ,
181+ TlsMode :: None ,
182+ & l. handle ( ) ,
183+ ) . then ( |c| {
184+ c. unwrap ( ) . batch_execute (
185+ "CREATE TEMPORARY TABLE foo (id SERIAL, name VARCHAR);
170186 INSERT INTO foo (name) VALUES ('joe'), ('bob')" ,
171- )
172- } )
187+ )
188+ } )
173189 . and_then ( |c| c. prepare ( "SELECT id, name FROM foo ORDER BY id" ) )
174190 . and_then ( |( s, c) | c. query ( & s, & [ ] ) . collect ( ) )
175191 . and_then ( |( r, c) | {
@@ -187,12 +203,15 @@ fn query() {
187203#[ test]
188204fn transaction ( ) {
189205 let mut l = Core :: new ( ) . unwrap ( ) ;
190- let done = Connection :: connect ( "postgres://postgres@localhost:5433" , TlsMode :: None , & l. handle ( ) )
191- . then ( |c| {
192- c. unwrap ( ) . batch_execute (
193- "CREATE TEMPORARY TABLE foo (id SERIAL, name VARCHAR);" ,
194- )
195- } )
206+ let done = Connection :: connect (
207+ "postgres://postgres@localhost:5433" ,
208+ TlsMode :: None ,
209+ & l. handle ( ) ,
210+ ) . then ( |c| {
211+ c. unwrap ( ) . batch_execute (
212+ "CREATE TEMPORARY TABLE foo (id SERIAL, name VARCHAR);" ,
213+ )
214+ } )
196215 . then ( |c| c. unwrap ( ) . transaction ( ) )
197216 . then ( |t| {
198217 t. unwrap ( ) . batch_execute (
@@ -451,13 +470,12 @@ fn notifications() {
451470 let done = Connection :: connect ( "postgres://postgres@localhost:5433" , TlsMode :: None , & handle)
452471 . then ( |c| c. unwrap ( ) . batch_execute ( "LISTEN test_notifications" ) )
453472 . and_then ( |c1| {
454- Connection :: connect ( "postgres://postgres@localhost:5433" , TlsMode :: None , & handle) . then (
455- |c2| {
473+ Connection :: connect ( "postgres://postgres@localhost:5433" , TlsMode :: None , & handle)
474+ . then ( |c2| {
456475 c2. unwrap ( )
457476 . batch_execute ( "NOTIFY test_notifications, 'foo'" )
458477 . map ( |_| c1)
459- } ,
460- )
478+ } )
461479 } )
462480 . and_then ( |c| c. notifications ( ) . into_future ( ) . map_err ( |( e, _) | e) )
463481 . map ( |( n, _) | {
0 commit comments