@@ -31,7 +31,8 @@ use error::{PgConnectDbError,
3131 SyntaxError ,
3232 InvalidPassword ,
3333 QueryCanceled ,
34- InvalidCatalogName } ;
34+ InvalidCatalogName ,
35+ PgWrongTransaction } ;
3536use types:: { ToSql , FromSql , PgInt4 , PgVarchar } ;
3637use types:: array:: { ArrayBase } ;
3738use types:: range:: { Range , Inclusive , Exclusive , RangeBound } ;
@@ -295,6 +296,39 @@ fn test_nested_transactions_finish() {
295296 assert_eq ! ( vec![ 1i32 ] , result. map( |row| row[ 1 ] ) . collect( ) ) ;
296297}
297298
299+ #[ test]
300+ fn test_conn_prepare_with_trans ( ) {
301+ let conn = or_fail ! ( PostgresConnection :: connect( "postgres://postgres@localhost" , & NoSsl ) ) ;
302+ let _trans = or_fail ! ( conn. transaction( ) ) ;
303+ match conn. prepare ( "" ) {
304+ Err ( PgWrongTransaction ) => { }
305+ Err ( r) => fail ! ( "Unexpected error {}" , r) ,
306+ Ok ( _) => fail ! ( "Unexpected success" ) ,
307+ }
308+ match conn. transaction ( ) {
309+ Err ( PgWrongTransaction ) => { }
310+ Err ( r) => fail ! ( "Unexpected error {}" , r) ,
311+ Ok ( _) => fail ! ( "Unexpected success" ) ,
312+ }
313+ }
314+
315+ #[ test]
316+ fn test_trans_prepare_with_nested_trans ( ) {
317+ let conn = or_fail ! ( PostgresConnection :: connect( "postgres://postgres@localhost" , & NoSsl ) ) ;
318+ let trans = or_fail ! ( conn. transaction( ) ) ;
319+ let _trans2 = or_fail ! ( trans. transaction( ) ) ;
320+ match trans. prepare ( "" ) {
321+ Err ( PgWrongTransaction ) => { }
322+ Err ( r) => fail ! ( "Unexpected error {}" , r) ,
323+ Ok ( _) => fail ! ( "Unexpected success" ) ,
324+ }
325+ match trans. transaction ( ) {
326+ Err ( PgWrongTransaction ) => { }
327+ Err ( r) => fail ! ( "Unexpected error {}" , r) ,
328+ Ok ( _) => fail ! ( "Unexpected success" ) ,
329+ }
330+ }
331+
298332#[ test]
299333fn test_stmt_finish ( ) {
300334 let conn = or_fail ! ( PostgresConnection :: connect( "postgres://postgres@localhost" , & NoSsl ) ) ;
0 commit comments