line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rose::DBx::TestDB; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1794
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
80
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
80
|
|
5
|
2
|
|
|
2
|
|
3139
|
use File::Temp 'tempfile'; |
|
2
|
|
|
|
|
49585
|
|
|
2
|
|
|
|
|
145
|
|
6
|
2
|
|
|
2
|
|
2976
|
use Rose::DB; |
|
2
|
|
|
|
|
912499
|
|
|
2
|
|
|
|
|
93
|
|
7
|
2
|
|
|
2
|
|
27
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
176
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# we want our END to run no matter what (even if ^C) |
10
|
2
|
|
|
2
|
|
2005
|
use sigtrap qw(die normal-signals error-signals); |
|
2
|
|
|
|
|
2946
|
|
|
2
|
|
|
|
|
15
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my @TMPFILES; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# check for sqlite version per Rose::DB tests |
17
|
|
|
|
|
|
|
eval { require DBD::SQLite }; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
if ( $@ || $DBD::SQLite::VERSION < 1.08 || $ENV{'RDBO_NO_SQLITE'} ) { |
20
|
|
|
|
|
|
|
croak 'Missing DBD::SQLite 1.08+'; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
elsif ( $DBD::SQLite::VERSION == 1.13 ) { |
23
|
|
|
|
|
|
|
carp 'DBD::SQLite 1.13 is broken but we will try testing anyway'; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
1
|
|
|
1
|
1
|
874
|
my ( undef, $filename ) = tempfile(); |
28
|
1
|
|
|
|
|
798
|
push @TMPFILES, $filename; |
29
|
|
|
|
|
|
|
|
30
|
1
|
50
|
|
|
|
20
|
Rose::DB->register_db( |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
domain => 'test', |
33
|
|
|
|
|
|
|
type => 'sqlite', |
34
|
|
|
|
|
|
|
driver => 'sqlite', |
35
|
|
|
|
|
|
|
database => $filename, |
36
|
|
|
|
|
|
|
auto_create => 0, |
37
|
|
|
|
|
|
|
connect_options => { |
38
|
|
|
|
|
|
|
AutoCommit => 1, |
39
|
|
|
|
|
|
|
( ( rand() < 0.5 ) ? ( FetchHashKeyName => 'NAME_lc' ) : () ), |
40
|
|
|
|
|
|
|
}, |
41
|
|
|
|
|
|
|
post_connect_sql => |
42
|
|
|
|
|
|
|
[ 'PRAGMA synchronous = OFF', 'PRAGMA temp_store = MEMORY', ], |
43
|
|
|
|
|
|
|
); |
44
|
1
|
|
|
|
|
10149
|
Rose::DB->default_domain('test'); |
45
|
1
|
|
|
|
|
13
|
Rose::DB->default_type('sqlite'); |
46
|
|
|
|
|
|
|
|
47
|
1
|
50
|
|
|
|
14
|
my $db = Rose::DB->new() |
48
|
|
|
|
|
|
|
or croak "could not create new Rose::DB instance: $!"; |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
466
|
return $db; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# in theory File::Temp should clean these up. In theory. |
54
|
|
|
|
|
|
|
END { |
55
|
2
|
|
|
2
|
|
14560
|
for my $file (@TMPFILES) { |
56
|
1
|
50
|
|
|
|
24
|
unlink $file unless -e $file; # Sets $! correctly |
57
|
1
|
|
|
|
|
170
|
1 while unlink $file; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Rose::DBx::TestDB - test Rose::DB::Object modules |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SYNOPSIS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
use Rose::DBx::TestDB; |
68
|
|
|
|
|
|
|
my $db = Rose::DBx::TestDB->new; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# do something with $db |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
exit; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# END block will automatically clean up all temp db files |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 METHODS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 new |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Returns a new Rose::DB object using a temp sqlite database. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Peter Karman, C<< >> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 BUGS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
89
|
|
|
|
|
|
|
C, or through the web interface at |
90
|
|
|
|
|
|
|
L. |
91
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
92
|
|
|
|
|
|
|
your bug as I make changes. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SUPPORT |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
perldoc Rose::DBx::TestDB |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
You can also look for information at: |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=over 4 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item * CPAN Ratings |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
L |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
L |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * Search CPAN |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Inspired by DBICx::TestDatabase. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Copyright 2007 Peter Karman, all rights reserved. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
131
|
|
|
|
|
|
|
under the same terms as Perl itself. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |