File Coverage

blib/lib/SmokeRunner/Multi/DBI.pm
Criterion Covered Total %
statement 26 26 100.0
branch 3 4 75.0
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 38 39 97.4


line stmt bran cond sub pod time code
1             package SmokeRunner::Multi::DBI;
2             our $AUTHORITY = 'cpan:YANICK';
3             #ABSTRACT: DBI helpers for SmokeRunner::Multi
4             $SmokeRunner::Multi::DBI::VERSION = '0.21';
5 8     8   21090 use strict;
  8         16  
  8         209  
6 8     8   37 use warnings;
  8         14  
  8         224  
7              
8 8     8   9076 use DBD::SQLite;
  8         250012  
  8         300  
9 8     8   82 use DBI;
  8         19  
  8         358  
10 8     8   48 use File::Spec;
  8         16  
  8         178  
11 8     8   4075 use SmokeRunner::Multi::Config;
  8         30  
  8         1531  
12              
13              
14             {
15             my $dbh;
16             sub handle
17             {
18 48 100   48 1 2840 return $dbh if $dbh;
19              
20 8         97 my $config = SmokeRunner::Multi::Config->instance();
21              
22 8         141 my $db_file = File::Spec->catfile( $config->root_dir(),
23             'smokerunner.sqlite' );
24              
25 8         135 $dbh = DBI->connect( "dbi:SQLite:dbname=$db_file", '', '',
26             { RaiseError => 1 } );
27              
28 8 50       16460 _create_database($dbh)
29             unless -s $db_file;
30              
31 8         9096475 return $dbh;
32             }
33             }
34              
35             {
36             my $ddl = <<'EOF';
37             CREATE TABLE TestSet (
38             name TEXT NOT NULL PRIMARY KEY,
39             last_run_time INTEGER NOT NULL DEFAULT 0,
40             is_prioritized INTEGER NOT NULL DEFAULT 0
41             );
42             EOF
43              
44             sub _create_database
45             {
46 8     8   23 my $dbh = shift;
47              
48 8         70 $dbh->do($ddl);
49             }
50             }
51              
52              
53             1;
54              
55             __END__