Test/Role/PostgreSQL.pm

filter: Statementstmt 41.3% 12 / 29 Branchbran 10.0% 1 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 4 / 10 Podpod 100% 2 / 2 totaltotal 37.2% 19 / 51 CC 6 SCAR 18.9
CC
6
Cov
33%
BUILD
16.2
_build_database
3.0
_build_dbd_version
2.0
CRAP 6.6
« Schema/Result/Tax.pm ↑ Summary Schema/Result/Zone.pm »
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 1 ▶sub BUILD {
Subroutine BUILD: called CC=5 SCAR=27.8
Pod documented
23 1 my $self = shift;
24  
25 0 ▶ eval('use DateTime::Format::Pg; 1')
Subroutine BEGIN: called CC=1 SCAR=1.2
Branch: 1 branch
BranchTrueFalseTotal
eval "use DateTime::Format::Pg; 1" or plan("skip_all", "DateTime::Format::Pg required to run these tests") 0 1 1
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
BranchTrueFalseTotal
eval "use DBD::Pg 3.0.0; 1" or plan("skip_all", "DBD::Pg >= 3.0.0 required to run these tests") 0 0 0
29 or plan skip_all => "DBD::Pg >= 3.0.0 required to run these tests";
30  
31 0 ▶ eval('use Test::Postgresql58; 1')
Branch: 1 branch
BranchTrueFalseTotal
eval "use Test::Postgresql58; 1" or plan("skip_all", "Test::Postgresql58 required to run these tests") 0 0 0
32 or plan skip_all => "Test::Postgresql58 required to run these tests";
33  
34 0 ▶ eval { $self->database }
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->database } } or plan("skip_all", "Init database failed: $@") 0 0 0
35 or plan skip_all => "Init database failed: $@";
36 }
37  
38 0 ▶sub _build_database {
Subroutine _build_database: not called CC=2 SCAR=10.9
39 0 my $self = shift;
40 1 ▶ no warnings 'once'; # prevent: "Test::Postgresql58::errstr" used only once
Subroutine BEGIN: called CC=1 SCAR=0.0
41 my $pgsql = Test::Postgresql58->new(
42 initdb_args
43 => $Test::Postgresql58::Defaults{initdb_args}
44 0 ▶ . ' --encoding=utf8 --no-locale'
Branch: 1 branch
BranchTrueFalseTotal
my $pgsql = "Test::Postgresql58"->new("initdb_args", $Test::Postgresql58::Defaults{"initdb_args"} . ' --encoding=utf8 --no-locale') or die $Test::Postgresql58::errstr 0 0 0
45 ) or die $Test::Postgresql58::errstr;
46 0 return $pgsql;
47 }
48  
49 0 ▶sub _build_dbd_version {
Subroutine _build_dbd_version: not called CC=1 SCAR=6.9
50 0 return "DBD::Pg $DBD::Pg::VERSION Test::Postgresql58 $Test::Postgresql58::VERSION";
51 }
52  
53 =head2 connect_info
54  
55 Returns appropriate DBI connect info for this role.
56  
57 =cut
58  
59 0 ▶sub connect_info {
Subroutine connect_info: not called CC=1 SCAR=6.9
Pod documented
60 0 my $self = shift;
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 0 ▶sub _build_database_info {
Subroutine _build_database_info: not called CC=1 SCAR=6.9
70 0 my $self = shift;
71 $self->ic6s_schema->storage->dbh_do(
72 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
73 0 my ( $storage, $dbh ) = @_;
74 0 @{ $dbh->selectrow_arrayref(q| SELECT version() |) }[0];
75 }
76 0 );
77 }
78  
79 0 ▶after teardown => sub {
Subroutine __ANON__: not called CC=1 SCAR=0.0
80 1 };
81  
82 1 1;
« Schema/Result/Tax.pm ↑ Summary Schema/Result/Zone.pm »