| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Interchange6::Test::Role::Database; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
385
|
use Test::Roo::Role; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
requires qw(_build_database _build_dbd_version); |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Interchange6::Test::Role::Database |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Role consumed by all database-specific roles such as SQLite and Pg to provide common functionality. |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head2 database |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
The database object. We expect a database-specific role to supply the builder. |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has database => ( |
|
24
|
|
|
|
|
|
|
is => 'lazy', |
|
25
|
|
|
|
|
|
|
clearer => 1, |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 database_info |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Database backend version and other interesting info (if available). We expect a database-specific role to supply the builder. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has database_info => ( |
|
35
|
|
|
|
|
|
|
is => 'lazy', |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _build_database_info { |
|
39
|
0
|
|
|
0
|
|
|
return "no info"; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 dbd_version |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
DBD::Foo version string. We expect a database-specific role to supply the builder. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has dbd_version => ( |
|
49
|
|
|
|
|
|
|
is => 'lazy', |
|
50
|
|
|
|
|
|
|
); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 schema_class |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Defaults to Interchange6::Schema. This gives tests the normal expected schema but allows them to overload with some other test schema if desired. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has schema_class => ( |
|
59
|
|
|
|
|
|
|
is => 'ro', |
|
60
|
|
|
|
|
|
|
default => 'Interchange6::Schema', |
|
61
|
|
|
|
|
|
|
); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 ic6s_schema |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Our connected and deployed schema, |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
has ic6s_schema => ( |
|
70
|
|
|
|
|
|
|
is => 'lazy', |
|
71
|
|
|
|
|
|
|
clearer => 1, |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _build_ic6s_schema { |
|
75
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
require DBIx::Class::Optional::Dependencies; |
|
78
|
0
|
0
|
|
|
|
|
if ( my $missing = |
|
79
|
|
|
|
|
|
|
DBIx::Class::Optional::Dependencies->req_missing_for('deploy') ) |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
0
|
|
|
|
|
|
diag "WARN: missing $missing"; |
|
82
|
0
|
|
|
|
|
|
plan skip_all => "$missing required to run tests"; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my $schema_class = $self->schema_class; |
|
86
|
0
|
0
|
|
|
|
|
eval "require $schema_class" |
|
87
|
|
|
|
|
|
|
or die "failed to require $schema_class: $@"; |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
my $schema = $schema_class->connect( $self->connect_info ) |
|
90
|
|
|
|
|
|
|
or die "failed to connect to "; |
|
91
|
0
|
|
|
|
|
|
$schema->deploy(); |
|
92
|
0
|
|
|
|
|
|
return $schema; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 MODIFIERS |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 before setup |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Add diag showing DBD version info. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
before setup => sub { |
|
104
|
|
|
|
|
|
|
my $self = shift; |
|
105
|
|
|
|
|
|
|
diag "using: " . $self->dbd_version; |
|
106
|
|
|
|
|
|
|
diag "db: " . $self->database_info; |
|
107
|
|
|
|
|
|
|
}; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |