line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::DBIx::Class::SchemaManager::Trait::SQLite; { |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1763
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use MooseX::Attribute::ENV; |
5
|
|
|
|
|
|
|
use Test::DBIx::Class::Types qw(ConnectInfo); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub dbname { |
8
|
|
|
|
|
|
|
my ($self) = @_; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $env_path = $ENV{DBNAME}; |
11
|
|
|
|
|
|
|
my $dsn = $self->{connect_info}{dsn}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
if($env_path) { |
14
|
|
|
|
|
|
|
return $env_path; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
elsif($dsn) { |
17
|
|
|
|
|
|
|
my ($dbname) = $dsn =~ m/dbi:[^:]+:dbname=(.+)/i; |
18
|
|
|
|
|
|
|
if($dbname) { |
19
|
|
|
|
|
|
|
return $dbname; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
else { |
22
|
|
|
|
|
|
|
croak("Couldn't find dbname in sqlite dsn '$dsn'"); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
|
|
|
|
|
|
return ':memory:'; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub get_default_connect_info { |
31
|
|
|
|
|
|
|
my ($self) = @_; |
32
|
|
|
|
|
|
|
return ["dbi:SQLite:dbname=".$self->dbname,'','']; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
before 'setup' => sub { |
36
|
|
|
|
|
|
|
my ($self) = @_; |
37
|
|
|
|
|
|
|
if(my $path = $ENV{DBNAME}) { |
38
|
|
|
|
|
|
|
if(-e $path) { |
39
|
|
|
|
|
|
|
$self->builder->ok(-w $path, "Path $path is accessible, forcing 'force_drop_table'"); |
40
|
|
|
|
|
|
|
$self->force_drop_table(1); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
after 'cleanup' => sub { |
46
|
|
|
|
|
|
|
my ($self) = @_; |
47
|
|
|
|
|
|
|
if(!$self->keep_db && lc $self->dbname ne ':memory:') { |
48
|
|
|
|
|
|
|
unlink $self->dbname; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
} 1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |