| 1 | package Interchange6::Test::Role::PostgreSQL; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | Interchange6::Test::Role::PostgreSQL | ||||||||||
| 6 | |||||||||||
| 7 | =cut | ||||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use Test::Roo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | with 'Interchange6::Test::Role::Database'; | |||||||||
| 11 | |||||||||||
| 12 | =head1 METHODS | ||||||||||
| 13 | |||||||||||
| 14 | See also L<Interchange6::Test::Role::Database> which is consumed by this role. | ||||||||||
| 15 | |||||||||||
| 16 | =head2 BUILD | ||||||||||
| 17 | |||||||||||
| 18 | Check that all required modules load or else plan skip_all | ||||||||||
| 19 | |||||||||||
| 20 | =cut | ||||||||||
| 21 | |||||||||||
| 22 | sub BUILD { | ||||||||||
| 23 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
BUILD: called CC=5 SCAR=27.8
Pod
documented
| |||||||||||
| 24 | |||||||||||
| 25 | 1 | ▶ | eval('use DateTime::Format::Pg; 1') | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
Branch: 1 branch
| |||||||||||
| 26 | or plan skip_all => "DateTime::Format::Pg required to run these tests"; | ||||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | eval('use DBD::Pg 3.0.0; 1') | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | or plan skip_all => "DBD::Pg >= 3.0.0 required to run these tests"; | ||||||||||
| 30 | |||||||||||
| 31 | 0 | ▶ | eval('use Test::PostgreSQL; 1') | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | or plan skip_all => "Test::PostgreSQL required to run these tests"; | ||||||||||
| 33 | |||||||||||
| 34 | 0 | ▶ | eval { $self->database } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | or plan skip_all => "Init database failed: $@"; | ||||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | sub _build_database { | ||||||||||
| 39 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_build_database: not called CC=2 SCAR=10.9
| |||||||||||
| 40 | 1 | ▶ | no warnings 'once'; # prevent: "Test::PostgreSQL::errstr" used only once | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 41 | my $pgsql = Test::PostgreSQL->new( | ||||||||||
| 42 | initdb_args | ||||||||||
| 43 | => $Test::PostgreSQL::Defaults{initdb_args} | ||||||||||
| 44 | 0 | ▶ | . ' --encoding=utf8 --no-locale' | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | ) or die $Test::PostgreSQL::errstr; | ||||||||||
| 46 | 0 | return $pgsql; | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | sub _build_dbd_version { | ||||||||||
| 50 | 0 | ▶ | return "DBD::Pg $DBD::Pg::VERSION Test::PostgreSQL $Test::PostgreSQL::VERSION"; | ||||||||
|
Subroutine
_build_dbd_version: not called CC=1 SCAR=6.9
| |||||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | =head2 connect_info | ||||||||||
| 54 | |||||||||||
| 55 | Returns appropriate DBI connect info for this role. | ||||||||||
| 56 | |||||||||||
| 57 | =cut | ||||||||||
| 58 | |||||||||||
| 59 | sub connect_info { | ||||||||||
| 60 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
connect_info: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 61 | 0 | return ( $self->database->dsn, undef, undef, | |||||||||
| 62 | { | ||||||||||
| 63 | on_connect_do => 'SET client_min_messages=WARNING;', | ||||||||||
| 64 | quote_names => 1, | ||||||||||
| 65 | } | ||||||||||
| 66 | ); | ||||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | sub _build_database_info { | ||||||||||
| 70 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_build_database_info: not called CC=1 SCAR=6.9
| |||||||||||
| 71 | $self->ic6s_schema->storage->dbh_do( | ||||||||||
| 72 | sub { | ||||||||||
| 73 | 0 | ▶ | my ( $storage, $dbh ) = @_; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 74 | 0 | @{ $dbh->selectrow_arrayref(q| SELECT version() |) }[0]; | |||||||||
| 75 | } | ||||||||||
| 76 | 0 | ); | |||||||||
| 77 | } | ||||||||||
| 78 | |||||||||||
| 79 | 1 | 1; | |||||||||