|
Subject: Depending on external tools (2) Newsgroups: gmane.comp.lang.perl.modules.authors Date: 2008-02-27 13:29:50 GMT (26 weeks, 1 day, 10 hours and 56 minutes ago)
The saga continues...
I have an app that works with PostgreSQL. It depends on DPD::Pg. So
far, so good.
However, the requirement that DBD::Pg is installed is by no means a
guarantee that there is a database server around. And if there is, the
user running the CPAN test may nog have (sufficient) access to this
database.
What would be a good means to arm the test scripts against this?
This is what I currently use:
$ntests = 37;
SKIP: {
eval { require DBD::Pg };
skip("DBI PostgreSQL driver (DBD::Pg) not installed", $ntests) if $@;
# Check minimal Pg interface version.
my $minpg = 1.31;
ok($DBD::Pg::VERSION >= $minpg,
"DBD::PG version = $DBD::Pg::VERSION, should be at east $minpg");
$ntests--;
SKIP: {
skip("Database tests skipped on request", $ntests)
if $ENV{EB_SKIPDBTESTS};
# Check whether we can contact the database.
my @ds;
eval {
@ds = DBI->data_sources("Pg");
skip("No access to database", $ntests)
if $DBI::errstr;
ok(!$DBI::errstr, "Database Connect");
$ntests--;
};
ok(@ds > 1, "Check databases");
... $ntests of tests follow ...
}
}
But I'm sure there are better ways?
-- Johan
|
|
|