Skip to content

Commit

Permalink
Relax test of finish to not bother about unrelated connections
Browse files Browse the repository at this point in the history
  • Loading branch information
larskanis committed Jul 11, 2024
1 parent 258fbf0 commit acb7fae
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion spec/pg/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -766,12 +766,18 @@
end

it "doesn't leave stale server connections after finish" do
res = @conn.exec(%[SELECT COUNT(*) AS n FROM pg_stat_activity
WHERE usename IS NOT NULL AND application_name != ''])
# there's still the global @conn, but should be no more
old_count = res[0]['n']

described_class.connect(@conninfo).finish

sleep 0.5
res = @conn.exec(%[SELECT COUNT(*) AS n FROM pg_stat_activity
WHERE usename IS NOT NULL AND application_name != ''])
# there's still the global @conn, but should be no more
expect( res[0]['n'] ).to eq( '1' )
expect( res[0]['n'] ).to eq( old_count )
end

it "can retrieve it's connection parameters for the established connection" do
Expand Down

0 comments on commit acb7fae

Please sign in to comment.