Project:Perl/maint-notes/dev-perl/DBD-Pg
From Gentoo Wiki
Jump to:navigation
Jump to:search
Testing
Testing this package is extra tricky, because you need a working PostgreSQL server.
The test suite in this package is supposed to auto-spawn one, but that consistently fails at present.
Portage Configuration
Instead, you need to set one up manually.
#!/bin/bash
# Important: You want to skip hostname and port
# here if you need to use unix sockets
# eg: under FEATURES="network-sandbox"
DBI_DSN="dbi:Pg:dbname=pgtest"
DBI_USER="pgtest_user"
DBI_PASS="test"
# Uncomment this if you have problems working out why its skipping
# DBDPG_DEBUG=1
dev-perl/DBD-Pg pgtest.conf
Database Configuration
Then, you must setup the named account, database, and permissions as follows via psql -U postgres
CREATE ROLE pgtest_user LOGIN PASSWORD 'test' VALID UNTIL 'infinity';
CREATE DATABASE pgtest
WITH OWNER = pgtest_user
ENCODING = 'UTF8';
GRANT ALL ON DATABASE pgtest TO pgtest_user;
Test Output
If you see output like this:
t/00basic.t ......... ok
t/01connect.t ....... Please wait, creating new database (version 9.6) for testing
#
# DBI Version 1.637
# DBD::Pg Version 3.7.0
# Perl Version 5.24.3
# OS linux
# PostgreSQL (compiled) ?
# PostgreSQL (target) ?
# PostgreSQL (reported) ?
# Default port ?
# DBI_DSN dbi:Pg:dbname=pgtest;host=localhost;port=5432
# DBI_USER pgtest_user
# Test schema dbd_pg_testschema
# LANG C
# Adjusted: initdb
# Error was: FATAL: role "pgtest_user" does not exist at t/dbdpg_test_setup.pl line 592.
t/01connect.t ....... skipped: Connection to database failed, cannot continue testing
t/01constants.t ..... ok
t/02attribs.t ....... skipped: Connection to database failed, cannot continue testing
t/03dbmethod.t ...... skipped: Connection to database failed, cannot continue testing
t/03smethod.t ....... skipped: Connection to database failed, cannot continue testing
t/04misc.t .......... skipped: Connection to database failed, cannot continue testing
t/06bytea.t ......... skipped: Connection to database failed, cannot continue testing
t/07copy.t .......... skipped: Connection to database failed, cannot continue testing
t/08async.t ......... skipped: Connection to database failed, cannot continue testing
t/09arrays.t ........ skipped: Connection to database failed, cannot continue testing
t/12placeholders.t .. skipped: Connection to database failed, cannot continue testing
t/20savepoints.t .... skipped: Connection to database failed, cannot continue testing
t/30unicode.t ....... skipped: Connection to database failed, cannot continue testing
t/99cleanup.t ....... ok
All tests successful.
Then your configuration has failed and you have not passed any meaningful tests, and you should probably employ DBDPG_DEBUG=1
to see what is breaking your connection attempts.