line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Interchange6::Test::Role::PostgreSQL; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Interchange6::Test::Role::PostgreSQL |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1294
|
use Test::Roo::Role; |
|
1
|
|
|
|
|
649
|
|
|
1
|
|
|
|
|
4
|
|
10
|
|
|
|
|
|
|
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
|
|
|
1
|
1
|
223976
|
my $self = shift; |
24
|
|
|
|
|
|
|
|
25
|
1
|
50
|
|
1
|
|
205
|
eval('use DateTime::Format::Pg; 1') |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
65
|
|
26
|
|
|
|
|
|
|
or plan skip_all => "DateTime::Format::Pg required to run these tests"; |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
eval('use DBD::Pg 3.0.0; 1') |
29
|
|
|
|
|
|
|
or plan skip_all => "DBD::Pg >= 3.0.0 required to run these tests"; |
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
eval('use Test::Postgresql58; 1') |
32
|
|
|
|
|
|
|
or plan skip_all => "Test::Postgresql58 required to run these tests"; |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
eval { $self->database } |
|
0
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
or plan skip_all => "Init database failed: $@"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _build_database { |
39
|
0
|
|
|
0
|
|
|
my $self = shift; |
40
|
1
|
|
|
1
|
|
1401
|
no warnings 'once'; # prevent: "Test::Postgresql58::errstr" used only once |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
306
|
|
41
|
|
|
|
|
|
|
my $pgsql = Test::Postgresql58->new( |
42
|
|
|
|
|
|
|
initdb_args |
43
|
|
|
|
|
|
|
=> $Test::Postgresql58::Defaults{initdb_args} |
44
|
0
|
0
|
|
|
|
|
. ' --encoding=utf8 --no-locale' |
45
|
|
|
|
|
|
|
) or die $Test::Postgresql58::errstr; |
46
|
0
|
|
|
|
|
|
return $pgsql; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _build_dbd_version { |
50
|
0
|
|
|
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
|
|
|
|
|
|
|
sub connect_info { |
60
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub _build_database_info { |
70
|
0
|
|
|
0
|
|
|
my $self = shift; |
71
|
|
|
|
|
|
|
$self->ic6s_schema->storage->dbh_do( |
72
|
|
|
|
|
|
|
sub { |
73
|
0
|
|
|
0
|
|
|
my ( $storage, $dbh ) = @_; |
74
|
0
|
|
|
|
|
|
@{ $dbh->selectrow_arrayref(q| SELECT version() |) }[0]; |
|
0
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
0
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
after teardown => sub { |
80
|
|
|
|
|
|
|
}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |