Test/Role/PostgreSQL.pm

filter: Statementstmt 39.2% 11 / 28 Branchbran 10.0% 1 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 4 / 9 Podpod 100% 2 / 2 totaltotal 36.7% 18 / 49 CC 6 SCAR 19.5
CC
6
Cov
32%
BUILD
16.2
_build_database
3.0
_build_dbd_version
2.0
CRAP 7.0
« Schema/Result/Product.pm ↑ Summary Schema/Result/Tax.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 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
BranchTrueFalseTotal
eval "use DateTime::Format::Pg; 1" or plan("skip_all", "DateTime::Format::Pg required to run these tests") 1 0 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::PostgreSQL; 1')
Branch: 1 branch
BranchTrueFalseTotal
eval "use Test::PostgreSQL; 1" or plan("skip_all", "Test::PostgreSQL required to run these tests") 0 0 0
32 or plan skip_all => "Test::PostgreSQL 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 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
BranchTrueFalseTotal
my $pgsql = "Test::PostgreSQL"->new("initdb_args", $Test::PostgreSQL::Defaults{"initdb_args"} . ' --encoding=utf8 --no-locale') or die $Test::PostgreSQL::errstr 0 0 0
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;
« Schema/Result/Product.pm ↑ Summary Schema/Result/Tax.pm »