Merge pull request #44347 from nvasilevski/fix-postgresql-reconnection-test-assertion

Fix postgresql reconnection_error test expects wrong exception
This commit is contained in:
Jean Boussier 2022-02-08 19:18:58 +01:00 committed by GitHub
commit c2ce4d6e14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -39,7 +39,7 @@ module ActiveRecord
end
def reset
raise PG::ConnectionBad
raise PG::ConnectionBad, "I'll be rescued by the reconnect method"
end
def close
@ -53,8 +53,13 @@ module ActiveRecord
{ host: File::NULL }
)
assert_raises ActiveRecord::ConnectionNotEstablished do
@conn.reconnect!
connect_raises_error = proc { |_conn_params| raise(PG::ConnectionBad, "actual bad connection error") }
PG.stub(:connect, connect_raises_error) do
error = assert_raises ActiveRecord::ConnectionNotEstablished do
@conn.reconnect!
end
assert_equal("actual bad connection error", error.message)
end
end