Fix postgres_session error Unable to connect to database

Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
This commit is contained in:
Vasu1105 2021-08-17 16:29:49 +05:30
parent d85bdbc4e1
commit d1bc86a214
2 changed files with 1 additions and 8 deletions

View file

@ -46,8 +46,6 @@ module Inspec::Resources
@host = host || "localhost"
@port = port || 5432
raise Inspec::Exceptions::ResourceFailed, "Can't run PostgreSQL SQL checks without authentication." if @user.nil? || @pass.nil?
test_connection
end
def query(query, db = [])
@ -65,10 +63,6 @@ module Inspec::Resources
private
def test_connection
query("select now()\;")
end
def escaped_query(query)
Shellwords.escape(query)
end

View file

@ -35,7 +35,6 @@ describe "Inspec::Resources::PostgresSession" do
end
it "fails when no connection established" do
resource = load_resource("postgres_session", "postgres", "postgres", "localhost", 5432)
_(resource.resource_failed?).must_equal true
_(resource.resource_exception_message).must_include "PostgreSQL query with errors"
_(proc { resource.send(:query, "Select 5;", ["mydatabase"]) }).must_raise Inspec::Exceptions::ResourceFailed
end
end