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.20';
5 8     8   21379 use strict;
  8         14  
  8         208  
6 8     8   41 use warnings;
  8         13  
  8         228  
7              
8 8     8   8985 use DBD::SQLite;
  8         243840  
  8         253  
9 8     8   74 use DBI;
  8         16  
  8         325  
10 8     8   44 use File::Spec;
  8         17  
  8         165  
11 8     8   4096 use SmokeRunner::Multi::Config;
  8         33  
  8         1554  
12              
13              
14             {
15             my $dbh;
16             sub handle
17             {
18 48 100   48 1 1687 return $dbh if $dbh;
19              
20 8         93 my $config = SmokeRunner::Multi::Config->instance();
21              
22 8         127 my $db_file = File::Spec->catfile( $config->root_dir(),
23             'smokerunner.sqlite' );
24              
25 8         130 $dbh = DBI->connect( "dbi:SQLite:dbname=$db_file", '', '',
26             { RaiseError => 1 } );
27              
28 8 50       15281 _create_database($dbh)
29             unless -s $db_file;
30              
31 8         668881 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   26 my $dbh = shift;
47              
48 8         69 $dbh->do($ddl);
49             }
50             }
51              
52              
53             1;
54              
55             __END__