Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests try to connect with wrong user #868

Closed
Suor opened this issue Oct 5, 2015 · 7 comments
Closed

Tests try to connect with wrong user #868

Suor opened this issue Oct 5, 2015 · 7 comments
Labels

Comments

@Suor
Copy link
Contributor

Suor commented Oct 5, 2015

I am trying to run tests with

make test-all connectionString=pg://postgres@localhost:5432/postgres

and also just

npm test

And both times I get:

130-tests.jsMessage: expected Error: Command failed: psql: FATAL:  role "suor" does not exist
 to be null
AssertionError: expected Error: Command failed: psql: FATAL:  role "suor" does not exist
 to be null
    at Function.assert.isNull (/home/suor/projects/node-postgres/test/test-helper.js:170:10)
    at /home/suor/projects/node-postgres/test/integration/gh-issues/130-tests.js:10:16
    at /home/suor/projects/node-postgres/test/test-helper.js:159:16
    at ChildProcess.exithandler (child_process.js:651:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:753:16)
    at Socket.<anonymous> (child_process.js:966:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:465:12)

Looks like it's trying to connect with current user instead of postgres.

@brianc
Copy link
Owner

brianc commented Oct 5, 2015

Weird - try setting the connection params w/ environment variables instead
of that connection string:

PGUSER=foo PGPASSWORD=bar PGDATABASE=baz make test-integration

On Mon, Oct 5, 2015 at 11:43 AM, Alexander Schepanovski <
notifications@github.com> wrote:

I am trying to run tests with

make test-all connectionString=pg://postgres@localhost:5432/postgres

and also just

npm test

And both times I get:

130-tests.jsMessage: expected Error: Command failed: psql: FATAL: role "suor" does not exist
to be null
AssertionError: expected Error: Command failed: psql: FATAL: role "suor" does not exist
to be null
at Function.assert.isNull (/home/suor/projects/node-postgres/test/test-helper.js:170:10)
at /home/suor/projects/node-postgres/test/integration/gh-issues/130-tests.js:10:16
at /home/suor/projects/node-postgres/test/test-helper.js:159:16
at ChildProcess.exithandler (child_process.js:651:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Socket. (child_process.js:966:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:465:12)

Looks like it's trying to connect with current user instead of postgres.


Reply to this email directly or view it on GitHub
#868.

@Suor
Copy link
Contributor Author

Suor commented Oct 6, 2015

That worked. Should docs and/or npm test be updated?

@whymarrh
Copy link

I'm seeing this same issue on 7.4.3 with a similar connection string:

postgres://postgres:password@localhost:5432/postgres

Using the environment variables works:

PGUSER=postgres PGPASSWORD=password PGDATABASE=postgres npm start

Is this expected behaviour?

@charmander
Copy link
Collaborator

@whymarrh How are you passing the connection string to pg?

@whymarrh
Copy link

I'm passing the connectionString option:

export default new Database(new Pool({
    connectionString: <string> process.env.PG_CONNECTION,
}));

It doesn't work on macOS but surprisingly this works fine (albeit with prod credentials) on Linux.

@charmander
Copy link
Collaborator

@whymarrh Does it work if you use a string literal instead of process.env.PG_CONNECTION?

@whymarrh
Copy link

whymarrh commented May 20, 2018

Inlining the string doesn't work either, no. (I incorrectly pasted it with ?ssl=true which failed with a different error.)

Turns Out™ the environment variable was being unset. My bad, I should've debugged further before commenting. Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants