Test/Role/PostgreSQL.pm

filter: Statementstmt 46.4% 13 / 28 Branchbran 10.0% 1 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 4 / 9 Podpod 100% 2 / 2 totaltotal 40.8% 20 / 49 CC 6 SCAR 19.9
CC
6
Cov
37%
BUILD
17.1
_build_database
3.0
_build_dbd_version
2.0
CRAP 7.3
« 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 Class::Load qw/try_load_class/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Test::Roo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 with 'Interchange6::Test::Role::Database';
12  
13 =head1 METHODS
14  
15 See also L<Interchange6::Test::Role::Database> which is consumed by this role.
16  
17 =head2 BUILD
18  
19 Check that all required modules load or else plan skip_all
20  
21 =cut
22  
23 sub BUILD {
24 1 ▶ my $self = shift;
Subroutine BUILD: called CC=5 SCAR=28.4
Pod documented
25  
26 1 ▶ try_load_class('DateTime::Format::Pg')
Branch: 1 branch
BranchTrueFalseTotal
try_load_class("DateTime::Format::Pg") or plan("skip_all", "DateTime::Format::Pg required to run these tests") 1 0 1
27 or plan skip_all => "DateTime::Format::Pg required to run these tests";
28  
29 0 ▶ try_load_class('DBD::Pg')
Branch: 1 branch
BranchTrueFalseTotal
try_load_class("DBD::Pg") or plan("skip_all", "DBD::Pg required to run these tests") 0 0 0
30 or plan skip_all => "DBD::Pg required to run these tests";
31  
32 0 ▶ try_load_class('Test::PostgreSQL')
Branch: 1 branch
BranchTrueFalseTotal
try_load_class("Test::PostgreSQL") or plan("skip_all", "Test::PostgreSQL required to run these tests") 0 0 0
33 or plan skip_all => "Test::PostgreSQL required to run these tests";
34  
35 0 ▶ eval { $self->database }
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->database } } or plan("skip_all", "Init database failed: $@") 0 0 0
36 or plan skip_all => "Init database failed: $@";
37 }
38  
39 sub _build_database {
40 0 ▶ my $self = shift;
Subroutine _build_database: not called CC=2 SCAR=10.9
41 1 ▶ no warnings 'once'; # prevent: "Test::PostgreSQL::errstr" used only once
Subroutine BEGIN: called CC=1 SCAR=0.0
42 my $pgsql = Test::PostgreSQL->new(
43 initdb_args
44 => $Test::PostgreSQL::Defaults{initdb_args}
45 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
46 ) or die $Test::PostgreSQL::errstr;
47 0 return $pgsql;
48 }
49  
50 sub _build_dbd_version {
51 0 ▶ return "DBD::Pg $DBD::Pg::VERSION Test::PostgreSQL $Test::PostgreSQL::VERSION";
Subroutine _build_dbd_version: not called CC=1 SCAR=6.9
52 }
53  
54 =head2 connect_info
55  
56 Returns appropriate DBI connect info for this role.
57  
58 =cut
59  
60 sub connect_info {
61 0 ▶ my $self = shift;
Subroutine connect_info: not called CC=1 SCAR=6.9
Pod documented
62 0 return ( $self->database->dsn, undef, undef,
63 {
64 on_connect_do => 'SET client_min_messages=WARNING;',
65 pg_enable_utf8 => 1,
66 quote_names => 1,
67 }
68 );
69 }
70  
71 sub _build_database_info {
72 0 ▶ my $self = shift;
Subroutine _build_database_info: not called CC=1 SCAR=6.9
73 $self->ic6s_schema->storage->dbh_do(
74 sub {
75 0 ▶ my ( $storage, $dbh ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
76 0 @{ $dbh->selectrow_arrayref(q| SELECT version() |) }[0];
77 }
78 0 );
79 }
80  
81 1 1;
« Schema/Result/Product.pm ↑ Summary Schema/Result/Tax.pm »