Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Johan Vromans <jvromans <at> squirrel.nl>
Subject: Depending on external tools (2)
Newsgroups: gmane.comp.lang.perl.modules.authors
Date: Wednesday 27th February 2008 13:29:50 UTC (over 9 years 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 [email protected];

      # 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
 
CD: 3ms