File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -901,6 +901,30 @@ fn test_notification_next_timeout() {
901
901
assert ! ( it. next( ) . unwrap( ) . is_none( ) ) ;
902
902
}
903
903
904
+ #[ test]
905
+ fn test_notification_disconnect ( ) {
906
+ let conn = or_panic ! ( Connection :: connect(
907
+ "postgres://postgres@localhost:5433" ,
908
+ TlsMode :: None ,
909
+ ) ) ;
910
+ or_panic ! ( conn. execute( "LISTEN test_notifications_disconnect" , & [ ] ) ) ;
911
+
912
+ let _t = thread:: spawn ( || {
913
+ let conn = or_panic ! ( Connection :: connect(
914
+ "postgres://postgres@localhost:5433" ,
915
+ TlsMode :: None ,
916
+ ) ) ;
917
+ thread:: sleep ( Duration :: from_millis ( 500 ) ) ;
918
+ or_panic ! ( conn. execute(
919
+ "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE query = 'LISTEN test_notifications_disconnect'" ,
920
+ & [ ] ,
921
+ ) ) ;
922
+ } ) ;
923
+
924
+ let notifications = conn. notifications ( ) ;
925
+ assert ! ( notifications. blocking_iter( ) . next( ) . is_err( ) ) ;
926
+ }
927
+
904
928
#[ test]
905
929
// This test is pretty sad, but I don't think there's a better way :(
906
930
fn test_cancel_query ( ) {
You can’t perform that action at this time.
0 commit comments