File Coverage

blib/lib/SmokeRunner/Multi/DBI.pm
Criterion Covered Total %
statement 27 27 100.0
branch 3 4 75.0
condition n/a
subroutine 9 9 100.0
pod 1 1 100.0
total 40 41 97.5


line stmt bran cond sub pod time code
1             package SmokeRunner::Multi::DBI;
2             BEGIN {
3 9     9   24425 $SmokeRunner::Multi::DBI::AUTHORITY = 'cpan:YANICK';
4             }
5             {
6             $SmokeRunner::Multi::DBI::VERSION = '0.19';
7             }
8             #ABSTRACT: DBI helpers for SmokeRunner::Multi
9              
10 9     9   51 use strict;
  9         18  
  9         300  
11 9     9   44 use warnings;
  9         16  
  9         289  
12              
13 9     9   12217 use DBD::SQLite;
  9         311922  
  9         353  
14 9     9   104 use DBI;
  9         19  
  9         416  
15 9     9   46 use File::Spec;
  9         17  
  9         182  
16 9     9   4838 use SmokeRunner::Multi::Config;
  9         27  
  9         1683  
17              
18              
19             {
20             my $dbh;
21             sub handle
22             {
23 49 100   49 1 2593 return $dbh if $dbh;
24              
25 9         139 my $config = SmokeRunner::Multi::Config->instance();
26              
27 9         68 my $db_file = File::Spec->catfile( $config->root_dir(),
28             'smokerunner.sqlite' );
29              
30 9         122 $dbh = DBI->connect( "dbi:SQLite:dbname=$db_file", '', '',
31             { RaiseError => 1 } );
32              
33 9 50       17829 _create_database($dbh)
34             unless -s $db_file;
35              
36 9         24127341 return $dbh;
37             }
38             }
39              
40             {
41             my $ddl = <<'EOF';
42             CREATE TABLE TestSet (
43             name TEXT NOT NULL PRIMARY KEY,
44             last_run_time INTEGER NOT NULL DEFAULT 0,
45             is_prioritized INTEGER NOT NULL DEFAULT 0
46             );
47             EOF
48              
49             sub _create_database
50             {
51 9     9   23 my $dbh = shift;
52              
53 9         78 $dbh->do($ddl);
54             }
55             }
56              
57              
58             1;
59              
60             __END__