line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Interchange6::Test::Role::SQLite; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Interchange6::Test::Role::SQLite |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
12880
|
use File::Temp; |
|
2
|
|
|
|
|
33782
|
|
|
2
|
|
|
|
|
156
|
|
10
|
2
|
|
|
2
|
|
935
|
use Test::Roo::Role; |
|
2
|
|
|
|
|
1070
|
|
|
2
|
|
|
|
|
10
|
|
11
|
|
|
|
|
|
|
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
|
50
|
|
1
|
1
|
224897
|
eval('use DBD::SQLite; 1') |
|
1
|
|
|
1
|
|
776
|
|
|
1
|
|
|
|
|
28304
|
|
|
1
|
|
|
|
|
20
|
|
25
|
|
|
|
|
|
|
or plan skip_all => "DBD::SQLite required to run these tests"; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $fh = File::Temp->new( |
29
|
|
|
|
|
|
|
TEMPLATE => 'ic6s_test_XXXXX', |
30
|
|
|
|
|
|
|
EXLOCK => 0, |
31
|
|
|
|
|
|
|
TMPDIR => 1, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
my $dbfile = $fh->filename; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
after teardown => sub { |
36
|
|
|
|
|
|
|
shift->clear_database; |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 clear_database |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Attempt to unlink temporary database file |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub clear_database { |
46
|
1
|
|
|
1
|
1
|
21
|
close($fh); |
47
|
1
|
50
|
|
|
|
81
|
unlink($dbfile) or diag "Could not unlink $dbfile: $!"; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _build_database { |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# does nothing atm for SQLite |
53
|
0
|
|
|
0
|
|
0
|
return; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _build_dbd_version { |
57
|
1
|
|
|
1
|
|
27
|
return "DBD::SQLite $DBD::SQLite::VERSION"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 connect_info |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Returns appropriate DBI connect info for this role. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub connect_info { |
67
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
24
|
return ( "dbi:SQLite:dbname=$dbfile", undef, undef, |
70
|
|
|
|
|
|
|
{ |
71
|
|
|
|
|
|
|
sqlite_unicode => 1, |
72
|
|
|
|
|
|
|
on_connect_call => 'use_foreign_keys', |
73
|
|
|
|
|
|
|
on_connect_do => 'PRAGMA synchronous = OFF', |
74
|
|
|
|
|
|
|
quote_names => 1, |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _build_database_info { |
80
|
1
|
|
|
1
|
|
16
|
my $self = shift; |
81
|
|
|
|
|
|
|
return "SQLite library version: " |
82
|
1
|
|
|
|
|
20
|
. $self->ic6s_schema->storage->dbh->{sqlite_version}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |