| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DBICx::TestDatabase; |
|
2
|
3
|
|
|
3
|
|
98146
|
use strict; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
108
|
|
|
3
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
105
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
4616
|
use File::Temp 'tempfile'; |
|
|
3
|
|
|
|
|
107965
|
|
|
|
3
|
|
|
|
|
921
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# avoid contaminating the schema with the tempfile |
|
10
|
|
|
|
|
|
|
my @TMPFILES; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
2
|
|
|
2
|
1
|
24
|
my ($class, $schema_class, $opts) = @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
2
|
50
|
|
|
|
129
|
eval "require $schema_class" |
|
16
|
|
|
|
|
|
|
or die "failed to require $schema_class: $@"; |
|
17
|
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
360830
|
my $filename = ':memory:'; # use in-memory database |
|
19
|
|
|
|
|
|
|
|
|
20
|
2
|
50
|
|
|
|
13
|
if($ENV{DBIC_KEEP_TEST}){ |
|
21
|
0
|
|
|
|
|
0
|
(undef, $filename) = tempfile; |
|
22
|
0
|
|
|
|
|
0
|
push @TMPFILES, $filename; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
2
|
50
|
|
|
|
28
|
my $schema = $schema_class->connect( "DBI:SQLite:$filename", '', '', |
|
26
|
|
|
|
|
|
|
{ sqlite_unicode => 1 } ) |
|
27
|
|
|
|
|
|
|
or die "failed to connect to DBI:SQLite:$filename ($schema_class)"; |
|
28
|
|
|
|
|
|
|
|
|
29
|
2
|
50
|
|
|
|
171397
|
$schema->deploy unless $opts->{nodeploy}; |
|
30
|
2
|
|
|
|
|
786845
|
return $schema; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
END { |
|
34
|
3
|
50
|
|
3
|
|
44864
|
if($ENV{DBIC_KEEP_TEST}){ |
|
35
|
0
|
|
|
|
|
0
|
print {*STDERR} "Keeping DBICx::TestDatabase databases: @TMPFILES\n"; |
|
|
0
|
|
|
|
|
0
|
|
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
*connect = *new; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |